@metamask/snaps-rpc-methods 10.0.1 → 11.1.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 +20 -1
- package/dist/__fixtures__/entropy.cjs +31 -0
- package/dist/__fixtures__/entropy.cjs.map +1 -0
- package/dist/{types/__fixtures__/entropy.d.ts → __fixtures__/entropy.d.cts} +1 -0
- package/dist/__fixtures__/entropy.d.cts.map +1 -0
- package/dist/__fixtures__/entropy.d.mts +15 -0
- package/dist/__fixtures__/entropy.d.mts.map +1 -0
- package/dist/__fixtures__/entropy.mjs +28 -0
- package/dist/__fixtures__/entropy.mjs.map +1 -0
- package/dist/__fixtures__/index.cjs +18 -0
- package/dist/__fixtures__/index.cjs.map +1 -0
- package/dist/__fixtures__/index.d.cts +2 -0
- package/dist/__fixtures__/index.d.cts.map +1 -0
- package/dist/__fixtures__/index.d.mts +2 -0
- package/dist/__fixtures__/index.d.mts.map +1 -0
- package/dist/__fixtures__/index.mjs +2 -0
- package/dist/__fixtures__/index.mjs.map +1 -0
- package/dist/endowments/caveats/generic.cjs +50 -0
- package/dist/endowments/caveats/generic.cjs.map +1 -0
- package/dist/{types/endowments/caveats/generic.d.ts → endowments/caveats/generic.d.cts} +5 -4
- package/dist/endowments/caveats/generic.d.cts.map +1 -0
- package/dist/endowments/caveats/generic.d.mts +20 -0
- package/dist/endowments/caveats/generic.d.mts.map +1 -0
- package/dist/endowments/caveats/generic.mjs +45 -6
- package/dist/endowments/caveats/generic.mjs.map +1 -1
- package/dist/endowments/caveats/index.cjs +19 -0
- package/dist/endowments/caveats/index.cjs.map +1 -0
- package/dist/endowments/caveats/index.d.cts +3 -0
- package/dist/endowments/caveats/index.d.cts.map +1 -0
- package/dist/endowments/caveats/index.d.mts +3 -0
- package/dist/endowments/caveats/index.d.mts.map +1 -0
- package/dist/endowments/caveats/index.mjs +2 -17
- package/dist/endowments/caveats/index.mjs.map +1 -1
- package/dist/endowments/caveats/requestTime.cjs +104 -0
- package/dist/{chunk-FCVWU5XH.js.map → endowments/caveats/requestTime.cjs.map} +1 -1
- package/dist/{types/endowments/caveats/requestTime.d.ts → endowments/caveats/requestTime.d.cts} +5 -4
- package/dist/endowments/caveats/requestTime.d.cts.map +1 -0
- package/dist/endowments/caveats/requestTime.d.mts +30 -0
- package/dist/endowments/caveats/requestTime.d.mts.map +1 -0
- package/dist/endowments/caveats/requestTime.mjs +96 -11
- package/dist/endowments/caveats/requestTime.mjs.map +1 -1
- package/dist/endowments/cronjob.cjs +105 -0
- package/dist/endowments/cronjob.cjs.map +1 -0
- package/dist/{types/endowments/cronjob.d.ts → endowments/cronjob.d.cts} +7 -6
- package/dist/endowments/cronjob.d.cts.map +1 -0
- package/dist/endowments/cronjob.d.mts +52 -0
- package/dist/endowments/cronjob.d.mts.map +1 -0
- package/dist/endowments/cronjob.mjs +97 -14
- package/dist/endowments/cronjob.mjs.map +1 -1
- package/dist/endowments/enum.cjs +18 -0
- package/dist/endowments/enum.cjs.map +1 -0
- package/dist/{types/endowments/enum.d.ts → endowments/enum.d.cts} +1 -0
- package/dist/endowments/enum.d.cts.map +1 -0
- package/dist/endowments/enum.d.mts +14 -0
- package/dist/endowments/enum.d.mts.map +1 -0
- package/dist/endowments/enum.mjs +14 -6
- package/dist/endowments/enum.mjs.map +1 -1
- package/dist/endowments/ethereum-provider.cjs +32 -0
- package/dist/endowments/ethereum-provider.cjs.map +1 -0
- package/dist/{types/endowments/ethereum-provider.d.ts → endowments/ethereum-provider.d.cts} +4 -3
- package/dist/endowments/ethereum-provider.d.cts.map +1 -0
- package/dist/endowments/ethereum-provider.d.mts +15 -0
- package/dist/endowments/ethereum-provider.d.mts.map +1 -0
- package/dist/endowments/ethereum-provider.mjs +27 -6
- package/dist/endowments/ethereum-provider.mjs.map +1 -1
- package/dist/endowments/home-page.cjs +28 -0
- package/dist/{chunk-2SFH57UV.js.map → endowments/home-page.cjs.map} +1 -1
- package/dist/{types/endowments/home-page.d.ts → endowments/home-page.d.cts} +5 -4
- package/dist/endowments/home-page.d.cts.map +1 -0
- package/dist/endowments/home-page.d.mts +16 -0
- package/dist/endowments/home-page.d.mts.map +1 -0
- package/dist/endowments/home-page.mjs +23 -6
- package/dist/endowments/home-page.mjs.map +1 -1
- package/dist/endowments/index.cjs +92 -0
- package/dist/endowments/index.cjs.map +1 -0
- package/dist/{types/endowments/index.d.ts → endowments/index.d.cts} +12 -11
- package/dist/endowments/index.d.cts.map +1 -0
- package/dist/endowments/index.d.mts +132 -0
- package/dist/endowments/index.d.mts.map +1 -0
- package/dist/endowments/index.mjs +65 -52
- package/dist/endowments/index.mjs.map +1 -1
- package/dist/endowments/keyring.cjs +96 -0
- package/dist/endowments/keyring.cjs.map +1 -0
- package/dist/{types/endowments/keyring.d.ts → endowments/keyring.d.cts} +7 -6
- package/dist/endowments/keyring.d.cts.map +1 -0
- package/dist/endowments/keyring.d.mts +40 -0
- package/dist/endowments/keyring.d.mts.map +1 -0
- package/dist/endowments/keyring.mjs +89 -15
- package/dist/endowments/keyring.mjs.map +1 -1
- package/dist/endowments/lifecycle-hooks.cjs +28 -0
- package/dist/endowments/lifecycle-hooks.cjs.map +1 -0
- package/dist/{types/endowments/lifecycle-hooks.d.ts → endowments/lifecycle-hooks.d.cts} +5 -4
- package/dist/endowments/lifecycle-hooks.d.cts.map +1 -0
- package/dist/endowments/lifecycle-hooks.d.mts +16 -0
- package/dist/endowments/lifecycle-hooks.d.mts.map +1 -0
- package/dist/endowments/lifecycle-hooks.mjs +23 -6
- package/dist/endowments/lifecycle-hooks.mjs.map +1 -1
- package/dist/endowments/name-lookup.cjs +141 -0
- package/dist/endowments/name-lookup.cjs.map +1 -0
- package/dist/{types/endowments/name-lookup.d.ts → endowments/name-lookup.d.cts} +6 -5
- package/dist/endowments/name-lookup.d.cts.map +1 -0
- package/dist/endowments/name-lookup.d.mts +50 -0
- package/dist/endowments/name-lookup.d.mts.map +1 -0
- package/dist/endowments/name-lookup.mjs +133 -17
- package/dist/endowments/name-lookup.mjs.map +1 -1
- package/dist/endowments/network-access.cjs +30 -0
- package/dist/endowments/network-access.cjs.map +1 -0
- package/dist/{types/endowments/network-access.d.ts → endowments/network-access.d.cts} +4 -3
- package/dist/endowments/network-access.d.cts.map +1 -0
- package/dist/endowments/network-access.d.mts +15 -0
- package/dist/endowments/network-access.d.mts.map +1 -0
- package/dist/endowments/network-access.mjs +25 -6
- package/dist/endowments/network-access.mjs.map +1 -1
- package/dist/endowments/rpc.cjs +90 -0
- package/dist/endowments/rpc.cjs.map +1 -0
- package/dist/{types/endowments/rpc.d.ts → endowments/rpc.d.cts} +8 -7
- package/dist/endowments/rpc.d.cts.map +1 -0
- package/dist/endowments/rpc.d.mts +39 -0
- package/dist/endowments/rpc.d.mts.map +1 -0
- package/dist/endowments/rpc.mjs +83 -15
- package/dist/endowments/rpc.mjs.map +1 -1
- package/dist/endowments/signature-insight.cjs +102 -0
- package/dist/endowments/signature-insight.cjs.map +1 -0
- package/dist/{types/endowments/signature-insight.d.ts → endowments/signature-insight.d.cts} +6 -5
- package/dist/endowments/signature-insight.d.cts.map +1 -0
- package/dist/endowments/signature-insight.d.mts +40 -0
- package/dist/endowments/signature-insight.d.mts.map +1 -0
- package/dist/endowments/signature-insight.mjs +95 -15
- package/dist/endowments/signature-insight.mjs.map +1 -1
- package/dist/endowments/transaction-insight.cjs +105 -0
- package/dist/endowments/transaction-insight.cjs.map +1 -0
- package/dist/{types/endowments/transaction-insight.d.ts → endowments/transaction-insight.d.cts} +6 -5
- package/dist/endowments/transaction-insight.d.cts.map +1 -0
- package/dist/endowments/transaction-insight.d.mts +40 -0
- package/dist/endowments/transaction-insight.d.mts.map +1 -0
- package/dist/endowments/transaction-insight.mjs +98 -15
- package/dist/endowments/transaction-insight.mjs.map +1 -1
- package/dist/endowments/web-assembly.cjs +31 -0
- package/dist/endowments/web-assembly.cjs.map +1 -0
- package/dist/{types/endowments/web-assembly.d.ts → endowments/web-assembly.d.cts} +4 -3
- package/dist/endowments/web-assembly.d.cts.map +1 -0
- package/dist/endowments/web-assembly.d.mts +15 -0
- package/dist/endowments/web-assembly.d.mts.map +1 -0
- package/dist/endowments/web-assembly.mjs +26 -6
- package/dist/endowments/web-assembly.mjs.map +1 -1
- package/dist/index.cjs +28 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +8 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +6 -121
- package/dist/index.mjs.map +1 -1
- package/dist/permissions.cjs +55 -0
- package/dist/permissions.cjs.map +1 -0
- package/dist/{types/permissions.d.ts → permissions.d.cts} +3 -2
- package/dist/permissions.d.cts.map +1 -0
- package/dist/permissions.d.mts +17 -0
- package/dist/permissions.d.mts.map +1 -0
- package/dist/permissions.mjs +48 -42
- package/dist/permissions.mjs.map +1 -1
- package/dist/permitted/createInterface.cjs +64 -0
- package/dist/permitted/createInterface.cjs.map +1 -0
- package/dist/{types/permitted/createInterface.d.ts → permitted/createInterface.d.cts} +62 -47
- package/dist/permitted/createInterface.d.cts.map +1 -0
- package/dist/permitted/createInterface.d.mts +181 -0
- package/dist/permitted/createInterface.d.mts.map +1 -0
- package/dist/permitted/createInterface.mjs +59 -5
- package/dist/permitted/createInterface.mjs.map +1 -1
- package/dist/permitted/getAllSnaps.cjs +39 -0
- package/dist/permitted/getAllSnaps.cjs.map +1 -0
- package/dist/{types/permitted/getAllSnaps.d.ts → permitted/getAllSnaps.d.cts} +5 -4
- package/dist/permitted/getAllSnaps.d.cts.map +1 -0
- package/dist/permitted/getAllSnaps.d.mts +15 -0
- package/dist/permitted/getAllSnaps.d.mts.map +1 -0
- package/dist/permitted/getAllSnaps.mjs +34 -5
- package/dist/permitted/getAllSnaps.mjs.map +1 -1
- package/dist/permitted/getClientStatus.cjs +32 -0
- package/dist/permitted/getClientStatus.cjs.map +1 -0
- package/dist/{types/permitted/getClientStatus.d.ts → permitted/getClientStatus.d.cts} +5 -4
- package/dist/permitted/getClientStatus.d.cts.map +1 -0
- package/dist/permitted/getClientStatus.d.mts +14 -0
- package/dist/permitted/getClientStatus.d.mts.map +1 -0
- package/dist/permitted/getClientStatus.mjs +27 -5
- package/dist/permitted/getClientStatus.mjs.map +1 -1
- package/dist/permitted/getFile.cjs +47 -0
- package/dist/permitted/getFile.cjs.map +1 -0
- package/dist/{types/permitted/getFile.d.ts → permitted/getFile.d.cts} +6 -5
- package/dist/permitted/getFile.d.cts.map +1 -0
- package/dist/permitted/getFile.d.mts +16 -0
- package/dist/permitted/getFile.d.mts.map +1 -0
- package/dist/permitted/getFile.mjs +42 -7
- package/dist/permitted/getFile.mjs.map +1 -1
- package/dist/permitted/getInterfaceState.cjs +62 -0
- package/dist/permitted/getInterfaceState.cjs.map +1 -0
- package/dist/{types/permitted/getInterfaceState.d.ts → permitted/getInterfaceState.d.cts} +6 -5
- package/dist/permitted/getInterfaceState.d.cts.map +1 -0
- package/dist/permitted/getInterfaceState.d.mts +19 -0
- package/dist/permitted/getInterfaceState.d.mts.map +1 -0
- package/dist/permitted/getInterfaceState.mjs +57 -5
- package/dist/permitted/getInterfaceState.mjs.map +1 -1
- package/dist/permitted/getSnaps.cjs +33 -0
- package/dist/permitted/getSnaps.cjs.map +1 -0
- package/dist/{types/permitted/getSnaps.d.ts → permitted/getSnaps.d.cts} +5 -4
- package/dist/permitted/getSnaps.d.cts.map +1 -0
- package/dist/permitted/getSnaps.d.mts +14 -0
- package/dist/permitted/getSnaps.d.mts.map +1 -0
- package/dist/permitted/getSnaps.mjs +28 -5
- package/dist/permitted/getSnaps.mjs.map +1 -1
- package/dist/permitted/handlers.cjs +31 -0
- package/dist/permitted/handlers.cjs.map +1 -0
- package/dist/{types/permitted/handlers.d.ts → permitted/handlers.d.cts} +1 -0
- package/dist/permitted/handlers.d.cts.map +1 -0
- package/dist/permitted/handlers.d.mts +35 -0
- package/dist/permitted/handlers.d.mts.map +1 -0
- package/dist/permitted/handlers.mjs +26 -19
- package/dist/permitted/handlers.mjs.map +1 -1
- package/dist/permitted/index.cjs +19 -0
- package/dist/permitted/index.cjs.map +1 -0
- package/dist/permitted/index.d.cts +12 -0
- package/dist/permitted/index.d.cts.map +1 -0
- package/dist/permitted/index.d.mts +12 -0
- package/dist/permitted/index.d.mts.map +1 -0
- package/dist/permitted/index.mjs +2 -26
- package/dist/permitted/index.mjs.map +1 -1
- package/dist/permitted/invokeKeyring.cjs +83 -0
- package/dist/permitted/invokeKeyring.cjs.map +1 -0
- package/dist/{types/permitted/invokeKeyring.d.ts → permitted/invokeKeyring.d.cts} +5 -4
- package/dist/permitted/invokeKeyring.d.cts.map +1 -0
- package/dist/permitted/invokeKeyring.d.mts +16 -0
- package/dist/permitted/invokeKeyring.d.mts.map +1 -0
- package/dist/permitted/invokeKeyring.mjs +78 -6
- package/dist/permitted/invokeKeyring.mjs.map +1 -1
- package/dist/permitted/invokeSnapSugar.cjs +68 -0
- package/dist/permitted/invokeSnapSugar.cjs.map +1 -0
- package/dist/{types/permitted/invokeSnapSugar.d.ts → permitted/invokeSnapSugar.d.cts} +6 -5
- package/dist/permitted/invokeSnapSugar.d.cts.map +1 -0
- package/dist/permitted/invokeSnapSugar.d.mts +35 -0
- package/dist/permitted/invokeSnapSugar.d.mts.map +1 -0
- package/dist/permitted/invokeSnapSugar.mjs +61 -9
- package/dist/permitted/invokeSnapSugar.mjs.map +1 -1
- package/dist/permitted/middleware.cjs +40 -0
- package/dist/permitted/middleware.cjs.map +1 -0
- package/dist/{types/permitted/middleware.d.ts → permitted/middleware.d.cts} +3 -2
- package/dist/permitted/middleware.d.cts.map +1 -0
- package/dist/permitted/middleware.d.mts +11 -0
- package/dist/permitted/middleware.d.mts.map +1 -0
- package/dist/permitted/middleware.mjs +35 -20
- package/dist/permitted/middleware.mjs.map +1 -1
- package/dist/permitted/requestSnaps.cjs +121 -0
- package/dist/permitted/requestSnaps.cjs.map +1 -0
- package/dist/{types/permitted/requestSnaps.d.ts → permitted/requestSnaps.d.cts} +5 -4
- package/dist/permitted/requestSnaps.d.cts.map +1 -0
- package/dist/permitted/requestSnaps.d.mts +51 -0
- package/dist/permitted/requestSnaps.d.mts.map +1 -0
- package/dist/permitted/requestSnaps.mjs +114 -10
- package/dist/permitted/requestSnaps.mjs.map +1 -1
- package/dist/permitted/resolveInterface.cjs +65 -0
- package/dist/permitted/resolveInterface.cjs.map +1 -0
- package/dist/{types/permitted/resolveInterface.d.ts → permitted/resolveInterface.d.cts} +8 -7
- package/dist/permitted/resolveInterface.d.cts.map +1 -0
- package/dist/permitted/resolveInterface.d.mts +22 -0
- package/dist/permitted/resolveInterface.d.mts.map +1 -0
- package/dist/permitted/resolveInterface.mjs +60 -5
- package/dist/permitted/resolveInterface.mjs.map +1 -1
- package/dist/permitted/updateInterface.cjs +65 -0
- package/dist/permitted/updateInterface.cjs.map +1 -0
- package/dist/{types/permitted/updateInterface.d.ts → permitted/updateInterface.d.cts} +62 -47
- package/dist/permitted/updateInterface.d.cts.map +1 -0
- package/dist/permitted/updateInterface.d.mts +181 -0
- package/dist/permitted/updateInterface.d.mts.map +1 -0
- package/dist/permitted/updateInterface.mjs +60 -5
- package/dist/permitted/updateInterface.mjs.map +1 -1
- package/dist/restricted/caveats/index.cjs +22 -0
- package/dist/restricted/caveats/index.cjs.map +1 -0
- package/dist/{types/restricted/caveats/index.d.ts → restricted/caveats/index.d.cts} +3 -2
- package/dist/restricted/caveats/index.d.cts.map +1 -0
- package/dist/restricted/caveats/index.d.mts +9 -0
- package/dist/restricted/caveats/index.d.mts.map +1 -0
- package/dist/restricted/caveats/index.mjs +17 -15
- package/dist/restricted/caveats/index.mjs.map +1 -1
- package/dist/restricted/caveats/permittedCoinTypes.cjs +90 -0
- package/dist/restricted/caveats/permittedCoinTypes.cjs.map +1 -0
- package/dist/{types/restricted/caveats/permittedCoinTypes.d.ts → restricted/caveats/permittedCoinTypes.d.cts} +5 -4
- package/dist/restricted/caveats/permittedCoinTypes.d.cts.map +1 -0
- package/dist/restricted/caveats/permittedCoinTypes.d.mts +30 -0
- package/dist/restricted/caveats/permittedCoinTypes.d.mts.map +1 -0
- package/dist/restricted/caveats/permittedCoinTypes.mjs +82 -11
- package/dist/restricted/caveats/permittedCoinTypes.mjs.map +1 -1
- package/dist/restricted/caveats/permittedDerivationPaths.cjs +70 -0
- package/dist/restricted/caveats/permittedDerivationPaths.cjs.map +1 -0
- package/dist/{types/restricted/caveats/permittedDerivationPaths.d.ts → restricted/caveats/permittedDerivationPaths.d.cts} +5 -4
- package/dist/restricted/caveats/permittedDerivationPaths.d.cts.map +1 -0
- package/dist/restricted/caveats/permittedDerivationPaths.d.mts +33 -0
- package/dist/restricted/caveats/permittedDerivationPaths.d.mts.map +1 -0
- package/dist/restricted/caveats/permittedDerivationPaths.mjs +62 -11
- package/dist/restricted/caveats/permittedDerivationPaths.mjs.map +1 -1
- package/dist/restricted/caveats/snapIds.cjs +56 -0
- package/dist/restricted/caveats/snapIds.cjs.map +1 -0
- package/dist/{types/restricted/caveats/snapIds.d.ts → restricted/caveats/snapIds.d.cts} +5 -4
- package/dist/restricted/caveats/snapIds.d.cts.map +1 -0
- package/dist/restricted/caveats/snapIds.d.mts +22 -0
- package/dist/restricted/caveats/snapIds.d.mts.map +1 -0
- package/dist/restricted/caveats/snapIds.mjs +49 -9
- package/dist/restricted/caveats/snapIds.mjs.map +1 -1
- package/dist/restricted/dialog.cjs +222 -0
- package/dist/restricted/dialog.cjs.map +1 -0
- package/dist/restricted/dialog.d.cts +432 -0
- package/dist/restricted/dialog.d.cts.map +1 -0
- package/dist/restricted/dialog.d.mts +432 -0
- package/dist/restricted/dialog.d.mts.map +1 -0
- package/dist/restricted/dialog.mjs +216 -9
- package/dist/restricted/dialog.mjs.map +1 -1
- package/dist/restricted/getBip32Entropy.cjs +69 -0
- package/dist/restricted/getBip32Entropy.cjs.map +1 -0
- package/dist/{types/restricted/getBip32Entropy.d.ts → restricted/getBip32Entropy.d.cts} +8 -7
- package/dist/restricted/getBip32Entropy.d.cts.map +1 -0
- package/dist/restricted/getBip32Entropy.d.mts +45 -0
- package/dist/restricted/getBip32Entropy.d.mts.map +1 -0
- package/dist/restricted/getBip32Entropy.mjs +63 -8
- package/dist/restricted/getBip32Entropy.mjs.map +1 -1
- package/dist/restricted/getBip32PublicKey.cjs +78 -0
- package/dist/restricted/getBip32PublicKey.cjs.map +1 -0
- package/dist/{types/restricted/getBip32PublicKey.d.ts → restricted/getBip32PublicKey.d.cts} +9 -8
- package/dist/restricted/getBip32PublicKey.d.cts.map +1 -0
- package/dist/restricted/getBip32PublicKey.d.mts +54 -0
- package/dist/restricted/getBip32PublicKey.d.mts.map +1 -0
- package/dist/restricted/getBip32PublicKey.mjs +72 -10
- package/dist/restricted/getBip32PublicKey.mjs.map +1 -1
- package/dist/restricted/getBip44Entropy.cjs +71 -0
- package/dist/restricted/getBip44Entropy.cjs.map +1 -0
- package/dist/{types/restricted/getBip44Entropy.d.ts → restricted/getBip44Entropy.d.cts} +8 -7
- package/dist/restricted/getBip44Entropy.d.cts.map +1 -0
- package/dist/restricted/getBip44Entropy.d.mts +47 -0
- package/dist/restricted/getBip44Entropy.d.mts.map +1 -0
- package/dist/restricted/getBip44Entropy.mjs +65 -7
- package/dist/restricted/getBip44Entropy.mjs.map +1 -1
- package/dist/restricted/getEntropy.cjs +59 -0
- package/dist/restricted/getEntropy.cjs.map +1 -0
- package/dist/{types/restricted/getEntropy.d.ts → restricted/getEntropy.d.cts} +10 -9
- package/dist/restricted/getEntropy.d.cts.map +1 -0
- package/dist/restricted/getEntropy.d.mts +62 -0
- package/dist/restricted/getEntropy.d.mts.map +1 -0
- package/dist/restricted/getEntropy.mjs +54 -8
- package/dist/restricted/getEntropy.mjs.map +1 -1
- package/dist/restricted/getLocale.cjs +47 -0
- package/dist/restricted/getLocale.cjs.map +1 -0
- package/dist/{types/restricted/getLocale.d.ts → restricted/getLocale.d.cts} +13 -11
- package/dist/restricted/getLocale.d.cts.map +1 -0
- package/dist/restricted/getLocale.d.mts +50 -0
- package/dist/restricted/getLocale.d.mts.map +1 -0
- package/dist/restricted/getLocale.mjs +40 -9
- package/dist/restricted/getLocale.mjs.map +1 -1
- package/dist/restricted/getPreferences.cjs +46 -0
- package/dist/restricted/getPreferences.cjs.map +1 -0
- package/dist/restricted/getPreferences.d.cts +49 -0
- package/dist/restricted/getPreferences.d.cts.map +1 -0
- package/dist/restricted/getPreferences.d.mts +49 -0
- package/dist/restricted/getPreferences.d.mts.map +1 -0
- package/dist/restricted/getPreferences.mjs +41 -0
- package/dist/restricted/getPreferences.mjs.map +1 -0
- package/dist/restricted/index.cjs +49 -0
- package/dist/restricted/index.cjs.map +1 -0
- package/dist/{types/restricted/index.d.ts → restricted/index.d.cts} +31 -16
- package/dist/restricted/index.d.cts.map +1 -0
- package/dist/restricted/index.d.mts +169 -0
- package/dist/restricted/index.d.mts.map +1 -0
- package/dist/restricted/index.mjs +27 -34
- package/dist/restricted/index.mjs.map +1 -1
- package/dist/restricted/invokeSnap.cjs +96 -0
- package/dist/restricted/invokeSnap.cjs.map +1 -0
- package/dist/{types/restricted/invokeSnap.d.ts → restricted/invokeSnap.d.cts} +14 -12
- package/dist/restricted/invokeSnap.d.cts.map +1 -0
- package/dist/restricted/invokeSnap.d.mts +65 -0
- package/dist/restricted/invokeSnap.d.mts.map +1 -0
- package/dist/restricted/invokeSnap.mjs +89 -11
- package/dist/restricted/invokeSnap.mjs.map +1 -1
- package/dist/restricted/manageAccounts.cjs +61 -0
- package/dist/restricted/manageAccounts.cjs.map +1 -0
- package/dist/{types/restricted/manageAccounts.d.ts → restricted/manageAccounts.d.cts} +10 -9
- package/dist/restricted/manageAccounts.d.cts.map +1 -0
- package/dist/restricted/manageAccounts.d.mts +65 -0
- package/dist/restricted/manageAccounts.d.mts.map +1 -0
- package/dist/restricted/manageAccounts.mjs +54 -11
- package/dist/restricted/manageAccounts.mjs.map +1 -1
- package/dist/restricted/manageState.cjs +175 -0
- package/dist/restricted/manageState.cjs.map +1 -0
- package/dist/{types/restricted/manageState.d.ts → restricted/manageState.d.cts} +10 -9
- package/dist/restricted/manageState.d.cts.map +1 -0
- package/dist/restricted/manageState.d.mts +111 -0
- package/dist/restricted/manageState.d.mts.map +1 -0
- package/dist/restricted/manageState.mjs +166 -18
- package/dist/restricted/manageState.mjs.map +1 -1
- package/dist/restricted/notify.cjs +108 -0
- package/dist/restricted/notify.cjs.map +1 -0
- package/dist/{types/restricted/notify.d.ts → restricted/notify.d.cts} +11 -10
- package/dist/restricted/notify.d.cts.map +1 -0
- package/dist/restricted/notify.d.mts +83 -0
- package/dist/restricted/notify.d.mts.map +1 -0
- package/dist/restricted/notify.mjs +100 -11
- package/dist/restricted/notify.mjs.map +1 -1
- package/dist/utils.cjs +140 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/{types/utils.d.ts → utils.d.cts} +9 -7
- package/dist/utils.d.cts.map +1 -0
- package/dist/utils.d.mts +98 -0
- package/dist/utils.d.mts.map +1 -0
- package/dist/utils.mjs +132 -12
- package/dist/utils.mjs.map +1 -1
- package/package.json +20 -19
- package/dist/chunk-23XDKQW2.mjs +0 -73
- package/dist/chunk-23XDKQW2.mjs.map +0 -1
- package/dist/chunk-2CTOCP34.mjs +0 -45
- package/dist/chunk-2CTOCP34.mjs.map +0 -1
- package/dist/chunk-2L2ATCIK.mjs +0 -78
- package/dist/chunk-2L2ATCIK.mjs.map +0 -1
- package/dist/chunk-2RDYC42U.mjs +0 -67
- package/dist/chunk-2RDYC42U.mjs.map +0 -1
- package/dist/chunk-2SFH57UV.js +0 -21
- package/dist/chunk-33LLA2MH.mjs +0 -75
- package/dist/chunk-33LLA2MH.mjs.map +0 -1
- package/dist/chunk-33MTKZ4H.js +0 -90
- package/dist/chunk-33MTKZ4H.js.map +0 -1
- package/dist/chunk-3UAWEHMF.js +0 -18
- package/dist/chunk-3UAWEHMF.js.map +0 -1
- package/dist/chunk-3WCLDJAS.mjs +0 -74
- package/dist/chunk-3WCLDJAS.mjs.map +0 -1
- package/dist/chunk-3WKIKYUH.js +0 -78
- package/dist/chunk-3WKIKYUH.js.map +0 -1
- package/dist/chunk-4D2B2UQ6.mjs +0 -23
- package/dist/chunk-4D2B2UQ6.mjs.map +0 -1
- package/dist/chunk-4LSOS7SM.js +0 -23
- package/dist/chunk-4LSOS7SM.js.map +0 -1
- package/dist/chunk-4PWFZPJC.js +0 -79
- package/dist/chunk-4PWFZPJC.js.map +0 -1
- package/dist/chunk-4TUORIA6.js +0 -59
- package/dist/chunk-4TUORIA6.js.map +0 -1
- package/dist/chunk-57BL7O2P.mjs +0 -69
- package/dist/chunk-57BL7O2P.mjs.map +0 -1
- package/dist/chunk-62URQ5VS.mjs +0 -18
- package/dist/chunk-62URQ5VS.mjs.map +0 -1
- package/dist/chunk-6VJVURH5.js +0 -43
- package/dist/chunk-6VJVURH5.js.map +0 -1
- package/dist/chunk-756OQVOC.js +0 -67
- package/dist/chunk-756OQVOC.js.map +0 -1
- package/dist/chunk-7CV677MM.js +0 -42
- package/dist/chunk-7CV677MM.js.map +0 -1
- package/dist/chunk-7HVABE5R.js +0 -74
- package/dist/chunk-7HVABE5R.js.map +0 -1
- package/dist/chunk-7P6TF6CE.mjs +0 -55
- package/dist/chunk-7P6TF6CE.mjs.map +0 -1
- package/dist/chunk-7TVJV425.js +0 -1
- package/dist/chunk-7TVJV425.js.map +0 -1
- package/dist/chunk-A6H6I4VH.js +0 -61
- package/dist/chunk-A6H6I4VH.js.map +0 -1
- package/dist/chunk-ATBKAX2S.js +0 -39
- package/dist/chunk-ATBKAX2S.js.map +0 -1
- package/dist/chunk-B3NIHNXW.js +0 -23
- package/dist/chunk-B3NIHNXW.js.map +0 -1
- package/dist/chunk-BSAXPL2T.mjs +0 -59
- package/dist/chunk-BSAXPL2T.mjs.map +0 -1
- package/dist/chunk-CD4OUHO5.mjs +0 -20
- package/dist/chunk-CD4OUHO5.mjs.map +0 -1
- package/dist/chunk-CH5O2YCX.mjs +0 -18
- package/dist/chunk-CH5O2YCX.mjs.map +0 -1
- package/dist/chunk-DLVPMPRZ.js +0 -45
- package/dist/chunk-DLVPMPRZ.js.map +0 -1
- package/dist/chunk-DTZF746A.mjs +0 -21
- package/dist/chunk-DTZF746A.mjs.map +0 -1
- package/dist/chunk-E27BGHCR.js +0 -78
- package/dist/chunk-E27BGHCR.js.map +0 -1
- package/dist/chunk-ELCOEVKA.js +0 -196
- package/dist/chunk-ELCOEVKA.js.map +0 -1
- package/dist/chunk-EOXTZF5U.js +0 -47
- package/dist/chunk-EOXTZF5U.js.map +0 -1
- package/dist/chunk-FCVWU5XH.js +0 -73
- package/dist/chunk-FFHVA6PP.js +0 -82
- package/dist/chunk-FFHVA6PP.js.map +0 -1
- package/dist/chunk-FJ7COFRJ.mjs +0 -54
- package/dist/chunk-FJ7COFRJ.mjs.map +0 -1
- package/dist/chunk-FNUO7MQ4.mjs +0 -43
- package/dist/chunk-FNUO7MQ4.mjs.map +0 -1
- package/dist/chunk-GE5XFDUE.js +0 -21
- package/dist/chunk-GE5XFDUE.js.map +0 -1
- package/dist/chunk-GPV4ETUH.mjs +0 -47
- package/dist/chunk-GPV4ETUH.mjs.map +0 -1
- package/dist/chunk-H6X3CWWQ.js +0 -54
- package/dist/chunk-H6X3CWWQ.js.map +0 -1
- package/dist/chunk-HOECEYMT.mjs +0 -70
- package/dist/chunk-HOECEYMT.mjs.map +0 -1
- package/dist/chunk-HZQ34FQT.js +0 -49
- package/dist/chunk-HZQ34FQT.js.map +0 -1
- package/dist/chunk-I2P65KBQ.mjs +0 -67
- package/dist/chunk-I2P65KBQ.mjs.map +0 -1
- package/dist/chunk-I3G6S6MJ.js +0 -68
- package/dist/chunk-I3G6S6MJ.js.map +0 -1
- package/dist/chunk-IE6EHYEG.js +0 -57
- package/dist/chunk-IE6EHYEG.js.map +0 -1
- package/dist/chunk-IZYMBIBD.mjs +0 -32
- package/dist/chunk-IZYMBIBD.mjs.map +0 -1
- package/dist/chunk-JWDQUKKU.mjs +0 -80
- package/dist/chunk-JWDQUKKU.mjs.map +0 -1
- package/dist/chunk-KRSIAVUJ.js +0 -115
- package/dist/chunk-KRSIAVUJ.js.map +0 -1
- package/dist/chunk-KSTF5JYB.mjs +0 -23
- package/dist/chunk-KSTF5JYB.mjs.map +0 -1
- package/dist/chunk-LR7UR4YU.mjs +0 -52
- package/dist/chunk-LR7UR4YU.mjs.map +0 -1
- package/dist/chunk-LXJBBRQ4.mjs +0 -57
- package/dist/chunk-LXJBBRQ4.mjs.map +0 -1
- package/dist/chunk-M2JQCKR7.js +0 -143
- package/dist/chunk-M2JQCKR7.js.map +0 -1
- package/dist/chunk-MC2Z4NF6.mjs +0 -45
- package/dist/chunk-MC2Z4NF6.mjs.map +0 -1
- package/dist/chunk-MXPVC2XP.mjs +0 -105
- package/dist/chunk-MXPVC2XP.mjs.map +0 -1
- package/dist/chunk-NU4NAAFG.js +0 -1
- package/dist/chunk-NU4NAAFG.js.map +0 -1
- package/dist/chunk-NWT2EXFD.js +0 -18
- package/dist/chunk-NWT2EXFD.js.map +0 -1
- package/dist/chunk-O66NZFSD.mjs +0 -23
- package/dist/chunk-O66NZFSD.mjs.map +0 -1
- package/dist/chunk-ODN35VOK.mjs +0 -119
- package/dist/chunk-ODN35VOK.mjs.map +0 -1
- package/dist/chunk-OI33OL7K.js +0 -47
- package/dist/chunk-OI33OL7K.js.map +0 -1
- package/dist/chunk-PIAWDTWO.mjs +0 -68
- package/dist/chunk-PIAWDTWO.mjs.map +0 -1
- package/dist/chunk-PIRQCNBJ.mjs +0 -78
- package/dist/chunk-PIRQCNBJ.mjs.map +0 -1
- package/dist/chunk-PS6OEQXL.js +0 -105
- package/dist/chunk-PS6OEQXL.js.map +0 -1
- package/dist/chunk-PXU6PORA.js +0 -119
- package/dist/chunk-PXU6PORA.js.map +0 -1
- package/dist/chunk-Q27K2I6Z.js +0 -23
- package/dist/chunk-Q27K2I6Z.js.map +0 -1
- package/dist/chunk-QDZAWH6F.js +0 -80
- package/dist/chunk-QDZAWH6F.js.map +0 -1
- package/dist/chunk-QMULJEYN.js +0 -35
- package/dist/chunk-QMULJEYN.js.map +0 -1
- package/dist/chunk-SYB5TG5O.mjs +0 -49
- package/dist/chunk-SYB5TG5O.mjs.map +0 -1
- package/dist/chunk-SYUGPLEP.js +0 -32
- package/dist/chunk-SYUGPLEP.js.map +0 -1
- package/dist/chunk-T56DKVFS.js +0 -70
- package/dist/chunk-T56DKVFS.js.map +0 -1
- package/dist/chunk-TAXLFFV4.mjs +0 -115
- package/dist/chunk-TAXLFFV4.mjs.map +0 -1
- package/dist/chunk-TE4W25CA.mjs +0 -143
- package/dist/chunk-TE4W25CA.mjs.map +0 -1
- package/dist/chunk-TG63GBK3.mjs +0 -1
- package/dist/chunk-TG63GBK3.mjs.map +0 -1
- package/dist/chunk-TNENASGX.mjs +0 -1
- package/dist/chunk-TNENASGX.mjs.map +0 -1
- package/dist/chunk-TQCUJQHY.mjs +0 -196
- package/dist/chunk-TQCUJQHY.mjs.map +0 -1
- package/dist/chunk-TT4DP2YW.mjs +0 -35
- package/dist/chunk-TT4DP2YW.mjs.map +0 -1
- package/dist/chunk-TVC3E5LI.mjs +0 -42
- package/dist/chunk-TVC3E5LI.mjs.map +0 -1
- package/dist/chunk-U6TJQLNV.js +0 -45
- package/dist/chunk-U6TJQLNV.js.map +0 -1
- package/dist/chunk-UB3733UY.mjs +0 -23
- package/dist/chunk-UB3733UY.mjs.map +0 -1
- package/dist/chunk-UCWANXBZ.js +0 -45
- package/dist/chunk-UCWANXBZ.js.map +0 -1
- package/dist/chunk-UF3UJTY3.js +0 -55
- package/dist/chunk-UF3UJTY3.js.map +0 -1
- package/dist/chunk-UY4DUF53.mjs +0 -45
- package/dist/chunk-UY4DUF53.mjs.map +0 -1
- package/dist/chunk-VUA6ICJO.js +0 -52
- package/dist/chunk-VUA6ICJO.js.map +0 -1
- package/dist/chunk-VVBTXSID.mjs +0 -82
- package/dist/chunk-VVBTXSID.mjs.map +0 -1
- package/dist/chunk-VYII7C3J.mjs +0 -79
- package/dist/chunk-VYII7C3J.mjs.map +0 -1
- package/dist/chunk-W33UWNA2.mjs +0 -90
- package/dist/chunk-W33UWNA2.mjs.map +0 -1
- package/dist/chunk-XGMYBPQR.mjs +0 -47
- package/dist/chunk-XGMYBPQR.mjs.map +0 -1
- package/dist/chunk-YGKFOOWI.js +0 -20
- package/dist/chunk-YGKFOOWI.js.map +0 -1
- package/dist/chunk-YOHE52XB.js +0 -23
- package/dist/chunk-YOHE52XB.js.map +0 -1
- package/dist/chunk-YT2Q3W5C.js +0 -69
- package/dist/chunk-YT2Q3W5C.js.map +0 -1
- package/dist/chunk-YZMFLB67.js +0 -75
- package/dist/chunk-YZMFLB67.js.map +0 -1
- package/dist/chunk-Z6YFGWHN.mjs +0 -61
- package/dist/chunk-Z6YFGWHN.mjs.map +0 -1
- package/dist/chunk-ZH3FC55E.mjs +0 -21
- package/dist/chunk-ZH3FC55E.mjs.map +0 -1
- package/dist/chunk-ZKISN6YP.js +0 -67
- package/dist/chunk-ZKISN6YP.js.map +0 -1
- package/dist/chunk-ZXDCQWMJ.mjs +0 -39
- package/dist/chunk-ZXDCQWMJ.mjs.map +0 -1
- package/dist/endowments/caveats/generic.js +0 -7
- package/dist/endowments/caveats/generic.js.map +0 -1
- package/dist/endowments/caveats/index.js +0 -18
- package/dist/endowments/caveats/index.js.map +0 -1
- package/dist/endowments/caveats/requestTime.js +0 -13
- package/dist/endowments/caveats/requestTime.js.map +0 -1
- package/dist/endowments/cronjob.js +0 -16
- package/dist/endowments/cronjob.js.map +0 -1
- package/dist/endowments/enum.js +0 -7
- package/dist/endowments/enum.js.map +0 -1
- package/dist/endowments/ethereum-provider.js +0 -8
- package/dist/endowments/ethereum-provider.js.map +0 -1
- package/dist/endowments/home-page.js +0 -8
- package/dist/endowments/home-page.js.map +0 -1
- package/dist/endowments/index.js +0 -54
- package/dist/endowments/index.js.map +0 -1
- package/dist/endowments/keyring.js +0 -17
- package/dist/endowments/keyring.js.map +0 -1
- package/dist/endowments/lifecycle-hooks.js +0 -8
- package/dist/endowments/lifecycle-hooks.js.map +0 -1
- package/dist/endowments/name-lookup.js +0 -19
- package/dist/endowments/name-lookup.js.map +0 -1
- package/dist/endowments/network-access.js +0 -8
- package/dist/endowments/network-access.js.map +0 -1
- package/dist/endowments/rpc.js +0 -17
- package/dist/endowments/rpc.js.map +0 -1
- package/dist/endowments/signature-insight.js +0 -17
- package/dist/endowments/signature-insight.js.map +0 -1
- package/dist/endowments/transaction-insight.js +0 -17
- package/dist/endowments/transaction-insight.js.map +0 -1
- package/dist/endowments/web-assembly.js +0 -8
- package/dist/endowments/web-assembly.js.map +0 -1
- package/dist/index.js +0 -122
- package/dist/index.js.map +0 -1
- package/dist/permissions.js +0 -43
- package/dist/permissions.js.map +0 -1
- package/dist/permitted/createInterface.js +0 -7
- package/dist/permitted/createInterface.js.map +0 -1
- package/dist/permitted/getAllSnaps.js +0 -7
- package/dist/permitted/getAllSnaps.js.map +0 -1
- package/dist/permitted/getClientStatus.js +0 -7
- package/dist/permitted/getClientStatus.js.map +0 -1
- package/dist/permitted/getFile.js +0 -9
- package/dist/permitted/getFile.js.map +0 -1
- package/dist/permitted/getInterfaceState.js +0 -7
- package/dist/permitted/getInterfaceState.js.map +0 -1
- package/dist/permitted/getSnaps.js +0 -7
- package/dist/permitted/getSnaps.js.map +0 -1
- package/dist/permitted/handlers.js +0 -21
- package/dist/permitted/handlers.js.map +0 -1
- package/dist/permitted/index.js +0 -27
- package/dist/permitted/index.js.map +0 -1
- package/dist/permitted/invokeKeyring.js +0 -8
- package/dist/permitted/invokeKeyring.js.map +0 -1
- package/dist/permitted/invokeSnapSugar.js +0 -11
- package/dist/permitted/invokeSnapSugar.js.map +0 -1
- package/dist/permitted/middleware.js +0 -21
- package/dist/permitted/middleware.js.map +0 -1
- package/dist/permitted/requestSnaps.js +0 -12
- package/dist/permitted/requestSnaps.js.map +0 -1
- package/dist/permitted/resolveInterface.js +0 -7
- package/dist/permitted/resolveInterface.js.map +0 -1
- package/dist/permitted/updateInterface.js +0 -7
- package/dist/permitted/updateInterface.js.map +0 -1
- package/dist/restricted/caveats/index.js +0 -17
- package/dist/restricted/caveats/index.js.map +0 -1
- package/dist/restricted/caveats/permittedCoinTypes.js +0 -13
- package/dist/restricted/caveats/permittedCoinTypes.js.map +0 -1
- package/dist/restricted/caveats/permittedDerivationPaths.js +0 -13
- package/dist/restricted/caveats/permittedDerivationPaths.js.map +0 -1
- package/dist/restricted/caveats/snapIds.js +0 -11
- package/dist/restricted/caveats/snapIds.js.map +0 -1
- package/dist/restricted/dialog.js +0 -11
- package/dist/restricted/dialog.js.map +0 -1
- package/dist/restricted/getBip32Entropy.js +0 -10
- package/dist/restricted/getBip32Entropy.js.map +0 -1
- package/dist/restricted/getBip32PublicKey.js +0 -12
- package/dist/restricted/getBip32PublicKey.js.map +0 -1
- package/dist/restricted/getBip44Entropy.js +0 -9
- package/dist/restricted/getBip44Entropy.js.map +0 -1
- package/dist/restricted/getEntropy.js +0 -10
- package/dist/restricted/getEntropy.js.map +0 -1
- package/dist/restricted/getLocale.js +0 -11
- package/dist/restricted/getLocale.js.map +0 -1
- package/dist/restricted/index.js +0 -36
- package/dist/restricted/index.js.map +0 -1
- package/dist/restricted/invokeSnap.js +0 -13
- package/dist/restricted/invokeSnap.js.map +0 -1
- package/dist/restricted/manageAccounts.js +0 -13
- package/dist/restricted/manageAccounts.js.map +0 -1
- package/dist/restricted/manageState.js +0 -20
- package/dist/restricted/manageState.js.map +0 -1
- package/dist/restricted/notify.js +0 -13
- package/dist/restricted/notify.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/types/__fixtures__/index.d.ts +0 -1
- package/dist/types/endowments/caveats/index.d.ts +0 -2
- package/dist/types/index.d.ts +0 -7
- package/dist/types/permitted/index.d.ts +0 -11
- package/dist/types/restricted/dialog.d.ts +0 -1351
- package/dist/utils.js +0 -13
- package/dist/utils.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [11.1.0]
|
|
10
|
+
### Changed
|
|
11
|
+
- Improve error messaging ([#2696](https://github.com/MetaMask/snaps/pull/2696))
|
|
12
|
+
- Increase character limit for in-app notification messages ([#2684](https://github.com/MetaMask/snaps/pull/2684))
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- Fix ESM version of the package ([#2682](https://github.com/MetaMask/snaps/pull/2682))
|
|
16
|
+
- This fixes the ESM version of the package to be fully compliant with the ESM
|
|
17
|
+
standard.
|
|
18
|
+
- Bump `@metamask/utils` from `^9.1.0` to `^9.2.1` ([#2680](https://github.com/MetaMask/snaps/pull/2680))
|
|
19
|
+
- Bump other MetaMask dependencies ([#2703](https://github.com/MetaMask/snaps/pull/2703))
|
|
20
|
+
|
|
21
|
+
## [11.0.0]
|
|
22
|
+
### Added
|
|
23
|
+
- **BREAKING:** Add `snap_getPreferences` ([#2607](https://github.com/MetaMask/snaps/pull/2607))
|
|
24
|
+
- This is breaking because a `getPreferences` method hook is now required.
|
|
25
|
+
|
|
9
26
|
## [10.0.1]
|
|
10
27
|
### Changed
|
|
11
28
|
- Bump `@metamask/json-rpc-engine` from `^9.0.0` to `^9.0.2` ([#2593](https://github.com/metamask/snaps/pull/2593))
|
|
@@ -184,7 +201,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
184
201
|
- The version of the package no longer needs to match the version of all other
|
|
185
202
|
MetaMask Snaps packages.
|
|
186
203
|
|
|
187
|
-
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@
|
|
204
|
+
[Unreleased]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@11.1.0...HEAD
|
|
205
|
+
[11.1.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@11.0.0...@metamask/snaps-rpc-methods@11.1.0
|
|
206
|
+
[11.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@10.0.1...@metamask/snaps-rpc-methods@11.0.0
|
|
188
207
|
[10.0.1]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@10.0.0...@metamask/snaps-rpc-methods@10.0.1
|
|
189
208
|
[10.0.0]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@9.1.4...@metamask/snaps-rpc-methods@10.0.0
|
|
190
209
|
[9.1.4]: https://github.com/MetaMask/snaps/compare/@metamask/snaps-rpc-methods@9.1.3...@metamask/snaps-rpc-methods@9.1.4
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ENTROPY_VECTORS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* SIP-6 test vectors.
|
|
6
|
+
*/
|
|
7
|
+
exports.ENTROPY_VECTORS = [
|
|
8
|
+
{
|
|
9
|
+
snapId: 'foo',
|
|
10
|
+
derivationPath: "m/1399742832'/1323571613'/1848851859'/458888073'/1339050117'/513522582'/1371866341'/2121938770'/1014285256'",
|
|
11
|
+
entropy: '0x8bbb59ec55a4a8dd5429268e367ebbbe54eee7467c0090ca835c64d45c33a155',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
snapId: 'bar',
|
|
15
|
+
derivationPath: "m/1399742832'/767024459'/1206550137'/1427647479'/1048031962'/1656784813'/1860822351'/1362389435'/2133253878'",
|
|
16
|
+
entropy: '0xbdae5c0790d9189d8ae27fd4860b3b57bab420b6594c420ae9ae3a9f87c1ea14',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
snapId: 'foo',
|
|
20
|
+
salt: 'bar',
|
|
21
|
+
derivationPath: "m/1399742832'/2002032866'/301374032'/1159533269'/453247377'/187127851'/1859522268'/152471137'/187531423'",
|
|
22
|
+
entropy: '0x59cbec1fa877ecb38d88c3a2326b23bff374954b39ad9482c9b082306ac4b3ad',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
snapId: 'bar',
|
|
26
|
+
salt: 'baz',
|
|
27
|
+
derivationPath: "m/1399742832'/734358031'/701613791'/1618075622'/1535938847'/1610213550'/18831365'/356906080'/2095933563'",
|
|
28
|
+
entropy: '0x814c1f121eb4067d1e1d177246461e8a1cc6a1b1152756737aba7fa9c2161ba2',
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
//# sourceMappingURL=entropy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entropy.cjs","sourceRoot":"","sources":["../../src/__fixtures__/entropy.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,eAAe,GAAG;IAC7B;QACE,MAAM,EAAE,KAAK;QACb,cAAc,EACZ,6GAA6G;QAC/G,OAAO,EACL,oEAAoE;KACvE;IACD;QACE,MAAM,EAAE,KAAK;QACb,cAAc,EACZ,8GAA8G;QAChH,OAAO,EACL,oEAAoE;KACvE;IACD;QACE,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,KAAK;QACX,cAAc,EACZ,0GAA0G;QAC5G,OAAO,EACL,oEAAoE;KACvE;IACD;QACE,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,KAAK;QACX,cAAc,EACZ,0GAA0G;QAC5G,OAAO,EACL,oEAAoE;KACvE;CACF,CAAC","sourcesContent":["/**\n * SIP-6 test vectors.\n */\nexport const ENTROPY_VECTORS = [\n {\n snapId: 'foo',\n derivationPath:\n \"m/1399742832'/1323571613'/1848851859'/458888073'/1339050117'/513522582'/1371866341'/2121938770'/1014285256'\",\n entropy:\n '0x8bbb59ec55a4a8dd5429268e367ebbbe54eee7467c0090ca835c64d45c33a155',\n },\n {\n snapId: 'bar',\n derivationPath:\n \"m/1399742832'/767024459'/1206550137'/1427647479'/1048031962'/1656784813'/1860822351'/1362389435'/2133253878'\",\n entropy:\n '0xbdae5c0790d9189d8ae27fd4860b3b57bab420b6594c420ae9ae3a9f87c1ea14',\n },\n {\n snapId: 'foo',\n salt: 'bar',\n derivationPath:\n \"m/1399742832'/2002032866'/301374032'/1159533269'/453247377'/187127851'/1859522268'/152471137'/187531423'\",\n entropy:\n '0x59cbec1fa877ecb38d88c3a2326b23bff374954b39ad9482c9b082306ac4b3ad',\n },\n {\n snapId: 'bar',\n salt: 'baz',\n derivationPath:\n \"m/1399742832'/734358031'/701613791'/1618075622'/1535938847'/1610213550'/18831365'/356906080'/2095933563'\",\n entropy:\n '0x814c1f121eb4067d1e1d177246461e8a1cc6a1b1152756737aba7fa9c2161ba2',\n },\n];\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entropy.d.cts","sourceRoot":"","sources":["../../src/__fixtures__/entropy.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;IA+B3B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SIP-6 test vectors.
|
|
3
|
+
*/
|
|
4
|
+
export declare const ENTROPY_VECTORS: ({
|
|
5
|
+
snapId: string;
|
|
6
|
+
derivationPath: string;
|
|
7
|
+
entropy: string;
|
|
8
|
+
salt?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
snapId: string;
|
|
11
|
+
salt: string;
|
|
12
|
+
derivationPath: string;
|
|
13
|
+
entropy: string;
|
|
14
|
+
})[];
|
|
15
|
+
//# sourceMappingURL=entropy.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entropy.d.mts","sourceRoot":"","sources":["../../src/__fixtures__/entropy.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;IA+B3B,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SIP-6 test vectors.
|
|
3
|
+
*/
|
|
4
|
+
export const ENTROPY_VECTORS = [
|
|
5
|
+
{
|
|
6
|
+
snapId: 'foo',
|
|
7
|
+
derivationPath: "m/1399742832'/1323571613'/1848851859'/458888073'/1339050117'/513522582'/1371866341'/2121938770'/1014285256'",
|
|
8
|
+
entropy: '0x8bbb59ec55a4a8dd5429268e367ebbbe54eee7467c0090ca835c64d45c33a155',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
snapId: 'bar',
|
|
12
|
+
derivationPath: "m/1399742832'/767024459'/1206550137'/1427647479'/1048031962'/1656784813'/1860822351'/1362389435'/2133253878'",
|
|
13
|
+
entropy: '0xbdae5c0790d9189d8ae27fd4860b3b57bab420b6594c420ae9ae3a9f87c1ea14',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
snapId: 'foo',
|
|
17
|
+
salt: 'bar',
|
|
18
|
+
derivationPath: "m/1399742832'/2002032866'/301374032'/1159533269'/453247377'/187127851'/1859522268'/152471137'/187531423'",
|
|
19
|
+
entropy: '0x59cbec1fa877ecb38d88c3a2326b23bff374954b39ad9482c9b082306ac4b3ad',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
snapId: 'bar',
|
|
23
|
+
salt: 'baz',
|
|
24
|
+
derivationPath: "m/1399742832'/734358031'/701613791'/1618075622'/1535938847'/1610213550'/18831365'/356906080'/2095933563'",
|
|
25
|
+
entropy: '0x814c1f121eb4067d1e1d177246461e8a1cc6a1b1152756737aba7fa9c2161ba2',
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
//# sourceMappingURL=entropy.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entropy.mjs","sourceRoot":"","sources":["../../src/__fixtures__/entropy.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B;QACE,MAAM,EAAE,KAAK;QACb,cAAc,EACZ,6GAA6G;QAC/G,OAAO,EACL,oEAAoE;KACvE;IACD;QACE,MAAM,EAAE,KAAK;QACb,cAAc,EACZ,8GAA8G;QAChH,OAAO,EACL,oEAAoE;KACvE;IACD;QACE,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,KAAK;QACX,cAAc,EACZ,0GAA0G;QAC5G,OAAO,EACL,oEAAoE;KACvE;IACD;QACE,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,KAAK;QACX,cAAc,EACZ,0GAA0G;QAC5G,OAAO,EACL,oEAAoE;KACvE;CACF,CAAC","sourcesContent":["/**\n * SIP-6 test vectors.\n */\nexport const ENTROPY_VECTORS = [\n {\n snapId: 'foo',\n derivationPath:\n \"m/1399742832'/1323571613'/1848851859'/458888073'/1339050117'/513522582'/1371866341'/2121938770'/1014285256'\",\n entropy:\n '0x8bbb59ec55a4a8dd5429268e367ebbbe54eee7467c0090ca835c64d45c33a155',\n },\n {\n snapId: 'bar',\n derivationPath:\n \"m/1399742832'/767024459'/1206550137'/1427647479'/1048031962'/1656784813'/1860822351'/1362389435'/2133253878'\",\n entropy:\n '0xbdae5c0790d9189d8ae27fd4860b3b57bab420b6594c420ae9ae3a9f87c1ea14',\n },\n {\n snapId: 'foo',\n salt: 'bar',\n derivationPath:\n \"m/1399742832'/2002032866'/301374032'/1159533269'/453247377'/187127851'/1859522268'/152471137'/187531423'\",\n entropy:\n '0x59cbec1fa877ecb38d88c3a2326b23bff374954b39ad9482c9b082306ac4b3ad',\n },\n {\n snapId: 'bar',\n salt: 'baz',\n derivationPath:\n \"m/1399742832'/734358031'/701613791'/1618075622'/1535938847'/1610213550'/18831365'/356906080'/2095933563'\",\n entropy:\n '0x814c1f121eb4067d1e1d177246461e8a1cc6a1b1152756737aba7fa9c2161ba2',\n },\n];\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./entropy.cjs"), exports);
|
|
18
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/__fixtures__/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA0B","sourcesContent":["export * from './entropy';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/__fixtures__/index.ts"],"names":[],"mappings":"AAAA,8BAA0B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/__fixtures__/index.ts"],"names":[],"mappings":"AAAA,8BAA0B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/__fixtures__/index.ts"],"names":[],"mappings":"AAAA,8BAA0B","sourcesContent":["export * from './entropy';\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createGenericPermissionValidator = void 0;
|
|
4
|
+
const rpc_errors_1 = require("@metamask/rpc-errors");
|
|
5
|
+
/**
|
|
6
|
+
* Create a generic permission validator that validates the presence of certain caveats.
|
|
7
|
+
*
|
|
8
|
+
* This validator only validates the types of the caveats, not the values.
|
|
9
|
+
*
|
|
10
|
+
* @param caveatsToValidate - A list of objects that represent caveats.
|
|
11
|
+
* @param caveatsToValidate.type - The string defining the caveat type.
|
|
12
|
+
* @param caveatsToValidate.optional - An optional boolean flag that defines
|
|
13
|
+
* whether the caveat is optional or not.
|
|
14
|
+
* @returns A function that validates a permission.
|
|
15
|
+
*/
|
|
16
|
+
function createGenericPermissionValidator(caveatsToValidate) {
|
|
17
|
+
const validCaveatTypes = new Set(caveatsToValidate.map((caveat) => caveat.type));
|
|
18
|
+
const requiredCaveats = caveatsToValidate.filter((caveat) => !caveat.optional);
|
|
19
|
+
return function ({ caveats }) {
|
|
20
|
+
const actualCaveats = caveats ?? [];
|
|
21
|
+
const passedCaveatTypes = actualCaveats.map((caveat) => caveat.type);
|
|
22
|
+
const passedCaveatsSet = new Set(passedCaveatTypes);
|
|
23
|
+
// Disallow duplicates
|
|
24
|
+
if (passedCaveatsSet.size !== passedCaveatTypes.length) {
|
|
25
|
+
throw rpc_errors_1.rpcErrors.invalidParams({
|
|
26
|
+
message: 'Duplicate caveats are not allowed.',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// Disallow caveats that don't match expected types
|
|
30
|
+
if (!actualCaveats.every((caveat) => validCaveatTypes.has(caveat.type))) {
|
|
31
|
+
throw rpc_errors_1.rpcErrors.invalidParams({
|
|
32
|
+
message: `Expected the following caveats: ${caveatsToValidate
|
|
33
|
+
.map((caveat) => `"${caveat.type}"`)
|
|
34
|
+
.join(', ')}, received ${actualCaveats
|
|
35
|
+
.map((caveat) => `"${caveat.type}"`)
|
|
36
|
+
.join(', ')}.`,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// Fail if not all required caveats are specified
|
|
40
|
+
if (!requiredCaveats.every((caveat) => passedCaveatsSet.has(caveat.type))) {
|
|
41
|
+
throw rpc_errors_1.rpcErrors.invalidParams({
|
|
42
|
+
message: `Expected the following caveats: ${requiredCaveats
|
|
43
|
+
.map((caveat) => `"${caveat.type}"`)
|
|
44
|
+
.join(', ')}.`,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
exports.createGenericPermissionValidator = createGenericPermissionValidator;
|
|
50
|
+
//# sourceMappingURL=generic.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic.cjs","sourceRoot":"","sources":["../../../src/endowments/caveats/generic.ts"],"names":[],"mappings":";;;AAIA,qDAAiD;AAOjD;;;;;;;;;;GAUG;AACH,SAAgB,gCAAgC,CAC9C,iBAGG;IAEH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAC9B,iBAAiB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAC/C,CAAC;IACF,MAAM,eAAe,GAAG,iBAAiB,CAAC,MAAM,CAC9C,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAC7B,CAAC;IAEF,OAAO,UAAU,EAAE,OAAO,EAAE;QAC1B,MAAM,aAAa,GAAG,OAAO,IAAI,EAAE,CAAC;QACpC,MAAM,iBAAiB,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACrE,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAEpD,sBAAsB;QACtB,IAAI,gBAAgB,CAAC,IAAI,KAAK,iBAAiB,CAAC,MAAM,EAAE,CAAC;YACvD,MAAM,sBAAS,CAAC,aAAa,CAAC;gBAC5B,OAAO,EAAE,oCAAoC;aAC9C,CAAC,CAAC;QACL,CAAC;QAED,mDAAmD;QACnD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACxE,MAAM,sBAAS,CAAC,aAAa,CAAC;gBAC5B,OAAO,EAAE,mCAAmC,iBAAiB;qBAC1D,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC;qBACnC,IAAI,CAAC,IAAI,CAAC,cAAc,aAAa;qBACrC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC;qBACnC,IAAI,CAAC,IAAI,CAAC,GAAG;aACjB,CAAC,CAAC;QACL,CAAC;QAED,iDAAiD;QACjD,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YAC1E,MAAM,sBAAS,CAAC,aAAa,CAAC;gBAC5B,OAAO,EAAE,mCAAmC,eAAe;qBACxD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC;qBACnC,IAAI,CAAC,IAAI,CAAC,GAAG;aACjB,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AA7CD,4EA6CC","sourcesContent":["import type {\n PermissionConstraint,\n PermissionValidatorConstraint,\n} from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { Json } from '@metamask/utils';\n\nexport type CaveatMapperReturnValue = Pick<PermissionConstraint, 'caveats'>;\n\nexport type CaveatMapperFunction = (value: Json) => CaveatMapperReturnValue;\n\n/**\n * Create a generic permission validator that validates the presence of certain caveats.\n *\n * This validator only validates the types of the caveats, not the values.\n *\n * @param caveatsToValidate - A list of objects that represent caveats.\n * @param caveatsToValidate.type - The string defining the caveat type.\n * @param caveatsToValidate.optional - An optional boolean flag that defines\n * whether the caveat is optional or not.\n * @returns A function that validates a permission.\n */\nexport function createGenericPermissionValidator(\n caveatsToValidate: {\n type: string;\n optional?: boolean;\n }[],\n): PermissionValidatorConstraint {\n const validCaveatTypes = new Set(\n caveatsToValidate.map((caveat) => caveat.type),\n );\n const requiredCaveats = caveatsToValidate.filter(\n (caveat) => !caveat.optional,\n );\n\n return function ({ caveats }) {\n const actualCaveats = caveats ?? [];\n const passedCaveatTypes = actualCaveats.map((caveat) => caveat.type);\n const passedCaveatsSet = new Set(passedCaveatTypes);\n\n // Disallow duplicates\n if (passedCaveatsSet.size !== passedCaveatTypes.length) {\n throw rpcErrors.invalidParams({\n message: 'Duplicate caveats are not allowed.',\n });\n }\n\n // Disallow caveats that don't match expected types\n if (!actualCaveats.every((caveat) => validCaveatTypes.has(caveat.type))) {\n throw rpcErrors.invalidParams({\n message: `Expected the following caveats: ${caveatsToValidate\n .map((caveat) => `\"${caveat.type}\"`)\n .join(', ')}, received ${actualCaveats\n .map((caveat) => `\"${caveat.type}\"`)\n .join(', ')}.`,\n });\n }\n\n // Fail if not all required caveats are specified\n if (!requiredCaveats.every((caveat) => passedCaveatsSet.has(caveat.type))) {\n throw rpcErrors.invalidParams({\n message: `Expected the following caveats: ${requiredCaveats\n .map((caveat) => `\"${caveat.type}\"`)\n .join(', ')}.`,\n });\n }\n };\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { PermissionConstraint, PermissionValidatorConstraint } from
|
|
2
|
-
import type { Json } from
|
|
3
|
-
export
|
|
4
|
-
export
|
|
1
|
+
import type { PermissionConstraint, PermissionValidatorConstraint } from "@metamask/permission-controller";
|
|
2
|
+
import type { Json } from "@metamask/utils";
|
|
3
|
+
export type CaveatMapperReturnValue = Pick<PermissionConstraint, 'caveats'>;
|
|
4
|
+
export type CaveatMapperFunction = (value: Json) => CaveatMapperReturnValue;
|
|
5
5
|
/**
|
|
6
6
|
* Create a generic permission validator that validates the presence of certain caveats.
|
|
7
7
|
*
|
|
@@ -17,3 +17,4 @@ export declare function createGenericPermissionValidator(caveatsToValidate: {
|
|
|
17
17
|
type: string;
|
|
18
18
|
optional?: boolean;
|
|
19
19
|
}[]): PermissionValidatorConstraint;
|
|
20
|
+
//# sourceMappingURL=generic.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic.d.cts","sourceRoot":"","sources":["../../../src/endowments/caveats/generic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,6BAA6B,EAC9B,wCAAwC;AAEzC,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAE5C,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC;AAE5E,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,IAAI,KAAK,uBAAuB,CAAC;AAE5E;;;;;;;;;;GAUG;AACH,wBAAgB,gCAAgC,CAC9C,iBAAiB,EAAE;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,EAAE,GACF,6BAA6B,CAwC/B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PermissionConstraint, PermissionValidatorConstraint } from "@metamask/permission-controller";
|
|
2
|
+
import type { Json } from "@metamask/utils";
|
|
3
|
+
export type CaveatMapperReturnValue = Pick<PermissionConstraint, 'caveats'>;
|
|
4
|
+
export type CaveatMapperFunction = (value: Json) => CaveatMapperReturnValue;
|
|
5
|
+
/**
|
|
6
|
+
* Create a generic permission validator that validates the presence of certain caveats.
|
|
7
|
+
*
|
|
8
|
+
* This validator only validates the types of the caveats, not the values.
|
|
9
|
+
*
|
|
10
|
+
* @param caveatsToValidate - A list of objects that represent caveats.
|
|
11
|
+
* @param caveatsToValidate.type - The string defining the caveat type.
|
|
12
|
+
* @param caveatsToValidate.optional - An optional boolean flag that defines
|
|
13
|
+
* whether the caveat is optional or not.
|
|
14
|
+
* @returns A function that validates a permission.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createGenericPermissionValidator(caveatsToValidate: {
|
|
17
|
+
type: string;
|
|
18
|
+
optional?: boolean;
|
|
19
|
+
}[]): PermissionValidatorConstraint;
|
|
20
|
+
//# sourceMappingURL=generic.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic.d.mts","sourceRoot":"","sources":["../../../src/endowments/caveats/generic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,6BAA6B,EAC9B,wCAAwC;AAEzC,OAAO,KAAK,EAAE,IAAI,EAAE,wBAAwB;AAE5C,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC;AAE5E,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,IAAI,KAAK,uBAAuB,CAAC;AAE5E;;;;;;;;;;GAUG;AACH,wBAAgB,gCAAgC,CAC9C,iBAAiB,EAAE;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,EAAE,GACF,6BAA6B,CAwC/B"}
|
|
@@ -1,7 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { rpcErrors } from "@metamask/rpc-errors";
|
|
2
|
+
/**
|
|
3
|
+
* Create a generic permission validator that validates the presence of certain caveats.
|
|
4
|
+
*
|
|
5
|
+
* This validator only validates the types of the caveats, not the values.
|
|
6
|
+
*
|
|
7
|
+
* @param caveatsToValidate - A list of objects that represent caveats.
|
|
8
|
+
* @param caveatsToValidate.type - The string defining the caveat type.
|
|
9
|
+
* @param caveatsToValidate.optional - An optional boolean flag that defines
|
|
10
|
+
* whether the caveat is optional or not.
|
|
11
|
+
* @returns A function that validates a permission.
|
|
12
|
+
*/
|
|
13
|
+
export function createGenericPermissionValidator(caveatsToValidate) {
|
|
14
|
+
const validCaveatTypes = new Set(caveatsToValidate.map((caveat) => caveat.type));
|
|
15
|
+
const requiredCaveats = caveatsToValidate.filter((caveat) => !caveat.optional);
|
|
16
|
+
return function ({ caveats }) {
|
|
17
|
+
const actualCaveats = caveats ?? [];
|
|
18
|
+
const passedCaveatTypes = actualCaveats.map((caveat) => caveat.type);
|
|
19
|
+
const passedCaveatsSet = new Set(passedCaveatTypes);
|
|
20
|
+
// Disallow duplicates
|
|
21
|
+
if (passedCaveatsSet.size !== passedCaveatTypes.length) {
|
|
22
|
+
throw rpcErrors.invalidParams({
|
|
23
|
+
message: 'Duplicate caveats are not allowed.',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
// Disallow caveats that don't match expected types
|
|
27
|
+
if (!actualCaveats.every((caveat) => validCaveatTypes.has(caveat.type))) {
|
|
28
|
+
throw rpcErrors.invalidParams({
|
|
29
|
+
message: `Expected the following caveats: ${caveatsToValidate
|
|
30
|
+
.map((caveat) => `"${caveat.type}"`)
|
|
31
|
+
.join(', ')}, received ${actualCaveats
|
|
32
|
+
.map((caveat) => `"${caveat.type}"`)
|
|
33
|
+
.join(', ')}.`,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// Fail if not all required caveats are specified
|
|
37
|
+
if (!requiredCaveats.every((caveat) => passedCaveatsSet.has(caveat.type))) {
|
|
38
|
+
throw rpcErrors.invalidParams({
|
|
39
|
+
message: `Expected the following caveats: ${requiredCaveats
|
|
40
|
+
.map((caveat) => `"${caveat.type}"`)
|
|
41
|
+
.join(', ')}.`,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
7
46
|
//# sourceMappingURL=generic.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"generic.mjs","sourceRoot":"","sources":["../../../src/endowments/caveats/generic.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAOjD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gCAAgC,CAC9C,iBAGG;IAEH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAC9B,iBAAiB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAC/C,CAAC;IACF,MAAM,eAAe,GAAG,iBAAiB,CAAC,MAAM,CAC9C,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAC7B,CAAC;IAEF,OAAO,UAAU,EAAE,OAAO,EAAE;QAC1B,MAAM,aAAa,GAAG,OAAO,IAAI,EAAE,CAAC;QACpC,MAAM,iBAAiB,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACrE,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAEpD,sBAAsB;QACtB,IAAI,gBAAgB,CAAC,IAAI,KAAK,iBAAiB,CAAC,MAAM,EAAE,CAAC;YACvD,MAAM,SAAS,CAAC,aAAa,CAAC;gBAC5B,OAAO,EAAE,oCAAoC;aAC9C,CAAC,CAAC;QACL,CAAC;QAED,mDAAmD;QACnD,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACxE,MAAM,SAAS,CAAC,aAAa,CAAC;gBAC5B,OAAO,EAAE,mCAAmC,iBAAiB;qBAC1D,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC;qBACnC,IAAI,CAAC,IAAI,CAAC,cAAc,aAAa;qBACrC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC;qBACnC,IAAI,CAAC,IAAI,CAAC,GAAG;aACjB,CAAC,CAAC;QACL,CAAC;QAED,iDAAiD;QACjD,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YAC1E,MAAM,SAAS,CAAC,aAAa,CAAC;gBAC5B,OAAO,EAAE,mCAAmC,eAAe;qBACxD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC;qBACnC,IAAI,CAAC,IAAI,CAAC,GAAG;aACjB,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type {\n PermissionConstraint,\n PermissionValidatorConstraint,\n} from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { Json } from '@metamask/utils';\n\nexport type CaveatMapperReturnValue = Pick<PermissionConstraint, 'caveats'>;\n\nexport type CaveatMapperFunction = (value: Json) => CaveatMapperReturnValue;\n\n/**\n * Create a generic permission validator that validates the presence of certain caveats.\n *\n * This validator only validates the types of the caveats, not the values.\n *\n * @param caveatsToValidate - A list of objects that represent caveats.\n * @param caveatsToValidate.type - The string defining the caveat type.\n * @param caveatsToValidate.optional - An optional boolean flag that defines\n * whether the caveat is optional or not.\n * @returns A function that validates a permission.\n */\nexport function createGenericPermissionValidator(\n caveatsToValidate: {\n type: string;\n optional?: boolean;\n }[],\n): PermissionValidatorConstraint {\n const validCaveatTypes = new Set(\n caveatsToValidate.map((caveat) => caveat.type),\n );\n const requiredCaveats = caveatsToValidate.filter(\n (caveat) => !caveat.optional,\n );\n\n return function ({ caveats }) {\n const actualCaveats = caveats ?? [];\n const passedCaveatTypes = actualCaveats.map((caveat) => caveat.type);\n const passedCaveatsSet = new Set(passedCaveatTypes);\n\n // Disallow duplicates\n if (passedCaveatsSet.size !== passedCaveatTypes.length) {\n throw rpcErrors.invalidParams({\n message: 'Duplicate caveats are not allowed.',\n });\n }\n\n // Disallow caveats that don't match expected types\n if (!actualCaveats.every((caveat) => validCaveatTypes.has(caveat.type))) {\n throw rpcErrors.invalidParams({\n message: `Expected the following caveats: ${caveatsToValidate\n .map((caveat) => `\"${caveat.type}\"`)\n .join(', ')}, received ${actualCaveats\n .map((caveat) => `\"${caveat.type}\"`)\n .join(', ')}.`,\n });\n }\n\n // Fail if not all required caveats are specified\n if (!requiredCaveats.every((caveat) => passedCaveatsSet.has(caveat.type))) {\n throw rpcErrors.invalidParams({\n message: `Expected the following caveats: ${requiredCaveats\n .map((caveat) => `\"${caveat.type}\"`)\n .join(', ')}.`,\n });\n }\n };\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./generic.cjs"), exports);
|
|
18
|
+
__exportStar(require("./requestTime.cjs"), exports);
|
|
19
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/endowments/caveats/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,oDAA8B","sourcesContent":["export * from './generic';\nexport * from './requestTime';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/endowments/caveats/index.ts"],"names":[],"mappings":"AAAA,8BAA0B;AAC1B,kCAA8B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/endowments/caveats/index.ts"],"names":[],"mappings":"AAAA,8BAA0B;AAC1B,kCAA8B"}
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
createGenericPermissionValidator
|
|
4
|
-
} from "../../chunk-TT4DP2YW.mjs";
|
|
5
|
-
import {
|
|
6
|
-
createMaxRequestTimeMapper,
|
|
7
|
-
getMaxRequestTimeCaveat,
|
|
8
|
-
getMaxRequestTimeCaveatMapper,
|
|
9
|
-
maxRequestTimeCaveatSpecifications
|
|
10
|
-
} from "../../chunk-23XDKQW2.mjs";
|
|
11
|
-
export {
|
|
12
|
-
createGenericPermissionValidator,
|
|
13
|
-
createMaxRequestTimeMapper,
|
|
14
|
-
getMaxRequestTimeCaveat,
|
|
15
|
-
getMaxRequestTimeCaveatMapper,
|
|
16
|
-
maxRequestTimeCaveatSpecifications
|
|
17
|
-
};
|
|
1
|
+
export * from "./generic.mjs";
|
|
2
|
+
export * from "./requestTime.mjs";
|
|
18
3
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/endowments/caveats/index.ts"],"names":[],"mappings":"AAAA,8BAA0B;AAC1B,kCAA8B","sourcesContent":["export * from './generic';\nexport * from './requestTime';\n"]}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.maxRequestTimeCaveatSpecifications = exports.getMaxRequestTimeCaveat = exports.createMaxRequestTimeMapper = exports.getMaxRequestTimeCaveatMapper = void 0;
|
|
4
|
+
const rpc_errors_1 = require("@metamask/rpc-errors");
|
|
5
|
+
const snaps_utils_1 = require("@metamask/snaps-utils");
|
|
6
|
+
const utils_1 = require("@metamask/utils");
|
|
7
|
+
/**
|
|
8
|
+
* Asserts that the given value is a valid `maxRequestTime` value.
|
|
9
|
+
*
|
|
10
|
+
* @param value - The value to assert.
|
|
11
|
+
* @param ErrorWrapper - An optional error wrapper to use. Defaults to
|
|
12
|
+
* {@link AssertionError}.
|
|
13
|
+
* @throws If the value is not a valid `maxRequestTime` value.
|
|
14
|
+
*/
|
|
15
|
+
function assertIsMaxRequestTime(value, // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
16
|
+
ErrorWrapper) {
|
|
17
|
+
(0, utils_1.assertStruct)(value, snaps_utils_1.MaxRequestTimeStruct, 'Invalid maxRequestTime', ErrorWrapper);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Validate the value of a caveat. This does not validate the type of the
|
|
21
|
+
* caveat itself, only the value of the caveat.
|
|
22
|
+
*
|
|
23
|
+
* @param caveat - The caveat to validate.
|
|
24
|
+
* @throws If the caveat value is invalid.
|
|
25
|
+
*/
|
|
26
|
+
function validateMaxRequestTimeCaveat(caveat) {
|
|
27
|
+
if (!(0, utils_1.hasProperty)(caveat, 'value')) {
|
|
28
|
+
throw rpc_errors_1.rpcErrors.invalidParams({
|
|
29
|
+
message: 'Invalid maxRequestTime caveat.',
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const { value } = caveat;
|
|
33
|
+
assertIsMaxRequestTime(value, rpc_errors_1.rpcErrors.invalidParams);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Map a raw value from the `initialPermissions` to a caveat specification.
|
|
37
|
+
* Note that this function does not do any validation, that's handled by the
|
|
38
|
+
* PermissionsController when the permission is requested.
|
|
39
|
+
*
|
|
40
|
+
* @param value - The raw value from the `initialPermissions`.
|
|
41
|
+
* @returns The caveat specification.
|
|
42
|
+
*/
|
|
43
|
+
function getMaxRequestTimeCaveatMapper(value) {
|
|
44
|
+
if (!value ||
|
|
45
|
+
!(0, utils_1.isObject)(value) ||
|
|
46
|
+
((0, utils_1.isObject)(value) && !(0, utils_1.hasProperty)(value, 'maxRequestTime'))) {
|
|
47
|
+
return { caveats: null };
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
caveats: [
|
|
51
|
+
{
|
|
52
|
+
type: snaps_utils_1.SnapCaveatType.MaxRequestTime,
|
|
53
|
+
value: value.maxRequestTime,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
exports.getMaxRequestTimeCaveatMapper = getMaxRequestTimeCaveatMapper;
|
|
59
|
+
/**
|
|
60
|
+
* Creates a wrapping caveat mapper that creates the `maxRequestTime` caveat
|
|
61
|
+
* and merges it with any other caveats created by the mapper function.
|
|
62
|
+
*
|
|
63
|
+
* @param mapper - Another caveat mapper function.
|
|
64
|
+
* @returns The caveat specification.
|
|
65
|
+
*/
|
|
66
|
+
function createMaxRequestTimeMapper(mapper) {
|
|
67
|
+
return function (value) {
|
|
68
|
+
// We assume this to be used only with caveats of this type
|
|
69
|
+
const { maxRequestTime, ...rest } = value;
|
|
70
|
+
const mapperResult = mapper(rest);
|
|
71
|
+
if (!maxRequestTime) {
|
|
72
|
+
return mapperResult;
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
...mapperResult,
|
|
76
|
+
caveats: [
|
|
77
|
+
...(mapperResult.caveats ?? []),
|
|
78
|
+
{
|
|
79
|
+
type: snaps_utils_1.SnapCaveatType.MaxRequestTime,
|
|
80
|
+
value: maxRequestTime,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
exports.createMaxRequestTimeMapper = createMaxRequestTimeMapper;
|
|
87
|
+
/**
|
|
88
|
+
* Getter function to get the {@link MaxRequestTime} caveat value from a permission if specified.
|
|
89
|
+
*
|
|
90
|
+
* @param permission - The permission to get the caveat value from.
|
|
91
|
+
* @returns The caveat value if present, otherwise null.
|
|
92
|
+
*/
|
|
93
|
+
function getMaxRequestTimeCaveat(permission) {
|
|
94
|
+
const foundCaveat = permission?.caveats?.find((caveat) => caveat.type === snaps_utils_1.SnapCaveatType.MaxRequestTime);
|
|
95
|
+
return foundCaveat?.value ?? null;
|
|
96
|
+
}
|
|
97
|
+
exports.getMaxRequestTimeCaveat = getMaxRequestTimeCaveat;
|
|
98
|
+
exports.maxRequestTimeCaveatSpecifications = {
|
|
99
|
+
[snaps_utils_1.SnapCaveatType.MaxRequestTime]: Object.freeze({
|
|
100
|
+
type: snaps_utils_1.SnapCaveatType.MaxRequestTime,
|
|
101
|
+
validator: (caveat) => validateMaxRequestTimeCaveat(caveat),
|
|
102
|
+
}),
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=requestTime.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"file":"requestTime.cjs","sourceRoot":"","sources":["../../../src/endowments/caveats/requestTime.ts"],"names":[],"mappings":";;;AAKA,qDAAiD;AACjD,uDAA6E;AAE7E,2CAAsE;AAItE;;;;;;;GAOG;AACH,SAAS,sBAAsB,CAC7B,KAAc,EAAE,gEAAgE;AAChF,YAAwC;IAExC,IAAA,oBAAY,EACV,KAAK,EACL,kCAAoB,EACpB,wBAAwB,EACxB,YAAY,CACb,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,SAAS,4BAA4B,CAAC,MAA2B;IAC/D,IAAI,CAAC,IAAA,mBAAW,EAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QAClC,MAAM,sBAAS,CAAC,aAAa,CAAC;YAC5B,OAAO,EAAE,gCAAgC;SAC1C,CAAC,CAAC;IACL,CAAC;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;IACzB,sBAAsB,CAAC,KAAK,EAAE,sBAAS,CAAC,aAAa,CAAC,CAAC;AACzD,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,6BAA6B,CAC3C,KAAW;IAEX,IACE,CAAC,KAAK;QACN,CAAC,IAAA,gBAAQ,EAAC,KAAK,CAAC;QAChB,CAAC,IAAA,gBAAQ,EAAC,KAAK,CAAC,IAAI,CAAC,IAAA,mBAAW,EAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,EAC1D,CAAC;QACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IACD,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,4BAAc,CAAC,cAAc;gBACnC,KAAK,EAAE,KAAK,CAAC,cAAc;aAC5B;SACF;KACF,CAAC;AACJ,CAAC;AAlBD,sEAkBC;AAED;;;;;;GAMG;AACH,SAAgB,0BAA0B,CACxC,MAA4B;IAE5B,OAAO,UAAU,KAAW;QAC1B,2DAA2D;QAC3D,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,KAA6B,CAAC;QAElE,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAElC,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,YAAY,CAAC;QACtB,CAAC;QAED,OAAO;YACL,GAAG,YAAY;YACf,OAAO,EAAE;gBACP,GAAG,CAAC,YAAY,CAAC,OAAO,IAAI,EAAE,CAAC;gBAC/B;oBACE,IAAI,EAAE,4BAAc,CAAC,cAAc;oBACnC,KAAK,EAAE,cAAc;iBACtB;aACF;SACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAxBD,gEAwBC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CACrC,UAAiC;IAEjC,MAAM,WAAW,GAAG,UAAU,EAAE,OAAO,EAAE,IAAI,CAC3C,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,4BAAc,CAAC,cAAc,CAC1D,CAAC;IACF,OAAQ,WAAW,EAAE,KAAgB,IAAI,IAAI,CAAC;AAChD,CAAC;AAPD,0DAOC;AAEY,QAAA,kCAAkC,GAG3C;IACF,CAAC,4BAAc,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC;QAC7C,IAAI,EAAE,4BAAc,CAAC,cAAc;QACnC,SAAS,EAAE,CAAC,MAA2B,EAAE,EAAE,CACzC,4BAA4B,CAAC,MAAM,CAAC;KACvC,CAAC;CACH,CAAC","sourcesContent":["import type {\n Caveat,\n CaveatSpecificationConstraint,\n PermissionConstraint,\n} from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport { MaxRequestTimeStruct, SnapCaveatType } from '@metamask/snaps-utils';\nimport type { AssertionErrorConstructor, Json } from '@metamask/utils';\nimport { assertStruct, hasProperty, isObject } from '@metamask/utils';\n\nimport type { CaveatMapperFunction, CaveatMapperReturnValue } from './generic';\n\n/**\n * Asserts that the given value is a valid `maxRequestTime` value.\n *\n * @param value - The value to assert.\n * @param ErrorWrapper - An optional error wrapper to use. Defaults to\n * {@link AssertionError}.\n * @throws If the value is not a valid `maxRequestTime` value.\n */\nfunction assertIsMaxRequestTime(\n value: unknown, // eslint-disable-next-line @typescript-eslint/naming-convention\n ErrorWrapper?: AssertionErrorConstructor,\n): asserts value is number {\n assertStruct(\n value,\n MaxRequestTimeStruct,\n 'Invalid maxRequestTime',\n ErrorWrapper,\n );\n}\n\n/**\n * Validate the value of a caveat. This does not validate the type of the\n * caveat itself, only the value of the caveat.\n *\n * @param caveat - The caveat to validate.\n * @throws If the caveat value is invalid.\n */\nfunction validateMaxRequestTimeCaveat(caveat: Caveat<string, any>) {\n if (!hasProperty(caveat, 'value')) {\n throw rpcErrors.invalidParams({\n message: 'Invalid maxRequestTime caveat.',\n });\n }\n\n const { value } = caveat;\n assertIsMaxRequestTime(value, rpcErrors.invalidParams);\n}\n\n/**\n * Map a raw value from the `initialPermissions` to a caveat specification.\n * Note that this function does not do any validation, that's handled by the\n * PermissionsController when the permission is requested.\n *\n * @param value - The raw value from the `initialPermissions`.\n * @returns The caveat specification.\n */\nexport function getMaxRequestTimeCaveatMapper(\n value: Json,\n): CaveatMapperReturnValue {\n if (\n !value ||\n !isObject(value) ||\n (isObject(value) && !hasProperty(value, 'maxRequestTime'))\n ) {\n return { caveats: null };\n }\n return {\n caveats: [\n {\n type: SnapCaveatType.MaxRequestTime,\n value: value.maxRequestTime,\n },\n ],\n };\n}\n\n/**\n * Creates a wrapping caveat mapper that creates the `maxRequestTime` caveat\n * and merges it with any other caveats created by the mapper function.\n *\n * @param mapper - Another caveat mapper function.\n * @returns The caveat specification.\n */\nexport function createMaxRequestTimeMapper(\n mapper: CaveatMapperFunction,\n): CaveatMapperFunction {\n return function (value: Json) {\n // We assume this to be used only with caveats of this type\n const { maxRequestTime, ...rest } = value as Record<string, Json>;\n\n const mapperResult = mapper(rest);\n\n if (!maxRequestTime) {\n return mapperResult;\n }\n\n return {\n ...mapperResult,\n caveats: [\n ...(mapperResult.caveats ?? []),\n {\n type: SnapCaveatType.MaxRequestTime,\n value: maxRequestTime,\n },\n ],\n };\n };\n}\n\n/**\n * Getter function to get the {@link MaxRequestTime} caveat value from a permission if specified.\n *\n * @param permission - The permission to get the caveat value from.\n * @returns The caveat value if present, otherwise null.\n */\nexport function getMaxRequestTimeCaveat(\n permission?: PermissionConstraint,\n): number | null {\n const foundCaveat = permission?.caveats?.find(\n (caveat) => caveat.type === SnapCaveatType.MaxRequestTime,\n );\n return (foundCaveat?.value as number) ?? null;\n}\n\nexport const maxRequestTimeCaveatSpecifications: Record<\n SnapCaveatType.MaxRequestTime,\n CaveatSpecificationConstraint\n> = {\n [SnapCaveatType.MaxRequestTime]: Object.freeze({\n type: SnapCaveatType.MaxRequestTime,\n validator: (caveat: Caveat<string, any>) =>\n validateMaxRequestTimeCaveat(caveat),\n }),\n};\n"]}
|
package/dist/{types/endowments/caveats/requestTime.d.ts → endowments/caveats/requestTime.d.cts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { CaveatSpecificationConstraint, PermissionConstraint } from
|
|
2
|
-
import { SnapCaveatType } from
|
|
3
|
-
import type { Json } from
|
|
4
|
-
import type { CaveatMapperFunction, CaveatMapperReturnValue } from
|
|
1
|
+
import type { CaveatSpecificationConstraint, PermissionConstraint } from "@metamask/permission-controller";
|
|
2
|
+
import { SnapCaveatType } from "@metamask/snaps-utils";
|
|
3
|
+
import type { Json } from "@metamask/utils";
|
|
4
|
+
import type { CaveatMapperFunction, CaveatMapperReturnValue } from "./generic.cjs";
|
|
5
5
|
/**
|
|
6
6
|
* Map a raw value from the `initialPermissions` to a caveat specification.
|
|
7
7
|
* Note that this function does not do any validation, that's handled by the
|
|
@@ -27,3 +27,4 @@ export declare function createMaxRequestTimeMapper(mapper: CaveatMapperFunction)
|
|
|
27
27
|
*/
|
|
28
28
|
export declare function getMaxRequestTimeCaveat(permission?: PermissionConstraint): number | null;
|
|
29
29
|
export declare const maxRequestTimeCaveatSpecifications: Record<SnapCaveatType.MaxRequestTime, CaveatSpecificationConstraint>;
|
|
30
|
+
//# sourceMappingURL=requestTime.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestTime.d.cts","sourceRoot":"","sources":["../../../src/endowments/caveats/requestTime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,6BAA6B,EAC7B,oBAAoB,EACrB,wCAAwC;AAEzC,OAAO,EAAwB,cAAc,EAAE,8BAA8B;AAC7E,OAAO,KAAK,EAA6B,IAAI,EAAE,wBAAwB;AAGvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,sBAAkB;AAwC/E;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,IAAI,GACV,uBAAuB,CAgBzB;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,oBAAoB,GAC3B,oBAAoB,CAsBtB;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,CAAC,EAAE,oBAAoB,GAChC,MAAM,GAAG,IAAI,CAKf;AAED,eAAO,MAAM,kCAAkC,EAAE,MAAM,CACrD,cAAc,CAAC,cAAc,EAC7B,6BAA6B,CAO9B,CAAC"}
|