···381381 * @see https://atproto.com/specs/permission#repo
382382 */
383383type RepoPermissionOptions = {
384384- /** Collections this permission applies to (lexicon schemas or NSID strings) */
384384+ /** NSID of record types (lexicon schemas or NSID strings). Wildcard (*) grants access to all records. Partial wildcards are not supported. Wildcards are not supported in permissions within a permission set */
385385 collection: NsidResolvable[];
386386- /** Allowed actions on the collections */
386386+ /** defines the set of record operations allowed. If not defined, all operations are allowed */
387387 action?: readonly ("create" | "update" | "delete")[];
388388};
389389···392392 * @see https://atproto.com/specs/permission#rpc
393393 */
394394type RpcPermissionOptions = {
395395- /** API endpoints this permission applies to (lexicon schemas or NSID strings) */
396396- lxm?: NsidResolvable[];
397397- /** DID of the target service */
395395+ /** NSID of API endpoints (lexicon schemas or NSID strings). Wildcard (*) gives access to all endpoints. Partial wildcards are not supported. Wildcards are not supported in permissions within a permission set */
396396+ lxm: NsidResolvable[];
397397+ /** audience of API requests, as a DID service reference: DID followed by required service type fragment (e.g. did:web:api.example.com#srvtype). Supports wildcard (*), though aud and lxm cannot both be wildcard. DID references are not allowed in permission set context. Always required in granular string representation; contingent on `inheritAud` in permission sets */
398398 aud?: string;
399399- /** Whether to inherit the audience from a parent include permission */
399399+ /** only used inside permission sets. If true, an `aud` value will be inherited from the `include:` invocation, and the `aud` field is not required on the permission */
400400 inheritAud?: boolean;
401401};
402402···405405 * @see https://atproto.com/specs/permission#blob
406406 */
407407type BlobPermissionOptions = {
408408- /** Accepted MIME types or patterns (e.g. "image/*") */
408408+ /** MIME types or partial MIME type glob patterns. Same syntax as the `accept` field in the `blob` lexicon type */
409409 accept: string[];
410410};
411411···414414 * @see https://atproto.com/specs/permission#account
415415 */
416416type AccountPermissionOptions = {
417417- /** Account attribute: "email" or "repo" */
417417+ /** a component of account configuration. Wildcard is not supported. "email": account email address — `read` makes email and verification status visible, `manage` includes `read` and allows changing the email. "repo": ability to update entire public repository using a CAR file — `manage` allows importing CAR files (e.g. during account migration), `read` does nothing */
418418 attr: "email" | "repo";
419419- /** Allowed action on the attribute */
419419+ /** degree of control. If not specified, default is `read` */
420420 action?: "read" | "manage";
421421};
422422···425425 * @see https://atproto.com/specs/permission#identity
426426 */
427427type IdentityPermissionOptions = {
428428- /** Identity attribute: "handle" or "*" for all */
428428+ /** an aspect or component of identity. Wildcard (*) indicates full control of DID document and handle. "handle": ability to update handle, including registration in the DID document and any domain names controlled by the PDS */
429429 attr: "handle" | "*";
430430};
431431432432-/**
433433- * Permission granting access to records in specified collections.
434434- * @see https://atproto.com/specs/permission#repo
435435- */
436436-type RepoPermissionEntry = {
432432+/** Resolves an Options type into a permission entry, converting NsidResolvable fields to strings */
433433+type PermissionEntryOf<Resource extends string, Opts> = {
437434 type: "permission";
438438- resource: "repo";
439439- collection: string[];
440440- action?: readonly ("create" | "update" | "delete")[];
435435+ resource: Resource;
436436+} & {
437437+ [K in keyof Opts]: Opts[K] extends readonly NsidResolvable[]
438438+ ? string[]
439439+ : Opts[K];
441440};
442441443443-/**
444444- * Permission granting access to call API endpoints on a specified service.
445445- * @see https://atproto.com/specs/permission#rpc
446446- */
447447-type RpcPermissionEntry = {
448448- type: "permission";
449449- resource: "rpc";
450450- lxm?: string[];
451451- aud?: string;
452452- inheritAud?: boolean;
453453-};
454454-455455-/**
456456- * Permission granting access to upload blobs with specified MIME types.
457457- * @see https://atproto.com/specs/permission#blob
458458- */
459459-type BlobPermissionEntry = {
460460- type: "permission";
461461- resource: "blob";
462462- accept: string[];
463463-};
464464-465465-/**
466466- * Permission granting access to account-level attributes; read/update the associated email address, or replacing the entire repo (with a CAR file).
467467- * @see https://atproto.com/specs/permission#account
468468- */
469469-type AccountPermissionEntry = {
470470- type: "permission";
471471- resource: "account";
472472- attr: "email" | "repo";
473473- action?: "read" | "manage";
474474-};
475475-476476-/**
477477- * Permission granting access to identity attributes like handle management.
478478- * @see https://atproto.com/specs/permission#identity
479479- */
480480-type IdentityPermissionEntry = {
481481- type: "permission";
482482- resource: "identity";
483483- attr: "handle" | "*";
484484-};
442442+/** @see https://atproto.com/specs/permission#repo */
443443+type RepoPermissionEntry = PermissionEntryOf<"repo", RepoPermissionOptions>;
444444+/** @see https://atproto.com/specs/permission#rpc */
445445+type RpcPermissionEntry = PermissionEntryOf<"rpc", RpcPermissionOptions>;
446446+/** @see https://atproto.com/specs/permission#blob */
447447+type BlobPermissionEntry = PermissionEntryOf<"blob", BlobPermissionOptions>;
448448+/** @see https://atproto.com/specs/permission#account */
449449+type AccountPermissionEntry = PermissionEntryOf<"account", AccountPermissionOptions>;
450450+/** @see https://atproto.com/specs/permission#identity */
451451+type IdentityPermissionEntry = PermissionEntryOf<"identity", IdentityPermissionOptions>;
485452486453/**
487454 * Union of all permission entry types.
···800767 return {
801768 type: "permission",
802769 resource: "rpc",
803803- ...(options.lxm ? { lxm: options.lxm.map(resolveNsid) } : {}),
770770+ lxm: options.lxm.map(resolveNsid),
804771 ...(options.aud !== undefined ? { aud: options.aud } : {}),
805772 ...(options.inheritAud !== undefined
806773 ? { inheritAud: options.inheritAud }