@gardenfi/utils 2.0.4 → 2.0.6-alpha.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.
Files changed (243) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +35 -24
  3. package/dist/index10.cjs +1 -1
  4. package/dist/index10.js +42 -32
  5. package/dist/index100.cjs +1 -0
  6. package/dist/index100.js +7 -0
  7. package/dist/index101.cjs +1 -0
  8. package/dist/index101.js +13 -0
  9. package/dist/index102.cjs +1 -0
  10. package/dist/index102.js +4 -0
  11. package/dist/index103.cjs +1 -0
  12. package/dist/index103.js +23 -0
  13. package/dist/index104.cjs +1 -0
  14. package/dist/index104.js +9 -0
  15. package/dist/index105.cjs +1 -0
  16. package/dist/index105.js +7 -0
  17. package/dist/index106.cjs +1 -0
  18. package/dist/index106.js +40 -0
  19. package/dist/index107.cjs +1 -0
  20. package/dist/index107.js +130 -0
  21. package/dist/index108.cjs +1 -0
  22. package/dist/index108.js +4 -0
  23. package/dist/index109.cjs +2 -0
  24. package/dist/index109.js +5 -0
  25. package/dist/index11.cjs +1 -1
  26. package/dist/index11.js +21 -14
  27. package/dist/index110.cjs +1 -0
  28. package/dist/index110.js +70 -0
  29. package/dist/index111.cjs +1 -0
  30. package/dist/index111.js +72 -0
  31. package/dist/index112.cjs +1 -0
  32. package/dist/index112.js +4 -0
  33. package/dist/index113.cjs +1 -0
  34. package/dist/index113.js +37 -0
  35. package/dist/index114.cjs +1 -0
  36. package/dist/index114.js +43 -0
  37. package/dist/index115.cjs +1 -0
  38. package/dist/index115.js +646 -0
  39. package/dist/index116.cjs +1 -0
  40. package/dist/index116.js +234 -0
  41. package/dist/index117.cjs +1 -0
  42. package/dist/index117.js +175 -0
  43. package/dist/index118.cjs +1 -0
  44. package/dist/index118.js +21 -0
  45. package/dist/index12.cjs +1 -1
  46. package/dist/index12.js +126 -173
  47. package/dist/index13.cjs +1 -1
  48. package/dist/index13.js +14 -93
  49. package/dist/index14.cjs +1 -16
  50. package/dist/index14.js +2 -114
  51. package/dist/index15.cjs +1 -1
  52. package/dist/index15.js +33 -31
  53. package/dist/index16.cjs +1 -1
  54. package/dist/index16.js +19 -31
  55. package/dist/index17.cjs +1 -1
  56. package/dist/index17.js +188 -17
  57. package/dist/index18.cjs +1 -1
  58. package/dist/index18.js +93 -7
  59. package/dist/index19.cjs +1 -1
  60. package/dist/index19.js +35 -20
  61. package/dist/index20.cjs +1 -1
  62. package/dist/index20.js +32 -22
  63. package/dist/index21.cjs +16 -1
  64. package/dist/index21.js +113 -8
  65. package/dist/index22.cjs +1 -1
  66. package/dist/index22.js +30 -31
  67. package/dist/index23.cjs +1 -1
  68. package/dist/index23.js +17 -26
  69. package/dist/index24.cjs +1 -1
  70. package/dist/index24.js +6 -22
  71. package/dist/index25.cjs +1 -1
  72. package/dist/index25.js +44 -50
  73. package/dist/index26.cjs +1 -1
  74. package/dist/index26.js +21 -12
  75. package/dist/index27.cjs +1 -1
  76. package/dist/index27.js +8 -24
  77. package/dist/index28.cjs +1 -1
  78. package/dist/index28.js +31 -75
  79. package/dist/index29.cjs +1 -1
  80. package/dist/index29.js +25 -22
  81. package/dist/index3.cjs +1 -1
  82. package/dist/index3.js +30 -7
  83. package/dist/index30.cjs +2 -1
  84. package/dist/index30.js +65 -7
  85. package/dist/index31.cjs +1 -1
  86. package/dist/index31.js +51 -32
  87. package/dist/index32.cjs +1 -1
  88. package/dist/index32.js +12 -15
  89. package/dist/index33.cjs +1 -1
  90. package/dist/index33.js +25 -2
  91. package/dist/index34.cjs +1 -1
  92. package/dist/index34.js +75 -8
  93. package/dist/index35.cjs +1 -1
  94. package/dist/index35.js +23 -20
  95. package/dist/index36.cjs +1 -1
  96. package/dist/index36.js +7 -12
  97. package/dist/index37.cjs +1 -1
  98. package/dist/index37.js +32 -34
  99. package/dist/index38.cjs +1 -2
  100. package/dist/index38.js +15 -59
  101. package/dist/index39.cjs +1 -1
  102. package/dist/index39.js +2 -2
  103. package/dist/index4.cjs +1 -1
  104. package/dist/index4.js +2 -2
  105. package/dist/index40.cjs +1 -1
  106. package/dist/index40.js +8 -4
  107. package/dist/index41.cjs +1 -1
  108. package/dist/index41.js +20 -11
  109. package/dist/index42.cjs +1 -1
  110. package/dist/index42.js +41 -3
  111. package/dist/index43.cjs +1 -1
  112. package/dist/index43.js +25 -21
  113. package/dist/index44.cjs +1 -1
  114. package/dist/index44.js +6 -12
  115. package/dist/index45.cjs +1 -1
  116. package/dist/index45.js +13 -55
  117. package/dist/index46.cjs +1 -1
  118. package/dist/index46.js +15 -6
  119. package/dist/index47.cjs +1 -1
  120. package/dist/index47.js +5 -21
  121. package/dist/index48.cjs +1 -1
  122. package/dist/index48.js +13 -11
  123. package/dist/index49.cjs +1 -1
  124. package/dist/index49.js +10 -3
  125. package/dist/index50.cjs +1 -1
  126. package/dist/index50.js +10 -9
  127. package/dist/index51.cjs +1 -1
  128. package/dist/index51.js +11 -19
  129. package/dist/index52.cjs +1 -1
  130. package/dist/index52.js +13 -6
  131. package/dist/index53.cjs +1 -1
  132. package/dist/index53.js +55 -8
  133. package/dist/index54.cjs +1 -1
  134. package/dist/index54.js +16 -104
  135. package/dist/index55.cjs +1 -1
  136. package/dist/index55.js +5 -28
  137. package/dist/index56.cjs +1 -1
  138. package/dist/index56.js +8 -18
  139. package/dist/index57.cjs +1 -1
  140. package/dist/index57.js +165 -32
  141. package/dist/index58.cjs +1 -0
  142. package/dist/index58.js +106 -0
  143. package/dist/index59.cjs +1 -0
  144. package/dist/index59.js +24 -0
  145. package/dist/index6.cjs +1 -1
  146. package/dist/index6.js +40 -22
  147. package/dist/index60.cjs +1 -0
  148. package/dist/index60.js +15 -0
  149. package/dist/index61.cjs +1 -0
  150. package/dist/index61.js +37 -0
  151. package/dist/index62.cjs +1 -0
  152. package/dist/index62.js +9 -0
  153. package/dist/index63.cjs +2 -0
  154. package/dist/index63.js +62 -0
  155. package/dist/index64.cjs +1 -0
  156. package/dist/index64.js +4 -0
  157. package/dist/index65.cjs +1 -0
  158. package/dist/index65.js +9 -0
  159. package/dist/index66.cjs +1 -0
  160. package/dist/index66.js +7 -0
  161. package/dist/index67.cjs +1 -0
  162. package/dist/index67.js +14 -0
  163. package/dist/index68.cjs +5 -0
  164. package/dist/index68.js +59 -0
  165. package/dist/index69.cjs +2 -0
  166. package/dist/index69.js +37 -0
  167. package/dist/index7.cjs +1 -1
  168. package/dist/index7.js +19 -104
  169. package/dist/index70.cjs +1 -0
  170. package/dist/index70.js +8 -0
  171. package/dist/index71.cjs +1 -0
  172. package/dist/index71.js +6 -0
  173. package/dist/index72.cjs +1 -0
  174. package/dist/index72.js +24 -0
  175. package/dist/index73.cjs +1 -0
  176. package/dist/index73.js +11 -0
  177. package/dist/index74.cjs +1 -0
  178. package/dist/index74.js +13 -0
  179. package/dist/index75.cjs +1 -0
  180. package/dist/index75.js +14 -0
  181. package/dist/index76.cjs +1 -0
  182. package/dist/index76.js +9 -0
  183. package/dist/index77.cjs +1 -0
  184. package/dist/index77.js +16 -0
  185. package/dist/index78.cjs +1 -0
  186. package/dist/index78.js +35 -0
  187. package/dist/index79.cjs +1 -0
  188. package/dist/index79.js +17 -0
  189. package/dist/index8.cjs +1 -1
  190. package/dist/index8.js +2 -15
  191. package/dist/index80.cjs +1 -0
  192. package/dist/index80.js +67 -0
  193. package/dist/index81.cjs +1 -0
  194. package/dist/index81.js +30 -0
  195. package/dist/index82.cjs +1 -0
  196. package/dist/index82.js +5 -0
  197. package/dist/index83.cjs +1 -0
  198. package/dist/index83.js +6 -0
  199. package/dist/index84.cjs +1 -0
  200. package/dist/index84.js +11 -0
  201. package/dist/index85.cjs +1 -0
  202. package/dist/index85.js +194 -0
  203. package/dist/index86.cjs +1 -0
  204. package/dist/index86.js +21 -0
  205. package/dist/index87.cjs +1 -0
  206. package/dist/index87.js +115 -0
  207. package/dist/index88.cjs +1 -0
  208. package/dist/index88.js +19 -0
  209. package/dist/index89.cjs +1 -0
  210. package/dist/index89.js +226 -0
  211. package/dist/index9.cjs +1 -1
  212. package/dist/index9.js +100 -2
  213. package/dist/index90.cjs +1 -0
  214. package/dist/index90.js +45 -0
  215. package/dist/index91.cjs +1 -0
  216. package/dist/index91.js +107 -0
  217. package/dist/index92.cjs +1 -0
  218. package/dist/index92.js +20 -0
  219. package/dist/index93.cjs +1 -0
  220. package/dist/index93.js +81 -0
  221. package/dist/index94.cjs +1 -0
  222. package/dist/index94.js +21 -0
  223. package/dist/index95.cjs +1 -0
  224. package/dist/index95.js +11 -0
  225. package/dist/index96.cjs +1 -0
  226. package/dist/index96.js +14 -0
  227. package/dist/index97.cjs +1 -0
  228. package/dist/index97.js +22 -0
  229. package/dist/index98.cjs +1 -0
  230. package/dist/index98.js +15 -0
  231. package/dist/index99.cjs +1 -0
  232. package/dist/index99.js +41 -0
  233. package/dist/src/index.d.ts +1 -0
  234. package/dist/src/lib/auth/apikey/apikey.d.ts +12 -0
  235. package/dist/src/lib/auth/auth.types.d.ts +21 -8
  236. package/dist/src/lib/auth/index.d.ts +5 -1
  237. package/dist/src/lib/auth/passkey/passkey.d.ts +10 -0
  238. package/dist/src/lib/auth/passkey/passkey.types.d.ts +17 -0
  239. package/dist/src/lib/auth/passkey/passkeyLogin.d.ts +37 -0
  240. package/dist/src/lib/auth/{siwe.d.ts → siwe/siwe.d.ts} +5 -15
  241. package/dist/src/lib/digestKey/digestKey.d.ts +12 -0
  242. package/dist/src/lib/utils.d.ts +3 -0
  243. package/package.json +3 -1
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index2.cjs"),e=require("./index3.cjs"),n=require("./index4.cjs"),r=require("./index5.cjs"),c=require("./index6.cjs"),t=require("./index7.cjs"),s=require("./index8.cjs"),u=require("./index9.cjs"),o=require("./index10.cjs"),l=require("./index11.cjs");exports.ApiStatus=i.ApiStatus;exports.Authorization=e.Authorization;exports.Environment=e.Environment;exports.Network=e.Network;exports.sleep=e.sleep;exports.with0x=e.with0x;exports.checkAllowanceAndApprove=n.checkAllowanceAndApprove;exports.Err=r.Err;exports.Ok=r.Ok;exports.Result=r.Result;exports.Void=r.Void;exports.Url=c.Url;exports.Auth=t.Auth;exports.Siwe=t.Siwe;exports.parseJwt=t.parseJwt;exports.MemoryStorage=s.MemoryStorage;exports.StoreKeys=u.StoreKeys;exports.fetchBitcoinBlockNumber=o.fetchBitcoinBlockNumber;exports.fetchEVMBlockNumber=o.fetchEVMBlockNumber;exports.EventBroker=l.EventBroker;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index2.cjs"),e=require("./index3.cjs"),s=require("./index4.cjs"),r=require("./index5.cjs"),i=require("./index6.cjs"),n=require("./index7.cjs"),u=require("./index8.cjs"),c=require("./index9.cjs"),a=require("./index10.cjs"),y=require("./index11.cjs"),p=require("./index12.cjs"),k=require("./index13.cjs"),l=require("./index14.cjs"),t=require("./index15.cjs"),A=require("./index16.cjs");exports.ApiStatus=o.ApiStatus;exports.Authorization=e.Authorization;exports.Environment=e.Environment;exports.Network=e.Network;exports.add0x=e.add0x;exports.hexToU32Array=e.hexToU32Array;exports.parseJwt=e.parseJwt;exports.sleep=e.sleep;exports.with0x=e.with0x;exports.checkAllowanceAndApprove=s.checkAllowanceAndApprove;exports.Err=r.Err;exports.Ok=r.Ok;exports.Result=r.Result;exports.Void=r.Void;exports.DigestKey=i.DigestKey;exports.Url=n.Url;exports.AuthHeaderEnum=u.AuthHeaderEnum;exports.Siwe=c.Siwe;exports.ApiKey=a.ApiKey;exports.Passkey=y.Passkey;exports.PasskeyLogin=p.PasskeyLogin;exports.MemoryStorage=k.MemoryStorage;exports.StoreKeys=l.StoreKeys;exports.fetchBitcoinBlockNumber=t.fetchBitcoinBlockNumber;exports.fetchEVMBlockNumber=t.fetchEVMBlockNumber;exports.EventBroker=A.EventBroker;
package/dist/index.js CHANGED
@@ -1,32 +1,43 @@
1
1
  import { ApiStatus as e } from "./index2.js";
2
- import { Authorization as p, Environment as m, Network as f, sleep as x, with0x as i } from "./index3.js";
3
- import { checkAllowanceAndApprove as n } from "./index4.js";
4
- import { Err as h, Ok as k, Result as u, Void as A } from "./index5.js";
5
- import { Url as s } from "./index6.js";
6
- import { Auth as B, Siwe as E, parseJwt as S } from "./index7.js";
7
- import { MemoryStorage as N } from "./index8.js";
8
- import { StoreKeys as d } from "./index9.js";
9
- import { fetchBitcoinBlockNumber as M, fetchEVMBlockNumber as V } from "./index10.js";
10
- import { EventBroker as z } from "./index11.js";
2
+ import { Authorization as p, Environment as m, Network as x, add0x as f, hexToU32Array as i, parseJwt as a, sleep as n, with0x as s } from "./index3.js";
3
+ import { checkAllowanceAndApprove as k } from "./index4.js";
4
+ import { Err as h, Ok as l, Result as u, Void as y } from "./index5.js";
5
+ import { DigestKey as w } from "./index6.js";
6
+ import { Url as B } from "./index7.js";
7
+ import { AuthHeaderEnum as g } from "./index8.js";
8
+ import { Siwe as K } from "./index9.js";
9
+ import { ApiKey as b } from "./index10.js";
10
+ import { Passkey as P } from "./index11.js";
11
+ import { PasskeyLogin as V } from "./index12.js";
12
+ import { MemoryStorage as D } from "./index13.js";
13
+ import { StoreKeys as J } from "./index14.js";
14
+ import { fetchBitcoinBlockNumber as O, fetchEVMBlockNumber as R } from "./index15.js";
15
+ import { EventBroker as j } from "./index16.js";
11
16
  export {
17
+ b as ApiKey,
12
18
  e as ApiStatus,
13
- B as Auth,
19
+ g as AuthHeaderEnum,
14
20
  p as Authorization,
21
+ w as DigestKey,
15
22
  m as Environment,
16
23
  h as Err,
17
- z as EventBroker,
18
- N as MemoryStorage,
19
- f as Network,
20
- k as Ok,
24
+ j as EventBroker,
25
+ D as MemoryStorage,
26
+ x as Network,
27
+ l as Ok,
28
+ P as Passkey,
29
+ V as PasskeyLogin,
21
30
  u as Result,
22
- E as Siwe,
23
- d as StoreKeys,
24
- s as Url,
25
- A as Void,
26
- n as checkAllowanceAndApprove,
27
- M as fetchBitcoinBlockNumber,
28
- V as fetchEVMBlockNumber,
29
- S as parseJwt,
30
- x as sleep,
31
- i as with0x
31
+ K as Siwe,
32
+ J as StoreKeys,
33
+ B as Url,
34
+ y as Void,
35
+ f as add0x,
36
+ k as checkAllowanceAndApprove,
37
+ O as fetchBitcoinBlockNumber,
38
+ R as fetchEVMBlockNumber,
39
+ i as hexToU32Array,
40
+ a as parseJwt,
41
+ n as sleep,
42
+ s as with0x
32
43
  };
package/dist/index10.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index12.cjs"),n=require("viem"),s=require("./index15.cjs"),l=require("./index16.cjs"),o={42161:s.mainnet,421614:l.sepolia},b=async e=>{const{chain:t}=e;if(!t)return r.Err("No chain found");const a=(u=>u in o)(t.id)?o[t.id]:t;return await i(a)},i=async e=>{const t=n.createPublicClient({chain:e,transport:n.http()});try{const c=await t.getBlockNumber();return r.Ok(Number(c))}catch(c){return r.Err("Failed to fetch evm block number",c)}},m=async e=>{try{const t=await e.getLatestTip();return r.Ok(t)}catch(t){return r.Err("Failed to fetch bitcoin block number",t)}};exports._fetchEVMBlockNumber=i;exports.fetchBitcoinBlockNumber=m;exports.fetchEVMBlockNumber=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index17.cjs"),l=require("./index8.cjs");class f{constructor(e){this.apiKey=e}async getToken(){const e=this.verifyToken();return e.error?t.Err(e.error):e.val?t.Ok(this.apiKey):t.Err("Token verification failed")}verifyToken(){const e=this.decodeBase64UrlSafe(this.apiKey),r=this.extractData(e);if(r.error)return t.Err(r.error);const{expiryTimestamp:i}=r.val;return i<new Date?t.Err("Token expired"):t.Ok(!0)}decodeBase64UrlSafe(e){let r=e.replace(/_/g,"/").replace(/-/g,"+");for(;r.length%4!==0;)r+="=";return Uint8Array.from(atob(r),i=>i.charCodeAt(0))}extractData(e){const r=new TextEncoder().encode("::"),i=e.findIndex((n,a)=>e.slice(a,a+r.length).every((u,d)=>u===r[d]));if(i===-1)return t.Err("Invalid format: delimiter not found");const o=e.slice(0,8),s=new DataView(o.buffer).getBigUint64(0,!1),c=e.slice(i+r.length);return t.Ok({expiryTimestamp:new Date(Number(s)*1e3),signature:Array.from(c).map(n=>n.toString(16).padStart(2,"0")).join("")})}async getAuthHeaders(){const e=await this.getToken();return e.ok?t.Ok({[l.AuthHeaderEnum.ApiKey]:e.val}):t.Err(e.error??"Failed to get auth token")}}exports.ApiKey=f;
package/dist/index10.js CHANGED
@@ -1,36 +1,46 @@
1
- import { Err as o, Ok as n } from "./index12.js";
2
- import { createPublicClient as s, http as m } from "viem";
3
- import { mainnet as u } from "./index15.js";
4
- import { sepolia as b } from "./index16.js";
5
- const e = {
6
- 42161: u,
7
- 421614: b
8
- }, N = async (r) => {
9
- const { chain: t } = r;
10
- if (!t) return o("No chain found");
11
- const i = ((a) => a in e)(t.id) ? e[t.id] : t;
12
- return await l(i);
13
- }, l = async (r) => {
14
- const t = s({
15
- chain: r,
16
- transport: m()
17
- });
18
- try {
19
- const c = await t.getBlockNumber();
20
- return n(Number(c));
21
- } catch (c) {
22
- return o("Failed to fetch evm block number", c);
1
+ import { Err as i, Ok as n } from "./index17.js";
2
+ import { AuthHeaderEnum as u } from "./index8.js";
3
+ class h {
4
+ constructor(e) {
5
+ this.apiKey = e;
23
6
  }
24
- }, C = async (r) => {
25
- try {
26
- const t = await r.getLatestTip();
27
- return n(t);
28
- } catch (t) {
29
- return o("Failed to fetch bitcoin block number", t);
7
+ async getToken() {
8
+ const e = this.verifyToken();
9
+ return e.error ? i(e.error) : e.val ? n(this.apiKey) : i("Token verification failed");
30
10
  }
31
- };
11
+ verifyToken() {
12
+ const e = this.decodeBase64UrlSafe(this.apiKey), r = this.extractData(e);
13
+ if (r.error)
14
+ return i(r.error);
15
+ const { expiryTimestamp: t } = r.val;
16
+ return t < /* @__PURE__ */ new Date() ? i("Token expired") : n(!0);
17
+ }
18
+ decodeBase64UrlSafe(e) {
19
+ let r = e.replace(/_/g, "/").replace(/-/g, "+");
20
+ for (; r.length % 4 !== 0; )
21
+ r += "=";
22
+ return Uint8Array.from(atob(r), (t) => t.charCodeAt(0));
23
+ }
24
+ extractData(e) {
25
+ const r = new TextEncoder().encode("::"), t = e.findIndex(
26
+ (a, o) => e.slice(o, o + r.length).every((f, l) => f === r[l])
27
+ );
28
+ if (t === -1)
29
+ return i("Invalid format: delimiter not found");
30
+ const s = e.slice(0, 8), c = new DataView(s.buffer).getBigUint64(
31
+ 0,
32
+ !1
33
+ ), d = e.slice(t + r.length);
34
+ return n({
35
+ expiryTimestamp: new Date(Number(c) * 1e3),
36
+ signature: Array.from(d).map((a) => a.toString(16).padStart(2, "0")).join("")
37
+ });
38
+ }
39
+ async getAuthHeaders() {
40
+ const e = await this.getToken();
41
+ return e.ok ? n({ [u.ApiKey]: e.val }) : i(e.error ?? "Failed to get auth token");
42
+ }
43
+ }
32
44
  export {
33
- l as _fetchEVMBlockNumber,
34
- C as fetchBitcoinBlockNumber,
35
- N as fetchEVMBlockNumber
45
+ h as ApiKey
36
46
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={ether:-9,wei:9};exports.gweiUnits=e;
@@ -0,0 +1,7 @@
1
+ const e = {
2
+ ether: -9,
3
+ wei: 9
4
+ };
5
+ export {
6
+ e as gweiUnits
7
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(r,i){let t=r.toString();const n=t.startsWith("-");n&&(t=t.slice(1)),t=t.padStart(i,"0");let[l,e]=[t.slice(0,t.length-i),t.slice(t.length-i)];return e=e.replace(/(0+)$/,""),`${n?"-":""}${l||"0"}${e?`.${e}`:""}`}exports.formatUnits=o;
@@ -0,0 +1,13 @@
1
+ function a(r, n) {
2
+ let t = r.toString();
3
+ const i = t.startsWith("-");
4
+ i && (t = t.slice(1)), t = t.padStart(n, "0");
5
+ let [l, e] = [
6
+ t.slice(0, t.length - n),
7
+ t.slice(t.length - n)
8
+ ];
9
+ return e = e.replace(/(0+)$/, ""), `${i ? "-" : ""}${l || "0"}${e ? `.${e}` : ""}`;
10
+ }
11
+ export {
12
+ a as formatUnits
13
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=2n**256n-1n;exports.maxUint256=t;
@@ -0,0 +1,4 @@
1
+ const n = 2n ** 256n - 1n;
2
+ export {
3
+ n as maxUint256
4
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index63.cjs");class t extends o.BaseError{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class i extends o.BaseError{constructor({length:e,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class n extends o.BaseError{constructor({count:e,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}exports.NegativeOffsetError=t;exports.PositionOutOfBoundsError=i;exports.RecursiveReadLimitExceededError=n;
@@ -0,0 +1,23 @@
1
+ import { BaseError as o } from "./index63.js";
2
+ class i extends o {
3
+ constructor({ offset: e }) {
4
+ super(`Offset \`${e}\` cannot be negative.`, {
5
+ name: "NegativeOffsetError"
6
+ });
7
+ }
8
+ }
9
+ class n extends o {
10
+ constructor({ length: e, position: r }) {
11
+ super(`Position \`${r}\` is out of bounds (\`0 < position < ${e}\`).`, { name: "PositionOutOfBoundsError" });
12
+ }
13
+ }
14
+ class c extends o {
15
+ constructor({ count: e, limit: r }) {
16
+ super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${e}\`).`, { name: "RecursiveReadLimitExceededError" });
17
+ }
18
+ }
19
+ export {
20
+ i as NegativeOffsetError,
21
+ n as PositionOutOfBoundsError,
22
+ c as RecursiveReadLimitExceededError
23
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index87.cjs"),s=require("./index83.cjs"),r=require("./index53.cjs");function o(t,i){return e.sha256(s.isHex(t,{strict:!1})?r.toBytes(t):t)}exports.sha256=o;
@@ -0,0 +1,9 @@
1
+ import { sha256 as o } from "./index87.js";
2
+ import { isHex as s } from "./index83.js";
3
+ import { toBytes as r } from "./index53.js";
4
+ function p(t, i) {
5
+ return o(s(t, { strict: !1 }) ? r(t) : t);
6
+ }
7
+ export {
8
+ p as sha256
9
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=6,s=32,e=4096,n=s*e,o=n*t-1-1*e*t;exports.bytesPerBlob=n;exports.bytesPerFieldElement=s;exports.fieldElementsPerBlob=e;exports.maxBytesPerTransaction=o;
@@ -0,0 +1,7 @@
1
+ const e = 32, s = 4096, t = 131072, l = 761855;
2
+ export {
3
+ t as bytesPerBlob,
4
+ e as bytesPerFieldElement,
5
+ s as fieldElementsPerBlob,
6
+ l as maxBytesPerTransaction
7
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index108.cjs"),s=require("./index63.cjs");class i extends s.BaseError{constructor({maxSize:e,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}}class n extends s.BaseError{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class t extends s.BaseError{constructor({hash:e,size:r}){super(`Versioned hash "${e}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}}class d extends s.BaseError{constructor({hash:e,version:r}){super(`Versioned hash "${e}" version is invalid.`,{metaMessages:[`Expected: ${a.versionedHashVersionKzg}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}}exports.BlobSizeTooLargeError=i;exports.EmptyBlobError=n;exports.InvalidVersionedHashSizeError=t;exports.InvalidVersionedHashVersionError=d;
@@ -0,0 +1,40 @@
1
+ import { versionedHashVersionKzg as a } from "./index108.js";
2
+ import { BaseError as s } from "./index63.js";
3
+ class t extends s {
4
+ constructor({ maxSize: e, size: r }) {
5
+ super("Blob size is too large.", {
6
+ metaMessages: [`Max: ${e} bytes`, `Given: ${r} bytes`],
7
+ name: "BlobSizeTooLargeError"
8
+ });
9
+ }
10
+ }
11
+ class d extends s {
12
+ constructor() {
13
+ super("Blob data must not be empty.", { name: "EmptyBlobError" });
14
+ }
15
+ }
16
+ class l extends s {
17
+ constructor({ hash: e, size: r }) {
18
+ super(`Versioned hash "${e}" size is invalid.`, {
19
+ metaMessages: ["Expected: 32", `Received: ${r}`],
20
+ name: "InvalidVersionedHashSizeError"
21
+ });
22
+ }
23
+ }
24
+ class c extends s {
25
+ constructor({ hash: e, version: r }) {
26
+ super(`Versioned hash "${e}" version is invalid.`, {
27
+ metaMessages: [
28
+ `Expected: ${a}`,
29
+ `Received: ${r}`
30
+ ],
31
+ name: "InvalidVersionedHashVersionError"
32
+ });
33
+ }
34
+ }
35
+ export {
36
+ t as BlobSizeTooLargeError,
37
+ d as EmptyBlobError,
38
+ l as InvalidVersionedHashSizeError,
39
+ c as InvalidVersionedHashVersionError
40
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index103.cjs"),e={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new o.RecursiveReadLimitExceededError({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(t){if(t<0||t>this.bytes.length-1)throw new o.PositionOutOfBoundsError({length:this.bytes.length,position:t})},decrementPosition(t){if(t<0)throw new o.NegativeOffsetError({offset:t});const i=this.position-t;this.assertPosition(i),this.position=i},getReadCount(t){return this.positionReadCount.get(t||this.position)||0},incrementPosition(t){if(t<0)throw new o.NegativeOffsetError({offset:t});const i=this.position+t;this.assertPosition(i),this.position=i},inspectByte(t){const i=t??this.position;return this.assertPosition(i),this.bytes[i]},inspectBytes(t,i){const s=i??this.position;return this.assertPosition(s+t-1),this.bytes.subarray(s,s+t)},inspectUint8(t){const i=t??this.position;return this.assertPosition(i),this.bytes[i]},inspectUint16(t){const i=t??this.position;return this.assertPosition(i+1),this.dataView.getUint16(i)},inspectUint24(t){const i=t??this.position;return this.assertPosition(i+2),(this.dataView.getUint16(i)<<8)+this.dataView.getUint8(i+2)},inspectUint32(t){const i=t??this.position;return this.assertPosition(i+3),this.dataView.getUint32(i)},pushByte(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushBytes(t){this.assertPosition(this.position+t.length-1),this.bytes.set(t,this.position),this.position+=t.length},pushUint8(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushUint16(t){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,t),this.position+=2},pushUint24(t){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,t>>8),this.dataView.setUint8(this.position+2,t&255),this.position+=3},pushUint32(t){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,t),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const t=this.inspectByte();return this.position++,t},readBytes(t,i){this.assertReadLimit(),this._touch();const s=this.inspectBytes(t);return this.position+=i??t,s},readUint8(){this.assertReadLimit(),this._touch();const t=this.inspectUint8();return this.position+=1,t},readUint16(){this.assertReadLimit(),this._touch();const t=this.inspectUint16();return this.position+=2,t},readUint24(){this.assertReadLimit(),this._touch();const t=this.inspectUint24();return this.position+=3,t},readUint32(){this.assertReadLimit(),this._touch();const t=this.inspectUint32();return this.position+=4,t},get remaining(){return this.bytes.length-this.position},setPosition(t){const i=this.position;return this.assertPosition(t),this.position=t,()=>this.position=i},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const t=this.getReadCount();this.positionReadCount.set(this.position,t+1),t>0&&this.recursiveReadCount++}};function n(t,{recursiveReadLimit:i=8192}={}){const s=Object.create(e);return s.bytes=t,s.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength),s.positionReadCount=new Map,s.recursiveReadLimit=i,s}exports.createCursor=n;
@@ -0,0 +1,130 @@
1
+ import { RecursiveReadLimitExceededError as e, PositionOutOfBoundsError as n, NegativeOffsetError as o } from "./index103.js";
2
+ const h = {
3
+ bytes: new Uint8Array(),
4
+ dataView: new DataView(new ArrayBuffer(0)),
5
+ position: 0,
6
+ positionReadCount: /* @__PURE__ */ new Map(),
7
+ recursiveReadCount: 0,
8
+ recursiveReadLimit: Number.POSITIVE_INFINITY,
9
+ assertReadLimit() {
10
+ if (this.recursiveReadCount >= this.recursiveReadLimit)
11
+ throw new e({
12
+ count: this.recursiveReadCount + 1,
13
+ limit: this.recursiveReadLimit
14
+ });
15
+ },
16
+ assertPosition(t) {
17
+ if (t < 0 || t > this.bytes.length - 1)
18
+ throw new n({
19
+ length: this.bytes.length,
20
+ position: t
21
+ });
22
+ },
23
+ decrementPosition(t) {
24
+ if (t < 0)
25
+ throw new o({ offset: t });
26
+ const i = this.position - t;
27
+ this.assertPosition(i), this.position = i;
28
+ },
29
+ getReadCount(t) {
30
+ return this.positionReadCount.get(t || this.position) || 0;
31
+ },
32
+ incrementPosition(t) {
33
+ if (t < 0)
34
+ throw new o({ offset: t });
35
+ const i = this.position + t;
36
+ this.assertPosition(i), this.position = i;
37
+ },
38
+ inspectByte(t) {
39
+ const i = t ?? this.position;
40
+ return this.assertPosition(i), this.bytes[i];
41
+ },
42
+ inspectBytes(t, i) {
43
+ const s = i ?? this.position;
44
+ return this.assertPosition(s + t - 1), this.bytes.subarray(s, s + t);
45
+ },
46
+ inspectUint8(t) {
47
+ const i = t ?? this.position;
48
+ return this.assertPosition(i), this.bytes[i];
49
+ },
50
+ inspectUint16(t) {
51
+ const i = t ?? this.position;
52
+ return this.assertPosition(i + 1), this.dataView.getUint16(i);
53
+ },
54
+ inspectUint24(t) {
55
+ const i = t ?? this.position;
56
+ return this.assertPosition(i + 2), (this.dataView.getUint16(i) << 8) + this.dataView.getUint8(i + 2);
57
+ },
58
+ inspectUint32(t) {
59
+ const i = t ?? this.position;
60
+ return this.assertPosition(i + 3), this.dataView.getUint32(i);
61
+ },
62
+ pushByte(t) {
63
+ this.assertPosition(this.position), this.bytes[this.position] = t, this.position++;
64
+ },
65
+ pushBytes(t) {
66
+ this.assertPosition(this.position + t.length - 1), this.bytes.set(t, this.position), this.position += t.length;
67
+ },
68
+ pushUint8(t) {
69
+ this.assertPosition(this.position), this.bytes[this.position] = t, this.position++;
70
+ },
71
+ pushUint16(t) {
72
+ this.assertPosition(this.position + 1), this.dataView.setUint16(this.position, t), this.position += 2;
73
+ },
74
+ pushUint24(t) {
75
+ this.assertPosition(this.position + 2), this.dataView.setUint16(this.position, t >> 8), this.dataView.setUint8(this.position + 2, t & 255), this.position += 3;
76
+ },
77
+ pushUint32(t) {
78
+ this.assertPosition(this.position + 3), this.dataView.setUint32(this.position, t), this.position += 4;
79
+ },
80
+ readByte() {
81
+ this.assertReadLimit(), this._touch();
82
+ const t = this.inspectByte();
83
+ return this.position++, t;
84
+ },
85
+ readBytes(t, i) {
86
+ this.assertReadLimit(), this._touch();
87
+ const s = this.inspectBytes(t);
88
+ return this.position += i ?? t, s;
89
+ },
90
+ readUint8() {
91
+ this.assertReadLimit(), this._touch();
92
+ const t = this.inspectUint8();
93
+ return this.position += 1, t;
94
+ },
95
+ readUint16() {
96
+ this.assertReadLimit(), this._touch();
97
+ const t = this.inspectUint16();
98
+ return this.position += 2, t;
99
+ },
100
+ readUint24() {
101
+ this.assertReadLimit(), this._touch();
102
+ const t = this.inspectUint24();
103
+ return this.position += 3, t;
104
+ },
105
+ readUint32() {
106
+ this.assertReadLimit(), this._touch();
107
+ const t = this.inspectUint32();
108
+ return this.position += 4, t;
109
+ },
110
+ get remaining() {
111
+ return this.bytes.length - this.position;
112
+ },
113
+ setPosition(t) {
114
+ const i = this.position;
115
+ return this.assertPosition(t), this.position = t, () => this.position = i;
116
+ },
117
+ _touch() {
118
+ if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
119
+ return;
120
+ const t = this.getReadCount();
121
+ this.positionReadCount.set(this.position, t + 1), t > 0 && this.recursiveReadCount++;
122
+ }
123
+ };
124
+ function a(t, { recursiveReadLimit: i = 8192 } = {}) {
125
+ const s = Object.create(h);
126
+ return s.bytes = t, s.dataView = new DataView(t.buffer, t.byteOffset, t.byteLength), s.positionReadCount = /* @__PURE__ */ new Map(), s.recursiveReadLimit = i, s;
127
+ }
128
+ export {
129
+ a as createCursor
130
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=1;exports.versionedHashVersionKzg=e;
@@ -0,0 +1,4 @@
1
+ const e = 1;
2
+ export {
3
+ e as versionedHashVersionKzg
4
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=`Ethereum Signed Message:
2
+ `;exports.presignMessagePrefix=e;
@@ -0,0 +1,5 @@
1
+ const e = `Ethereum Signed Message:
2
+ `;
3
+ export {
4
+ e as presignMessagePrefix
5
+ };
package/dist/index11.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class n{constructor(){this.listeners=new Map}emit(e,...t){(this.listeners.get(e)??[]).forEach(i=>{i(...t)})}on(e,t){const s=this.listeners.get(e)??[];s.push(t),this.listeners.set(e,s)}off(e,t){const s=this.listeners.get(e)??[],i=s.indexOf(t);i!==-1&&s.splice(i,1)}}exports.EventBroker=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index17.cjs"),o=require("./index8.cjs"),s=require("./index3.cjs");class i{constructor(e){this.token=e}async getToken(){return this.token?this.verifyToken(this.token).ok?t.Ok(this.token):t.Err("Token is invalid"):t.Err("Token is not set")}verifyToken(e){try{const r=s.parseJwt(e);if(!r)return t.Ok(!1);const n=Math.floor(Date.now()/1e3)+120;return t.Ok(r.exp>n)}catch{return t.Ok(!1)}}async getAuthHeaders(){const e=await this.getToken();return e.ok?t.Ok({[o.AuthHeaderEnum.Authorization]:e.val}):t.Err(e.error??"Failed to get auth token")}}exports.Passkey=i;
package/dist/index11.js CHANGED
@@ -1,21 +1,28 @@
1
- class r {
2
- constructor() {
3
- this.listeners = /* @__PURE__ */ new Map();
1
+ import { Err as r, Ok as e } from "./index17.js";
2
+ import { AuthHeaderEnum as s } from "./index8.js";
3
+ import { parseJwt as i } from "./index3.js";
4
+ class c {
5
+ constructor(t) {
6
+ this.token = t;
4
7
  }
5
- emit(s, ...t) {
6
- (this.listeners.get(s) ?? []).forEach((i) => {
7
- i(...t);
8
- });
8
+ async getToken() {
9
+ return this.token ? this.verifyToken(this.token).ok ? e(this.token) : r("Token is invalid") : r("Token is not set");
9
10
  }
10
- on(s, t) {
11
- const e = this.listeners.get(s) ?? [];
12
- e.push(t), this.listeners.set(s, e);
11
+ verifyToken(t) {
12
+ try {
13
+ const o = i(t);
14
+ if (!o) return e(!1);
15
+ const n = Math.floor(Date.now() / 1e3) + 120;
16
+ return e(o.exp > n);
17
+ } catch {
18
+ return e(!1);
19
+ }
13
20
  }
14
- off(s, t) {
15
- const e = this.listeners.get(s) ?? [], i = e.indexOf(t);
16
- i !== -1 && e.splice(i, 1);
21
+ async getAuthHeaders() {
22
+ const t = await this.getToken();
23
+ return t.ok ? e({ [s.Authorization]: t.val }) : r(t.error ?? "Failed to get auth token");
17
24
  }
18
25
  }
19
26
  export {
20
- r as EventBroker
27
+ c as Passkey
21
28
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./index113.cjs"),c=require("./index111.cjs");function a(o,t,s,i){if(typeof o.setBigUint64=="function")return o.setBigUint64(t,s,i);const n=BigInt(32),r=BigInt(4294967295),e=Number(s>>n&r),h=Number(s&r),u=i?4:0,l=i?0:4;o.setUint32(t+u,e,i),o.setUint32(t+l,h,i)}function d(o,t,s){return o&t^~o&s}function b(o,t,s){return o&t^o&s^t&s}class w extends c.Hash{constructor(t,s,i,n){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=c.createView(this.buffer)}update(t){p.aexists(this);const{view:s,buffer:i,blockLen:n}=this;t=c.toBytes(t);const r=t.length;for(let e=0;e<r;){const h=Math.min(n-this.pos,r-e);if(h===n){const u=c.createView(t);for(;n<=r-e;e+=n)this.process(u,e);continue}i.set(t.subarray(e,e+h),this.pos),this.pos+=h,e+=h,this.pos===n&&(this.process(s,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){p.aexists(this),p.aoutput(t,this),this.finished=!0;const{buffer:s,view:i,blockLen:n,isLE:r}=this;let{pos:e}=this;s[e++]=128,this.buffer.subarray(e).fill(0),this.padOffset>n-e&&(this.process(i,0),e=0);for(let f=e;f<n;f++)s[f]=0;a(i,n-8,BigInt(this.length*8),r),this.process(i,0);const h=c.createView(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,g=this.get();if(l>g.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)h.setUint32(4*f,g[f],r)}digest(){const{buffer:t,outputLen:s}=this;this.digestInto(t);const i=t.slice(0,s);return this.destroy(),i}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:s,buffer:i,length:n,finished:r,destroyed:e,pos:h}=this;return t.length=n,t.pos=h,t.finished=r,t.destroyed=e,n%s&&t.buffer.set(i),t}}exports.Chi=d;exports.HashMD=w;exports.Maj=b;exports.setBigUint64=a;
@@ -0,0 +1,70 @@
1
+ import { aexists as g, aoutput as d } from "./index113.js";
2
+ import { Hash as b, createView as p, toBytes as a } from "./index111.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;
63
+ }
64
+ }
65
+ export {
66
+ B as Chi,
67
+ U as HashMD,
68
+ L as Maj,
69
+ w as setBigUint64
70
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index112.cjs"),f=require("./index113.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;