Skip to content

Commit 2c10a6d

Browse files
release(runway): cherry-pick fix: cp-13.11.0 replace deeplink with signed link (#38326)
- fix: cp-13.11.0 replace deeplink with signed link (#38270) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** Use signed links for qr code <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/38270?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Switch QR code to signed onboarding URLs (Apple/Google/SRP) selected by socialType and update tests accordingly. > > - **UI – `ui/components/app/rewards/RewardsQRCode.tsx`**: > - Use signed URLs for QR data via `APPLE_ONBOARDING_URL`, `GOOGLE_ONBOARDING_URL`, and `SRP_ONBOARDING_URL` based on `socialType`. > - Import new constants from `./utils/constants`. > - **Tests – `ui/components/app/rewards/RewardsQRCode.test.tsx`**: > - Update assertions to compare against signed URLs from constants (accounting for HTML entity encoding). > - Add test case for Apple social type. > - **Constants – `ui/components/app/rewards/utils/constants.ts`**: > - Add signed onboarding URL constants: `GOOGLE_ONBOARDING_URL`, `APPLE_ONBOARDING_URL`, `SRP_ONBOARDING_URL`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 58fb6e4. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> [85115d6](85115d6) Co-authored-by: sophieqgu <[email protected]>
1 parent 6e3fef1 commit 2c10a6d

File tree

3 files changed

+43
-11
lines changed

3 files changed

+43
-11
lines changed

ui/components/app/rewards/RewardsQRCode.test.tsx

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import { useSelector, useDispatch } from 'react-redux';
55
import { setOnboardingModalOpen } from '../../../ducks/rewards';
66
import { getSocialLoginType } from '../../../selectors/seedless-onboarding/social-sync';
77
import RewardsQRCode from './RewardsQRCode';
8+
import {
9+
GOOGLE_ONBOARDING_URL,
10+
SRP_ONBOARDING_URL,
11+
APPLE_ONBOARDING_URL,
12+
} from './utils/constants';
813

914
// Mock react-redux hooks
1015
jest.mock('react-redux', () => ({
@@ -78,7 +83,7 @@ describe('RewardsQRCode', () => {
7883
expect(mockUseSelector).toHaveBeenCalledWith(getSocialLoginType);
7984
});
8085

81-
it('encodes socialType in QR data when provided', () => {
86+
it('encodes Google socialType in QR data when provided', () => {
8287
mockUseSelector.mockImplementation((selector) => {
8388
if (selector === getSocialLoginType) {
8489
return 'google';
@@ -91,9 +96,25 @@ describe('RewardsQRCode', () => {
9196
const qrImageContainer = screen.getByTestId('qr-code-image');
9297
expect(qrImageContainer).toBeInTheDocument();
9398
// The inner HTML is produced by our qr generator mock and includes data-qr
94-
expect(qrImageContainer.innerHTML).toContain(
95-
'data-qr="https://link.metamask.io/onboarding?type=google&amp;existing=true"',
96-
);
99+
// InnerHTML encodes ampersands, so compare against encoded version
100+
const encoded = GOOGLE_ONBOARDING_URL.replaceAll('&', '&amp;');
101+
expect(qrImageContainer.innerHTML).toContain(`data-qr="${encoded}"`);
102+
});
103+
104+
it('encodes Apple socialType in QR data when provided', () => {
105+
mockUseSelector.mockImplementation((selector) => {
106+
if (selector === getSocialLoginType) {
107+
return 'apple';
108+
}
109+
return undefined;
110+
});
111+
112+
render(<RewardsQRCode />);
113+
114+
const qrImageContainer = screen.getByTestId('qr-code-image');
115+
expect(qrImageContainer).toBeInTheDocument();
116+
const encoded = APPLE_ONBOARDING_URL.replaceAll('&', '&amp;');
117+
expect(qrImageContainer.innerHTML).toContain(`data-qr="${encoded}"`);
97118
});
98119

99120
it('defaults to SRP flow in QR data when socialType is absent', () => {
@@ -108,9 +129,8 @@ describe('RewardsQRCode', () => {
108129

109130
const qrImageContainer = screen.getByTestId('qr-code-image');
110131
expect(qrImageContainer).toBeInTheDocument();
111-
expect(qrImageContainer.innerHTML).toContain(
112-
'data-qr="https://link.metamask.io/onboarding?type=srp"',
113-
);
132+
const encoded = SRP_ONBOARDING_URL.replaceAll('&', '&amp;');
133+
expect(qrImageContainer.innerHTML).toContain(`data-qr="${encoded}"`);
114134
});
115135

116136
it('dispatches close action when clicking Got it', () => {

ui/components/app/rewards/RewardsQRCode.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import { getSocialLoginType } from '../../../selectors/seedless-onboarding/socia
1313
import { useI18nContext } from '../../../hooks/useI18nContext';
1414
import { setOnboardingModalOpen } from '../../../ducks/rewards';
1515
import { ModalBody } from '../../component-library/modal-body/modal-body';
16+
import {
17+
APPLE_ONBOARDING_URL,
18+
GOOGLE_ONBOARDING_URL,
19+
SRP_ONBOARDING_URL,
20+
} from './utils/constants';
1621

1722
const QrCodeView = ({ data }: { data: string }) => {
1823
const qrImage = qrCode(0, 'M');
@@ -48,11 +53,12 @@ export default function RewardsQRCode() {
4853
}, [dispatch]);
4954

5055
const dataToEncode = useMemo(() => {
51-
if (socialType) {
52-
return `https://link.metamask.io/onboarding?type=${socialType}&existing=true`;
56+
if (socialType === 'apple') {
57+
return APPLE_ONBOARDING_URL;
58+
} else if (socialType === 'google') {
59+
return GOOGLE_ONBOARDING_URL;
5360
}
54-
55-
return `https://link.metamask.io/onboarding?type=srp`;
61+
return SRP_ONBOARDING_URL;
5662
}, [socialType]);
5763

5864
return (
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
export const REWARDS_GTM_MODAL_SHOWN = 'REWARDS_GTM_MODAL_SHOWN';
22
export const REWARDS_BADGE_HIDDEN = 'REWARDS_BADGE_HIDDEN';
3+
export const GOOGLE_ONBOARDING_URL =
4+
'https://link.metamask.io/onboarding?sig_params=type&type=google&sig=S5CFw2lW6WfLMA9ksQyqKoGNevtCHoSxqbTc4uuc8UpG4qrkLfZnUT31_dK5KWVmalm_j0RBCsJElzg_9XnB4A';
5+
export const APPLE_ONBOARDING_URL =
6+
'https://link.metamask.io/onboarding?existing=true&sig_params=existing%2Ctype&type=apple&sig=XnjGKreBsg7pEP-P9NYKmJ1lNYr_GQcfT8kUMF70B9s9tG9X9vCzZ6ghLZWFqGxlmztCYQraRhOgSj7TKQrlpw';
7+
export const SRP_ONBOARDING_URL =
8+
'https://link.metamask.io/onboarding?sig_params=type&type=srp&sig=nwtLGtTMWX8DFUBZaFtqONyo2gp2pglsaymliHaf5UJ4Z42H79N6d9gT-7lXq0Tk0ldaQjvKyiagABBX9eZ8bQ';

0 commit comments

Comments
 (0)