diff --git a/.github/workflows/validate-js.yml b/.github/workflows/validate-js.yml index 12cd0cdb..cc6c3cbe 100644 --- a/.github/workflows/validate-js.yml +++ b/.github/workflows/validate-js.yml @@ -68,7 +68,7 @@ jobs: - name: Bootstrap JS run: | - bun install --frozen-lockfile + bun install - name: Run ESLint (rnqc) run: | @@ -83,4 +83,4 @@ jobs: bun format:fix - name: Verify no files have changed after auto-fix - run: git diff --exit-code HEAD + run: git diff --exit-code HEAD -- . ':(exclude)bun.lockb' diff --git a/bun.lockb b/bun.lockb index 3193ed6a..f9de01b6 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index ac0552f5..51fedc84 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -31,7 +31,7 @@ PODS: - ReactCommon/turbomodule/core - Yoga - OpenSSL-Universal (3.3.2000) - - QuickCrypto (1.0.0-beta.5): + - QuickCrypto (1.0.0-beta.6): - DoubleConversion - glog - hermes-engine @@ -1719,8 +1719,8 @@ DEPENDENCIES: - fmt (from `../../node_modules/react-native/third-party-podspecs/fmt.podspec`) - glog (from `../../node_modules/react-native/third-party-podspecs/glog.podspec`) - hermes-engine (from `../../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`) - - NitroModules (from `../node_modules/react-native-nitro-modules`) - - QuickCrypto (from `../node_modules/react-native-quick-crypto`) + - NitroModules (from `../../node_modules/react-native-nitro-modules`) + - QuickCrypto (from `../../node_modules/react-native-quick-crypto`) - RCT-Folly (from `../../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) - RCT-Folly/Fabric (from `../../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`) - RCTDeprecation (from `../../node_modules/react-native/ReactApple/Libraries/RCTFoundation/RCTDeprecation`) @@ -1805,9 +1805,9 @@ EXTERNAL SOURCES: :podspec: "../../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec" :tag: hermes-2024-09-09-RNv0.76.0-db6d12e202e15f7a446d8848d6ca8f7abb3cfb32 NitroModules: - :path: "../node_modules/react-native-nitro-modules" + :path: "../../node_modules/react-native-nitro-modules" QuickCrypto: - :path: "../node_modules/react-native-quick-crypto" + :path: "../../node_modules/react-native-quick-crypto" RCT-Folly: :podspec: "../../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec" RCTDeprecation: @@ -1940,7 +1940,7 @@ SPEC CHECKSUMS: hermes-engine: 46f1ffbf0297f4298862068dd4c274d4ac17a1fd NitroModules: 55f64932b4581a7d02103bc35b84c7bd3204106b OpenSSL-Universal: b60a3702c9fea8b3145549d421fdb018e53ab7b4 - QuickCrypto: 8d76ae3a0bf60509f671193eb4ed666a80da34cb + QuickCrypto: e68316432823f70bdae0bf1486dc5e9afdfdff4d RCT-Folly: 84578c8756030547307e4572ab1947de1685c599 RCTDeprecation: fde92935b3caa6cb65cbff9fbb7d3a9867ffb259 RCTRequired: 75c6cee42d21c1530a6f204ba32ff57335d19007 diff --git a/example/package.json b/example/package.json index 861621b8..f0b6cf6d 100644 --- a/example/package.json +++ b/example/package.json @@ -36,7 +36,7 @@ "react-native-bouncy-checkbox": "4.0.1", "react-native-nitro-modules": "0.18.1", "react-native-quick-base64": "2.1.2", - "react-native-quick-crypto": "1.0.0-beta.5", + "react-native-quick-crypto": "workspace:*", "react-native-safe-area-context": "4.14.0", "react-native-screens": "3.35.0", "react-native-vector-icons": "^10.1.0", diff --git a/example/src/navigators/Root.tsx b/example/src/navigators/Root.tsx index 4a3b547a..1bb792c6 100644 --- a/example/src/navigators/Root.tsx +++ b/example/src/navigators/Root.tsx @@ -12,7 +12,7 @@ const Tab = createBottomTabNavigator(); export const Root: React.FC = () => { return ( - + { }); */ -test(SUITE, 'sign/verify', async () => { +test(SUITE, 'sign/verify - round trip happy', async () => { const data = Buffer.from('hello world'); const ed = new Ed('ed25519', {}); await ed.generateKeyPair(); @@ -54,3 +54,24 @@ test(SUITE, 'sign/verify', async () => { const verified = await ed.verify(signature, data.buffer); expect(verified).to.be.true; }); + +test(SUITE, 'sign/verify - round trip sad', async () => { + const data1 = Buffer.from('hello world'); + const data2 = Buffer.from('goodbye cruel world'); + const ed = new Ed('ed25519', {}); + await ed.generateKeyPair(); + const signature = await ed.sign(data1.buffer); + const verified = await ed.verify(signature, data2.buffer); + expect(verified).to.be.false; +}); + +test(SUITE, 'sign/verify - bad signature does not verify', async () => { + const data = Buffer.from('hello world'); + const ed = new Ed('ed25519', {}); + await ed.generateKeyPair(); + const signature = await ed.sign(data.buffer); + const signature2 = randomBytes(64).buffer; + expect(ab2str(signature2)).not.to.equal(ab2str(signature)); + const verified = await ed.verify(signature2, data.buffer); + expect(verified).to.be.false; +}); diff --git a/package.json b/package.json index 3608cd67..e3469cd7 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,10 @@ }, { "file": "example/package.json", - "path": "version" + "path": [ + "version", + "dependencies.react-native-quick-crypto" + ] } ] }, diff --git a/packages/react-native-quick-crypto/src/index.ts b/packages/react-native-quick-crypto/src/index.ts index 88d87814..3151ea98 100644 --- a/packages/react-native-quick-crypto/src/index.ts +++ b/packages/react-native-quick-crypto/src/index.ts @@ -60,6 +60,8 @@ global.process.nextTick = setImmediate; // exports export default QuickCrypto; export * from './ed'; +export * from './pbkdf2'; +export * from './random'; export * from './utils'; // Additional exports for CommonJS compatibility