{"version":3,"file":"response.cjs","sourceRoot":"","sources":["../../src/api/response.ts"],"names":[],"mappings":";;;AAAA,2DAAgE;AAEhE,uDAA+D;AAC/D,2CAA6C;AAEhC,QAAA,qBAAqB,GAAG,IAAA,mBAAK,EAAC;IACzC,IAAA,sBAAM,EAAC;QACL;;;;;;WAMG;QACH,OAAO,EAAE,IAAA,qBAAO,EAAC,IAAI,CAAC;QAEtB;;;;;;WAMG;QACH,QAAQ,EAAE,IAAA,6BAAa,EACrB,IAAA,sBAAM,EAAC;YACL,OAAO,EAAE,IAAA,6BAAa,EAAC,IAAA,oBAAM,GAAE,CAAC;YAChC,GAAG,EAAE,IAAA,6BAAa,EAAC,IAAA,oBAAM,GAAE,CAAC;SAC7B,CAAC,CACH;KACF,CAAC;IACF,IAAA,sBAAM,EAAC;QACL;;;;;;WAMG;QACH,OAAO,EAAE,IAAA,qBAAO,EAAC,KAAK,CAAC;QAEvB;;WAEG;QACH,MAAM,EAAE,kBAAU;KACnB,CAAC;CACH,CAAC,CAAC","sourcesContent":["import { exactOptional, object } from '@metamask/keyring-utils';\nimport type { Infer } from '@metamask/superstruct';\nimport { literal, string, union } from '@metamask/superstruct';\nimport { JsonStruct } from '@metamask/utils';\n\nexport const KeyringResponseStruct = union([\n  object({\n    /**\n     * Pending flag.\n     *\n     * Setting the pending flag to true indicates that the request will be\n     * handled asynchronously. The keyring must be called with `approveRequest`\n     * or `rejectRequest` to resolve the request.\n     */\n    pending: literal(true),\n\n    /**\n     * Redirect URL.\n     *\n     * If present in the response, MetaMask will display a confirmation dialog\n     * with a link to the redirect URL. The user can choose to follow the link\n     * or cancel the request.\n     */\n    redirect: exactOptional(\n      object({\n        message: exactOptional(string()),\n        url: exactOptional(string()),\n      }),\n    ),\n  }),\n  object({\n    /**\n     * Pending flag.\n     *\n     * Setting the pending flag to false indicates that the request will be\n     * handled synchronously. The keyring must return the result of the\n     * request execution.\n     */\n    pending: literal(false),\n\n    /**\n     * Request result.\n     */\n    result: JsonStruct,\n  }),\n]);\n\n/**\n * Response to a call to `submitRequest`.\n *\n * Keyring implementations must return a response with `pending: true` if the\n * request will be handled asynchronously. Otherwise, the response must contain\n * the result of the request and `pending: false`.\n *\n * In the asynchronous case, the keyring can return a redirect URL and message\n * to be shown to the user. The user can choose to follow the link or cancel\n * the request. The main use case for this is to redirect the user to the snap\n * dapp to review the request.\n */\nexport type KeyringResponse = Infer<typeof KeyringResponseStruct>;\n"]}