Skip to content

Commit

Permalink
Pass correctly-typed value to webcrypto.getRandomValues()
Browse files Browse the repository at this point in the history
This was previously a `DataView`, not an integer-type TypedArray,
throwing in Node 17.5.0: nodejs/node#41481
  • Loading branch information
mrbbot committed Feb 25, 2022
1 parent 5d90324 commit b887877
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/durable-objects/src/namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export class DurableObjectNamespace {
const view = new DataView(id.buffer);
view.setBigUint64(1, BigInt(Date.now()));
// ...then fill 15 (32 - 1 - 8 - 8) bytes with random data
webcrypto.getRandomValues(new DataView(id.buffer, 9, 15));
webcrypto.getRandomValues(new Uint8Array(id.buffer, 9, 15));
// ...then copy objectName hash
id.set(this.#objectNameHash, 24 /* 32 - 8 */);
return new DurableObjectId(this.#objectName, hexEncode(id));
Expand Down

0 comments on commit b887877

Please sign in to comment.