@ar.io/wayfinder-core 0.0.5-alpha.2 → 0.0.5-alpha.4

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.
Files changed (52) hide show
  1. package/README.md +58 -2
  2. package/dist/classifiers/gql-classifier.d.ts +1 -2
  3. package/dist/classifiers/gql-classifier.d.ts.map +1 -1
  4. package/dist/classifiers/gql-classifier.js +16 -0
  5. package/dist/gateways/network.d.ts +2 -3
  6. package/dist/gateways/network.d.ts.map +1 -1
  7. package/dist/gateways/simple-cache.d.ts +1 -19
  8. package/dist/gateways/simple-cache.d.ts.map +1 -1
  9. package/dist/gateways/simple-cache.js +10 -11
  10. package/dist/gateways/static.d.ts +1 -1
  11. package/dist/gateways/static.d.ts.map +1 -1
  12. package/dist/index.d.ts +2 -0
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +3 -0
  15. package/dist/logger.d.ts +1 -10
  16. package/dist/logger.d.ts.map +1 -1
  17. package/dist/logger.js +16 -0
  18. package/dist/routing/ping.d.ts +1 -2
  19. package/dist/routing/ping.d.ts.map +1 -1
  20. package/dist/routing/preferred-with-fallback.d.ts +1 -2
  21. package/dist/routing/preferred-with-fallback.d.ts.map +1 -1
  22. package/dist/routing/preferred-with-fallback.js +16 -0
  23. package/dist/routing/random.d.ts +1 -1
  24. package/dist/routing/random.d.ts.map +1 -1
  25. package/dist/routing/round-robin.d.ts +1 -19
  26. package/dist/routing/round-robin.d.ts.map +1 -1
  27. package/dist/routing/round-robin.js +10 -11
  28. package/dist/routing/simple-cache.d.ts +37 -0
  29. package/dist/routing/simple-cache.d.ts.map +1 -0
  30. package/dist/routing/simple-cache.js +72 -0
  31. package/dist/routing/static.d.ts +1 -19
  32. package/dist/routing/static.d.ts.map +1 -1
  33. package/dist/routing/static.js +10 -11
  34. package/dist/telemetry.d.ts +33 -0
  35. package/dist/telemetry.d.ts.map +1 -0
  36. package/dist/telemetry.js +115 -0
  37. package/dist/types.d.ts +170 -0
  38. package/dist/types.d.ts.map +1 -0
  39. package/dist/types.js +17 -0
  40. package/dist/utils/hash.d.ts +1 -2
  41. package/dist/utils/hash.d.ts.map +1 -1
  42. package/dist/verification/data-root-verifier.d.ts +2 -3
  43. package/dist/verification/data-root-verifier.d.ts.map +1 -1
  44. package/dist/verification/hash-verifier.d.ts +2 -3
  45. package/dist/verification/hash-verifier.d.ts.map +1 -1
  46. package/dist/verification/signature-verifier.d.ts +4 -4
  47. package/dist/verification/signature-verifier.d.ts.map +1 -1
  48. package/dist/verification/signature-verifier.js +2 -0
  49. package/dist/wayfinder.d.ts +29 -113
  50. package/dist/wayfinder.d.ts.map +1 -1
  51. package/dist/wayfinder.js +163 -90
  52. package/package.json +6 -1
@@ -0,0 +1,33 @@
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
+ import { Span, type Tracer } from '@opentelemetry/api';
18
+ import type { GatewaysProvider, TelemetryConfig, WayfinderOptions } from './types.js';
19
+ import { WayfinderEmitter } from './wayfinder.js';
20
+ export declare const initTelemetry: (config?: TelemetryConfig) => Tracer | undefined;
21
+ export declare const startRequestSpans: ({ originalUrl, emitter, tracer, verificationSettings, routingSettings, gatewaysProvider, }?: {
22
+ originalUrl?: string;
23
+ emitter?: WayfinderEmitter;
24
+ tracer?: Tracer;
25
+ verificationSettings?: WayfinderOptions["verificationSettings"];
26
+ routingSettings?: WayfinderOptions["routingSettings"];
27
+ gatewaysProvider?: GatewaysProvider;
28
+ }) => {
29
+ parentSpan: Span | undefined;
30
+ routingSpan: Span | undefined;
31
+ verificationSpan: Span | undefined;
32
+ };
33
+ //# sourceMappingURL=telemetry.d.ts.map
@@ -0,0 +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,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,eAAO,MAAM,aAAa,GACxB,SAAQ,eAIP,KACA,MAAM,GAAG,SAmCX,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+DL,CAAC"}
@@ -0,0 +1,115 @@
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
+ import { DiagConsoleLogger, DiagLogLevel, context, diag, trace, } from '@opentelemetry/api';
18
+ import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
19
+ import { resourceFromAttributes } from '@opentelemetry/resources';
20
+ import { BatchSpanProcessor, TraceIdRatioBasedSampler, } from '@opentelemetry/sdk-trace-base';
21
+ import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
22
+ import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
23
+ import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION, } from '@opentelemetry/semantic-conventions';
24
+ export const initTelemetry = (config = {
25
+ enabled: false,
26
+ sampleRate: 0,
27
+ serviceName: 'wayfinder-core',
28
+ }) => {
29
+ if (config.enabled === false)
30
+ return undefined;
31
+ diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.ERROR);
32
+ const exporter = new OTLPTraceExporter({
33
+ url: config.exporterUrl ?? 'https://api.honeycomb.io',
34
+ headers: {
35
+ 'x-honeycomb-team': config.apiKey ?? '',
36
+ 'x-honeycomb-dataset': 'wayfinder-dev',
37
+ },
38
+ });
39
+ const isBrowser = typeof window !== 'undefined';
40
+ const spanProcessor = new BatchSpanProcessor(exporter);
41
+ const sampler = new TraceIdRatioBasedSampler(config.sampleRate ?? 1);
42
+ const resource = resourceFromAttributes({
43
+ [ATTR_SERVICE_NAME]: 'wayfinder-core',
44
+ [ATTR_SERVICE_VERSION]: 'v0.0.5-alpha.5', // hard coded for now as importing JSON breaks wayfinder-react
45
+ });
46
+ const provider = isBrowser
47
+ ? new WebTracerProvider({
48
+ sampler,
49
+ resource,
50
+ spanProcessors: [spanProcessor],
51
+ })
52
+ : new NodeTracerProvider({
53
+ sampler,
54
+ resource,
55
+ spanProcessors: [spanProcessor],
56
+ });
57
+ provider.register();
58
+ return trace.getTracer('wayfinder-core');
59
+ };
60
+ export const startRequestSpans = ({ originalUrl, emitter, tracer, verificationSettings, routingSettings, gatewaysProvider, } = {}) => {
61
+ const activeContext = context.active();
62
+ const parentSpan = tracer?.startSpan('wayfinder.request', {
63
+ attributes: {
64
+ originalUrl: originalUrl ?? 'undefined',
65
+ 'verification.enabled': verificationSettings?.enabled ?? false,
66
+ 'verification.strategy': verificationSettings?.strategy?.constructor.name ?? 'undefined',
67
+ 'verification.strict': verificationSettings?.strict ?? false,
68
+ 'verification.trustedGateways': verificationSettings?.strategy?.trustedGateways
69
+ ?.map((gateway) => gateway.toString())
70
+ .join(','),
71
+ 'routing.strategy': routingSettings?.strategy?.constructor.name ?? 'undefined',
72
+ gatewaysProvider: gatewaysProvider?.constructor.name,
73
+ },
74
+ }, activeContext);
75
+ const parentContext = parentSpan
76
+ ? trace.setSpan(context.active(), parentSpan)
77
+ : context.active();
78
+ let routingSpan;
79
+ let verificationSpan;
80
+ // add listeners on the emitter to the span
81
+ emitter?.on('routing-started', () => {
82
+ if (parentSpan && !routingSpan) {
83
+ context.with(parentContext, () => {
84
+ routingSpan = tracer?.startSpan('wayfinder.routing');
85
+ });
86
+ }
87
+ });
88
+ emitter?.on('routing-skipped', () => {
89
+ parentSpan?.setAttribute('routing.skipped', true);
90
+ routingSpan?.end();
91
+ parentSpan?.end();
92
+ });
93
+ emitter?.on('routing-succeeded', () => {
94
+ parentSpan?.setAttribute('routing.succeeded', true);
95
+ routingSpan?.end();
96
+ });
97
+ emitter?.on('verification-progress', () => {
98
+ if (parentSpan && !verificationSpan) {
99
+ context.with(parentContext, () => {
100
+ verificationSpan = tracer?.startSpan('wayfinder.verification');
101
+ });
102
+ }
103
+ });
104
+ emitter?.on('verification-succeeded', () => {
105
+ parentSpan?.setAttribute('verification.succeeded', true);
106
+ verificationSpan?.end();
107
+ parentSpan?.end();
108
+ });
109
+ emitter?.on('verification-failed', () => {
110
+ parentSpan?.setAttribute('verification.failed', true);
111
+ verificationSpan?.end();
112
+ parentSpan?.end();
113
+ });
114
+ return { parentSpan, routingSpan, verificationSpan };
115
+ };
@@ -0,0 +1,170 @@
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
+ import type { WayfinderEmitter } from './wayfinder.js';
18
+ /**
19
+ * This is an extension of the fetch function that allows for overriding the verification and routing settings for a single request.
20
+ */
21
+ export type WayfinderFetch = (input: URL | RequestInfo, init?: RequestInit & {
22
+ verificationSettings?: WayfinderOptions['verificationSettings'];
23
+ routingSettings?: WayfinderOptions['routingSettings'];
24
+ }) => Promise<Response>;
25
+ export type WayfinderEvent = {
26
+ 'routing-started': {
27
+ originalUrl: string;
28
+ };
29
+ 'routing-skipped': {
30
+ originalUrl: string;
31
+ };
32
+ 'routing-succeeded': {
33
+ originalUrl: string;
34
+ selectedGateway: string;
35
+ redirectUrl: string;
36
+ };
37
+ 'routing-failed': Error;
38
+ 'verification-succeeded': {
39
+ txId: string;
40
+ };
41
+ 'verification-failed': Error;
42
+ 'verification-skipped': {
43
+ originalUrl: string;
44
+ };
45
+ 'verification-progress': {
46
+ txId: string;
47
+ processedBytes: number;
48
+ totalBytes: number;
49
+ };
50
+ };
51
+ /**
52
+ * Simple logger interface that Wayfinder will use
53
+ * This allows users to provide their own logger implementation
54
+ */
55
+ export interface Logger {
56
+ debug: (message: string, ...args: any[]) => void;
57
+ info: (message: string, ...args: any[]) => void;
58
+ warn: (message: string, ...args: any[]) => void;
59
+ error: (message: string, ...args: any[]) => void;
60
+ }
61
+ export interface WayfinderRoutingEventArgs {
62
+ onRoutingStarted?: (payload: WayfinderEvent['routing-started']) => void;
63
+ onRoutingSkipped?: (payload: WayfinderEvent['routing-skipped']) => void;
64
+ onRoutingSucceeded?: (payload: WayfinderEvent['routing-succeeded']) => void;
65
+ }
66
+ export interface WayfinderVerificationEventArgs {
67
+ onVerificationSucceeded?: (payload: WayfinderEvent['verification-succeeded']) => void;
68
+ onVerificationFailed?: (payload: WayfinderEvent['verification-failed']) => void;
69
+ onVerificationProgress?: (payload: WayfinderEvent['verification-progress']) => void;
70
+ }
71
+ export interface WayfinderEventArgs {
72
+ verification?: WayfinderVerificationEventArgs;
73
+ routing?: WayfinderRoutingEventArgs;
74
+ parentEmitter?: WayfinderEmitter;
75
+ }
76
+ /**
77
+ * Configuration options for the Wayfinder
78
+ */
79
+ export interface WayfinderOptions {
80
+ /**
81
+ * Logger to use for logging
82
+ * @default defaultLogger (standard console logger)
83
+ */
84
+ logger?: Logger;
85
+ /**
86
+ * The gateways provider to use for routing requests.
87
+ */
88
+ gatewaysProvider: GatewaysProvider;
89
+ /**
90
+ * The verification settings to use for verifying data
91
+ */
92
+ verificationSettings?: {
93
+ /**
94
+ * Whether verification is enabled. If false, verification will be skipped for all requests. If true, strategy must be provided.
95
+ * @default true
96
+ */
97
+ enabled?: boolean;
98
+ /**
99
+ * The events to use for verification
100
+ */
101
+ events?: WayfinderVerificationEventArgs | undefined;
102
+ /**
103
+ * The verification strategy to use for verifying data
104
+ */
105
+ strategy?: VerificationStrategy;
106
+ /**
107
+ * Whether verification should be strict (blocking)
108
+ * If true, verification failures will cause requests to fail
109
+ * If false, verification will be performed asynchronously with events emitted
110
+ * @default false
111
+ */
112
+ strict?: boolean;
113
+ };
114
+ /**
115
+ * The routing settings to use for routing requests
116
+ */
117
+ routingSettings?: {
118
+ /**
119
+ * The events to use for routing requests
120
+ */
121
+ events?: WayfinderRoutingEventArgs;
122
+ /**
123
+ * The routing strategy to use for routing requests
124
+ */
125
+ strategy?: RoutingStrategy;
126
+ };
127
+ /**
128
+ * Telemetry configuration used to initialize OpenTelemetry tracing
129
+ */
130
+ telemetrySettings?: TelemetryConfig;
131
+ }
132
+ export interface TelemetryConfig {
133
+ /** Enable or disable telemetry collection */
134
+ enabled: boolean;
135
+ /** Sampling ratio between 0 and 1 */
136
+ sampleRate: number;
137
+ /** Honeycomb API key */
138
+ apiKey?: string;
139
+ /** Optional custom OTLP exporter URL */
140
+ exporterUrl?: string;
141
+ /** Service name used for traces */
142
+ serviceName: string;
143
+ }
144
+ export type DataStream = ReadableStream<Uint8Array> | AsyncIterable<Uint8Array>;
145
+ export interface GatewaysProvider {
146
+ getGateways(params?: {
147
+ path?: string;
148
+ subdomain?: string;
149
+ }): Promise<URL[]>;
150
+ }
151
+ export interface RoutingStrategy {
152
+ selectGateway(params: {
153
+ gateways: URL[];
154
+ path?: string;
155
+ subdomain?: string;
156
+ }): Promise<URL>;
157
+ }
158
+ export interface VerificationStrategy {
159
+ trustedGateways: URL[];
160
+ verifyData(params: {
161
+ data: DataStream;
162
+ txId: string;
163
+ }): Promise<void>;
164
+ }
165
+ export interface DataClassifier {
166
+ classify(params: {
167
+ txId: string;
168
+ }): Promise<'ans104' | 'transaction'>;
169
+ }
170
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIvD;;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,MA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AC,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;CACrB;AAID,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;AAEhF,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;CAC7E;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,CAAC,MAAM,EAAE;QACpB,QAAQ,EAAE,GAAG,EAAE,CAAC;QAChB,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;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE;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/types.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 {};
@@ -1,5 +1,4 @@
1
- import { DataStream } from '../../types/wayfinder.js';
2
- import { Logger } from '../logger.js';
1
+ import type { DataStream, Logger } from '../types.js';
3
2
  export declare function isAsyncIterable(obj: unknown): obj is AsyncIterable<Uint8Array>;
4
3
  export declare function readableStreamToAsyncIterable(stream: ReadableStream<Uint8Array>): AsyncIterable<Uint8Array>;
5
4
  export declare function hashDataStreamToB64Url({ stream, algorithm, logger, }: {
@@ -1 +1 @@
1
- {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/utils/hash.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAiB,MAAM,cAAc,CAAC;AAGrD,wBAAgB,eAAe,CAC7B,GAAG,EAAE,OAAO,GACX,GAAG,IAAI,aAAa,CAAC,UAAU,CAAC,CAQlC;AAED,wBAAuB,6BAA6B,CAClD,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GACjC,aAAa,CAAC,UAAU,CAAC,CAa3B;AAED,wBAAsB,sBAAsB,CAAC,EAC3C,MAAM,EACN,SAAoB,EACpB,MAAsB,GACvB,EAAE;IACD,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA2C9B"}
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/utils/hash.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGtD,wBAAgB,eAAe,CAC7B,GAAG,EAAE,OAAO,GACX,GAAG,IAAI,aAAa,CAAC,UAAU,CAAC,CAQlC;AAED,wBAAuB,6BAA6B,CAClD,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GACjC,aAAa,CAAC,UAAU,CAAC,CAa3B;AAED,wBAAsB,sBAAsB,CAAC,EAC3C,MAAM,EACN,SAAoB,EACpB,MAAsB,GACvB,EAAE;IACD,MAAM,EAAE,UAAU,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CA2C9B"}
@@ -1,10 +1,9 @@
1
- import { DataClassifier, DataStream, VerificationStrategy } from '../../types/wayfinder.js';
2
- import { Logger } from '../logger.js';
1
+ import { DataClassifier, DataStream, Logger, VerificationStrategy } from '../types.js';
3
2
  export declare const convertDataStreamToDataRoot: ({ stream, }: {
4
3
  stream: DataStream;
5
4
  }) => Promise<string>;
6
5
  export declare class DataRootVerificationStrategy implements VerificationStrategy {
7
- private readonly trustedGateways;
6
+ readonly trustedGateways: URL[];
8
7
  private readonly maxConcurrency;
9
8
  private readonly logger;
10
9
  private readonly classifier;
@@ -1 +1 @@
1
- {"version":3,"file":"data-root-verifier.d.ts","sourceRoot":"","sources":["../../src/verification/data-root-verifier.ts"],"names":[],"mappings":"AA0BA,OAAO,EACL,cAAc,EACd,UAAU,EACV,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,MAAM,EAAiB,MAAM,cAAc,CAAC;AAOrD,eAAO,MAAM,2BAA2B,GAAU,aAE/C;IACD,MAAM,EAAE,UAAU,CAAC;CACpB,KAAG,OAAO,CAAC,MAAM,CAwDjB,CAAC;AAGF,qBAAa,4BAA6B,YAAW,oBAAoB;IACvE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAQ;IACxC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiB;gBAChC,EACV,eAAe,EACf,cAAkB,EAClB,MAAsB,EACtB,UAA0C,GAC3C,EAAE;QACD,eAAe,EAAE,GAAG,EAAE,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,cAAc,CAAC;KAC7B;IAOD;;;;OAIG;IACG,WAAW,CAAC,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAuCxD,UAAU,CAAC,EACf,IAAI,EACJ,IAAI,GACL,EAAE;QACD,IAAI,EAAE,UAAU,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC,IAAI,CAAC;CA0BlB"}
1
+ {"version":3,"file":"data-root-verifier.d.ts","sourceRoot":"","sources":["../../src/verification/data-root-verifier.ts"],"names":[],"mappings":"AA4BA,OAAO,EACL,cAAc,EACd,UAAU,EACV,MAAM,EACN,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAOrB,eAAO,MAAM,2BAA2B,GAAU,aAE/C;IACD,MAAM,EAAE,UAAU,CAAC;CACpB,KAAG,OAAO,CAAC,MAAM,CAwDjB,CAAC;AAGF,qBAAa,4BAA6B,YAAW,oBAAoB;IACvE,SAAgB,eAAe,EAAE,GAAG,EAAE,CAAC;IACvC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiB;gBAChC,EACV,eAAe,EACf,cAAkB,EAClB,MAAsB,EACtB,UAA0C,GAC3C,EAAE;QACD,eAAe,EAAE,GAAG,EAAE,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,cAAc,CAAC;KAC7B;IAOD;;;;OAIG;IACG,WAAW,CAAC,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAuCxD,UAAU,CAAC,EACf,IAAI,EACJ,IAAI,GACL,EAAE;QACD,IAAI,EAAE,UAAU,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC,IAAI,CAAC;CA0BlB"}
@@ -1,7 +1,6 @@
1
- import { DataStream, VerificationStrategy } from '../../types/wayfinder.js';
2
- import { Logger } from '../logger.js';
1
+ import type { DataStream, Logger, VerificationStrategy } from '../types.js';
3
2
  export declare class HashVerificationStrategy implements VerificationStrategy {
4
- private readonly trustedGateways;
3
+ readonly trustedGateways: URL[];
5
4
  private readonly maxConcurrency;
6
5
  private readonly logger;
7
6
  constructor({ trustedGateways, maxConcurrency, logger, }: {
@@ -1 +1 @@
1
- {"version":3,"file":"hash-verifier.d.ts","sourceRoot":"","sources":["../../src/verification/hash-verifier.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAiB,MAAM,cAAc,CAAC;AAKrD,qBAAa,wBAAyB,YAAW,oBAAoB;IACnE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAQ;IACxC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBACpB,EACV,eAAe,EACf,cAAkB,EAClB,MAAsB,GACvB,EAAE;QACD,eAAe,EAAE,GAAG,EAAE,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAMD;;;;OAIG;IACG,SAAS,CAAC,EACd,IAAI,GACL,EAAE;QACD,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,QAAQ,CAAA;KAAE,CAAC;IAqE5C,UAAU,CAAC,EACf,IAAI,EACJ,IAAI,GACL,EAAE;QACD,IAAI,EAAE,UAAU,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC,IAAI,CAAC;CAgBlB"}
1
+ {"version":3,"file":"hash-verifier.d.ts","sourceRoot":"","sources":["../../src/verification/hash-verifier.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAK5E,qBAAa,wBAAyB,YAAW,oBAAoB;IACnE,SAAgB,eAAe,EAAE,GAAG,EAAE,CAAC;IACvC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBACpB,EACV,eAAe,EACf,cAAkB,EAClB,MAAsB,GACvB,EAAE;QACD,eAAe,EAAE,GAAG,EAAE,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAMD;;;;OAIG;IACG,SAAS,CAAC,EACd,IAAI,GACL,EAAE;QACD,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,QAAQ,CAAA;KAAE,CAAC;IAqE5C,UAAU,CAAC,EACf,IAAI,EACJ,IAAI,GACL,EAAE;QACD,IAAI,EAAE,UAAU,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC,IAAI,CAAC;CAgBlB"}
@@ -1,11 +1,10 @@
1
- import { DataClassifier, DataStream, VerificationStrategy } from '../../types/wayfinder.js';
2
- import { Logger } from '../logger.js';
1
+ import type { DataClassifier, DataStream, Logger, VerificationStrategy } from '../types.js';
3
2
  /**
4
3
  * Implementation of DataVerificationStrategy that verifies data item signatures
5
4
  * using trusted gateways to provide the metadata needed for verification.
6
5
  */
7
6
  export declare class Ans104SignatureVerificationStrategy implements VerificationStrategy {
8
- private readonly trustedGateways;
7
+ readonly trustedGateways: URL[];
9
8
  private readonly maxConcurrency;
10
9
  private readonly logger;
11
10
  constructor({ trustedGateways, maxConcurrency, logger, }: {
@@ -59,7 +58,7 @@ export declare class Ans104SignatureVerificationStrategy implements Verification
59
58
  * from a trusted gateway's /tx/<tx-id>/signature endpoint.
60
59
  */
61
60
  export declare class TransactionSignatureVerificationStrategy implements VerificationStrategy {
62
- private readonly trustedGateways;
61
+ readonly trustedGateways: URL[];
63
62
  private readonly logger;
64
63
  constructor({ trustedGateways, logger, }: {
65
64
  trustedGateways: URL[];
@@ -103,6 +102,7 @@ export declare class SignatureVerificationStrategy {
103
102
  private readonly ans104;
104
103
  private readonly transaction;
105
104
  private readonly classifier;
105
+ readonly trustedGateways: URL[];
106
106
  constructor({ trustedGateways, maxConcurrency, logger, classifier, }: {
107
107
  trustedGateways: URL[];
108
108
  maxConcurrency?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"signature-verifier.d.ts","sourceRoot":"","sources":["../../src/verification/signature-verifier.ts"],"names":[],"mappings":"AAyBA,OAAO,EACL,cAAc,EACd,UAAU,EACV,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,MAAM,EAAiB,MAAM,cAAc,CAAC;AASrD;;;GAGG;AACH,qBAAa,mCACX,YAAW,oBAAoB;IAE/B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAQ;IACxC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBACpB,EACV,eAAe,EACf,cAAkB,EAClB,MAAsB,GACvB,EAAE;QAAE,eAAe,EAAE,GAAG,EAAE,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA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CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QACxC,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IA2DI,UAAU,CAAC,EACf,IAAI,EACJ,IAAI,GACL,EAAE;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAkDtD;AAED,eAAO,MAAM,+BAA+B;;;CAI3C,CAAC;AAEF,qBAAa,6BAA6B;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsC;IAC7D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA2C;IACvE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiB;gBAChC,EACV,eAAe,EACf,cAAkB,EAClB,MAAsB,EACtB,UAA0C,GAC3C,EAAE;QACD,eAAe,EAAE,GAAG,EAAE,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,cAAc,CAAC;KAC7B;IAaK,UAAU,CAAC,EACf,IAAI,EACJ,IAAI,GACL,EAAE;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAatD"}
1
+ {"version":3,"file":"signature-verifier.d.ts","sourceRoot":"","sources":["../../src/verification/signature-verifier.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,MAAM,EACN,oBAAoB,EACrB,MAAM,aAAa,CAAC;AASrB;;;GAGG;AACH,qBAAa,mCACX,YAAW,oBAAoB;IAE/B,SAAgB,eAAe,EAAE,GAAG,EAAE,CAAC;IACvC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBACpB,EACV,eAAe,EACf,cAAkB,EAClB,MAAsB,GACvB,EAAE;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AC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QACxC,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IA2DI,UAAU,CAAC,EACf,IAAI,EACJ,IAAI,GACL,EAAE;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAkDtD;AAED,eAAO,MAAM,+BAA+B;;;CAI3C,CAAC;AAEF,qBAAa,6BAA6B;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsC;IAC7D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA2C;IACvE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiB;IAC5C,SAAgB,eAAe,EAAE,GAAG,EAAE,CAAC;gBAC3B,EACV,eAAe,EACf,cAAkB,EAClB,MAAsB,EACtB,UAA0C,GAC3C,EAAE;QACD,eAAe,EAAE,GAAG,EAAE,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,cAAc,CAAC;KAC7B;IAcK,UAAU,CAAC,EACf,IAAI,EACJ,IAAI,GACL,EAAE;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAatD"}
@@ -334,7 +334,9 @@ export class SignatureVerificationStrategy {
334
334
  ans104;
335
335
  transaction;
336
336
  classifier;
337
+ trustedGateways;
337
338
  constructor({ trustedGateways, maxConcurrency = 1, logger = defaultLogger, classifier = new GqlClassifier({ logger }), }) {
339
+ this.trustedGateways = trustedGateways;
338
340
  this.ans104 = new Ans104SignatureVerificationStrategy({
339
341
  trustedGateways,
340
342
  maxConcurrency,
@@ -15,8 +15,8 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  import { EventEmitter } from 'eventemitter3';
18
- import { Logger } from './logger.js';
19
- import { GatewaysProvider, RoutingStrategy, VerificationStrategy, WayfinderFetch } from '../types/wayfinder.js';
18
+ import { type Tracer } from '@opentelemetry/api';
19
+ import type { GatewaysProvider, Logger, TelemetryConfig, VerificationStrategy, WayfinderEvent, WayfinderEventArgs, WayfinderFetch, WayfinderOptions } from './types.js';
20
20
  export declare const arnsRegex: RegExp;
21
21
  export declare const txIdRegex: RegExp;
22
22
  /**
@@ -30,56 +30,8 @@ export declare const resolveWayfinderUrl: ({ originalUrl, selectedGateway, logge
30
30
  selectedGateway: URL;
31
31
  logger?: Logger;
32
32
  }) => URL;
33
- /**
34
- * Wayfinder event emitter with verification events
35
- */
36
- export type WayfinderEvent = {
37
- 'verification-succeeded': {
38
- txId: string;
39
- };
40
- 'verification-failed': Error;
41
- 'verification-skipped': {
42
- originalUrl: string;
43
- };
44
- 'verification-progress': {
45
- txId: string;
46
- processedBytes: number;
47
- totalBytes: number;
48
- };
49
- 'routing-started': {
50
- originalUrl: string;
51
- };
52
- 'routing-skipped': {
53
- originalUrl: string;
54
- };
55
- 'routing-succeeded': {
56
- originalUrl: string;
57
- selectedGateway: string;
58
- redirectUrl: string;
59
- };
60
- 'routing-failed': Error;
61
- 'identified-transaction-id': {
62
- originalUrl: string;
63
- selectedGateway: string;
64
- txId: string;
65
- };
66
- };
67
- export interface WayfinderRoutingEventArgs {
68
- onRoutingStarted?: (payload: WayfinderEvent['routing-started']) => void;
69
- onRoutingSkipped?: (payload: WayfinderEvent['routing-skipped']) => void;
70
- onRoutingSucceeded?: (payload: WayfinderEvent['routing-succeeded']) => void;
71
- }
72
- export interface WayfinderVerificationEventArgs {
73
- onVerificationSucceeded?: (payload: WayfinderEvent['verification-succeeded']) => void;
74
- onVerificationFailed?: (payload: WayfinderEvent['verification-failed']) => void;
75
- onVerificationProgress?: (payload: WayfinderEvent['verification-progress']) => void;
76
- }
77
- export interface WayfinderEventArgs {
78
- verification?: WayfinderVerificationEventArgs;
79
- routing?: WayfinderRoutingEventArgs;
80
- }
81
33
  export declare class WayfinderEmitter extends EventEmitter<WayfinderEvent> {
82
- constructor({ verification, routing }?: WayfinderEventArgs);
34
+ constructor({ verification, routing, parentEmitter, }?: WayfinderEventArgs);
83
35
  }
84
36
  export declare function tapAndVerifyReadableStream({ originalStream, contentLength, verifyData, txId, emitter, strict, }: {
85
37
  originalStream: ReadableStream;
@@ -100,65 +52,17 @@ export declare function tapAndVerifyReadableStream({ originalStream, contentLeng
100
52
  * @param resolveUrl - the function to construct the redirect url for ar:// requests
101
53
  * @returns a wrapped fetch function that supports ar:// protocol and always returns Response
102
54
  */
103
- export declare const wayfinderFetch: ({ emitter, logger, gatewaysProvider, verificationSettings, routingSettings, }: {
55
+ export declare const wayfinderFetch: ({ logger, gatewaysProvider, verificationSettings, routingSettings, emitter, tracer, }: {
104
56
  logger?: Logger;
105
- emitter?: WayfinderEmitter;
106
57
  gatewaysProvider: GatewaysProvider;
107
58
  verificationSettings: NonNullable<WayfinderOptions["verificationSettings"]>;
108
59
  routingSettings: NonNullable<WayfinderOptions["routingSettings"]>;
109
- }) => (input: URL | RequestInfo, init?: RequestInit) => Promise<Response>;
110
- /**
111
- * Configuration options for the Wayfinder
112
- */
113
- export interface WayfinderOptions {
114
- /**
115
- * Logger to use for logging
116
- * @default defaultLogger (standard console logger)
117
- */
118
- logger?: Logger;
119
- /**
120
- * The gateways provider to use for routing requests.
121
- */
122
- gatewaysProvider: GatewaysProvider;
123
- /**
124
- * The verification settings to use for verifying data
125
- */
126
- verificationSettings?: {
127
- /**
128
- * Whether verification is enabled. If false, verification will be skipped for all requests. If true, strategy must be provided.
129
- * @default true
130
- */
131
- enabled?: boolean;
132
- /**
133
- * The events to use for verification
134
- */
135
- events?: WayfinderVerificationEventArgs | undefined;
136
- /**
137
- * The verification strategy to use for verifying data
138
- */
139
- strategy: VerificationStrategy;
140
- /**
141
- * Whether verification should be strict (blocking)
142
- * If true, verification failures will cause requests to fail
143
- * If false, verification will be performed asynchronously with events emitted
144
- * @default false
145
- */
146
- strict?: boolean;
147
- };
148
- /**
149
- * The routing settings to use for routing requests
150
- */
151
- routingSettings?: {
152
- /**
153
- * The events to use for routing requests
154
- */
155
- events?: WayfinderRoutingEventArgs;
156
- /**
157
- * The routing strategy to use for routing requests
158
- */
159
- strategy: RoutingStrategy;
160
- };
161
- }
60
+ emitter?: WayfinderEmitter;
61
+ tracer?: Tracer;
62
+ }) => (input: URL | RequestInfo, init?: RequestInit & {
63
+ verificationSettings?: NonNullable<WayfinderOptions["verificationSettings"]>;
64
+ routingSettings?: NonNullable<WayfinderOptions["routingSettings"]>;
65
+ }) => Promise<Response>;
162
66
  /**
163
67
  * The main class for the wayfinder
164
68
  */
@@ -180,11 +84,19 @@ export declare class Wayfinder {
180
84
  * This includes the routing strategy and event handlers for routing events.
181
85
  * If not provided, the default FastestPingRoutingStrategy will be used.
182
86
  */
183
- readonly routingSettings: NonNullable<WayfinderOptions['routingSettings']>;
87
+ readonly routingSettings: Required<NonNullable<WayfinderOptions['routingSettings']>>;
184
88
  /**
185
89
  * The verification settings to use when verifying data.
186
90
  */
187
91
  readonly verificationSettings: WayfinderOptions['verificationSettings'];
92
+ /**
93
+ * Telemetry configuration used for OpenTelemetry tracing
94
+ */
95
+ readonly telemetrySettings: TelemetryConfig;
96
+ /**
97
+ * OpenTelemetry tracer instance
98
+ */
99
+ protected tracer?: Tracer;
188
100
  /**
189
101
  * A helper function that resolves the redirect url for ar:// requests to a target gateway.
190
102
  *
@@ -239,7 +151,13 @@ export declare class Wayfinder {
239
151
  */
240
152
  protected logger: Logger;
241
153
  /**
242
- * The event emitter for wayfinder that emits routing and verification events.
154
+ * The event emitter for wayfinder that emits routing and verification events for all requests.
155
+ *
156
+ * This is useful for tracking all requests and their statuses, and is updated for each request.
157
+ *
158
+ * If you prefer request-specific events, you can pass in the events to the `request` function.
159
+ *
160
+ * @example
243
161
  *
244
162
  * const wayfinder = new Wayfinder()
245
163
  *
@@ -266,10 +184,8 @@ export declare class Wayfinder {
266
184
  * console.log('Verification passed!', event);
267
185
  * },
268
186
  * onVerificationFailed: (event) => {
269
- * console.log('Verification failed!', event);
270
- * },
271
- * onVerificationProgress: (event) => {
272
- * console.log('Verification progress!', event);
187
+ * console.log('Verification failed!', event);
188
+ * },
273
189
  * },
274
190
  * }
275
191
  * routingSettings: {
@@ -298,6 +214,6 @@ export declare class Wayfinder {
298
214
  * @param options - Wayfinder configuration options
299
215
  */
300
216
  constructor({ logger, gatewaysProvider, // forcing it to be required to avoid making ar-io-sdk a dependency
301
- verificationSettings, routingSettings, }: WayfinderOptions);
217
+ verificationSettings, routingSettings, telemetrySettings, }: WayfinderOptions);
302
218
  }
303
219
  //# sourceMappingURL=wayfinder.d.ts.map