pokertools-arena 0.4.0

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.
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ // @pokertools/engine/browser injects Web Crypto as its randomProvider, so its
4
+ // Node-only getSecureRandom() path should never be used in the browser. The
5
+ // published engine still contains a static require("crypto") in deck.js,
6
+ // however, which browser bundlers must resolve. This tiny compatibility shim
7
+ // keeps the bundle browser-only and also provides randomBytes if that dead path
8
+ // is ever reached by a future engine change.
9
+ exports.randomBytes = function randomBytes(size) {
10
+ if (!globalThis.crypto?.getRandomValues) {
11
+ throw new Error('[pokertools-arena] Web Crypto API is required for secure browser RNG.');
12
+ }
13
+ const bytes = new Uint8Array(size);
14
+ globalThis.crypto.getRandomValues(bytes);
15
+ bytes.readUInt32BE = function readUInt32BE(offset = 0) {
16
+ return (((this[offset] << 24) >>> 0) + (this[offset + 1] << 16) + (this[offset + 2] << 8) + this[offset + 3]) >>> 0;
17
+ };
18
+ return bytes;
19
+ };