@gardenfi/utils 2.0.4 → 2.0.6-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +35 -24
  3. package/dist/index10.cjs +1 -1
  4. package/dist/index10.js +42 -32
  5. package/dist/index100.cjs +1 -0
  6. package/dist/index100.js +7 -0
  7. package/dist/index101.cjs +1 -0
  8. package/dist/index101.js +13 -0
  9. package/dist/index102.cjs +1 -0
  10. package/dist/index102.js +4 -0
  11. package/dist/index103.cjs +1 -0
  12. package/dist/index103.js +23 -0
  13. package/dist/index104.cjs +1 -0
  14. package/dist/index104.js +9 -0
  15. package/dist/index105.cjs +1 -0
  16. package/dist/index105.js +7 -0
  17. package/dist/index106.cjs +1 -0
  18. package/dist/index106.js +40 -0
  19. package/dist/index107.cjs +1 -0
  20. package/dist/index107.js +130 -0
  21. package/dist/index108.cjs +1 -0
  22. package/dist/index108.js +4 -0
  23. package/dist/index109.cjs +2 -0
  24. package/dist/index109.js +5 -0
  25. package/dist/index11.cjs +1 -1
  26. package/dist/index11.js +21 -14
  27. package/dist/index110.cjs +1 -0
  28. package/dist/index110.js +70 -0
  29. package/dist/index111.cjs +1 -0
  30. package/dist/index111.js +72 -0
  31. package/dist/index112.cjs +1 -0
  32. package/dist/index112.js +4 -0
  33. package/dist/index113.cjs +1 -0
  34. package/dist/index113.js +37 -0
  35. package/dist/index114.cjs +1 -0
  36. package/dist/index114.js +43 -0
  37. package/dist/index115.cjs +1 -0
  38. package/dist/index115.js +646 -0
  39. package/dist/index116.cjs +1 -0
  40. package/dist/index116.js +234 -0
  41. package/dist/index117.cjs +1 -0
  42. package/dist/index117.js +175 -0
  43. package/dist/index118.cjs +1 -0
  44. package/dist/index118.js +21 -0
  45. package/dist/index12.cjs +1 -1
  46. package/dist/index12.js +126 -173
  47. package/dist/index13.cjs +1 -1
  48. package/dist/index13.js +14 -93
  49. package/dist/index14.cjs +1 -16
  50. package/dist/index14.js +2 -114
  51. package/dist/index15.cjs +1 -1
  52. package/dist/index15.js +33 -31
  53. package/dist/index16.cjs +1 -1
  54. package/dist/index16.js +19 -31
  55. package/dist/index17.cjs +1 -1
  56. package/dist/index17.js +188 -17
  57. package/dist/index18.cjs +1 -1
  58. package/dist/index18.js +93 -7
  59. package/dist/index19.cjs +1 -1
  60. package/dist/index19.js +35 -20
  61. package/dist/index20.cjs +1 -1
  62. package/dist/index20.js +32 -22
  63. package/dist/index21.cjs +16 -1
  64. package/dist/index21.js +113 -8
  65. package/dist/index22.cjs +1 -1
  66. package/dist/index22.js +30 -31
  67. package/dist/index23.cjs +1 -1
  68. package/dist/index23.js +17 -26
  69. package/dist/index24.cjs +1 -1
  70. package/dist/index24.js +6 -22
  71. package/dist/index25.cjs +1 -1
  72. package/dist/index25.js +44 -50
  73. package/dist/index26.cjs +1 -1
  74. package/dist/index26.js +21 -12
  75. package/dist/index27.cjs +1 -1
  76. package/dist/index27.js +8 -24
  77. package/dist/index28.cjs +1 -1
  78. package/dist/index28.js +31 -75
  79. package/dist/index29.cjs +1 -1
  80. package/dist/index29.js +25 -22
  81. package/dist/index3.cjs +1 -1
  82. package/dist/index3.js +30 -7
  83. package/dist/index30.cjs +2 -1
  84. package/dist/index30.js +65 -7
  85. package/dist/index31.cjs +1 -1
  86. package/dist/index31.js +51 -32
  87. package/dist/index32.cjs +1 -1
  88. package/dist/index32.js +12 -15
  89. package/dist/index33.cjs +1 -1
  90. package/dist/index33.js +25 -2
  91. package/dist/index34.cjs +1 -1
  92. package/dist/index34.js +75 -8
  93. package/dist/index35.cjs +1 -1
  94. package/dist/index35.js +23 -20
  95. package/dist/index36.cjs +1 -1
  96. package/dist/index36.js +7 -12
  97. package/dist/index37.cjs +1 -1
  98. package/dist/index37.js +32 -34
  99. package/dist/index38.cjs +1 -2
  100. package/dist/index38.js +15 -59
  101. package/dist/index39.cjs +1 -1
  102. package/dist/index39.js +2 -2
  103. package/dist/index4.cjs +1 -1
  104. package/dist/index4.js +2 -2
  105. package/dist/index40.cjs +1 -1
  106. package/dist/index40.js +8 -4
  107. package/dist/index41.cjs +1 -1
  108. package/dist/index41.js +20 -11
  109. package/dist/index42.cjs +1 -1
  110. package/dist/index42.js +41 -3
  111. package/dist/index43.cjs +1 -1
  112. package/dist/index43.js +25 -21
  113. package/dist/index44.cjs +1 -1
  114. package/dist/index44.js +6 -12
  115. package/dist/index45.cjs +1 -1
  116. package/dist/index45.js +13 -55
  117. package/dist/index46.cjs +1 -1
  118. package/dist/index46.js +15 -6
  119. package/dist/index47.cjs +1 -1
  120. package/dist/index47.js +5 -21
  121. package/dist/index48.cjs +1 -1
  122. package/dist/index48.js +13 -11
  123. package/dist/index49.cjs +1 -1
  124. package/dist/index49.js +10 -3
  125. package/dist/index50.cjs +1 -1
  126. package/dist/index50.js +10 -9
  127. package/dist/index51.cjs +1 -1
  128. package/dist/index51.js +11 -19
  129. package/dist/index52.cjs +1 -1
  130. package/dist/index52.js +13 -6
  131. package/dist/index53.cjs +1 -1
  132. package/dist/index53.js +55 -8
  133. package/dist/index54.cjs +1 -1
  134. package/dist/index54.js +16 -104
  135. package/dist/index55.cjs +1 -1
  136. package/dist/index55.js +5 -28
  137. package/dist/index56.cjs +1 -1
  138. package/dist/index56.js +8 -18
  139. package/dist/index57.cjs +1 -1
  140. package/dist/index57.js +165 -32
  141. package/dist/index58.cjs +1 -0
  142. package/dist/index58.js +106 -0
  143. package/dist/index59.cjs +1 -0
  144. package/dist/index59.js +24 -0
  145. package/dist/index6.cjs +1 -1
  146. package/dist/index6.js +40 -22
  147. package/dist/index60.cjs +1 -0
  148. package/dist/index60.js +15 -0
  149. package/dist/index61.cjs +1 -0
  150. package/dist/index61.js +37 -0
  151. package/dist/index62.cjs +1 -0
  152. package/dist/index62.js +9 -0
  153. package/dist/index63.cjs +2 -0
  154. package/dist/index63.js +62 -0
  155. package/dist/index64.cjs +1 -0
  156. package/dist/index64.js +4 -0
  157. package/dist/index65.cjs +1 -0
  158. package/dist/index65.js +9 -0
  159. package/dist/index66.cjs +1 -0
  160. package/dist/index66.js +7 -0
  161. package/dist/index67.cjs +1 -0
  162. package/dist/index67.js +14 -0
  163. package/dist/index68.cjs +5 -0
  164. package/dist/index68.js +59 -0
  165. package/dist/index69.cjs +2 -0
  166. package/dist/index69.js +37 -0
  167. package/dist/index7.cjs +1 -1
  168. package/dist/index7.js +19 -104
  169. package/dist/index70.cjs +1 -0
  170. package/dist/index70.js +8 -0
  171. package/dist/index71.cjs +1 -0
  172. package/dist/index71.js +6 -0
  173. package/dist/index72.cjs +1 -0
  174. package/dist/index72.js +24 -0
  175. package/dist/index73.cjs +1 -0
  176. package/dist/index73.js +11 -0
  177. package/dist/index74.cjs +1 -0
  178. package/dist/index74.js +13 -0
  179. package/dist/index75.cjs +1 -0
  180. package/dist/index75.js +14 -0
  181. package/dist/index76.cjs +1 -0
  182. package/dist/index76.js +9 -0
  183. package/dist/index77.cjs +1 -0
  184. package/dist/index77.js +16 -0
  185. package/dist/index78.cjs +1 -0
  186. package/dist/index78.js +35 -0
  187. package/dist/index79.cjs +1 -0
  188. package/dist/index79.js +17 -0
  189. package/dist/index8.cjs +1 -1
  190. package/dist/index8.js +2 -15
  191. package/dist/index80.cjs +1 -0
  192. package/dist/index80.js +67 -0
  193. package/dist/index81.cjs +1 -0
  194. package/dist/index81.js +30 -0
  195. package/dist/index82.cjs +1 -0
  196. package/dist/index82.js +5 -0
  197. package/dist/index83.cjs +1 -0
  198. package/dist/index83.js +6 -0
  199. package/dist/index84.cjs +1 -0
  200. package/dist/index84.js +11 -0
  201. package/dist/index85.cjs +1 -0
  202. package/dist/index85.js +194 -0
  203. package/dist/index86.cjs +1 -0
  204. package/dist/index86.js +21 -0
  205. package/dist/index87.cjs +1 -0
  206. package/dist/index87.js +115 -0
  207. package/dist/index88.cjs +1 -0
  208. package/dist/index88.js +19 -0
  209. package/dist/index89.cjs +1 -0
  210. package/dist/index89.js +226 -0
  211. package/dist/index9.cjs +1 -1
  212. package/dist/index9.js +100 -2
  213. package/dist/index90.cjs +1 -0
  214. package/dist/index90.js +45 -0
  215. package/dist/index91.cjs +1 -0
  216. package/dist/index91.js +107 -0
  217. package/dist/index92.cjs +1 -0
  218. package/dist/index92.js +20 -0
  219. package/dist/index93.cjs +1 -0
  220. package/dist/index93.js +81 -0
  221. package/dist/index94.cjs +1 -0
  222. package/dist/index94.js +21 -0
  223. package/dist/index95.cjs +1 -0
  224. package/dist/index95.js +11 -0
  225. package/dist/index96.cjs +1 -0
  226. package/dist/index96.js +14 -0
  227. package/dist/index97.cjs +1 -0
  228. package/dist/index97.js +22 -0
  229. package/dist/index98.cjs +1 -0
  230. package/dist/index98.js +15 -0
  231. package/dist/index99.cjs +1 -0
  232. package/dist/index99.js +41 -0
  233. package/dist/src/index.d.ts +1 -0
  234. package/dist/src/lib/auth/apikey/apikey.d.ts +12 -0
  235. package/dist/src/lib/auth/auth.types.d.ts +21 -8
  236. package/dist/src/lib/auth/index.d.ts +5 -1
  237. package/dist/src/lib/auth/passkey/passkey.d.ts +10 -0
  238. package/dist/src/lib/auth/passkey/passkey.types.d.ts +17 -0
  239. package/dist/src/lib/auth/passkey/passkeyLogin.d.ts +37 -0
  240. package/dist/src/lib/auth/{siwe.d.ts → siwe/siwe.d.ts} +5 -15
  241. package/dist/src/lib/digestKey/digestKey.d.ts +12 -0
  242. package/dist/src/lib/utils.d.ts +3 -0
  243. package/package.json +3 -1
package/dist/index9.js CHANGED
@@ -1,4 +1,102 @@
1
- var t = /* @__PURE__ */ ((r) => (r.AUTH_TOKEN = "auth_token", r))(t || {});
1
+ import { Ok as r, Err as a, Fetcher as h } from "./index17.js";
2
+ import { MemoryStorage as u } from "./index13.js";
3
+ import { StoreKeys as d } from "./index14.js";
4
+ import { createWalletClient as f, http as w } from "viem";
5
+ import { add0x as g, parseJwt as y, Authorization as p } from "./index3.js";
6
+ import { Url as v } from "./index7.js";
7
+ import { privateKeyToAccount as T } from "./index19.js";
8
+ import { mainnet as k } from "./index20.js";
9
+ import { createSiweMessage as C } from "./index21.js";
10
+ class m {
11
+ constructor(e, i, t) {
12
+ this.API = new v("https://api.garden.finance"), this.url = e ?? this.API, this.walletClient = i, 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, i, t) {
15
+ const n = f({
16
+ account: T(g(i.digestKey)),
17
+ transport: w(),
18
+ chain: k
19
+ });
20
+ return new m(e, n, t);
21
+ }
22
+ verifyToken(e, i) {
23
+ try {
24
+ const t = y(e);
25
+ if (!t) return r(!1);
26
+ const n = Math.floor(Date.now() / 1e3) + 120;
27
+ return r(
28
+ t.exp > n && t.user_id.toLowerCase() === i.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(d.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 i = await this.signStatement();
47
+ if (i.error)
48
+ return a(i.error);
49
+ const t = await h.post(
50
+ this.url.endpoint("verify"),
51
+ {
52
+ body: JSON.stringify({
53
+ ...i.val
54
+ }),
55
+ headers: {
56
+ "Content-Type": "application/json"
57
+ }
58
+ }
59
+ );
60
+ if (t.error) return a(t.error);
61
+ const n = t.result;
62
+ if (!n) return a("Failed to get token");
63
+ if (!this.verifyToken(n, this.walletClient.account.address).val)
64
+ throw new Error("Token verification failed");
65
+ return this.store.setItem(d.AUTH_TOKEN, n), r(n);
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(), i = new Date(e.getTime() + 300 * 1e3), n = (await h.get(
72
+ this.url.endpoint("nonce")
73
+ )).result;
74
+ if (!n)
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: n,
81
+ uri: "https://" + this.domain,
82
+ version: "1",
83
+ chainId: c,
84
+ notBefore: i
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: n
93
+ });
94
+ }
95
+ async getAuthHeaders() {
96
+ const e = await this.getToken();
97
+ return e.error ? a(e.error) : r({ Authorization: p(e.val) });
98
+ }
99
+ }
2
100
  export {
3
- t as StoreKeys
101
+ m as Siwe
4
102
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index63.cjs"),u=require("./index107.cjs"),f=require("./index53.cjs"),g=require("./index25.cjs");function c(n,e="hex"){const i=o(n),s=u.createCursor(new Uint8Array(i.length));return i.encode(s),e==="hex"?g.bytesToHex(s.bytes):s.bytes}function o(n){return Array.isArray(n)?p(n.map(e=>o(e))):y(n)}function p(n){const e=n.reduce((t,h)=>t+h.length,0),i=l(e);return{length:e<=55?1+e:1+i+e,encode(t){e<=55?t.pushByte(192+e):(t.pushByte(247+i),i===1?t.pushUint8(e):i===2?t.pushUint16(e):i===3?t.pushUint24(e):t.pushUint32(e));for(const{encode:h}of n)h(t)}}}function y(n){const e=typeof n=="string"?f.hexToBytes(n):n,i=l(e.length);return{length:e.length===1&&e[0]<128?1:e.length<=55?1+e.length:1+i+e.length,encode(t){e.length===1&&e[0]<128?t.pushBytes(e):e.length<=55?(t.pushByte(128+e.length),t.pushBytes(e)):(t.pushByte(183+i),i===1?t.pushUint8(e.length):i===2?t.pushUint16(e.length):i===3?t.pushUint24(e.length):t.pushUint32(e.length),t.pushBytes(e))}}}function l(n){if(n<2**8)return 1;if(n<2**16)return 2;if(n<2**24)return 3;if(n<2**32)return 4;throw new r.BaseError("Length is too large.")}exports.toRlp=c;
@@ -0,0 +1,45 @@
1
+ import { BaseError as l } from "./index63.js";
2
+ import { createCursor as r } from "./index107.js";
3
+ import { hexToBytes as g } from "./index53.js";
4
+ import { bytesToHex as u } from "./index25.js";
5
+ function m(n, e = "hex") {
6
+ const i = s(n), h = r(new Uint8Array(i.length));
7
+ return i.encode(h), e === "hex" ? u(h.bytes) : h.bytes;
8
+ }
9
+ function s(n) {
10
+ return Array.isArray(n) ? p(n.map((e) => s(e))) : y(n);
11
+ }
12
+ function p(n) {
13
+ const e = n.reduce((t, f) => t + f.length, 0), i = o(e);
14
+ return {
15
+ length: e <= 55 ? 1 + e : 1 + i + e,
16
+ encode(t) {
17
+ e <= 55 ? t.pushByte(192 + e) : (t.pushByte(247 + i), i === 1 ? t.pushUint8(e) : i === 2 ? t.pushUint16(e) : i === 3 ? t.pushUint24(e) : t.pushUint32(e));
18
+ for (const { encode: f } of n)
19
+ f(t);
20
+ }
21
+ };
22
+ }
23
+ function y(n) {
24
+ const e = typeof n == "string" ? g(n) : n, i = o(e.length);
25
+ return {
26
+ length: e.length === 1 && e[0] < 128 ? 1 : e.length <= 55 ? 1 + e.length : 1 + i + e.length,
27
+ encode(t) {
28
+ e.length === 1 && e[0] < 128 ? t.pushBytes(e) : e.length <= 55 ? (t.pushByte(128 + e.length), t.pushBytes(e)) : (t.pushByte(183 + i), i === 1 ? t.pushUint8(e.length) : i === 2 ? t.pushUint16(e.length) : i === 3 ? t.pushUint24(e.length) : t.pushUint32(e.length), t.pushBytes(e));
29
+ }
30
+ };
31
+ }
32
+ function o(n) {
33
+ if (n < 2 ** 8)
34
+ return 1;
35
+ if (n < 2 ** 16)
36
+ return 2;
37
+ if (n < 2 ** 24)
38
+ return 3;
39
+ if (n < 2 ** 32)
40
+ return 4;
41
+ throw new l("Length is too large.");
42
+ }
43
+ export {
44
+ m as toRlp
45
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index113.cjs"),f=require("./index118.cjs"),c=require("./index111.cjs"),I=[],O=[],w=[],B=BigInt(0),a=BigInt(1),A=BigInt(2),S=BigInt(7),H=BigInt(256),T=BigInt(113);for(let i=0,t=a,s=1,n=0;i<24;i++){[s,n]=[n,(2*s+3*n)%5],I.push(2*(5*n+s)),O.push((i+1)*(i+2)/2%64);let o=B;for(let r=0;r<7;r++)t=(t<<a^(t>>S)*T)%H,t&A&&(o^=a<<(a<<BigInt(r))-a);w.push(o)}const[m,E]=f.split(w,!0),y=(i,t,s)=>s>32?f.rotlBH(i,t,s):f.rotlSH(i,t,s),b=(i,t,s)=>s>32?f.rotlBL(i,t,s):f.rotlSL(i,t,s);function L(i,t=24){const s=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let e=0;e<10;e++)s[e]=i[e]^i[e+10]^i[e+20]^i[e+30]^i[e+40];for(let e=0;e<10;e+=2){const h=(e+8)%10,p=(e+2)%10,d=s[p],u=s[p+1],_=y(d,u,1)^s[h],g=b(d,u,1)^s[h+1];for(let k=0;k<50;k+=10)i[e+k]^=_,i[e+k+1]^=g}let o=i[2],r=i[3];for(let e=0;e<24;e++){const h=O[e],p=y(o,r,h),d=b(o,r,h),u=I[e];o=i[u],r=i[u+1],i[u]=p,i[u+1]=d}for(let e=0;e<50;e+=10){for(let h=0;h<10;h++)s[h]=i[e+h];for(let h=0;h<10;h++)i[e+h]^=~s[(h+2)%10]&s[(h+4)%10]}i[0]^=m[n],i[1]^=E[n]}s.fill(0)}class x extends c.Hash{constructor(t,s,n,o=!1,r=24){if(super(),this.blockLen=t,this.suffix=s,this.outputLen=n,this.enableXOF=o,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,l.anumber(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=c.u32(this.state)}keccak(){c.isLE||c.byteSwap32(this.state32),L(this.state32,this.rounds),c.isLE||c.byteSwap32(this.state32),this.posOut=0,this.pos=0}update(t){l.aexists(this);const{blockLen:s,state:n}=this;t=c.toBytes(t);const o=t.length;for(let r=0;r<o;){const e=Math.min(s-this.pos,o-r);for(let h=0;h<e;h++)n[this.pos++]^=t[r++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:s,pos:n,blockLen:o}=this;t[n]^=s,s&128&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){l.aexists(this,!1),l.abytes(t),this.finish();const s=this.state,{blockLen:n}=this;for(let o=0,r=t.length;o<r;){this.posOut>=n&&this.keccak();const e=Math.min(n-this.posOut,r-o);t.set(s.subarray(this.posOut,this.posOut+e),o),this.posOut+=e,o+=e}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return l.anumber(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(l.aoutput(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:s,suffix:n,outputLen:o,rounds:r,enableXOF:e}=this;return t||(t=new x(s,n,o,e,r)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=r,t.suffix=n,t.outputLen=o,t.enableXOF=e,t.destroyed=this.destroyed,t}}const F=(i,t,s)=>c.wrapConstructor(()=>new x(t,i,s)),P=F(1,136,256/8);exports.Keccak=x;exports.keccakP=L;exports.keccak_256=P;
@@ -0,0 +1,107 @@
1
+ import { anumber as d, aexists as k, abytes as B, aoutput as A } from "./index113.js";
2
+ import { split as H, rotlBH as m, rotlSH as S, rotlBL as T, rotlSL as F } from "./index118.js";
3
+ import { wrapConstructor as X, Hash as E, u32 as U, isLE as x, byteSwap32 as I, toBytes as P } from "./index111.js";
4
+ const y = [], L = [], b = [], M = /* @__PURE__ */ BigInt(0), f = /* @__PURE__ */ BigInt(1), R = /* @__PURE__ */ BigInt(2), j = /* @__PURE__ */ BigInt(7), C = /* @__PURE__ */ BigInt(256), q = /* @__PURE__ */ BigInt(113);
5
+ for (let e = 0, t = f, s = 1, n = 0; e < 24; e++) {
6
+ [s, n] = [n, (2 * s + 3 * n) % 5], y.push(2 * (5 * n + s)), L.push((e + 1) * (e + 2) / 2 % 64);
7
+ let o = M;
8
+ for (let r = 0; r < 7; r++)
9
+ t = (t << f ^ (t >> j) * q) % C, t & R && (o ^= f << (f << /* @__PURE__ */ BigInt(r)) - f);
10
+ b.push(o);
11
+ }
12
+ const [v, z] = /* @__PURE__ */ H(b, !0), O = (e, t, s) => s > 32 ? m(e, t, s) : S(e, t, s), w = (e, t, s) => s > 32 ? T(e, t, s) : F(e, t, s);
13
+ function D(e, t = 24) {
14
+ const s = new Uint32Array(10);
15
+ for (let n = 24 - t; n < 24; n++) {
16
+ for (let i = 0; i < 10; i++)
17
+ s[i] = e[i] ^ e[i + 10] ^ e[i + 20] ^ e[i + 30] ^ e[i + 40];
18
+ for (let i = 0; i < 10; i += 2) {
19
+ const h = (i + 8) % 10, l = (i + 2) % 10, u = s[l], c = s[l + 1], _ = O(u, c, 1) ^ s[h], g = w(u, c, 1) ^ s[h + 1];
20
+ for (let a = 0; a < 50; a += 10)
21
+ e[i + a] ^= _, e[i + a + 1] ^= g;
22
+ }
23
+ let o = e[2], r = e[3];
24
+ for (let i = 0; i < 24; i++) {
25
+ const h = L[i], l = O(o, r, h), u = w(o, r, h), c = y[i];
26
+ o = e[c], r = e[c + 1], e[c] = l, e[c + 1] = u;
27
+ }
28
+ for (let i = 0; i < 50; i += 10) {
29
+ for (let h = 0; h < 10; h++)
30
+ s[h] = e[i + h];
31
+ for (let h = 0; h < 10; h++)
32
+ e[i + h] ^= ~s[(h + 2) % 10] & s[(h + 4) % 10];
33
+ }
34
+ e[0] ^= v[n], e[1] ^= z[n];
35
+ }
36
+ s.fill(0);
37
+ }
38
+ class p extends E {
39
+ // NOTE: we accept arguments in bytes instead of bits here.
40
+ constructor(t, s, n, o = !1, r = 24) {
41
+ if (super(), this.blockLen = t, this.suffix = s, this.outputLen = n, this.enableXOF = o, this.rounds = r, this.pos = 0, this.posOut = 0, this.finished = !1, this.destroyed = !1, d(n), 0 >= this.blockLen || this.blockLen >= 200)
42
+ throw new Error("Sha3 supports only keccak-f1600 function");
43
+ this.state = new Uint8Array(200), this.state32 = U(this.state);
44
+ }
45
+ keccak() {
46
+ x || I(this.state32), D(this.state32, this.rounds), x || I(this.state32), this.posOut = 0, this.pos = 0;
47
+ }
48
+ update(t) {
49
+ k(this);
50
+ const { blockLen: s, state: n } = this;
51
+ t = P(t);
52
+ const o = t.length;
53
+ for (let r = 0; r < o; ) {
54
+ const i = Math.min(s - this.pos, o - r);
55
+ for (let h = 0; h < i; h++)
56
+ n[this.pos++] ^= t[r++];
57
+ this.pos === s && this.keccak();
58
+ }
59
+ return this;
60
+ }
61
+ finish() {
62
+ if (this.finished)
63
+ return;
64
+ this.finished = !0;
65
+ const { state: t, suffix: s, pos: n, blockLen: o } = this;
66
+ t[n] ^= s, s & 128 && n === o - 1 && this.keccak(), t[o - 1] ^= 128, this.keccak();
67
+ }
68
+ writeInto(t) {
69
+ k(this, !1), B(t), this.finish();
70
+ const s = this.state, { blockLen: n } = this;
71
+ for (let o = 0, r = t.length; o < r; ) {
72
+ this.posOut >= n && this.keccak();
73
+ const i = Math.min(n - this.posOut, r - o);
74
+ t.set(s.subarray(this.posOut, this.posOut + i), o), this.posOut += i, o += i;
75
+ }
76
+ return t;
77
+ }
78
+ xofInto(t) {
79
+ if (!this.enableXOF)
80
+ throw new Error("XOF is not possible for this instance");
81
+ return this.writeInto(t);
82
+ }
83
+ xof(t) {
84
+ return d(t), this.xofInto(new Uint8Array(t));
85
+ }
86
+ digestInto(t) {
87
+ if (A(t, this), this.finished)
88
+ throw new Error("digest() was already called");
89
+ return this.writeInto(t), this.destroy(), t;
90
+ }
91
+ digest() {
92
+ return this.digestInto(new Uint8Array(this.outputLen));
93
+ }
94
+ destroy() {
95
+ this.destroyed = !0, this.state.fill(0);
96
+ }
97
+ _cloneInto(t) {
98
+ const { blockLen: s, suffix: n, outputLen: o, rounds: r, enableXOF: i } = this;
99
+ return t || (t = new p(s, n, o, i, r)), t.state32.set(this.state32), t.pos = this.pos, t.posOut = this.posOut, t.finished = this.finished, t.rounds = r, t.suffix = n, t.outputLen = o, t.enableXOF = i, t.destroyed = this.destroyed, t;
100
+ }
101
+ }
102
+ const G = (e, t, s) => X(() => new p(t, e, s)), Q = /* @__PURE__ */ G(1, 136, 256 / 8);
103
+ export {
104
+ p as Keccak,
105
+ D as keccakP,
106
+ Q as keccak_256
107
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index25.cjs"),c=require("./index57.cjs");function u(t){if(!t||t.length===0)return[];const e=[];for(const n of t){const{contractAddress:s,chainId:r,nonce:i,...a}=n;e.push([r?o.toHex(r):"0x",s,i?o.toHex(i):"0x",...c.toYParitySignatureArray({},a)])}return e}exports.serializeAuthorizationList=u;
@@ -0,0 +1,20 @@
1
+ import { toHex as i } from "./index25.js";
2
+ import { toYParitySignatureArray as c } from "./index57.js";
3
+ function d(r) {
4
+ if (!r || r.length === 0)
5
+ return [];
6
+ const t = [];
7
+ for (const e of r) {
8
+ const { contractAddress: s, chainId: o, nonce: n, ...a } = e;
9
+ t.push([
10
+ o ? i(o) : "0x",
11
+ s,
12
+ n ? i(n) : "0x",
13
+ ...c({}, a)
14
+ ]);
15
+ }
16
+ return t;
17
+ }
18
+ export {
19
+ d as serializeAuthorizationList
20
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./index108.cjs"),w=require("./index102.cjs"),t=require("./index50.cjs"),P=require("./index63.cjs"),h=require("./index106.cjs"),d=require("./index65.cjs"),n=require("./index69.cjs"),c=require("./index51.cjs"),I=require("./index66.cjs"),u=require("./index99.cjs"),l=require("./index35.cjs");function m(o){const{authorizationList:e}=o;if(e)for(const s of e){const{contractAddress:r,chainId:i}=s;if(!c.isAddress(r))throw new t.InvalidAddressError({address:r});if(i<0)throw new d.InvalidChainIdError({chainId:i})}f(o)}function T(o){const{blobVersionedHashes:e}=o;if(e){if(e.length===0)throw new h.EmptyBlobError;for(const s of e){const r=I.size(s),i=l.hexToNumber(u.slice(s,0,1));if(r!==32)throw new h.InvalidVersionedHashSizeError({hash:s,size:r});if(i!==E.versionedHashVersionKzg)throw new h.InvalidVersionedHashVersionError({hash:s,version:i})}}f(o)}function f(o){const{chainId:e,maxPriorityFeePerGas:s,maxFeePerGas:r,to:i}=o;if(e<=0)throw new d.InvalidChainIdError({chainId:e});if(i&&!c.isAddress(i))throw new t.InvalidAddressError({address:i});if(r&&r>w.maxUint256)throw new n.FeeCapTooHighError({maxFeePerGas:r});if(s&&r&&s>r)throw new n.TipAboveFeeCapError({maxFeePerGas:r,maxPriorityFeePerGas:s})}function x(o){const{chainId:e,maxPriorityFeePerGas:s,gasPrice:r,maxFeePerGas:i,to:a}=o;if(e<=0)throw new d.InvalidChainIdError({chainId:e});if(a&&!c.isAddress(a))throw new t.InvalidAddressError({address:a});if(s||i)throw new P.BaseError("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(r&&r>w.maxUint256)throw new n.FeeCapTooHighError({maxFeePerGas:r})}function v(o){const{chainId:e,maxPriorityFeePerGas:s,gasPrice:r,maxFeePerGas:i,to:a}=o;if(a&&!c.isAddress(a))throw new t.InvalidAddressError({address:a});if(typeof e<"u"&&e<=0)throw new d.InvalidChainIdError({chainId:e});if(s||i)throw new P.BaseError("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(r&&r>w.maxUint256)throw new n.FeeCapTooHighError({maxFeePerGas:r})}exports.assertTransactionEIP1559=f;exports.assertTransactionEIP2930=x;exports.assertTransactionEIP4844=T;exports.assertTransactionEIP7702=m;exports.assertTransactionLegacy=v;
@@ -0,0 +1,81 @@
1
+ import { versionedHashVersionKzg as d } from "./index108.js";
2
+ import { maxUint256 as m } from "./index102.js";
3
+ import { InvalidAddressError as s } from "./index50.js";
4
+ import { BaseError as h } from "./index63.js";
5
+ import { EmptyBlobError as P, InvalidVersionedHashSizeError as p, InvalidVersionedHashVersionError as x } from "./index106.js";
6
+ import { InvalidChainIdError as n } from "./index65.js";
7
+ import { FeeCapTooHighError as w, TipAboveFeeCapError as E } from "./index69.js";
8
+ import { isAddress as f } from "./index51.js";
9
+ import { size as F } from "./index66.js";
10
+ import { slice as I } from "./index99.js";
11
+ import { hexToNumber as G } from "./index35.js";
12
+ function C(t) {
13
+ const { authorizationList: e } = t;
14
+ if (e)
15
+ for (const o of e) {
16
+ const { contractAddress: r, chainId: i } = o;
17
+ if (!f(r))
18
+ throw new s({ address: r });
19
+ if (i < 0)
20
+ throw new n({ chainId: i });
21
+ }
22
+ c(t);
23
+ }
24
+ function L(t) {
25
+ const { blobVersionedHashes: e } = t;
26
+ if (e) {
27
+ if (e.length === 0)
28
+ throw new P();
29
+ for (const o of e) {
30
+ const r = F(o), i = G(I(o, 0, 1));
31
+ if (r !== 32)
32
+ throw new p({ hash: o, size: r });
33
+ if (i !== d)
34
+ throw new x({
35
+ hash: o,
36
+ version: i
37
+ });
38
+ }
39
+ }
40
+ c(t);
41
+ }
42
+ function c(t) {
43
+ const { chainId: e, maxPriorityFeePerGas: o, maxFeePerGas: r, to: i } = t;
44
+ if (e <= 0)
45
+ throw new n({ chainId: e });
46
+ if (i && !f(i))
47
+ throw new s({ address: i });
48
+ if (r && r > m)
49
+ throw new w({ maxFeePerGas: r });
50
+ if (o && r && o > r)
51
+ throw new E({ maxFeePerGas: r, maxPriorityFeePerGas: o });
52
+ }
53
+ function B(t) {
54
+ const { chainId: e, maxPriorityFeePerGas: o, gasPrice: r, maxFeePerGas: i, to: a } = t;
55
+ if (e <= 0)
56
+ throw new n({ chainId: e });
57
+ if (a && !f(a))
58
+ throw new s({ address: a });
59
+ if (o || i)
60
+ throw new h("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");
61
+ if (r && r > m)
62
+ throw new w({ maxFeePerGas: r });
63
+ }
64
+ function K(t) {
65
+ const { chainId: e, maxPriorityFeePerGas: o, gasPrice: r, maxFeePerGas: i, to: a } = t;
66
+ if (a && !f(a))
67
+ throw new s({ address: a });
68
+ if (typeof e < "u" && e <= 0)
69
+ throw new n({ chainId: e });
70
+ if (o || i)
71
+ throw new h("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");
72
+ if (r && r > m)
73
+ throw new w({ maxFeePerGas: r });
74
+ }
75
+ export {
76
+ c as assertTransactionEIP1559,
77
+ B as assertTransactionEIP2930,
78
+ L as assertTransactionEIP4844,
79
+ C as assertTransactionEIP7702,
80
+ K as assertTransactionLegacy
81
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index50.cjs"),d=require("./index30.cjs"),l=require("./index51.cjs");function a(e){if(!e||e.length===0)return[];const n=[];for(let t=0;t<e.length;t++){const{address:i,storageKeys:r}=e[t];for(let s=0;s<r.length;s++)if(r[s].length-2!==64)throw new d.InvalidStorageKeySizeError({storageKey:r[s]});if(!l.isAddress(i,{strict:!1}))throw new o.InvalidAddressError({address:i});n.push([i,r])}return n}exports.serializeAccessList=a;
@@ -0,0 +1,21 @@
1
+ import { InvalidAddressError as s } from "./index50.js";
2
+ import { InvalidStorageKeySizeError as l } from "./index30.js";
3
+ import { isAddress as f } from "./index51.js";
4
+ function a(r) {
5
+ if (!r || r.length === 0)
6
+ return [];
7
+ const n = [];
8
+ for (let o = 0; o < r.length; o++) {
9
+ const { address: i, storageKeys: e } = r[o];
10
+ for (let t = 0; t < e.length; t++)
11
+ if (e[t].length - 2 !== 64)
12
+ throw new l({ storageKey: e[t] });
13
+ if (!f(i, { strict: !1 }))
14
+ throw new s({ address: i });
15
+ n.push([i, e]);
16
+ }
17
+ return n;
18
+ }
19
+ export {
20
+ a as serializeAccessList
21
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}exports.defineChain=n;
@@ -0,0 +1,11 @@
1
+ function n(e) {
2
+ return {
3
+ formatters: void 0,
4
+ fees: void 0,
5
+ serializers: void 0,
6
+ ...e
7
+ };
8
+ }
9
+ export {
10
+ n as defineChain
11
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index63.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;
@@ -0,0 +1,14 @@
1
+ import { BaseError as i } from "./index63.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
+ };
@@ -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;
@@ -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
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index63.cjs");class i extends t.BaseError{constructor({offset:r,position:s,size:e}){super(`Slice ${s==="start"?"starting":"ending"} at offset "${r}" is out-of-bounds (size: ${e}).`,{name:"SliceOffsetOutOfBoundsError"})}}class d extends t.BaseError{constructor({size:r,targetSize:s,type:e}){super(`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()} size (${r}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}exports.SizeExceedsPaddingSizeError=d;exports.SliceOffsetOutOfBoundsError=i;
@@ -0,0 +1,15 @@
1
+ import { BaseError as o } from "./index63.js";
2
+ class d extends o {
3
+ constructor({ offset: r, position: s, size: e }) {
4
+ super(`Slice ${s === "start" ? "starting" : "ending"} at offset "${r}" is out-of-bounds (size: ${e}).`, { name: "SliceOffsetOutOfBoundsError" });
5
+ }
6
+ }
7
+ class n extends o {
8
+ constructor({ size: r, targetSize: s, type: e }) {
9
+ super(`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()} size (${r}) exceeds padding size (${s}).`, { name: "SizeExceedsPaddingSizeError" });
10
+ }
11
+ }
12
+ export {
13
+ n as SizeExceedsPaddingSizeError,
14
+ d as SliceOffsetOutOfBoundsError
15
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index98.cjs"),O=require("./index83.cjs"),n=require("./index66.cjs");function p(i,e,s,{strict:f}={}){return O.isHex(i,{strict:!1})?l(i,e,s,{strict:f}):u(i,e,s,{strict:f})}function r(i,e){if(typeof e=="number"&&e>0&&e>n.size(i)-1)throw new t.SliceOffsetOutOfBoundsError({offset:e,position:"start",size:n.size(i)})}function c(i,e,s){if(typeof e=="number"&&typeof s=="number"&&n.size(i)!==s-e)throw new t.SliceOffsetOutOfBoundsError({offset:s,position:"end",size:n.size(i)})}function u(i,e,s,{strict:f}={}){r(i,e);const o=i.slice(e,s);return f&&c(o,e,s),o}function l(i,e,s,{strict:f}={}){r(i,e);const o=`0x${i.replace("0x","").slice((e??0)*2,(s??i.length)*2)}`;return f&&c(o,e,s),o}exports.slice=p;exports.sliceBytes=u;exports.sliceHex=l;
@@ -0,0 +1,41 @@
1
+ import { SliceOffsetOutOfBoundsError as t } from "./index98.js";
2
+ import { isHex as p } from "./index83.js";
3
+ import { size as r } from "./index66.js";
4
+ function w(e, f, i, { strict: o } = {}) {
5
+ return p(e, { strict: !1 }) ? u(e, f, i, {
6
+ strict: o
7
+ }) : m(e, f, i, {
8
+ strict: o
9
+ });
10
+ }
11
+ function s(e, f) {
12
+ if (typeof f == "number" && f > 0 && f > r(e) - 1)
13
+ throw new t({
14
+ offset: f,
15
+ position: "start",
16
+ size: r(e)
17
+ });
18
+ }
19
+ function c(e, f, i) {
20
+ if (typeof f == "number" && typeof i == "number" && r(e) !== i - f)
21
+ throw new t({
22
+ offset: i,
23
+ position: "end",
24
+ size: r(e)
25
+ });
26
+ }
27
+ function m(e, f, i, { strict: o } = {}) {
28
+ s(e, f);
29
+ const n = e.slice(f, i);
30
+ return o && c(n, f, i), n;
31
+ }
32
+ function u(e, f, i, { strict: o } = {}) {
33
+ s(e, f);
34
+ const n = `0x${e.replace("0x", "").slice((f ?? 0) * 2, (i ?? e.length) * 2)}`;
35
+ return o && c(n, f, i), n;
36
+ }
37
+ export {
38
+ w as slice,
39
+ m as sliceBytes,
40
+ u as sliceHex
41
+ };
@@ -7,3 +7,4 @@ export * from './lib/approve';
7
7
  export * from './lib/blockNumber';
8
8
  export * from './lib/eventBroker';
9
9
  export * from './lib/result';
10
+ export * from './lib/digestKey/digestKey';
@@ -0,0 +1,12 @@
1
+ import { Result, AsyncResult } from '@catalogfi/utils';
2
+ import { AuthHeader, IAuth } from '../auth.types';
3
+
4
+ export declare class ApiKey implements IAuth {
5
+ private readonly apiKey;
6
+ constructor(apiKey: string);
7
+ getToken(): AsyncResult<string, string>;
8
+ verifyToken(): Result<boolean, string>;
9
+ private decodeBase64UrlSafe;
10
+ private extractData;
11
+ getAuthHeaders(): AsyncResult<AuthHeader, string>;
12
+ }
@@ -6,15 +6,28 @@ export type SiweOpts = {
6
6
  store?: IStore;
7
7
  signingStatement?: string;
8
8
  };
9
- export type AuthHeader = {
10
- [key: string]: string;
11
- };
12
- export interface ISiwe {
13
- getToken(): AsyncResult<string, string>;
14
- verifyToken(token: string, account: string): Result<boolean, string>;
9
+ export declare enum AuthHeaderEnum {
10
+ Authorization = "Authorization",
11
+ ApiKey = "api-key"
15
12
  }
13
+ export type AuthHeader = Record<AuthHeaderEnum.ApiKey, string> | Record<AuthHeaderEnum.Authorization, string>;
16
14
  export interface IAuth {
17
- siwe?: ISiwe;
18
- apiKey?: string;
15
+ /**
16
+ * Get a token from store if available or fetch from the wallet
17
+ * @returns verified token
18
+ */
19
+ getToken(): AsyncResult<string, string>;
20
+ /**
21
+ * Verify the token expiry and account
22
+ * @param token The token to verify
23
+ * @param account The account to verify the token against
24
+ */
25
+ verifyToken(token: string, account: string): Result<boolean, string>;
26
+ /**
27
+ * Retrieves the authentication token and formats it into the appropriate header object.
28
+ * Example: For API keys, returns { 'api-key': apiKey }
29
+ * Example: For SIWE, returns { Authorization: 'Bearer token' }
30
+ * @returns An AsyncResult containing the formatted auth header object or an error message
31
+ */
19
32
  getAuthHeaders(): AsyncResult<AuthHeader, string>;
20
33
  }
@@ -1,2 +1,6 @@
1
1
  export * from './auth.types';
2
- export * from './siwe';
2
+ export * from './siwe/siwe';
3
+ export * from './apikey/apikey';
4
+ export * from './passkey/passkey';
5
+ export * from './passkey/passkey.types';
6
+ export * from './passkey/passkeyLogin';
@@ -0,0 +1,10 @@
1
+ import { Result, AsyncResult } from '@catalogfi/utils';
2
+ import { AuthHeader, IAuth } from '../auth.types';
3
+
4
+ export declare class Passkey implements IAuth {
5
+ private token;
6
+ constructor(token: string);
7
+ getToken(): AsyncResult<string, string>;
8
+ verifyToken(token: string): Result<boolean, string>;
9
+ getAuthHeaders(): AsyncResult<AuthHeader, string>;
10
+ }
@@ -0,0 +1,17 @@
1
+ import { PublicKeyCredentialCreationOptionsJSON } from '@simplewebauthn/browser';
2
+
3
+ export type PasskeyToken = {
4
+ token: string;
5
+ gardenUserName: string;
6
+ };
7
+ export type RegisterChallenge = {
8
+ challenge: {
9
+ publicKey: PublicKeyCredentialCreationOptionsJSON;
10
+ };
11
+ };
12
+ export type ConditionalLoginChallenge = {
13
+ challenge: {
14
+ publicKey: PublicKeyCredentialCreationOptionsJSON;
15
+ };
16
+ login_id: string;
17
+ };