@seedprotocol/arweave 0.5.1 → 0.5.3
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/ArweaveClient/BaseArweaveClient.d.ts +12 -3
- package/dist/ArweaveClient/BaseArweaveClient.d.ts.map +1 -1
- package/dist/easAttestationUrl.d.ts +5 -0
- package/dist/easAttestationUrl.d.ts.map +1 -0
- package/dist/gateway/resolveSeedGatewayEndpoints.d.ts +18 -3
- package/dist/gateway/resolveSeedGatewayEndpoints.d.ts.map +1 -1
- package/dist/gateway/seedGatewayConfig.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +297 -105
- package/dist/index.js.map +1 -1
- package/dist/mediaRef.d.ts +3 -0
- package/dist/mediaRef.d.ts.map +1 -1
- package/dist/node/ArweaveClient.d.ts.map +1 -1
- package/dist/node.js +13 -8
- package/dist/node.js.map +1 -1
- package/dist/{queries-DgB0O5RC.js → queries-BLXr3teJ.js} +9 -1
- package/dist/queries-BLXr3teJ.js.map +1 -0
- package/dist/resolveSeedRssImageRelationRef.d.ts +19 -0
- package/dist/resolveSeedRssImageRelationRef.d.ts.map +1 -0
- package/dist/types/gateway.d.ts +14 -3
- package/dist/types/gateway.d.ts.map +1 -1
- package/dist/types/seedConfig.d.ts +2 -0
- package/dist/types/seedConfig.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/queries-DgB0O5RC.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
import { a as e, c as t, d as n, f as r, g as i, h as a, i as o, l as s, m as c, n as l, o as
|
|
1
|
+
import { a as e, c as t, d as n, f as r, g as i, h as a, i as o, l as s, m as c, n as l, o as ee, p as u, r as d, s as f, t as te, u as p } from "./queries-BLXr3teJ.js";
|
|
2
|
+
//#region src/easAttestationUrl.ts
|
|
3
|
+
var ne = /(^|\.)easscan\.(org|xyz)$/i;
|
|
4
|
+
function m(e) {
|
|
5
|
+
let t = e.trim();
|
|
6
|
+
if (!t) return !1;
|
|
7
|
+
try {
|
|
8
|
+
let e = new URL(t);
|
|
9
|
+
return ne.test(e.hostname) ? /\/attestation\/view\//i.test(e.pathname) : !1;
|
|
10
|
+
} catch {
|
|
11
|
+
return !1;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
2
15
|
//#region src/relationSeedRef.ts
|
|
3
16
|
function h(e) {
|
|
4
17
|
let t = {
|
|
@@ -20,25 +33,25 @@ function g(e) {
|
|
|
20
33
|
}
|
|
21
34
|
}
|
|
22
35
|
}
|
|
23
|
-
var
|
|
24
|
-
function
|
|
36
|
+
var re = /^[a-zA-Z0-9_-]{10,21}$/;
|
|
37
|
+
function _(e) {
|
|
25
38
|
let t = h(e);
|
|
26
39
|
return t.localId || t.uid ? {
|
|
27
40
|
seedLocalId: t.localId,
|
|
28
41
|
seedUid: t.uid
|
|
29
|
-
} :
|
|
42
|
+
} : re.test(e) && !e.startsWith("0x") ? { seedLocalId: e } : {};
|
|
30
43
|
}
|
|
31
44
|
//#endregion
|
|
32
45
|
//#region src/mediaRef.ts
|
|
33
|
-
var
|
|
34
|
-
function
|
|
46
|
+
var ie = /^[a-zA-Z0-9_-]{43}$/;
|
|
47
|
+
function ae(e) {
|
|
35
48
|
return e == null ? "" : typeof e == "string" ? e.trim() : String(e).trim();
|
|
36
49
|
}
|
|
37
|
-
function
|
|
50
|
+
function v(e, t) {
|
|
38
51
|
let n = e[t];
|
|
39
52
|
return n == null ? "" : typeof n == "string" ? n.trim() : typeof n == "number" || typeof n == "boolean" ? String(n) : "";
|
|
40
53
|
}
|
|
41
|
-
function
|
|
54
|
+
function y(e) {
|
|
42
55
|
let t = e.trim();
|
|
43
56
|
if (!t) return t;
|
|
44
57
|
try {
|
|
@@ -47,8 +60,8 @@ function b(e) {
|
|
|
47
60
|
} catch {}
|
|
48
61
|
return t;
|
|
49
62
|
}
|
|
50
|
-
function
|
|
51
|
-
let n =
|
|
63
|
+
function b(e, t) {
|
|
64
|
+
let n = ae(e);
|
|
52
65
|
if (!n) return { kind: "empty" };
|
|
53
66
|
let r = t?.treatAs;
|
|
54
67
|
if (r === "url") return {
|
|
@@ -66,11 +79,14 @@ function x(e, t) {
|
|
|
66
79
|
kind: "unknown",
|
|
67
80
|
raw: n
|
|
68
81
|
};
|
|
69
|
-
if (n.startsWith("http://") || n.startsWith("https://") || n.startsWith("blob:") || n.startsWith("data:")) return {
|
|
82
|
+
if (n.startsWith("http://") || n.startsWith("https://") || n.startsWith("blob:") || n.startsWith("data:")) return m(n) ? {
|
|
83
|
+
kind: "nonMediaUrl",
|
|
84
|
+
href: n
|
|
85
|
+
} : {
|
|
70
86
|
kind: "url",
|
|
71
87
|
href: n
|
|
72
88
|
};
|
|
73
|
-
let i =
|
|
89
|
+
let i = y(n), a = _(i);
|
|
74
90
|
return a.seedUid ? {
|
|
75
91
|
kind: "seedUid",
|
|
76
92
|
uid: a.seedUid
|
|
@@ -80,7 +96,7 @@ function x(e, t) {
|
|
|
80
96
|
} : i.startsWith("0x") && i.length === 66 ? {
|
|
81
97
|
kind: "seedUid",
|
|
82
98
|
uid: i
|
|
83
|
-
} :
|
|
99
|
+
} : ie.test(i) && !i.startsWith("0x") ? {
|
|
84
100
|
kind: "arweaveTxId",
|
|
85
101
|
txId: i
|
|
86
102
|
} : {
|
|
@@ -88,25 +104,25 @@ function x(e, t) {
|
|
|
88
104
|
raw: n
|
|
89
105
|
};
|
|
90
106
|
}
|
|
91
|
-
function
|
|
92
|
-
let n =
|
|
107
|
+
function x(e, t) {
|
|
108
|
+
let n = v(e, t);
|
|
93
109
|
if (n) return n;
|
|
94
110
|
let r = t.replace(/[A-Z]/g, (e) => `_${e.toLowerCase()}`);
|
|
95
111
|
if (r !== t) {
|
|
96
|
-
let t =
|
|
112
|
+
let t = v(e, r);
|
|
97
113
|
if (t) return t;
|
|
98
114
|
}
|
|
99
115
|
let i = t.split("_");
|
|
100
116
|
if (i.length > 1) {
|
|
101
|
-
let t =
|
|
117
|
+
let t = v(e, i[0] + i.slice(1).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(""));
|
|
102
118
|
if (t) return t;
|
|
103
119
|
}
|
|
104
120
|
return "";
|
|
105
121
|
}
|
|
106
|
-
function
|
|
122
|
+
function oe(e, t) {
|
|
107
123
|
let n = {};
|
|
108
124
|
for (let [r, i] of Object.entries(t)) {
|
|
109
|
-
let t =
|
|
125
|
+
let t = x(e, r);
|
|
110
126
|
if (!t) {
|
|
111
127
|
n[r] = void 0;
|
|
112
128
|
continue;
|
|
@@ -125,7 +141,7 @@ function C(e, t) {
|
|
|
125
141
|
};
|
|
126
142
|
continue;
|
|
127
143
|
}
|
|
128
|
-
let a =
|
|
144
|
+
let a = b(t, { treatAs: i.treatAs });
|
|
129
145
|
n[r] = {
|
|
130
146
|
role: i.role,
|
|
131
147
|
raw: t,
|
|
@@ -134,21 +150,124 @@ function C(e, t) {
|
|
|
134
150
|
}
|
|
135
151
|
return n;
|
|
136
152
|
}
|
|
137
|
-
function
|
|
138
|
-
return `${
|
|
153
|
+
function se(e) {
|
|
154
|
+
return `${d.getBaseUrl()}/${e}`;
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/resolveSeedRssImageRelationRef.ts
|
|
158
|
+
var S = [
|
|
159
|
+
"featureImage",
|
|
160
|
+
"feature_image",
|
|
161
|
+
"image",
|
|
162
|
+
"images",
|
|
163
|
+
"coverImage",
|
|
164
|
+
"cover_image",
|
|
165
|
+
"thumbnail",
|
|
166
|
+
"thumbnail_image",
|
|
167
|
+
"thumbnailImage"
|
|
168
|
+
];
|
|
169
|
+
function C(e) {
|
|
170
|
+
return e == null ? "" : typeof e == "string" ? e.trim() : typeof e == "number" || typeof e == "boolean" ? String(e) : "";
|
|
171
|
+
}
|
|
172
|
+
function w(e, ...t) {
|
|
173
|
+
for (let n of t) {
|
|
174
|
+
let t = C(e[n]);
|
|
175
|
+
if (t) return t;
|
|
176
|
+
}
|
|
177
|
+
let n = t.map((e) => e.split(":").pop().toLowerCase());
|
|
178
|
+
for (let [t, r] of Object.entries(e)) {
|
|
179
|
+
let e = (t.includes(":") ? t.split(":").pop() : t).toLowerCase();
|
|
180
|
+
if (n.some((t) => e === t.toLowerCase())) {
|
|
181
|
+
let e = C(r);
|
|
182
|
+
if (e) return e;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return "";
|
|
186
|
+
}
|
|
187
|
+
function T(e) {
|
|
188
|
+
let t = e.trim();
|
|
189
|
+
if (t && !t.startsWith("0x")) try {
|
|
190
|
+
return `${d.getBaseUrl()}/${t}`;
|
|
191
|
+
} catch {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function E(e) {
|
|
196
|
+
let t = e.storageTransactionId?.trim();
|
|
197
|
+
if (t) {
|
|
198
|
+
let e = T(t);
|
|
199
|
+
if (e) return e;
|
|
200
|
+
}
|
|
201
|
+
let n = e.arweaveUrl?.trim();
|
|
202
|
+
if (n && !m(n)) return n;
|
|
203
|
+
}
|
|
204
|
+
function ce(e) {
|
|
205
|
+
let t = e.trim();
|
|
206
|
+
if (!t || m(t)) return;
|
|
207
|
+
let n = b(t);
|
|
208
|
+
switch (n.kind) {
|
|
209
|
+
case "url": return { mediaUrl: n.href };
|
|
210
|
+
case "arweaveTxId": {
|
|
211
|
+
let e = T(n.txId);
|
|
212
|
+
return {
|
|
213
|
+
storageTransactionId: n.txId,
|
|
214
|
+
...e ? { mediaUrl: e } : {}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
case "seedUid": return { seedUid: n.uid };
|
|
218
|
+
default: {
|
|
219
|
+
let e = T(t);
|
|
220
|
+
return e ? {
|
|
221
|
+
storageTransactionId: t,
|
|
222
|
+
mediaUrl: e
|
|
223
|
+
} : void 0;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function le(e) {
|
|
228
|
+
let t = w(e, "storageTransactionId", "storage_transaction_id"), n = w(e, "arweaveUrl", "arweave_url"), r = w(e, "seedUid", "SeedUid", "seed_uid"), i = w(e, "link", "Link"), a = E({
|
|
229
|
+
storageTransactionId: t,
|
|
230
|
+
arweaveUrl: n
|
|
231
|
+
}) ?? (i && !m(i) ? i : void 0);
|
|
232
|
+
if (t || n || r || a) return {
|
|
233
|
+
...t ? { storageTransactionId: t } : {},
|
|
234
|
+
...n && !m(n) ? { arweaveUrl: n } : {},
|
|
235
|
+
...r ? { seedUid: r } : {},
|
|
236
|
+
...a ? { mediaUrl: a } : {}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function D(e) {
|
|
240
|
+
if (e != null) {
|
|
241
|
+
if (typeof e == "string") return ce(e);
|
|
242
|
+
if (Array.isArray(e)) {
|
|
243
|
+
for (let t of e) {
|
|
244
|
+
let e = D(t);
|
|
245
|
+
if (e?.mediaUrl || e?.storageTransactionId || e?.seedUid) return e;
|
|
246
|
+
}
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (typeof e == "object") return le(e);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function ue(e, t = S) {
|
|
253
|
+
for (let n of t) {
|
|
254
|
+
if (!(n in e)) continue;
|
|
255
|
+
let t = D(e[n]);
|
|
256
|
+
if (t) return t;
|
|
257
|
+
}
|
|
139
258
|
}
|
|
140
259
|
//#endregion
|
|
141
260
|
//#region src/ArweaveClient/selectReadGateway.ts
|
|
142
|
-
var
|
|
143
|
-
function
|
|
144
|
-
|
|
261
|
+
var de = 18e4, fe = 5e3, O = null, k = null;
|
|
262
|
+
function A() {
|
|
263
|
+
O = null, k = null;
|
|
145
264
|
}
|
|
146
|
-
function
|
|
147
|
-
|
|
265
|
+
function pe() {
|
|
266
|
+
A(), d.resetReadGatewaySelectionStateForTests(), d.isReadGatewayLocked() || d.setPreferredReadGateway(f);
|
|
148
267
|
}
|
|
149
|
-
async function
|
|
268
|
+
async function j(e, t) {
|
|
150
269
|
let n = `${e.replace(/\/$/, "")}/info`, r, i = new AbortController(), a = t ?? i.signal;
|
|
151
|
-
t || (r = setTimeout(() => i.abort(),
|
|
270
|
+
t || (r = setTimeout(() => i.abort(), fe));
|
|
152
271
|
try {
|
|
153
272
|
let e = await fetch(n, {
|
|
154
273
|
method: "GET",
|
|
@@ -170,44 +289,44 @@ async function A(e, t) {
|
|
|
170
289
|
r && clearTimeout(r);
|
|
171
290
|
}
|
|
172
291
|
}
|
|
173
|
-
async function
|
|
292
|
+
async function M(e, t = "https", n) {
|
|
174
293
|
for (let r of e) {
|
|
175
294
|
let e = r.trim().replace(/\/$/, "");
|
|
176
|
-
if (e && await
|
|
295
|
+
if (e && await j(`${t}://${e}`, n)) return e;
|
|
177
296
|
}
|
|
178
297
|
return null;
|
|
179
298
|
}
|
|
180
|
-
function
|
|
181
|
-
return r(
|
|
182
|
-
}
|
|
183
|
-
async function
|
|
184
|
-
if (
|
|
185
|
-
if (
|
|
186
|
-
if (
|
|
187
|
-
|
|
188
|
-
let t = await
|
|
189
|
-
return
|
|
190
|
-
host:
|
|
191
|
-
expiresAt: Date.now() +
|
|
192
|
-
},
|
|
299
|
+
function N() {
|
|
300
|
+
return r(d.getHost());
|
|
301
|
+
}
|
|
302
|
+
async function P(e) {
|
|
303
|
+
if (d.isReadGatewayLocked()) return d.getHost();
|
|
304
|
+
if (O && Date.now() < O.expiresAt) return O.host;
|
|
305
|
+
if (k) return k;
|
|
306
|
+
k = (async () => {
|
|
307
|
+
let t = await M(N(), d.getProtocol(), e);
|
|
308
|
+
return d.isReadGatewayLocked() || t && d.applyProbedReadGateway(t), O = {
|
|
309
|
+
host: d.getHost(),
|
|
310
|
+
expiresAt: Date.now() + de
|
|
311
|
+
}, O.host;
|
|
193
312
|
})();
|
|
194
313
|
try {
|
|
195
|
-
return await
|
|
314
|
+
return await k;
|
|
196
315
|
} finally {
|
|
197
|
-
|
|
316
|
+
k = null;
|
|
198
317
|
}
|
|
199
318
|
}
|
|
200
319
|
//#endregion
|
|
201
320
|
//#region src/ArweaveClient/uploadApiVerification.ts
|
|
202
|
-
function
|
|
321
|
+
function F(e) {
|
|
203
322
|
return e.trim().replace(/\/+$/, "");
|
|
204
323
|
}
|
|
205
|
-
function
|
|
206
|
-
return `${
|
|
324
|
+
function I(e, t) {
|
|
325
|
+
return `${F(e)}/api/upload/arweave/data/${encodeURIComponent(t)}`;
|
|
207
326
|
}
|
|
208
|
-
var
|
|
209
|
-
async function
|
|
210
|
-
let r =
|
|
327
|
+
var L = 45e3;
|
|
328
|
+
async function R(e, t, n) {
|
|
329
|
+
let r = I(e, t), i = n?.timeoutMs ?? L, a = new AbortController(), o = setTimeout(() => a.abort(), i);
|
|
211
330
|
try {
|
|
212
331
|
let e = await fetch(r, { signal: a.signal });
|
|
213
332
|
return clearTimeout(o), e.status === 404 ? {
|
|
@@ -232,16 +351,16 @@ async function L(e, t, n) {
|
|
|
232
351
|
}
|
|
233
352
|
//#endregion
|
|
234
353
|
//#region src/ArweaveClient/arweaveL1UploadApi.ts
|
|
235
|
-
var
|
|
236
|
-
function
|
|
237
|
-
return `${
|
|
354
|
+
var z = "\n query ArweaveGatewayTransaction($id: String!) {\n transaction(id: $id) {\n id\n bundledIn {\n id\n }\n block {\n height\n timestamp\n }\n }\n }\n";
|
|
355
|
+
function B(e, t) {
|
|
356
|
+
return `${F(e)}/api/upload/arweave/status/${encodeURIComponent(t)}`;
|
|
238
357
|
}
|
|
239
|
-
function
|
|
358
|
+
function me(e) {
|
|
240
359
|
let t = e.l1;
|
|
241
360
|
return t ? t.meetsMinConfirmations === !0 || t.confirmed === !0 : !1;
|
|
242
361
|
}
|
|
243
|
-
async function
|
|
244
|
-
let n =
|
|
362
|
+
async function he(e, t) {
|
|
363
|
+
let n = B(e, t);
|
|
245
364
|
try {
|
|
246
365
|
let e = await fetch(n);
|
|
247
366
|
if (!e.ok) return null;
|
|
@@ -251,7 +370,7 @@ async function V(e, t) {
|
|
|
251
370
|
return null;
|
|
252
371
|
}
|
|
253
372
|
}
|
|
254
|
-
async function
|
|
373
|
+
async function V(e, t, n) {
|
|
255
374
|
let r = e.trim();
|
|
256
375
|
if (!r) return null;
|
|
257
376
|
try {
|
|
@@ -259,7 +378,7 @@ async function H(e, t, n) {
|
|
|
259
378
|
method: "POST",
|
|
260
379
|
headers: { "Content-Type": "application/json" },
|
|
261
380
|
body: JSON.stringify({
|
|
262
|
-
query:
|
|
381
|
+
query: z,
|
|
263
382
|
variables: { id: t }
|
|
264
383
|
}),
|
|
265
384
|
signal: n?.signal
|
|
@@ -283,8 +402,8 @@ async function H(e, t, n) {
|
|
|
283
402
|
return null;
|
|
284
403
|
}
|
|
285
404
|
}
|
|
286
|
-
async function
|
|
287
|
-
let i =
|
|
405
|
+
async function ge(e, t, n) {
|
|
406
|
+
let i = u(), a = e?.trim(), o = "https", s = null;
|
|
288
407
|
if (a) try {
|
|
289
408
|
let e = new URL(a);
|
|
290
409
|
o = e.protocol === "http:" ? "http" : "https", s = e.hostname || null;
|
|
@@ -293,28 +412,28 @@ async function U(e, t, n) {
|
|
|
293
412
|
}
|
|
294
413
|
let c = s && s.length > 0 ? r(s) : [...i], l = n?.signal;
|
|
295
414
|
for (let e of c) {
|
|
296
|
-
if (!await
|
|
297
|
-
let r = await
|
|
415
|
+
if (!await j(`${o}://${e}`, l ?? void 0)) continue;
|
|
416
|
+
let r = await V(`${o}://${e}/graphql`, t, n);
|
|
298
417
|
if (r !== null) return r;
|
|
299
418
|
}
|
|
300
419
|
return null;
|
|
301
420
|
}
|
|
302
421
|
//#endregion
|
|
303
422
|
//#region src/gateway/gatewayState.ts
|
|
304
|
-
var
|
|
305
|
-
function
|
|
306
|
-
return
|
|
423
|
+
var H = null;
|
|
424
|
+
function _e() {
|
|
425
|
+
return H;
|
|
307
426
|
}
|
|
308
|
-
function
|
|
309
|
-
|
|
427
|
+
function ve(e) {
|
|
428
|
+
H = e;
|
|
310
429
|
}
|
|
311
430
|
//#endregion
|
|
312
431
|
//#region src/gateway/resolveSeedGatewayEndpoints.ts
|
|
313
|
-
var
|
|
314
|
-
function
|
|
315
|
-
|
|
432
|
+
var U = 18e4, W = null, G = /* @__PURE__ */ new Map();
|
|
433
|
+
function K() {
|
|
434
|
+
W = null, G.clear();
|
|
316
435
|
}
|
|
317
|
-
function
|
|
436
|
+
function ye(e) {
|
|
318
437
|
let t = (e ?? "ar.seedprotocol.io").trim();
|
|
319
438
|
return t.startsWith("http://") ? {
|
|
320
439
|
protocol: "http",
|
|
@@ -327,7 +446,7 @@ function ie(e) {
|
|
|
327
446
|
host: t.replace(/\/$/, "")
|
|
328
447
|
};
|
|
329
448
|
}
|
|
330
|
-
function
|
|
449
|
+
function q(e) {
|
|
331
450
|
let t = e.hyper?.localSidecarHost?.trim() || "127.0.0.1", n = e.hyper?.localSidecarPort ?? 1984;
|
|
332
451
|
return {
|
|
333
452
|
host: n === 80 || n === 443 ? t : `${t}:${n}`,
|
|
@@ -335,17 +454,45 @@ function X(e) {
|
|
|
335
454
|
baseUrl: `http://${t}:${n}`
|
|
336
455
|
};
|
|
337
456
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
457
|
+
function be() {
|
|
458
|
+
try {
|
|
459
|
+
let e = globalThis.window?.location?.origin;
|
|
460
|
+
return typeof e == "string" && e.length > 0 ? e.replace(/\/$/, "") : void 0;
|
|
461
|
+
} catch {
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
function J(e, t) {
|
|
466
|
+
let n = e.trim();
|
|
467
|
+
if (!n) throw Error("proxyBaseUrl is empty");
|
|
468
|
+
if (n.startsWith("http://") || n.startsWith("https://")) return n.replace(/\/$/, "");
|
|
469
|
+
if (n.startsWith("/")) {
|
|
470
|
+
let r = (t?.origin?.trim() || be() || "").replace(/\/$/, "");
|
|
471
|
+
if (!r) throw Error(`Relative proxyBaseUrl "${e}" requires a browser origin or resolve options.origin`);
|
|
472
|
+
return `${r}${n.replace(/\/$/, "")}`;
|
|
473
|
+
}
|
|
474
|
+
return `https://${n.replace(/\/$/, "")}`;
|
|
475
|
+
}
|
|
476
|
+
async function Y(e, t, n) {
|
|
477
|
+
let r = Date.now();
|
|
478
|
+
if (t === "sidecar") {
|
|
479
|
+
if (W && r < W.expiresAt) return W.healthy;
|
|
480
|
+
let t = await j(e, n);
|
|
481
|
+
return W = {
|
|
482
|
+
healthy: t,
|
|
483
|
+
expiresAt: r + U
|
|
484
|
+
}, t;
|
|
485
|
+
}
|
|
486
|
+
let i = G.get(t);
|
|
487
|
+
if (i && r < i.expiresAt) return i.healthy;
|
|
488
|
+
let a = await j(e, n);
|
|
489
|
+
return G.set(t, {
|
|
490
|
+
healthy: a,
|
|
491
|
+
expiresAt: r + U
|
|
492
|
+
}), a;
|
|
493
|
+
}
|
|
494
|
+
function X(e) {
|
|
495
|
+
let { host: t, protocol: n } = ye(e.arweaveDomain), r = `${n}://${t}`, i = e.uploadApiBaseUrl?.trim() || r;
|
|
349
496
|
return {
|
|
350
497
|
mode: e.transport ?? "http-gateway",
|
|
351
498
|
arweaveHost: t,
|
|
@@ -357,8 +504,8 @@ function Q(e) {
|
|
|
357
504
|
gatewayHyperKey: e.hyper?.gatewayHyperKey?.trim() || void 0
|
|
358
505
|
};
|
|
359
506
|
}
|
|
360
|
-
function
|
|
361
|
-
let t =
|
|
507
|
+
function Z(e) {
|
|
508
|
+
let t = q(e), n = e.hyper?.gatewayHyperKey?.trim();
|
|
362
509
|
return {
|
|
363
510
|
mode: "hyper",
|
|
364
511
|
arweaveHost: t.host,
|
|
@@ -370,24 +517,67 @@ function $(e) {
|
|
|
370
517
|
gatewayHyperKey: n || void 0
|
|
371
518
|
};
|
|
372
519
|
}
|
|
373
|
-
|
|
374
|
-
t
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
520
|
+
function Q(e, t) {
|
|
521
|
+
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}`;
|
|
522
|
+
return {
|
|
523
|
+
mode: e.transport ?? "http-gateway",
|
|
524
|
+
arweaveHost: a,
|
|
525
|
+
arweaveProtocol: r,
|
|
526
|
+
arweaveBaseUrl: o,
|
|
527
|
+
arweaveGraphqlUrl: `${o}/graphql`,
|
|
528
|
+
uploadApiBaseUrl: o,
|
|
529
|
+
activePath: "http-proxy",
|
|
530
|
+
gatewayHyperKey: e.hyper?.gatewayHyperKey?.trim() || void 0,
|
|
531
|
+
proxyBaseUrl: t
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
async function $(e, t) {
|
|
535
|
+
let n = e.proxyBaseUrl?.trim();
|
|
536
|
+
if (!n) return null;
|
|
537
|
+
let r = J(n, { origin: t?.origin });
|
|
538
|
+
return e.hyper?.probeSidecar !== !1 && !await Y(r, `proxy:${r}`, t?.signal) ? null : Q(e, r);
|
|
539
|
+
}
|
|
540
|
+
async function xe(e, t) {
|
|
541
|
+
t?.forceSidecarProbe && K();
|
|
542
|
+
let n = e.transport ?? "http-gateway", r = e.hyper?.probeSidecar !== !1;
|
|
543
|
+
if (n === "http-gateway") {
|
|
544
|
+
if (e.proxyBaseUrl?.trim()) {
|
|
545
|
+
let i = J(e.proxyBaseUrl, { origin: t?.origin });
|
|
546
|
+
if (r && !await Y(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.`);
|
|
547
|
+
return Q({
|
|
548
|
+
...e,
|
|
549
|
+
transport: n
|
|
550
|
+
}, i);
|
|
551
|
+
}
|
|
552
|
+
return X({
|
|
553
|
+
...e,
|
|
554
|
+
transport: n
|
|
555
|
+
});
|
|
556
|
+
}
|
|
380
557
|
if (n === "hyper") {
|
|
381
|
-
let
|
|
382
|
-
|
|
383
|
-
|
|
558
|
+
let i = await $({
|
|
559
|
+
...e,
|
|
560
|
+
transport: n
|
|
561
|
+
}, t);
|
|
562
|
+
if (i) return i;
|
|
563
|
+
let a = Z({
|
|
564
|
+
...e,
|
|
565
|
+
transport: n
|
|
566
|
+
});
|
|
567
|
+
if (r && !await Y(a.arweaveBaseUrl, "sidecar", t?.signal)) throw Error(`Gateway Hyper sidecar not reachable at ${a.arweaveBaseUrl}. Run: seed gateway tunnel connect <operator-z32-key> — or configure gateway.proxyBaseUrl for an app-server proxy.`);
|
|
568
|
+
return a;
|
|
384
569
|
}
|
|
385
|
-
let
|
|
386
|
-
|
|
570
|
+
let i = await $({
|
|
571
|
+
...e,
|
|
572
|
+
transport: n
|
|
573
|
+
}, t);
|
|
574
|
+
if (i) return i;
|
|
575
|
+
let a = q(e);
|
|
576
|
+
return r && await Y(a.baseUrl, "sidecar", t?.signal) ? Z({
|
|
387
577
|
...e,
|
|
388
578
|
transport: "hyper"
|
|
389
579
|
}) : {
|
|
390
|
-
...
|
|
580
|
+
...X({
|
|
391
581
|
...e,
|
|
392
582
|
transport: "http-gateway"
|
|
393
583
|
}),
|
|
@@ -395,17 +585,18 @@ async function ae(e, t) {
|
|
|
395
585
|
activePath: "hybrid-fallback-http"
|
|
396
586
|
};
|
|
397
587
|
}
|
|
398
|
-
function
|
|
399
|
-
return e.activePath === "hyper-sidecar" ? [e.arweaveHost] : r(e.arweaveHost);
|
|
588
|
+
function Se(e, t) {
|
|
589
|
+
return e.activePath === "hyper-sidecar" || e.activePath === "http-proxy" ? [e.arweaveHost] : r(e.arweaveHost);
|
|
400
590
|
}
|
|
401
591
|
//#endregion
|
|
402
592
|
//#region src/gateway/seedGatewayConfig.ts
|
|
403
|
-
function
|
|
593
|
+
function Ce(e) {
|
|
404
594
|
let t = e.gateway ?? {};
|
|
405
595
|
return {
|
|
406
596
|
transport: t.transport,
|
|
407
597
|
arweaveDomain: e.arweaveDomain ?? t.arweaveDomain,
|
|
408
598
|
uploadApiBaseUrl: e.uploadApiBaseUrl ?? t.uploadApiBaseUrl,
|
|
599
|
+
proxyBaseUrl: t.proxyBaseUrl?.trim() || void 0,
|
|
409
600
|
hyper: {
|
|
410
601
|
gatewayHyperKey: t.hyper?.gatewayHyperKey?.trim() || t.gatewayHyperKey?.trim() || void 0,
|
|
411
602
|
localSidecarHost: t.hyper?.localSidecarHost ?? t.localSidecarHost,
|
|
@@ -414,11 +605,12 @@ function se(e) {
|
|
|
414
605
|
}
|
|
415
606
|
};
|
|
416
607
|
}
|
|
417
|
-
function
|
|
608
|
+
function we(e) {
|
|
418
609
|
return {
|
|
419
610
|
transport: e.gatewayTransport,
|
|
420
611
|
arweaveDomain: e.arweaveDomain,
|
|
421
612
|
uploadApiBaseUrl: e.uploadApiBaseUrl,
|
|
613
|
+
proxyBaseUrl: e.gatewayProxyBaseUrl?.trim() || void 0,
|
|
422
614
|
hyper: {
|
|
423
615
|
gatewayHyperKey: e.gatewayHyperKey?.trim() || void 0,
|
|
424
616
|
localSidecarHost: e.gatewaySidecarHost,
|
|
@@ -427,6 +619,6 @@ function ce(e) {
|
|
|
427
619
|
};
|
|
428
620
|
}
|
|
429
621
|
//#endregion
|
|
430
|
-
export { o as ARWEAVE_HOST_ENV_KEYS,
|
|
622
|
+
export { o as ARWEAVE_HOST_ENV_KEYS, d as ArweaveClient, d as BaseArweaveClient, e as DEFAULT_ARWEAVE_GATEWAYS, ee as DEFAULT_ARWEAVE_GRAPHQL_URL, f as DEFAULT_ARWEAVE_HOST, t as DEFAULT_GATEWAY_SIDECAR_HOST, s as DEFAULT_GATEWAY_SIDECAR_PORT, p as DEFAULT_SEED_FEED_HYPER_KEY, n as DEFAULT_SEED_GATEWAY_HYPER_KEY, te as GET_ARWEAVE_TRANSACTIONS, l as GET_TRANSACTION_TAGS, S as SEED_RSS_IMAGE_RELATION_FIELD_KEYS, b as classifyMediaRef, P as ensureReadGatewaySelected, r as getArweaveReadGatewayHostsForPrimary, he as getArweaveUploadStatus, se as getArweaveUrlForTransaction, u as getDefaultArweaveReadGatewayHostsOrdered, x as getFeedItemStringField, Se as getReadGatewayHostsForConfig, _e as getResolvedSeedGatewayEndpoints, I as getUploadApiArweaveDataUrl, B as getUploadApiArweaveStatusUrl, R as getUploadPipelineTransactionStatus, A as invalidateReadGatewayCache, K as invalidateSidecarProbeCache, me as isArweaveL1AnchoringComplete, m as isEasAttestationExplorerUrl, c as isKnownArweaveGatewayHostname, a as mergePrimaryHostWithDefaults, oe as normalizeFeedItemFields, g as normalizeRelationPropertyValue, F as normalizeUploadApiBaseUrl, j as probeGateway, V as queryArweaveGatewayTransaction, ge as queryArweaveGatewayTransactionWithFallback, pe as resetArweaveReadGatewayForTests, i as resolveArweaveHostFromEnv, J as resolveProxyBaseUrl, xe as resolveSeedGatewayEndpoints, _ as resolveSeedIdsFromRefString, ue as resolveSeedRssImageRelationFromItem, D as resolveSeedRssImageRelationRef, we as seedGatewayConfigFromClientContext, Ce as seedGatewayConfigFromSeedConfig, M as selectFirstHealthyReadGateway, ve as setResolvedSeedGatewayEndpoints };
|
|
431
623
|
|
|
432
624
|
//# sourceMappingURL=index.js.map
|