@metamask/snaps-rpc-methods
Version:
MetaMask Snaps JSON-RPC method implementations
47 lines • 2.44 kB
text/typescript
import type { CaveatSpecificationConstraint, EndowmentGetterParams, PermissionConstraint, PermissionSpecificationBuilder, PermissionValidatorConstraint } from "@metamask/permission-controller";
import { PermissionType, SubjectType } from "@metamask/permission-controller";
import type { KeyringCapabilities, KeyringOrigins } from "@metamask/snaps-utils";
import { SnapCaveatType } from "@metamask/snaps-utils";
import type { Json, NonEmptyArray } from "@metamask/utils";
import { SnapEndowments } from "./enum.cjs";
declare const permissionName = SnapEndowments.Keyring;
export declare const keyringEndowmentBuilder: Readonly<{
readonly targetName: SnapEndowments.Keyring;
readonly specificationBuilder: PermissionSpecificationBuilder<PermissionType.Endowment, any, {
permissionType: PermissionType.Endowment;
targetName: typeof permissionName;
endowmentGetter: (_options?: EndowmentGetterParams) => null;
allowedCaveats: Readonly<NonEmptyArray<string>> | null;
validator: PermissionValidatorConstraint;
subjectTypes: readonly SubjectType[];
}>;
}>;
/**
* Map a raw value from the `initialPermissions` to a caveat specification.
* Note that this function does not do any validation, that's handled by the
* PermissionsController when the permission is requested.
*
* @param value - The raw value from the `initialPermissions`.
* @returns The caveat specification.
*/
export declare function getKeyringCaveatMapper(value: Json): Pick<PermissionConstraint, 'caveats'>;
/**
* Getter function to get the {@link KeyringOrigins} caveat value from a
* permission.
*
* @param permission - The permission to get the caveat value from.
* @returns The caveat value.
*/
export declare function getKeyringCaveatOrigins(permission?: PermissionConstraint): KeyringOrigins;
/**
* Getter function to get the {@link KeyringCapabilities} caveat value from a
* permission.
*
* @param permission - The permission to get the caveat value from.
* @returns The caveat value, or `null` if the permission does not have a
* {@link KeyringCapabilities} caveat.
*/
export declare function getKeyringCaveatCapabilities(permission?: PermissionConstraint): KeyringCapabilities | null;
export declare const keyringCaveatSpecifications: Record<SnapCaveatType.KeyringOrigin | SnapCaveatType.KeyringCapabilities, CaveatSpecificationConstraint>;
export {};
//# sourceMappingURL=keyring.d.cts.map