@metamask/permission-controller 13.1.0 → 14.0.0

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 (116) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/LICENSE +1 -0
  3. package/dist/{Caveat.d.mts → Caveat.d.ts} +3 -3
  4. package/dist/Caveat.d.ts.map +1 -0
  5. package/dist/{Caveat.mjs → Caveat.js} +4 -4
  6. package/dist/Caveat.js.map +1 -0
  7. package/dist/{Permission.d.mts → Permission.d.ts} +7 -7
  8. package/dist/Permission.d.ts.map +1 -0
  9. package/dist/{Permission.mjs → Permission.js} +2 -2
  10. package/dist/Permission.js.map +1 -0
  11. package/dist/{PermissionController-method-action-types.d.cts → PermissionController-method-action-types.d.ts} +2 -2
  12. package/dist/PermissionController-method-action-types.d.ts.map +1 -0
  13. package/dist/{PermissionController-method-action-types.mjs → PermissionController-method-action-types.js} +1 -1
  14. package/dist/PermissionController-method-action-types.js.map +1 -0
  15. package/dist/{PermissionController.d.cts → PermissionController.d.ts} +11 -11
  16. package/dist/PermissionController.d.ts.map +1 -0
  17. package/dist/PermissionController.js +1533 -0
  18. package/dist/PermissionController.js.map +1 -0
  19. package/dist/{SubjectMetadataController-method-action-types.d.cts → SubjectMetadataController-method-action-types.d.ts} +2 -2
  20. package/dist/SubjectMetadataController-method-action-types.d.ts.map +1 -0
  21. package/dist/{SubjectMetadataController-method-action-types.mjs → SubjectMetadataController-method-action-types.js} +1 -1
  22. package/dist/SubjectMetadataController-method-action-types.js.map +1 -0
  23. package/dist/{SubjectMetadataController.d.cts → SubjectMetadataController.d.ts} +8 -8
  24. package/dist/SubjectMetadataController.d.ts.map +1 -0
  25. package/dist/SubjectMetadataController.js +157 -0
  26. package/dist/SubjectMetadataController.js.map +1 -0
  27. package/dist/{createRestrictedMethodMessenger.d.cts → createRestrictedMethodMessenger.d.ts} +3 -3
  28. package/dist/createRestrictedMethodMessenger.d.ts.map +1 -0
  29. package/dist/{createRestrictedMethodMessenger.mjs → createRestrictedMethodMessenger.js} +2 -2
  30. package/dist/createRestrictedMethodMessenger.js.map +1 -0
  31. package/dist/{errors.d.mts → errors.d.ts} +6 -6
  32. package/dist/errors.d.ts.map +1 -0
  33. package/dist/{errors.mjs → errors.js} +17 -3
  34. package/dist/errors.js.map +1 -0
  35. package/dist/{index.d.cts → index.d.ts} +12 -12
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +9 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/{permission-middleware.d.cts → permission-middleware.d.ts} +7 -7
  40. package/dist/permission-middleware.d.ts.map +1 -0
  41. package/dist/{permission-middleware.mjs → permission-middleware.js} +2 -2
  42. package/dist/permission-middleware.js.map +1 -0
  43. package/dist/{utils.d.cts → utils.d.ts} +3 -3
  44. package/dist/utils.d.ts.map +1 -0
  45. package/dist/{utils.mjs → utils.js} +1 -1
  46. package/dist/utils.js.map +1 -0
  47. package/package.json +25 -27
  48. package/dist/Caveat.cjs +0 -48
  49. package/dist/Caveat.cjs.map +0 -1
  50. package/dist/Caveat.d.cts +0 -211
  51. package/dist/Caveat.d.cts.map +0 -1
  52. package/dist/Caveat.d.mts.map +0 -1
  53. package/dist/Caveat.mjs.map +0 -1
  54. package/dist/Permission.cjs +0 -65
  55. package/dist/Permission.cjs.map +0 -1
  56. package/dist/Permission.d.cts +0 -415
  57. package/dist/Permission.d.cts.map +0 -1
  58. package/dist/Permission.d.mts.map +0 -1
  59. package/dist/Permission.mjs.map +0 -1
  60. package/dist/PermissionController-method-action-types.cjs +0 -7
  61. package/dist/PermissionController-method-action-types.cjs.map +0 -1
  62. package/dist/PermissionController-method-action-types.d.cts.map +0 -1
  63. package/dist/PermissionController-method-action-types.d.mts +0 -374
  64. package/dist/PermissionController-method-action-types.d.mts.map +0 -1
  65. package/dist/PermissionController-method-action-types.mjs.map +0 -1
  66. package/dist/PermissionController.cjs +0 -1257
  67. package/dist/PermissionController.cjs.map +0 -1
  68. package/dist/PermissionController.d.cts.map +0 -1
  69. package/dist/PermissionController.d.mts +0 -753
  70. package/dist/PermissionController.d.mts.map +0 -1
  71. package/dist/PermissionController.mjs +0 -1257
  72. package/dist/PermissionController.mjs.map +0 -1
  73. package/dist/SubjectMetadataController-method-action-types.cjs +0 -7
  74. package/dist/SubjectMetadataController-method-action-types.cjs.map +0 -1
  75. package/dist/SubjectMetadataController-method-action-types.d.cts.map +0 -1
  76. package/dist/SubjectMetadataController-method-action-types.d.mts +0 -51
  77. package/dist/SubjectMetadataController-method-action-types.d.mts.map +0 -1
  78. package/dist/SubjectMetadataController-method-action-types.mjs.map +0 -1
  79. package/dist/SubjectMetadataController.cjs +0 -158
  80. package/dist/SubjectMetadataController.cjs.map +0 -1
  81. package/dist/SubjectMetadataController.d.cts.map +0 -1
  82. package/dist/SubjectMetadataController.d.mts +0 -104
  83. package/dist/SubjectMetadataController.d.mts.map +0 -1
  84. package/dist/SubjectMetadataController.mjs +0 -154
  85. package/dist/SubjectMetadataController.mjs.map +0 -1
  86. package/dist/createRestrictedMethodMessenger.cjs +0 -20
  87. package/dist/createRestrictedMethodMessenger.cjs.map +0 -1
  88. package/dist/createRestrictedMethodMessenger.d.cts.map +0 -1
  89. package/dist/createRestrictedMethodMessenger.d.mts +0 -42
  90. package/dist/createRestrictedMethodMessenger.d.mts.map +0 -1
  91. package/dist/createRestrictedMethodMessenger.mjs.map +0 -1
  92. package/dist/errors.cjs +0 -226
  93. package/dist/errors.cjs.map +0 -1
  94. package/dist/errors.d.cts +0 -183
  95. package/dist/errors.d.cts.map +0 -1
  96. package/dist/errors.d.mts.map +0 -1
  97. package/dist/errors.mjs.map +0 -1
  98. package/dist/index.cjs +0 -30
  99. package/dist/index.cjs.map +0 -1
  100. package/dist/index.d.cts.map +0 -1
  101. package/dist/index.d.mts +0 -12
  102. package/dist/index.d.mts.map +0 -1
  103. package/dist/index.mjs +0 -9
  104. package/dist/index.mjs.map +0 -1
  105. package/dist/permission-middleware.cjs +0 -59
  106. package/dist/permission-middleware.cjs.map +0 -1
  107. package/dist/permission-middleware.d.cts.map +0 -1
  108. package/dist/permission-middleware.d.mts +0 -49
  109. package/dist/permission-middleware.d.mts.map +0 -1
  110. package/dist/permission-middleware.mjs.map +0 -1
  111. package/dist/utils.cjs +0 -44
  112. package/dist/utils.cjs.map +0 -1
  113. package/dist/utils.d.cts.map +0 -1
  114. package/dist/utils.d.mts +0 -34
  115. package/dist/utils.d.mts.map +0 -1
  116. package/dist/utils.mjs.map +0 -1
@@ -1,374 +0,0 @@
1
- /**
2
- * This file is auto generated.
3
- * Do not edit manually.
4
- */
5
- import type { PermissionController } from "./PermissionController.mjs";
6
- /**
7
- * Checks whether the given method was declared as unrestricted at
8
- * construction time. Methods unknown to the controller return `false` and
9
- * would be treated as restricted by callers such as the permission
10
- * middleware.
11
- *
12
- * @param method - The name of the method to check.
13
- * @returns Whether the method is unrestricted.
14
- */
15
- export type PermissionControllerHasUnrestrictedMethodAction = {
16
- type: `PermissionController:hasUnrestrictedMethod`;
17
- handler: PermissionController['hasUnrestrictedMethod'];
18
- };
19
- /**
20
- * Clears the state of the controller.
21
- */
22
- export type PermissionControllerClearStateAction = {
23
- type: `PermissionController:clearState`;
24
- handler: PermissionController['clearState'];
25
- };
26
- /**
27
- * Gets a list of all origins of subjects.
28
- *
29
- * @returns The origins (i.e. IDs) of all subjects.
30
- */
31
- export type PermissionControllerGetSubjectNamesAction = {
32
- type: `PermissionController:getSubjectNames`;
33
- handler: PermissionController['getSubjectNames'];
34
- };
35
- /**
36
- * Gets the permission for the specified target of the subject corresponding
37
- * to the specified origin.
38
- *
39
- * @param origin - The origin of the subject.
40
- * @param targetName - The method name as invoked by a third party (i.e., not
41
- * a method key).
42
- * @returns The permission if it exists, or undefined otherwise.
43
- */
44
- export type PermissionControllerGetPermissionAction = {
45
- type: `PermissionController:getPermission`;
46
- handler: PermissionController['getPermission'];
47
- };
48
- /**
49
- * Gets all permissions for the specified subject, if any.
50
- *
51
- * @param origin - The origin of the subject.
52
- * @returns The permissions of the subject, if any.
53
- */
54
- export type PermissionControllerGetPermissionsAction = {
55
- type: `PermissionController:getPermissions`;
56
- handler: PermissionController['getPermissions'];
57
- };
58
- /**
59
- * Checks whether the subject with the specified origin has the specified
60
- * permission.
61
- *
62
- * @param origin - The origin of the subject.
63
- * @param target - The target name of the permission.
64
- * @returns Whether the subject has the permission.
65
- */
66
- export type PermissionControllerHasPermissionAction = {
67
- type: `PermissionController:hasPermission`;
68
- handler: PermissionController['hasPermission'];
69
- };
70
- /**
71
- * Checks whether the subject with the specified origin has any permissions.
72
- * Use this if you want to know if a subject "exists".
73
- *
74
- * @param origin - The origin of the subject to check.
75
- * @returns Whether the subject has any permissions.
76
- */
77
- export type PermissionControllerHasPermissionsAction = {
78
- type: `PermissionController:hasPermissions`;
79
- handler: PermissionController['hasPermissions'];
80
- };
81
- /**
82
- * Revokes all permissions from the specified origin.
83
- *
84
- * Throws an error if the origin has no permissions.
85
- *
86
- * @param origin - The origin whose permissions to revoke.
87
- */
88
- export type PermissionControllerRevokeAllPermissionsAction = {
89
- type: `PermissionController:revokeAllPermissions`;
90
- handler: PermissionController['revokeAllPermissions'];
91
- };
92
- /**
93
- * Revokes the specified permission from the subject with the specified
94
- * origin.
95
- *
96
- * Throws an error if the subject or the permission does not exist.
97
- *
98
- * @param origin - The origin of the subject whose permission to revoke.
99
- * @param target - The target name of the permission to revoke.
100
- */
101
- export type PermissionControllerRevokePermissionAction = {
102
- type: `PermissionController:revokePermission`;
103
- handler: PermissionController['revokePermission'];
104
- };
105
- /**
106
- * Revokes the specified permissions from the specified subjects.
107
- *
108
- * Throws an error if any of the subjects or permissions do not exist.
109
- *
110
- * @param subjectsAndPermissions - An object mapping subject origins
111
- * to arrays of permission target names to revoke.
112
- */
113
- export type PermissionControllerRevokePermissionsAction = {
114
- type: `PermissionController:revokePermissions`;
115
- handler: PermissionController['revokePermissions'];
116
- };
117
- /**
118
- * Revokes all permissions corresponding to the specified target for all subjects.
119
- * Does nothing if no subjects or no such permission exists.
120
- *
121
- * @param target - The name of the target to revoke all permissions for.
122
- */
123
- export type PermissionControllerRevokePermissionForAllSubjectsAction = {
124
- type: `PermissionController:revokePermissionForAllSubjects`;
125
- handler: PermissionController['revokePermissionForAllSubjects'];
126
- };
127
- /**
128
- * Gets the caveat of the specified type, if any, for the permission of
129
- * the subject corresponding to the given origin.
130
- *
131
- * Throws an error if the subject does not have a permission with the
132
- * specified target name.
133
- *
134
- * @template TargetName - The permission target name. Should be inferred.
135
- * @template CaveatType - The valid caveat types for the permission. Should
136
- * be inferred.
137
- * @param origin - The origin of the subject.
138
- * @param target - The target name of the permission.
139
- * @param caveatType - The type of the caveat to get.
140
- * @returns The caveat, or `undefined` if no such caveat exists.
141
- */
142
- export type PermissionControllerGetCaveatAction = {
143
- type: `PermissionController:getCaveat`;
144
- handler: PermissionController['getCaveat'];
145
- };
146
- /**
147
- * Updates the value of the caveat of the specified type belonging to the
148
- * permission corresponding to the given subject origin and permission
149
- * target.
150
- *
151
- * For adding new caveats, use
152
- * {@link PermissionController.addCaveat}.
153
- *
154
- * Throws an error if no such permission or caveat exists.
155
- *
156
- * @template TargetName - The permission target name. Should be inferred.
157
- * @template CaveatType - The valid caveat types for the permission. Should
158
- * be inferred.
159
- * @param origin - The origin of the subject.
160
- * @param target - The target name of the permission.
161
- * @param caveatType - The type of the caveat to update.
162
- * @param caveatValue - The new value of the caveat.
163
- */
164
- export type PermissionControllerUpdateCaveatAction = {
165
- type: `PermissionController:updateCaveat`;
166
- handler: PermissionController['updateCaveat'];
167
- };
168
- /**
169
- * Updates all caveats with the specified type for all subjects and
170
- * permissions by applying the specified mutator function to them.
171
- *
172
- * ATTN: Permissions can be revoked entirely by the action of this method,
173
- * read on for details.
174
- *
175
- * Caveat mutators are functions that receive a caveat value and return a
176
- * tuple consisting of a {@link CaveatMutatorOperation} and, optionally, a new
177
- * value to update the existing caveat with.
178
- *
179
- * For each caveat, depending on the mutator result, this method will:
180
- * - Do nothing ({@link CaveatMutatorOperation.Noop})
181
- * - Update the value of the caveat ({@link CaveatMutatorOperation.UpdateValue}). The caveat specification validator, if any, will be called after updating the value.
182
- * - Delete the caveat ({@link CaveatMutatorOperation.DeleteCaveat}). The permission specification validator, if any, will be called after deleting the caveat.
183
- * - Revoke the parent permission ({@link CaveatMutatorOperation.RevokePermission})
184
- *
185
- * This method throws if the validation of any caveat or permission fails.
186
- *
187
- * @param targetCaveatType - The type of the caveats to update.
188
- * @param mutator - The mutator function which will be applied to all caveat
189
- * values.
190
- */
191
- export type PermissionControllerUpdatePermissionsByCaveatAction = {
192
- type: `PermissionController:updatePermissionsByCaveat`;
193
- handler: PermissionController['updatePermissionsByCaveat'];
194
- };
195
- /**
196
- * Grants _approved_ permissions to the specified subject. Every permission and
197
- * caveat is stringently validated—including by calling their specification
198
- * validators—and an error is thrown if validation fails.
199
- *
200
- * ATTN: This method does **not** prompt the user for approval. User consent must
201
- * first be obtained through some other means.
202
- *
203
- * @see {@link PermissionController.requestPermissions} For initiating a
204
- * permissions request requiring user approval.
205
- * @param options - Options bag.
206
- * @param options.approvedPermissions - The requested permissions approved by
207
- * the user.
208
- * @param options.requestData - Permission request data. Passed to permission
209
- * factory functions.
210
- * @param options.preserveExistingPermissions - Whether to preserve the
211
- * subject's existing permissions.
212
- * @param options.subject - The subject to grant permissions to.
213
- * @returns The subject's new permission state. It may or may not have changed.
214
- */
215
- export type PermissionControllerGrantPermissionsAction = {
216
- type: `PermissionController:grantPermissions`;
217
- handler: PermissionController['grantPermissions'];
218
- };
219
- /**
220
- * Incrementally grants _approved_ permissions to the specified subject. Every
221
- * permission and caveat is stringently validated—including by calling their
222
- * specification validators—and an error is thrown if validation fails.
223
- *
224
- * ATTN: This method does **not** prompt the user for approval. User consent must
225
- * first be obtained through some other means.
226
- *
227
- * @see {@link PermissionController.requestPermissionsIncremental} For initiating
228
- * an incremental permissions request requiring user approval.
229
- * @param options - Options bag.
230
- * @param options.approvedPermissions - The requested permissions approved by
231
- * the user.
232
- * @param options.requestData - Permission request data. Passed to permission
233
- * factory functions.
234
- * @param options.subject - The subject to grant permissions to.
235
- * @returns The subject's new permission state. It may or may not have changed.
236
- */
237
- export type PermissionControllerGrantPermissionsIncrementalAction = {
238
- type: `PermissionController:grantPermissionsIncremental`;
239
- handler: PermissionController['grantPermissionsIncremental'];
240
- };
241
- /**
242
- * Initiates a permission request that requires user approval.
243
- *
244
- * Either this or {@link PermissionController.requestPermissionsIncremental}
245
- * should always be used to grant additional permissions to a subject,
246
- * unless user approval has been obtained through some other means.
247
- *
248
- * Permissions are validated at every step of the approval process, and this
249
- * method will reject if validation fails.
250
- *
251
- * @see {@link ApprovalController} For the user approval logic.
252
- * @see {@link PermissionController.acceptPermissionsRequest} For the method
253
- * that _accepts_ the request and resolves the user approval promise.
254
- * @see {@link PermissionController.rejectPermissionsRequest} For the method
255
- * that _rejects_ the request and the user approval promise.
256
- * @param subject - The grantee subject.
257
- * @param requestedPermissions - The requested permissions.
258
- * @param options - Additional options.
259
- * @param options.id - The id of the permissions request. Defaults to a unique
260
- * id.
261
- * @param options.preserveExistingPermissions - Whether to preserve the
262
- * subject's existing permissions. Defaults to `true`.
263
- * @param options.metadata - Additional metadata about the permission request.
264
- * @returns The granted permissions and request metadata.
265
- */
266
- export type PermissionControllerRequestPermissionsAction = {
267
- type: `PermissionController:requestPermissions`;
268
- handler: PermissionController['requestPermissions'];
269
- };
270
- /**
271
- * Initiates an incremental permission request that prompts for user approval.
272
- * Incremental permission requests allow the caller to replace existing and/or
273
- * add brand new permissions and caveats for the specified subject.
274
- *
275
- * Incremental permission request are merged with the subject's existing permissions
276
- * through a right-biased union, where the incremental permission are the right-hand
277
- * side of the merger. If both sides of the merger specify the same caveats for a
278
- * given permission, the caveats are merged using their specification's caveat value
279
- * merger property.
280
- *
281
- * Either this or {@link PermissionController.requestPermissions} should
282
- * always be used to grant additional permissions to a subject, unless user
283
- * approval has been obtained through some other means.
284
- *
285
- * Permissions are validated at every step of the approval process, and this
286
- * method will reject if validation fails.
287
- *
288
- * @see {@link ApprovalController} For the user approval logic.
289
- * @see {@link PermissionController.acceptPermissionsRequest} For the method
290
- * that _accepts_ the request and resolves the user approval promise.
291
- * @see {@link PermissionController.rejectPermissionsRequest} For the method
292
- * that _rejects_ the request and the user approval promise.
293
- * @param subject - The grantee subject.
294
- * @param requestedPermissions - The requested permissions.
295
- * @param options - Additional options.
296
- * @param options.id - The id of the permissions request. Defaults to a unique
297
- * id.
298
- * @param options.metadata - Additional metadata about the permission request.
299
- * @returns The granted permissions and request metadata.
300
- */
301
- export type PermissionControllerRequestPermissionsIncrementalAction = {
302
- type: `PermissionController:requestPermissionsIncremental`;
303
- handler: PermissionController['requestPermissionsIncremental'];
304
- };
305
- /**
306
- * Accepts a permissions request created by
307
- * {@link PermissionController.requestPermissions}.
308
- *
309
- * @param request - The permissions request.
310
- */
311
- export type PermissionControllerAcceptPermissionsRequestAction = {
312
- type: `PermissionController:acceptPermissionsRequest`;
313
- handler: PermissionController['acceptPermissionsRequest'];
314
- };
315
- /**
316
- * Rejects a permissions request created by
317
- * {@link PermissionController.requestPermissions}.
318
- *
319
- * @param id - The id of the request to be rejected.
320
- */
321
- export type PermissionControllerRejectPermissionsRequestAction = {
322
- type: `PermissionController:rejectPermissionsRequest`;
323
- handler: PermissionController['rejectPermissionsRequest'];
324
- };
325
- /**
326
- * Gets the subject's endowments per the specified endowment permission.
327
- * Throws if the subject does not have the required permission or if the
328
- * permission is not an endowment permission.
329
- *
330
- * @param origin - The origin of the subject whose endowments to retrieve.
331
- * @param targetName - The name of the endowment permission. This must be a
332
- * valid permission target name.
333
- * @param requestData - Additional data associated with the request, if any.
334
- * Forwarded to the endowment getter function for the permission.
335
- * @returns The endowments, if any.
336
- */
337
- export type PermissionControllerGetEndowmentsAction = {
338
- type: `PermissionController:getEndowments`;
339
- handler: PermissionController['getEndowments'];
340
- };
341
- /**
342
- * Executes a restricted method as the subject with the given origin.
343
- * The specified params, if any, will be passed to the method implementation.
344
- *
345
- * ATTN: Great caution should be exercised in the use of this method.
346
- * Methods that cause side effects or affect application state should
347
- * be avoided.
348
- *
349
- * This method will first attempt to retrieve the requested restricted method
350
- * implementation, throwing if it does not exist. The method will then be
351
- * invoked as though the subject with the specified origin had invoked it with
352
- * the specified parameters. This means that any existing caveats will be
353
- * applied to the restricted method, and this method will throw if the
354
- * restricted method or its caveat decorators throw.
355
- *
356
- * In addition, this method will throw if the subject does not have a
357
- * permission for the specified restricted method.
358
- *
359
- * @param origin - The origin of the subject to execute the method on behalf
360
- * of.
361
- * @param targetName - The name of the method to execute. This must be a valid
362
- * permission target name.
363
- * @param params - The parameters to pass to the method implementation.
364
- * @returns The result of the executed method.
365
- */
366
- export type PermissionControllerExecuteRestrictedMethodAction = {
367
- type: `PermissionController:executeRestrictedMethod`;
368
- handler: PermissionController['executeRestrictedMethod'];
369
- };
370
- /**
371
- * Union of all PermissionController action types.
372
- */
373
- export type PermissionControllerMethodActions = PermissionControllerHasUnrestrictedMethodAction | PermissionControllerClearStateAction | PermissionControllerGetSubjectNamesAction | PermissionControllerGetPermissionAction | PermissionControllerGetPermissionsAction | PermissionControllerHasPermissionAction | PermissionControllerHasPermissionsAction | PermissionControllerRevokeAllPermissionsAction | PermissionControllerRevokePermissionAction | PermissionControllerRevokePermissionsAction | PermissionControllerRevokePermissionForAllSubjectsAction | PermissionControllerGetCaveatAction | PermissionControllerUpdateCaveatAction | PermissionControllerUpdatePermissionsByCaveatAction | PermissionControllerGrantPermissionsAction | PermissionControllerGrantPermissionsIncrementalAction | PermissionControllerRequestPermissionsAction | PermissionControllerRequestPermissionsIncrementalAction | PermissionControllerAcceptPermissionsRequestAction | PermissionControllerRejectPermissionsRequestAction | PermissionControllerGetEndowmentsAction | PermissionControllerExecuteRestrictedMethodAction;
374
- //# sourceMappingURL=PermissionController-method-action-types.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PermissionController-method-action-types.d.mts","sourceRoot":"","sources":["../src/PermissionController-method-action-types.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GACnC,sCAAsC,GACtC,mDAAmD,GACnD,0CAA0C,GAC1C,qDAAqD,GACrD,4CAA4C,GAC5C,uDAAuD,GACvD,kDAAkD,GAClD,kDAAkD,GAClD,uCAAuC,GACvC,iDAAiD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PermissionController-method-action-types.mjs","sourceRoot":"","sources":["../src/PermissionController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { PermissionController } from './PermissionController';\n\n/**\n * Checks whether the given method was declared as unrestricted at\n * construction time. Methods unknown to the controller return `false` and\n * would be treated as restricted by callers such as the permission\n * middleware.\n *\n * @param method - The name of the method to check.\n * @returns Whether the method is unrestricted.\n */\nexport type PermissionControllerHasUnrestrictedMethodAction = {\n type: `PermissionController:hasUnrestrictedMethod`;\n handler: PermissionController['hasUnrestrictedMethod'];\n};\n\n/**\n * Clears the state of the controller.\n */\nexport type PermissionControllerClearStateAction = {\n type: `PermissionController:clearState`;\n handler: PermissionController['clearState'];\n};\n\n/**\n * Gets a list of all origins of subjects.\n *\n * @returns The origins (i.e. IDs) of all subjects.\n */\nexport type PermissionControllerGetSubjectNamesAction = {\n type: `PermissionController:getSubjectNames`;\n handler: PermissionController['getSubjectNames'];\n};\n\n/**\n * Gets the permission for the specified target of the subject corresponding\n * to the specified origin.\n *\n * @param origin - The origin of the subject.\n * @param targetName - The method name as invoked by a third party (i.e., not\n * a method key).\n * @returns The permission if it exists, or undefined otherwise.\n */\nexport type PermissionControllerGetPermissionAction = {\n type: `PermissionController:getPermission`;\n handler: PermissionController['getPermission'];\n};\n\n/**\n * Gets all permissions for the specified subject, if any.\n *\n * @param origin - The origin of the subject.\n * @returns The permissions of the subject, if any.\n */\nexport type PermissionControllerGetPermissionsAction = {\n type: `PermissionController:getPermissions`;\n handler: PermissionController['getPermissions'];\n};\n\n/**\n * Checks whether the subject with the specified origin has the specified\n * permission.\n *\n * @param origin - The origin of the subject.\n * @param target - The target name of the permission.\n * @returns Whether the subject has the permission.\n */\nexport type PermissionControllerHasPermissionAction = {\n type: `PermissionController:hasPermission`;\n handler: PermissionController['hasPermission'];\n};\n\n/**\n * Checks whether the subject with the specified origin has any permissions.\n * Use this if you want to know if a subject \"exists\".\n *\n * @param origin - The origin of the subject to check.\n * @returns Whether the subject has any permissions.\n */\nexport type PermissionControllerHasPermissionsAction = {\n type: `PermissionController:hasPermissions`;\n handler: PermissionController['hasPermissions'];\n};\n\n/**\n * Revokes all permissions from the specified origin.\n *\n * Throws an error if the origin has no permissions.\n *\n * @param origin - The origin whose permissions to revoke.\n */\nexport type PermissionControllerRevokeAllPermissionsAction = {\n type: `PermissionController:revokeAllPermissions`;\n handler: PermissionController['revokeAllPermissions'];\n};\n\n/**\n * Revokes the specified permission from the subject with the specified\n * origin.\n *\n * Throws an error if the subject or the permission does not exist.\n *\n * @param origin - The origin of the subject whose permission to revoke.\n * @param target - The target name of the permission to revoke.\n */\nexport type PermissionControllerRevokePermissionAction = {\n type: `PermissionController:revokePermission`;\n handler: PermissionController['revokePermission'];\n};\n\n/**\n * Revokes the specified permissions from the specified subjects.\n *\n * Throws an error if any of the subjects or permissions do not exist.\n *\n * @param subjectsAndPermissions - An object mapping subject origins\n * to arrays of permission target names to revoke.\n */\nexport type PermissionControllerRevokePermissionsAction = {\n type: `PermissionController:revokePermissions`;\n handler: PermissionController['revokePermissions'];\n};\n\n/**\n * Revokes all permissions corresponding to the specified target for all subjects.\n * Does nothing if no subjects or no such permission exists.\n *\n * @param target - The name of the target to revoke all permissions for.\n */\nexport type PermissionControllerRevokePermissionForAllSubjectsAction = {\n type: `PermissionController:revokePermissionForAllSubjects`;\n handler: PermissionController['revokePermissionForAllSubjects'];\n};\n\n/**\n * Gets the caveat of the specified type, if any, for the permission of\n * the subject corresponding to the given origin.\n *\n * Throws an error if the subject does not have a permission with the\n * specified target name.\n *\n * @template TargetName - The permission target name. Should be inferred.\n * @template CaveatType - The valid caveat types for the permission. Should\n * be inferred.\n * @param origin - The origin of the subject.\n * @param target - The target name of the permission.\n * @param caveatType - The type of the caveat to get.\n * @returns The caveat, or `undefined` if no such caveat exists.\n */\nexport type PermissionControllerGetCaveatAction = {\n type: `PermissionController:getCaveat`;\n handler: PermissionController['getCaveat'];\n};\n\n/**\n * Updates the value of the caveat of the specified type belonging to the\n * permission corresponding to the given subject origin and permission\n * target.\n *\n * For adding new caveats, use\n * {@link PermissionController.addCaveat}.\n *\n * Throws an error if no such permission or caveat exists.\n *\n * @template TargetName - The permission target name. Should be inferred.\n * @template CaveatType - The valid caveat types for the permission. Should\n * be inferred.\n * @param origin - The origin of the subject.\n * @param target - The target name of the permission.\n * @param caveatType - The type of the caveat to update.\n * @param caveatValue - The new value of the caveat.\n */\nexport type PermissionControllerUpdateCaveatAction = {\n type: `PermissionController:updateCaveat`;\n handler: PermissionController['updateCaveat'];\n};\n\n/**\n * Updates all caveats with the specified type for all subjects and\n * permissions by applying the specified mutator function to them.\n *\n * ATTN: Permissions can be revoked entirely by the action of this method,\n * read on for details.\n *\n * Caveat mutators are functions that receive a caveat value and return a\n * tuple consisting of a {@link CaveatMutatorOperation} and, optionally, a new\n * value to update the existing caveat with.\n *\n * For each caveat, depending on the mutator result, this method will:\n * - Do nothing ({@link CaveatMutatorOperation.Noop})\n * - Update the value of the caveat ({@link CaveatMutatorOperation.UpdateValue}). The caveat specification validator, if any, will be called after updating the value.\n * - Delete the caveat ({@link CaveatMutatorOperation.DeleteCaveat}). The permission specification validator, if any, will be called after deleting the caveat.\n * - Revoke the parent permission ({@link CaveatMutatorOperation.RevokePermission})\n *\n * This method throws if the validation of any caveat or permission fails.\n *\n * @param targetCaveatType - The type of the caveats to update.\n * @param mutator - The mutator function which will be applied to all caveat\n * values.\n */\nexport type PermissionControllerUpdatePermissionsByCaveatAction = {\n type: `PermissionController:updatePermissionsByCaveat`;\n handler: PermissionController['updatePermissionsByCaveat'];\n};\n\n/**\n * Grants _approved_ permissions to the specified subject. Every permission and\n * caveat is stringently validated—including by calling their specification\n * validators—and an error is thrown if validation fails.\n *\n * ATTN: This method does **not** prompt the user for approval. User consent must\n * first be obtained through some other means.\n *\n * @see {@link PermissionController.requestPermissions} For initiating a\n * permissions request requiring user approval.\n * @param options - Options bag.\n * @param options.approvedPermissions - The requested permissions approved by\n * the user.\n * @param options.requestData - Permission request data. Passed to permission\n * factory functions.\n * @param options.preserveExistingPermissions - Whether to preserve the\n * subject's existing permissions.\n * @param options.subject - The subject to grant permissions to.\n * @returns The subject's new permission state. It may or may not have changed.\n */\nexport type PermissionControllerGrantPermissionsAction = {\n type: `PermissionController:grantPermissions`;\n handler: PermissionController['grantPermissions'];\n};\n\n/**\n * Incrementally grants _approved_ permissions to the specified subject. Every\n * permission and caveat is stringently validated—including by calling their\n * specification validators—and an error is thrown if validation fails.\n *\n * ATTN: This method does **not** prompt the user for approval. User consent must\n * first be obtained through some other means.\n *\n * @see {@link PermissionController.requestPermissionsIncremental} For initiating\n * an incremental permissions request requiring user approval.\n * @param options - Options bag.\n * @param options.approvedPermissions - The requested permissions approved by\n * the user.\n * @param options.requestData - Permission request data. Passed to permission\n * factory functions.\n * @param options.subject - The subject to grant permissions to.\n * @returns The subject's new permission state. It may or may not have changed.\n */\nexport type PermissionControllerGrantPermissionsIncrementalAction = {\n type: `PermissionController:grantPermissionsIncremental`;\n handler: PermissionController['grantPermissionsIncremental'];\n};\n\n/**\n * Initiates a permission request that requires user approval.\n *\n * Either this or {@link PermissionController.requestPermissionsIncremental}\n * should always be used to grant additional permissions to a subject,\n * unless user approval has been obtained through some other means.\n *\n * Permissions are validated at every step of the approval process, and this\n * method will reject if validation fails.\n *\n * @see {@link ApprovalController} For the user approval logic.\n * @see {@link PermissionController.acceptPermissionsRequest} For the method\n * that _accepts_ the request and resolves the user approval promise.\n * @see {@link PermissionController.rejectPermissionsRequest} For the method\n * that _rejects_ the request and the user approval promise.\n * @param subject - The grantee subject.\n * @param requestedPermissions - The requested permissions.\n * @param options - Additional options.\n * @param options.id - The id of the permissions request. Defaults to a unique\n * id.\n * @param options.preserveExistingPermissions - Whether to preserve the\n * subject's existing permissions. Defaults to `true`.\n * @param options.metadata - Additional metadata about the permission request.\n * @returns The granted permissions and request metadata.\n */\nexport type PermissionControllerRequestPermissionsAction = {\n type: `PermissionController:requestPermissions`;\n handler: PermissionController['requestPermissions'];\n};\n\n/**\n * Initiates an incremental permission request that prompts for user approval.\n * Incremental permission requests allow the caller to replace existing and/or\n * add brand new permissions and caveats for the specified subject.\n *\n * Incremental permission request are merged with the subject's existing permissions\n * through a right-biased union, where the incremental permission are the right-hand\n * side of the merger. If both sides of the merger specify the same caveats for a\n * given permission, the caveats are merged using their specification's caveat value\n * merger property.\n *\n * Either this or {@link PermissionController.requestPermissions} should\n * always be used to grant additional permissions to a subject, unless user\n * approval has been obtained through some other means.\n *\n * Permissions are validated at every step of the approval process, and this\n * method will reject if validation fails.\n *\n * @see {@link ApprovalController} For the user approval logic.\n * @see {@link PermissionController.acceptPermissionsRequest} For the method\n * that _accepts_ the request and resolves the user approval promise.\n * @see {@link PermissionController.rejectPermissionsRequest} For the method\n * that _rejects_ the request and the user approval promise.\n * @param subject - The grantee subject.\n * @param requestedPermissions - The requested permissions.\n * @param options - Additional options.\n * @param options.id - The id of the permissions request. Defaults to a unique\n * id.\n * @param options.metadata - Additional metadata about the permission request.\n * @returns The granted permissions and request metadata.\n */\nexport type PermissionControllerRequestPermissionsIncrementalAction = {\n type: `PermissionController:requestPermissionsIncremental`;\n handler: PermissionController['requestPermissionsIncremental'];\n};\n\n/**\n * Accepts a permissions request created by\n * {@link PermissionController.requestPermissions}.\n *\n * @param request - The permissions request.\n */\nexport type PermissionControllerAcceptPermissionsRequestAction = {\n type: `PermissionController:acceptPermissionsRequest`;\n handler: PermissionController['acceptPermissionsRequest'];\n};\n\n/**\n * Rejects a permissions request created by\n * {@link PermissionController.requestPermissions}.\n *\n * @param id - The id of the request to be rejected.\n */\nexport type PermissionControllerRejectPermissionsRequestAction = {\n type: `PermissionController:rejectPermissionsRequest`;\n handler: PermissionController['rejectPermissionsRequest'];\n};\n\n/**\n * Gets the subject's endowments per the specified endowment permission.\n * Throws if the subject does not have the required permission or if the\n * permission is not an endowment permission.\n *\n * @param origin - The origin of the subject whose endowments to retrieve.\n * @param targetName - The name of the endowment permission. This must be a\n * valid permission target name.\n * @param requestData - Additional data associated with the request, if any.\n * Forwarded to the endowment getter function for the permission.\n * @returns The endowments, if any.\n */\nexport type PermissionControllerGetEndowmentsAction = {\n type: `PermissionController:getEndowments`;\n handler: PermissionController['getEndowments'];\n};\n\n/**\n * Executes a restricted method as the subject with the given origin.\n * The specified params, if any, will be passed to the method implementation.\n *\n * ATTN: Great caution should be exercised in the use of this method.\n * Methods that cause side effects or affect application state should\n * be avoided.\n *\n * This method will first attempt to retrieve the requested restricted method\n * implementation, throwing if it does not exist. The method will then be\n * invoked as though the subject with the specified origin had invoked it with\n * the specified parameters. This means that any existing caveats will be\n * applied to the restricted method, and this method will throw if the\n * restricted method or its caveat decorators throw.\n *\n * In addition, this method will throw if the subject does not have a\n * permission for the specified restricted method.\n *\n * @param origin - The origin of the subject to execute the method on behalf\n * of.\n * @param targetName - The name of the method to execute. This must be a valid\n * permission target name.\n * @param params - The parameters to pass to the method implementation.\n * @returns The result of the executed method.\n */\nexport type PermissionControllerExecuteRestrictedMethodAction = {\n type: `PermissionController:executeRestrictedMethod`;\n handler: PermissionController['executeRestrictedMethod'];\n};\n\n/**\n * Union of all PermissionController action types.\n */\nexport type PermissionControllerMethodActions =\n | PermissionControllerHasUnrestrictedMethodAction\n | PermissionControllerClearStateAction\n | PermissionControllerGetSubjectNamesAction\n | PermissionControllerGetPermissionAction\n | PermissionControllerGetPermissionsAction\n | PermissionControllerHasPermissionAction\n | PermissionControllerHasPermissionsAction\n | PermissionControllerRevokeAllPermissionsAction\n | PermissionControllerRevokePermissionAction\n | PermissionControllerRevokePermissionsAction\n | PermissionControllerRevokePermissionForAllSubjectsAction\n | PermissionControllerGetCaveatAction\n | PermissionControllerUpdateCaveatAction\n | PermissionControllerUpdatePermissionsByCaveatAction\n | PermissionControllerGrantPermissionsAction\n | PermissionControllerGrantPermissionsIncrementalAction\n | PermissionControllerRequestPermissionsAction\n | PermissionControllerRequestPermissionsIncrementalAction\n | PermissionControllerAcceptPermissionsRequestAction\n | PermissionControllerRejectPermissionsRequestAction\n | PermissionControllerGetEndowmentsAction\n | PermissionControllerExecuteRestrictedMethodAction;\n"]}