@ar.io/wayfinder-core 1.4.0-alpha.1 → 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 +17 -16
- package/dist/client.d.ts +32 -12
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +54 -228
- package/dist/gateways/network.d.ts +3 -3
- package/dist/gateways/network.d.ts.map +1 -1
- package/dist/gateways/static.d.ts +1 -1
- package/dist/gateways/static.d.ts.map +1 -1
- package/dist/routing/preferred-with-fallback.d.ts +2 -2
- package/dist/routing/preferred-with-fallback.d.ts.map +1 -1
- package/dist/types.d.ts +6 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/wayfinder.d.ts +5 -2
- package/dist/wayfinder.d.ts.map +1 -1
- package/dist/wayfinder.js +12 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -89,11 +89,12 @@ const wayfinder = createWayfinderClient({
|
|
|
89
89
|
ario: ARIO.mainnet(),
|
|
90
90
|
|
|
91
91
|
// Gateway selection (only works with ARIO instance)
|
|
92
|
-
gatewaySelection: '
|
|
93
|
-
// '
|
|
94
|
-
// '
|
|
92
|
+
gatewaySelection: 'top-ranked', // Options:
|
|
93
|
+
// 'top-ranked' - Gateways with highest composite weight
|
|
94
|
+
// 'most-tenured' - Gateways with longest service history
|
|
95
95
|
// 'highest-staked' - Gateways with most stake
|
|
96
|
-
// '
|
|
96
|
+
// 'top-ranked' - Gateways with highest composite weight
|
|
97
|
+
// 'best-performance' - Gateways with best performance metrics
|
|
97
98
|
// 'longest-streak' - Gateways with longest uptime streak
|
|
98
99
|
|
|
99
100
|
routing: 'random', // How to select from the filtered gateways
|
|
@@ -691,23 +692,23 @@ import { createWayfinderClient, NetworkGatewaysProvider } from '@ar.io/wayfinder
|
|
|
691
692
|
import { ARIO } from '@ar.io/sdk';
|
|
692
693
|
|
|
693
694
|
const wayfinder = createWayfinderClient({
|
|
694
|
-
|
|
695
|
-
gatewaysProvider: new NetworkGatewaysProvider({
|
|
696
|
-
ario: ARIO.mainnet(),
|
|
697
|
-
sortBy: 'operatorStake',
|
|
698
|
-
sortOrder: 'desc',
|
|
699
|
-
limit: 10,
|
|
700
|
-
}),
|
|
701
|
-
|
|
702
|
-
// Override with custom verification strategy
|
|
703
|
-
verification: 'hash',
|
|
704
|
-
trustedGateways: ['https://permagate.io'],
|
|
695
|
+
ario: ARIO.mainnet()
|
|
705
696
|
|
|
706
697
|
// Gateway selection
|
|
707
|
-
gatewaySelection: '
|
|
698
|
+
gatewaySelection: 'top-ranked',
|
|
708
699
|
|
|
709
700
|
// Enable caching with custom TTL
|
|
710
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
|
+
}),
|
|
711
712
|
});
|
|
712
713
|
```
|
|
713
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 '
|
|
39
|
+
* @default 'top-ranked'
|
|
48
40
|
*/
|
|
49
41
|
gatewaySelection?: GatewaySelection;
|
|
50
42
|
/**
|
|
51
43
|
* The trusted gateways to use
|
|
52
|
-
* @default ['https://
|
|
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
|
package/dist/client.d.ts.map
CHANGED
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["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qB,CACnC,OAAO,GAAE,4BAAiC,GACzC,SAAS,CAkHX;AAED,eAAO,MAAM,eAAe,8BAAwB,CAAC"}
|
package/dist/client.js
CHANGED
|
@@ -21,179 +21,65 @@ import { StaticGatewaysProvider } from './gateways/static.js';
|
|
|
21
21
|
import { 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
|
-
*
|
|
32
|
-
*
|
|
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
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
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
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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
|
-
|
|
148
|
+
const verificationEnabled = true;
|
|
303
149
|
if (customVerificationStrategy) {
|
|
304
150
|
verificationStrategy = customVerificationStrategy;
|
|
305
151
|
}
|
|
306
152
|
else {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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;
|
|
@@ -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?:
|
|
29
|
-
sortOrder?:
|
|
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;
|
|
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 +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,
|
|
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
|
-
|
|
21
|
-
|
|
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,
|
|
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
|
package/dist/types.d.ts.map
CHANGED
|
@@ -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,CAAC,QAAQ,CAAC,CAAC;AAEvB,MAAM,MAAM,cAAc,GAAG;IAC3B,iBAAiB,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,iBAAiB,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,mBAAmB,EAAE;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,gBAAgB,EAAE,KAAK,CAAC;IACxB,wBAAwB,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3C,qBAAqB,EAAE,KAAK,CAAC;IAC7B,sBAAsB,EAAE;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,uBAAuB,EAAE;QACvB,IAAI,EAAE,MAAM,CAAC;QACb,cAAc,EAAE,MAAM,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;
|
|
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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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.
|
|
17
|
+
export declare const WAYFINDER_CORE_VERSION = "v1.4.0-alpha.2";
|
|
18
18
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
package/dist/wayfinder.d.ts
CHANGED
|
@@ -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,
|
package/dist/wayfinder.d.ts.map
CHANGED
|
@@ -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,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAKpB,eAAO,MAAM,uBAAuB,GAAI,cAErC;IACD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;;;CAMA,CAAC;AAGF,eAAO,MAAM,SAAS,QAAuB,CAAC;A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;;;;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:
|
|
541
|
-
|
|
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