UNPKG

@atproto/oauth-scopes

Version:

A library for manipulating and validating ATproto OAuth scopes in TypeScript.

22 lines • 686 B
/** * Allows to quickly check if a scope is for a specific resource. */ export function isScopeStringFor(value, prefix) { if (value.length > prefix.length) { // First, check the next char is either : or ? const nextChar = value.charCodeAt(prefix.length); if (nextChar !== 0x3a /* : */ && nextChar !== 0x3f /* ? */) { return false; } // Then check the full prefix return value.startsWith(prefix); } else { // value and prefix must be equal return value === prefix; } } export function isScopeSyntaxFor(syntax, prefix) { return syntax.prefix === prefix; } //# sourceMappingURL=syntax.js.map