@metamask/snaps-rpc-methods 11.0.0 → 11.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -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} +3 -2
- 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} +34 -33
- 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} +7 -6
- 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 -122
- 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 -43
- 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 -49
- package/dist/permitted/createInterface.d.cts.map +1 -0
- package/dist/permitted/createInterface.d.mts +193 -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} +4 -3
- 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} +4 -3
- 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} +4 -3
- 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} +4 -3
- 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} +4 -3
- 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/permitted/handlers.d.cts +35 -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} +4 -3
- 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} +5 -4
- 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} +4 -3
- 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} +6 -5
- 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} +48 -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 +488 -0
- package/dist/restricted/dialog.d.cts.map +1 -0
- package/dist/restricted/dialog.d.mts +488 -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} +6 -5
- 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} +7 -6
- 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} +6 -5
- 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} +7 -6
- 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} +6 -5
- 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/{types/restricted/getPreferences.d.ts → restricted/getPreferences.d.cts} +6 -5
- 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 +39 -9
- package/dist/restricted/getPreferences.mjs.map +1 -1
- 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} +29 -28
- 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 -35
- 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} +8 -6
- 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} +6 -5
- 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} +6 -5
- 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} +7 -6
- 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} +6 -4
- 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-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-6XKVFSC2.js +0 -32
- package/dist/chunk-6XKVFSC2.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-AMMJ744B.mjs +0 -32
- package/dist/chunk-AMMJ744B.mjs.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-CD4OUHO5.mjs +0 -20
- package/dist/chunk-CD4OUHO5.mjs.map +0 -1
- package/dist/chunk-CDAVFOUS.js +0 -53
- package/dist/chunk-CDAVFOUS.js.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-FM4LNQR7.mjs +0 -34
- package/dist/chunk-FM4LNQR7.mjs.map +0 -1
- package/dist/chunk-GE5XFDUE.js +0 -21
- package/dist/chunk-GE5XFDUE.js.map +0 -1
- package/dist/chunk-GEJDXRTL.mjs +0 -59
- package/dist/chunk-GEJDXRTL.mjs.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-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-JWDQUKKU.mjs +0 -80
- package/dist/chunk-JWDQUKKU.mjs.map +0 -1
- package/dist/chunk-K3UL5RVN.mjs +0 -43
- package/dist/chunk-K3UL5RVN.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-LP3RWEDJ.js +0 -43
- package/dist/chunk-LP3RWEDJ.js.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-PK2RPAXI.js +0 -59
- package/dist/chunk-PK2RPAXI.js.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-RHPSYX7X.js +0 -34
- package/dist/chunk-RHPSYX7X.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-V3KRSCUK.mjs +0 -53
- package/dist/chunk-V3KRSCUK.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 -123
- package/dist/index.js.map +0 -1
- package/dist/permissions.js +0 -44
- 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/getPreferences.js +0 -11
- package/dist/restricted/getPreferences.js.map +0 -1
- package/dist/restricted/index.js +0 -37
- 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/handlers.d.ts +0 -34
- package/dist/types/permitted/index.d.ts +0 -11
- package/dist/types/restricted/dialog.d.ts +0 -1463
- package/dist/utils.js +0 -13
- package/dist/utils.js.map +0 -1
|
@@ -1,10 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "
|
|
5
|
-
import "
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { PermissionType, SubjectType } from "@metamask/permission-controller";
|
|
2
|
+
import { rpcErrors } from "@metamask/rpc-errors";
|
|
3
|
+
import { SIP_6_MAGIC_VALUE } from "@metamask/snaps-utils";
|
|
4
|
+
import { literal, object, optional, string } from "@metamask/superstruct";
|
|
5
|
+
import { assertStruct } from "@metamask/utils";
|
|
6
|
+
import { deriveEntropy } from "../utils.mjs";
|
|
7
|
+
const targetName = 'snap_getEntropy';
|
|
8
|
+
export const GetEntropyArgsStruct = object({
|
|
9
|
+
version: literal(1),
|
|
10
|
+
salt: optional(string()),
|
|
11
|
+
});
|
|
12
|
+
const specificationBuilder = ({ allowedCaveats = null, methodHooks, }) => {
|
|
13
|
+
return {
|
|
14
|
+
permissionType: PermissionType.RestrictedMethod,
|
|
15
|
+
targetName,
|
|
16
|
+
allowedCaveats,
|
|
17
|
+
methodImplementation: getEntropyImplementation(methodHooks),
|
|
18
|
+
subjectTypes: [SubjectType.Snap],
|
|
19
|
+
};
|
|
9
20
|
};
|
|
21
|
+
const methodHooks = {
|
|
22
|
+
getMnemonic: true,
|
|
23
|
+
getUnlockPromise: true,
|
|
24
|
+
};
|
|
25
|
+
export const getEntropyBuilder = Object.freeze({
|
|
26
|
+
targetName,
|
|
27
|
+
specificationBuilder,
|
|
28
|
+
methodHooks,
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Builds the method implementation for `snap_getEntropy`. The implementation
|
|
32
|
+
* is based on the reference implementation of
|
|
33
|
+
* [SIP-6](https://metamask.github.io/SIPs/SIPS/sip-6).
|
|
34
|
+
*
|
|
35
|
+
* @param hooks - The RPC method hooks.
|
|
36
|
+
* @param hooks.getMnemonic - The method to get the mnemonic of the user's
|
|
37
|
+
* primary keyring.
|
|
38
|
+
* @param hooks.getUnlockPromise - The method to get a promise that resolves
|
|
39
|
+
* once the extension is unlocked.
|
|
40
|
+
* @returns The method implementation.
|
|
41
|
+
*/
|
|
42
|
+
function getEntropyImplementation({ getMnemonic, getUnlockPromise, }) {
|
|
43
|
+
return async function getEntropy(options) {
|
|
44
|
+
const { params, context: { origin }, } = options;
|
|
45
|
+
assertStruct(params, GetEntropyArgsStruct, 'Invalid "snap_getEntropy" parameters', rpcErrors.invalidParams);
|
|
46
|
+
await getUnlockPromise(true);
|
|
47
|
+
const mnemonicPhrase = await getMnemonic();
|
|
48
|
+
return deriveEntropy({
|
|
49
|
+
input: origin,
|
|
50
|
+
salt: params.salt,
|
|
51
|
+
mnemonicPhrase,
|
|
52
|
+
magic: SIP_6_MAGIC_VALUE,
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
}
|
|
10
56
|
//# sourceMappingURL=getEntropy.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"getEntropy.mjs","sourceRoot":"","sources":["../../src/restricted/getEntropy.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,wCAAwC;AAC9E,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAEjD,OAAO,EAAE,iBAAiB,EAAE,8BAA8B;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,8BAA8B;AAE1E,OAAO,EAAE,YAAY,EAAE,wBAAwB;AAG/C,OAAO,EAAE,aAAa,EAAE,qBAAiB;AAEzC,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAcrC,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC;IACzC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;CACzB,CAAC,CAAC;AAUH,MAAM,oBAAoB,GAItB,CAAC,EACH,cAAc,GAAG,IAAI,EACrB,WAAW,GAC2B,EAAE,EAAE;IAC1C,OAAO;QACL,cAAc,EAAE,cAAc,CAAC,gBAAgB;QAC/C,UAAU;QACV,cAAc;QACd,oBAAoB,EAAE,wBAAwB,CAAC,WAAW,CAAC;QAC3D,YAAY,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,WAAW,GAAuC;IACtD,WAAW,EAAE,IAAI;IACjB,gBAAgB,EAAE,IAAI;CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7C,UAAU;IACV,oBAAoB;IACpB,WAAW;CACH,CAAC,CAAC;AAgBZ;;;;;;;;;;;GAWG;AACH,SAAS,wBAAwB,CAAC,EAChC,WAAW,EACX,gBAAgB,GACA;IAChB,OAAO,KAAK,UAAU,UAAU,CAC9B,OAAkD;QAElD,MAAM,EACJ,MAAM,EACN,OAAO,EAAE,EAAE,MAAM,EAAE,GACpB,GAAG,OAAO,CAAC;QAEZ,YAAY,CACV,MAAM,EACN,oBAAoB,EACpB,sCAAsC,EACtC,SAAS,CAAC,aAAa,CACxB,CAAC;QAEF,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,cAAc,GAAG,MAAM,WAAW,EAAE,CAAC;QAE3C,OAAO,aAAa,CAAC;YACnB,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,cAAc;YACd,KAAK,EAAE,iBAAiB;SACzB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type {\n PermissionSpecificationBuilder,\n RestrictedMethodOptions,\n ValidPermissionSpecification,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport type { GetEntropyParams, GetEntropyResult } from '@metamask/snaps-sdk';\nimport { SIP_6_MAGIC_VALUE } from '@metamask/snaps-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { literal, object, optional, string } from '@metamask/superstruct';\nimport type { NonEmptyArray } from '@metamask/utils';\nimport { assertStruct } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\nimport { deriveEntropy } from '../utils';\n\nconst targetName = 'snap_getEntropy';\n\ntype GetEntropySpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: GetEntropyHooks;\n};\n\ntype GetEntropySpecification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof targetName;\n methodImplementation: ReturnType<typeof getEntropyImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\nexport const GetEntropyArgsStruct = object({\n version: literal(1),\n salt: optional(string()),\n});\n\n/**\n * @property version - The version of the `snap_getEntropy` method. This must be\n * the numeric literal `1`.\n * @property salt - A string to use as the salt when deriving the entropy. If\n * omitted, the salt will be an empty string.\n */\nexport type GetEntropyArgs = Infer<typeof GetEntropyArgsStruct>;\n\nconst specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n GetEntropySpecificationBuilderOptions,\n GetEntropySpecification\n> = ({\n allowedCaveats = null,\n methodHooks,\n}: GetEntropySpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName,\n allowedCaveats,\n methodImplementation: getEntropyImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetEntropyHooks> = {\n getMnemonic: true,\n getUnlockPromise: true,\n};\n\nexport const getEntropyBuilder = Object.freeze({\n targetName,\n specificationBuilder,\n methodHooks,\n} as const);\n\nexport type GetEntropyHooks = {\n /**\n * @returns The mnemonic of the user's primary keyring.\n */\n getMnemonic: () => Promise<Uint8Array>;\n\n /**\n * Waits for the extension to be unlocked.\n *\n * @returns A promise that resolves once the extension is unlocked.\n */\n getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>;\n};\n\n/**\n * Builds the method implementation for `snap_getEntropy`. The implementation\n * is based on the reference implementation of\n * [SIP-6](https://metamask.github.io/SIPs/SIPS/sip-6).\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getMnemonic - The method to get the mnemonic of the user's\n * primary keyring.\n * @param hooks.getUnlockPromise - The method to get a promise that resolves\n * once the extension is unlocked.\n * @returns The method implementation.\n */\nfunction getEntropyImplementation({\n getMnemonic,\n getUnlockPromise,\n}: GetEntropyHooks) {\n return async function getEntropy(\n options: RestrictedMethodOptions<GetEntropyParams>,\n ): Promise<GetEntropyResult> {\n const {\n params,\n context: { origin },\n } = options;\n\n assertStruct(\n params,\n GetEntropyArgsStruct,\n 'Invalid \"snap_getEntropy\" parameters',\n rpcErrors.invalidParams,\n );\n\n await getUnlockPromise(true);\n const mnemonicPhrase = await getMnemonic();\n\n return deriveEntropy({\n input: origin,\n salt: params.salt,\n mnemonicPhrase,\n magic: SIP_6_MAGIC_VALUE,\n });\n };\n}\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getImplementation = exports.getLocaleBuilder = exports.specificationBuilder = void 0;
|
|
4
|
+
const permission_controller_1 = require("@metamask/permission-controller");
|
|
5
|
+
const methodName = 'snap_getLocale';
|
|
6
|
+
/**
|
|
7
|
+
* The specification builder for the `snap_getLocale` permission.
|
|
8
|
+
* `snap_getLocale` allows snaps to get the user selected locale.
|
|
9
|
+
*
|
|
10
|
+
* @param options - The specification builder options.
|
|
11
|
+
* @param options.allowedCaveats - The optional allowed caveats for the permission.
|
|
12
|
+
* @param options.methodHooks - The RPC method hooks needed by the method implementation.
|
|
13
|
+
* @returns The specification for the `snap_getLocale` permission.
|
|
14
|
+
* @deprecated - To be removed in favor of `snap_getPreferences`.
|
|
15
|
+
*/
|
|
16
|
+
const specificationBuilder = ({ allowedCaveats = null, methodHooks }) => {
|
|
17
|
+
return {
|
|
18
|
+
permissionType: permission_controller_1.PermissionType.RestrictedMethod,
|
|
19
|
+
targetName: methodName,
|
|
20
|
+
allowedCaveats,
|
|
21
|
+
methodImplementation: getImplementation(methodHooks),
|
|
22
|
+
subjectTypes: [permission_controller_1.SubjectType.Snap],
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
exports.specificationBuilder = specificationBuilder;
|
|
26
|
+
const methodHooks = {
|
|
27
|
+
getPreferences: true,
|
|
28
|
+
};
|
|
29
|
+
exports.getLocaleBuilder = Object.freeze({
|
|
30
|
+
targetName: methodName,
|
|
31
|
+
specificationBuilder: exports.specificationBuilder,
|
|
32
|
+
methodHooks,
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Builds the method implementation for `snap_getLocale`.
|
|
36
|
+
*
|
|
37
|
+
* @param hooks - The RPC method hooks.
|
|
38
|
+
* @param hooks.getPreferences - A function that returns the user selected preferences.
|
|
39
|
+
* @returns The user selected locale.
|
|
40
|
+
*/
|
|
41
|
+
function getImplementation({ getPreferences }) {
|
|
42
|
+
return async function implementation(_args) {
|
|
43
|
+
return getPreferences().locale;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
exports.getImplementation = getImplementation;
|
|
47
|
+
//# sourceMappingURL=getLocale.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLocale.cjs","sourceRoot":"","sources":["../../src/restricted/getLocale.ts"],"names":[],"mappings":";;;AAMA,2EAA8E;AAS9E,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAkBpC;;;;;;;;;GASG;AACI,MAAM,oBAAoB,GAI7B,CAAC,EAAE,cAAc,GAAG,IAAI,EAAE,WAAW,EAA+B,EAAE,EAAE;IAC1E,OAAO;QACL,cAAc,EAAE,sCAAc,CAAC,gBAAgB;QAC/C,UAAU,EAAE,UAAU;QACtB,cAAc;QACd,oBAAoB,EAAE,iBAAiB,CAAC,WAAW,CAAC;QACpD,YAAY,EAAE,CAAC,mCAAW,CAAC,IAAI,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,oBAAoB,wBAY/B;AAEF,MAAM,WAAW,GAA4C;IAC3D,cAAc,EAAE,IAAI;CACrB,CAAC;AAEW,QAAA,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,UAAU,EAAE,UAAU;IACtB,oBAAoB,EAApB,4BAAoB;IACpB,WAAW;CACH,CAAC,CAAC;AAEZ;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,EAAE,cAAc,EAAwB;IACxE,OAAO,KAAK,UAAU,cAAc,CAClC,KAA0D;QAE1D,OAAO,cAAc,EAAE,CAAC,MAAM,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC;AAND,8CAMC","sourcesContent":["import type {\n PermissionSpecificationBuilder,\n ValidPermissionSpecification,\n RestrictedMethodOptions,\n RestrictedMethodParameters,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport type {\n GetLocaleResult,\n GetPreferencesResult,\n} from '@metamask/snaps-sdk';\nimport type { NonEmptyArray } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst methodName = 'snap_getLocale';\n\nexport type GetLocaleMethodHooks = {\n getPreferences: () => GetPreferencesResult;\n};\n\ntype SpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: GetLocaleMethodHooks;\n};\n\ntype Specification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof methodName;\n methodImplementation: ReturnType<typeof getImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * The specification builder for the `snap_getLocale` permission.\n * `snap_getLocale` allows snaps to get the user selected locale.\n *\n * @param options - The specification builder options.\n * @param options.allowedCaveats - The optional allowed caveats for the permission.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_getLocale` permission.\n * @deprecated - To be removed in favor of `snap_getPreferences`.\n */\nexport const specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n SpecificationBuilderOptions,\n Specification\n> = ({ allowedCaveats = null, methodHooks }: SpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: methodName,\n allowedCaveats,\n methodImplementation: getImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetLocaleMethodHooks> = {\n getPreferences: true,\n};\n\nexport const getLocaleBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getLocale`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getPreferences - A function that returns the user selected preferences.\n * @returns The user selected locale.\n */\nexport function getImplementation({ getPreferences }: GetLocaleMethodHooks) {\n return async function implementation(\n _args: RestrictedMethodOptions<RestrictedMethodParameters>,\n ): Promise<GetLocaleResult> {\n return getPreferences().locale;\n };\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { PermissionSpecificationBuilder, ValidPermissionSpecification, RestrictedMethodOptions, RestrictedMethodParameters } from
|
|
2
|
-
import { PermissionType } from
|
|
3
|
-
import type { GetLocaleResult, GetPreferencesResult } from
|
|
4
|
-
import type { NonEmptyArray } from
|
|
5
|
-
import type { MethodHooksObject } from
|
|
1
|
+
import type { PermissionSpecificationBuilder, ValidPermissionSpecification, RestrictedMethodOptions, RestrictedMethodParameters } from "@metamask/permission-controller";
|
|
2
|
+
import { PermissionType } from "@metamask/permission-controller";
|
|
3
|
+
import type { GetLocaleResult, GetPreferencesResult } from "@metamask/snaps-sdk";
|
|
4
|
+
import type { NonEmptyArray } from "@metamask/utils";
|
|
5
|
+
import type { MethodHooksObject } from "../utils.cjs";
|
|
6
6
|
declare const methodName = "snap_getLocale";
|
|
7
7
|
export type GetLocaleMethodHooks = {
|
|
8
8
|
getPreferences: () => GetPreferencesResult;
|
|
@@ -47,3 +47,4 @@ export declare const getLocaleBuilder: Readonly<{
|
|
|
47
47
|
*/
|
|
48
48
|
export declare function getImplementation({ getPreferences }: GetLocaleMethodHooks): (_args: RestrictedMethodOptions<RestrictedMethodParameters>) => Promise<GetLocaleResult>;
|
|
49
49
|
export {};
|
|
50
|
+
//# sourceMappingURL=getLocale.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLocale.d.cts","sourceRoot":"","sources":["../../src/restricted/getLocale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8BAA8B,EAC9B,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,EAC3B,wCAAwC;AACzC,OAAO,EAAE,cAAc,EAAe,wCAAwC;AAC9E,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACrB,4BAA4B;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAErD,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AAElD,QAAA,MAAM,UAAU,mBAAmB,CAAC;AAEpC,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,MAAM,oBAAoB,CAAC;CAC5C,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,cAAc,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IACxD,WAAW,EAAE,oBAAoB,CAAC;CACnC,CAAC;AAEF,KAAK,aAAa,GAAG,4BAA4B,CAAC;IAChD,cAAc,EAAE,cAAc,CAAC,gBAAgB,CAAC;IAChD,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,oBAAoB,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAC3D,cAAc,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;CACxD,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,EAAE,8BAA8B,CAC/D,cAAc,CAAC,gBAAgB,EAC/B,2BAA2B,EAC3B,aAAa,CASd,CAAC;AAMF,eAAO,MAAM,gBAAgB;;;wBAlCX,eAAe,gBAAgB;oBACnC,iBAAiB;8BACP,WAAW,wBAAwB,CAAC;wBAC1C,SAAS,cAAc,MAAM,CAAC,CAAC,GAAG,IAAI;;;EAmC7C,CAAC;AAEZ;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,cAAc,EAAE,EAAE,oBAAoB,WAE/D,wBAAwB,0BAA0B,CAAC,KACzD,QAAQ,eAAe,CAAC,CAG5B"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { PermissionSpecificationBuilder, ValidPermissionSpecification, RestrictedMethodOptions, RestrictedMethodParameters } from "@metamask/permission-controller";
|
|
2
|
+
import { PermissionType } from "@metamask/permission-controller";
|
|
3
|
+
import type { GetLocaleResult, GetPreferencesResult } from "@metamask/snaps-sdk";
|
|
4
|
+
import type { NonEmptyArray } from "@metamask/utils";
|
|
5
|
+
import type { MethodHooksObject } from "../utils.mjs";
|
|
6
|
+
declare const methodName = "snap_getLocale";
|
|
7
|
+
export type GetLocaleMethodHooks = {
|
|
8
|
+
getPreferences: () => GetPreferencesResult;
|
|
9
|
+
};
|
|
10
|
+
type SpecificationBuilderOptions = {
|
|
11
|
+
allowedCaveats?: Readonly<NonEmptyArray<string>> | null;
|
|
12
|
+
methodHooks: GetLocaleMethodHooks;
|
|
13
|
+
};
|
|
14
|
+
type Specification = ValidPermissionSpecification<{
|
|
15
|
+
permissionType: PermissionType.RestrictedMethod;
|
|
16
|
+
targetName: typeof methodName;
|
|
17
|
+
methodImplementation: ReturnType<typeof getImplementation>;
|
|
18
|
+
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* The specification builder for the `snap_getLocale` permission.
|
|
22
|
+
* `snap_getLocale` allows snaps to get the user selected locale.
|
|
23
|
+
*
|
|
24
|
+
* @param options - The specification builder options.
|
|
25
|
+
* @param options.allowedCaveats - The optional allowed caveats for the permission.
|
|
26
|
+
* @param options.methodHooks - The RPC method hooks needed by the method implementation.
|
|
27
|
+
* @returns The specification for the `snap_getLocale` permission.
|
|
28
|
+
* @deprecated - To be removed in favor of `snap_getPreferences`.
|
|
29
|
+
*/
|
|
30
|
+
export declare const specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, SpecificationBuilderOptions, Specification>;
|
|
31
|
+
export declare const getLocaleBuilder: Readonly<{
|
|
32
|
+
readonly targetName: "snap_getLocale";
|
|
33
|
+
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, SpecificationBuilderOptions, {
|
|
34
|
+
permissionType: PermissionType.RestrictedMethod;
|
|
35
|
+
targetName: typeof methodName;
|
|
36
|
+
methodImplementation: ReturnType<typeof getImplementation>;
|
|
37
|
+
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
|
|
38
|
+
}>;
|
|
39
|
+
readonly methodHooks: MethodHooksObject<GetLocaleMethodHooks>;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Builds the method implementation for `snap_getLocale`.
|
|
43
|
+
*
|
|
44
|
+
* @param hooks - The RPC method hooks.
|
|
45
|
+
* @param hooks.getPreferences - A function that returns the user selected preferences.
|
|
46
|
+
* @returns The user selected locale.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getImplementation({ getPreferences }: GetLocaleMethodHooks): (_args: RestrictedMethodOptions<RestrictedMethodParameters>) => Promise<GetLocaleResult>;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=getLocale.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLocale.d.mts","sourceRoot":"","sources":["../../src/restricted/getLocale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8BAA8B,EAC9B,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,EAC3B,wCAAwC;AACzC,OAAO,EAAE,cAAc,EAAe,wCAAwC;AAC9E,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACrB,4BAA4B;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAErD,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AAElD,QAAA,MAAM,UAAU,mBAAmB,CAAC;AAEpC,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,MAAM,oBAAoB,CAAC;CAC5C,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,cAAc,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IACxD,WAAW,EAAE,oBAAoB,CAAC;CACnC,CAAC;AAEF,KAAK,aAAa,GAAG,4BAA4B,CAAC;IAChD,cAAc,EAAE,cAAc,CAAC,gBAAgB,CAAC;IAChD,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,oBAAoB,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAC3D,cAAc,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;CACxD,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,EAAE,8BAA8B,CAC/D,cAAc,CAAC,gBAAgB,EAC/B,2BAA2B,EAC3B,aAAa,CASd,CAAC;AAMF,eAAO,MAAM,gBAAgB;;;wBAlCX,eAAe,gBAAgB;oBACnC,iBAAiB;8BACP,WAAW,wBAAwB,CAAC;wBAC1C,SAAS,cAAc,MAAM,CAAC,CAAC,GAAG,IAAI;;;EAmC7C,CAAC;AAEZ;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,cAAc,EAAE,EAAE,oBAAoB,WAE/D,wBAAwB,0BAA0B,CAAC,KACzD,QAAQ,eAAe,CAAC,CAG5B"}
|
|
@@ -1,11 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { PermissionType, SubjectType } from "@metamask/permission-controller";
|
|
2
|
+
const methodName = 'snap_getLocale';
|
|
3
|
+
/**
|
|
4
|
+
* The specification builder for the `snap_getLocale` permission.
|
|
5
|
+
* `snap_getLocale` allows snaps to get the user selected locale.
|
|
6
|
+
*
|
|
7
|
+
* @param options - The specification builder options.
|
|
8
|
+
* @param options.allowedCaveats - The optional allowed caveats for the permission.
|
|
9
|
+
* @param options.methodHooks - The RPC method hooks needed by the method implementation.
|
|
10
|
+
* @returns The specification for the `snap_getLocale` permission.
|
|
11
|
+
* @deprecated - To be removed in favor of `snap_getPreferences`.
|
|
12
|
+
*/
|
|
13
|
+
export const specificationBuilder = ({ allowedCaveats = null, methodHooks }) => {
|
|
14
|
+
return {
|
|
15
|
+
permissionType: PermissionType.RestrictedMethod,
|
|
16
|
+
targetName: methodName,
|
|
17
|
+
allowedCaveats,
|
|
18
|
+
methodImplementation: getImplementation(methodHooks),
|
|
19
|
+
subjectTypes: [SubjectType.Snap],
|
|
20
|
+
};
|
|
10
21
|
};
|
|
22
|
+
const methodHooks = {
|
|
23
|
+
getPreferences: true,
|
|
24
|
+
};
|
|
25
|
+
export const getLocaleBuilder = Object.freeze({
|
|
26
|
+
targetName: methodName,
|
|
27
|
+
specificationBuilder,
|
|
28
|
+
methodHooks,
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Builds the method implementation for `snap_getLocale`.
|
|
32
|
+
*
|
|
33
|
+
* @param hooks - The RPC method hooks.
|
|
34
|
+
* @param hooks.getPreferences - A function that returns the user selected preferences.
|
|
35
|
+
* @returns The user selected locale.
|
|
36
|
+
*/
|
|
37
|
+
export function getImplementation({ getPreferences }) {
|
|
38
|
+
return async function implementation(_args) {
|
|
39
|
+
return getPreferences().locale;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
11
42
|
//# sourceMappingURL=getLocale.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"getLocale.mjs","sourceRoot":"","sources":["../../src/restricted/getLocale.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,wCAAwC;AAS9E,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAkBpC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAI7B,CAAC,EAAE,cAAc,GAAG,IAAI,EAAE,WAAW,EAA+B,EAAE,EAAE;IAC1E,OAAO;QACL,cAAc,EAAE,cAAc,CAAC,gBAAgB;QAC/C,UAAU,EAAE,UAAU;QACtB,cAAc;QACd,oBAAoB,EAAE,iBAAiB,CAAC,WAAW,CAAC;QACpD,YAAY,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,WAAW,GAA4C;IAC3D,cAAc,EAAE,IAAI;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,UAAU,EAAE,UAAU;IACtB,oBAAoB;IACpB,WAAW;CACH,CAAC,CAAC;AAEZ;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAE,cAAc,EAAwB;IACxE,OAAO,KAAK,UAAU,cAAc,CAClC,KAA0D;QAE1D,OAAO,cAAc,EAAE,CAAC,MAAM,CAAC;IACjC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type {\n PermissionSpecificationBuilder,\n ValidPermissionSpecification,\n RestrictedMethodOptions,\n RestrictedMethodParameters,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport type {\n GetLocaleResult,\n GetPreferencesResult,\n} from '@metamask/snaps-sdk';\nimport type { NonEmptyArray } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst methodName = 'snap_getLocale';\n\nexport type GetLocaleMethodHooks = {\n getPreferences: () => GetPreferencesResult;\n};\n\ntype SpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: GetLocaleMethodHooks;\n};\n\ntype Specification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof methodName;\n methodImplementation: ReturnType<typeof getImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * The specification builder for the `snap_getLocale` permission.\n * `snap_getLocale` allows snaps to get the user selected locale.\n *\n * @param options - The specification builder options.\n * @param options.allowedCaveats - The optional allowed caveats for the permission.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_getLocale` permission.\n * @deprecated - To be removed in favor of `snap_getPreferences`.\n */\nexport const specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n SpecificationBuilderOptions,\n Specification\n> = ({ allowedCaveats = null, methodHooks }: SpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: methodName,\n allowedCaveats,\n methodImplementation: getImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetLocaleMethodHooks> = {\n getPreferences: true,\n};\n\nexport const getLocaleBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getLocale`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getPreferences - A function that returns the user selected preferences.\n * @returns The user selected locale.\n */\nexport function getImplementation({ getPreferences }: GetLocaleMethodHooks) {\n return async function implementation(\n _args: RestrictedMethodOptions<RestrictedMethodParameters>,\n ): Promise<GetLocaleResult> {\n return getPreferences().locale;\n };\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getImplementation = exports.getPreferencesBuilder = exports.specificationBuilder = void 0;
|
|
4
|
+
const permission_controller_1 = require("@metamask/permission-controller");
|
|
5
|
+
const methodName = 'snap_getPreferences';
|
|
6
|
+
/**
|
|
7
|
+
* The specification builder for the `snap_getPreferences` permission.
|
|
8
|
+
* `snap_getPreferences` allows snaps to access user preferences.
|
|
9
|
+
*
|
|
10
|
+
* @param options - The specification builder options.
|
|
11
|
+
* @param options.allowedCaveats - The optional allowed caveats for the permission.
|
|
12
|
+
* @param options.methodHooks - The RPC method hooks needed by the method implementation.
|
|
13
|
+
* @returns The specification for the `snap_getPreferences` permission.
|
|
14
|
+
*/
|
|
15
|
+
const specificationBuilder = ({ allowedCaveats = null, methodHooks }) => {
|
|
16
|
+
return {
|
|
17
|
+
permissionType: permission_controller_1.PermissionType.RestrictedMethod,
|
|
18
|
+
targetName: methodName,
|
|
19
|
+
allowedCaveats,
|
|
20
|
+
methodImplementation: getImplementation(methodHooks),
|
|
21
|
+
subjectTypes: [permission_controller_1.SubjectType.Snap],
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.specificationBuilder = specificationBuilder;
|
|
25
|
+
const methodHooks = {
|
|
26
|
+
getPreferences: true,
|
|
27
|
+
};
|
|
28
|
+
exports.getPreferencesBuilder = Object.freeze({
|
|
29
|
+
targetName: methodName,
|
|
30
|
+
specificationBuilder: exports.specificationBuilder,
|
|
31
|
+
methodHooks,
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Builds the method implementation for `snap_getPreferences`.
|
|
35
|
+
*
|
|
36
|
+
* @param hooks - The RPC method hooks.
|
|
37
|
+
* @param hooks.getPreferences - A function that returns the user selected preferences.
|
|
38
|
+
* @returns The user preferences.
|
|
39
|
+
*/
|
|
40
|
+
function getImplementation({ getPreferences, }) {
|
|
41
|
+
return async function implementation(_args) {
|
|
42
|
+
return getPreferences();
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
exports.getImplementation = getImplementation;
|
|
46
|
+
//# sourceMappingURL=getPreferences.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPreferences.cjs","sourceRoot":"","sources":["../../src/restricted/getPreferences.ts"],"names":[],"mappings":";;;AAMA,2EAA8E;AAM9E,MAAM,UAAU,GAAG,qBAAqB,CAAC;AAkBzC;;;;;;;;GAQG;AACI,MAAM,oBAAoB,GAI7B,CAAC,EAAE,cAAc,GAAG,IAAI,EAAE,WAAW,EAA+B,EAAE,EAAE;IAC1E,OAAO;QACL,cAAc,EAAE,sCAAc,CAAC,gBAAgB;QAC/C,UAAU,EAAE,UAAU;QACtB,cAAc;QACd,oBAAoB,EAAE,iBAAiB,CAAC,WAAW,CAAC;QACpD,YAAY,EAAE,CAAC,mCAAW,CAAC,IAAI,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,oBAAoB,wBAY/B;AAEF,MAAM,WAAW,GAAiD;IAChE,cAAc,EAAE,IAAI;CACrB,CAAC;AAEW,QAAA,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC;IACjD,UAAU,EAAE,UAAU;IACtB,oBAAoB,EAApB,4BAAoB;IACpB,WAAW;CACH,CAAC,CAAC;AAEZ;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,EAChC,cAAc,GACY;IAC1B,OAAO,KAAK,UAAU,cAAc,CAClC,KAA0D;QAE1D,OAAO,cAAc,EAAE,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC;AARD,8CAQC","sourcesContent":["import type {\n PermissionSpecificationBuilder,\n ValidPermissionSpecification,\n RestrictedMethodOptions,\n RestrictedMethodParameters,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport type { GetPreferencesResult } from '@metamask/snaps-sdk';\nimport type { NonEmptyArray } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst methodName = 'snap_getPreferences';\n\nexport type GetPreferencesMethodHooks = {\n getPreferences: () => GetPreferencesResult;\n};\n\ntype SpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: GetPreferencesMethodHooks;\n};\n\ntype Specification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof methodName;\n methodImplementation: ReturnType<typeof getImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * The specification builder for the `snap_getPreferences` permission.\n * `snap_getPreferences` allows snaps to access user preferences.\n *\n * @param options - The specification builder options.\n * @param options.allowedCaveats - The optional allowed caveats for the permission.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_getPreferences` permission.\n */\nexport const specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n SpecificationBuilderOptions,\n Specification\n> = ({ allowedCaveats = null, methodHooks }: SpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: methodName,\n allowedCaveats,\n methodImplementation: getImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetPreferencesMethodHooks> = {\n getPreferences: true,\n};\n\nexport const getPreferencesBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getPreferences`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getPreferences - A function that returns the user selected preferences.\n * @returns The user preferences.\n */\nexport function getImplementation({\n getPreferences,\n}: GetPreferencesMethodHooks) {\n return async function implementation(\n _args: RestrictedMethodOptions<RestrictedMethodParameters>,\n ): Promise<GetPreferencesResult> {\n return getPreferences();\n };\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { PermissionSpecificationBuilder, ValidPermissionSpecification, RestrictedMethodOptions, RestrictedMethodParameters } from
|
|
2
|
-
import { PermissionType } from
|
|
3
|
-
import type { GetPreferencesResult } from
|
|
4
|
-
import type { NonEmptyArray } from
|
|
5
|
-
import type { MethodHooksObject } from
|
|
1
|
+
import type { PermissionSpecificationBuilder, ValidPermissionSpecification, RestrictedMethodOptions, RestrictedMethodParameters } from "@metamask/permission-controller";
|
|
2
|
+
import { PermissionType } from "@metamask/permission-controller";
|
|
3
|
+
import type { GetPreferencesResult } from "@metamask/snaps-sdk";
|
|
4
|
+
import type { NonEmptyArray } from "@metamask/utils";
|
|
5
|
+
import type { MethodHooksObject } from "../utils.cjs";
|
|
6
6
|
declare const methodName = "snap_getPreferences";
|
|
7
7
|
export type GetPreferencesMethodHooks = {
|
|
8
8
|
getPreferences: () => GetPreferencesResult;
|
|
@@ -46,3 +46,4 @@ export declare const getPreferencesBuilder: Readonly<{
|
|
|
46
46
|
*/
|
|
47
47
|
export declare function getImplementation({ getPreferences, }: GetPreferencesMethodHooks): (_args: RestrictedMethodOptions<RestrictedMethodParameters>) => Promise<GetPreferencesResult>;
|
|
48
48
|
export {};
|
|
49
|
+
//# sourceMappingURL=getPreferences.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPreferences.d.cts","sourceRoot":"","sources":["../../src/restricted/getPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8BAA8B,EAC9B,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,EAC3B,wCAAwC;AACzC,OAAO,EAAE,cAAc,EAAe,wCAAwC;AAC9E,OAAO,KAAK,EAAE,oBAAoB,EAAE,4BAA4B;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAErD,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AAElD,QAAA,MAAM,UAAU,wBAAwB,CAAC;AAEzC,MAAM,MAAM,yBAAyB,GAAG;IACtC,cAAc,EAAE,MAAM,oBAAoB,CAAC;CAC5C,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,cAAc,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IACxD,WAAW,EAAE,yBAAyB,CAAC;CACxC,CAAC;AAEF,KAAK,aAAa,GAAG,4BAA4B,CAAC;IAChD,cAAc,EAAE,cAAc,CAAC,gBAAgB,CAAC;IAChD,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,oBAAoB,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAC3D,cAAc,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;CACxD,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,EAAE,8BAA8B,CAC/D,cAAc,CAAC,gBAAgB,EAC/B,2BAA2B,EAC3B,aAAa,CASd,CAAC;AAMF,eAAO,MAAM,qBAAqB;;;wBAjChB,eAAe,gBAAgB;oBACnC,iBAAiB;8BACP,WAAW,wBAAwB,CAAC;wBAC1C,SAAS,cAAc,MAAM,CAAC,CAAC,GAAG,IAAI;;;EAkC7C,CAAC;AAEZ;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,cAAc,GACf,EAAE,yBAAyB,WAEjB,wBAAwB,0BAA0B,CAAC,KACzD,QAAQ,oBAAoB,CAAC,CAGjC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { PermissionSpecificationBuilder, ValidPermissionSpecification, RestrictedMethodOptions, RestrictedMethodParameters } from "@metamask/permission-controller";
|
|
2
|
+
import { PermissionType } from "@metamask/permission-controller";
|
|
3
|
+
import type { GetPreferencesResult } from "@metamask/snaps-sdk";
|
|
4
|
+
import type { NonEmptyArray } from "@metamask/utils";
|
|
5
|
+
import type { MethodHooksObject } from "../utils.mjs";
|
|
6
|
+
declare const methodName = "snap_getPreferences";
|
|
7
|
+
export type GetPreferencesMethodHooks = {
|
|
8
|
+
getPreferences: () => GetPreferencesResult;
|
|
9
|
+
};
|
|
10
|
+
type SpecificationBuilderOptions = {
|
|
11
|
+
allowedCaveats?: Readonly<NonEmptyArray<string>> | null;
|
|
12
|
+
methodHooks: GetPreferencesMethodHooks;
|
|
13
|
+
};
|
|
14
|
+
type Specification = ValidPermissionSpecification<{
|
|
15
|
+
permissionType: PermissionType.RestrictedMethod;
|
|
16
|
+
targetName: typeof methodName;
|
|
17
|
+
methodImplementation: ReturnType<typeof getImplementation>;
|
|
18
|
+
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* The specification builder for the `snap_getPreferences` permission.
|
|
22
|
+
* `snap_getPreferences` allows snaps to access user preferences.
|
|
23
|
+
*
|
|
24
|
+
* @param options - The specification builder options.
|
|
25
|
+
* @param options.allowedCaveats - The optional allowed caveats for the permission.
|
|
26
|
+
* @param options.methodHooks - The RPC method hooks needed by the method implementation.
|
|
27
|
+
* @returns The specification for the `snap_getPreferences` permission.
|
|
28
|
+
*/
|
|
29
|
+
export declare const specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, SpecificationBuilderOptions, Specification>;
|
|
30
|
+
export declare const getPreferencesBuilder: Readonly<{
|
|
31
|
+
readonly targetName: "snap_getPreferences";
|
|
32
|
+
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, SpecificationBuilderOptions, {
|
|
33
|
+
permissionType: PermissionType.RestrictedMethod;
|
|
34
|
+
targetName: typeof methodName;
|
|
35
|
+
methodImplementation: ReturnType<typeof getImplementation>;
|
|
36
|
+
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
|
|
37
|
+
}>;
|
|
38
|
+
readonly methodHooks: MethodHooksObject<GetPreferencesMethodHooks>;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Builds the method implementation for `snap_getPreferences`.
|
|
42
|
+
*
|
|
43
|
+
* @param hooks - The RPC method hooks.
|
|
44
|
+
* @param hooks.getPreferences - A function that returns the user selected preferences.
|
|
45
|
+
* @returns The user preferences.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getImplementation({ getPreferences, }: GetPreferencesMethodHooks): (_args: RestrictedMethodOptions<RestrictedMethodParameters>) => Promise<GetPreferencesResult>;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=getPreferences.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPreferences.d.mts","sourceRoot":"","sources":["../../src/restricted/getPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8BAA8B,EAC9B,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,EAC3B,wCAAwC;AACzC,OAAO,EAAE,cAAc,EAAe,wCAAwC;AAC9E,OAAO,KAAK,EAAE,oBAAoB,EAAE,4BAA4B;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,wBAAwB;AAErD,OAAO,KAAK,EAAE,iBAAiB,EAAE,qBAAiB;AAElD,QAAA,MAAM,UAAU,wBAAwB,CAAC;AAEzC,MAAM,MAAM,yBAAyB,GAAG;IACtC,cAAc,EAAE,MAAM,oBAAoB,CAAC;CAC5C,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,cAAc,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;IACxD,WAAW,EAAE,yBAAyB,CAAC;CACxC,CAAC;AAEF,KAAK,aAAa,GAAG,4BAA4B,CAAC;IAChD,cAAc,EAAE,cAAc,CAAC,gBAAgB,CAAC;IAChD,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,oBAAoB,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC;IAC3D,cAAc,EAAE,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC;CACxD,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,EAAE,8BAA8B,CAC/D,cAAc,CAAC,gBAAgB,EAC/B,2BAA2B,EAC3B,aAAa,CASd,CAAC;AAMF,eAAO,MAAM,qBAAqB;;;wBAjChB,eAAe,gBAAgB;oBACnC,iBAAiB;8BACP,WAAW,wBAAwB,CAAC;wBAC1C,SAAS,cAAc,MAAM,CAAC,CAAC,GAAG,IAAI;;;EAkC7C,CAAC;AAEZ;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,cAAc,GACf,EAAE,yBAAyB,WAEjB,wBAAwB,0BAA0B,CAAC,KACzD,QAAQ,oBAAoB,CAAC,CAGjC"}
|
|
@@ -1,11 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { PermissionType, SubjectType } from "@metamask/permission-controller";
|
|
2
|
+
const methodName = 'snap_getPreferences';
|
|
3
|
+
/**
|
|
4
|
+
* The specification builder for the `snap_getPreferences` permission.
|
|
5
|
+
* `snap_getPreferences` allows snaps to access user preferences.
|
|
6
|
+
*
|
|
7
|
+
* @param options - The specification builder options.
|
|
8
|
+
* @param options.allowedCaveats - The optional allowed caveats for the permission.
|
|
9
|
+
* @param options.methodHooks - The RPC method hooks needed by the method implementation.
|
|
10
|
+
* @returns The specification for the `snap_getPreferences` permission.
|
|
11
|
+
*/
|
|
12
|
+
export const specificationBuilder = ({ allowedCaveats = null, methodHooks }) => {
|
|
13
|
+
return {
|
|
14
|
+
permissionType: PermissionType.RestrictedMethod,
|
|
15
|
+
targetName: methodName,
|
|
16
|
+
allowedCaveats,
|
|
17
|
+
methodImplementation: getImplementation(methodHooks),
|
|
18
|
+
subjectTypes: [SubjectType.Snap],
|
|
19
|
+
};
|
|
10
20
|
};
|
|
21
|
+
const methodHooks = {
|
|
22
|
+
getPreferences: true,
|
|
23
|
+
};
|
|
24
|
+
export const getPreferencesBuilder = Object.freeze({
|
|
25
|
+
targetName: methodName,
|
|
26
|
+
specificationBuilder,
|
|
27
|
+
methodHooks,
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Builds the method implementation for `snap_getPreferences`.
|
|
31
|
+
*
|
|
32
|
+
* @param hooks - The RPC method hooks.
|
|
33
|
+
* @param hooks.getPreferences - A function that returns the user selected preferences.
|
|
34
|
+
* @returns The user preferences.
|
|
35
|
+
*/
|
|
36
|
+
export function getImplementation({ getPreferences, }) {
|
|
37
|
+
return async function implementation(_args) {
|
|
38
|
+
return getPreferences();
|
|
39
|
+
};
|
|
40
|
+
}
|
|
11
41
|
//# sourceMappingURL=getPreferences.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"getPreferences.mjs","sourceRoot":"","sources":["../../src/restricted/getPreferences.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,wCAAwC;AAM9E,MAAM,UAAU,GAAG,qBAAqB,CAAC;AAkBzC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAI7B,CAAC,EAAE,cAAc,GAAG,IAAI,EAAE,WAAW,EAA+B,EAAE,EAAE;IAC1E,OAAO;QACL,cAAc,EAAE,cAAc,CAAC,gBAAgB;QAC/C,UAAU,EAAE,UAAU;QACtB,cAAc;QACd,oBAAoB,EAAE,iBAAiB,CAAC,WAAW,CAAC;QACpD,YAAY,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;KACjC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,WAAW,GAAiD;IAChE,cAAc,EAAE,IAAI;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC;IACjD,UAAU,EAAE,UAAU;IACtB,oBAAoB;IACpB,WAAW;CACH,CAAC,CAAC;AAEZ;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,cAAc,GACY;IAC1B,OAAO,KAAK,UAAU,cAAc,CAClC,KAA0D;QAE1D,OAAO,cAAc,EAAE,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type {\n PermissionSpecificationBuilder,\n ValidPermissionSpecification,\n RestrictedMethodOptions,\n RestrictedMethodParameters,\n} from '@metamask/permission-controller';\nimport { PermissionType, SubjectType } from '@metamask/permission-controller';\nimport type { GetPreferencesResult } from '@metamask/snaps-sdk';\nimport type { NonEmptyArray } from '@metamask/utils';\n\nimport type { MethodHooksObject } from '../utils';\n\nconst methodName = 'snap_getPreferences';\n\nexport type GetPreferencesMethodHooks = {\n getPreferences: () => GetPreferencesResult;\n};\n\ntype SpecificationBuilderOptions = {\n allowedCaveats?: Readonly<NonEmptyArray<string>> | null;\n methodHooks: GetPreferencesMethodHooks;\n};\n\ntype Specification = ValidPermissionSpecification<{\n permissionType: PermissionType.RestrictedMethod;\n targetName: typeof methodName;\n methodImplementation: ReturnType<typeof getImplementation>;\n allowedCaveats: Readonly<NonEmptyArray<string>> | null;\n}>;\n\n/**\n * The specification builder for the `snap_getPreferences` permission.\n * `snap_getPreferences` allows snaps to access user preferences.\n *\n * @param options - The specification builder options.\n * @param options.allowedCaveats - The optional allowed caveats for the permission.\n * @param options.methodHooks - The RPC method hooks needed by the method implementation.\n * @returns The specification for the `snap_getPreferences` permission.\n */\nexport const specificationBuilder: PermissionSpecificationBuilder<\n PermissionType.RestrictedMethod,\n SpecificationBuilderOptions,\n Specification\n> = ({ allowedCaveats = null, methodHooks }: SpecificationBuilderOptions) => {\n return {\n permissionType: PermissionType.RestrictedMethod,\n targetName: methodName,\n allowedCaveats,\n methodImplementation: getImplementation(methodHooks),\n subjectTypes: [SubjectType.Snap],\n };\n};\n\nconst methodHooks: MethodHooksObject<GetPreferencesMethodHooks> = {\n getPreferences: true,\n};\n\nexport const getPreferencesBuilder = Object.freeze({\n targetName: methodName,\n specificationBuilder,\n methodHooks,\n} as const);\n\n/**\n * Builds the method implementation for `snap_getPreferences`.\n *\n * @param hooks - The RPC method hooks.\n * @param hooks.getPreferences - A function that returns the user selected preferences.\n * @returns The user preferences.\n */\nexport function getImplementation({\n getPreferences,\n}: GetPreferencesMethodHooks) {\n return async function implementation(\n _args: RestrictedMethodOptions<RestrictedMethodParameters>,\n ): Promise<GetPreferencesResult> {\n return getPreferences();\n };\n}\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
exports.DIALOG_APPROVAL_TYPES = exports.restrictedMethodPermissionBuilders = exports.getEncryptionEntropy = exports.WALLET_SNAP_PERMISSION_KEY = void 0;
|
|
18
|
+
const dialog_1 = require("./dialog.cjs");
|
|
19
|
+
const getBip32Entropy_1 = require("./getBip32Entropy.cjs");
|
|
20
|
+
const getBip32PublicKey_1 = require("./getBip32PublicKey.cjs");
|
|
21
|
+
const getBip44Entropy_1 = require("./getBip44Entropy.cjs");
|
|
22
|
+
const getEntropy_1 = require("./getEntropy.cjs");
|
|
23
|
+
const getLocale_1 = require("./getLocale.cjs");
|
|
24
|
+
const getPreferences_1 = require("./getPreferences.cjs");
|
|
25
|
+
const invokeSnap_1 = require("./invokeSnap.cjs");
|
|
26
|
+
const manageAccounts_1 = require("./manageAccounts.cjs");
|
|
27
|
+
const manageState_1 = require("./manageState.cjs");
|
|
28
|
+
const notify_1 = require("./notify.cjs");
|
|
29
|
+
var invokeSnap_2 = require("./invokeSnap.cjs");
|
|
30
|
+
Object.defineProperty(exports, "WALLET_SNAP_PERMISSION_KEY", { enumerable: true, get: function () { return invokeSnap_2.WALLET_SNAP_PERMISSION_KEY; } });
|
|
31
|
+
var manageState_2 = require("./manageState.cjs");
|
|
32
|
+
Object.defineProperty(exports, "getEncryptionEntropy", { enumerable: true, get: function () { return manageState_2.getEncryptionEntropy; } });
|
|
33
|
+
exports.restrictedMethodPermissionBuilders = {
|
|
34
|
+
[dialog_1.dialogBuilder.targetName]: dialog_1.dialogBuilder,
|
|
35
|
+
[getBip32Entropy_1.getBip32EntropyBuilder.targetName]: getBip32Entropy_1.getBip32EntropyBuilder,
|
|
36
|
+
[getBip32PublicKey_1.getBip32PublicKeyBuilder.targetName]: getBip32PublicKey_1.getBip32PublicKeyBuilder,
|
|
37
|
+
[getBip44Entropy_1.getBip44EntropyBuilder.targetName]: getBip44Entropy_1.getBip44EntropyBuilder,
|
|
38
|
+
[getEntropy_1.getEntropyBuilder.targetName]: getEntropy_1.getEntropyBuilder,
|
|
39
|
+
[invokeSnap_1.invokeSnapBuilder.targetName]: invokeSnap_1.invokeSnapBuilder,
|
|
40
|
+
[manageState_1.manageStateBuilder.targetName]: manageState_1.manageStateBuilder,
|
|
41
|
+
[notify_1.notifyBuilder.targetName]: notify_1.notifyBuilder,
|
|
42
|
+
[manageAccounts_1.manageAccountsBuilder.targetName]: manageAccounts_1.manageAccountsBuilder,
|
|
43
|
+
[getLocale_1.getLocaleBuilder.targetName]: getLocale_1.getLocaleBuilder,
|
|
44
|
+
[getPreferences_1.getPreferencesBuilder.targetName]: getPreferences_1.getPreferencesBuilder,
|
|
45
|
+
};
|
|
46
|
+
__exportStar(require("./caveats/index.cjs"), exports);
|
|
47
|
+
var dialog_2 = require("./dialog.cjs");
|
|
48
|
+
Object.defineProperty(exports, "DIALOG_APPROVAL_TYPES", { enumerable: true, get: function () { return dialog_2.DIALOG_APPROVAL_TYPES; } });
|
|
49
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/restricted/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,yCAAyC;AAEzC,2DAA2D;AAE3D,+DAA+D;AAE/D,2DAA2D;AAE3D,iDAAiD;AAEjD,+CAA+C;AAE/C,yDAAyD;AAEzD,iDAAiD;AAEjD,yDAAyD;AAEzD,mDAAmD;AAEnD,yCAAyC;AAEzC,+CAA0D;AAAjD,wHAAA,0BAA0B,OAAA;AACnC,iDAAqD;AAA5C,mHAAA,oBAAoB,OAAA;AAchB,QAAA,kCAAkC,GAAG;IAChD,CAAC,sBAAa,CAAC,UAAU,CAAC,EAAE,sBAAa;IACzC,CAAC,wCAAsB,CAAC,UAAU,CAAC,EAAE,wCAAsB;IAC3D,CAAC,4CAAwB,CAAC,UAAU,CAAC,EAAE,4CAAwB;IAC/D,CAAC,wCAAsB,CAAC,UAAU,CAAC,EAAE,wCAAsB;IAC3D,CAAC,8BAAiB,CAAC,UAAU,CAAC,EAAE,8BAAiB;IACjD,CAAC,8BAAiB,CAAC,UAAU,CAAC,EAAE,8BAAiB;IACjD,CAAC,gCAAkB,CAAC,UAAU,CAAC,EAAE,gCAAkB;IACnD,CAAC,sBAAa,CAAC,UAAU,CAAC,EAAE,sBAAa;IACzC,CAAC,sCAAqB,CAAC,UAAU,CAAC,EAAE,sCAAqB;IACzD,CAAC,4BAAgB,CAAC,UAAU,CAAC,EAAE,4BAAgB;IAC/C,CAAC,sCAAqB,CAAC,UAAU,CAAC,EAAE,sCAAqB;CACjD,CAAC;AAEX,sDAA0B;AAE1B,uCAAiD;AAAxC,+GAAA,qBAAqB,OAAA","sourcesContent":["import type { DialogMethodHooks } from './dialog';\nimport { dialogBuilder } from './dialog';\nimport type { GetBip32EntropyMethodHooks } from './getBip32Entropy';\nimport { getBip32EntropyBuilder } from './getBip32Entropy';\nimport type { GetBip32PublicKeyMethodHooks } from './getBip32PublicKey';\nimport { getBip32PublicKeyBuilder } from './getBip32PublicKey';\nimport type { GetBip44EntropyMethodHooks } from './getBip44Entropy';\nimport { getBip44EntropyBuilder } from './getBip44Entropy';\nimport type { GetEntropyHooks } from './getEntropy';\nimport { getEntropyBuilder } from './getEntropy';\nimport type { GetLocaleMethodHooks } from './getLocale';\nimport { getLocaleBuilder } from './getLocale';\nimport type { GetPreferencesMethodHooks } from './getPreferences';\nimport { getPreferencesBuilder } from './getPreferences';\nimport type { InvokeSnapMethodHooks } from './invokeSnap';\nimport { invokeSnapBuilder } from './invokeSnap';\nimport type { ManageAccountsMethodHooks } from './manageAccounts';\nimport { manageAccountsBuilder } from './manageAccounts';\nimport type { ManageStateMethodHooks } from './manageState';\nimport { manageStateBuilder } from './manageState';\nimport type { NotifyMethodHooks } from './notify';\nimport { notifyBuilder } from './notify';\n\nexport { WALLET_SNAP_PERMISSION_KEY } from './invokeSnap';\nexport { getEncryptionEntropy } from './manageState';\n\nexport type RestrictedMethodHooks = DialogMethodHooks &\n GetBip32EntropyMethodHooks &\n GetBip32PublicKeyMethodHooks &\n GetBip44EntropyMethodHooks &\n GetEntropyHooks &\n InvokeSnapMethodHooks &\n ManageStateMethodHooks &\n NotifyMethodHooks &\n ManageAccountsMethodHooks &\n GetLocaleMethodHooks &\n GetPreferencesMethodHooks;\n\nexport const restrictedMethodPermissionBuilders = {\n [dialogBuilder.targetName]: dialogBuilder,\n [getBip32EntropyBuilder.targetName]: getBip32EntropyBuilder,\n [getBip32PublicKeyBuilder.targetName]: getBip32PublicKeyBuilder,\n [getBip44EntropyBuilder.targetName]: getBip44EntropyBuilder,\n [getEntropyBuilder.targetName]: getEntropyBuilder,\n [invokeSnapBuilder.targetName]: invokeSnapBuilder,\n [manageStateBuilder.targetName]: manageStateBuilder,\n [notifyBuilder.targetName]: notifyBuilder,\n [manageAccountsBuilder.targetName]: manageAccountsBuilder,\n [getLocaleBuilder.targetName]: getLocaleBuilder,\n [getPreferencesBuilder.targetName]: getPreferencesBuilder,\n} as const;\n\nexport * from './caveats';\nexport type { DialogApprovalTypes } from './dialog';\nexport { DIALOG_APPROVAL_TYPES } from './dialog';\n"]}
|