@cubist-labs/cubesigner-sdk 0.4.201 → 0.4.204

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.
@@ -35,6 +35,36 @@ export type OrgEvents = schemas["OrgEventDiscriminants"];
35
35
  export type BillingEvent = schemas["BillingEvent"];
36
36
  export type OperationKind = schemas["OperationKind"];
37
37
 
38
+ // NOTE:
39
+ // we use `Record<OperationKind, ...>` (instead of `OperationKind[]`) to get
40
+ // the type checker to complain unless this record includes every single operation
41
+ const AllOperationKinds: Record<OperationKind, true> = {
42
+ AvaSign: true,
43
+ AvaChainTxSign: true,
44
+ BabylonCovSign: true,
45
+ BabylonRegistration: true,
46
+ BabylonStaking: true,
47
+ BlobSign: true,
48
+ BtcMessageSign: true,
49
+ BtcSign: true,
50
+ DiffieHellman: true,
51
+ PsbtSign: true,
52
+ TaprootSign: true,
53
+ Eip191Sign: true,
54
+ Eip712Sign: true,
55
+ EotsNonces: true,
56
+ EotsSign: true,
57
+ Eth1Sign: true,
58
+ Eth2Sign: true,
59
+ Eth2Stake: true,
60
+ Eth2Unstake: true,
61
+ SolanaSign: true,
62
+ SuiSign: true,
63
+ TendermintSign: true,
64
+ RoleUpdate: true,
65
+ };
66
+ export const ALL_OPERATION_KINDS = Object.keys(AllOperationKinds) as readonly OperationKind[];
67
+
38
68
  export type OrgData = schemas["OrgData"];
39
69
  export type UserOrgsResponse = schemas["UserOrgsResponse"];
40
70
 
@@ -48,6 +78,7 @@ export type UpdateKeyRequest = schemas["UpdateKeyRequest"];
48
78
  export type KeyProperties = schemas["CreateAndUpdateKeyProperties"];
49
79
  export type CreateKeyRequest = schemas["CreateKeyRequest"];
50
80
  export type KeyInfo = schemas["KeyInfo"];
81
+ export type KeyInfoJwt = schemas["KeyInfoJwt"];
51
82
  export type KeyInRoleInfo = schemas["KeyInRoleInfo"];
52
83
  export type GetUsersInOrgResponse = schemas["PaginatedGetUsersInOrgResponse"];
53
84
  export type GetUserByEmailResponse = schemas["GetUserByEmailResponse"];
@@ -90,7 +121,7 @@ export type Eip191SignRequest = schemas["Eip191SignRequest"];
90
121
  export type Eip712SignRequest = schemas["Eip712SignRequest"];
91
122
  export type Eip191Or712SignResponse = schemas["SignResponse"];
92
123
  export type Eth2SignRequest = schemas["Eth2SignRequest"];
93
- export type Eth2SignResponse = schemas["Eth2SignResponse"];
124
+ export type Eth2SignResponse = schemas["SignResponse"];
94
125
  export type Eth2StakeRequest = schemas["StakeRequest"];
95
126
  export type Eth2StakeResponse = schemas["StakeResponse"];
96
127
  export type Eth2UnstakeRequest = schemas["UnstakeRequest"];
@@ -202,6 +233,7 @@ export type EmailTemplatePurpose = schemas["Purpose"];
202
233
 
203
234
  export type Empty = schemas["EmptyImpl"];
204
235
 
236
+ export type ExplicitScope = schemas["ExplicitScope"];
205
237
  export type Scope = schemas["Scope"];
206
238
 
207
239
  /** Options for a new OIDC user */
package/src/scopes.ts ADDED
@@ -0,0 +1,338 @@
1
+ // eslint-disable spaced-comment
2
+
3
+ import { type ExplicitScope } from ".";
4
+
5
+ export type ScopesDictionary = Record<string, { label: string; scopes: ScopeItem[] }>;
6
+
7
+ export interface ScopeItem {
8
+ value: ExplicitScope;
9
+ description: string;
10
+ children?: ScopeItem[];
11
+ }
12
+
13
+ /** Mapping from scope name to scope description */
14
+ export const AllScopes: Record<ExplicitScope, string> =
15
+ // prettier-ignore
16
+ {
17
+ "sign:*" : "Allows access to all signer endpoints (e.g., sign blob, sign bitcoin/avalanche/evm transaction, etc.)",
18
+ "sign:ava" : "Allows access to the sign 'ava' endpoint",
19
+ "sign:blob" : "Allows access to the sign 'blob' endpoint",
20
+ "sign:diffieHellman" : "Allows access to the Diffie-Hellman endpoint. This is not really signing, but we put it under the `sign` hierarchy because it is conceptually similar.",
21
+ "sign:btc:*" : "Allows access to all BTC endpoints",
22
+ "sign:btc:segwit" : "Allows access to the signing endpoint for segwit transactions",
23
+ "sign:btc:taproot" : "Allows access to the signing endpoint for taproot transactions",
24
+ "sign:btc:psbt:*" : "Allows access to the PSBT signing endpoint for any key type",
25
+ "sign:btc:psbt:doge" : "Allows access to the PSBT signing endpoint for Doge keys",
26
+ "sign:btc:psbt:legacy" : "Allows access to the PSBT signing endpoint for legacy keys",
27
+ "sign:btc:psbt:segwit" : "Allows access to the PSBT signing endpoint for segwit keys",
28
+ "sign:btc:psbt:taproot" : "Allows access to the PSBT signing endpoint for taproot keys",
29
+ "sign:btc:psbt:ltcSegwit" : "Allows access to the PSBT signing endpoint for Litecoin segwit keys",
30
+ "sign:btc:message:*" : "Allows access to the BTC message signing endpoint for any key type",
31
+ "sign:btc:message:segwit" : "Allows access to the BTC message signing endpoint for segwit keys",
32
+ "sign:btc:message:legacy" : "Allows access to the BTC message signing endpoint for legacy keys",
33
+ "sign:babylon:*" : "Allows access to all Babylon endpoints",
34
+ "sign:babylon:eots:*" : "Allows access to all Babylon EOTS endpoints",
35
+ "sign:babylon:eots:nonces" : "Allows access to the EOTS nonce generation endpoint",
36
+ "sign:babylon:eots:sign" : "Allows access to the EOTS signing endpoint",
37
+ "sign:babylon:staking:*" : "Allows access to the signing endpoint for all Babylon staking operations",
38
+ "sign:babylon:staking:deposit" : "Allows access to the signing endpoint for Babylon deposits",
39
+ "sign:babylon:staking:unbond" : "Allows access to the signing endpoint for Babylon unbonding",
40
+ "sign:babylon:staking:withdraw" : "Allows access to the signing endpoint for Babylon withdrawals",
41
+ "sign:babylon:staking:slash" : "Allows access to the signing endpoint for Babylon slashing pre-signatures",
42
+ "sign:babylon:registration" : "Allows access to the signing endpoint for Babylon registration",
43
+ "sign:babylon:covenant" : "Allows access to the signing endpoint for Babylon covenant signing",
44
+ "sign:evm:*" : "Allows access to all sign 'evm' endpoints",
45
+ "sign:evm:tx" : "Allows access to the signing endpoint for evm transactions",
46
+ "sign:evm:eip191" : "Allows access to the signing endpoint for EIP-191 personal_message data",
47
+ "sign:evm:eip712" : "Allows acess to the signing endpoint for EIP-712 typed data",
48
+ "sign:eth2:*" : "Allows access to all sign 'eth2' endpoints",
49
+ "sign:eth2:validate" : "Allows access to the sign eth2 'validate' endpoint",
50
+ "sign:eth2:stake" : "Allows access to the sign eth2 'stake' endpoint",
51
+ "sign:eth2:unstake" : "Allows access to the sign eth2 'unstake' endpoint",
52
+ "sign:solana" : "Allows access to the sign 'solana' endpoint",
53
+ "sign:sui" : "Allows access to the sign 'sui' endpoint",
54
+ "sign:tendermint" : "Allows access to the sign 'tendermint' endpoint",
55
+ "sign:mmi" : "Allows access to the sign 'mmi' endpoint",
56
+ "manage:*" : "Allows access to all management endpoints (e.g., create role, create key, add key to role, etc.)",
57
+ "manage:readonly" : "Allows access to all management readonly endpoints",
58
+ "manage:email" : "Allows access only to the email management endpoints",
59
+ "manage:mfa:*" : "Allows access only to MFA endpoints (e.g., get/approve existing MFA request)",
60
+ "manage:mfa:readonly" : "Allows access only to MFA readonly endpoints (e.g., get/list existing MFA request(s))",
61
+ "manage:mfa:list" : "Allows access only to the MFA list endpoint (list existing MFA requests)",
62
+ "manage:mfa:vote:*" : "Allows access to all MFA vote endpoints (vote using current CubeSigner session, TOTP, or FIDO)",
63
+ "manage:mfa:vote:cs" : "Allows access only to the MFA 'vote with CubeSigner' endpoint",
64
+ "manage:mfa:vote:email" : "Allows access only to the MFA 'vote with email' endpoint",
65
+ "manage:mfa:vote:fido" : "Allows access only to the MFA 'vote with TOTP' endpoint",
66
+ "manage:mfa:vote:totp" : "Allows access only to the MFA 'vote with FIDO' endpoint",
67
+ "manage:mfa:register:*" : "Allows access to all MFA register endpoints",
68
+ "manage:mfa:register:fido" : "Allows access only to the MFA 'register TOTP' endpoint",
69
+ "manage:mfa:register:totp" : "Allows access only to the MFA 'register FIDO' endpoint",
70
+ "manage:mfa:register:email" : "Allows access only to the MFA 'register verified email' endpoint",
71
+ "manage:mfa:unregister:*" : "Allows access to all MFA unregister endpoints",
72
+ "manage:mfa:unregister:fido" : "Allows access only to the MFA 'delete TOTP' endpoint",
73
+ "manage:mfa:unregister:totp" : "Allows access only to the MFA 'delete FIDO' endpoint",
74
+ "manage:mfa:verify:*" : "Allows access to all MFA verify endpoints",
75
+ "manage:mfa:verify:totp" : "Allows access only to the MFA 'verify TOTP' endpoint",
76
+ "manage:key:*" : "Allows access to all key endpoints",
77
+ "manage:key:readonly" : "Allows access to all key readonly endpoints",
78
+ "manage:key:attest" : "Allows access only to the key 'attest' endpoint",
79
+ "manage:key:get" : "Allows access only to the key 'get' endpoint",
80
+ "manage:key:listRoles" : "Allows access only to the key 'listRoles' endpoint",
81
+ "manage:key:list" : "Allows access only to the key 'list' endpoint",
82
+ "manage:key:history:tx:list" : "Allows access only to the key 'list_historical_tx' endpoint",
83
+ "manage:key:create" : "Allows access only to key creation endpoints (e.g., 'create' and 'derive')",
84
+ "manage:key:import" : "Allows access only to the key 'import' endpoint",
85
+ "manage:key:update:*" : "Allows access only to the key 'update' endpoint, within which allowing all possible updates",
86
+ "manage:key:update:owner" : "Allows access only to the key 'update' endpoint, but restricting updates to the key owner property",
87
+ "manage:key:update:policy" : "Allows access only to the key 'update' endpoint, but restricting updates to the key policy property",
88
+ "manage:key:update:enabled" : "Allows access only to the key 'update' endpoint, but restricting updates to the key enabled property",
89
+ "manage:key:update:metadata" : "Allows access only to the key 'update' endpoint and restricts updates to the key metadata property",
90
+ "manage:key:update:editPolicy" : "Allows access only to the key 'update' endpoint and restricts updates to the 'edit_policy' property",
91
+ "manage:key:delete" : "Allows access only to the key 'delete' endpoint",
92
+ "manage:policy:*" : "Allows access to all policy endpoints",
93
+ "manage:policy:create" : "Allows access only to the policy creation endpoint",
94
+ "manage:policy:get" : "Allows access only to the policy 'get' endpoint",
95
+ "manage:policy:list" : "Allows access only to the policy 'list' endpoint",
96
+ "manage:policy:delete" : "Allows access only to the policy `delete` endpoint",
97
+ "manage:policy:update:*" : "Allows access only to the policy 'update' endpoint, within which allowing all possible updates",
98
+ "manage:policy:update:acl" : "Allows access only to the policy 'update' endpoint, but restricting updates to the policy ACL",
99
+ "manage:policy:update:owner" : "Allows access only to the policy 'update' endpoint, but restricting updates to the policy owner property",
100
+ "manage:policy:update:name" : "Allows access only to the policy 'update' endpoint, but restricting updates to the policy name",
101
+ "manage:policy:update:editPolicy" : "Allows access only to the policy 'update' endpoint, but restricting updates to the 'edit_policy' property",
102
+ "manage:policy:update:metadata" : "Allows access only to the policy 'update' endpoint, but restricting updates to the 'metadata' property",
103
+ "manage:policy:update:rule" : "Allows access only to the policy 'update' endpoint, but restricting updates to the policy rule itself",
104
+ "manage:policy:invoke" : "Allows access only to the policy 'invoke' endpoint.",
105
+ "manage:policy:wasm:*" : "Allows access to all wasm policy endpoints",
106
+ "manage:policy:wasm:upload" : "Allows access only to the wasm policy 'upload' endpoint",
107
+ "manage:policy:secrets:*" : "Allows access to all policy secrets endpoints",
108
+ "manage:policy:secrets:get" : "Allows access only to the policy secrets 'get' endpoint",
109
+ "manage:policy:secrets:update:*" : "Allows access to all policy secrets 'update' endpoints",
110
+ "manage:policy:secrets:update:values" : "Allows access only to the policy secrets 'update' endpoint, but restricting updates to the secrets keys and values",
111
+ "manage:policy:secrets:update:editPolicy" : "Allows access only to the policy secrets 'update' endpoint, but restricting updates to the `edit_policy` property",
112
+ "manage:contact:*" : "Allows access to all contact endpoints",
113
+ "manage:contact:create" : "Allows access to the contact 'create' endpoint",
114
+ "manage:contact:get" : "Allows access to the contact `get` endpoint",
115
+ "manage:contact:list" : "Allows access to the contact `list` endpoint",
116
+ "manage:contact:delete" : "Allows access to the contact `delete` endpoint",
117
+ "manage:contact:update:*" : "Allows access only to the contact 'update' endpoint",
118
+ "manage:contact:update:name" : "Allows access only to the contact 'update' endpoint, but restricts updates to the contact's 'name' field.",
119
+ "manage:contact:update:addresses" : "Allows access only to the contact 'update' endpoint, but restricts updates to the contact's 'addresses' field.",
120
+ "manage:contact:update:owner" : "Allows access only to the contact 'update' endpoint, but restricts updates to the contact's 'owner' field.",
121
+ "manage:contact:update:metadata" : "Allows access only to the contact 'update' endpoint, but restricts updates to the contact's 'metadata' field.",
122
+ "manage:contact:update:editPolicy" : "Allows access only to the contact 'update' endpoint, but restricts updates to the contact's 'edit_policy' field.",
123
+ "manage:contact:lookup:*" : "Allows access to the contact `lookup` endpoints",
124
+ "manage:contact:lookup:address" : "Allows access only to the contact 'lookup by address' endpoint",
125
+ "manage:policy:createImportKey" : "Allows access only to the policy key endpoint",
126
+ "manage:role:*" : "Allows access to all role endpoints",
127
+ "manage:role:readonly" : "Allows access to all role readonly endpoints",
128
+ "manage:role:create" : "Allows access only to the role 'create' endpoint",
129
+ "manage:role:delete" : "Allows access only to the role 'delete' endpoint",
130
+ "manage:role:get:*" : "Allows access only to the role 'get' endpoint",
131
+ "manage:role:get:keys" : "Allows access to the role 'list keys' and 'get key' endpoints",
132
+ "manage:role:get:keys:list" : "Allows access to the role 'list keys' endpoint",
133
+ "manage:role:get:keys:get" : "Allows access to the role 'get key' endpoint",
134
+ "manage:role:get:users" : "Allows access to the role 'list users' endpoint",
135
+ "manage:role:list" : "Allows access only to the role 'list' endpoint",
136
+ "manage:role:update:*" : "Allows access only to the role 'update' endpoint",
137
+ "manage:role:update:enabled" : "Allows access only to the role 'update' endpoint, but restricting updates to the role 'enabled' property",
138
+ "manage:role:update:policy" : "Allows access only to the role 'update' endpoint, but restricting updates to the role 'policy' property",
139
+ "manage:role:update:editPolicy" : "Allows access only to the role 'update' endpoint, but restricting updates to the role 'edit_policy' property",
140
+ "manage:role:update:key:*" : "Allows access to all role 'update:key' endpoints",
141
+ "manage:role:update:key:add" : "Allows access to the role 'update:keys:add' endpoint",
142
+ "manage:role:update:key:remove" : "Allows access to the role 'update:keys:remove' endpoint",
143
+ "manage:role:update:user:*" : "Allows access to all role 'update:user' endpoints",
144
+ "manage:role:update:user:add" : "Allows access to the role 'update:user:add' endpoint",
145
+ "manage:role:update:user:remove" : "Allows access to the role 'update:user:remove' endpoint",
146
+ "manage:role:history:tx:list" : "Allows access only to the role 'list_historical_tx' endpoint",
147
+ "manage:identity:*" : "Allows access to all identity endpoints",
148
+ "manage:identity:verify" : "Allows access only to the identity 'verify' endpoint",
149
+ "manage:identity:add" : "Allows access only to the identity 'add' endpoint",
150
+ "manage:identity:remove" : "Allows access only to the identity 'remove' endpoint",
151
+ "manage:identity:list" : "Allows access only to the identity 'list' endpoint",
152
+ "manage:org:*" : "Allows access to all org endpoints",
153
+ "manage:org:create" : "Allows access to the org 'create' endpoint",
154
+ "manage:org:metrics:query" : "Allows access to retrieving org metrics",
155
+ "manage:org:readonly" : "Allows access to all org readonly endpoints",
156
+ "manage:org:addUser" : "Allows access only to the org endpoint for adding an OIDC user to the org",
157
+ "manage:org:inviteUser" : "Allows access only to the org endpoint for inviting a new member or org owner to the org",
158
+ "manage:org:inviteAlien" : "Allows access only to the org endpoint for inviting a new alien user to the org",
159
+ "manage:org:updateMembership" : "Allows access only to the org endpoint for updating existing user's org membership",
160
+ "manage:org:listUsers" : "Allows access only to the org endpoint for listing all org users (members)",
161
+ "manage:org:user:get" : "Allows access only to the org endpoints for getting users by id or email",
162
+ "manage:org:deleteUser" : "Allows access only to the org endpoint for deleting an OIDC user",
163
+ "manage:org:get" : "Allows access to retrieving organization information",
164
+ "manage:org:user:resetMfa" : "Allows an owner to initiate an MFA reset for a user",
165
+ "manage:session:*" : "Allows access to all session endpoints",
166
+ "manage:session:readonly" : "Allows access to all session readonly endpoints",
167
+ "manage:session:get" : "Allows access only to the session 'get' endpoint",
168
+ "manage:session:list" : "Allows access only to the session 'list' endpoint",
169
+ "manage:session:create" : "Allows access only to the session 'create' endpoint, but without the ability to extend session lifetimes",
170
+ "manage:session:extend" : "Allows access only to the session 'create' endpoint, including the ability to extend session lifetimes",
171
+ "manage:session:revoke" : "Allows access only to the session 'revoke' endpoints",
172
+ "manage:export:*" : "Allows access to all export endpoints",
173
+ "manage:export:org:*" : "Allows access to all org-export management endpoints",
174
+ "manage:export:org:get" : "Allows access to the org-export download endpoint",
175
+ "manage:export:user:*" : "Allows access to all user-export management endpoints",
176
+ "manage:export:user:delete" : "Allows deleting an existing user-export request",
177
+ "manage:export:user:list" : "Allows listing existing user-export requests",
178
+ "manage:authMigration:*" : "Allows all auth migration scopes",
179
+ "manage:authMigration:identity:add" : "Allows adding identities to existing users during an auth migration",
180
+ "manage:authMigration:identity:remove" : "Allows removing identities from existing users during an auth migration",
181
+ "manage:authMigration:user:update" : "Allows updating existing users' profiles",
182
+ "manage:mmi:*" : "Allows all CRUD operations on MMI pending messages",
183
+ "manage:mmi:readonly" : "Allows all readonly operations on MMI pending messages",
184
+ "manage:mmi:get" : "Allows retrieving MMI pending messages",
185
+ "manage:mmi:list" : "Allows listing MMI pending messages",
186
+ "manage:mmi:reject" : "Allows rejecting MMI pending messages",
187
+ "manage:mmi:delete" : "Allows deleting MMI pending messages",
188
+ "export:*" : "Allows access to all export endpoints",
189
+ "export:user:*" : "Allows access to all user-export execution endpoints",
190
+ "export:user:init" : "Allows initiating a new user-export request",
191
+ "export:user:complete" : "Allows completing an existing user-export request",
192
+ "mmi:*" : "Allows calls to the MMI endpoint",
193
+ "orgAccess:*" : "Allows access to certain orgs other than the current session's",
194
+ "orgAccess:child:*" : "Allows a session to be used for access to orgs transitively parented by the session's org.",
195
+ };
196
+
197
+ // Const for scope category labels
198
+ const CATEGORY_LABELS: Record<string, string> = {
199
+ sign: "Sign",
200
+ manage: "Manage",
201
+ export: "Export",
202
+ mmi: "MMI",
203
+ orgAccess: "Org Access",
204
+ };
205
+
206
+ /**
207
+ * Finds the parent scope for a given scope.
208
+ * A parent is a scope ending with '*' that is a prefix of the current scope.
209
+ *
210
+ * @param scope The scope to find the parent for.
211
+ * @param allScopes The list of all scopes.
212
+ * @returns The parent scope or null if no parent is found.
213
+ */
214
+ function findParent(scope: ExplicitScope, allScopes: ExplicitScope[]): ExplicitScope | null {
215
+ for (const candidate of allScopes) {
216
+ if (candidate.endsWith("*") && scope.startsWith(candidate.slice(0, -1))) {
217
+ return candidate;
218
+ }
219
+ }
220
+ return null;
221
+ }
222
+
223
+ /**
224
+ * Computes the scopes dictionary from AllScopes.
225
+ *
226
+ * @returns The complete dictionary of all available scopes organized by category.
227
+ */
228
+ function computeScopesDictionary(): ScopesDictionary {
229
+ const allScopes = Object.keys(AllScopes) as ExplicitScope[];
230
+ const items = new Map<ExplicitScope, ScopeItem>();
231
+ const result: ScopesDictionary = {};
232
+
233
+ // First pass: create all items
234
+ for (const scope of allScopes) {
235
+ const category = scope.split(":")[0];
236
+ if (!result[category]) {
237
+ result[category] = { label: CATEGORY_LABELS[category] || category, scopes: [] };
238
+ }
239
+
240
+ items.set(scope, {
241
+ value: scope,
242
+ description: AllScopes[scope],
243
+ children: [],
244
+ });
245
+ }
246
+
247
+ // Second pass: build parent-child relationships
248
+ for (const scope of allScopes) {
249
+ const category = scope.split(":")[0];
250
+ const item = items.get(scope)!;
251
+ const parentScope = findParent(scope, allScopes);
252
+
253
+ if (parentScope && parentScope !== scope) {
254
+ items.get(parentScope)!.children!.push(item);
255
+ } else {
256
+ result[category].scopes.push(item);
257
+ }
258
+ }
259
+
260
+ // Sort roots: wildcards first
261
+ for (const category of Object.values(result)) {
262
+ category.scopes.sort((a, b) => {
263
+ if (a.value.endsWith("*") && !b.value.endsWith("*")) return -1;
264
+ if (!a.value.endsWith("*") && b.value.endsWith("*")) return 1;
265
+ return a.value.localeCompare(b.value);
266
+ });
267
+ }
268
+
269
+ return result;
270
+ }
271
+
272
+ /**
273
+ * Complete dictionary of all available scopes organized by category.
274
+ *
275
+ * This dictionary is automatically computed from {@link AllScopes} by inferring
276
+ * the hierarchy from scope names. A scope's parent is determined by finding a
277
+ * scope ending with '*' that is a prefix of the current scope.
278
+ *
279
+ * The dictionary is organized into the following categories:
280
+ * - `sign`: Scopes for signing operations (blob, transactions, etc.)
281
+ * - `manage`: Scopes for management operations (keys, roles, policies, etc.)
282
+ * - `export`: Scopes for export operations
283
+ * - `mmi`: Scopes for MetaMask Integration
284
+ * - `orgAccess`: Scopes for cross-organization access
285
+ *
286
+ * This dictionary serves as the source of truth for scope definitions and is used
287
+ * to generate scopes for role and user sessions. It is also referenced by
288
+ * {@link roleScopesDictionary} and {@link userScopesDictionary} which provide
289
+ * filtered subsets of these scopes.
290
+ *
291
+ * @see {@link AllScopes} - The source record containing scope descriptions
292
+ * @see {@link roleScopesDictionary} - Restricted scopes for role sessions
293
+ * @see {@link userScopesDictionary} - Restricted scopes for user sessions
294
+ */
295
+ export const allScopesDictionary: ScopesDictionary = computeScopesDictionary();
296
+
297
+ /**
298
+ * Restricted scopes dictionary for role-based session generation.
299
+ * Contains only the scopes that are allowed for role sessions.
300
+ */
301
+ export const roleScopesDictionary = {
302
+ sign: allScopesDictionary.sign,
303
+ mmi: allScopesDictionary.mmi,
304
+ manage: {
305
+ label: "Manage",
306
+ scopes: [
307
+ // Find and include manage:mmi:*
308
+ (allScopesDictionary.manage.scopes as ScopeItem[])
309
+ .find((s) => s.value === "manage:*")!
310
+ .children!.find((s) => s.value === "manage:mmi:*")!,
311
+ // Find and include manage:mfa:list
312
+ (allScopesDictionary.manage.scopes as ScopeItem[])
313
+ .find((s) => s.value === "manage:*")!
314
+ .children!.find((s) => s.value === "manage:mfa:*")!
315
+ .children!.find((s) => s.value === "manage:mfa:list")!,
316
+ // Find and include manage:key:get
317
+ (allScopesDictionary.manage.scopes as ScopeItem[])
318
+ .find((s) => s.value === "manage:*")!
319
+ .children!.find((s) => s.value === "manage:key:*")!
320
+ .children!.find((s) => s.value === "manage:key:get")!,
321
+ // Find and include manage:key:list
322
+ (allScopesDictionary.manage.scopes as ScopeItem[])
323
+ .find((s) => s.value === "manage:*")!
324
+ .children!.find((s) => s.value === "manage:key:*")!
325
+ .children!.find((s) => s.value === "manage:key:list")!,
326
+ ],
327
+ },
328
+ } satisfies ScopesDictionary;
329
+
330
+ /**
331
+ * Restricted scopes dictionary for user session generation.
332
+ * Excludes scopes that require elevated permissions (orgAccess, export).
333
+ */
334
+ export const userScopesDictionary = {
335
+ manage: allScopesDictionary.manage,
336
+ sign: allScopesDictionary.sign,
337
+ mmi: allScopesDictionary.mmi,
338
+ };