@matter/react-native 0.16.0-alpha.0-20251216-71c21f901 → 0.16.0-alpha.0-20251220-0bb8d9f89

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.
@@ -3,34 +3,12 @@
3
3
  * Copyright 2022-2025 Matter.js Authors
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { Bytes, HashAlgorithm, PrivateKey, PublicKey, StandardCrypto } from "#general";
6
+ import { StandardCrypto } from "#general";
7
7
  /**
8
- * Crypto implementation for React Native.
8
+ * Crypto implementation for React Native should work with a WebCrypto basis with 1.x
9
9
  */
10
10
  export declare class ReactNativeCrypto extends StandardCrypto {
11
11
  implementationName: string;
12
12
  static provider(): ReactNativeCrypto;
13
- /**
14
- * Quick Crypto doesn't currently support {@link SubtleCrypto#deriveBits}.
15
- */
16
- createHkdfKey(secret: Bytes, salt: Bytes, info: Bytes, length?: number): Promise<Uint8Array<ArrayBuffer>>;
17
- /**
18
- * Quick Crypto apparently appends a "." to the base64 encoded properties. I'm not aware of a legitimate reason for
19
- * this, seems likely just a bug. Regardless it trips us off so strip off.
20
- */
21
- generateJwk(): Promise<JsonWebKey>;
22
- /**
23
- * See comment on {@link createHkdfKey}.
24
- */
25
- generateDhSecret(key: PrivateKey, peerKey: PublicKey): Promise<AllowSharedBufferSource>;
26
- /**
27
- * QuickCrypto's subtle doesn't support HMAC signing; instead rely on Node.js crypto emulation.
28
- */
29
- signHmac: (key: Bytes, data: Bytes) => Bytes;
30
- /**
31
- * Override computeHash to block Tier 3 algorithms (SHA-512/224, SHA-512/256, SHA3-256).
32
- * React Native/QuickCrypto is assumed to not support these advanced algorithms.
33
- */
34
- computeHash(data: Bytes | Bytes[] | ReadableStreamDefaultReader<Bytes> | AsyncIterator<Bytes>, algorithm?: HashAlgorithm): Promise<ArrayBuffer>;
35
13
  }
36
14
  //# sourceMappingURL=ReactNativeCrypto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeCrypto.d.ts","sourceRoot":"","sources":["../../../src/crypto/ReactNativeCrypto.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACH,KAAK,EAML,aAAa,EAIb,UAAU,EACV,SAAS,EACT,cAAc,EAEjB,MAAM,UAAU,CAAC;AAkBlB;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,cAAc;IACxC,kBAAkB,SAAuB;WAElC,QAAQ;IAIxB;;OAEG;IACY,aAAa,CACxB,MAAM,EAAE,KAAK,EACb,IAAI,EAAE,KAAK,EACX,IAAI,EAAE,KAAK,EACX,MAAM,GAAE,MAAoC;IAyChD;;;OAGG;IACY,WAAW;IAY1B;;OAEG;IACY,gBAAgB,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS;IAInE;;OAEG;IACM,QAAQ,qCAA4C;IAE7D;;;OAGG;IACM,WAAW,CAChB,IAAI,EAAE,KAAK,GAAG,KAAK,EAAE,GAAG,2BAA2B,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,EACjF,SAAS,GAAE,aAAyB;CAK3C"}
1
+ {"version":3,"file":"ReactNativeCrypto.d.ts","sourceRoot":"","sources":["../../../src/crypto/ReactNativeCrypto.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAgC,cAAc,EAAa,MAAM,UAAU,CAAC;AAcnF;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,cAAc;IACxC,kBAAkB,SAAuB;WAElC,QAAQ;CAG3B"}
@@ -39,7 +39,6 @@ var import_react_native_quick_crypto = __toESM(require("react-native-quick-crypt
39
39
  * Copyright 2022-2025 Matter.js Authors
40
40
  * SPDX-License-Identifier: Apache-2.0
41
41
  */
42
- const nodeJsCrypto = new import_general.NodeJsStyleCrypto(import_react_native_quick_crypto.default);
43
42
  const crypto = import_react_native_quick_crypto.default;
44
43
  if (!("Buffer" in globalThis)) {
45
44
  globalThis.Buffer = import_react_native_buffer.Buffer;
@@ -49,57 +48,6 @@ class ReactNativeCrypto extends import_general.StandardCrypto {
49
48
  static provider() {
50
49
  return new ReactNativeCrypto(crypto);
51
50
  }
52
- /**
53
- * Quick Crypto doesn't currently support {@link SubtleCrypto#deriveBits}.
54
- */
55
- async createHkdfKey(secret, salt, info, length = import_general.CRYPTO_SYMMETRIC_KEY_LENGTH) {
56
- const prk = crypto.createHmac("SHA-256", salt.byteLength ? import_general.Bytes.of(salt) : new Uint8Array(import_general.CRYPTO_HASH_LEN_BYTES)).update(import_general.Bytes.of(secret)).digest();
57
- const N = Math.ceil(length / import_general.CRYPTO_HASH_LEN_BYTES);
58
- const T = new Uint8Array(import_general.CRYPTO_HASH_LEN_BYTES * N + info.byteLength + 1);
59
- let prev = 0;
60
- let start = 0;
61
- for (let c = 1; c <= N; c++) {
62
- T.set(import_general.Bytes.of(info), start);
63
- T[start + info.byteLength] = c;
64
- T.set(
65
- crypto.createHmac("SHA-256", prk).update(T.subarray(prev, start + info.byteLength + 1)).digest(),
66
- start
67
- );
68
- prev = start;
69
- start += import_general.CRYPTO_HASH_LEN_BYTES;
70
- }
71
- return T.slice(0, length);
72
- }
73
- /**
74
- * Quick Crypto apparently appends a "." to the base64 encoded properties. I'm not aware of a legitimate reason for
75
- * this, seems likely just a bug. Regardless it trips us off so strip off.
76
- */
77
- async generateJwk() {
78
- const key = await super.generateJwk();
79
- for (const prop of ["d", "x", "y"]) {
80
- if (key[prop]?.endsWith(".")) {
81
- key[prop] = key[prop].slice(0, key[prop].length - 1);
82
- }
83
- }
84
- return key;
85
- }
86
- /**
87
- * See comment on {@link createHkdfKey}.
88
- */
89
- async generateDhSecret(key, peerKey) {
90
- return import_general.Key.sharedSecretFor(key, peerKey);
91
- }
92
- /**
93
- * QuickCrypto's subtle doesn't support HMAC signing; instead rely on Node.js crypto emulation.
94
- */
95
- signHmac = nodeJsCrypto.signHmac.bind(nodeJsCrypto);
96
- /**
97
- * Override computeHash to block Tier 3 algorithms (SHA-512/224, SHA-512/256, SHA3-256).
98
- * React Native/QuickCrypto is assumed to not support these advanced algorithms.
99
- */
100
- computeHash(data, algorithm = "SHA-256") {
101
- return super.computeHash(data, algorithm);
102
- }
103
51
  }
104
52
  {
105
53
  const rnCrypto = new ReactNativeCrypto(crypto);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/crypto/ReactNativeCrypto.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,qBAeO;AACP,iCAAuB;AACvB,uCAAwB;AAvBxB;AAAA;AAAA;AAAA;AAAA;AA2BA,MAAM,eAAe,IAAI,iCAAkB,iCAAAA,OAA6C;AAIxF,MAAM,SAAS,iCAAAA;AAIf,IAAI,EAAE,YAAY,aAAa;AAC3B,EAAC,WAAoD,SAAS;AAClE;AAKO,MAAM,0BAA0B,8BAAe;AAAA,EACzC,qBAAqB;AAAA,EAE9B,OAAgB,WAAW;AACvB,WAAO,IAAI,kBAAkB,MAA8B;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA,EAKA,MAAe,cACX,QACA,MACA,MACA,SAAiB,4CACnB;AACE,UAAM,MAAM,OACP,WAAW,WAAW,KAAK,aAAa,qBAAM,GAAG,IAAI,IAAI,IAAI,WAAW,oCAAqB,CAAC,EAC9F,OAAO,qBAAM,GAAG,MAAM,CAAC,EACvB,OAAO;AASZ,UAAM,IAAI,KAAK,KAAK,SAAS,oCAAqB;AAIlD,UAAM,IAAI,IAAI,WAAW,uCAAwB,IAAI,KAAK,aAAa,CAAC;AACxE,QAAI,OAAO;AACX,QAAI,QAAQ;AACZ,aAAS,IAAI,GAAG,KAAK,GAAG,KAAK;AACzB,QAAE,IAAI,qBAAM,GAAG,IAAI,GAAG,KAAK;AAC3B,QAAE,QAAQ,KAAK,UAAU,IAAI;AAE7B,QAAE;AAAA,QACE,OACK,WAAW,WAAW,GAAG,EACzB,OAAO,EAAE,SAAS,MAAM,QAA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B;AAAA,EAC/D;AACJ;AAEA;AACI,QAAM,WAAW,IAAI,kBAAkB,MAA8B;AACrE,6BAAY,QAAQ,IAAI,wBAAS,QAAQ;AACzC,6BAAY,QAAQ,IAAI,uBAAQ,QAAQ;AAC5C;",
5
5
  "names": ["QuickCrypto"]
6
6
  }
@@ -3,34 +3,12 @@
3
3
  * Copyright 2022-2025 Matter.js Authors
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { Bytes, HashAlgorithm, PrivateKey, PublicKey, StandardCrypto } from "#general";
6
+ import { StandardCrypto } from "#general";
7
7
  /**
8
- * Crypto implementation for React Native.
8
+ * Crypto implementation for React Native should work with a WebCrypto basis with 1.x
9
9
  */
10
10
  export declare class ReactNativeCrypto extends StandardCrypto {
11
11
  implementationName: string;
12
12
  static provider(): ReactNativeCrypto;
13
- /**
14
- * Quick Crypto doesn't currently support {@link SubtleCrypto#deriveBits}.
15
- */
16
- createHkdfKey(secret: Bytes, salt: Bytes, info: Bytes, length?: number): Promise<Uint8Array<ArrayBuffer>>;
17
- /**
18
- * Quick Crypto apparently appends a "." to the base64 encoded properties. I'm not aware of a legitimate reason for
19
- * this, seems likely just a bug. Regardless it trips us off so strip off.
20
- */
21
- generateJwk(): Promise<JsonWebKey>;
22
- /**
23
- * See comment on {@link createHkdfKey}.
24
- */
25
- generateDhSecret(key: PrivateKey, peerKey: PublicKey): Promise<AllowSharedBufferSource>;
26
- /**
27
- * QuickCrypto's subtle doesn't support HMAC signing; instead rely on Node.js crypto emulation.
28
- */
29
- signHmac: (key: Bytes, data: Bytes) => Bytes;
30
- /**
31
- * Override computeHash to block Tier 3 algorithms (SHA-512/224, SHA-512/256, SHA3-256).
32
- * React Native/QuickCrypto is assumed to not support these advanced algorithms.
33
- */
34
- computeHash(data: Bytes | Bytes[] | ReadableStreamDefaultReader<Bytes> | AsyncIterator<Bytes>, algorithm?: HashAlgorithm): Promise<ArrayBuffer>;
35
13
  }
36
14
  //# sourceMappingURL=ReactNativeCrypto.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeCrypto.d.ts","sourceRoot":"","sources":["../../../src/crypto/ReactNativeCrypto.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACH,KAAK,EAML,aAAa,EAIb,UAAU,EACV,SAAS,EACT,cAAc,EAEjB,MAAM,UAAU,CAAC;AAkBlB;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,cAAc;IACxC,kBAAkB,SAAuB;WAElC,QAAQ;IAIxB;;OAEG;IACY,aAAa,CACxB,MAAM,EAAE,KAAK,EACb,IAAI,EAAE,KAAK,EACX,IAAI,EAAE,KAAK,EACX,MAAM,GAAE,MAAoC;IAyChD;;;OAGG;IACY,WAAW;IAY1B;;OAEG;IACY,gBAAgB,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS;IAInE;;OAEG;IACM,QAAQ,qCAA4C;IAE7D;;;OAGG;IACM,WAAW,CAChB,IAAI,EAAE,KAAK,GAAG,KAAK,EAAE,GAAG,2BAA2B,CAAC,KAAK,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,EACjF,SAAS,GAAE,aAAyB;CAK3C"}
1
+ {"version":3,"file":"ReactNativeCrypto.d.ts","sourceRoot":"","sources":["../../../src/crypto/ReactNativeCrypto.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAgC,cAAc,EAAa,MAAM,UAAU,CAAC;AAcnF;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,cAAc;IACxC,kBAAkB,SAAuB;WAElC,QAAQ;CAG3B"}
@@ -3,20 +3,9 @@
3
3
  * Copyright 2022-2025 Matter.js Authors
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import {
7
- Bytes,
8
- Crypto,
9
- CRYPTO_HASH_LEN_BYTES,
10
- CRYPTO_SYMMETRIC_KEY_LENGTH,
11
- Entropy,
12
- Environment,
13
- Key,
14
- NodeJsStyleCrypto,
15
- StandardCrypto
16
- } from "#general";
6
+ import { Crypto, Entropy, Environment, StandardCrypto } from "#general";
17
7
  import { Buffer } from "@craftzdog/react-native-buffer";
18
8
  import QuickCrypto from "react-native-quick-crypto";
19
- const nodeJsCrypto = new NodeJsStyleCrypto(QuickCrypto);
20
9
  const crypto = QuickCrypto;
21
10
  if (!("Buffer" in globalThis)) {
22
11
  globalThis.Buffer = Buffer;
@@ -26,57 +15,6 @@ class ReactNativeCrypto extends StandardCrypto {
26
15
  static provider() {
27
16
  return new ReactNativeCrypto(crypto);
28
17
  }
29
- /**
30
- * Quick Crypto doesn't currently support {@link SubtleCrypto#deriveBits}.
31
- */
32
- async createHkdfKey(secret, salt, info, length = CRYPTO_SYMMETRIC_KEY_LENGTH) {
33
- const prk = crypto.createHmac("SHA-256", salt.byteLength ? Bytes.of(salt) : new Uint8Array(CRYPTO_HASH_LEN_BYTES)).update(Bytes.of(secret)).digest();
34
- const N = Math.ceil(length / CRYPTO_HASH_LEN_BYTES);
35
- const T = new Uint8Array(CRYPTO_HASH_LEN_BYTES * N + info.byteLength + 1);
36
- let prev = 0;
37
- let start = 0;
38
- for (let c = 1; c <= N; c++) {
39
- T.set(Bytes.of(info), start);
40
- T[start + info.byteLength] = c;
41
- T.set(
42
- crypto.createHmac("SHA-256", prk).update(T.subarray(prev, start + info.byteLength + 1)).digest(),
43
- start
44
- );
45
- prev = start;
46
- start += CRYPTO_HASH_LEN_BYTES;
47
- }
48
- return T.slice(0, length);
49
- }
50
- /**
51
- * Quick Crypto apparently appends a "." to the base64 encoded properties. I'm not aware of a legitimate reason for
52
- * this, seems likely just a bug. Regardless it trips us off so strip off.
53
- */
54
- async generateJwk() {
55
- const key = await super.generateJwk();
56
- for (const prop of ["d", "x", "y"]) {
57
- if (key[prop]?.endsWith(".")) {
58
- key[prop] = key[prop].slice(0, key[prop].length - 1);
59
- }
60
- }
61
- return key;
62
- }
63
- /**
64
- * See comment on {@link createHkdfKey}.
65
- */
66
- async generateDhSecret(key, peerKey) {
67
- return Key.sharedSecretFor(key, peerKey);
68
- }
69
- /**
70
- * QuickCrypto's subtle doesn't support HMAC signing; instead rely on Node.js crypto emulation.
71
- */
72
- signHmac = nodeJsCrypto.signHmac.bind(nodeJsCrypto);
73
- /**
74
- * Override computeHash to block Tier 3 algorithms (SHA-512/224, SHA-512/256, SHA3-256).
75
- * React Native/QuickCrypto is assumed to not support these advanced algorithms.
76
- */
77
- computeHash(data, algorithm = "SHA-256") {
78
- return super.computeHash(data, algorithm);
79
- }
80
18
  }
81
19
  {
82
20
  const rnCrypto = new ReactNativeCrypto(crypto);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/crypto/ReactNativeCrypto.ts"],
4
- "mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,EAGA;AAAA,OAEG;AACP,SAAS,cAAc;AACvB,OAAO,iBAAiB;AAIxB,MAAM,eAAe,IAAI,kBAAkB,WAA6C;AAIxF,MAAM,SAAS;AAIf,IAAI,EAAE,YAAY,aAAa;AAC3B,EAAC,WAAoD,SAAS;AAClE;AAKO,MAAM,0BAA0B,eAAe;AAAA,EACzC,qBAAqB;AAAA,EAE9B,OAAgB,WAAW;AACvB,WAAO,IAAI,kBAAkB,MAA8B;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA,EAKA,MAAe,cACX,QACA,MACA,MACA,SAAiB,6BACnB;AACE,UAAM,MAAM,OACP,WAAW,WAAW,KAAK,aAAa,MAAM,GAAG,IAAI,IAAI,IAAI,WAAW,qBAAqB,CAAC,EAC9F,OAAO,MAAM,GAAG,MAAM,CAAC,EACvB,OAAO;AASZ,UAAM,IAAI,KAAK,KAAK,SAAS,qBAAqB;AAIlD,UAAM,IAAI,IAAI,WAAW,wBAAwB,IAAI,KAAK,aAAa,CAAC;AACxE,QAAI,OAAO;AAC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B,MAAM,SAAS;AAIf,IAAI,EAAE,YAAY,aAAa;AAC3B,EAAC,WAAoD,SAAS;AAClE;AAKO,MAAM,0BAA0B,eAAe;AAAA,EACzC,qBAAqB;AAAA,EAE9B,OAAgB,WAAW;AACvB,WAAO,IAAI,kBAAkB,MAA8B;AAAA,EAC/D;AACJ;AAEA;AACI,QAAM,WAAW,IAAI,kBAAkB,MAA8B;AACrE,cAAY,QAAQ,IAAI,SAAS,QAAQ;AACzC,cAAY,QAAQ,IAAI,QAAQ,QAAQ;AAC5C;",
5
5
  "names": []
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matter/react-native",
3
- "version": "0.16.0-alpha.0-20251216-71c21f901",
3
+ "version": "0.16.0-alpha.0-20251220-0bb8d9f89",
4
4
  "description": "Experimental React Native support for matter.js",
5
5
  "keywords": [
6
6
  "iot",
@@ -36,19 +36,19 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@craftzdog/react-native-buffer": "6.1.1",
39
- "@matter/general": "0.16.0-alpha.0-20251216-71c21f901",
40
- "@matter/nodejs": "0.16.0-alpha.0-20251216-71c21f901",
41
- "@matter/protocol": "0.16.0-alpha.0-20251216-71c21f901",
39
+ "@matter/general": "0.16.0-alpha.0-20251220-0bb8d9f89",
40
+ "@matter/nodejs": "0.16.0-alpha.0-20251220-0bb8d9f89",
41
+ "@matter/protocol": "0.16.0-alpha.0-20251220-0bb8d9f89",
42
42
  "@react-native-async-storage/async-storage": "^2.2.0",
43
43
  "@react-native-community/netinfo": "^11.4.1",
44
- "@types/node": "^24.10.2",
44
+ "@types/node": "^25.0.3",
45
45
  "react-native-ble-plx": "^3.5.0",
46
46
  "react-native-polyfill-globals": "^3.1.0",
47
- "react-native-quick-crypto": "^0.7.17",
47
+ "react-native-quick-crypto": "^1.0.6",
48
48
  "react-native-udp": "^4.1.7"
49
49
  },
50
50
  "devDependencies": {
51
- "@matter/tools": "0.16.0-alpha.0-20251216-71c21f901"
51
+ "@matter/tools": "0.16.0-alpha.0-20251220-0bb8d9f89"
52
52
  },
53
53
  "overrides": {
54
54
  "brorand": "npm:@matter.js/brorand@1.1.0"
@@ -4,29 +4,10 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import {
8
- Bytes,
9
- Crypto,
10
- CRYPTO_HASH_LEN_BYTES,
11
- CRYPTO_SYMMETRIC_KEY_LENGTH,
12
- Entropy,
13
- Environment,
14
- HashAlgorithm,
15
- Key,
16
- NodeJsCryptoApiLike,
17
- NodeJsStyleCrypto,
18
- PrivateKey,
19
- PublicKey,
20
- StandardCrypto,
21
- WebCrypto,
22
- } from "#general";
7
+ import { Crypto, Entropy, Environment, StandardCrypto, WebCrypto } from "#general";
23
8
  import { Buffer } from "@craftzdog/react-native-buffer";
24
9
  import QuickCrypto from "react-native-quick-crypto";
25
10
 
26
- // This is probably the crypto implementation we should be building on because Quick Crypto's node.js emulation is more
27
- // mature than their web crypto support. However, for now we just use for API portions where web crypto does not work
28
- const nodeJsCrypto = new NodeJsStyleCrypto(QuickCrypto as unknown as NodeJsCryptoApiLike);
29
-
30
11
  // The default export from QuickCrypto should be compatible with the standard `crypto` object but the type system
31
12
  // seems confused by CJS exports. Use a forced cast to correct types.
32
13
  const crypto = QuickCrypto as unknown as typeof QuickCrypto.default;
@@ -38,7 +19,7 @@ if (!("Buffer" in globalThis)) {
38
19
  }
39
20
 
40
21
  /**
41
- * Crypto implementation for React Native.
22
+ * Crypto implementation for React Native should work with a WebCrypto basis with 1.x
42
23
  */
43
24
  export class ReactNativeCrypto extends StandardCrypto {
44
25
  override implementationName = "ReactNativeCrypto";
@@ -46,94 +27,6 @@ export class ReactNativeCrypto extends StandardCrypto {
46
27
  static override provider() {
47
28
  return new ReactNativeCrypto(crypto as unknown as WebCrypto);
48
29
  }
49
-
50
- /**
51
- * Quick Crypto doesn't currently support {@link SubtleCrypto#deriveBits}.
52
- */
53
- override async createHkdfKey(
54
- secret: Bytes,
55
- salt: Bytes,
56
- info: Bytes,
57
- length: number = CRYPTO_SYMMETRIC_KEY_LENGTH,
58
- ) {
59
- const prk = crypto
60
- .createHmac("SHA-256", salt.byteLength ? Bytes.of(salt) : new Uint8Array(CRYPTO_HASH_LEN_BYTES))
61
- .update(Bytes.of(secret))
62
- .digest();
63
-
64
- // T(0) = empty
65
- // T(1) = HMAC(PRK, T(0) | info | 0x01)
66
- // T(2) = HMAC(PRK, T(1) | info | 0x02)
67
- // T(3) = HMAC(PRK, T(2) | info | 0x03)
68
- // ...
69
- // T(N) = HMAC(PRK, T(N-1) | info | N)
70
-
71
- const N = Math.ceil(length / CRYPTO_HASH_LEN_BYTES);
72
-
73
- // Single T buffer to accommodate T = T(1) | T(2) | T(3) | ... | T(N)
74
- // with a little extra for info | N during T(N)
75
- const T = new Uint8Array(CRYPTO_HASH_LEN_BYTES * N + info.byteLength + 1);
76
- let prev = 0;
77
- let start = 0;
78
- for (let c = 1; c <= N; c++) {
79
- T.set(Bytes.of(info), start);
80
- T[start + info.byteLength] = c;
81
-
82
- T.set(
83
- crypto
84
- .createHmac("SHA-256", prk)
85
- .update(T.subarray(prev, start + info.byteLength + 1))
86
- .digest(),
87
- start,
88
- );
89
-
90
- prev = start;
91
- start += CRYPTO_HASH_LEN_BYTES;
92
- }
93
-
94
- // OKM, releasing T
95
- return T.slice(0, length);
96
- }
97
-
98
- /**
99
- * Quick Crypto apparently appends a "." to the base64 encoded properties. I'm not aware of a legitimate reason for
100
- * this, seems likely just a bug. Regardless it trips us off so strip off.
101
- */
102
- override async generateJwk() {
103
- const key = await super.generateJwk();
104
-
105
- for (const prop of ["d", "x", "y"] as const) {
106
- if (key[prop]?.endsWith(".")) {
107
- key[prop] = key[prop].slice(0, key[prop].length - 1);
108
- }
109
- }
110
-
111
- return key;
112
- }
113
-
114
- /**
115
- * See comment on {@link createHkdfKey}.
116
- */
117
- override async generateDhSecret(key: PrivateKey, peerKey: PublicKey) {
118
- return Key.sharedSecretFor(key, peerKey);
119
- }
120
-
121
- /**
122
- * QuickCrypto's subtle doesn't support HMAC signing; instead rely on Node.js crypto emulation.
123
- */
124
- override signHmac = nodeJsCrypto.signHmac.bind(nodeJsCrypto);
125
-
126
- /**
127
- * Override computeHash to block Tier 3 algorithms (SHA-512/224, SHA-512/256, SHA3-256).
128
- * React Native/QuickCrypto is assumed to not support these advanced algorithms.
129
- */
130
- override computeHash(
131
- data: Bytes | Bytes[] | ReadableStreamDefaultReader<Bytes> | AsyncIterator<Bytes>,
132
- algorithm: HashAlgorithm = "SHA-256",
133
- ) {
134
- // Delegate to StandardCrypto for algorithms SHA-256, SHA-512 and SHA-384
135
- return super.computeHash(data, algorithm);
136
- }
137
30
  }
138
31
 
139
32
  {