1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-02 06:07:06 +01:00
metamask-extension/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-check-if-token-is-present.js
2023-06-02 18:40:58 +02:00

47 lines
1.6 KiB
JavaScript

import { MESSAGE_TYPE } from '../../../../../../shared/constants/app';
const mmiAuthenticate = {
methodNames: [MESSAGE_TYPE.MMI_CHECK_IF_TOKEN_IS_PRESENT],
implementation: mmiCheckIfTokenIsPresentHandler,
hookNames: {
handleMmiCheckIfTokenIsPresent: true,
},
};
export default mmiAuthenticate;
/**
* @typedef {object} MmiAuthenticateOptions
* @property {Function} handleMmiCheckIfTokenIsPresent - The metamaskinstitutional_checkIfTokenIsPresent method implementation.
*/
/**
* @typedef {object} MmiCheckIfTokenIsPresentParam
* @property {string} service - The service to which we are authenticating, e.g. 'codefi-compliance'
* @property {object} environment - The environment in which we are authenticating, e.g. 'saturn-dev'
* @property {apiUrl} apiUrl - The API URL to which we are authenticating, e.g. 'https://saturn-custody.codefi.network/eth'
* @property {object} token - The token used to authenticate
*/
/**
* @param {import('json-rpc-engine').JsonRpcRequest<MmiCheckIfTokenIsPresentParam>} req - The JSON-RPC request object.
* @param {import('json-rpc-engine').JsonRpcResponse<true>} res - The JSON-RPC response object.
* @param {Function} _next - The json-rpc-engine 'next' callback.
* @param {Function} end - The json-rpc-engine 'end' callback.
* @param options0
* @param options0.handleMmiCheckIfTokenIsPresent
*/
async function mmiCheckIfTokenIsPresentHandler(
req,
res,
_next,
end,
{ handleMmiCheckIfTokenIsPresent },
) {
try {
res.result = await handleMmiCheckIfTokenIsPresent(req);
return end();
} catch (error) {
return end(error);
}
}