@gardenfi/utils 2.0.3 → 2.0.5
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/index.cjs +1 -1
- package/dist/index.js +35 -21
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +21 -14
- package/dist/index100.cjs +1 -0
- package/dist/index100.js +9 -0
- package/dist/index101.cjs +2 -0
- package/dist/index101.js +5 -0
- package/dist/index102.cjs +1 -0
- package/dist/index102.js +115 -0
- package/dist/index103.cjs +1 -0
- package/dist/index103.js +81 -0
- package/dist/index104.cjs +1 -0
- package/dist/index104.js +4 -0
- package/dist/index105.cjs +1 -0
- package/dist/index105.js +20 -0
- package/dist/index106.cjs +1 -0
- package/dist/index106.js +21 -0
- package/dist/index107.cjs +1 -0
- package/dist/index107.js +19 -0
- package/dist/index108.cjs +1 -0
- package/dist/index108.js +226 -0
- package/dist/index109.cjs +1 -0
- package/dist/index109.js +37 -0
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +126 -173
- package/dist/index110.cjs +1 -0
- package/dist/index110.js +21 -0
- package/dist/index111.cjs +1 -0
- package/dist/index111.js +72 -0
- package/dist/index112.cjs +1 -0
- package/dist/index112.js +70 -0
- package/dist/index113.cjs +1 -0
- package/dist/index113.js +4 -0
- package/dist/index114.cjs +1 -0
- package/dist/index114.js +43 -0
- package/dist/index115.cjs +1 -0
- package/dist/index115.js +646 -0
- package/dist/index116.cjs +1 -0
- package/dist/index116.js +234 -0
- package/dist/index117.cjs +1 -0
- package/dist/index117.js +175 -0
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +14 -93
- package/dist/index13.cjs +1 -16
- package/dist/index13.js +2 -114
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +33 -31
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +19 -31
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +187 -17
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +93 -7
- package/dist/index18.cjs +1 -1
- package/dist/index18.js +35 -20
- package/dist/index19.cjs +1 -1
- package/dist/index19.js +32 -22
- package/dist/index20.cjs +16 -1
- package/dist/index20.js +113 -8
- package/dist/index21.cjs +1 -1
- package/dist/index21.js +30 -31
- package/dist/index22.cjs +1 -1
- package/dist/index22.js +17 -26
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +6 -22
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +44 -50
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +21 -12
- package/dist/index26.cjs +1 -1
- package/dist/index26.js +8 -24
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +31 -75
- package/dist/index28.cjs +1 -1
- package/dist/index28.js +25 -22
- package/dist/index29.cjs +2 -1
- package/dist/index29.js +65 -7
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +30 -7
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +51 -32
- package/dist/index31.cjs +1 -1
- package/dist/index31.js +12 -15
- package/dist/index32.cjs +1 -1
- package/dist/index32.js +25 -2
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +75 -8
- package/dist/index34.cjs +1 -1
- package/dist/index34.js +23 -20
- package/dist/index35.cjs +1 -1
- package/dist/index35.js +7 -12
- package/dist/index36.cjs +1 -1
- package/dist/index36.js +32 -34
- package/dist/index37.cjs +1 -2
- package/dist/index37.js +15 -59
- package/dist/index38.cjs +1 -1
- package/dist/index38.js +2 -2
- package/dist/index39.cjs +1 -1
- package/dist/index39.js +8 -4
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +2 -2
- package/dist/index40.cjs +1 -1
- package/dist/index40.js +20 -11
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +12 -3
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +33 -20
- package/dist/index43.cjs +2 -1
- package/dist/index43.js +58 -11
- package/dist/index44.cjs +1 -1
- package/dist/index44.js +2 -56
- package/dist/index45.cjs +1 -1
- package/dist/index45.js +6 -6
- package/dist/index46.cjs +1 -1
- package/dist/index46.js +6 -21
- package/dist/index47.cjs +1 -1
- package/dist/index47.js +4 -11
- package/dist/index48.cjs +1 -1
- package/dist/index48.js +11 -3
- package/dist/index49.cjs +5 -1
- package/dist/index49.js +53 -8
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +43 -19
- package/dist/index50.cjs +1 -1
- package/dist/index50.js +3 -19
- package/dist/index51.cjs +2 -1
- package/dist/index51.js +33 -5
- package/dist/index52.cjs +1 -1
- package/dist/index52.js +5 -8
- package/dist/index53.cjs +1 -1
- package/dist/index53.js +20 -103
- package/dist/index54.cjs +1 -1
- package/dist/index54.js +12 -28
- package/dist/index55.cjs +1 -1
- package/dist/index55.js +53 -16
- package/dist/index56.cjs +1 -1
- package/dist/index56.js +8 -38
- package/dist/index57.cjs +1 -0
- package/dist/index57.js +24 -0
- package/dist/index58.cjs +1 -0
- package/dist/index58.js +14 -0
- package/dist/index59.cjs +1 -0
- package/dist/index59.js +11 -0
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +19 -104
- package/dist/index60.cjs +1 -0
- package/dist/index60.js +13 -0
- package/dist/index61.cjs +1 -0
- package/dist/index61.js +14 -0
- package/dist/index62.cjs +1 -0
- package/dist/index62.js +9 -0
- package/dist/index63.cjs +1 -0
- package/dist/index63.js +16 -0
- package/dist/index64.cjs +1 -0
- package/dist/index64.js +35 -0
- package/dist/index65.cjs +1 -0
- package/dist/index65.js +17 -0
- package/dist/index66.cjs +1 -0
- package/dist/index66.js +67 -0
- package/dist/index67.cjs +1 -0
- package/dist/index67.js +30 -0
- package/dist/index68.cjs +1 -0
- package/dist/index68.js +5 -0
- package/dist/index69.cjs +1 -0
- package/dist/index69.js +8 -0
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +2 -15
- package/dist/index70.cjs +1 -0
- package/dist/index70.js +11 -0
- package/dist/index71.cjs +1 -0
- package/dist/index71.js +6 -0
- package/dist/index72.cjs +1 -0
- package/dist/index72.js +16 -0
- package/dist/index73.cjs +1 -0
- package/dist/index73.js +44 -0
- package/dist/index74.cjs +1 -0
- package/dist/index74.js +106 -0
- package/dist/index75.cjs +1 -0
- package/dist/index75.js +194 -0
- package/dist/index76.cjs +1 -0
- package/dist/index76.js +21 -0
- package/dist/index77.cjs +1 -0
- package/dist/index77.js +14 -0
- package/dist/index78.cjs +1 -0
- package/dist/index78.js +22 -0
- package/dist/index79.cjs +1 -0
- package/dist/index79.js +28 -0
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +100 -2
- package/dist/index80.cjs +1 -0
- package/dist/index80.js +9 -0
- package/dist/index81.cjs +1 -0
- package/dist/index81.js +16 -0
- package/dist/index82.cjs +1 -0
- package/dist/index82.js +18 -0
- package/dist/index83.cjs +1 -0
- package/dist/index83.js +8 -0
- package/dist/index84.cjs +1 -0
- package/dist/index84.js +16 -0
- package/dist/index85.cjs +1 -0
- package/dist/index85.js +13 -0
- package/dist/index86.cjs +1 -0
- package/dist/index86.js +19 -0
- package/dist/index87.cjs +1 -0
- package/dist/index87.js +174 -0
- package/dist/index88.cjs +1 -0
- package/dist/index88.js +11 -0
- package/dist/index89.cjs +1 -0
- package/dist/index89.js +15 -0
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +42 -32
- package/dist/index90.cjs +1 -0
- package/dist/index90.js +107 -0
- package/dist/index91.cjs +1 -0
- package/dist/index91.js +41 -0
- package/dist/index92.cjs +1 -0
- package/dist/index92.js +4 -0
- package/dist/index93.cjs +1 -0
- package/dist/index93.js +7 -0
- package/dist/index94.cjs +1 -0
- package/dist/index94.js +13 -0
- package/dist/index95.cjs +1 -0
- package/dist/index95.js +45 -0
- package/dist/index96.cjs +1 -0
- package/dist/index96.js +23 -0
- package/dist/index97.cjs +1 -0
- package/dist/index97.js +7 -0
- package/dist/index98.cjs +1 -0
- package/dist/index98.js +40 -0
- package/dist/index99.cjs +1 -0
- package/dist/index99.js +130 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/lib/auth/apikey/apikey.d.ts +12 -0
- package/dist/src/lib/auth/auth.types.d.ts +21 -8
- package/dist/src/lib/auth/index.d.ts +5 -1
- package/dist/src/lib/auth/passkey/passkey.d.ts +10 -0
- package/dist/src/lib/auth/passkey/passkey.types.d.ts +17 -0
- package/dist/src/lib/auth/passkey/passkeyLogin.d.ts +37 -0
- package/dist/src/lib/auth/{siwe.d.ts → siwe/siwe.d.ts} +4 -15
- package/dist/src/lib/result.d.ts +16 -0
- package/dist/src/lib/utils.d.ts +3 -0
- package/package.json +2 -1
package/dist/index74.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { encodeAbiParameters as p } from "./index75.js";
|
|
2
|
+
import { concat as h } from "./index76.js";
|
|
3
|
+
import { toHex as d } from "./index24.js";
|
|
4
|
+
import { keccak256 as c } from "./index56.js";
|
|
5
|
+
import { getTypesForEIP712Domain as T, validateTypedData as D } from "./index66.js";
|
|
6
|
+
function k(o) {
|
|
7
|
+
const { domain: t = {}, message: e, primaryType: n } = o, r = {
|
|
8
|
+
EIP712Domain: T({ domain: t }),
|
|
9
|
+
...o.types
|
|
10
|
+
};
|
|
11
|
+
D({
|
|
12
|
+
domain: t,
|
|
13
|
+
message: e,
|
|
14
|
+
primaryType: n,
|
|
15
|
+
types: r
|
|
16
|
+
});
|
|
17
|
+
const a = ["0x1901"];
|
|
18
|
+
return t && a.push(b({
|
|
19
|
+
domain: t,
|
|
20
|
+
types: r
|
|
21
|
+
})), n !== "EIP712Domain" && a.push(f({
|
|
22
|
+
data: e,
|
|
23
|
+
primaryType: n,
|
|
24
|
+
types: r
|
|
25
|
+
})), c(h(a));
|
|
26
|
+
}
|
|
27
|
+
function b({ domain: o, types: t }) {
|
|
28
|
+
return f({
|
|
29
|
+
data: o,
|
|
30
|
+
primaryType: "EIP712Domain",
|
|
31
|
+
types: t
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function f({ data: o, primaryType: t, types: e }) {
|
|
35
|
+
const n = m({
|
|
36
|
+
data: o,
|
|
37
|
+
primaryType: t,
|
|
38
|
+
types: e
|
|
39
|
+
});
|
|
40
|
+
return c(n);
|
|
41
|
+
}
|
|
42
|
+
function m({ data: o, primaryType: t, types: e }) {
|
|
43
|
+
const n = [{ type: "bytes32" }], r = [l({ primaryType: t, types: e })];
|
|
44
|
+
for (const a of e[t]) {
|
|
45
|
+
const [i, s] = y({
|
|
46
|
+
types: e,
|
|
47
|
+
name: a.name,
|
|
48
|
+
type: a.type,
|
|
49
|
+
value: o[a.name]
|
|
50
|
+
});
|
|
51
|
+
n.push(i), r.push(s);
|
|
52
|
+
}
|
|
53
|
+
return p(n, r);
|
|
54
|
+
}
|
|
55
|
+
function l({ primaryType: o, types: t }) {
|
|
56
|
+
const e = d(x({ primaryType: o, types: t }));
|
|
57
|
+
return c(e);
|
|
58
|
+
}
|
|
59
|
+
function x({ primaryType: o, types: t }) {
|
|
60
|
+
let e = "";
|
|
61
|
+
const n = u({ primaryType: o, types: t });
|
|
62
|
+
n.delete(o);
|
|
63
|
+
const r = [o, ...Array.from(n).sort()];
|
|
64
|
+
for (const a of r)
|
|
65
|
+
e += `${a}(${t[a].map(({ name: i, type: s }) => `${s} ${i}`).join(",")})`;
|
|
66
|
+
return e;
|
|
67
|
+
}
|
|
68
|
+
function u({ primaryType: o, types: t }, e = /* @__PURE__ */ new Set()) {
|
|
69
|
+
const n = o.match(/^\w*/u), r = n == null ? void 0 : n[0];
|
|
70
|
+
if (e.has(r) || t[r] === void 0)
|
|
71
|
+
return e;
|
|
72
|
+
e.add(r);
|
|
73
|
+
for (const a of t[r])
|
|
74
|
+
u({ primaryType: a.type, types: t }, e);
|
|
75
|
+
return e;
|
|
76
|
+
}
|
|
77
|
+
function y({ types: o, name: t, type: e, value: n }) {
|
|
78
|
+
if (o[e] !== void 0)
|
|
79
|
+
return [
|
|
80
|
+
{ type: "bytes32" },
|
|
81
|
+
c(m({ data: n, primaryType: e, types: o }))
|
|
82
|
+
];
|
|
83
|
+
if (e === "bytes")
|
|
84
|
+
return n = `0x${(n.length % 2 ? "0" : "") + n.slice(2)}`, [{ type: "bytes32" }, c(n)];
|
|
85
|
+
if (e === "string")
|
|
86
|
+
return [{ type: "bytes32" }, c(d(n))];
|
|
87
|
+
if (e.lastIndexOf("]") === e.length - 1) {
|
|
88
|
+
const r = e.slice(0, e.lastIndexOf("[")), a = n.map((i) => y({
|
|
89
|
+
name: t,
|
|
90
|
+
type: r,
|
|
91
|
+
types: o,
|
|
92
|
+
value: i
|
|
93
|
+
}));
|
|
94
|
+
return [
|
|
95
|
+
{ type: "bytes32" },
|
|
96
|
+
c(p(a.map(([i]) => i), a.map(([, i]) => i)))
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
return [{ type: e }, n];
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
x as encodeType,
|
|
103
|
+
b as hashDomain,
|
|
104
|
+
f as hashStruct,
|
|
105
|
+
k as hashTypedData
|
|
106
|
+
};
|
package/dist/index75.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index49.cjs"),g=require("./index54.cjs"),l=require("./index43.cjs"),b=require("./index41.cjs"),x=require("./index58.cjs"),u=require("./index76.cjs"),d=require("./index42.cjs"),y=require("./index47.cjs"),A=require("./index91.cjs"),a=require("./index24.cjs"),z=require("./index68.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/index75.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { AbiEncodingLengthMismatchError as y, InvalidAbiEncodingTypeError as u, InvalidArrayError as g, AbiEncodingArrayLengthMismatchError as l, AbiEncodingBytesSizeMismatchError as b } from "./index49.js";
|
|
2
|
+
import { InvalidAddressError as w } from "./index54.js";
|
|
3
|
+
import { BaseError as A } from "./index43.js";
|
|
4
|
+
import { IntegerOutOfRangeError as x } from "./index41.js";
|
|
5
|
+
import { isAddress as z } from "./index58.js";
|
|
6
|
+
import { concat as f } from "./index76.js";
|
|
7
|
+
import { padHex as d } from "./index42.js";
|
|
8
|
+
import { size as a } from "./index47.js";
|
|
9
|
+
import { slice as E } from "./index91.js";
|
|
10
|
+
import { numberToHex as m, boolToHex as P, stringToHex as S } from "./index24.js";
|
|
11
|
+
import { integerRegex as I } from "./index68.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"
|
|
57
|
+
});
|
|
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
|
+
}
|
|
191
|
+
export {
|
|
192
|
+
K as encodeAbiParameters,
|
|
193
|
+
W as getArrayComponents
|
|
194
|
+
};
|
package/dist/index76.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
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/index76.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
i as concat,
|
|
19
|
+
c as concatBytes,
|
|
20
|
+
f as concatHex
|
|
21
|
+
};
|
package/dist/index77.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index43.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/index77.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseError as i } from "./index43.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
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
d as SiweInvalidMessageFieldError
|
|
14
|
+
};
|
package/dist/index78.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function o(e){if(/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(e)||/%[^0-9a-f]/i.test(e)||/%[0-9a-f](:?[^0-9a-f]|$)/i.test(e))return!1;const s=a(e),f=s[1],t=s[2],i=s[3],r=s[4],l=s[5];if(!(f!=null&&f.length&&i.length>=0))return!1;if(t!=null&&t.length){if(!(i.length===0||/^\//.test(i)))return!1}else if(/^\/\//.test(i))return!1;if(!/^[a-z][a-z0-9\+\-\.]*$/.test(f.toLowerCase()))return!1;let n="";return n+=`${f}:`,t!=null&&t.length&&(n+=`//${t}`),n+=i,r!=null&&r.length&&(n+=`?${r}`),l!=null&&l.length&&(n+=`#${l}`),n}function a(e){return e.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/)}exports.isUri=o;
|
package/dist/index78.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function o(e) {
|
|
2
|
+
if (/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(e) || /%[^0-9a-f]/i.test(e) || /%[0-9a-f](:?[^0-9a-f]|$)/i.test(e))
|
|
3
|
+
return !1;
|
|
4
|
+
const s = a(e), f = s[1], t = s[2], i = s[3], r = s[4], l = s[5];
|
|
5
|
+
if (!(f != null && f.length && i.length >= 0))
|
|
6
|
+
return !1;
|
|
7
|
+
if (t != null && t.length) {
|
|
8
|
+
if (!(i.length === 0 || /^\//.test(i)))
|
|
9
|
+
return !1;
|
|
10
|
+
} else if (/^\/\//.test(i))
|
|
11
|
+
return !1;
|
|
12
|
+
if (!/^[a-z][a-z0-9\+\-\.]*$/.test(f.toLowerCase()))
|
|
13
|
+
return !1;
|
|
14
|
+
let n = "";
|
|
15
|
+
return n += `${f}:`, t != null && t.length && (n += `//${t}`), n += i, r != null && r.length && (n += `?${r}`), l != null && l.length && (n += `#${l}`), n;
|
|
16
|
+
}
|
|
17
|
+
function a(e) {
|
|
18
|
+
return e.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/);
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
o as isUri
|
|
22
|
+
};
|
package/dist/index79.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index54.cjs"),e=require("./index58.cjs");function t(s){if(typeof s=="string"){if(!e.isAddress(s,{strict:!1}))throw new n.InvalidAddressError({address:s});return{address:s,type:"json-rpc"}}if(!e.isAddress(s.address,{strict:!1}))throw new n.InvalidAddressError({address:s.address});return{address:s.address,nonceManager:s.nonceManager,sign:s.sign,experimental_signAuthorization:s.experimental_signAuthorization,signMessage:s.signMessage,signTransaction:s.signTransaction,signTypedData:s.signTypedData,source:"custom",type:"local"}}exports.toAccount=t;
|
package/dist/index79.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
e as toAccount
|
|
28
|
+
};
|
package/dist/index8.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index16.cjs"),f=require("./index12.cjs"),h=require("./index13.cjs"),d=require("viem"),o=require("./index3.cjs"),g=require("./index6.cjs"),w=require("./index18.cjs"),m=require("./index19.cjs"),y=require("./index20.cjs");class c{constructor(n,r,e){this.API=new g.Url("https://api.garden.finance"),this.url=n??this.API,this.walletClient=r,this.domain=(e==null?void 0:e.domain)||"app.garden.finance",this.domain.startsWith("https://")&&(this.domain=this.domain.split("https://")[1]),this.signingStatement=(e==null?void 0:e.signingStatement)??"Garden.fi",this.store=(e==null?void 0:e.store)??new f.MemoryStorage}static fromDigestKey(n,r){const e=d.createWalletClient({account:w.privateKeyToAccount(o.add0x(r)),transport:d.http(),chain:m.mainnet});return new c(n,e)}verifyToken(n,r){try{const e=o.parseJwt(n);if(!e)return t.Ok(!1);const i=Math.floor(Date.now()/1e3)+120;return t.Ok(e.exp>i&&e.user_id.toLowerCase()===r.toLowerCase())}catch{return t.Ok(!1)}}async getToken(){var a;if(!((a=this.walletClient.account)!=null&&a.address))return t.Err("Wallet client does not have an account");const n=this.store.getItem(h.StoreKeys.AUTH_TOKEN);if(n){const s=this.verifyToken(n,this.walletClient.account.address);if(s.ok&&s.val)return t.Ok(n)}const r=await this.signStatement();if(r.error)return t.Err(r.error);const e=await t.Fetcher.post(this.url.endpoint("verify"),{body:JSON.stringify({...r.val}),headers:{"Content-Type":"application/json"}});if(e.error)return t.Err(e.error);const i=e.result;if(!i)return t.Err("Failed to get token");if(!this.verifyToken(i,this.walletClient.account.address).val)throw new Error("Token verification failed");return this.store.setItem(h.StoreKeys.AUTH_TOKEN,i),t.Ok(i)}async signStatement(){var u;if(!((u=this.walletClient.account)!=null&&u.address))return t.Err("Wallet client does not have a valid account");const n=new Date,r=new Date(n.getTime()+300*1e3),i=(await t.Fetcher.get(this.url.endpoint("nonce"))).result;if(!i)return t.Err("Failed to get nonce");const l=await this.walletClient.getChainId(),a=y.createSiweMessage({domain:this.domain,address:this.walletClient.account.address,statement:this.signingStatement,nonce:i,uri:"https://"+this.domain,version:"1",chainId:l,notBefore:r}),s=await this.walletClient.signMessage({account:this.walletClient.account,message:a});return t.Ok({message:a,signature:s,nonce:i})}async getAuthHeaders(){const n=await this.getToken();return n.error?t.Err(n.error):t.Ok({Authorization:o.Authorization(n.val)})}}exports.Siwe=c;
|
package/dist/index8.js
CHANGED
|
@@ -1,4 +1,102 @@
|
|
|
1
|
-
|
|
1
|
+
import { Ok as r, Err as a, Fetcher as h } from "./index16.js";
|
|
2
|
+
import { MemoryStorage as u } from "./index12.js";
|
|
3
|
+
import { StoreKeys as m } from "./index13.js";
|
|
4
|
+
import { createWalletClient as f, http as w } from "viem";
|
|
5
|
+
import { add0x as g, parseJwt as p, Authorization as y } from "./index3.js";
|
|
6
|
+
import { Url as v } from "./index6.js";
|
|
7
|
+
import { privateKeyToAccount as T } from "./index18.js";
|
|
8
|
+
import { mainnet as k } from "./index19.js";
|
|
9
|
+
import { createSiweMessage as C } from "./index20.js";
|
|
10
|
+
class d {
|
|
11
|
+
constructor(e, n, t) {
|
|
12
|
+
this.API = new v("https://api.garden.finance"), this.url = e ?? this.API, this.walletClient = n, this.domain = (t == null ? void 0 : t.domain) || "app.garden.finance", this.domain.startsWith("https://") && (this.domain = this.domain.split("https://")[1]), this.signingStatement = (t == null ? void 0 : t.signingStatement) ?? "Garden.fi", this.store = (t == null ? void 0 : t.store) ?? new u();
|
|
13
|
+
}
|
|
14
|
+
static fromDigestKey(e, n) {
|
|
15
|
+
const t = f({
|
|
16
|
+
account: T(g(n)),
|
|
17
|
+
transport: w(),
|
|
18
|
+
chain: k
|
|
19
|
+
});
|
|
20
|
+
return new d(e, t);
|
|
21
|
+
}
|
|
22
|
+
verifyToken(e, n) {
|
|
23
|
+
try {
|
|
24
|
+
const t = p(e);
|
|
25
|
+
if (!t) return r(!1);
|
|
26
|
+
const i = Math.floor(Date.now() / 1e3) + 120;
|
|
27
|
+
return r(
|
|
28
|
+
t.exp > i && t.user_id.toLowerCase() === n.toLowerCase()
|
|
29
|
+
);
|
|
30
|
+
} catch {
|
|
31
|
+
return r(!1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async getToken() {
|
|
35
|
+
var o;
|
|
36
|
+
if (!((o = this.walletClient.account) != null && o.address))
|
|
37
|
+
return a("Wallet client does not have an account");
|
|
38
|
+
const e = this.store.getItem(m.AUTH_TOKEN);
|
|
39
|
+
if (e) {
|
|
40
|
+
const s = this.verifyToken(
|
|
41
|
+
e,
|
|
42
|
+
this.walletClient.account.address
|
|
43
|
+
);
|
|
44
|
+
if (s.ok && s.val) return r(e);
|
|
45
|
+
}
|
|
46
|
+
const n = await this.signStatement();
|
|
47
|
+
if (n.error)
|
|
48
|
+
return a(n.error);
|
|
49
|
+
const t = await h.post(
|
|
50
|
+
this.url.endpoint("verify"),
|
|
51
|
+
{
|
|
52
|
+
body: JSON.stringify({
|
|
53
|
+
...n.val
|
|
54
|
+
}),
|
|
55
|
+
headers: {
|
|
56
|
+
"Content-Type": "application/json"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
if (t.error) return a(t.error);
|
|
61
|
+
const i = t.result;
|
|
62
|
+
if (!i) return a("Failed to get token");
|
|
63
|
+
if (!this.verifyToken(i, this.walletClient.account.address).val)
|
|
64
|
+
throw new Error("Token verification failed");
|
|
65
|
+
return this.store.setItem(m.AUTH_TOKEN, i), r(i);
|
|
66
|
+
}
|
|
67
|
+
async signStatement() {
|
|
68
|
+
var l;
|
|
69
|
+
if (!((l = this.walletClient.account) != null && l.address))
|
|
70
|
+
return a("Wallet client does not have a valid account");
|
|
71
|
+
const e = /* @__PURE__ */ new Date(), n = new Date(e.getTime() + 300 * 1e3), i = (await h.get(
|
|
72
|
+
this.url.endpoint("nonce")
|
|
73
|
+
)).result;
|
|
74
|
+
if (!i)
|
|
75
|
+
return a("Failed to get nonce");
|
|
76
|
+
const c = await this.walletClient.getChainId(), o = C({
|
|
77
|
+
domain: this.domain,
|
|
78
|
+
address: this.walletClient.account.address,
|
|
79
|
+
statement: this.signingStatement,
|
|
80
|
+
nonce: i,
|
|
81
|
+
uri: "https://" + this.domain,
|
|
82
|
+
version: "1",
|
|
83
|
+
chainId: c,
|
|
84
|
+
notBefore: n
|
|
85
|
+
}), s = await this.walletClient.signMessage({
|
|
86
|
+
account: this.walletClient.account,
|
|
87
|
+
message: o
|
|
88
|
+
});
|
|
89
|
+
return r({
|
|
90
|
+
message: o,
|
|
91
|
+
signature: s,
|
|
92
|
+
nonce: i
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
async getAuthHeaders() {
|
|
96
|
+
const e = await this.getToken();
|
|
97
|
+
return e.error ? a(e.error) : r({ Authorization: y(e.val) });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
2
100
|
export {
|
|
3
|
-
|
|
101
|
+
d as Siwe
|
|
4
102
|
};
|
package/dist/index80.cjs
ADDED
|
@@ -0,0 +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;
|
package/dist/index80.js
ADDED
package/dist/index81.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index73.cjs"),s=require("./index24.cjs"),a=require("./index72.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;
|
package/dist/index81.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { secp256k1 as u } from "./index73.js";
|
|
2
|
+
import { numberToHex as i } from "./index24.js";
|
|
3
|
+
import { serializeSignature as a } from "./index72.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;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
y as sign
|
|
16
|
+
};
|
package/dist/index82.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index86.cjs"),c=require("./index81.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;
|
package/dist/index82.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { hashAuthorization as c } from "./index86.js";
|
|
2
|
+
import { sign as s } from "./index81.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
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
m as experimental_signAuthorization
|
|
18
|
+
};
|
package/dist/index83.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index69.cjs"),n=require("./index81.cjs");async function t({message:e,privateKey:s}){return await n.sign({hash:a.hashMessage(e),privateKey:s,to:"hex"})}exports.signMessage=t;
|
package/dist/index83.js
ADDED
package/dist/index84.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index56.cjs"),c=require("./index87.cjs"),o=require("./index81.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;
|
package/dist/index84.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { keccak256 as e } from "./index56.js";
|
|
2
|
+
import { serializeTransaction as o } from "./index87.js";
|
|
3
|
+
import { sign as c } from "./index81.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);
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
u as signTransaction
|
|
16
|
+
};
|
package/dist/index85.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index74.cjs"),s=require("./index81.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;
|
package/dist/index85.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { hashTypedData as o } from "./index74.js";
|
|
2
|
+
import { sign as r } from "./index81.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"
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
p as signTypedData
|
|
13
|
+
};
|
package/dist/index86.cjs
ADDED
|
@@ -0,0 +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;
|
package/dist/index86.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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;
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
b as hashAuthorization
|
|
19
|
+
};
|