@metamask-previews/permission-controller 12.3.0-preview-938fc5d87 → 12.3.0-preview-495c91e

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 (46) hide show
  1. package/CHANGELOG.md +16 -2
  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.map +1 -1
  9. package/dist/PermissionController-method-action-types.d.cts +44 -25
  10. package/dist/PermissionController-method-action-types.d.cts.map +1 -1
  11. package/dist/PermissionController-method-action-types.d.mts +44 -25
  12. package/dist/PermissionController-method-action-types.d.mts.map +1 -1
  13. package/dist/PermissionController-method-action-types.mjs.map +1 -1
  14. package/dist/PermissionController.cjs +23 -65
  15. package/dist/PermissionController.cjs.map +1 -1
  16. package/dist/PermissionController.d.cts +12 -36
  17. package/dist/PermissionController.d.cts.map +1 -1
  18. package/dist/PermissionController.d.mts +12 -36
  19. package/dist/PermissionController.d.mts.map +1 -1
  20. package/dist/PermissionController.mjs +23 -65
  21. package/dist/PermissionController.mjs.map +1 -1
  22. package/dist/createRestrictedMethodMessenger.cjs +20 -0
  23. package/dist/createRestrictedMethodMessenger.cjs.map +1 -0
  24. package/dist/createRestrictedMethodMessenger.d.cts +42 -0
  25. package/dist/createRestrictedMethodMessenger.d.cts.map +1 -0
  26. package/dist/createRestrictedMethodMessenger.d.mts +42 -0
  27. package/dist/createRestrictedMethodMessenger.d.mts.map +1 -0
  28. package/dist/createRestrictedMethodMessenger.mjs +16 -0
  29. package/dist/createRestrictedMethodMessenger.mjs.map +1 -0
  30. package/dist/index.cjs +6 -1
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.cts +3 -1
  33. package/dist/index.d.cts.map +1 -1
  34. package/dist/index.d.mts +3 -1
  35. package/dist/index.d.mts.map +1 -1
  36. package/dist/index.mjs +2 -0
  37. package/dist/index.mjs.map +1 -1
  38. package/dist/permission-middleware.cjs +59 -0
  39. package/dist/permission-middleware.cjs.map +1 -0
  40. package/dist/permission-middleware.d.cts +49 -0
  41. package/dist/permission-middleware.d.cts.map +1 -0
  42. package/dist/permission-middleware.d.mts +49 -0
  43. package/dist/permission-middleware.d.mts.map +1 -0
  44. package/dist/permission-middleware.mjs +54 -0
  45. package/dist/permission-middleware.mjs.map +1 -0
  46. package/package.json +1 -1
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createRestrictedMethodMessenger = void 0;
4
+ const messenger_1 = require("@metamask/messenger");
5
+ function createRestrictedMethodMessenger({ rootMessenger, namespace, actionNames, }) {
6
+ if (!actionNames?.length) {
7
+ return undefined;
8
+ }
9
+ const restrictedMethodMessenger = new messenger_1.Messenger({
10
+ namespace,
11
+ parent: rootMessenger,
12
+ });
13
+ rootMessenger.delegate({
14
+ actions: actionNames,
15
+ messenger: restrictedMethodMessenger,
16
+ });
17
+ return restrictedMethodMessenger;
18
+ }
19
+ exports.createRestrictedMethodMessenger = createRestrictedMethodMessenger;
20
+ //# sourceMappingURL=createRestrictedMethodMessenger.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createRestrictedMethodMessenger.cjs","sourceRoot":"","sources":["../src/createRestrictedMethodMessenger.ts"],"names":[],"mappings":";;;AAKA,mDAAgD;AA2DhD,SAAgB,+BAA+B,CAO7C,EACA,aAAa,EACb,SAAS,EACT,WAAW,GAKZ;IAQC,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,yBAAyB,GAAG,IAAI,qBAAS,CAK7C;QACA,SAAS;QACT,MAAM,EAAE,aAAa;KACtB,CAAC,CAAC;IAEH,aAAa,CAAC,QAAQ,CAAC;QACrB,OAAO,EAAE,WAAW;QACpB,SAAS,EAAE,yBAAyB;KACrC,CAAC,CAAC;IAEH,OAAO,yBAAyB,CAAC;AACnC,CAAC;AA3CD,0EA2CC","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n MessengerActions,\n} from '@metamask/messenger';\nimport { Messenger } from '@metamask/messenger';\n\n/**\n * The subset of `RootMessenger`'s actions selected by `DelegatedActions`.\n */\ntype SelectedActions<\n RootMessenger extends Messenger<string, ActionConstraint, EventConstraint>,\n DelegatedActions extends readonly MessengerActions<RootMessenger>['type'][],\n> = Extract<\n MessengerActions<RootMessenger>,\n { type: DelegatedActions[number] }\n>;\n\n/**\n * Create a child messenger scoped to a restricted-method permission\n * specification, delegating only the spec's declared actions from the root\n * messenger. This produces a minimally-scoped messenger whose action surface\n * matches exactly what the spec has declared it needs.\n *\n * Returns `undefined` when `actionNames` is omitted — there is nothing to\n * scope, and the builder can be invoked without a messenger.\n *\n * @param args - The arguments.\n * @param args.rootMessenger - The root messenger to delegate actions from.\n * @param args.namespace - The namespace for the scoped child messenger,\n * typically the spec's `targetName`.\n * @param args.actionNames - The action types the specification requires,\n * typically the spec's declared `actionNames`. Must be a non-empty tuple of\n * action types that exist on the root messenger.\n * @returns A scoped child messenger with the requested actions delegated, or\n * `undefined` if no actions were requested.\n */\nexport function createRestrictedMethodMessenger<\n Namespace extends string,\n RootMessenger extends Messenger<string, ActionConstraint, EventConstraint>,\n DelegatedActions extends readonly [\n MessengerActions<RootMessenger>['type'],\n ...MessengerActions<RootMessenger>['type'][],\n ],\n>(args: {\n rootMessenger: RootMessenger;\n namespace: Namespace;\n actionNames: DelegatedActions;\n}): Messenger<\n Namespace,\n SelectedActions<RootMessenger, DelegatedActions>,\n never,\n RootMessenger\n>;\n\nexport function createRestrictedMethodMessenger<\n Namespace extends string,\n RootMessenger extends Messenger<string, ActionConstraint, EventConstraint>,\n>(args: {\n rootMessenger: RootMessenger;\n namespace: Namespace;\n actionNames?: undefined;\n}): undefined;\n\nexport function createRestrictedMethodMessenger<\n Namespace extends string,\n RootMessenger extends Messenger<string, ActionConstraint, EventConstraint>,\n DelegatedActions extends [\n MessengerActions<RootMessenger>['type'],\n ...MessengerActions<RootMessenger>['type'][],\n ],\n>({\n rootMessenger,\n namespace,\n actionNames,\n}: {\n rootMessenger: RootMessenger;\n namespace: Namespace;\n actionNames?: DelegatedActions;\n}):\n | Messenger<\n Namespace,\n SelectedActions<RootMessenger, DelegatedActions>,\n never,\n RootMessenger\n >\n | undefined {\n if (!actionNames?.length) {\n return undefined;\n }\n\n const restrictedMethodMessenger = new Messenger<\n Namespace,\n SelectedActions<RootMessenger, DelegatedActions>,\n never,\n RootMessenger\n >({\n namespace,\n parent: rootMessenger,\n });\n\n rootMessenger.delegate({\n actions: actionNames,\n messenger: restrictedMethodMessenger,\n });\n\n return restrictedMethodMessenger;\n}\n"]}
@@ -0,0 +1,42 @@
1
+ import type { ActionConstraint, EventConstraint, MessengerActions } from "@metamask/messenger";
2
+ import { Messenger } from "@metamask/messenger";
3
+ /**
4
+ * The subset of `RootMessenger`'s actions selected by `DelegatedActions`.
5
+ */
6
+ type SelectedActions<RootMessenger extends Messenger<string, ActionConstraint, EventConstraint>, DelegatedActions extends readonly MessengerActions<RootMessenger>['type'][]> = Extract<MessengerActions<RootMessenger>, {
7
+ type: DelegatedActions[number];
8
+ }>;
9
+ /**
10
+ * Create a child messenger scoped to a restricted-method permission
11
+ * specification, delegating only the spec's declared actions from the root
12
+ * messenger. This produces a minimally-scoped messenger whose action surface
13
+ * matches exactly what the spec has declared it needs.
14
+ *
15
+ * Returns `undefined` when `actionNames` is omitted — there is nothing to
16
+ * scope, and the builder can be invoked without a messenger.
17
+ *
18
+ * @param args - The arguments.
19
+ * @param args.rootMessenger - The root messenger to delegate actions from.
20
+ * @param args.namespace - The namespace for the scoped child messenger,
21
+ * typically the spec's `targetName`.
22
+ * @param args.actionNames - The action types the specification requires,
23
+ * typically the spec's declared `actionNames`. Must be a non-empty tuple of
24
+ * action types that exist on the root messenger.
25
+ * @returns A scoped child messenger with the requested actions delegated, or
26
+ * `undefined` if no actions were requested.
27
+ */
28
+ export declare function createRestrictedMethodMessenger<Namespace extends string, RootMessenger extends Messenger<string, ActionConstraint, EventConstraint>, DelegatedActions extends readonly [
29
+ MessengerActions<RootMessenger>['type'],
30
+ ...MessengerActions<RootMessenger>['type'][]
31
+ ]>(args: {
32
+ rootMessenger: RootMessenger;
33
+ namespace: Namespace;
34
+ actionNames: DelegatedActions;
35
+ }): Messenger<Namespace, SelectedActions<RootMessenger, DelegatedActions>, never, RootMessenger>;
36
+ export declare function createRestrictedMethodMessenger<Namespace extends string, RootMessenger extends Messenger<string, ActionConstraint, EventConstraint>>(args: {
37
+ rootMessenger: RootMessenger;
38
+ namespace: Namespace;
39
+ actionNames?: undefined;
40
+ }): undefined;
41
+ export {};
42
+ //# sourceMappingURL=createRestrictedMethodMessenger.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createRestrictedMethodMessenger.d.cts","sourceRoot":"","sources":["../src/createRestrictedMethodMessenger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EACjB,4BAA4B;AAC7B,OAAO,EAAE,SAAS,EAAE,4BAA4B;AAEhD;;GAEG;AACH,KAAK,eAAe,CAClB,aAAa,SAAS,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,eAAe,CAAC,EAC1E,gBAAgB,SAAS,SAAS,gBAAgB,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,EAAE,IACzE,OAAO,CACT,gBAAgB,CAAC,aAAa,CAAC,EAC/B;IAAE,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;CAAE,CACnC,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,SAAS,MAAM,EACxB,aAAa,SAAS,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,eAAe,CAAC,EAC1E,gBAAgB,SAAS,SAAS;IAChC,gBAAgB,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC;IACvC,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,EAAE;CAC7C,EACD,IAAI,EAAE;IACN,aAAa,EAAE,aAAa,CAAC;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,gBAAgB,CAAC;CAC/B,GAAG,SAAS,CACX,SAAS,EACT,eAAe,CAAC,aAAa,EAAE,gBAAgB,CAAC,EAChD,KAAK,EACL,aAAa,CACd,CAAC;AAEF,wBAAgB,+BAA+B,CAC7C,SAAS,SAAS,MAAM,EACxB,aAAa,SAAS,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,eAAe,CAAC,EAC1E,IAAI,EAAE;IACN,aAAa,EAAE,aAAa,CAAC;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB,GAAG,SAAS,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { ActionConstraint, EventConstraint, MessengerActions } from "@metamask/messenger";
2
+ import { Messenger } from "@metamask/messenger";
3
+ /**
4
+ * The subset of `RootMessenger`'s actions selected by `DelegatedActions`.
5
+ */
6
+ type SelectedActions<RootMessenger extends Messenger<string, ActionConstraint, EventConstraint>, DelegatedActions extends readonly MessengerActions<RootMessenger>['type'][]> = Extract<MessengerActions<RootMessenger>, {
7
+ type: DelegatedActions[number];
8
+ }>;
9
+ /**
10
+ * Create a child messenger scoped to a restricted-method permission
11
+ * specification, delegating only the spec's declared actions from the root
12
+ * messenger. This produces a minimally-scoped messenger whose action surface
13
+ * matches exactly what the spec has declared it needs.
14
+ *
15
+ * Returns `undefined` when `actionNames` is omitted — there is nothing to
16
+ * scope, and the builder can be invoked without a messenger.
17
+ *
18
+ * @param args - The arguments.
19
+ * @param args.rootMessenger - The root messenger to delegate actions from.
20
+ * @param args.namespace - The namespace for the scoped child messenger,
21
+ * typically the spec's `targetName`.
22
+ * @param args.actionNames - The action types the specification requires,
23
+ * typically the spec's declared `actionNames`. Must be a non-empty tuple of
24
+ * action types that exist on the root messenger.
25
+ * @returns A scoped child messenger with the requested actions delegated, or
26
+ * `undefined` if no actions were requested.
27
+ */
28
+ export declare function createRestrictedMethodMessenger<Namespace extends string, RootMessenger extends Messenger<string, ActionConstraint, EventConstraint>, DelegatedActions extends readonly [
29
+ MessengerActions<RootMessenger>['type'],
30
+ ...MessengerActions<RootMessenger>['type'][]
31
+ ]>(args: {
32
+ rootMessenger: RootMessenger;
33
+ namespace: Namespace;
34
+ actionNames: DelegatedActions;
35
+ }): Messenger<Namespace, SelectedActions<RootMessenger, DelegatedActions>, never, RootMessenger>;
36
+ export declare function createRestrictedMethodMessenger<Namespace extends string, RootMessenger extends Messenger<string, ActionConstraint, EventConstraint>>(args: {
37
+ rootMessenger: RootMessenger;
38
+ namespace: Namespace;
39
+ actionNames?: undefined;
40
+ }): undefined;
41
+ export {};
42
+ //# sourceMappingURL=createRestrictedMethodMessenger.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createRestrictedMethodMessenger.d.mts","sourceRoot":"","sources":["../src/createRestrictedMethodMessenger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EACjB,4BAA4B;AAC7B,OAAO,EAAE,SAAS,EAAE,4BAA4B;AAEhD;;GAEG;AACH,KAAK,eAAe,CAClB,aAAa,SAAS,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,eAAe,CAAC,EAC1E,gBAAgB,SAAS,SAAS,gBAAgB,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,EAAE,IACzE,OAAO,CACT,gBAAgB,CAAC,aAAa,CAAC,EAC/B;IAAE,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;CAAE,CACnC,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,+BAA+B,CAC7C,SAAS,SAAS,MAAM,EACxB,aAAa,SAAS,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,eAAe,CAAC,EAC1E,gBAAgB,SAAS,SAAS;IAChC,gBAAgB,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC;IACvC,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,EAAE;CAC7C,EACD,IAAI,EAAE;IACN,aAAa,EAAE,aAAa,CAAC;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,gBAAgB,CAAC;CAC/B,GAAG,SAAS,CACX,SAAS,EACT,eAAe,CAAC,aAAa,EAAE,gBAAgB,CAAC,EAChD,KAAK,EACL,aAAa,CACd,CAAC;AAEF,wBAAgB,+BAA+B,CAC7C,SAAS,SAAS,MAAM,EACxB,aAAa,SAAS,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,eAAe,CAAC,EAC1E,IAAI,EAAE;IACN,aAAa,EAAE,aAAa,CAAC;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB,GAAG,SAAS,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Messenger } from "@metamask/messenger";
2
+ export function createRestrictedMethodMessenger({ rootMessenger, namespace, actionNames, }) {
3
+ if (!actionNames?.length) {
4
+ return undefined;
5
+ }
6
+ const restrictedMethodMessenger = new Messenger({
7
+ namespace,
8
+ parent: rootMessenger,
9
+ });
10
+ rootMessenger.delegate({
11
+ actions: actionNames,
12
+ messenger: restrictedMethodMessenger,
13
+ });
14
+ return restrictedMethodMessenger;
15
+ }
16
+ //# sourceMappingURL=createRestrictedMethodMessenger.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createRestrictedMethodMessenger.mjs","sourceRoot":"","sources":["../src/createRestrictedMethodMessenger.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,4BAA4B;AA2DhD,MAAM,UAAU,+BAA+B,CAO7C,EACA,aAAa,EACb,SAAS,EACT,WAAW,GAKZ;IAQC,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,yBAAyB,GAAG,IAAI,SAAS,CAK7C;QACA,SAAS;QACT,MAAM,EAAE,aAAa;KACtB,CAAC,CAAC;IAEH,aAAa,CAAC,QAAQ,CAAC;QACrB,OAAO,EAAE,WAAW;QACpB,SAAS,EAAE,yBAAyB;KACrC,CAAC,CAAC;IAEH,OAAO,yBAAyB,CAAC;AACnC,CAAC","sourcesContent":["import type {\n ActionConstraint,\n EventConstraint,\n MessengerActions,\n} from '@metamask/messenger';\nimport { Messenger } from '@metamask/messenger';\n\n/**\n * The subset of `RootMessenger`'s actions selected by `DelegatedActions`.\n */\ntype SelectedActions<\n RootMessenger extends Messenger<string, ActionConstraint, EventConstraint>,\n DelegatedActions extends readonly MessengerActions<RootMessenger>['type'][],\n> = Extract<\n MessengerActions<RootMessenger>,\n { type: DelegatedActions[number] }\n>;\n\n/**\n * Create a child messenger scoped to a restricted-method permission\n * specification, delegating only the spec's declared actions from the root\n * messenger. This produces a minimally-scoped messenger whose action surface\n * matches exactly what the spec has declared it needs.\n *\n * Returns `undefined` when `actionNames` is omitted — there is nothing to\n * scope, and the builder can be invoked without a messenger.\n *\n * @param args - The arguments.\n * @param args.rootMessenger - The root messenger to delegate actions from.\n * @param args.namespace - The namespace for the scoped child messenger,\n * typically the spec's `targetName`.\n * @param args.actionNames - The action types the specification requires,\n * typically the spec's declared `actionNames`. Must be a non-empty tuple of\n * action types that exist on the root messenger.\n * @returns A scoped child messenger with the requested actions delegated, or\n * `undefined` if no actions were requested.\n */\nexport function createRestrictedMethodMessenger<\n Namespace extends string,\n RootMessenger extends Messenger<string, ActionConstraint, EventConstraint>,\n DelegatedActions extends readonly [\n MessengerActions<RootMessenger>['type'],\n ...MessengerActions<RootMessenger>['type'][],\n ],\n>(args: {\n rootMessenger: RootMessenger;\n namespace: Namespace;\n actionNames: DelegatedActions;\n}): Messenger<\n Namespace,\n SelectedActions<RootMessenger, DelegatedActions>,\n never,\n RootMessenger\n>;\n\nexport function createRestrictedMethodMessenger<\n Namespace extends string,\n RootMessenger extends Messenger<string, ActionConstraint, EventConstraint>,\n>(args: {\n rootMessenger: RootMessenger;\n namespace: Namespace;\n actionNames?: undefined;\n}): undefined;\n\nexport function createRestrictedMethodMessenger<\n Namespace extends string,\n RootMessenger extends Messenger<string, ActionConstraint, EventConstraint>,\n DelegatedActions extends [\n MessengerActions<RootMessenger>['type'],\n ...MessengerActions<RootMessenger>['type'][],\n ],\n>({\n rootMessenger,\n namespace,\n actionNames,\n}: {\n rootMessenger: RootMessenger;\n namespace: Namespace;\n actionNames?: DelegatedActions;\n}):\n | Messenger<\n Namespace,\n SelectedActions<RootMessenger, DelegatedActions>,\n never,\n RootMessenger\n >\n | undefined {\n if (!actionNames?.length) {\n return undefined;\n }\n\n const restrictedMethodMessenger = new Messenger<\n Namespace,\n SelectedActions<RootMessenger, DelegatedActions>,\n never,\n RootMessenger\n >({\n namespace,\n parent: rootMessenger,\n });\n\n rootMessenger.delegate({\n actions: actionNames,\n messenger: restrictedMethodMessenger,\n });\n\n return restrictedMethodMessenger;\n}\n"]}
package/dist/index.cjs CHANGED
@@ -26,11 +26,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
26
  return result;
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.permissionRpcMethods = exports.MethodNames = void 0;
29
+ exports.permissionRpcMethods = exports.MethodNames = exports.createPermissionMiddlewareV2 = exports.createPermissionMiddleware = exports.createRestrictedMethodMessenger = void 0;
30
30
  __exportStar(require("./Caveat.cjs"), exports);
31
+ var createRestrictedMethodMessenger_1 = require("./createRestrictedMethodMessenger.cjs");
32
+ Object.defineProperty(exports, "createRestrictedMethodMessenger", { enumerable: true, get: function () { return createRestrictedMethodMessenger_1.createRestrictedMethodMessenger; } });
31
33
  __exportStar(require("./errors.cjs"), exports);
32
34
  __exportStar(require("./Permission.cjs"), exports);
33
35
  __exportStar(require("./PermissionController.cjs"), exports);
36
+ var permission_middleware_1 = require("./permission-middleware.cjs");
37
+ Object.defineProperty(exports, "createPermissionMiddleware", { enumerable: true, get: function () { return permission_middleware_1.createPermissionMiddleware; } });
38
+ Object.defineProperty(exports, "createPermissionMiddlewareV2", { enumerable: true, get: function () { return permission_middleware_1.createPermissionMiddlewareV2; } });
34
39
  var utils_1 = require("./utils.cjs");
35
40
  Object.defineProperty(exports, "MethodNames", { enumerable: true, get: function () { return utils_1.MethodNames; } });
36
41
  exports.permissionRpcMethods = __importStar(require("./rpc-methods/index.cjs"));
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAyB;AACzB,+CAAyB;AACzB,mDAA6B;AAC7B,6DAAuC;AAyBvC,qCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,gFAAsD;AACtD,kEAA4C","sourcesContent":["export * from './Caveat';\nexport * from './errors';\nexport * from './Permission';\nexport * from './PermissionController';\nexport type {\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 PermissionControllerCreatePermissionMiddlewareAction,\n} from './PermissionController-method-action-types';\nexport type {\n ExtractSpecifications,\n HandlerMiddlewareFunction,\n HookNames,\n PermittedHandlerExport,\n} from './utils';\nexport { MethodNames } from './utils';\nexport * as permissionRpcMethods from './rpc-methods';\nexport * from './SubjectMetadataController';\nexport type {\n SubjectMetadataControllerClearStateAction,\n SubjectMetadataControllerAddSubjectMetadataAction,\n SubjectMetadataControllerGetSubjectMetadataAction,\n SubjectMetadataControllerTrimMetadataStateAction,\n} from './SubjectMetadataController-method-action-types';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAyB;AACzB,yFAAoF;AAA3E,kJAAA,+BAA+B,OAAA;AACxC,+CAAyB;AACzB,mDAA6B;AAC7B,6DAAuC;AAoBvC,qEAIiC;AAH/B,mIAAA,0BAA0B,OAAA;AAC1B,qIAAA,4BAA4B,OAAA;AAS9B,qCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,gFAAsD;AACtD,kEAA4C","sourcesContent":["export * from './Caveat';\nexport { createRestrictedMethodMessenger } from './createRestrictedMethodMessenger';\nexport * from './errors';\nexport * from './Permission';\nexport * from './PermissionController';\nexport type {\n PermissionControllerClearStateAction,\n PermissionControllerExecuteRestrictedMethodAction,\n PermissionControllerGetCaveatAction,\n PermissionControllerGetEndowmentsAction,\n PermissionControllerGetPermissionsAction,\n PermissionControllerGetSubjectNamesAction,\n PermissionControllerGrantPermissionsAction,\n PermissionControllerGrantPermissionsIncrementalAction,\n PermissionControllerHasPermissionAction,\n PermissionControllerHasPermissionsAction,\n PermissionControllerHasUnrestrictedMethodAction,\n PermissionControllerRequestPermissionsAction,\n PermissionControllerRequestPermissionsIncrementalAction,\n PermissionControllerRevokeAllPermissionsAction,\n PermissionControllerRevokePermissionForAllSubjectsAction,\n PermissionControllerRevokePermissionsAction,\n PermissionControllerUpdateCaveatAction,\n} from './PermissionController-method-action-types';\nexport {\n createPermissionMiddleware,\n createPermissionMiddlewareV2,\n type PermissionMiddlewareActions,\n} from './permission-middleware';\nexport type {\n ExtractSpecifications,\n HandlerMiddlewareFunction,\n HookNames,\n PermittedHandlerExport,\n} from './utils';\nexport { MethodNames } from './utils';\nexport * as permissionRpcMethods from './rpc-methods';\nexport * from './SubjectMetadataController';\nexport type {\n SubjectMetadataControllerClearStateAction,\n SubjectMetadataControllerAddSubjectMetadataAction,\n SubjectMetadataControllerGetSubjectMetadataAction,\n SubjectMetadataControllerTrimMetadataStateAction,\n} from './SubjectMetadataController-method-action-types';\n"]}
package/dist/index.d.cts CHANGED
@@ -1,8 +1,10 @@
1
1
  export * from "./Caveat.cjs";
2
+ export { createRestrictedMethodMessenger } from "./createRestrictedMethodMessenger.cjs";
2
3
  export * from "./errors.cjs";
3
4
  export * from "./Permission.cjs";
4
5
  export * from "./PermissionController.cjs";
5
- export type { PermissionControllerClearStateAction, PermissionControllerGetSubjectNamesAction, PermissionControllerGetPermissionsAction, PermissionControllerHasPermissionAction, PermissionControllerHasPermissionsAction, PermissionControllerRevokeAllPermissionsAction, PermissionControllerRevokePermissionsAction, PermissionControllerRevokePermissionForAllSubjectsAction, PermissionControllerGetCaveatAction, PermissionControllerUpdateCaveatAction, PermissionControllerGrantPermissionsAction, PermissionControllerGrantPermissionsIncrementalAction, PermissionControllerRequestPermissionsAction, PermissionControllerRequestPermissionsIncrementalAction, PermissionControllerGetEndowmentsAction, PermissionControllerCreatePermissionMiddlewareAction, } from "./PermissionController-method-action-types.cjs";
6
+ export type { PermissionControllerClearStateAction, PermissionControllerExecuteRestrictedMethodAction, PermissionControllerGetCaveatAction, PermissionControllerGetEndowmentsAction, PermissionControllerGetPermissionsAction, PermissionControllerGetSubjectNamesAction, PermissionControllerGrantPermissionsAction, PermissionControllerGrantPermissionsIncrementalAction, PermissionControllerHasPermissionAction, PermissionControllerHasPermissionsAction, PermissionControllerHasUnrestrictedMethodAction, PermissionControllerRequestPermissionsAction, PermissionControllerRequestPermissionsIncrementalAction, PermissionControllerRevokeAllPermissionsAction, PermissionControllerRevokePermissionForAllSubjectsAction, PermissionControllerRevokePermissionsAction, PermissionControllerUpdateCaveatAction, } from "./PermissionController-method-action-types.cjs";
7
+ export { createPermissionMiddleware, createPermissionMiddlewareV2, type PermissionMiddlewareActions, } from "./permission-middleware.cjs";
6
8
  export type { ExtractSpecifications, HandlerMiddlewareFunction, HookNames, PermittedHandlerExport, } from "./utils.cjs";
7
9
  export { MethodNames } from "./utils.cjs";
8
10
  export * as permissionRpcMethods from "./rpc-methods/index.cjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAAyB;AACzB,6BAAyB;AACzB,iCAA6B;AAC7B,2CAAuC;AACvC,YAAY,EACV,oCAAoC,EACpC,yCAAyC,EACzC,wCAAwC,EACxC,uCAAuC,EACvC,wCAAwC,EACxC,8CAA8C,EAC9C,2CAA2C,EAC3C,wDAAwD,EACxD,mCAAmC,EACnC,sCAAsC,EACtC,0CAA0C,EAC1C,qDAAqD,EACrD,4CAA4C,EAC5C,uDAAuD,EACvD,uCAAuC,EACvC,oDAAoD,GACrD,uDAAmD;AACpD,YAAY,EACV,qBAAqB,EACrB,yBAAyB,EACzB,SAAS,EACT,sBAAsB,GACvB,oBAAgB;AACjB,OAAO,EAAE,WAAW,EAAE,oBAAgB;AACtC,OAAO,KAAK,oBAAoB,gCAAsB;AACtD,gDAA4C;AAC5C,YAAY,EACV,yCAAyC,EACzC,iDAAiD,EACjD,iDAAiD,EACjD,gDAAgD,GACjD,4DAAwD"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAAyB;AACzB,OAAO,EAAE,+BAA+B,EAAE,8CAA0C;AACpF,6BAAyB;AACzB,iCAA6B;AAC7B,2CAAuC;AACvC,YAAY,EACV,oCAAoC,EACpC,iDAAiD,EACjD,mCAAmC,EACnC,uCAAuC,EACvC,wCAAwC,EACxC,yCAAyC,EACzC,0CAA0C,EAC1C,qDAAqD,EACrD,uCAAuC,EACvC,wCAAwC,EACxC,+CAA+C,EAC/C,4CAA4C,EAC5C,uDAAuD,EACvD,8CAA8C,EAC9C,wDAAwD,EACxD,2CAA2C,EAC3C,sCAAsC,GACvC,uDAAmD;AACpD,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,KAAK,2BAA2B,GACjC,oCAAgC;AACjC,YAAY,EACV,qBAAqB,EACrB,yBAAyB,EACzB,SAAS,EACT,sBAAsB,GACvB,oBAAgB;AACjB,OAAO,EAAE,WAAW,EAAE,oBAAgB;AACtC,OAAO,KAAK,oBAAoB,gCAAsB;AACtD,gDAA4C;AAC5C,YAAY,EACV,yCAAyC,EACzC,iDAAiD,EACjD,iDAAiD,EACjD,gDAAgD,GACjD,4DAAwD"}
package/dist/index.d.mts CHANGED
@@ -1,8 +1,10 @@
1
1
  export * from "./Caveat.mjs";
2
+ export { createRestrictedMethodMessenger } from "./createRestrictedMethodMessenger.mjs";
2
3
  export * from "./errors.mjs";
3
4
  export * from "./Permission.mjs";
4
5
  export * from "./PermissionController.mjs";
5
- export type { PermissionControllerClearStateAction, PermissionControllerGetSubjectNamesAction, PermissionControllerGetPermissionsAction, PermissionControllerHasPermissionAction, PermissionControllerHasPermissionsAction, PermissionControllerRevokeAllPermissionsAction, PermissionControllerRevokePermissionsAction, PermissionControllerRevokePermissionForAllSubjectsAction, PermissionControllerGetCaveatAction, PermissionControllerUpdateCaveatAction, PermissionControllerGrantPermissionsAction, PermissionControllerGrantPermissionsIncrementalAction, PermissionControllerRequestPermissionsAction, PermissionControllerRequestPermissionsIncrementalAction, PermissionControllerGetEndowmentsAction, PermissionControllerCreatePermissionMiddlewareAction, } from "./PermissionController-method-action-types.mjs";
6
+ export type { PermissionControllerClearStateAction, PermissionControllerExecuteRestrictedMethodAction, PermissionControllerGetCaveatAction, PermissionControllerGetEndowmentsAction, PermissionControllerGetPermissionsAction, PermissionControllerGetSubjectNamesAction, PermissionControllerGrantPermissionsAction, PermissionControllerGrantPermissionsIncrementalAction, PermissionControllerHasPermissionAction, PermissionControllerHasPermissionsAction, PermissionControllerHasUnrestrictedMethodAction, PermissionControllerRequestPermissionsAction, PermissionControllerRequestPermissionsIncrementalAction, PermissionControllerRevokeAllPermissionsAction, PermissionControllerRevokePermissionForAllSubjectsAction, PermissionControllerRevokePermissionsAction, PermissionControllerUpdateCaveatAction, } from "./PermissionController-method-action-types.mjs";
7
+ export { createPermissionMiddleware, createPermissionMiddlewareV2, type PermissionMiddlewareActions, } from "./permission-middleware.mjs";
6
8
  export type { ExtractSpecifications, HandlerMiddlewareFunction, HookNames, PermittedHandlerExport, } from "./utils.mjs";
7
9
  export { MethodNames } from "./utils.mjs";
8
10
  export * as permissionRpcMethods from "./rpc-methods/index.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAAyB;AACzB,6BAAyB;AACzB,iCAA6B;AAC7B,2CAAuC;AACvC,YAAY,EACV,oCAAoC,EACpC,yCAAyC,EACzC,wCAAwC,EACxC,uCAAuC,EACvC,wCAAwC,EACxC,8CAA8C,EAC9C,2CAA2C,EAC3C,wDAAwD,EACxD,mCAAmC,EACnC,sCAAsC,EACtC,0CAA0C,EAC1C,qDAAqD,EACrD,4CAA4C,EAC5C,uDAAuD,EACvD,uCAAuC,EACvC,oDAAoD,GACrD,uDAAmD;AACpD,YAAY,EACV,qBAAqB,EACrB,yBAAyB,EACzB,SAAS,EACT,sBAAsB,GACvB,oBAAgB;AACjB,OAAO,EAAE,WAAW,EAAE,oBAAgB;AACtC,OAAO,KAAK,oBAAoB,gCAAsB;AACtD,gDAA4C;AAC5C,YAAY,EACV,yCAAyC,EACzC,iDAAiD,EACjD,iDAAiD,EACjD,gDAAgD,GACjD,4DAAwD"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAAyB;AACzB,OAAO,EAAE,+BAA+B,EAAE,8CAA0C;AACpF,6BAAyB;AACzB,iCAA6B;AAC7B,2CAAuC;AACvC,YAAY,EACV,oCAAoC,EACpC,iDAAiD,EACjD,mCAAmC,EACnC,uCAAuC,EACvC,wCAAwC,EACxC,yCAAyC,EACzC,0CAA0C,EAC1C,qDAAqD,EACrD,uCAAuC,EACvC,wCAAwC,EACxC,+CAA+C,EAC/C,4CAA4C,EAC5C,uDAAuD,EACvD,8CAA8C,EAC9C,wDAAwD,EACxD,2CAA2C,EAC3C,sCAAsC,GACvC,uDAAmD;AACpD,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,KAAK,2BAA2B,GACjC,oCAAgC;AACjC,YAAY,EACV,qBAAqB,EACrB,yBAAyB,EACzB,SAAS,EACT,sBAAsB,GACvB,oBAAgB;AACjB,OAAO,EAAE,WAAW,EAAE,oBAAgB;AACtC,OAAO,KAAK,oBAAoB,gCAAsB;AACtD,gDAA4C;AAC5C,YAAY,EACV,yCAAyC,EACzC,iDAAiD,EACjD,iDAAiD,EACjD,gDAAgD,GACjD,4DAAwD"}
package/dist/index.mjs CHANGED
@@ -1,7 +1,9 @@
1
1
  export * from "./Caveat.mjs";
2
+ export { createRestrictedMethodMessenger } from "./createRestrictedMethodMessenger.mjs";
2
3
  export * from "./errors.mjs";
3
4
  export * from "./Permission.mjs";
4
5
  export * from "./PermissionController.mjs";
6
+ export { createPermissionMiddleware, createPermissionMiddlewareV2 } from "./permission-middleware.mjs";
5
7
  export { MethodNames } from "./utils.mjs";
6
8
  export * as permissionRpcMethods from "./rpc-methods/index.mjs";
7
9
  export * from "./SubjectMetadataController.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAAyB;AACzB,6BAAyB;AACzB,iCAA6B;AAC7B,2CAAuC;AAyBvC,OAAO,EAAE,WAAW,EAAE,oBAAgB;AACtC,OAAO,KAAK,oBAAoB,gCAAsB;AACtD,gDAA4C","sourcesContent":["export * from './Caveat';\nexport * from './errors';\nexport * from './Permission';\nexport * from './PermissionController';\nexport type {\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 PermissionControllerCreatePermissionMiddlewareAction,\n} from './PermissionController-method-action-types';\nexport type {\n ExtractSpecifications,\n HandlerMiddlewareFunction,\n HookNames,\n PermittedHandlerExport,\n} from './utils';\nexport { MethodNames } from './utils';\nexport * as permissionRpcMethods from './rpc-methods';\nexport * from './SubjectMetadataController';\nexport type {\n SubjectMetadataControllerClearStateAction,\n SubjectMetadataControllerAddSubjectMetadataAction,\n SubjectMetadataControllerGetSubjectMetadataAction,\n SubjectMetadataControllerTrimMetadataStateAction,\n} from './SubjectMetadataController-method-action-types';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAAyB;AACzB,OAAO,EAAE,+BAA+B,EAAE,8CAA0C;AACpF,6BAAyB;AACzB,iCAA6B;AAC7B,2CAAuC;AAoBvC,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAE7B,oCAAgC;AAOjC,OAAO,EAAE,WAAW,EAAE,oBAAgB;AACtC,OAAO,KAAK,oBAAoB,gCAAsB;AACtD,gDAA4C","sourcesContent":["export * from './Caveat';\nexport { createRestrictedMethodMessenger } from './createRestrictedMethodMessenger';\nexport * from './errors';\nexport * from './Permission';\nexport * from './PermissionController';\nexport type {\n PermissionControllerClearStateAction,\n PermissionControllerExecuteRestrictedMethodAction,\n PermissionControllerGetCaveatAction,\n PermissionControllerGetEndowmentsAction,\n PermissionControllerGetPermissionsAction,\n PermissionControllerGetSubjectNamesAction,\n PermissionControllerGrantPermissionsAction,\n PermissionControllerGrantPermissionsIncrementalAction,\n PermissionControllerHasPermissionAction,\n PermissionControllerHasPermissionsAction,\n PermissionControllerHasUnrestrictedMethodAction,\n PermissionControllerRequestPermissionsAction,\n PermissionControllerRequestPermissionsIncrementalAction,\n PermissionControllerRevokeAllPermissionsAction,\n PermissionControllerRevokePermissionForAllSubjectsAction,\n PermissionControllerRevokePermissionsAction,\n PermissionControllerUpdateCaveatAction,\n} from './PermissionController-method-action-types';\nexport {\n createPermissionMiddleware,\n createPermissionMiddlewareV2,\n type PermissionMiddlewareActions,\n} from './permission-middleware';\nexport type {\n ExtractSpecifications,\n HandlerMiddlewareFunction,\n HookNames,\n PermittedHandlerExport,\n} from './utils';\nexport { MethodNames } from './utils';\nexport * as permissionRpcMethods from './rpc-methods';\nexport * from './SubjectMetadataController';\nexport type {\n SubjectMetadataControllerClearStateAction,\n SubjectMetadataControllerAddSubjectMetadataAction,\n SubjectMetadataControllerGetSubjectMetadataAction,\n SubjectMetadataControllerTrimMetadataStateAction,\n} from './SubjectMetadataController-method-action-types';\n"]}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPermissionMiddlewareV2 = exports.createPermissionMiddleware = void 0;
4
+ const json_rpc_engine_1 = require("@metamask/json-rpc-engine");
5
+ /**
6
+ * Creates a JSON-RPC middleware that enforces permissions for a single subject.
7
+ *
8
+ * The middleware passes through unrestricted methods, and otherwise dispatches
9
+ * restricted methods to the `PermissionController` via messenger actions. If
10
+ * the subject lacks the required permission, or if the method does not exist,
11
+ * the corresponding error is propagated to the JSON-RPC response.
12
+ *
13
+ * @deprecated Use {@link createPermissionMiddlewareV2} with `JsonRpcEngineV2`.
14
+ * @param options - Options bag.
15
+ * @param options.messenger - A messenger with the
16
+ * `PermissionController:executeRestrictedMethod` and
17
+ * `PermissionController:hasUnrestrictedMethod` actions.
18
+ * @param options.origin - The origin of the subject for which to create the middleware.
19
+ * @returns A `json-rpc-engine` middleware.
20
+ */
21
+ function createPermissionMiddleware({ messenger, origin, }) {
22
+ const permissionsMiddleware = async (request, response, next) => {
23
+ const { method, params } = request;
24
+ if (messenger.call('PermissionController:hasUnrestrictedMethod', method)) {
25
+ return next();
26
+ }
27
+ response.result = await messenger.call('PermissionController:executeRestrictedMethod', origin, method, params);
28
+ return undefined;
29
+ };
30
+ return (0, json_rpc_engine_1.createAsyncMiddleware)(permissionsMiddleware);
31
+ }
32
+ exports.createPermissionMiddleware = createPermissionMiddleware;
33
+ /**
34
+ * Creates a `JsonRpcEngineV2` middleware that enforces permissions for a
35
+ * single subject.
36
+ *
37
+ * The middleware passes through unrestricted methods, and otherwise dispatches
38
+ * restricted methods to the `PermissionController` via messenger actions. If
39
+ * the subject lacks the required permission, or if the method does not exist,
40
+ * the corresponding error is thrown.
41
+ *
42
+ * @param options - Options bag.
43
+ * @param options.messenger - A messenger with the
44
+ * `PermissionController:executeRestrictedMethod` and
45
+ * `PermissionController:hasUnrestrictedMethod` actions.
46
+ * @param options.origin - The origin of the subject for which to create the middleware.
47
+ * @returns A `JsonRpcEngineV2` middleware.
48
+ */
49
+ function createPermissionMiddlewareV2({ messenger, origin, }) {
50
+ return async ({ request, next }) => {
51
+ const { method, params } = request;
52
+ if (messenger.call('PermissionController:hasUnrestrictedMethod', method)) {
53
+ return next();
54
+ }
55
+ return messenger.call('PermissionController:executeRestrictedMethod', origin, method, params);
56
+ };
57
+ }
58
+ exports.createPermissionMiddlewareV2 = createPermissionMiddlewareV2;
59
+ //# sourceMappingURL=permission-middleware.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission-middleware.cjs","sourceRoot":"","sources":["../src/permission-middleware.ts"],"names":[],"mappings":";;;AAAA,+DAAkE;AA+BlE;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,0BAA0B,CAAC,EACzC,SAAS,EACT,MAAM,GAC4B;IAIlC,MAAM,qBAAqB,GAAG,KAAK,EACjC,OAAmD,EACnD,QAAgC,EAChC,IAAoC,EACrB,EAAE;QACjB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAEnC,IAAI,SAAS,CAAC,IAAI,CAAC,4CAA4C,EAAE,MAAM,CAAC,EAAE,CAAC;YACzE,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;QAED,QAAQ,CAAC,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CACpC,8CAA8C,EAC9C,MAAM,EACN,MAAM,EACN,MAAM,CACP,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,IAAA,uCAAqB,EAAC,qBAAqB,CAAC,CAAC;AACtD,CAAC;AA5BD,gEA4BC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,4BAA4B,CAAC,EAC3C,SAAS,EACT,MAAM,GAC4B;IAClC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;QACjC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAEnC,IAAI,SAAS,CAAC,IAAI,CAAC,4CAA4C,EAAE,MAAM,CAAC,EAAE,CAAC;YACzE,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;QAED,OAAO,SAAS,CAAC,IAAI,CACnB,8CAA8C,EAC9C,MAAM,EACN,MAAM,EACN,MAAM,CACP,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAlBD,oEAkBC","sourcesContent":["import { createAsyncMiddleware } from '@metamask/json-rpc-engine';\nimport type {\n AsyncJsonRpcEngineNextCallback,\n JsonRpcMiddleware,\n} from '@metamask/json-rpc-engine';\nimport type { JsonRpcMiddleware as JsonRpcMiddlewareV2 } from '@metamask/json-rpc-engine/v2';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n Json,\n JsonRpcRequest,\n PendingJsonRpcResponse,\n} from '@metamask/utils';\n\nimport type { RestrictedMethodParameters } from './Permission';\nimport type {\n PermissionControllerExecuteRestrictedMethodAction,\n PermissionControllerHasUnrestrictedMethodAction,\n} from './PermissionController-method-action-types';\n\n/**\n * The set of messenger actions required by the permission middleware.\n */\nexport type PermissionMiddlewareActions =\n | PermissionControllerExecuteRestrictedMethodAction\n | PermissionControllerHasUnrestrictedMethodAction;\n\nexport type CreatePermissionMiddlewareOptions = {\n messenger: Messenger<string, PermissionMiddlewareActions>;\n origin: string;\n};\n\n/**\n * Creates a JSON-RPC middleware that enforces permissions for a single subject.\n *\n * The middleware passes through unrestricted methods, and otherwise dispatches\n * restricted methods to the `PermissionController` via messenger actions. If\n * the subject lacks the required permission, or if the method does not exist,\n * the corresponding error is propagated to the JSON-RPC response.\n *\n * @deprecated Use {@link createPermissionMiddlewareV2} with `JsonRpcEngineV2`.\n * @param options - Options bag.\n * @param options.messenger - A messenger with the\n * `PermissionController:executeRestrictedMethod` and\n * `PermissionController:hasUnrestrictedMethod` actions.\n * @param options.origin - The origin of the subject for which to create the middleware.\n * @returns A `json-rpc-engine` middleware.\n */\nexport function createPermissionMiddleware({\n messenger,\n origin,\n}: CreatePermissionMiddlewareOptions): JsonRpcMiddleware<\n RestrictedMethodParameters,\n Json\n> {\n const permissionsMiddleware = async (\n request: JsonRpcRequest<RestrictedMethodParameters>,\n response: PendingJsonRpcResponse,\n next: AsyncJsonRpcEngineNextCallback,\n ): Promise<void> => {\n const { method, params } = request;\n\n if (messenger.call('PermissionController:hasUnrestrictedMethod', method)) {\n return next();\n }\n\n response.result = await messenger.call(\n 'PermissionController:executeRestrictedMethod',\n origin,\n method,\n params,\n );\n return undefined;\n };\n\n return createAsyncMiddleware(permissionsMiddleware);\n}\n\n/**\n * Creates a `JsonRpcEngineV2` middleware that enforces permissions for a\n * single subject.\n *\n * The middleware passes through unrestricted methods, and otherwise dispatches\n * restricted methods to the `PermissionController` via messenger actions. If\n * the subject lacks the required permission, or if the method does not exist,\n * the corresponding error is thrown.\n *\n * @param options - Options bag.\n * @param options.messenger - A messenger with the\n * `PermissionController:executeRestrictedMethod` and\n * `PermissionController:hasUnrestrictedMethod` actions.\n * @param options.origin - The origin of the subject for which to create the middleware.\n * @returns A `JsonRpcEngineV2` middleware.\n */\nexport function createPermissionMiddlewareV2({\n messenger,\n origin,\n}: CreatePermissionMiddlewareOptions): JsonRpcMiddlewareV2 {\n return async ({ request, next }) => {\n const { method, params } = request;\n\n if (messenger.call('PermissionController:hasUnrestrictedMethod', method)) {\n return next();\n }\n\n return messenger.call(\n 'PermissionController:executeRestrictedMethod',\n origin,\n method,\n params,\n );\n };\n}\n"]}
@@ -0,0 +1,49 @@
1
+ import type { JsonRpcMiddleware } from "@metamask/json-rpc-engine";
2
+ import type { JsonRpcMiddleware as JsonRpcMiddlewareV2 } from "@metamask/json-rpc-engine/v2";
3
+ import type { Messenger } from "@metamask/messenger";
4
+ import type { Json } from "@metamask/utils";
5
+ import type { RestrictedMethodParameters } from "./Permission.cjs";
6
+ import type { PermissionControllerExecuteRestrictedMethodAction, PermissionControllerHasUnrestrictedMethodAction } from "./PermissionController-method-action-types.cjs";
7
+ /**
8
+ * The set of messenger actions required by the permission middleware.
9
+ */
10
+ export type PermissionMiddlewareActions = PermissionControllerExecuteRestrictedMethodAction | PermissionControllerHasUnrestrictedMethodAction;
11
+ export type CreatePermissionMiddlewareOptions = {
12
+ messenger: Messenger<string, PermissionMiddlewareActions>;
13
+ origin: string;
14
+ };
15
+ /**
16
+ * Creates a JSON-RPC middleware that enforces permissions for a single subject.
17
+ *
18
+ * The middleware passes through unrestricted methods, and otherwise dispatches
19
+ * restricted methods to the `PermissionController` via messenger actions. If
20
+ * the subject lacks the required permission, or if the method does not exist,
21
+ * the corresponding error is propagated to the JSON-RPC response.
22
+ *
23
+ * @deprecated Use {@link createPermissionMiddlewareV2} with `JsonRpcEngineV2`.
24
+ * @param options - Options bag.
25
+ * @param options.messenger - A messenger with the
26
+ * `PermissionController:executeRestrictedMethod` and
27
+ * `PermissionController:hasUnrestrictedMethod` actions.
28
+ * @param options.origin - The origin of the subject for which to create the middleware.
29
+ * @returns A `json-rpc-engine` middleware.
30
+ */
31
+ export declare function createPermissionMiddleware({ messenger, origin, }: CreatePermissionMiddlewareOptions): JsonRpcMiddleware<RestrictedMethodParameters, Json>;
32
+ /**
33
+ * Creates a `JsonRpcEngineV2` middleware that enforces permissions for a
34
+ * single subject.
35
+ *
36
+ * The middleware passes through unrestricted methods, and otherwise dispatches
37
+ * restricted methods to the `PermissionController` via messenger actions. If
38
+ * the subject lacks the required permission, or if the method does not exist,
39
+ * the corresponding error is thrown.
40
+ *
41
+ * @param options - Options bag.
42
+ * @param options.messenger - A messenger with the
43
+ * `PermissionController:executeRestrictedMethod` and
44
+ * `PermissionController:hasUnrestrictedMethod` actions.
45
+ * @param options.origin - The origin of the subject for which to create the middleware.
46
+ * @returns A `JsonRpcEngineV2` middleware.
47
+ */
48
+ export declare function createPermissionMiddlewareV2({ messenger, origin, }: CreatePermissionMiddlewareOptions): JsonRpcMiddlewareV2;
49
+ //# sourceMappingURL=permission-middleware.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission-middleware.d.cts","sourceRoot":"","sources":["../src/permission-middleware.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,iBAAiB,EAClB,kCAAkC;AACnC,OAAO,KAAK,EAAE,iBAAiB,IAAI,mBAAmB,EAAE,qCAAqC;AAC7F,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EACV,IAAI,EAGL,wBAAwB;AAEzB,OAAO,KAAK,EAAE,0BAA0B,EAAE,yBAAqB;AAC/D,OAAO,KAAK,EACV,iDAAiD,EACjD,+CAA+C,EAChD,uDAAmD;AAEpD;;GAEG;AACH,MAAM,MAAM,2BAA2B,GACnC,iDAAiD,GACjD,+CAA+C,CAAC;AAEpD,MAAM,MAAM,iCAAiC,GAAG;IAC9C,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC;IAC1D,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,SAAS,EACT,MAAM,GACP,EAAE,iCAAiC,GAAG,iBAAiB,CACtD,0BAA0B,EAC1B,IAAI,CACL,CAsBA;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,SAAS,EACT,MAAM,GACP,EAAE,iCAAiC,GAAG,mBAAmB,CAezD"}
@@ -0,0 +1,49 @@
1
+ import type { JsonRpcMiddleware } from "@metamask/json-rpc-engine";
2
+ import type { JsonRpcMiddleware as JsonRpcMiddlewareV2 } from "@metamask/json-rpc-engine/v2";
3
+ import type { Messenger } from "@metamask/messenger";
4
+ import type { Json } from "@metamask/utils";
5
+ import type { RestrictedMethodParameters } from "./Permission.mjs";
6
+ import type { PermissionControllerExecuteRestrictedMethodAction, PermissionControllerHasUnrestrictedMethodAction } from "./PermissionController-method-action-types.mjs";
7
+ /**
8
+ * The set of messenger actions required by the permission middleware.
9
+ */
10
+ export type PermissionMiddlewareActions = PermissionControllerExecuteRestrictedMethodAction | PermissionControllerHasUnrestrictedMethodAction;
11
+ export type CreatePermissionMiddlewareOptions = {
12
+ messenger: Messenger<string, PermissionMiddlewareActions>;
13
+ origin: string;
14
+ };
15
+ /**
16
+ * Creates a JSON-RPC middleware that enforces permissions for a single subject.
17
+ *
18
+ * The middleware passes through unrestricted methods, and otherwise dispatches
19
+ * restricted methods to the `PermissionController` via messenger actions. If
20
+ * the subject lacks the required permission, or if the method does not exist,
21
+ * the corresponding error is propagated to the JSON-RPC response.
22
+ *
23
+ * @deprecated Use {@link createPermissionMiddlewareV2} with `JsonRpcEngineV2`.
24
+ * @param options - Options bag.
25
+ * @param options.messenger - A messenger with the
26
+ * `PermissionController:executeRestrictedMethod` and
27
+ * `PermissionController:hasUnrestrictedMethod` actions.
28
+ * @param options.origin - The origin of the subject for which to create the middleware.
29
+ * @returns A `json-rpc-engine` middleware.
30
+ */
31
+ export declare function createPermissionMiddleware({ messenger, origin, }: CreatePermissionMiddlewareOptions): JsonRpcMiddleware<RestrictedMethodParameters, Json>;
32
+ /**
33
+ * Creates a `JsonRpcEngineV2` middleware that enforces permissions for a
34
+ * single subject.
35
+ *
36
+ * The middleware passes through unrestricted methods, and otherwise dispatches
37
+ * restricted methods to the `PermissionController` via messenger actions. If
38
+ * the subject lacks the required permission, or if the method does not exist,
39
+ * the corresponding error is thrown.
40
+ *
41
+ * @param options - Options bag.
42
+ * @param options.messenger - A messenger with the
43
+ * `PermissionController:executeRestrictedMethod` and
44
+ * `PermissionController:hasUnrestrictedMethod` actions.
45
+ * @param options.origin - The origin of the subject for which to create the middleware.
46
+ * @returns A `JsonRpcEngineV2` middleware.
47
+ */
48
+ export declare function createPermissionMiddlewareV2({ messenger, origin, }: CreatePermissionMiddlewareOptions): JsonRpcMiddlewareV2;
49
+ //# sourceMappingURL=permission-middleware.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission-middleware.d.mts","sourceRoot":"","sources":["../src/permission-middleware.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,iBAAiB,EAClB,kCAAkC;AACnC,OAAO,KAAK,EAAE,iBAAiB,IAAI,mBAAmB,EAAE,qCAAqC;AAC7F,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EACV,IAAI,EAGL,wBAAwB;AAEzB,OAAO,KAAK,EAAE,0BAA0B,EAAE,yBAAqB;AAC/D,OAAO,KAAK,EACV,iDAAiD,EACjD,+CAA+C,EAChD,uDAAmD;AAEpD;;GAEG;AACH,MAAM,MAAM,2BAA2B,GACnC,iDAAiD,GACjD,+CAA+C,CAAC;AAEpD,MAAM,MAAM,iCAAiC,GAAG;IAC9C,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAC;IAC1D,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,SAAS,EACT,MAAM,GACP,EAAE,iCAAiC,GAAG,iBAAiB,CACtD,0BAA0B,EAC1B,IAAI,CACL,CAsBA;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,SAAS,EACT,MAAM,GACP,EAAE,iCAAiC,GAAG,mBAAmB,CAezD"}
@@ -0,0 +1,54 @@
1
+ import { createAsyncMiddleware } from "@metamask/json-rpc-engine";
2
+ /**
3
+ * Creates a JSON-RPC middleware that enforces permissions for a single subject.
4
+ *
5
+ * The middleware passes through unrestricted methods, and otherwise dispatches
6
+ * restricted methods to the `PermissionController` via messenger actions. If
7
+ * the subject lacks the required permission, or if the method does not exist,
8
+ * the corresponding error is propagated to the JSON-RPC response.
9
+ *
10
+ * @deprecated Use {@link createPermissionMiddlewareV2} with `JsonRpcEngineV2`.
11
+ * @param options - Options bag.
12
+ * @param options.messenger - A messenger with the
13
+ * `PermissionController:executeRestrictedMethod` and
14
+ * `PermissionController:hasUnrestrictedMethod` actions.
15
+ * @param options.origin - The origin of the subject for which to create the middleware.
16
+ * @returns A `json-rpc-engine` middleware.
17
+ */
18
+ export function createPermissionMiddleware({ messenger, origin, }) {
19
+ const permissionsMiddleware = async (request, response, next) => {
20
+ const { method, params } = request;
21
+ if (messenger.call('PermissionController:hasUnrestrictedMethod', method)) {
22
+ return next();
23
+ }
24
+ response.result = await messenger.call('PermissionController:executeRestrictedMethod', origin, method, params);
25
+ return undefined;
26
+ };
27
+ return createAsyncMiddleware(permissionsMiddleware);
28
+ }
29
+ /**
30
+ * Creates a `JsonRpcEngineV2` middleware that enforces permissions for a
31
+ * single subject.
32
+ *
33
+ * The middleware passes through unrestricted methods, and otherwise dispatches
34
+ * restricted methods to the `PermissionController` via messenger actions. If
35
+ * the subject lacks the required permission, or if the method does not exist,
36
+ * the corresponding error is thrown.
37
+ *
38
+ * @param options - Options bag.
39
+ * @param options.messenger - A messenger with the
40
+ * `PermissionController:executeRestrictedMethod` and
41
+ * `PermissionController:hasUnrestrictedMethod` actions.
42
+ * @param options.origin - The origin of the subject for which to create the middleware.
43
+ * @returns A `JsonRpcEngineV2` middleware.
44
+ */
45
+ export function createPermissionMiddlewareV2({ messenger, origin, }) {
46
+ return async ({ request, next }) => {
47
+ const { method, params } = request;
48
+ if (messenger.call('PermissionController:hasUnrestrictedMethod', method)) {
49
+ return next();
50
+ }
51
+ return messenger.call('PermissionController:executeRestrictedMethod', origin, method, params);
52
+ };
53
+ }
54
+ //# sourceMappingURL=permission-middleware.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission-middleware.mjs","sourceRoot":"","sources":["../src/permission-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,kCAAkC;AA+BlE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,0BAA0B,CAAC,EACzC,SAAS,EACT,MAAM,GAC4B;IAIlC,MAAM,qBAAqB,GAAG,KAAK,EACjC,OAAmD,EACnD,QAAgC,EAChC,IAAoC,EACrB,EAAE;QACjB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAEnC,IAAI,SAAS,CAAC,IAAI,CAAC,4CAA4C,EAAE,MAAM,CAAC,EAAE,CAAC;YACzE,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;QAED,QAAQ,CAAC,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,CACpC,8CAA8C,EAC9C,MAAM,EACN,MAAM,EACN,MAAM,CACP,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,qBAAqB,CAAC,qBAAqB,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,4BAA4B,CAAC,EAC3C,SAAS,EACT,MAAM,GAC4B;IAClC,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;QACjC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAEnC,IAAI,SAAS,CAAC,IAAI,CAAC,4CAA4C,EAAE,MAAM,CAAC,EAAE,CAAC;YACzE,OAAO,IAAI,EAAE,CAAC;QAChB,CAAC;QAED,OAAO,SAAS,CAAC,IAAI,CACnB,8CAA8C,EAC9C,MAAM,EACN,MAAM,EACN,MAAM,CACP,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { createAsyncMiddleware } from '@metamask/json-rpc-engine';\nimport type {\n AsyncJsonRpcEngineNextCallback,\n JsonRpcMiddleware,\n} from '@metamask/json-rpc-engine';\nimport type { JsonRpcMiddleware as JsonRpcMiddlewareV2 } from '@metamask/json-rpc-engine/v2';\nimport type { Messenger } from '@metamask/messenger';\nimport type {\n Json,\n JsonRpcRequest,\n PendingJsonRpcResponse,\n} from '@metamask/utils';\n\nimport type { RestrictedMethodParameters } from './Permission';\nimport type {\n PermissionControllerExecuteRestrictedMethodAction,\n PermissionControllerHasUnrestrictedMethodAction,\n} from './PermissionController-method-action-types';\n\n/**\n * The set of messenger actions required by the permission middleware.\n */\nexport type PermissionMiddlewareActions =\n | PermissionControllerExecuteRestrictedMethodAction\n | PermissionControllerHasUnrestrictedMethodAction;\n\nexport type CreatePermissionMiddlewareOptions = {\n messenger: Messenger<string, PermissionMiddlewareActions>;\n origin: string;\n};\n\n/**\n * Creates a JSON-RPC middleware that enforces permissions for a single subject.\n *\n * The middleware passes through unrestricted methods, and otherwise dispatches\n * restricted methods to the `PermissionController` via messenger actions. If\n * the subject lacks the required permission, or if the method does not exist,\n * the corresponding error is propagated to the JSON-RPC response.\n *\n * @deprecated Use {@link createPermissionMiddlewareV2} with `JsonRpcEngineV2`.\n * @param options - Options bag.\n * @param options.messenger - A messenger with the\n * `PermissionController:executeRestrictedMethod` and\n * `PermissionController:hasUnrestrictedMethod` actions.\n * @param options.origin - The origin of the subject for which to create the middleware.\n * @returns A `json-rpc-engine` middleware.\n */\nexport function createPermissionMiddleware({\n messenger,\n origin,\n}: CreatePermissionMiddlewareOptions): JsonRpcMiddleware<\n RestrictedMethodParameters,\n Json\n> {\n const permissionsMiddleware = async (\n request: JsonRpcRequest<RestrictedMethodParameters>,\n response: PendingJsonRpcResponse,\n next: AsyncJsonRpcEngineNextCallback,\n ): Promise<void> => {\n const { method, params } = request;\n\n if (messenger.call('PermissionController:hasUnrestrictedMethod', method)) {\n return next();\n }\n\n response.result = await messenger.call(\n 'PermissionController:executeRestrictedMethod',\n origin,\n method,\n params,\n );\n return undefined;\n };\n\n return createAsyncMiddleware(permissionsMiddleware);\n}\n\n/**\n * Creates a `JsonRpcEngineV2` middleware that enforces permissions for a\n * single subject.\n *\n * The middleware passes through unrestricted methods, and otherwise dispatches\n * restricted methods to the `PermissionController` via messenger actions. If\n * the subject lacks the required permission, or if the method does not exist,\n * the corresponding error is thrown.\n *\n * @param options - Options bag.\n * @param options.messenger - A messenger with the\n * `PermissionController:executeRestrictedMethod` and\n * `PermissionController:hasUnrestrictedMethod` actions.\n * @param options.origin - The origin of the subject for which to create the middleware.\n * @returns A `JsonRpcEngineV2` middleware.\n */\nexport function createPermissionMiddlewareV2({\n messenger,\n origin,\n}: CreatePermissionMiddlewareOptions): JsonRpcMiddlewareV2 {\n return async ({ request, next }) => {\n const { method, params } = request;\n\n if (messenger.call('PermissionController:hasUnrestrictedMethod', method)) {\n return next();\n }\n\n return messenger.call(\n 'PermissionController:executeRestrictedMethod',\n origin,\n method,\n params,\n );\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/permission-controller",
3
- "version": "12.3.0-preview-938fc5d87",
3
+ "version": "12.3.0-preview-495c91e",
4
4
  "description": "Mediates access to JSON-RPC methods, used to interact with pieces of the MetaMask stack, via middleware for json-rpc-engine",
5
5
  "keywords": [
6
6
  "Ethereum",