UNPKG

@metamask/snaps-rpc-methods

Version:
80 lines 3.78 kB
import type { CryptographicFunctions } from "@metamask/key-tree"; import type { PermissionSpecificationBuilder, RestrictedMethodOptions } from "@metamask/permission-controller"; import { PermissionType } from "@metamask/permission-controller"; import type { GetEntropyParams, GetEntropyResult } from "@metamask/snaps-sdk"; import type { Infer } from "@metamask/superstruct"; import type { NonEmptyArray } from "@metamask/utils"; import type { MethodHooksObject } from "../utils.mjs"; declare const targetName = "snap_getEntropy"; type GetEntropySpecificationBuilderOptions = { allowedCaveats?: Readonly<NonEmptyArray<string>> | null; methodHooks: GetEntropyHooks; }; export declare const GetEntropyArgsStruct: import("@metamask/superstruct").Struct<{ version: 1; salt?: string | undefined; source?: string | undefined; }, { version: import("@metamask/superstruct").Struct<1, 1>; salt: import("@metamask/superstruct").Struct<string | undefined, null>; source: import("@metamask/superstruct").Struct<string | undefined, null>; }>; /** * @property version - The version of the `snap_getEntropy` method. This must be * the numeric literal `1`. * @property salt - A string to use as the salt when deriving the entropy. If * omitted, the salt will be an empty string. */ export type GetEntropyArgs = Infer<typeof GetEntropyArgsStruct>; export declare const getEntropyBuilder: Readonly<{ readonly targetName: "snap_getEntropy"; readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.RestrictedMethod, GetEntropySpecificationBuilderOptions, { permissionType: PermissionType.RestrictedMethod; targetName: typeof targetName; methodImplementation: ReturnType<typeof getEntropyImplementation>; allowedCaveats: Readonly<NonEmptyArray<string>> | null; }>; readonly methodHooks: MethodHooksObject<GetEntropyHooks>; }>; export type GetEntropyHooks = { /** * Get the mnemonic seed of the provided source. If no source is provided, the * mnemonic seed of the primary keyring will be returned. * * @param source - The optional ID of the source to get the mnemonic of. * @returns The mnemonic seed of the provided source, or the default source if no * source is provided. */ getMnemonicSeed: (source?: string | undefined) => Promise<Uint8Array>; /** * Waits for the extension to be unlocked. * * @returns A promise that resolves once the extension is unlocked. */ getUnlockPromise: (shouldShowUnlockRequest: boolean) => Promise<void>; /** * Get the cryptographic functions to use for the client. This may return an * empty object or `undefined` to fall back to the default cryptographic * functions. * * @returns The cryptographic functions to use for the client. */ getClientCryptography: () => CryptographicFunctions | undefined; }; /** * Builds the method implementation for `snap_getEntropy`. The implementation * is based on the reference implementation of * [SIP-6](https://metamask.github.io/SIPs/SIPS/sip-6). * * @param hooks - The RPC method hooks. * @param hooks.getMnemonicSeed - A function to retrieve the BIP-39 seed * of the user. * @param hooks.getUnlockPromise - The method to get a promise that resolves * once the extension is unlocked. * @param hooks.getClientCryptography - A function to retrieve the cryptographic * functions to use for the client. * @returns The method implementation. */ declare function getEntropyImplementation({ getMnemonicSeed, getUnlockPromise, getClientCryptography, }: GetEntropyHooks): (options: RestrictedMethodOptions<GetEntropyParams>) => Promise<GetEntropyResult>; export {}; //# sourceMappingURL=getEntropy.d.mts.map