From 6e40a0eb7ec48889815ea9691e1d389f7677b2c4 Mon Sep 17 00:00:00 2001 From: OGPoyraz Date: Tue, 4 Apr 2023 17:25:57 +0200 Subject: [PATCH] feat: use siwe detection from @metamask/controller-utils (#18409) --- app/scripts/controllers/sign.test.ts | 38 ---- app/scripts/controllers/sign.ts | 10 +- .../lib/createRPCMethodTrackingMiddleware.js | 3 +- .../createRPCMethodTrackingMiddleware.test.js | 4 +- lavamoat/browserify/beta/policy.json | 195 ++++++++-------- lavamoat/browserify/desktop/policy.json | 212 ++++++++++-------- lavamoat/browserify/flask/policy.json | 212 ++++++++++-------- lavamoat/browserify/main/policy.json | 195 ++++++++-------- package.json | 5 +- shared/modules/siwe.js | 52 ----- yarn.lock | 17 +- 11 files changed, 447 insertions(+), 496 deletions(-) diff --git a/app/scripts/controllers/sign.test.ts b/app/scripts/controllers/sign.test.ts index 7212df2ae..36dddf65b 100644 --- a/app/scripts/controllers/sign.test.ts +++ b/app/scripts/controllers/sign.test.ts @@ -8,7 +8,6 @@ import { OriginalRequest, } from '@metamask/message-manager/dist/AbstractMessageManager'; import { MetaMetricsEventCategory } from '../../../shared/constants/metametrics'; -import { detectSIWE } from '../../../shared/modules/siwe'; import SignController, { SignControllerMessenger, SignControllerOptions, @@ -20,10 +19,6 @@ jest.mock('@metamask/message-manager', () => ({ TypedMessageManager: jest.fn(), })); -jest.mock('../../../shared/modules/siwe', () => ({ - detectSIWE: jest.fn(), -})); - const messageIdMock = '123'; const messageIdMock2 = '456'; const versionMock = '1'; @@ -69,13 +64,6 @@ const requestMock = { origin: 'http://test2.com', } as OriginalRequest; -const siweMockFound = { - isSIWEMessage: true, - parsedMessage: { domain: 'test.com', test: 'value' }, -}; - -const siweMockNotFound = { isSIWEMessage: false }; - const createMessengerMock = () => ({ registerActionHandler: jest.fn(), @@ -128,7 +116,6 @@ describe('SignController', () => { const messengerMock = createMessengerMock(); const preferencesControllerMock = createPreferencesControllerMock(); const keyringControllerMock = createKeyringControllerMock(); - const detectSIWEMock = detectSIWE as jest.MockedFunction; const getStateMock = jest.fn(); const securityProviderRequestMock = jest.fn(); const metricsEventMock = jest.fn(); @@ -147,8 +134,6 @@ describe('SignController', () => { disabledRpcMethodPreferences: { eth_sign: true }, }); - detectSIWEMock.mockReturnValue(siweMockNotFound); - signController = new SignController({ messenger: messengerMock as any, preferencesController: preferencesControllerMock as any, @@ -354,29 +339,6 @@ describe('SignController', () => { requestMock, ); }); - - it('adds message to personal message manager including Ethereum sign in data', async () => { - detectSIWEMock.mockReturnValueOnce(siweMockFound); - - await signController.newUnsignedPersonalMessage( - messageParamsMock, - requestMock, - ); - - expect( - personalMessageManagerMock.addUnapprovedMessageAsync, - ).toHaveBeenCalledTimes(1); - - expect( - personalMessageManagerMock.addUnapprovedMessageAsync, - ).toHaveBeenCalledWith( - { - ...messageParamsMock, - siwe: siweMockFound, - }, - requestMock, - ); - }); }); describe('newUnsignedTypedMessage', () => { diff --git a/app/scripts/controllers/sign.ts b/app/scripts/controllers/sign.ts index afaeaa499..e04d70c09 100644 --- a/app/scripts/controllers/sign.ts +++ b/app/scripts/controllers/sign.ts @@ -33,7 +33,6 @@ import { RejectRequest, } from '@metamask/approval-controller'; import { MetaMetricsEventCategory } from '../../../shared/constants/metametrics'; -import { detectSIWE } from '../../../shared/modules/siwe'; import PreferencesController from './preferences'; const controllerName = 'SignController'; @@ -321,11 +320,8 @@ export default class SignController extends BaseControllerV2< msgParams: PersonalMessageParams, req: OriginalRequest, ): Promise { - const ethereumSignInData = this._getEthereumSignInData(msgParams); - const finalMsgParams = { ...msgParams, siwe: ethereumSignInData }; - return this._personalMessageManager.addUnapprovedMessageAsync( - finalMsgParams, + msgParams, req, ); } @@ -618,10 +614,6 @@ export default class SignController extends BaseControllerV2< }[messageId]; } - private _getEthereumSignInData(messgeParams: PersonalMessageParams): any { - return detectSIWE(messgeParams); - } - private _requestApproval( msgParams: AbstractMessageParamsMetamask, type: string, diff --git a/app/scripts/lib/createRPCMethodTrackingMiddleware.js b/app/scripts/lib/createRPCMethodTrackingMiddleware.js index cd3b9720a..c0fc09e24 100644 --- a/app/scripts/lib/createRPCMethodTrackingMiddleware.js +++ b/app/scripts/lib/createRPCMethodTrackingMiddleware.js @@ -1,8 +1,9 @@ import { errorCodes } from 'eth-rpc-errors'; +import { detectSIWE } from '@metamask/controller-utils'; import { MESSAGE_TYPE, ORIGIN_METAMASK } from '../../../shared/constants/app'; import { TransactionStatus } from '../../../shared/constants/transaction'; import { SECOND } from '../../../shared/constants/time'; -import { detectSIWE } from '../../../shared/modules/siwe'; + import { MetaMetricsEventCategory, MetaMetricsEventName, diff --git a/app/scripts/lib/createRPCMethodTrackingMiddleware.test.js b/app/scripts/lib/createRPCMethodTrackingMiddleware.test.js index 342fd320a..070ad12b2 100644 --- a/app/scripts/lib/createRPCMethodTrackingMiddleware.test.js +++ b/app/scripts/lib/createRPCMethodTrackingMiddleware.test.js @@ -1,11 +1,11 @@ import { errorCodes } from 'eth-rpc-errors'; +import { detectSIWE } from '@metamask/controller-utils'; import { MESSAGE_TYPE } from '../../../shared/constants/app'; import { MetaMetricsEventName, MetaMetricsEventUiCustomization, } from '../../../shared/constants/metametrics'; import { SECOND } from '../../../shared/constants/time'; -import { detectSIWE } from '../../../shared/modules/siwe'; import createRPCMethodTrackingMiddleware from './createRPCMethodTrackingMiddleware'; const trackEvent = jest.fn(); @@ -56,7 +56,7 @@ function getNext(timeout = 500) { const waitForSeconds = async (seconds) => await new Promise((resolve) => setTimeout(resolve, SECOND * seconds)); -jest.mock('../../../shared/modules/siwe', () => ({ +jest.mock('@metamask/controller-utils', () => ({ detectSIWE: jest.fn().mockImplementation(() => { return { isSIWEMessage: false }; }), diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 98b889720..dd174c63d 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -661,7 +661,7 @@ "@metamask/address-book-controller": { "packages": { "@metamask/address-book-controller>@metamask/base-controller": true, - "@metamask/controller-utils": true + "@metamask/address-book-controller>@metamask/controller-utils": true } }, "@metamask/address-book-controller>@metamask/base-controller": { @@ -669,6 +669,21 @@ "immer": true } }, + "@metamask/address-book-controller>@metamask/controller-utils": { + "globals": { + "console.error": true, + "fetch": true, + "setTimeout": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch": true, + "browserify>buffer": true, + "eslint>fast-deep-equal": true, + "eth-ens-namehash": true, + "ethereumjs-util": true, + "ethjs>ethjs-unit": true + } + }, "@metamask/announcement-controller": { "packages": { "@metamask/announcement-controller>@metamask/base-controller": true @@ -680,6 +695,9 @@ } }, "@metamask/approval-controller": { + "globals": { + "console.log": true + }, "packages": { "@metamask/approval-controller>nanoid": true, "@metamask/base-controller": true, @@ -747,7 +765,7 @@ "setTimeout": true }, "packages": { - "@metamask/controller-utils>isomorphic-fetch": true, + "@metamask/phishing-controller>isomorphic-fetch": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true, @@ -791,7 +809,8 @@ "setTimeout": true }, "packages": { - "@metamask/controller-utils>isomorphic-fetch": true, + "@metamask/controller-utils>@metamask/utils": true, + "@metamask/controller-utils>@spruceid/siwe-parser": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true, @@ -799,23 +818,34 @@ "ethjs>ethjs-unit": true } }, - "@metamask/controller-utils>isomorphic-fetch": { + "@metamask/controller-utils>@metamask/utils": { "globals": { - "fetch.bind": true + "TextDecoder": true, + "TextEncoder": true }, "packages": { - "@metamask/controller-utils>isomorphic-fetch>whatwg-fetch": true + "@metamask/utils>superstruct": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true } }, - "@metamask/controller-utils>isomorphic-fetch>whatwg-fetch": { + "@metamask/controller-utils>@spruceid/siwe-parser": { "globals": { - "Blob": true, - "FileReader": true, - "FormData": true, - "URLSearchParams.prototype.isPrototypeOf": true, - "XMLHttpRequest": true, - "define": true, - "setTimeout": true + "console.error": true, + "console.log": true + }, + "packages": { + "@metamask/controller-utils>@spruceid/siwe-parser>apg-js": true + } + }, + "@metamask/controller-utils>@spruceid/siwe-parser>apg-js": { + "globals": { + "mode": true + }, + "packages": { + "browserify>buffer": true, + "browserify>insert-module-globals>is-buffer": true } }, "@metamask/controllers>nanoid": { @@ -1171,8 +1201,8 @@ "setInterval": true }, "packages": { - "@metamask/controller-utils": true, "@metamask/gas-fee-controller>@metamask/base-controller": true, + "@metamask/gas-fee-controller>@metamask/controller-utils": true, "eth-query": true, "ethereumjs-util": true, "ethjs>ethjs-unit": true, @@ -1184,6 +1214,21 @@ "immer": true } }, + "@metamask/gas-fee-controller>@metamask/controller-utils": { + "globals": { + "console.error": true, + "fetch": true, + "setTimeout": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch": true, + "browserify>buffer": true, + "eslint>fast-deep-equal": true, + "eth-ens-namehash": true, + "ethereumjs-util": true, + "ethjs>ethjs-unit": true + } + }, "@metamask/jazzicon": { "globals": { "document.createElement": true, @@ -1282,8 +1327,8 @@ }, "@metamask/message-manager": { "packages": { + "@metamask/controller-utils": true, "@metamask/message-manager>@metamask/base-controller": true, - "@metamask/message-manager>@metamask/controller-utils": true, "@metamask/message-manager>jsonschema": true, "browserify>buffer": true, "browserify>events": true, @@ -1297,34 +1342,6 @@ "immer": true } }, - "@metamask/message-manager>@metamask/controller-utils": { - "globals": { - "console.error": true, - "fetch": true, - "setTimeout": true - }, - "packages": { - "@metamask/message-manager>@metamask/controller-utils>@metamask/utils": true, - "@spruceid/siwe-parser": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true, - "ethereumjs-util": true, - "ethjs>ethjs-unit": true - } - }, - "@metamask/message-manager>@metamask/controller-utils>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>superstruct": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/message-manager>jsonschema": { "packages": { "browserify>url": true @@ -1355,8 +1372,8 @@ "console.error": true }, "packages": { + "@metamask/controller-utils": true, "@metamask/permission-controller>@metamask/base-controller": true, - "@metamask/permission-controller>@metamask/controller-utils": true, "@metamask/permission-controller>nanoid": true, "deep-freeze-strict": true, "eth-rpc-errors": true, @@ -1369,34 +1386,6 @@ "immer": true } }, - "@metamask/permission-controller>@metamask/controller-utils": { - "globals": { - "console.error": true, - "fetch": true, - "setTimeout": true - }, - "packages": { - "@metamask/permission-controller>@metamask/controller-utils>@metamask/utils": true, - "@spruceid/siwe-parser": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true, - "ethereumjs-util": true, - "ethjs>ethjs-unit": true - } - }, - "@metamask/permission-controller>@metamask/controller-utils>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>superstruct": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -1408,8 +1397,8 @@ }, "packages": { "@metamask/base-controller": true, - "@metamask/controller-utils>isomorphic-fetch": true, "@metamask/phishing-controller>@metamask/controller-utils": true, + "@metamask/phishing-controller>isomorphic-fetch": true, "@metamask/phishing-warning>eth-phishing-detect": true, "punycode": true } @@ -1421,7 +1410,7 @@ "setTimeout": true }, "packages": { - "@metamask/controller-utils>isomorphic-fetch": true, + "@metamask/phishing-controller>isomorphic-fetch": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true, @@ -1429,6 +1418,25 @@ "ethjs>ethjs-unit": true } }, + "@metamask/phishing-controller>isomorphic-fetch": { + "globals": { + "fetch.bind": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch>whatwg-fetch": true + } + }, + "@metamask/phishing-controller>isomorphic-fetch>whatwg-fetch": { + "globals": { + "Blob": true, + "FileReader": true, + "FormData": true, + "URLSearchParams.prototype.isPrototypeOf": true, + "XMLHttpRequest": true, + "define": true, + "setTimeout": true + } + }, "@metamask/phishing-warning>eth-phishing-detect": { "packages": { "eslint>optionator>fast-levenshtein": true @@ -1492,13 +1500,28 @@ "@ethersproject/bignumber": true, "@ethersproject/providers": true, "@metamask/base-controller": true, - "@metamask/controller-utils": true, - "@metamask/controller-utils>isomorphic-fetch": true, + "@metamask/phishing-controller>isomorphic-fetch": true, + "@metamask/smart-transactions-controller>@metamask/controller-utils": true, "@metamask/smart-transactions-controller>bignumber.js": true, "fast-json-patch": true, "lodash": true } }, + "@metamask/smart-transactions-controller>@metamask/controller-utils": { + "globals": { + "console.error": true, + "fetch": true, + "setTimeout": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch": true, + "browserify>buffer": true, + "eslint>fast-deep-equal": true, + "eth-ens-namehash": true, + "ethereumjs-util": true, + "ethjs>ethjs-unit": true + } + }, "@metamask/smart-transactions-controller>@metamask/controllers>nanoid": { "globals": { "crypto.getRandomValues": true @@ -1770,24 +1793,6 @@ "define": true } }, - "@spruceid/siwe-parser": { - "globals": { - "console.error": true, - "console.log": true - }, - "packages": { - "@spruceid/siwe-parser>apg-js": true - } - }, - "@spruceid/siwe-parser>apg-js": { - "globals": { - "mode": true - }, - "packages": { - "browserify>buffer": true, - "browserify>insert-module-globals>is-buffer": true - } - }, "@storybook/api>regenerator-runtime": { "globals": { "regeneratorRuntime": "write" diff --git a/lavamoat/browserify/desktop/policy.json b/lavamoat/browserify/desktop/policy.json index 5967ac0ac..fa9312ae5 100644 --- a/lavamoat/browserify/desktop/policy.json +++ b/lavamoat/browserify/desktop/policy.json @@ -661,7 +661,7 @@ "@metamask/address-book-controller": { "packages": { "@metamask/address-book-controller>@metamask/base-controller": true, - "@metamask/controller-utils": true + "@metamask/address-book-controller>@metamask/controller-utils": true } }, "@metamask/address-book-controller>@metamask/base-controller": { @@ -669,6 +669,21 @@ "immer": true } }, + "@metamask/address-book-controller>@metamask/controller-utils": { + "globals": { + "console.error": true, + "fetch": true, + "setTimeout": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch": true, + "browserify>buffer": true, + "eslint>fast-deep-equal": true, + "eth-ens-namehash": true, + "ethereumjs-util": true, + "ethjs>ethjs-unit": true + } + }, "@metamask/announcement-controller": { "packages": { "@metamask/announcement-controller>@metamask/base-controller": true @@ -680,6 +695,9 @@ } }, "@metamask/approval-controller": { + "globals": { + "console.log": true + }, "packages": { "@metamask/approval-controller>nanoid": true, "@metamask/base-controller": true, @@ -747,7 +765,7 @@ "setTimeout": true }, "packages": { - "@metamask/controller-utils>isomorphic-fetch": true, + "@metamask/phishing-controller>isomorphic-fetch": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true, @@ -791,7 +809,8 @@ "setTimeout": true }, "packages": { - "@metamask/controller-utils>isomorphic-fetch": true, + "@metamask/controller-utils>@metamask/utils": true, + "@metamask/controller-utils>@spruceid/siwe-parser": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true, @@ -799,23 +818,34 @@ "ethjs>ethjs-unit": true } }, - "@metamask/controller-utils>isomorphic-fetch": { + "@metamask/controller-utils>@metamask/utils": { "globals": { - "fetch.bind": true + "TextDecoder": true, + "TextEncoder": true }, "packages": { - "@metamask/controller-utils>isomorphic-fetch>whatwg-fetch": true + "@metamask/utils>superstruct": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true } }, - "@metamask/controller-utils>isomorphic-fetch>whatwg-fetch": { + "@metamask/controller-utils>@spruceid/siwe-parser": { "globals": { - "Blob": true, - "FileReader": true, - "FormData": true, - "URLSearchParams.prototype.isPrototypeOf": true, - "XMLHttpRequest": true, - "define": true, - "setTimeout": true + "console.error": true, + "console.log": true + }, + "packages": { + "@metamask/controller-utils>@spruceid/siwe-parser>apg-js": true + } + }, + "@metamask/controller-utils>@spruceid/siwe-parser>apg-js": { + "globals": { + "mode": true + }, + "packages": { + "browserify>buffer": true, + "browserify>insert-module-globals>is-buffer": true } }, "@metamask/controllers>nanoid": { @@ -1243,8 +1273,8 @@ "setInterval": true }, "packages": { - "@metamask/controller-utils": true, "@metamask/gas-fee-controller>@metamask/base-controller": true, + "@metamask/gas-fee-controller>@metamask/controller-utils": true, "eth-query": true, "ethereumjs-util": true, "ethjs>ethjs-unit": true, @@ -1256,6 +1286,21 @@ "immer": true } }, + "@metamask/gas-fee-controller>@metamask/controller-utils": { + "globals": { + "console.error": true, + "fetch": true, + "setTimeout": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch": true, + "browserify>buffer": true, + "eslint>fast-deep-equal": true, + "eth-ens-namehash": true, + "ethereumjs-util": true, + "ethjs>ethjs-unit": true + } + }, "@metamask/jazzicon": { "globals": { "document.createElement": true, @@ -1354,8 +1399,8 @@ }, "@metamask/message-manager": { "packages": { + "@metamask/controller-utils": true, "@metamask/message-manager>@metamask/base-controller": true, - "@metamask/message-manager>@metamask/controller-utils": true, "@metamask/message-manager>jsonschema": true, "browserify>buffer": true, "browserify>events": true, @@ -1369,34 +1414,6 @@ "immer": true } }, - "@metamask/message-manager>@metamask/controller-utils": { - "globals": { - "console.error": true, - "fetch": true, - "setTimeout": true - }, - "packages": { - "@metamask/message-manager>@metamask/controller-utils>@metamask/utils": true, - "@spruceid/siwe-parser": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true, - "ethereumjs-util": true, - "ethjs>ethjs-unit": true - } - }, - "@metamask/message-manager>@metamask/controller-utils>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>superstruct": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/message-manager>jsonschema": { "packages": { "browserify>url": true @@ -1404,8 +1421,8 @@ }, "@metamask/notification-controller": { "packages": { - "@metamask/controller-utils": true, "@metamask/notification-controller>@metamask/base-controller": true, + "@metamask/notification-controller>@metamask/controller-utils": true, "@metamask/notification-controller>nanoid": true } }, @@ -1414,6 +1431,21 @@ "immer": true } }, + "@metamask/notification-controller>@metamask/controller-utils": { + "globals": { + "console.error": true, + "fetch": true, + "setTimeout": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch": true, + "browserify>buffer": true, + "eslint>fast-deep-equal": true, + "eth-ens-namehash": true, + "ethereumjs-util": true, + "ethjs>ethjs-unit": true + } + }, "@metamask/notification-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -1439,8 +1471,8 @@ "console.error": true }, "packages": { + "@metamask/controller-utils": true, "@metamask/permission-controller>@metamask/base-controller": true, - "@metamask/permission-controller>@metamask/controller-utils": true, "@metamask/permission-controller>nanoid": true, "deep-freeze-strict": true, "eth-rpc-errors": true, @@ -1453,34 +1485,6 @@ "immer": true } }, - "@metamask/permission-controller>@metamask/controller-utils": { - "globals": { - "console.error": true, - "fetch": true, - "setTimeout": true - }, - "packages": { - "@metamask/permission-controller>@metamask/controller-utils>@metamask/utils": true, - "@spruceid/siwe-parser": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true, - "ethereumjs-util": true, - "ethjs>ethjs-unit": true - } - }, - "@metamask/permission-controller>@metamask/controller-utils>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>superstruct": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -1492,8 +1496,8 @@ }, "packages": { "@metamask/base-controller": true, - "@metamask/controller-utils>isomorphic-fetch": true, "@metamask/phishing-controller>@metamask/controller-utils": true, + "@metamask/phishing-controller>isomorphic-fetch": true, "@metamask/phishing-warning>eth-phishing-detect": true, "punycode": true } @@ -1505,7 +1509,7 @@ "setTimeout": true }, "packages": { - "@metamask/controller-utils>isomorphic-fetch": true, + "@metamask/phishing-controller>isomorphic-fetch": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true, @@ -1513,6 +1517,25 @@ "ethjs>ethjs-unit": true } }, + "@metamask/phishing-controller>isomorphic-fetch": { + "globals": { + "fetch.bind": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch>whatwg-fetch": true + } + }, + "@metamask/phishing-controller>isomorphic-fetch>whatwg-fetch": { + "globals": { + "Blob": true, + "FileReader": true, + "FormData": true, + "URLSearchParams.prototype.isPrototypeOf": true, + "XMLHttpRequest": true, + "define": true, + "setTimeout": true + } + }, "@metamask/phishing-warning>eth-phishing-detect": { "packages": { "eslint>optionator>fast-levenshtein": true @@ -1665,13 +1688,28 @@ "@ethersproject/bignumber": true, "@ethersproject/providers": true, "@metamask/base-controller": true, - "@metamask/controller-utils": true, - "@metamask/controller-utils>isomorphic-fetch": true, + "@metamask/phishing-controller>isomorphic-fetch": true, + "@metamask/smart-transactions-controller>@metamask/controller-utils": true, "@metamask/smart-transactions-controller>bignumber.js": true, "fast-json-patch": true, "lodash": true } }, + "@metamask/smart-transactions-controller>@metamask/controller-utils": { + "globals": { + "console.error": true, + "fetch": true, + "setTimeout": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch": true, + "browserify>buffer": true, + "eslint>fast-deep-equal": true, + "eth-ens-namehash": true, + "ethereumjs-util": true, + "ethjs>ethjs-unit": true + } + }, "@metamask/smart-transactions-controller>@metamask/controllers>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2183,24 +2221,6 @@ "define": true } }, - "@spruceid/siwe-parser": { - "globals": { - "console.error": true, - "console.log": true - }, - "packages": { - "@spruceid/siwe-parser>apg-js": true - } - }, - "@spruceid/siwe-parser>apg-js": { - "globals": { - "mode": true - }, - "packages": { - "browserify>buffer": true, - "browserify>insert-module-globals>is-buffer": true - } - }, "@storybook/api>regenerator-runtime": { "globals": { "regeneratorRuntime": "write" diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 5967ac0ac..fa9312ae5 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -661,7 +661,7 @@ "@metamask/address-book-controller": { "packages": { "@metamask/address-book-controller>@metamask/base-controller": true, - "@metamask/controller-utils": true + "@metamask/address-book-controller>@metamask/controller-utils": true } }, "@metamask/address-book-controller>@metamask/base-controller": { @@ -669,6 +669,21 @@ "immer": true } }, + "@metamask/address-book-controller>@metamask/controller-utils": { + "globals": { + "console.error": true, + "fetch": true, + "setTimeout": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch": true, + "browserify>buffer": true, + "eslint>fast-deep-equal": true, + "eth-ens-namehash": true, + "ethereumjs-util": true, + "ethjs>ethjs-unit": true + } + }, "@metamask/announcement-controller": { "packages": { "@metamask/announcement-controller>@metamask/base-controller": true @@ -680,6 +695,9 @@ } }, "@metamask/approval-controller": { + "globals": { + "console.log": true + }, "packages": { "@metamask/approval-controller>nanoid": true, "@metamask/base-controller": true, @@ -747,7 +765,7 @@ "setTimeout": true }, "packages": { - "@metamask/controller-utils>isomorphic-fetch": true, + "@metamask/phishing-controller>isomorphic-fetch": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true, @@ -791,7 +809,8 @@ "setTimeout": true }, "packages": { - "@metamask/controller-utils>isomorphic-fetch": true, + "@metamask/controller-utils>@metamask/utils": true, + "@metamask/controller-utils>@spruceid/siwe-parser": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true, @@ -799,23 +818,34 @@ "ethjs>ethjs-unit": true } }, - "@metamask/controller-utils>isomorphic-fetch": { + "@metamask/controller-utils>@metamask/utils": { "globals": { - "fetch.bind": true + "TextDecoder": true, + "TextEncoder": true }, "packages": { - "@metamask/controller-utils>isomorphic-fetch>whatwg-fetch": true + "@metamask/utils>superstruct": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true } }, - "@metamask/controller-utils>isomorphic-fetch>whatwg-fetch": { + "@metamask/controller-utils>@spruceid/siwe-parser": { "globals": { - "Blob": true, - "FileReader": true, - "FormData": true, - "URLSearchParams.prototype.isPrototypeOf": true, - "XMLHttpRequest": true, - "define": true, - "setTimeout": true + "console.error": true, + "console.log": true + }, + "packages": { + "@metamask/controller-utils>@spruceid/siwe-parser>apg-js": true + } + }, + "@metamask/controller-utils>@spruceid/siwe-parser>apg-js": { + "globals": { + "mode": true + }, + "packages": { + "browserify>buffer": true, + "browserify>insert-module-globals>is-buffer": true } }, "@metamask/controllers>nanoid": { @@ -1243,8 +1273,8 @@ "setInterval": true }, "packages": { - "@metamask/controller-utils": true, "@metamask/gas-fee-controller>@metamask/base-controller": true, + "@metamask/gas-fee-controller>@metamask/controller-utils": true, "eth-query": true, "ethereumjs-util": true, "ethjs>ethjs-unit": true, @@ -1256,6 +1286,21 @@ "immer": true } }, + "@metamask/gas-fee-controller>@metamask/controller-utils": { + "globals": { + "console.error": true, + "fetch": true, + "setTimeout": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch": true, + "browserify>buffer": true, + "eslint>fast-deep-equal": true, + "eth-ens-namehash": true, + "ethereumjs-util": true, + "ethjs>ethjs-unit": true + } + }, "@metamask/jazzicon": { "globals": { "document.createElement": true, @@ -1354,8 +1399,8 @@ }, "@metamask/message-manager": { "packages": { + "@metamask/controller-utils": true, "@metamask/message-manager>@metamask/base-controller": true, - "@metamask/message-manager>@metamask/controller-utils": true, "@metamask/message-manager>jsonschema": true, "browserify>buffer": true, "browserify>events": true, @@ -1369,34 +1414,6 @@ "immer": true } }, - "@metamask/message-manager>@metamask/controller-utils": { - "globals": { - "console.error": true, - "fetch": true, - "setTimeout": true - }, - "packages": { - "@metamask/message-manager>@metamask/controller-utils>@metamask/utils": true, - "@spruceid/siwe-parser": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true, - "ethereumjs-util": true, - "ethjs>ethjs-unit": true - } - }, - "@metamask/message-manager>@metamask/controller-utils>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>superstruct": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/message-manager>jsonschema": { "packages": { "browserify>url": true @@ -1404,8 +1421,8 @@ }, "@metamask/notification-controller": { "packages": { - "@metamask/controller-utils": true, "@metamask/notification-controller>@metamask/base-controller": true, + "@metamask/notification-controller>@metamask/controller-utils": true, "@metamask/notification-controller>nanoid": true } }, @@ -1414,6 +1431,21 @@ "immer": true } }, + "@metamask/notification-controller>@metamask/controller-utils": { + "globals": { + "console.error": true, + "fetch": true, + "setTimeout": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch": true, + "browserify>buffer": true, + "eslint>fast-deep-equal": true, + "eth-ens-namehash": true, + "ethereumjs-util": true, + "ethjs>ethjs-unit": true + } + }, "@metamask/notification-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -1439,8 +1471,8 @@ "console.error": true }, "packages": { + "@metamask/controller-utils": true, "@metamask/permission-controller>@metamask/base-controller": true, - "@metamask/permission-controller>@metamask/controller-utils": true, "@metamask/permission-controller>nanoid": true, "deep-freeze-strict": true, "eth-rpc-errors": true, @@ -1453,34 +1485,6 @@ "immer": true } }, - "@metamask/permission-controller>@metamask/controller-utils": { - "globals": { - "console.error": true, - "fetch": true, - "setTimeout": true - }, - "packages": { - "@metamask/permission-controller>@metamask/controller-utils>@metamask/utils": true, - "@spruceid/siwe-parser": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true, - "ethereumjs-util": true, - "ethjs>ethjs-unit": true - } - }, - "@metamask/permission-controller>@metamask/controller-utils>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>superstruct": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -1492,8 +1496,8 @@ }, "packages": { "@metamask/base-controller": true, - "@metamask/controller-utils>isomorphic-fetch": true, "@metamask/phishing-controller>@metamask/controller-utils": true, + "@metamask/phishing-controller>isomorphic-fetch": true, "@metamask/phishing-warning>eth-phishing-detect": true, "punycode": true } @@ -1505,7 +1509,7 @@ "setTimeout": true }, "packages": { - "@metamask/controller-utils>isomorphic-fetch": true, + "@metamask/phishing-controller>isomorphic-fetch": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true, @@ -1513,6 +1517,25 @@ "ethjs>ethjs-unit": true } }, + "@metamask/phishing-controller>isomorphic-fetch": { + "globals": { + "fetch.bind": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch>whatwg-fetch": true + } + }, + "@metamask/phishing-controller>isomorphic-fetch>whatwg-fetch": { + "globals": { + "Blob": true, + "FileReader": true, + "FormData": true, + "URLSearchParams.prototype.isPrototypeOf": true, + "XMLHttpRequest": true, + "define": true, + "setTimeout": true + } + }, "@metamask/phishing-warning>eth-phishing-detect": { "packages": { "eslint>optionator>fast-levenshtein": true @@ -1665,13 +1688,28 @@ "@ethersproject/bignumber": true, "@ethersproject/providers": true, "@metamask/base-controller": true, - "@metamask/controller-utils": true, - "@metamask/controller-utils>isomorphic-fetch": true, + "@metamask/phishing-controller>isomorphic-fetch": true, + "@metamask/smart-transactions-controller>@metamask/controller-utils": true, "@metamask/smart-transactions-controller>bignumber.js": true, "fast-json-patch": true, "lodash": true } }, + "@metamask/smart-transactions-controller>@metamask/controller-utils": { + "globals": { + "console.error": true, + "fetch": true, + "setTimeout": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch": true, + "browserify>buffer": true, + "eslint>fast-deep-equal": true, + "eth-ens-namehash": true, + "ethereumjs-util": true, + "ethjs>ethjs-unit": true + } + }, "@metamask/smart-transactions-controller>@metamask/controllers>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2183,24 +2221,6 @@ "define": true } }, - "@spruceid/siwe-parser": { - "globals": { - "console.error": true, - "console.log": true - }, - "packages": { - "@spruceid/siwe-parser>apg-js": true - } - }, - "@spruceid/siwe-parser>apg-js": { - "globals": { - "mode": true - }, - "packages": { - "browserify>buffer": true, - "browserify>insert-module-globals>is-buffer": true - } - }, "@storybook/api>regenerator-runtime": { "globals": { "regeneratorRuntime": "write" diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 98b889720..dd174c63d 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -661,7 +661,7 @@ "@metamask/address-book-controller": { "packages": { "@metamask/address-book-controller>@metamask/base-controller": true, - "@metamask/controller-utils": true + "@metamask/address-book-controller>@metamask/controller-utils": true } }, "@metamask/address-book-controller>@metamask/base-controller": { @@ -669,6 +669,21 @@ "immer": true } }, + "@metamask/address-book-controller>@metamask/controller-utils": { + "globals": { + "console.error": true, + "fetch": true, + "setTimeout": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch": true, + "browserify>buffer": true, + "eslint>fast-deep-equal": true, + "eth-ens-namehash": true, + "ethereumjs-util": true, + "ethjs>ethjs-unit": true + } + }, "@metamask/announcement-controller": { "packages": { "@metamask/announcement-controller>@metamask/base-controller": true @@ -680,6 +695,9 @@ } }, "@metamask/approval-controller": { + "globals": { + "console.log": true + }, "packages": { "@metamask/approval-controller>nanoid": true, "@metamask/base-controller": true, @@ -747,7 +765,7 @@ "setTimeout": true }, "packages": { - "@metamask/controller-utils>isomorphic-fetch": true, + "@metamask/phishing-controller>isomorphic-fetch": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true, @@ -791,7 +809,8 @@ "setTimeout": true }, "packages": { - "@metamask/controller-utils>isomorphic-fetch": true, + "@metamask/controller-utils>@metamask/utils": true, + "@metamask/controller-utils>@spruceid/siwe-parser": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true, @@ -799,23 +818,34 @@ "ethjs>ethjs-unit": true } }, - "@metamask/controller-utils>isomorphic-fetch": { + "@metamask/controller-utils>@metamask/utils": { "globals": { - "fetch.bind": true + "TextDecoder": true, + "TextEncoder": true }, "packages": { - "@metamask/controller-utils>isomorphic-fetch>whatwg-fetch": true + "@metamask/utils>superstruct": true, + "browserify>buffer": true, + "nock>debug": true, + "semver": true } }, - "@metamask/controller-utils>isomorphic-fetch>whatwg-fetch": { + "@metamask/controller-utils>@spruceid/siwe-parser": { "globals": { - "Blob": true, - "FileReader": true, - "FormData": true, - "URLSearchParams.prototype.isPrototypeOf": true, - "XMLHttpRequest": true, - "define": true, - "setTimeout": true + "console.error": true, + "console.log": true + }, + "packages": { + "@metamask/controller-utils>@spruceid/siwe-parser>apg-js": true + } + }, + "@metamask/controller-utils>@spruceid/siwe-parser>apg-js": { + "globals": { + "mode": true + }, + "packages": { + "browserify>buffer": true, + "browserify>insert-module-globals>is-buffer": true } }, "@metamask/controllers>nanoid": { @@ -1171,8 +1201,8 @@ "setInterval": true }, "packages": { - "@metamask/controller-utils": true, "@metamask/gas-fee-controller>@metamask/base-controller": true, + "@metamask/gas-fee-controller>@metamask/controller-utils": true, "eth-query": true, "ethereumjs-util": true, "ethjs>ethjs-unit": true, @@ -1184,6 +1214,21 @@ "immer": true } }, + "@metamask/gas-fee-controller>@metamask/controller-utils": { + "globals": { + "console.error": true, + "fetch": true, + "setTimeout": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch": true, + "browserify>buffer": true, + "eslint>fast-deep-equal": true, + "eth-ens-namehash": true, + "ethereumjs-util": true, + "ethjs>ethjs-unit": true + } + }, "@metamask/jazzicon": { "globals": { "document.createElement": true, @@ -1282,8 +1327,8 @@ }, "@metamask/message-manager": { "packages": { + "@metamask/controller-utils": true, "@metamask/message-manager>@metamask/base-controller": true, - "@metamask/message-manager>@metamask/controller-utils": true, "@metamask/message-manager>jsonschema": true, "browserify>buffer": true, "browserify>events": true, @@ -1297,34 +1342,6 @@ "immer": true } }, - "@metamask/message-manager>@metamask/controller-utils": { - "globals": { - "console.error": true, - "fetch": true, - "setTimeout": true - }, - "packages": { - "@metamask/message-manager>@metamask/controller-utils>@metamask/utils": true, - "@spruceid/siwe-parser": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true, - "ethereumjs-util": true, - "ethjs>ethjs-unit": true - } - }, - "@metamask/message-manager>@metamask/controller-utils>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>superstruct": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/message-manager>jsonschema": { "packages": { "browserify>url": true @@ -1355,8 +1372,8 @@ "console.error": true }, "packages": { + "@metamask/controller-utils": true, "@metamask/permission-controller>@metamask/base-controller": true, - "@metamask/permission-controller>@metamask/controller-utils": true, "@metamask/permission-controller>nanoid": true, "deep-freeze-strict": true, "eth-rpc-errors": true, @@ -1369,34 +1386,6 @@ "immer": true } }, - "@metamask/permission-controller>@metamask/controller-utils": { - "globals": { - "console.error": true, - "fetch": true, - "setTimeout": true - }, - "packages": { - "@metamask/permission-controller>@metamask/controller-utils>@metamask/utils": true, - "@spruceid/siwe-parser": true, - "browserify>buffer": true, - "eslint>fast-deep-equal": true, - "eth-ens-namehash": true, - "ethereumjs-util": true, - "ethjs>ethjs-unit": true - } - }, - "@metamask/permission-controller>@metamask/controller-utils>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>superstruct": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -1408,8 +1397,8 @@ }, "packages": { "@metamask/base-controller": true, - "@metamask/controller-utils>isomorphic-fetch": true, "@metamask/phishing-controller>@metamask/controller-utils": true, + "@metamask/phishing-controller>isomorphic-fetch": true, "@metamask/phishing-warning>eth-phishing-detect": true, "punycode": true } @@ -1421,7 +1410,7 @@ "setTimeout": true }, "packages": { - "@metamask/controller-utils>isomorphic-fetch": true, + "@metamask/phishing-controller>isomorphic-fetch": true, "browserify>buffer": true, "eslint>fast-deep-equal": true, "eth-ens-namehash": true, @@ -1429,6 +1418,25 @@ "ethjs>ethjs-unit": true } }, + "@metamask/phishing-controller>isomorphic-fetch": { + "globals": { + "fetch.bind": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch>whatwg-fetch": true + } + }, + "@metamask/phishing-controller>isomorphic-fetch>whatwg-fetch": { + "globals": { + "Blob": true, + "FileReader": true, + "FormData": true, + "URLSearchParams.prototype.isPrototypeOf": true, + "XMLHttpRequest": true, + "define": true, + "setTimeout": true + } + }, "@metamask/phishing-warning>eth-phishing-detect": { "packages": { "eslint>optionator>fast-levenshtein": true @@ -1492,13 +1500,28 @@ "@ethersproject/bignumber": true, "@ethersproject/providers": true, "@metamask/base-controller": true, - "@metamask/controller-utils": true, - "@metamask/controller-utils>isomorphic-fetch": true, + "@metamask/phishing-controller>isomorphic-fetch": true, + "@metamask/smart-transactions-controller>@metamask/controller-utils": true, "@metamask/smart-transactions-controller>bignumber.js": true, "fast-json-patch": true, "lodash": true } }, + "@metamask/smart-transactions-controller>@metamask/controller-utils": { + "globals": { + "console.error": true, + "fetch": true, + "setTimeout": true + }, + "packages": { + "@metamask/phishing-controller>isomorphic-fetch": true, + "browserify>buffer": true, + "eslint>fast-deep-equal": true, + "eth-ens-namehash": true, + "ethereumjs-util": true, + "ethjs>ethjs-unit": true + } + }, "@metamask/smart-transactions-controller>@metamask/controllers>nanoid": { "globals": { "crypto.getRandomValues": true @@ -1770,24 +1793,6 @@ "define": true } }, - "@spruceid/siwe-parser": { - "globals": { - "console.error": true, - "console.log": true - }, - "packages": { - "@spruceid/siwe-parser>apg-js": true - } - }, - "@spruceid/siwe-parser>apg-js": { - "globals": { - "mode": true - }, - "packages": { - "browserify>buffer": true, - "browserify>insert-module-globals>is-buffer": true - } - }, "@storybook/api>regenerator-runtime": { "globals": { "regeneratorRuntime": "write" diff --git a/package.json b/package.json index 95d04fb04..6dc22b4da 100644 --- a/package.json +++ b/package.json @@ -231,7 +231,7 @@ "@metamask/assets-controllers": "^4.0.1", "@metamask/base-controller": "^1.0.0", "@metamask/contract-metadata": "^2.3.1", - "@metamask/controller-utils": "^1.0.0", + "@metamask/controller-utils": "^3.1.0", "@metamask/design-tokens": "^1.9.0", "@metamask/desktop": "^0.3.0", "@metamask/eth-json-rpc-infura": "^8.0.0", @@ -245,7 +245,7 @@ "@metamask/jazzicon": "^2.0.0", "@metamask/key-tree": "^7.0.0", "@metamask/logo": "^3.1.1", - "@metamask/message-manager": "^2.0.0", + "@metamask/message-manager": "^2.1.0", "@metamask/metamask-eth-abis": "^3.0.0", "@metamask/notification-controller": "^1.0.0", "@metamask/obs-store": "^8.0.0", @@ -273,7 +273,6 @@ "@sentry/integrations": "^6.0.0", "@sentry/types": "^6.0.1", "@sentry/utils": "^6.0.1", - "@spruceid/siwe-parser": "^1.1.3", "@truffle/codec": "^0.14.12", "@truffle/decoder": "^5.3.5", "@zxing/browser": "^0.0.10", diff --git a/shared/modules/siwe.js b/shared/modules/siwe.js index 6edbc7d75..5d719d243 100644 --- a/shared/modules/siwe.js +++ b/shared/modules/siwe.js @@ -1,55 +1,3 @@ -import { ParsedMessage } from '@spruceid/siwe-parser'; -import log from 'loglevel'; -import { stripHexPrefix } from './hexstring-utils'; - -const msgHexToText = (hex) => { - try { - const stripped = stripHexPrefix(hex); - const buff = Buffer.from(stripped, 'hex'); - return buff.length === 32 ? hex : buff.toString('utf8'); - } catch (e) { - log.error(e); - return hex; - } -}; - -/** - * A locally defined object used to provide data to identify a Sign-In With Ethereum (SIWE)(EIP-4361) message and provide the parsed message - * - * @typedef localSIWEObject - * @param {boolean} isSIWEMessage - Does the intercepted message conform to the SIWE specification? - * @param {ParsedMessage} parsedMessage - The data parsed out of the message - */ - -/** - * This function intercepts a sign message, detects if it's a - * Sign-In With Ethereum (SIWE)(EIP-4361) message, and returns an object with - * relevant SIWE data. - * - * {@see {@link https://eips.ethereum.org/EIPS/eip-4361}} - * - * @param {object} msgParams - The params of the message to sign - * @returns {localSIWEObject} - */ -export const detectSIWE = (msgParams) => { - try { - const { data } = msgParams; - const message = msgHexToText(data); - const parsedMessage = new ParsedMessage(message); - - return { - isSIWEMessage: true, - parsedMessage, - }; - } catch (error) { - // ignore error, it's not a valid SIWE message - return { - isSIWEMessage: false, - parsedMessage: null, - }; - } -}; - /** * Takes in a parsed Sign-In with Ethereum Message (EIP-4361) * and generates an array of label-value pairs diff --git a/yarn.lock b/yarn.lock index da88ae8bb..31bf1eb1b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4036,18 +4036,18 @@ __metadata: languageName: node linkType: hard -"@metamask/message-manager@npm:^2.0.0": - version: 2.0.0 - resolution: "@metamask/message-manager@npm:2.0.0" +"@metamask/message-manager@npm:^2.1.0": + version: 2.1.0 + resolution: "@metamask/message-manager@npm:2.1.0" dependencies: "@metamask/base-controller": ^2.0.0 - "@metamask/controller-utils": ^3.0.0 + "@metamask/controller-utils": ^3.1.0 "@types/uuid": ^8.3.0 eth-sig-util: ^3.0.0 ethereumjs-util: ^7.0.10 jsonschema: ^1.2.4 uuid: ^8.3.2 - checksum: f130b5c58fbbb5ccd69da32cfa43839a09dec906974c6d0f6e2d46f15d1a872c564b0c880aac2979b7ffc8d00bcf328bf1989cb133cc41bc612e1e6e16ef9ef5 + checksum: f3a233a84aec73051f8f1183dab32c4d9a976edaa3c6461b118a8e6f20cf43f8757827ad6c877aed635ef850944ce054af03b34592f5b72f5d0667fa8b179dc9 languageName: node linkType: hard @@ -5117,7 +5117,7 @@ __metadata: languageName: node linkType: hard -"@spruceid/siwe-parser@npm:1.1.3, @spruceid/siwe-parser@npm:^1.1.3": +"@spruceid/siwe-parser@npm:1.1.3": version: 1.1.3 resolution: "@spruceid/siwe-parser@npm:1.1.3" dependencies: @@ -24283,7 +24283,7 @@ __metadata: "@metamask/auto-changelog": ^2.1.0 "@metamask/base-controller": ^1.0.0 "@metamask/contract-metadata": ^2.3.1 - "@metamask/controller-utils": ^1.0.0 + "@metamask/controller-utils": ^3.1.0 "@metamask/design-tokens": ^1.9.0 "@metamask/desktop": ^0.3.0 "@metamask/eslint-config": ^9.0.0 @@ -24303,7 +24303,7 @@ __metadata: "@metamask/jazzicon": ^2.0.0 "@metamask/key-tree": ^7.0.0 "@metamask/logo": ^3.1.1 - "@metamask/message-manager": ^2.0.0 + "@metamask/message-manager": ^2.1.0 "@metamask/metamask-eth-abis": ^3.0.0 "@metamask/notification-controller": ^1.0.0 "@metamask/obs-store": ^8.0.0 @@ -24334,7 +24334,6 @@ __metadata: "@sentry/integrations": ^6.0.0 "@sentry/types": ^6.0.1 "@sentry/utils": ^6.0.1 - "@spruceid/siwe-parser": ^1.1.3 "@storybook/addon-a11y": ^6.5.13 "@storybook/addon-actions": ^6.5.13 "@storybook/addon-essentials": ^6.5.13