feat: add parameter for Bitbucket ScmAuth scopes

Signed-off-by: RedlineTriad <39059512+RedlineTriad@users.noreply.github.com>
This commit is contained in:
RedlineTriad
2024-09-24 15:18:49 +02:00
parent 17ecea8223
commit 481637b97d
2 changed files with 22 additions and 2 deletions
+4
View File
@@ -55,6 +55,10 @@ export class ScmAuth implements ScmAuthApi {
bitbucketAuthApi: OAuthApi,
options?: {
host?: string;
scopeMapping?: {
default?: string[];
repoWrite?: string[];
};
},
): ScmAuth;
static forGithub(
+18 -2
View File
@@ -226,12 +226,28 @@ export class ScmAuth implements ScmAuthApi {
bitbucketAuthApi: OAuthApi,
options?: {
host?: string;
scopeMapping?: {
default?: string[];
repoWrite?: string[];
};
},
): ScmAuth {
const host = options?.host ?? 'bitbucket.org';
const defaultScopes = options?.scopeMapping?.default ?? [
'account',
'team',
'pullrequest',
'snippet',
'issue',
];
const repoWriteScopes = options?.scopeMapping?.repoWrite ?? [
'pullrequest:write',
'snippet:write',
'issue:write',
];
return new ScmAuth('bitbucket', bitbucketAuthApi, host, {
default: ['account', 'team', 'pullrequest', 'snippet', 'issue'],
repoWrite: ['pullrequest:write', 'snippet:write', 'issue:write'],
default: defaultScopes,
repoWrite: repoWriteScopes,
});
}