velocious 1.0.643 → 1.0.644

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.
Files changed (48) hide show
  1. package/README.md +10 -1
  2. package/build/src/sync/assets/cache.d.ts +288 -0
  3. package/build/src/sync/assets/cache.d.ts.map +1 -0
  4. package/build/src/sync/assets/cache.js +883 -0
  5. package/build/src/sync/assets/types.d.ts +199 -0
  6. package/build/src/sync/assets/types.d.ts.map +1 -0
  7. package/build/src/sync/assets/types.js +56 -0
  8. package/build/src/testing/test-runner.d.ts +8 -0
  9. package/build/src/testing/test-runner.d.ts.map +1 -1
  10. package/build/src/testing/test-runner.js +49 -548
  11. package/build/src/testing/velocious-attempt-executor.d.ts +69 -0
  12. package/build/src/testing/velocious-attempt-executor.d.ts.map +1 -0
  13. package/build/src/testing/velocious-attempt-executor.js +402 -0
  14. package/build/src/testing/velocious-runner-reporter.d.ts +72 -0
  15. package/build/src/testing/velocious-runner-reporter.d.ts.map +1 -0
  16. package/build/src/testing/velocious-runner-reporter.js +152 -0
  17. package/build/src/testing/velocious-suite-hook-executor.d.ts +37 -0
  18. package/build/src/testing/velocious-suite-hook-executor.d.ts.map +1 -0
  19. package/build/src/testing/velocious-suite-hook-executor.js +66 -0
  20. package/build/src/testing/velocious-test-arguments.d.ts +34 -0
  21. package/build/src/testing/velocious-test-arguments.d.ts.map +1 -0
  22. package/build/src/testing/velocious-test-arguments.js +47 -0
  23. package/build/src/utils/sha256-bytes-hex.d.ts +7 -0
  24. package/build/src/utils/sha256-bytes-hex.d.ts.map +1 -0
  25. package/build/src/utils/sha256-bytes-hex.js +117 -0
  26. package/build/src/utils/sha256-hex.d.ts +2 -4
  27. package/build/src/utils/sha256-hex.d.ts.map +1 -1
  28. package/build/src/utils/sha256-hex.js +6 -120
  29. package/build/sync/assets/cache.js +998 -0
  30. package/build/sync/assets/types.js +62 -0
  31. package/build/testing/test-runner.js +46 -584
  32. package/build/testing/velocious-attempt-executor.js +431 -0
  33. package/build/testing/velocious-runner-reporter.js +166 -0
  34. package/build/testing/velocious-suite-hook-executor.js +71 -0
  35. package/build/testing/velocious-test-arguments.js +55 -0
  36. package/build/tsconfig.tsbuildinfo +1 -1
  37. package/build/utils/sha256-bytes-hex.js +132 -0
  38. package/build/utils/sha256-hex.js +7 -135
  39. package/package.json +1 -1
  40. package/src/sync/assets/cache.js +998 -0
  41. package/src/sync/assets/types.js +62 -0
  42. package/src/testing/test-runner.js +46 -584
  43. package/src/testing/velocious-attempt-executor.js +431 -0
  44. package/src/testing/velocious-runner-reporter.js +166 -0
  45. package/src/testing/velocious-suite-hook-executor.js +71 -0
  46. package/src/testing/velocious-test-arguments.js +55 -0
  47. package/src/utils/sha256-bytes-hex.js +132 -0
  48. package/src/utils/sha256-hex.js +7 -135
@@ -0,0 +1,55 @@
1
+ // @ts-check
2
+
3
+ import restArgsError from "../utils/rest-args-error.js"
4
+
5
+ /** @typedef {import("./test-runner.js").TestArgs} TestArgs */
6
+ /** @typedef {import("./test-runner.js").TestData} TestData */
7
+
8
+ export default class VelociousTestArguments {
9
+ /**
10
+ * Creates the framework-owned test argument adapter.
11
+ * @param {object} args - Constructor arguments.
12
+ * @param {import("./test-runner.js").default} args.testRunner - Owning Velocious runner.
13
+ */
14
+ constructor({testRunner, ...restArgs}) {
15
+ restArgsError(restArgs)
16
+ this.testRunner = testRunner
17
+ }
18
+
19
+ /**
20
+ * Builds the stable framework-owned argument object for one selected test.
21
+ * @param {TestData} testData - Selected test registration.
22
+ * @returns {Promise<TestArgs>} - Attempt-shared callback arguments.
23
+ */
24
+ async build(testData) {
25
+ const testArgs = this.copy(testData)
26
+
27
+ await this.inject(testArgs)
28
+
29
+ return testArgs
30
+ }
31
+
32
+ /**
33
+ * Copies declaration metadata before selection can inspect it.
34
+ * @param {TestData} testData - Test registration.
35
+ * @returns {TestArgs} - Independent test arguments.
36
+ */
37
+ copy(testData) {
38
+ return /** @type {TestArgs} */ (Object.assign({}, testData.args))
39
+ }
40
+
41
+ /**
42
+ * Injects type-specific framework collaborators after selection.
43
+ * @param {TestArgs} testArgs - Selected test arguments.
44
+ * @returns {Promise<void>} - Resolves after required collaborators are ready.
45
+ */
46
+ async inject(testArgs) {
47
+ if (testArgs.type == "model" || testArgs.type == "request") {
48
+ testArgs.application = await this.testRunner.application()
49
+ }
50
+
51
+ if (testArgs.type == "request") {
52
+ testArgs.client = await this.testRunner.requestClient()
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,132 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * Computes a SHA-256 hex digest for arbitrary bytes without Node-only imports.
5
+ * @param {Uint8Array} bytes - Bytes to digest.
6
+ * @returns {string} Hex digest.
7
+ */
8
+ export default function sha256BytesHex(bytes) {
9
+ const bitLength = bytes.length * 8
10
+ const blockCount = Math.ceil((bytes.length + 9) / 64)
11
+ const block = new Uint8Array(64)
12
+ const hash = SHA256_INITIAL_HASH.slice()
13
+ /** @type {number[]} */
14
+ const words = new Array(64)
15
+
16
+ const highLength = Math.floor(bitLength / 0x100000000)
17
+ const lowLength = bitLength >>> 0
18
+
19
+ for (let blockIndex = 0; blockIndex < blockCount; blockIndex += 1) {
20
+ const offset = blockIndex * 64
21
+ const chunkLength = Math.min(64, Math.max(0, bytes.length - offset))
22
+
23
+ block.fill(0)
24
+ if (chunkLength > 0) block.set(bytes.subarray(offset, offset + chunkLength))
25
+ if (bytes.length >= offset && bytes.length < offset + 64) block[bytes.length - offset] = 0x80
26
+
27
+ if (blockIndex === blockCount - 1) {
28
+ block[56] = (highLength >>> 24) & 0xff
29
+ block[57] = (highLength >>> 16) & 0xff
30
+ block[58] = (highLength >>> 8) & 0xff
31
+ block[59] = highLength & 0xff
32
+ block[60] = (lowLength >>> 24) & 0xff
33
+ block[61] = (lowLength >>> 16) & 0xff
34
+ block[62] = (lowLength >>> 8) & 0xff
35
+ block[63] = lowLength & 0xff
36
+ }
37
+
38
+ for (let index = 0; index < 16; index++) {
39
+ const byteIndex = index * 4
40
+
41
+ words[index] = ((block[byteIndex] << 24) | (block[byteIndex + 1] << 16) | (block[byteIndex + 2] << 8) | block[byteIndex + 3]) >>> 0
42
+ }
43
+
44
+ for (let index = 16; index < 64; index++) {
45
+ const s0 = rotateRight(words[index - 15], 7) ^ rotateRight(words[index - 15], 18) ^ (words[index - 15] >>> 3)
46
+ const s1 = rotateRight(words[index - 2], 17) ^ rotateRight(words[index - 2], 19) ^ (words[index - 2] >>> 10)
47
+
48
+ words[index] = add32(words[index - 16], s0, words[index - 7], s1)
49
+ }
50
+
51
+ let a = hash[0]
52
+ let b = hash[1]
53
+ let c = hash[2]
54
+ let d = hash[3]
55
+ let e = hash[4]
56
+ let f = hash[5]
57
+ let g = hash[6]
58
+ let h = hash[7]
59
+
60
+ for (let index = 0; index < 64; index++) {
61
+ const s1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25)
62
+ const ch = (e & f) ^ ((~e) & g)
63
+ const temp1 = add32(h, s1, ch, SHA256_K[index], words[index])
64
+ const s0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22)
65
+ const maj = (a & b) ^ (a & c) ^ (b & c)
66
+ const temp2 = add32(s0, maj)
67
+
68
+ h = g
69
+ g = f
70
+ f = e
71
+ e = add32(d, temp1)
72
+ d = c
73
+ c = b
74
+ b = a
75
+ a = add32(temp1, temp2)
76
+ }
77
+
78
+ hash[0] = add32(hash[0], a)
79
+ hash[1] = add32(hash[1], b)
80
+ hash[2] = add32(hash[2], c)
81
+ hash[3] = add32(hash[3], d)
82
+ hash[4] = add32(hash[4], e)
83
+ hash[5] = add32(hash[5], f)
84
+ hash[6] = add32(hash[6], g)
85
+ hash[7] = add32(hash[7], h)
86
+ }
87
+
88
+ return hash.map((value) => value.toString(16).padStart(8, "0")).join("")
89
+ }
90
+
91
+ const SHA256_INITIAL_HASH = [
92
+ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
93
+ 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
94
+ ]
95
+
96
+ const SHA256_K = [
97
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
98
+ 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
99
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
100
+ 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
101
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
102
+ 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
103
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
104
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
105
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
106
+ 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
107
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
108
+ 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
109
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
110
+ 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
111
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
112
+ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
113
+ ]
114
+
115
+ /**
116
+ * Rotates an unsigned value right.
117
+ * @param {number} value Unsigned value.
118
+ * @param {number} bits Rotation count.
119
+ * @returns {number} Rotated value.
120
+ */
121
+ function rotateRight(value, bits) {
122
+ return (value >>> bits) | (value << (32 - bits))
123
+ }
124
+
125
+ /**
126
+ * Adds numbers with unsigned 32-bit overflow.
127
+ * @param {...number} values Values to add.
128
+ * @returns {number} Unsigned sum.
129
+ */
130
+ function add32(...values) {
131
+ return values.reduce((sum, value) => (sum + value) >>> 0, 0)
132
+ }
@@ -1,141 +1,13 @@
1
+ // @ts-check
2
+
3
+ import sha256BytesHex from "./sha256-bytes-hex.js"
4
+
1
5
  /**
2
6
  * Computes SHA-256 without importing Node-only crypto modules, keeping this
3
- * module safe for Expo/browser bundles. Implementation is a straightforward
4
- * pure-JavaScript SHA-256 derived from FIPS 180-4, using only 32-bit unsigned
5
- * integer arithmetic.
7
+ * module safe for Expo/browser bundles.
6
8
  * @param {string} message - UTF-8 message.
7
- * @returns {string} - Hex digest.
9
+ * @returns {string} Hex digest.
8
10
  */
9
11
  export default function sha256Hex(message) {
10
- const bytes = utf8Bytes(message)
11
- const padded = [...bytes]
12
- const bitLength = bytes.length * 8
13
- const hash = [...SHA256_INITIAL_HASH]
14
- /** @type {number[]} */
15
- const words = new Array(64)
16
-
17
- padded.push(0x80)
18
- while (padded.length % 64 !== 56) padded.push(0)
19
-
20
- const highLength = Math.floor(bitLength / 0x100000000)
21
- const lowLength = bitLength >>> 0
22
-
23
- for (const value of [highLength, lowLength]) {
24
- padded.push((value >>> 24) & 0xff, (value >>> 16) & 0xff, (value >>> 8) & 0xff, value & 0xff)
25
- }
26
-
27
- for (let offset = 0; offset < padded.length; offset += 64) {
28
- for (let i = 0; i < 16; i++) {
29
- const index = offset + (i * 4)
30
-
31
- words[i] = (((padded[index] || 0) << 24) | ((padded[index + 1] || 0) << 16) | ((padded[index + 2] || 0) << 8) | (padded[index + 3] || 0)) >>> 0
32
- }
33
-
34
- for (let i = 16; i < 64; i++) {
35
- const s0 = rotateRight(words[i - 15], 7) ^ rotateRight(words[i - 15], 18) ^ (words[i - 15] >>> 3)
36
- const s1 = rotateRight(words[i - 2], 17) ^ rotateRight(words[i - 2], 19) ^ (words[i - 2] >>> 10)
37
-
38
- words[i] = add32(words[i - 16], s0, words[i - 7], s1)
39
- }
40
-
41
- let [a, b, c, d, e, f, g, h] = hash
42
-
43
- for (let i = 0; i < 64; i++) {
44
- const s1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25)
45
- const ch = (e & f) ^ ((~e) & g)
46
- const temp1 = add32(h, s1, ch, SHA256_K[i], words[i])
47
- const s0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22)
48
- const maj = (a & b) ^ (a & c) ^ (b & c)
49
- const temp2 = add32(s0, maj)
50
-
51
- h = g
52
- g = f
53
- f = e
54
- e = add32(d, temp1)
55
- d = c
56
- c = b
57
- b = a
58
- a = add32(temp1, temp2)
59
- }
60
-
61
- hash[0] = add32(hash[0], a)
62
- hash[1] = add32(hash[1], b)
63
- hash[2] = add32(hash[2], c)
64
- hash[3] = add32(hash[3], d)
65
- hash[4] = add32(hash[4], e)
66
- hash[5] = add32(hash[5], f)
67
- hash[6] = add32(hash[6], g)
68
- hash[7] = add32(hash[7], h)
69
- }
70
-
71
- return hash.map((value) => value.toString(16).padStart(8, "0")).join("")
72
- }
73
-
74
- const SHA256_INITIAL_HASH = [
75
- 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
76
- 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
77
- ]
78
-
79
- const SHA256_K = [
80
- 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
81
- 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
82
- 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
83
- 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
84
- 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
85
- 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
86
- 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
87
- 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
88
- 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
89
- 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
90
- 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
91
- 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
92
- 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
93
- 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
94
- 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
95
- 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
96
- ]
97
-
98
- /**
99
- * Converts a string to UTF-8 bytes.
100
- * @param {string} value - String value.
101
- * @returns {number[]} - UTF-8 bytes.
102
- */
103
- function utf8Bytes(value) {
104
- /** @type {number[]} */
105
- const bytes = []
106
-
107
- for (const character of value) {
108
- const codePoint = /** @type {number} */ (character.codePointAt(0))
109
-
110
- if (codePoint <= 0x7f) {
111
- bytes.push(codePoint)
112
- } else if (codePoint <= 0x7ff) {
113
- bytes.push(0xc0 | (codePoint >>> 6), 0x80 | (codePoint & 0x3f))
114
- } else if (codePoint <= 0xffff) {
115
- bytes.push(0xe0 | (codePoint >>> 12), 0x80 | ((codePoint >>> 6) & 0x3f), 0x80 | (codePoint & 0x3f))
116
- } else {
117
- bytes.push(0xf0 | (codePoint >>> 18), 0x80 | ((codePoint >>> 12) & 0x3f), 0x80 | ((codePoint >>> 6) & 0x3f), 0x80 | (codePoint & 0x3f))
118
- }
119
- }
120
-
121
- return bytes
122
- }
123
-
124
- /**
125
- * Adds unsigned 32-bit integers.
126
- * @param {...number} values - Values to add.
127
- * @returns {number} - Unsigned 32-bit result.
128
- */
129
- function add32(...values) {
130
- return values.reduce((sum, value) => (sum + value) >>> 0, 0)
131
- }
132
-
133
- /**
134
- * Rotates a 32-bit integer right.
135
- * @param {number} value - Value to rotate.
136
- * @param {number} bits - Bit count.
137
- * @returns {number} - Rotated value.
138
- */
139
- function rotateRight(value, bits) {
140
- return (value >>> bits) | (value << (32 - bits))
12
+ return sha256BytesHex(new TextEncoder().encode(message))
141
13
  }