@atproto/oauth-scopes
Version:
A library for manipulating and validating ATproto OAuth scopes in TypeScript.
54 lines • 2.65 kB
TypeScript
import type { LexiconPermission, LexiconPermissionSet } from '../lib/lexicon.js';
import { type Nsid, isNsid } from '../lib/nsid.js';
import { Parser } from '../lib/parser.js';
import { type ScopeStringFor, type ScopeSyntax } from '../lib/syntax.js';
import { RepoPermission } from './repo-permission.js';
import { type AtprotoDidRefAbsolute, RpcPermission, isAtprotoDidRefAbsolute } from './rpc-permission.js';
export { type LexiconPermission, type LexiconPermissionSet, type Nsid, isNsid };
/**
* This is used to handle "include:" oauth scope values, used to include
* permissions from a lexicon defined permission set. Not being a resource
* permission, it does not implement `Matchable`.
*/
export declare class IncludeScope {
readonly nsid: Nsid;
readonly aud: undefined | AtprotoDidRefAbsolute;
constructor(nsid: Nsid, aud?: undefined | AtprotoDidRefAbsolute);
toString(): ScopeStringFor<"include">;
toPermissions(permissionSet: LexiconPermissionSet): Array<RepoPermission | RpcPermission>;
toScopes(permissionSet: LexiconPermissionSet): Array<ScopeStringFor<'repo' | 'rpc'>>;
/**
* Converts an "include:" to the list of permissions it includes, based on the
* lexicon defined permission set.
*/
buildPermissions(permissionSet: LexiconPermissionSet): Generator<RepoPermission | RpcPermission, void, unknown>;
protected parseLexPermission(permission: LexiconPermission): ScopeSyntax<'repo' | 'rpc'> | null;
/**
* Verifies that a permission included through a lexicon permission set is
* allowed in the context of the `include:` scope. This basically checks that
* the permission is "under" the namespace authority of the `include:` scope,
* and that it only contains "repo:", "rpc:", or "blob:" permissions.
*/
protected isAllowedPermission(permission: RpcPermission | RepoPermission): boolean;
/**
* Verifies that a permission item's nsid is under the same authority as the
* nsid of the lexicon itself (which is the same as the nsid of the `include:`
* scope).
*/
isParentAuthorityOf(otherNsid: '*' | Nsid): boolean;
protected static readonly parser: Parser<"include", {
nsid: {
multiple: false;
required: true;
validate: typeof isNsid;
};
aud: {
multiple: false;
required: false;
validate: typeof isAtprotoDidRefAbsolute;
};
}>;
static fromString(scope: string): IncludeScope | null;
static fromSyntax(syntax: ScopeSyntax<'include'>): IncludeScope | null;
}
//# sourceMappingURL=include-scope.d.ts.map