react-native-quick-crypto 0.7.9 → 0.7.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/CMakeLists.txt +59 -62
- package/android/build.gradle +10 -9
- package/android/src/main/cpp/cpp-adapter.cpp +9 -0
- package/cpp/JSIUtils/MGLTypedArray.cpp +38 -17
- package/cpp/JSIUtils/MGLTypedArray.h +20 -1
- package/cpp/MGLQuickCryptoHostObject.h +1 -1
- package/ios/QuickCrypto.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/QuickCrypto.xcodeproj/project.xcworkspace/xcuserdata/brad.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/QuickCrypto.xcodeproj/xcuserdata/brad.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/QuickCryptoModule.mm +10 -0
- package/lib/commonjs/Algorithms.js +224 -0
- package/lib/commonjs/Algorithms.js.map +1 -0
- package/lib/commonjs/Hash.js +1 -1
- package/lib/commonjs/Hash.js.map +1 -1
- package/lib/commonjs/Hashnames.js +1 -1
- package/lib/commonjs/Hashnames.js.map +1 -1
- package/lib/commonjs/Utils.js +27 -235
- package/lib/commonjs/Utils.js.map +1 -1
- package/lib/commonjs/keys.js.map +1 -1
- package/lib/commonjs/pbkdf2.js +1 -1
- package/lib/commonjs/pbkdf2.js.map +1 -1
- package/lib/commonjs/random.js.map +1 -1
- package/lib/commonjs/subtle.js +7 -6
- package/lib/commonjs/subtle.js.map +1 -1
- package/lib/module/Algorithms.js +219 -0
- package/lib/module/Algorithms.js.map +1 -0
- package/lib/module/Hash.js +1 -1
- package/lib/module/Hash.js.map +1 -1
- package/lib/module/Hashnames.js +1 -1
- package/lib/module/Hashnames.js.map +1 -1
- package/lib/module/Utils.js +25 -230
- package/lib/module/Utils.js.map +1 -1
- package/lib/module/keys.js.map +1 -1
- package/lib/module/pbkdf2.js +1 -1
- package/lib/module/pbkdf2.js.map +1 -1
- package/lib/module/random.js.map +1 -1
- package/lib/module/subtle.js +2 -1
- package/lib/module/subtle.js.map +1 -1
- package/lib/typescript/src/Algorithms.d.ts +4 -0
- package/lib/typescript/src/Algorithms.d.ts.map +1 -0
- package/lib/typescript/src/Hashnames.d.ts +2 -2
- package/lib/typescript/src/Hashnames.d.ts.map +1 -1
- package/lib/typescript/src/Utils.d.ts +20 -8
- package/lib/typescript/src/Utils.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +4 -4
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/keys.d.ts +5 -2
- package/lib/typescript/src/keys.d.ts.map +1 -1
- package/lib/typescript/src/random.d.ts +5 -6
- package/lib/typescript/src/random.d.ts.map +1 -1
- package/lib/typescript/src/sig.d.ts +1 -1
- package/lib/typescript/src/subtle.d.ts.map +1 -1
- package/package.json +40 -52
- package/react-native-quick-crypto.podspec +1 -1
- package/src/Algorithms.ts +247 -0
- package/src/Hash.ts +1 -1
- package/src/Hashnames.ts +4 -4
- package/src/Utils.ts +34 -279
- package/src/keys.ts +5 -1
- package/src/pbkdf2.ts +1 -1
- package/src/random.ts +16 -24
- package/src/subtle.ts +1 -2
- package/LICENSE +0 -27
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Buffer as CraftzdogBuffer } from '@craftzdog/react-native-buffer';
|
|
2
2
|
import { Buffer as SafeBuffer } from 'safe-buffer';
|
|
3
|
-
import {
|
|
4
|
-
import type { AnyAlgorithm, EncryptDecryptParams, KeyUsage, SubtleAlgorithm } from './keys';
|
|
3
|
+
import type { KeyUsage } from './keys';
|
|
5
4
|
import { type CipherKey } from 'crypto';
|
|
6
|
-
export type BufferLike = ArrayBuffer | CraftzdogBuffer |
|
|
7
|
-
export type BinaryLike = string | ArrayBuffer | CraftzdogBuffer |
|
|
5
|
+
export type BufferLike = ArrayBuffer | CraftzdogBuffer | SafeBuffer | ArrayBufferView;
|
|
6
|
+
export type BinaryLike = string | ArrayBuffer | CraftzdogBuffer | SafeBuffer | TypedArray | DataView;
|
|
8
7
|
export type BinaryLikeNode = CipherKey | BinaryLike;
|
|
9
8
|
export type BinaryToTextEncoding = 'base64' | 'base64url' | 'hex' | 'binary';
|
|
10
9
|
export type CharacterEncoding = 'utf8' | 'utf-8' | 'utf16le' | 'latin1';
|
|
@@ -20,6 +19,7 @@ export type CipherECBType = 'aes-128-ecb' | 'aes-192-ecb' | 'aes-256-ecb';
|
|
|
20
19
|
export type CipherGCMType = 'aes-128-gcm' | 'aes-192-gcm' | 'aes-256-gcm';
|
|
21
20
|
export type CipherOFBType = 'aes-128-ofb' | 'aes-192-ofb' | 'aes-256-ofb';
|
|
22
21
|
export type TypedArray = Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | Int8Array | Int16Array | Int32Array | Float32Array | Float64Array;
|
|
22
|
+
export type ABV = TypedArray | DataView | ArrayBufferLike | CraftzdogBuffer;
|
|
23
23
|
type DOMName = string | {
|
|
24
24
|
name: string;
|
|
25
25
|
cause: unknown;
|
|
@@ -27,7 +27,22 @@ type DOMName = string | {
|
|
|
27
27
|
export declare function setDefaultEncoding(encoding: CipherEncoding): void;
|
|
28
28
|
export declare function getDefaultEncoding(): CipherEncoding;
|
|
29
29
|
export declare const kEmptyObject: any;
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Converts supplied argument to an ArrayBuffer. Note this does not copy the
|
|
32
|
+
* data so it is faster than toArrayBuffer. Not copying is important for
|
|
33
|
+
* functions like randomFill which need to be able to write to the underlying
|
|
34
|
+
* buffer.
|
|
35
|
+
* @param buf
|
|
36
|
+
* @returns ArrayBuffer
|
|
37
|
+
*/
|
|
38
|
+
export declare function abvToArrayBuffer(buffer: ABV): ArrayBuffer;
|
|
39
|
+
/**
|
|
40
|
+
* Converts supplied argument to an ArrayBuffer. Note this copies data if the
|
|
41
|
+
* supplied buffer has the .slice() method, so can be a bit slow.
|
|
42
|
+
* @param buf
|
|
43
|
+
* @returns ArrayBuffer
|
|
44
|
+
*/
|
|
45
|
+
export declare function toArrayBuffer(buf: CraftzdogBuffer | SafeBuffer | ArrayBufferView): ArrayBuffer;
|
|
31
46
|
export declare function bufferLikeToArrayBuffer(buf: BufferLike): ArrayBuffer;
|
|
32
47
|
export declare function binaryLikeToArrayBuffer(input: BinaryLikeNode, // CipherKey adds compat with node types
|
|
33
48
|
encoding?: string): ArrayBuffer;
|
|
@@ -44,15 +59,12 @@ export declare function validateInt32(value: any, name: string, min?: number, ma
|
|
|
44
59
|
export declare function validateUint32(value: number, name: string, positive?: boolean): void;
|
|
45
60
|
export declare function hasAnyNotIn(set: string[], checks: string[]): boolean;
|
|
46
61
|
export declare function lazyDOMException(message: string, domName: DOMName): Error;
|
|
47
|
-
export type Operation = 'digest' | 'generateKey' | 'sign' | 'verify' | 'importKey' | 'deriveBits' | 'encrypt' | 'decrypt' | 'get key length' | 'wrapKey' | 'unwrapKey';
|
|
48
62
|
export declare const validateMaxBufferLength: (data: BinaryLike | BufferLike, name: string) => void;
|
|
49
|
-
export declare const normalizeAlgorithm: (algorithm: SubtleAlgorithm | EncryptDecryptParams | AnyAlgorithm, op: Operation) => SubtleAlgorithm | EncryptDecryptParams;
|
|
50
63
|
export declare const validateBitLength: (length: number, name: string, required?: boolean) => void;
|
|
51
64
|
export declare const validateByteLength: (buf: BufferLike, name: string, target: number) => void;
|
|
52
65
|
export declare const getUsagesUnion: (usageSet: KeyUsage[], ...usages: KeyUsage[]) => KeyUsage[];
|
|
53
66
|
export declare const validateKeyOps: (keyOps: KeyUsage[] | undefined, usagesSet: KeyUsage[]) => void;
|
|
54
67
|
export declare const bigIntArrayToUnsignedInt: (input: Uint8Array) => number | undefined;
|
|
55
|
-
export declare function abvToArrayBuffer(buffer: ArrayBufferView): ArrayBuffer;
|
|
56
68
|
export declare const getHashes: () => string[];
|
|
57
69
|
export declare const getCiphers: () => string[];
|
|
58
70
|
export * from './Hashnames';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.d.ts","sour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,MAAM,iBAAiB,WACpB,MAAM,QACR,MAAM,aACF,OAAO,SAYlB,CAAC;AAEF,eAAO,MAAM,kBAAkB,QACxB,UAAU,QACT,MAAM,UACJ,MAAM,SAYf,CAAC;AAEF,eAAO,MAAM,cAAc,aAAc,QAAQ,EAAE,aAAa,QAAQ,EAAE,eAQzE,CAAC;AAeF,eAAO,MAAM,cAAc,WACjB,QAAQ,EAAE,GAAG,SAAS,aACnB,QAAQ,EAAE,SAgCtB,CAAC;AASF,eAAO,MAAM,wBAAwB,UAC5B,UAAU,KAChB,MAAM,GAAG,SAWX,CAAC;AAIF,eAAO,MAAM,SAAS,gBAsCrB,CAAC;AAIF,eAAO,MAAM,UAAU,gBAoCtB,CAAC;AAEF,cAAc,aAAa,CAAC"}
|
|
@@ -16,10 +16,10 @@ declare const QuickCrypto: {
|
|
|
16
16
|
SubtleCrypto: typeof import("./subtle").Subtle;
|
|
17
17
|
CryptoKey: typeof import("./keys").CryptoKey;
|
|
18
18
|
};
|
|
19
|
-
randomFill<T extends import("./Utils").
|
|
20
|
-
randomFill<T extends import("./Utils").
|
|
21
|
-
randomFill<T extends import("./Utils").
|
|
22
|
-
randomFillSync<T extends import("./Utils").
|
|
19
|
+
randomFill<T extends import("./Utils").ABV>(buffer: T, callback: (err: Error | null, buf: T) => void): void;
|
|
20
|
+
randomFill<T extends import("./Utils").ABV>(buffer: T, offset: number, callback: (err: Error | null, buf: T) => void): void;
|
|
21
|
+
randomFill<T extends import("./Utils").ABV>(buffer: T, offset: number, size: number, callback: (err: Error | null, buf: T) => void): void;
|
|
22
|
+
randomFillSync<T extends import("./Utils").ABV>(buffer: T, offset?: number, size?: number): T;
|
|
23
23
|
randomBytes(size: number): Buffer;
|
|
24
24
|
randomBytes(size: number, callback: (err: Error | null, buf?: Buffer) => void): void;
|
|
25
25
|
randomInt(max: number, callback: (err: Error | null, value: number) => void): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAExD,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,gBAAgB,EAKhB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAKpC,OAAO,EAAoB,eAAe,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE5E;;GAEG;AACH,QAAA,MAAM,WAAW;;;;;;;;;;;;;+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAExD,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AACnC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,gBAAgB,EAKhB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAKpC,OAAO,EAAoB,eAAe,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE5E;;GAEG;AACH,QAAA,MAAM,WAAW;;;;;;;;;;;;;+DA8CP,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAlBV,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,YAMnB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -56,12 +56,15 @@ export type SubtleAlgorithm = {
|
|
|
56
56
|
name: AnyAlgorithm;
|
|
57
57
|
salt?: string;
|
|
58
58
|
iterations?: number;
|
|
59
|
-
hash?: HashAlgorithm;
|
|
59
|
+
hash?: HashAlgorithm | HashAlgorithmIdentifier;
|
|
60
60
|
namedCurve?: NamedCurve;
|
|
61
61
|
length?: number;
|
|
62
62
|
modulusLength?: number;
|
|
63
63
|
publicExponent?: number | Uint8Array;
|
|
64
64
|
};
|
|
65
|
+
export type HashAlgorithmIdentifier = {
|
|
66
|
+
name: HashAlgorithm;
|
|
67
|
+
};
|
|
65
68
|
export type KeyUsage = 'encrypt' | 'decrypt' | 'sign' | 'verify' | 'deriveKey' | 'deriveBits' | 'wrapKey' | 'unwrapKey';
|
|
66
69
|
export declare enum KFormatType {
|
|
67
70
|
kKeyFormatDER = 0,
|
|
@@ -175,7 +178,7 @@ export declare class CryptoKey {
|
|
|
175
178
|
keyExtractable: boolean;
|
|
176
179
|
constructor(keyObject: KeyObject, keyAlgorithm: SubtleAlgorithm, keyUsages: KeyUsage[], keyExtractable: boolean);
|
|
177
180
|
inspect(_depth: number, _options: any): any;
|
|
178
|
-
get type(): "public" | "
|
|
181
|
+
get type(): "public" | "private" | "secret" | "unknown";
|
|
179
182
|
get extractable(): boolean;
|
|
180
183
|
get algorithm(): SubtleAlgorithm;
|
|
181
184
|
get usages(): KeyUsage[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../../src/keys.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,UAAU,EAGf,KAAK,UAAU,EACf,KAAK,UAAU,EAChB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MA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eAAO,MAAM,WAAW,QAAS,GAAG,KAAG,OAEtC,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Buffer } from '@craftzdog/react-native-buffer';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
export declare function randomFill<T extends
|
|
5
|
-
export declare function randomFill<T extends
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function randomFillSync<T extends RandomBuffer>(buffer: T, offset?: number, size?: number): T;
|
|
2
|
+
import type { ABV } from './Utils';
|
|
3
|
+
export declare function randomFill<T extends ABV>(buffer: T, callback: (err: Error | null, buf: T) => void): void;
|
|
4
|
+
export declare function randomFill<T extends ABV>(buffer: T, offset: number, callback: (err: Error | null, buf: T) => void): void;
|
|
5
|
+
export declare function randomFill<T extends ABV>(buffer: T, offset: number, size: number, callback: (err: Error | null, buf: T) => void): void;
|
|
6
|
+
export declare function randomFillSync<T extends ABV>(buffer: T, offset?: number, size?: number): T;
|
|
8
7
|
export declare function randomBytes(size: number): Buffer;
|
|
9
8
|
export declare function randomBytes(size: number, callback: (err: Error | null, buf?: Buffer) => void): void;
|
|
10
9
|
export declare const rng: typeof randomBytes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../../src/random.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../../src/random.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAInC,wBAAgB,UAAU,CAAC,CAAC,SAAS,GAAG,EACtC,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,IAAI,GAC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M,EACX,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,iBAAiB,GAC1B,IAAI,CAAC;AACR,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;AAwH5D,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,UAAU,GACV,UAAU,GACV,UAAU,GACV,WAAW,GACX,WAAW,CAAC;AAChB,wBAAgB,eAAe,CAAC,IAAI,EAAE,iBAAiB,qBAMtD;AASD,wBAAgB,UAAU,WA+BzB"}
|
|
@@ -13,7 +13,7 @@ declare class Sign extends Stream.Writable {
|
|
|
13
13
|
constructor(algorithm: string, options?: WritableOptions);
|
|
14
14
|
_write(chunk: BinaryLike, encoding: string, callback: () => void): void;
|
|
15
15
|
update(data: BinaryLike, encoding?: string): this;
|
|
16
|
-
sign(options: EncodingOptions, encoding?: string): string | Buffer
|
|
16
|
+
sign(options: EncodingOptions, encoding?: string): string | Buffer<ArrayBuffer>;
|
|
17
17
|
}
|
|
18
18
|
export declare function createSign(algorithm: string, options?: WritableOptions): Sign;
|
|
19
19
|
export declare function createVerify(algorithm: string, options?: WritableOptions): Verify;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subtle.d.ts","sourceRoot":"","sources":["../../../src/subtle.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,SAAS,EAGT,KAAK,YAAY,EACjB,KAAK,GAAG,EACR,KAAK,aAAa,EAElB,KAAK,oBAAoB,EAE1B,MAAM,QAAQ,CAAC;AAChB,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"subtle.d.ts","sourceRoot":"","sources":["../../../src/subtle.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,SAAS,EAGT,KAAK,YAAY,EACjB,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ACd,SAAS,EAAE,UAAU,EACrB,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,WAAW,CAAC;CAGxB;AAED,eAAO,MAAM,MAAM,QAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-quick-crypto",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.11",
|
|
4
4
|
"description": "A fast implementation of Node's `crypto` module written in C/C++ JSI",
|
|
5
5
|
"packageManager": "bun@1.1.26",
|
|
6
6
|
"main": "lib/commonjs/index",
|
|
@@ -26,17 +26,16 @@
|
|
|
26
26
|
"!**/__mocks__"
|
|
27
27
|
],
|
|
28
28
|
"scripts": {
|
|
29
|
+
"clean": "del-cli android/build lib",
|
|
30
|
+
"deepclean": "del-cli node_modules",
|
|
29
31
|
"tsc": "tsc --noEmit",
|
|
30
32
|
"typescript": "tsc --noEmit",
|
|
31
33
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
32
34
|
"lint:fix": "eslint \"**/*.{js,ts,tsx}\" --fix",
|
|
33
35
|
"format": "prettier --check \"**/*.{js,ts,tsx}\"",
|
|
34
36
|
"format:fix": "prettier --write \"**/*.{js,ts,tsx}\"",
|
|
35
|
-
"prepare": "bob build",
|
|
37
|
+
"prepare": "bun clean && bun tsc && bob build",
|
|
36
38
|
"release": "release-it",
|
|
37
|
-
"example": "cd example && bun start",
|
|
38
|
-
"pods": "cd example && bun install && bun pods",
|
|
39
|
-
"bootstrap": "bun install && bun pods && bun example",
|
|
40
39
|
"test": "jest"
|
|
41
40
|
},
|
|
42
41
|
"keywords": [
|
|
@@ -53,7 +52,11 @@
|
|
|
53
52
|
"type": "git",
|
|
54
53
|
"url": "git+https://github.com/margelo/react-native-quick-crypto.git"
|
|
55
54
|
},
|
|
56
|
-
"authors":
|
|
55
|
+
"authors": [
|
|
56
|
+
"Szymon Kapała <szymon20000@gmail.com>",
|
|
57
|
+
"Marc Rousavy <me@mrousavy.com> (https://github.com/mrousavy)",
|
|
58
|
+
"Brad Anderson <brad@sankatygroup.com> (https://github.com/boorad)"
|
|
59
|
+
],
|
|
57
60
|
"license": "MIT",
|
|
58
61
|
"bugs": {
|
|
59
62
|
"url": "https://github.com/margelo/react-native-quick-crypto/issues"
|
|
@@ -71,69 +74,50 @@
|
|
|
71
74
|
},
|
|
72
75
|
"devDependencies": {
|
|
73
76
|
"@eslint/compat": "^1.1.1",
|
|
74
|
-
"@eslint/js": "
|
|
75
|
-
"@react-native/babel-preset": "
|
|
76
|
-
"@react-native/eslint-config": "
|
|
77
|
-
"@react-native/eslint-plugin": "
|
|
77
|
+
"@eslint/js": "9.17.0",
|
|
78
|
+
"@react-native/babel-preset": "0.76.5",
|
|
79
|
+
"@react-native/eslint-config": "0.76.5",
|
|
80
|
+
"@react-native/eslint-plugin": "0.76.5",
|
|
78
81
|
"@release-it/conventional-changelog": "^9.0.3",
|
|
79
82
|
"@types/jest": "^29.5.11",
|
|
80
83
|
"@types/node": "^22.0.0",
|
|
81
84
|
"@types/react": "^18.0.33",
|
|
82
85
|
"@types/readable-stream": "^4.0.11",
|
|
86
|
+
"del-cli": "^6.0.0",
|
|
83
87
|
"eslint": "9.15.0",
|
|
84
88
|
"eslint-plugin-react-native": "^4.1.0",
|
|
85
89
|
"jest": "^29.7.0",
|
|
86
90
|
"prettier": "3.3.3",
|
|
87
|
-
"react": "
|
|
88
|
-
"react-native": "
|
|
89
|
-
"react-native-builder-bob": "0.
|
|
90
|
-
"release-it": "
|
|
91
|
+
"react": "18.2.0",
|
|
92
|
+
"react-native": "0.72.7",
|
|
93
|
+
"react-native-builder-bob": "0.35.2",
|
|
94
|
+
"release-it": "17.11.0",
|
|
91
95
|
"sscrypto": "^1.1.1",
|
|
92
|
-
"typescript": "5.
|
|
93
|
-
"typescript-eslint": "8.
|
|
94
|
-
},
|
|
95
|
-
"peerDependencies": {
|
|
96
|
-
"react": "*",
|
|
97
|
-
"react-native": "*"
|
|
96
|
+
"typescript": "5.7.2",
|
|
97
|
+
"typescript-eslint": "8.19.0"
|
|
98
98
|
},
|
|
99
99
|
"release-it": {
|
|
100
|
-
"git": {
|
|
101
|
-
"commitMessage": "chore: release ${version}",
|
|
102
|
-
"tagName": "v${version}"
|
|
103
|
-
},
|
|
104
100
|
"npm": {
|
|
105
101
|
"publish": true
|
|
106
102
|
},
|
|
103
|
+
"git": false,
|
|
107
104
|
"github": {
|
|
108
|
-
"release":
|
|
105
|
+
"release": false
|
|
106
|
+
},
|
|
107
|
+
"hooks": {
|
|
108
|
+
"after:bump": "bun tsc && bun lint && bun format && bun prepare"
|
|
109
109
|
},
|
|
110
110
|
"plugins": {
|
|
111
|
-
"@release-it/
|
|
112
|
-
"
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
"section": "🐛 Bug Fixes"
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
"type": "perf",
|
|
125
|
-
"section": "💨 Performance Improvements"
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
"type": "chore(deps)",
|
|
129
|
-
"section": "🛠️ Dependency Upgrades"
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
"type": "docs",
|
|
133
|
-
"section": "📚 Documentation"
|
|
134
|
-
}
|
|
135
|
-
]
|
|
136
|
-
}
|
|
111
|
+
"@release-it/bumper": {
|
|
112
|
+
"out": [
|
|
113
|
+
{
|
|
114
|
+
"file": "../../packages/example/package.json",
|
|
115
|
+
"path": [
|
|
116
|
+
"version",
|
|
117
|
+
"dependencies.react-native-quick-crypto"
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
]
|
|
137
121
|
}
|
|
138
122
|
}
|
|
139
123
|
},
|
|
@@ -150,5 +134,9 @@
|
|
|
150
134
|
}
|
|
151
135
|
]
|
|
152
136
|
]
|
|
153
|
-
}
|
|
137
|
+
},
|
|
138
|
+
"workspaces": [
|
|
139
|
+
".",
|
|
140
|
+
"example"
|
|
141
|
+
]
|
|
154
142
|
}
|
|
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.authors = package["authors"]
|
|
12
12
|
|
|
13
13
|
s.platforms = { :ios => "12.4", :tvos => "12.0", :osx => "10.14" }
|
|
14
|
-
s.source = { :git => "https://github.com/
|
|
14
|
+
s.source = { :git => "https://github.com/margelo/react-native-quick-crypto.git", :tag => "#{s.version}" }
|
|
15
15
|
|
|
16
16
|
s.source_files = [
|
|
17
17
|
"ios/**/*.{h,m,mm}",
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AnyAlgorithm,
|
|
3
|
+
DeriveBitsAlgorithm,
|
|
4
|
+
DigestAlgorithm,
|
|
5
|
+
EncryptDecryptAlgorithm,
|
|
6
|
+
EncryptDecryptParams,
|
|
7
|
+
KeyPairAlgorithm,
|
|
8
|
+
SecretKeyAlgorithm,
|
|
9
|
+
SignVerifyAlgorithm,
|
|
10
|
+
SubtleAlgorithm,
|
|
11
|
+
} from './keys';
|
|
12
|
+
|
|
13
|
+
type SupportedAlgorithm<Type extends string> = {
|
|
14
|
+
[key in Type]: string | null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type SupportedAlgorithms = {
|
|
18
|
+
digest: SupportedAlgorithm<DigestAlgorithm>;
|
|
19
|
+
generateKey: SupportedAlgorithm<KeyPairAlgorithm | SecretKeyAlgorithm>;
|
|
20
|
+
sign: SupportedAlgorithm<SignVerifyAlgorithm>;
|
|
21
|
+
verify: SupportedAlgorithm<SignVerifyAlgorithm>;
|
|
22
|
+
importKey: SupportedAlgorithm<
|
|
23
|
+
KeyPairAlgorithm | 'PBKDF2' | SecretKeyAlgorithm | 'HKDF'
|
|
24
|
+
>;
|
|
25
|
+
deriveBits: SupportedAlgorithm<DeriveBitsAlgorithm>;
|
|
26
|
+
encrypt: SupportedAlgorithm<EncryptDecryptAlgorithm>;
|
|
27
|
+
decrypt: SupportedAlgorithm<EncryptDecryptAlgorithm>;
|
|
28
|
+
'get key length': SupportedAlgorithm<SecretKeyAlgorithm | 'PBKDF2' | 'HKDF'>;
|
|
29
|
+
wrapKey: SupportedAlgorithm<'AES-KW'>;
|
|
30
|
+
unwrapKey: SupportedAlgorithm<'AES-KW'>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type Operation =
|
|
34
|
+
| 'digest'
|
|
35
|
+
| 'generateKey'
|
|
36
|
+
| 'sign'
|
|
37
|
+
| 'verify'
|
|
38
|
+
| 'importKey'
|
|
39
|
+
| 'deriveBits'
|
|
40
|
+
| 'encrypt'
|
|
41
|
+
| 'decrypt'
|
|
42
|
+
| 'get key length'
|
|
43
|
+
| 'wrapKey'
|
|
44
|
+
| 'unwrapKey';
|
|
45
|
+
|
|
46
|
+
const kSupportedAlgorithms: SupportedAlgorithms = {
|
|
47
|
+
digest: {
|
|
48
|
+
'SHA-1': null,
|
|
49
|
+
'SHA-256': null,
|
|
50
|
+
'SHA-384': null,
|
|
51
|
+
'SHA-512': null,
|
|
52
|
+
},
|
|
53
|
+
generateKey: {
|
|
54
|
+
'RSASSA-PKCS1-v1_5': 'RsaHashedKeyGenParams',
|
|
55
|
+
'RSA-PSS': 'RsaHashedKeyGenParams',
|
|
56
|
+
'RSA-OAEP': 'RsaHashedKeyGenParams',
|
|
57
|
+
ECDSA: 'EcKeyGenParams',
|
|
58
|
+
ECDH: 'EcKeyGenParams',
|
|
59
|
+
'AES-CTR': 'AesKeyGenParams',
|
|
60
|
+
'AES-CBC': 'AesKeyGenParams',
|
|
61
|
+
'AES-GCM': 'AesKeyGenParams',
|
|
62
|
+
'AES-KW': 'AesKeyGenParams',
|
|
63
|
+
HMAC: 'HmacKeyGenParams',
|
|
64
|
+
X25519: null,
|
|
65
|
+
Ed25519: null,
|
|
66
|
+
X448: null,
|
|
67
|
+
Ed448: null,
|
|
68
|
+
},
|
|
69
|
+
sign: {
|
|
70
|
+
'RSASSA-PKCS1-v1_5': null,
|
|
71
|
+
'RSA-PSS': 'RsaPssParams',
|
|
72
|
+
ECDSA: 'EcdsaParams',
|
|
73
|
+
HMAC: null,
|
|
74
|
+
Ed25519: null,
|
|
75
|
+
Ed448: 'Ed448Params',
|
|
76
|
+
},
|
|
77
|
+
verify: {
|
|
78
|
+
'RSASSA-PKCS1-v1_5': null,
|
|
79
|
+
'RSA-PSS': 'RsaPssParams',
|
|
80
|
+
ECDSA: 'EcdsaParams',
|
|
81
|
+
HMAC: null,
|
|
82
|
+
Ed25519: null,
|
|
83
|
+
Ed448: 'Ed448Params',
|
|
84
|
+
},
|
|
85
|
+
importKey: {
|
|
86
|
+
'RSASSA-PKCS1-v1_5': 'RsaHashedImportParams',
|
|
87
|
+
'RSA-PSS': 'RsaHashedImportParams',
|
|
88
|
+
'RSA-OAEP': 'RsaHashedImportParams',
|
|
89
|
+
ECDSA: 'EcKeyImportParams',
|
|
90
|
+
ECDH: 'EcKeyImportParams',
|
|
91
|
+
HMAC: 'HmacImportParams',
|
|
92
|
+
HKDF: null,
|
|
93
|
+
PBKDF2: null,
|
|
94
|
+
'AES-CTR': null,
|
|
95
|
+
'AES-CBC': null,
|
|
96
|
+
'AES-GCM': null,
|
|
97
|
+
'AES-KW': null,
|
|
98
|
+
Ed25519: null,
|
|
99
|
+
X25519: null,
|
|
100
|
+
Ed448: null,
|
|
101
|
+
X448: null,
|
|
102
|
+
},
|
|
103
|
+
deriveBits: {
|
|
104
|
+
HKDF: 'HkdfParams',
|
|
105
|
+
PBKDF2: 'Pbkdf2Params',
|
|
106
|
+
ECDH: 'EcdhKeyDeriveParams',
|
|
107
|
+
X25519: 'EcdhKeyDeriveParams',
|
|
108
|
+
X448: 'EcdhKeyDeriveParams',
|
|
109
|
+
},
|
|
110
|
+
encrypt: {
|
|
111
|
+
'RSA-OAEP': 'RsaOaepParams',
|
|
112
|
+
'AES-CBC': 'AesCbcParams',
|
|
113
|
+
'AES-GCM': 'AesGcmParams',
|
|
114
|
+
'AES-CTR': 'AesCtrParams',
|
|
115
|
+
},
|
|
116
|
+
decrypt: {
|
|
117
|
+
'RSA-OAEP': 'RsaOaepParams',
|
|
118
|
+
'AES-CBC': 'AesCbcParams',
|
|
119
|
+
'AES-GCM': 'AesGcmParams',
|
|
120
|
+
'AES-CTR': 'AesCtrParams',
|
|
121
|
+
},
|
|
122
|
+
'get key length': {
|
|
123
|
+
'AES-CBC': 'AesDerivedKeyParams',
|
|
124
|
+
'AES-CTR': 'AesDerivedKeyParams',
|
|
125
|
+
'AES-GCM': 'AesDerivedKeyParams',
|
|
126
|
+
'AES-KW': 'AesDerivedKeyParams',
|
|
127
|
+
HMAC: 'HmacImportParams',
|
|
128
|
+
HKDF: null,
|
|
129
|
+
PBKDF2: null,
|
|
130
|
+
},
|
|
131
|
+
wrapKey: {
|
|
132
|
+
'AES-KW': null,
|
|
133
|
+
},
|
|
134
|
+
unwrapKey: {
|
|
135
|
+
'AES-KW': null,
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
type AlgorithmDictionaries = {
|
|
140
|
+
[key in string]: object;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const simpleAlgorithmDictionaries: AlgorithmDictionaries = {
|
|
144
|
+
AesGcmParams: { iv: 'BufferSource', additionalData: 'BufferSource' },
|
|
145
|
+
RsaHashedKeyGenParams: { hash: 'HashAlgorithmIdentifier' },
|
|
146
|
+
EcKeyGenParams: {},
|
|
147
|
+
HmacKeyGenParams: { hash: 'HashAlgorithmIdentifier' },
|
|
148
|
+
RsaPssParams: {},
|
|
149
|
+
EcdsaParams: { hash: 'HashAlgorithmIdentifier' },
|
|
150
|
+
HmacImportParams: { hash: 'HashAlgorithmIdentifier' },
|
|
151
|
+
HkdfParams: {
|
|
152
|
+
hash: 'HashAlgorithmIdentifier',
|
|
153
|
+
salt: 'BufferSource',
|
|
154
|
+
info: 'BufferSource',
|
|
155
|
+
},
|
|
156
|
+
Ed448Params: { context: 'BufferSource' },
|
|
157
|
+
Pbkdf2Params: { hash: 'HashAlgorithmIdentifier', salt: 'BufferSource' },
|
|
158
|
+
RsaOaepParams: { label: 'BufferSource' },
|
|
159
|
+
RsaHashedImportParams: { hash: 'HashAlgorithmIdentifier' },
|
|
160
|
+
EcKeyImportParams: {},
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// https://w3c.github.io/webcrypto/#algorithm-normalization-normalize-an-algorithm
|
|
164
|
+
// adapted for Node.js from Deno's implementation
|
|
165
|
+
// https://github.com/denoland/deno/blob/v1.29.1/ext/crypto/00_crypto.js#L195
|
|
166
|
+
export const normalizeAlgorithm = (
|
|
167
|
+
algorithm: SubtleAlgorithm | EncryptDecryptParams | AnyAlgorithm,
|
|
168
|
+
op: Operation,
|
|
169
|
+
): SubtleAlgorithm | EncryptDecryptParams => {
|
|
170
|
+
if (typeof algorithm === 'string') {
|
|
171
|
+
return normalizeAlgorithm({ name: algorithm }, op);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// 1.
|
|
175
|
+
const registeredAlgorithms = kSupportedAlgorithms[op];
|
|
176
|
+
// 2. 3.
|
|
177
|
+
// commented, because typescript takes care of this for us 🤞👀
|
|
178
|
+
// const initialAlg = webidl.converters.Algorithm(algorithm, {
|
|
179
|
+
// prefix: 'Failed to normalize algorithm',
|
|
180
|
+
// context: 'passed algorithm',
|
|
181
|
+
// });
|
|
182
|
+
|
|
183
|
+
// 4.
|
|
184
|
+
let algName = algorithm.name;
|
|
185
|
+
if (algName === undefined) return { name: 'unknown' };
|
|
186
|
+
|
|
187
|
+
// 5.
|
|
188
|
+
let desiredType: string | null | undefined;
|
|
189
|
+
for (const key in registeredAlgorithms) {
|
|
190
|
+
if (!Object.prototype.hasOwnProperty.call(registeredAlgorithms, key)) {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
if (key.toUpperCase() === algName.toUpperCase()) {
|
|
194
|
+
algName = key as AnyAlgorithm;
|
|
195
|
+
desiredType = (
|
|
196
|
+
registeredAlgorithms as Record<string, typeof desiredType>
|
|
197
|
+
)[algName];
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (desiredType === undefined)
|
|
201
|
+
throw new Error(`Unrecognized algorithm name: ${algName}`);
|
|
202
|
+
|
|
203
|
+
// Fast path everything below if the registered dictionary is null
|
|
204
|
+
if (desiredType === null) return { name: algName };
|
|
205
|
+
|
|
206
|
+
// 6.
|
|
207
|
+
const normalizedAlgorithm = algorithm;
|
|
208
|
+
// TODO: implement this? Maybe via typescript?
|
|
209
|
+
// webidl.converters[desiredType](algorithm, {
|
|
210
|
+
// prefix: 'Failed to normalize algorithm',
|
|
211
|
+
// context: 'passed algorithm',
|
|
212
|
+
// });
|
|
213
|
+
// 7.
|
|
214
|
+
normalizedAlgorithm.name = algName;
|
|
215
|
+
|
|
216
|
+
// 9.
|
|
217
|
+
const dict = simpleAlgorithmDictionaries[desiredType];
|
|
218
|
+
// 10.
|
|
219
|
+
const dictKeys = dict ? Object.keys(dict) : [];
|
|
220
|
+
for (let i = 0; i < dictKeys.length; i++) {
|
|
221
|
+
const member = dictKeys[i] || '';
|
|
222
|
+
if (!Object.prototype.hasOwnProperty.call(dict, member)) continue;
|
|
223
|
+
// TODO: implement this? Maybe via typescript?
|
|
224
|
+
// const idlType = dict[member];
|
|
225
|
+
// const idlValue = normalizedAlgorithm[member];
|
|
226
|
+
// 3.
|
|
227
|
+
// if (idlType === 'BufferSource' && idlValue) {
|
|
228
|
+
// const isView = ArrayBufferIsView(idlValue);
|
|
229
|
+
// normalizedAlgorithm[member] = TypedArrayPrototypeSlice(
|
|
230
|
+
// new Uint8Array(
|
|
231
|
+
// isView ? getDataViewOrTypedArrayBuffer(idlValue) : idlValue,
|
|
232
|
+
// isView ? getDataViewOrTypedArrayByteOffset(idlValue) : 0,
|
|
233
|
+
// isView
|
|
234
|
+
// ? getDataViewOrTypedArrayByteLength(idlValue)
|
|
235
|
+
// : ArrayBufferPrototypeGetByteLength(idlValue)
|
|
236
|
+
// )
|
|
237
|
+
// );
|
|
238
|
+
// } else if (idlType === 'HashAlgorithmIdentifier') {
|
|
239
|
+
// normalizedAlgorithm[member] = normalizeAlgorithm(idlValue, 'digest');
|
|
240
|
+
// } else if (idlType === 'AlgorithmIdentifier') {
|
|
241
|
+
// // This extension point is not used by any supported algorithm (yet?)
|
|
242
|
+
// throw lazyDOMException('Not implemented.', 'NotSupportedError');
|
|
243
|
+
// }
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return normalizedAlgorithm;
|
|
247
|
+
};
|
package/src/Hash.ts
CHANGED
package/src/Hashnames.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HashAlgorithmIdentifier, HashAlgorithm } from './keys';
|
|
2
2
|
|
|
3
3
|
export enum HashContext {
|
|
4
4
|
Node,
|
|
@@ -79,7 +79,7 @@ const kHashNames: HashNames = {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export function normalizeHashName(
|
|
82
|
-
algo: string | HashAlgorithm |
|
|
82
|
+
algo: string | HashAlgorithm | HashAlgorithmIdentifier | undefined,
|
|
83
83
|
context: HashContext = HashContext.Node,
|
|
84
84
|
): HashAlgorithm {
|
|
85
85
|
if (typeof algo !== 'undefined') {
|
|
@@ -91,8 +91,8 @@ export function normalizeHashName(
|
|
|
91
91
|
const alias = kHashNames[normAlgo]![context] as HashAlgorithm;
|
|
92
92
|
if (alias) return alias;
|
|
93
93
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
94
|
-
} catch (_e) {
|
|
95
|
-
|
|
94
|
+
} catch (_e: unknown) {
|
|
95
|
+
/* empty */
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
throw new Error(`Invalid Hash Algorithm: ${algo}`);
|