@ar.io/wayfinder-core 1.0.6-alpha.0 → 1.0.6
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 +9 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/wayfinder.d.ts +4 -4
- package/dist/wayfinder.d.ts.map +1 -1
- package/dist/wayfinder.js +4 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
### Installation
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
To install the latest version, run:
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
npm install @ar.io/wayfinder-core
|
|
@@ -98,19 +98,23 @@ Gateway providers are responsible for providing a list of gateways to Wayfinder
|
|
|
98
98
|
|
|
99
99
|
### NetworkGatewaysProvider
|
|
100
100
|
|
|
101
|
-
Returns a list of gateways from the ARIO Network based on on-chain metrics. You can specify on-chain metrics for gateways to prioritize the highest quality gateways. This
|
|
101
|
+
Returns a list of gateways from the ARIO Network based on on-chain metrics. 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. *It is recommended to use this provider for most use cases to leverage the AR.IO Network.*
|
|
102
102
|
|
|
103
103
|
```javascript
|
|
104
104
|
// requests will be routed to one of the top 10 gateways by operator stake
|
|
105
105
|
const gatewayProvider = new NetworkGatewaysProvider({
|
|
106
106
|
ario: ARIO.mainnet(),
|
|
107
|
-
sortBy: 'operatorStake', // sort by
|
|
107
|
+
sortBy: 'operatorStake', // sort by 'operatorStake' | 'totalDelegatedStake'
|
|
108
108
|
sortOrder: 'desc', // 'asc'
|
|
109
|
-
limit: 10, // number of gateways to
|
|
109
|
+
limit: 10, // number of gateways to use
|
|
110
|
+
filter: (gateway) => {
|
|
111
|
+
// use only active gateways that did not fail in the last epoch
|
|
112
|
+
return gateway.status === 'joined' && gateway.stats.failedConsecutiveEpochs === 0;
|
|
113
|
+
},
|
|
110
114
|
});
|
|
111
115
|
```
|
|
112
116
|
|
|
113
|
-
###
|
|
117
|
+
### StaticGatewaysProvider
|
|
114
118
|
|
|
115
119
|
The static gateway provider returns a list of gateways that you provide. This is useful for testing or for users who want to use a specific gateway for all requests.
|
|
116
120
|
|
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.0.6
|
|
17
|
+
export declare const WAYFINDER_CORE_VERSION = "v1.0.6";
|
|
18
18
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,sBAAsB,WAAW,CAAC"}
|
package/dist/version.js
CHANGED
package/dist/wayfinder.d.ts
CHANGED
|
@@ -55,10 +55,10 @@ export declare const constructGatewayUrl: ({ selectedGateway, subdomain, path, }
|
|
|
55
55
|
subdomain: string;
|
|
56
56
|
path: string;
|
|
57
57
|
}) => URL;
|
|
58
|
-
export declare function tapAndVerifyReadableStream({ originalStream, contentLength,
|
|
58
|
+
export declare function tapAndVerifyReadableStream({ originalStream, contentLength, verifyData, txId, emitter, headers, strict, }: {
|
|
59
59
|
originalStream: ReadableStream;
|
|
60
60
|
contentLength: number;
|
|
61
|
-
headers
|
|
61
|
+
headers?: Record<string, string>;
|
|
62
62
|
verifyData: VerificationStrategy['verifyData'];
|
|
63
63
|
txId: string;
|
|
64
64
|
emitter?: WayfinderEmitter;
|
|
@@ -111,7 +111,7 @@ export declare class Wayfinder {
|
|
|
111
111
|
/**
|
|
112
112
|
* The verification settings to use when verifying data.
|
|
113
113
|
*/
|
|
114
|
-
readonly verificationSettings: WayfinderOptions['verificationSettings']
|
|
114
|
+
readonly verificationSettings: Required<NonNullable<WayfinderOptions['verificationSettings']>>;
|
|
115
115
|
/**
|
|
116
116
|
* Telemetry configuration used for OpenTelemetry tracing
|
|
117
117
|
*/
|
|
@@ -255,6 +255,6 @@ export declare class Wayfinder {
|
|
|
255
255
|
* The constructor for the wayfinder
|
|
256
256
|
* @param options - Wayfinder configuration options
|
|
257
257
|
*/
|
|
258
|
-
constructor({ logger, gatewaysProvider, verificationSettings, routingSettings, telemetrySettings, }
|
|
258
|
+
constructor({ logger, gatewaysProvider, verificationSettings, routingSettings, telemetrySettings, }?: WayfinderOptions);
|
|
259
259
|
}
|
|
260
260
|
//# sourceMappingURL=wayfinder.d.ts.map
|
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;AAIhD,OAAO,KAAK,EACV,gBAAgB,EAChB,MAAM,EACN,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,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,e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ain, path, }) => {
|
|
|
130
130
|
}
|
|
131
131
|
return gatewayUrl;
|
|
132
132
|
};
|
|
133
|
-
export function tapAndVerifyReadableStream({ originalStream, contentLength,
|
|
133
|
+
export function tapAndVerifyReadableStream({ originalStream, contentLength, verifyData, txId, emitter, headers = {}, strict = false, }) {
|
|
134
134
|
if (originalStream instanceof ReadableStream &&
|
|
135
135
|
typeof originalStream.tee === 'function') {
|
|
136
136
|
/**
|
|
@@ -580,7 +580,7 @@ export class Wayfinder {
|
|
|
580
580
|
* The constructor for the wayfinder
|
|
581
581
|
* @param options - Wayfinder configuration options
|
|
582
582
|
*/
|
|
583
|
-
constructor({ logger, gatewaysProvider, verificationSettings, routingSettings, telemetrySettings, }) {
|
|
583
|
+
constructor({ logger, gatewaysProvider, verificationSettings, routingSettings, telemetrySettings, } = {}) {
|
|
584
584
|
// default logger to use if no logger is provided
|
|
585
585
|
this.logger = logger ?? defaultLogger;
|
|
586
586
|
this.logger.info('Initializing Wayfinder', {
|
|
@@ -600,6 +600,8 @@ export class Wayfinder {
|
|
|
600
600
|
this.verificationSettings = {
|
|
601
601
|
enabled: verificationSettings?.enabled ??
|
|
602
602
|
verificationSettings?.strategy !== undefined,
|
|
603
|
+
events: {},
|
|
604
|
+
strict: false,
|
|
603
605
|
strategy: new HashVerificationStrategy({
|
|
604
606
|
trustedGateways: [new URL('https://permagate.io')],
|
|
605
607
|
}),
|
package/package.json
CHANGED