@gardenfi/utils 2.0.5 → 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 (232) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +22 -20
  3. package/dist/index10.cjs +1 -1
  4. package/dist/index10.js +37 -19
  5. package/dist/index100.cjs +1 -1
  6. package/dist/index100.js +5 -7
  7. package/dist/index101.cjs +1 -2
  8. package/dist/index101.js +11 -3
  9. package/dist/index102.cjs +1 -1
  10. package/dist/index102.js +2 -113
  11. package/dist/index103.cjs +1 -1
  12. package/dist/index103.js +17 -75
  13. package/dist/index104.cjs +1 -1
  14. package/dist/index104.js +7 -2
  15. package/dist/index105.cjs +1 -1
  16. package/dist/index105.js +5 -18
  17. package/dist/index106.cjs +1 -1
  18. package/dist/index106.js +36 -17
  19. package/dist/index107.cjs +1 -1
  20. package/dist/index107.js +127 -16
  21. package/dist/index108.cjs +1 -1
  22. package/dist/index108.js +2 -224
  23. package/dist/index109.cjs +2 -1
  24. package/dist/index109.js +3 -35
  25. package/dist/index11.cjs +1 -1
  26. package/dist/index11.js +19 -134
  27. package/dist/index110.cjs +1 -1
  28. package/dist/index110.js +65 -16
  29. package/dist/index111.cjs +1 -1
  30. package/dist/index111.js +2 -2
  31. package/dist/index112.cjs +1 -1
  32. package/dist/index112.js +2 -68
  33. package/dist/index113.cjs +1 -1
  34. package/dist/index113.js +35 -2
  35. package/dist/index114.cjs +1 -1
  36. package/dist/index114.js +1 -1
  37. package/dist/index115.cjs +1 -1
  38. package/dist/index115.js +1 -1
  39. package/dist/index117.cjs +1 -1
  40. package/dist/index117.js +1 -1
  41. package/dist/index118.cjs +1 -0
  42. package/dist/index118.js +21 -0
  43. package/dist/index12.cjs +1 -1
  44. package/dist/index12.js +136 -10
  45. package/dist/index13.cjs +1 -1
  46. package/dist/index13.js +15 -2
  47. package/dist/index14.cjs +1 -1
  48. package/dist/index14.js +2 -34
  49. package/dist/index15.cjs +1 -1
  50. package/dist/index15.js +32 -17
  51. package/dist/index16.cjs +1 -1
  52. package/dist/index16.js +14 -183
  53. package/dist/index17.cjs +1 -1
  54. package/dist/index17.js +187 -92
  55. package/dist/index18.cjs +1 -1
  56. package/dist/index18.js +92 -34
  57. package/dist/index19.cjs +1 -1
  58. package/dist/index19.js +36 -32
  59. package/dist/index20.cjs +1 -16
  60. package/dist/index20.js +30 -112
  61. package/dist/index21.cjs +16 -1
  62. package/dist/index21.js +113 -30
  63. package/dist/index22.cjs +1 -1
  64. package/dist/index22.js +31 -18
  65. package/dist/index23.cjs +1 -1
  66. package/dist/index23.js +17 -7
  67. package/dist/index24.cjs +1 -1
  68. package/dist/index24.js +6 -44
  69. package/dist/index25.cjs +1 -1
  70. package/dist/index25.js +45 -21
  71. package/dist/index26.cjs +1 -1
  72. package/dist/index26.js +21 -8
  73. package/dist/index27.cjs +1 -1
  74. package/dist/index27.js +8 -31
  75. package/dist/index28.cjs +1 -1
  76. package/dist/index28.js +31 -26
  77. package/dist/index29.cjs +1 -2
  78. package/dist/index29.js +25 -64
  79. package/dist/index30.cjs +2 -1
  80. package/dist/index30.js +64 -50
  81. package/dist/index31.cjs +1 -1
  82. package/dist/index31.js +51 -12
  83. package/dist/index32.cjs +1 -1
  84. package/dist/index32.js +12 -24
  85. package/dist/index33.cjs +1 -1
  86. package/dist/index33.js +24 -75
  87. package/dist/index34.cjs +1 -1
  88. package/dist/index34.js +74 -22
  89. package/dist/index35.cjs +1 -1
  90. package/dist/index35.js +23 -7
  91. package/dist/index36.cjs +1 -1
  92. package/dist/index36.js +7 -32
  93. package/dist/index37.cjs +1 -1
  94. package/dist/index37.js +31 -14
  95. package/dist/index38.cjs +1 -1
  96. package/dist/index38.js +16 -2
  97. package/dist/index39.cjs +1 -1
  98. package/dist/index39.js +2 -9
  99. package/dist/index4.cjs +1 -1
  100. package/dist/index4.js +2 -2
  101. package/dist/index40.cjs +1 -1
  102. package/dist/index40.js +8 -20
  103. package/dist/index41.cjs +1 -1
  104. package/dist/index41.js +20 -12
  105. package/dist/index42.cjs +1 -1
  106. package/dist/index42.js +40 -33
  107. package/dist/index43.cjs +1 -2
  108. package/dist/index43.js +24 -58
  109. package/dist/index44.cjs +1 -1
  110. package/dist/index44.js +7 -2
  111. package/dist/index45.cjs +1 -1
  112. package/dist/index45.js +13 -6
  113. package/dist/index46.cjs +1 -1
  114. package/dist/index46.js +15 -6
  115. package/dist/index47.cjs +1 -1
  116. package/dist/index47.js +5 -4
  117. package/dist/index48.cjs +1 -1
  118. package/dist/index48.js +13 -11
  119. package/dist/index49.cjs +1 -5
  120. package/dist/index49.js +10 -56
  121. package/dist/index50.cjs +1 -1
  122. package/dist/index50.js +12 -3
  123. package/dist/index51.cjs +1 -2
  124. package/dist/index51.js +11 -34
  125. package/dist/index52.cjs +1 -1
  126. package/dist/index52.js +13 -5
  127. package/dist/index53.cjs +1 -1
  128. package/dist/index53.js +54 -20
  129. package/dist/index54.cjs +1 -1
  130. package/dist/index54.js +16 -12
  131. package/dist/index55.cjs +1 -1
  132. package/dist/index55.js +5 -55
  133. package/dist/index56.cjs +1 -1
  134. package/dist/index56.js +4 -4
  135. package/dist/index57.cjs +1 -1
  136. package/dist/index57.js +169 -19
  137. package/dist/index58.cjs +1 -1
  138. package/dist/index58.js +103 -11
  139. package/dist/index59.cjs +1 -1
  140. package/dist/index59.js +21 -8
  141. package/dist/index6.cjs +1 -1
  142. package/dist/index6.js +40 -22
  143. package/dist/index60.cjs +1 -1
  144. package/dist/index60.js +11 -9
  145. package/dist/index61.cjs +1 -1
  146. package/dist/index61.js +34 -11
  147. package/dist/index62.cjs +1 -1
  148. package/dist/index62.js +6 -6
  149. package/dist/index63.cjs +2 -1
  150. package/dist/index63.js +59 -13
  151. package/dist/index64.cjs +1 -1
  152. package/dist/index64.js +2 -33
  153. package/dist/index65.cjs +1 -1
  154. package/dist/index65.js +6 -14
  155. package/dist/index66.cjs +1 -1
  156. package/dist/index66.js +4 -64
  157. package/dist/index67.cjs +1 -1
  158. package/dist/index67.js +11 -27
  159. package/dist/index68.cjs +5 -1
  160. package/dist/index68.js +57 -3
  161. package/dist/index69.cjs +2 -1
  162. package/dist/index69.js +34 -5
  163. package/dist/index7.cjs +1 -1
  164. package/dist/index7.js +24 -2
  165. package/dist/index70.cjs +1 -1
  166. package/dist/index70.js +5 -8
  167. package/dist/index71.cjs +1 -1
  168. package/dist/index71.js +3 -3
  169. package/dist/index72.cjs +1 -1
  170. package/dist/index72.js +21 -13
  171. package/dist/index73.cjs +1 -1
  172. package/dist/index73.js +8 -41
  173. package/dist/index74.cjs +1 -1
  174. package/dist/index74.js +9 -102
  175. package/dist/index75.cjs +1 -1
  176. package/dist/index75.js +10 -190
  177. package/dist/index76.cjs +1 -1
  178. package/dist/index76.js +5 -17
  179. package/dist/index77.cjs +1 -1
  180. package/dist/index77.js +12 -10
  181. package/dist/index78.cjs +1 -1
  182. package/dist/index78.js +32 -19
  183. package/dist/index79.cjs +1 -1
  184. package/dist/index79.js +14 -25
  185. package/dist/index8.cjs +1 -1
  186. package/dist/index8.js +2 -100
  187. package/dist/index80.cjs +1 -1
  188. package/dist/index80.js +64 -6
  189. package/dist/index81.cjs +1 -1
  190. package/dist/index81.js +27 -13
  191. package/dist/index82.cjs +1 -1
  192. package/dist/index82.js +3 -16
  193. package/dist/index83.cjs +1 -1
  194. package/dist/index83.js +3 -5
  195. package/dist/index84.cjs +1 -1
  196. package/dist/index84.js +8 -13
  197. package/dist/index85.cjs +1 -1
  198. package/dist/index85.js +190 -9
  199. package/dist/index86.cjs +1 -1
  200. package/dist/index86.js +18 -16
  201. package/dist/index87.cjs +1 -1
  202. package/dist/index87.js +110 -169
  203. package/dist/index88.cjs +1 -1
  204. package/dist/index88.js +14 -6
  205. package/dist/index89.cjs +1 -1
  206. package/dist/index89.js +220 -9
  207. package/dist/index9.cjs +1 -1
  208. package/dist/index9.js +90 -34
  209. package/dist/index90.cjs +1 -1
  210. package/dist/index90.js +38 -100
  211. package/dist/index91.cjs +1 -1
  212. package/dist/index91.js +102 -36
  213. package/dist/index92.cjs +1 -1
  214. package/dist/index92.js +18 -2
  215. package/dist/index93.cjs +1 -1
  216. package/dist/index93.js +79 -5
  217. package/dist/index94.cjs +1 -1
  218. package/dist/index94.js +18 -10
  219. package/dist/index95.cjs +1 -1
  220. package/dist/index95.js +6 -40
  221. package/dist/index96.cjs +1 -1
  222. package/dist/index96.js +9 -18
  223. package/dist/index97.cjs +1 -1
  224. package/dist/index97.js +20 -5
  225. package/dist/index98.cjs +1 -1
  226. package/dist/index98.js +9 -34
  227. package/dist/index99.cjs +1 -1
  228. package/dist/index99.js +38 -127
  229. package/dist/src/index.d.ts +1 -0
  230. package/dist/src/lib/auth/siwe/siwe.d.ts +2 -1
  231. package/dist/src/lib/digestKey/digestKey.d.ts +12 -0
  232. package/package.json +2 -1
package/dist/index99.js CHANGED
@@ -1,130 +1,41 @@
1
- import { RecursiveReadLimitExceededError as e, PositionOutOfBoundsError as n, NegativeOffsetError as o } from "./index96.js";
2
- const h = {
3
- bytes: new Uint8Array(),
4
- dataView: new DataView(new ArrayBuffer(0)),
5
- position: 0,
6
- positionReadCount: /* @__PURE__ */ new Map(),
7
- recursiveReadCount: 0,
8
- recursiveReadLimit: Number.POSITIVE_INFINITY,
9
- assertReadLimit() {
10
- if (this.recursiveReadCount >= this.recursiveReadLimit)
11
- throw new e({
12
- count: this.recursiveReadCount + 1,
13
- limit: this.recursiveReadLimit
14
- });
15
- },
16
- assertPosition(t) {
17
- if (t < 0 || t > this.bytes.length - 1)
18
- throw new n({
19
- length: this.bytes.length,
20
- position: t
21
- });
22
- },
23
- decrementPosition(t) {
24
- if (t < 0)
25
- throw new o({ offset: t });
26
- const i = this.position - t;
27
- this.assertPosition(i), this.position = i;
28
- },
29
- getReadCount(t) {
30
- return this.positionReadCount.get(t || this.position) || 0;
31
- },
32
- incrementPosition(t) {
33
- if (t < 0)
34
- throw new o({ offset: t });
35
- const i = this.position + t;
36
- this.assertPosition(i), this.position = i;
37
- },
38
- inspectByte(t) {
39
- const i = t ?? this.position;
40
- return this.assertPosition(i), this.bytes[i];
41
- },
42
- inspectBytes(t, i) {
43
- const s = i ?? this.position;
44
- return this.assertPosition(s + t - 1), this.bytes.subarray(s, s + t);
45
- },
46
- inspectUint8(t) {
47
- const i = t ?? this.position;
48
- return this.assertPosition(i), this.bytes[i];
49
- },
50
- inspectUint16(t) {
51
- const i = t ?? this.position;
52
- return this.assertPosition(i + 1), this.dataView.getUint16(i);
53
- },
54
- inspectUint24(t) {
55
- const i = t ?? this.position;
56
- return this.assertPosition(i + 2), (this.dataView.getUint16(i) << 8) + this.dataView.getUint8(i + 2);
57
- },
58
- inspectUint32(t) {
59
- const i = t ?? this.position;
60
- return this.assertPosition(i + 3), this.dataView.getUint32(i);
61
- },
62
- pushByte(t) {
63
- this.assertPosition(this.position), this.bytes[this.position] = t, this.position++;
64
- },
65
- pushBytes(t) {
66
- this.assertPosition(this.position + t.length - 1), this.bytes.set(t, this.position), this.position += t.length;
67
- },
68
- pushUint8(t) {
69
- this.assertPosition(this.position), this.bytes[this.position] = t, this.position++;
70
- },
71
- pushUint16(t) {
72
- this.assertPosition(this.position + 1), this.dataView.setUint16(this.position, t), this.position += 2;
73
- },
74
- pushUint24(t) {
75
- this.assertPosition(this.position + 2), this.dataView.setUint16(this.position, t >> 8), this.dataView.setUint8(this.position + 2, t & 255), this.position += 3;
76
- },
77
- pushUint32(t) {
78
- this.assertPosition(this.position + 3), this.dataView.setUint32(this.position, t), this.position += 4;
79
- },
80
- readByte() {
81
- this.assertReadLimit(), this._touch();
82
- const t = this.inspectByte();
83
- return this.position++, t;
84
- },
85
- readBytes(t, i) {
86
- this.assertReadLimit(), this._touch();
87
- const s = this.inspectBytes(t);
88
- return this.position += i ?? t, s;
89
- },
90
- readUint8() {
91
- this.assertReadLimit(), this._touch();
92
- const t = this.inspectUint8();
93
- return this.position += 1, t;
94
- },
95
- readUint16() {
96
- this.assertReadLimit(), this._touch();
97
- const t = this.inspectUint16();
98
- return this.position += 2, t;
99
- },
100
- readUint24() {
101
- this.assertReadLimit(), this._touch();
102
- const t = this.inspectUint24();
103
- return this.position += 3, t;
104
- },
105
- readUint32() {
106
- this.assertReadLimit(), this._touch();
107
- const t = this.inspectUint32();
108
- return this.position += 4, t;
109
- },
110
- get remaining() {
111
- return this.bytes.length - this.position;
112
- },
113
- setPosition(t) {
114
- const i = this.position;
115
- return this.assertPosition(t), this.position = t, () => this.position = i;
116
- },
117
- _touch() {
118
- if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
119
- return;
120
- const t = this.getReadCount();
121
- this.positionReadCount.set(this.position, t + 1), t > 0 && this.recursiveReadCount++;
122
- }
123
- };
124
- function a(t, { recursiveReadLimit: i = 8192 } = {}) {
125
- const s = Object.create(h);
126
- return s.bytes = t, s.dataView = new DataView(t.buffer, t.byteOffset, t.byteLength), s.positionReadCount = /* @__PURE__ */ new Map(), s.recursiveReadLimit = i, s;
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;
127
36
  }
128
37
  export {
129
- a as createCursor
38
+ w as slice,
39
+ m as sliceBytes,
40
+ u as sliceHex
130
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';
@@ -2,6 +2,7 @@ import { AuthHeader, IAuth, SiweOpts } from '../auth.types';
2
2
  import { AsyncResult, Result } from '@catalogfi/utils';
3
3
  import { Url } from '../../url';
4
4
  import { WalletClient } from 'viem';
5
+ import { DigestKey } from '../../digestKey/digestKey';
5
6
 
6
7
  export declare class Siwe implements IAuth {
7
8
  private readonly API;
@@ -11,7 +12,7 @@ export declare class Siwe implements IAuth {
11
12
  private readonly signingStatement;
12
13
  private readonly domain;
13
14
  constructor(url: Url, walletClient: WalletClient, opts?: SiweOpts);
14
- static fromDigestKey(url: Url, digestKey: string): Siwe;
15
+ static fromDigestKey(url: Url, digestKey: DigestKey, siweOpts?: SiweOpts): Siwe;
15
16
  verifyToken(token: string, account: string): Result<boolean, string>;
16
17
  getToken(): AsyncResult<string, string>;
17
18
  private signStatement;
@@ -0,0 +1,12 @@
1
+ export declare class DigestKey {
2
+ private _digestKey;
3
+ private _userId;
4
+ constructor(digestKey: string);
5
+ static from(digestKey: string): import('../result').Result<never, string> | import('../result').Result<DigestKey, never>;
6
+ static generateRandom(): import('../result').Result<never, string> | import('../result').Result<DigestKey, never>;
7
+ private static isValidDigestKey;
8
+ private static isValidPrivateKey;
9
+ private static generateRandomDigestKey;
10
+ get digestKey(): string;
11
+ get userId(): string;
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/utils",
3
- "version": "2.0.5",
3
+ "version": "2.0.6-alpha.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",
@@ -35,6 +35,7 @@
35
35
  },
36
36
  "sideEffects": false,
37
37
  "dependencies": {
38
+ "@peculiar/webcrypto": "^1.5.0",
38
39
  "@simplewebauthn/browser": "^13.1.0",
39
40
  "jwt-decode": "^4.0.0",
40
41
  "viem": "^2.21.23"