@atproto/oauth-scopes
Version:
A library for manipulating and validating ATproto OAuth scopes in TypeScript.
50 lines • 1.53 kB
JavaScript
import { ScopePermissions, } from './scope-permissions.js';
/**
* Overrides the default permission set to allow transitional scopes to be used
* in place of the generic scopes.
*/
export class ScopePermissionsTransition extends ScopePermissions {
get hasTransitionGeneric() {
return this.scopes.has('transition:generic');
}
get hasTransitionEmail() {
return this.scopes.has('transition:email');
}
get hasTransitionChatBsky() {
return this.scopes.has('transition:chat.bsky');
}
allowsAccount(options) {
if (options.attr === 'email' &&
options.action === 'read' &&
this.hasTransitionEmail) {
return true;
}
return super.allowsAccount(options);
}
allowsBlob(options) {
if (this.hasTransitionGeneric) {
return true;
}
return super.allowsBlob(options);
}
allowsRepo(options) {
if (this.hasTransitionGeneric) {
return true;
}
return super.allowsRepo(options);
}
allowsRpc(options) {
const { lxm } = options;
if (this.hasTransitionGeneric && lxm === '*') {
return true;
}
if (this.hasTransitionGeneric && !lxm.startsWith('chat.bsky.')) {
return true;
}
if (this.hasTransitionChatBsky && lxm.startsWith('chat.bsky.')) {
return true;
}
return super.allowsRpc(options);
}
}
//# sourceMappingURL=scope-permissions-transition.js.map