@seedprotocol/arweave 0.7.8 → 0.7.9-next.1177.ga3e08ed
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/gateway/publicUrl.d.ts +9 -0
- package/dist/gateway/publicUrl.d.ts.map +1 -0
- package/dist/gateway/resolveSeedGatewayEndpoints.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +83 -75
- package/dist/index.js.map +1 -1
- package/dist/node.js +1 -1
- package/dist/{transactionStatus-BpYIaQyY.js → transactionStatus-zdutyXNX.js} +164 -157
- package/dist/transactionStatus-zdutyXNX.js.map +1 -0
- package/dist/types/gateway.d.ts +6 -0
- package/dist/types/gateway.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/transactionStatus-BpYIaQyY.js.map +0 -1
|
@@ -16,20 +16,20 @@ function te(e) {
|
|
|
16
16
|
let t = e.trim();
|
|
17
17
|
return t.startsWith("http://") ? t.slice(7).replace(/\/$/, "") : t.startsWith("https://") ? t.slice(8).replace(/\/$/, "") : t.replace(/\/$/, "");
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function c() {
|
|
20
20
|
if (typeof process < "u" && process.env) for (let e of ee) {
|
|
21
21
|
let t = process.env[e]?.trim();
|
|
22
22
|
if (t) return te(t);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function ne(t, n) {
|
|
26
26
|
let r = t.trim().toLowerCase().replace(/\/$/, ""), i = e.toLowerCase();
|
|
27
27
|
return r === i ? [...n] : n.filter((e) => e.toLowerCase() !== i);
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
return
|
|
29
|
+
function l(e) {
|
|
30
|
+
return d(e, ne(e, u()));
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function u() {
|
|
33
33
|
if (typeof process > "u" || !process.env) return [...o];
|
|
34
34
|
for (let e of s) {
|
|
35
35
|
let t = process.env[e]?.trim();
|
|
@@ -37,7 +37,7 @@ function l() {
|
|
|
37
37
|
}
|
|
38
38
|
return [...o];
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function d(e, t) {
|
|
41
41
|
let n = /* @__PURE__ */ new Set(), r = [], i = (e) => e.trim().toLowerCase().replace(/\/$/, ""), a = (e) => {
|
|
42
42
|
let t = e.trim().replace(/\/$/, "");
|
|
43
43
|
if (!t) return;
|
|
@@ -48,7 +48,7 @@ function u(e, t) {
|
|
|
48
48
|
for (let e of t) a(e);
|
|
49
49
|
return r;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function re(e) {
|
|
52
52
|
let t = e.trim().toLowerCase();
|
|
53
53
|
if (!t) return !1;
|
|
54
54
|
if (t.endsWith("arweave.net") || t.endsWith("ar-io.net")) return !0;
|
|
@@ -60,23 +60,23 @@ function ie(e) {
|
|
|
60
60
|
}
|
|
61
61
|
//#endregion
|
|
62
62
|
//#region src/content/arweaveContent.ts
|
|
63
|
-
var
|
|
64
|
-
function
|
|
65
|
-
|
|
63
|
+
var f;
|
|
64
|
+
function ie(e) {
|
|
65
|
+
f = e;
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
return
|
|
67
|
+
function ae() {
|
|
68
|
+
return f !== void 0;
|
|
69
69
|
}
|
|
70
70
|
async function p(e, t) {
|
|
71
|
-
return
|
|
71
|
+
return f ? f(e, t) : e;
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function oe(e) {
|
|
74
74
|
return (e.headers?.get("content-type"))?.split(";")[0]?.trim().toLowerCase() || void 0;
|
|
75
75
|
}
|
|
76
|
-
async function
|
|
76
|
+
async function m(e, t) {
|
|
77
77
|
return p({
|
|
78
78
|
bytes: new Uint8Array(await e.arrayBuffer()),
|
|
79
|
-
contentType:
|
|
79
|
+
contentType: oe(e)
|
|
80
80
|
}, t);
|
|
81
81
|
}
|
|
82
82
|
//#endregion
|
|
@@ -126,7 +126,7 @@ var v = e, y = "https", b = !1, x = !1, S = class e {
|
|
|
126
126
|
return e._impl;
|
|
127
127
|
}
|
|
128
128
|
static resolveGateway() {
|
|
129
|
-
let e =
|
|
129
|
+
let e = c();
|
|
130
130
|
return e && !b && !x ? _(e) : {
|
|
131
131
|
protocol: y,
|
|
132
132
|
host: v
|
|
@@ -202,7 +202,7 @@ var v = e, y = "https", b = !1, x = !1, S = class e {
|
|
|
202
202
|
}
|
|
203
203
|
static async getTransactionData(t, n) {
|
|
204
204
|
let r = await e.requireImpl().getTransactionData(t, n);
|
|
205
|
-
if (n?.decode === !1 || !
|
|
205
|
+
if (n?.decode === !1 || !ae()) return r;
|
|
206
206
|
let i = typeof r == "string", { bytes: a } = await p({ bytes: i ? new TextEncoder().encode(r) : r }, { transactionId: t });
|
|
207
207
|
return i ? new TextDecoder().decode(a) : a;
|
|
208
208
|
}
|
|
@@ -569,88 +569,88 @@ var v = e, y = "https", b = !1, x = !1, S = class e {
|
|
|
569
569
|
}]
|
|
570
570
|
}
|
|
571
571
|
};
|
|
572
|
-
function
|
|
572
|
+
function fe(e) {
|
|
573
573
|
return de[e] ?? {};
|
|
574
574
|
}
|
|
575
575
|
//#endregion
|
|
576
576
|
//#region src/ArweaveClient/queries.ts
|
|
577
|
-
var
|
|
578
|
-
function
|
|
577
|
+
var pe = fe("\n query GetTransactionTags($transactionId: ID!) {\n tags: transaction(id: $transactionId) {\n id\n tags {\n name\n value\n }\n }\n }\n"), me = fe("\n query GetArweaveTransactions(\n $owners: [String!]\n $first: Int\n $after: String\n ) {\n transactions(owners: $owners, first: $first, after: $after) {\n edges {\n cursor\n node {\n id\n anchor\n signature\n block {\n id\n height\n }\n data {\n size\n type\n }\n tags {\n name\n value\n }\n }\n }\n pageInfo {\n hasNextPage\n }\n }\n }\n"), C = 1, w = 6e4, T = C, E = w, D = /* @__PURE__ */ new Map();
|
|
578
|
+
function O(e) {
|
|
579
579
|
let t = e.trim();
|
|
580
580
|
return t ? (t.startsWith("http://") ? t = t.slice(7) : t.startsWith("https://") && (t = t.slice(8)), t.replace(/\/$/, "").toLowerCase()) : "";
|
|
581
581
|
}
|
|
582
|
-
function
|
|
583
|
-
let t =
|
|
582
|
+
function he(e) {
|
|
583
|
+
let t = D.get(e);
|
|
584
584
|
return t || (t = {
|
|
585
585
|
failures: 0,
|
|
586
586
|
openedAt: null,
|
|
587
587
|
halfOpenProbeInFlight: !1
|
|
588
|
-
},
|
|
588
|
+
}, D.set(e, t)), t;
|
|
589
589
|
}
|
|
590
|
-
function
|
|
591
|
-
return e.openedAt == null ? "closed" : t - e.openedAt >=
|
|
590
|
+
function k(e, t) {
|
|
591
|
+
return e.openedAt == null ? "closed" : t - e.openedAt >= E ? "half-open" : "open";
|
|
592
592
|
}
|
|
593
|
-
function
|
|
594
|
-
e.failureThreshold != null && e.failureThreshold >= 1 && (
|
|
593
|
+
function ge(e) {
|
|
594
|
+
e.failureThreshold != null && e.failureThreshold >= 1 && (T = e.failureThreshold), e.openDurationMs != null && e.openDurationMs >= 0 && (E = e.openDurationMs);
|
|
595
595
|
}
|
|
596
|
-
function
|
|
597
|
-
|
|
596
|
+
function A() {
|
|
597
|
+
D.clear(), T = C, E = w;
|
|
598
598
|
}
|
|
599
599
|
function j(e, t = Date.now()) {
|
|
600
|
-
let n =
|
|
600
|
+
let n = O(e);
|
|
601
601
|
if (!n) return !1;
|
|
602
|
-
let r =
|
|
602
|
+
let r = D.get(n);
|
|
603
603
|
if (!r) return !1;
|
|
604
|
-
let i =
|
|
604
|
+
let i = k(r, t);
|
|
605
605
|
return !!(i === "open" || i === "half-open" && r.halfOpenProbeInFlight);
|
|
606
606
|
}
|
|
607
607
|
function _e(e, t = Date.now()) {
|
|
608
|
-
let n =
|
|
608
|
+
let n = O(e);
|
|
609
609
|
if (!n) return "closed";
|
|
610
|
-
let r =
|
|
611
|
-
return r ?
|
|
610
|
+
let r = D.get(n);
|
|
611
|
+
return r ? k(r, t) : "closed";
|
|
612
612
|
}
|
|
613
|
-
function
|
|
614
|
-
let n =
|
|
613
|
+
function M(e, t = Date.now()) {
|
|
614
|
+
let n = O(e);
|
|
615
615
|
if (!n) return;
|
|
616
|
-
let r =
|
|
617
|
-
|
|
616
|
+
let r = he(n);
|
|
617
|
+
k(r, t) === "half-open" && (r.halfOpenProbeInFlight = !0);
|
|
618
618
|
}
|
|
619
|
-
function
|
|
620
|
-
let t =
|
|
621
|
-
t &&
|
|
619
|
+
function N(e) {
|
|
620
|
+
let t = O(e);
|
|
621
|
+
t && D.set(t, {
|
|
622
622
|
failures: 0,
|
|
623
623
|
openedAt: null,
|
|
624
624
|
halfOpenProbeInFlight: !1
|
|
625
625
|
});
|
|
626
626
|
}
|
|
627
|
-
function
|
|
628
|
-
let n =
|
|
627
|
+
function P(e, t = Date.now()) {
|
|
628
|
+
let n = O(e);
|
|
629
629
|
if (!n) return;
|
|
630
|
-
let r =
|
|
631
|
-
r.failures += 1, r.halfOpenProbeInFlight = !1, r.failures >=
|
|
630
|
+
let r = he(n);
|
|
631
|
+
r.failures += 1, r.halfOpenProbeInFlight = !1, r.failures >= T && (r.openedAt = t);
|
|
632
632
|
}
|
|
633
|
-
function
|
|
633
|
+
function ve(e = Date.now()) {
|
|
634
634
|
let t = [];
|
|
635
|
-
for (let n of
|
|
635
|
+
for (let n of D.keys()) j(n, e) && t.push(n);
|
|
636
636
|
return t;
|
|
637
637
|
}
|
|
638
638
|
//#endregion
|
|
639
639
|
//#region src/ArweaveClient/selectReadGateway.ts
|
|
640
|
-
var
|
|
641
|
-
function
|
|
642
|
-
|
|
640
|
+
var F = 18e4, ye = 6e4, be = 5e3, I = null, L = null, R = null;
|
|
641
|
+
function z() {
|
|
642
|
+
I = null, L = null;
|
|
643
|
+
}
|
|
644
|
+
function xe() {
|
|
645
|
+
z(), R = null, A(), S.resetReadGatewaySelectionStateForTests(), S.isReadGatewayLocked() || S.setPreferredReadGateway(e);
|
|
643
646
|
}
|
|
644
647
|
function Se() {
|
|
645
|
-
|
|
648
|
+
return S.isReadGatewayLocked() ? !0 : I && Date.now() < I.expiresAt ? I.healthy : R != null;
|
|
646
649
|
}
|
|
647
650
|
function Ce() {
|
|
648
|
-
return
|
|
651
|
+
return R;
|
|
649
652
|
}
|
|
650
|
-
function
|
|
651
|
-
return L;
|
|
652
|
-
}
|
|
653
|
-
async function z(e, t) {
|
|
653
|
+
async function B(e, t) {
|
|
654
654
|
let n = `${e.replace(/\/$/, "")}/info`, r = e;
|
|
655
655
|
try {
|
|
656
656
|
r = new URL(e.includes("://") ? e : `https://${e}`).host;
|
|
@@ -658,79 +658,79 @@ async function z(e, t) {
|
|
|
658
658
|
r = e.replace(/^https?:\/\//, "").replace(/\/$/, "");
|
|
659
659
|
}
|
|
660
660
|
if (j(r)) return !1;
|
|
661
|
-
|
|
661
|
+
M(r);
|
|
662
662
|
let i, a = new AbortController(), o = t ?? a.signal;
|
|
663
|
-
t || (i = setTimeout(() => a.abort(),
|
|
663
|
+
t || (i = setTimeout(() => a.abort(), be));
|
|
664
664
|
try {
|
|
665
665
|
let e = await fetch(n, {
|
|
666
666
|
method: "GET",
|
|
667
667
|
signal: o,
|
|
668
668
|
headers: { Accept: "application/json" }
|
|
669
669
|
});
|
|
670
|
-
if (!e.ok) return
|
|
670
|
+
if (!e.ok) return P(r), !1;
|
|
671
671
|
let t = await e.text();
|
|
672
|
-
if (!t.trim()) return
|
|
672
|
+
if (!t.trim()) return P(r), !1;
|
|
673
673
|
try {
|
|
674
674
|
let e = JSON.parse(t), n = typeof e == "object" && !!e;
|
|
675
|
-
return n ?
|
|
675
|
+
return n ? N(r) : P(r), n;
|
|
676
676
|
} catch {
|
|
677
|
-
return
|
|
677
|
+
return P(r), !1;
|
|
678
678
|
}
|
|
679
679
|
} catch {
|
|
680
|
-
return
|
|
680
|
+
return P(r), !1;
|
|
681
681
|
} finally {
|
|
682
682
|
i && clearTimeout(i);
|
|
683
683
|
}
|
|
684
684
|
}
|
|
685
|
-
async function
|
|
685
|
+
async function V(e, t = "https", n) {
|
|
686
686
|
for (let r of e) {
|
|
687
687
|
let e = r.trim().replace(/\/$/, "");
|
|
688
|
-
if (e && !j(e) && await
|
|
688
|
+
if (e && !j(e) && await B(`${t}://${e}`, n)) return e;
|
|
689
689
|
}
|
|
690
690
|
return null;
|
|
691
691
|
}
|
|
692
|
-
function
|
|
693
|
-
return
|
|
692
|
+
function we() {
|
|
693
|
+
return l(S.getHost());
|
|
694
694
|
}
|
|
695
|
-
async function
|
|
695
|
+
async function H(e) {
|
|
696
696
|
if (S.isReadGatewayLocked()) return S.getHost();
|
|
697
|
-
if (
|
|
698
|
-
if (
|
|
699
|
-
|
|
700
|
-
let t = await
|
|
701
|
-
if (S.isReadGatewayLocked())
|
|
697
|
+
if (I && Date.now() < I.expiresAt) return I.host;
|
|
698
|
+
if (L) return L;
|
|
699
|
+
L = (async () => {
|
|
700
|
+
let t = await V(we(), S.getProtocol(), e);
|
|
701
|
+
if (S.isReadGatewayLocked()) I = {
|
|
702
702
|
host: S.getHost(),
|
|
703
703
|
healthy: !0,
|
|
704
|
-
expiresAt: Date.now() +
|
|
704
|
+
expiresAt: Date.now() + F
|
|
705
705
|
};
|
|
706
|
-
else if (t) S.applyProbedReadGateway(t),
|
|
706
|
+
else if (t) S.applyProbedReadGateway(t), R = t, I = {
|
|
707
707
|
host: t,
|
|
708
708
|
healthy: !0,
|
|
709
|
-
expiresAt: Date.now() +
|
|
709
|
+
expiresAt: Date.now() + F
|
|
710
710
|
};
|
|
711
711
|
else {
|
|
712
|
-
let e =
|
|
713
|
-
|
|
712
|
+
let e = R ?? S.getHost();
|
|
713
|
+
R && S.getHost() !== R && S.applyProbedReadGateway(R), I = {
|
|
714
714
|
host: e,
|
|
715
715
|
healthy: !1,
|
|
716
|
-
expiresAt: Date.now() +
|
|
716
|
+
expiresAt: Date.now() + ye
|
|
717
717
|
};
|
|
718
718
|
}
|
|
719
|
-
return
|
|
719
|
+
return I.host;
|
|
720
720
|
})();
|
|
721
721
|
try {
|
|
722
|
-
return await
|
|
722
|
+
return await L;
|
|
723
723
|
} finally {
|
|
724
|
-
|
|
724
|
+
L = null;
|
|
725
725
|
}
|
|
726
726
|
}
|
|
727
727
|
//#endregion
|
|
728
728
|
//#region src/gateway/resolveSeedGatewayEndpoints.ts
|
|
729
|
-
var
|
|
730
|
-
function
|
|
731
|
-
|
|
729
|
+
var U = 18e4, W = null, G = /* @__PURE__ */ new Map();
|
|
730
|
+
function K() {
|
|
731
|
+
W = null, G.clear();
|
|
732
732
|
}
|
|
733
|
-
function
|
|
733
|
+
function Te(e) {
|
|
734
734
|
let t = (e ?? "ar.seedprotocol.io").trim();
|
|
735
735
|
return t.startsWith("http://") ? {
|
|
736
736
|
protocol: "http",
|
|
@@ -743,7 +743,11 @@ function Ee(e) {
|
|
|
743
743
|
host: t.replace(/\/$/, "")
|
|
744
744
|
};
|
|
745
745
|
}
|
|
746
|
-
function
|
|
746
|
+
function Ee(e) {
|
|
747
|
+
let { host: t, protocol: n } = Te(e.arweaveDomain);
|
|
748
|
+
return `${n}://${t}`;
|
|
749
|
+
}
|
|
750
|
+
function De(e) {
|
|
747
751
|
let t = e.hyper?.localSidecarHost?.trim() || "127.0.0.1", n = e.hyper?.localSidecarPort ?? 1984;
|
|
748
752
|
return {
|
|
749
753
|
host: n === 80 || n === 443 ? t : `${t}:${n}`,
|
|
@@ -751,7 +755,7 @@ function K(e) {
|
|
|
751
755
|
baseUrl: `http://${t}:${n}`
|
|
752
756
|
};
|
|
753
757
|
}
|
|
754
|
-
function
|
|
758
|
+
function Oe() {
|
|
755
759
|
try {
|
|
756
760
|
let e = globalThis.window?.location?.origin;
|
|
757
761
|
return typeof e == "string" && e.length > 0 ? e.replace(/\/$/, "") : void 0;
|
|
@@ -764,7 +768,7 @@ function q(e, t) {
|
|
|
764
768
|
if (!n) throw Error("proxyBaseUrl is empty");
|
|
765
769
|
if (n.startsWith("http://") || n.startsWith("https://")) return n.replace(/\/$/, "");
|
|
766
770
|
if (n.startsWith("/")) {
|
|
767
|
-
let r = (t?.origin?.trim() ||
|
|
771
|
+
let r = (t?.origin?.trim() || Oe() || "").replace(/\/$/, "");
|
|
768
772
|
if (!r) throw Error(`Relative proxyBaseUrl "${e}" requires a browser origin or resolve options.origin`);
|
|
769
773
|
return `${r}${n.replace(/\/$/, "")}`;
|
|
770
774
|
}
|
|
@@ -773,23 +777,23 @@ function q(e, t) {
|
|
|
773
777
|
async function J(e, t, n) {
|
|
774
778
|
let r = Date.now();
|
|
775
779
|
if (t === "sidecar") {
|
|
776
|
-
if (
|
|
777
|
-
let t = await
|
|
778
|
-
return
|
|
780
|
+
if (W && r < W.expiresAt) return W.healthy;
|
|
781
|
+
let t = await B(e, n);
|
|
782
|
+
return W = {
|
|
779
783
|
healthy: t,
|
|
780
|
-
expiresAt: r +
|
|
784
|
+
expiresAt: r + U
|
|
781
785
|
}, t;
|
|
782
786
|
}
|
|
783
|
-
let i =
|
|
787
|
+
let i = G.get(t);
|
|
784
788
|
if (i && r < i.expiresAt) return i.healthy;
|
|
785
|
-
let a = await
|
|
786
|
-
return
|
|
789
|
+
let a = await B(e, n);
|
|
790
|
+
return G.set(t, {
|
|
787
791
|
healthy: a,
|
|
788
|
-
expiresAt: r +
|
|
792
|
+
expiresAt: r + U
|
|
789
793
|
}), a;
|
|
790
794
|
}
|
|
791
|
-
function
|
|
792
|
-
let { host: t, protocol: n } =
|
|
795
|
+
function ke(e) {
|
|
796
|
+
let { host: t, protocol: n } = Te(e.arweaveDomain), r = `${n}://${t}`, i = e.uploadApiBaseUrl?.trim() || r;
|
|
793
797
|
return {
|
|
794
798
|
mode: e.transport ?? "http-gateway",
|
|
795
799
|
arweaveHost: t,
|
|
@@ -798,11 +802,12 @@ function Oe(e) {
|
|
|
798
802
|
arweaveGraphqlUrl: `${n}://${t}/graphql`,
|
|
799
803
|
uploadApiBaseUrl: i,
|
|
800
804
|
activePath: "http",
|
|
801
|
-
gatewayHyperKey: e.hyper?.gatewayHyperKey?.trim() || void 0
|
|
805
|
+
gatewayHyperKey: e.hyper?.gatewayHyperKey?.trim() || void 0,
|
|
806
|
+
publicArweaveBaseUrl: r
|
|
802
807
|
};
|
|
803
808
|
}
|
|
804
|
-
function
|
|
805
|
-
let t =
|
|
809
|
+
function Ae(e) {
|
|
810
|
+
let t = De(e), n = e.hyper?.gatewayHyperKey?.trim();
|
|
806
811
|
return {
|
|
807
812
|
mode: "hyper",
|
|
808
813
|
arweaveHost: t.host,
|
|
@@ -811,10 +816,11 @@ function Y(e) {
|
|
|
811
816
|
arweaveGraphqlUrl: `${t.baseUrl}/graphql`,
|
|
812
817
|
uploadApiBaseUrl: t.baseUrl,
|
|
813
818
|
activePath: "hyper-sidecar",
|
|
814
|
-
gatewayHyperKey: n || void 0
|
|
819
|
+
gatewayHyperKey: n || void 0,
|
|
820
|
+
publicArweaveBaseUrl: Ee(e)
|
|
815
821
|
};
|
|
816
822
|
}
|
|
817
|
-
function
|
|
823
|
+
function je(e, t) {
|
|
818
824
|
let n = new URL(t), r = n.protocol === "http:" ? "http" : "https", i = n.pathname.replace(/\/$/, ""), a = i ? `${n.host}${i}` : n.host, o = `${r}://${a}`;
|
|
819
825
|
return {
|
|
820
826
|
mode: e.transport ?? "http-gateway",
|
|
@@ -825,56 +831,57 @@ function ke(e, t) {
|
|
|
825
831
|
uploadApiBaseUrl: o,
|
|
826
832
|
activePath: "http-proxy",
|
|
827
833
|
gatewayHyperKey: e.hyper?.gatewayHyperKey?.trim() || void 0,
|
|
828
|
-
proxyBaseUrl: t
|
|
834
|
+
proxyBaseUrl: t,
|
|
835
|
+
publicArweaveBaseUrl: Ee(e)
|
|
829
836
|
};
|
|
830
837
|
}
|
|
831
|
-
async function
|
|
838
|
+
async function Me(e, t) {
|
|
832
839
|
let n = e.proxyBaseUrl?.trim();
|
|
833
840
|
if (!n) return null;
|
|
834
841
|
let r = q(n, { origin: t?.origin });
|
|
835
|
-
return e.hyper?.probeSidecar !== !1 && !await J(r, `proxy:${r}`, t?.signal) ? null :
|
|
842
|
+
return e.hyper?.probeSidecar !== !1 && !await J(r, `proxy:${r}`, t?.signal) ? null : je(e, r);
|
|
836
843
|
}
|
|
837
|
-
async function
|
|
838
|
-
t?.forceSidecarProbe &&
|
|
844
|
+
async function Ne(e, t) {
|
|
845
|
+
t?.forceSidecarProbe && K();
|
|
839
846
|
let n = e.transport ?? "http-gateway", r = e.hyper?.probeSidecar !== !1;
|
|
840
847
|
if (n === "http-gateway") {
|
|
841
848
|
if (e.proxyBaseUrl?.trim()) {
|
|
842
849
|
let i = q(e.proxyBaseUrl, { origin: t?.origin });
|
|
843
850
|
if (r && !await J(i, `proxy:${i}`, t?.signal)) throw Error(`Gateway HTTP proxy not reachable at ${i}. Ensure your Node route runs createGatewayProxy (or equivalent) and mounts at proxyBaseUrl.`);
|
|
844
|
-
return
|
|
851
|
+
return je({
|
|
845
852
|
...e,
|
|
846
853
|
transport: n
|
|
847
854
|
}, i);
|
|
848
855
|
}
|
|
849
|
-
return
|
|
856
|
+
return ke({
|
|
850
857
|
...e,
|
|
851
858
|
transport: n
|
|
852
859
|
});
|
|
853
860
|
}
|
|
854
861
|
if (n === "hyper") {
|
|
855
|
-
let i = await
|
|
862
|
+
let i = await Me({
|
|
856
863
|
...e,
|
|
857
864
|
transport: n
|
|
858
865
|
}, t);
|
|
859
866
|
if (i) return i;
|
|
860
|
-
let a =
|
|
867
|
+
let a = Ae({
|
|
861
868
|
...e,
|
|
862
869
|
transport: n
|
|
863
870
|
});
|
|
864
871
|
if (r && !await J(a.arweaveBaseUrl, "sidecar", t?.signal)) throw Error(`Gateway Hyper sidecar not reachable at ${a.arweaveBaseUrl}. Run: seed-gateway connect <operator-z32-key> — or configure gateway.proxyBaseUrl for an app-server proxy.`);
|
|
865
872
|
return a;
|
|
866
873
|
}
|
|
867
|
-
let i = await
|
|
874
|
+
let i = await Me({
|
|
868
875
|
...e,
|
|
869
876
|
transport: n
|
|
870
877
|
}, t);
|
|
871
878
|
if (i) return i;
|
|
872
|
-
let a =
|
|
873
|
-
return r && await J(a.baseUrl, "sidecar", t?.signal) ?
|
|
879
|
+
let a = De(e);
|
|
880
|
+
return r && await J(a.baseUrl, "sidecar", t?.signal) ? Ae({
|
|
874
881
|
...e,
|
|
875
882
|
transport: "hyper"
|
|
876
883
|
}) : {
|
|
877
|
-
...
|
|
884
|
+
...ke({
|
|
878
885
|
...e,
|
|
879
886
|
transport: "http-gateway"
|
|
880
887
|
}),
|
|
@@ -882,23 +889,23 @@ async function je(e, t) {
|
|
|
882
889
|
activePath: "hybrid-fallback-http"
|
|
883
890
|
};
|
|
884
891
|
}
|
|
885
|
-
function
|
|
886
|
-
return e.activePath === "hyper-sidecar" || e.activePath === "http-proxy" ? [e.arweaveHost] :
|
|
892
|
+
function Pe(e, t) {
|
|
893
|
+
return e.activePath === "hyper-sidecar" || e.activePath === "http-proxy" ? [e.arweaveHost] : l(e.arweaveHost);
|
|
887
894
|
}
|
|
888
895
|
//#endregion
|
|
889
896
|
//#region src/gateway/gatewayState.ts
|
|
890
|
-
var
|
|
891
|
-
function
|
|
892
|
-
return Ne;
|
|
893
|
-
}
|
|
894
|
-
function Pe(e) {
|
|
895
|
-
Ne = e;
|
|
896
|
-
}
|
|
897
|
-
var Fe = [];
|
|
898
|
-
function Z() {
|
|
897
|
+
var Fe = null;
|
|
898
|
+
function Y() {
|
|
899
899
|
return Fe;
|
|
900
900
|
}
|
|
901
901
|
function Ie(e) {
|
|
902
|
+
Fe = e;
|
|
903
|
+
}
|
|
904
|
+
var Le = [];
|
|
905
|
+
function X() {
|
|
906
|
+
return Le;
|
|
907
|
+
}
|
|
908
|
+
function Re(e) {
|
|
902
909
|
let t = [], n = /* @__PURE__ */ new Set();
|
|
903
910
|
for (let r of e) {
|
|
904
911
|
let e = r?.trim();
|
|
@@ -912,37 +919,37 @@ function Ie(e) {
|
|
|
912
919
|
}
|
|
913
920
|
n.has(i) || (n.add(i), t.push(i));
|
|
914
921
|
}
|
|
915
|
-
|
|
922
|
+
Le = t;
|
|
916
923
|
}
|
|
917
924
|
//#endregion
|
|
918
925
|
//#region src/gateway/readBaseUrls.ts
|
|
919
|
-
var
|
|
920
|
-
function
|
|
926
|
+
var ze = 1e4;
|
|
927
|
+
function Z(e, t, n) {
|
|
921
928
|
let r = n.trim().replace(/\/$/, "");
|
|
922
929
|
r && !t.has(r) && (t.add(r), e.push(r));
|
|
923
930
|
}
|
|
924
|
-
function
|
|
925
|
-
let t =
|
|
931
|
+
function Q(e) {
|
|
932
|
+
let t = Y(), n = S.getProtocol(), r = t ? Pe(t) : e?.fallbackHosts?.length ? [...e.fallbackHosts] : l(S.getHost()), i = [], a = /* @__PURE__ */ new Set();
|
|
926
933
|
for (let e of r) {
|
|
927
934
|
let t = e.trim();
|
|
928
|
-
t &&
|
|
935
|
+
t && Z(i, a, /^https?:\/\//i.test(t) ? t : `${n}://${t}`);
|
|
929
936
|
}
|
|
930
937
|
return i;
|
|
931
938
|
}
|
|
932
|
-
function
|
|
939
|
+
function Be(e) {
|
|
933
940
|
let t = [], n = /* @__PURE__ */ new Set();
|
|
934
|
-
for (let e of
|
|
935
|
-
for (let r of
|
|
941
|
+
for (let e of X()) Z(t, n, e);
|
|
942
|
+
for (let r of Q(e)) Z(t, n, r);
|
|
936
943
|
return t;
|
|
937
944
|
}
|
|
938
|
-
async function
|
|
945
|
+
async function Ve() {
|
|
939
946
|
try {
|
|
940
|
-
let e =
|
|
947
|
+
let e = Y();
|
|
941
948
|
if (e && (e.activePath === "hyper-sidecar" || e.activePath === "http-proxy")) return;
|
|
942
|
-
await
|
|
949
|
+
await H();
|
|
943
950
|
} catch {}
|
|
944
951
|
}
|
|
945
|
-
async function
|
|
952
|
+
async function $(e, t, n) {
|
|
946
953
|
let r = new AbortController(), i = setTimeout(() => r.abort(), n?.timeoutMs ?? 1e4);
|
|
947
954
|
try {
|
|
948
955
|
let n = await fetch(`${e.replace(/\/$/, "")}/raw/${encodeURIComponent(t)}`, {
|
|
@@ -957,24 +964,24 @@ async function Be(e, t, n) {
|
|
|
957
964
|
clearTimeout(i);
|
|
958
965
|
}
|
|
959
966
|
}
|
|
960
|
-
async function
|
|
967
|
+
async function He(e, t) {
|
|
961
968
|
let n = /* @__PURE__ */ new Set(), r = async (r) => {
|
|
962
969
|
for (let i of r) {
|
|
963
970
|
if (n.has(i)) continue;
|
|
964
971
|
n.add(i);
|
|
965
|
-
let r = await
|
|
972
|
+
let r = await $(i, e, t);
|
|
966
973
|
if (r) try {
|
|
967
|
-
let { bytes: t } = await
|
|
974
|
+
let { bytes: t } = await m(r, { transactionId: e }), n = new TextDecoder().decode(t);
|
|
968
975
|
if (n.length > 0) return n;
|
|
969
976
|
} catch {}
|
|
970
977
|
}
|
|
971
978
|
};
|
|
972
|
-
return await r(
|
|
979
|
+
return await r(X()) || (await Ve(), r(Q(t)));
|
|
973
980
|
}
|
|
974
981
|
//#endregion
|
|
975
982
|
//#region src/gateway/transactionStatus.ts
|
|
976
|
-
var
|
|
977
|
-
async function
|
|
983
|
+
var Ue = 1e4, We = 2e4, Ge = (e) => e >= 500 || e === 429;
|
|
984
|
+
async function Ke(e, t, n) {
|
|
978
985
|
let r = new AbortController(), i = setTimeout(() => r.abort(), n);
|
|
979
986
|
try {
|
|
980
987
|
let n = await fetch(`${e.replace(/\/$/, "")}/${encodeURIComponent(t)}`, {
|
|
@@ -982,7 +989,7 @@ async function Ge(e, t, n) {
|
|
|
982
989
|
credentials: "omit",
|
|
983
990
|
signal: r.signal
|
|
984
991
|
});
|
|
985
|
-
return await n.body?.cancel().catch(() => {}),
|
|
992
|
+
return await n.body?.cancel().catch(() => {}), Ge(n.status) ? {
|
|
986
993
|
kind: "retry",
|
|
987
994
|
status: n.status
|
|
988
995
|
} : {
|
|
@@ -998,17 +1005,17 @@ async function Ge(e, t, n) {
|
|
|
998
1005
|
clearTimeout(i);
|
|
999
1006
|
}
|
|
1000
1007
|
}
|
|
1001
|
-
async function
|
|
1002
|
-
let n = t.timeoutMs ?? 1e4, r = Date.now() + (t.totalTimeoutMs ?? 2e4), i = t.baseUrls ??
|
|
1008
|
+
async function qe(e, t = {}) {
|
|
1009
|
+
let n = t.timeoutMs ?? 1e4, r = Date.now() + (t.totalTimeoutMs ?? 2e4), i = t.baseUrls ?? Be(), a = i.filter((e) => !j(e)), o = a.length > 0 ? a : i, s = 500;
|
|
1003
1010
|
for (let t of o) {
|
|
1004
1011
|
let i = r - Date.now();
|
|
1005
1012
|
if (i <= 0) break;
|
|
1006
|
-
let a = await
|
|
1007
|
-
if (a.kind === "answer") return
|
|
1013
|
+
let a = await Ke(t, e, Math.min(n, i));
|
|
1014
|
+
if (a.kind === "answer") return N(t), {
|
|
1008
1015
|
status: a.status >= 200 && a.status < 300 ? 200 : a.status,
|
|
1009
1016
|
confirmed: null
|
|
1010
1017
|
};
|
|
1011
|
-
|
|
1018
|
+
P(t), s = a.status;
|
|
1012
1019
|
}
|
|
1013
1020
|
return {
|
|
1014
1021
|
status: s,
|
|
@@ -1016,6 +1023,6 @@ async function Ke(e, t = {}) {
|
|
|
1016
1023
|
};
|
|
1017
1024
|
}
|
|
1018
1025
|
//#endregion
|
|
1019
|
-
export {
|
|
1026
|
+
export { l as $, O as A, oe as B, xe as C, _e as D, ge as E, pe as F, ee as G, m as H, S as I, e as J, o as K, ce as L, N as M, A as N, j as O, me as P, n as Q, le as R, B as S, M as T, ie as U, ae as V, p as W, i as X, r as Y, t as Z, Ne as _, Ve as a, z as b, Be as c, Y as d, u as et, Re as f, q as g, K as h, ze as i, P as j, ve as k, Q as l, Pe as m, We as n, d as nt, $ as o, Ie as p, a as q, qe as r, c as rt, He as s, Ue as t, re as tt, X as u, H as v, V as w, Se as x, Ce as y, ue as z };
|
|
1020
1027
|
|
|
1021
|
-
//# sourceMappingURL=transactionStatus-
|
|
1028
|
+
//# sourceMappingURL=transactionStatus-zdutyXNX.js.map
|