UNPKG

@metamask/snaps-rpc-methods

Version:
39 lines 2.08 kB
import type { CaveatSpecificationConstraint, EndowmentGetterParams, PermissionConstraint, PermissionSpecificationBuilder, PermissionValidatorConstraint } from "@metamask/permission-controller"; import { PermissionType, SubjectType } from "@metamask/permission-controller"; import { ProtocolScopesStruct, SnapCaveatType } from "@metamask/snaps-utils"; import type { Infer } from "@metamask/superstruct"; import type { Json, NonEmptyArray } from "@metamask/utils"; import { SnapEndowments } from "./enum.mjs"; declare const permissionName = SnapEndowments.Protocol; export declare const protocolEndowmentBuilder: Readonly<{ readonly targetName: SnapEndowments.Protocol; 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 getProtocolCaveatMapper(value: Json): Pick<PermissionConstraint, 'caveats'>; export type ProtocolScopes = Infer<typeof ProtocolScopesStruct>; /** * Getter function to get the {@link ProtocolSnapScopes} caveat value from a * permission. * * @param permission - The permission to get the caveat value from. * @returns The caveat value. */ export declare function getProtocolCaveatScopes(permission?: PermissionConstraint): ProtocolScopes | null; export declare const protocolCaveatSpecifications: Record<SnapCaveatType.ProtocolSnapScopes, CaveatSpecificationConstraint>; export {}; //# sourceMappingURL=protocol.d.mts.map