@gardenfi/utils 2.0.6-beta.8 → 2.0.6-beta.9
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/index100.cjs +1 -1
- package/dist/index100.js +5 -11
- package/dist/index101.cjs +1 -1
- package/dist/index101.js +10 -11
- package/dist/index102.cjs +1 -1
- package/dist/index102.js +2 -20
- package/dist/index103.cjs +1 -1
- package/dist/index103.js +1 -1
- package/dist/index104.cjs +1 -1
- package/dist/index104.js +1 -1
- package/dist/index106.cjs +1 -1
- package/dist/index106.js +1 -1
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +1 -1
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +1 -1
- package/dist/index21.cjs +16 -1
- package/dist/index21.js +113 -30
- package/dist/index22.cjs +1 -16
- package/dist/index22.js +30 -113
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +1 -1
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +2 -2
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +1 -1
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +1 -1
- package/dist/index35.cjs +1 -1
- package/dist/index35.js +2 -2
- package/dist/index38.cjs +1 -1
- package/dist/index38.js +1 -1
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +1 -1
- package/dist/index50.cjs +1 -1
- package/dist/index50.js +1 -1
- package/dist/index51.cjs +1 -1
- package/dist/index51.js +1 -1
- package/dist/index53.cjs +1 -1
- package/dist/index53.js +3 -3
- package/dist/index54.cjs +1 -1
- package/dist/index54.js +1 -1
- package/dist/index55.cjs +1 -1
- package/dist/index55.js +1 -1
- package/dist/index56.cjs +1 -1
- package/dist/index56.js +1 -1
- package/dist/index57.cjs +1 -1
- package/dist/index57.js +7 -7
- package/dist/index58.cjs +1 -1
- package/dist/index58.js +3 -3
- package/dist/index59.cjs +1 -1
- package/dist/index59.js +1 -1
- package/dist/index60.cjs +1 -1
- package/dist/index60.js +6 -12
- package/dist/index61.cjs +1 -1
- package/dist/index61.js +10 -32
- package/dist/index62.cjs +1 -1
- package/dist/index62.js +34 -6
- package/dist/index63.cjs +1 -2
- package/dist/index63.js +8 -59
- package/dist/index64.cjs +2 -1
- package/dist/index64.js +60 -2
- package/dist/index65.cjs +1 -1
- package/dist/index65.js +2 -7
- package/dist/index66.cjs +1 -1
- package/dist/index66.js +6 -4
- package/dist/index67.cjs +1 -1
- package/dist/index67.js +4 -11
- package/dist/index68.cjs +1 -5
- package/dist/index68.js +11 -56
- package/dist/index69.cjs +5 -2
- package/dist/index69.js +48 -26
- package/dist/index70.cjs +1 -1
- package/dist/index70.js +3 -5
- package/dist/index71.cjs +2 -1
- package/dist/index71.js +34 -3
- package/dist/index72.cjs +1 -1
- package/dist/index72.js +5 -21
- package/dist/index73.cjs +1 -1
- package/dist/index73.js +21 -8
- package/dist/index74.cjs +1 -1
- package/dist/index74.js +8 -10
- package/dist/index75.cjs +1 -1
- package/dist/index75.js +10 -11
- package/dist/index76.cjs +1 -1
- package/dist/index76.js +11 -6
- package/dist/index77.cjs +1 -1
- package/dist/index77.js +6 -13
- package/dist/index78.cjs +1 -1
- package/dist/index78.js +12 -31
- package/dist/index79.cjs +1 -1
- package/dist/index79.js +32 -14
- package/dist/index80.cjs +1 -1
- package/dist/index80.js +14 -64
- package/dist/index81.cjs +1 -1
- package/dist/index81.js +61 -24
- package/dist/index82.cjs +1 -1
- package/dist/index82.js +28 -3
- package/dist/index83.cjs +1 -1
- package/dist/index83.js +3 -4
- package/dist/index84.cjs +1 -1
- package/dist/index84.js +3 -8
- package/dist/index85.cjs +1 -1
- package/dist/index85.js +8 -191
- package/dist/index86.cjs +1 -1
- package/dist/index86.js +191 -18
- package/dist/index87.cjs +1 -1
- package/dist/index87.js +18 -8
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +1 -1
- package/dist/index91.cjs +1 -1
- package/dist/index91.js +1 -1
- package/dist/index94.cjs +1 -1
- package/dist/index94.js +6 -6
- package/dist/index96.cjs +1 -1
- package/dist/index96.js +10 -11
- package/dist/index97.cjs +1 -1
- package/dist/index97.js +18 -37
- package/dist/index98.cjs +1 -1
- package/dist/index98.js +39 -2
- package/dist/index99.cjs +1 -1
- package/dist/index99.js +13 -5
- package/package.json +1 -1
package/dist/index9.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index17.cjs"),f=require("./index13.cjs"),h=require("./index14.cjs"),d=require("viem"),o=require("./index3.cjs"),g=require("./index7.cjs"),w=require("./index19.cjs"),m=require("./index20.cjs"),y=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index17.cjs"),f=require("./index13.cjs"),h=require("./index14.cjs"),d=require("viem"),o=require("./index3.cjs"),g=require("./index7.cjs"),w=require("./index19.cjs"),m=require("./index20.cjs"),y=require("./index21.cjs");class c{constructor(n,i,e){this.API=new g.Url("https://api.garden.finance"),this.url=n??this.API,this.walletClient=i,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,i,e){const r=d.createWalletClient({account:w.privateKeyToAccount(o.add0x(i.digestKey)),transport:d.http(),chain:m.mainnet});return new c(n,r,e)}verifyToken(n,i){try{const e=o.parseJwt(n);if(!e)return t.Ok(!1);const r=Math.floor(Date.now()/1e3)+120;return t.Ok(e.exp>r&&e.user_id.toLowerCase()===i.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 i=await this.signStatement();if(i.error)return t.Err(i.error);const e=await t.Fetcher.post(this.url.endpoint("verify"),{body:JSON.stringify({...i.val}),headers:{"Content-Type":"application/json"}});if(e.error)return t.Err(e.error);const r=e.result;if(!r)return t.Err("Failed to get token");if(!this.verifyToken(r,this.walletClient.account.address).val)throw new Error("Token verification failed");return this.store.setItem(h.StoreKeys.AUTH_TOKEN,r),t.Ok(r)}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,i=new Date(n.getTime()+300*1e3),r=(await t.Fetcher.get(this.url.endpoint("nonce"))).result;if(!r)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:r,uri:"https://"+this.domain,version:"1",chainId:l,notBefore:i}),s=await this.walletClient.signMessage({account:this.walletClient.account,message:a});return t.Ok({message:a,signature:s,nonce:r})}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/index9.js
CHANGED
|
@@ -6,7 +6,7 @@ import { add0x as g, parseJwt as y, Authorization as p } from "./index3.js";
|
|
|
6
6
|
import { Url as v } from "./index7.js";
|
|
7
7
|
import { privateKeyToAccount as T } from "./index19.js";
|
|
8
8
|
import { mainnet as k } from "./index20.js";
|
|
9
|
-
import { createSiweMessage as C } from "./
|
|
9
|
+
import { createSiweMessage as C } from "./index21.js";
|
|
10
10
|
class m {
|
|
11
11
|
constructor(e, i, t) {
|
|
12
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();
|
package/dist/index91.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index64.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;
|
package/dist/index91.js
CHANGED
package/dist/index94.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("./index108.cjs"),w=require("./
|
|
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("./index64.cjs"),h=require("./index106.cjs"),d=require("./index66.cjs"),n=require("./index71.cjs"),c=require("./index51.cjs"),I=require("./index67.cjs"),u=require("./index98.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;
|
package/dist/index94.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { versionedHashVersionKzg as d } from "./index108.js";
|
|
2
|
-
import { maxUint256 as m } from "./
|
|
2
|
+
import { maxUint256 as m } from "./index102.js";
|
|
3
3
|
import { InvalidAddressError as s } from "./index50.js";
|
|
4
|
-
import { BaseError as h } from "./
|
|
4
|
+
import { BaseError as h } from "./index64.js";
|
|
5
5
|
import { EmptyBlobError as P, InvalidVersionedHashSizeError as p, InvalidVersionedHashVersionError as x } from "./index106.js";
|
|
6
|
-
import { InvalidChainIdError as n } from "./
|
|
7
|
-
import { FeeCapTooHighError as w, TipAboveFeeCapError as E } from "./
|
|
6
|
+
import { InvalidChainIdError as n } from "./index66.js";
|
|
7
|
+
import { FeeCapTooHighError as w, TipAboveFeeCapError as E } from "./index71.js";
|
|
8
8
|
import { isAddress as f } from "./index51.js";
|
|
9
|
-
import { size as F } from "./
|
|
10
|
-
import { slice as I } from "./
|
|
9
|
+
import { size as F } from "./index67.js";
|
|
10
|
+
import { slice as I } from "./index98.js";
|
|
11
11
|
import { hexToNumber as G } from "./index35.js";
|
|
12
12
|
function C(t) {
|
|
13
13
|
const { authorizationList: e } = t;
|
package/dist/index96.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index64.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/index96.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { BaseError as
|
|
2
|
-
class d extends
|
|
3
|
-
constructor(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { BaseError as i } from "./index64.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
10
|
}
|
|
11
11
|
}
|
|
12
12
|
export {
|
|
13
|
-
|
|
14
|
-
d as SliceOffsetOutOfBoundsError
|
|
13
|
+
d as SiweInvalidMessageFieldError
|
|
15
14
|
};
|
package/dist/index97.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function 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/index97.js
CHANGED
|
@@ -1,41 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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;
|
|
10
16
|
}
|
|
11
|
-
function
|
|
12
|
-
|
|
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;
|
|
17
|
+
function a(e) {
|
|
18
|
+
return e.match(/(?:([^:\/?#]+):)?(?:\/\/([^\/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?/);
|
|
36
19
|
}
|
|
37
20
|
export {
|
|
38
|
-
|
|
39
|
-
m as sliceBytes,
|
|
40
|
-
u as sliceHex
|
|
21
|
+
o as isUri
|
|
41
22
|
};
|
package/dist/index98.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index99.cjs"),O=require("./index84.cjs"),n=require("./index67.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;
|
package/dist/index98.js
CHANGED
|
@@ -1,4 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
import { SliceOffsetOutOfBoundsError as t } from "./index99.js";
|
|
2
|
+
import { isHex as p } from "./index84.js";
|
|
3
|
+
import { size as r } from "./index67.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
|
+
}
|
|
2
37
|
export {
|
|
3
|
-
|
|
38
|
+
w as slice,
|
|
39
|
+
m as sliceBytes,
|
|
40
|
+
u as sliceHex
|
|
4
41
|
};
|
package/dist/index99.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index64.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;
|
package/dist/index99.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
1
|
+
import { BaseError as o } from "./index64.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
|
+
}
|
|
5
12
|
export {
|
|
6
|
-
|
|
13
|
+
n as SizeExceedsPaddingSizeError,
|
|
14
|
+
d as SliceOffsetOutOfBoundsError
|
|
7
15
|
};
|