@metamask/snaps-controllers 0.35.2-flask.1 → 0.36.0-flask.1
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.
- package/CHANGELOG.md +7 -1
- package/dist/cjs/snaps/SnapController.js +40 -25
- package/dist/cjs/snaps/SnapController.js.map +1 -1
- package/dist/esm/snaps/SnapController.js +41 -26
- package/dist/esm/snaps/SnapController.js.map +1 -1
- package/dist/types/snaps/SnapController.d.ts +16 -6
- package/package.json +5 -5
|
@@ -3,7 +3,7 @@ import { BaseControllerV2 as BaseController, RestrictedControllerMessenger } fro
|
|
|
3
3
|
import { GetEndowments, GetPermissions, GetSubjects, GrantPermissions, HasPermission, HasPermissions, RevokeAllPermissions, RevokePermissionForAllSubjects, RevokePermissions, UpdateCaveat, GetSubjectMetadata } from '@metamask/permission-controller';
|
|
4
4
|
import { BlockReason } from '@metamask/snaps-registry';
|
|
5
5
|
import { InstallSnapsResult, PersistedSnap, RequestedSnapPermissions, Snap, SnapId, SnapRpcHook, SnapRpcHookArgs, SnapStatusEvents, StatusContext, StatusEvents, StatusStates, TruncatedSnap, ValidatedSnapId } from '@metamask/snaps-utils';
|
|
6
|
-
import { Json } from '@metamask/utils';
|
|
6
|
+
import { Json, NonEmptyArray } from '@metamask/utils';
|
|
7
7
|
import { StateMachine } from '@xstate/fsm';
|
|
8
8
|
import type { Patch } from 'immer';
|
|
9
9
|
import { ExecuteSnapAction, ExecutionServiceEvents, HandleRpcRequestAction, SnapErrorJson, TerminateAllSnapsAction, TerminateSnapAction } from '../services';
|
|
@@ -178,7 +178,11 @@ export declare type DisconnectOrigin = {
|
|
|
178
178
|
type: `${typeof controllerName}:disconnectOrigin`;
|
|
179
179
|
handler: SnapController['removeSnapFromSubject'];
|
|
180
180
|
};
|
|
181
|
-
export declare type
|
|
181
|
+
export declare type RevokeDynamicPermissions = {
|
|
182
|
+
type: `${typeof controllerName}:revokeDynamicPermissions`;
|
|
183
|
+
handler: SnapController['revokeDynamicSnapPermissions'];
|
|
184
|
+
};
|
|
185
|
+
export declare type SnapControllerActions = ClearSnapState | GetSnap | GetSnapState | HandleSnapRequest | HasSnap | UpdateBlockedSnaps | UpdateSnapState | EnableSnap | DisableSnap | RemoveSnap | GetPermittedSnaps | InstallSnaps | RemoveSnapError | GetAllSnaps | IncrementActiveReferences | DecrementActiveReferences | GetRegistryMetadata | DisconnectOrigin | RevokeDynamicPermissions;
|
|
182
186
|
export declare type SnapStateChange = {
|
|
183
187
|
type: `${typeof controllerName}:stateChange`;
|
|
184
188
|
payload: [SnapControllerState, Patch[]];
|
|
@@ -263,6 +267,10 @@ declare type SnapControllerArgs = {
|
|
|
263
267
|
* for a running snap.
|
|
264
268
|
*/
|
|
265
269
|
closeAllConnections: CloseAllConnectionsFunction;
|
|
270
|
+
/**
|
|
271
|
+
* A list of permissions that are allowed to be dynamic, meaning they can be revoked from the snap whenever.
|
|
272
|
+
*/
|
|
273
|
+
dynamicPermissions: string[];
|
|
266
274
|
/**
|
|
267
275
|
* The names of endowment permissions whose values are the names of JavaScript
|
|
268
276
|
* APIs that will be added to the snap execution environment at runtime.
|
|
@@ -318,7 +326,7 @@ export declare class SnapController extends BaseController<string, SnapControlle
|
|
|
318
326
|
#private;
|
|
319
327
|
private readonly maxRequestTime;
|
|
320
328
|
private readonly snapsRuntimeData;
|
|
321
|
-
constructor({ closeAllConnections, messenger, state, environmentEndowmentPermissions, excludedPermissions, idleTimeCheckInterval, maxIdleTime, maxRequestTime, fetchFunction, featureFlags, detectSnapLocation: detectSnapLocationFunction, }: SnapControllerArgs);
|
|
329
|
+
constructor({ closeAllConnections, messenger, state, dynamicPermissions, environmentEndowmentPermissions, excludedPermissions, idleTimeCheckInterval, maxIdleTime, maxRequestTime, fetchFunction, featureFlags, detectSnapLocation: detectSnapLocationFunction, }: SnapControllerArgs);
|
|
322
330
|
/**
|
|
323
331
|
* Checks all installed snaps against the block list and
|
|
324
332
|
* blocks/unblocks snaps as appropriate. See {@link SnapController.blockSnap}
|
|
@@ -477,11 +485,13 @@ export declare class SnapController extends BaseController<string, SnapControlle
|
|
|
477
485
|
*/
|
|
478
486
|
removeSnapFromSubject(origin: string, snapId: ValidatedSnapId): void;
|
|
479
487
|
/**
|
|
480
|
-
*
|
|
488
|
+
* Checks if a list of permissions are dynamic and allowed to be revoked, if they are they will all be revoked.
|
|
481
489
|
*
|
|
482
490
|
* @param snapId - The snap ID.
|
|
491
|
+
* @param permissionNames - The names of the permissions.
|
|
492
|
+
* @throws If non-dynamic permissions are passed.
|
|
483
493
|
*/
|
|
484
|
-
|
|
494
|
+
revokeDynamicSnapPermissions(snapId: string, permissionNames: NonEmptyArray<string>): void;
|
|
485
495
|
/**
|
|
486
496
|
* Handles incrementing the activeReferences counter.
|
|
487
497
|
*
|
|
@@ -578,7 +588,7 @@ export declare class SnapController extends BaseController<string, SnapControlle
|
|
|
578
588
|
* @param options.request - The JSON-RPC request object.
|
|
579
589
|
* @returns The result of the JSON-RPC request.
|
|
580
590
|
*/
|
|
581
|
-
handleRequest({ snapId, origin, handler: handlerType, request, }: SnapRpcHookArgs & {
|
|
591
|
+
handleRequest({ snapId, origin, handler: handlerType, request: rawRequest, }: SnapRpcHookArgs & {
|
|
582
592
|
snapId: ValidatedSnapId;
|
|
583
593
|
}): Promise<unknown>;
|
|
584
594
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-controllers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0-flask.1",
|
|
4
4
|
"description": "Controllers for MetaMask Snaps.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"build:esm": "swc src --out-dir dist/esm --config-file ../../.swcrc.build.json --config module.type=es6",
|
|
32
32
|
"build:cjs": "swc src --out-dir dist/cjs --config-file ../../.swcrc.build.json --config module.type=commonjs",
|
|
33
33
|
"build:clean": "yarn clean && yarn build",
|
|
34
|
-
"clean": "rimraf '*.tsbuildinfo' 'dist
|
|
34
|
+
"clean": "rimraf '*.tsbuildinfo' 'dist'",
|
|
35
35
|
"lint:eslint": "eslint . --cache --ext js,ts,jsx,tsx",
|
|
36
36
|
"lint:misc": "prettier --no-error-on-unmatched-pattern --loglevel warn \"**/*.json\" \"**/*.md\" \"**/*.html\" \"!CHANGELOG.md\" --ignore-path ../../.gitignore",
|
|
37
37
|
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:changelog",
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
"@metamask/object-multiplex": "^1.2.0",
|
|
48
48
|
"@metamask/permission-controller": "^4.0.0",
|
|
49
49
|
"@metamask/post-message-stream": "^6.1.2",
|
|
50
|
-
"@metamask/rpc-methods": "^0.
|
|
51
|
-
"@metamask/snaps-execution-environments": "^0.
|
|
50
|
+
"@metamask/rpc-methods": "^0.36.0-flask.1",
|
|
51
|
+
"@metamask/snaps-execution-environments": "^0.36.0-flask.1",
|
|
52
52
|
"@metamask/snaps-registry": "^1.2.1",
|
|
53
|
-
"@metamask/snaps-utils": "^0.
|
|
53
|
+
"@metamask/snaps-utils": "^0.36.0-flask.1",
|
|
54
54
|
"@metamask/utils": "^6.0.1",
|
|
55
55
|
"@xstate/fsm": "^2.0.0",
|
|
56
56
|
"concat-stream": "^2.0.0",
|