@bytecodealliance/preview2-shim 0.17.2 → 0.17.3

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.
@@ -1,17 +1,9 @@
1
- import * as clocks from "./clocks.js";
2
- import * as filesystem from "./filesystem.js";
3
- import * as http from "./http.js";
4
- import * as io from "./io.js";
5
- import * as random from "./random.js";
6
- import * as sockets from "./sockets.js";
7
- import * as cli from "./cli.js";
1
+ import * as clocks from './clocks.js';
2
+ import * as filesystem from './filesystem.js';
3
+ import * as http from './http.js';
4
+ import * as io from './io.js';
5
+ import * as random from './random.js';
6
+ import * as sockets from './sockets.js';
7
+ import * as cli from './cli.js';
8
8
 
9
- export {
10
- clocks,
11
- filesystem,
12
- http,
13
- io,
14
- random,
15
- sockets,
16
- cli
17
- }
9
+ export { clocks, filesystem, http, io, random, sockets, cli };
@@ -1,45 +1,49 @@
1
- import { randomBytes, randomFillSync } from "node:crypto";
1
+ import { randomBytes, randomFillSync } from 'node:crypto';
2
2
 
3
3
  export const insecure = {
4
- getInsecureRandomBytes: getRandomBytes,
5
- getInsecureRandomU64() {
6
- return new BigUint64Array(randomBytes(8).buffer)[0];
7
- },
4
+ getInsecureRandomBytes: getRandomBytes,
5
+ getInsecureRandomU64() {
6
+ return new BigUint64Array(randomBytes(8).buffer)[0];
7
+ },
8
8
  };
9
9
 
10
10
  let insecureSeedValue1, insecureSeedValue2;
11
11
 
12
12
  export const insecureSeed = {
13
- insecureSeed() {
14
- if (insecureSeedValue1 === undefined) {
15
- insecureSeedValue1 = random.getRandomU64();
16
- insecureSeedValue2 = random.getRandomU64();
17
- }
18
- return [insecureSeedValue1, insecureSeedValue2];
19
- },
13
+ insecureSeed() {
14
+ if (insecureSeedValue1 === undefined) {
15
+ insecureSeedValue1 = random.getRandomU64();
16
+ insecureSeedValue2 = random.getRandomU64();
17
+ }
18
+ return [insecureSeedValue1, insecureSeedValue2];
19
+ },
20
20
  };
21
21
 
22
22
  export const random = {
23
- getRandomBytes,
23
+ getRandomBytes,
24
24
 
25
- getRandomU64() {
26
- return new BigUint64Array(randomBytes(8).buffer)[0];
27
- },
25
+ getRandomU64() {
26
+ return new BigUint64Array(randomBytes(8).buffer)[0];
27
+ },
28
28
  };
29
29
 
30
30
  function getRandomBytes(len) {
31
- return randomBytes(Number(len));
31
+ return randomBytes(Number(len));
32
32
  }
33
33
 
34
- getRandomBytes[Symbol.for("cabiLower")] = ({ memory, realloc }) => {
35
- let buf32 = new Uint32Array(memory.buffer);
36
- return function randomBytes(len, retptr) {
37
- len = Number(len);
38
- const ptr = realloc(0, 0, 1, len);
39
- randomFillSync(memory.buffer, ptr, len);
40
- if (memory.buffer !== buf32.buffer) buf32 = new Uint32Array(memory.buffer);
41
- if (retptr % 4) throw new Error('wasi-io trap: retptr not aligned');
42
- buf32[retptr >> 2] = ptr;
43
- buf32[(retptr >> 2) + 1] = len;
44
- };
34
+ getRandomBytes[Symbol.for('cabiLower')] = ({ memory, realloc }) => {
35
+ let buf32 = new Uint32Array(memory.buffer);
36
+ return function randomBytes(len, retptr) {
37
+ len = Number(len);
38
+ const ptr = realloc(0, 0, 1, len);
39
+ randomFillSync(memory.buffer, ptr, len);
40
+ if (memory.buffer !== buf32.buffer) {
41
+ buf32 = new Uint32Array(memory.buffer);
42
+ }
43
+ if (retptr % 4) {
44
+ throw new Error('wasi-io trap: retptr not aligned');
45
+ }
46
+ buf32[retptr >> 2] = ptr;
47
+ buf32[(retptr >> 2) + 1] = len;
48
+ };
45
49
  };