@metamask/snaps-rpc-methods
Advanced tools
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.createWalletSnapPermissionMiddleware = void 0; | ||
| const rpc_errors_1 = require("@metamask/rpc-errors"); | ||
| const restricted_1 = require("../restricted/index.cjs"); | ||
| /** | ||
| * Create a middleware that validates `wallet_requestPermissions` calls that | ||
| * include the `wallet_snap` permission. | ||
| * | ||
| * This prevents requesting the `wallet_snap` permission in the same call as | ||
| * other permissions, which could lead to a confusing user experience where | ||
| * multiple permission screens are shown at once, or the other permissions are | ||
| * not displayed properly because the `wallet_snap` permission screen takes | ||
| * precedence. | ||
| * | ||
| * @returns The middleware. | ||
| */ | ||
| function createWalletSnapPermissionMiddleware() { | ||
| return async ({ request, next }) => { | ||
| if (request.method === 'wallet_requestPermissions') { | ||
| const requestedPermissions = request.params?.[0]; | ||
| const requestedPermissionsKeys = Object.keys(requestedPermissions ?? {}); | ||
| if (requestedPermissionsKeys.length > 1 && | ||
| requestedPermissionsKeys.includes(restricted_1.WALLET_SNAP_PERMISSION_KEY)) { | ||
| throw rpc_errors_1.rpcErrors.invalidParams('Permission request for `wallet_snap` cannot include other permissions. Please separate your permission requests into multiple calls to `wallet_requestPermissions`.'); | ||
| } | ||
| } | ||
| return await next(); | ||
| }; | ||
| } | ||
| exports.createWalletSnapPermissionMiddleware = createWalletSnapPermissionMiddleware; | ||
| //# sourceMappingURL=wallet-snap-permission.cjs.map |
| {"version":3,"file":"wallet-snap-permission.cjs","sourceRoot":"","sources":["../../src/middleware/wallet-snap-permission.ts"],"names":[],"mappings":";;;AAIA,qDAAiD;AAGjD,wDAA2D;AAI3D;;;;;;;;;;;GAWG;AACH,SAAgB,oCAAoC;IAGlD,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;QACjC,IAAI,OAAO,CAAC,MAAM,KAAK,2BAA2B,EAAE,CAAC;YACnD,MAAM,oBAAoB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;YACjD,MAAM,wBAAwB,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC;YAEzE,IACE,wBAAwB,CAAC,MAAM,GAAG,CAAC;gBACnC,wBAAwB,CAAC,QAAQ,CAAC,uCAA0B,CAAC,EAC7D,CAAC;gBACD,MAAM,sBAAS,CAAC,aAAa,CAC3B,qKAAqK,CACtK,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,MAAM,IAAI,EAAE,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC;AApBD,oFAoBC","sourcesContent":["import type {\n JsonRpcCall,\n JsonRpcMiddleware,\n} from '@metamask/json-rpc-engine/v2';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { Json } from '@metamask/utils';\n\nimport { WALLET_SNAP_PERMISSION_KEY } from '../restricted';\n\ntype RequestParams = [Record<string, Json>];\n\n/**\n * Create a middleware that validates `wallet_requestPermissions` calls that\n * include the `wallet_snap` permission.\n *\n * This prevents requesting the `wallet_snap` permission in the same call as\n * other permissions, which could lead to a confusing user experience where\n * multiple permission screens are shown at once, or the other permissions are\n * not displayed properly because the `wallet_snap` permission screen takes\n * precedence.\n *\n * @returns The middleware.\n */\nexport function createWalletSnapPermissionMiddleware(): JsonRpcMiddleware<\n JsonRpcCall<RequestParams>\n> {\n return async ({ request, next }) => {\n if (request.method === 'wallet_requestPermissions') {\n const requestedPermissions = request.params?.[0];\n const requestedPermissionsKeys = Object.keys(requestedPermissions ?? {});\n\n if (\n requestedPermissionsKeys.length > 1 &&\n requestedPermissionsKeys.includes(WALLET_SNAP_PERMISSION_KEY)\n ) {\n throw rpcErrors.invalidParams(\n 'Permission request for `wallet_snap` cannot include other permissions. Please separate your permission requests into multiple calls to `wallet_requestPermissions`.',\n );\n }\n }\n\n return await next();\n };\n}\n"]} |
| import type { JsonRpcCall, JsonRpcMiddleware } from "@metamask/json-rpc-engine/v2"; | ||
| import type { Json } from "@metamask/utils"; | ||
| type RequestParams = [Record<string, Json>]; | ||
| /** | ||
| * Create a middleware that validates `wallet_requestPermissions` calls that | ||
| * include the `wallet_snap` permission. | ||
| * | ||
| * This prevents requesting the `wallet_snap` permission in the same call as | ||
| * other permissions, which could lead to a confusing user experience where | ||
| * multiple permission screens are shown at once, or the other permissions are | ||
| * not displayed properly because the `wallet_snap` permission screen takes | ||
| * precedence. | ||
| * | ||
| * @returns The middleware. | ||
| */ | ||
| export declare function createWalletSnapPermissionMiddleware(): JsonRpcMiddleware<JsonRpcCall<RequestParams>>; | ||
| export {}; | ||
| //# sourceMappingURL=wallet-snap-permission.d.cts.map |
| {"version":3,"file":"wallet-snap-permission.d.cts","sourceRoot":"","sources":["../../src/middleware/wallet-snap-permission.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EAClB,qCAAqC;AAEtC,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAI5C,KAAK,aAAa,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,wBAAgB,oCAAoC,IAAI,iBAAiB,CACvE,WAAW,CAAC,aAAa,CAAC,CAC3B,CAkBA"} |
| import type { JsonRpcCall, JsonRpcMiddleware } from "@metamask/json-rpc-engine/v2"; | ||
| import type { Json } from "@metamask/utils"; | ||
| type RequestParams = [Record<string, Json>]; | ||
| /** | ||
| * Create a middleware that validates `wallet_requestPermissions` calls that | ||
| * include the `wallet_snap` permission. | ||
| * | ||
| * This prevents requesting the `wallet_snap` permission in the same call as | ||
| * other permissions, which could lead to a confusing user experience where | ||
| * multiple permission screens are shown at once, or the other permissions are | ||
| * not displayed properly because the `wallet_snap` permission screen takes | ||
| * precedence. | ||
| * | ||
| * @returns The middleware. | ||
| */ | ||
| export declare function createWalletSnapPermissionMiddleware(): JsonRpcMiddleware<JsonRpcCall<RequestParams>>; | ||
| export {}; | ||
| //# sourceMappingURL=wallet-snap-permission.d.mts.map |
| {"version":3,"file":"wallet-snap-permission.d.mts","sourceRoot":"","sources":["../../src/middleware/wallet-snap-permission.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EAClB,qCAAqC;AAEtC,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAI5C,KAAK,aAAa,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,wBAAgB,oCAAoC,IAAI,iBAAiB,CACvE,WAAW,CAAC,aAAa,CAAC,CAC3B,CAkBA"} |
| import { rpcErrors } from "@metamask/rpc-errors"; | ||
| import { WALLET_SNAP_PERMISSION_KEY } from "../restricted/index.mjs"; | ||
| /** | ||
| * Create a middleware that validates `wallet_requestPermissions` calls that | ||
| * include the `wallet_snap` permission. | ||
| * | ||
| * This prevents requesting the `wallet_snap` permission in the same call as | ||
| * other permissions, which could lead to a confusing user experience where | ||
| * multiple permission screens are shown at once, or the other permissions are | ||
| * not displayed properly because the `wallet_snap` permission screen takes | ||
| * precedence. | ||
| * | ||
| * @returns The middleware. | ||
| */ | ||
| export function createWalletSnapPermissionMiddleware() { | ||
| return async ({ request, next }) => { | ||
| if (request.method === 'wallet_requestPermissions') { | ||
| const requestedPermissions = request.params?.[0]; | ||
| const requestedPermissionsKeys = Object.keys(requestedPermissions ?? {}); | ||
| if (requestedPermissionsKeys.length > 1 && | ||
| requestedPermissionsKeys.includes(WALLET_SNAP_PERMISSION_KEY)) { | ||
| throw rpcErrors.invalidParams('Permission request for `wallet_snap` cannot include other permissions. Please separate your permission requests into multiple calls to `wallet_requestPermissions`.'); | ||
| } | ||
| } | ||
| return await next(); | ||
| }; | ||
| } | ||
| //# sourceMappingURL=wallet-snap-permission.mjs.map |
| {"version":3,"file":"wallet-snap-permission.mjs","sourceRoot":"","sources":["../../src/middleware/wallet-snap-permission.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAGjD,OAAO,EAAE,0BAA0B,EAAE,gCAAsB;AAI3D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oCAAoC;IAGlD,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;QACjC,IAAI,OAAO,CAAC,MAAM,KAAK,2BAA2B,EAAE,CAAC;YACnD,MAAM,oBAAoB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;YACjD,MAAM,wBAAwB,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC;YAEzE,IACE,wBAAwB,CAAC,MAAM,GAAG,CAAC;gBACnC,wBAAwB,CAAC,QAAQ,CAAC,0BAA0B,CAAC,EAC7D,CAAC;gBACD,MAAM,SAAS,CAAC,aAAa,CAC3B,qKAAqK,CACtK,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,MAAM,IAAI,EAAE,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type {\n JsonRpcCall,\n JsonRpcMiddleware,\n} from '@metamask/json-rpc-engine/v2';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { Json } from '@metamask/utils';\n\nimport { WALLET_SNAP_PERMISSION_KEY } from '../restricted';\n\ntype RequestParams = [Record<string, Json>];\n\n/**\n * Create a middleware that validates `wallet_requestPermissions` calls that\n * include the `wallet_snap` permission.\n *\n * This prevents requesting the `wallet_snap` permission in the same call as\n * other permissions, which could lead to a confusing user experience where\n * multiple permission screens are shown at once, or the other permissions are\n * not displayed properly because the `wallet_snap` permission screen takes\n * precedence.\n *\n * @returns The middleware.\n */\nexport function createWalletSnapPermissionMiddleware(): JsonRpcMiddleware<\n JsonRpcCall<RequestParams>\n> {\n return async ({ request, next }) => {\n if (request.method === 'wallet_requestPermissions') {\n const requestedPermissions = request.params?.[0];\n const requestedPermissionsKeys = Object.keys(requestedPermissions ?? {});\n\n if (\n requestedPermissionsKeys.length > 1 &&\n requestedPermissionsKeys.includes(WALLET_SNAP_PERMISSION_KEY)\n ) {\n throw rpcErrors.invalidParams(\n 'Permission request for `wallet_snap` cannot include other permissions. Please separate your permission requests into multiple calls to `wallet_requestPermissions`.',\n );\n }\n }\n\n return await next();\n };\n}\n"]} |
+12
-1
@@ -10,2 +10,12 @@ # Changelog | ||
| ## [14.3.0] | ||
| ### Added | ||
| - Add middleware to validate `wallet_snap` permission request ([#3838](https://github.com/MetaMask/snaps/pull/3838)) | ||
| ### Fixed | ||
| - Cleanup endowment handling of `maxRequestTime` ([#3826](https://github.com/MetaMask/snaps/pull/3826)) | ||
| ## [14.2.0] | ||
@@ -561,3 +571,4 @@ | ||
| [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@14.2.0...HEAD | ||
| [Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@14.3.0...HEAD | ||
| [14.3.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@14.2.0...@metamask/snaps-rpc-methods@14.3.0 | ||
| [14.2.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@14.1.1...@metamask/snaps-rpc-methods@14.2.0 | ||
@@ -564,0 +575,0 @@ [14.1.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@14.1.0...@metamask/snaps-rpc-methods@14.1.1 |
@@ -20,3 +20,3 @@ "use strict"; | ||
| targetName: permissionName, | ||
| allowedCaveats: [snaps_utils_1.SnapCaveatType.ChainIds], | ||
| allowedCaveats: [snaps_utils_1.SnapCaveatType.ChainIds, snaps_utils_1.SnapCaveatType.MaxRequestTime], | ||
| endowmentGetter: (_getterOptions) => null, | ||
@@ -23,0 +23,0 @@ subjectTypes: [permission_controller_1.SubjectType.Snap], |
@@ -17,3 +17,3 @@ import { PermissionType, SubjectType } from "@metamask/permission-controller"; | ||
| targetName: permissionName, | ||
| allowedCaveats: [SnapCaveatType.ChainIds], | ||
| allowedCaveats: [SnapCaveatType.ChainIds, SnapCaveatType.MaxRequestTime], | ||
| endowmentGetter: (_getterOptions) => null, | ||
@@ -20,0 +20,0 @@ subjectTypes: [SubjectType.Snap], |
@@ -21,3 +21,3 @@ "use strict"; | ||
| targetName: permissionName, | ||
| allowedCaveats: [snaps_utils_1.SnapCaveatType.SnapCronjob], | ||
| allowedCaveats: [snaps_utils_1.SnapCaveatType.SnapCronjob, snaps_utils_1.SnapCaveatType.MaxRequestTime], | ||
| endowmentGetter: (_getterOptions) => null, | ||
@@ -69,9 +69,4 @@ subjectTypes: [permission_controller_1.SubjectType.Snap], | ||
| function getCronjobCaveatJobs(permission) { | ||
| if (!permission?.caveats) { | ||
| return null; | ||
| } | ||
| (0, utils_1.assert)(permission.caveats.length === 1); | ||
| (0, utils_1.assert)(permission.caveats[0].type === snaps_utils_1.SnapCaveatType.SnapCronjob); | ||
| const caveat = permission.caveats[0]; | ||
| return caveat.value?.jobs ?? null; | ||
| const caveat = permission?.caveats?.find((permCaveat) => permCaveat.type === snaps_utils_1.SnapCaveatType.SnapCronjob); | ||
| return caveat?.value?.jobs ?? null; | ||
| } | ||
@@ -78,0 +73,0 @@ exports.getCronjobCaveatJobs = getCronjobCaveatJobs; |
| import { PermissionType, SubjectType } from "@metamask/permission-controller"; | ||
| import { rpcErrors } from "@metamask/rpc-errors"; | ||
| import { SnapCaveatType, isCronjobSpecificationArray } from "@metamask/snaps-utils"; | ||
| import { assert, hasProperty, isObject, isPlainObject } from "@metamask/utils"; | ||
| import { hasProperty, isObject, isPlainObject } from "@metamask/utils"; | ||
| import { createGenericPermissionValidator } from "./caveats/index.mjs"; | ||
@@ -18,3 +18,3 @@ import { SnapEndowments } from "./enum.mjs"; | ||
| targetName: permissionName, | ||
| allowedCaveats: [SnapCaveatType.SnapCronjob], | ||
| allowedCaveats: [SnapCaveatType.SnapCronjob, SnapCaveatType.MaxRequestTime], | ||
| endowmentGetter: (_getterOptions) => null, | ||
@@ -65,9 +65,4 @@ subjectTypes: [SubjectType.Snap], | ||
| export function getCronjobCaveatJobs(permission) { | ||
| if (!permission?.caveats) { | ||
| return null; | ||
| } | ||
| assert(permission.caveats.length === 1); | ||
| assert(permission.caveats[0].type === SnapCaveatType.SnapCronjob); | ||
| const caveat = permission.caveats[0]; | ||
| return caveat.value?.jobs ?? null; | ||
| const caveat = permission?.caveats?.find((permCaveat) => permCaveat.type === SnapCaveatType.SnapCronjob); | ||
| return caveat?.value?.jobs ?? null; | ||
| } | ||
@@ -74,0 +69,0 @@ /** |
@@ -5,2 +5,4 @@ "use strict"; | ||
| const permission_controller_1 = require("@metamask/permission-controller"); | ||
| const snaps_utils_1 = require("@metamask/snaps-utils"); | ||
| const caveats_1 = require("./caveats/index.cjs"); | ||
| const enum_1 = require("./enum.cjs"); | ||
@@ -20,5 +22,8 @@ const permissionName = enum_1.SnapEndowments.HomePage; | ||
| targetName: permissionName, | ||
| allowedCaveats: null, | ||
| allowedCaveats: [snaps_utils_1.SnapCaveatType.MaxRequestTime], | ||
| endowmentGetter: (_getterOptions) => null, | ||
| subjectTypes: [permission_controller_1.SubjectType.Snap], | ||
| validator: (0, caveats_1.createGenericPermissionValidator)([ | ||
| { type: snaps_utils_1.SnapCaveatType.MaxRequestTime, optional: true }, | ||
| ]), | ||
| }; | ||
@@ -25,0 +30,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
| import type { PermissionSpecificationBuilder, EndowmentGetterParams } from "@metamask/permission-controller"; | ||
| import type { PermissionSpecificationBuilder, EndowmentGetterParams, PermissionValidatorConstraint } from "@metamask/permission-controller"; | ||
| import { PermissionType } from "@metamask/permission-controller"; | ||
@@ -13,2 +13,3 @@ import type { NonEmptyArray } from "@metamask/utils"; | ||
| allowedCaveats: Readonly<NonEmptyArray<string>> | null; | ||
| validator: PermissionValidatorConstraint; | ||
| }>; | ||
@@ -15,0 +16,0 @@ }>; |
@@ -1,2 +0,2 @@ | ||
| import type { PermissionSpecificationBuilder, EndowmentGetterParams } from "@metamask/permission-controller"; | ||
| import type { PermissionSpecificationBuilder, EndowmentGetterParams, PermissionValidatorConstraint } from "@metamask/permission-controller"; | ||
| import { PermissionType } from "@metamask/permission-controller"; | ||
@@ -13,2 +13,3 @@ import type { NonEmptyArray } from "@metamask/utils"; | ||
| allowedCaveats: Readonly<NonEmptyArray<string>> | null; | ||
| validator: PermissionValidatorConstraint; | ||
| }>; | ||
@@ -15,0 +16,0 @@ }>; |
| import { PermissionType, SubjectType } from "@metamask/permission-controller"; | ||
| import { SnapCaveatType } from "@metamask/snaps-utils"; | ||
| import { createGenericPermissionValidator } from "./caveats/index.mjs"; | ||
| import { SnapEndowments } from "./enum.mjs"; | ||
@@ -16,5 +18,8 @@ const permissionName = SnapEndowments.HomePage; | ||
| targetName: permissionName, | ||
| allowedCaveats: null, | ||
| allowedCaveats: [SnapCaveatType.MaxRequestTime], | ||
| endowmentGetter: (_getterOptions) => null, | ||
| subjectTypes: [SubjectType.Snap], | ||
| validator: createGenericPermissionValidator([ | ||
| { type: SnapCaveatType.MaxRequestTime, optional: true }, | ||
| ]), | ||
| }; | ||
@@ -21,0 +26,0 @@ }; |
@@ -88,2 +88,3 @@ import type { PermissionConstraint } from "@metamask/permission-controller"; | ||
| allowedCaveats: readonly [string, ...string[]] | null; | ||
| validator: import("@metamask/permission-controller").PermissionValidatorConstraint; | ||
| }>; | ||
@@ -109,2 +110,3 @@ }>; | ||
| allowedCaveats: readonly [string, ...string[]] | null; | ||
| validator: import("@metamask/permission-controller").PermissionValidatorConstraint; | ||
| }>; | ||
@@ -130,2 +132,3 @@ }>; | ||
| allowedCaveats: readonly [string, ...string[]] | null; | ||
| validator: import("@metamask/permission-controller").PermissionValidatorConstraint; | ||
| }>; | ||
@@ -132,0 +135,0 @@ }>; |
@@ -88,2 +88,3 @@ import type { PermissionConstraint } from "@metamask/permission-controller"; | ||
| allowedCaveats: readonly [string, ...string[]] | null; | ||
| validator: import("@metamask/permission-controller").PermissionValidatorConstraint; | ||
| }>; | ||
@@ -109,2 +110,3 @@ }>; | ||
| allowedCaveats: readonly [string, ...string[]] | null; | ||
| validator: import("@metamask/permission-controller").PermissionValidatorConstraint; | ||
| }>; | ||
@@ -130,2 +132,3 @@ }>; | ||
| allowedCaveats: readonly [string, ...string[]] | null; | ||
| validator: import("@metamask/permission-controller").PermissionValidatorConstraint; | ||
| }>; | ||
@@ -132,0 +135,0 @@ }>; |
@@ -83,6 +83,4 @@ "use strict"; | ||
| function getKeyringCaveatOrigins(permission) { | ||
| (0, utils_1.assert)(permission?.caveats); | ||
| (0, utils_1.assert)(permission.caveats.length === 1); | ||
| (0, utils_1.assert)(permission.caveats[0].type === snaps_utils_1.SnapCaveatType.KeyringOrigin); | ||
| const caveat = permission.caveats[0]; | ||
| const caveat = permission?.caveats?.find((permCaveat) => permCaveat.type === snaps_utils_1.SnapCaveatType.KeyringOrigin); | ||
| (0, utils_1.assert)(caveat); | ||
| return caveat.value; | ||
@@ -89,0 +87,0 @@ } |
@@ -37,5 +37,5 @@ import type { CaveatSpecificationConstraint, EndowmentGetterParams, PermissionConstraint, PermissionSpecificationBuilder, PermissionValidatorConstraint } from "@metamask/permission-controller"; | ||
| */ | ||
| export declare function getKeyringCaveatOrigins(permission?: PermissionConstraint): KeyringOrigins | null; | ||
| export declare function getKeyringCaveatOrigins(permission?: PermissionConstraint): KeyringOrigins; | ||
| export declare const keyringCaveatSpecifications: Record<SnapCaveatType.KeyringOrigin, CaveatSpecificationConstraint>; | ||
| export {}; | ||
| //# sourceMappingURL=keyring.d.cts.map |
@@ -37,5 +37,5 @@ import type { CaveatSpecificationConstraint, EndowmentGetterParams, PermissionConstraint, PermissionSpecificationBuilder, PermissionValidatorConstraint } from "@metamask/permission-controller"; | ||
| */ | ||
| export declare function getKeyringCaveatOrigins(permission?: PermissionConstraint): KeyringOrigins | null; | ||
| export declare function getKeyringCaveatOrigins(permission?: PermissionConstraint): KeyringOrigins; | ||
| export declare const keyringCaveatSpecifications: Record<SnapCaveatType.KeyringOrigin, CaveatSpecificationConstraint>; | ||
| export {}; | ||
| //# sourceMappingURL=keyring.d.mts.map |
@@ -79,6 +79,4 @@ import { PermissionType, SubjectType } from "@metamask/permission-controller"; | ||
| export function getKeyringCaveatOrigins(permission) { | ||
| assert(permission?.caveats); | ||
| assert(permission.caveats.length === 1); | ||
| assert(permission.caveats[0].type === SnapCaveatType.KeyringOrigin); | ||
| const caveat = permission.caveats[0]; | ||
| const caveat = permission?.caveats?.find((permCaveat) => permCaveat.type === SnapCaveatType.KeyringOrigin); | ||
| assert(caveat); | ||
| return caveat.value; | ||
@@ -85,0 +83,0 @@ } |
@@ -5,2 +5,4 @@ "use strict"; | ||
| const permission_controller_1 = require("@metamask/permission-controller"); | ||
| const snaps_utils_1 = require("@metamask/snaps-utils"); | ||
| const caveats_1 = require("./caveats/index.cjs"); | ||
| const enum_1 = require("./enum.cjs"); | ||
@@ -20,5 +22,8 @@ const permissionName = enum_1.SnapEndowments.LifecycleHooks; | ||
| targetName: permissionName, | ||
| allowedCaveats: null, | ||
| allowedCaveats: [snaps_utils_1.SnapCaveatType.MaxRequestTime], | ||
| endowmentGetter: (_getterOptions) => null, | ||
| subjectTypes: [permission_controller_1.SubjectType.Snap], | ||
| validator: (0, caveats_1.createGenericPermissionValidator)([ | ||
| { type: snaps_utils_1.SnapCaveatType.MaxRequestTime, optional: true }, | ||
| ]), | ||
| }; | ||
@@ -25,0 +30,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
| import type { PermissionSpecificationBuilder, EndowmentGetterParams } from "@metamask/permission-controller"; | ||
| import type { PermissionSpecificationBuilder, EndowmentGetterParams, PermissionValidatorConstraint } from "@metamask/permission-controller"; | ||
| import { PermissionType } from "@metamask/permission-controller"; | ||
@@ -13,2 +13,3 @@ import type { NonEmptyArray } from "@metamask/utils"; | ||
| allowedCaveats: Readonly<NonEmptyArray<string>> | null; | ||
| validator: PermissionValidatorConstraint; | ||
| }>; | ||
@@ -15,0 +16,0 @@ }>; |
@@ -1,2 +0,2 @@ | ||
| import type { PermissionSpecificationBuilder, EndowmentGetterParams } from "@metamask/permission-controller"; | ||
| import type { PermissionSpecificationBuilder, EndowmentGetterParams, PermissionValidatorConstraint } from "@metamask/permission-controller"; | ||
| import { PermissionType } from "@metamask/permission-controller"; | ||
@@ -13,2 +13,3 @@ import type { NonEmptyArray } from "@metamask/utils"; | ||
| allowedCaveats: Readonly<NonEmptyArray<string>> | null; | ||
| validator: PermissionValidatorConstraint; | ||
| }>; | ||
@@ -15,0 +16,0 @@ }>; |
| import { PermissionType, SubjectType } from "@metamask/permission-controller"; | ||
| import { SnapCaveatType } from "@metamask/snaps-utils"; | ||
| import { createGenericPermissionValidator } from "./caveats/index.mjs"; | ||
| import { SnapEndowments } from "./enum.mjs"; | ||
@@ -16,5 +18,8 @@ const permissionName = SnapEndowments.LifecycleHooks; | ||
| targetName: permissionName, | ||
| allowedCaveats: null, | ||
| allowedCaveats: [SnapCaveatType.MaxRequestTime], | ||
| endowmentGetter: (_getterOptions) => null, | ||
| subjectTypes: [SubjectType.Snap], | ||
| validator: createGenericPermissionValidator([ | ||
| { type: SnapCaveatType.MaxRequestTime, optional: true }, | ||
| ]), | ||
| }; | ||
@@ -21,0 +26,0 @@ }; |
@@ -77,6 +77,4 @@ "use strict"; | ||
| function getRpcCaveatOrigins(permission) { | ||
| const caveats = permission?.caveats?.filter((caveat) => caveat.type === snaps_utils_1.SnapCaveatType.RpcOrigin); | ||
| (0, utils_1.assert)(caveats); | ||
| (0, utils_1.assert)(caveats.length === 1); | ||
| const caveat = caveats[0]; | ||
| const caveat = permission?.caveats?.find((permCaveat) => permCaveat.type === snaps_utils_1.SnapCaveatType.RpcOrigin); | ||
| (0, utils_1.assert)(caveat); | ||
| return caveat.value; | ||
@@ -83,0 +81,0 @@ } |
@@ -36,5 +36,5 @@ import type { CaveatSpecificationConstraint, PermissionConstraint, PermissionSpecificationBuilder, PermissionValidatorConstraint } from "@metamask/permission-controller"; | ||
| */ | ||
| export declare function getRpcCaveatOrigins(permission?: PermissionConstraint): RpcOrigins | null; | ||
| export declare function getRpcCaveatOrigins(permission?: PermissionConstraint): RpcOrigins; | ||
| export declare const rpcCaveatSpecifications: Record<SnapCaveatType.RpcOrigin, CaveatSpecificationConstraint>; | ||
| export {}; | ||
| //# sourceMappingURL=rpc.d.cts.map |
@@ -36,5 +36,5 @@ import type { CaveatSpecificationConstraint, PermissionConstraint, PermissionSpecificationBuilder, PermissionValidatorConstraint } from "@metamask/permission-controller"; | ||
| */ | ||
| export declare function getRpcCaveatOrigins(permission?: PermissionConstraint): RpcOrigins | null; | ||
| export declare function getRpcCaveatOrigins(permission?: PermissionConstraint): RpcOrigins; | ||
| export declare const rpcCaveatSpecifications: Record<SnapCaveatType.RpcOrigin, CaveatSpecificationConstraint>; | ||
| export {}; | ||
| //# sourceMappingURL=rpc.d.mts.map |
@@ -73,6 +73,4 @@ import { PermissionType, SubjectType } from "@metamask/permission-controller"; | ||
| export function getRpcCaveatOrigins(permission) { | ||
| const caveats = permission?.caveats?.filter((caveat) => caveat.type === SnapCaveatType.RpcOrigin); | ||
| assert(caveats); | ||
| assert(caveats.length === 1); | ||
| const caveat = caveats[0]; | ||
| const caveat = permission?.caveats?.find((permCaveat) => permCaveat.type === SnapCaveatType.RpcOrigin); | ||
| assert(caveat); | ||
| return caveat.value; | ||
@@ -79,0 +77,0 @@ } |
@@ -5,2 +5,4 @@ "use strict"; | ||
| const permission_controller_1 = require("@metamask/permission-controller"); | ||
| const snaps_utils_1 = require("@metamask/snaps-utils"); | ||
| const caveats_1 = require("./caveats/index.cjs"); | ||
| const enum_1 = require("./enum.cjs"); | ||
@@ -20,5 +22,8 @@ const permissionName = enum_1.SnapEndowments.SettingsPage; | ||
| targetName: permissionName, | ||
| allowedCaveats: null, | ||
| allowedCaveats: [snaps_utils_1.SnapCaveatType.MaxRequestTime], | ||
| endowmentGetter: (_getterOptions) => null, | ||
| subjectTypes: [permission_controller_1.SubjectType.Snap], | ||
| validator: (0, caveats_1.createGenericPermissionValidator)([ | ||
| { type: snaps_utils_1.SnapCaveatType.MaxRequestTime, optional: true }, | ||
| ]), | ||
| }; | ||
@@ -25,0 +30,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
| import type { PermissionSpecificationBuilder, EndowmentGetterParams } from "@metamask/permission-controller"; | ||
| import type { PermissionSpecificationBuilder, EndowmentGetterParams, PermissionValidatorConstraint } from "@metamask/permission-controller"; | ||
| import { PermissionType } from "@metamask/permission-controller"; | ||
@@ -13,2 +13,3 @@ import type { NonEmptyArray } from "@metamask/utils"; | ||
| allowedCaveats: Readonly<NonEmptyArray<string>> | null; | ||
| validator: PermissionValidatorConstraint; | ||
| }>; | ||
@@ -15,0 +16,0 @@ }>; |
@@ -1,2 +0,2 @@ | ||
| import type { PermissionSpecificationBuilder, EndowmentGetterParams } from "@metamask/permission-controller"; | ||
| import type { PermissionSpecificationBuilder, EndowmentGetterParams, PermissionValidatorConstraint } from "@metamask/permission-controller"; | ||
| import { PermissionType } from "@metamask/permission-controller"; | ||
@@ -13,2 +13,3 @@ import type { NonEmptyArray } from "@metamask/utils"; | ||
| allowedCaveats: Readonly<NonEmptyArray<string>> | null; | ||
| validator: PermissionValidatorConstraint; | ||
| }>; | ||
@@ -15,0 +16,0 @@ }>; |
| import { PermissionType, SubjectType } from "@metamask/permission-controller"; | ||
| import { SnapCaveatType } from "@metamask/snaps-utils"; | ||
| import { createGenericPermissionValidator } from "./caveats/index.mjs"; | ||
| import { SnapEndowments } from "./enum.mjs"; | ||
@@ -16,5 +18,8 @@ const permissionName = SnapEndowments.SettingsPage; | ||
| targetName: permissionName, | ||
| allowedCaveats: null, | ||
| allowedCaveats: [SnapCaveatType.MaxRequestTime], | ||
| endowmentGetter: (_getterOptions) => null, | ||
| subjectTypes: [SubjectType.Snap], | ||
| validator: createGenericPermissionValidator([ | ||
| { type: SnapCaveatType.MaxRequestTime, optional: true }, | ||
| ]), | ||
| }; | ||
@@ -21,0 +26,0 @@ }; |
@@ -22,3 +22,6 @@ "use strict"; | ||
| targetName: permissionName, | ||
| allowedCaveats: [snaps_utils_1.SnapCaveatType.SignatureOrigin], | ||
| allowedCaveats: [ | ||
| snaps_utils_1.SnapCaveatType.SignatureOrigin, | ||
| snaps_utils_1.SnapCaveatType.MaxRequestTime, | ||
| ], | ||
| endowmentGetter: (_getterOptions) => null, | ||
@@ -88,9 +91,4 @@ validator: (0, caveats_1.createGenericPermissionValidator)([ | ||
| function getSignatureOriginCaveat(permission) { | ||
| if (!permission?.caveats) { | ||
| return null; | ||
| } | ||
| (0, utils_1.assert)(permission.caveats.length === 1); | ||
| (0, utils_1.assert)(permission.caveats[0].type === snaps_utils_1.SnapCaveatType.SignatureOrigin); | ||
| const caveat = permission.caveats[0]; | ||
| return caveat.value ?? null; | ||
| const caveat = permission?.caveats?.find((permCaveat) => permCaveat.type === snaps_utils_1.SnapCaveatType.SignatureOrigin); | ||
| return caveat?.value ?? null; | ||
| } | ||
@@ -97,0 +95,0 @@ exports.getSignatureOriginCaveat = getSignatureOriginCaveat; |
@@ -19,3 +19,6 @@ import { PermissionType, SubjectType } from "@metamask/permission-controller"; | ||
| targetName: permissionName, | ||
| allowedCaveats: [SnapCaveatType.SignatureOrigin], | ||
| allowedCaveats: [ | ||
| SnapCaveatType.SignatureOrigin, | ||
| SnapCaveatType.MaxRequestTime, | ||
| ], | ||
| endowmentGetter: (_getterOptions) => null, | ||
@@ -84,9 +87,4 @@ validator: createGenericPermissionValidator([ | ||
| export function getSignatureOriginCaveat(permission) { | ||
| if (!permission?.caveats) { | ||
| return null; | ||
| } | ||
| assert(permission.caveats.length === 1); | ||
| assert(permission.caveats[0].type === SnapCaveatType.SignatureOrigin); | ||
| const caveat = permission.caveats[0]; | ||
| return caveat.value ?? null; | ||
| const caveat = permission?.caveats?.find((permCaveat) => permCaveat.type === SnapCaveatType.SignatureOrigin); | ||
| return caveat?.value ?? null; | ||
| } | ||
@@ -93,0 +91,0 @@ export const signatureInsightCaveatSpecifications = { |
@@ -90,9 +90,4 @@ "use strict"; | ||
| function getTransactionOriginCaveat(permission) { | ||
| if (!permission?.caveats) { | ||
| return null; | ||
| } | ||
| (0, utils_1.assert)(permission.caveats.length === 1); | ||
| (0, utils_1.assert)(permission.caveats[0].type === snaps_utils_1.SnapCaveatType.TransactionOrigin); | ||
| const caveat = permission.caveats[0]; | ||
| return caveat.value ?? null; | ||
| const caveat = permission?.caveats?.find((permCaveat) => permCaveat.type === snaps_utils_1.SnapCaveatType.TransactionOrigin); | ||
| return caveat?.value ?? null; | ||
| } | ||
@@ -99,0 +94,0 @@ exports.getTransactionOriginCaveat = getTransactionOriginCaveat; |
@@ -86,9 +86,4 @@ import { PermissionType, SubjectType } from "@metamask/permission-controller"; | ||
| export function getTransactionOriginCaveat(permission) { | ||
| if (!permission?.caveats) { | ||
| return null; | ||
| } | ||
| assert(permission.caveats.length === 1); | ||
| assert(permission.caveats[0].type === SnapCaveatType.TransactionOrigin); | ||
| const caveat = permission.caveats[0]; | ||
| return caveat.value ?? null; | ||
| const caveat = permission?.caveats?.find((permCaveat) => permCaveat.type === SnapCaveatType.TransactionOrigin); | ||
| return caveat?.value ?? null; | ||
| } | ||
@@ -95,0 +90,0 @@ export const transactionInsightCaveatSpecifications = { |
@@ -17,3 +17,6 @@ "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.createWalletSnapPermissionMiddleware = void 0; | ||
| __exportStar(require("./preinstalled-snaps.cjs"), exports); | ||
| var wallet_snap_permission_1 = require("./wallet-snap-permission.cjs"); | ||
| Object.defineProperty(exports, "createWalletSnapPermissionMiddleware", { enumerable: true, get: function () { return wallet_snap_permission_1.createWalletSnapPermissionMiddleware; } }); | ||
| //# sourceMappingURL=index.cjs.map |
| export * from "./preinstalled-snaps.cjs"; | ||
| export { createWalletSnapPermissionMiddleware } from "./wallet-snap-permission.cjs"; | ||
| //# sourceMappingURL=index.d.cts.map |
| export * from "./preinstalled-snaps.mjs"; | ||
| export { createWalletSnapPermissionMiddleware } from "./wallet-snap-permission.mjs"; | ||
| //# sourceMappingURL=index.d.mts.map |
| export * from "./preinstalled-snaps.mjs"; | ||
| export { createWalletSnapPermissionMiddleware } from "./wallet-snap-permission.mjs"; | ||
| //# sourceMappingURL=index.mjs.map |
+2
-2
| { | ||
| "name": "@metamask/snaps-rpc-methods", | ||
| "version": "14.2.0", | ||
| "version": "14.3.0", | ||
| "description": "MetaMask Snaps JSON-RPC method implementations", | ||
@@ -62,3 +62,3 @@ "keywords": [ | ||
| "@metamask/snaps-sdk": "^10.4.0", | ||
| "@metamask/snaps-utils": "^12.0.0", | ||
| "@metamask/snaps-utils": "^12.1.0", | ||
| "@metamask/superstruct": "^3.2.1", | ||
@@ -65,0 +65,0 @@ "@metamask/utils": "^11.9.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
1867464
0.81%612
1.32%10576
0.57%