react-native-quick-crypto 1.1.2 → 1.1.4

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.
@@ -93,7 +93,7 @@ export function rejectSharedArrayBuffer(buf: unknown): void {
93
93
  * Only use this when the caller separately tracks `byteOffset`/`byteLength`
94
94
  * and the native receiver needs to write back into the original memory
95
95
  * (e.g. `randomFill`). For data that will be read by native crypto, use
96
- * `binaryLikeToArrayBuffer`/`toArrayBuffer` instead — those slice to the
96
+ * `binaryLikeToArrayBuffer`/`toArrayBuffer` instead — those return only the
97
97
  * view's region and won't leak unrelated bytes from the backing buffer.
98
98
  */
99
99
  export const abvToArrayBuffer = (buf: ABV) => {
@@ -108,8 +108,10 @@ export const abvToArrayBuffer = (buf: ABV) => {
108
108
  };
109
109
 
110
110
  /**
111
- * Converts supplied argument to an ArrayBuffer. Note this copies data if the
112
- * supplied buffer has the .slice() method, so can be a bit slow.
111
+ * Converts supplied argument to an ArrayBuffer. Note this copies data
112
+ * only when the supplied view represents a subrange of the underlying
113
+ * ArrayBuffer; otherwise the backing buffer is returned directly
114
+ * (aliased — do not mutate after passing).
113
115
  * @param buf
114
116
  * @returns ArrayBuffer
115
117
  */
@@ -117,13 +119,13 @@ export function toArrayBuffer(
117
119
  buf: CraftzdogBuffer | SafeBuffer | ArrayBufferView,
118
120
  ): ArrayBuffer {
119
121
  if (CraftzdogBuffer.isBuffer(buf) || ArrayBuffer.isView(buf)) {
120
- if (buf?.buffer?.slice) {
122
+ if (buf.byteOffset === 0 && buf.byteLength === buf.buffer.byteLength) {
123
+ return buf.buffer as ArrayBuffer;
124
+ } else {
121
125
  return buf.buffer.slice(
122
126
  buf.byteOffset,
123
127
  buf.byteOffset + buf.byteLength,
124
128
  ) as ArrayBuffer;
125
- } else {
126
- return buf.buffer as ArrayBuffer;
127
129
  }
128
130
  }
129
131
  const ab = new ArrayBuffer(buf.length);
@@ -271,6 +271,10 @@ export type SubtleAlgorithm = {
271
271
  saltLength?: number;
272
272
  public?: CryptoKey;
273
273
  info?: BufferLike;
274
+ // AEAD / AES-CBC / AES-CTR parameters surfaced here so callers (e.g.
275
+ // Subtle.supports) can pass a single union without per-algorithm casts.
276
+ iv?: BufferLike;
277
+ counter?: BufferLike;
274
278
  // Argon2 parameters
275
279
  nonce?: BufferLike;
276
280
  parallelism?: number;
@@ -595,6 +599,7 @@ export type Operation =
595
599
  | 'decapsulateBits'
596
600
  | 'encapsulateKey'
597
601
  | 'decapsulateKey'
602
+ | 'digest'
598
603
  | 'get key length';
599
604
 
600
605
  export interface KeyPairOptions {