@metamask/permission-controller 12.2.1 → 13.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 (102) hide show
  1. package/CHANGELOG.md +85 -6
  2. package/dist/Permission.cjs.map +1 -1
  3. package/dist/Permission.d.cts +9 -15
  4. package/dist/Permission.d.cts.map +1 -1
  5. package/dist/Permission.d.mts +9 -15
  6. package/dist/Permission.d.mts.map +1 -1
  7. package/dist/Permission.mjs.map +1 -1
  8. package/dist/PermissionController-method-action-types.cjs +7 -0
  9. package/dist/PermissionController-method-action-types.cjs.map +1 -0
  10. package/dist/PermissionController-method-action-types.d.cts +301 -0
  11. package/dist/PermissionController-method-action-types.d.cts.map +1 -0
  12. package/dist/PermissionController-method-action-types.d.mts +301 -0
  13. package/dist/PermissionController-method-action-types.d.mts.map +1 -0
  14. package/dist/PermissionController-method-action-types.mjs +6 -0
  15. package/dist/PermissionController-method-action-types.mjs.map +1 -0
  16. package/dist/PermissionController.cjs +41 -45
  17. package/dist/PermissionController.cjs.map +1 -1
  18. package/dist/PermissionController.d.cts +59 -33
  19. package/dist/PermissionController.d.cts.map +1 -1
  20. package/dist/PermissionController.d.mts +59 -33
  21. package/dist/PermissionController.d.mts.map +1 -1
  22. package/dist/PermissionController.mjs +41 -45
  23. package/dist/PermissionController.mjs.map +1 -1
  24. package/dist/SubjectMetadataController-method-action-types.cjs +7 -0
  25. package/dist/SubjectMetadataController-method-action-types.cjs.map +1 -0
  26. package/dist/SubjectMetadataController-method-action-types.d.cts +51 -0
  27. package/dist/SubjectMetadataController-method-action-types.d.cts.map +1 -0
  28. package/dist/SubjectMetadataController-method-action-types.d.mts +51 -0
  29. package/dist/SubjectMetadataController-method-action-types.d.mts.map +1 -0
  30. package/dist/SubjectMetadataController-method-action-types.mjs +6 -0
  31. package/dist/SubjectMetadataController-method-action-types.mjs.map +1 -0
  32. package/dist/SubjectMetadataController.cjs +7 -2
  33. package/dist/SubjectMetadataController.cjs.map +1 -1
  34. package/dist/SubjectMetadataController.d.cts +16 -4
  35. package/dist/SubjectMetadataController.d.cts.map +1 -1
  36. package/dist/SubjectMetadataController.d.mts +16 -4
  37. package/dist/SubjectMetadataController.d.mts.map +1 -1
  38. package/dist/SubjectMetadataController.mjs +7 -2
  39. package/dist/SubjectMetadataController.mjs.map +1 -1
  40. package/dist/createRestrictedMethodMessenger.cjs +20 -0
  41. package/dist/createRestrictedMethodMessenger.cjs.map +1 -0
  42. package/dist/createRestrictedMethodMessenger.d.cts +42 -0
  43. package/dist/createRestrictedMethodMessenger.d.cts.map +1 -0
  44. package/dist/createRestrictedMethodMessenger.d.mts +42 -0
  45. package/dist/createRestrictedMethodMessenger.d.mts.map +1 -0
  46. package/dist/createRestrictedMethodMessenger.mjs +16 -0
  47. package/dist/createRestrictedMethodMessenger.mjs.map +1 -0
  48. package/dist/index.cjs +6 -14
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +5 -2
  51. package/dist/index.d.cts.map +1 -1
  52. package/dist/index.d.mts +5 -2
  53. package/dist/index.d.mts.map +1 -1
  54. package/dist/index.mjs +2 -1
  55. package/dist/index.mjs.map +1 -1
  56. package/dist/permission-middleware.cjs +47 -43
  57. package/dist/permission-middleware.cjs.map +1 -1
  58. package/dist/permission-middleware.d.cts +40 -25
  59. package/dist/permission-middleware.d.cts.map +1 -1
  60. package/dist/permission-middleware.d.mts +40 -25
  61. package/dist/permission-middleware.d.mts.map +1 -1
  62. package/dist/permission-middleware.mjs +44 -41
  63. package/dist/permission-middleware.mjs.map +1 -1
  64. package/dist/utils.cjs.map +1 -1
  65. package/dist/utils.d.cts +0 -23
  66. package/dist/utils.d.cts.map +1 -1
  67. package/dist/utils.d.mts +0 -23
  68. package/dist/utils.d.mts.map +1 -1
  69. package/dist/utils.mjs.map +1 -1
  70. package/package.json +22 -19
  71. package/dist/rpc-methods/getPermissions.cjs +0 -27
  72. package/dist/rpc-methods/getPermissions.cjs.map +0 -1
  73. package/dist/rpc-methods/getPermissions.d.cts +0 -9
  74. package/dist/rpc-methods/getPermissions.d.cts.map +0 -1
  75. package/dist/rpc-methods/getPermissions.d.mts +0 -9
  76. package/dist/rpc-methods/getPermissions.d.mts.map +0 -1
  77. package/dist/rpc-methods/getPermissions.mjs +0 -24
  78. package/dist/rpc-methods/getPermissions.mjs.map +0 -1
  79. package/dist/rpc-methods/index.cjs +0 -12
  80. package/dist/rpc-methods/index.cjs.map +0 -1
  81. package/dist/rpc-methods/index.d.cts +0 -6
  82. package/dist/rpc-methods/index.d.cts.map +0 -1
  83. package/dist/rpc-methods/index.d.mts +0 -6
  84. package/dist/rpc-methods/index.d.mts.map +0 -1
  85. package/dist/rpc-methods/index.mjs +0 -9
  86. package/dist/rpc-methods/index.mjs.map +0 -1
  87. package/dist/rpc-methods/requestPermissions.cjs +0 -36
  88. package/dist/rpc-methods/requestPermissions.cjs.map +0 -1
  89. package/dist/rpc-methods/requestPermissions.d.cts +0 -17
  90. package/dist/rpc-methods/requestPermissions.d.cts.map +0 -1
  91. package/dist/rpc-methods/requestPermissions.d.mts +0 -17
  92. package/dist/rpc-methods/requestPermissions.d.mts.map +0 -1
  93. package/dist/rpc-methods/requestPermissions.mjs +0 -33
  94. package/dist/rpc-methods/requestPermissions.mjs.map +0 -1
  95. package/dist/rpc-methods/revokePermissions.cjs +0 -41
  96. package/dist/rpc-methods/revokePermissions.cjs.map +0 -1
  97. package/dist/rpc-methods/revokePermissions.d.cts +0 -11
  98. package/dist/rpc-methods/revokePermissions.d.cts.map +0 -1
  99. package/dist/rpc-methods/revokePermissions.d.mts +0 -11
  100. package/dist/rpc-methods/revokePermissions.d.mts.map +0 -1
  101. package/dist/rpc-methods/revokePermissions.mjs +0 -38
  102. package/dist/rpc-methods/revokePermissions.mjs.map +0 -1
@@ -0,0 +1,301 @@
1
+ /**
2
+ * This file is auto generated.
3
+ * Do not edit manually.
4
+ */
5
+ import type { PermissionController } from "./PermissionController.cjs";
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 all permissions for the specified subject, if any.
37
+ *
38
+ * @param origin - The origin of the subject.
39
+ * @returns The permissions of the subject, if any.
40
+ */
41
+ export type PermissionControllerGetPermissionsAction = {
42
+ type: `PermissionController:getPermissions`;
43
+ handler: PermissionController['getPermissions'];
44
+ };
45
+ /**
46
+ * Checks whether the subject with the specified origin has the specified
47
+ * permission.
48
+ *
49
+ * @param origin - The origin of the subject.
50
+ * @param target - The target name of the permission.
51
+ * @returns Whether the subject has the permission.
52
+ */
53
+ export type PermissionControllerHasPermissionAction = {
54
+ type: `PermissionController:hasPermission`;
55
+ handler: PermissionController['hasPermission'];
56
+ };
57
+ /**
58
+ * Checks whether the subject with the specified origin has any permissions.
59
+ * Use this if you want to know if a subject "exists".
60
+ *
61
+ * @param origin - The origin of the subject to check.
62
+ * @returns Whether the subject has any permissions.
63
+ */
64
+ export type PermissionControllerHasPermissionsAction = {
65
+ type: `PermissionController:hasPermissions`;
66
+ handler: PermissionController['hasPermissions'];
67
+ };
68
+ /**
69
+ * Revokes all permissions from the specified origin.
70
+ *
71
+ * Throws an error if the origin has no permissions.
72
+ *
73
+ * @param origin - The origin whose permissions to revoke.
74
+ */
75
+ export type PermissionControllerRevokeAllPermissionsAction = {
76
+ type: `PermissionController:revokeAllPermissions`;
77
+ handler: PermissionController['revokeAllPermissions'];
78
+ };
79
+ /**
80
+ * Revokes the specified permissions from the specified subjects.
81
+ *
82
+ * Throws an error if any of the subjects or permissions do not exist.
83
+ *
84
+ * @param subjectsAndPermissions - An object mapping subject origins
85
+ * to arrays of permission target names to revoke.
86
+ */
87
+ export type PermissionControllerRevokePermissionsAction = {
88
+ type: `PermissionController:revokePermissions`;
89
+ handler: PermissionController['revokePermissions'];
90
+ };
91
+ /**
92
+ * Revokes all permissions corresponding to the specified target for all subjects.
93
+ * Does nothing if no subjects or no such permission exists.
94
+ *
95
+ * @param target - The name of the target to revoke all permissions for.
96
+ */
97
+ export type PermissionControllerRevokePermissionForAllSubjectsAction = {
98
+ type: `PermissionController:revokePermissionForAllSubjects`;
99
+ handler: PermissionController['revokePermissionForAllSubjects'];
100
+ };
101
+ /**
102
+ * Gets the caveat of the specified type, if any, for the permission of
103
+ * the subject corresponding to the given origin.
104
+ *
105
+ * Throws an error if the subject does not have a permission with the
106
+ * specified target name.
107
+ *
108
+ * @template TargetName - The permission target name. Should be inferred.
109
+ * @template CaveatType - The valid caveat types for the permission. Should
110
+ * be inferred.
111
+ * @param origin - The origin of the subject.
112
+ * @param target - The target name of the permission.
113
+ * @param caveatType - The type of the caveat to get.
114
+ * @returns The caveat, or `undefined` if no such caveat exists.
115
+ */
116
+ export type PermissionControllerGetCaveatAction = {
117
+ type: `PermissionController:getCaveat`;
118
+ handler: PermissionController['getCaveat'];
119
+ };
120
+ /**
121
+ * Updates the value of the caveat of the specified type belonging to the
122
+ * permission corresponding to the given subject origin and permission
123
+ * target.
124
+ *
125
+ * For adding new caveats, use
126
+ * {@link PermissionController.addCaveat}.
127
+ *
128
+ * Throws an error if no such permission or caveat exists.
129
+ *
130
+ * @template TargetName - The permission target name. Should be inferred.
131
+ * @template CaveatType - The valid caveat types for the permission. Should
132
+ * be inferred.
133
+ * @param origin - The origin of the subject.
134
+ * @param target - The target name of the permission.
135
+ * @param caveatType - The type of the caveat to update.
136
+ * @param caveatValue - The new value of the caveat.
137
+ */
138
+ export type PermissionControllerUpdateCaveatAction = {
139
+ type: `PermissionController:updateCaveat`;
140
+ handler: PermissionController['updateCaveat'];
141
+ };
142
+ /**
143
+ * Grants _approved_ permissions to the specified subject. Every permission and
144
+ * caveat is stringently validated—including by calling their specification
145
+ * validators—and an error is thrown if validation fails.
146
+ *
147
+ * ATTN: This method does **not** prompt the user for approval. User consent must
148
+ * first be obtained through some other means.
149
+ *
150
+ * @see {@link PermissionController.requestPermissions} For initiating a
151
+ * permissions request requiring user approval.
152
+ * @param options - Options bag.
153
+ * @param options.approvedPermissions - The requested permissions approved by
154
+ * the user.
155
+ * @param options.requestData - Permission request data. Passed to permission
156
+ * factory functions.
157
+ * @param options.preserveExistingPermissions - Whether to preserve the
158
+ * subject's existing permissions.
159
+ * @param options.subject - The subject to grant permissions to.
160
+ * @returns The subject's new permission state. It may or may not have changed.
161
+ */
162
+ export type PermissionControllerGrantPermissionsAction = {
163
+ type: `PermissionController:grantPermissions`;
164
+ handler: PermissionController['grantPermissions'];
165
+ };
166
+ /**
167
+ * Incrementally grants _approved_ permissions to the specified subject. Every
168
+ * permission and caveat is stringently validated—including by calling their
169
+ * specification validators—and an error is thrown if validation fails.
170
+ *
171
+ * ATTN: This method does **not** prompt the user for approval. User consent must
172
+ * first be obtained through some other means.
173
+ *
174
+ * @see {@link PermissionController.requestPermissionsIncremental} For initiating
175
+ * an incremental permissions request requiring user approval.
176
+ * @param options - Options bag.
177
+ * @param options.approvedPermissions - The requested permissions approved by
178
+ * the user.
179
+ * @param options.requestData - Permission request data. Passed to permission
180
+ * factory functions.
181
+ * @param options.subject - The subject to grant permissions to.
182
+ * @returns The subject's new permission state. It may or may not have changed.
183
+ */
184
+ export type PermissionControllerGrantPermissionsIncrementalAction = {
185
+ type: `PermissionController:grantPermissionsIncremental`;
186
+ handler: PermissionController['grantPermissionsIncremental'];
187
+ };
188
+ /**
189
+ * Initiates a permission request that requires user approval.
190
+ *
191
+ * Either this or {@link PermissionController.requestPermissionsIncremental}
192
+ * should always be used to grant additional permissions to a subject,
193
+ * unless user approval has been obtained through some other means.
194
+ *
195
+ * Permissions are validated at every step of the approval process, and this
196
+ * method will reject if validation fails.
197
+ *
198
+ * @see {@link ApprovalController} For the user approval logic.
199
+ * @see {@link PermissionController.acceptPermissionsRequest} For the method
200
+ * that _accepts_ the request and resolves the user approval promise.
201
+ * @see {@link PermissionController.rejectPermissionsRequest} For the method
202
+ * that _rejects_ the request and the user approval promise.
203
+ * @param subject - The grantee subject.
204
+ * @param requestedPermissions - The requested permissions.
205
+ * @param options - Additional options.
206
+ * @param options.id - The id of the permissions request. Defaults to a unique
207
+ * id.
208
+ * @param options.preserveExistingPermissions - Whether to preserve the
209
+ * subject's existing permissions. Defaults to `true`.
210
+ * @param options.metadata - Additional metadata about the permission request.
211
+ * @returns The granted permissions and request metadata.
212
+ */
213
+ export type PermissionControllerRequestPermissionsAction = {
214
+ type: `PermissionController:requestPermissions`;
215
+ handler: PermissionController['requestPermissions'];
216
+ };
217
+ /**
218
+ * Initiates an incremental permission request that prompts for user approval.
219
+ * Incremental permission requests allow the caller to replace existing and/or
220
+ * add brand new permissions and caveats for the specified subject.
221
+ *
222
+ * Incremental permission request are merged with the subject's existing permissions
223
+ * through a right-biased union, where the incremental permission are the right-hand
224
+ * side of the merger. If both sides of the merger specify the same caveats for a
225
+ * given permission, the caveats are merged using their specification's caveat value
226
+ * merger property.
227
+ *
228
+ * Either this or {@link PermissionController.requestPermissions} should
229
+ * always be used to grant additional permissions to a subject, unless user
230
+ * approval has been obtained through some other means.
231
+ *
232
+ * Permissions are validated at every step of the approval process, and this
233
+ * method will reject if validation fails.
234
+ *
235
+ * @see {@link ApprovalController} For the user approval logic.
236
+ * @see {@link PermissionController.acceptPermissionsRequest} For the method
237
+ * that _accepts_ the request and resolves the user approval promise.
238
+ * @see {@link PermissionController.rejectPermissionsRequest} For the method
239
+ * that _rejects_ the request and the user approval promise.
240
+ * @param subject - The grantee subject.
241
+ * @param requestedPermissions - The requested permissions.
242
+ * @param options - Additional options.
243
+ * @param options.id - The id of the permissions request. Defaults to a unique
244
+ * id.
245
+ * @param options.metadata - Additional metadata about the permission request.
246
+ * @returns The granted permissions and request metadata.
247
+ */
248
+ export type PermissionControllerRequestPermissionsIncrementalAction = {
249
+ type: `PermissionController:requestPermissionsIncremental`;
250
+ handler: PermissionController['requestPermissionsIncremental'];
251
+ };
252
+ /**
253
+ * Gets the subject's endowments per the specified endowment permission.
254
+ * Throws if the subject does not have the required permission or if the
255
+ * permission is not an endowment permission.
256
+ *
257
+ * @param origin - The origin of the subject whose endowments to retrieve.
258
+ * @param targetName - The name of the endowment permission. This must be a
259
+ * valid permission target name.
260
+ * @param requestData - Additional data associated with the request, if any.
261
+ * Forwarded to the endowment getter function for the permission.
262
+ * @returns The endowments, if any.
263
+ */
264
+ export type PermissionControllerGetEndowmentsAction = {
265
+ type: `PermissionController:getEndowments`;
266
+ handler: PermissionController['getEndowments'];
267
+ };
268
+ /**
269
+ * Executes a restricted method as the subject with the given origin.
270
+ * The specified params, if any, will be passed to the method implementation.
271
+ *
272
+ * ATTN: Great caution should be exercised in the use of this method.
273
+ * Methods that cause side effects or affect application state should
274
+ * be avoided.
275
+ *
276
+ * This method will first attempt to retrieve the requested restricted method
277
+ * implementation, throwing if it does not exist. The method will then be
278
+ * invoked as though the subject with the specified origin had invoked it with
279
+ * the specified parameters. This means that any existing caveats will be
280
+ * applied to the restricted method, and this method will throw if the
281
+ * restricted method or its caveat decorators throw.
282
+ *
283
+ * In addition, this method will throw if the subject does not have a
284
+ * permission for the specified restricted method.
285
+ *
286
+ * @param origin - The origin of the subject to execute the method on behalf
287
+ * of.
288
+ * @param targetName - The name of the method to execute. This must be a valid
289
+ * permission target name.
290
+ * @param params - The parameters to pass to the method implementation.
291
+ * @returns The result of the executed method.
292
+ */
293
+ export type PermissionControllerExecuteRestrictedMethodAction = {
294
+ type: `PermissionController:executeRestrictedMethod`;
295
+ handler: PermissionController['executeRestrictedMethod'];
296
+ };
297
+ /**
298
+ * Union of all PermissionController action types.
299
+ */
300
+ export type PermissionControllerMethodActions = PermissionControllerHasUnrestrictedMethodAction | PermissionControllerClearStateAction | PermissionControllerGetSubjectNamesAction | PermissionControllerGetPermissionsAction | PermissionControllerHasPermissionAction | PermissionControllerHasPermissionsAction | PermissionControllerRevokeAllPermissionsAction | PermissionControllerRevokePermissionsAction | PermissionControllerRevokePermissionForAllSubjectsAction | PermissionControllerGetCaveatAction | PermissionControllerUpdateCaveatAction | PermissionControllerGrantPermissionsAction | PermissionControllerGrantPermissionsIncrementalAction | PermissionControllerRequestPermissionsAction | PermissionControllerRequestPermissionsIncrementalAction | PermissionControllerGetEndowmentsAction | PermissionControllerExecuteRestrictedMethodAction;
301
+ //# sourceMappingURL=PermissionController-method-action-types.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PermissionController-method-action-types.d.cts","sourceRoot":"","sources":["../src/PermissionController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,mCAA+B;AAEnE;;;;;;;;GAQG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;CACxD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,oBAAoB,CAAC,YAAY,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,oBAAoB,CAAC,iBAAiB,CAAC,CAAC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C,uDAAuD,GACvD,uCAAuC,GACvC,iDAAiD,CAAC"}
@@ -0,0 +1,301 @@
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 all permissions for the specified subject, if any.
37
+ *
38
+ * @param origin - The origin of the subject.
39
+ * @returns The permissions of the subject, if any.
40
+ */
41
+ export type PermissionControllerGetPermissionsAction = {
42
+ type: `PermissionController:getPermissions`;
43
+ handler: PermissionController['getPermissions'];
44
+ };
45
+ /**
46
+ * Checks whether the subject with the specified origin has the specified
47
+ * permission.
48
+ *
49
+ * @param origin - The origin of the subject.
50
+ * @param target - The target name of the permission.
51
+ * @returns Whether the subject has the permission.
52
+ */
53
+ export type PermissionControllerHasPermissionAction = {
54
+ type: `PermissionController:hasPermission`;
55
+ handler: PermissionController['hasPermission'];
56
+ };
57
+ /**
58
+ * Checks whether the subject with the specified origin has any permissions.
59
+ * Use this if you want to know if a subject "exists".
60
+ *
61
+ * @param origin - The origin of the subject to check.
62
+ * @returns Whether the subject has any permissions.
63
+ */
64
+ export type PermissionControllerHasPermissionsAction = {
65
+ type: `PermissionController:hasPermissions`;
66
+ handler: PermissionController['hasPermissions'];
67
+ };
68
+ /**
69
+ * Revokes all permissions from the specified origin.
70
+ *
71
+ * Throws an error if the origin has no permissions.
72
+ *
73
+ * @param origin - The origin whose permissions to revoke.
74
+ */
75
+ export type PermissionControllerRevokeAllPermissionsAction = {
76
+ type: `PermissionController:revokeAllPermissions`;
77
+ handler: PermissionController['revokeAllPermissions'];
78
+ };
79
+ /**
80
+ * Revokes the specified permissions from the specified subjects.
81
+ *
82
+ * Throws an error if any of the subjects or permissions do not exist.
83
+ *
84
+ * @param subjectsAndPermissions - An object mapping subject origins
85
+ * to arrays of permission target names to revoke.
86
+ */
87
+ export type PermissionControllerRevokePermissionsAction = {
88
+ type: `PermissionController:revokePermissions`;
89
+ handler: PermissionController['revokePermissions'];
90
+ };
91
+ /**
92
+ * Revokes all permissions corresponding to the specified target for all subjects.
93
+ * Does nothing if no subjects or no such permission exists.
94
+ *
95
+ * @param target - The name of the target to revoke all permissions for.
96
+ */
97
+ export type PermissionControllerRevokePermissionForAllSubjectsAction = {
98
+ type: `PermissionController:revokePermissionForAllSubjects`;
99
+ handler: PermissionController['revokePermissionForAllSubjects'];
100
+ };
101
+ /**
102
+ * Gets the caveat of the specified type, if any, for the permission of
103
+ * the subject corresponding to the given origin.
104
+ *
105
+ * Throws an error if the subject does not have a permission with the
106
+ * specified target name.
107
+ *
108
+ * @template TargetName - The permission target name. Should be inferred.
109
+ * @template CaveatType - The valid caveat types for the permission. Should
110
+ * be inferred.
111
+ * @param origin - The origin of the subject.
112
+ * @param target - The target name of the permission.
113
+ * @param caveatType - The type of the caveat to get.
114
+ * @returns The caveat, or `undefined` if no such caveat exists.
115
+ */
116
+ export type PermissionControllerGetCaveatAction = {
117
+ type: `PermissionController:getCaveat`;
118
+ handler: PermissionController['getCaveat'];
119
+ };
120
+ /**
121
+ * Updates the value of the caveat of the specified type belonging to the
122
+ * permission corresponding to the given subject origin and permission
123
+ * target.
124
+ *
125
+ * For adding new caveats, use
126
+ * {@link PermissionController.addCaveat}.
127
+ *
128
+ * Throws an error if no such permission or caveat exists.
129
+ *
130
+ * @template TargetName - The permission target name. Should be inferred.
131
+ * @template CaveatType - The valid caveat types for the permission. Should
132
+ * be inferred.
133
+ * @param origin - The origin of the subject.
134
+ * @param target - The target name of the permission.
135
+ * @param caveatType - The type of the caveat to update.
136
+ * @param caveatValue - The new value of the caveat.
137
+ */
138
+ export type PermissionControllerUpdateCaveatAction = {
139
+ type: `PermissionController:updateCaveat`;
140
+ handler: PermissionController['updateCaveat'];
141
+ };
142
+ /**
143
+ * Grants _approved_ permissions to the specified subject. Every permission and
144
+ * caveat is stringently validated—including by calling their specification
145
+ * validators—and an error is thrown if validation fails.
146
+ *
147
+ * ATTN: This method does **not** prompt the user for approval. User consent must
148
+ * first be obtained through some other means.
149
+ *
150
+ * @see {@link PermissionController.requestPermissions} For initiating a
151
+ * permissions request requiring user approval.
152
+ * @param options - Options bag.
153
+ * @param options.approvedPermissions - The requested permissions approved by
154
+ * the user.
155
+ * @param options.requestData - Permission request data. Passed to permission
156
+ * factory functions.
157
+ * @param options.preserveExistingPermissions - Whether to preserve the
158
+ * subject's existing permissions.
159
+ * @param options.subject - The subject to grant permissions to.
160
+ * @returns The subject's new permission state. It may or may not have changed.
161
+ */
162
+ export type PermissionControllerGrantPermissionsAction = {
163
+ type: `PermissionController:grantPermissions`;
164
+ handler: PermissionController['grantPermissions'];
165
+ };
166
+ /**
167
+ * Incrementally grants _approved_ permissions to the specified subject. Every
168
+ * permission and caveat is stringently validated—including by calling their
169
+ * specification validators—and an error is thrown if validation fails.
170
+ *
171
+ * ATTN: This method does **not** prompt the user for approval. User consent must
172
+ * first be obtained through some other means.
173
+ *
174
+ * @see {@link PermissionController.requestPermissionsIncremental} For initiating
175
+ * an incremental permissions request requiring user approval.
176
+ * @param options - Options bag.
177
+ * @param options.approvedPermissions - The requested permissions approved by
178
+ * the user.
179
+ * @param options.requestData - Permission request data. Passed to permission
180
+ * factory functions.
181
+ * @param options.subject - The subject to grant permissions to.
182
+ * @returns The subject's new permission state. It may or may not have changed.
183
+ */
184
+ export type PermissionControllerGrantPermissionsIncrementalAction = {
185
+ type: `PermissionController:grantPermissionsIncremental`;
186
+ handler: PermissionController['grantPermissionsIncremental'];
187
+ };
188
+ /**
189
+ * Initiates a permission request that requires user approval.
190
+ *
191
+ * Either this or {@link PermissionController.requestPermissionsIncremental}
192
+ * should always be used to grant additional permissions to a subject,
193
+ * unless user approval has been obtained through some other means.
194
+ *
195
+ * Permissions are validated at every step of the approval process, and this
196
+ * method will reject if validation fails.
197
+ *
198
+ * @see {@link ApprovalController} For the user approval logic.
199
+ * @see {@link PermissionController.acceptPermissionsRequest} For the method
200
+ * that _accepts_ the request and resolves the user approval promise.
201
+ * @see {@link PermissionController.rejectPermissionsRequest} For the method
202
+ * that _rejects_ the request and the user approval promise.
203
+ * @param subject - The grantee subject.
204
+ * @param requestedPermissions - The requested permissions.
205
+ * @param options - Additional options.
206
+ * @param options.id - The id of the permissions request. Defaults to a unique
207
+ * id.
208
+ * @param options.preserveExistingPermissions - Whether to preserve the
209
+ * subject's existing permissions. Defaults to `true`.
210
+ * @param options.metadata - Additional metadata about the permission request.
211
+ * @returns The granted permissions and request metadata.
212
+ */
213
+ export type PermissionControllerRequestPermissionsAction = {
214
+ type: `PermissionController:requestPermissions`;
215
+ handler: PermissionController['requestPermissions'];
216
+ };
217
+ /**
218
+ * Initiates an incremental permission request that prompts for user approval.
219
+ * Incremental permission requests allow the caller to replace existing and/or
220
+ * add brand new permissions and caveats for the specified subject.
221
+ *
222
+ * Incremental permission request are merged with the subject's existing permissions
223
+ * through a right-biased union, where the incremental permission are the right-hand
224
+ * side of the merger. If both sides of the merger specify the same caveats for a
225
+ * given permission, the caveats are merged using their specification's caveat value
226
+ * merger property.
227
+ *
228
+ * Either this or {@link PermissionController.requestPermissions} should
229
+ * always be used to grant additional permissions to a subject, unless user
230
+ * approval has been obtained through some other means.
231
+ *
232
+ * Permissions are validated at every step of the approval process, and this
233
+ * method will reject if validation fails.
234
+ *
235
+ * @see {@link ApprovalController} For the user approval logic.
236
+ * @see {@link PermissionController.acceptPermissionsRequest} For the method
237
+ * that _accepts_ the request and resolves the user approval promise.
238
+ * @see {@link PermissionController.rejectPermissionsRequest} For the method
239
+ * that _rejects_ the request and the user approval promise.
240
+ * @param subject - The grantee subject.
241
+ * @param requestedPermissions - The requested permissions.
242
+ * @param options - Additional options.
243
+ * @param options.id - The id of the permissions request. Defaults to a unique
244
+ * id.
245
+ * @param options.metadata - Additional metadata about the permission request.
246
+ * @returns The granted permissions and request metadata.
247
+ */
248
+ export type PermissionControllerRequestPermissionsIncrementalAction = {
249
+ type: `PermissionController:requestPermissionsIncremental`;
250
+ handler: PermissionController['requestPermissionsIncremental'];
251
+ };
252
+ /**
253
+ * Gets the subject's endowments per the specified endowment permission.
254
+ * Throws if the subject does not have the required permission or if the
255
+ * permission is not an endowment permission.
256
+ *
257
+ * @param origin - The origin of the subject whose endowments to retrieve.
258
+ * @param targetName - The name of the endowment permission. This must be a
259
+ * valid permission target name.
260
+ * @param requestData - Additional data associated with the request, if any.
261
+ * Forwarded to the endowment getter function for the permission.
262
+ * @returns The endowments, if any.
263
+ */
264
+ export type PermissionControllerGetEndowmentsAction = {
265
+ type: `PermissionController:getEndowments`;
266
+ handler: PermissionController['getEndowments'];
267
+ };
268
+ /**
269
+ * Executes a restricted method as the subject with the given origin.
270
+ * The specified params, if any, will be passed to the method implementation.
271
+ *
272
+ * ATTN: Great caution should be exercised in the use of this method.
273
+ * Methods that cause side effects or affect application state should
274
+ * be avoided.
275
+ *
276
+ * This method will first attempt to retrieve the requested restricted method
277
+ * implementation, throwing if it does not exist. The method will then be
278
+ * invoked as though the subject with the specified origin had invoked it with
279
+ * the specified parameters. This means that any existing caveats will be
280
+ * applied to the restricted method, and this method will throw if the
281
+ * restricted method or its caveat decorators throw.
282
+ *
283
+ * In addition, this method will throw if the subject does not have a
284
+ * permission for the specified restricted method.
285
+ *
286
+ * @param origin - The origin of the subject to execute the method on behalf
287
+ * of.
288
+ * @param targetName - The name of the method to execute. This must be a valid
289
+ * permission target name.
290
+ * @param params - The parameters to pass to the method implementation.
291
+ * @returns The result of the executed method.
292
+ */
293
+ export type PermissionControllerExecuteRestrictedMethodAction = {
294
+ type: `PermissionController:executeRestrictedMethod`;
295
+ handler: PermissionController['executeRestrictedMethod'];
296
+ };
297
+ /**
298
+ * Union of all PermissionController action types.
299
+ */
300
+ export type PermissionControllerMethodActions = PermissionControllerHasUnrestrictedMethodAction | PermissionControllerClearStateAction | PermissionControllerGetSubjectNamesAction | PermissionControllerGetPermissionsAction | PermissionControllerHasPermissionAction | PermissionControllerHasPermissionsAction | PermissionControllerRevokeAllPermissionsAction | PermissionControllerRevokePermissionsAction | PermissionControllerRevokePermissionForAllSubjectsAction | PermissionControllerGetCaveatAction | PermissionControllerUpdateCaveatAction | PermissionControllerGrantPermissionsAction | PermissionControllerGrantPermissionsIncrementalAction | PermissionControllerRequestPermissionsAction | PermissionControllerRequestPermissionsIncrementalAction | PermissionControllerGetEndowmentsAction | PermissionControllerExecuteRestrictedMethodAction;
301
+ //# sourceMappingURL=PermissionController-method-action-types.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PermissionController-method-action-types.d.mts","sourceRoot":"","sources":["../src/PermissionController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,mCAA+B;AAEnE;;;;;;;;GAQG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,oBAAoB,CAAC,uBAAuB,CAAC,CAAC;CACxD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,oBAAoB,CA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GACzC,wCAAwC,GACxC,uCAAuC,GACvC,wCAAwC,GACxC,8CAA8C,GAC9C,2CAA2C,GAC3C,wDAAwD,GACxD,mCAAmC,GACnC,sCAAsC,GACtC,0CAA0C,GAC1C,qDAAqD,GACrD,4CAA4C,GAC5C,uDAAuD,GACvD,uCAAuC,GACvC,iDAAiD,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file is auto generated.
3
+ * Do not edit manually.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=PermissionController-method-action-types.mjs.map
@@ -0,0 +1 @@
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 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 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 * 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 * 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 | PermissionControllerGetPermissionsAction\n | PermissionControllerHasPermissionAction\n | PermissionControllerHasPermissionsAction\n | PermissionControllerRevokeAllPermissionsAction\n | PermissionControllerRevokePermissionsAction\n | PermissionControllerRevokePermissionForAllSubjectsAction\n | PermissionControllerGetCaveatAction\n | PermissionControllerUpdateCaveatAction\n | PermissionControllerGrantPermissionsAction\n | PermissionControllerGrantPermissionsIncrementalAction\n | PermissionControllerRequestPermissionsAction\n | PermissionControllerRequestPermissionsIncrementalAction\n | PermissionControllerGetEndowmentsAction\n | PermissionControllerExecuteRestrictedMethodAction;\n"]}