@gardenfi/utils 2.0.6-alpha.0 → 2.0.6-alpha.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 (197) hide show
  1. package/dist/index100.cjs +1 -1
  2. package/dist/index100.js +41 -5
  3. package/dist/index101.cjs +1 -1
  4. package/dist/index101.js +643 -10
  5. package/dist/index102.cjs +1 -1
  6. package/dist/index102.js +232 -2
  7. package/dist/index103.cjs +1 -1
  8. package/dist/index103.js +169 -17
  9. package/dist/index104.cjs +1 -1
  10. package/dist/index104.js +12 -6
  11. package/dist/index105.cjs +1 -1
  12. package/dist/index105.js +128 -5
  13. package/dist/index106.cjs +2 -1
  14. package/dist/index106.js +3 -38
  15. package/dist/index107.cjs +1 -1
  16. package/dist/index107.js +17 -126
  17. package/dist/index108.cjs +1 -1
  18. package/dist/index108.js +39 -2
  19. package/dist/index109.cjs +1 -2
  20. package/dist/index109.js +2 -3
  21. package/dist/index110.cjs +1 -1
  22. package/dist/index110.js +2 -68
  23. package/dist/index111.cjs +1 -1
  24. package/dist/index111.js +32 -64
  25. package/dist/index112.cjs +1 -1
  26. package/dist/index112.js +12 -2
  27. package/dist/index113.cjs +1 -1
  28. package/dist/index113.js +17 -32
  29. package/dist/index114.cjs +1 -1
  30. package/dist/index114.js +5 -41
  31. package/dist/index115.cjs +1 -1
  32. package/dist/index115.js +10 -643
  33. package/dist/index116.cjs +1 -1
  34. package/dist/index116.js +16 -227
  35. package/dist/index117.cjs +1 -1
  36. package/dist/index117.js +6 -172
  37. package/dist/index118.cjs +1 -1
  38. package/dist/index118.js +5 -19
  39. package/dist/index18.cjs +1 -1
  40. package/dist/index18.js +11 -11
  41. package/dist/index19.cjs +1 -1
  42. package/dist/index19.js +9 -9
  43. package/dist/index21.cjs +1 -1
  44. package/dist/index21.js +3 -3
  45. package/dist/index23.cjs +1 -1
  46. package/dist/index23.js +41 -17
  47. package/dist/index24.cjs +1 -1
  48. package/dist/index24.js +44 -6
  49. package/dist/index25.cjs +1 -1
  50. package/dist/index25.js +24 -44
  51. package/dist/index26.cjs +1 -1
  52. package/dist/index26.js +6 -21
  53. package/dist/index27.cjs +1 -1
  54. package/dist/index27.js +13 -8
  55. package/dist/index28.cjs +1 -1
  56. package/dist/index28.js +15 -31
  57. package/dist/index29.cjs +1 -1
  58. package/dist/index29.js +5 -26
  59. package/dist/index30.cjs +1 -2
  60. package/dist/index30.js +13 -65
  61. package/dist/index31.cjs +1 -1
  62. package/dist/index31.js +10 -51
  63. package/dist/index32.cjs +1 -1
  64. package/dist/index32.js +12 -12
  65. package/dist/index33.cjs +1 -1
  66. package/dist/index33.js +11 -24
  67. package/dist/index34.cjs +1 -1
  68. package/dist/index34.js +13 -75
  69. package/dist/index35.cjs +1 -1
  70. package/dist/index35.js +2 -2
  71. package/dist/index36.cjs +1 -1
  72. package/dist/index36.js +55 -7
  73. package/dist/index37.cjs +1 -1
  74. package/dist/index37.js +16 -32
  75. package/dist/index38.cjs +1 -1
  76. package/dist/index38.js +5 -15
  77. package/dist/index39.cjs +1 -1
  78. package/dist/index39.js +9 -2
  79. package/dist/index40.cjs +1 -1
  80. package/dist/index40.js +171 -8
  81. package/dist/index41.cjs +1 -1
  82. package/dist/index41.js +102 -19
  83. package/dist/index42.cjs +1 -1
  84. package/dist/index42.js +21 -41
  85. package/dist/index43.cjs +1 -1
  86. package/dist/index43.js +17 -25
  87. package/dist/index44.cjs +1 -1
  88. package/dist/index44.js +7 -6
  89. package/dist/index45.cjs +1 -1
  90. package/dist/index45.js +20 -12
  91. package/dist/index46.cjs +1 -1
  92. package/dist/index46.js +8 -15
  93. package/dist/index47.cjs +1 -1
  94. package/dist/index47.js +31 -5
  95. package/dist/index48.cjs +1 -1
  96. package/dist/index48.js +26 -13
  97. package/dist/index49.cjs +2 -1
  98. package/dist/index49.js +65 -10
  99. package/dist/index50.cjs +1 -1
  100. package/dist/index50.js +51 -12
  101. package/dist/index51.cjs +1 -1
  102. package/dist/index51.js +12 -11
  103. package/dist/index52.cjs +1 -1
  104. package/dist/index52.js +24 -13
  105. package/dist/index53.cjs +1 -1
  106. package/dist/index53.js +75 -55
  107. package/dist/index54.cjs +1 -1
  108. package/dist/index54.js +7 -16
  109. package/dist/index55.cjs +1 -1
  110. package/dist/index55.js +32 -5
  111. package/dist/index56.cjs +1 -1
  112. package/dist/index56.js +15 -8
  113. package/dist/index57.cjs +1 -1
  114. package/dist/index57.js +2 -172
  115. package/dist/index58.cjs +1 -1
  116. package/dist/index58.js +7 -102
  117. package/dist/index59.cjs +1 -1
  118. package/dist/index59.js +20 -21
  119. package/dist/index60.cjs +1 -1
  120. package/dist/index60.js +110 -10
  121. package/dist/index61.cjs +1 -1
  122. package/dist/index61.js +15 -33
  123. package/dist/index62.cjs +1 -1
  124. package/dist/index62.js +223 -6
  125. package/dist/index63.cjs +1 -2
  126. package/dist/index63.js +10 -57
  127. package/dist/index64.cjs +1 -1
  128. package/dist/index64.js +35 -2
  129. package/dist/index65.cjs +2 -1
  130. package/dist/index65.js +58 -5
  131. package/dist/index66.cjs +1 -1
  132. package/dist/index66.js +21 -4
  133. package/dist/index67.cjs +1 -1
  134. package/dist/index67.js +4 -11
  135. package/dist/index68.cjs +1 -5
  136. package/dist/index68.js +3 -56
  137. package/dist/index69.cjs +1 -2
  138. package/dist/index69.js +17 -33
  139. package/dist/index70.cjs +1 -1
  140. package/dist/index70.js +42 -5
  141. package/dist/index71.cjs +1 -1
  142. package/dist/index71.js +8 -3
  143. package/dist/index72.cjs +1 -1
  144. package/dist/index72.js +101 -18
  145. package/dist/index73.cjs +1 -1
  146. package/dist/index73.js +2 -2
  147. package/dist/index74.cjs +1 -1
  148. package/dist/index74.js +2 -2
  149. package/dist/index75.cjs +1 -1
  150. package/dist/index75.js +1 -1
  151. package/dist/index76.cjs +1 -1
  152. package/dist/index76.js +13 -6
  153. package/dist/index77.cjs +1 -1
  154. package/dist/index77.js +6 -13
  155. package/dist/index78.cjs +1 -1
  156. package/dist/index78.js +16 -31
  157. package/dist/index79.cjs +1 -1
  158. package/dist/index79.js +78 -14
  159. package/dist/index80.cjs +1 -1
  160. package/dist/index80.js +14 -64
  161. package/dist/index81.cjs +1 -1
  162. package/dist/index81.js +17 -26
  163. package/dist/index82.cjs +1 -1
  164. package/dist/index82.js +192 -3
  165. package/dist/index83.cjs +1 -1
  166. package/dist/index83.js +64 -3
  167. package/dist/index84.cjs +1 -1
  168. package/dist/index84.js +2 -9
  169. package/dist/index85.cjs +1 -1
  170. package/dist/index85.js +5 -190
  171. package/dist/index86.cjs +1 -1
  172. package/dist/index86.js +11 -18
  173. package/dist/index87.cjs +5 -1
  174. package/dist/index87.js +50 -106
  175. package/dist/index88.cjs +2 -1
  176. package/dist/index88.js +33 -15
  177. package/dist/index89.cjs +1 -1
  178. package/dist/index89.js +5 -223
  179. package/dist/index90.cjs +1 -1
  180. package/dist/index90.js +3 -42
  181. package/dist/index91.cjs +1 -1
  182. package/dist/index91.js +6 -104
  183. package/dist/index92.cjs +1 -1
  184. package/dist/index92.js +31 -16
  185. package/dist/index93.cjs +1 -1
  186. package/dist/index93.js +24 -75
  187. package/dist/index94.cjs +1 -1
  188. package/dist/index94.js +3 -19
  189. package/dist/index96.cjs +1 -1
  190. package/dist/index96.js +66 -10
  191. package/dist/index97.cjs +1 -1
  192. package/dist/index97.js +69 -19
  193. package/dist/index98.cjs +1 -1
  194. package/dist/index98.js +2 -13
  195. package/dist/index99.cjs +1 -1
  196. package/dist/index99.js +30 -34
  197. package/package.json +1 -1
package/dist/index96.js CHANGED
@@ -1,14 +1,70 @@
1
- import { BaseError as i } from "./index63.js";
2
- class d extends i {
3
- constructor(e) {
4
- const { docsPath: s, field: r, metaMessages: a } = e;
5
- super(`Invalid Sign-In with Ethereum message field "${r}".`, {
6
- docsPath: s,
7
- metaMessages: a,
8
- name: "SiweInvalidMessageFieldError"
9
- });
1
+ import { aexists as g, aoutput as d } from "./index99.js";
2
+ import { Hash as b, createView as p, toBytes as a } from "./index97.js";
3
+ function w(o, t, s, i) {
4
+ if (typeof o.setBigUint64 == "function")
5
+ return o.setBigUint64(t, s, i);
6
+ const n = BigInt(32), h = BigInt(4294967295), e = Number(s >> n & h), r = Number(s & h), u = i ? 4 : 0, c = i ? 0 : 4;
7
+ o.setUint32(t + u, e, i), o.setUint32(t + c, r, i);
8
+ }
9
+ function B(o, t, s) {
10
+ return o & t ^ ~o & s;
11
+ }
12
+ function L(o, t, s) {
13
+ return o & t ^ o & s ^ t & s;
14
+ }
15
+ class U extends b {
16
+ constructor(t, s, i, n) {
17
+ super(), this.blockLen = t, this.outputLen = s, this.padOffset = i, this.isLE = n, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(t), this.view = p(this.buffer);
18
+ }
19
+ update(t) {
20
+ g(this);
21
+ const { view: s, buffer: i, blockLen: n } = this;
22
+ t = a(t);
23
+ const h = t.length;
24
+ for (let e = 0; e < h; ) {
25
+ const r = Math.min(n - this.pos, h - e);
26
+ if (r === n) {
27
+ const u = p(t);
28
+ for (; n <= h - e; e += n)
29
+ this.process(u, e);
30
+ continue;
31
+ }
32
+ i.set(t.subarray(e, e + r), this.pos), this.pos += r, e += r, this.pos === n && (this.process(s, 0), this.pos = 0);
33
+ }
34
+ return this.length += t.length, this.roundClean(), this;
35
+ }
36
+ digestInto(t) {
37
+ g(this), d(t, this), this.finished = !0;
38
+ const { buffer: s, view: i, blockLen: n, isLE: h } = this;
39
+ let { pos: e } = this;
40
+ s[e++] = 128, this.buffer.subarray(e).fill(0), this.padOffset > n - e && (this.process(i, 0), e = 0);
41
+ for (let f = e; f < n; f++)
42
+ s[f] = 0;
43
+ w(i, n - 8, BigInt(this.length * 8), h), this.process(i, 0);
44
+ const r = p(t), u = this.outputLen;
45
+ if (u % 4)
46
+ throw new Error("_sha2: outputLen should be aligned to 32bit");
47
+ const c = u / 4, l = this.get();
48
+ if (c > l.length)
49
+ throw new Error("_sha2: outputLen bigger than state");
50
+ for (let f = 0; f < c; f++)
51
+ r.setUint32(4 * f, l[f], h);
52
+ }
53
+ digest() {
54
+ const { buffer: t, outputLen: s } = this;
55
+ this.digestInto(t);
56
+ const i = t.slice(0, s);
57
+ return this.destroy(), i;
58
+ }
59
+ _cloneInto(t) {
60
+ t || (t = new this.constructor()), t.set(...this.get());
61
+ const { blockLen: s, buffer: i, length: n, finished: h, destroyed: e, pos: r } = this;
62
+ return t.length = n, t.pos = r, t.finished = h, t.destroyed = e, n % s && t.buffer.set(i), t;
10
63
  }
11
64
  }
12
65
  export {
13
- d as SiweInvalidMessageFieldError
66
+ B as Chi,
67
+ U as HashMD,
68
+ L as Maj,
69
+ w as setBigUint64
14
70
  };
package/dist/index97.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(e){if(/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(e)||/%[^0-9a-f]/i.test(e)||/%[0-9a-f](:?[^0-9a-f]|$)/i.test(e))return!1;const s=a(e),f=s[1],t=s[2],i=s[3],r=s[4],l=s[5];if(!(f!=null&&f.length&&i.length>=0))return!1;if(t!=null&&t.length){if(!(i.length===0||/^\//.test(i)))return!1}else if(/^\/\//.test(i))return!1;if(!/^[a-z][a-z0-9\+\-\.]*$/.test(f.toLowerCase()))return!1;let n="";return n+=`${f}:`,t!=null&&t.length&&(n+=`//${t}`),n+=i,r!=null&&r.length&&(n+=`?${r}`),l!=null&&l.length&&(n+=`#${l}`),n}function a(e){return e.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/)}exports.isUri=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index98.cjs"),f=require("./index99.cjs");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function p(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function a(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function l(t,e){return t<<32-e|t>>>e}const b=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function i(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function w(t){for(let e=0;e<t.length;e++)t[e]=i(t[e])}function y(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function s(t){return typeof t=="string"&&(t=y(t)),f.abytes(t),t}function g(...t){let e=0;for(let n=0;n<t.length;n++){const u=t[n];f.abytes(u),e+=u.length}const r=new Uint8Array(e);for(let n=0,u=0;n<t.length;n++){const c=t[n];r.set(c,u),u+=c.length}return r}class m{clone(){return this._cloneInto()}}function B(t){const e=n=>t().update(s(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function d(t=32){if(o.crypto&&typeof o.crypto.getRandomValues=="function")return o.crypto.getRandomValues(new Uint8Array(t));if(o.crypto&&typeof o.crypto.randomBytes=="function")return o.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}exports.Hash=m;exports.byteSwap=i;exports.byteSwap32=w;exports.concatBytes=g;exports.createView=a;exports.isLE=b;exports.randomBytes=d;exports.rotr=l;exports.toBytes=s;exports.u32=p;exports.utf8ToBytes=y;exports.wrapConstructor=B;
package/dist/index97.js CHANGED
@@ -1,22 +1,72 @@
1
- function o(e) {
2
- if (/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(e) || /%[^0-9a-f]/i.test(e) || /%[0-9a-f](:?[^0-9a-f]|$)/i.test(e))
3
- return !1;
4
- const s = a(e), f = s[1], t = s[2], i = s[3], r = s[4], l = s[5];
5
- if (!(f != null && f.length && i.length >= 0))
6
- return !1;
7
- if (t != null && t.length) {
8
- if (!(i.length === 0 || /^\//.test(i)))
9
- return !1;
10
- } else if (/^\/\//.test(i))
11
- return !1;
12
- if (!/^[a-z][a-z0-9\+\-\.]*$/.test(f.toLowerCase()))
13
- return !1;
14
- let n = "";
15
- return n += `${f}:`, t != null && t.length && (n += `//${t}`), n += i, r != null && r.length && (n += `?${r}`), l != null && l.length && (n += `#${l}`), n;
16
- }
17
- function a(e) {
18
- return e.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/);
1
+ import { crypto as o } from "./index98.js";
2
+ import { abytes as i } from "./index99.js";
3
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
4
+ function g(t) {
5
+ return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
6
+ }
7
+ function m(t) {
8
+ return new DataView(t.buffer, t.byteOffset, t.byteLength);
9
+ }
10
+ function w(t, e) {
11
+ return t << 32 - e | t >>> e;
12
+ }
13
+ const b = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
14
+ function c(t) {
15
+ return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
16
+ }
17
+ function a(t) {
18
+ for (let e = 0; e < t.length; e++)
19
+ t[e] = c(t[e]);
20
+ }
21
+ function s(t) {
22
+ if (typeof t != "string")
23
+ throw new Error("utf8ToBytes expected string, got " + typeof t);
24
+ return new Uint8Array(new TextEncoder().encode(t));
25
+ }
26
+ function y(t) {
27
+ return typeof t == "string" && (t = s(t)), i(t), t;
28
+ }
29
+ function x(...t) {
30
+ let e = 0;
31
+ for (let n = 0; n < t.length; n++) {
32
+ const r = t[n];
33
+ i(r), e += r.length;
34
+ }
35
+ const f = new Uint8Array(e);
36
+ for (let n = 0, r = 0; n < t.length; n++) {
37
+ const u = t[n];
38
+ f.set(u, r), r += u.length;
39
+ }
40
+ return f;
41
+ }
42
+ class h {
43
+ // Safe version that clones internal state
44
+ clone() {
45
+ return this._cloneInto();
46
+ }
47
+ }
48
+ function B(t) {
49
+ const e = (n) => t().update(y(n)).digest(), f = t();
50
+ return e.outputLen = f.outputLen, e.blockLen = f.blockLen, e.create = () => t(), e;
51
+ }
52
+ function d(t = 32) {
53
+ if (o && typeof o.getRandomValues == "function")
54
+ return o.getRandomValues(new Uint8Array(t));
55
+ if (o && typeof o.randomBytes == "function")
56
+ return o.randomBytes(t);
57
+ throw new Error("crypto.getRandomValues must be defined");
19
58
  }
20
59
  export {
21
- o as isUri
60
+ h as Hash,
61
+ c as byteSwap,
62
+ a as byteSwap32,
63
+ x as concatBytes,
64
+ m as createView,
65
+ b as isLE,
66
+ d as randomBytes,
67
+ w as rotr,
68
+ y as toBytes,
69
+ g as u32,
70
+ s as utf8ToBytes,
71
+ B as wrapConstructor
22
72
  };
package/dist/index98.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index63.cjs");class i extends t.BaseError{constructor({offset:r,position:s,size:e}){super(`Slice ${s==="start"?"starting":"ending"} at offset "${r}" is out-of-bounds (size: ${e}).`,{name:"SliceOffsetOutOfBoundsError"})}}class d extends t.BaseError{constructor({size:r,targetSize:s,type:e}){super(`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()} size (${r}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}exports.SizeExceedsPaddingSizeError=d;exports.SliceOffsetOutOfBoundsError=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;exports.crypto=o;
package/dist/index98.js CHANGED
@@ -1,15 +1,4 @@
1
- import { BaseError as o } from "./index63.js";
2
- class d extends o {
3
- constructor({ offset: r, position: s, size: e }) {
4
- super(`Slice ${s === "start" ? "starting" : "ending"} at offset "${r}" is out-of-bounds (size: ${e}).`, { name: "SliceOffsetOutOfBoundsError" });
5
- }
6
- }
7
- class n extends o {
8
- constructor({ size: r, targetSize: s, type: e }) {
9
- super(`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()} size (${r}) exceeds padding size (${s}).`, { name: "SizeExceedsPaddingSizeError" });
10
- }
11
- }
1
+ const o = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
12
2
  export {
13
- n as SizeExceedsPaddingSizeError,
14
- d as SliceOffsetOutOfBoundsError
3
+ o as crypto
15
4
  };
package/dist/index99.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index98.cjs"),O=require("./index83.cjs"),n=require("./index66.cjs");function p(i,e,s,{strict:f}={}){return O.isHex(i,{strict:!1})?l(i,e,s,{strict:f}):u(i,e,s,{strict:f})}function r(i,e){if(typeof e=="number"&&e>0&&e>n.size(i)-1)throw new t.SliceOffsetOutOfBoundsError({offset:e,position:"start",size:n.size(i)})}function c(i,e,s){if(typeof e=="number"&&typeof s=="number"&&n.size(i)!==s-e)throw new t.SliceOffsetOutOfBoundsError({offset:s,position:"end",size:n.size(i)})}function u(i,e,s,{strict:f}={}){r(i,e);const o=i.slice(e,s);return f&&c(o,e,s),o}function l(i,e,s,{strict:f}={}){r(i,e);const o=`0x${i.replace("0x","").slice((e??0)*2,(s??i.length)*2)}`;return f&&c(o,e,s),o}exports.slice=p;exports.sliceBytes=u;exports.sliceHex=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function i(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function o(e,...t){if(!i(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function a(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");r(e.outputLen),r(e.blockLen)}function s(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function u(e,t){o(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}exports.abytes=o;exports.aexists=s;exports.ahash=a;exports.anumber=r;exports.aoutput=u;
package/dist/index99.js CHANGED
@@ -1,41 +1,37 @@
1
- import { SliceOffsetOutOfBoundsError as t } from "./index98.js";
2
- import { isHex as p } from "./index83.js";
3
- import { size as r } from "./index66.js";
4
- function w(e, f, i, { strict: o } = {}) {
5
- return p(e, { strict: !1 }) ? u(e, f, i, {
6
- strict: o
7
- }) : m(e, f, i, {
8
- strict: o
9
- });
1
+ function n(e) {
2
+ if (!Number.isSafeInteger(e) || e < 0)
3
+ throw new Error("positive integer expected, got " + e);
10
4
  }
11
- function s(e, f) {
12
- if (typeof f == "number" && f > 0 && f > r(e) - 1)
13
- throw new t({
14
- offset: f,
15
- position: "start",
16
- size: r(e)
17
- });
5
+ function o(e) {
6
+ return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
18
7
  }
19
- function c(e, f, i) {
20
- if (typeof f == "number" && typeof i == "number" && r(e) !== i - f)
21
- throw new t({
22
- offset: i,
23
- position: "end",
24
- size: r(e)
25
- });
8
+ function i(e, ...t) {
9
+ if (!o(e))
10
+ throw new Error("Uint8Array expected");
11
+ if (t.length > 0 && !t.includes(e.length))
12
+ throw new Error("Uint8Array expected of length " + t + ", got length=" + e.length);
26
13
  }
27
- function m(e, f, i, { strict: o } = {}) {
28
- s(e, f);
29
- const n = e.slice(f, i);
30
- return o && c(n, f, i), n;
14
+ function f(e) {
15
+ if (typeof e != "function" || typeof e.create != "function")
16
+ throw new Error("Hash should be wrapped by utils.wrapConstructor");
17
+ n(e.outputLen), n(e.blockLen);
31
18
  }
32
- function u(e, f, i, { strict: o } = {}) {
33
- s(e, f);
34
- const n = `0x${e.replace("0x", "").slice((f ?? 0) * 2, (i ?? e.length) * 2)}`;
35
- return o && c(n, f, i), n;
19
+ function s(e, t = !0) {
20
+ if (e.destroyed)
21
+ throw new Error("Hash instance has been destroyed");
22
+ if (t && e.finished)
23
+ throw new Error("Hash#digest() has already been called");
24
+ }
25
+ function u(e, t) {
26
+ i(e);
27
+ const r = t.outputLen;
28
+ if (e.length < r)
29
+ throw new Error("digestInto() expects output buffer of length at least " + r);
36
30
  }
37
31
  export {
38
- w as slice,
39
- m as sliceBytes,
40
- u as sliceHex
32
+ i as abytes,
33
+ s as aexists,
34
+ f as ahash,
35
+ n as anumber,
36
+ u as aoutput
41
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/utils",
3
- "version": "2.0.6-alpha.0",
3
+ "version": "2.0.6-alpha.1",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",