@metamask/snaps-rpc-methods 10.0.0 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/dist/{chunk-SYUGPLEP.js → chunk-6XKVFSC2.js} +4 -4
  3. package/dist/chunk-6XKVFSC2.js.map +1 -0
  4. package/dist/{chunk-IZYMBIBD.mjs → chunk-AMMJ744B.mjs} +4 -4
  5. package/dist/chunk-AMMJ744B.mjs.map +1 -0
  6. package/dist/{chunk-HZQ34FQT.js → chunk-CDAVFOUS.js} +9 -5
  7. package/dist/chunk-CDAVFOUS.js.map +1 -0
  8. package/dist/chunk-FM4LNQR7.mjs +34 -0
  9. package/dist/chunk-FM4LNQR7.mjs.map +1 -0
  10. package/dist/{chunk-BSAXPL2T.mjs → chunk-GEJDXRTL.mjs} +3 -3
  11. package/dist/{chunk-FNUO7MQ4.mjs → chunk-K3UL5RVN.mjs} +5 -5
  12. package/dist/{chunk-6VJVURH5.js → chunk-LP3RWEDJ.js} +4 -4
  13. package/dist/{chunk-4TUORIA6.js → chunk-PK2RPAXI.js} +6 -6
  14. package/dist/chunk-RHPSYX7X.js +34 -0
  15. package/dist/chunk-RHPSYX7X.js.map +1 -0
  16. package/dist/{chunk-SYB5TG5O.mjs → chunk-V3KRSCUK.mjs} +10 -6
  17. package/dist/chunk-V3KRSCUK.mjs.map +1 -0
  18. package/dist/index.js +10 -9
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.mjs +9 -8
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/permissions.js +8 -7
  23. package/dist/permissions.mjs +7 -6
  24. package/dist/restricted/caveats/index.js +3 -3
  25. package/dist/restricted/caveats/index.mjs +2 -2
  26. package/dist/restricted/getLocale.js +2 -2
  27. package/dist/restricted/getLocale.mjs +1 -1
  28. package/dist/restricted/getPreferences.js +11 -0
  29. package/dist/restricted/getPreferences.js.map +1 -0
  30. package/dist/restricted/getPreferences.mjs +11 -0
  31. package/dist/restricted/getPreferences.mjs.map +1 -0
  32. package/dist/restricted/index.js +9 -8
  33. package/dist/restricted/index.mjs +8 -7
  34. package/dist/tsconfig.build.tsbuildinfo +1 -1
  35. package/dist/types/endowments/caveats/generic.d.ts +2 -2
  36. package/dist/types/endowments/rpc.d.ts +1 -1
  37. package/dist/types/permitted/createInterface.d.ts +16 -2
  38. package/dist/types/permitted/getAllSnaps.d.ts +1 -1
  39. package/dist/types/permitted/getClientStatus.d.ts +1 -1
  40. package/dist/types/permitted/getFile.d.ts +2 -2
  41. package/dist/types/permitted/getInterfaceState.d.ts +2 -2
  42. package/dist/types/permitted/getSnaps.d.ts +1 -1
  43. package/dist/types/permitted/index.d.ts +1 -1
  44. package/dist/types/permitted/invokeKeyring.d.ts +1 -1
  45. package/dist/types/permitted/invokeSnapSugar.d.ts +1 -1
  46. package/dist/types/permitted/requestSnaps.d.ts +1 -1
  47. package/dist/types/permitted/resolveInterface.d.ts +2 -2
  48. package/dist/types/permitted/updateInterface.d.ts +16 -2
  49. package/dist/types/restricted/dialog.d.ts +121 -9
  50. package/dist/types/restricted/getBip32Entropy.d.ts +2 -2
  51. package/dist/types/restricted/getBip32PublicKey.d.ts +2 -2
  52. package/dist/types/restricted/getBip44Entropy.d.ts +2 -2
  53. package/dist/types/restricted/getEntropy.d.ts +3 -3
  54. package/dist/types/restricted/getLocale.d.ts +8 -7
  55. package/dist/types/restricted/getPreferences.d.ts +48 -0
  56. package/dist/types/restricted/index.d.ts +15 -1
  57. package/dist/types/restricted/invokeSnap.d.ts +6 -6
  58. package/dist/types/restricted/manageAccounts.d.ts +4 -4
  59. package/dist/types/restricted/manageState.d.ts +4 -4
  60. package/dist/types/restricted/notify.d.ts +4 -4
  61. package/dist/types/utils.d.ts +3 -3
  62. package/package.json +6 -6
  63. package/dist/chunk-HZQ34FQT.js.map +0 -1
  64. package/dist/chunk-IZYMBIBD.mjs.map +0 -1
  65. package/dist/chunk-SYB5TG5O.mjs.map +0 -1
  66. package/dist/chunk-SYUGPLEP.js.map +0 -1
  67. /package/dist/{chunk-BSAXPL2T.mjs.map → chunk-GEJDXRTL.mjs.map} +0 -0
  68. /package/dist/{chunk-FNUO7MQ4.mjs.map → chunk-K3UL5RVN.mjs.map} +0 -0
  69. /package/dist/{chunk-6VJVURH5.js.map → chunk-LP3RWEDJ.js.map} +0 -0
  70. /package/dist/{chunk-4TUORIA6.js.map → chunk-PK2RPAXI.js.map} +0 -0
@@ -0,0 +1,48 @@
1
+ import type { PermissionSpecificationBuilder, ValidPermissionSpecification, RestrictedMethodOptions, RestrictedMethodParameters } from '@metamask/permission-controller';
2
+ import { PermissionType } from '@metamask/permission-controller';
3
+ import type { GetPreferencesResult } from '@metamask/snaps-sdk';
4
+ import type { NonEmptyArray } from '@metamask/utils';
5
+ import type { MethodHooksObject } from '../utils';
6
+ declare const methodName = "snap_getPreferences";
7
+ export type GetPreferencesMethodHooks = {
8
+ getPreferences: () => GetPreferencesResult;
9
+ };
10
+ type SpecificationBuilderOptions = {
11
+ allowedCaveats?: Readonly<NonEmptyArray<string>> | null;
12
+ methodHooks: GetPreferencesMethodHooks;
13
+ };
14
+ type Specification = ValidPermissionSpecification<{
15
+ permissionType: PermissionType.RestrictedMethod;
16
+ targetName: typeof methodName;
17
+ methodImplementation: ReturnType<typeof getImplementation>;
18
+ allowedCaveats: Readonly<NonEmptyArray<string>> | null;
19
+ }>;
20
+ /**
21
+ * The specification builder for the `snap_getPreferences` permission.
22
+ * `snap_getPreferences` allows snaps to access user preferences.
23
+ *
24
+ * @param options - The specification builder options.
25
+ * @param options.allowedCaveats - The optional allowed caveats for the permission.
26
+ * @param options.methodHooks - The RPC method hooks needed by the method implementation.
27
+ * @returns The specification for the `snap_getPreferences` permission.
28
+ */
29
+ export declare const specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, SpecificationBuilderOptions, Specification>;
30
+ export declare const getPreferencesBuilder: Readonly<{
31
+ readonly targetName: "snap_getPreferences";
32
+ readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, SpecificationBuilderOptions, {
33
+ permissionType: PermissionType.RestrictedMethod;
34
+ targetName: typeof methodName;
35
+ methodImplementation: ReturnType<typeof getImplementation>;
36
+ allowedCaveats: Readonly<NonEmptyArray<string>> | null;
37
+ }>;
38
+ readonly methodHooks: MethodHooksObject<GetPreferencesMethodHooks>;
39
+ }>;
40
+ /**
41
+ * Builds the method implementation for `snap_getPreferences`.
42
+ *
43
+ * @param hooks - The RPC method hooks.
44
+ * @param hooks.getPreferences - A function that returns the user selected preferences.
45
+ * @returns The user preferences.
46
+ */
47
+ export declare function getImplementation({ getPreferences, }: GetPreferencesMethodHooks): (_args: RestrictedMethodOptions<RestrictedMethodParameters>) => Promise<GetPreferencesResult>;
48
+ export {};
@@ -4,13 +4,14 @@ import type { GetBip32PublicKeyMethodHooks } from './getBip32PublicKey';
4
4
  import type { GetBip44EntropyMethodHooks } from './getBip44Entropy';
5
5
  import type { GetEntropyHooks } from './getEntropy';
6
6
  import type { GetLocaleMethodHooks } from './getLocale';
7
+ import type { GetPreferencesMethodHooks } from './getPreferences';
7
8
  import type { InvokeSnapMethodHooks } from './invokeSnap';
8
9
  import type { ManageAccountsMethodHooks } from './manageAccounts';
9
10
  import type { ManageStateMethodHooks } from './manageState';
10
11
  import type { NotifyMethodHooks } from './notify';
11
12
  export { WALLET_SNAP_PERMISSION_KEY } from './invokeSnap';
12
13
  export { getEncryptionEntropy } from './manageState';
13
- export declare type RestrictedMethodHooks = DialogMethodHooks & GetBip32EntropyMethodHooks & GetBip32PublicKeyMethodHooks & GetBip44EntropyMethodHooks & GetEntropyHooks & InvokeSnapMethodHooks & ManageStateMethodHooks & NotifyMethodHooks & ManageAccountsMethodHooks & GetLocaleMethodHooks;
14
+ export type RestrictedMethodHooks = DialogMethodHooks & GetBip32EntropyMethodHooks & GetBip32PublicKeyMethodHooks & GetBip44EntropyMethodHooks & GetEntropyHooks & InvokeSnapMethodHooks & ManageStateMethodHooks & NotifyMethodHooks & ManageAccountsMethodHooks & GetLocaleMethodHooks & GetPreferencesMethodHooks;
14
15
  export declare const restrictedMethodPermissionBuilders: {
15
16
  readonly snap_dialog: Readonly<{
16
17
  readonly targetName: "snap_dialog";
@@ -148,6 +149,19 @@ export declare const restrictedMethodPermissionBuilders: {
148
149
  }>;
149
150
  readonly methodHooks: import("../utils").MethodHooksObject<GetLocaleMethodHooks>;
150
151
  }>;
152
+ readonly snap_getPreferences: Readonly<{
153
+ readonly targetName: "snap_getPreferences";
154
+ readonly specificationBuilder: import("@metamask/permission-controller").PermissionSpecificationBuilder<import("@metamask/permission-controller").PermissionType.RestrictedMethod, {
155
+ allowedCaveats?: readonly [string, ...string[]] | null | undefined;
156
+ methodHooks: GetPreferencesMethodHooks;
157
+ }, {
158
+ permissionType: import("@metamask/permission-controller").PermissionType.RestrictedMethod;
159
+ targetName: "snap_getPreferences";
160
+ methodImplementation: (_args: import("@metamask/permission-controller").RestrictedMethodOptions<import("@metamask/permission-controller").RestrictedMethodParameters>) => Promise<import("@metamask/snaps-sdk").GetPreferencesResult>;
161
+ allowedCaveats: readonly [string, ...string[]] | null;
162
+ }>;
163
+ readonly methodHooks: import("../utils").MethodHooksObject<GetPreferencesMethodHooks>;
164
+ }>;
151
165
  };
152
166
  export * from './caveats';
153
167
  export type { DialogApprovalTypes } from './dialog';
@@ -5,26 +5,26 @@ import type { Snap, SnapRpcHookArgs } from '@metamask/snaps-utils';
5
5
  import type { Json, NonEmptyArray } from '@metamask/utils';
6
6
  import type { MethodHooksObject } from '../utils';
7
7
  export declare const WALLET_SNAP_PERMISSION_KEY = "wallet_snap";
8
- export declare type InstallSnaps = {
8
+ export type InstallSnaps = {
9
9
  type: `SnapController:install`;
10
10
  handler: (origin: string, requestedSnaps: RequestSnapsParams) => Promise<RequestSnapsResult>;
11
11
  };
12
- export declare type GetPermittedSnaps = {
12
+ export type GetPermittedSnaps = {
13
13
  type: `SnapController:getPermitted`;
14
14
  handler: (origin: string) => RequestSnapsResult;
15
15
  };
16
- declare type AllowedActions = InstallSnaps | GetPermittedSnaps;
17
- export declare type InvokeSnapMethodHooks = {
16
+ type AllowedActions = InstallSnaps | GetPermittedSnaps;
17
+ export type InvokeSnapMethodHooks = {
18
18
  getSnap: (snapId: string) => Snap | undefined;
19
19
  handleSnapRpcRequest: ({ snapId, origin, handler, request, }: SnapRpcHookArgs & {
20
20
  snapId: string;
21
21
  }) => Promise<unknown>;
22
22
  };
23
- declare type InvokeSnapSpecificationBuilderOptions = {
23
+ type InvokeSnapSpecificationBuilderOptions = {
24
24
  allowedCaveats?: Readonly<NonEmptyArray<string>> | null;
25
25
  methodHooks: InvokeSnapMethodHooks;
26
26
  };
27
- export declare type InvokeSnapParams = {
27
+ export type InvokeSnapParams = {
28
28
  snapId: string;
29
29
  request: Record<string, Json>;
30
30
  };
@@ -9,9 +9,9 @@ declare const SnapMessageStruct: import("@metamask/superstruct").Struct<{
9
9
  method: string;
10
10
  params: Record<string, Json> | Json[];
11
11
  }, null>;
12
- declare type Message = InferMatching<typeof SnapMessageStruct, ManageAccountsParams>;
12
+ type Message = InferMatching<typeof SnapMessageStruct, ManageAccountsParams>;
13
13
  export declare const methodName = "snap_manageAccounts";
14
- export declare type ManageAccountsMethodHooks = {
14
+ export type ManageAccountsMethodHooks = {
15
15
  /**
16
16
  * Gets the snap keyring implementation.
17
17
  */
@@ -19,11 +19,11 @@ export declare type ManageAccountsMethodHooks = {
19
19
  handleKeyringSnapMessage: (snapId: string, message: Message) => Promise<Json>;
20
20
  }>;
21
21
  };
22
- declare type ManageAccountsSpecificationBuilderOptions = {
22
+ type ManageAccountsSpecificationBuilderOptions = {
23
23
  allowedCaveats?: Readonly<NonEmptyArray<string>> | null;
24
24
  methodHooks: ManageAccountsMethodHooks;
25
25
  };
26
- declare type ManageAccountsSpecification = ValidPermissionSpecification<{
26
+ type ManageAccountsSpecification = ValidPermissionSpecification<{
27
27
  permissionType: PermissionType.RestrictedMethod;
28
28
  targetName: typeof methodName;
29
29
  methodImplementation: ReturnType<typeof manageAccountsImplementation>;
@@ -5,7 +5,7 @@ import type { Json, NonEmptyArray } from '@metamask/utils';
5
5
  import type { MethodHooksObject } from '../utils';
6
6
  export declare const STATE_ENCRYPTION_SALT = "snap_manageState encryption";
7
7
  declare const methodName = "snap_manageState";
8
- export declare type ManageStateMethodHooks = {
8
+ export type ManageStateMethodHooks = {
9
9
  /**
10
10
  * Waits for the extension to be unlocked.
11
11
  *
@@ -29,11 +29,11 @@ export declare type ManageStateMethodHooks = {
29
29
  */
30
30
  updateSnapState: (snapId: string, newState: Record<string, Json>, encrypted: boolean) => Promise<void>;
31
31
  };
32
- declare type ManageStateSpecificationBuilderOptions = {
32
+ type ManageStateSpecificationBuilderOptions = {
33
33
  allowedCaveats?: Readonly<NonEmptyArray<string>> | null;
34
34
  methodHooks: ManageStateMethodHooks;
35
35
  };
36
- declare type ManageStateSpecification = ValidPermissionSpecification<{
36
+ type ManageStateSpecification = ValidPermissionSpecification<{
37
37
  permissionType: PermissionType.RestrictedMethod;
38
38
  targetName: typeof methodName;
39
39
  methodImplementation: ReturnType<typeof getManageStateImplementation>;
@@ -61,7 +61,7 @@ export declare const manageStateBuilder: Readonly<{
61
61
  readonly methodHooks: MethodHooksObject<ManageStateMethodHooks>;
62
62
  }>;
63
63
  export declare const STORAGE_SIZE_LIMIT = 104857600;
64
- declare type GetEncryptionKeyArgs = {
64
+ type GetEncryptionKeyArgs = {
65
65
  snapId: string;
66
66
  mnemonicPhrase: Uint8Array;
67
67
  };
@@ -5,7 +5,7 @@ import type { NotifyParams, NotifyResult, EnumToUnion } from '@metamask/snaps-sd
5
5
  import type { NonEmptyArray } from '@metamask/utils';
6
6
  import { type MethodHooksObject } from '../utils';
7
7
  declare const methodName = "snap_notify";
8
- export declare type NotificationArgs = {
8
+ export type NotificationArgs = {
9
9
  /**
10
10
  * Enum type to determine notification type.
11
11
  */
@@ -15,7 +15,7 @@ export declare type NotificationArgs = {
15
15
  */
16
16
  message: string;
17
17
  };
18
- export declare type NotifyMethodHooks = {
18
+ export type NotifyMethodHooks = {
19
19
  /**
20
20
  * @param snapId - The ID of the Snap that created the notification.
21
21
  * @param args - The notification arguments.
@@ -29,11 +29,11 @@ export declare type NotifyMethodHooks = {
29
29
  isOnPhishingList: (url: string) => boolean;
30
30
  maybeUpdatePhishingList: () => Promise<void>;
31
31
  };
32
- declare type SpecificationBuilderOptions = {
32
+ type SpecificationBuilderOptions = {
33
33
  allowedCaveats?: Readonly<NonEmptyArray<string>> | null;
34
34
  methodHooks: NotifyMethodHooks;
35
35
  };
36
- declare type Specification = ValidPermissionSpecification<{
36
+ type Specification = ValidPermissionSpecification<{
37
37
  permissionType: PermissionType.RestrictedMethod;
38
38
  targetName: typeof methodName;
39
39
  methodImplementation: ReturnType<typeof getImplementation>;
@@ -7,7 +7,7 @@ import type { Hex } from '@metamask/utils';
7
7
  * interface, and `true` as value. This ensures that the `methodHooks` object
8
8
  * has the same values as the interface.
9
9
  */
10
- export declare type MethodHooksObject<HooksType extends Record<string, unknown>> = {
10
+ export type MethodHooksObject<HooksType extends Record<string, unknown>> = {
11
11
  [Key in keyof HooksType]: true;
12
12
  };
13
13
  /**
@@ -23,7 +23,7 @@ export declare type MethodHooksObject<HooksType extends Record<string, unknown>>
23
23
  * @template HookName - The names of the hooks to select.
24
24
  */
25
25
  export declare function selectHooks<Hooks extends Record<string, unknown>, HookName extends keyof Hooks>(hooks: Hooks, hookNames?: Record<HookName, boolean>): Pick<Hooks, HookName> | undefined;
26
- declare type DeriveEntropyOptions = {
26
+ type DeriveEntropyOptions = {
27
27
  /**
28
28
  * The input value to derive entropy from.
29
29
  */
@@ -74,7 +74,7 @@ export declare function deriveEntropy({ input, salt, mnemonicPhrase, magic, }: D
74
74
  * @returns The path prefix, i.e., `bip32` or `slip10`.
75
75
  */
76
76
  export declare function getPathPrefix(curve: SupportedCurve): 'bip32' | 'slip10' | 'cip3';
77
- declare type GetNodeArgs = {
77
+ type GetNodeArgs = {
78
78
  curve: SupportedCurve;
79
79
  secretRecoveryPhrase: Uint8Array;
80
80
  path: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/snaps-rpc-methods",
3
- "version": "10.0.0",
3
+ "version": "11.0.0",
4
4
  "description": "MetaMask Snaps JSON-RPC method implementations.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,10 +40,10 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@metamask/key-tree": "^9.1.2",
43
- "@metamask/permission-controller": "^10.0.1",
43
+ "@metamask/permission-controller": "^11.0.0",
44
44
  "@metamask/rpc-errors": "^6.3.1",
45
- "@metamask/snaps-sdk": "^6.1.0",
46
- "@metamask/snaps-utils": "^7.8.0",
45
+ "@metamask/snaps-sdk": "^6.2.0",
46
+ "@metamask/snaps-utils": "^8.0.0",
47
47
  "@metamask/superstruct": "^3.1.0",
48
48
  "@metamask/utils": "^9.1.0",
49
49
  "@noble/hashes": "^1.3.1"
@@ -55,7 +55,7 @@
55
55
  "@metamask/eslint-config-jest": "^12.1.0",
56
56
  "@metamask/eslint-config-nodejs": "^12.1.0",
57
57
  "@metamask/eslint-config-typescript": "^12.1.0",
58
- "@metamask/json-rpc-engine": "^9.0.0",
58
+ "@metamask/json-rpc-engine": "^9.0.2",
59
59
  "@swc/core": "1.3.78",
60
60
  "@swc/jest": "^0.2.26",
61
61
  "@types/node": "18.14.2",
@@ -77,7 +77,7 @@
77
77
  "prettier-plugin-packagejson": "^2.2.11",
78
78
  "rimraf": "^4.1.2",
79
79
  "tsup": "^8.0.1",
80
- "typescript": "~4.8.4"
80
+ "typescript": "~5.0.4"
81
81
  },
82
82
  "engines": {
83
83
  "node": "^18.16 || >=20"
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/restricted/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCO,IAAM,qCAAqC;AAAA,EAChD,CAAC,cAAc,UAAU,GAAG;AAAA,EAC5B,CAAC,uBAAuB,UAAU,GAAG;AAAA,EACrC,CAAC,yBAAyB,UAAU,GAAG;AAAA,EACvC,CAAC,uBAAuB,UAAU,GAAG;AAAA,EACrC,CAAC,kBAAkB,UAAU,GAAG;AAAA,EAChC,CAAC,kBAAkB,UAAU,GAAG;AAAA,EAChC,CAAC,mBAAmB,UAAU,GAAG;AAAA,EACjC,CAAC,cAAc,UAAU,GAAG;AAAA,EAC5B,CAAC,sBAAsB,UAAU,GAAG;AAAA,EACpC,CAAC,iBAAiB,UAAU,GAAG;AACjC","sourcesContent":["import type { DialogMethodHooks } from './dialog';\nimport { dialogBuilder } from './dialog';\nimport type { GetBip32EntropyMethodHooks } from './getBip32Entropy';\nimport { getBip32EntropyBuilder } from './getBip32Entropy';\nimport type { GetBip32PublicKeyMethodHooks } from './getBip32PublicKey';\nimport { getBip32PublicKeyBuilder } from './getBip32PublicKey';\nimport type { GetBip44EntropyMethodHooks } from './getBip44Entropy';\nimport { getBip44EntropyBuilder } from './getBip44Entropy';\nimport type { GetEntropyHooks } from './getEntropy';\nimport { getEntropyBuilder } from './getEntropy';\nimport type { GetLocaleMethodHooks } from './getLocale';\nimport { getLocaleBuilder } from './getLocale';\nimport type { InvokeSnapMethodHooks } from './invokeSnap';\nimport { invokeSnapBuilder } from './invokeSnap';\nimport type { ManageAccountsMethodHooks } from './manageAccounts';\nimport { manageAccountsBuilder } from './manageAccounts';\nimport type { ManageStateMethodHooks } from './manageState';\nimport { manageStateBuilder } from './manageState';\nimport type { NotifyMethodHooks } from './notify';\nimport { notifyBuilder } from './notify';\n\nexport { WALLET_SNAP_PERMISSION_KEY } from './invokeSnap';\nexport { getEncryptionEntropy } from './manageState';\n\nexport type RestrictedMethodHooks = DialogMethodHooks &\n GetBip32EntropyMethodHooks &\n GetBip32PublicKeyMethodHooks &\n GetBip44EntropyMethodHooks &\n GetEntropyHooks &\n InvokeSnapMethodHooks &\n ManageStateMethodHooks &\n NotifyMethodHooks &\n ManageAccountsMethodHooks &\n GetLocaleMethodHooks;\n\nexport const restrictedMethodPermissionBuilders = {\n [dialogBuilder.targetName]: dialogBuilder,\n [getBip32EntropyBuilder.targetName]: getBip32EntropyBuilder,\n [getBip32PublicKeyBuilder.targetName]: getBip32PublicKeyBuilder,\n [getBip44EntropyBuilder.targetName]: getBip44EntropyBuilder,\n [getEntropyBuilder.targetName]: getEntropyBuilder,\n [invokeSnapBuilder.targetName]: invokeSnapBuilder,\n [manageStateBuilder.targetName]: manageStateBuilder,\n [notifyBuilder.targetName]: notifyBuilder,\n [manageAccountsBuilder.targetName]: manageAccountsBuilder,\n [getLocaleBuilder.targetName]: getLocaleBuilder,\n} as const;\n\nexport * from './caveats';\nexport type { DialogApprovalTypes } from './dialog';\nexport { DIALOG_APPROVAL_TYPES } from './dialog';\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/restricted/getLocale.ts"],"sourcesContent":["import type {\n PermissionSpecificationBuilder,\n ValidPermissionSpecification,\n RestrictedMethodOptions,\n RestrictedMethodParameters,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport type { GetLocaleResult } from '@metamask/snaps-sdk';\nimport type { NonEmptyArray } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst methodName = 'snap_getLocale';\n\nexport type GetLocaleMethodHooks = {\n getLocale: () => Promise<string>;\n};\n\ntype SpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: GetLocaleMethodHooks;\n};\n\ntype Specification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof methodName;\n methodImplementation: ReturnType<typeof getImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * The specification builder for the `snap_getLocale` permission.\n * `snap_getLocale` allows snaps to get the user selected locale.\n *\n * @param options - The specification builder options.\n * @param options.allowedCaveats - The optional allowed caveats for the permission.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_getLocale` permission.\n */\nexport const specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n SpecificationBuilderOptions,\n Specification\n> = ({ allowedCaveats = null, methodHooks }: SpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: methodName,\n allowedCaveats,\n methodImplementation: getImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetLocaleMethodHooks> = {\n getLocale: true,\n};\n\nexport const getLocaleBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getLocale`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getLocale - A function that returns the user selected locale.\n * @returns The user selected locale.\n */\nexport function getImplementation({ getLocale }: GetLocaleMethodHooks) {\n return async function implementation(\n _args: RestrictedMethodOptions<RestrictedMethodParameters>,\n ): Promise<GetLocaleResult> {\n return getLocale();\n };\n}\n"],"mappings":";AAMA,SAAS,gBAAgB,mBAAmB;AAM5C,IAAM,aAAa;AA2BZ,IAAM,uBAIT,CAAC,EAAE,iBAAiB,MAAM,aAAAA,aAAY,MAAmC;AAC3E,SAAO;AAAA,IACL,gBAAgB,eAAe;AAAA,IAC/B,YAAY;AAAA,IACZ;AAAA,IACA,sBAAsB,kBAAkBA,YAAW;AAAA,IACnD,cAAc,CAAC,YAAY,IAAI;AAAA,EACjC;AACF;AAEA,IAAM,cAAuD;AAAA,EAC3D,WAAW;AACb;AAEO,IAAM,mBAAmB,OAAO,OAAO;AAAA,EAC5C,YAAY;AAAA,EACZ;AAAA,EACA;AACF,CAAU;AASH,SAAS,kBAAkB,EAAE,UAAU,GAAyB;AACrE,SAAO,eAAe,eACpB,OAC0B;AAC1B,WAAO,UAAU;AAAA,EACnB;AACF;","names":["methodHooks"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/restricted/index.ts"],"sourcesContent":["import type { DialogMethodHooks } from './dialog';\nimport { dialogBuilder } from './dialog';\nimport type { GetBip32EntropyMethodHooks } from './getBip32Entropy';\nimport { getBip32EntropyBuilder } from './getBip32Entropy';\nimport type { GetBip32PublicKeyMethodHooks } from './getBip32PublicKey';\nimport { getBip32PublicKeyBuilder } from './getBip32PublicKey';\nimport type { GetBip44EntropyMethodHooks } from './getBip44Entropy';\nimport { getBip44EntropyBuilder } from './getBip44Entropy';\nimport type { GetEntropyHooks } from './getEntropy';\nimport { getEntropyBuilder } from './getEntropy';\nimport type { GetLocaleMethodHooks } from './getLocale';\nimport { getLocaleBuilder } from './getLocale';\nimport type { InvokeSnapMethodHooks } from './invokeSnap';\nimport { invokeSnapBuilder } from './invokeSnap';\nimport type { ManageAccountsMethodHooks } from './manageAccounts';\nimport { manageAccountsBuilder } from './manageAccounts';\nimport type { ManageStateMethodHooks } from './manageState';\nimport { manageStateBuilder } from './manageState';\nimport type { NotifyMethodHooks } from './notify';\nimport { notifyBuilder } from './notify';\n\nexport { WALLET_SNAP_PERMISSION_KEY } from './invokeSnap';\nexport { getEncryptionEntropy } from './manageState';\n\nexport type RestrictedMethodHooks = DialogMethodHooks &\n GetBip32EntropyMethodHooks &\n GetBip32PublicKeyMethodHooks &\n GetBip44EntropyMethodHooks &\n GetEntropyHooks &\n InvokeSnapMethodHooks &\n ManageStateMethodHooks &\n NotifyMethodHooks &\n ManageAccountsMethodHooks &\n GetLocaleMethodHooks;\n\nexport const restrictedMethodPermissionBuilders = {\n [dialogBuilder.targetName]: dialogBuilder,\n [getBip32EntropyBuilder.targetName]: getBip32EntropyBuilder,\n [getBip32PublicKeyBuilder.targetName]: getBip32PublicKeyBuilder,\n [getBip44EntropyBuilder.targetName]: getBip44EntropyBuilder,\n [getEntropyBuilder.targetName]: getEntropyBuilder,\n [invokeSnapBuilder.targetName]: invokeSnapBuilder,\n [manageStateBuilder.targetName]: manageStateBuilder,\n [notifyBuilder.targetName]: notifyBuilder,\n [manageAccountsBuilder.targetName]: manageAccountsBuilder,\n [getLocaleBuilder.targetName]: getLocaleBuilder,\n} as const;\n\nexport * from './caveats';\nexport type { DialogApprovalTypes } from './dialog';\nexport { DIALOG_APPROVAL_TYPES } from './dialog';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCO,IAAM,qCAAqC;AAAA,EAChD,CAAC,cAAc,UAAU,GAAG;AAAA,EAC5B,CAAC,uBAAuB,UAAU,GAAG;AAAA,EACrC,CAAC,yBAAyB,UAAU,GAAG;AAAA,EACvC,CAAC,uBAAuB,UAAU,GAAG;AAAA,EACrC,CAAC,kBAAkB,UAAU,GAAG;AAAA,EAChC,CAAC,kBAAkB,UAAU,GAAG;AAAA,EAChC,CAAC,mBAAmB,UAAU,GAAG;AAAA,EACjC,CAAC,cAAc,UAAU,GAAG;AAAA,EAC5B,CAAC,sBAAsB,UAAU,GAAG;AAAA,EACpC,CAAC,iBAAiB,UAAU,GAAG;AACjC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/restricted/getLocale.ts"],"names":["methodHooks"],"mappings":";AAMA,SAAS,gBAAgB,mBAAmB;AAM5C,IAAM,aAAa;AA2BZ,IAAM,uBAIT,CAAC,EAAE,iBAAiB,MAAM,aAAAA,aAAY,MAAmC;AAC3E,SAAO;AAAA,IACL,gBAAgB,eAAe;AAAA,IAC/B,YAAY;AAAA,IACZ;AAAA,IACA,sBAAsB,kBAAkBA,YAAW;AAAA,IACnD,cAAc,CAAC,YAAY,IAAI;AAAA,EACjC;AACF;AAEA,IAAM,cAAuD;AAAA,EAC3D,WAAW;AACb;AAEO,IAAM,mBAAmB,OAAO,OAAO;AAAA,EAC5C,YAAY;AAAA,EACZ;AAAA,EACA;AACF,CAAU;AASH,SAAS,kBAAkB,EAAE,UAAU,GAAyB;AACrE,SAAO,eAAe,eACpB,OAC0B;AAC1B,WAAO,UAAU;AAAA,EACnB;AACF","sourcesContent":["import type {\n PermissionSpecificationBuilder,\n ValidPermissionSpecification,\n RestrictedMethodOptions,\n RestrictedMethodParameters,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport type { GetLocaleResult } from '@metamask/snaps-sdk';\nimport type { NonEmptyArray } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst methodName = 'snap_getLocale';\n\nexport type GetLocaleMethodHooks = {\n getLocale: () => Promise<string>;\n};\n\ntype SpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: GetLocaleMethodHooks;\n};\n\ntype Specification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof methodName;\n methodImplementation: ReturnType<typeof getImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * The specification builder for the `snap_getLocale` permission.\n * `snap_getLocale` allows snaps to get the user selected locale.\n *\n * @param options - The specification builder options.\n * @param options.allowedCaveats - The optional allowed caveats for the permission.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_getLocale` permission.\n */\nexport const specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n SpecificationBuilderOptions,\n Specification\n> = ({ allowedCaveats = null, methodHooks }: SpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: methodName,\n allowedCaveats,\n methodImplementation: getImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetLocaleMethodHooks> = {\n getLocale: true,\n};\n\nexport const getLocaleBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getLocale`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getLocale - A function that returns the user selected locale.\n * @returns The user selected locale.\n */\nexport function getImplementation({ getLocale }: GetLocaleMethodHooks) {\n return async function implementation(\n _args: RestrictedMethodOptions<RestrictedMethodParameters>,\n ): Promise<GetLocaleResult> {\n return getLocale();\n };\n}\n"]}