@metamask/snaps-rpc-methods 11.13.0 → 11.13.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 CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [11.13.1]
11
+
12
+ ### Fixed
13
+
14
+ - Unlock client before calling `getEntropySources` in `snap_listEntropySources` method ([#3194](https://github.com/MetaMask/snaps/pull/3194))
15
+
10
16
  ## [11.13.0]
11
17
 
12
18
  ### Added
@@ -400,7 +406,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
400
406
  - The version of the package no longer needs to match the version of all other
401
407
  MetaMask Snaps packages.
402
408
 
403
- [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@11.13.0...HEAD
409
+ [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@11.13.1...HEAD
410
+ [11.13.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@11.13.0...@metamask/snaps-rpc-methods@11.13.1
404
411
  [11.13.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@11.12.0...@metamask/snaps-rpc-methods@11.13.0
405
412
  [11.12.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@11.11.0...@metamask/snaps-rpc-methods@11.12.0
406
413
  [11.11.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@11.10.0...@metamask/snaps-rpc-methods@11.11.0
@@ -19,6 +19,7 @@ const REQUIRED_PERMISSIONS = [
19
19
  const hookNames = {
20
20
  hasPermission: true,
21
21
  getEntropySources: true,
22
+ getUnlockPromise: true,
22
23
  };
23
24
  exports.listEntropySourcesHandler = {
24
25
  methodNames: ['snap_listEntropySources'],
@@ -26,7 +27,7 @@ exports.listEntropySourcesHandler = {
26
27
  hookNames,
27
28
  };
28
29
  /**
29
- * The `snap_getInterfaceContext` method implementation.
30
+ * The `snap_listEntropySources` method implementation.
30
31
  *
31
32
  * @param _request - The JSON-RPC request object. Not used by this function.
32
33
  * @param response - The JSON-RPC response object.
@@ -37,13 +38,15 @@ exports.listEntropySourcesHandler = {
37
38
  * @param hooks.hasPermission - The function to check if the origin has a
38
39
  * permission.
39
40
  * @param hooks.getEntropySources - The function to get the entropy sources.
41
+ * @param hooks.getUnlockPromise - The function to get the unlock promise.
40
42
  * @returns Noting.
41
43
  */
42
- function listEntropySourcesImplementation(_request, response, _next, end, { hasPermission, getEntropySources }) {
44
+ async function listEntropySourcesImplementation(_request, response, _next, end, { hasPermission, getEntropySources, getUnlockPromise, }) {
43
45
  const isPermitted = REQUIRED_PERMISSIONS.some(hasPermission);
44
46
  if (!isPermitted) {
45
47
  return end(rpc_errors_1.providerErrors.unauthorized());
46
48
  }
49
+ await getUnlockPromise(true);
47
50
  response.result = getEntropySources();
48
51
  return end();
49
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"listEntropySources.cjs","sourceRoot":"","sources":["../../src/permitted/listEntropySources.ts"],"names":[],"mappings":";;;AAEA,qDAAsD;AAStD,uEAAuE;AACvE,2EAA2E;AAC3E,uEAAuE;AACvE,6DAA6D;AAG7D;;;GAGG;AACH,MAAM,oBAAoB,GAAG;IAC3B,wCAAsB,CAAC,UAAU;IACjC,4CAAwB,CAAC,UAAU;IACnC,wCAAsB,CAAC,UAAU;IACjC,8BAAiB,CAAC,UAAU;CAC7B,CAAC;AAEF,MAAM,SAAS,GAA+C;IAC5D,aAAa,EAAE,IAAI;IACnB,iBAAiB,EAAE,IAAI;CACxB,CAAC;AAmBW,QAAA,yBAAyB,GAIlC;IACF,WAAW,EAAE,CAAC,yBAAyB,CAAC;IACxC,cAAc,EAAE,gCAAgC;IAChD,SAAS;CACV,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,SAAS,gCAAgC,CACvC,QAAkD,EAClD,QAA0D,EAC1D,KAAc,EACd,GAA6B,EAC7B,EAAE,aAAa,EAAE,iBAAiB,EAA2B;IAE7D,MAAM,WAAW,GAAG,oBAAoB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC7D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,GAAG,CAAC,2BAAc,CAAC,YAAY,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,QAAQ,CAAC,MAAM,GAAG,iBAAiB,EAAE,CAAC;IACtC,OAAO,GAAG,EAAE,CAAC;AACf,CAAC","sourcesContent":["import type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine';\nimport type { PermittedHandlerExport } from '@metamask/permission-controller';\nimport { providerErrors } from '@metamask/rpc-errors';\nimport type {\n EntropySource,\n JsonRpcRequest,\n ListEntropySourcesParams,\n ListEntropySourcesResult,\n} from '@metamask/snaps-sdk';\nimport type { PendingJsonRpcResponse } from '@metamask/utils';\n\nimport { getBip32EntropyBuilder } from '../restricted/getBip32Entropy';\nimport { getBip32PublicKeyBuilder } from '../restricted/getBip32PublicKey';\nimport { getBip44EntropyBuilder } from '../restricted/getBip44Entropy';\nimport { getEntropyBuilder } from '../restricted/getEntropy';\nimport type { MethodHooksObject } from '../utils';\n\n/**\n * A list of permissions that the requesting origin must have at least one of\n * in order to call this method.\n */\nconst REQUIRED_PERMISSIONS = [\n getBip32EntropyBuilder.targetName,\n getBip32PublicKeyBuilder.targetName,\n getBip44EntropyBuilder.targetName,\n getEntropyBuilder.targetName,\n];\n\nconst hookNames: MethodHooksObject<ListEntropySourcesHooks> = {\n hasPermission: true,\n getEntropySources: true,\n};\n\nexport type ListEntropySourcesHooks = {\n /**\n * Check if the requesting origin has a given permission.\n *\n * @param permissionName - The name of the permission to check.\n * @returns Whether the origin has the permission.\n */\n hasPermission: (permissionName: string) => boolean;\n\n /**\n * Get the entropy sources from the client.\n *\n * @returns The entropy sources.\n */\n getEntropySources: () => EntropySource[];\n};\n\nexport const listEntropySourcesHandler: PermittedHandlerExport<\n ListEntropySourcesHooks,\n ListEntropySourcesParams,\n ListEntropySourcesResult\n> = {\n methodNames: ['snap_listEntropySources'],\n implementation: listEntropySourcesImplementation,\n hookNames,\n};\n\n/**\n * The `snap_getInterfaceContext` method implementation.\n *\n * @param _request - The JSON-RPC request object. Not used by this function.\n * @param response - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param hooks - The RPC method hooks.\n * @param hooks.hasPermission - The function to check if the origin has a\n * permission.\n * @param hooks.getEntropySources - The function to get the entropy sources.\n * @returns Noting.\n */\nfunction listEntropySourcesImplementation(\n _request: JsonRpcRequest<ListEntropySourcesParams>,\n response: PendingJsonRpcResponse<ListEntropySourcesResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n { hasPermission, getEntropySources }: ListEntropySourcesHooks,\n): void {\n const isPermitted = REQUIRED_PERMISSIONS.some(hasPermission);\n if (!isPermitted) {\n return end(providerErrors.unauthorized());\n }\n\n response.result = getEntropySources();\n return end();\n}\n"]}
1
+ {"version":3,"file":"listEntropySources.cjs","sourceRoot":"","sources":["../../src/permitted/listEntropySources.ts"],"names":[],"mappings":";;;AAEA,qDAAsD;AAStD,uEAAuE;AACvE,2EAA2E;AAC3E,uEAAuE;AACvE,6DAA6D;AAG7D;;;GAGG;AACH,MAAM,oBAAoB,GAAG;IAC3B,wCAAsB,CAAC,UAAU;IACjC,4CAAwB,CAAC,UAAU;IACnC,wCAAsB,CAAC,UAAU;IACjC,8BAAiB,CAAC,UAAU;CAC7B,CAAC;AAEF,MAAM,SAAS,GAA+C;IAC5D,aAAa,EAAE,IAAI;IACnB,iBAAiB,EAAE,IAAI;IACvB,gBAAgB,EAAE,IAAI;CACvB,CAAC;AA0BW,QAAA,yBAAyB,GAIlC;IACF,WAAW,EAAE,CAAC,yBAAyB,CAAC;IACxC,cAAc,EAAE,gCAAgC;IAChD,SAAS;CACV,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,KAAK,UAAU,gCAAgC,CAC7C,QAAkD,EAClD,QAA0D,EAC1D,KAAc,EACd,GAA6B,EAC7B,EACE,aAAa,EACb,iBAAiB,EACjB,gBAAgB,GACQ;IAE1B,MAAM,WAAW,GAAG,oBAAoB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC7D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,GAAG,CAAC,2BAAc,CAAC,YAAY,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAE7B,QAAQ,CAAC,MAAM,GAAG,iBAAiB,EAAE,CAAC;IACtC,OAAO,GAAG,EAAE,CAAC;AACf,CAAC","sourcesContent":["import type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine';\nimport type { PermittedHandlerExport } from '@metamask/permission-controller';\nimport { providerErrors } from '@metamask/rpc-errors';\nimport type {\n EntropySource,\n JsonRpcRequest,\n ListEntropySourcesParams,\n ListEntropySourcesResult,\n} from '@metamask/snaps-sdk';\nimport type { PendingJsonRpcResponse } from '@metamask/utils';\n\nimport { getBip32EntropyBuilder } from '../restricted/getBip32Entropy';\nimport { getBip32PublicKeyBuilder } from '../restricted/getBip32PublicKey';\nimport { getBip44EntropyBuilder } from '../restricted/getBip44Entropy';\nimport { getEntropyBuilder } from '../restricted/getEntropy';\nimport type { MethodHooksObject } from '../utils';\n\n/**\n * A list of permissions that the requesting origin must have at least one of\n * in order to call this method.\n */\nconst REQUIRED_PERMISSIONS = [\n getBip32EntropyBuilder.targetName,\n getBip32PublicKeyBuilder.targetName,\n getBip44EntropyBuilder.targetName,\n getEntropyBuilder.targetName,\n];\n\nconst hookNames: MethodHooksObject<ListEntropySourcesHooks> = {\n hasPermission: true,\n getEntropySources: true,\n getUnlockPromise: true,\n};\n\nexport type ListEntropySourcesHooks = {\n /**\n * Check if the requesting origin has a given permission.\n *\n * @param permissionName - The name of the permission to check.\n * @returns Whether the origin has the permission.\n */\n hasPermission: (permissionName: string) => boolean;\n\n /**\n * Get the entropy sources from the client.\n *\n * @returns The entropy sources.\n */\n getEntropySources: () => EntropySource[];\n\n /**\n * Wait for the extension to be unlocked.\n *\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n};\n\nexport const listEntropySourcesHandler: PermittedHandlerExport<\n ListEntropySourcesHooks,\n ListEntropySourcesParams,\n ListEntropySourcesResult\n> = {\n methodNames: ['snap_listEntropySources'],\n implementation: listEntropySourcesImplementation,\n hookNames,\n};\n\n/**\n * The `snap_listEntropySources` method implementation.\n *\n * @param _request - The JSON-RPC request object. Not used by this function.\n * @param response - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param hooks - The RPC method hooks.\n * @param hooks.hasPermission - The function to check if the origin has a\n * permission.\n * @param hooks.getEntropySources - The function to get the entropy sources.\n * @param hooks.getUnlockPromise - The function to get the unlock promise.\n * @returns Noting.\n */\nasync function listEntropySourcesImplementation(\n _request: JsonRpcRequest<ListEntropySourcesParams>,\n response: PendingJsonRpcResponse<ListEntropySourcesResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n {\n hasPermission,\n getEntropySources,\n getUnlockPromise,\n }: ListEntropySourcesHooks,\n): Promise<void> {\n const isPermitted = REQUIRED_PERMISSIONS.some(hasPermission);\n if (!isPermitted) {\n return end(providerErrors.unauthorized());\n }\n\n await getUnlockPromise(true);\n\n response.result = getEntropySources();\n return end();\n}\n"]}
@@ -14,6 +14,12 @@ export type ListEntropySourcesHooks = {
14
14
  * @returns The entropy sources.
15
15
  */
16
16
  getEntropySources: () => EntropySource[];
17
+ /**
18
+ * Wait for the extension to be unlocked.
19
+ *
20
+ * @returns A promise that resolves once the extension is unlocked.
21
+ */
22
+ getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;
17
23
  };
18
24
  export declare const listEntropySourcesHandler: PermittedHandlerExport<ListEntropySourcesHooks, ListEntropySourcesParams, ListEntropySourcesResult>;
19
25
  //# sourceMappingURL=listEntropySources.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"listEntropySources.d.cts","sourceRoot":"","sources":["../../src/permitted/listEntropySources.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAwC;AAE9E,OAAO,KAAK,EACV,aAAa,EAEb,wBAAwB,EACxB,wBAAwB,EACzB,4BAA4B;AAyB7B,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;;;OAKG;IACH,aAAa,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC;IAEnD;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,aAAa,EAAE,CAAC;CAC1C,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,sBAAsB,CAC5D,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,CAKzB,CAAC"}
1
+ {"version":3,"file":"listEntropySources.d.cts","sourceRoot":"","sources":["../../src/permitted/listEntropySources.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAwC;AAE9E,OAAO,KAAK,EACV,aAAa,EAEb,wBAAwB,EACxB,wBAAwB,EACzB,4BAA4B;AA0B7B,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;;;OAKG;IACH,aAAa,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC;IAEnD;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,aAAa,EAAE,CAAC;IAEzC;;;;OAIG;IACH,gBAAgB,EAAE,CAAC,uBAAuB,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,sBAAsB,CAC5D,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,CAKzB,CAAC"}
@@ -14,6 +14,12 @@ export type ListEntropySourcesHooks = {
14
14
  * @returns The entropy sources.
15
15
  */
16
16
  getEntropySources: () => EntropySource[];
17
+ /**
18
+ * Wait for the extension to be unlocked.
19
+ *
20
+ * @returns A promise that resolves once the extension is unlocked.
21
+ */
22
+ getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;
17
23
  };
18
24
  export declare const listEntropySourcesHandler: PermittedHandlerExport<ListEntropySourcesHooks, ListEntropySourcesParams, ListEntropySourcesResult>;
19
25
  //# sourceMappingURL=listEntropySources.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"listEntropySources.d.mts","sourceRoot":"","sources":["../../src/permitted/listEntropySources.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAwC;AAE9E,OAAO,KAAK,EACV,aAAa,EAEb,wBAAwB,EACxB,wBAAwB,EACzB,4BAA4B;AAyB7B,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;;;OAKG;IACH,aAAa,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC;IAEnD;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,aAAa,EAAE,CAAC;CAC1C,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,sBAAsB,CAC5D,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,CAKzB,CAAC"}
1
+ {"version":3,"file":"listEntropySources.d.mts","sourceRoot":"","sources":["../../src/permitted/listEntropySources.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,wCAAwC;AAE9E,OAAO,KAAK,EACV,aAAa,EAEb,wBAAwB,EACxB,wBAAwB,EACzB,4BAA4B;AA0B7B,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;;;OAKG;IACH,aAAa,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC;IAEnD;;;;OAIG;IACH,iBAAiB,EAAE,MAAM,aAAa,EAAE,CAAC;IAEzC;;;;OAIG;IACH,gBAAgB,EAAE,CAAC,uBAAuB,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,sBAAsB,CAC5D,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,CAKzB,CAAC"}
@@ -16,6 +16,7 @@ const REQUIRED_PERMISSIONS = [
16
16
  const hookNames = {
17
17
  hasPermission: true,
18
18
  getEntropySources: true,
19
+ getUnlockPromise: true,
19
20
  };
20
21
  export const listEntropySourcesHandler = {
21
22
  methodNames: ['snap_listEntropySources'],
@@ -23,7 +24,7 @@ export const listEntropySourcesHandler = {
23
24
  hookNames,
24
25
  };
25
26
  /**
26
- * The `snap_getInterfaceContext` method implementation.
27
+ * The `snap_listEntropySources` method implementation.
27
28
  *
28
29
  * @param _request - The JSON-RPC request object. Not used by this function.
29
30
  * @param response - The JSON-RPC response object.
@@ -34,13 +35,15 @@ export const listEntropySourcesHandler = {
34
35
  * @param hooks.hasPermission - The function to check if the origin has a
35
36
  * permission.
36
37
  * @param hooks.getEntropySources - The function to get the entropy sources.
38
+ * @param hooks.getUnlockPromise - The function to get the unlock promise.
37
39
  * @returns Noting.
38
40
  */
39
- function listEntropySourcesImplementation(_request, response, _next, end, { hasPermission, getEntropySources }) {
41
+ async function listEntropySourcesImplementation(_request, response, _next, end, { hasPermission, getEntropySources, getUnlockPromise, }) {
40
42
  const isPermitted = REQUIRED_PERMISSIONS.some(hasPermission);
41
43
  if (!isPermitted) {
42
44
  return end(providerErrors.unauthorized());
43
45
  }
46
+ await getUnlockPromise(true);
44
47
  response.result = getEntropySources();
45
48
  return end();
46
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"listEntropySources.mjs","sourceRoot":"","sources":["../../src/permitted/listEntropySources.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,6BAA6B;AAStD,OAAO,EAAE,sBAAsB,EAAE,0CAAsC;AACvE,OAAO,EAAE,wBAAwB,EAAE,4CAAwC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,0CAAsC;AACvE,OAAO,EAAE,iBAAiB,EAAE,qCAAiC;AAG7D;;;GAGG;AACH,MAAM,oBAAoB,GAAG;IAC3B,sBAAsB,CAAC,UAAU;IACjC,wBAAwB,CAAC,UAAU;IACnC,sBAAsB,CAAC,UAAU;IACjC,iBAAiB,CAAC,UAAU;CAC7B,CAAC;AAEF,MAAM,SAAS,GAA+C;IAC5D,aAAa,EAAE,IAAI;IACnB,iBAAiB,EAAE,IAAI;CACxB,CAAC;AAmBF,MAAM,CAAC,MAAM,yBAAyB,GAIlC;IACF,WAAW,EAAE,CAAC,yBAAyB,CAAC;IACxC,cAAc,EAAE,gCAAgC;IAChD,SAAS;CACV,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,SAAS,gCAAgC,CACvC,QAAkD,EAClD,QAA0D,EAC1D,KAAc,EACd,GAA6B,EAC7B,EAAE,aAAa,EAAE,iBAAiB,EAA2B;IAE7D,MAAM,WAAW,GAAG,oBAAoB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC7D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,GAAG,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,QAAQ,CAAC,MAAM,GAAG,iBAAiB,EAAE,CAAC;IACtC,OAAO,GAAG,EAAE,CAAC;AACf,CAAC","sourcesContent":["import type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine';\nimport type { PermittedHandlerExport } from '@metamask/permission-controller';\nimport { providerErrors } from '@metamask/rpc-errors';\nimport type {\n EntropySource,\n JsonRpcRequest,\n ListEntropySourcesParams,\n ListEntropySourcesResult,\n} from '@metamask/snaps-sdk';\nimport type { PendingJsonRpcResponse } from '@metamask/utils';\n\nimport { getBip32EntropyBuilder } from '../restricted/getBip32Entropy';\nimport { getBip32PublicKeyBuilder } from '../restricted/getBip32PublicKey';\nimport { getBip44EntropyBuilder } from '../restricted/getBip44Entropy';\nimport { getEntropyBuilder } from '../restricted/getEntropy';\nimport type { MethodHooksObject } from '../utils';\n\n/**\n * A list of permissions that the requesting origin must have at least one of\n * in order to call this method.\n */\nconst REQUIRED_PERMISSIONS = [\n getBip32EntropyBuilder.targetName,\n getBip32PublicKeyBuilder.targetName,\n getBip44EntropyBuilder.targetName,\n getEntropyBuilder.targetName,\n];\n\nconst hookNames: MethodHooksObject<ListEntropySourcesHooks> = {\n hasPermission: true,\n getEntropySources: true,\n};\n\nexport type ListEntropySourcesHooks = {\n /**\n * Check if the requesting origin has a given permission.\n *\n * @param permissionName - The name of the permission to check.\n * @returns Whether the origin has the permission.\n */\n hasPermission: (permissionName: string) => boolean;\n\n /**\n * Get the entropy sources from the client.\n *\n * @returns The entropy sources.\n */\n getEntropySources: () => EntropySource[];\n};\n\nexport const listEntropySourcesHandler: PermittedHandlerExport<\n ListEntropySourcesHooks,\n ListEntropySourcesParams,\n ListEntropySourcesResult\n> = {\n methodNames: ['snap_listEntropySources'],\n implementation: listEntropySourcesImplementation,\n hookNames,\n};\n\n/**\n * The `snap_getInterfaceContext` method implementation.\n *\n * @param _request - The JSON-RPC request object. Not used by this function.\n * @param response - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param hooks - The RPC method hooks.\n * @param hooks.hasPermission - The function to check if the origin has a\n * permission.\n * @param hooks.getEntropySources - The function to get the entropy sources.\n * @returns Noting.\n */\nfunction listEntropySourcesImplementation(\n _request: JsonRpcRequest<ListEntropySourcesParams>,\n response: PendingJsonRpcResponse<ListEntropySourcesResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n { hasPermission, getEntropySources }: ListEntropySourcesHooks,\n): void {\n const isPermitted = REQUIRED_PERMISSIONS.some(hasPermission);\n if (!isPermitted) {\n return end(providerErrors.unauthorized());\n }\n\n response.result = getEntropySources();\n return end();\n}\n"]}
1
+ {"version":3,"file":"listEntropySources.mjs","sourceRoot":"","sources":["../../src/permitted/listEntropySources.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,6BAA6B;AAStD,OAAO,EAAE,sBAAsB,EAAE,0CAAsC;AACvE,OAAO,EAAE,wBAAwB,EAAE,4CAAwC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,0CAAsC;AACvE,OAAO,EAAE,iBAAiB,EAAE,qCAAiC;AAG7D;;;GAGG;AACH,MAAM,oBAAoB,GAAG;IAC3B,sBAAsB,CAAC,UAAU;IACjC,wBAAwB,CAAC,UAAU;IACnC,sBAAsB,CAAC,UAAU;IACjC,iBAAiB,CAAC,UAAU;CAC7B,CAAC;AAEF,MAAM,SAAS,GAA+C;IAC5D,aAAa,EAAE,IAAI;IACnB,iBAAiB,EAAE,IAAI;IACvB,gBAAgB,EAAE,IAAI;CACvB,CAAC;AA0BF,MAAM,CAAC,MAAM,yBAAyB,GAIlC;IACF,WAAW,EAAE,CAAC,yBAAyB,CAAC;IACxC,cAAc,EAAE,gCAAgC;IAChD,SAAS;CACV,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,KAAK,UAAU,gCAAgC,CAC7C,QAAkD,EAClD,QAA0D,EAC1D,KAAc,EACd,GAA6B,EAC7B,EACE,aAAa,EACb,iBAAiB,EACjB,gBAAgB,GACQ;IAE1B,MAAM,WAAW,GAAG,oBAAoB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC7D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,GAAG,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAE7B,QAAQ,CAAC,MAAM,GAAG,iBAAiB,EAAE,CAAC;IACtC,OAAO,GAAG,EAAE,CAAC;AACf,CAAC","sourcesContent":["import type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine';\nimport type { PermittedHandlerExport } from '@metamask/permission-controller';\nimport { providerErrors } from '@metamask/rpc-errors';\nimport type {\n EntropySource,\n JsonRpcRequest,\n ListEntropySourcesParams,\n ListEntropySourcesResult,\n} from '@metamask/snaps-sdk';\nimport type { PendingJsonRpcResponse } from '@metamask/utils';\n\nimport { getBip32EntropyBuilder } from '../restricted/getBip32Entropy';\nimport { getBip32PublicKeyBuilder } from '../restricted/getBip32PublicKey';\nimport { getBip44EntropyBuilder } from '../restricted/getBip44Entropy';\nimport { getEntropyBuilder } from '../restricted/getEntropy';\nimport type { MethodHooksObject } from '../utils';\n\n/**\n * A list of permissions that the requesting origin must have at least one of\n * in order to call this method.\n */\nconst REQUIRED_PERMISSIONS = [\n getBip32EntropyBuilder.targetName,\n getBip32PublicKeyBuilder.targetName,\n getBip44EntropyBuilder.targetName,\n getEntropyBuilder.targetName,\n];\n\nconst hookNames: MethodHooksObject<ListEntropySourcesHooks> = {\n hasPermission: true,\n getEntropySources: true,\n getUnlockPromise: true,\n};\n\nexport type ListEntropySourcesHooks = {\n /**\n * Check if the requesting origin has a given permission.\n *\n * @param permissionName - The name of the permission to check.\n * @returns Whether the origin has the permission.\n */\n hasPermission: (permissionName: string) => boolean;\n\n /**\n * Get the entropy sources from the client.\n *\n * @returns The entropy sources.\n */\n getEntropySources: () => EntropySource[];\n\n /**\n * Wait for the extension to be unlocked.\n *\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n};\n\nexport const listEntropySourcesHandler: PermittedHandlerExport<\n ListEntropySourcesHooks,\n ListEntropySourcesParams,\n ListEntropySourcesResult\n> = {\n methodNames: ['snap_listEntropySources'],\n implementation: listEntropySourcesImplementation,\n hookNames,\n};\n\n/**\n * The `snap_listEntropySources` method implementation.\n *\n * @param _request - The JSON-RPC request object. Not used by this function.\n * @param response - The JSON-RPC response object.\n * @param _next - The `json-rpc-engine` \"next\" callback. Not used by this\n * function.\n * @param end - The `json-rpc-engine` \"end\" callback.\n * @param hooks - The RPC method hooks.\n * @param hooks.hasPermission - The function to check if the origin has a\n * permission.\n * @param hooks.getEntropySources - The function to get the entropy sources.\n * @param hooks.getUnlockPromise - The function to get the unlock promise.\n * @returns Noting.\n */\nasync function listEntropySourcesImplementation(\n _request: JsonRpcRequest<ListEntropySourcesParams>,\n response: PendingJsonRpcResponse<ListEntropySourcesResult>,\n _next: unknown,\n end: JsonRpcEngineEndCallback,\n {\n hasPermission,\n getEntropySources,\n getUnlockPromise,\n }: ListEntropySourcesHooks,\n): Promise<void> {\n const isPermitted = REQUIRED_PERMISSIONS.some(hasPermission);\n if (!isPermitted) {\n return end(providerErrors.unauthorized());\n }\n\n await getUnlockPromise(true);\n\n response.result = getEntropySources();\n return end();\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/snaps-rpc-methods",
3
- "version": "11.13.0",
3
+ "version": "11.13.1",
4
4
  "description": "MetaMask Snaps JSON-RPC method implementations",
5
5
  "keywords": [
6
6
  "MetaMask",