From 09a03987fec94f4e41542b8b880653ff6ef8dff2 Mon Sep 17 00:00:00 2001 From: Harsh Vardhan Date: Tue, 14 Nov 2023 13:51:35 +0530 Subject: [PATCH] feat(INJI-474): use polyfill for URL searchParams feat Signed-off-by: Harsh Vardhan --- .talismanrc | 2 +- index.js | 3 +- machines/bleShare/scan/scanMachine.ts | 7 +- package-lock.json | 98 +++++++++++++++++++++++++++ package.json | 1 + screens/Scan/ScanScreen.tsx | 6 +- 6 files changed, 107 insertions(+), 10 deletions(-) diff --git a/.talismanrc b/.talismanrc index 1b1812b1f..ab780979c 100644 --- a/.talismanrc +++ b/.talismanrc @@ -4,7 +4,7 @@ fileignoreconfig: - filename: package.json checksum: fdd5905228a1afbfb004c710fd6c61adf073a12840200327c0592b76bea5e7e3 - filename: package-lock.json - checksum: 179883df6d414d82b7f54353a3a4cc75e6a681224f4b6d1831ce85de27de2726 + checksum: 489ccd69f2deecedb8b2ff9a3a02d74c704dfba01fdfb6179316a9df698c4562 - filename: components/PasscodeVerify.tsx checksum: 14654c0f038979fcd0d260170a45894a072f81e0767ca9a0e66935d33b5cc703 - filename: i18n.ts diff --git a/index.js b/index.js index d689463be..1e3c7c1c8 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ import 'react-native-gesture-handler'; -import { registerRootComponent } from 'expo'; +import 'react-native-url-polyfill/auto'; // https://stackoverflow.com/a/75787849 +import {registerRootComponent} from 'expo'; import App from './App'; diff --git a/machines/bleShare/scan/scanMachine.ts b/machines/bleShare/scan/scanMachine.ts index 353562b82..ac2d88f08 100644 --- a/machines/bleShare/scan/scanMachine.ts +++ b/machines/bleShare/scan/scanMachine.ts @@ -869,7 +869,7 @@ export const scanMachine = }), setLinkCode: assign({ - linkCode: (_context, event) => + linkCode: (_, event) => new URL(event.params).searchParams.get('linkCode'), }), setStayInProgress: assign({ @@ -1180,10 +1180,7 @@ export const scanMachine = try { let linkCode = new URL(event.params); // sample: 'inji://landing-page-name?linkCode=sTjp0XVH3t3dGCU&linkExpireDateTime=2023-11-09T06:56:18.482Z' - return ( - linkCode.searchParams.get('linkCode') && - linkCode.searchParams.get('linkExpireDateTime') - ); + return linkCode.searchParams.get('linkCode') !== ''; } catch (e) { return false; } diff --git a/package-lock.json b/package-lock.json index aa67ca424..b5f4e1ba4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -109,6 +109,7 @@ "react-native-flipper": "^0.212.0", "react-native-flipper-xstate": "^1.0.5", "react-native-svg-transformer": "^1.1.0", + "react-native-url-polyfill": "^2.0.0", "rn-mmkv-storage-flipper": "^1.1.1", "typescript": "^4.9.4" }, @@ -26275,6 +26276,18 @@ "react-native": "*" } }, + "node_modules/react-native-url-polyfill": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/react-native-url-polyfill/-/react-native-url-polyfill-2.0.0.tgz", + "integrity": "sha512-My330Do7/DvKnEvwQc0WdcBnFPploYKp9CYlefDXzIdEaA+PAhDYllkvGeEroEzvc4Kzzj2O4yVdz8v6fjRvhA==", + "dev": true, + "dependencies": { + "whatwg-url-without-unicode": "8.0.0-3" + }, + "peerDependencies": { + "react-native": "*" + } + }, "node_modules/react-native-vector-icons": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/react-native-vector-icons/-/react-native-vector-icons-10.0.0.tgz", @@ -29908,6 +29921,53 @@ "webidl-conversions": "^3.0.0" } }, + "node_modules/whatwg-url-without-unicode": { + "version": "8.0.0-3", + "resolved": "https://registry.npmjs.org/whatwg-url-without-unicode/-/whatwg-url-without-unicode-8.0.0-3.tgz", + "integrity": "sha512-HoKuzZrUlgpz35YO27XgD28uh/WJH4B0+3ttFqRo//lmq+9T/mIOJ6kqmINI9HpUpz1imRC/nR/lxKpJiv0uig==", + "dev": true, + "dependencies": { + "buffer": "^5.4.3", + "punycode": "^2.1.1", + "webidl-conversions": "^5.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/whatwg-url-without-unicode/node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/whatwg-url-without-unicode/node_modules/webidl-conversions": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-5.0.0.tgz", + "integrity": "sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -50100,6 +50160,15 @@ "from": "react-native-tuvali@github:mosip/tuvali#v0.4.5", "requires": {} }, + "react-native-url-polyfill": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/react-native-url-polyfill/-/react-native-url-polyfill-2.0.0.tgz", + "integrity": "sha512-My330Do7/DvKnEvwQc0WdcBnFPploYKp9CYlefDXzIdEaA+PAhDYllkvGeEroEzvc4Kzzj2O4yVdz8v6fjRvhA==", + "dev": true, + "requires": { + "whatwg-url-without-unicode": "8.0.0-3" + } + }, "react-native-vector-icons": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/react-native-vector-icons/-/react-native-vector-icons-10.0.0.tgz", @@ -52898,6 +52967,35 @@ "webidl-conversions": "^3.0.0" } }, + "whatwg-url-without-unicode": { + "version": "8.0.0-3", + "resolved": "https://registry.npmjs.org/whatwg-url-without-unicode/-/whatwg-url-without-unicode-8.0.0-3.tgz", + "integrity": "sha512-HoKuzZrUlgpz35YO27XgD28uh/WJH4B0+3ttFqRo//lmq+9T/mIOJ6kqmINI9HpUpz1imRC/nR/lxKpJiv0uig==", + "dev": true, + "requires": { + "buffer": "^5.4.3", + "punycode": "^2.1.1", + "webidl-conversions": "^5.0.0" + }, + "dependencies": { + "buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "webidl-conversions": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-5.0.0.tgz", + "integrity": "sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==", + "dev": true + } + } + }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index c89e9029c..bd17c90a2 100644 --- a/package.json +++ b/package.json @@ -111,6 +111,7 @@ "react-native-flipper": "^0.212.0", "react-native-flipper-xstate": "^1.0.5", "react-native-svg-transformer": "^1.1.0", + "react-native-url-polyfill": "^2.0.0", "rn-mmkv-storage-flipper": "^1.1.1", "typescript": "^4.9.4" }, diff --git a/screens/Scan/ScanScreen.tsx b/screens/Scan/ScanScreen.tsx index c1967e114..5f93d44b8 100644 --- a/screens/Scan/ScanScreen.tsx +++ b/screens/Scan/ScanScreen.tsx @@ -125,7 +125,7 @@ export const ScanScreen: React.FC = () => { return noShareableVcText(); } if (controller.selectIsInvalid) { - return invalidQR(); + return displayInvalidQR(); } if (controller.isNearByDevicesPermissionDenied) { return allowNearbyDevicesPermissionComponent(); @@ -163,7 +163,7 @@ export const ScanScreen: React.FC = () => { ); } - function invalidQR(): React.ReactNode { + function displayInvalidQR(): React.ReactNode { return ( !controller.isEmpty && ( {