@ar.io/wayfinder-core 0.0.5-alpha.7 → 1.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/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +3 -2
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +18 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +17 -0
- package/dist/wayfinder.d.ts +35 -8
- package/dist/wayfinder.d.ts.map +1 -1
- package/dist/wayfinder.js +80 -9
- package/package.json +3 -2
package/dist/telemetry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAGL,IAAI,EACJ,KAAK,MAAM,EAIZ,MAAM,oBAAoB,CAAC;AAc5B,OAAO,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAGL,IAAI,EACJ,KAAK,MAAM,EAIZ,MAAM,oBAAoB,CAAC;AAc5B,OAAO,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAGpB,eAAO,MAAM,aAAa,GAAI,+CAK3B,iBAAiB,KAAG,MAAM,GAAG,SA2C/B,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,6FAO/B;IACD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;IAChE,eAAe,CAAC,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IACtD,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CAChC;;;;CA+EL,CAAC"}
|
package/dist/telemetry.js
CHANGED
|
@@ -23,6 +23,7 @@ import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
|
23
23
|
import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
|
|
24
24
|
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION, } from '@opentelemetry/semantic-conventions';
|
|
25
25
|
import 'zone.js';
|
|
26
|
+
import { WAYFINDER_CORE_VERSION } from './version.js';
|
|
26
27
|
export const initTelemetry = ({ enabled = false, sampleRate = 0.1, // 10% sample rate by default
|
|
27
28
|
exporterUrl = 'https://api.honeycomb.io/v1/traces', apiKey = 'c8gU8dHlu6V7e5k2Gn9LaG', // intentionally left here - if it gets abused we'll disable it
|
|
28
29
|
}) => {
|
|
@@ -33,7 +34,7 @@ exporterUrl = 'https://api.honeycomb.io/v1/traces', apiKey = 'c8gU8dHlu6V7e5k2Gn
|
|
|
33
34
|
url: exporterUrl,
|
|
34
35
|
headers: {
|
|
35
36
|
'x-honeycomb-team': apiKey,
|
|
36
|
-
'x-honeycomb-dataset': 'wayfinder-
|
|
37
|
+
'x-honeycomb-dataset': 'wayfinder-core',
|
|
37
38
|
},
|
|
38
39
|
});
|
|
39
40
|
const isBrowser = typeof window !== 'undefined';
|
|
@@ -41,7 +42,7 @@ exporterUrl = 'https://api.honeycomb.io/v1/traces', apiKey = 'c8gU8dHlu6V7e5k2Gn
|
|
|
41
42
|
const sampler = new TraceIdRatioBasedSampler(sampleRate);
|
|
42
43
|
const resource = resourceFromAttributes({
|
|
43
44
|
[ATTR_SERVICE_NAME]: 'wayfinder-core',
|
|
44
|
-
[ATTR_SERVICE_VERSION]:
|
|
45
|
+
[ATTR_SERVICE_VERSION]: WAYFINDER_CORE_VERSION,
|
|
45
46
|
});
|
|
46
47
|
const provider = isBrowser
|
|
47
48
|
? new WebTracerProvider({
|
package/dist/types.d.ts
CHANGED
|
@@ -73,6 +73,16 @@ export interface WayfinderEventArgs {
|
|
|
73
73
|
routing?: WayfinderRoutingEventArgs;
|
|
74
74
|
parentEmitter?: WayfinderEmitter;
|
|
75
75
|
}
|
|
76
|
+
export type WayfinderURL = `ar://${string}`;
|
|
77
|
+
export type WayfinderURLParams = {
|
|
78
|
+
originalUrl: string;
|
|
79
|
+
} | {
|
|
80
|
+
wayfinderUrl: WayfinderURL;
|
|
81
|
+
} | {
|
|
82
|
+
txId: string;
|
|
83
|
+
} | {
|
|
84
|
+
arnsName: string;
|
|
85
|
+
};
|
|
76
86
|
/**
|
|
77
87
|
* Configuration options for the Wayfinder
|
|
78
88
|
*/
|
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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,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,QAAQ,GAAG,aAAa,CAAC,CAAC;CACvE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WayFinder
|
|
3
|
+
* Copyright (C) 2022-2025 Permanent Data Solutions, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
export declare const WAYFINDER_CORE_VERSION = "v1.0.0";
|
|
18
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WayFinder
|
|
3
|
+
* Copyright (C) 2022-2025 Permanent Data Solutions, Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
export const WAYFINDER_CORE_VERSION = 'v1.0.0';
|
package/dist/wayfinder.d.ts
CHANGED
|
@@ -16,9 +16,21 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { type Tracer } from '@opentelemetry/api';
|
|
18
18
|
import { WayfinderEmitter } from './emitter.js';
|
|
19
|
-
import type { GatewaysProvider, Logger, TelemetrySettings, VerificationStrategy, WayfinderFetch, WayfinderOptions } from './types.js';
|
|
19
|
+
import type { GatewaysProvider, Logger, TelemetrySettings, VerificationStrategy, WayfinderFetch, WayfinderOptions, WayfinderURL, WayfinderURLParams } from './types.js';
|
|
20
|
+
export declare const wayfinderRequestHeaders: ({ traceId, }: {
|
|
21
|
+
traceId?: string;
|
|
22
|
+
}) => {
|
|
23
|
+
'x-ar-io-trace-id'?: string | undefined;
|
|
24
|
+
'x-ar-io-component': string;
|
|
25
|
+
};
|
|
20
26
|
export declare const arnsRegex: RegExp;
|
|
21
27
|
export declare const txIdRegex: RegExp;
|
|
28
|
+
/**
|
|
29
|
+
* Parses the original URL from the params and returns a WayfinderURL (e.g. ar://<txId>)
|
|
30
|
+
* @param params - The params to parse
|
|
31
|
+
* @returns The WayfinderURL
|
|
32
|
+
*/
|
|
33
|
+
export declare const createWayfinderUrl: (params: WayfinderURLParams) => WayfinderURL;
|
|
22
34
|
/**
|
|
23
35
|
* Extracts subdomain and path information from an ar:// URL for routing purposes
|
|
24
36
|
* @param arUrl - the ar:// URL to parse
|
|
@@ -106,9 +118,10 @@ export declare class Wayfinder {
|
|
|
106
118
|
*/
|
|
107
119
|
protected tracer?: Tracer;
|
|
108
120
|
/**
|
|
109
|
-
* A helper function that resolves
|
|
121
|
+
* A helper function that resolves a provided url to a target gateway.
|
|
110
122
|
*
|
|
111
|
-
* Note: no verification is done when
|
|
123
|
+
* Note: no verification is done when calling this function.
|
|
124
|
+
* It just generates the redirect url based on the routing strategy.
|
|
112
125
|
* In order to verify the data, you must use the `request` function or request the data and
|
|
113
126
|
* verify it yourself via the `verifyData` function.
|
|
114
127
|
*
|
|
@@ -116,14 +129,28 @@ export declare class Wayfinder {
|
|
|
116
129
|
* const { resolveUrl } = new Wayfinder();
|
|
117
130
|
*
|
|
118
131
|
* // returns the redirected URL based on the routing strategy and the original url
|
|
119
|
-
* const redirectUrl = await resolveUrl({
|
|
132
|
+
* const redirectUrl = await resolveUrl({
|
|
133
|
+
* originalUrl: 'https://arweave.net/<txId>',
|
|
134
|
+
* });
|
|
135
|
+
*
|
|
136
|
+
* // returns the redirected URL based on the routing strategy and the provided arns name
|
|
137
|
+
* const redirectUrl = await resolveUrl({
|
|
138
|
+
* arnsName: 'ardrive',
|
|
139
|
+
* });
|
|
140
|
+
*
|
|
141
|
+
* // returns the redirected URL based on the routing strategy and the provided wayfinder url
|
|
142
|
+
* const redirectUrl = await resolveUrl({
|
|
143
|
+
* wayfinderUrl: 'ar://1234567890',
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* // returns the redirected URL based on the routing strategy and the provided txId
|
|
147
|
+
* const redirectUrl = await resolveUrl({
|
|
148
|
+
* txId: '1234567890',
|
|
149
|
+
* });
|
|
120
150
|
*
|
|
121
151
|
* window.open(redirectUrl.toString(), '_blank');
|
|
122
152
|
*/
|
|
123
|
-
readonly resolveUrl: (params:
|
|
124
|
-
originalUrl: string;
|
|
125
|
-
logger?: Logger;
|
|
126
|
-
}) => Promise<URL>;
|
|
153
|
+
readonly resolveUrl: (params: WayfinderURLParams) => Promise<URL>;
|
|
127
154
|
/**
|
|
128
155
|
* A wrapped fetch function that supports ar:// protocol. If a verification strategy is provided,
|
|
129
156
|
* the request will be verified and events will be emitted as the request is processed.
|
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,EAAE,KAAK,MAAM,EAAkB,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,KAAK,EACV,gBAAgB,EAChB,MAAM,EACN,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,gBAAgB,
|
|
1
|
+
{"version":3,"file":"wayfinder.d.ts","sourceRoot":"","sources":["../src/wayfinder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,KAAK,MAAM,EAAkB,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,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,eAAO,MAAM,SAAS,QAAuB,CAAC;AAC9C,eAAO,MAAM,SAAS,QAAwB,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,kBAAkB,KACzB,YAoCF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAC7B,OAAO,MAAM,KACZ;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAqCnC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,uCAIjC;IACD,eAAe,EAAE,GAAG,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CAC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gB,CAAC,sBAAsB,CAAC,CAAC;IAE/E;;OAEG;IACH,SAAgB,iBAAiB,EAAE,iBAAiB,CAAC;IAErD;;OAEG;IACH,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,SAAgB,UAAU,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAEzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACI,OAAO,EAAE,cAAc,CAAC;IAE/B;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyDG;IACH,SAAgB,OAAO,EAAE,gBAAgB,CAAC;IAE1C;;;OAGG;gBACS,EACV,MAAsB,EACtB,gBAAgB,EAAE,mEAAmE;IACrF,oBAAoB,EACpB,eAAe,EACf,iBAAiB,GAClB,EAAE,gBAAgB;CA8EpB"}
|
package/dist/wayfinder.js
CHANGED
|
@@ -21,9 +21,58 @@ import { FastestPingRoutingStrategy } from './routing/ping.js';
|
|
|
21
21
|
import { initTelemetry, startRequestSpans } from './telemetry.js';
|
|
22
22
|
import { sandboxFromId } from './utils/base64.js';
|
|
23
23
|
import { HashVerificationStrategy } from './verification/hash-verifier.js';
|
|
24
|
+
// headers
|
|
25
|
+
export const wayfinderRequestHeaders = ({ traceId, }) => {
|
|
26
|
+
return {
|
|
27
|
+
'x-ar-io-component': 'wayfinder',
|
|
28
|
+
// TODO: add the version to the header
|
|
29
|
+
...(traceId ? { 'x-ar-io-trace-id': traceId } : {}),
|
|
30
|
+
};
|
|
31
|
+
};
|
|
24
32
|
// known regexes for wayfinder urls
|
|
25
33
|
export const arnsRegex = /^[a-z0-9_-]{1,51}$/;
|
|
26
34
|
export const txIdRegex = /^[A-Za-z0-9_-]{43}$/;
|
|
35
|
+
/**
|
|
36
|
+
* Parses the original URL from the params and returns a WayfinderURL (e.g. ar://<txId>)
|
|
37
|
+
* @param params - The params to parse
|
|
38
|
+
* @returns The WayfinderURL
|
|
39
|
+
*/
|
|
40
|
+
export const createWayfinderUrl = (params) => {
|
|
41
|
+
// only allow one of the params to be provided
|
|
42
|
+
if (Object.keys(params).length !== 1) {
|
|
43
|
+
throw new Error('Invalid URL params, only one of the following is allowed: originalUrl, wayfinderUrl, txId, arnsName');
|
|
44
|
+
}
|
|
45
|
+
let wayfinderUrl;
|
|
46
|
+
if ('originalUrl' in params) {
|
|
47
|
+
// for backwards compatibility, if the original url is already a wayfinder url, return it as-is
|
|
48
|
+
if (params.originalUrl.startsWith('ar://')) {
|
|
49
|
+
return params.originalUrl;
|
|
50
|
+
}
|
|
51
|
+
// parse out old urls to arweave.net and arweave.dev, e.g. put it into a URL and get the path
|
|
52
|
+
const url = new URL(params.originalUrl);
|
|
53
|
+
// hard coded for now, but can extend to other hosts
|
|
54
|
+
if (url.hostname.toLowerCase().includes('arweave.net') ||
|
|
55
|
+
url.hostname.toLowerCase().includes('arweave.dev')) {
|
|
56
|
+
wayfinderUrl = `ar://${url.pathname.startsWith('/') ? url.pathname.slice(1) : url.pathname}`;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
throw new Error('Invalid URL');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if ('wayfinderUrl' in params) {
|
|
63
|
+
wayfinderUrl = params.wayfinderUrl;
|
|
64
|
+
}
|
|
65
|
+
else if ('txId' in params) {
|
|
66
|
+
wayfinderUrl = `ar://${params.txId}`;
|
|
67
|
+
}
|
|
68
|
+
else if ('arnsName' in params) {
|
|
69
|
+
wayfinderUrl = `ar://${params.arnsName}`;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
throw new Error('Invalid URL params');
|
|
73
|
+
}
|
|
74
|
+
return wayfinderUrl;
|
|
75
|
+
};
|
|
27
76
|
/**
|
|
28
77
|
* Extracts subdomain and path information from an ar:// URL for routing purposes
|
|
29
78
|
* @param arUrl - the ar:// URL to parse
|
|
@@ -241,6 +290,13 @@ export const wayfinderFetch = ({ logger = defaultLogger, gatewaysProvider, verif
|
|
|
241
290
|
// enforce CORS given we're likely going to a different origin, but always allow the client to override
|
|
242
291
|
redirect: 'follow',
|
|
243
292
|
mode: 'cors',
|
|
293
|
+
headers: {
|
|
294
|
+
// add wayfinder headers, but allow the client to override
|
|
295
|
+
...wayfinderRequestHeaders({
|
|
296
|
+
traceId: requestSpan?.spanContext().traceId,
|
|
297
|
+
}),
|
|
298
|
+
...restInit.headers,
|
|
299
|
+
},
|
|
244
300
|
...restInit,
|
|
245
301
|
});
|
|
246
302
|
// add response attributes to the span
|
|
@@ -381,9 +437,10 @@ export class Wayfinder {
|
|
|
381
437
|
*/
|
|
382
438
|
tracer;
|
|
383
439
|
/**
|
|
384
|
-
* A helper function that resolves
|
|
440
|
+
* A helper function that resolves a provided url to a target gateway.
|
|
385
441
|
*
|
|
386
|
-
* Note: no verification is done when
|
|
442
|
+
* Note: no verification is done when calling this function.
|
|
443
|
+
* It just generates the redirect url based on the routing strategy.
|
|
387
444
|
* In order to verify the data, you must use the `request` function or request the data and
|
|
388
445
|
* verify it yourself via the `verifyData` function.
|
|
389
446
|
*
|
|
@@ -391,7 +448,24 @@ export class Wayfinder {
|
|
|
391
448
|
* const { resolveUrl } = new Wayfinder();
|
|
392
449
|
*
|
|
393
450
|
* // returns the redirected URL based on the routing strategy and the original url
|
|
394
|
-
* const redirectUrl = await resolveUrl({
|
|
451
|
+
* const redirectUrl = await resolveUrl({
|
|
452
|
+
* originalUrl: 'https://arweave.net/<txId>',
|
|
453
|
+
* });
|
|
454
|
+
*
|
|
455
|
+
* // returns the redirected URL based on the routing strategy and the provided arns name
|
|
456
|
+
* const redirectUrl = await resolveUrl({
|
|
457
|
+
* arnsName: 'ardrive',
|
|
458
|
+
* });
|
|
459
|
+
*
|
|
460
|
+
* // returns the redirected URL based on the routing strategy and the provided wayfinder url
|
|
461
|
+
* const redirectUrl = await resolveUrl({
|
|
462
|
+
* wayfinderUrl: 'ar://1234567890',
|
|
463
|
+
* });
|
|
464
|
+
*
|
|
465
|
+
* // returns the redirected URL based on the routing strategy and the provided txId
|
|
466
|
+
* const redirectUrl = await resolveUrl({
|
|
467
|
+
* txId: '1234567890',
|
|
468
|
+
* });
|
|
395
469
|
*
|
|
396
470
|
* window.open(redirectUrl.toString(), '_blank');
|
|
397
471
|
*/
|
|
@@ -537,13 +611,10 @@ export class Wayfinder {
|
|
|
537
611
|
verificationSettings: this.verificationSettings,
|
|
538
612
|
tracer: this.tracer,
|
|
539
613
|
});
|
|
540
|
-
this.resolveUrl = async (
|
|
614
|
+
this.resolveUrl = async (params) => {
|
|
615
|
+
const wayfinderUrl = createWayfinderUrl(params);
|
|
541
616
|
// extract routing information from the original URL
|
|
542
|
-
const { subdomain, path } = extractRoutingInfo(
|
|
543
|
-
// if not an ar:// URL, return as-is
|
|
544
|
-
if (!originalUrl.startsWith('ar://')) {
|
|
545
|
-
return new URL(originalUrl);
|
|
546
|
-
}
|
|
617
|
+
const { subdomain, path } = extractRoutingInfo(wayfinderUrl);
|
|
547
618
|
const selectedGateway = await this.routingSettings.strategy.selectGateway({
|
|
548
619
|
gateways: await this.gatewaysProvider.getGateways(),
|
|
549
620
|
path,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ar.io/wayfinder-core",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.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",
|
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
"url": "git+https://github.com/ar-io/wayfinder.git"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
|
-
"build": "npm run clean && tsc",
|
|
31
|
+
"build": "npm run clean && npm run update-version && tsc",
|
|
32
32
|
"clean": "rimraf dist",
|
|
33
|
+
"update-version": "node scripts/update-version.mjs",
|
|
33
34
|
"test": "npm run test:unit",
|
|
34
35
|
"test:unit": "c8 tsx --test 'src/**/*.test.ts'",
|
|
35
36
|
"lint:fix": "biome check --write --unsafe --config-path=../../biome.json",
|