@gardenfi/utils 2.1.2-beta.3 → 2.1.2-beta.4
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.
- package/dist/index103.cjs +1 -1
- package/dist/index103.js +3 -3
- package/dist/index104.cjs +1 -1
- package/dist/index104.js +2 -2
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +2 -2
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +18 -17
- package/dist/index21.cjs +16 -1
- package/dist/index21.js +112 -30
- package/dist/index22.cjs +1 -16
- package/dist/index22.js +30 -113
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +3 -3
- package/dist/index39.cjs +1 -1
- package/dist/index39.js +1 -1
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +25 -25
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +1 -1
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +4 -4
- package/dist/index73.cjs +1 -1
- package/dist/index73.js +10 -39
- package/dist/index74.cjs +1 -1
- package/dist/index74.js +17 -32
- package/dist/index75.cjs +1 -1
- package/dist/index75.js +37 -66
- package/dist/index76.cjs +1 -1
- package/dist/index76.js +34 -112
- package/dist/index77.cjs +1 -1
- package/dist/index77.js +63 -61
- package/dist/index78.cjs +1 -1
- package/dist/index78.js +113 -2
- package/dist/index79.cjs +1 -1
- package/dist/index79.js +66 -15
- package/dist/index80.cjs +1 -1
- package/dist/index80.js +2 -224
- package/dist/index81.cjs +1 -1
- package/dist/index81.js +13 -228
- package/dist/index82.cjs +1 -1
- package/dist/index82.js +218 -37
- package/dist/index83.cjs +1 -1
- package/dist/index83.js +225 -98
- package/dist/index84.cjs +1 -1
- package/dist/index84.js +8 -17
- package/dist/index85.cjs +1 -1
- package/dist/index85.js +38 -74
- package/dist/index86.cjs +1 -1
- package/dist/index86.js +104 -18
- package/dist/index87.cjs +1 -1
- package/dist/index87.js +17 -8
- package/dist/index88.cjs +1 -1
- package/dist/index88.js +77 -10
- package/dist/index89.cjs +1 -1
- package/dist/index89.js +18 -19
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +2 -2
- package/dist/index96.cjs +1 -1
- package/dist/index96.js +1 -1
- package/package.json +1 -1
package/dist/index4.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { Err as
|
|
2
|
-
import { getContract as
|
|
3
|
-
import { with0x as
|
|
1
|
+
import { Err as o, Ok as u } from "./index17.js";
|
|
2
|
+
import { getContract as m, erc20Abi as f, maxUint256 as d } from "viem";
|
|
3
|
+
import { with0x as n } from "./index3.js";
|
|
4
4
|
import { getTransactionReceipt as g } from "./index18.js";
|
|
5
|
-
const
|
|
6
|
-
if (!t.account) return
|
|
7
|
-
const c =
|
|
8
|
-
address: i
|
|
9
|
-
abi:
|
|
5
|
+
const A = async (s, i, a, t) => {
|
|
6
|
+
if (!t.account) return o("No account found");
|
|
7
|
+
const c = m({
|
|
8
|
+
address: n(i),
|
|
9
|
+
abi: f,
|
|
10
10
|
client: t
|
|
11
11
|
});
|
|
12
12
|
try {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const e = await c.read.allowance([
|
|
14
|
+
n(t.account.address),
|
|
15
|
+
n(a)
|
|
16
16
|
]);
|
|
17
|
-
if (BigInt(
|
|
17
|
+
if (BigInt(e) < BigInt(s)) {
|
|
18
18
|
const r = await c.write.approve(
|
|
19
|
-
[
|
|
19
|
+
[n(a), d],
|
|
20
20
|
{
|
|
21
21
|
account: t.account,
|
|
22
22
|
chain: t.chain
|
|
23
23
|
}
|
|
24
24
|
);
|
|
25
25
|
console.log("approval tx: ", r);
|
|
26
|
-
const p = await
|
|
27
|
-
return p.error ?
|
|
26
|
+
const p = await w(t, r);
|
|
27
|
+
return p.error ? o(p.error) : p.val.status !== "success" ? o("Failed to approve") : u(r);
|
|
28
28
|
}
|
|
29
29
|
return u("Already approved");
|
|
30
|
-
} catch (
|
|
31
|
-
return
|
|
30
|
+
} catch (e) {
|
|
31
|
+
return o("Failed to approve: " + e);
|
|
32
32
|
}
|
|
33
|
-
},
|
|
33
|
+
}, w = async (s, i, a = 2e3, t = 12e4) => {
|
|
34
34
|
const c = Math.ceil(t / a);
|
|
35
|
-
for (let
|
|
35
|
+
for (let e = 0; e < c; e++) {
|
|
36
36
|
try {
|
|
37
|
-
const r = await g(s, { hash:
|
|
37
|
+
const r = await g(s, { hash: i });
|
|
38
38
|
if (r)
|
|
39
39
|
return u(r);
|
|
40
40
|
} catch (r) {
|
|
41
|
-
if (
|
|
41
|
+
if (console.log("txReceipt err: ", r), !r.message.includes("Transaction receipt with hash")) return o(r.message);
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
e < c - 1 && await new Promise((r) => setTimeout(r, a));
|
|
44
44
|
}
|
|
45
|
-
return
|
|
45
|
+
return o(`Timed out waiting for receipt of ${i}`);
|
|
46
46
|
};
|
|
47
47
|
export {
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
A as checkAllowanceAndApprove,
|
|
49
|
+
w as waitForTransactionReceipt
|
|
50
50
|
};
|
package/dist/index41.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index86.cjs"),o=require("./index69.cjs"),i=require("./index38.cjs"),n=require("./index26.cjs");function u(e,r){const s=r||"hex",t=c.keccak_256(o.isHex(e,{strict:!1})?i.toBytes(e):e);return s==="bytes"?t:n.toHex(t)}exports.keccak256=u;
|
package/dist/index41.js
CHANGED
package/dist/index42.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("./index23.cjs"),G=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("./index23.cjs"),G=require("./index87.cjs"),R=require("./index59.cjs"),S=require("./index60.cjs"),B=require("./index61.cjs"),V=require("./index63.cjs"),L=require("./index72.cjs"),h=require("./index47.cjs"),t=require("./index26.cjs"),b=require("./index85.cjs"),z=require("./index88.cjs"),C=require("./index65.cjs"),v=require("./index89.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=G.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=R.blobsToCommitments({blobs:m,kzg:P});if(typeof f>"u"&&(f=B.commitmentsToVersionedHashes({commitments:p})),typeof u>"u"){const y=S.blobsToProofs({blobs:m,commitments:p,kzg:P});u=V.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;
|
package/dist/index42.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InvalidLegacyVError as H } from "./index23.js";
|
|
2
|
-
import { serializeAuthorizationList as g } from "./
|
|
2
|
+
import { serializeAuthorizationList as g } from "./index87.js";
|
|
3
3
|
import { blobsToCommitments as B } from "./index59.js";
|
|
4
4
|
import { blobsToProofs as V } from "./index60.js";
|
|
5
5
|
import { commitmentsToVersionedHashes as C } from "./index61.js";
|
|
@@ -7,10 +7,10 @@ import { toBlobSidecars as k } from "./index63.js";
|
|
|
7
7
|
import { concatHex as h } from "./index72.js";
|
|
8
8
|
import { trim as T } from "./index47.js";
|
|
9
9
|
import { toHex as o, bytesToHex as w } from "./index26.js";
|
|
10
|
-
import { toRlp as y } from "./
|
|
11
|
-
import { assertTransactionEIP1559 as S, assertTransactionEIP2930 as _, assertTransactionEIP4844 as R, assertTransactionEIP7702 as Y, assertTransactionLegacy as j } from "./
|
|
10
|
+
import { toRlp as y } from "./index85.js";
|
|
11
|
+
import { assertTransactionEIP1559 as S, assertTransactionEIP2930 as _, assertTransactionEIP4844 as R, assertTransactionEIP7702 as Y, assertTransactionLegacy as j } from "./index88.js";
|
|
12
12
|
import { getTransactionType as q } from "./index65.js";
|
|
13
|
-
import { serializeAccessList as v } from "./
|
|
13
|
+
import { serializeAccessList as v } from "./index89.js";
|
|
14
14
|
function te(e, r) {
|
|
15
15
|
const i = q(e);
|
|
16
16
|
return i === "eip1559" ? K(e, r) : i === "eip2930" ? M(e, r) : i === "eip4844" ? J(e, r) : i === "eip7702" ? D(e, r) : N(e, r);
|
package/dist/index73.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index48.cjs");class t extends a.BaseError{constructor(e){const{docsPath:s,field:r,metaMessages:i}=e;super(`Invalid Sign-In with Ethereum message field "${r}".`,{docsPath:s,metaMessages:i,name:"SiweInvalidMessageFieldError"})}}exports.SiweInvalidMessageFieldError=t;
|
package/dist/index73.js
CHANGED
|
@@ -1,43 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
super(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const o = this.blockLen, e = new Uint8Array(o);
|
|
11
|
-
e.set(h.length > o ? t.create().update(h).digest() : h);
|
|
12
|
-
for (let s = 0; s < e.length; s++)
|
|
13
|
-
e[s] ^= 54;
|
|
14
|
-
this.iHash.update(e), this.oHash = t.create();
|
|
15
|
-
for (let s = 0; s < e.length; s++)
|
|
16
|
-
e[s] ^= 106;
|
|
17
|
-
this.oHash.update(e), e.fill(0);
|
|
18
|
-
}
|
|
19
|
-
update(t) {
|
|
20
|
-
return a(this), this.iHash.update(t), this;
|
|
21
|
-
}
|
|
22
|
-
digestInto(t) {
|
|
23
|
-
a(this), u(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
|
|
24
|
-
}
|
|
25
|
-
digest() {
|
|
26
|
-
const t = new Uint8Array(this.oHash.outputLen);
|
|
27
|
-
return this.digestInto(t), t;
|
|
28
|
-
}
|
|
29
|
-
_cloneInto(t) {
|
|
30
|
-
t || (t = Object.create(Object.getPrototypeOf(this), {}));
|
|
31
|
-
const { oHash: i, iHash: h, finished: o, destroyed: e, blockLen: s, outputLen: d } = this;
|
|
32
|
-
return t = t, t.finished = o, t.destroyed = e, t.blockLen = s, t.outputLen = d, t.oHash = i._cloneInto(t.oHash), t.iHash = h._cloneInto(t.iHash), t;
|
|
33
|
-
}
|
|
34
|
-
destroy() {
|
|
35
|
-
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
1
|
+
import { BaseError as i } from "./index48.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
|
+
});
|
|
36
10
|
}
|
|
37
11
|
}
|
|
38
|
-
const l = (n, t, i) => new r(n, t).update(i).digest();
|
|
39
|
-
l.create = (n, t) => new r(n, t);
|
|
40
12
|
export {
|
|
41
|
-
|
|
42
|
-
l as hmac
|
|
13
|
+
d as SiweInvalidMessageFieldError
|
|
43
14
|
};
|
package/dist/index74.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
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;
|
package/dist/index74.js
CHANGED
|
@@ -1,37 +1,22 @@
|
|
|
1
|
-
function n(e) {
|
|
2
|
-
if (!Number.isSafeInteger(e) || e < 0)
|
|
3
|
-
throw new Error("positive integer expected, got " + e);
|
|
4
|
-
}
|
|
5
1
|
function o(e) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (!
|
|
10
|
-
|
|
11
|
-
if (t
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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");
|
|
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;
|
|
24
16
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
const r = t.outputLen;
|
|
28
|
-
if (e.length < r)
|
|
29
|
-
throw new Error("digestInto() expects output buffer of length at least " + r);
|
|
17
|
+
function a(e) {
|
|
18
|
+
return e.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/);
|
|
30
19
|
}
|
|
31
20
|
export {
|
|
32
|
-
|
|
33
|
-
s as aexists,
|
|
34
|
-
f as ahash,
|
|
35
|
-
n as anumber,
|
|
36
|
-
u as aoutput
|
|
21
|
+
o as isUri
|
|
37
22
|
};
|
package/dist/index75.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index76.cjs"),c=require("./index77.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;
|
package/dist/index75.js
CHANGED
|
@@ -1,72 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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;
|
|
1
|
+
import { ahash as c, aexists as a, abytes as u } from "./index76.js";
|
|
2
|
+
import { Hash as H, toBytes as p } from "./index77.js";
|
|
3
|
+
class r extends H {
|
|
4
|
+
constructor(t, i) {
|
|
5
|
+
super(), this.finished = !1, this.destroyed = !1, c(t);
|
|
6
|
+
const h = p(i);
|
|
7
|
+
if (this.iHash = t.create(), typeof this.iHash.update != "function")
|
|
8
|
+
throw new Error("Expected instance of class which extends utils.Hash");
|
|
9
|
+
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
10
|
+
const o = this.blockLen, e = new Uint8Array(o);
|
|
11
|
+
e.set(h.length > o ? t.create().update(h).digest() : h);
|
|
12
|
+
for (let s = 0; s < e.length; s++)
|
|
13
|
+
e[s] ^= 54;
|
|
14
|
+
this.iHash.update(e), this.oHash = t.create();
|
|
15
|
+
for (let s = 0; s < e.length; s++)
|
|
16
|
+
e[s] ^= 106;
|
|
17
|
+
this.oHash.update(e), e.fill(0);
|
|
34
18
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const u = t[n];
|
|
38
|
-
f.set(u, r), r += u.length;
|
|
19
|
+
update(t) {
|
|
20
|
+
return a(this), this.iHash.update(t), this;
|
|
39
21
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return this.
|
|
22
|
+
digestInto(t) {
|
|
23
|
+
a(this), u(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
|
|
24
|
+
}
|
|
25
|
+
digest() {
|
|
26
|
+
const t = new Uint8Array(this.oHash.outputLen);
|
|
27
|
+
return this.digestInto(t), t;
|
|
28
|
+
}
|
|
29
|
+
_cloneInto(t) {
|
|
30
|
+
t || (t = Object.create(Object.getPrototypeOf(this), {}));
|
|
31
|
+
const { oHash: i, iHash: h, finished: o, destroyed: e, blockLen: s, outputLen: d } = this;
|
|
32
|
+
return t = t, t.finished = o, t.destroyed = e, t.blockLen = s, t.outputLen = d, t.oHash = i._cloneInto(t.oHash), t.iHash = h._cloneInto(t.iHash), t;
|
|
33
|
+
}
|
|
34
|
+
destroy() {
|
|
35
|
+
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
46
36
|
}
|
|
47
37
|
}
|
|
48
|
-
|
|
49
|
-
|
|
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");
|
|
58
|
-
}
|
|
38
|
+
const l = (n, t, i) => new r(n, t).update(i).digest();
|
|
39
|
+
l.create = (n, t) => new r(n, t);
|
|
59
40
|
export {
|
|
60
|
-
|
|
61
|
-
|
|
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
|
|
41
|
+
r as HMAC,
|
|
42
|
+
l as hmac
|
|
72
43
|
};
|
package/dist/index76.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
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/index76.js
CHANGED
|
@@ -1,115 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
2952996808,
|
|
31
|
-
3210313671,
|
|
32
|
-
3336571891,
|
|
33
|
-
3584528711,
|
|
34
|
-
113926993,
|
|
35
|
-
338241895,
|
|
36
|
-
666307205,
|
|
37
|
-
773529912,
|
|
38
|
-
1294757372,
|
|
39
|
-
1396182291,
|
|
40
|
-
1695183700,
|
|
41
|
-
1986661051,
|
|
42
|
-
2177026350,
|
|
43
|
-
2456956037,
|
|
44
|
-
2730485921,
|
|
45
|
-
2820302411,
|
|
46
|
-
3259730800,
|
|
47
|
-
3345764771,
|
|
48
|
-
3516065817,
|
|
49
|
-
3600352804,
|
|
50
|
-
4094571909,
|
|
51
|
-
275423344,
|
|
52
|
-
430227734,
|
|
53
|
-
506948616,
|
|
54
|
-
659060556,
|
|
55
|
-
883997877,
|
|
56
|
-
958139571,
|
|
57
|
-
1322822218,
|
|
58
|
-
1537002063,
|
|
59
|
-
1747873779,
|
|
60
|
-
1955562222,
|
|
61
|
-
2024104815,
|
|
62
|
-
2227730452,
|
|
63
|
-
2361852424,
|
|
64
|
-
2428436474,
|
|
65
|
-
2756734187,
|
|
66
|
-
3204031479,
|
|
67
|
-
3329325298
|
|
68
|
-
]), b = /* @__PURE__ */ new Uint32Array([
|
|
69
|
-
1779033703,
|
|
70
|
-
3144134277,
|
|
71
|
-
1013904242,
|
|
72
|
-
2773480762,
|
|
73
|
-
1359893119,
|
|
74
|
-
2600822924,
|
|
75
|
-
528734635,
|
|
76
|
-
1541459225
|
|
77
|
-
]), h = /* @__PURE__ */ new Uint32Array(64);
|
|
78
|
-
class w extends m {
|
|
79
|
-
constructor() {
|
|
80
|
-
super(64, 32, 8, !1), this.A = b[0] | 0, this.B = b[1] | 0, this.C = b[2] | 0, this.D = b[3] | 0, this.E = b[4] | 0, this.F = b[5] | 0, this.G = b[6] | 0, this.H = b[7] | 0;
|
|
81
|
-
}
|
|
82
|
-
get() {
|
|
83
|
-
const { A: d, B: o, C: t, D: s, E: a, F: f, G: c, H: e } = this;
|
|
84
|
-
return [d, o, t, s, a, f, c, e];
|
|
85
|
-
}
|
|
86
|
-
// prettier-ignore
|
|
87
|
-
set(d, o, t, s, a, f, c, e) {
|
|
88
|
-
this.A = d | 0, this.B = o | 0, this.C = t | 0, this.D = s | 0, this.E = a | 0, this.F = f | 0, this.G = c | 0, this.H = e | 0;
|
|
89
|
-
}
|
|
90
|
-
process(d, o) {
|
|
91
|
-
for (let x = 0; x < 16; x++, o += 4)
|
|
92
|
-
h[x] = d.getUint32(o, !1);
|
|
93
|
-
for (let x = 16; x < 64; x++) {
|
|
94
|
-
const A = h[x - 15], n = h[x - 2], C = i(A, 7) ^ i(A, 18) ^ A >>> 3, H = i(n, 17) ^ i(n, 19) ^ n >>> 10;
|
|
95
|
-
h[x] = H + h[x - 7] + C + h[x - 16] | 0;
|
|
96
|
-
}
|
|
97
|
-
let { A: t, B: s, C: a, D: f, E: c, F: e, G: r, H: l } = this;
|
|
98
|
-
for (let x = 0; x < 64; x++) {
|
|
99
|
-
const A = i(c, 6) ^ i(c, 11) ^ i(c, 25), n = l + A + p(c, e, r) + g[x] + h[x] | 0, H = (i(t, 2) ^ i(t, 13) ^ i(t, 22)) + u(t, s, a) | 0;
|
|
100
|
-
l = r, r = e, e = c, c = f + n | 0, f = a, a = s, s = t, t = n + H | 0;
|
|
101
|
-
}
|
|
102
|
-
t = t + this.A | 0, s = s + this.B | 0, a = a + this.C | 0, f = f + this.D | 0, c = c + this.E | 0, e = e + this.F | 0, r = r + this.G | 0, l = l + this.H | 0, this.set(t, s, a, f, c, e, r, l);
|
|
103
|
-
}
|
|
104
|
-
roundClean() {
|
|
105
|
-
h.fill(0);
|
|
106
|
-
}
|
|
107
|
-
destroy() {
|
|
108
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
|
|
109
|
-
}
|
|
1
|
+
function n(e) {
|
|
2
|
+
if (!Number.isSafeInteger(e) || e < 0)
|
|
3
|
+
throw new Error("positive integer expected, got " + e);
|
|
4
|
+
}
|
|
5
|
+
function o(e) {
|
|
6
|
+
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
|
|
7
|
+
}
|
|
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);
|
|
13
|
+
}
|
|
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);
|
|
18
|
+
}
|
|
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);
|
|
110
30
|
}
|
|
111
|
-
const G = /* @__PURE__ */ D(() => new w());
|
|
112
31
|
export {
|
|
113
|
-
|
|
114
|
-
|
|
32
|
+
i as abytes,
|
|
33
|
+
s as aexists,
|
|
34
|
+
f as ahash,
|
|
35
|
+
n as anumber,
|
|
36
|
+
u as aoutput
|
|
115
37
|
};
|
package/dist/index77.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index80.cjs"),f=require("./index76.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;
|