Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/validate-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ jobs:
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check circular dependencies
run: |
cd packages/react-native-quick-crypto
bun circular

lint_js:
name: JS Lint (eslint, prettier)
runs-on: ubuntu-latest
Expand Down
101 changes: 35 additions & 66 deletions bun.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
},
"devDependencies": {
"@eslint/compat": "1.2.8",
"husky": "9.1.7",
"lint-staged": "16.1.6",
"@eslint/js": "9.24.0",
"@release-it/bumper": "7.0.5",
"@release-it/conventional-changelog": "10.0.1",
Expand All @@ -44,6 +42,8 @@
"eslint-config-prettier": "10.1.8",
"eslint-plugin-prettier": "5.5.4",
"eslint-plugin-react-native": "5.0.0",
"husky": "9.1.7",
"lint-staged": "16.1.6",
"nitrogen": "0.33.2",
"prettier": "3.5.3",
"release-it": "19.0.5",
Expand Down
2 changes: 2 additions & 0 deletions packages/react-native-quick-crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"prepare": "bun clean && bun tsc && bob build",
"release": "release-it",
"specs": "nitrogen",
"circular": "dpdm --circular --no-tree --no-warning --exit-code circular:1 --transform src/index.ts",
"test": "jest"
},
"files": [
Expand Down Expand Up @@ -85,6 +86,7 @@
"@types/react": "18.3.3",
"@types/readable-stream": "4.0.18",
"del-cli": "7.0.0",
"dpdm": "^4.0.1",
"expo": "^54.0.25",
"expo-build-properties": "^1.0.0",
"jest": "29.7.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-quick-crypto/src/dhKeyPair.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NitroModules } from 'react-native-nitro-modules';
import { Buffer } from '@craftzdog/react-native-buffer';
import { KeyObject, PublicKeyObject, PrivateKeyObject } from './keys';
import { KeyObject, PublicKeyObject, PrivateKeyObject } from './keys/classes';
import type { DhKeyPair } from './specs/dhKeyPair.nitro';
import type { GenerateKeyPairOptions, KeyPairGenConfig } from './utils/types';
import { KFormatType, KeyEncoding } from './utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-quick-crypto/src/dsa.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NitroModules } from 'react-native-nitro-modules';
import { Buffer } from '@craftzdog/react-native-buffer';
import { KeyObject, PublicKeyObject, PrivateKeyObject } from './keys';
import { KeyObject, PublicKeyObject, PrivateKeyObject } from './keys/classes';
import type { DsaKeyPair } from './specs/dsaKeyPair.nitro';
import type { GenerateKeyPairOptions, KeyPairGenConfig } from './utils/types';
import { KFormatType, KeyEncoding } from './utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-quick-crypto/src/ec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
KeyObject,
PublicKeyObject,
PrivateKeyObject,
} from './keys';
} from './keys/classes';
import type {
CryptoKeyPair,
KeyPairOptions,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-native-quick-crypto/src/ed.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { NitroModules } from 'react-native-nitro-modules';
import { Buffer } from '@craftzdog/react-native-buffer';
import type { AsymmetricKeyObject, PrivateKeyObject } from './keys';
import type { AsymmetricKeyObject, PrivateKeyObject } from './keys/classes';
import {
CryptoKey,
KeyObject,
PublicKeyObject,
PrivateKeyObject as PrivateKeyObjectClass,
} from './keys';
} from './keys/classes';
import type { EdKeyPair } from './specs/edKeyPair.nitro';
import type {
BinaryLike,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-quick-crypto/src/rsa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
KeyObject,
PrivateKeyObject,
PublicKeyObject,
} from './keys';
} from './keys/classes';
import {
getUsagesUnion,
hasAnyNotIn,
Expand Down
14 changes: 10 additions & 4 deletions packages/react-native-quick-crypto/src/utils/conversion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Buffer as CraftzdogBuffer } from '@craftzdog/react-native-buffer';
import { Buffer as SafeBuffer } from 'safe-buffer';
import type { ABV, BinaryLikeNode, BufferLike } from './types';
import { KeyObject } from '../keys/classes';

/**
* Converts supplied argument to an ArrayBuffer. Note this does not copy the
Expand Down Expand Up @@ -133,9 +132,16 @@ export function binaryLikeToArrayBuffer(
// }
// }

// KeyObject
if (input instanceof KeyObject) {
return input.handle.exportKey();
// KeyObject — duck-typed via Symbol.toStringTag to avoid circular dependency
// with keys/classes. The type assertion must match KeyObjectHandle.exportKey().
if (
typeof input === 'object' &&
input != null &&
Object.prototype.toString.call(input) === '[object KeyObject]'
) {
return (
input as { handle: { exportKey(): ArrayBuffer } }
).handle.exportKey();
}

throw new Error(
Expand Down