@byline/admin 2.3.3 → 2.4.1

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 (177) hide show
  1. package/dist/abilities.js +5 -24
  2. package/dist/index.js +8 -30
  3. package/dist/lib/assert-admin-actor.js +13 -74
  4. package/dist/lib/create-command.js +6 -16
  5. package/dist/modules/admin-account/commands.js +35 -24
  6. package/dist/modules/admin-account/components/change-password.d.ts +8 -0
  7. package/dist/modules/admin-account/components/change-password.js +192 -0
  8. package/dist/modules/admin-account/components/change-password.module.js +8 -0
  9. package/dist/modules/admin-account/components/change-password_module.css +27 -0
  10. package/dist/modules/admin-account/components/container.d.ts +29 -0
  11. package/dist/modules/admin-account/components/container.js +298 -0
  12. package/dist/modules/admin-account/components/container.module.js +28 -0
  13. package/dist/modules/admin-account/components/container_module.css +106 -0
  14. package/dist/modules/admin-account/components/update.d.ts +8 -0
  15. package/dist/modules/admin-account/components/update.js +207 -0
  16. package/dist/modules/admin-account/components/update.module.js +8 -0
  17. package/dist/modules/admin-account/components/update_module.css +27 -0
  18. package/dist/modules/admin-account/errors.js +14 -45
  19. package/dist/modules/admin-account/index.js +4 -34
  20. package/dist/modules/admin-account/schemas.js +25 -59
  21. package/dist/modules/admin-account/service.js +56 -61
  22. package/dist/modules/admin-permissions/abilities.js +6 -24
  23. package/dist/modules/admin-permissions/commands.js +42 -28
  24. package/dist/modules/admin-permissions/components/inspector.d.ts +4 -0
  25. package/dist/modules/admin-permissions/components/inspector.js +284 -0
  26. package/dist/modules/admin-permissions/components/inspector.module.js +56 -0
  27. package/dist/modules/admin-permissions/components/inspector_module.css +238 -0
  28. package/dist/modules/admin-permissions/dto.js +3 -16
  29. package/dist/modules/admin-permissions/errors.js +14 -27
  30. package/dist/modules/admin-permissions/index.js +6 -26
  31. package/dist/modules/admin-permissions/repository.js +1 -8
  32. package/dist/modules/admin-permissions/schemas.js +33 -70
  33. package/dist/modules/admin-permissions/service.js +88 -92
  34. package/dist/modules/admin-roles/abilities.js +8 -30
  35. package/dist/modules/admin-roles/commands.js +89 -55
  36. package/dist/modules/admin-roles/components/create.d.ts +7 -0
  37. package/dist/modules/admin-roles/components/create.js +177 -0
  38. package/dist/modules/admin-roles/components/create.module.js +8 -0
  39. package/dist/modules/admin-roles/components/create_module.css +27 -0
  40. package/dist/modules/admin-roles/components/permissions.d.ts +10 -0
  41. package/dist/modules/admin-roles/components/permissions.js +303 -0
  42. package/dist/modules/admin-roles/components/permissions.module.js +44 -0
  43. package/dist/modules/admin-roles/components/permissions_module.css +192 -0
  44. package/dist/modules/admin-roles/components/update.d.ts +8 -0
  45. package/dist/modules/admin-roles/components/update.js +166 -0
  46. package/dist/modules/admin-roles/components/update.module.js +8 -0
  47. package/dist/modules/admin-roles/components/update_module.css +27 -0
  48. package/dist/modules/admin-roles/dto.js +3 -16
  49. package/dist/modules/admin-roles/errors.js +16 -40
  50. package/dist/modules/admin-roles/index.js +6 -26
  51. package/dist/modules/admin-roles/repository.js +1 -8
  52. package/dist/modules/admin-roles/schemas.js +41 -71
  53. package/dist/modules/admin-roles/service.js +79 -82
  54. package/dist/modules/admin-users/abilities.js +9 -38
  55. package/dist/modules/admin-users/commands.js +92 -50
  56. package/dist/modules/admin-users/components/create.d.ts +8 -0
  57. package/dist/modules/admin-users/components/create.js +268 -0
  58. package/dist/modules/admin-users/components/create.module.js +10 -0
  59. package/dist/modules/admin-users/components/create_module.css +45 -0
  60. package/dist/modules/admin-users/components/roles.d.ts +11 -0
  61. package/dist/modules/admin-users/components/roles.js +148 -0
  62. package/dist/modules/admin-users/components/roles.module.js +18 -0
  63. package/dist/modules/admin-users/components/roles_module.css +75 -0
  64. package/dist/modules/admin-users/components/set-password.d.ts +8 -0
  65. package/dist/modules/admin-users/components/set-password.js +170 -0
  66. package/dist/modules/admin-users/components/set-password.module.js +9 -0
  67. package/dist/modules/admin-users/components/set-password_module.css +31 -0
  68. package/dist/modules/admin-users/components/update.d.ts +8 -0
  69. package/dist/modules/admin-users/components/update.js +254 -0
  70. package/dist/modules/admin-users/components/update.module.js +9 -0
  71. package/dist/modules/admin-users/components/update_module.css +34 -0
  72. package/dist/modules/admin-users/dto.js +3 -18
  73. package/dist/modules/admin-users/errors.js +17 -43
  74. package/dist/modules/admin-users/index.js +7 -27
  75. package/dist/modules/admin-users/repository.js +1 -8
  76. package/dist/modules/admin-users/schemas.js +44 -75
  77. package/dist/modules/admin-users/seed-super-admin.js +9 -34
  78. package/dist/modules/admin-users/service.js +76 -91
  79. package/dist/modules/auth/components/sign-in-form.d.ts +12 -0
  80. package/dist/modules/auth/components/sign-in-form.js +115 -0
  81. package/dist/modules/auth/components/sign-in-form.module.js +12 -0
  82. package/dist/modules/auth/components/sign-in-form_module.css +41 -0
  83. package/dist/modules/auth/index.js +3 -24
  84. package/dist/modules/auth/jwt-session-provider.js +179 -149
  85. package/dist/modules/auth/password.js +11 -53
  86. package/dist/modules/auth/phc.js +21 -54
  87. package/dist/modules/auth/refresh-tokens-repository.js +1 -8
  88. package/dist/modules/auth/resolve-actor.js +6 -28
  89. package/dist/services/admin-services-context.d.ts +16 -0
  90. package/dist/services/admin-services-context.js +13 -0
  91. package/dist/services/admin-services-types.d.ts +129 -0
  92. package/dist/services/admin-services-types.js +1 -0
  93. package/dist/store.js +1 -8
  94. package/dist/vendor/noble-argon2/_blake.js +277 -45
  95. package/dist/vendor/noble-argon2/_md.js +81 -136
  96. package/dist/vendor/noble-argon2/_u64.js +65 -67
  97. package/dist/vendor/noble-argon2/argon2.js +181 -342
  98. package/dist/vendor/noble-argon2/blake2.js +252 -327
  99. package/dist/vendor/noble-argon2/utils.js +110 -490
  100. package/dist/vendor/noble-argon2/utils.js.LICENSE.txt +1 -0
  101. package/package.json +89 -10
  102. package/src/abilities.ts +32 -0
  103. package/src/declarations.d.ts +4 -0
  104. package/src/index.ts +39 -0
  105. package/src/lib/assert-admin-actor.ts +90 -0
  106. package/src/lib/create-command.ts +109 -0
  107. package/src/modules/admin-account/commands.ts +76 -0
  108. package/src/modules/admin-account/components/change-password.module.css +40 -0
  109. package/src/modules/admin-account/components/change-password.tsx +232 -0
  110. package/src/modules/admin-account/components/container.module.css +158 -0
  111. package/src/modules/admin-account/components/container.tsx +229 -0
  112. package/src/modules/admin-account/components/update.module.css +40 -0
  113. package/src/modules/admin-account/components/update.tsx +263 -0
  114. package/src/modules/admin-account/errors.ts +75 -0
  115. package/src/modules/admin-account/index.ts +60 -0
  116. package/src/modules/admin-account/schemas.ts +84 -0
  117. package/src/modules/admin-account/service.ts +92 -0
  118. package/src/modules/admin-permissions/abilities.ts +46 -0
  119. package/src/modules/admin-permissions/commands.ts +103 -0
  120. package/src/modules/admin-permissions/components/inspector.module.css +326 -0
  121. package/src/modules/admin-permissions/components/inspector.tsx +298 -0
  122. package/src/modules/admin-permissions/dto.ts +28 -0
  123. package/src/modules/admin-permissions/errors.ts +57 -0
  124. package/src/modules/admin-permissions/index.ts +72 -0
  125. package/src/modules/admin-permissions/repository.ts +49 -0
  126. package/src/modules/admin-permissions/schemas.ts +128 -0
  127. package/src/modules/admin-permissions/service.ts +137 -0
  128. package/src/modules/admin-roles/abilities.ts +62 -0
  129. package/src/modules/admin-roles/commands.ts +161 -0
  130. package/src/modules/admin-roles/components/create.module.css +40 -0
  131. package/src/modules/admin-roles/components/create.tsx +218 -0
  132. package/src/modules/admin-roles/components/permissions.module.css +279 -0
  133. package/src/modules/admin-roles/components/permissions.tsx +396 -0
  134. package/src/modules/admin-roles/components/update.module.css +40 -0
  135. package/src/modules/admin-roles/components/update.tsx +218 -0
  136. package/src/modules/admin-roles/dto.ts +30 -0
  137. package/src/modules/admin-roles/errors.ts +76 -0
  138. package/src/modules/admin-roles/index.ts +81 -0
  139. package/src/modules/admin-roles/repository.ts +96 -0
  140. package/src/modules/admin-roles/schemas.ts +139 -0
  141. package/src/modules/admin-roles/service.ts +136 -0
  142. package/src/modules/admin-users/abilities.ts +76 -0
  143. package/src/modules/admin-users/commands.ts +157 -0
  144. package/src/modules/admin-users/components/create.module.css +63 -0
  145. package/src/modules/admin-users/components/create.tsx +323 -0
  146. package/src/modules/admin-users/components/roles.module.css +119 -0
  147. package/src/modules/admin-users/components/roles.tsx +172 -0
  148. package/src/modules/admin-users/components/set-password.module.css +46 -0
  149. package/src/modules/admin-users/components/set-password.tsx +199 -0
  150. package/src/modules/admin-users/components/update.module.css +49 -0
  151. package/src/modules/admin-users/components/update.tsx +328 -0
  152. package/src/modules/admin-users/dto.ts +39 -0
  153. package/src/modules/admin-users/errors.ts +84 -0
  154. package/src/modules/admin-users/index.ts +91 -0
  155. package/src/modules/admin-users/repository.ts +161 -0
  156. package/src/modules/admin-users/schemas.ts +168 -0
  157. package/src/modules/admin-users/seed-super-admin.ts +102 -0
  158. package/src/modules/admin-users/service.ts +166 -0
  159. package/src/modules/auth/components/sign-in-form.module.css +62 -0
  160. package/src/modules/auth/components/sign-in-form.tsx +132 -0
  161. package/src/modules/auth/index.ts +31 -0
  162. package/src/modules/auth/jwt-session-provider.ts +301 -0
  163. package/src/modules/auth/password.ts +94 -0
  164. package/src/modules/auth/phc.ts +121 -0
  165. package/src/modules/auth/refresh-tokens-repository.ts +74 -0
  166. package/src/modules/auth/resolve-actor.ts +42 -0
  167. package/src/services/admin-services-context.tsx +52 -0
  168. package/src/services/admin-services-types.ts +177 -0
  169. package/src/store.ts +32 -0
  170. package/src/vendor/noble-argon2/LICENSE +21 -0
  171. package/src/vendor/noble-argon2/README.md +87 -0
  172. package/src/vendor/noble-argon2/_blake.ts +58 -0
  173. package/src/vendor/noble-argon2/_md.ts +223 -0
  174. package/src/vendor/noble-argon2/_u64.ts +118 -0
  175. package/src/vendor/noble-argon2/argon2.ts +668 -0
  176. package/src/vendor/noble-argon2/blake2.ts +583 -0
  177. package/src/vendor/noble-argon2/utils.ts +849 -0
@@ -1,95 +1,21 @@
1
- // @ts-nocheck vendored from noble-hashes; see ./README.md
2
- /**
3
- * Internal Merkle-Damgard hash utils.
4
- * @module
5
- */
6
- import { abytes, aexists, aoutput, clean, createView, } from './utils.js';
7
- /**
8
- * Shared 32-bit conditional boolean primitive reused by SHA-256, SHA-1, and MD5 `F`.
9
- * Returns bits from `b` when `a` is set, otherwise from `c`.
10
- * The XOR form is equivalent to MD5's `F(X,Y,Z) = XY v not(X)Z` because the masked terms never
11
- * set the same bit.
12
- * @param a - selector word
13
- * @param b - word chosen when selector bit is set
14
- * @param c - word chosen when selector bit is clear
15
- * @returns Mixed 32-bit word.
16
- * @example
17
- * Combine three words with the shared 32-bit choice primitive.
18
- * ```ts
19
- * Chi(0xffffffff, 0x12345678, 0x87654321);
20
- * ```
21
- */
22
- export function Chi(a, b, c) {
23
- return (a & b) ^ (~a & c);
1
+ import { abytes, aexists, aoutput, clean, createView } from "./utils.js";
2
+ function Chi(a, b, c) {
3
+ return a & b ^ ~a & c;
24
4
  }
25
- /**
26
- * Shared 32-bit majority primitive reused by SHA-256 and SHA-1.
27
- * Returns bits shared by at least two inputs.
28
- * @param a - first input word
29
- * @param b - second input word
30
- * @param c - third input word
31
- * @returns Mixed 32-bit word.
32
- * @example
33
- * Combine three words with the shared 32-bit majority primitive.
34
- * ```ts
35
- * Maj(0xffffffff, 0x12345678, 0x87654321);
36
- * ```
37
- */
38
- export function Maj(a, b, c) {
39
- return (a & b) ^ (a & c) ^ (b & c);
5
+ function Maj(a, b, c) {
6
+ return a & b ^ a & c ^ b & c;
40
7
  }
41
- /**
42
- * Merkle-Damgard hash construction base class.
43
- * Could be used to create MD5, RIPEMD, SHA1, SHA2.
44
- * Accepts only byte-aligned `Uint8Array` input, even when the underlying spec describes bit
45
- * strings with partial-byte tails.
46
- * @param blockLen - internal block size in bytes
47
- * @param outputLen - digest size in bytes
48
- * @param padOffset - trailing length field size in bytes
49
- * @param isLE - whether length and state words are encoded in little-endian
50
- * @example
51
- * Use a concrete subclass to get the shared Merkle-Damgard update/digest flow.
52
- * ```ts
53
- * import { _SHA1 } from '@noble/hashes/legacy.js';
54
- * const hash = new _SHA1();
55
- * hash.update(new Uint8Array([97, 98, 99]));
56
- * hash.digest();
57
- * ```
58
- */
59
- export class HashMD {
60
- blockLen;
61
- outputLen;
62
- canXOF = false;
63
- padOffset;
64
- isLE;
65
- // For partial updates less than block size
66
- buffer;
67
- view;
68
- finished = false;
69
- length = 0;
70
- pos = 0;
71
- destroyed = false;
72
- constructor(blockLen, outputLen, padOffset, isLE) {
73
- this.blockLen = blockLen;
74
- this.outputLen = outputLen;
75
- this.padOffset = padOffset;
76
- this.isLE = isLE;
77
- this.buffer = new Uint8Array(blockLen);
78
- this.view = createView(this.buffer);
79
- }
8
+ class HashMD {
80
9
  update(data) {
81
10
  aexists(this);
82
11
  abytes(data);
83
12
  const { view, buffer, blockLen } = this;
84
13
  const len = data.length;
85
- for (let pos = 0; pos < len;) {
14
+ for(let pos = 0; pos < len;){
86
15
  const take = Math.min(blockLen - this.pos, len - pos);
87
- // Fast path only when there is no buffered partial block: `take === blockLen` implies
88
- // `this.pos === 0`, so we can process full blocks directly from the input view.
89
16
  if (take === blockLen) {
90
17
  const dataView = createView(data);
91
- for (; blockLen <= len - pos; pos += blockLen)
92
- this.process(dataView, pos);
18
+ for(; blockLen <= len - pos; pos += blockLen)this.process(dataView, pos);
93
19
  continue;
94
20
  }
95
21
  buffer.set(data.subarray(pos, pos + take), this.pos);
@@ -108,45 +34,28 @@ export class HashMD {
108
34
  aexists(this);
109
35
  aoutput(out, this);
110
36
  this.finished = true;
111
- // Padding
112
- // We can avoid allocation of buffer for padding completely if it
113
- // was previously not allocated here. But it won't change performance.
114
37
  const { buffer, view, blockLen, isLE } = this;
115
38
  let { pos } = this;
116
- // append the bit '1' to the message
117
- buffer[pos++] = 0b10000000;
39
+ buffer[pos++] = 128;
118
40
  clean(this.buffer.subarray(pos));
119
- // we have less than padOffset left in buffer, so we cannot put length in
120
- // current block, need process it and pad again
121
41
  if (this.padOffset > blockLen - pos) {
122
42
  this.process(view, 0);
123
43
  pos = 0;
124
44
  }
125
- // Pad until full block byte with zeros
126
- for (let i = pos; i < blockLen; i++)
127
- buffer[i] = 0;
128
- // `padOffset` reserves the whole length field. For SHA-384/512 the high 64 bits stay zero from
129
- // the padding fill above, and JS will overflow before user input can make that half non-zero.
130
- // So we only need to write the low 64 bits here.
131
- view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
45
+ for(let i = pos; i < blockLen; i++)buffer[i] = 0;
46
+ view.setBigUint64(blockLen - 8, BigInt(8 * this.length), isLE);
132
47
  this.process(view, 0);
133
48
  const oview = createView(out);
134
49
  const len = this.outputLen;
135
- // NOTE: we do division by 4 later, which must be fused in single op with modulo by JIT
136
- if (len % 4)
137
- throw new Error('_sha2: outputLen must be aligned to 32bit');
50
+ if (len % 4) throw new Error('_sha2: outputLen must be aligned to 32bit');
138
51
  const outLen = len / 4;
139
52
  const state = this.get();
140
- if (outLen > state.length)
141
- throw new Error('_sha2: outputLen bigger than state');
142
- for (let i = 0; i < outLen; i++)
143
- oview.setUint32(4 * i, state[i], isLE);
53
+ if (outLen > state.length) throw new Error('_sha2: outputLen bigger than state');
54
+ for(let i = 0; i < outLen; i++)oview.setUint32(4 * i, state[i], isLE);
144
55
  }
145
56
  digest() {
146
57
  const { buffer, outputLen } = this;
147
58
  this.digestInto(buffer);
148
- // Copy before destroy(): subclasses wipe `buffer` during cleanup, but `digest()` must return
149
- // fresh bytes to the caller.
150
59
  const res = buffer.slice(0, outputLen);
151
60
  this.destroy();
152
61
  return res;
@@ -159,44 +68,80 @@ export class HashMD {
159
68
  to.finished = finished;
160
69
  to.length = length;
161
70
  to.pos = pos;
162
- // Only partial-block bytes need copying: when `length % blockLen === 0`, `pos === 0` and
163
- // later `update()` / `digestInto()` overwrite `to.buffer` from the start before reading it.
164
- if (length % blockLen)
165
- to.buffer.set(buffer);
71
+ if (length % blockLen) to.buffer.set(buffer);
166
72
  return to;
167
73
  }
168
74
  clone() {
169
75
  return this._cloneInto();
170
76
  }
77
+ constructor(blockLen, outputLen, padOffset, isLE){
78
+ this.canXOF = false;
79
+ this.finished = false;
80
+ this.length = 0;
81
+ this.pos = 0;
82
+ this.destroyed = false;
83
+ this.blockLen = blockLen;
84
+ this.outputLen = outputLen;
85
+ this.padOffset = padOffset;
86
+ this.isLE = isLE;
87
+ this.buffer = new Uint8Array(blockLen);
88
+ this.view = createView(this.buffer);
89
+ }
171
90
  }
172
- /**
173
- * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
174
- * Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
175
- */
176
- /** Initial SHA256 state from RFC 6234 §6.1: the first 32 bits of the fractional parts of the
177
- * square roots of the first eight prime numbers. Exported as a shared table; callers must treat
178
- * it as read-only because constructors copy words from it by index. */
179
- export const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
180
- 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
91
+ const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
92
+ 0x6a09e667,
93
+ 0xbb67ae85,
94
+ 0x3c6ef372,
95
+ 0xa54ff53a,
96
+ 0x510e527f,
97
+ 0x9b05688c,
98
+ 0x1f83d9ab,
99
+ 0x5be0cd19
181
100
  ]);
182
- /** Initial SHA224 state `H(0)` from RFC 6234 §6.1. Exported as a shared table; callers must
183
- * treat it as read-only because constructors copy words from it by index. */
184
- export const SHA224_IV = /* @__PURE__ */ Uint32Array.from([
185
- 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4,
101
+ const SHA224_IV = /* @__PURE__ */ Uint32Array.from([
102
+ 0xc1059ed8,
103
+ 0x367cd507,
104
+ 0x3070dd17,
105
+ 0xf70e5939,
106
+ 0xffc00b31,
107
+ 0x68581511,
108
+ 0x64f98fa7,
109
+ 0xbefa4fa4
186
110
  ]);
187
- /** Initial SHA384 state from RFC 6234 §6.3: eight RFC 64-bit `H(0)` words stored as sixteen
188
- * big-endian 32-bit halves. Derived from the fractional parts of the square roots of the ninth
189
- * through sixteenth prime numbers. Exported as a shared table; callers must treat it as read-only
190
- * because constructors copy halves from it by index. */
191
- export const SHA384_IV = /* @__PURE__ */ Uint32Array.from([
192
- 0xcbbb9d5d, 0xc1059ed8, 0x629a292a, 0x367cd507, 0x9159015a, 0x3070dd17, 0x152fecd8, 0xf70e5939,
193
- 0x67332667, 0xffc00b31, 0x8eb44a87, 0x68581511, 0xdb0c2e0d, 0x64f98fa7, 0x47b5481d, 0xbefa4fa4,
111
+ const SHA384_IV = /* @__PURE__ */ Uint32Array.from([
112
+ 0xcbbb9d5d,
113
+ 0xc1059ed8,
114
+ 0x629a292a,
115
+ 0x367cd507,
116
+ 0x9159015a,
117
+ 0x3070dd17,
118
+ 0x152fecd8,
119
+ 0xf70e5939,
120
+ 0x67332667,
121
+ 0xffc00b31,
122
+ 0x8eb44a87,
123
+ 0x68581511,
124
+ 0xdb0c2e0d,
125
+ 0x64f98fa7,
126
+ 0x47b5481d,
127
+ 0xbefa4fa4
194
128
  ]);
195
- /** Initial SHA512 state from RFC 6234 §6.3: eight RFC 64-bit `H(0)` words stored as sixteen
196
- * big-endian 32-bit halves. Derived from the fractional parts of the square roots of the first
197
- * eight prime numbers. Exported as a shared table; callers must treat it as read-only because
198
- * constructors copy halves from it by index. */
199
- export const SHA512_IV = /* @__PURE__ */ Uint32Array.from([
200
- 0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1,
201
- 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179,
129
+ const SHA512_IV = /* @__PURE__ */ Uint32Array.from([
130
+ 0x6a09e667,
131
+ 0xf3bcc908,
132
+ 0xbb67ae85,
133
+ 0x84caa73b,
134
+ 0x3c6ef372,
135
+ 0xfe94f82b,
136
+ 0xa54ff53a,
137
+ 0x5f1d36f1,
138
+ 0x510e527f,
139
+ 0xade682d1,
140
+ 0x9b05688c,
141
+ 0x2b3e6c1f,
142
+ 0x1f83d9ab,
143
+ 0xfb41bd6b,
144
+ 0x5be0cd19,
145
+ 0x137e2179
202
146
  ]);
147
+ export { Chi, HashMD, Maj, SHA224_IV, SHA256_IV, SHA384_IV, SHA512_IV };
@@ -1,83 +1,81 @@
1
1
  const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
2
2
  const _32n = /* @__PURE__ */ BigInt(32);
3
- // Split bigint into two 32-bit halves. With `le=true`, returned fields become `{ h: low, l: high
4
- // }` to match little-endian word order rather than the property names.
5
3
  function fromBig(n, le = false) {
6
- if (le)
7
- return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
8
- return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
4
+ if (le) return {
5
+ h: Number(n & U32_MASK64),
6
+ l: Number(n >> _32n & U32_MASK64)
7
+ };
8
+ return {
9
+ h: 0 | Number(n >> _32n & U32_MASK64),
10
+ l: 0 | Number(n & U32_MASK64)
11
+ };
9
12
  }
10
- // Split bigint list into `[highWords, lowWords]` when `le=false`; with `le=true`, the first array
11
- // holds the low halves because `fromBig(...)` swaps the semantic meaning of `h` and `l`.
12
13
  function split(lst, le = false) {
13
14
  const len = lst.length;
14
15
  let Ah = new Uint32Array(len);
15
16
  let Al = new Uint32Array(len);
16
- for (let i = 0; i < len; i++) {
17
+ for(let i = 0; i < len; i++){
17
18
  const { h, l } = fromBig(lst[i], le);
18
- [Ah[i], Al[i]] = [h, l];
19
+ [Ah[i], Al[i]] = [
20
+ h,
21
+ l
22
+ ];
19
23
  }
20
- return [Ah, Al];
24
+ return [
25
+ Ah,
26
+ Al
27
+ ];
21
28
  }
22
- // Combine explicit `(high, low)` 32-bit halves into a bigint; `>>> 0` normalizes signed JS
23
- // bitwise results back to uint32 first, and little-endian callers must swap.
24
- const toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);
25
- // High 32-bit half of a 64-bit logical right shift for `s` in `0..31`.
26
- const shrSH = (h, _l, s) => h >>> s;
27
- // Low 32-bit half of a 64-bit logical right shift, valid for `s` in `1..31`.
28
- const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
29
- // High 32-bit half of a 64-bit right rotate, valid for `s` in `1..31`.
30
- const rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));
31
- // Low 32-bit half of a 64-bit right rotate, valid for `s` in `1..31`.
32
- const rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
33
- // High 32-bit half of a 64-bit right rotate, valid for `s` in `33..63`; `32` uses `rotr32*`.
34
- const rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));
35
- // Low 32-bit half of a 64-bit right rotate, valid for `s` in `33..63`; `32` uses `rotr32*`.
36
- const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
37
- // High 32-bit half of a 64-bit right rotate for `s === 32`; this is just the swapped low half.
38
- const rotr32H = (_h, l) => l;
39
- // Low 32-bit half of a 64-bit right rotate for `s === 32`; this is just the swapped high half.
40
- const rotr32L = (h, _l) => h;
41
- // High 32-bit half of a 64-bit left rotate, valid for `s` in `1..31`.
42
- const rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));
43
- // Low 32-bit half of a 64-bit left rotate, valid for `s` in `1..31`.
44
- const rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));
45
- // High 32-bit half of a 64-bit left rotate, valid for `s` in `33..63`; `32` uses `rotr32*`.
46
- const rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));
47
- // Low 32-bit half of a 64-bit left rotate, valid for `s` in `33..63`; `32` uses `rotr32*`.
48
- const rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));
49
- // Add two split 64-bit words and return the split `{ h, l }` sum.
50
- // JS uses 32-bit signed integers for bitwise operations, so we cannot simply shift the carry out
51
- // of the low sum and instead use division.
29
+ const toBig = (h, l)=>BigInt(h >>> 0) << _32n | BigInt(l >>> 0);
30
+ const shrSH = (h, _l, s)=>h >>> s;
31
+ const shrSL = (h, l, s)=>h << 32 - s | l >>> s;
32
+ const rotrSH = (h, l, s)=>h >>> s | l << 32 - s;
33
+ const rotrSL = (h, l, s)=>h << 32 - s | l >>> s;
34
+ const rotrBH = (h, l, s)=>h << 64 - s | l >>> s - 32;
35
+ const rotrBL = (h, l, s)=>h >>> s - 32 | l << 64 - s;
36
+ const rotr32H = (_h, l)=>l;
37
+ const rotr32L = (h, _l)=>h;
38
+ const rotlSH = (h, l, s)=>h << s | l >>> 32 - s;
39
+ const rotlSL = (h, l, s)=>l << s | h >>> 32 - s;
40
+ const rotlBH = (h, l, s)=>l << s - 32 | h >>> 64 - s;
41
+ const rotlBL = (h, l, s)=>h << s - 32 | l >>> 64 - s;
52
42
  function add(Ah, Al, Bh, Bl) {
53
43
  const l = (Al >>> 0) + (Bl >>> 0);
54
- return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };
44
+ return {
45
+ h: Ah + Bh + (l / 2 ** 32 | 0) | 0,
46
+ l: 0 | l
47
+ };
55
48
  }
56
- // Addition with more than 2 elements
57
- // Unmasked low-word accumulator for 3-way addition; pass the raw result into `add3H(...)`.
58
- const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
59
- // High-word finalize step for 3-way addition; `low` must be the untruncated output of `add3L(...)`.
60
- const add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;
61
- // Unmasked low-word accumulator for 4-way addition; pass the raw result into `add4H(...)`.
62
- const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
63
- // High-word finalize step for 4-way addition; `low` must be the untruncated output of `add4L(...)`.
64
- const add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;
65
- // Unmasked low-word accumulator for 5-way addition; pass the raw result into `add5H(...)`.
66
- const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
67
- // High-word finalize step for 5-way addition; `low` must be the untruncated output of `add5L(...)`.
68
- const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
69
- // prettier-ignore
70
- export { add, add3H, add3L, add4H, add4L, add5H, add5L, fromBig, rotlBH, rotlBL, rotlSH, rotlSL, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL, shrSH, shrSL, split, toBig };
71
- // Canonical grouped namespace for callers that prefer one object.
72
- // Named exports stay for direct imports.
73
- // prettier-ignore
49
+ const add3L = (Al, Bl, Cl)=>(Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
50
+ const add3H = (low, Ah, Bh, Ch)=>Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
51
+ const add4L = (Al, Bl, Cl, Dl)=>(Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
52
+ const add4H = (low, Ah, Bh, Ch, Dh)=>Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
53
+ const add5L = (Al, Bl, Cl, Dl, El)=>(Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
54
+ const add5H = (low, Ah, Bh, Ch, Dh, Eh)=>Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
74
55
  const u64 = {
75
- fromBig, split, toBig,
76
- shrSH, shrSL,
77
- rotrSH, rotrSL, rotrBH, rotrBL,
78
- rotr32H, rotr32L,
79
- rotlSH, rotlSL, rotlBH, rotlBL,
80
- add, add3L, add3H, add4L, add4H, add5H, add5L,
56
+ fromBig: fromBig,
57
+ split: split,
58
+ toBig: toBig,
59
+ shrSH: shrSH,
60
+ shrSL: shrSL,
61
+ rotrSH: rotrSH,
62
+ rotrSL: rotrSL,
63
+ rotrBH: rotrBH,
64
+ rotrBL: rotrBL,
65
+ rotr32H: rotr32H,
66
+ rotr32L: rotr32L,
67
+ rotlSH: rotlSH,
68
+ rotlSL: rotlSL,
69
+ rotlBH: rotlBH,
70
+ rotlBL: rotlBL,
71
+ add: add,
72
+ add3L: add3L,
73
+ add3H: add3H,
74
+ add4L: add4L,
75
+ add4H: add4H,
76
+ add5H: add5H,
77
+ add5L: add5L
81
78
  };
82
- // Default export mirrors named `u64` for compatibility with object-style imports.
83
- export default u64;
79
+ const _u64 = u64;
80
+ export default _u64;
81
+ export { add, add3H, add3L, add4H, add4L, add5H, add5L, fromBig, rotlBH, rotlBL, rotlSH, rotlSL, rotr32H, rotr32L, rotrBH, rotrBL, rotrSH, rotrSL, shrSH, shrSL, split, toBig };