@@ -16,60 +16,15 @@ async function getOidcToken(): Promise<string> {
1616 }
1717}
1818
19- const DEFAULT_PERMISSIONS : Record < string , string > = {
20- contents : "write" ,
21- pull_requests : "write" ,
22- issues : "write" ,
23- } ;
24-
25- export function parseAdditionalPermissions ( ) :
26- | Record < string , string >
27- | undefined {
28- const raw = process . env . ADDITIONAL_PERMISSIONS ;
29- if ( ! raw || ! raw . trim ( ) ) {
30- return undefined ;
31- }
32-
33- const additional : Record < string , string > = { } ;
34- for ( const line of raw . split ( "\n" ) ) {
35- const trimmed = line . trim ( ) ;
36- if ( ! trimmed ) continue ;
37- const colonIndex = trimmed . indexOf ( ":" ) ;
38- if ( colonIndex === - 1 ) continue ;
39- const key = trimmed . slice ( 0 , colonIndex ) . trim ( ) ;
40- const value = trimmed . slice ( colonIndex + 1 ) . trim ( ) ;
41- if ( key && value ) {
42- additional [ key ] = value ;
43- }
44- }
45-
46- if ( Object . keys ( additional ) . length === 0 ) {
47- return undefined ;
48- }
49-
50- return { ...DEFAULT_PERMISSIONS , ...additional } ;
51- }
52-
53- async function exchangeForAppToken (
54- oidcToken : string ,
55- permissions ?: Record < string , string > ,
56- ) : Promise < string > {
57- const headers : Record < string , string > = {
58- Authorization : `Bearer ${ oidcToken } ` ,
59- } ;
60- const fetchOptions : RequestInit = {
61- method : "POST" ,
62- headers,
63- } ;
64-
65- if ( permissions ) {
66- headers [ "Content-Type" ] = "application/json" ;
67- fetchOptions . body = JSON . stringify ( { permissions } ) ;
68- }
69-
19+ async function exchangeForAppToken ( oidcToken : string ) : Promise < string > {
7020 const response = await fetch (
7121 "https://api.anthropic.com/api/github/github-app-token-exchange" ,
72- fetchOptions ,
22+ {
23+ method : "POST" ,
24+ headers : {
25+ Authorization : `Bearer ${ oidcToken } ` ,
26+ } ,
27+ } ,
7328 ) ;
7429
7530 if ( ! response . ok ) {
@@ -134,11 +89,9 @@ export async function setupGitHubToken(): Promise<string> {
13489 const oidcToken = await retryWithBackoff ( ( ) => getOidcToken ( ) ) ;
13590 console . log ( "OIDC token successfully obtained" ) ;
13691
137- const permissions = parseAdditionalPermissions ( ) ;
138-
13992 console . log ( "Exchanging OIDC token for app token..." ) ;
14093 const appToken = await retryWithBackoff ( ( ) =>
141- exchangeForAppToken ( oidcToken , permissions ) ,
94+ exchangeForAppToken ( oidcToken ) ,
14295 ) ;
14396 console . log ( "App token successfully obtained" ) ;
14497
0 commit comments