(bytes: ArrayBuffer | ArrayBufferView)
| 435 | } |
| 436 | |
| 437 | function hashBytesForCacheKey(bytes: ArrayBuffer | ArrayBufferView) { |
| 438 | const buffer = ArrayBuffer.isView(bytes) |
| 439 | ? Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength) |
| 440 | : Buffer.from(bytes); |
| 441 | return { |
| 442 | byteLength: buffer.byteLength, |
| 443 | hmacSha256: crypto |
| 444 | .createHmac('sha256', FETCH_CACHE_SECRET_HMAC_SALT) |
| 445 | .update(`${FETCH_CACHE_SECRET_HMAC_CONTEXT}:bytes`) |
| 446 | .update('\0') |
| 447 | .update(buffer) |
| 448 | .digest('hex'), |
| 449 | }; |
| 450 | } |
| 451 | |
| 452 | function getBodyForFetchCacheKey(body: RequestInit['body'] | ReadableStream | null | undefined) { |
| 453 | if (body == null) { |
no test coverage detected
searching dependent graphs…