@gardenfi/utils 2.0.6 → 2.1.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 (234) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +22 -20
  3. package/dist/index10.cjs +1 -1
  4. package/dist/index10.js +37 -19
  5. package/dist/index100.cjs +1 -1
  6. package/dist/index100.js +77 -126
  7. package/dist/index101.cjs +1 -1
  8. package/dist/index101.js +17 -111
  9. package/dist/index102.cjs +1 -1
  10. package/dist/index102.js +10 -77
  11. package/dist/index103.cjs +1 -1
  12. package/dist/index103.js +20 -2
  13. package/dist/index104.cjs +1 -1
  14. package/dist/index104.js +11 -16
  15. package/dist/index105.cjs +1 -1
  16. package/dist/index105.js +38 -18
  17. package/dist/index106.cjs +1 -1
  18. package/dist/index106.js +5 -17
  19. package/dist/index107.cjs +1 -1
  20. package/dist/index107.js +10 -223
  21. package/dist/index108.cjs +1 -2
  22. package/dist/index108.js +2 -3
  23. package/dist/index109.cjs +1 -1
  24. package/dist/index109.js +18 -32
  25. package/dist/index11.cjs +1 -1
  26. package/dist/index11.js +19 -134
  27. package/dist/index110.cjs +1 -1
  28. package/dist/index110.js +126 -17
  29. package/dist/index111.cjs +1 -1
  30. package/dist/index111.js +6 -69
  31. package/dist/index112.cjs +1 -1
  32. package/dist/index112.js +2 -68
  33. package/dist/index113.cjs +1 -1
  34. package/dist/index113.js +38 -2
  35. package/dist/index114.cjs +1 -1
  36. package/dist/index114.js +5 -41
  37. package/dist/index115.cjs +2 -1
  38. package/dist/index115.js +3 -644
  39. package/dist/index116.cjs +1 -1
  40. package/dist/index116.js +15 -228
  41. package/dist/index117.cjs +1 -1
  42. package/dist/index117.js +624 -153
  43. package/dist/index118.cjs +1 -0
  44. package/dist/index118.js +175 -0
  45. package/dist/index12.cjs +1 -1
  46. package/dist/index12.js +136 -10
  47. package/dist/index13.cjs +1 -1
  48. package/dist/index13.js +15 -2
  49. package/dist/index14.cjs +1 -1
  50. package/dist/index14.js +2 -34
  51. package/dist/index15.cjs +1 -1
  52. package/dist/index15.js +32 -17
  53. package/dist/index16.cjs +1 -1
  54. package/dist/index16.js +14 -183
  55. package/dist/index17.cjs +1 -1
  56. package/dist/index17.js +187 -92
  57. package/dist/index18.cjs +1 -1
  58. package/dist/index18.js +92 -34
  59. package/dist/index19.cjs +1 -1
  60. package/dist/index19.js +36 -32
  61. package/dist/index20.cjs +1 -16
  62. package/dist/index20.js +30 -113
  63. package/dist/index21.cjs +1 -1
  64. package/dist/index21.js +18 -17
  65. package/dist/index22.cjs +16 -1
  66. package/dist/index22.js +113 -17
  67. package/dist/index23.cjs +1 -1
  68. package/dist/index23.js +17 -7
  69. package/dist/index24.cjs +1 -1
  70. package/dist/index24.js +6 -44
  71. package/dist/index25.cjs +1 -1
  72. package/dist/index25.js +45 -21
  73. package/dist/index26.cjs +1 -1
  74. package/dist/index26.js +21 -8
  75. package/dist/index27.cjs +1 -1
  76. package/dist/index27.js +8 -31
  77. package/dist/index28.cjs +1 -1
  78. package/dist/index28.js +31 -26
  79. package/dist/index29.cjs +1 -2
  80. package/dist/index29.js +25 -64
  81. package/dist/index30.cjs +2 -1
  82. package/dist/index30.js +64 -50
  83. package/dist/index31.cjs +1 -1
  84. package/dist/index31.js +51 -12
  85. package/dist/index32.cjs +1 -1
  86. package/dist/index32.js +12 -24
  87. package/dist/index33.cjs +1 -1
  88. package/dist/index33.js +24 -75
  89. package/dist/index34.cjs +1 -1
  90. package/dist/index34.js +74 -22
  91. package/dist/index35.cjs +1 -1
  92. package/dist/index35.js +23 -7
  93. package/dist/index36.cjs +1 -1
  94. package/dist/index36.js +7 -32
  95. package/dist/index37.cjs +1 -1
  96. package/dist/index37.js +31 -14
  97. package/dist/index38.cjs +1 -1
  98. package/dist/index38.js +16 -2
  99. package/dist/index39.cjs +1 -1
  100. package/dist/index39.js +2 -9
  101. package/dist/index4.cjs +1 -1
  102. package/dist/index4.js +2 -2
  103. package/dist/index40.cjs +1 -1
  104. package/dist/index40.js +8 -20
  105. package/dist/index41.cjs +1 -1
  106. package/dist/index41.js +20 -12
  107. package/dist/index42.cjs +1 -1
  108. package/dist/index42.js +40 -33
  109. package/dist/index43.cjs +1 -2
  110. package/dist/index43.js +24 -58
  111. package/dist/index44.cjs +1 -1
  112. package/dist/index44.js +7 -2
  113. package/dist/index45.cjs +1 -1
  114. package/dist/index45.js +13 -6
  115. package/dist/index46.cjs +1 -1
  116. package/dist/index46.js +15 -6
  117. package/dist/index47.cjs +1 -1
  118. package/dist/index47.js +5 -4
  119. package/dist/index48.cjs +1 -1
  120. package/dist/index48.js +13 -11
  121. package/dist/index49.cjs +1 -5
  122. package/dist/index49.js +10 -56
  123. package/dist/index50.cjs +1 -2
  124. package/dist/index50.js +10 -32
  125. package/dist/index51.cjs +1 -1
  126. package/dist/index51.js +11 -5
  127. package/dist/index52.cjs +1 -1
  128. package/dist/index52.js +13 -3
  129. package/dist/index53.cjs +1 -1
  130. package/dist/index53.js +54 -20
  131. package/dist/index54.cjs +1 -1
  132. package/dist/index54.js +16 -12
  133. package/dist/index55.cjs +1 -1
  134. package/dist/index55.js +5 -55
  135. package/dist/index56.cjs +1 -1
  136. package/dist/index56.js +4 -4
  137. package/dist/index57.cjs +1 -1
  138. package/dist/index57.js +169 -19
  139. package/dist/index58.cjs +1 -1
  140. package/dist/index58.js +103 -11
  141. package/dist/index59.cjs +1 -1
  142. package/dist/index59.js +21 -8
  143. package/dist/index6.cjs +1 -1
  144. package/dist/index6.js +40 -22
  145. package/dist/index60.cjs +1 -1
  146. package/dist/index60.js +11 -9
  147. package/dist/index61.cjs +1 -1
  148. package/dist/index61.js +34 -11
  149. package/dist/index62.cjs +1 -1
  150. package/dist/index62.js +8 -6
  151. package/dist/index63.cjs +2 -1
  152. package/dist/index63.js +59 -13
  153. package/dist/index64.cjs +1 -1
  154. package/dist/index64.js +2 -33
  155. package/dist/index65.cjs +1 -1
  156. package/dist/index65.js +6 -14
  157. package/dist/index66.cjs +1 -1
  158. package/dist/index66.js +6 -64
  159. package/dist/index67.cjs +1 -1
  160. package/dist/index67.js +4 -27
  161. package/dist/index68.cjs +1 -1
  162. package/dist/index68.js +12 -3
  163. package/dist/index69.cjs +1 -1
  164. package/dist/index69.js +3 -3
  165. package/dist/index7.cjs +1 -1
  166. package/dist/index7.js +24 -2
  167. package/dist/index70.cjs +5 -1
  168. package/dist/index70.js +56 -13
  169. package/dist/index71.cjs +2 -1
  170. package/dist/index71.js +33 -40
  171. package/dist/index72.cjs +1 -1
  172. package/dist/index72.js +5 -5
  173. package/dist/index73.cjs +1 -1
  174. package/dist/index73.js +21 -8
  175. package/dist/index74.cjs +1 -1
  176. package/dist/index74.js +8 -103
  177. package/dist/index75.cjs +1 -1
  178. package/dist/index75.js +9 -190
  179. package/dist/index76.cjs +1 -1
  180. package/dist/index76.js +11 -18
  181. package/dist/index77.cjs +1 -1
  182. package/dist/index77.js +6 -11
  183. package/dist/index78.cjs +1 -1
  184. package/dist/index78.js +13 -19
  185. package/dist/index79.cjs +1 -1
  186. package/dist/index79.js +31 -11
  187. package/dist/index8.cjs +1 -1
  188. package/dist/index8.js +2 -100
  189. package/dist/index80.cjs +1 -1
  190. package/dist/index80.js +14 -25
  191. package/dist/index81.cjs +1 -1
  192. package/dist/index81.js +64 -6
  193. package/dist/index82.cjs +1 -1
  194. package/dist/index82.js +27 -13
  195. package/dist/index83.cjs +1 -1
  196. package/dist/index83.js +3 -16
  197. package/dist/index84.cjs +1 -1
  198. package/dist/index84.js +3 -5
  199. package/dist/index85.cjs +1 -1
  200. package/dist/index85.js +8 -13
  201. package/dist/index86.cjs +1 -1
  202. package/dist/index86.js +190 -9
  203. package/dist/index87.cjs +1 -1
  204. package/dist/index87.js +18 -16
  205. package/dist/index88.cjs +1 -1
  206. package/dist/index88.js +39 -170
  207. package/dist/index89.cjs +1 -1
  208. package/dist/index89.js +30 -34
  209. package/dist/index9.cjs +1 -1
  210. package/dist/index9.js +105 -34
  211. package/dist/index90.cjs +1 -1
  212. package/dist/index90.js +69 -8
  213. package/dist/index91.cjs +1 -1
  214. package/dist/index91.js +113 -5
  215. package/dist/index92.cjs +1 -1
  216. package/dist/index92.js +67 -10
  217. package/dist/index93.cjs +1 -1
  218. package/dist/index93.js +2 -2
  219. package/dist/index94.cjs +1 -1
  220. package/dist/index94.js +15 -103
  221. package/dist/index95.cjs +1 -1
  222. package/dist/index95.js +218 -37
  223. package/dist/index96.cjs +1 -1
  224. package/dist/index96.js +227 -16
  225. package/dist/index97.cjs +1 -1
  226. package/dist/index97.js +42 -6
  227. package/dist/index98.cjs +1 -1
  228. package/dist/index98.js +105 -5
  229. package/dist/index99.cjs +1 -1
  230. package/dist/index99.js +16 -36
  231. package/dist/src/index.d.ts +1 -0
  232. package/dist/src/lib/auth/siwe/siwe.d.ts +3 -2
  233. package/dist/src/lib/digestKey/digestKey.d.ts +12 -0
  234. package/package.json +4 -1
package/dist/index80.js CHANGED
@@ -1,28 +1,17 @@
1
- import { InvalidAddressError as s } from "./index54.js";
2
- import { isAddress as a } from "./index58.js";
3
- function e(n) {
4
- if (typeof n == "string") {
5
- if (!a(n, { strict: !1 }))
6
- throw new s({ address: n });
7
- return {
8
- address: n,
9
- type: "json-rpc"
10
- };
11
- }
12
- if (!a(n.address, { strict: !1 }))
13
- throw new s({ address: n.address });
14
- return {
15
- address: n.address,
16
- nonceManager: n.nonceManager,
17
- sign: n.sign,
18
- experimental_signAuthorization: n.experimental_signAuthorization,
19
- signMessage: n.signMessage,
20
- signTransaction: n.signTransaction,
21
- signTypedData: n.signTypedData,
22
- source: "custom",
23
- type: "local"
24
- };
1
+ import { InvalidSerializableTransactionError as f } from "./index30.js";
2
+ function d(e) {
3
+ if (e.type)
4
+ return e.type;
5
+ if (typeof e.authorizationList < "u")
6
+ return "eip7702";
7
+ if (typeof e.blobs < "u" || typeof e.blobVersionedHashes < "u" || typeof e.maxFeePerBlobGas < "u" || typeof e.sidecars < "u")
8
+ return "eip4844";
9
+ if (typeof e.maxFeePerGas < "u" || typeof e.maxPriorityFeePerGas < "u")
10
+ return "eip1559";
11
+ if (typeof e.gasPrice < "u")
12
+ return typeof e.accessList < "u" ? "eip2930" : "legacy";
13
+ throw new f({ transaction: e });
25
14
  }
26
15
  export {
27
- e as toAccount
16
+ d as getTransactionType
28
17
  };
package/dist/index81.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index53.cjs"),c=require("./index56.cjs");function t(e){const s=c.keccak256(`0x${e.substring(4)}`).substring(26);return r.checksumAddress(`0x${s}`)}exports.publicKeyToAddress=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./index70.cjs"),z=require("./index50.cjs"),o=require("./index82.cjs"),T=require("./index51.cjs"),u=require("./index67.cjs"),q=require("./index25.cjs"),g=require("./index83.cjs");function P(e){const{domain:n,message:b,primaryType:a,types:r}=e,c=(l,h)=>{for(const v of l){const{name:I,type:s}=v,t=h[I],y=s.match(g.integerRegex);if(y&&(typeof t=="number"||typeof t=="bigint")){const[w,i,D]=y;q.numberToHex(t,{signed:i==="int",size:Number.parseInt(D)/8})}if(s==="address"&&typeof t=="string"&&!T.isAddress(t))throw new z.InvalidAddressError({address:t});const f=s.match(g.bytesRegex);if(f){const[w,i]=f;if(i&&u.size(t)!==Number.parseInt(i))throw new E.BytesSizeMismatchError({expectedSize:Number.parseInt(i),givenSize:u.size(t)})}const p=r[s];p&&(x(s),c(p,t))}};if(r.EIP712Domain&&n){if(typeof n!="object")throw new o.InvalidDomainError({domain:n});c(r.EIP712Domain,n)}if(a!=="EIP712Domain")if(r[a])c(r[a],b);else throw new o.InvalidPrimaryTypeError({primaryType:a,types:r})}function d({domain:e}){return[typeof(e==null?void 0:e.name)=="string"&&{name:"name",type:"string"},(e==null?void 0:e.version)&&{name:"version",type:"string"},(typeof(e==null?void 0:e.chainId)=="number"||typeof(e==null?void 0:e.chainId)=="bigint")&&{name:"chainId",type:"uint256"},(e==null?void 0:e.verifyingContract)&&{name:"verifyingContract",type:"address"},(e==null?void 0:e.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}function x(e){if(e==="address"||e==="bool"||e==="string"||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new o.InvalidStructTypeError({type:e})}exports.getTypesForEIP712Domain=d;exports.validateTypedData=P;
package/dist/index81.js CHANGED
@@ -1,9 +1,67 @@
1
- import { checksumAddress as e } from "./index53.js";
2
- import { keccak256 as o } from "./index56.js";
3
- function d(r) {
4
- const s = o(`0x${r.substring(4)}`).substring(26);
5
- return e(`0x${s}`);
1
+ import { BytesSizeMismatchError as m } from "./index70.js";
2
+ import { InvalidAddressError as w } from "./index50.js";
3
+ import { InvalidDomainError as E, InvalidPrimaryTypeError as z, InvalidStructTypeError as D } from "./index82.js";
4
+ import { isAddress as T } from "./index51.js";
5
+ import { size as y } from "./index67.js";
6
+ import { numberToHex as x } from "./index25.js";
7
+ import { integerRegex as P, bytesRegex as S } from "./index83.js";
8
+ function j(e) {
9
+ const { domain: n, message: g, primaryType: o, types: r } = e, f = (h, b) => {
10
+ for (const u of h) {
11
+ const { name: l, type: s } = u, t = b[l], a = s.match(P);
12
+ if (a && (typeof t == "number" || typeof t == "bigint")) {
13
+ const [I, i, v] = a;
14
+ x(t, {
15
+ signed: i === "int",
16
+ size: Number.parseInt(v) / 8
17
+ });
18
+ }
19
+ if (s === "address" && typeof t == "string" && !T(t))
20
+ throw new w({ address: t });
21
+ const p = s.match(S);
22
+ if (p) {
23
+ const [I, i] = p;
24
+ if (i && y(t) !== Number.parseInt(i))
25
+ throw new m({
26
+ expectedSize: Number.parseInt(i),
27
+ givenSize: y(t)
28
+ });
29
+ }
30
+ const c = r[s];
31
+ c && (_(s), f(c, t));
32
+ }
33
+ };
34
+ if (r.EIP712Domain && n) {
35
+ if (typeof n != "object")
36
+ throw new E({ domain: n });
37
+ f(r.EIP712Domain, n);
38
+ }
39
+ if (o !== "EIP712Domain")
40
+ if (r[o])
41
+ f(r[o], g);
42
+ else
43
+ throw new z({ primaryType: o, types: r });
44
+ }
45
+ function F({ domain: e }) {
46
+ return [
47
+ typeof (e == null ? void 0 : e.name) == "string" && { name: "name", type: "string" },
48
+ (e == null ? void 0 : e.version) && { name: "version", type: "string" },
49
+ (typeof (e == null ? void 0 : e.chainId) == "number" || typeof (e == null ? void 0 : e.chainId) == "bigint") && {
50
+ name: "chainId",
51
+ type: "uint256"
52
+ },
53
+ (e == null ? void 0 : e.verifyingContract) && {
54
+ name: "verifyingContract",
55
+ type: "address"
56
+ },
57
+ (e == null ? void 0 : e.salt) && { name: "salt", type: "bytes32" }
58
+ ].filter(Boolean);
59
+ }
60
+ function _(e) {
61
+ if (e === "address" || e === "bool" || e === "string" || e.startsWith("bytes") || e.startsWith("uint") || e.startsWith("int"))
62
+ throw new D({ type: e });
6
63
  }
7
64
  export {
8
- d as publicKeyToAddress
65
+ F as getTypesForEIP712Domain,
66
+ j as validateTypedData
9
67
  };
package/dist/index82.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index71.cjs"),s=require("./index24.cjs"),a=require("./index70.cjs");let l=!1;async function g({hash:t,privateKey:i,to:e="object"}){const{r:u,s:c,recovery:r}=o.secp256k1.sign(t.slice(2),i.slice(2),{lowS:!0,extraEntropy:l}),n={r:s.numberToHex(u,{size:32}),s:s.numberToHex(c,{size:32}),v:r?28n:27n,yParity:r};return e==="bytes"||e==="hex"?a.serializeSignature({...n,to:e}):n}exports.sign=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index39.cjs"),e=require("./index63.cjs");class i extends e.BaseError{constructor({domain:r}){super(`Invalid domain "${s.stringify(r)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class o extends e.BaseError{constructor({primaryType:r,types:a}){super(`Invalid primary type \`${r}\` must be one of \`${JSON.stringify(Object.keys(a))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class n extends e.BaseError{constructor({type:r}){super(`Struct type "${r}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}exports.InvalidDomainError=i;exports.InvalidPrimaryTypeError=o;exports.InvalidStructTypeError=n;
package/dist/index82.js CHANGED
@@ -1,16 +1,30 @@
1
- import { secp256k1 as u } from "./index71.js";
2
- import { numberToHex as i } from "./index24.js";
3
- import { serializeSignature as a } from "./index70.js";
4
- let m = !1;
5
- async function y({ hash: n, privateKey: s, to: r = "object" }) {
6
- const { r: o, s: c, recovery: e } = u.sign(n.slice(2), s.slice(2), { lowS: !0, extraEntropy: m }), t = {
7
- r: i(o, { size: 32 }),
8
- s: i(c, { size: 32 }),
9
- v: e ? 28n : 27n,
10
- yParity: e
11
- };
12
- return r === "bytes" || r === "hex" ? a({ ...t, to: r }) : t;
1
+ import { stringify as a } from "./index39.js";
2
+ import { BaseError as t } from "./index63.js";
3
+ class n extends t {
4
+ constructor({ domain: r }) {
5
+ super(`Invalid domain "${a(r)}".`, {
6
+ metaMessages: ["Must be a valid EIP-712 domain."]
7
+ });
8
+ }
9
+ }
10
+ class p extends t {
11
+ constructor({ primaryType: r, types: s }) {
12
+ super(`Invalid primary type \`${r}\` must be one of \`${JSON.stringify(Object.keys(s))}\`.`, {
13
+ docsPath: "/api/glossary/Errors#typeddatainvalidprimarytypeerror",
14
+ metaMessages: ["Check that the primary type is a key in `types`."]
15
+ });
16
+ }
17
+ }
18
+ class y extends t {
19
+ constructor({ type: r }) {
20
+ super(`Struct type "${r}" is invalid.`, {
21
+ metaMessages: ["Struct type must not be a Solidity type."],
22
+ name: "InvalidStructTypeError"
23
+ });
24
+ }
13
25
  }
14
26
  export {
15
- y as sign
27
+ n as InvalidDomainError,
28
+ p as InvalidPrimaryTypeError,
29
+ y as InvalidStructTypeError
16
30
  };
package/dist/index83.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index87.cjs"),c=require("./index82.cjs");async function u(r){const{contractAddress:t,chainId:e,nonce:n,privateKey:a,to:i="object"}=r,o=await c.sign({hash:s.hashAuthorization({contractAddress:t,chainId:e,nonce:n}),privateKey:a,to:i});return i==="object"?{contractAddress:t,chainId:e,nonce:n,...o}:o}exports.experimental_signAuthorization=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,t=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;exports.bytesRegex=e;exports.integerRegex=t;
package/dist/index83.js CHANGED
@@ -1,18 +1,5 @@
1
- import { hashAuthorization as c } from "./index87.js";
2
- import { sign as s } from "./index82.js";
3
- async function m(e) {
4
- const { contractAddress: t, chainId: n, nonce: o, privateKey: a, to: r = "object" } = e, i = await s({
5
- hash: c({ contractAddress: t, chainId: n, nonce: o }),
6
- privateKey: a,
7
- to: r
8
- });
9
- return r === "object" ? {
10
- contractAddress: t,
11
- chainId: n,
12
- nonce: o,
13
- ...i
14
- } : i;
15
- }
1
+ const e = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/, t = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
16
2
  export {
17
- m as experimental_signAuthorization
3
+ e as bytesRegex,
4
+ t as integerRegex
18
5
  };
package/dist/index84.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index72.cjs"),n=require("./index82.cjs");async function t({message:e,privateKey:s}){return await n.sign({hash:a.hashMessage(e),privateKey:s,to:"hex"})}exports.signMessage=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function r(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}exports.isHex=r;
package/dist/index84.js CHANGED
@@ -1,8 +1,6 @@
1
- import { hashMessage as e } from "./index72.js";
2
- import { sign as o } from "./index82.js";
3
- async function i({ message: s, privateKey: a }) {
4
- return await o({ hash: e(s), privateKey: a, to: "hex" });
1
+ function e(t, { strict: r = !0 } = {}) {
2
+ return !t || typeof t != "string" ? !1 : r ? /^0x[0-9a-fA-F]*$/.test(t) : t.startsWith("0x");
5
3
  }
6
4
  export {
7
- i as signMessage
5
+ e as isHex
8
6
  };
package/dist/index85.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index56.cjs"),c=require("./index88.cjs"),o=require("./index82.cjs");async function u(i){const{privateKey:r,transaction:e,serializer:n=c.serializeTransaction}=i,a=e.type==="eip4844"?{...e,sidecars:!1}:e,s=await o.sign({hash:t.keccak256(n(a)),privateKey:r});return n(e,s)}exports.signTransaction=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index115.cjs"),o=require("./index87.cjs"),s=require("./index67.cjs"),r=require("./index25.cjs");function c(e){const t=typeof e=="string"?r.stringToHex(e):typeof e.raw=="string"?e.raw:r.bytesToHex(e.raw),i=r.stringToHex(`${n.presignMessagePrefix}${s.size(t)}`);return o.concat([i,t])}exports.toPrefixedMessage=c;
package/dist/index85.js CHANGED
@@ -1,16 +1,11 @@
1
- import { keccak256 as e } from "./index56.js";
2
- import { serializeTransaction as o } from "./index88.js";
3
- import { sign as c } from "./index82.js";
4
- async function u(n) {
5
- const { privateKey: a, transaction: r, serializer: i = o } = n, t = r.type === "eip4844" ? {
6
- ...r,
7
- sidecars: !1
8
- } : r, s = await c({
9
- hash: e(i(t)),
10
- privateKey: a
11
- });
12
- return i(r, s);
1
+ import { presignMessagePrefix as e } from "./index115.js";
2
+ import { concat as n } from "./index87.js";
3
+ import { size as f } from "./index67.js";
4
+ import { stringToHex as o, bytesToHex as p } from "./index25.js";
5
+ function u(r) {
6
+ const t = typeof r == "string" ? o(r) : typeof r.raw == "string" ? r.raw : p(r.raw), i = o(`${e}${f(t)}`);
7
+ return n([i, t]);
13
8
  }
14
9
  export {
15
- u as signTransaction
10
+ u as toPrefixedMessage
16
11
  };
package/dist/index86.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index74.cjs"),s=require("./index82.cjs");async function i(e){const{privateKey:t,...a}=e;return await s.sign({hash:n.hashTypedData(a),privateKey:t,to:"hex"})}exports.signTypedData=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index70.cjs"),g=require("./index50.cjs"),l=require("./index63.cjs"),b=require("./index60.cjs"),x=require("./index51.cjs"),u=require("./index87.cjs"),d=require("./index61.cjs"),y=require("./index67.cjs"),A=require("./index105.cjs"),a=require("./index25.cjs"),z=require("./index83.cjs");function w(e,n){if(e.length!==n.length)throw new f.AbiEncodingLengthMismatchError({expectedLength:e.length,givenLength:n.length});const o=H({params:e,values:n}),t=p(o);return t.length===0?"0x":t}function H({params:e,values:n}){const o=[];for(let t=0;t<e.length;t++)o.push(h({param:e[t],value:n[t]}));return o}function h({param:e,value:n}){const o=m(e.type);if(o){const[t,r]=o;return P(n,{length:t,param:{...e,type:r}})}if(e.type==="tuple")return L(n,{param:e});if(e.type==="address")return E(n);if(e.type==="bool")return q(n);if(e.type.startsWith("uint")||e.type.startsWith("int")){const t=e.type.startsWith("int"),[,,r="256"]=z.integerRegex.exec(e.type)??[];return T(n,{signed:t,size:Number(r)})}if(e.type.startsWith("bytes"))return S(n,{param:e});if(e.type==="string")return I(n);throw new f.InvalidAbiEncodingTypeError(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function p(e){let n=0;for(let i=0;i<e.length;i++){const{dynamic:c,encoded:s}=e[i];c?n+=32:n+=y.size(s)}const o=[],t=[];let r=0;for(let i=0;i<e.length;i++){const{dynamic:c,encoded:s}=e[i];c?(o.push(a.numberToHex(n+r,{size:32})),t.push(s),r+=y.size(s)):o.push(s)}return u.concat([...o,...t])}function E(e){if(!x.isAddress(e))throw new g.InvalidAddressError({address:e});return{dynamic:!1,encoded:d.padHex(e.toLowerCase())}}function P(e,{length:n,param:o}){const t=n===null;if(!Array.isArray(e))throw new f.InvalidArrayError(e);if(!t&&e.length!==n)throw new f.AbiEncodingArrayLengthMismatchError({expectedLength:n,givenLength:e.length,type:`${o.type}[${n}]`});let r=!1;const i=[];for(let c=0;c<e.length;c++){const s=h({param:o,value:e[c]});s.dynamic&&(r=!0),i.push(s)}if(t||r){const c=p(i);if(t){const s=a.numberToHex(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?u.concat([s,c]):s}}if(r)return{dynamic:!0,encoded:c}}return{dynamic:!1,encoded:u.concat(i.map(({encoded:c})=>c))}}function S(e,{param:n}){const[,o]=n.type.split("bytes"),t=y.size(e);if(!o){let r=e;return t%32!==0&&(r=d.padHex(r,{dir:"right",size:Math.ceil((e.length-2)/2/32)*32})),{dynamic:!0,encoded:u.concat([d.padHex(a.numberToHex(t,{size:32})),r])}}if(t!==Number.parseInt(o))throw new f.AbiEncodingBytesSizeMismatchError({expectedSize:Number.parseInt(o),value:e});return{dynamic:!1,encoded:d.padHex(e,{dir:"right"})}}function q(e){if(typeof e!="boolean")throw new l.BaseError(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:d.padHex(a.boolToHex(e))}}function T(e,{signed:n,size:o=256}){if(typeof o=="number"){const t=2n**(BigInt(o)-(n?1n:0n))-1n,r=n?-t-1n:0n;if(e>t||e<r)throw new b.IntegerOutOfRangeError({max:t.toString(),min:r.toString(),signed:n,size:o/8,value:e.toString()})}return{dynamic:!1,encoded:a.numberToHex(e,{size:32,signed:n})}}function I(e){const n=a.stringToHex(e),o=Math.ceil(y.size(n)/32),t=[];for(let r=0;r<o;r++)t.push(d.padHex(A.slice(n,r*32,(r+1)*32),{dir:"right"}));return{dynamic:!0,encoded:u.concat([d.padHex(a.numberToHex(y.size(n),{size:32})),...t])}}function L(e,{param:n}){let o=!1;const t=[];for(let r=0;r<n.components.length;r++){const i=n.components[r],c=Array.isArray(e)?r:i.name,s=h({param:i,value:e[c]});t.push(s),s.dynamic&&(o=!0)}return{dynamic:o,encoded:o?p(t):u.concat(t.map(({encoded:r})=>r))}}function m(e){const n=e.match(/^(.*)\[(\d+)?\]$/);return n?[n[2]?Number(n[2]):null,n[1]]:void 0}exports.encodeAbiParameters=w;exports.getArrayComponents=m;
package/dist/index86.js CHANGED
@@ -1,13 +1,194 @@
1
- import { hashTypedData as o } from "./index74.js";
2
- import { sign as r } from "./index82.js";
3
- async function p(t) {
4
- const { privateKey: a, ...e } = t;
5
- return await r({
6
- hash: o(e),
7
- privateKey: a,
8
- to: "hex"
1
+ import { AbiEncodingLengthMismatchError as y, InvalidAbiEncodingTypeError as u, InvalidArrayError as g, AbiEncodingArrayLengthMismatchError as l, AbiEncodingBytesSizeMismatchError as b } from "./index70.js";
2
+ import { InvalidAddressError as w } from "./index50.js";
3
+ import { BaseError as A } from "./index63.js";
4
+ import { IntegerOutOfRangeError as x } from "./index60.js";
5
+ import { isAddress as z } from "./index51.js";
6
+ import { concat as f } from "./index87.js";
7
+ import { padHex as d } from "./index61.js";
8
+ import { size as a } from "./index67.js";
9
+ import { slice as E } from "./index105.js";
10
+ import { numberToHex as m, boolToHex as P, stringToHex as S } from "./index25.js";
11
+ import { integerRegex as I } from "./index83.js";
12
+ function K(e, t) {
13
+ if (e.length !== t.length)
14
+ throw new y({
15
+ expectedLength: e.length,
16
+ givenLength: t.length
17
+ });
18
+ const o = L({
19
+ params: e,
20
+ values: t
21
+ }), n = h(o);
22
+ return n.length === 0 ? "0x" : n;
23
+ }
24
+ function L({ params: e, values: t }) {
25
+ const o = [];
26
+ for (let n = 0; n < e.length; n++)
27
+ o.push(p({ param: e[n], value: t[n] }));
28
+ return o;
29
+ }
30
+ function p({ param: e, value: t }) {
31
+ const o = W(e.type);
32
+ if (o) {
33
+ const [n, r] = o;
34
+ return M(t, { length: n, param: { ...e, type: r } });
35
+ }
36
+ if (e.type === "tuple")
37
+ return H(t, {
38
+ param: e
39
+ });
40
+ if (e.type === "address")
41
+ return B(t);
42
+ if (e.type === "bool")
43
+ return T(t);
44
+ if (e.type.startsWith("uint") || e.type.startsWith("int")) {
45
+ const n = e.type.startsWith("int"), [, , r = "256"] = I.exec(e.type) ?? [];
46
+ return $(t, {
47
+ signed: n,
48
+ size: Number(r)
49
+ });
50
+ }
51
+ if (e.type.startsWith("bytes"))
52
+ return N(t, { param: e });
53
+ if (e.type === "string")
54
+ return C(t);
55
+ throw new u(e.type, {
56
+ docsPath: "/docs/contract/encodeAbiParameters"
9
57
  });
10
58
  }
59
+ function h(e) {
60
+ let t = 0;
61
+ for (let i = 0; i < e.length; i++) {
62
+ const { dynamic: c, encoded: s } = e[i];
63
+ c ? t += 32 : t += a(s);
64
+ }
65
+ const o = [], n = [];
66
+ let r = 0;
67
+ for (let i = 0; i < e.length; i++) {
68
+ const { dynamic: c, encoded: s } = e[i];
69
+ c ? (o.push(m(t + r, { size: 32 })), n.push(s), r += a(s)) : o.push(s);
70
+ }
71
+ return f([...o, ...n]);
72
+ }
73
+ function B(e) {
74
+ if (!z(e))
75
+ throw new w({ address: e });
76
+ return { dynamic: !1, encoded: d(e.toLowerCase()) };
77
+ }
78
+ function M(e, { length: t, param: o }) {
79
+ const n = t === null;
80
+ if (!Array.isArray(e))
81
+ throw new g(e);
82
+ if (!n && e.length !== t)
83
+ throw new l({
84
+ expectedLength: t,
85
+ givenLength: e.length,
86
+ type: `${o.type}[${t}]`
87
+ });
88
+ let r = !1;
89
+ const i = [];
90
+ for (let c = 0; c < e.length; c++) {
91
+ const s = p({ param: o, value: e[c] });
92
+ s.dynamic && (r = !0), i.push(s);
93
+ }
94
+ if (n || r) {
95
+ const c = h(i);
96
+ if (n) {
97
+ const s = m(i.length, { size: 32 });
98
+ return {
99
+ dynamic: !0,
100
+ encoded: i.length > 0 ? f([s, c]) : s
101
+ };
102
+ }
103
+ if (r)
104
+ return { dynamic: !0, encoded: c };
105
+ }
106
+ return {
107
+ dynamic: !1,
108
+ encoded: f(i.map(({ encoded: c }) => c))
109
+ };
110
+ }
111
+ function N(e, { param: t }) {
112
+ const [, o] = t.type.split("bytes"), n = a(e);
113
+ if (!o) {
114
+ let r = e;
115
+ return n % 32 !== 0 && (r = d(r, {
116
+ dir: "right",
117
+ size: Math.ceil((e.length - 2) / 2 / 32) * 32
118
+ })), {
119
+ dynamic: !0,
120
+ encoded: f([d(m(n, { size: 32 })), r])
121
+ };
122
+ }
123
+ if (n !== Number.parseInt(o))
124
+ throw new b({
125
+ expectedSize: Number.parseInt(o),
126
+ value: e
127
+ });
128
+ return { dynamic: !1, encoded: d(e, { dir: "right" }) };
129
+ }
130
+ function T(e) {
131
+ if (typeof e != "boolean")
132
+ throw new A(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);
133
+ return { dynamic: !1, encoded: d(P(e)) };
134
+ }
135
+ function $(e, { signed: t, size: o = 256 }) {
136
+ if (typeof o == "number") {
137
+ const n = 2n ** (BigInt(o) - (t ? 1n : 0n)) - 1n, r = t ? -n - 1n : 0n;
138
+ if (e > n || e < r)
139
+ throw new x({
140
+ max: n.toString(),
141
+ min: r.toString(),
142
+ signed: t,
143
+ size: o / 8,
144
+ value: e.toString()
145
+ });
146
+ }
147
+ return {
148
+ dynamic: !1,
149
+ encoded: m(e, {
150
+ size: 32,
151
+ signed: t
152
+ })
153
+ };
154
+ }
155
+ function C(e) {
156
+ const t = S(e), o = Math.ceil(a(t) / 32), n = [];
157
+ for (let r = 0; r < o; r++)
158
+ n.push(d(E(t, r * 32, (r + 1) * 32), {
159
+ dir: "right"
160
+ }));
161
+ return {
162
+ dynamic: !0,
163
+ encoded: f([
164
+ d(m(a(t), { size: 32 })),
165
+ ...n
166
+ ])
167
+ };
168
+ }
169
+ function H(e, { param: t }) {
170
+ let o = !1;
171
+ const n = [];
172
+ for (let r = 0; r < t.components.length; r++) {
173
+ const i = t.components[r], c = Array.isArray(e) ? r : i.name, s = p({
174
+ param: i,
175
+ value: e[c]
176
+ });
177
+ n.push(s), s.dynamic && (o = !0);
178
+ }
179
+ return {
180
+ dynamic: o,
181
+ encoded: o ? h(n) : f(n.map(({ encoded: r }) => r))
182
+ };
183
+ }
184
+ function W(e) {
185
+ const t = e.match(/^(.*)\[(\d+)?\]$/);
186
+ return t ? (
187
+ // Return `null` if the array is dynamic.
188
+ [t[2] ? Number(t[2]) : null, t[1]]
189
+ ) : void 0;
190
+ }
11
191
  export {
12
- p as signTypedData
192
+ K as encodeAbiParameters,
193
+ W as getArrayComponents
13
194
  };
package/dist/index87.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index76.cjs"),u=require("./index55.cjs"),r=require("./index24.cjs"),a=require("./index95.cjs"),h=require("./index56.cjs");function x(n){const{chainId:e,contractAddress:c,nonce:t,to:s}=n,o=h.keccak256(i.concatHex(["0x05",a.toRlp([e?r.numberToHex(e):"0x",c,t?r.numberToHex(t):"0x"])]));return s==="bytes"?u.hexToBytes(o):o}exports.hashAuthorization=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function a(t){return typeof t[0]=="string"?f(t):o(t)}function o(t){let n=0;for(const r of t)n+=r.length;const e=new Uint8Array(n);let c=0;for(const r of t)e.set(r,c),c+=r.length;return e}function f(t){return`0x${t.reduce((n,e)=>n+e.replace("0x",""),"")}`}exports.concat=a;exports.concatBytes=o;exports.concatHex=f;
package/dist/index87.js CHANGED
@@ -1,19 +1,21 @@
1
- import { concatHex as i } from "./index76.js";
2
- import { hexToBytes as s } from "./index55.js";
3
- import { numberToHex as n } from "./index24.js";
4
- import { toRlp as a } from "./index95.js";
5
- import { keccak256 as f } from "./index56.js";
6
- function b(e) {
7
- const { chainId: o, contractAddress: c, nonce: t, to: m } = e, r = f(i([
8
- "0x05",
9
- a([
10
- o ? n(o) : "0x",
11
- c,
12
- t ? n(t) : "0x"
13
- ])
14
- ]));
15
- return m === "bytes" ? s(r) : r;
1
+ function i(t) {
2
+ return typeof t[0] == "string" ? f(t) : c(t);
3
+ }
4
+ function c(t) {
5
+ let n = 0;
6
+ for (const e of t)
7
+ n += e.length;
8
+ const r = new Uint8Array(n);
9
+ let o = 0;
10
+ for (const e of t)
11
+ r.set(e, o), o += e.length;
12
+ return r;
13
+ }
14
+ function f(t) {
15
+ return `0x${t.reduce((n, r) => n + r.replace("0x", ""), "")}`;
16
16
  }
17
17
  export {
18
- b as hashAuthorization
18
+ i as concat,
19
+ c as concatBytes,
20
+ f as concatHex
19
21
  };
package/dist/index88.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("./index29.cjs"),G=require("./index59.cjs"),R=require("./index60.cjs"),S=require("./index61.cjs"),B=require("./index63.cjs"),L=require("./index76.cjs"),h=require("./index46.cjs"),t=require("./index24.cjs"),b=require("./index95.cjs"),V=require("./index104.cjs"),z=require("./index102.cjs"),C=require("./index65.cjs"),v=require("./index105.cjs");function k(e,o){const s=C.getTransactionType(e);return s==="eip1559"?_(e,o):s==="eip2930"?j(e,o):s==="eip4844"?Y(e,o):s==="eip7702"?w(e,o):M(e,o)}function w(e,o){const{authorizationList:s,chainId:i,gas:r,nonce:c,to:a,value:x,maxFeePerGas:l,maxPriorityFeePerGas:n,accessList:H,data:d}=e;z.assertTransactionEIP7702(e);const f=v.serializeAccessList(H),u=V.serializeAuthorizationList(s);return L.concatHex(["0x04",b.toRlp([t.toHex(i),c?t.toHex(c):"0x",n?t.toHex(n):"0x",l?t.toHex(l):"0x",r?t.toHex(r):"0x",a??"0x",x?t.toHex(x):"0x",d??"0x",f,u,...T(e,o)])])}function Y(e,o){const{chainId:s,gas:i,nonce:r,to:c,value:a,maxFeePerBlobGas:x,maxFeePerGas:l,maxPriorityFeePerGas:n,accessList:H,data:d}=e;z.assertTransactionEIP4844(e);let f=e.blobVersionedHashes,u=e.sidecars;if(e.blobs&&(typeof f>"u"||typeof u>"u")){const m=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(y=>t.bytesToHex(y)),P=e.kzg,p=G.blobsToCommitments({blobs:m,kzg:P});if(typeof f>"u"&&(f=S.commitmentsToVersionedHashes({commitments:p})),typeof u>"u"){const y=R.blobsToProofs({blobs:m,commitments:p,kzg:P});u=B.toBlobSidecars({blobs:m,commitments:p,proofs:y})}}const I=v.serializeAccessList(H),A=[t.toHex(s),r?t.toHex(r):"0x",n?t.toHex(n):"0x",l?t.toHex(l):"0x",i?t.toHex(i):"0x",c??"0x",a?t.toHex(a):"0x",d??"0x",I,x?t.toHex(x):"0x",f??[],...T(e,o)],q=[],g=[],E=[];if(u)for(let m=0;m<u.length;m++){const{blob:P,commitment:p,proof:y}=u[m];q.push(P),g.push(p),E.push(y)}return L.concatHex(["0x03",u?b.toRlp([A,q,g,E]):b.toRlp(A)])}function _(e,o){const{chainId:s,gas:i,nonce:r,to:c,value:a,maxFeePerGas:x,maxPriorityFeePerGas:l,accessList:n,data:H}=e;z.assertTransactionEIP1559(e);const d=v.serializeAccessList(n),f=[t.toHex(s),r?t.toHex(r):"0x",l?t.toHex(l):"0x",x?t.toHex(x):"0x",i?t.toHex(i):"0x",c??"0x",a?t.toHex(a):"0x",H??"0x",d,...T(e,o)];return L.concatHex(["0x02",b.toRlp(f)])}function j(e,o){const{chainId:s,gas:i,data:r,nonce:c,to:a,value:x,accessList:l,gasPrice:n}=e;z.assertTransactionEIP2930(e);const H=v.serializeAccessList(l),d=[t.toHex(s),c?t.toHex(c):"0x",n?t.toHex(n):"0x",i?t.toHex(i):"0x",a??"0x",x?t.toHex(x):"0x",r??"0x",H,...T(e,o)];return L.concatHex(["0x01",b.toRlp(d)])}function M(e,o){const{chainId:s=0,gas:i,data:r,nonce:c,to:a,value:x,gasPrice:l}=e;z.assertTransactionLegacy(e);let n=[c?t.toHex(c):"0x",l?t.toHex(l):"0x",i?t.toHex(i):"0x",a??"0x",x?t.toHex(x):"0x",r??"0x"];if(o){const H=(()=>{if(o.v>=35n)return(o.v-35n)/2n>0?o.v:27n+(o.v===35n?0n:1n);if(s>0)return BigInt(s*2)+BigInt(35n+o.v-27n);const u=27n+(o.v===27n?0n:1n);if(o.v!==u)throw new F.InvalidLegacyVError({v:o.v});return u})(),d=h.trim(o.r),f=h.trim(o.s);n=[...n,t.toHex(H),d==="0x00"?"0x":d,f==="0x00"?"0x":f]}else s>0&&(n=[...n,t.toHex(s),"0x","0x"]);return b.toRlp(n)}function T(e,o){const s=o??e,{v:i,yParity:r}=s;if(typeof s.r>"u")return[];if(typeof s.s>"u")return[];if(typeof i>"u"&&typeof r>"u")return[];const c=h.trim(s.r),a=h.trim(s.s);return[typeof r=="number"?r?t.toHex(1):"0x":i===0n?"0x":i===1n?t.toHex(1):i===27n?"0x":t.toHex(1),c==="0x00"?"0x":c,a==="0x00"?"0x":a]}exports.serializeTransaction=k;exports.toYParitySignatureArray=T;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index89.cjs"),c=require("./index90.cjs");class r extends c.Hash{constructor(t,i){super(),this.finished=!1,this.destroyed=!1,o.ahash(t);const h=c.toBytes(i);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const a=this.blockLen,e=new Uint8Array(a);e.set(h.length>a?t.create().update(h).digest():h);for(let s=0;s<e.length;s++)e[s]^=54;this.iHash.update(e),this.oHash=t.create();for(let s=0;s<e.length;s++)e[s]^=106;this.oHash.update(e),e.fill(0)}update(t){return o.aexists(this),this.iHash.update(t),this}digestInto(t){o.aexists(this),o.abytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:i,iHash:h,finished:a,destroyed:e,blockLen:s,outputLen:u}=this;return t=t,t.finished=a,t.destroyed=e,t.blockLen=s,t.outputLen=u,t.oHash=i._cloneInto(t.oHash),t.iHash=h._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const d=(n,t,i)=>new r(n,t).update(i).digest();d.create=(n,t)=>new r(n,t);exports.HMAC=r;exports.hmac=d;