@gardenfi/utils 2.4.1 → 2.4.2
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/index10.cjs +1 -1
- package/dist/index10.js +4 -4
- package/dist/index107.cjs +1 -1
- package/dist/index107.js +1 -1
- package/dist/index110.cjs +1 -1
- package/dist/index110.js +1 -1
- package/dist/index111.cjs +1 -1
- package/dist/index111.js +4 -4
- package/dist/index113.cjs +1 -1
- package/dist/index113.js +1 -1
- package/dist/index114.cjs +1 -1
- package/dist/index114.js +1 -1
- package/dist/index115.cjs +1 -1
- package/dist/index115.js +1 -1
- package/dist/index116.cjs +1 -1
- package/dist/index116.js +1 -1
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +4 -4
- package/dist/index18.cjs +1 -1
- package/dist/index18.js +2 -2
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +6 -6
- package/dist/index233.cjs +1 -1
- package/dist/index233.js +25 -10
- package/dist/index234.cjs +1 -1
- package/dist/index234.js +13 -16
- package/dist/index235.cjs +1 -1
- package/dist/index235.js +14 -21
- package/dist/index236.cjs +1 -1
- package/dist/index236.js +5 -30
- package/dist/index237.cjs +1 -1
- package/dist/index237.js +14 -2
- package/dist/index238.cjs +1 -1
- package/dist/index238.js +9 -12
- package/dist/index239.cjs +1 -1
- package/dist/index239.js +16 -12
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +31 -13
- package/dist/index240.cjs +1 -1
- package/dist/index240.js +10 -47
- package/dist/index241.cjs +1 -1
- package/dist/index241.js +15 -10
- package/dist/index242.cjs +1 -1
- package/dist/index242.js +22 -7
- package/dist/index243.cjs +1 -1
- package/dist/index243.js +30 -9
- package/dist/index244.cjs +1 -1
- package/dist/index244.js +2 -14
- package/dist/index245.cjs +1 -1
- package/dist/index245.js +13 -14
- package/dist/index246.cjs +1 -1
- package/dist/index246.js +12 -9
- package/dist/index247.cjs +1 -1
- package/dist/index247.js +47 -24
- package/dist/index248.cjs +1 -1
- package/dist/index248.js +11 -12
- package/dist/index249.cjs +1 -1
- package/dist/index249.js +7 -24
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +32 -58
- package/dist/index250.cjs +1 -1
- package/dist/index250.js +8 -12
- package/dist/index251.cjs +1 -1
- package/dist/index251.js +13 -15
- package/dist/index252.cjs +1 -2
- package/dist/index252.js +11 -21
- package/dist/index253.cjs +1 -1
- package/dist/index253.js +9 -52
- package/dist/index254.cjs +1 -1
- package/dist/index254.js +24 -25
- package/dist/index255.cjs +1 -1
- package/dist/index255.js +12 -13
- package/dist/index256.cjs +1 -1
- package/dist/index256.js +24 -15
- package/dist/index257.cjs +1 -1
- package/dist/index257.js +13 -5
- package/dist/index258.cjs +1 -1
- package/dist/index258.js +15 -13
- package/dist/index259.cjs +2 -1
- package/dist/index259.js +24 -10
- package/dist/index26.cjs +1 -16
- package/dist/index26.js +11 -113
- package/dist/index260.cjs +1 -1
- package/dist/index260.js +52 -16
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +58 -32
- package/dist/index28.cjs +1 -1
- package/dist/index28.js +12 -26
- package/dist/index280.cjs +1 -1
- package/dist/index280.js +1 -1
- package/dist/index282.cjs +1 -1
- package/dist/index282.js +1 -1
- package/dist/index287.cjs +1 -1
- package/dist/index287.js +1 -1
- package/dist/index288.cjs +1 -1
- package/dist/index288.js +139 -3
- package/dist/index289.cjs +1 -1
- package/dist/index289.js +39 -137
- package/dist/index29.cjs +16 -1
- package/dist/index29.js +113 -7
- package/dist/index290.cjs +1 -1
- package/dist/index290.js +72 -149
- package/dist/index291.cjs +1 -1
- package/dist/index291.js +2 -10
- package/dist/index292.cjs +1 -1
- package/dist/index292.js +3 -113
- package/dist/index293.cjs +1 -2
- package/dist/index293.js +128 -122
- package/dist/index294.cjs +1 -1
- package/dist/index294.js +153 -137
- package/dist/index295.cjs +1 -1
- package/dist/index295.js +9 -42
- package/dist/index296.cjs +1 -1
- package/dist/index296.js +107 -72
- package/dist/index297.cjs +2 -1
- package/dist/index297.js +135 -2
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +27 -31
- package/dist/index301.cjs +1 -1
- package/dist/index301.js +2 -2
- package/dist/index302.cjs +1 -1
- package/dist/index302.js +1 -1
- package/dist/index305.cjs +1 -1
- package/dist/index305.js +1 -1
- package/dist/index306.cjs +1 -1
- package/dist/index306.js +1 -1
- package/dist/index31.cjs +1 -1
- package/dist/index31.js +8 -12
- package/dist/index310.cjs +1 -1
- package/dist/index310.js +2 -2
- package/dist/index311.cjs +1 -1
- package/dist/index311.js +1 -1
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +1 -1
- package/dist/index39.cjs +1 -1
- package/dist/index39.js +1 -1
- package/dist/index56.cjs +1 -1
- package/dist/index56.js +2 -2
- package/dist/index57.cjs +1 -1
- package/dist/index57.js +1 -1
- package/dist/index58.cjs +1 -1
- package/dist/index58.js +2 -2
- package/dist/index59.cjs +1 -1
- package/dist/index59.js +1 -1
- package/dist/index60.cjs +1 -1
- package/dist/index60.js +2 -2
- package/dist/index61.cjs +1 -1
- package/dist/index61.js +6 -6
- package/dist/index62.cjs +1 -1
- package/dist/index62.js +2 -2
- package/dist/index63.cjs +1 -1
- package/dist/index63.js +1 -1
- package/dist/index64.cjs +1 -1
- package/dist/index64.js +1 -1
- package/dist/index65.cjs +1 -1
- package/dist/index65.js +1 -1
- package/dist/index67.cjs +1 -1
- package/dist/index67.js +4 -4
- package/dist/index76.cjs +1 -1
- package/dist/index76.js +1 -1
- package/dist/index77.cjs +1 -1
- package/dist/index77.js +1 -1
- package/dist/index82.cjs +1 -1
- package/dist/index82.js +1 -1
- package/dist/index88.cjs +1 -1
- package/dist/index88.js +3 -3
- package/dist/index89.cjs +1 -1
- package/dist/index89.js +2 -2
- package/dist/index91.cjs +1 -1
- package/dist/index91.js +1 -1
- package/dist/index92.cjs +1 -1
- package/dist/index92.js +1 -1
- package/dist/index98.cjs +1 -1
- package/dist/index98.js +1 -1
- package/package.json +1 -1
package/dist/index289.js
CHANGED
|
@@ -1,143 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}, r.onerror = () => {
|
|
18
|
-
n(!1);
|
|
19
|
-
}, r.src = t;
|
|
20
|
-
});
|
|
1
|
+
import { Hash as d, ahash as u, toBytes as H, clean as l, aexists as a, abytes as p } from "./index287.js";
|
|
2
|
+
class r extends d {
|
|
3
|
+
constructor(t, i) {
|
|
4
|
+
super(), this.finished = !1, this.destroyed = !1, u(t);
|
|
5
|
+
const h = H(i);
|
|
6
|
+
if (this.iHash = t.create(), typeof this.iHash.update != "function")
|
|
7
|
+
throw new Error("Expected instance of class which extends utils.Hash");
|
|
8
|
+
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
9
|
+
const o = this.blockLen, e = new Uint8Array(o);
|
|
10
|
+
e.set(h.length > o ? t.create().update(h).digest() : h);
|
|
11
|
+
for (let s = 0; s < e.length; s++)
|
|
12
|
+
e[s] ^= 54;
|
|
13
|
+
this.iHash.update(e), this.oHash = t.create();
|
|
14
|
+
for (let s = 0; s < e.length; s++)
|
|
15
|
+
e[s] ^= 106;
|
|
16
|
+
this.oHash.update(e), l(e);
|
|
21
17
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return t ? t.endsWith("/") ? t.slice(0, -1) : t : e;
|
|
25
|
-
}
|
|
26
|
-
function N({ uri: t, gatewayUrls: e }) {
|
|
27
|
-
const n = E.test(t);
|
|
28
|
-
if (n)
|
|
29
|
-
return { uri: t, isOnChain: !0, isEncoded: n };
|
|
30
|
-
const r = w(e == null ? void 0 : e.ipfs, "https://ipfs.io"), a = w(e == null ? void 0 : e.arweave, "https://arweave.net"), i = t.match(b), { protocol: o, subpath: p, target: s, subtarget: m = "" } = (i == null ? void 0 : i.groups) || {}, u = o === "ipns:/" || p === "ipns/", h = o === "ipfs:/" || p === "ipfs/" || l.test(t);
|
|
31
|
-
if (t.startsWith("http") && !u && !h) {
|
|
32
|
-
let I = t;
|
|
33
|
-
return e != null && e.arweave && (I = t.replace(/https:\/\/arweave.net/g, e == null ? void 0 : e.arweave)), { uri: I, isOnChain: !1, isEncoded: !1 };
|
|
18
|
+
update(t) {
|
|
19
|
+
return a(this), this.iHash.update(t), this;
|
|
34
20
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
isEncoded: !1
|
|
53
|
-
};
|
|
54
|
-
throw new d({ uri: t });
|
|
55
|
-
}
|
|
56
|
-
function R(t) {
|
|
57
|
-
if (typeof t != "object" || !("image" in t) && !("image_url" in t) && !("image_data" in t))
|
|
58
|
-
throw new A({ data: t });
|
|
59
|
-
return t.image || t.image_url || t.image_data;
|
|
60
|
-
}
|
|
61
|
-
async function O({ gatewayUrls: t, uri: e }) {
|
|
62
|
-
try {
|
|
63
|
-
const n = await fetch(e).then((a) => a.json());
|
|
64
|
-
return await _({
|
|
65
|
-
gatewayUrls: t,
|
|
66
|
-
uri: R(n)
|
|
67
|
-
});
|
|
68
|
-
} catch {
|
|
69
|
-
throw new d({ uri: e });
|
|
21
|
+
digestInto(t) {
|
|
22
|
+
a(this), p(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
|
|
23
|
+
}
|
|
24
|
+
digest() {
|
|
25
|
+
const t = new Uint8Array(this.oHash.outputLen);
|
|
26
|
+
return this.digestInto(t), t;
|
|
27
|
+
}
|
|
28
|
+
_cloneInto(t) {
|
|
29
|
+
t || (t = Object.create(Object.getPrototypeOf(this), {}));
|
|
30
|
+
const { oHash: i, iHash: h, finished: o, destroyed: e, blockLen: s, outputLen: c } = this;
|
|
31
|
+
return t = t, t.finished = o, t.destroyed = e, t.blockLen = s, t.outputLen = c, t.oHash = i._cloneInto(t.oHash), t.iHash = h._cloneInto(t.iHash), t;
|
|
32
|
+
}
|
|
33
|
+
clone() {
|
|
34
|
+
return this._cloneInto();
|
|
35
|
+
}
|
|
36
|
+
destroy() {
|
|
37
|
+
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
70
38
|
}
|
|
71
39
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (r || await k(n))
|
|
75
|
-
return n;
|
|
76
|
-
throw new d({ uri: e });
|
|
77
|
-
}
|
|
78
|
-
function z(t) {
|
|
79
|
-
let e = t;
|
|
80
|
-
e.startsWith("did:nft:") && (e = e.replace("did:nft:", "").replace(/_/g, "/"));
|
|
81
|
-
const [n, r, a] = e.split("/"), [i, o] = n.split(":"), [p, s] = r.split(":");
|
|
82
|
-
if (!i || i.toLowerCase() !== "eip155")
|
|
83
|
-
throw new f({ reason: "Only EIP-155 supported" });
|
|
84
|
-
if (!o)
|
|
85
|
-
throw new f({ reason: "Chain ID not found" });
|
|
86
|
-
if (!s)
|
|
87
|
-
throw new f({
|
|
88
|
-
reason: "Contract address not found"
|
|
89
|
-
});
|
|
90
|
-
if (!a)
|
|
91
|
-
throw new f({ reason: "Token ID not found" });
|
|
92
|
-
if (!p)
|
|
93
|
-
throw new f({ reason: "ERC namespace not found" });
|
|
94
|
-
return {
|
|
95
|
-
chainID: Number.parseInt(o),
|
|
96
|
-
namespace: p.toLowerCase(),
|
|
97
|
-
contractAddress: s,
|
|
98
|
-
tokenID: a
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
async function P(t, { nft: e }) {
|
|
102
|
-
if (e.namespace === "erc721")
|
|
103
|
-
return g(t, {
|
|
104
|
-
address: e.contractAddress,
|
|
105
|
-
abi: [
|
|
106
|
-
{
|
|
107
|
-
name: "tokenURI",
|
|
108
|
-
type: "function",
|
|
109
|
-
stateMutability: "view",
|
|
110
|
-
inputs: [{ name: "tokenId", type: "uint256" }],
|
|
111
|
-
outputs: [{ name: "", type: "string" }]
|
|
112
|
-
}
|
|
113
|
-
],
|
|
114
|
-
functionName: "tokenURI",
|
|
115
|
-
args: [BigInt(e.tokenID)]
|
|
116
|
-
});
|
|
117
|
-
if (e.namespace === "erc1155")
|
|
118
|
-
return g(t, {
|
|
119
|
-
address: e.contractAddress,
|
|
120
|
-
abi: [
|
|
121
|
-
{
|
|
122
|
-
name: "uri",
|
|
123
|
-
type: "function",
|
|
124
|
-
stateMutability: "view",
|
|
125
|
-
inputs: [{ name: "_id", type: "uint256" }],
|
|
126
|
-
outputs: [{ name: "", type: "string" }]
|
|
127
|
-
}
|
|
128
|
-
],
|
|
129
|
-
functionName: "uri",
|
|
130
|
-
args: [BigInt(e.tokenID)]
|
|
131
|
-
});
|
|
132
|
-
throw new v({ namespace: e.namespace });
|
|
133
|
-
}
|
|
40
|
+
const y = (n, t, i) => new r(n, t).update(i).digest();
|
|
41
|
+
y.create = (n, t) => new r(n, t);
|
|
134
42
|
export {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
O as getMetadataAvatarUri,
|
|
138
|
-
P as getNftTokenUri,
|
|
139
|
-
k as isImageUri,
|
|
140
|
-
_ as parseAvatarUri,
|
|
141
|
-
z as parseNftUri,
|
|
142
|
-
N as resolveAvatarUri
|
|
43
|
+
r as HMAC,
|
|
44
|
+
y as hmac
|
|
143
45
|
};
|
package/dist/index29.cjs
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=e
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index298.cjs"),M=require("./index162.cjs"),h=require("./index299.cjs");function R(r){const{chainId:o,domain:s,expirationTime:l,issuedAt:m=new Date,nonce:a,notBefore:f,requestId:w,resources:g,scheme:i,uri:c,version:d}=r;{if(o!==Math.floor(o))throw new e.SiweInvalidMessageFieldError({field:"chainId",metaMessages:["- Chain ID must be a EIP-155 chain ID.","- See https://eips.ethereum.org/EIPS/eip-155","",`Provided value: ${o}`]});if(!(E.test(s)||F.test(s)||b.test(s)))throw new e.SiweInvalidMessageFieldError({field:"domain",metaMessages:["- Domain must be an RFC 3986 authority.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${s}`]});if(!A.test(a))throw new e.SiweInvalidMessageFieldError({field:"nonce",metaMessages:["- Nonce must be at least 8 characters.","- Nonce must be alphanumeric.","",`Provided value: ${a}`]});if(!h.isUri(c))throw new e.SiweInvalidMessageFieldError({field:"uri",metaMessages:["- URI must be a RFC 3986 URI referring to the resource that is the subject of the signing.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${c}`]});if(d!=="1")throw new e.SiweInvalidMessageFieldError({field:"version",metaMessages:["- Version must be '1'.","",`Provided value: ${d}`]});if(i&&!P.test(i))throw new e.SiweInvalidMessageFieldError({field:"scheme",metaMessages:["- Scheme must be an RFC 3986 URI scheme.","- See https://www.rfc-editor.org/rfc/rfc3986#section-3.1","",`Provided value: ${i}`]});const t=r.statement;if(t!=null&&t.includes(`
|
|
2
|
+
`))throw new e.SiweInvalidMessageFieldError({field:"statement",metaMessages:["- Statement must not include '\\n'.","",`Provided value: ${t}`]})}const $=M.getAddress(r.address),v=i?`${i}://${s}`:s,I=r.statement?`${r.statement}
|
|
3
|
+
`:"",S=`${v} wants you to sign in with your Ethereum account:
|
|
4
|
+
${$}
|
|
5
|
+
|
|
6
|
+
${I}`;let n=`URI: ${c}
|
|
7
|
+
Version: ${d}
|
|
8
|
+
Chain ID: ${o}
|
|
9
|
+
Nonce: ${a}
|
|
10
|
+
Issued At: ${m.toISOString()}`;if(l&&(n+=`
|
|
11
|
+
Expiration Time: ${l.toISOString()}`),f&&(n+=`
|
|
12
|
+
Not Before: ${f.toISOString()}`),w&&(n+=`
|
|
13
|
+
Request ID: ${w}`),g){let t=`
|
|
14
|
+
Resources:`;for(const u of g){if(!h.isUri(u))throw new e.SiweInvalidMessageFieldError({field:"resources",metaMessages:["- Every resource must be a RFC 3986 URI.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${u}`]});t+=`
|
|
15
|
+
- ${u}`}n+=t}return`${S}
|
|
16
|
+
${n}`}const E=/^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?$/,F=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:[0-9]{1,5})?$/,b=/^localhost(:[0-9]{1,5})?$/,A=/^[a-zA-Z0-9]{8,}$/,P=/^([a-zA-Z][a-zA-Z0-9+-.]*)$/;exports.createSiweMessage=R;
|
package/dist/index29.js
CHANGED
|
@@ -1,10 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { SiweInvalidMessageFieldError as e } from "./index298.js";
|
|
2
|
+
import { getAddress as S } from "./index162.js";
|
|
3
|
+
import { isUri as $ } from "./index299.js";
|
|
4
|
+
function C(n) {
|
|
5
|
+
const { chainId: i, domain: s, expirationTime: u, issuedAt: g = /* @__PURE__ */ new Date(), nonce: a, notBefore: m, requestId: h, resources: w, scheme: o, uri: c, version: f } = n;
|
|
6
|
+
{
|
|
7
|
+
if (i !== Math.floor(i))
|
|
8
|
+
throw new e({
|
|
9
|
+
field: "chainId",
|
|
10
|
+
metaMessages: [
|
|
11
|
+
"- Chain ID must be a EIP-155 chain ID.",
|
|
12
|
+
"- See https://eips.ethereum.org/EIPS/eip-155",
|
|
13
|
+
"",
|
|
14
|
+
`Provided value: ${i}`
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
if (!(p.test(s) || M.test(s) || x.test(s)))
|
|
18
|
+
throw new e({
|
|
19
|
+
field: "domain",
|
|
20
|
+
metaMessages: [
|
|
21
|
+
"- Domain must be an RFC 3986 authority.",
|
|
22
|
+
"- See https://www.rfc-editor.org/rfc/rfc3986",
|
|
23
|
+
"",
|
|
24
|
+
`Provided value: ${s}`
|
|
25
|
+
]
|
|
26
|
+
});
|
|
27
|
+
if (!A.test(a))
|
|
28
|
+
throw new e({
|
|
29
|
+
field: "nonce",
|
|
30
|
+
metaMessages: [
|
|
31
|
+
"- Nonce must be at least 8 characters.",
|
|
32
|
+
"- Nonce must be alphanumeric.",
|
|
33
|
+
"",
|
|
34
|
+
`Provided value: ${a}`
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
if (!$(c))
|
|
38
|
+
throw new e({
|
|
39
|
+
field: "uri",
|
|
40
|
+
metaMessages: [
|
|
41
|
+
"- URI must be a RFC 3986 URI referring to the resource that is the subject of the signing.",
|
|
42
|
+
"- See https://www.rfc-editor.org/rfc/rfc3986",
|
|
43
|
+
"",
|
|
44
|
+
`Provided value: ${c}`
|
|
45
|
+
]
|
|
46
|
+
});
|
|
47
|
+
if (f !== "1")
|
|
48
|
+
throw new e({
|
|
49
|
+
field: "version",
|
|
50
|
+
metaMessages: [
|
|
51
|
+
"- Version must be '1'.",
|
|
52
|
+
"",
|
|
53
|
+
`Provided value: ${f}`
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
if (o && !P.test(o))
|
|
57
|
+
throw new e({
|
|
58
|
+
field: "scheme",
|
|
59
|
+
metaMessages: [
|
|
60
|
+
"- Scheme must be an RFC 3986 URI scheme.",
|
|
61
|
+
"- See https://www.rfc-editor.org/rfc/rfc3986#section-3.1",
|
|
62
|
+
"",
|
|
63
|
+
`Provided value: ${o}`
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
const t = n.statement;
|
|
67
|
+
if (t != null && t.includes(`
|
|
68
|
+
`))
|
|
69
|
+
throw new e({
|
|
70
|
+
field: "statement",
|
|
71
|
+
metaMessages: [
|
|
72
|
+
"- Statement must not include '\\n'.",
|
|
73
|
+
"",
|
|
74
|
+
`Provided value: ${t}`
|
|
75
|
+
]
|
|
76
|
+
});
|
|
6
77
|
}
|
|
7
|
-
}
|
|
78
|
+
const l = S(n.address), v = o ? `${o}://${s}` : s, I = n.statement ? `${n.statement}
|
|
79
|
+
` : "", R = `${v} wants you to sign in with your Ethereum account:
|
|
80
|
+
${l}
|
|
81
|
+
|
|
82
|
+
${I}`;
|
|
83
|
+
let r = `URI: ${c}
|
|
84
|
+
Version: ${f}
|
|
85
|
+
Chain ID: ${i}
|
|
86
|
+
Nonce: ${a}
|
|
87
|
+
Issued At: ${g.toISOString()}`;
|
|
88
|
+
if (u && (r += `
|
|
89
|
+
Expiration Time: ${u.toISOString()}`), m && (r += `
|
|
90
|
+
Not Before: ${m.toISOString()}`), h && (r += `
|
|
91
|
+
Request ID: ${h}`), w) {
|
|
92
|
+
let t = `
|
|
93
|
+
Resources:`;
|
|
94
|
+
for (const d of w) {
|
|
95
|
+
if (!$(d))
|
|
96
|
+
throw new e({
|
|
97
|
+
field: "resources",
|
|
98
|
+
metaMessages: [
|
|
99
|
+
"- Every resource must be a RFC 3986 URI.",
|
|
100
|
+
"- See https://www.rfc-editor.org/rfc/rfc3986",
|
|
101
|
+
"",
|
|
102
|
+
`Provided value: ${d}`
|
|
103
|
+
]
|
|
104
|
+
});
|
|
105
|
+
t += `
|
|
106
|
+
- ${d}`;
|
|
107
|
+
}
|
|
108
|
+
r += t;
|
|
109
|
+
}
|
|
110
|
+
return `${R}
|
|
111
|
+
${r}`;
|
|
112
|
+
}
|
|
113
|
+
const p = /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}(:[0-9]{1,5})?$/, M = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:[0-9]{1,5})?$/, x = /^localhost(:[0-9]{1,5})?$/, A = /^[a-zA-Z0-9]{8,}$/, P = /^([a-zA-Z][a-zA-Z0-9+-.]*)$/;
|
|
8
114
|
export {
|
|
9
|
-
|
|
115
|
+
C as createSiweMessage
|
|
10
116
|
};
|
package/dist/index290.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 f=require("./index287.cjs");function p(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 g(o,t,s){return o&t^~o&s}function b(o,t,s){return o&t^o&s^t&s}class d extends f.Hash{constructor(t,s,i,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=s,this.padOffset=i,this.isLE=n,this.buffer=new Uint8Array(t),this.view=f.createView(this.buffer)}update(t){f.aexists(this),t=f.toBytes(t),f.abytes(t);const{view:s,buffer:i,blockLen:n}=this,r=t.length;for(let e=0;e<r;){const h=Math.min(n-this.pos,r-e);if(h===n){const u=f.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){f.aexists(this),f.aoutput(t,this),this.finished=!0;const{buffer:s,view:i,blockLen:n,isLE:r}=this;let{pos:e}=this;s[e++]=128,f.clean(this.buffer.subarray(e)),this.padOffset>n-e&&(this.process(i,0),e=0);for(let c=e;c<n;c++)s[c]=0;p(i,n-8,BigInt(this.length*8),r),this.process(i,0);const h=f.createView(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,a=this.get();if(l>a.length)throw new Error("_sha2: outputLen bigger than state");for(let c=0;c<l;c++)h.setUint32(4*c,a[c],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.destroyed=e,t.finished=r,t.length=n,t.pos=h,n%s&&t.buffer.set(i),t}clone(){return this._cloneInto()}}const w=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);exports.Chi=g;exports.HashMD=d;exports.Maj=b;exports.SHA256_IV=w;exports.setBigUint64=p;
|
package/dist/index290.js
CHANGED
|
@@ -1,158 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return `0x${t.reduce((e, r) => e + r.replace("0x", ""), "")}`;
|
|
18
|
-
}
|
|
19
|
-
function P(t, e = {}) {
|
|
20
|
-
const r = `0x${Number(t)}`;
|
|
21
|
-
return typeof e.size == "number" ? (g(r, e.size), x(r, e.size)) : r;
|
|
22
|
-
}
|
|
23
|
-
function w(t, e = {}) {
|
|
24
|
-
let r = "";
|
|
25
|
-
for (let i = 0; i < t.length; i++)
|
|
26
|
-
r += h[t[i]];
|
|
27
|
-
const n = `0x${r}`;
|
|
28
|
-
return typeof e.size == "number" ? (g(n, e.size), E(n, e.size)) : n;
|
|
29
|
-
}
|
|
30
|
-
function V(t, e = {}) {
|
|
31
|
-
const { signed: r, size: n } = e, i = BigInt(t);
|
|
32
|
-
let s;
|
|
33
|
-
n ? r ? s = (1n << BigInt(n) * 8n - 1n) - 1n : s = 2n ** (BigInt(n) * 8n) - 1n : typeof t == "number" && (s = BigInt(Number.MAX_SAFE_INTEGER));
|
|
34
|
-
const u = typeof s == "bigint" && r ? -s - 1n : 0;
|
|
35
|
-
if (s && i > s || i < u) {
|
|
36
|
-
const a = typeof t == "bigint" ? "n" : "";
|
|
37
|
-
throw new O({
|
|
38
|
-
max: s ? `${s}${a}` : void 0,
|
|
39
|
-
min: `${u}${a}`,
|
|
40
|
-
signed: r,
|
|
41
|
-
size: n,
|
|
42
|
-
value: `${t}${a}`
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
const c = `0x${(r && i < 0 ? (1n << BigInt(n * 8)) + BigInt(i) : i).toString(16)}`;
|
|
46
|
-
return n ? x(c, n) : c;
|
|
47
|
-
}
|
|
48
|
-
function j(t, e = {}) {
|
|
49
|
-
return w($.encode(t), e);
|
|
50
|
-
}
|
|
51
|
-
function x(t, e) {
|
|
52
|
-
return d(t, { dir: "left", size: e });
|
|
53
|
-
}
|
|
54
|
-
function E(t, e) {
|
|
55
|
-
return d(t, { dir: "right", size: e });
|
|
56
|
-
}
|
|
57
|
-
function v(t, e, r, n = {}) {
|
|
58
|
-
const { strict: i } = n;
|
|
59
|
-
p(t, e);
|
|
60
|
-
const s = `0x${t.replace("0x", "").slice((e ?? 0) * 2, (r ?? t.length) * 2)}`;
|
|
61
|
-
return i && m(s, e, r), s;
|
|
62
|
-
}
|
|
63
|
-
function A(t) {
|
|
64
|
-
return Math.ceil((t.length - 2) / 2);
|
|
65
|
-
}
|
|
66
|
-
function N(t, e = {}) {
|
|
67
|
-
const { strict: r = !1 } = e;
|
|
68
|
-
try {
|
|
69
|
-
return y(t, { strict: r }), !0;
|
|
70
|
-
} catch {
|
|
71
|
-
return !1;
|
|
1
|
+
import { Hash as g, createView as l, aexists as b, toBytes as a, abytes as d, aoutput as x, clean as w } from "./index287.js";
|
|
2
|
+
function y(o, t, s, n) {
|
|
3
|
+
if (typeof o.setBigUint64 == "function")
|
|
4
|
+
return o.setBigUint64(t, s, n);
|
|
5
|
+
const i = BigInt(32), h = BigInt(4294967295), e = Number(s >> i & h), r = Number(s & h), c = n ? 4 : 0, u = n ? 0 : 4;
|
|
6
|
+
o.setUint32(t + c, e, n), o.setUint32(t + u, r, n);
|
|
7
|
+
}
|
|
8
|
+
function U(o, t, s) {
|
|
9
|
+
return o & t ^ ~o & s;
|
|
10
|
+
}
|
|
11
|
+
function _(o, t, s) {
|
|
12
|
+
return o & t ^ o & s ^ t & s;
|
|
13
|
+
}
|
|
14
|
+
class m extends g {
|
|
15
|
+
constructor(t, s, n, i) {
|
|
16
|
+
super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = t, this.outputLen = s, this.padOffset = n, this.isLE = i, this.buffer = new Uint8Array(t), this.view = l(this.buffer);
|
|
72
17
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
18
|
+
update(t) {
|
|
19
|
+
b(this), t = a(t), d(t);
|
|
20
|
+
const { view: s, buffer: n, blockLen: i } = this, h = t.length;
|
|
21
|
+
for (let e = 0; e < h; ) {
|
|
22
|
+
const r = Math.min(i - this.pos, h - e);
|
|
23
|
+
if (r === i) {
|
|
24
|
+
const c = l(t);
|
|
25
|
+
for (; i <= h - e; e += i)
|
|
26
|
+
this.process(c, e);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
n.set(t.subarray(e, e + r), this.pos), this.pos += r, e += r, this.pos === i && (this.process(s, 0), this.pos = 0);
|
|
30
|
+
}
|
|
31
|
+
return this.length += t.length, this.roundClean(), this;
|
|
82
32
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
33
|
+
digestInto(t) {
|
|
34
|
+
b(this), x(t, this), this.finished = !0;
|
|
35
|
+
const { buffer: s, view: n, blockLen: i, isLE: h } = this;
|
|
36
|
+
let { pos: e } = this;
|
|
37
|
+
s[e++] = 128, w(this.buffer.subarray(e)), this.padOffset > i - e && (this.process(n, 0), e = 0);
|
|
38
|
+
for (let f = e; f < i; f++)
|
|
39
|
+
s[f] = 0;
|
|
40
|
+
y(n, i - 8, BigInt(this.length * 8), h), this.process(n, 0);
|
|
41
|
+
const r = l(t), c = this.outputLen;
|
|
42
|
+
if (c % 4)
|
|
43
|
+
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
44
|
+
const u = c / 4, p = this.get();
|
|
45
|
+
if (u > p.length)
|
|
46
|
+
throw new Error("_sha2: outputLen bigger than state");
|
|
47
|
+
for (let f = 0; f < u; f++)
|
|
48
|
+
r.setUint32(4 * f, p[f], h);
|
|
94
49
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
'Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).'
|
|
101
|
-
]
|
|
102
|
-
}), Object.defineProperty(this, "name", {
|
|
103
|
-
enumerable: !0,
|
|
104
|
-
configurable: !0,
|
|
105
|
-
writable: !0,
|
|
106
|
-
value: "Hex.InvalidHexValueError"
|
|
107
|
-
});
|
|
50
|
+
digest() {
|
|
51
|
+
const { buffer: t, outputLen: s } = this;
|
|
52
|
+
this.digestInto(t);
|
|
53
|
+
const n = t.slice(0, s);
|
|
54
|
+
return this.destroy(), n;
|
|
108
55
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
enumerable: !0,
|
|
114
|
-
configurable: !0,
|
|
115
|
-
writable: !0,
|
|
116
|
-
value: "Hex.SizeOverflowError"
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
class M extends o {
|
|
121
|
-
constructor({ offset: e, position: r, size: n }) {
|
|
122
|
-
super(`Slice ${r === "start" ? "starting" : "ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`), Object.defineProperty(this, "name", {
|
|
123
|
-
enumerable: !0,
|
|
124
|
-
configurable: !0,
|
|
125
|
-
writable: !0,
|
|
126
|
-
value: "Hex.SliceOffsetOutOfBoundsError"
|
|
127
|
-
});
|
|
56
|
+
_cloneInto(t) {
|
|
57
|
+
t || (t = new this.constructor()), t.set(...this.get());
|
|
58
|
+
const { blockLen: s, buffer: n, length: i, finished: h, destroyed: e, pos: r } = this;
|
|
59
|
+
return t.destroyed = e, t.finished = h, t.length = i, t.pos = r, i % s && t.buffer.set(n), t;
|
|
128
60
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
constructor({ size: e, targetSize: r, type: n }) {
|
|
132
|
-
super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${r}\`).`), Object.defineProperty(this, "name", {
|
|
133
|
-
enumerable: !0,
|
|
134
|
-
configurable: !0,
|
|
135
|
-
writable: !0,
|
|
136
|
-
value: "Hex.SizeExceedsPaddingSizeError"
|
|
137
|
-
});
|
|
61
|
+
clone() {
|
|
62
|
+
return this._cloneInto();
|
|
138
63
|
}
|
|
139
64
|
}
|
|
65
|
+
const B = /* @__PURE__ */ Uint32Array.from([
|
|
66
|
+
1779033703,
|
|
67
|
+
3144134277,
|
|
68
|
+
1013904242,
|
|
69
|
+
2773480762,
|
|
70
|
+
1359893119,
|
|
71
|
+
2600822924,
|
|
72
|
+
528734635,
|
|
73
|
+
1541459225
|
|
74
|
+
]);
|
|
140
75
|
export {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
M as SliceOffsetOutOfBoundsError,
|
|
147
|
-
y as assert,
|
|
148
|
-
B as concat,
|
|
149
|
-
P as fromBoolean,
|
|
150
|
-
w as fromBytes,
|
|
151
|
-
V as fromNumber,
|
|
152
|
-
j as fromString,
|
|
153
|
-
x as padLeft,
|
|
154
|
-
E as padRight,
|
|
155
|
-
A as size,
|
|
156
|
-
v as slice,
|
|
157
|
-
N as validate
|
|
76
|
+
U as Chi,
|
|
77
|
+
m as HashMD,
|
|
78
|
+
_ as Maj,
|
|
79
|
+
B as SHA256_IV,
|
|
80
|
+
y as setBigUint64
|
|
158
81
|
};
|
package/dist/index291.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;exports.crypto=o;
|
package/dist/index291.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
function r(o) {
|
|
3
|
-
return {
|
|
4
|
-
address: o.address,
|
|
5
|
-
amount: e(o.amount),
|
|
6
|
-
index: e(o.index),
|
|
7
|
-
validatorIndex: e(o.validatorIndex)
|
|
8
|
-
};
|
|
9
|
-
}
|
|
1
|
+
const o = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
10
2
|
export {
|
|
11
|
-
|
|
3
|
+
o as crypto
|
|
12
4
|
};
|
package/dist/index292.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 t(e){return`[${e.slice(2)}]`}exports.encodeLabelhash=t;
|