@gvnrdao/dh-sdk 0.0.272 → 0.0.273
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/browser/dist/browser.js +1 -1
- package/dist/index.js +14 -3
- package/dist/index.mjs +14 -3
- package/dist/utils/service-endpoint-policy.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -34716,6 +34716,12 @@ function getSepoliaConfig() {
|
|
|
34716
34716
|
});
|
|
34717
34717
|
return {
|
|
34718
34718
|
mode: "service",
|
|
34719
|
+
// No production default — fail closed if unset. A missing LIT_OPS_ENDPOINT must
|
|
34720
|
+
// NOT silently route signed/authenticated requests to the production service:
|
|
34721
|
+
// that masks misconfiguration in local/dev/test. Returns "" when unset (Node:
|
|
34722
|
+
// env missing; browser: always), so downstream validateServiceModeConfig throws.
|
|
34723
|
+
// Node consumers must set LIT_OPS_ENDPOINT; browser apps pass serviceEndpoint
|
|
34724
|
+
// explicitly from decrypted /v1/init (user config still wins over this).
|
|
34719
34725
|
serviceEndpoint: readInitBackedEnv("LIT_OPS_ENDPOINT"),
|
|
34720
34726
|
chainId: 11155111,
|
|
34721
34727
|
name: "sepolia",
|
|
@@ -107694,7 +107700,8 @@ function assertSafeServiceEndpoint(endpoint) {
|
|
|
107694
107700
|
if (url.protocol === "http:") {
|
|
107695
107701
|
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
107696
107702
|
const isLoopback = host === "localhost" || host === "127.0.0.1" || host === "::1" || // IPv4 loopback range 127.0.0.0/8 (numeric — not resolvable/hijackable).
|
|
107697
|
-
|
|
107703
|
+
// Each of the trailing three octets must be a valid 0–255 value.
|
|
107704
|
+
/^127\.(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){2}(?:25[0-5]|2[0-4]\d|1?\d?\d)$/.test(host);
|
|
107698
107705
|
if (isLoopback)
|
|
107699
107706
|
return;
|
|
107700
107707
|
throw new Error(
|
|
@@ -123004,11 +123011,15 @@ Error data: ${errorData || "none"}`
|
|
|
123004
123011
|
async getAddressBalance(vaultAddress) {
|
|
123005
123012
|
this.ensureInitialized();
|
|
123006
123013
|
try {
|
|
123007
|
-
if (this.config
|
|
123014
|
+
if (!isServiceModeConfig(this.config)) {
|
|
123008
123015
|
throw new Error("getAddressBalance requires service mode \u2014 standalone mode is not supported");
|
|
123009
123016
|
}
|
|
123017
|
+
const trimmedAddress = vaultAddress?.trim();
|
|
123018
|
+
if (!trimmedAddress) {
|
|
123019
|
+
throw new Error("vaultAddress is required");
|
|
123020
|
+
}
|
|
123010
123021
|
const serviceEndpoint = this.config.serviceEndpoint;
|
|
123011
|
-
const url = `${serviceEndpoint}/api/lit/address-balance?vaultAddress=${encodeURIComponent(
|
|
123022
|
+
const url = `${serviceEndpoint}/api/lit/address-balance?vaultAddress=${encodeURIComponent(trimmedAddress)}`;
|
|
123012
123023
|
const response = await fetch(url, {
|
|
123013
123024
|
headers: await this.getAuthHeader()
|
|
123014
123025
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -34722,6 +34722,12 @@ function getSepoliaConfig() {
|
|
|
34722
34722
|
});
|
|
34723
34723
|
return {
|
|
34724
34724
|
mode: "service",
|
|
34725
|
+
// No production default — fail closed if unset. A missing LIT_OPS_ENDPOINT must
|
|
34726
|
+
// NOT silently route signed/authenticated requests to the production service:
|
|
34727
|
+
// that masks misconfiguration in local/dev/test. Returns "" when unset (Node:
|
|
34728
|
+
// env missing; browser: always), so downstream validateServiceModeConfig throws.
|
|
34729
|
+
// Node consumers must set LIT_OPS_ENDPOINT; browser apps pass serviceEndpoint
|
|
34730
|
+
// explicitly from decrypted /v1/init (user config still wins over this).
|
|
34725
34731
|
serviceEndpoint: readInitBackedEnv("LIT_OPS_ENDPOINT"),
|
|
34726
34732
|
chainId: 11155111,
|
|
34727
34733
|
name: "sepolia",
|
|
@@ -107618,7 +107624,8 @@ function assertSafeServiceEndpoint(endpoint) {
|
|
|
107618
107624
|
if (url.protocol === "http:") {
|
|
107619
107625
|
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
107620
107626
|
const isLoopback = host === "localhost" || host === "127.0.0.1" || host === "::1" || // IPv4 loopback range 127.0.0.0/8 (numeric — not resolvable/hijackable).
|
|
107621
|
-
|
|
107627
|
+
// Each of the trailing three octets must be a valid 0–255 value.
|
|
107628
|
+
/^127\.(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){2}(?:25[0-5]|2[0-4]\d|1?\d?\d)$/.test(host);
|
|
107622
107629
|
if (isLoopback)
|
|
107623
107630
|
return;
|
|
107624
107631
|
throw new Error(
|
|
@@ -122928,11 +122935,15 @@ Error data: ${errorData || "none"}`
|
|
|
122928
122935
|
async getAddressBalance(vaultAddress) {
|
|
122929
122936
|
this.ensureInitialized();
|
|
122930
122937
|
try {
|
|
122931
|
-
if (this.config
|
|
122938
|
+
if (!isServiceModeConfig(this.config)) {
|
|
122932
122939
|
throw new Error("getAddressBalance requires service mode \u2014 standalone mode is not supported");
|
|
122933
122940
|
}
|
|
122941
|
+
const trimmedAddress = vaultAddress?.trim();
|
|
122942
|
+
if (!trimmedAddress) {
|
|
122943
|
+
throw new Error("vaultAddress is required");
|
|
122944
|
+
}
|
|
122934
122945
|
const serviceEndpoint = this.config.serviceEndpoint;
|
|
122935
|
-
const url = `${serviceEndpoint}/api/lit/address-balance?vaultAddress=${encodeURIComponent(
|
|
122946
|
+
const url = `${serviceEndpoint}/api/lit/address-balance?vaultAddress=${encodeURIComponent(trimmedAddress)}`;
|
|
122936
122947
|
const response = await fetch(url, {
|
|
122937
122948
|
headers: await this.getAuthHeader()
|
|
122938
122949
|
});
|
|
@@ -8,5 +8,9 @@
|
|
|
8
8
|
* loopback by RFC 6761, but not every resolver honours it strictly — a hostile or misconfigured
|
|
9
9
|
* DNS could resolve `foo.localhost` to an off-host IP and exfiltrate the cleartext token. Exact
|
|
10
10
|
* loopback literals + the numeric 127.0.0.0/8 range can't be DNS-hijacked.
|
|
11
|
+
*
|
|
12
|
+
* IPv4-mapped IPv6 loopback (e.g. `http://[::ffff:127.0.0.1]`) is intentionally NOT accepted: the
|
|
13
|
+
* URL parser normalises it to a hex form (`[::ffff:7f00:1]`) that is fragile to match safely. Use
|
|
14
|
+
* `127.0.0.1`, `::1`, or `localhost` for local development.
|
|
11
15
|
*/
|
|
12
16
|
export declare function assertSafeServiceEndpoint(endpoint: string): void;
|
package/package.json
CHANGED