@atproto/oauth-scopes 0.0.0-spaces-alpha-20260818021221

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/CHANGELOG.md +220 -0
  2. package/LICENSE.txt +7 -0
  3. package/dist/atproto-oauth-scope.d.ts +17 -0
  4. package/dist/atproto-oauth-scope.d.ts.map +1 -0
  5. package/dist/atproto-oauth-scope.js +63 -0
  6. package/dist/atproto-oauth-scope.js.map +1 -0
  7. package/dist/index.d.ts +13 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +13 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/lib/lexicon.d.ts +26 -0
  12. package/dist/lib/lexicon.d.ts.map +1 -0
  13. package/dist/lib/lexicon.js +2 -0
  14. package/dist/lib/lexicon.js.map +1 -0
  15. package/dist/lib/mime.d.ts +7 -0
  16. package/dist/lib/mime.d.ts.map +1 -0
  17. package/dist/lib/mime.js +61 -0
  18. package/dist/lib/mime.js.map +1 -0
  19. package/dist/lib/nsid.d.ts +3 -0
  20. package/dist/lib/nsid.d.ts.map +1 -0
  21. package/dist/lib/nsid.js +3 -0
  22. package/dist/lib/nsid.js.map +1 -0
  23. package/dist/lib/parser.d.ts +29 -0
  24. package/dist/lib/parser.d.ts.map +1 -0
  25. package/dist/lib/parser.js +127 -0
  26. package/dist/lib/parser.js.map +1 -0
  27. package/dist/lib/resource-permission.d.ts +10 -0
  28. package/dist/lib/resource-permission.d.ts.map +1 -0
  29. package/dist/lib/resource-permission.js +2 -0
  30. package/dist/lib/resource-permission.js.map +1 -0
  31. package/dist/lib/syntax-lexicon.d.ts +17 -0
  32. package/dist/lib/syntax-lexicon.d.ts.map +1 -0
  33. package/dist/lib/syntax-lexicon.js +62 -0
  34. package/dist/lib/syntax-lexicon.js.map +1 -0
  35. package/dist/lib/syntax-string.d.ts +16 -0
  36. package/dist/lib/syntax-string.d.ts.map +1 -0
  37. package/dist/lib/syntax-string.js +102 -0
  38. package/dist/lib/syntax-string.js.map +1 -0
  39. package/dist/lib/syntax.d.ts +24 -0
  40. package/dist/lib/syntax.d.ts.map +1 -0
  41. package/dist/lib/syntax.js +22 -0
  42. package/dist/lib/syntax.js.map +1 -0
  43. package/dist/lib/util.d.ts +7 -0
  44. package/dist/lib/util.d.ts.map +1 -0
  45. package/dist/lib/util.js +15 -0
  46. package/dist/lib/util.js.map +1 -0
  47. package/dist/scope-missing-error.d.ts +9 -0
  48. package/dist/scope-missing-error.d.ts.map +1 -0
  49. package/dist/scope-missing-error.js +15 -0
  50. package/dist/scope-missing-error.js.map +1 -0
  51. package/dist/scope-permissions-transition.d.ts +21 -0
  52. package/dist/scope-permissions-transition.d.ts.map +1 -0
  53. package/dist/scope-permissions-transition.js +58 -0
  54. package/dist/scope-permissions-transition.js.map +1 -0
  55. package/dist/scope-permissions.d.ts +25 -0
  56. package/dist/scope-permissions.d.ts.map +1 -0
  57. package/dist/scope-permissions.js +72 -0
  58. package/dist/scope-permissions.js.map +1 -0
  59. package/dist/scopes/account-permission.d.ts +35 -0
  60. package/dist/scopes/account-permission.d.ts.map +1 -0
  61. package/dist/scopes/account-permission.js +55 -0
  62. package/dist/scopes/account-permission.js.map +1 -0
  63. package/dist/scopes/blob-permission.d.ts +27 -0
  64. package/dist/scopes/blob-permission.d.ts.map +1 -0
  65. package/dist/scopes/blob-permission.js +73 -0
  66. package/dist/scopes/blob-permission.js.map +1 -0
  67. package/dist/scopes/identity-permission.d.ts +25 -0
  68. package/dist/scopes/identity-permission.d.ts.map +1 -0
  69. package/dist/scopes/identity-permission.js +39 -0
  70. package/dist/scopes/identity-permission.js.map +1 -0
  71. package/dist/scopes/include-scope.d.ts +55 -0
  72. package/dist/scopes/include-scope.d.ts.map +1 -0
  73. package/dist/scopes/include-scope.js +165 -0
  74. package/dist/scopes/include-scope.js.map +1 -0
  75. package/dist/scopes/repo-permission.d.ts +40 -0
  76. package/dist/scopes/repo-permission.d.ts.map +1 -0
  77. package/dist/scopes/repo-permission.js +81 -0
  78. package/dist/scopes/repo-permission.js.map +1 -0
  79. package/dist/scopes/rpc-permission.d.ts +38 -0
  80. package/dist/scopes/rpc-permission.d.ts.map +1 -0
  81. package/dist/scopes/rpc-permission.js +59 -0
  82. package/dist/scopes/rpc-permission.js.map +1 -0
  83. package/dist/scopes/space-permission.d.ts +111 -0
  84. package/dist/scopes/space-permission.d.ts.map +1 -0
  85. package/dist/scopes/space-permission.js +195 -0
  86. package/dist/scopes/space-permission.js.map +1 -0
  87. package/dist/scopes-set.d.ts +34 -0
  88. package/dist/scopes-set.d.ts.map +1 -0
  89. package/dist/scopes-set.js +102 -0
  90. package/dist/scopes-set.js.map +1 -0
  91. package/package.json +43 -0
@@ -0,0 +1,165 @@
1
+ import { isNsid } from '../lib/nsid.js';
2
+ import { Parser } from '../lib/parser.js';
3
+ import { LexPermissionSyntax } from '../lib/syntax-lexicon.js';
4
+ import { ScopeStringSyntax } from '../lib/syntax-string.js';
5
+ import { isScopeStringFor, isScopeSyntaxFor, } from '../lib/syntax.js';
6
+ import { RepoPermission } from './repo-permission.js';
7
+ import { RpcPermission, isAtprotoDidRefAbsolute, } from './rpc-permission.js';
8
+ import { SpacePermission } from './space-permission.js';
9
+ export { isNsid };
10
+ /**
11
+ * This is used to handle "include:" oauth scope values, used to include
12
+ * permissions from a lexicon defined permission set. Not being a resource
13
+ * permission, it does not implement `Matchable`.
14
+ */
15
+ export class IncludeScope {
16
+ constructor(nsid, aud = undefined) {
17
+ this.nsid = nsid;
18
+ this.aud = aud;
19
+ }
20
+ toString() {
21
+ return IncludeScope.parser.format(this);
22
+ }
23
+ toPermissions(permissionSet) {
24
+ return Array.from(this.buildPermissions(permissionSet));
25
+ }
26
+ toScopes(permissionSet) {
27
+ return Array.from(this.buildPermissions(permissionSet), (p) => p.toString());
28
+ }
29
+ /**
30
+ * Converts an "include:" to the list of permissions it includes, based on the
31
+ * lexicon defined permission set.
32
+ */
33
+ *buildPermissions(permissionSet) {
34
+ for (const lexPermission of permissionSet.permissions) {
35
+ const syntax = this.parseLexPermission(lexPermission);
36
+ if (!syntax)
37
+ continue;
38
+ const resourcePermission = toResourcePermission(syntax);
39
+ if (!resourcePermission)
40
+ continue;
41
+ if (this.isAllowedPermission(resourcePermission)) {
42
+ yield resourcePermission;
43
+ }
44
+ }
45
+ }
46
+ parseLexPermission(permission) {
47
+ // This function converts permissions listed in the permission set into
48
+ // their respective ScopeSyntax representations, handling special cases as
49
+ // needed.
50
+ if (isLexPermissionForResource(permission, 'repo')) {
51
+ return new LexPermissionSyntax(permission);
52
+ }
53
+ if (isLexPermissionForResource(permission, 'space')) {
54
+ return new LexPermissionSyntax(permission);
55
+ }
56
+ if (isLexPermissionForResource(permission, 'rpc')) {
57
+ // "rpc" permissions with a defined audience are not allowed in permission
58
+ // sets
59
+ if (permission.aud !== undefined && permission.aud !== '*') {
60
+ return null;
61
+ }
62
+ // "rpc" permissions can "inherit" their audience from "aud" param defined
63
+ // in the "include:<nsid>?aud=<audience>" scope the permission set was
64
+ // loaded from.
65
+ if (permission.inheritAud === true &&
66
+ permission.aud === undefined &&
67
+ this.aud !== undefined) {
68
+ const { inheritAud, ...rest } = permission;
69
+ return new LexPermissionSyntax({ aud: this.aud, ...rest });
70
+ }
71
+ return new LexPermissionSyntax(permission);
72
+ }
73
+ return null;
74
+ }
75
+ /**
76
+ * Verifies that a permission included through a lexicon permission set is
77
+ * allowed in the context of the `include:` scope. This basically checks that
78
+ * the permission is "under" the namespace authority of the `include:` scope,
79
+ * and that it only contains "repo:", "rpc:", or "blob:" permissions.
80
+ */
81
+ isAllowedPermission(permission) {
82
+ if (permission instanceof RpcPermission) {
83
+ return permission.lxm.every(this.isParentAuthorityOf, this);
84
+ }
85
+ if (permission instanceof RepoPermission) {
86
+ return permission.collection.every(this.isParentAuthorityOf, this);
87
+ }
88
+ if (permission instanceof SpacePermission) {
89
+ // Only the space type is authority-checked; collections may live under a
90
+ // different authority.
91
+ return this.isParentAuthorityOf(permission.type);
92
+ }
93
+ throw new TypeError(`Unexpected permission ${permission}`);
94
+ }
95
+ /**
96
+ * Verifies that a permission item's nsid is under the same authority as the
97
+ * nsid of the lexicon itself (which is the same as the nsid of the `include:`
98
+ * scope).
99
+ */
100
+ isParentAuthorityOf(otherNsid) {
101
+ if (otherNsid === '*') {
102
+ return false;
103
+ }
104
+ const lexiconNsid = this.nsid;
105
+ const groupPrefixEnd = lexiconNsid.lastIndexOf('.');
106
+ // There should always be a dot, but since this is a security feature, let's
107
+ // be strict about it.
108
+ if (groupPrefixEnd === -1) {
109
+ throw new TypeError('Dot character (".") missing from lexicon NSID');
110
+ }
111
+ // Make sure that otherNsid is at least as long as the "group prefix"
112
+ if (groupPrefixEnd >= otherNsid.length - 1) {
113
+ return false;
114
+ }
115
+ // Make sure that the "otherNsid" starts with the group of the lexiconNsid,
116
+ // up to the dot itself. We check in reverse order as nsids tend to have
117
+ // long common prefixes.
118
+ for (let i = groupPrefixEnd; i >= 0; i--) {
119
+ if (lexiconNsid.charCodeAt(i) !== otherNsid.charCodeAt(i)) {
120
+ return false;
121
+ }
122
+ }
123
+ return true;
124
+ }
125
+ static { this.parser = new Parser('include', {
126
+ nsid: {
127
+ multiple: false,
128
+ required: true,
129
+ validate: isNsid,
130
+ },
131
+ aud: {
132
+ multiple: false,
133
+ required: false,
134
+ validate: isAtprotoDidRefAbsolute,
135
+ },
136
+ }, 'nsid'); }
137
+ static fromString(scope) {
138
+ if (!isScopeStringFor(scope, 'include'))
139
+ return null;
140
+ const syntax = ScopeStringSyntax.fromString(scope);
141
+ return IncludeScope.fromSyntax(syntax);
142
+ }
143
+ static fromSyntax(syntax) {
144
+ const result = IncludeScope.parser.parse(syntax);
145
+ if (!result)
146
+ return null;
147
+ return new IncludeScope(result.nsid, result.aud);
148
+ }
149
+ }
150
+ function toResourcePermission(syntax) {
151
+ if (isScopeSyntaxFor(syntax, 'repo')) {
152
+ return RepoPermission.fromSyntax(syntax);
153
+ }
154
+ if (isScopeSyntaxFor(syntax, 'rpc')) {
155
+ return RpcPermission.fromSyntax(syntax);
156
+ }
157
+ if (isScopeSyntaxFor(syntax, 'space')) {
158
+ return SpacePermission.fromSyntax(syntax);
159
+ }
160
+ return null;
161
+ }
162
+ function isLexPermissionForResource(permission, type) {
163
+ return permission.resource === type;
164
+ }
165
+ //# sourceMappingURL=include-scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"include-scope.js","sourceRoot":"","sources":["../../src/scopes/include-scope.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAGL,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAEL,aAAa,EACb,uBAAuB,GACxB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAgE,MAAM,EAAE,CAAA;AAE/E;;;;GAIG;AACH,MAAM,OAAO,YAAY;IACvB,YACkB,IAAU,EACV,GAAG,GAAsC,SAAS;oBADlD,IAAI;mBACJ,GAAG;IAClB,CAAC;IAEJ,QAAQ;QACN,OAAO,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACzC,CAAC;IAED,aAAa,CACX,aAAmC;QAEnC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAA;IACzD,CAAC;IAED,QAAQ,CACN,aAAmC;QAEnC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,aAAa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oBAAoB,CAC3B,MAA6C;IAE7C,IAAI,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;QACrC,OAAO,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IAC1C,CAAC;IACD,IAAI,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC;QACpC,OAAO,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IACzC,CAAC;IACD,IAAI,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QACtC,OAAO,eAAe,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IAC3C,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,0BAA0B,CAGjC,UAAa,EAAE,IAAO;IACtB,OAAO,UAAU,CAAC,QAAQ,KAAK,IAAI,CAAA;AACrC,CAAC","sourcesContent":["import type { LexiconPermission, LexiconPermissionSet } from '../lib/lexicon.js'\nimport { type Nsid, isNsid } from '../lib/nsid.js'\nimport { Parser } from '../lib/parser.js'\nimport { LexPermissionSyntax } from '../lib/syntax-lexicon.js'\nimport { ScopeStringSyntax } from '../lib/syntax-string.js'\nimport {\n type ScopeStringFor,\n type ScopeSyntax,\n isScopeStringFor,\n isScopeSyntaxFor,\n} from '../lib/syntax.js'\nimport { RepoPermission } from './repo-permission.js'\nimport {\n type AtprotoDidRefAbsolute,\n RpcPermission,\n isAtprotoDidRefAbsolute,\n} from './rpc-permission.js'\nimport { SpacePermission } from './space-permission.js'\n\nexport { type LexiconPermission, type LexiconPermissionSet, type Nsid, isNsid }\n\n/**\n * This is used to handle \"include:\" oauth scope values, used to include\n * permissions from a lexicon defined permission set. Not being a resource\n * permission, it does not implement `Matchable`.\n */\nexport class IncludeScope {\n constructor(\n public readonly nsid: Nsid,\n public readonly aud: undefined | AtprotoDidRefAbsolute = undefined,\n ) {}\n\n toString() {\n return IncludeScope.parser.format(this)\n }\n\n toPermissions(\n permissionSet: LexiconPermissionSet,\n ): Array<RepoPermission | RpcPermission | SpacePermission> {\n return Array.from(this.buildPermissions(permissionSet))\n }\n\n toScopes(\n permissionSet: LexiconPermissionSet,\n ): Array<ScopeStringFor<'repo' | 'rpc' | 'space'>> {\n return Array.from(this.buildPermissions(permissionSet), (p) => p.toString())\n }\n\n /**\n * Converts an \"include:\" to the list of permissions it includes, based on the\n * lexicon defined permission set.\n */\n *buildPermissions(\n permissionSet: LexiconPermissionSet,\n ): Generator<\n RepoPermission | RpcPermission | SpacePermission,\n void,\n unknown\n > {\n for (const lexPermission of permissionSet.permissions) {\n const syntax = this.parseLexPermission(lexPermission)\n if (!syntax) continue\n\n const resourcePermission = toResourcePermission(syntax)\n if (!resourcePermission) continue\n\n if (this.isAllowedPermission(resourcePermission)) {\n yield resourcePermission\n }\n }\n }\n\n protected parseLexPermission(\n permission: LexiconPermission,\n ): ScopeSyntax<'repo' | 'rpc' | 'space'> | null {\n // This function converts permissions listed in the permission set into\n // their respective ScopeSyntax representations, handling special cases as\n // needed.\n\n if (isLexPermissionForResource(permission, 'repo')) {\n return new LexPermissionSyntax(permission)\n }\n\n if (isLexPermissionForResource(permission, 'space')) {\n return new LexPermissionSyntax(permission)\n }\n\n if (isLexPermissionForResource(permission, 'rpc')) {\n // \"rpc\" permissions with a defined audience are not allowed in permission\n // sets\n if (permission.aud !== undefined && permission.aud !== '*') {\n return null\n }\n\n // \"rpc\" permissions can \"inherit\" their audience from \"aud\" param defined\n // in the \"include:<nsid>?aud=<audience>\" scope the permission set was\n // loaded from.\n if (\n permission.inheritAud === true &&\n permission.aud === undefined &&\n this.aud !== undefined\n ) {\n const { inheritAud, ...rest } = permission\n return new LexPermissionSyntax({ aud: this.aud, ...rest })\n }\n\n return new LexPermissionSyntax(permission)\n }\n\n return null\n }\n\n /**\n * Verifies that a permission included through a lexicon permission set is\n * allowed in the context of the `include:` scope. This basically checks that\n * the permission is \"under\" the namespace authority of the `include:` scope,\n * and that it only contains \"repo:\", \"rpc:\", or \"blob:\" permissions.\n */\n protected isAllowedPermission(\n permission: RpcPermission | RepoPermission | SpacePermission,\n ): boolean {\n if (permission instanceof RpcPermission) {\n return permission.lxm.every(this.isParentAuthorityOf, this)\n }\n\n if (permission instanceof RepoPermission) {\n return permission.collection.every(this.isParentAuthorityOf, this)\n }\n\n if (permission instanceof SpacePermission) {\n // Only the space type is authority-checked; collections may live under a\n // different authority.\n return this.isParentAuthorityOf(permission.type)\n }\n\n throw new TypeError(`Unexpected permission ${permission}`)\n }\n\n /**\n * Verifies that a permission item's nsid is under the same authority as the\n * nsid of the lexicon itself (which is the same as the nsid of the `include:`\n * scope).\n */\n public isParentAuthorityOf(otherNsid: '*' | Nsid) {\n if (otherNsid === '*') {\n return false\n }\n\n const lexiconNsid = this.nsid\n\n const groupPrefixEnd = lexiconNsid.lastIndexOf('.')\n\n // There should always be a dot, but since this is a security feature, let's\n // be strict about it.\n if (groupPrefixEnd === -1) {\n throw new TypeError('Dot character (\".\") missing from lexicon NSID')\n }\n\n // Make sure that otherNsid is at least as long as the \"group prefix\"\n if (groupPrefixEnd >= otherNsid.length - 1) {\n return false\n }\n\n // Make sure that the \"otherNsid\" starts with the group of the lexiconNsid,\n // up to the dot itself. We check in reverse order as nsids tend to have\n // long common prefixes.\n for (let i = groupPrefixEnd; i >= 0; i--) {\n if (lexiconNsid.charCodeAt(i) !== otherNsid.charCodeAt(i)) {\n return false\n }\n }\n\n return true\n }\n\n protected static readonly parser = new Parser(\n 'include',\n {\n nsid: {\n multiple: false,\n required: true,\n validate: isNsid,\n },\n aud: {\n multiple: false,\n required: false,\n validate: isAtprotoDidRefAbsolute,\n },\n },\n 'nsid',\n )\n\n static fromString(scope: string) {\n if (!isScopeStringFor(scope, 'include')) return null\n const syntax = ScopeStringSyntax.fromString(scope)\n return IncludeScope.fromSyntax(syntax)\n }\n\n static fromSyntax(syntax: ScopeSyntax<'include'>) {\n const result = IncludeScope.parser.parse(syntax)\n if (!result) return null\n return new IncludeScope(result.nsid, result.aud)\n }\n}\n\nfunction toResourcePermission(\n syntax: ScopeSyntax<'repo' | 'rpc' | 'space'>,\n): RepoPermission | RpcPermission | SpacePermission | null {\n if (isScopeSyntaxFor(syntax, 'repo')) {\n return RepoPermission.fromSyntax(syntax)\n }\n if (isScopeSyntaxFor(syntax, 'rpc')) {\n return RpcPermission.fromSyntax(syntax)\n }\n if (isScopeSyntaxFor(syntax, 'space')) {\n return SpacePermission.fromSyntax(syntax)\n }\n return null\n}\n\nfunction isLexPermissionForResource<\n P extends { resource: unknown },\n T extends string,\n>(permission: P, type: T): permission is P & { resource: T } {\n return permission.resource === type\n}\n"]}
@@ -0,0 +1,40 @@
1
+ import { type Nsid, isNsid } from '../lib/nsid.js';
2
+ import { Parser } from '../lib/parser.js';
3
+ import type { ResourcePermission } from '../lib/resource-permission.js';
4
+ import { type NeArray, type NeRoArray, type ScopeSyntax } from '../lib/syntax.js';
5
+ export { type Nsid, isNsid };
6
+ export declare const REPO_ACTIONS: readonly ["create", "update", "delete"];
7
+ export type RepoAction = (typeof REPO_ACTIONS)[number];
8
+ export declare const isRepoAction: (value: unknown) => value is "create" | "delete" | "update";
9
+ export type CollectionParam = '*' | Nsid;
10
+ export declare const isCollectionParam: (value: unknown) => value is CollectionParam;
11
+ export type RepoPermissionMatch = {
12
+ collection: string;
13
+ action: RepoAction;
14
+ };
15
+ export declare class RepoPermission implements ResourcePermission<'repo', RepoPermissionMatch> {
16
+ readonly collection: NeRoArray<'*' | Nsid>;
17
+ readonly action: NeRoArray<RepoAction>;
18
+ constructor(collection: NeRoArray<'*' | Nsid>, action: NeRoArray<RepoAction>);
19
+ matches({ action, collection }: RepoPermissionMatch): boolean;
20
+ toString(): import("../lib/syntax.js").ScopeStringFor<"repo">;
21
+ protected static readonly parser: Parser<"repo", {
22
+ collection: {
23
+ multiple: true;
24
+ required: true;
25
+ validate: typeof isCollectionParam;
26
+ normalize: (value: NeRoArray<import("../lib/syntax.js").ParamValue>) => NeArray<`${string}.${string}.${string}`> | ["*" | `${string}.${string}.${string}`] | readonly ["*"];
27
+ };
28
+ action: {
29
+ multiple: true;
30
+ required: false;
31
+ validate: (value: unknown) => value is "create" | "delete" | "update";
32
+ default: readonly ["create", "update", "delete"];
33
+ normalize: (value: NeRoArray<import("../lib/syntax.js").ParamValue>) => NeArray<"create" | "delete" | "update"> | readonly ["create", "update", "delete"];
34
+ };
35
+ }>;
36
+ static fromString(scope: string): RepoPermission | null;
37
+ static fromSyntax(syntax: ScopeSyntax<'repo'>): RepoPermission | null;
38
+ static scopeNeededFor(options: RepoPermissionMatch): string;
39
+ }
40
+ //# sourceMappingURL=repo-permission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-permission.d.ts","sourceRoot":"","sources":["../../src/scopes/repo-permission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAEvE,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,WAAW,EAEjB,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,EAAE,CAAA;AAE5B,eAAO,MAAM,YAAY,yCAId,CAAA;AACX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AACtD,eAAO,MAAM,YAAY,6DAAqC,CAAA;AAE9D,MAAM,MAAM,eAAe,GAAG,GAAG,GAAG,IAAI,CAAA;AACxC,eAAO,MAAM,iBAAiB,UAAW,OAAO,KAAG,KAAK,IAAI,eAC5B,CAAA;AAEhC,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,UAAU,CAAA;CACnB,CAAA;AAED,qBAAa,cAAe,YAAW,kBAAkB,CACvD,MAAM,EACN,mBAAmB,CACpB;aAEmB,UAAU,EAAE,SAAS,CAAC,GAAG,GAAG,IAAI,CAAC;aACjC,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC;IAF/C,YACkB,UAAU,EAAE,SAAS,CAAC,GAAG,GAAG,IAAI,CAAC,EACjC,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC,EAC3C;IAEJ,OAAO,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,mBAAmB,WAMlD;IAED,QAAQ,sDAEP;IAED,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM;;;;;;;;;;;;;;OA4B/B;IAED,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAItD;IAED,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,cAAc,GAAG,IAAI,CAKpE;IAED,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,CAK1D;CACF"}
@@ -0,0 +1,81 @@
1
+ import { isNsid } from '../lib/nsid.js';
2
+ import { Parser } from '../lib/parser.js';
3
+ import { ScopeStringSyntax } from '../lib/syntax-string.js';
4
+ import { isScopeStringFor, } from '../lib/syntax.js';
5
+ import { knownValuesValidator } from '../lib/util.js';
6
+ export { isNsid };
7
+ export const REPO_ACTIONS = Object.freeze([
8
+ 'create',
9
+ 'update',
10
+ 'delete',
11
+ ]);
12
+ export const isRepoAction = knownValuesValidator(REPO_ACTIONS);
13
+ export const isCollectionParam = (value) => value === '*' || isNsid(value);
14
+ export class RepoPermission {
15
+ constructor(collection, action) {
16
+ this.collection = collection;
17
+ this.action = action;
18
+ }
19
+ matches({ action, collection }) {
20
+ return (this.action.includes(action) &&
21
+ (this.collection.includes('*') ||
22
+ this.collection.includes(collection)));
23
+ }
24
+ toString() {
25
+ return RepoPermission.parser.format(this);
26
+ }
27
+ static { this.parser = new Parser('repo', {
28
+ collection: {
29
+ multiple: true,
30
+ required: true,
31
+ validate: isCollectionParam,
32
+ normalize: (value) => {
33
+ if (value.length > 1) {
34
+ if (value.includes('*'))
35
+ return ['*'];
36
+ return [...new Set(value)].sort();
37
+ }
38
+ return value;
39
+ },
40
+ },
41
+ action: {
42
+ multiple: true,
43
+ required: false,
44
+ validate: isRepoAction,
45
+ default: REPO_ACTIONS,
46
+ normalize: (value) => {
47
+ return value === REPO_ACTIONS
48
+ ? REPO_ACTIONS // No need to filter if the default was used
49
+ : REPO_ACTIONS.filter(includedIn, value);
50
+ },
51
+ },
52
+ }, 'collection'); }
53
+ static fromString(scope) {
54
+ if (!isScopeStringFor(scope, 'repo'))
55
+ return null;
56
+ const syntax = ScopeStringSyntax.fromString(scope);
57
+ return RepoPermission.fromSyntax(syntax);
58
+ }
59
+ static fromSyntax(syntax) {
60
+ const result = RepoPermission.parser.parse(syntax);
61
+ if (!result)
62
+ return null;
63
+ return new RepoPermission(result.collection, result.action);
64
+ }
65
+ static scopeNeededFor(options) {
66
+ return RepoPermission.parser.format({
67
+ collection: [options.collection],
68
+ action: [options.action],
69
+ });
70
+ }
71
+ }
72
+ /**
73
+ * Special utility function to be used as predicate for array methods like
74
+ * `Array.prototype.includes`, etc. When used as predicate, it expects that
75
+ * the array method is called with a `thisArg` that is a readonly array of
76
+ * the same type as the `value` parameter.
77
+ */
78
+ function includedIn(value) {
79
+ return this.includes(value);
80
+ }
81
+ //# sourceMappingURL=repo-permission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-permission.js","sourceRoot":"","sources":["../../src/scopes/repo-permission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAIL,gBAAgB,GACjB,MAAM,kBAAkB,CAAA;AACzB,OA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AC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC7B,CAAC","sourcesContent":["import { type Nsid, isNsid } from '../lib/nsid.js'\nimport { Parser } from '../lib/parser.js'\nimport type { ResourcePermission } from '../lib/resource-permission.js'\nimport { ScopeStringSyntax } from '../lib/syntax-string.js'\nimport {\n type NeArray,\n type NeRoArray,\n type ScopeSyntax,\n isScopeStringFor,\n} from '../lib/syntax.js'\nimport { knownValuesValidator } from '../lib/util.js'\n\nexport { type Nsid, isNsid }\n\nexport const REPO_ACTIONS = Object.freeze([\n 'create',\n 'update',\n 'delete',\n] as const)\nexport type RepoAction = (typeof REPO_ACTIONS)[number]\nexport const isRepoAction = knownValuesValidator(REPO_ACTIONS)\n\nexport type CollectionParam = '*' | Nsid\nexport const isCollectionParam = (value: unknown): value is CollectionParam =>\n value === '*' || isNsid(value)\n\nexport type RepoPermissionMatch = {\n collection: string\n action: RepoAction\n}\n\nexport class RepoPermission implements ResourcePermission<\n 'repo',\n RepoPermissionMatch\n> {\n constructor(\n public readonly collection: NeRoArray<'*' | Nsid>,\n public readonly action: NeRoArray<RepoAction>,\n ) {}\n\n matches({ action, collection }: RepoPermissionMatch) {\n return (\n this.action.includes(action) &&\n (this.collection.includes('*') ||\n (this.collection as readonly string[]).includes(collection))\n )\n }\n\n toString() {\n return RepoPermission.parser.format(this)\n }\n\n protected static readonly parser = new Parser(\n 'repo',\n {\n collection: {\n multiple: true,\n required: true,\n validate: isCollectionParam,\n normalize: (value) => {\n if (value.length > 1) {\n if (value.includes('*')) return ['*'] as const\n return [...new Set(value)].sort() as NeArray<Nsid>\n }\n return value as ['*' | Nsid]\n },\n },\n action: {\n multiple: true,\n required: false,\n validate: isRepoAction,\n default: REPO_ACTIONS,\n normalize: (value) => {\n return value === REPO_ACTIONS\n ? REPO_ACTIONS // No need to filter if the default was used\n : (REPO_ACTIONS.filter(includedIn, value) as NeArray<RepoAction>)\n },\n },\n },\n 'collection',\n )\n\n static fromString(scope: string): RepoPermission | null {\n if (!isScopeStringFor(scope, 'repo')) return null\n const syntax = ScopeStringSyntax.fromString(scope)\n return RepoPermission.fromSyntax(syntax)\n }\n\n static fromSyntax(syntax: ScopeSyntax<'repo'>): RepoPermission | null {\n const result = RepoPermission.parser.parse(syntax)\n if (!result) return null\n\n return new RepoPermission(result.collection, result.action)\n }\n\n static scopeNeededFor(options: RepoPermissionMatch): string {\n return RepoPermission.parser.format({\n collection: [options.collection as '*' | Nsid],\n action: [options.action],\n })\n }\n}\n\n/**\n * Special utility function to be used as predicate for array methods like\n * `Array.prototype.includes`, etc. When used as predicate, it expects that\n * the array method is called with a `thisArg` that is a readonly array of\n * the same type as the `value` parameter.\n */\nfunction includedIn<T>(this: readonly T[], value: T): boolean {\n return this.includes(value)\n}\n"]}
@@ -0,0 +1,38 @@
1
+ import { type AtprotoDidRefAbsolute, isAtprotoDidRefAbsolute } from '@atproto/did';
2
+ import { type Nsid, isNsid } from '../lib/nsid.js';
3
+ import { Parser } from '../lib/parser.js';
4
+ import type { ResourcePermission } from '../lib/resource-permission.js';
5
+ import { type NeRoArray, type ScopeSyntax } from '../lib/syntax.js';
6
+ export { type AtprotoDidRefAbsolute, type Nsid, isAtprotoDidRefAbsolute, isNsid, };
7
+ export type LxmParam = '*' | Nsid;
8
+ export declare const isLxmParam: (value: unknown) => value is LxmParam;
9
+ export type AudParam = '*' | AtprotoDidRefAbsolute;
10
+ export declare const isAudParam: (value: unknown) => value is AudParam;
11
+ export type RpcPermissionMatch = {
12
+ lxm: string;
13
+ aud: string;
14
+ };
15
+ export declare class RpcPermission implements ResourcePermission<'rpc', RpcPermissionMatch> {
16
+ readonly aud: AudParam;
17
+ readonly lxm: NeRoArray<LxmParam>;
18
+ constructor(aud: AudParam, lxm: NeRoArray<LxmParam>);
19
+ matches(options: RpcPermissionMatch): boolean;
20
+ toString(): import("../lib/syntax.js").ScopeStringFor<"rpc">;
21
+ protected static readonly parser: Parser<"rpc", {
22
+ lxm: {
23
+ multiple: true;
24
+ required: true;
25
+ validate: typeof isLxmParam;
26
+ normalize: (value: NeRoArray<import("../lib/syntax.js").ParamValue>) => [`${string}.${string}.${string}`, ...`${string}.${string}.${string}`[]] | readonly ["*"];
27
+ };
28
+ aud: {
29
+ multiple: false;
30
+ required: true;
31
+ validate: typeof isAudParam;
32
+ };
33
+ }>;
34
+ static fromString(scope: string): RpcPermission | null;
35
+ static fromSyntax(syntax: ScopeSyntax<'rpc'>): RpcPermission | null;
36
+ static scopeNeededFor(options: RpcPermissionMatch): string;
37
+ }
38
+ //# sourceMappingURL=rpc-permission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-permission.d.ts","sourceRoot":"","sources":["../../src/scopes/rpc-permission.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,uBAAuB,EACxB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAEvE,OAAO,EACL,KAAK,SAAS,EACd,KAAK,WAAW,EAEjB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,IAAI,EACT,uBAAuB,EACvB,MAAM,GACP,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,GAAG,GAAG,IAAI,CAAA;AACjC,eAAO,MAAM,UAAU,UAAW,OAAO,KAAG,KAAK,IAAI,QACrB,CAAA;AAChC,MAAM,MAAM,QAAQ,GAAG,GAAG,GAAG,qBAAqB,CAAA;AAClD,eAAO,MAAM,UAAU,UAAW,OAAO,KAAG,KAAK,IAAI,QACJ,CAAA;AAEjD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,qBAAa,aAAc,YAAW,kBAAkB,CACtD,KAAK,EACL,kBAAkB,CACnB;aAEmB,GAAG,EAAE,QAAQ;aACb,GAAG,EAAE,SAAS,CAAC,QAAQ,CAAC;IAF1C,YACkB,GAAG,EAAE,QAAQ,EACb,GAAG,EAAE,SAAS,CAAC,QAAQ,CAAC,EACtC;IAEJ,OAAO,CAAC,OAAO,EAAE,kBAAkB,WAMlC;IAED,QAAQ,qDAEP;IAED,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM;;;;;;;;;;;;OAmB/B;IAED,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAIrD;IAED,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,GAAG,aAAa,GAAG,IAAI,CAQlE;IAED,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAKzD;CACF"}
@@ -0,0 +1,59 @@
1
+ import { isAtprotoDidRefAbsolute, } from '@atproto/did';
2
+ import { isNsid } from '../lib/nsid.js';
3
+ import { Parser } from '../lib/parser.js';
4
+ import { ScopeStringSyntax } from '../lib/syntax-string.js';
5
+ import { isScopeStringFor, } from '../lib/syntax.js';
6
+ export { isAtprotoDidRefAbsolute, isNsid, };
7
+ export const isLxmParam = (value) => value === '*' || isNsid(value);
8
+ export const isAudParam = (value) => value === '*' || isAtprotoDidRefAbsolute(value);
9
+ export class RpcPermission {
10
+ constructor(aud, lxm) {
11
+ this.aud = aud;
12
+ this.lxm = lxm;
13
+ }
14
+ matches(options) {
15
+ const { aud, lxm } = this;
16
+ return ((aud === '*' || aud === options.aud) &&
17
+ (lxm.includes('*') || lxm.includes(options.lxm)));
18
+ }
19
+ toString() {
20
+ return RpcPermission.parser.format(this);
21
+ }
22
+ static { this.parser = new Parser('rpc', {
23
+ lxm: {
24
+ multiple: true,
25
+ required: true,
26
+ validate: isLxmParam,
27
+ normalize: (value) => value.length > 1 && value.includes('*')
28
+ ? ['*']
29
+ : [...new Set(value)].sort(),
30
+ },
31
+ aud: {
32
+ multiple: false,
33
+ required: true,
34
+ validate: isAudParam,
35
+ },
36
+ }, 'lxm'); }
37
+ static fromString(scope) {
38
+ if (!isScopeStringFor(scope, 'rpc'))
39
+ return null;
40
+ const syntax = ScopeStringSyntax.fromString(scope);
41
+ return RpcPermission.fromSyntax(syntax);
42
+ }
43
+ static fromSyntax(syntax) {
44
+ const result = RpcPermission.parser.parse(syntax);
45
+ if (!result)
46
+ return null;
47
+ // rpc:*?aud=* is forbidden
48
+ if (result.aud === '*' && result.lxm.includes('*'))
49
+ return null;
50
+ return new RpcPermission(result.aud, result.lxm);
51
+ }
52
+ static scopeNeededFor(options) {
53
+ return RpcPermission.parser.format({
54
+ aud: options.aud,
55
+ lxm: [options.lxm],
56
+ });
57
+ }
58
+ }
59
+ //# sourceMappingURL=rpc-permission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-permission.js","sourceRoot":"","sources":["../../src/scopes/rpc-permission.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,uBAAuB,GACxB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAa,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAGL,gBAAgB,GACjB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAGL,uBAAuB,EACvB,MAAM,GACP,CAAA;AAGD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAc,EAAqB,EAAE,CAC9D,KAAK,KAAK,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAA;AAEhC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAc,EAAqB,EAAE,CAC9D,KAAK,KAAK,GAAG,IAAI,uBAAuB,CAAC,KAAK,CAAC,CAAA;AAOjD,MAAM,OAA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C;IAED,MAAM,CAAC,UAAU,CAAC,MAA0B;QAC1C,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QACjD,IAAI,CAAC,MAAM;YAAE,OAAO,IAAI,CAAA;QAExB,2BAA2B;QAC3B,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,OAAO,IAAI,CAAA;QAE/D,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAA;IAClD,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,OAA2B;QAC/C,OAAO,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC;YACjC,GAAG,EAAE,OAAO,CAAC,GAA4B;YACzC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAW,CAAC;SAC3B,CAAC,CAAA;IACJ,CAAC;CACF","sourcesContent":["import {\n type AtprotoDidRefAbsolute,\n isAtprotoDidRefAbsolute,\n} from '@atproto/did'\nimport { type Nsid, isNsid } from '../lib/nsid.js'\nimport { Parser } from '../lib/parser.js'\nimport type { ResourcePermission } from '../lib/resource-permission.js'\nimport { ScopeStringSyntax } from '../lib/syntax-string.js'\nimport {\n type NeRoArray,\n type ScopeSyntax,\n isScopeStringFor,\n} from '../lib/syntax.js'\n\nexport {\n type AtprotoDidRefAbsolute,\n type Nsid,\n isAtprotoDidRefAbsolute,\n isNsid,\n}\n\nexport type LxmParam = '*' | Nsid\nexport const isLxmParam = (value: unknown): value is LxmParam =>\n value === '*' || isNsid(value)\nexport type AudParam = '*' | AtprotoDidRefAbsolute\nexport const isAudParam = (value: unknown): value is AudParam =>\n value === '*' || isAtprotoDidRefAbsolute(value)\n\nexport type RpcPermissionMatch = {\n lxm: string\n aud: string\n}\n\nexport class RpcPermission implements ResourcePermission<\n 'rpc',\n RpcPermissionMatch\n> {\n constructor(\n public readonly aud: AudParam,\n public readonly lxm: NeRoArray<LxmParam>,\n ) {}\n\n matches(options: RpcPermissionMatch) {\n const { aud, lxm } = this\n return (\n (aud === '*' || aud === options.aud) &&\n (lxm.includes('*') || (lxm as readonly string[]).includes(options.lxm))\n )\n }\n\n toString() {\n return RpcPermission.parser.format(this)\n }\n\n protected static readonly parser = new Parser(\n 'rpc',\n {\n lxm: {\n multiple: true,\n required: true,\n validate: isLxmParam,\n normalize: (value) =>\n value.length > 1 && value.includes('*')\n ? (['*'] as const)\n : ([...new Set(value)].sort() as [Nsid, ...Nsid[]]),\n },\n aud: {\n multiple: false,\n required: true,\n validate: isAudParam,\n },\n },\n 'lxm',\n )\n\n static fromString(scope: string): RpcPermission | null {\n if (!isScopeStringFor(scope, 'rpc')) return null\n const syntax = ScopeStringSyntax.fromString(scope)\n return RpcPermission.fromSyntax(syntax)\n }\n\n static fromSyntax(syntax: ScopeSyntax<'rpc'>): RpcPermission | null {\n const result = RpcPermission.parser.parse(syntax)\n if (!result) return null\n\n // rpc:*?aud=* is forbidden\n if (result.aud === '*' && result.lxm.includes('*')) return null\n\n return new RpcPermission(result.aud, result.lxm)\n }\n\n static scopeNeededFor(options: RpcPermissionMatch): string {\n return RpcPermission.parser.format({\n aud: options.aud as AtprotoDidRefAbsolute,\n lxm: [options.lxm as Nsid],\n })\n }\n}\n"]}
@@ -0,0 +1,111 @@
1
+ import { type Nsid } from '../lib/nsid.js';
2
+ import { Parser } from '../lib/parser.js';
3
+ import type { ResourcePermission } from '../lib/resource-permission.js';
4
+ import { type NeArray, type NeRoArray, type ScopeSyntax } from '../lib/syntax.js';
5
+ export declare const SPACE_ACTIONS: readonly ["read_self", "read", "create", "update", "delete"];
6
+ export type SpaceAction = (typeof SPACE_ACTIONS)[number];
7
+ export declare const isSpaceAction: (value: unknown) => value is "create" | "delete" | "read" | "read_self" | "update";
8
+ export declare const SPACE_DEFAULT_ACTIONS: readonly ["read", "create", "update", "delete"];
9
+ export declare const SPACE_MANAGE_OPS: readonly ["create", "update", "delete"];
10
+ export type SpaceManageOp = (typeof SPACE_MANAGE_OPS)[number];
11
+ export declare const isSpaceManageOp: (value: unknown) => value is "create" | "delete" | "update";
12
+ export type SpaceTypeParam = '*' | Nsid;
13
+ export declare const isSpaceTypeParam: (value: unknown) => value is SpaceTypeParam;
14
+ type DidString = `did:${string}:${string}`;
15
+ export type SpaceAuthorityParam = '*' | 'self' | DidString;
16
+ export declare const isSpaceAuthorityParam: (value: unknown) => value is SpaceAuthorityParam;
17
+ export type SpaceSkeyParam = string;
18
+ export declare const isSpaceSkeyParam: (value: unknown) => value is SpaceSkeyParam;
19
+ export type SpaceCollectionParam = '*' | Nsid;
20
+ export declare const isSpaceCollectionParam: (value: unknown) => value is SpaceCollectionParam;
21
+ export type SpacePermissionMatch = {
22
+ type: string;
23
+ authority: string;
24
+ skey: string;
25
+ } & ({
26
+ action: 'read';
27
+ collection?: never;
28
+ manage?: never;
29
+ } | {
30
+ action: 'read_self';
31
+ collection?: never;
32
+ manage?: never;
33
+ } | {
34
+ action: 'create' | 'update' | 'delete';
35
+ collection: string;
36
+ manage?: never;
37
+ } | {
38
+ action?: never;
39
+ collection?: never;
40
+ manage: SpaceManageOp;
41
+ });
42
+ export declare class SpacePermission implements ResourcePermission<'space', SpacePermissionMatch> {
43
+ readonly type: SpaceTypeParam;
44
+ readonly authority: SpaceAuthorityParam;
45
+ readonly skey: SpaceSkeyParam | '*';
46
+ readonly collection: NeRoArray<SpaceCollectionParam>;
47
+ readonly action: NeRoArray<SpaceAction>;
48
+ readonly manage: NeRoArray<SpaceManageOp>;
49
+ constructor(type: SpaceTypeParam, authority: SpaceAuthorityParam, skey: SpaceSkeyParam | '*', collection: NeRoArray<SpaceCollectionParam>, action: NeRoArray<SpaceAction>, manage: NeRoArray<SpaceManageOp>);
50
+ matches(target: SpacePermissionMatch): boolean;
51
+ private collectionAllows;
52
+ get hasCollections(): boolean;
53
+ /**
54
+ * Materializes a space type's declared collections into a bare
55
+ * `space:<type>` grant. Called at token-issuance time, since the matcher is
56
+ * context-free and cannot resolve declarations itself.
57
+ */
58
+ withDefaultCollections(collections: readonly SpaceCollectionParam[]): SpacePermission;
59
+ get isSelfAuthority(): boolean;
60
+ /**
61
+ * Resolves an `authority` of `self` to the granting user's DID. Called at
62
+ * token-issuance time, alongside {@link withDefaultCollections}.
63
+ */
64
+ withResolvedAuthority(userDid: DidString): SpacePermission;
65
+ toString(): import("../lib/syntax.js").ScopeStringFor<"space">;
66
+ protected static readonly parser: Parser<"space", {
67
+ type: {
68
+ multiple: false;
69
+ required: true;
70
+ validate: typeof isSpaceTypeParam;
71
+ };
72
+ authority: {
73
+ multiple: false;
74
+ required: false;
75
+ default: 'self';
76
+ validate: typeof isSpaceAuthorityParam;
77
+ };
78
+ skey: {
79
+ multiple: false;
80
+ required: false;
81
+ default: '*';
82
+ validate: (value: import("../lib/syntax.js").ParamValue) => value is SpaceSkeyParam | '*';
83
+ };
84
+ collection: {
85
+ multiple: true;
86
+ required: false;
87
+ validate: typeof isSpaceCollectionParam;
88
+ default: NeRoArray<SpaceCollectionParam>;
89
+ normalize: (value: NeRoArray<import("../lib/syntax.js").ParamValue>) => NeArray<`${string}.${string}.${string}`> | ["*" | `${string}.${string}.${string}`] | readonly ["*"];
90
+ };
91
+ action: {
92
+ multiple: true;
93
+ required: false;
94
+ validate: (value: unknown) => value is "create" | "delete" | "read" | "read_self" | "update";
95
+ default: NeRoArray<SpaceAction>;
96
+ normalize: (value: NeRoArray<import("../lib/syntax.js").ParamValue>) => NeArray<SpaceAction>;
97
+ };
98
+ manage: {
99
+ multiple: true;
100
+ required: false;
101
+ validate: (value: unknown) => value is "create" | "delete" | "update";
102
+ default: NeRoArray<SpaceManageOp>;
103
+ normalize: (value: NeRoArray<import("../lib/syntax.js").ParamValue>) => NeArray<SpaceManageOp>;
104
+ };
105
+ }>;
106
+ static fromString(scope: string): SpacePermission | null;
107
+ static fromSyntax(syntax: ScopeSyntax<'space'>): SpacePermission | null;
108
+ static scopeNeededFor(options: SpacePermissionMatch): string;
109
+ }
110
+ export {};
111
+ //# sourceMappingURL=space-permission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-permission.d.ts","sourceRoot":"","sources":["../../src/scopes/space-permission.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,EAAU,MAAM,gBAAgB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAEvE,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,WAAW,EAEjB,MAAM,kBAAkB,CAAA;AAGzB,eAAO,MAAM,aAAa,8DAMf,CAAA;AACX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAA;AACxD,eAAO,MAAM,aAAa,oFAAsC,CAAA;AAGhE,eAAO,MAAM,qBAAqB,iDAKvB,CAAA;AAEX,eAAO,MAAM,gBAAgB,yCAIlB,CAAA;AACX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAA;AAC7D,eAAO,MAAM,eAAe,6DAAyC,CAAA;AAErE,MAAM,MAAM,cAAc,GAAG,GAAG,GAAG,IAAI,CAAA;AACvC,eAAO,MAAM,gBAAgB,UAAW,OAAO,KAAG,KAAK,IAAI,cAC3B,CAAA;AAEhC,KAAK,SAAS,GAAG,OAAO,MAAM,IAAI,MAAM,EAAE,CAAA;AAG1C,MAAM,MAAM,mBAAmB,GAAG,GAAG,GAAG,MAAM,GAAG,SAAS,CAAA;AAC1D,eAAO,MAAM,qBAAqB,UACzB,OAAO,KACb,KAAK,IAAI,mBAC6C,CAAA;AAGzD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAA;AACnC,eAAO,MAAM,gBAAgB,UAAW,OAAO,KAAG,KAAK,IAAI,cACL,CAAA;AAEtD,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