@ar.io/wayfinder-core 1.9.1 → 2.0.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.
package/README.md CHANGED
@@ -38,11 +38,18 @@ import {
38
38
  NetworkGatewaysProvider,
39
39
  } from '@ar.io/wayfinder-core';
40
40
  import { ARIO } from '@ar.io/sdk';
41
+ import { createSolanaRpc } from '@solana/kit';
42
+
43
+ // AR.IO Solana mainnet — program-id overrides are not needed on mainnet
44
+ // (the SDK ships defaults). For devnet, pass explicit program IDs.
45
+ const ario = ARIO.init({
46
+ rpc: createSolanaRpc('https://api.mainnet-beta.solana.com'),
47
+ });
41
48
 
42
49
  const wayfinder = createWayfinderClient({
43
50
  routingStrategy: new FastestPingRoutingStrategy({
44
51
  gatewaysProvider: new NetworkGatewaysProvider({
45
- ario: ARIO.mainnet(),
52
+ ario,
46
53
  sortBy: 'operatorStake',
47
54
  sortOrder: 'desc',
48
55
  limit: 10,
@@ -61,7 +68,7 @@ import {
61
68
 
62
69
  const wayfinder = createWayfinderClient({
63
70
  verificationStrategy: new HashVerificationStrategy({
64
- trustedGateways: [new URL('https://permagate.io')],
71
+ trustedGateways: [new URL('https://turbo-gateway.com')],
65
72
  }),
66
73
  strict: true, // Fail requests on verification errors
67
74
  });
@@ -96,7 +103,7 @@ import { createVerificationStrategy } from '@ar.io/wayfinder-core';
96
103
  // Create a hash verification strategy
97
104
  const hashStrategy = createVerificationStrategy({
98
105
  strategy: 'hash',
99
- trustedGateways: [new URL('https://permagate.io')],
106
+ trustedGateways: [new URL('https://turbo-gateway.com')],
100
107
  logger: myLogger,
101
108
  });
102
109
 
@@ -176,14 +183,19 @@ Gateway providers supply the list of gateways for routing. **By default, `create
176
183
 
177
184
  #### NetworkGatewaysProvider
178
185
 
179
- Returns a list of gateways from the ARIO Network based on on-chain [Gateway Address Registry](https://docs.ar.io/learn/gateways/gateway-registry). You can specify on-chain metrics for gateways to prioritize the highest quality gateways. This requires installing the `@ar.io/sdk` package and importing the `ARIO` object.
186
+ Returns a list of gateways from the ARIO Network based on on-chain [Gateway Address Registry](https://docs.ar.io/learn/gateways/gateway-registry). You can specify on-chain metrics for gateways to prioritize the highest quality gateways. Requires `@ar.io/sdk` and `@solana/kit`.
180
187
 
181
188
  ```javascript
182
189
  import { NetworkGatewaysProvider } from '@ar.io/wayfinder-core';
183
190
  import { ARIO } from '@ar.io/sdk';
191
+ import { createSolanaRpc } from '@solana/kit';
192
+
193
+ const ario = ARIO.init({
194
+ rpc: createSolanaRpc('https://api.mainnet-beta.solana.com'),
195
+ });
184
196
 
185
197
  const gatewayProvider = new NetworkGatewaysProvider({
186
- ario: ARIO.mainnet(),
198
+ ario,
187
199
  sortBy: 'operatorStake',
188
200
  sortOrder: 'desc',
189
201
  limit: 10,
@@ -199,7 +211,7 @@ Fetches a dynamic list of trusted peer gateways from an AR.IO gateway's `/ar-io/
199
211
  import { TrustedPeersGatewaysProvider } from '@ar.io/wayfinder-core';
200
212
 
201
213
  const gatewayProvider = new TrustedPeersGatewaysProvider({
202
- trustedGateway: 'https://arweave.net',
214
+ trustedGateway: 'https://turbo-gateway.com',
203
215
  });
204
216
  ```
205
217
 
@@ -222,23 +234,28 @@ import {
222
234
  TrustedPeersGatewaysProvider,
223
235
  } from '@ar.io/wayfinder-core';
224
236
  import { ARIO } from '@ar.io/sdk';
237
+ import { createSolanaRpc } from '@solana/kit';
238
+
239
+ const ario = ARIO.init({
240
+ rpc: createSolanaRpc('https://api.mainnet-beta.solana.com'),
241
+ });
225
242
 
226
243
  // Example: Network-first with static fallback
227
244
  const gatewayProvider = new CompositeGatewaysProvider({
228
245
  providers: [
229
246
  // Try fetching from AR.IO network first
230
247
  new NetworkGatewaysProvider({
231
- ario: ARIO.mainnet(),
248
+ ario,
232
249
  sortBy: 'operatorStake',
233
250
  limit: 10,
234
251
  }),
235
252
  // Fallback to trusted peers if network fetch fails
236
253
  new TrustedPeersGatewaysProvider({
237
- trustedGateway: 'https://arweave.net',
254
+ trustedGateway: 'https://turbo-gateway.com',
238
255
  }),
239
256
  // Final fallback to static list
240
257
  new StaticGatewaysProvider({
241
- gateways: ['https://arweave.net', 'https://permagate.io'],
258
+ gateways: ['https://turbo-gateway.com', 'https://g8way.io'],
242
259
  }),
243
260
  ],
244
261
  });
@@ -325,6 +342,11 @@ import {
325
342
  NetworkGatewaysProvider,
326
343
  } from '@ar.io/wayfinder-core';
327
344
  import { ARIO } from '@ar.io/sdk';
345
+ import { createSolanaRpc } from '@solana/kit';
346
+
347
+ const ario = ARIO.init({
348
+ rpc: createSolanaRpc('https://api.mainnet-beta.solana.com'),
349
+ });
328
350
 
329
351
  // Example 1: Performance-first with resilience fallback
330
352
  const performanceWayfinder = createWayfinderClient({
@@ -334,7 +356,7 @@ const performanceWayfinder = createWayfinderClient({
334
356
  new FastestPingRoutingStrategy({
335
357
  timeoutMs: 500,
336
358
  gatewaysProvider: new NetworkGatewaysProvider({
337
- ario: ARIO.mainnet(),
359
+ ario,
338
360
  sortBy: 'operatorStake',
339
361
  limit: 10,
340
362
  }),
@@ -342,7 +364,7 @@ const performanceWayfinder = createWayfinderClient({
342
364
  // Fallback to random selection (guaranteed to work if gateways exist)
343
365
  new RandomRoutingStrategy({
344
366
  gatewaysProvider: new NetworkGatewaysProvider({
345
- ario: ARIO.mainnet(),
367
+ ario,
346
368
  sortBy: 'operatorStake',
347
369
  limit: 20, // Use more gateways for fallback
348
370
  }),
@@ -363,7 +385,7 @@ const preferredWayfinder = createWayfinderClient({
363
385
  new FastestPingRoutingStrategy({
364
386
  timeoutMs: 1000,
365
387
  gatewaysProvider: new NetworkGatewaysProvider({
366
- ario: ARIO.mainnet(),
388
+ ario,
367
389
  sortBy: 'operatorStake',
368
390
  limit: 5, // Only top 5 gateways
369
391
  }),
@@ -371,7 +393,7 @@ const preferredWayfinder = createWayfinderClient({
371
393
  // Final fallback: any random gateway from a larger pool
372
394
  new RandomRoutingStrategy({
373
395
  gatewaysProvider: new NetworkGatewaysProvider({
374
- ario: ARIO.mainnet(),
396
+ ario,
375
397
  limit: 50, // Larger pool for maximum availability
376
398
  }),
377
399
  }),
@@ -543,7 +565,7 @@ const wayfinder = new Wayfinder({
543
565
  verificationSettings: {
544
566
  enabled: true,
545
567
  strategy: new HashVerificationStrategy({
546
- trustedGateways: [new URL('https://permagate.io')],
568
+ trustedGateways: [new URL('https://turbo-gateway.com')],
547
569
  }),
548
570
  },
549
571
  });
@@ -560,7 +582,7 @@ const wayfinder = new Wayfinder({
560
582
  verificationSettings: {
561
583
  enabled: true,
562
584
  strategy: new DataRootVerificationStrategy({
563
- trustedGateways: [new URL('https://permagate.io')],
585
+ trustedGateways: [new URL('https://turbo-gateway.com')],
564
586
  }),
565
587
  },
566
588
  });
@@ -577,7 +599,7 @@ const wayfinder = new Wayfinder({
577
599
  verificationSettings: {
578
600
  enabled: true,
579
601
  strategy: new SignatureVerificationStrategy({
580
- trustedGateways: [new URL('https://permagate.io')],
602
+ trustedGateways: [new URL('https://turbo-gateway.com')],
581
603
  }),
582
604
  },
583
605
  });
package/dist/client.js CHANGED
@@ -28,7 +28,7 @@ import { DataRootVerificationStrategy } from './verification/data-root-verificat
28
28
  import { HashVerificationStrategy } from './verification/hash-verification.js';
29
29
  import { RemoteVerificationStrategy } from './verification/remote-verification.js';
30
30
  import { Wayfinder } from './wayfinder.js';
31
- const DEFAULT_TRUSTED_GATEWAY = 'https://permagate.io';
31
+ const DEFAULT_TRUSTED_GATEWAY = 'https://turbo-gateway.com';
32
32
  /**
33
33
  * Helper function to construct a routing strategy
34
34
  */
@@ -43,7 +43,7 @@ export const createRoutingStrategy = ({ strategy, gatewaysProvider, logger, }) =
43
43
  return new RoundRobinRoutingStrategy(baseConfig);
44
44
  case 'preferred':
45
45
  return new PreferredWithFallbackRoutingStrategy({
46
- preferredGateway: 'https://arweave.net',
46
+ preferredGateway: 'https://turbo-gateway.com',
47
47
  fallbackStrategy: createRoutingStrategy({
48
48
  strategy: 'fastest',
49
49
  gatewaysProvider,
@@ -55,7 +55,7 @@ export const createRoutingStrategy = ({ strategy, gatewaysProvider, logger, }) =
55
55
  /**
56
56
  * Helper function to construct a verification strategy
57
57
  */
58
- export const createVerificationStrategy = ({ strategy, logger, trustedGateways = [new URL('https://permagate.io')], }) => {
58
+ export const createVerificationStrategy = ({ strategy, logger, trustedGateways = [new URL('https://turbo-gateway.com')], }) => {
59
59
  const verificationMap = {
60
60
  hash: new HashVerificationStrategy({ logger, trustedGateways }),
61
61
  'data-root': new DataRootVerificationStrategy({ logger, trustedGateways }),
@@ -39,6 +39,9 @@ export declare const arioHeaderNames: {
39
39
  chunkTxId: string;
40
40
  chunkTxStartOffset: string;
41
41
  rootTransactionId: string;
42
+ rootPath: string;
43
+ rootItemOffset: string;
44
+ rootItemSize: string;
42
45
  dataItemDataOffset: string;
43
46
  dataItemRootParentOffset: string;
44
47
  dataItemOffset: string;
@@ -51,9 +54,17 @@ export declare const arioHeaderNames: {
51
54
  arnsRecord: string;
52
55
  arnsResolvedId: string;
53
56
  dataId: string;
54
- arnsProcessId: string;
57
+ arnsAntProgramId: string;
58
+ arnsAntId: string;
55
59
  arnsResolvedAt: string;
56
60
  arnsLimit: string;
57
61
  arnsIndex: string;
62
+ signatureInput: string;
63
+ signature: string;
64
+ arweaveOwner: string;
65
+ arweaveOwnerAddress: string;
66
+ arweaveSignature: string;
67
+ arweaveSignatureType: string;
68
+ arweaveTagCount: string;
58
69
  };
59
70
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,eAAO,MAAM,SAAS,QAA2C,CAAC;AAClE,eAAO,MAAM,SAAS,QAAwB,CAAC;AAG/C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuC3B,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,eAAO,MAAM,SAAS,QAA2C,CAAC;AAClE,eAAO,MAAM,SAAS,QAAwB,CAAC;AAG/C,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoD3B,CAAC"}
package/dist/constants.js CHANGED
@@ -41,6 +41,9 @@ export const arioHeaderNames = {
41
41
  chunkTxId: 'X-Arweave-Chunk-Tx-Id',
42
42
  chunkTxStartOffset: 'X-Arweave-Chunk-Tx-Start-Offset',
43
43
  rootTransactionId: 'X-AR-IO-Root-Transaction-Id',
44
+ rootPath: 'X-AR-IO-Root-Path',
45
+ rootItemOffset: 'X-AR-IO-Root-Item-Offset',
46
+ rootItemSize: 'X-AR-IO-Root-Item-Size',
44
47
  dataItemDataOffset: 'X-AR-IO-Data-Item-Data-Offset',
45
48
  dataItemRootParentOffset: 'X-AR-IO-Data-Item-Root-Parent-Offset',
46
49
  dataItemOffset: 'X-AR-IO-Data-Item-Offset',
@@ -53,8 +56,18 @@ export const arioHeaderNames = {
53
56
  arnsRecord: 'X-ArNS-Record',
54
57
  arnsResolvedId: 'X-ArNS-Resolved-Id',
55
58
  dataId: 'X-AR-IO-Data-Id',
56
- arnsProcessId: 'X-ArNS-Process-Id',
59
+ arnsAntProgramId: 'X-ArNS-Ant-Program-Id',
60
+ arnsAntId: 'X-ArNS-Ant-Id',
57
61
  arnsResolvedAt: 'X-ArNS-Resolved-At',
58
62
  arnsLimit: 'X-ArNS-Undername-Limit',
59
63
  arnsIndex: 'X-ArNS-Record-Index',
64
+ // HTTPSIG headers (RFC 9421)
65
+ signatureInput: 'Signature-Input',
66
+ signature: 'Signature',
67
+ // Arweave transaction metadata
68
+ arweaveOwner: 'X-Arweave-Owner',
69
+ arweaveOwnerAddress: 'X-Arweave-Owner-Address',
70
+ arweaveSignature: 'X-Arweave-Signature',
71
+ arweaveSignatureType: 'X-Arweave-Signature-Type',
72
+ arweaveTagCount: 'X-Arweave-Tag-Count',
60
73
  };
@@ -14,7 +14,7 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import type { AoARIORead } from '@ar.io/sdk';
17
+ import type { ARIORead } from '@ar.io/sdk';
18
18
  import type { GatewaysProvider, Logger, SortBy, SortOrder } from '../types.js';
19
19
  export declare class NetworkGatewaysProvider implements GatewaysProvider {
20
20
  private ario;
@@ -24,7 +24,7 @@ export declare class NetworkGatewaysProvider implements GatewaysProvider {
24
24
  private filter;
25
25
  private logger;
26
26
  constructor({ ario, sortBy, sortOrder, limit, filter, logger, }: {
27
- ario: AoARIORead;
27
+ ario: ARIORead;
28
28
  sortBy?: SortBy;
29
29
  sortOrder?: SortOrder;
30
30
  limit?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/gateways/network.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE/E,qBAAa,uBAAwB,YAAW,gBAAgB;IAC9D,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,MAAM,CAAS;gBAEX,EACV,IAAI,EACJ,MAAwB,EACxB,SAAkB,EAClB,KAAY,EACZ,MAAqC,EACrC,MAAsB,GACvB,EAAE;QACD,IAAI,EAAE,UAAU,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC;QACnC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IASK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;CA2DpC"}
1
+ {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/gateways/network.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE/E,qBAAa,uBAAwB,YAAW,gBAAgB;IAC9D,OAAO,CAAC,IAAI,CAAW;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,MAAM,CAAS;gBAEX,EACV,IAAI,EACJ,MAAwB,EACxB,SAAkB,EAClB,KAAY,EACZ,MAAqC,EACrC,MAAsB,GACvB,EAAE;QACD,IAAI,EAAE,QAAQ,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;QACrB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC;QACnC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IASK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;CA2DpC"}
@@ -23,9 +23,11 @@ import type { GatewaysProvider, Logger } from '../types.js';
23
23
  export declare class TrustedPeersGatewaysProvider implements GatewaysProvider {
24
24
  private trustedGateway;
25
25
  private logger;
26
- constructor({ trustedGateway, logger, }: {
26
+ private timeoutMs;
27
+ constructor({ trustedGateway, logger, timeoutMs, }: {
27
28
  trustedGateway: string | URL;
28
29
  logger?: Logger;
30
+ timeoutMs?: number;
29
31
  });
30
32
  getGateways(): Promise<URL[]>;
31
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"trusted-peers.d.ts","sourceRoot":"","sources":["../../src/gateways/trusted-peers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH;;;;GAIG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE5D,qBAAa,4BAA6B,YAAW,gBAAgB;IACnE,OAAO,CAAC,cAAc,CAAM;IAC5B,OAAO,CAAC,MAAM,CAAS;gBAEX,EACV,cAAc,EACd,MAAsB,GACvB,EAAE;QAAE,cAAc,EAAE,MAAM,GAAG,GAAG,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAK9C,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;CAoCpC"}
1
+ {"version":3,"file":"trusted-peers.d.ts","sourceRoot":"","sources":["../../src/gateways/trusted-peers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH;;;;GAIG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE5D,qBAAa,4BAA6B,YAAW,gBAAgB;IACnE,OAAO,CAAC,cAAc,CAAM;IAC5B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAS;gBAEd,EACV,cAAc,EACd,MAAsB,EACtB,SAAkB,GACnB,EAAE;QAAE,cAAc,EAAE,MAAM,GAAG,GAAG,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;IAMlE,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;CAuCpC"}
@@ -23,14 +23,19 @@ import { defaultLogger } from '../logger.js';
23
23
  export class TrustedPeersGatewaysProvider {
24
24
  trustedGateway;
25
25
  logger;
26
- constructor({ trustedGateway, logger = defaultLogger, }) {
26
+ timeoutMs;
27
+ constructor({ trustedGateway, logger = defaultLogger, timeoutMs = 10_000, }) {
27
28
  this.trustedGateway = new URL(trustedGateway.toString());
28
29
  this.logger = logger;
30
+ this.timeoutMs = timeoutMs;
29
31
  }
30
32
  async getGateways() {
31
33
  const endpoint = new URL('/ar-io/peers', this.trustedGateway).toString();
32
34
  this.logger.debug('Fetching trusted peer list from', { endpoint });
33
- const response = await fetch(endpoint, { method: 'GET' });
35
+ const response = await fetch(endpoint, {
36
+ method: 'GET',
37
+ signal: AbortSignal.timeout(this.timeoutMs),
38
+ });
34
39
  if (!response.ok) {
35
40
  throw new Error(`Failed to fetch trusted peer list: ${response.status} ${response.statusText} ${await response.text()}`);
36
41
  }
@@ -23,9 +23,13 @@ import type { DataRetrievalStrategy, Logger } from '../types.js';
23
23
  export declare class ChunkDataRetrievalStrategy implements DataRetrievalStrategy {
24
24
  private logger;
25
25
  private fetch;
26
- constructor({ logger, fetch, }?: {
26
+ private metadataTimeoutMs;
27
+ private chunkTimeoutMs;
28
+ constructor({ logger, fetch, metadataTimeoutMs, chunkTimeoutMs, }?: {
27
29
  logger?: Logger;
28
30
  fetch?: typeof globalThis.fetch;
31
+ metadataTimeoutMs?: number;
32
+ chunkTimeoutMs?: number;
29
33
  });
30
34
  getData({ gateway, requestUrl, headers, }: {
31
35
  gateway: URL;
@@ -1 +1 @@
1
- {"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../src/retrieval/chunk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEjE;;;;GAIG;AACH,qBAAa,0BAA2B,YAAW,qBAAqB;IACtE,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAA0B;gBAE3B,EACV,MAAsB,EACtB,KAAwB,GACzB,GAAE;QACD,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;KAC5B;IAKA,OAAO,CAAC,EACZ,OAAO,EACP,UAAU,EACV,OAAO,GACR,EAAE;QACD,OAAO,EAAE,GAAG,CAAC;QACb,UAAU,EAAE,GAAG,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,GAAG,OAAO,CAAC,QAAQ,CAAC;CAwOtB"}
1
+ {"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../src/retrieval/chunk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEjE;;;;GAIG;AACH,qBAAa,0BAA2B,YAAW,qBAAqB;IACtE,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,cAAc,CAAS;gBAEnB,EACV,MAAsB,EACtB,KAAwB,EACxB,iBAA0B,EAC1B,cAAuB,GACxB,GAAE;QACD,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;QAChC,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;KACpB;IAOA,OAAO,CAAC,EACZ,OAAO,EACP,UAAU,EACV,OAAO,GACR,EAAE;QACD,OAAO,EAAE,GAAG,CAAC;QACb,UAAU,EAAE,GAAG,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,GAAG,OAAO,CAAC,QAAQ,CAAC;CA4OtB"}
@@ -24,9 +24,13 @@ import { defaultLogger } from '../logger.js';
24
24
  export class ChunkDataRetrievalStrategy {
25
25
  logger;
26
26
  fetch;
27
- constructor({ logger = defaultLogger, fetch = globalThis.fetch, } = {}) {
27
+ metadataTimeoutMs;
28
+ chunkTimeoutMs;
29
+ constructor({ logger = defaultLogger, fetch = globalThis.fetch, metadataTimeoutMs = 10_000, chunkTimeoutMs = 30_000, } = {}) {
28
30
  this.logger = logger;
29
31
  this.fetch = fetch;
32
+ this.metadataTimeoutMs = metadataTimeoutMs;
33
+ this.chunkTimeoutMs = chunkTimeoutMs;
30
34
  }
31
35
  async getData({ gateway, requestUrl, headers, }) {
32
36
  this.logger.debug('Fetching data via ChunkDataRetrievalStrategy from gateway', {
@@ -35,6 +39,7 @@ export class ChunkDataRetrievalStrategy {
35
39
  });
36
40
  const headResponse = await this.fetch(requestUrl.toString(), {
37
41
  method: 'HEAD',
42
+ signal: AbortSignal.timeout(this.metadataTimeoutMs),
38
43
  headers,
39
44
  });
40
45
  if (!headResponse.ok) {
@@ -56,6 +61,7 @@ export class ChunkDataRetrievalStrategy {
56
61
  const offsetResponse = await this.fetch(offsetForRootTransactionIdUrl.toString(), {
57
62
  method: 'GET',
58
63
  redirect: 'follow',
64
+ signal: AbortSignal.timeout(this.metadataTimeoutMs),
59
65
  headers,
60
66
  });
61
67
  if (!offsetResponse.ok) {
@@ -86,6 +92,7 @@ export class ChunkDataRetrievalStrategy {
86
92
  const logger = this.logger;
87
93
  const fetchFn = this.fetch;
88
94
  const chunkGateway = gateway;
95
+ const chunkTimeoutMs = this.chunkTimeoutMs;
89
96
  // Create a readable stream that fetches chunks on demand
90
97
  const stream = new ReadableStream({
91
98
  async start(controller) {
@@ -103,6 +110,7 @@ export class ChunkDataRetrievalStrategy {
103
110
  const chunkResponse = await fetchFn(chunkUrl.toString(), {
104
111
  method: 'GET',
105
112
  redirect: 'follow',
113
+ signal: AbortSignal.timeout(chunkTimeoutMs),
106
114
  headers,
107
115
  });
108
116
  if (!chunkResponse.ok) {
@@ -22,9 +22,11 @@ import type { DataRetrievalStrategy, Logger } from '../types.js';
22
22
  export declare class ContiguousDataRetrievalStrategy implements DataRetrievalStrategy {
23
23
  private logger;
24
24
  private fetch;
25
- constructor({ logger, fetch, }?: {
25
+ private timeoutMs;
26
+ constructor({ logger, fetch, timeoutMs, }?: {
26
27
  logger?: Logger;
27
28
  fetch?: typeof globalThis.fetch;
29
+ timeoutMs?: number;
28
30
  });
29
31
  getData({ requestUrl, headers, }: {
30
32
  gateway: URL;
@@ -1 +1 @@
1
- {"version":3,"file":"contiguous.d.ts","sourceRoot":"","sources":["../../src/retrieval/contiguous.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEjE;;;GAGG;AACH,qBAAa,+BAAgC,YAAW,qBAAqB;IAC3E,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAA0B;gBAE3B,EACV,MAAsB,EACtB,KAAwB,GACzB,GAAE;QACD,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;KAC5B;IAKA,OAAO,CAAC,EACZ,UAAU,EACV,OAAO,GACR,EAAE;QACD,OAAO,EAAE,GAAG,CAAC;QACb,UAAU,EAAE,GAAG,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,GAAG,OAAO,CAAC,QAAQ,CAAC;CAatB"}
1
+ {"version":3,"file":"contiguous.d.ts","sourceRoot":"","sources":["../../src/retrieval/contiguous.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEjE;;;GAGG;AACH,qBAAa,+BAAgC,YAAW,qBAAqB;IAC3E,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,SAAS,CAAS;gBAEd,EACV,MAAsB,EACtB,KAAwB,EACxB,SAAkB,GACnB,GAAE;QACD,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;QAChC,SAAS,CAAC,EAAE,MAAM,CAAC;KACf;IAMA,OAAO,CAAC,EACZ,UAAU,EACV,OAAO,GACR,EAAE;QACD,OAAO,EAAE,GAAG,CAAC;QACb,UAAU,EAAE,GAAG,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,GAAG,OAAO,CAAC,QAAQ,CAAC;CActB"}
@@ -22,9 +22,11 @@ import { defaultLogger } from '../logger.js';
22
22
  export class ContiguousDataRetrievalStrategy {
23
23
  logger;
24
24
  fetch;
25
- constructor({ logger = defaultLogger, fetch = globalThis.fetch, } = {}) {
25
+ timeoutMs;
26
+ constructor({ logger = defaultLogger, fetch = globalThis.fetch, timeoutMs = 30_000, } = {}) {
26
27
  this.logger = logger;
27
28
  this.fetch = fetch;
29
+ this.timeoutMs = timeoutMs;
28
30
  }
29
31
  async getData({ requestUrl, headers, }) {
30
32
  this.logger.debug('Fetching contiguous transaction data', {
@@ -32,6 +34,7 @@ export class ContiguousDataRetrievalStrategy {
32
34
  });
33
35
  return this.fetch(requestUrl.toString(), {
34
36
  method: 'GET',
37
+ signal: AbortSignal.timeout(this.timeoutMs),
35
38
  headers: {
36
39
  ...headers,
37
40
  'x-wayfinder-data-retrieval-strategy': 'contiguous',
@@ -27,8 +27,8 @@ export class RoundRobinRoutingStrategy {
27
27
  }
28
28
  if (!gateways && !gatewaysProvider) {
29
29
  gateways = [
30
- new URL('https://arweave.net'),
31
- new URL('https://permagate.io'),
30
+ new URL('https://turbo-gateway.com'),
31
+ new URL('https://g8way.io'),
32
32
  ];
33
33
  }
34
34
  this.gateways = gateways || [];
package/dist/version.d.ts CHANGED
@@ -14,5 +14,5 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- export declare const WAYFINDER_CORE_VERSION = "v1.9.1";
17
+ export declare const WAYFINDER_CORE_VERSION = "v2.0.0";
18
18
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -14,4 +14,4 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- export const WAYFINDER_CORE_VERSION = 'v1.9.1';
17
+ export const WAYFINDER_CORE_VERSION = 'v2.0.0';
@@ -119,7 +119,7 @@ export declare class Wayfinder {
119
119
  * const wayfinder = new Wayfinder({
120
120
  * verificationSettings: {
121
121
  * strategy: new HashVerificationStrategy({
122
- * trustedGateways: [new URL('https://permagate.io')],
122
+ * trustedGateways: [new URL('https://turbo-gateway.com')],
123
123
  * }),
124
124
  * events: {
125
125
  * onVerificationProgress: (event) => {
@@ -189,7 +189,7 @@ export declare class Wayfinder {
189
189
  * @example
190
190
  * const wayfinder = new Wayfinder();
191
191
  * wayfinder.setVerificationStrategy(new HashVerificationStrategy({
192
- * trustedGateways: [new URL('https://permagate.io')],
192
+ * trustedGateways: [new URL('https://turbo-gateway.com')],
193
193
  * }));
194
194
  *
195
195
  * @param strategy - The verification strategy to use
@@ -240,7 +240,7 @@ export declare class Wayfinder {
240
240
  * @example
241
241
  * const wayfinder = new Wayfinder({
242
242
  * verificationStrategy: new HashVerificationStrategy({
243
- * trustedGateways: [new URL('https://permagate.io')],
243
+ * trustedGateways: [new URL('https://turbo-gateway.com')],
244
244
  * }),
245
245
  * })
246
246
  *
package/dist/wayfinder.js CHANGED
@@ -209,7 +209,7 @@ export class Wayfinder {
209
209
  * const wayfinder = new Wayfinder({
210
210
  * verificationSettings: {
211
211
  * strategy: new HashVerificationStrategy({
212
- * trustedGateways: [new URL('https://permagate.io')],
212
+ * trustedGateways: [new URL('https://turbo-gateway.com')],
213
213
  * }),
214
214
  * events: {
215
215
  * onVerificationProgress: (event) => {
@@ -263,7 +263,7 @@ export class Wayfinder {
263
263
  this.gatewaysProvider =
264
264
  gatewaysProvider ??
265
265
  new TrustedPeersGatewaysProvider({
266
- trustedGateway: 'https://arweave.net',
266
+ trustedGateway: 'https://turbo-gateway.com',
267
267
  logger: this.logger,
268
268
  });
269
269
  // default verification settings
@@ -276,7 +276,7 @@ export class Wayfinder {
276
276
  strategy: (verificationSettings?.strategy ?? verificationSettings?.enabled)
277
277
  ? new HashVerificationStrategy({
278
278
  logger,
279
- trustedGateways: [new URL('https://permagate.io')],
279
+ trustedGateways: [new URL('https://turbo-gateway.com')],
280
280
  })
281
281
  : undefined,
282
282
  // overwrite the default settings with the provided ones
@@ -391,7 +391,7 @@ export class Wayfinder {
391
391
  * @example
392
392
  * const wayfinder = new Wayfinder();
393
393
  * wayfinder.setVerificationStrategy(new HashVerificationStrategy({
394
- * trustedGateways: [new URL('https://permagate.io')],
394
+ * trustedGateways: [new URL('https://turbo-gateway.com')],
395
395
  * }));
396
396
  *
397
397
  * @param strategy - The verification strategy to use
@@ -443,7 +443,7 @@ export class Wayfinder {
443
443
  this.verificationSettings.strategy ??
444
444
  new HashVerificationStrategy({
445
445
  logger: this.logger,
446
- trustedGateways: [new URL('https://permagate.io')],
446
+ trustedGateways: [new URL('https://turbo-gateway.com')],
447
447
  });
448
448
  }
449
449
  /**
@@ -453,7 +453,7 @@ export class Wayfinder {
453
453
  * @example
454
454
  * const wayfinder = new Wayfinder({
455
455
  * verificationStrategy: new HashVerificationStrategy({
456
- * trustedGateways: [new URL('https://permagate.io')],
456
+ * trustedGateways: [new URL('https://turbo-gateway.com')],
457
457
  * }),
458
458
  * })
459
459
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/wayfinder-core",
3
- "version": "1.9.1",
3
+ "version": "2.0.0",
4
4
  "description": "WayFinder core library for intelligently routing to optimal AR.IO gateways",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -44,7 +44,8 @@
44
44
  "clean": "rimraf dist",
45
45
  "update-version": "node scripts/update-version.mjs",
46
46
  "test": "npm run test:unit",
47
- "test:unit": "c8 tsx --test 'src/**/*.test.ts'",
47
+ "test:unit": "c8 tsx --test 'src/client.test.ts' 'src/routing/*.test.ts' 'src/gateways/*.test.ts' 'src/retrieval/*.test.ts' 'src/verification/*.test.ts' 'src/utils/*.test.ts'",
48
+ "test:integration": "c8 tsx --test 'src/wayfinder.test.ts'",
48
49
  "lint:fix": "biome check --write --unsafe --config-path=../../biome.json",
49
50
  "lint:check": "biome check --unsafe --config-path=../../biome.json",
50
51
  "format:fix": "biome format --write --config-path=../../biome.json",
@@ -65,7 +66,7 @@
65
66
  "zone.js": "^0.15.1"
66
67
  },
67
68
  "peerDependencies": {
68
- "@ar.io/sdk": ">=3.12.0"
69
+ "@ar.io/sdk": ">=4.0.0"
69
70
  },
70
71
  "peerDependenciesMeta": {
71
72
  "@ar.io/sdk": {
@@ -73,7 +74,7 @@
73
74
  }
74
75
  },
75
76
  "devDependencies": {
76
- "@ar.io/sdk": "^3.13.0",
77
+ "@ar.io/sdk": "^4.0.2",
77
78
  "@types/node": "^24.0.0",
78
79
  "tsx": "^4.20.3"
79
80
  }