Skip to content

Commit

Permalink
👽️ app: polyfill webcrypto for turnkey
Browse files Browse the repository at this point in the history
  • Loading branch information
cruzdanilo committed Jan 9, 2024
1 parent 08238e0 commit 255ec63
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 16 deletions.
1 change: 0 additions & 1 deletion .ncurc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module.exports = {
"expo-web-browser",
"react-native",
"react-native-gesture-handler",
"react-native-get-random-values",
"react-native-safe-area-context",
"react-native-screens",
"sharp-cli",
Expand Down
2 changes: 1 addition & 1 deletion app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default {
[
"expo-build-properties",
{
android: { compileSdkVersion: 34, targetSdkVersion: 34 },
android: { compileSdkVersion: 34, targetSdkVersion: 34, packagingOptions: { pickFirst: ["**/libcrypto.so"] } },
ios: { deploymentTarget: "13.4" },
} as BuildPropertiesConfig,
],
Expand Down
Binary file modified bun.lockb
Binary file not shown.
5 changes: 5 additions & 0 deletions metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ module.exports = {
: [defaultConfig.resolver?.blockList]),
new RegExp(`${__dirname}/contracts/`),
],
extraNodeModules: {
buffer: require.resolve("@craftzdog/react-native-buffer"),
crypto: require.resolve("react-native-quick-crypto"),
stream: require.resolve("stream-browserify"),
},
},
};
24 changes: 14 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@
"node": ">=20.0.0"
},
"dependencies": {
"@alchemy/aa-accounts": "^1.2.3",
"@alchemy/aa-alchemy": "^1.2.3",
"@alchemy/aa-core": "^1.2.3",
"@alchemy/aa-accounts": "^1.2.4",
"@alchemy/aa-alchemy": "^1.2.4",
"@alchemy/aa-core": "^1.2.4",
"@craftzdog/react-native-buffer": "^6.0.5",
"@exactly/protocol": "^0.2.19",
"@expo/vector-icons": "^13.0.0",
"@onesignal/node-onesignal": "^2.0.1-beta2",
"@peculiar/webcrypto": "^1.4.3",
"@react-native-async-storage/async-storage": "1.18.2",
"@sentry/react-native": "^5.15.2",
"@tamagui/config": "^1.83.0",
"@tamagui/config": "^1.84.0",
"@tanstack/react-query": "5.8.4",
"@turnkey/api-key-stamper": "^0.3.1",
"@turnkey/http": "^2.6.2",
Expand All @@ -52,20 +54,22 @@
"expo-status-bar": "~1.6.0",
"expo-system-ui": "~2.4.0",
"expo-web-browser": "~12.3.2",
"js-base64": "^3.7.5",
"onesignal-expo-plugin": "^2.0.2",
"process": "^0.11.10",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-native": "0.72.6",
"react-native-gesture-handler": "~2.12.0",
"react-native-get-random-values": "~1.9.0",
"react-native-onesignal": "^5.0.4",
"react-native-quick-base64": "^2.0.8",
"react-native-quick-crypto": "^0.6.1",
"react-native-safe-area-context": "4.6.3",
"react-native-screens": "~3.22.0",
"react-native-web": "^0.19.10",
"react-onesignal": "^3.0.1",
"sentry-expo": "^7.1.1",
"tamagui": "^1.83.0",
"stream-browserify": "^3.0.0",
"tamagui": "^1.84.0",
"text-encoding": "^0.7.0",
"ua-parser-js": "^1.0.37",
"viem": "2.0.3",
Expand All @@ -75,14 +79,14 @@
"devDependencies": {
"@babel/core": "^7.23.7",
"@babel/plugin-transform-private-methods": "^7.23.3",
"@tamagui/babel-plugin": "^1.83.0",
"@tamagui/babel-plugin": "^1.84.0",
"@types/babel__core": "^7.20.5",
"@types/eslint": "^8.56.1",
"@types/react": "^18.2.47",
"@types/text-encoding": "^0.0.39",
"@types/ua-parser-js": "^0.7.39",
"@typescript-eslint/eslint-plugin": "^6.18.0",
"@typescript-eslint/parser": "^6.18.0",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
"concurrently": "^8.2.2",
"eas-cli": "^5.9.3",
Expand Down
2 changes: 1 addition & 1 deletion pomelo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@types/node": "^20.10.7",
"@types/node": "^20.10.8",
"drizzle-kit": "^0.20.10",
"typescript": "^5.3.3",
"vercel": "^33.0.2"
Expand Down
2 changes: 0 additions & 2 deletions utils/generateRandomBuffer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import "react-native-get-random-values";

export default function generateRandomBuffer() {
const array = new Uint8Array(32);
crypto.getRandomValues(array);
Expand Down
5 changes: 4 additions & 1 deletion utils/polyfill.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { atob, btoa } from "js-base64";
import { atob, btoa } from "react-native-quick-base64";
import { TextEncoder } from "text-encoding";

/* eslint-disable @typescript-eslint/no-unnecessary-condition */

global.atob ??= atob;
global.btoa ??= btoa;
global.TextEncoder ??= TextEncoder;
// @ts-expect-error -- polyfill
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, unicorn/prefer-module
global.crypto.subtle ??= new (require("@peculiar/webcrypto").Crypto)().subtle;

if (global.window) {
// @ts-expect-error -- enough for mipd
Expand Down

0 comments on commit 255ec63

Please sign in to comment.