@metamask/snaps-sdk 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -1
- package/dist/cjs/types/handlers/index.js +1 -0
- package/dist/cjs/types/handlers/index.js.map +1 -1
- package/dist/cjs/types/handlers/signature.js +6 -0
- package/dist/cjs/types/handlers/signature.js.map +1 -0
- package/dist/cjs/types/methods/get-client-status.js +10 -0
- package/dist/cjs/types/methods/get-client-status.js.map +1 -0
- package/dist/cjs/types/methods/index.js +1 -0
- package/dist/cjs/types/methods/index.js.map +1 -1
- package/dist/esm/types/handlers/index.js +1 -0
- package/dist/esm/types/handlers/index.js.map +1 -1
- package/dist/esm/types/handlers/signature.js +3 -0
- package/dist/esm/types/handlers/signature.js.map +1 -0
- package/dist/esm/types/methods/get-client-status.js +7 -0
- package/dist/esm/types/methods/get-client-status.js.map +1 -0
- package/dist/esm/types/methods/index.js +1 -0
- package/dist/esm/types/methods/index.js.map +1 -1
- package/dist/esm/types/methods/methods.js.map +1 -1
- package/dist/esm/types/permissions.js.map +1 -1
- package/dist/types/types/handlers/index.d.ts +1 -0
- package/dist/types/types/handlers/signature.d.ts +107 -0
- package/dist/types/types/methods/get-client-status.d.ts +14 -0
- package/dist/types/types/methods/index.d.ts +1 -0
- package/dist/types/types/methods/methods.d.ts +2 -0
- package/dist/types/types/permissions.d.ts +3 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [1.4.0]
|
|
10
|
+
### Added
|
|
11
|
+
- Add support for signature insights ([#2074](https://github.com/MetaMask/snaps/pull/2074), [#2079](https://github.com/MetaMask/snaps/pull/2079))
|
|
12
|
+
- Add types for `snap_getClientStatus` ([#2051](https://github.com/MetaMask/snaps/pull/2051))
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- Bump @metamask/utils from 8.2.1 to 8.3.0 ([#2100](https://github.com/MetaMask/snaps/pull/2100))
|
|
16
|
+
|
|
9
17
|
## [1.3.2]
|
|
10
18
|
### Fixed
|
|
11
19
|
- Fix missing `sensitive` property in `Copyable` type ([#2070](https://github.com/MetaMask/snaps/pull/2070))
|
|
@@ -37,7 +45,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
37
45
|
### Added
|
|
38
46
|
- Initial release of this package.
|
|
39
47
|
|
|
40
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.
|
|
48
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.4.0...HEAD
|
|
49
|
+
[1.4.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.3.2...@metamask/snaps-sdk@1.4.0
|
|
41
50
|
[1.3.2]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.3.1...@metamask/snaps-sdk@1.3.2
|
|
42
51
|
[1.3.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.3.0...@metamask/snaps-sdk@1.3.1
|
|
43
52
|
[1.3.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-sdk@1.2.0...@metamask/snaps-sdk@1.3.0
|
|
@@ -9,6 +9,7 @@ _export_star(require("./lifecycle"), exports);
|
|
|
9
9
|
_export_star(require("./name-lookup"), exports);
|
|
10
10
|
_export_star(require("./rpc-request"), exports);
|
|
11
11
|
_export_star(require("./transaction"), exports);
|
|
12
|
+
_export_star(require("./signature"), exports);
|
|
12
13
|
function _export_star(from, to) {
|
|
13
14
|
Object.keys(from).forEach(function(k) {
|
|
14
15
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/types/handlers/index.ts"],"sourcesContent":["export * from './cronjob';\nexport * from './home-page';\nexport * from './keyring';\nexport * from './lifecycle';\nexport * from './name-lookup';\nexport * from './rpc-request';\nexport * from './transaction';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/handlers/index.ts"],"sourcesContent":["export * from './cronjob';\nexport * from './home-page';\nexport * from './keyring';\nexport * from './lifecycle';\nexport * from './name-lookup';\nexport * from './rpc-request';\nexport * from './transaction';\nexport * from './signature';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/handlers/signature.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/get-client-status.ts"],"sourcesContent":["/**\n * The request parameters for the `snap_getClientStatus` method.\n *\n * This method does not accept any parameters.\n */\nexport type GetClientStatusParams = never;\n\n/**\n * The result returned by the `snap_getClientStatus` method.\n *\n * It returns an object containing useful information about the client.\n */\nexport type GetClientStatusResult = { locked: boolean };\n"],"names":[],"mappings":"AAAA;;;;CAIC"}
|
|
@@ -6,6 +6,7 @@ _export_star(require("./dialog"), exports);
|
|
|
6
6
|
_export_star(require("./get-bip32-entropy"), exports);
|
|
7
7
|
_export_star(require("./get-bip32-public-key"), exports);
|
|
8
8
|
_export_star(require("./get-bip44-entropy"), exports);
|
|
9
|
+
_export_star(require("./get-client-status"), exports);
|
|
9
10
|
_export_star(require("./get-entropy"), exports);
|
|
10
11
|
_export_star(require("./get-file"), exports);
|
|
11
12
|
_export_star(require("./get-locale"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/types/methods/index.ts"],"sourcesContent":["export * from './dialog';\nexport * from './get-bip32-entropy';\nexport * from './get-bip32-public-key';\nexport * from './get-bip44-entropy';\nexport * from './get-entropy';\nexport * from './get-file';\nexport * from './get-locale';\nexport * from './get-snaps';\nexport * from './invoke-keyring';\nexport * from './invoke-snap';\nexport * from './manage-accounts';\nexport * from './manage-state';\nexport * from './methods';\nexport * from './notify';\nexport * from './request-snaps';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/index.ts"],"sourcesContent":["export * from './dialog';\nexport * from './get-bip32-entropy';\nexport * from './get-bip32-public-key';\nexport * from './get-bip44-entropy';\nexport * from './get-client-status';\nexport * from './get-entropy';\nexport * from './get-file';\nexport * from './get-locale';\nexport * from './get-snaps';\nexport * from './invoke-keyring';\nexport * from './invoke-snap';\nexport * from './manage-accounts';\nexport * from './manage-state';\nexport * from './methods';\nexport * from './notify';\nexport * from './request-snaps';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA;qBACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/types/handlers/index.ts"],"sourcesContent":["export * from './cronjob';\nexport * from './home-page';\nexport * from './keyring';\nexport * from './lifecycle';\nexport * from './name-lookup';\nexport * from './rpc-request';\nexport * from './transaction';\n"],"names":[],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/handlers/index.ts"],"sourcesContent":["export * from './cronjob';\nexport * from './home-page';\nexport * from './keyring';\nexport * from './lifecycle';\nexport * from './name-lookup';\nexport * from './rpc-request';\nexport * from './transaction';\nexport * from './signature';\n"],"names":[],"mappings":"AAAA,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,YAAY;AAC1B,cAAc,cAAc;AAC5B,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,cAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/handlers/signature.ts"],"sourcesContent":["import type { EnumToUnion } from '../../internals';\nimport type { Component } from '../../ui';\nimport type { SeverityLevel } from './transaction';\n\n/**\n * An eth_sign signature object.\n *\n * @property from - The address the signature is being sent from.\n * @property data - The data (hex string) that is being signed.\n * @property signatureMethod - The signature method, which in this case is eth_sign\n */\nexport type EthSignature = {\n from: string;\n data: string;\n signatureMethod: 'eth_sign';\n};\n\n/**\n * A personal_sign signature object.\n *\n * @property from - The address the signature is being sent from.\n * @property data - The data (hex string) that is being signed.\n * @property signatureMethod - The signature method, which in this case is personal_sign\n */\nexport type PersonalSignature = {\n from: string;\n data: string;\n signatureMethod: 'personal_sign';\n};\n\n/**\n * An eth_signTypedData signature object.\n *\n * @property from - The address the signature is being sent from.\n * @property data - The data that is being signed.\n * @property signatureMethod - The signature method, which in this case is eth_signTypedData\n */\nexport type SignTypedDataSignature = {\n from: string;\n data: Record<string, any>[];\n signatureMethod: 'eth_signTypedData';\n};\n\n/**\n * An eth_signTypedData_v3 signature object.\n *\n * @property from - The address the signature is being sent from.\n * @property data - The data that is being signed.\n * @property signatureMethod - The signature method, which in this case is eth_signTypedData_v3\n */\nexport type SignTypedDataV3Signature = {\n from: string;\n data: Record<string, any>;\n signatureMethod: 'eth_signTypedData_v3';\n};\n\n/**\n * An eth_signTypedData_v4 signature object.\n *\n * @property from - The address the signature is being sent from.\n * @property data - The data that is being signed.\n * @property signatureMethod - The signature method, which in this case is eth_signTypedData_v4\n */\nexport type SignTypedDataV4Signature = {\n from: string;\n data: Record<string, any>;\n signatureMethod: 'eth_signTypedData_v4';\n};\n\n/**\n * A signature object. This can be one of the below signature methods.\n *\n * @see EthSignature\n * @see PersonalSignature\n * @see SignTypedDataSignature\n * @see SignTypedDataV3Signature\n * @see SignTypedDataV4Signature\n */\nexport type Signature =\n | EthSignature\n | PersonalSignature\n | SignTypedDataSignature\n | SignTypedDataV3Signature\n | SignTypedDataV4Signature;\n\n/**\n * The `onSignature` handler. This is called whenever a signature is\n * submitted to the snap. It can return insights about the signature, which\n * will be displayed to the user.\n *\n * Note that using this handler requires the `endowment:signature-insight`\n * permission.\n *\n * @param args - The request arguments.\n * @param args.signature - The signature object that contains the from address,\n * data and signature method.\n * @param args.signatureOrigin - The origin of the signature. This is the\n * URL of the website that submitted the signature. This is only available if\n * the Snap has enabled the `allowSignatureOrigin` option in the\n * `endowment:signature-insight` permission.\n * @returns An object containing insights about the signature. See\n * {@link OnSignatureResponse}. Can also return `null` if no insights are\n * available.\n */\nexport type OnSignatureHandler = (args: {\n signature: Signature;\n signatureOrigin?: string;\n}) => Promise<OnSignatureResponse | null>;\n\n/**\n * The response from a Snap's `onSignature` handler.\n *\n * @property component - A custom UI component, that will be shown in MetaMask.\n * @property severity - The severity level of the content. Currently only one\n * level is supported: `critical`.\n */\nexport type OnSignatureResponse = {\n content: Component;\n severity?: EnumToUnion<SeverityLevel>;\n};\n"],"names":[],"mappings":"AAAA,WAuHE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/get-client-status.ts"],"sourcesContent":["/**\n * The request parameters for the `snap_getClientStatus` method.\n *\n * This method does not accept any parameters.\n */\nexport type GetClientStatusParams = never;\n\n/**\n * The result returned by the `snap_getClientStatus` method.\n *\n * It returns an object containing useful information about the client.\n */\nexport type GetClientStatusResult = { locked: boolean };\n"],"names":[],"mappings":"AAAA;;;;CAIC,GACD,WAOwD"}
|
|
@@ -2,6 +2,7 @@ export * from './dialog';
|
|
|
2
2
|
export * from './get-bip32-entropy';
|
|
3
3
|
export * from './get-bip32-public-key';
|
|
4
4
|
export * from './get-bip44-entropy';
|
|
5
|
+
export * from './get-client-status';
|
|
5
6
|
export * from './get-entropy';
|
|
6
7
|
export * from './get-file';
|
|
7
8
|
export * from './get-locale';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/types/methods/index.ts"],"sourcesContent":["export * from './dialog';\nexport * from './get-bip32-entropy';\nexport * from './get-bip32-public-key';\nexport * from './get-bip44-entropy';\nexport * from './get-entropy';\nexport * from './get-file';\nexport * from './get-locale';\nexport * from './get-snaps';\nexport * from './invoke-keyring';\nexport * from './invoke-snap';\nexport * from './manage-accounts';\nexport * from './manage-state';\nexport * from './methods';\nexport * from './notify';\nexport * from './request-snaps';\n"],"names":[],"mappings":"AAAA,cAAc,WAAW;AACzB,cAAc,sBAAsB;AACpC,cAAc,yBAAyB;AACvC,cAAc,sBAAsB;AACpC,cAAc,gBAAgB;AAC9B,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,cAAc;AAC5B,cAAc,mBAAmB;AACjC,cAAc,gBAAgB;AAC9B,cAAc,oBAAoB;AAClC,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,kBAAkB"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/index.ts"],"sourcesContent":["export * from './dialog';\nexport * from './get-bip32-entropy';\nexport * from './get-bip32-public-key';\nexport * from './get-bip44-entropy';\nexport * from './get-client-status';\nexport * from './get-entropy';\nexport * from './get-file';\nexport * from './get-locale';\nexport * from './get-snaps';\nexport * from './invoke-keyring';\nexport * from './invoke-snap';\nexport * from './manage-accounts';\nexport * from './manage-state';\nexport * from './methods';\nexport * from './notify';\nexport * from './request-snaps';\n"],"names":[],"mappings":"AAAA,cAAc,WAAW;AACzB,cAAc,sBAAsB;AACpC,cAAc,yBAAyB;AACvC,cAAc,sBAAsB;AACpC,cAAc,sBAAsB;AACpC,cAAc,gBAAgB;AAC9B,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,cAAc;AAC5B,cAAc,mBAAmB;AACjC,cAAc,gBAAgB;AAC9B,cAAc,oBAAoB;AAClC,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/types/methods/methods.ts"],"sourcesContent":["import type { Method } from '../../internals';\nimport type { DialogParams, DialogResult } from './dialog';\nimport type {\n GetBip32EntropyParams,\n GetBip32EntropyResult,\n} from './get-bip32-entropy';\nimport type {\n GetBip32PublicKeyParams,\n GetBip32PublicKeyResult,\n} from './get-bip32-public-key';\nimport type {\n GetBip44EntropyParams,\n GetBip44EntropyResult,\n} from './get-bip44-entropy';\nimport type { GetEntropyParams, GetEntropyResult } from './get-entropy';\nimport type { GetFileParams, GetFileResult } from './get-file';\nimport type { GetLocaleParams, GetLocaleResult } from './get-locale';\nimport type { GetSnapsParams, GetSnapsResult } from './get-snaps';\nimport type {\n InvokeKeyringParams,\n InvokeKeyringResult,\n} from './invoke-keyring';\nimport type { InvokeSnapParams, InvokeSnapResult } from './invoke-snap';\nimport type {\n ManageAccountsParams,\n ManageAccountsResult,\n} from './manage-accounts';\nimport type { ManageStateParams, ManageStateResult } from './manage-state';\nimport type { NotifyParams, NotifyResult } from './notify';\nimport type { RequestSnapsParams, RequestSnapsResult } from './request-snaps';\n\n/**\n * The methods that are available to the Snap. Each method is a tuple of the\n * request parameters and the result returned by the method.\n */\nexport type SnapMethods = {\n /* eslint-disable @typescript-eslint/naming-convention */\n snap_dialog: [DialogParams, DialogResult];\n snap_getBip32Entropy: [GetBip32EntropyParams, GetBip32EntropyResult];\n snap_getBip32PublicKey: [GetBip32PublicKeyParams, GetBip32PublicKeyResult];\n snap_getBip44Entropy: [GetBip44EntropyParams, GetBip44EntropyResult];\n snap_getEntropy: [GetEntropyParams, GetEntropyResult];\n snap_getFile: [GetFileParams, GetFileResult];\n snap_getLocale: [GetLocaleParams, GetLocaleResult];\n snap_manageAccounts: [ManageAccountsParams, ManageAccountsResult];\n snap_manageState: [ManageStateParams, ManageStateResult];\n snap_notify: [NotifyParams, NotifyResult];\n wallet_getSnaps: [GetSnapsParams, GetSnapsResult];\n wallet_invokeKeyring: [InvokeKeyringParams, InvokeKeyringResult];\n wallet_invokeSnap: [InvokeSnapParams, InvokeSnapResult];\n wallet_snap: [InvokeSnapParams, InvokeSnapResult];\n wallet_requestSnaps: [RequestSnapsParams, RequestSnapsResult];\n /* eslint-enable @typescript-eslint/naming-convention */\n};\n\n/**\n * The request function that is available to the Snap. It takes a request\n * object and returns a promise that resolves to the result of the request.\n *\n * @param request - The request object.\n * @param request.method - The method to call.\n * @param request.params - The parameters to pass to the method. This is\n * inferred from the method, based on the {@link SnapMethods} type, and may be\n * optional.\n * @returns A promise that resolves to the result of the request. This is\n * inferred from the request method, based on the {@link SnapMethods} type.\n * @example\n * // Get the user's locale\n * const result = await request({\n * method: 'snap_getLocale',\n * });\n * @example\n * // Get a file\n * const result = await request({\n * method: 'snap_getFile',\n * params: {\n * path: 'foo/bar.txt',\n * },\n * });\n */\nexport type RequestFunction = <MethodName extends keyof SnapMethods>(\n request: Method<MethodName, SnapMethods[MethodName][0]>,\n) => Promise<SnapMethods[MethodName][1]>;\n"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../../src/types/methods/methods.ts"],"sourcesContent":["import type { Method } from '../../internals';\nimport type { DialogParams, DialogResult } from './dialog';\nimport type {\n GetBip32EntropyParams,\n GetBip32EntropyResult,\n} from './get-bip32-entropy';\nimport type {\n GetBip32PublicKeyParams,\n GetBip32PublicKeyResult,\n} from './get-bip32-public-key';\nimport type {\n GetBip44EntropyParams,\n GetBip44EntropyResult,\n} from './get-bip44-entropy';\nimport type {\n GetClientStatusParams,\n GetClientStatusResult,\n} from './get-client-status';\nimport type { GetEntropyParams, GetEntropyResult } from './get-entropy';\nimport type { GetFileParams, GetFileResult } from './get-file';\nimport type { GetLocaleParams, GetLocaleResult } from './get-locale';\nimport type { GetSnapsParams, GetSnapsResult } from './get-snaps';\nimport type {\n InvokeKeyringParams,\n InvokeKeyringResult,\n} from './invoke-keyring';\nimport type { InvokeSnapParams, InvokeSnapResult } from './invoke-snap';\nimport type {\n ManageAccountsParams,\n ManageAccountsResult,\n} from './manage-accounts';\nimport type { ManageStateParams, ManageStateResult } from './manage-state';\nimport type { NotifyParams, NotifyResult } from './notify';\nimport type { RequestSnapsParams, RequestSnapsResult } from './request-snaps';\n\n/**\n * The methods that are available to the Snap. Each method is a tuple of the\n * request parameters and the result returned by the method.\n */\nexport type SnapMethods = {\n /* eslint-disable @typescript-eslint/naming-convention */\n snap_dialog: [DialogParams, DialogResult];\n snap_getBip32Entropy: [GetBip32EntropyParams, GetBip32EntropyResult];\n snap_getBip32PublicKey: [GetBip32PublicKeyParams, GetBip32PublicKeyResult];\n snap_getBip44Entropy: [GetBip44EntropyParams, GetBip44EntropyResult];\n snap_getClientStatus: [GetClientStatusParams, GetClientStatusResult];\n snap_getEntropy: [GetEntropyParams, GetEntropyResult];\n snap_getFile: [GetFileParams, GetFileResult];\n snap_getLocale: [GetLocaleParams, GetLocaleResult];\n snap_manageAccounts: [ManageAccountsParams, ManageAccountsResult];\n snap_manageState: [ManageStateParams, ManageStateResult];\n snap_notify: [NotifyParams, NotifyResult];\n wallet_getSnaps: [GetSnapsParams, GetSnapsResult];\n wallet_invokeKeyring: [InvokeKeyringParams, InvokeKeyringResult];\n wallet_invokeSnap: [InvokeSnapParams, InvokeSnapResult];\n wallet_snap: [InvokeSnapParams, InvokeSnapResult];\n wallet_requestSnaps: [RequestSnapsParams, RequestSnapsResult];\n /* eslint-enable @typescript-eslint/naming-convention */\n};\n\n/**\n * The request function that is available to the Snap. It takes a request\n * object and returns a promise that resolves to the result of the request.\n *\n * @param request - The request object.\n * @param request.method - The method to call.\n * @param request.params - The parameters to pass to the method. This is\n * inferred from the method, based on the {@link SnapMethods} type, and may be\n * optional.\n * @returns A promise that resolves to the result of the request. This is\n * inferred from the request method, based on the {@link SnapMethods} type.\n * @example\n * // Get the user's locale\n * const result = await request({\n * method: 'snap_getLocale',\n * });\n * @example\n * // Get a file\n * const result = await request({\n * method: 'snap_getFile',\n * params: {\n * path: 'foo/bar.txt',\n * },\n * });\n */\nexport type RequestFunction = <MethodName extends keyof SnapMethods>(\n request: Method<MethodName, SnapMethods[MethodName][0]>,\n) => Promise<SnapMethods[MethodName][1]>;\n"],"names":[],"mappings":"AAAA,WAuFyC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/types/permissions.ts"],"sourcesContent":["import type { JsonRpcRequest } from '@metamask/utils';\n\nimport type { ChainId } from './caip';\n\nexport type EmptyObject = Record<string, never>;\n\nexport type Cronjob = {\n expression: string;\n request: Omit<JsonRpcRequest, 'jsonrpc' | 'id'>;\n};\n\nexport type Bip32Entropy = {\n curve: 'secp256k1' | 'ed25519';\n path: string[];\n};\n\nexport type Bip44Entropy = {\n coinType: number;\n};\n\nexport type RequestedSnap = {\n version?: string;\n};\n\nexport type InitialPermissions = {\n 'endowment:cronjob'?: {\n jobs: Cronjob[];\n };\n 'endowment:keyring'?: {\n allowedOrigins?: string[];\n };\n 'endowment:name-lookup'?: ChainId[];\n 'endowment:network-access'?: EmptyObject;\n 'endowment:rpc'?: {\n dapps?: boolean;\n snaps?: boolean;\n allowedOrigins?: string[];\n };\n 'endowment:transaction-insight'?: {\n allowTransactionOrigin?: boolean;\n };\n 'endowment:webassembly'?: EmptyObject;\n\n /* eslint-disable @typescript-eslint/naming-convention */\n snap_confirm?: EmptyObject;\n snap_dialog?: EmptyObject;\n snap_getBip32Entropy?: Bip32Entropy[];\n snap_getBip32PublicKey?: Bip32Entropy[];\n snap_getBip44Entropy?: Bip44Entropy[];\n snap_getEntropy?: EmptyObject;\n snap_manageAccounts?: EmptyObject;\n snap_manageState?: EmptyObject;\n snap_notify?: EmptyObject;\n wallet_snap?: Record<string, RequestedSnap>;\n /* eslint-enable @typescript-eslint/naming-convention */\n};\n"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/types/permissions.ts"],"sourcesContent":["import type { JsonRpcRequest } from '@metamask/utils';\n\nimport type { ChainId } from './caip';\n\nexport type EmptyObject = Record<string, never>;\n\nexport type Cronjob = {\n expression: string;\n request: Omit<JsonRpcRequest, 'jsonrpc' | 'id'>;\n};\n\nexport type Bip32Entropy = {\n curve: 'secp256k1' | 'ed25519';\n path: string[];\n};\n\nexport type Bip44Entropy = {\n coinType: number;\n};\n\nexport type RequestedSnap = {\n version?: string;\n};\n\nexport type InitialPermissions = {\n 'endowment:cronjob'?: {\n jobs: Cronjob[];\n };\n 'endowment:keyring'?: {\n allowedOrigins?: string[];\n };\n 'endowment:name-lookup'?: ChainId[];\n 'endowment:network-access'?: EmptyObject;\n 'endowment:rpc'?: {\n dapps?: boolean;\n snaps?: boolean;\n allowedOrigins?: string[];\n };\n 'endowment:signature-insight'?: {\n allowSignatureOrigin?: boolean;\n };\n 'endowment:transaction-insight'?: {\n allowTransactionOrigin?: boolean;\n };\n 'endowment:webassembly'?: EmptyObject;\n\n /* eslint-disable @typescript-eslint/naming-convention */\n snap_confirm?: EmptyObject;\n snap_dialog?: EmptyObject;\n snap_getBip32Entropy?: Bip32Entropy[];\n snap_getBip32PublicKey?: Bip32Entropy[];\n snap_getBip44Entropy?: Bip44Entropy[];\n snap_getEntropy?: EmptyObject;\n snap_manageAccounts?: EmptyObject;\n snap_manageState?: EmptyObject;\n snap_notify?: EmptyObject;\n wallet_snap?: Record<string, RequestedSnap>;\n /* eslint-enable @typescript-eslint/naming-convention */\n};\n"],"names":[],"mappings":"AAAA,WA0DE"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { EnumToUnion } from '../../internals';
|
|
2
|
+
import type { Component } from '../../ui';
|
|
3
|
+
import type { SeverityLevel } from './transaction';
|
|
4
|
+
/**
|
|
5
|
+
* An eth_sign signature object.
|
|
6
|
+
*
|
|
7
|
+
* @property from - The address the signature is being sent from.
|
|
8
|
+
* @property data - The data (hex string) that is being signed.
|
|
9
|
+
* @property signatureMethod - The signature method, which in this case is eth_sign
|
|
10
|
+
*/
|
|
11
|
+
export declare type EthSignature = {
|
|
12
|
+
from: string;
|
|
13
|
+
data: string;
|
|
14
|
+
signatureMethod: 'eth_sign';
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A personal_sign signature object.
|
|
18
|
+
*
|
|
19
|
+
* @property from - The address the signature is being sent from.
|
|
20
|
+
* @property data - The data (hex string) that is being signed.
|
|
21
|
+
* @property signatureMethod - The signature method, which in this case is personal_sign
|
|
22
|
+
*/
|
|
23
|
+
export declare type PersonalSignature = {
|
|
24
|
+
from: string;
|
|
25
|
+
data: string;
|
|
26
|
+
signatureMethod: 'personal_sign';
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* An eth_signTypedData signature object.
|
|
30
|
+
*
|
|
31
|
+
* @property from - The address the signature is being sent from.
|
|
32
|
+
* @property data - The data that is being signed.
|
|
33
|
+
* @property signatureMethod - The signature method, which in this case is eth_signTypedData
|
|
34
|
+
*/
|
|
35
|
+
export declare type SignTypedDataSignature = {
|
|
36
|
+
from: string;
|
|
37
|
+
data: Record<string, any>[];
|
|
38
|
+
signatureMethod: 'eth_signTypedData';
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* An eth_signTypedData_v3 signature object.
|
|
42
|
+
*
|
|
43
|
+
* @property from - The address the signature is being sent from.
|
|
44
|
+
* @property data - The data that is being signed.
|
|
45
|
+
* @property signatureMethod - The signature method, which in this case is eth_signTypedData_v3
|
|
46
|
+
*/
|
|
47
|
+
export declare type SignTypedDataV3Signature = {
|
|
48
|
+
from: string;
|
|
49
|
+
data: Record<string, any>;
|
|
50
|
+
signatureMethod: 'eth_signTypedData_v3';
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* An eth_signTypedData_v4 signature object.
|
|
54
|
+
*
|
|
55
|
+
* @property from - The address the signature is being sent from.
|
|
56
|
+
* @property data - The data that is being signed.
|
|
57
|
+
* @property signatureMethod - The signature method, which in this case is eth_signTypedData_v4
|
|
58
|
+
*/
|
|
59
|
+
export declare type SignTypedDataV4Signature = {
|
|
60
|
+
from: string;
|
|
61
|
+
data: Record<string, any>;
|
|
62
|
+
signatureMethod: 'eth_signTypedData_v4';
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* A signature object. This can be one of the below signature methods.
|
|
66
|
+
*
|
|
67
|
+
* @see EthSignature
|
|
68
|
+
* @see PersonalSignature
|
|
69
|
+
* @see SignTypedDataSignature
|
|
70
|
+
* @see SignTypedDataV3Signature
|
|
71
|
+
* @see SignTypedDataV4Signature
|
|
72
|
+
*/
|
|
73
|
+
export declare type Signature = EthSignature | PersonalSignature | SignTypedDataSignature | SignTypedDataV3Signature | SignTypedDataV4Signature;
|
|
74
|
+
/**
|
|
75
|
+
* The `onSignature` handler. This is called whenever a signature is
|
|
76
|
+
* submitted to the snap. It can return insights about the signature, which
|
|
77
|
+
* will be displayed to the user.
|
|
78
|
+
*
|
|
79
|
+
* Note that using this handler requires the `endowment:signature-insight`
|
|
80
|
+
* permission.
|
|
81
|
+
*
|
|
82
|
+
* @param args - The request arguments.
|
|
83
|
+
* @param args.signature - The signature object that contains the from address,
|
|
84
|
+
* data and signature method.
|
|
85
|
+
* @param args.signatureOrigin - The origin of the signature. This is the
|
|
86
|
+
* URL of the website that submitted the signature. This is only available if
|
|
87
|
+
* the Snap has enabled the `allowSignatureOrigin` option in the
|
|
88
|
+
* `endowment:signature-insight` permission.
|
|
89
|
+
* @returns An object containing insights about the signature. See
|
|
90
|
+
* {@link OnSignatureResponse}. Can also return `null` if no insights are
|
|
91
|
+
* available.
|
|
92
|
+
*/
|
|
93
|
+
export declare type OnSignatureHandler = (args: {
|
|
94
|
+
signature: Signature;
|
|
95
|
+
signatureOrigin?: string;
|
|
96
|
+
}) => Promise<OnSignatureResponse | null>;
|
|
97
|
+
/**
|
|
98
|
+
* The response from a Snap's `onSignature` handler.
|
|
99
|
+
*
|
|
100
|
+
* @property component - A custom UI component, that will be shown in MetaMask.
|
|
101
|
+
* @property severity - The severity level of the content. Currently only one
|
|
102
|
+
* level is supported: `critical`.
|
|
103
|
+
*/
|
|
104
|
+
export declare type OnSignatureResponse = {
|
|
105
|
+
content: Component;
|
|
106
|
+
severity?: EnumToUnion<SeverityLevel>;
|
|
107
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The request parameters for the `snap_getClientStatus` method.
|
|
3
|
+
*
|
|
4
|
+
* This method does not accept any parameters.
|
|
5
|
+
*/
|
|
6
|
+
export declare type GetClientStatusParams = never;
|
|
7
|
+
/**
|
|
8
|
+
* The result returned by the `snap_getClientStatus` method.
|
|
9
|
+
*
|
|
10
|
+
* It returns an object containing useful information about the client.
|
|
11
|
+
*/
|
|
12
|
+
export declare type GetClientStatusResult = {
|
|
13
|
+
locked: boolean;
|
|
14
|
+
};
|
|
@@ -2,6 +2,7 @@ export * from './dialog';
|
|
|
2
2
|
export * from './get-bip32-entropy';
|
|
3
3
|
export * from './get-bip32-public-key';
|
|
4
4
|
export * from './get-bip44-entropy';
|
|
5
|
+
export * from './get-client-status';
|
|
5
6
|
export * from './get-entropy';
|
|
6
7
|
export * from './get-file';
|
|
7
8
|
export * from './get-locale';
|
|
@@ -3,6 +3,7 @@ import type { DialogParams, DialogResult } from './dialog';
|
|
|
3
3
|
import type { GetBip32EntropyParams, GetBip32EntropyResult } from './get-bip32-entropy';
|
|
4
4
|
import type { GetBip32PublicKeyParams, GetBip32PublicKeyResult } from './get-bip32-public-key';
|
|
5
5
|
import type { GetBip44EntropyParams, GetBip44EntropyResult } from './get-bip44-entropy';
|
|
6
|
+
import type { GetClientStatusParams, GetClientStatusResult } from './get-client-status';
|
|
6
7
|
import type { GetEntropyParams, GetEntropyResult } from './get-entropy';
|
|
7
8
|
import type { GetFileParams, GetFileResult } from './get-file';
|
|
8
9
|
import type { GetLocaleParams, GetLocaleResult } from './get-locale';
|
|
@@ -22,6 +23,7 @@ export declare type SnapMethods = {
|
|
|
22
23
|
snap_getBip32Entropy: [GetBip32EntropyParams, GetBip32EntropyResult];
|
|
23
24
|
snap_getBip32PublicKey: [GetBip32PublicKeyParams, GetBip32PublicKeyResult];
|
|
24
25
|
snap_getBip44Entropy: [GetBip44EntropyParams, GetBip44EntropyResult];
|
|
26
|
+
snap_getClientStatus: [GetClientStatusParams, GetClientStatusResult];
|
|
25
27
|
snap_getEntropy: [GetEntropyParams, GetEntropyResult];
|
|
26
28
|
snap_getFile: [GetFileParams, GetFileResult];
|
|
27
29
|
snap_getLocale: [GetLocaleParams, GetLocaleResult];
|
|
@@ -29,6 +29,9 @@ export declare type InitialPermissions = {
|
|
|
29
29
|
snaps?: boolean;
|
|
30
30
|
allowedOrigins?: string[];
|
|
31
31
|
};
|
|
32
|
+
'endowment:signature-insight'?: {
|
|
33
|
+
allowSignatureOrigin?: boolean;
|
|
34
|
+
};
|
|
32
35
|
'endowment:transaction-insight'?: {
|
|
33
36
|
allowTransactionOrigin?: boolean;
|
|
34
37
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask/snaps-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/MetaMask/snaps.git"
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"@metamask/key-tree": "^9.0.0",
|
|
39
39
|
"@metamask/providers": "^14.0.2",
|
|
40
40
|
"@metamask/rpc-errors": "^6.1.0",
|
|
41
|
-
"@metamask/utils": "^8.
|
|
41
|
+
"@metamask/utils": "^8.3.0",
|
|
42
42
|
"is-svg": "^4.4.0",
|
|
43
43
|
"superstruct": "^1.0.3"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@lavamoat/allow-scripts": "^
|
|
46
|
+
"@lavamoat/allow-scripts": "^3.0.0",
|
|
47
47
|
"@metamask/auto-changelog": "^3.4.4",
|
|
48
48
|
"@metamask/eslint-config": "^12.1.0",
|
|
49
49
|
"@metamask/eslint-config-jest": "^12.1.0",
|