1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

[MMI] Prevent multiple instances of MM at the same browser (#17856)

This commit is contained in:
Albert Olivé 2023-03-02 17:17:45 +01:00 committed by GitHub
parent 6b15d0bae7
commit 9ba0b50b9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View File

@ -7,6 +7,8 @@ import {
METAMASK_BETA_CHROME_ID,
METAMASK_PROD_CHROME_ID,
METAMASK_FLASK_CHROME_ID,
METAMASK_MMI_PROD_CHROME_ID,
METAMASK_MMI_BETA_CHROME_ID,
} from '../../shared/constants/app';
import {
checkForMultipleVersionsRunning,
@ -38,7 +40,7 @@ describe('multiple instances running detector', function () {
it('should send ping message to multiple instances', async function () {
await checkForMultipleVersionsRunning();
assert(sendMessageStub.calledTwice);
assert(sendMessageStub.callCount === 4);
assert(
sendMessageStub
.getCall(0)
@ -49,6 +51,16 @@ describe('multiple instances running detector', function () {
.getCall(1)
.calledWithExactly(METAMASK_FLASK_CHROME_ID, PING_MESSAGE),
);
assert(
sendMessageStub
.getCall(2)
.calledWithExactly(METAMASK_MMI_BETA_CHROME_ID, PING_MESSAGE),
);
assert(
sendMessageStub
.getCall(3)
.calledWithExactly(METAMASK_MMI_PROD_CHROME_ID, PING_MESSAGE),
);
});
it('should not send ping message if platform is not Chrome or Firefox', async function () {

View File

@ -64,6 +64,17 @@ export const MESSAGE_TYPE = {
///: BEGIN:ONLY_INCLUDE_IN(desktop)
ENABLE_DESKTOP: `metamask_enableDesktop`,
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(mmi)
MMI_AUTHENTICATE: 'metamaskinstitutional_authenticate',
MMI_REAUTHENTICATE: 'metamaskinstitutional_reauthenticate',
MMI_REFRESH_TOKEN: 'metamaskinstitutional_refresh_token',
MMI_SUPPORTED: 'metamaskinstitutional_supported',
MMI_PORTFOLIO: 'metamaskinstitutional_portfolio',
MMI_OPEN_SWAPS: 'metamaskinstitutional_open_swaps',
MMI_CHECK_IF_TOKEN_IS_PRESENT: 'metamaskinstitutional_checkIfTokenIsPresent',
MMI_SET_ACCOUNT_AND_NETWORK: 'metamaskinstitutional_setAccountAndNetwork',
MMI_OPEN_ADD_HARDWARE_WALLET: 'metamaskinstitutional_openAddHardwareWallet',
///: END:ONLY_INCLUDE_IN
} as const;
///: BEGIN:ONLY_INCLUDE_IN(flask)
@ -95,10 +106,15 @@ export const METAMASK_BETA_CHROME_ID = 'pbbkamfgmaedccnfkmjcofcecjhfgldn';
export const METAMASK_PROD_CHROME_ID = 'nkbihfbeogaeaoehlefnkodbefgpgknn';
export const METAMASK_FLASK_CHROME_ID = 'ljfoeinjpaedjfecbmggjgodbgkmjkjk';
export const METAMASK_MMI_BETA_CHROME_ID = 'kmbhbcbadohhhgdgihejcicbgcehoaeg';
export const METAMASK_MMI_PROD_CHROME_ID = 'ikkihjamdhfiojpdbnfllpjigpneipbc';
export const CHROME_BUILD_IDS = [
METAMASK_BETA_CHROME_ID,
METAMASK_PROD_CHROME_ID,
METAMASK_FLASK_CHROME_ID,
METAMASK_MMI_BETA_CHROME_ID,
METAMASK_MMI_PROD_CHROME_ID,
] as const;
const METAMASK_BETA_FIREFOX_ID = 'webextension-beta@metamask.io';