import { parseScopesForDisplay } from '@pdsjs/core/scope'; /** * A granted scope string as the shape ScopeSummary renders, mirroring the * server's consent-page serialization. Granted scopes hold concrete grants * (include: expands at approval), so any include token still present renders * by its NSID alone. * @param {string} scope */ export function scopeDisplay(scope) { const parsed = parseScopesForDisplay(scope || 'atproto'); return { scope: scope || 'atproto', hasAtproto: parsed.hasAtproto, hasTransitionGeneric: parsed.hasTransitionGeneric, hasEmail: parsed.hasEmail, repo: [...parsed.repoPermissions.entries()].map( ([collection, actions]) => ({ collection, ...actions, }), ), rpc: parsed.rpcPermissions, includes: parsed.includeScopes.map(({ nsid, aud }) => ({ nsid, aud, title: null, detail: null, titleLangs: {}, detailLangs: {}, repo: [], rpc: [], })), blobs: parsed.blobPermissions, spaces: parsed.spacePermissions, }; }