{"version":3,"file":"signature.cjs","sourceRoot":"","sources":["../../../src/types/handlers/signature.ts"],"names":[],"mappings":"","sourcesContent":["import type { SeverityLevel } from './transaction';\nimport type { EnumToUnion } from '../../internals';\nimport type { Component } from '../../ui';\n\n/**\n * A personal_sign signature object.\n *\n * @property from - The address the signature is being sent from.\n * @property data - The data (hex string) that is being signed.\n * @property signatureMethod - The signature method, which in this case is personal_sign\n */\nexport type PersonalSignature = {\n  from: string;\n  data: string;\n  signatureMethod: 'personal_sign';\n};\n\n/**\n * An eth_signTypedData signature object.\n *\n * @property from - The address the signature is being sent from.\n * @property data - The data that is being signed.\n * @property signatureMethod - The signature method, which in this case is eth_signTypedData\n */\nexport type SignTypedDataSignature = {\n  from: string;\n  data: Record<string, any>[];\n  signatureMethod: 'eth_signTypedData';\n};\n\n/**\n * An eth_signTypedData_v3 signature object.\n *\n * @property from - The address the signature is being sent from.\n * @property data - The data that is being signed.\n * @property signatureMethod - The signature method, which in this case is eth_signTypedData_v3\n */\nexport type SignTypedDataV3Signature = {\n  from: string;\n  data: Record<string, any>;\n  signatureMethod: 'eth_signTypedData_v3';\n};\n\n/**\n * An eth_signTypedData_v4 signature object.\n *\n * @property from - The address the signature is being sent from.\n * @property data - The data that is being signed.\n * @property signatureMethod - The signature method, which in this case is eth_signTypedData_v4\n */\nexport type SignTypedDataV4Signature = {\n  from: string;\n  data: Record<string, any>;\n  signatureMethod: 'eth_signTypedData_v4';\n};\n\n/**\n * A signature object. This can be one of the below signature methods.\n *\n * @see PersonalSignature\n * @see SignTypedDataSignature\n * @see SignTypedDataV3Signature\n * @see SignTypedDataV4Signature\n */\nexport type Signature =\n  | PersonalSignature\n  | SignTypedDataSignature\n  | SignTypedDataV3Signature\n  | SignTypedDataV4Signature;\n\n/**\n * The `onSignature` handler. This is called whenever a signature is\n * submitted to the snap. It can return insights about the signature, which\n * will be displayed to the user.\n *\n * Note that using this handler requires the `endowment:signature-insight`\n * permission.\n *\n * @param args - The request arguments.\n * @param args.signature - The signature object that contains the from address,\n * data and signature method.\n * @param args.signatureOrigin - The origin of the signature. This is the\n * URL of the website that submitted the signature. This is only available if\n * the Snap has enabled the `allowSignatureOrigin` option in the\n * `endowment:signature-insight` permission.\n * @returns An object containing insights about the signature. See\n * {@link OnSignatureResponse}. Can also return `null` if no insights are\n * available.\n */\nexport type OnSignatureHandler = (args: {\n  signature: Signature;\n  signatureOrigin?: string;\n}) => Promise<OnSignatureResponse | null>;\n\n/**\n * The response from a Snap's `onSignature` handler.\n *\n * @property component - A custom UI component, that will be shown in MetaMask.\n * @property id - A Snap interface ID.\n * @property severity - The severity level of the content. Currently only one\n * level is supported: `critical`.\n */\nexport type OnSignatureResponse =\n  | {\n      content: Component;\n      severity?: EnumToUnion<SeverityLevel>;\n    }\n  | {\n      id: string;\n      severity?: EnumToUnion<SeverityLevel>;\n    };\n"]}