@metamask-previews/multichain-api-middleware 2.0.0-preview-45a82ea8e → 2.0.0-preview-d8ff44d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/CHANGELOG.md +1 -4
  2. package/dist/handlers/wallet-createSession.cjs +4 -6
  3. package/dist/handlers/wallet-createSession.cjs.map +1 -1
  4. package/dist/handlers/wallet-createSession.d.cts +27 -44
  5. package/dist/handlers/wallet-createSession.d.cts.map +1 -1
  6. package/dist/handlers/wallet-createSession.d.mts +27 -44
  7. package/dist/handlers/wallet-createSession.d.mts.map +1 -1
  8. package/dist/handlers/wallet-createSession.mjs +3 -5
  9. package/dist/handlers/wallet-createSession.mjs.map +1 -1
  10. package/dist/handlers/wallet-getSession.cjs +4 -6
  11. package/dist/handlers/wallet-getSession.cjs.map +1 -1
  12. package/dist/handlers/wallet-getSession.d.cts +15 -26
  13. package/dist/handlers/wallet-getSession.d.cts.map +1 -1
  14. package/dist/handlers/wallet-getSession.d.mts +15 -26
  15. package/dist/handlers/wallet-getSession.d.mts.map +1 -1
  16. package/dist/handlers/wallet-getSession.mjs +3 -5
  17. package/dist/handlers/wallet-getSession.mjs.map +1 -1
  18. package/dist/handlers/wallet-invokeMethod.cjs +4 -9
  19. package/dist/handlers/wallet-invokeMethod.cjs.map +1 -1
  20. package/dist/handlers/wallet-invokeMethod.d.cts +25 -39
  21. package/dist/handlers/wallet-invokeMethod.d.cts.map +1 -1
  22. package/dist/handlers/wallet-invokeMethod.d.mts +25 -39
  23. package/dist/handlers/wallet-invokeMethod.d.mts.map +1 -1
  24. package/dist/handlers/wallet-invokeMethod.mjs +4 -9
  25. package/dist/handlers/wallet-invokeMethod.mjs.map +1 -1
  26. package/dist/handlers/wallet-revokeSession.cjs +4 -6
  27. package/dist/handlers/wallet-revokeSession.cjs.map +1 -1
  28. package/dist/handlers/wallet-revokeSession.d.cts +12 -21
  29. package/dist/handlers/wallet-revokeSession.d.cts.map +1 -1
  30. package/dist/handlers/wallet-revokeSession.d.mts +12 -21
  31. package/dist/handlers/wallet-revokeSession.d.mts.map +1 -1
  32. package/dist/handlers/wallet-revokeSession.mjs +3 -5
  33. package/dist/handlers/wallet-revokeSession.mjs.map +1 -1
  34. package/dist/index.cjs +9 -3
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +4 -1
  37. package/dist/index.d.cts.map +1 -1
  38. package/dist/index.d.mts +4 -1
  39. package/dist/index.d.mts.map +1 -1
  40. package/dist/index.mjs +4 -1
  41. package/dist/index.mjs.map +1 -1
  42. package/package.json +2 -2
  43. package/dist/handlers/index.cjs +0 -14
  44. package/dist/handlers/index.cjs.map +0 -1
  45. package/dist/handlers/index.d.cts +0 -8
  46. package/dist/handlers/index.d.cts.map +0 -1
  47. package/dist/handlers/index.d.mts +0 -8
  48. package/dist/handlers/index.d.mts.map +0 -1
  49. package/dist/handlers/index.mjs +0 -11
  50. package/dist/handlers/index.mjs.map +0 -1
@@ -70,7 +70,7 @@ function partialRevokePermissions(scopes, hooks) {
70
70
  * @param hooks.getCaveatForOrigin - The hook to fetch an existing caveat for the origin of the request.
71
71
  * @returns Nothing.
72
72
  */
73
- async function handleWalletRevokeSession(request, response, _next, end, hooks) {
73
+ async function walletRevokeSessionHandler(request, response, _next, end, hooks) {
74
74
  try {
75
75
  if (request.params?.scopes?.length) {
76
76
  partialRevokePermissions(request.params.scopes, hooks);
@@ -89,14 +89,12 @@ async function handleWalletRevokeSession(request, response, _next, end, hooks) {
89
89
  return end();
90
90
  }
91
91
  export const walletRevokeSession = {
92
- implementation: handleWalletRevokeSession,
92
+ methodNames: ['wallet_revokeSession'],
93
+ implementation: walletRevokeSessionHandler,
93
94
  hookNames: {
94
95
  revokePermissionForOrigin: true,
95
96
  updateCaveat: true,
96
97
  getCaveatForOrigin: true,
97
98
  },
98
99
  };
99
- export const walletRevokeSessionHandler = {
100
- wallet_revokeSession: walletRevokeSession,
101
- };
102
100
  //# sourceMappingURL=wallet-revokeSession.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"wallet-revokeSession.mjs","sourceRoot":"","sources":["../../src/handlers/wallet-revokeSession.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,6BAA6B,EAC7B,sCAAsC,EACvC,4CAA4C;AAM7C,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC3B,wBAAwB,EACzB,wCAAwC;AACzC,OAAO,EAAE,SAAS,EAAE,6BAA6B;AACjD,OAAO,EAAE,QAAQ,EAAE,wBAAwB;AAW3C;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,KAAc;IACvC,IACE,CAAC,QAAQ,CAAC,KAAK,CAAC;QAChB,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC;QAClB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAC9B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO;QACL,wBAAwB,CAAC,IAAI;QAC7B,2BAA2B,CAAC,IAAI;KACjC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,wBAAwB,CAC/B,MAAgB,EAChB,KAA+B;IAE/B,IAAI,kBAAkB,GAAG,KAAK,CAAC,kBAAkB,CAC/C,6BAA6B,EAC7B,gBAAgB,CACjB,CAAC,KAAK,CAAC;IAER,KAAK,MAAM,WAAW,IAAI,MAAM,EAAE,CAAC;QACjC,MAAM,MAAM,GAAG,oBAAoB,CAAC,gBAAgB,CAAC,CAAC,WAAW,CAC/D,kBAAkB,EAClB,WAAW,CACZ,CAAC;QAEF,0HAA0H;QAC1H,IAAI,MAAM,CAAC,SAAS,KAAK,sBAAsB,CAAC,IAAI,EAAE,CAAC;YACrD,SAAS;QACX,CAAC;QAED,kBAAkB,GAAG,MAAM,EAAE,KAAK,IAAI;YACpC,cAAc,EAAE,EAAE;YAClB,cAAc,EAA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ACzB;CACyC,CAAC;AAE7C,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,oBAAoB,EAAE,mBAAmB;CAC1C,CAAC","sourcesContent":["import {\n Caip25CaveatMutators,\n Caip25CaveatType,\n Caip25EndowmentPermissionName,\n getCaipAccountIdsFromCaip25CaveatValue,\n} from '@metamask/chain-agnostic-permission';\nimport type {\n JsonRpcEngineEndCallback,\n JsonRpcEngineNextCallback,\n MethodHandler,\n} from '@metamask/json-rpc-engine';\nimport {\n CaveatMutatorOperation,\n PermissionDoesNotExistError,\n UnrecognizedSubjectError,\n} from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport { isObject } from '@metamask/utils';\nimport type {\n Json,\n JsonRpcRequest,\n PendingJsonRpcResponse,\n} from '@metamask/utils';\n\nimport type { WalletRevokeSessionHooks } from './types';\n\ntype WalletRevokeSessionParams = { scopes?: string[] };\n\n/**\n * Check whether the given error is a permission error.\n *\n * @param error - The error to check.\n * @returns Whether the error is a permission error.\n */\nfunction isPermissionError(error: unknown) {\n if (\n !isObject(error) ||\n !('name' in error) ||\n typeof error.name !== 'string'\n ) {\n return false;\n }\n\n return [\n UnrecognizedSubjectError.name,\n PermissionDoesNotExistError.name,\n ].includes(error.name);\n}\n\n/**\n * Revokes specific session scopes from an existing caveat.\n * Fully revokes permission if no accounts remain permitted after iterating through scopes.\n *\n * @param scopes - Array of scope strings to remove from the caveat.\n * @param hooks - The hooks object.\n * @param hooks.revokePermissionForOrigin - The hook for revoking a permission for an origin function.\n * @param hooks.updateCaveat - The hook used to conditionally update the caveat rather than fully revoke the permission.\n * @param hooks.getCaveatForOrigin - The hook to fetch an existing caveat for the origin of the request.\n */\nfunction partialRevokePermissions(\n scopes: string[],\n hooks: WalletRevokeSessionHooks,\n) {\n let updatedCaveatValue = hooks.getCaveatForOrigin(\n Caip25EndowmentPermissionName,\n Caip25CaveatType,\n ).value;\n\n for (const scopeString of scopes) {\n const result = Caip25CaveatMutators[Caip25CaveatType].removeScope(\n updatedCaveatValue,\n scopeString,\n );\n\n // If operation is a Noop, it means a scope was passed that was not present in the permission, so we proceed with the loop\n if (result.operation === CaveatMutatorOperation.Noop) {\n continue;\n }\n\n updatedCaveatValue = result?.value ?? {\n requiredScopes: {},\n optionalScopes: {},\n sessionProperties: {},\n isMultichainOrigin: true,\n };\n }\n\n const caipAccountIds =\n getCaipAccountIdsFromCaip25CaveatValue(updatedCaveatValue);\n\n // We fully revoke permission if no accounts are left after scope removal loop.\n if (!caipAccountIds.length) {\n hooks.revokePermissionForOrigin(Caip25EndowmentPermissionName);\n } else {\n hooks.updateCaveat(\n Caip25EndowmentPermissionName,\n Caip25CaveatType,\n updatedCaveatValue,\n );\n }\n}\n\n/**\n * Handler for the `wallet_revokeSession` RPC method as specified by [CAIP-285](https://chainagnostic.org/CAIPs/caip-285).\n * The implementation below deviates from the linked spec in that it ignores the `sessionId` param\n * and instead revokes the singular session for the origin if available. Additionally,\n * the handler also does not return an error if there is currently no active session and instead\n * returns true which is the same result returned if an active session was actually revoked.\n *\n * @param request - The JSON-RPC request object. Unused.\n * @param response - The JSON-RPC response object.\n * @param _next - The next middleware function. Unused.\n * @param end - The end callback function.\n * @param hooks - The hooks object.\n * @param hooks.revokePermissionForOrigin - The hook for revoking a permission for an origin function.\n * @param hooks.updateCaveat - The hook used to conditionally update the caveat rather than fully revoke the permission.\n * @param hooks.getCaveatForOrigin - The hook to fetch an existing caveat for the origin of the request.\n * @returns Nothing.\n */\nasync function handleWalletRevokeSession(\n request: JsonRpcRequest<WalletRevokeSessionParams> & { origin: string },\n response: PendingJsonRpcResponse<Json>,\n _next: JsonRpcEngineNextCallback,\n end: JsonRpcEngineEndCallback,\n hooks: WalletRevokeSessionHooks,\n) {\n try {\n if (request.params?.scopes?.length) {\n partialRevokePermissions(request.params.scopes, hooks);\n } else {\n hooks.revokePermissionForOrigin(Caip25EndowmentPermissionName);\n }\n } catch (err) {\n if (!isPermissionError(err)) {\n console.error(err);\n return end(rpcErrors.internal());\n }\n }\n\n response.result = true;\n return end();\n}\n\ntype WalletRevokeSessionMethodHandler = MethodHandler<\n WalletRevokeSessionHooks,\n never,\n WalletRevokeSessionParams,\n Json,\n { origin: string }\n>;\n\nexport const walletRevokeSession = {\n implementation: handleWalletRevokeSession,\n hookNames: {\n revokePermissionForOrigin: true,\n updateCaveat: true,\n getCaveatForOrigin: true,\n },\n} satisfies WalletRevokeSessionMethodHandler;\n\nexport const walletRevokeSessionHandler = {\n wallet_revokeSession: walletRevokeSession,\n};\n"]}
1
+ {"version":3,"file":"wallet-revokeSession.mjs","sourceRoot":"","sources":["../../src/handlers/wallet-revokeSession.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,6BAA6B,EAC7B,sCAAsC,EACvC,4CAA4C;AAK7C,OAAO,EACL,sBAAsB,EACtB,2BAA2B,EAC3B,wBAAwB,EACzB,wCAAwC;AACzC,OAAO,EAAE,SAAS,EAAE,6BAA6B;AACjD,OAAO,EAAE,QAAQ,EAAE,wBAAwB;AAK3C;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,KAAc;IACvC,IACE,CAAC,QAAQ,CAAC,KAAK,CAAC;QAChB,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC;QAClB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAC9B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO;QACL,wBAAwB,CAAC,IAAI;QAC7B,2BAA2B,CAAC,IAAI;KACjC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,wBAAwB,CAC/B,MAAgB,EAChB,KAA+B;IAE/B,IAAI,kBAAkB,GAAG,KAAK,CAAC,kBAAkB,CAC/C,6BAA6B,EAC7B,gBAAgB,CACjB,CAAC,KAAK,CAAC;IAER,KAAK,MAAM,WAAW,IAAI,MAAM,EAAE,CAAC;QACjC,M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EAAE,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,OAAO,GAAG,EAAE,CAAC;AACf,CAAC;AACD,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,WAAW,EAAE,CAAC,sBAAsB,CAAC;IACrC,cAAc,EAAE,0BAA0B;IAC1C,SAAS,EAAE;QACT,yBAAyB,EAAE,IAAI;QAC/B,YAAY,EAAE,IAAI;QAClB,kBAAkB,EAAE,IAAI;KACzB;CACF,CAAC","sourcesContent":["import {\n Caip25CaveatMutators,\n Caip25CaveatType,\n Caip25EndowmentPermissionName,\n getCaipAccountIdsFromCaip25CaveatValue,\n} from '@metamask/chain-agnostic-permission';\nimport type {\n JsonRpcEngineNextCallback,\n JsonRpcEngineEndCallback,\n} from '@metamask/json-rpc-engine';\nimport {\n CaveatMutatorOperation,\n PermissionDoesNotExistError,\n UnrecognizedSubjectError,\n} from '@metamask/permission-controller';\nimport { rpcErrors } from '@metamask/rpc-errors';\nimport { isObject } from '@metamask/utils';\nimport type { JsonRpcSuccess, JsonRpcRequest } from '@metamask/utils';\n\nimport type { WalletRevokeSessionHooks } from './types';\n\n/**\n * Check whether the given error is a permission error.\n *\n * @param error - The error to check.\n * @returns Whether the error is a permission error.\n */\nfunction isPermissionError(error: unknown) {\n if (\n !isObject(error) ||\n !('name' in error) ||\n typeof error.name !== 'string'\n ) {\n return false;\n }\n\n return [\n UnrecognizedSubjectError.name,\n PermissionDoesNotExistError.name,\n ].includes(error.name);\n}\n\n/**\n * Revokes specific session scopes from an existing caveat.\n * Fully revokes permission if no accounts remain permitted after iterating through scopes.\n *\n * @param scopes - Array of scope strings to remove from the caveat.\n * @param hooks - The hooks object.\n * @param hooks.revokePermissionForOrigin - The hook for revoking a permission for an origin function.\n * @param hooks.updateCaveat - The hook used to conditionally update the caveat rather than fully revoke the permission.\n * @param hooks.getCaveatForOrigin - The hook to fetch an existing caveat for the origin of the request.\n */\nfunction partialRevokePermissions(\n scopes: string[],\n hooks: WalletRevokeSessionHooks,\n) {\n let updatedCaveatValue = hooks.getCaveatForOrigin(\n Caip25EndowmentPermissionName,\n Caip25CaveatType,\n ).value;\n\n for (const scopeString of scopes) {\n const result = Caip25CaveatMutators[Caip25CaveatType].removeScope(\n updatedCaveatValue,\n scopeString,\n );\n\n // If operation is a Noop, it means a scope was passed that was not present in the permission, so we proceed with the loop\n if (result.operation === CaveatMutatorOperation.Noop) {\n continue;\n }\n\n updatedCaveatValue = result?.value ?? {\n requiredScopes: {},\n optionalScopes: {},\n sessionProperties: {},\n isMultichainOrigin: true,\n };\n }\n\n const caipAccountIds =\n getCaipAccountIdsFromCaip25CaveatValue(updatedCaveatValue);\n\n // We fully revoke permission if no accounts are left after scope removal loop.\n if (!caipAccountIds.length) {\n hooks.revokePermissionForOrigin(Caip25EndowmentPermissionName);\n } else {\n hooks.updateCaveat(\n Caip25EndowmentPermissionName,\n Caip25CaveatType,\n updatedCaveatValue,\n );\n }\n}\n\n/**\n * Handler for the `wallet_revokeSession` RPC method as specified by [CAIP-285](https://chainagnostic.org/CAIPs/caip-285).\n * The implementation below deviates from the linked spec in that it ignores the `sessionId` param\n * and instead revokes the singular session for the origin if available. Additionally,\n * the handler also does not return an error if there is currently no active session and instead\n * returns true which is the same result returned if an active session was actually revoked.\n *\n * @param request - The JSON-RPC request object. Unused.\n * @param response - The JSON-RPC response object.\n * @param _next - The next middleware function. Unused.\n * @param end - The end callback function.\n * @param hooks - The hooks object.\n * @param hooks.revokePermissionForOrigin - The hook for revoking a permission for an origin function.\n * @param hooks.updateCaveat - The hook used to conditionally update the caveat rather than fully revoke the permission.\n * @param hooks.getCaveatForOrigin - The hook to fetch an existing caveat for the origin of the request.\n * @returns Nothing.\n */\nasync function walletRevokeSessionHandler(\n request: JsonRpcRequest & {\n origin: string;\n params: { scopes?: string[] };\n },\n response: JsonRpcSuccess,\n _next: JsonRpcEngineNextCallback,\n end: JsonRpcEngineEndCallback,\n hooks: WalletRevokeSessionHooks,\n) {\n try {\n if (request.params?.scopes?.length) {\n partialRevokePermissions(request.params.scopes, hooks);\n } else {\n hooks.revokePermissionForOrigin(Caip25EndowmentPermissionName);\n }\n } catch (err) {\n if (!isPermissionError(err)) {\n console.error(err);\n return end(rpcErrors.internal());\n }\n }\n\n response.result = true;\n return end();\n}\nexport const walletRevokeSession = {\n methodNames: ['wallet_revokeSession'],\n implementation: walletRevokeSessionHandler,\n hookNames: {\n revokePermissionForOrigin: true,\n updateCaveat: true,\n getCaveatForOrigin: true,\n },\n};\n"]}
package/dist/index.cjs CHANGED
@@ -1,8 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MultichainApiNotifications = exports.MultichainSubscriptionManager = exports.MultichainMiddlewareManager = exports.multichainMethodCallValidatorMiddleware = exports.methodHandlers = void 0;
4
- var handlers_1 = require("./handlers/index.cjs");
5
- Object.defineProperty(exports, "methodHandlers", { enumerable: true, get: function () { return handlers_1.methodHandlers; } });
3
+ exports.MultichainApiNotifications = exports.MultichainSubscriptionManager = exports.MultichainMiddlewareManager = exports.multichainMethodCallValidatorMiddleware = exports.walletRevokeSession = exports.walletInvokeMethod = exports.walletGetSession = exports.walletCreateSession = void 0;
4
+ var wallet_createSession_1 = require("./handlers/wallet-createSession.cjs");
5
+ Object.defineProperty(exports, "walletCreateSession", { enumerable: true, get: function () { return wallet_createSession_1.walletCreateSession; } });
6
+ var wallet_getSession_1 = require("./handlers/wallet-getSession.cjs");
7
+ Object.defineProperty(exports, "walletGetSession", { enumerable: true, get: function () { return wallet_getSession_1.walletGetSession; } });
8
+ var wallet_invokeMethod_1 = require("./handlers/wallet-invokeMethod.cjs");
9
+ Object.defineProperty(exports, "walletInvokeMethod", { enumerable: true, get: function () { return wallet_invokeMethod_1.walletInvokeMethod; } });
10
+ var wallet_revokeSession_1 = require("./handlers/wallet-revokeSession.cjs");
11
+ Object.defineProperty(exports, "walletRevokeSession", { enumerable: true, get: function () { return wallet_revokeSession_1.walletRevokeSession; } });
6
12
  var multichainMethodCallValidatorMiddleware_1 = require("./middlewares/multichainMethodCallValidatorMiddleware.cjs");
7
13
  Object.defineProperty(exports, "multichainMethodCallValidatorMiddleware", { enumerable: true, get: function () { return multichainMethodCallValidatorMiddleware_1.multichainMethodCallValidatorMiddleware; } });
8
14
  var MultichainMiddlewareManager_1 = require("./middlewares/MultichainMiddlewareManager.cjs");
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAAnC,0GAAA,cAAc,OAAA;AAEvB,qHAAgH;AAAvG,kKAAA,uCAAuC,OAAA;AAChD,6FAAwF;AAA/E,0IAAA,2BAA2B,OAAA;AACpC,iGAA4F;AAAnF,8IAAA,6BAA6B,OAAA;AACtC,8CAA8D;AAArD,mHAAA,0BAA0B,OAAA","sourcesContent":["export { methodHandlers } from './handlers';\n\nexport { multichainMethodCallValidatorMiddleware } from './middlewares/multichainMethodCallValidatorMiddleware';\nexport { MultichainMiddlewareManager } from './middlewares/MultichainMiddlewareManager';\nexport { MultichainSubscriptionManager } from './middlewares/MultichainSubscriptionManager';\nexport { MultichainApiNotifications } from './handlers/types';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,4EAAsE;AAA7D,2HAAA,mBAAmB,OAAA;AAC5B,sEAAgE;AAAvD,qHAAA,gBAAgB,OAAA;AACzB,0EAAoE;AAA3D,yHAAA,kBAAkB,OAAA;AAC3B,4EAAsE;AAA7D,2HAAA,mBAAmB,OAAA;AAE5B,qHAAgH;AAAvG,kKAAA,uCAAuC,OAAA;AAChD,6FAAwF;AAA/E,0IAAA,2BAA2B,OAAA;AACpC,iGAA4F;AAAnF,8IAAA,6BAA6B,OAAA;AACtC,8CAA8D;AAArD,mHAAA,0BAA0B,OAAA","sourcesContent":["export { walletCreateSession } from './handlers/wallet-createSession';\nexport { walletGetSession } from './handlers/wallet-getSession';\nexport { walletInvokeMethod } from './handlers/wallet-invokeMethod';\nexport { walletRevokeSession } from './handlers/wallet-revokeSession';\n\nexport { multichainMethodCallValidatorMiddleware } from './middlewares/multichainMethodCallValidatorMiddleware';\nexport { MultichainMiddlewareManager } from './middlewares/MultichainMiddlewareManager';\nexport { MultichainSubscriptionManager } from './middlewares/MultichainSubscriptionManager';\nexport { MultichainApiNotifications } from './handlers/types';\n"]}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,7 @@
1
- export { methodHandlers } from "./handlers/index.cjs";
1
+ export { walletCreateSession } from "./handlers/wallet-createSession.cjs";
2
+ export { walletGetSession } from "./handlers/wallet-getSession.cjs";
3
+ export { walletInvokeMethod } from "./handlers/wallet-invokeMethod.cjs";
4
+ export { walletRevokeSession } from "./handlers/wallet-revokeSession.cjs";
2
5
  export { multichainMethodCallValidatorMiddleware } from "./middlewares/multichainMethodCallValidatorMiddleware.cjs";
3
6
  export { MultichainMiddlewareManager } from "./middlewares/MultichainMiddlewareManager.cjs";
4
7
  export { MultichainSubscriptionManager } from "./middlewares/MultichainSubscriptionManager.cjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,6BAAmB;AAE5C,OAAO,EAAE,uCAAuC,EAAE,kEAA8D;AAChH,OAAO,EAAE,2BAA2B,EAAE,sDAAkD;AACxF,OAAO,EAAE,6BAA6B,EAAE,wDAAoD;AAC5F,OAAO,EAAE,0BAA0B,EAAE,6BAAyB"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,4CAAwC;AACtE,OAAO,EAAE,gBAAgB,EAAE,yCAAqC;AAChE,OAAO,EAAE,kBAAkB,EAAE,2CAAuC;AACpE,OAAO,EAAE,mBAAmB,EAAE,4CAAwC;AAEtE,OAAO,EAAE,uCAAuC,EAAE,kEAA8D;AAChH,OAAO,EAAE,2BAA2B,EAAE,sDAAkD;AACxF,OAAO,EAAE,6BAA6B,EAAE,wDAAoD;AAC5F,OAAO,EAAE,0BAA0B,EAAE,6BAAyB"}
package/dist/index.d.mts CHANGED
@@ -1,4 +1,7 @@
1
- export { methodHandlers } from "./handlers/index.mjs";
1
+ export { walletCreateSession } from "./handlers/wallet-createSession.mjs";
2
+ export { walletGetSession } from "./handlers/wallet-getSession.mjs";
3
+ export { walletInvokeMethod } from "./handlers/wallet-invokeMethod.mjs";
4
+ export { walletRevokeSession } from "./handlers/wallet-revokeSession.mjs";
2
5
  export { multichainMethodCallValidatorMiddleware } from "./middlewares/multichainMethodCallValidatorMiddleware.mjs";
3
6
  export { MultichainMiddlewareManager } from "./middlewares/MultichainMiddlewareManager.mjs";
4
7
  export { MultichainSubscriptionManager } from "./middlewares/MultichainSubscriptionManager.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,6BAAmB;AAE5C,OAAO,EAAE,uCAAuC,EAAE,kEAA8D;AAChH,OAAO,EAAE,2BAA2B,EAAE,sDAAkD;AACxF,OAAO,EAAE,6BAA6B,EAAE,wDAAoD;AAC5F,OAAO,EAAE,0BAA0B,EAAE,6BAAyB"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,4CAAwC;AACtE,OAAO,EAAE,gBAAgB,EAAE,yCAAqC;AAChE,OAAO,EAAE,kBAAkB,EAAE,2CAAuC;AACpE,OAAO,EAAE,mBAAmB,EAAE,4CAAwC;AAEtE,OAAO,EAAE,uCAAuC,EAAE,kEAA8D;AAChH,OAAO,EAAE,2BAA2B,EAAE,sDAAkD;AACxF,OAAO,EAAE,6BAA6B,EAAE,wDAAoD;AAC5F,OAAO,EAAE,0BAA0B,EAAE,6BAAyB"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,7 @@
1
- export { methodHandlers } from "./handlers/index.mjs";
1
+ export { walletCreateSession } from "./handlers/wallet-createSession.mjs";
2
+ export { walletGetSession } from "./handlers/wallet-getSession.mjs";
3
+ export { walletInvokeMethod } from "./handlers/wallet-invokeMethod.mjs";
4
+ export { walletRevokeSession } from "./handlers/wallet-revokeSession.mjs";
2
5
  export { multichainMethodCallValidatorMiddleware } from "./middlewares/multichainMethodCallValidatorMiddleware.mjs";
3
6
  export { MultichainMiddlewareManager } from "./middlewares/MultichainMiddlewareManager.mjs";
4
7
  export { MultichainSubscriptionManager } from "./middlewares/MultichainSubscriptionManager.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,6BAAmB;AAE5C,OAAO,EAAE,uCAAuC,EAAE,kEAA8D;AAChH,OAAO,EAAE,2BAA2B,EAAE,sDAAkD;AACxF,OAAO,EAAE,6BAA6B,EAAE,wDAAoD;AAC5F,OAAO,EAAE,0BAA0B,EAAE,6BAAyB","sourcesContent":["export { methodHandlers } from './handlers';\n\nexport { multichainMethodCallValidatorMiddleware } from './middlewares/multichainMethodCallValidatorMiddleware';\nexport { MultichainMiddlewareManager } from './middlewares/MultichainMiddlewareManager';\nexport { MultichainSubscriptionManager } from './middlewares/MultichainSubscriptionManager';\nexport { MultichainApiNotifications } from './handlers/types';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,4CAAwC;AACtE,OAAO,EAAE,gBAAgB,EAAE,yCAAqC;AAChE,OAAO,EAAE,kBAAkB,EAAE,2CAAuC;AACpE,OAAO,EAAE,mBAAmB,EAAE,4CAAwC;AAEtE,OAAO,EAAE,uCAAuC,EAAE,kEAA8D;AAChH,OAAO,EAAE,2BAA2B,EAAE,sDAAkD;AACxF,OAAO,EAAE,6BAA6B,EAAE,wDAAoD;AAC5F,OAAO,EAAE,0BAA0B,EAAE,6BAAyB","sourcesContent":["export { walletCreateSession } from './handlers/wallet-createSession';\nexport { walletGetSession } from './handlers/wallet-getSession';\nexport { walletInvokeMethod } from './handlers/wallet-invokeMethod';\nexport { walletRevokeSession } from './handlers/wallet-revokeSession';\n\nexport { multichainMethodCallValidatorMiddleware } from './middlewares/multichainMethodCallValidatorMiddleware';\nexport { MultichainMiddlewareManager } from './middlewares/MultichainMiddlewareManager';\nexport { MultichainSubscriptionManager } from './middlewares/MultichainSubscriptionManager';\nexport { MultichainApiNotifications } from './handlers/types';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/multichain-api-middleware",
3
- "version": "2.0.0-preview-45a82ea8e",
3
+ "version": "2.0.0-preview-d8ff44d",
4
4
  "description": "JSON-RPC methods and middleware to support the MetaMask Multichain API",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -55,7 +55,7 @@
55
55
  "@metamask/chain-agnostic-permission": "^1.5.0",
56
56
  "@metamask/controller-utils": "^11.20.0",
57
57
  "@metamask/json-rpc-engine": "^10.2.4",
58
- "@metamask/network-controller": "^30.0.1",
58
+ "@metamask/network-controller": "^30.1.0",
59
59
  "@metamask/permission-controller": "^12.3.0",
60
60
  "@metamask/rpc-errors": "^7.0.2",
61
61
  "@metamask/utils": "^11.9.0",
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.methodHandlers = void 0;
4
- const wallet_createSession_1 = require("./wallet-createSession.cjs");
5
- const wallet_getSession_1 = require("./wallet-getSession.cjs");
6
- const wallet_invokeMethod_1 = require("./wallet-invokeMethod.cjs");
7
- const wallet_revokeSession_1 = require("./wallet-revokeSession.cjs");
8
- exports.methodHandlers = {
9
- ...wallet_createSession_1.walletCreateSessionHandler,
10
- ...wallet_getSession_1.walletGetSessionHandler,
11
- ...wallet_invokeMethod_1.walletInvokeMethodHandler,
12
- ...wallet_revokeSession_1.walletRevokeSessionHandler,
13
- };
14
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":";;;AAAA,qEAAoE;AACpE,+DAA8D;AAC9D,mEAAkE;AAClE,qEAAoE;AAOvD,QAAA,cAAc,GAA6B;IACtD,GAAG,iDAA0B;IAC7B,GAAG,2CAAuB;IAC1B,GAAG,+CAAyB;IAC5B,GAAG,iDAA0B;CACrB,CAAC","sourcesContent":["import { walletCreateSessionHandler } from './wallet-createSession';\nimport { walletGetSessionHandler } from './wallet-getSession';\nimport { walletInvokeMethodHandler } from './wallet-invokeMethod';\nimport { walletRevokeSessionHandler } from './wallet-revokeSession';\n\ntype MethodHandlers = typeof walletCreateSessionHandler &\n typeof walletGetSessionHandler &\n typeof walletInvokeMethodHandler &\n typeof walletRevokeSessionHandler;\n\nexport const methodHandlers: Readonly<MethodHandlers> = {\n ...walletCreateSessionHandler,\n ...walletGetSessionHandler,\n ...walletInvokeMethodHandler,\n ...walletRevokeSessionHandler,\n} as const;\n"]}
@@ -1,8 +0,0 @@
1
- import { walletCreateSessionHandler } from "./wallet-createSession.cjs";
2
- import { walletGetSessionHandler } from "./wallet-getSession.cjs";
3
- import { walletInvokeMethodHandler } from "./wallet-invokeMethod.cjs";
4
- import { walletRevokeSessionHandler } from "./wallet-revokeSession.cjs";
5
- type MethodHandlers = typeof walletCreateSessionHandler & typeof walletGetSessionHandler & typeof walletInvokeMethodHandler & typeof walletRevokeSessionHandler;
6
- export declare const methodHandlers: Readonly<MethodHandlers>;
7
- export {};
8
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,mCAA+B;AACpE,OAAO,EAAE,uBAAuB,EAAE,gCAA4B;AAC9D,OAAO,EAAE,yBAAyB,EAAE,kCAA8B;AAClE,OAAO,EAAE,0BAA0B,EAAE,mCAA+B;AAEpE,KAAK,cAAc,GAAG,OAAO,0BAA0B,GACrD,OAAO,uBAAuB,GAC9B,OAAO,yBAAyB,GAChC,OAAO,0BAA0B,CAAC;AAEpC,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,cAAc,CAK1C,CAAC"}
@@ -1,8 +0,0 @@
1
- import { walletCreateSessionHandler } from "./wallet-createSession.mjs";
2
- import { walletGetSessionHandler } from "./wallet-getSession.mjs";
3
- import { walletInvokeMethodHandler } from "./wallet-invokeMethod.mjs";
4
- import { walletRevokeSessionHandler } from "./wallet-revokeSession.mjs";
5
- type MethodHandlers = typeof walletCreateSessionHandler & typeof walletGetSessionHandler & typeof walletInvokeMethodHandler & typeof walletRevokeSessionHandler;
6
- export declare const methodHandlers: Readonly<MethodHandlers>;
7
- export {};
8
- //# sourceMappingURL=index.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,mCAA+B;AACpE,OAAO,EAAE,uBAAuB,EAAE,gCAA4B;AAC9D,OAAO,EAAE,yBAAyB,EAAE,kCAA8B;AAClE,OAAO,EAAE,0BAA0B,EAAE,mCAA+B;AAEpE,KAAK,cAAc,GAAG,OAAO,0BAA0B,GACrD,OAAO,uBAAuB,GAC9B,OAAO,yBAAyB,GAChC,OAAO,0BAA0B,CAAC;AAEpC,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,cAAc,CAK1C,CAAC"}
@@ -1,11 +0,0 @@
1
- import { walletCreateSessionHandler } from "./wallet-createSession.mjs";
2
- import { walletGetSessionHandler } from "./wallet-getSession.mjs";
3
- import { walletInvokeMethodHandler } from "./wallet-invokeMethod.mjs";
4
- import { walletRevokeSessionHandler } from "./wallet-revokeSession.mjs";
5
- export const methodHandlers = {
6
- ...walletCreateSessionHandler,
7
- ...walletGetSessionHandler,
8
- ...walletInvokeMethodHandler,
9
- ...walletRevokeSessionHandler,
10
- };
11
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,mCAA+B;AACpE,OAAO,EAAE,uBAAuB,EAAE,gCAA4B;AAC9D,OAAO,EAAE,yBAAyB,EAAE,kCAA8B;AAClE,OAAO,EAAE,0BAA0B,EAAE,mCAA+B;AAOpE,MAAM,CAAC,MAAM,cAAc,GAA6B;IACtD,GAAG,0BAA0B;IAC7B,GAAG,uBAAuB;IAC1B,GAAG,yBAAyB;IAC5B,GAAG,0BAA0B;CACrB,CAAC","sourcesContent":["import { walletCreateSessionHandler } from './wallet-createSession';\nimport { walletGetSessionHandler } from './wallet-getSession';\nimport { walletInvokeMethodHandler } from './wallet-invokeMethod';\nimport { walletRevokeSessionHandler } from './wallet-revokeSession';\n\ntype MethodHandlers = typeof walletCreateSessionHandler &\n typeof walletGetSessionHandler &\n typeof walletInvokeMethodHandler &\n typeof walletRevokeSessionHandler;\n\nexport const methodHandlers: Readonly<MethodHandlers> = {\n ...walletCreateSessionHandler,\n ...walletGetSessionHandler,\n ...walletInvokeMethodHandler,\n ...walletRevokeSessionHandler,\n} as const;\n"]}