Skip to content

Commit 5ac43c3

Browse files
authored
Merge pull request #2123 from garden-co/repro-rnquickcrypto-chat-signature-issue
Fix the InvalidSignature issues on RNQuickCrypto
2 parents e809214 + 0641745 commit 5ac43c3

File tree

7 files changed

+99
-22
lines changed

7 files changed

+99
-22
lines changed

.changeset/early-dogs-jog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"jazz-react-native-core": patch
3+
---
4+
5+
Fix the InvalidSignature errors on RNQuickCrypto
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const { withBuildProperties } = require("expo-build-properties");
2+
const { withDangerousMod } = require("@expo/config-plugins");
3+
const fs = require("fs/promises");
4+
const path = require("path");
5+
6+
/**
7+
* https://github.com/mrousavy/nitro/issues/422#issuecomment-2545988256
8+
*/
9+
function withCustomIosMod(config) {
10+
// Use expo-build-properties to bump iOS deployment target
11+
config = withBuildProperties(config, { ios: { deploymentTarget: "16.0" } });
12+
// Patch the generated Podfile fallback to ensure platform is always 16.0
13+
config = withDangerousMod(config, [
14+
"ios",
15+
async (modConfig) => {
16+
const podfilePath = path.join(
17+
modConfig.modRequest.platformProjectRoot,
18+
"Podfile",
19+
);
20+
let contents = await fs.readFile(podfilePath, "utf-8");
21+
22+
// Check if the IPHONEOS_DEPLOYMENT_TARGET setting is already present
23+
// We search for the key being assigned, e.g., config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] =
24+
const deploymentTargetSettingExists =
25+
/\.build_settings\s*\[\s*['"]IPHONEOS_DEPLOYMENT_TARGET['"]\s*\]\s*=/.test(
26+
contents,
27+
);
28+
29+
if (!deploymentTargetSettingExists) {
30+
// IPHONEOS_DEPLOYMENT_TARGET setting not found, proceed to add it.
31+
contents = contents.replace(
32+
/(post_install\s+do\s+\|installer\|[\s\S]*?)(\r?\n\s end\s*)$/m,
33+
`$1
34+
35+
# Expo Build Properties: force deployment target
36+
# https://github.com/mrousavy/nitro/issues/422#issuecomment-2545988256
37+
installer.pods_project.targets.each do |target|
38+
target.build_configurations.each do |config|
39+
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '16.0'
40+
end
41+
end
42+
$2`,
43+
);
44+
}
45+
46+
await fs.writeFile(podfilePath, contents);
47+
return modConfig;
48+
},
49+
]);
50+
return config;
51+
}
52+
53+
module.exports = ({ config }) => {
54+
return withCustomIosMod(config);
55+
};

examples/chat-rn-expo/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
"react-dom": "18.3.1",
3737
"react-native": "0.76.7",
3838
"react-native-get-random-values": "^1.11.0",
39+
"react-native-nitro-modules": "0.25.2",
40+
"react-native-quick-crypto": "1.0.0-beta.15",
3941
"react-native-safe-area-context": "4.12.0",
4042
"react-native-screens": "4.4.0",
4143
"react-native-url-polyfill": "^2.0.0",

examples/chat-rn-expo/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
} from "@react-navigation/native";
77
import { createNativeStackNavigator } from "@react-navigation/native-stack";
88
import * as Linking from "expo-linking";
9+
import { RNQuickCrypto } from "jazz-expo/crypto";
910
import React, { StrictMode, useEffect, useState } from "react";
1011
import HandleInviteScreen from "./invite";
1112

@@ -46,6 +47,7 @@ function App() {
4647
return (
4748
<StrictMode>
4849
<JazzProvider
50+
CryptoProvider={RNQuickCrypto}
4951
sync={{
5052
peer: `wss://cloud.jazz.tools/?key=${apiKey}`,
5153
}}

packages/jazz-react-native-core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
"cojson-transport-ws": "workspace:*",
4141
"jazz-react-core": "workspace:*",
4242
"jazz-tools": "workspace:*",
43-
"react-native-nitro-modules": "0.24.1",
44-
"react-native-quick-crypto": "1.0.0-beta.13"
43+
"react-native-nitro-modules": "0.25.2",
44+
"react-native-quick-crypto": "1.0.0-beta.15"
4545
},
4646
"devDependencies": {
4747
"typescript": "catalog:"

packages/jazz-react-native-core/src/crypto/RNQuickCrypto.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ export class RNQuickCrypto extends PureJSCrypto {
2424
return new Uint8Array(this.ed.getPrivateKey());
2525
}
2626

27-
getSignerID(
28-
secret: CojsonInternalTypes.SignerSecret,
29-
): CojsonInternalTypes.SignerID {
30-
return `signer_z${base58.encode(
31-
base58.decode(secret.substring("signerSecret_z".length)),
32-
)}`;
33-
}
34-
3527
sign(
3628
secret: CojsonInternalTypes.SignerSecret,
3729
message: JsonValue,

pnpm-lock.yaml

Lines changed: 33 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)