Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
74a0c70
feat: added 'changePassword' method to metamask-controller & redux ac…
lwin-kyaw May 12, 2025
566b088
Merge remote-tracking branch 'origin/feat/create-wallet-social' into …
lwin-kyaw May 13, 2025
3de5273
feat: added password change ui
lionellbriones May 13, 2025
60d709d
feat: integrate 'ChangePassword' with UI
lwin-kyaw May 13, 2025
98f3957
Merge remote-tracking branch 'origin/feat/create-wallet-social' into …
lwin-kyaw May 13, 2025
27912d2
fix: fixed onboarding routes flow
lwin-kyaw May 13, 2025
25324dd
chanMerge remote-tracking branch 'origin/feat/create-wallet-social' i…
lwin-kyaw May 21, 2025
57e3692
fix: fixed lint
lwin-kyaw May 21, 2025
efbbfdd
Merge remote-tracking branch 'origin/feat/create-wallet-social' into …
lwin-kyaw May 23, 2025
0647869
Merge remote-tracking branch 'origin/feat/create-wallet-social' into …
lwin-kyaw May 23, 2025
d005759
fix: fixed changePassword and tests
lwin-kyaw May 23, 2025
cdd9c41
Merge remote-tracking branch 'origin/feat/create-wallet-social' into …
lwin-kyaw May 23, 2025
be17505
fix: removed duplicated setting routes
lwin-kyaw May 23, 2025
2462fd0
fix: divs to Box component
lionellbriones May 23, 2025
db82bae
test: updated changePassword test
lwin-kyaw May 23, 2025
efba5bd
Merge remote-tracking branch 'origin/feat/create-wallet-social' into …
lwin-kyaw May 23, 2025
5dfa522
Merge remote-tracking branch 'origin/feat/create-wallet-social' into …
lwin-kyaw May 26, 2025
f28bcb7
Merge remote-tracking branch 'origin/feat/create-wallet-social' into …
lwin-kyaw May 26, 2025
98deaa6
Merge branch 'feat/create-wallet-social' into feat/change-password
lionellbriones May 26, 2025
5e629df
Merge branch 'feat/create-wallet-social' into feat/change-password
lionellbriones May 27, 2025
dce5c79
chore: update copywriting on srp setting description
lionellbriones May 27, 2025
6e054a2
Merge remote-tracking branch 'origin/feat/create-wallet-social' into …
lwin-kyaw May 28, 2025
9a9eb5c
Merge remote-tracking branch 'origin/feat/create-wallet-social' into …
lwin-kyaw May 28, 2025
dcddd53
feat: add banners for login with and srp backup status
lionellbriones May 28, 2025
77852b0
feat: added social login banner at privacy & security page
lwin-kyaw May 28, 2025
fb6ea41
fix: fixed SRP backup state in privacy settings page
lwin-kyaw May 28, 2025
4b94ab9
Merge branch 'feat/create-wallet-social' into feat/change-password
lionellbriones May 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions app/_locales/en_GB/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ import { BRIDGE_API_BASE_URL } from '../../shared/constants/bridge';
import { MultichainWalletSnapClient } from '../../shared/lib/accounts';
import { SOLANA_WALLET_SNAP_ID } from '../../shared/lib/accounts/solana-wallet-snap';
///: END:ONLY_INCLUDE_IF
import { FirstTimeFlowType } from '../../shared/constants/onboarding';
import {
///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
handleMMITransactionUpdate,
Expand Down Expand Up @@ -3717,6 +3718,7 @@ export default class MetamaskController extends EventEmitter {
createSeedPhraseBackup: this.createSeedPhraseBackup.bind(this),
fetchAllSeedPhrases: this.fetchAllSeedPhrases.bind(this),
updateBackupMetadataState: this.updateBackupMetadataState.bind(this),
changePassword: this.changePassword.bind(this),

// hardware wallets
connectHardware: this.connectHardware.bind(this),
Expand Down Expand Up @@ -4970,6 +4972,33 @@ export default class MetamaskController extends EventEmitter {
);
}

/**
* Changes the password of the current wallet.
*
* If the wallet is created with social login, the password is changed for the seedless onboarding flow and sync across the devices too.
*
* @param {string} newPassword - The new password.
* @param {string} oldPassword - The old password.
* @returns {Promise<void>}
*/
async changePassword(newPassword, oldPassword) {
const { firstTimeFlowType } = this.onboardingController.state;

if (
firstTimeFlowType === FirstTimeFlowType.socialCreate ||
firstTimeFlowType === FirstTimeFlowType.socialImport
) {
// change password for the social login flow
await this.seedlessOnboardingController.changePassword(
newPassword,
oldPassword,
);
}

// also update the vault password for keyring controller
await this.keyringController.changePassword(newPassword);
}

//=============================================================================
// VAULT / KEYRING RELATED METHODS
//=============================================================================
Expand Down
47 changes: 47 additions & 0 deletions app/scripts/metamask-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import {
EndowmentTypes,
RestrictedEthMethods,
} from '../../shared/constants/permissions';
import { FirstTimeFlowType } from '../../shared/constants/onboarding';
import { deferredPromise } from './lib/util';
import { METAMASK_COOKIE_HANDLER } from './constants/stream';
import MetaMaskController from './metamask-controller';
Expand Down Expand Up @@ -799,6 +800,52 @@ describe('MetaMaskController', () => {
});
});

describe('#changePassword', () => {
it('should change the password for both seedless onboarding and keyring controller', async () => {
const oldPassword = 'old-password';
const newPassword = 'new-password';

metamaskController.onboardingController.setFirstTimeFlowType(
FirstTimeFlowType.socialCreate,
);

await metamaskController.createNewVaultAndKeychain(oldPassword);

const changePwdSeedlessOnboardingSpy = jest
.spyOn(
metamaskController.seedlessOnboardingController,
'changePassword',
)
.mockResolvedValueOnce();
const changePwdKeyringControllerSpy = jest
.spyOn(metamaskController.keyringController, 'changePassword')
.mockResolvedValueOnce();

await metamaskController.changePassword(newPassword, oldPassword);

expect(changePwdSeedlessOnboardingSpy).toHaveBeenCalledWith(
newPassword,
oldPassword,
);
expect(changePwdKeyringControllerSpy).toHaveBeenCalledWith(newPassword);
});

it('should change the password for Keyring Vault for the SRP flow', async () => {
const oldPassword = 'old-password';
const newPassword = 'new-password';

await metamaskController.createNewVaultAndKeychain(oldPassword);

const changePwdKeyringControllerSpy = jest
.spyOn(metamaskController.keyringController, 'changePassword')
.mockResolvedValueOnce();

await metamaskController.changePassword(newPassword, oldPassword);

expect(changePwdKeyringControllerSpy).toHaveBeenCalledWith(newPassword);
});
});

describe('#createNewVaultAndRestore', () => {
it('should be able to call newVaultAndRestore despite a mistake.', async () => {
const password = 'what-what-what';
Expand Down
1 change: 1 addition & 0 deletions test/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ process.env.PUSH_NOTIFICATIONS_SERVICE_URL =
process.env.PORTFOLIO_URL = 'https://portfolio.test';
process.env.METAMASK_VERSION = 'MOCK_VERSION';
process.env.TZ = 'UTC';
process.env.WEB3AUTH_NETWORK = 'sapphire_devnet';
4 changes: 4 additions & 0 deletions ui/helpers/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export const REVEAL_SRP_LIST_ROUTE =
PATH_NAME_MAP[REVEAL_SRP_LIST_ROUTE] =
'Reveal Secret Recovery Phrase List Page';

export const SECURITY_PASSWORD_CHANGE_ROUTE =
'/settings/security-and-privacy/password-change';
PATH_NAME_MAP[SECURITY_PASSWORD_CHANGE_ROUTE] = 'Change Password';

export const BACKUPANDSYNC_ROUTE =
'/settings/security-and-privacy/backup-and-sync';
PATH_NAME_MAP[BACKUPANDSYNC_ROUTE] = 'Backup And Sync Settings Page';
Expand Down
1 change: 1 addition & 0 deletions ui/pages/settings/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@import 'networks-tab/index';
@import 'settings-tab/index';
@import 'contact-list-tab/index';
@import 'security-tab/index';

.settings-page {
position: relative;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import ChangePassword from './change-password';

export default {
title: 'Pages/SettingsPage/ChangePassword',
};

export const DefaultStory = () => <ChangePassword />;

DefaultStory.storyName = 'Default';
Loading
Loading