@@ -30,22 +30,24 @@ import {Status} from './common/http-utils.js'
30
30
import { components } from '@octokit/openapi-types'
31
31
import { createAppAuth } from '@octokit/auth-app'
32
32
import limit from 'p-limit'
33
- import { config } from './config.js'
34
33
import log from './logger.js'
35
34
import type {
36
35
RestEndpointMethodTypes ,
37
36
} from '@octokit/plugin-rest-endpoint-methods/dist-types/generated/parameters-and-response-types'
38
37
39
38
/**
40
39
* GitHub Access Manager
41
- * @param appAuth - GitHub App authentication
40
+ * @param options - options
42
41
* @returns access token manager
43
42
*/
44
- export async function accessTokenManager ( appAuth : {
45
- appId : string ,
46
- privateKey : string ,
47
- } ) {
48
- const GITHUB_APP_CLIENT = new Octokit ( { authStrategy : createAppAuth , auth : appAuth } )
43
+ export async function accessTokenManager ( options : {
44
+ githubAppAuth : { appId : string , privateKey : string , } ,
45
+ accessPolicyLocation : {
46
+ owner : { repo : string , path : string , } ,
47
+ repo : { path : string }
48
+ } } ) {
49
+ log . debug ( { appId : options . githubAppAuth . appId } , 'GitHub app' )
50
+ const GITHUB_APP_CLIENT = new Octokit ( { authStrategy : createAppAuth , auth : options . githubAppAuth } )
49
51
const GITHUB_APP = await GITHUB_APP_CLIENT . apps . getAuthenticated ( )
50
52
. then ( ( res ) => res . data ! )
51
53
@@ -106,8 +108,8 @@ export async function accessTokenManager(appAuth: {
106
108
107
109
// --- load owner access policy ----------------------------------------------------------------------------------
108
110
const ownerAccessPolicy = await getOwnerAccessPolicy ( appInstallationClient , {
109
- owner : tokenRequest . owner , repo : config . accessPolicyLocation . owner . repo ,
110
- path : config . accessPolicyLocation . owner . path ,
111
+ owner : tokenRequest . owner , repo : options . accessPolicyLocation . owner . repo ,
112
+ path : options . accessPolicyLocation . owner . path ,
111
113
strict : false , // ignore invalid access policy entries
112
114
} )
113
115
log . debug ( { ownerAccessPolicy} , `${ tokenRequest . owner } access policy:` )
@@ -196,7 +198,7 @@ export async function accessTokenManager(appAuth: {
196
198
tokenRequest . repositories . map ( ( repo ) => limitRepoPermissionRequests ( async ( ) => {
197
199
const repoAccessPolicy = await getRepoAccessPolicy ( appInstallationClient , {
198
200
owner : tokenRequest . owner , repo,
199
- path : config . accessPolicyLocation . repo . path ,
201
+ path : options . accessPolicyLocation . repo . path ,
200
202
strict : false , // ignore invalid access policy entries
201
203
} )
202
204
log . debug ( { repoAccessPolicy} , `${ tokenRequest . owner } /${ repo } access policy` )
0 commit comments