@@ -4,31 +4,35 @@ import btoa from "btoa-lite";
44
55import { GitHubAppAuthentication } from "./types" ;
66
7- type TargetOption =
8- | {
9- target : string ;
10- }
11- | {
12- target_id : number ;
13- } ;
14- type RepositoriesOption =
15- | {
16- repositories ?: string [ ] ;
17- }
18- | {
19- repository_ids ?: number [ ] ;
20- } ;
21- type Endpoint = Endpoints [ "POST /applications/{client_id}/token/scoped" ] ;
22-
23- export type ScopeTokenOptions = {
7+ type CommonOptions = {
248 clientType : "github-app" ;
259 clientId : string ;
2610 clientSecret : string ;
2711 token : string ;
2812 permissions ?: Endpoint [ "parameters" ] [ "permissions" ] ;
2913 request ?: RequestInterface ;
30- } & TargetOption &
31- RepositoriesOption ;
14+ } ;
15+
16+ type TargetOption = {
17+ target : string ;
18+ } ;
19+ type TargetIdOption = {
20+ target_id : number ;
21+ } ;
22+ type RepositoriesOption = {
23+ repositories ?: string [ ] ;
24+ } ;
25+ type RepositoryIdsOption = {
26+ repository_ids ?: number [ ] ;
27+ } ;
28+
29+ type Endpoint = Endpoints [ "POST /applications/{client_id}/token/scoped" ] ;
30+
31+ export type ScopeTokenOptions =
32+ | ( CommonOptions & TargetOption & RepositoriesOption )
33+ | ( CommonOptions & TargetIdOption & RepositoriesOption )
34+ | ( CommonOptions & TargetOption & RepositoryIdsOption )
35+ | ( CommonOptions & TargetIdOption & RepositoryIdsOption ) ;
3236
3337export type ScopeTokenResponse = Endpoint [ "response" ] & {
3438 authentication : GitHubAppAuthentication ;
@@ -62,7 +66,7 @@ export async function scopeToken(
6266 clientType,
6367 clientId,
6468 clientSecret,
65- token : options . token ,
69+ token : response . data . token ,
6670 } ;
6771
6872 return { ...response , authentication } ;
0 commit comments