@ar.io/wayfinder-core 1.4.0-alpha.0 → 1.4.0-alpha.2

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
@@ -75,14 +75,6 @@ const wayfinder = createWayfinderClient({
75
75
  // List of trusted gateways for verification
76
76
  trustedGateways: ['https://arweave.net', 'https://permagate.io'],
77
77
  });
78
-
79
- // Sync version with static gateways (when no ario instance provided)
80
- const wayfinderSync = createWayfinderClientSync({
81
- // Same options as above, but uses static gateways by default
82
- routing: 'random',
83
- verification: 'disabled',
84
- trustedGateways: ['https://permagate.io', 'https://arweave.net'],
85
- });
86
78
  ```
87
79
 
88
80
  ### Gateway Selection Options (with AR.IO Network)
@@ -97,11 +89,12 @@ const wayfinder = createWayfinderClient({
97
89
  ario: ARIO.mainnet(),
98
90
 
99
91
  // Gateway selection (only works with ARIO instance)
100
- gatewaySelection: 'highest-performing', // Options:
101
- // 'highest-performing' - Gateways with best performance metrics
102
- // 'longest-tenure' - Gateways with longest service history
92
+ gatewaySelection: 'top-ranked', // Options:
93
+ // 'top-ranked' - Gateways with highest composite weight
94
+ // 'most-tenured' - Gateways with longest service history
103
95
  // 'highest-staked' - Gateways with most stake
104
- // 'highest-weight' - Gateways with highest composite weight
96
+ // 'top-ranked' - Gateways with highest composite weight
97
+ // 'best-performance' - Gateways with best performance metrics
105
98
  // 'longest-streak' - Gateways with longest uptime streak
106
99
 
107
100
  routing: 'random', // How to select from the filtered gateways
@@ -216,10 +209,28 @@ Wayfinder supports multiple routing strategies to select target gateways for you
216
209
  Selects a random gateway from a list of gateways.
217
210
 
218
211
  ```javascript
219
- const routingStrategy = new RandomRoutingStrategy();
212
+ import { RandomRoutingStrategy, NetworkGatewaysProvider } from '@ar.io/wayfinder-core';
213
+ import { ARIO } from '@ar.io/sdk';
220
214
 
215
+ // Option 1: Use with static gateways (override gatewaysProvider if provided)
216
+ const routingStrategy = new RandomRoutingStrategy();
221
217
  const gateway = await routingStrategy.selectGateway({
222
- gateways: ['https://arweave.net', 'https://permagate.io'],
218
+ gateways: [new URL('https://arweave.net'), new URL('https://permagate.io')],
219
+ });
220
+
221
+ // Option 2: Use with gatewaysProvider (fetches dynamically)
222
+ const routingStrategy2 = new RandomRoutingStrategy({
223
+ gatewaysProvider: new NetworkGatewaysProvider({
224
+ ario: ARIO.mainnet(),
225
+ sortBy: 'operatorStake',
226
+ limit: 10,
227
+ }),
228
+ });
229
+ const gateway2 = await routingStrategy2.selectGateway(); // uses gatewaysProvider
230
+
231
+ // Option 3: Override gatewaysProvider with static gateways
232
+ const gateway3 = await routingStrategy2.selectGateway({
233
+ gateways: [new URL('https://custom-gateway.net')], // overrides gatewaysProvider
223
234
  });
224
235
  ```
225
236
 
@@ -237,42 +248,61 @@ const gateway = await routingStrategy.selectGateway(); // always returns the sam
237
248
 
238
249
  ### RoundRobinRoutingStrategy
239
250
 
240
- Selects gateways in round-robin order. The gateway list is stored in memory and is not persisted across instances.
251
+ Selects gateways in round-robin order. The gateway list is stored in memory and is not persisted across instances. You must provide either `gateways` OR `gatewaysProvider` (not both).
241
252
 
242
253
  ```javascript
243
- import { Wayfinder, NetworkGatewaysProvider, RoundRobinRoutingStrategy } from '@ar.io/wayfinder-core';
254
+ import { RoundRobinRoutingStrategy, NetworkGatewaysProvider } from '@ar.io/wayfinder-core';
244
255
  import { ARIO } from '@ar.io/sdk';
245
256
 
246
- const gatewayProvider = new NetworkGatewaysProvider({
247
- ario: ARIO.mainnet(),
248
- sortBy: 'operatorStake',
249
- sortOrder: 'desc',
250
- limit: 10,
257
+ // use with a static list of gateways
258
+ const routingStrategy = new RoundRobinRoutingStrategy({
259
+ gateways: [new URL('https://arweave.net'), new URL('https://permagate.io')],
251
260
  });
252
261
 
253
- // provide the gateways to the routing strategy on initialization to track the request count per gateway.
254
- // Any additional gateways provided to the selectGateway method will be ignored.
255
- const routingStrategy = new RoundRobinRoutingStrategy({
256
- gateways: await gatewayProvider.getGateways(),
262
+ // use with gatewaysProvider (loaded once and memoized)
263
+ const routingStrategy2 = new RoundRobinRoutingStrategy({
264
+ gatewaysProvider: new NetworkGatewaysProvider({
265
+ ario: ARIO.mainnet(),
266
+ sortBy: 'operatorStake',
267
+ sortOrder: 'desc',
268
+ limit: 10,
269
+ }),
257
270
  });
258
271
 
259
- const gateway = await routingStrategy.selectGateway(); // returns the next gateway in the list
272
+ const gateway = await routingStrategy.selectGateway(); // returns the next gateway in round-robin order
260
273
  ```
261
274
 
262
275
  ### FastestPingRoutingStrategy
263
276
 
264
- Selects the fastest gateway based simple HEAD request to the specified route.
277
+ Selects the fastest gateway based on simple HEAD request to the specified route.
265
278
 
266
279
  ```javascript
267
- import { Wayfinder, FastestPingRoutingStrategy } from '@ar.io/wayfinder-core';
280
+ import { FastestPingRoutingStrategy, NetworkGatewaysProvider } from '@ar.io/wayfinder-core';
281
+ import { ARIO } from '@ar.io/sdk';
268
282
 
283
+ // use with static gateways (override gatewaysProvider if provided)
269
284
  const routingStrategy = new FastestPingRoutingStrategy({
270
285
  timeoutMs: 1000,
271
286
  });
272
-
273
- // will select the fastest gateway from the list based on the ping time of the /ar-io/info route
274
287
  const gateway = await routingStrategy.selectGateway({
275
- gateways: ['https://slow.net', 'https://medium.net', 'https://fast.net'],
288
+ gateways: [new URL('https://slow.net'), new URL('https://medium.net'), new URL('https://fast.net')],
289
+ });
290
+
291
+ // use with gatewaysProvider (fetches dynamically)
292
+ const routingStrategy2 = new FastestPingRoutingStrategy({
293
+ timeoutMs: 1000,
294
+ gatewaysProvider: new NetworkGatewaysProvider({
295
+ ario: ARIO.mainnet(),
296
+ sortBy: 'operatorStake',
297
+ limit: 20,
298
+ }),
299
+ });
300
+ const gateway2 = await routingStrategy2.selectGateway({ path: '/ar-io/info' }); // uses gatewaysProvider
301
+
302
+ // override the gatewaysProvider with a static list of gateways
303
+ const gateway3 = await routingStrategy2.selectGateway({
304
+ gateways: [new URL('https://priority-gateway.net')], // overrides gatewaysProvider
305
+ path: '/ar-io/info'
276
306
  });
277
307
  ```
278
308
 
@@ -332,7 +362,7 @@ const strategy = new SimpleCacheRoutingStrategy({
332
362
  });
333
363
  ```
334
364
 
335
- #### Preferred gateway with fallback to ping-random
365
+ #### Preferred gateway + network fallback strategy
336
366
 
337
367
  Attempt to use a favorite gateway, but fallback to a fastest pinging strategy using the ARIO Network if it fails.
338
368
 
@@ -639,15 +669,6 @@ yarn add @ar.io/wayfinder-core @ar.io/sdk
639
669
  - Supports intelligent gateway selection criteria
640
670
  - Dynamic gateway discovery and updates
641
671
 
642
- **Without AR.IO SDK:**
643
- ```bash
644
- npm install @ar.io/wayfinder-core
645
- ```
646
- - `createWayfinderClient()` falls back to curated static gateways
647
- - `createWayfinderClientSync()` uses only static gateways
648
- - Full routing and verification functionality available
649
- - No network gateway selection options
650
-
651
672
  ### Caching
652
673
 
653
674
  Wayfinder supports intelligent caching:
@@ -671,23 +692,23 @@ import { createWayfinderClient, NetworkGatewaysProvider } from '@ar.io/wayfinder
671
692
  import { ARIO } from '@ar.io/sdk';
672
693
 
673
694
  const wayfinder = createWayfinderClient({
674
- // Use custom gateways provider
675
- gatewaysProvider: new NetworkGatewaysProvider({
676
- ario: ARIO.mainnet(),
677
- sortBy: 'operatorStake',
678
- sortOrder: 'desc',
679
- limit: 10,
680
- }),
681
-
682
- // Override with custom verification strategy
683
- verification: 'hash',
684
- trustedGateways: ['https://permagate.io'],
695
+ ario: ARIO.mainnet()
685
696
 
686
697
  // Gateway selection
687
- gatewaySelection: 'highest-staked',
698
+ gatewaySelection: 'top-ranked',
688
699
 
689
700
  // Enable caching with custom TTL
690
701
  cache: { ttlSeconds: 3600 }, // 1 hour
702
+
703
+ // Override 'routing' with custom routing strategy
704
+ routingStrategy: new FastestPingRoutingStrategy({
705
+ timeoutMs: 1000,
706
+ }),
707
+
708
+ // Override 'verification' with custom verification strategy
709
+ verificationStrategy: new HashVerificationStrategy({
710
+ trustedGateways: ['https://permagate.io'],
711
+ }),
691
712
  });
692
713
  ```
693
714
 
package/dist/client.d.ts CHANGED
@@ -15,16 +15,8 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import type { AoARIORead } from '@ar.io/sdk';
18
- import type { GatewaysProvider, Logger, RoutingStrategy, VerificationStrategy } from './types.js';
18
+ import type { GatewaySelection, GatewaysProvider, Logger, RoutingOption, RoutingStrategy, VerificationOption, VerificationStrategy } from './types.js';
19
19
  import { Wayfinder } from './wayfinder.js';
20
- export type RoutingOption = 'random' | 'fastest' | 'round-robin' | 'preferred';
21
- export type VerificationOption = 'hash' | 'data-root' | 'remote' | 'disabled';
22
- export type GatewaySelection = 'highest-performing' | 'longest-tenure' | 'highest-staked' | 'highest-weight' | 'longest-streak';
23
- /**
24
- * Creates a Wayfinder client synchronously using static gateways
25
- * Use this when you want to avoid the AR.IO SDK dependency
26
- */
27
- export declare function createWayfinderClientSync(options?: CreateWayfinderClientOptions): Wayfinder;
28
20
  export interface CreateWayfinderClientOptions {
29
21
  /**
30
22
  * The ARIO instance to use for network gateways provider
@@ -44,12 +36,12 @@ export interface CreateWayfinderClientOptions {
44
36
  /**
45
37
  * The gateway selection when using NetworkGatewaysProvider (requires ario instance)
46
38
  * Only applies when using AR.IO network - ignored for static gateways
47
- * @default 'highest-performing'
39
+ * @default 'top-ranked'
48
40
  */
49
41
  gatewaySelection?: GatewaySelection;
50
42
  /**
51
43
  * The trusted gateways to use
52
- * @default ['https://arweave.net']
44
+ * @default ['https://permagate.io']
53
45
  */
54
46
  trustedGateways?: string[];
55
47
  /**
@@ -64,26 +56,54 @@ export interface CreateWayfinderClientOptions {
64
56
  };
65
57
  /**
66
58
  * Custom logger implementation
59
+ * @default undefined
67
60
  */
68
61
  logger?: Logger;
69
62
  /**
70
63
  * Custom gateways provider (overrides gatewaySelection)
64
+ * @default undefined
71
65
  */
72
66
  gatewaysProvider?: GatewaysProvider;
73
67
  /**
74
68
  * Custom routing strategy (overrides routing option)
69
+ * @default undefined
75
70
  */
76
71
  routingStrategy?: RoutingStrategy;
77
72
  /**
78
73
  * Custom verification strategy (overrides verification option)
74
+ * @default undefined
79
75
  */
80
76
  verificationStrategy?: VerificationStrategy;
77
+ /**
78
+ * The preferred gateway to use when routing is 'preferred'
79
+ * Defaults to the first trusted gateway if not specified
80
+ * @default 'arweave.net'
81
+ */
82
+ preferredGateway?: string;
83
+ /**
84
+ * The fallback routing strategy to use when routing is 'preferred'
85
+ * @default 'random'
86
+ */
87
+ fallbackStrategy?: RoutingOption;
81
88
  }
89
+ /**
90
+ * Helper function to construct a routing strategy
91
+ * @param strategy - The routing strategy to use
92
+ * @param config
93
+ * @returns
94
+ */
95
+ export declare const useRoutingStrategy: (strategy: RoutingOption, config?: any) => RoutingStrategy;
96
+ /**
97
+ * Helper function to construct a verification strategy
98
+ * @param strategy - The verification strategy to use
99
+ * @param config - The configuration to use
100
+ * @returns
101
+ */
102
+ export declare const useVerificationStrategy: (strategy: VerificationOption, config?: any) => VerificationStrategy;
82
103
  /**
83
104
  * Creates a Wayfinder client with the specified configuration
84
105
  * Uses static gateways by default. Provide an `ario` instance to use NetworkGatewaysProvider
85
106
  */
86
107
  export declare function createWayfinderClient(options?: CreateWayfinderClientOptions): Wayfinder;
87
108
  export declare const createWayfinder: typeof createWayfinderClient;
88
- export declare const createWayfinderSync: typeof createWayfinderClientSync;
89
109
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAS7C,OAAO,KAAK,EACV,gBAAgB,EAChB,MAAM,EACN,eAAe,EACf,oBAAoB,EAErB,MAAM,YAAY,CAAC;AAKpB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC;AAE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FastestPingRoutingStrategy } from './routing/ping.js';
22
22
  import { PreferredWithFallbackRoutingStrategy } from './routing/preferred-with-fallback.js';
23
23
  import { RandomRoutingStrategy } from './routing/random.js';
24
+ import { RoundRobinRoutingStrategy } from './routing/round-robin.js';
24
25
  import { SimpleCacheRoutingStrategy } from './routing/simple-cache.js';
25
26
  import { isBrowser } from './utils/browser.js';
26
27
  import { DataRootVerificationStrategy } from './verification/data-root-verification.js';
27
28
  import { HashVerificationStrategy } from './verification/hash-verification.js';
28
29
  import { RemoteVerificationStrategy } from './verification/remote-verification.js';
29
30
  import { Wayfinder } from './wayfinder.js';
31
+ const selectionSortMap = {
32
+ 'best-performance': {
33
+ sortBy: 'weights.gatewayPerformanceRatio',
34
+ sortOrder: 'desc',
35
+ },
36
+ 'most-tenured': { sortBy: 'weights.tenureWeight', sortOrder: 'desc' },
37
+ 'highest-staked': { sortBy: 'weights.stakeWeight', sortOrder: 'desc' },
38
+ 'top-ranked': {
39
+ sortBy: 'weights.normalizedCompositeWeight',
40
+ sortOrder: 'desc',
41
+ },
42
+ 'longest-streak': {
43
+ sortBy: 'stats.passedConsecutiveEpochs',
44
+ sortOrder: 'desc',
45
+ },
46
+ };
30
47
  /**
31
- * Creates a Wayfinder client synchronously using static gateways
32
- * Use this when you want to avoid the AR.IO SDK dependency
48
+ * Helper function to construct a routing strategy
49
+ * @param strategy - The routing strategy to use
50
+ * @param config
51
+ * @returns
33
52
  */
34
- export function createWayfinderClientSync(options = {}) {
35
- const { routing = 'random', verification = 'disabled', trustedGateways = [], cache = false, gatewaySelection, logger, ario, gatewaysProvider: customGatewaysProvider, routingStrategy: customRoutingStrategy, verificationStrategy: customVerificationStrategy, } = options;
36
- // Parse cache configuration
37
- const cacheEnabled = !!cache;
38
- const cacheTTLSeconds = typeof cache === 'object' ? cache.ttlSeconds : 300; // 5 minutes default
39
- // Set up gateways provider
40
- let gatewaysProvider;
41
- if (customGatewaysProvider) {
42
- gatewaysProvider = customGatewaysProvider;
43
- }
44
- else if (ario) {
45
- // Use NetworkGatewaysProvider if ARIO instance is provided
46
- let sortBy = 'totalDelegatedStake';
47
- let sortOrder = 'desc';
48
- const selection = gatewaySelection || 'highest-performing';
49
- switch (selection) {
50
- case 'highest-performing':
51
- sortBy = 'weights.gatewayPerformanceRatio';
52
- sortOrder = 'desc';
53
- break;
54
- case 'longest-tenure':
55
- sortBy = 'weights.tenureWeight';
56
- sortOrder = 'desc';
57
- break;
58
- case 'highest-staked':
59
- sortBy = 'weights.stakeWeight';
60
- sortOrder = 'desc';
61
- break;
62
- case 'highest-weight':
63
- sortBy = 'weights.normalizedCompositeWeight';
64
- sortOrder = 'desc';
65
- break;
66
- case 'longest-streak':
67
- sortBy = 'stats.passedConsecutiveEpochs';
68
- sortOrder = 'desc';
69
- break;
70
- default:
71
- sortBy = 'weights.normalizedCompositeWeight';
72
- sortOrder = 'desc';
73
- break;
74
- }
75
- gatewaysProvider = new NetworkGatewaysProvider({
76
- ario,
77
- sortBy,
78
- sortOrder,
79
- limit: 10,
80
- });
81
- }
82
- else {
83
- // Fall back to static gateways when no ARIO instance is provided
84
- gatewaysProvider = new StaticGatewaysProvider({
85
- gateways: trustedGateways.length
86
- ? trustedGateways
87
- : [
88
- 'https://permagate.io',
89
- 'https://arweave.net',
90
- 'https://ardrive.net',
91
- ],
92
- });
93
- }
94
- // Wrap with cache if enabled
95
- if (cacheEnabled) {
96
- if (isBrowser()) {
97
- gatewaysProvider = new LocalStorageGatewaysProvider({
98
- gatewaysProvider: gatewaysProvider,
99
- ttlSeconds: cacheTTLSeconds,
100
- });
101
- }
102
- else {
103
- gatewaysProvider = new SimpleCacheGatewaysProvider({
104
- gatewaysProvider: gatewaysProvider,
105
- ttlSeconds: cacheTTLSeconds,
106
- });
107
- }
108
- }
109
- // Set up routing strategy
110
- let routingStrategy;
111
- if (customRoutingStrategy) {
112
- routingStrategy = customRoutingStrategy;
113
- }
114
- else {
115
- switch (routing) {
116
- case 'random':
117
- routingStrategy = new RandomRoutingStrategy();
118
- break;
119
- case 'fastest':
120
- routingStrategy = new FastestPingRoutingStrategy();
121
- break;
122
- case 'preferred':
123
- routingStrategy = new PreferredWithFallbackRoutingStrategy({
124
- preferredGateway: trustedGateways[0],
125
- fallbackStrategy: new RandomRoutingStrategy(),
126
- });
127
- break;
128
- default:
129
- throw new Error(`Unknown routing strategy: ${routing}`);
130
- }
131
- // Wrap with cache if enabled
132
- if (cacheEnabled) {
133
- // TODO: add browser cache support for routing strategy
134
- routingStrategy = new SimpleCacheRoutingStrategy({
135
- routingStrategy,
136
- ttlSeconds: cacheTTLSeconds,
137
- });
138
- }
139
- }
140
- // Set up verification strategy
141
- let verificationStrategy;
142
- let verificationEnabled = true;
143
- if (customVerificationStrategy) {
144
- verificationStrategy = customVerificationStrategy;
145
- }
146
- else {
147
- switch (verification) {
148
- case 'hash':
149
- verificationStrategy = new HashVerificationStrategy({
150
- trustedGateways: trustedGateways.map((url) => new URL(url)),
151
- });
152
- break;
153
- case 'data-root':
154
- verificationStrategy = new DataRootVerificationStrategy({
155
- trustedGateways: trustedGateways.map((url) => new URL(url)),
156
- });
157
- break;
158
- case 'remote':
159
- verificationStrategy = new RemoteVerificationStrategy();
160
- break;
161
- case 'disabled':
162
- verificationEnabled = false;
163
- verificationStrategy = undefined;
164
- break;
165
- default:
166
- throw new Error(`Unknown verification strategy: ${verification}`);
167
- }
168
- }
169
- // Create Wayfinder options
170
- const wayfinderOptions = {
171
- logger,
172
- gatewaysProvider,
173
- routingSettings: {
174
- strategy: routingStrategy,
175
- },
53
+ export const useRoutingStrategy = (strategy, config) => {
54
+ const routingMap = {
55
+ random: new RandomRoutingStrategy(config),
56
+ fastest: new FastestPingRoutingStrategy(config),
57
+ preferred: new PreferredWithFallbackRoutingStrategy(config),
58
+ 'round-robin': new RoundRobinRoutingStrategy(config),
176
59
  };
177
- // Only add verification settings if not disabled
178
- if (verificationEnabled && verificationStrategy) {
179
- wayfinderOptions.verificationSettings = {
180
- enabled: true,
181
- strategy: verificationStrategy,
182
- };
183
- }
184
- else {
185
- wayfinderOptions.verificationSettings = {
186
- enabled: false,
187
- };
188
- }
189
- return new Wayfinder(wayfinderOptions);
190
- }
60
+ return routingMap[strategy];
61
+ };
62
+ /**
63
+ * Helper function to construct a verification strategy
64
+ * @param strategy - The verification strategy to use
65
+ * @param config - The configuration to use
66
+ * @returns
67
+ */
68
+ export const useVerificationStrategy = (strategy, config) => {
69
+ const verificationMap = {
70
+ hash: new HashVerificationStrategy(config),
71
+ 'data-root': new DataRootVerificationStrategy(config),
72
+ remote: new RemoteVerificationStrategy(),
73
+ disabled: undefined,
74
+ };
75
+ return verificationMap[strategy];
76
+ };
191
77
  /**
192
78
  * Creates a Wayfinder client with the specified configuration
193
79
  * Uses static gateways by default. Provide an `ario` instance to use NetworkGatewaysProvider
194
80
  */
195
81
  export function createWayfinderClient(options = {}) {
196
- const { routing = 'random', verification = 'disabled', trustedGateways = [], cache = false, gatewaySelection, logger, ario, gatewaysProvider: customGatewaysProvider, routingStrategy: customRoutingStrategy, verificationStrategy: customVerificationStrategy, } = options;
82
+ const { routing = 'random', verification = 'disabled', trustedGateways = ['https://permagate.io'], cache = false, gatewaySelection = 'top-ranked', logger, ario, gatewaysProvider: customGatewaysProvider, routingStrategy: customRoutingStrategy, verificationStrategy: customVerificationStrategy, preferredGateway = 'arweave.net', fallbackStrategy = 'random', } = options;
197
83
  // Parse cache configuration
198
84
  const cacheEnabled = !!cache;
199
85
  const cacheTTLSeconds = typeof cache === 'object' ? cache.ttlSeconds : 300; // 5 minutes default
@@ -203,35 +89,7 @@ export function createWayfinderClient(options = {}) {
203
89
  gatewaysProvider = customGatewaysProvider;
204
90
  }
205
91
  else if (ario) {
206
- // Use NetworkGatewaysProvider with dynamically imported ARIO
207
- let sortBy = 'totalDelegatedStake';
208
- let sortOrder = 'desc';
209
- switch (gatewaySelection) {
210
- case 'highest-performing':
211
- sortBy = 'weights.gatewayPerformanceRatio';
212
- sortOrder = 'desc';
213
- break;
214
- case 'longest-tenure':
215
- sortBy = 'weights.tenureWeight';
216
- sortOrder = 'desc';
217
- break;
218
- case 'highest-staked':
219
- sortBy = 'weights.stakeWeight';
220
- sortOrder = 'desc';
221
- break;
222
- case 'highest-weight':
223
- sortBy = 'weights.normalizedCompositeWeight';
224
- sortOrder = 'desc';
225
- break;
226
- case 'longest-streak':
227
- sortBy = 'stats.passedConsecutiveEpochs';
228
- sortOrder = 'desc';
229
- break;
230
- default:
231
- sortBy = 'weights.normalizedCompositeWeight';
232
- sortOrder = 'desc';
233
- break;
234
- }
92
+ const { sortBy, sortOrder } = selectionSortMap[gatewaySelection];
235
93
  gatewaysProvider = new NetworkGatewaysProvider({
236
94
  ario,
237
95
  sortBy,
@@ -272,22 +130,10 @@ export function createWayfinderClient(options = {}) {
272
130
  routingStrategy = customRoutingStrategy;
273
131
  }
274
132
  else {
275
- switch (routing) {
276
- case 'random':
277
- routingStrategy = new RandomRoutingStrategy();
278
- break;
279
- case 'fastest':
280
- routingStrategy = new FastestPingRoutingStrategy();
281
- break;
282
- case 'preferred':
283
- routingStrategy = new PreferredWithFallbackRoutingStrategy({
284
- preferredGateway: trustedGateways[0],
285
- fallbackStrategy: new RandomRoutingStrategy(),
286
- });
287
- break;
288
- default:
289
- throw new Error(`Unknown routing strategy: ${routing}`);
290
- }
133
+ routingStrategy = useRoutingStrategy(routing, {
134
+ preferredGateway,
135
+ fallbackStrategy,
136
+ });
291
137
  // Wrap with cache if enabled
292
138
  if (cacheEnabled) {
293
139
  // TODO: add browser cache support for routing strategy
@@ -299,32 +145,14 @@ export function createWayfinderClient(options = {}) {
299
145
  }
300
146
  // Set up verification strategy
301
147
  let verificationStrategy;
302
- let verificationEnabled = true;
148
+ const verificationEnabled = true;
303
149
  if (customVerificationStrategy) {
304
150
  verificationStrategy = customVerificationStrategy;
305
151
  }
306
152
  else {
307
- switch (verification) {
308
- case 'hash':
309
- verificationStrategy = new HashVerificationStrategy({
310
- trustedGateways: trustedGateways.map((url) => new URL(url)),
311
- });
312
- break;
313
- case 'data-root':
314
- verificationStrategy = new DataRootVerificationStrategy({
315
- trustedGateways: trustedGateways.map((url) => new URL(url)),
316
- });
317
- break;
318
- case 'remote':
319
- verificationStrategy = new RemoteVerificationStrategy();
320
- break;
321
- case 'disabled':
322
- verificationEnabled = false;
323
- verificationStrategy = undefined;
324
- break;
325
- default:
326
- throw new Error(`Unknown verification strategy: ${verification}`);
327
- }
153
+ verificationStrategy = useVerificationStrategy(verification, {
154
+ trustedGateways: trustedGateways.map((url) => new URL(url)),
155
+ });
328
156
  }
329
157
  // Create Wayfinder options
330
158
  const wayfinderOptions = {
@@ -348,6 +176,4 @@ export function createWayfinderClient(options = {}) {
348
176
  }
349
177
  return new Wayfinder(wayfinderOptions);
350
178
  }
351
- // Re-export as aliases
352
179
  export const createWayfinder = createWayfinderClient;
353
- export const createWayfinderSync = createWayfinderClientSync;
@@ -23,10 +23,11 @@ export declare class LocalStorageGatewaysProvider implements GatewaysProvider {
23
23
  private readonly ttlSeconds;
24
24
  private readonly logger;
25
25
  private gatewaysPromise;
26
- constructor({ ttlSeconds, gatewaysProvider, logger, }: {
26
+ constructor({ ttlSeconds, gatewaysProvider, logger, cacheKey, }: {
27
27
  ttlSeconds?: number;
28
28
  gatewaysProvider: GatewaysProvider;
29
29
  logger?: Logger;
30
+ cacheKey?: string;
30
31
  });
31
32
  getGateways(): Promise<URL[]>;
32
33
  private getCachedGateways;
@@ -1 +1 @@
1
- {"version":3,"file":"local-storage-cache.d.ts","sourceRoot":"","sources":["../../src/gateways/local-storage-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA+B1C,qBAAa,4BAA6B,YAAW,gBAAgB;IACnE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA8B;IACzD,OAAO,CAAC,QAAQ,CAAC,i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AAM,CAAC;KACnB;IAaK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAyCnC,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,aAAa;IAuBrB,UAAU,IAAI,IAAI;CAWnB"}
@@ -1,16 +1,17 @@
1
1
  import { defaultLogger } from '../logger.js';
2
2
  import { isBrowser } from '../utils/browser.js';
3
3
  export class LocalStorageGatewaysProvider {
4
- storageKey = 'wayfinder-gateways-cache';
4
+ storageKey;
5
5
  defaultTtlSeconds = 3600; // 1 hour default
6
6
  gatewaysProvider;
7
7
  ttlSeconds;
8
8
  logger;
9
9
  gatewaysPromise;
10
- constructor({ ttlSeconds, gatewaysProvider, logger = defaultLogger, }) {
10
+ constructor({ ttlSeconds, gatewaysProvider, logger = defaultLogger, cacheKey = 'gateways', }) {
11
11
  if (!isBrowser()) {
12
12
  throw new Error('LocalStorageGatewaysProvider is only available in browser environments. Consider using SimpleCacheGatewaysProvider for node.js environments.');
13
13
  }
14
+ this.storageKey = `wayfinder|${cacheKey}`;
14
15
  this.ttlSeconds = ttlSeconds ?? this.defaultTtlSeconds;
15
16
  this.gatewaysProvider = gatewaysProvider;
16
17
  this.logger = logger;
@@ -19,6 +20,7 @@ export class LocalStorageGatewaysProvider {
19
20
  const cached = this.getCachedGateways();
20
21
  if (cached && this.isCacheValid(cached)) {
21
22
  this.logger?.debug('Using cached gateways', {
23
+ storageKey: this.storageKey,
22
24
  ttlSeconds: this.ttlSeconds,
23
25
  timestamp: cached.timestamp,
24
26
  expiresAt: cached.expiresAt,
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import type { AoARIORead } from '@ar.io/sdk';
18
- import type { GatewaysProvider, Logger } from '../types.js';
18
+ import type { GatewaysProvider, Logger, SortBy, SortOrder } from '../types.js';
19
19
  export declare class NetworkGatewaysProvider implements GatewaysProvider {
20
20
  private ario;
21
21
  private sortBy;
@@ -25,8 +25,8 @@ export declare class NetworkGatewaysProvider implements GatewaysProvider {
25
25
  private logger;
26
26
  constructor({ ario, sortBy, sortOrder, limit, filter, logger, }: {
27
27
  ario: AoARIORead;
28
- sortBy?: 'totalDelegatedStake' | 'operatorStake' | 'startTimestamp' | 'weights.gatewayPerformanceRatio' | 'weights.tenureWeight' | 'weights.stakeWeight' | 'weights.compositeWeight' | 'stats.passedConsecutiveEpochs' | 'weights.normalizedCompositeWeight';
29
- sortOrder?: 'asc' | 'desc';
28
+ sortBy?: SortBy;
29
+ sortOrder?: SortOrder;
30
30
  limit?: number;
31
31
  blocklist?: string[];
32
32
  filter?: (gateway: any) => boolean;
@@ -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,aAAa,CAAC;AAE5D,qBAAa,uBAAwB,YAAW,gBAAgB;IAC9D,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,MAAM,CAS0B;IACxC,OAAO,CAAC,SAAS,CAAiB;IAClC,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,EACH,qBAAqB,GACrB,eAAe,GACf,gBAAgB,GAChB,iCAAiC,GACjC,sBAAsB,GACtB,qBAAqB,GACrB,yBAAyB,GACzB,+BAA+B,GAC/B,mCAAmC,CAAC;QACxC,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;QAC3B,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,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"}
@@ -16,7 +16,7 @@
16
16
  */
17
17
  import type { GatewaysProvider } from '../types.js';
18
18
  export declare class StaticGatewaysProvider implements GatewaysProvider {
19
- private gateways;
19
+ readonly gateways: URL[];
20
20
  constructor({ gateways }: {
21
21
  gateways: string[];
22
22
  });
@@ -1 +1 @@
1
- {"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../src/gateways/static.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,qBAAa,sBAAuB,YAAW,gBAAgB;IAC7D,OAAO,CAAC,QAAQ,CAAQ;gBACZ,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE;IAI1C,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;CAGpC"}
1
+ {"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../src/gateways/static.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,qBAAa,sBAAuB,YAAW,gBAAgB;IAC7D,SAAgB,QAAQ,EAAE,GAAG,EAAE,CAAC;gBACpB,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE;IAI1C,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;CAGpC"}
@@ -17,8 +17,8 @@
17
17
  import type { Logger, RoutingStrategy } from '../types.js';
18
18
  export declare class PreferredWithFallbackRoutingStrategy implements RoutingStrategy {
19
19
  readonly name = "preferred-with-fallback";
20
- private preferredGateway;
21
- private fallbackStrategy;
20
+ readonly preferredGateway: URL;
21
+ readonly fallbackStrategy: RoutingStrategy;
22
22
  private logger;
23
23
  constructor({ preferredGateway, fallbackStrategy, logger, }: {
24
24
  preferredGateway: string;
@@ -1 +1 @@
1
- {"version":3,"file":"preferred-with-fallback.d.ts","sourceRoot":"","sources":["../../src/routing/preferred-with-fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG3D,qBAAa,oCAAqC,YAAW,eAAe;IAC1E,SAAgB,IAAI,6BAA6B;IACjD,OAAO,CAAC,gBAAgB,CAAM;IAC9B,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,MAAM,CAAS;gBAEX,EACV,gBAAgB,EAChB,gBAAmD,EACnD,MAAsB,GACvB,EAAE;QACD,gBAAgB,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,eAAe,CAAC;QACnC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAMK,aAAa,CAAC,EAClB,QAAQ,EACR,IAAS,EACT,SAAS,GACV,EAAE;QACD,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,GAAG,CAAC;CA6CjB"}
1
+ {"version":3,"file":"preferred-with-fallback.d.ts","sourceRoot":"","sources":["../../src/routing/preferred-with-fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG3D,qBAAa,oCAAqC,YAAW,eAAe;IAC1E,SAAgB,IAAI,6BAA6B;IACjD,SAAgB,gBAAgB,EAAE,GAAG,CAAC;IACtC,SAAgB,gBAAgB,EAAE,eAAe,CAAC;IAClD,OAAO,CAAC,MAAM,CAAS;gBAEX,EACV,gBAAgB,EAChB,gBAAmD,EACnD,MAAsB,GACvB,EAAE;QACD,gBAAgB,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,eAAe,CAAC;QACnC,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAMK,aAAa,CAAC,EAClB,QAAQ,EACR,IAAS,EACT,SAAS,GACV,EAAE;QACD,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,GAAG,CAAC;CA6CjB"}
package/dist/types.d.ts CHANGED
@@ -48,6 +48,11 @@ export type WayfinderEvent = {
48
48
  totalBytes: number;
49
49
  };
50
50
  };
51
+ export type RoutingOption = 'random' | 'fastest' | 'round-robin' | 'preferred';
52
+ export type VerificationOption = 'hash' | 'data-root' | 'remote' | 'disabled';
53
+ export type GatewaySelection = 'best-performance' | 'most-tenured' | 'highest-staked' | 'top-ranked' | 'longest-streak';
54
+ export type SortBy = 'totalDelegatedStake' | 'operatorStake' | 'startTimestamp' | 'weights.gatewayPerformanceRatio' | 'weights.tenureWeight' | 'weights.stakeWeight' | 'weights.compositeWeight' | 'stats.passedConsecutiveEpochs' | 'weights.normalizedCompositeWeight';
55
+ export type SortOrder = 'asc' | 'desc';
51
56
  /**
52
57
  * Simple logger interface that Wayfinder will use
53
58
  * This allows users to provide their own logger implementation
@@ -112,7 +117,7 @@ export interface WayfinderOptions {
112
117
  /**
113
118
  * The verification strategy to use for verifying data
114
119
  */
115
- strategy?: VerificationStrategy;
120
+ strategy?: VerificationStrategy | undefined;
116
121
  /**
117
122
  * Whether verification should be strict (blocking)
118
123
  * If true, verification failures will cause requests to fail
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIrD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAC3B,KAAK,EAAE,GAAG,GAAG,WAAW,EACxB,IAAI,CAAC,EAAE,WAAW,GAAG;IACnB,oBAAoB,CAAC,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;IAChE,eAAe,CAAC,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;CACvD,KACE,OAAO,CA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WAAW,iBAAiB;IAChC,6CAA6C;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wBAAwB;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAID,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;AAEhF,MAAM,WAAW,gBAAgB;IAC/B,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,MAAM,EAAE;QACpB,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,GAAG,EAAE,CAAC;IACvB,UAAU,CAAC,MAAM,EAAE;QACjB,IAAI,EAAE,UAAU,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAChC,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,QAAQ,GAAG,aAAa,CAAC,CAAC;CACvE"}
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.4.0-alpha.0";
17
+ export declare const WAYFINDER_CORE_VERSION = "v1.4.0-alpha.2";
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.4.0-alpha.0';
17
+ export const WAYFINDER_CORE_VERSION = 'v1.4.0-alpha.2';
@@ -111,7 +111,9 @@ export declare class Wayfinder {
111
111
  /**
112
112
  * The verification settings to use when verifying data.
113
113
  */
114
- readonly verificationSettings: Required<NonNullable<WayfinderOptions['verificationSettings']>>;
114
+ readonly verificationSettings: Required<Omit<NonNullable<WayfinderOptions['verificationSettings']>, 'strategy'>> & {
115
+ strategy: VerificationStrategy | undefined;
116
+ };
115
117
  /**
116
118
  * Telemetry configuration used for OpenTelemetry tracing
117
119
  */
@@ -248,8 +250,9 @@ export declare class Wayfinder {
248
250
  * wayfinder.enableVerification();
249
251
  * @param strict - Whether to make verification strict
250
252
  */
251
- enableVerification({ strict, }?: {
253
+ enableVerification({ strict, strategy, }?: {
252
254
  strict?: boolean;
255
+ strategy?: VerificationStrategy;
253
256
  }): void;
254
257
  /**
255
258
  * A wrapped fetch function that supports ar:// protocol. If a verification strategy is provided,
@@ -1 +1 @@
1
- {"version":3,"file":"wayfinder.d.ts","sourceRoot":"","sources":["../src/wayfinder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAQ,KAAK,MAAM,EAAkB,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKhD,OAAO,KAAK,EACV,gBAAgB,EAChB,MAAM,EACN,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB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QG;IACH,kBAAkB,CAAC,QAAQ,EAAE,eAAe;IAI5C;;;;;;;;;;OAUG;IACH,uBAAuB,CAAC,QAAQ,EAAE,oBAAoB;IAItD;;;;;;;;;;;;;;;OAeG;IACH,mBAAmB;IAInB;;;;;;;;;;;;;;;;OAgBG;IACH,kBAAkB,CAAC,EACjB,MAAc,EACd,QAAQ,GACT,GAAE;QACD,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;KAC5B;IAWN;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,OAAO,CACL,KAAK,EAAE,GAAG,GAAG,WAAW,EACxB,IAAI,CAAC,EAAE,WAAW,GAAG;QACnB,oBAAoB,CAAC,EAAE,WAAW,CAChC,gBAAgB,CAAC,sBAAsB,CAAC,CACzC,CAAC;QACF,eAAe,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,CAAC;KACpE,GACA,OAAO,CAAC,QAAQ,CAAC;IAWpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,UAAU,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC;CAiD3D"}
package/dist/wayfinder.js CHANGED
@@ -537,9 +537,11 @@ export class Wayfinder {
537
537
  verificationSettings?.strategy !== undefined,
538
538
  events: {},
539
539
  strict: false,
540
- strategy: new HashVerificationStrategy({
541
- trustedGateways: [new URL('https://permagate.io')],
542
- }),
540
+ strategy: (verificationSettings?.strategy ?? verificationSettings?.enabled)
541
+ ? new HashVerificationStrategy({
542
+ trustedGateways: [new URL('https://permagate.io')],
543
+ })
544
+ : undefined,
543
545
  // overwrite the default settings with the provided ones
544
546
  ...verificationSettings,
545
547
  };
@@ -650,9 +652,15 @@ export class Wayfinder {
650
652
  * wayfinder.enableVerification();
651
653
  * @param strict - Whether to make verification strict
652
654
  */
653
- enableVerification({ strict = false, } = {}) {
655
+ enableVerification({ strict = false, strategy, } = {}) {
654
656
  this.verificationSettings.enabled = true;
655
657
  this.verificationSettings.strict = strict;
658
+ this.verificationSettings.strategy =
659
+ strategy ??
660
+ this.verificationSettings.strategy ??
661
+ new HashVerificationStrategy({
662
+ trustedGateways: [new URL('https://permagate.io')],
663
+ });
656
664
  }
657
665
  /**
658
666
  * A wrapped fetch function that supports ar:// protocol. If a verification strategy is provided,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/wayfinder-core",
3
- "version": "1.4.0-alpha.0",
3
+ "version": "1.4.0-alpha.2",
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",