@ar.io/wayfinder-core 1.9.0 → 1.9.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/LICENSE +1 -1
- package/README.md +8 -8
- package/dist/client.js +3 -3
- package/dist/fetch/wayfinder-fetch.d.ts.map +1 -1
- package/dist/fetch/wayfinder-fetch.js +20 -6
- package/dist/routing/round-robin.js +2 -2
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/ario.d.ts +5 -0
- package/dist/utils/ario.d.ts.map +1 -1
- package/dist/utils/ario.js +10 -0
- package/dist/utils/verification-url.d.ts +3 -1
- package/dist/utils/verification-url.d.ts.map +1 -1
- package/dist/utils/verification-url.js +6 -1
- package/dist/utils/verify-stream.d.ts +3 -1
- package/dist/utils/verify-stream.d.ts.map +1 -1
- package/dist/utils/verify-stream.js +3 -1
- package/dist/verification/data-root-verification.d.ts +3 -1
- package/dist/verification/data-root-verification.d.ts.map +1 -1
- package/dist/verification/data-root-verification.js +5 -1
- package/dist/verification/hash-verification.d.ts +6 -2
- package/dist/verification/hash-verification.d.ts.map +1 -1
- package/dist/verification/hash-verification.js +56 -12
- package/dist/verification/remote-verification.d.ts +1 -16
- package/dist/verification/remote-verification.d.ts.map +1 -1
- package/dist/verification/remote-verification.js +23 -6
- package/dist/verification/signature-verification.d.ts +11 -3
- package/dist/verification/signature-verification.d.ts.map +1 -1
- package/dist/verification/signature-verification.js +10 -5
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/wayfinder.d.ts +3 -3
- package/dist/wayfinder.d.ts.map +1 -1
- package/dist/wayfinder.js +7 -6
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -186,7 +186,7 @@ APPENDIX: How to apply the Apache License to your work.
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright
|
|
189
|
+
Copyright 2025 Permanent Data Solutions, Inc.
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
|
|
62
62
|
const wayfinder = createWayfinderClient({
|
|
63
63
|
verificationStrategy: new HashVerificationStrategy({
|
|
64
|
-
trustedGateways: [new URL('https://
|
|
64
|
+
trustedGateways: [new URL('https://turbo-gateway.com')],
|
|
65
65
|
}),
|
|
66
66
|
strict: true, // Fail requests on verification errors
|
|
67
67
|
});
|
|
@@ -96,7 +96,7 @@ import { createVerificationStrategy } from '@ar.io/wayfinder-core';
|
|
|
96
96
|
// Create a hash verification strategy
|
|
97
97
|
const hashStrategy = createVerificationStrategy({
|
|
98
98
|
strategy: 'hash',
|
|
99
|
-
trustedGateways: [new URL('https://
|
|
99
|
+
trustedGateways: [new URL('https://turbo-gateway.com')],
|
|
100
100
|
logger: myLogger,
|
|
101
101
|
});
|
|
102
102
|
|
|
@@ -199,7 +199,7 @@ Fetches a dynamic list of trusted peer gateways from an AR.IO gateway's `/ar-io/
|
|
|
199
199
|
import { TrustedPeersGatewaysProvider } from '@ar.io/wayfinder-core';
|
|
200
200
|
|
|
201
201
|
const gatewayProvider = new TrustedPeersGatewaysProvider({
|
|
202
|
-
trustedGateway: 'https://
|
|
202
|
+
trustedGateway: 'https://turbo-gateway.com',
|
|
203
203
|
});
|
|
204
204
|
```
|
|
205
205
|
|
|
@@ -234,11 +234,11 @@ const gatewayProvider = new CompositeGatewaysProvider({
|
|
|
234
234
|
}),
|
|
235
235
|
// Fallback to trusted peers if network fetch fails
|
|
236
236
|
new TrustedPeersGatewaysProvider({
|
|
237
|
-
trustedGateway: 'https://
|
|
237
|
+
trustedGateway: 'https://turbo-gateway.com',
|
|
238
238
|
}),
|
|
239
239
|
// Final fallback to static list
|
|
240
240
|
new StaticGatewaysProvider({
|
|
241
|
-
gateways: ['https://
|
|
241
|
+
gateways: ['https://turbo-gateway.com', 'https://g8way.io'],
|
|
242
242
|
}),
|
|
243
243
|
],
|
|
244
244
|
});
|
|
@@ -543,7 +543,7 @@ const wayfinder = new Wayfinder({
|
|
|
543
543
|
verificationSettings: {
|
|
544
544
|
enabled: true,
|
|
545
545
|
strategy: new HashVerificationStrategy({
|
|
546
|
-
trustedGateways: [new URL('https://
|
|
546
|
+
trustedGateways: [new URL('https://turbo-gateway.com')],
|
|
547
547
|
}),
|
|
548
548
|
},
|
|
549
549
|
});
|
|
@@ -560,7 +560,7 @@ const wayfinder = new Wayfinder({
|
|
|
560
560
|
verificationSettings: {
|
|
561
561
|
enabled: true,
|
|
562
562
|
strategy: new DataRootVerificationStrategy({
|
|
563
|
-
trustedGateways: [new URL('https://
|
|
563
|
+
trustedGateways: [new URL('https://turbo-gateway.com')],
|
|
564
564
|
}),
|
|
565
565
|
},
|
|
566
566
|
});
|
|
@@ -577,7 +577,7 @@ const wayfinder = new Wayfinder({
|
|
|
577
577
|
verificationSettings: {
|
|
578
578
|
enabled: true,
|
|
579
579
|
strategy: new SignatureVerificationStrategy({
|
|
580
|
-
trustedGateways: [new URL('https://
|
|
580
|
+
trustedGateways: [new URL('https://turbo-gateway.com')],
|
|
581
581
|
}),
|
|
582
582
|
},
|
|
583
583
|
});
|
package/dist/client.js
CHANGED
|
@@ -28,7 +28,7 @@ import { DataRootVerificationStrategy } from './verification/data-root-verificat
|
|
|
28
28
|
import { HashVerificationStrategy } from './verification/hash-verification.js';
|
|
29
29
|
import { RemoteVerificationStrategy } from './verification/remote-verification.js';
|
|
30
30
|
import { Wayfinder } from './wayfinder.js';
|
|
31
|
-
const DEFAULT_TRUSTED_GATEWAY = 'https://
|
|
31
|
+
const DEFAULT_TRUSTED_GATEWAY = 'https://turbo-gateway.com';
|
|
32
32
|
/**
|
|
33
33
|
* Helper function to construct a routing strategy
|
|
34
34
|
*/
|
|
@@ -43,7 +43,7 @@ export const createRoutingStrategy = ({ strategy, gatewaysProvider, logger, }) =
|
|
|
43
43
|
return new RoundRobinRoutingStrategy(baseConfig);
|
|
44
44
|
case 'preferred':
|
|
45
45
|
return new PreferredWithFallbackRoutingStrategy({
|
|
46
|
-
preferredGateway: 'https://
|
|
46
|
+
preferredGateway: 'https://turbo-gateway.com',
|
|
47
47
|
fallbackStrategy: createRoutingStrategy({
|
|
48
48
|
strategy: 'fastest',
|
|
49
49
|
gatewaysProvider,
|
|
@@ -55,7 +55,7 @@ export const createRoutingStrategy = ({ strategy, gatewaysProvider, logger, }) =
|
|
|
55
55
|
/**
|
|
56
56
|
* Helper function to construct a verification strategy
|
|
57
57
|
*/
|
|
58
|
-
export const createVerificationStrategy = ({ strategy, logger, trustedGateways = [new URL('https://
|
|
58
|
+
export const createVerificationStrategy = ({ strategy, logger, trustedGateways = [new URL('https://turbo-gateway.com')], }) => {
|
|
59
59
|
const verificationMap = {
|
|
60
60
|
hash: new HashVerificationStrategy({ logger, trustedGateways }),
|
|
61
61
|
'data-root': new DataRootVerificationStrategy({ logger, trustedGateways }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wayfinder-fetch.d.ts","sourceRoot":"","sources":["../../src/fetch/wayfinder-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"wayfinder-fetch.d.ts","sourceRoot":"","sources":["../../src/fetch/wayfinder-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAS/E;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAAI,mHAYlC,qBAAqB,KAAG,CAAC,CAC1B,KAAK,EAAE,GAAG,GAAG,WAAW,EACxB,IAAI,CAAC,EAAE,oBAAoB,KACxB,OAAO,CAAC,QAAQ,CAAC,CA4MrB,CAAC"}
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { context, trace } from '@opentelemetry/api';
|
|
18
|
-
import { arioHeaderNames } from '../constants.js';
|
|
19
18
|
import { WayfinderEmitter } from '../emitter.js';
|
|
20
19
|
import { defaultLogger } from '../logger.js';
|
|
21
20
|
import { ContiguousDataRetrievalStrategy } from '../retrieval/contiguous.js';
|
|
@@ -143,8 +142,6 @@ export const createWayfinderFetch = ({ logger = defaultLogger, strict = false, f
|
|
|
143
142
|
logger.debug('Successfully fetched data', {
|
|
144
143
|
uri: requestUri,
|
|
145
144
|
});
|
|
146
|
-
// Extract data ID from headers for verification
|
|
147
|
-
const resolvedDataId = dataResponse.headers.get(arioHeaderNames.dataId.toLowerCase()) || txId;
|
|
148
145
|
const contentLength = dataResponse.headers.has('content-length')
|
|
149
146
|
? parseInt(dataResponse.headers.get('content-length'), 10)
|
|
150
147
|
: 0;
|
|
@@ -153,20 +150,37 @@ export const createWayfinderFetch = ({ logger = defaultLogger, strict = false, f
|
|
|
153
150
|
: verificationStrategy;
|
|
154
151
|
let finalStream = dataResponse.body;
|
|
155
152
|
// Apply verification if strategy is provided
|
|
156
|
-
if (
|
|
153
|
+
if ((txId || arnsName) &&
|
|
154
|
+
dataResponse.body &&
|
|
155
|
+
finalVerificationStrategy) {
|
|
156
|
+
// Extract verification ID from response headers
|
|
157
|
+
// For ArNS requests, the gateway returns the resolved txId in headers
|
|
158
|
+
const headerDataId = dataResponse.headers.get('x-ar-io-data-id');
|
|
159
|
+
const headerResolvedId = dataResponse.headers.get('x-arns-resolved-id');
|
|
160
|
+
const verificationTxId = headerDataId || headerResolvedId || txId || '';
|
|
157
161
|
logger.debug('Applying verification to data stream', {
|
|
158
|
-
|
|
162
|
+
txId,
|
|
163
|
+
arnsName,
|
|
164
|
+
headerDataId,
|
|
165
|
+
headerResolvedId,
|
|
166
|
+
verificationTxId,
|
|
159
167
|
});
|
|
160
168
|
// Determine strict mode - check init first, then fall back to instance settings
|
|
161
169
|
const isStrictMode = init?.verificationSettings?.strict ?? strict;
|
|
170
|
+
// Determine raw mode - check init first, then auto-detect from path
|
|
171
|
+
// Raw mode is needed when explicitly fetching via /raw/ endpoint
|
|
172
|
+
// Only auto-detect for non-ArNS requests since /raw/ on ArNS is just a manifest path
|
|
173
|
+
const isRawMode = init?.verificationSettings?.raw ??
|
|
174
|
+
(!arnsName && path.startsWith('/raw/'));
|
|
162
175
|
finalStream = tapAndVerifyReadableStream({
|
|
163
176
|
originalStream: dataResponse.body,
|
|
164
177
|
contentLength: contentLength,
|
|
165
178
|
verifyData: finalVerificationStrategy.verifyData.bind(finalVerificationStrategy),
|
|
166
|
-
txId:
|
|
179
|
+
txId: verificationTxId,
|
|
167
180
|
headers: Object.fromEntries(dataResponse.headers),
|
|
168
181
|
emitter: requestEmitter,
|
|
169
182
|
strict: isStrictMode,
|
|
183
|
+
raw: isRawMode,
|
|
170
184
|
});
|
|
171
185
|
}
|
|
172
186
|
return new Response(finalStream, {
|
|
@@ -27,8 +27,8 @@ export class RoundRobinRoutingStrategy {
|
|
|
27
27
|
}
|
|
28
28
|
if (!gateways && !gatewaysProvider) {
|
|
29
29
|
gateways = [
|
|
30
|
-
new URL('https://
|
|
31
|
-
new URL('https://
|
|
30
|
+
new URL('https://turbo-gateway.com'),
|
|
31
|
+
new URL('https://g8way.io'),
|
|
32
32
|
];
|
|
33
33
|
}
|
|
34
34
|
this.gateways = gateways || [];
|
package/dist/types.d.ts
CHANGED
|
@@ -146,6 +146,13 @@ export interface WayfinderOptions {
|
|
|
146
146
|
* @default false
|
|
147
147
|
*/
|
|
148
148
|
strict?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* When true, fetch expected hash from /raw/{txId} endpoint instead of /{txId}.
|
|
151
|
+
* This is needed for verifying raw manifest data which has a different hash
|
|
152
|
+
* than the resolved index content.
|
|
153
|
+
* @default false (auto-detected based on request path)
|
|
154
|
+
*/
|
|
155
|
+
raw?: boolean;
|
|
149
156
|
};
|
|
150
157
|
/**
|
|
151
158
|
* The routing settings to use for routing requests
|
|
@@ -251,6 +258,12 @@ export interface VerificationStrategy {
|
|
|
251
258
|
data: DataStream;
|
|
252
259
|
headers: Record<string, string>;
|
|
253
260
|
txId: string;
|
|
261
|
+
/**
|
|
262
|
+
* When true, fetch expected hash from /raw/{txId} endpoint instead of /{txId}.
|
|
263
|
+
* This is needed for verifying raw manifest data which has a different hash
|
|
264
|
+
* than the resolved index content.
|
|
265
|
+
*/
|
|
266
|
+
raw?: boolean;
|
|
254
267
|
}): Promise<void>;
|
|
255
268
|
}
|
|
256
269
|
export interface DataClassifier {
|
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,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIrD;;GAEG;AACH;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG;IAC/C,oBAAoB,CAAC,EAAE,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;IAChE,eAAe,CAAC,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;CACvD,CAAC;AAEF;;;GAGG;AACH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAC3B,KAAK,EAAE,GAAG,GAAG,WAAW,EACxB,IAAI,CAAC,EAAE,oBAAoB,KACxB,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;Q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GACR,EAAE;QACD,OAAO,EAAE,GAAG,CAAC;QACb,UAAU,EAAE,GAAG,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CACvB"}
|
package/dist/utils/ario.d.ts
CHANGED
|
@@ -24,4 +24,9 @@ export declare const arioGatewayHeaders: {
|
|
|
24
24
|
dataItemSize: string;
|
|
25
25
|
rootTransactionId: string;
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Normalizes HTTP headers to lowercase keys with trimmed values.
|
|
29
|
+
* This ensures consistent header access regardless of original casing.
|
|
30
|
+
*/
|
|
31
|
+
export declare function normalizeHeaders(headers: Record<string, string>): Record<string, string>;
|
|
27
32
|
//# sourceMappingURL=ario.d.ts.map
|
package/dist/utils/ario.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ario.d.ts","sourceRoot":"","sources":["../../src/utils/ario.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;CAS9B,CAAC"}
|
|
1
|
+
{"version":3,"file":"ario.d.ts","sourceRoot":"","sources":["../../src/utils/ario.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;CAS9B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOxB"}
|
package/dist/utils/ario.js
CHANGED
|
@@ -24,3 +24,13 @@ export const arioGatewayHeaders = {
|
|
|
24
24
|
dataItemSize: 'x-ar-io-data-item-size',
|
|
25
25
|
rootTransactionId: 'x-ar-io-root-transaction-id',
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Normalizes HTTP headers to lowercase keys with trimmed values.
|
|
29
|
+
* This ensures consistent header access regardless of original casing.
|
|
30
|
+
*/
|
|
31
|
+
export function normalizeHeaders(headers) {
|
|
32
|
+
return Object.fromEntries(Object.entries(headers).map(([key, value]) => [
|
|
33
|
+
key.toLowerCase().trim(),
|
|
34
|
+
value.trim(),
|
|
35
|
+
]));
|
|
36
|
+
}
|
|
@@ -19,12 +19,14 @@
|
|
|
19
19
|
* @param gateway - The gateway URL to use for verification
|
|
20
20
|
* @param txId - The transaction ID
|
|
21
21
|
* @param path - Optional path to append (e.g., '/data_root', '/tx/', etc.)
|
|
22
|
+
* @param raw - When true, constructs a /raw/{txId} URL without sandbox routing
|
|
22
23
|
* @returns The constructed verification URL
|
|
23
24
|
*/
|
|
24
|
-
export declare function constructVerificationUrl({ gateway, txId, path, }: {
|
|
25
|
+
export declare function constructVerificationUrl({ gateway, txId, path, raw, }: {
|
|
25
26
|
gateway: URL;
|
|
26
27
|
txId: string;
|
|
27
28
|
path?: string;
|
|
29
|
+
raw?: boolean;
|
|
28
30
|
}): string;
|
|
29
31
|
/**
|
|
30
32
|
* Constructs a verification URL for a gateway endpoint without sandbox routing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification-url.d.ts","sourceRoot":"","sources":["../../src/utils/verification-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH
|
|
1
|
+
{"version":3,"file":"verification-url.d.ts","sourceRoot":"","sources":["../../src/utils/verification-url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,OAAO,EACP,IAAI,EACJ,IAAS,EACT,GAAW,GACZ,EAAE;IACD,OAAO,EAAE,GAAG,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,GAAG,MAAM,CAgBT;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,IAAI,GACL,EAAE;IACD,OAAO,EAAE,GAAG,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,MAAM,CAET"}
|
|
@@ -20,10 +20,15 @@ import { sandboxFromId } from './base64.js';
|
|
|
20
20
|
* @param gateway - The gateway URL to use for verification
|
|
21
21
|
* @param txId - The transaction ID
|
|
22
22
|
* @param path - Optional path to append (e.g., '/data_root', '/tx/', etc.)
|
|
23
|
+
* @param raw - When true, constructs a /raw/{txId} URL without sandbox routing
|
|
23
24
|
* @returns The constructed verification URL
|
|
24
25
|
*/
|
|
25
|
-
export function constructVerificationUrl({ gateway, txId, path = '', }) {
|
|
26
|
+
export function constructVerificationUrl({ gateway, txId, path = '', raw = false, }) {
|
|
26
27
|
const port = gateway.port ? `:${gateway.port}` : '';
|
|
28
|
+
// For raw requests, don't use sandbox routing - just use /raw/{txId}
|
|
29
|
+
if (raw) {
|
|
30
|
+
return `${gateway.protocol}//${gateway.hostname}${port}/raw/${txId}`;
|
|
31
|
+
}
|
|
27
32
|
// For localhost, use port-based routing instead of subdomain routing
|
|
28
33
|
if (gateway.hostname === 'localhost' || gateway.hostname === '127.0.0.1') {
|
|
29
34
|
return `${gateway.protocol}//${gateway.hostname}${port}${path}/${txId}`;
|
|
@@ -26,9 +26,10 @@ import { VerificationStrategy } from '../types.js';
|
|
|
26
26
|
* @param emitter Optional WayfinderEmitter to emit verification events.
|
|
27
27
|
* @param headers Optional headers to pass to the verification function.
|
|
28
28
|
* @param strict If true, the client stream will error if verification fails; otherwise, verification runs asynchronously.
|
|
29
|
+
* @param raw If true, indicates the data is raw manifest data and verification should use /raw/ endpoints.
|
|
29
30
|
* @returns A ReadableStream that passes through data to the client while verifying in parallel.
|
|
30
31
|
*/
|
|
31
|
-
export declare const tapAndVerifyReadableStream: ({ originalStream, contentLength, verifyData, txId, emitter, headers, strict, }: {
|
|
32
|
+
export declare const tapAndVerifyReadableStream: ({ originalStream, contentLength, verifyData, txId, emitter, headers, strict, raw, }: {
|
|
32
33
|
originalStream: ReadableStream;
|
|
33
34
|
contentLength: number;
|
|
34
35
|
headers?: Record<string, string>;
|
|
@@ -36,5 +37,6 @@ export declare const tapAndVerifyReadableStream: ({ originalStream, contentLengt
|
|
|
36
37
|
txId: string;
|
|
37
38
|
emitter?: WayfinderEmitter;
|
|
38
39
|
strict?: boolean;
|
|
40
|
+
raw?: boolean;
|
|
39
41
|
}) => ReadableStream;
|
|
40
42
|
//# sourceMappingURL=verify-stream.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-stream.d.ts","sourceRoot":"","sources":["../../src/utils/verify-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD
|
|
1
|
+
{"version":3,"file":"verify-stream.d.ts","sourceRoot":"","sources":["../../src/utils/verify-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,0BAA0B,GAAI,qFASxC;IACD,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,UAAU,EAAE,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,KAAG,cAmFH,CAAC"}
|
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
* @param emitter Optional WayfinderEmitter to emit verification events.
|
|
25
25
|
* @param headers Optional headers to pass to the verification function.
|
|
26
26
|
* @param strict If true, the client stream will error if verification fails; otherwise, verification runs asynchronously.
|
|
27
|
+
* @param raw If true, indicates the data is raw manifest data and verification should use /raw/ endpoints.
|
|
27
28
|
* @returns A ReadableStream that passes through data to the client while verifying in parallel.
|
|
28
29
|
*/
|
|
29
|
-
export const tapAndVerifyReadableStream = ({ originalStream, contentLength, verifyData, txId, emitter, headers = {}, strict = false, }) => {
|
|
30
|
+
export const tapAndVerifyReadableStream = ({ originalStream, contentLength, verifyData, txId, emitter, headers = {}, strict = false, raw = false, }) => {
|
|
30
31
|
if (originalStream instanceof ReadableStream &&
|
|
31
32
|
typeof originalStream.tee === 'function') {
|
|
32
33
|
/**
|
|
@@ -42,6 +43,7 @@ export const tapAndVerifyReadableStream = ({ originalStream, contentLength, veri
|
|
|
42
43
|
data: verifyBranch,
|
|
43
44
|
txId,
|
|
44
45
|
headers,
|
|
46
|
+
raw,
|
|
45
47
|
});
|
|
46
48
|
let bytesProcessed = 0;
|
|
47
49
|
const reader = clientBranch.getReader();
|
|
@@ -21,9 +21,11 @@ export declare class DataRootVerificationStrategy implements VerificationStrateg
|
|
|
21
21
|
getDataRoot({ txId }: {
|
|
22
22
|
txId: string;
|
|
23
23
|
}): Promise<string>;
|
|
24
|
-
verifyData({ data, txId, }: {
|
|
24
|
+
verifyData({ data, txId, headers: _headers, raw: _raw, }: {
|
|
25
25
|
data: DataStream;
|
|
26
26
|
txId: string;
|
|
27
|
+
headers?: Record<string, string>;
|
|
28
|
+
raw?: boolean;
|
|
27
29
|
}): Promise<void>;
|
|
28
30
|
}
|
|
29
31
|
//# sourceMappingURL=data-root-verification.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-root-verification.d.ts","sourceRoot":"","sources":["../../src/verification/data-root-verification.ts"],"names":[],"mappings":"AA4BA,OAAO,EACL,cAAc,EACd,UAAU,EACV,MAAM,EACN,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAQrB,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,
|
|
1
|
+
{"version":3,"file":"data-root-verification.d.ts","sourceRoot":"","sources":["../../src/verification/data-root-verification.ts"],"names":[],"mappings":"AA4BA,OAAO,EACL,cAAc,EACd,UAAU,EACV,MAAM,EACN,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAQrB,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,EACJ,OAAO,EAAE,QAAa,EACtB,GAAG,EAAE,IAAY,GAClB,EAAE;QACD,IAAI,EAAE,UAAU,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,GAAG,CAAC,EAAE,OAAO,CAAC;KACf,GAAG,OAAO,CAAC,IAAI,CAAC;CA+BlB"}
|
|
@@ -115,7 +115,11 @@ export class DataRootVerificationStrategy {
|
|
|
115
115
|
});
|
|
116
116
|
return dataRoot;
|
|
117
117
|
}
|
|
118
|
-
async verifyData({ data, txId, }) {
|
|
118
|
+
async verifyData({ data, txId, headers: _headers = {}, raw: _raw = false, }) {
|
|
119
|
+
// Note: The raw parameter is not applicable for data root verification
|
|
120
|
+
// as this strategy is specifically for L1 transactions which don't have
|
|
121
|
+
// the manifest/raw distinction. The parameter is accepted for interface
|
|
122
|
+
// compatibility but ignored.
|
|
119
123
|
// classify the data, if ans104 throw an error
|
|
120
124
|
const dataType = await this.classifier.classify({ txId });
|
|
121
125
|
if (dataType === 'ans104') {
|
|
@@ -11,17 +11,21 @@ export declare class HashVerificationStrategy implements VerificationStrategy {
|
|
|
11
11
|
/**
|
|
12
12
|
* Gets the digest for a given txId from all trusted gateways and ensures they all match.
|
|
13
13
|
* @param txId - The txId to get the digest for.
|
|
14
|
+
* @param raw - When true, fetch from /raw/{txId} endpoint instead of /{txId}.
|
|
14
15
|
* @returns The digest for the given txId.
|
|
15
16
|
*/
|
|
16
|
-
getDigest({ txId, }: {
|
|
17
|
+
getDigest({ txId, raw, }: {
|
|
17
18
|
txId: string;
|
|
19
|
+
raw?: boolean;
|
|
18
20
|
}): Promise<{
|
|
19
21
|
hash: string;
|
|
20
22
|
algorithm: 'sha256';
|
|
21
23
|
}>;
|
|
22
|
-
verifyData({ data, txId, }: {
|
|
24
|
+
verifyData({ data, txId, headers, raw, }: {
|
|
23
25
|
data: DataStream;
|
|
24
26
|
txId: string;
|
|
27
|
+
headers?: Record<string, string>;
|
|
28
|
+
raw?: boolean;
|
|
25
29
|
}): Promise<void>;
|
|
26
30
|
}
|
|
27
31
|
//# sourceMappingURL=hash-verification.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash-verification.d.ts","sourceRoot":"","sources":["../../src/verification/hash-verification.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hash-verification.d.ts","sourceRoot":"","sources":["../../src/verification/hash-verification.ts"],"names":[],"mappings":"AAmBA,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;;;;;OAKG;IACG,SAAS,CAAC,EACd,IAAI,EACJ,GAAW,GACZ,EAAE;QACD,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,OAAO,CAAC;KACf,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,QAAQ,CAAA;KAAE,CAAC;IA2E5C,UAAU,CAAC,EACf,IAAI,EACJ,IAAI,EACJ,OAAY,EACZ,GAAW,GACZ,EAAE;QACD,IAAI,EAAE,UAAU,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,GAAG,CAAC,EAAE,OAAO,CAAC;KACf,GAAG,OAAO,CAAC,IAAI,CAAC;CA6DlB"}
|
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { pLimit } from 'plimit-lit';
|
|
18
|
+
import { arioHeaderNames } from '../constants.js';
|
|
18
19
|
import { defaultLogger } from '../logger.js';
|
|
19
|
-
import {
|
|
20
|
+
import { normalizeHeaders } from '../utils/ario.js';
|
|
20
21
|
import { hashDataStreamToB64Url } from '../utils/hash.js';
|
|
21
22
|
import { constructVerificationUrl } from '../utils/verification-url.js';
|
|
22
23
|
export class HashVerificationStrategy {
|
|
@@ -31,11 +32,13 @@ export class HashVerificationStrategy {
|
|
|
31
32
|
/**
|
|
32
33
|
* Gets the digest for a given txId from all trusted gateways and ensures they all match.
|
|
33
34
|
* @param txId - The txId to get the digest for.
|
|
35
|
+
* @param raw - When true, fetch from /raw/{txId} endpoint instead of /{txId}.
|
|
34
36
|
* @returns The digest for the given txId.
|
|
35
37
|
*/
|
|
36
|
-
async getDigest({ txId, }) {
|
|
38
|
+
async getDigest({ txId, raw = false, }) {
|
|
37
39
|
this.logger.debug('Getting digest for txId', {
|
|
38
40
|
txId,
|
|
41
|
+
raw,
|
|
39
42
|
maxConcurrency: this.maxConcurrency,
|
|
40
43
|
trustedGateways: this.trustedGateways,
|
|
41
44
|
});
|
|
@@ -43,12 +46,15 @@ export class HashVerificationStrategy {
|
|
|
43
46
|
const throttle = pLimit(this.maxConcurrency);
|
|
44
47
|
const hashPromises = this.trustedGateways.map(async (gateway) => {
|
|
45
48
|
return throttle(async () => {
|
|
46
|
-
const
|
|
49
|
+
const url = constructVerificationUrl({ gateway, txId, raw });
|
|
47
50
|
/**
|
|
48
51
|
* This is a problem because we're not able to verify the hash of the data item if the gateway doesn't have the data in its cache. We start with a HEAD request, if it fails, we do a GET request to hydrate the cache and then a HEAD request again to get the cached digest.
|
|
52
|
+
*
|
|
53
|
+
* Note: Not all gateways return x-ar-io-digest for /raw/ endpoints (e.g., turbo-gateway.com doesn't, but ardrive.net does).
|
|
54
|
+
* The implementation tries multiple trusted gateways until one returns the digest.
|
|
49
55
|
*/
|
|
50
56
|
for (const method of ['HEAD', 'GET', 'HEAD']) {
|
|
51
|
-
const response = await fetch(
|
|
57
|
+
const response = await fetch(url, {
|
|
52
58
|
method,
|
|
53
59
|
redirect: 'follow',
|
|
54
60
|
mode: 'cors',
|
|
@@ -61,11 +67,12 @@ export class HashVerificationStrategy {
|
|
|
61
67
|
throw new Error('Failed to fetch digest for txId', {
|
|
62
68
|
cause: {
|
|
63
69
|
txId,
|
|
70
|
+
raw,
|
|
64
71
|
gateway: gateway.toString(),
|
|
65
72
|
},
|
|
66
73
|
});
|
|
67
74
|
}
|
|
68
|
-
const fetchedTxIdHash = response.headers.get(
|
|
75
|
+
const fetchedTxIdHash = response.headers.get(arioHeaderNames.digest);
|
|
69
76
|
if (fetchedTxIdHash) {
|
|
70
77
|
// avoid hitting other gateways if we've found the hash
|
|
71
78
|
throttle.clearQueue();
|
|
@@ -75,6 +82,7 @@ export class HashVerificationStrategy {
|
|
|
75
82
|
throw new Error('No hash found for txId', {
|
|
76
83
|
cause: {
|
|
77
84
|
txId,
|
|
85
|
+
raw,
|
|
78
86
|
gateway: gateway.toString(),
|
|
79
87
|
},
|
|
80
88
|
});
|
|
@@ -83,24 +91,60 @@ export class HashVerificationStrategy {
|
|
|
83
91
|
const { hash, gateway } = await Promise.any(hashPromises);
|
|
84
92
|
this.logger.debug('Successfully fetched digest for txId from trusted gateway', {
|
|
85
93
|
txId,
|
|
94
|
+
raw,
|
|
86
95
|
hash,
|
|
87
96
|
gateway: gateway.toString(),
|
|
88
97
|
});
|
|
89
98
|
return { hash, algorithm: 'sha256' };
|
|
90
99
|
}
|
|
91
|
-
async verifyData({ data, txId, }) {
|
|
92
|
-
|
|
93
|
-
|
|
100
|
+
async verifyData({ data, txId, headers = {}, raw = false, }) {
|
|
101
|
+
const normalizedHeaders = normalizeHeaders(headers);
|
|
102
|
+
// Extract header values for manifest/ArNS detection
|
|
103
|
+
const headerDataId = normalizedHeaders[arioHeaderNames.dataId.toLowerCase()];
|
|
104
|
+
const headerResolvedId = normalizedHeaders[arioHeaderNames.arnsResolvedId.toLowerCase()];
|
|
105
|
+
// Determine what data was actually served and what ID to verify against:
|
|
106
|
+
// - x-ar-io-data-id: The actual content served (e.g., index.html for manifests)
|
|
107
|
+
// - x-arns-resolved-id: The resolved txId from ArNS (could be manifest or direct)
|
|
108
|
+
//
|
|
109
|
+
// Manifest detection:
|
|
110
|
+
// - If dataId !== resolvedId → it's a manifest, dataId is the index content
|
|
111
|
+
// - If dataId === resolvedId (or only one present) → direct content
|
|
112
|
+
// - If neither present → fall back to original txId
|
|
113
|
+
const isManifest = headerDataId && headerResolvedId && headerDataId !== headerResolvedId;
|
|
114
|
+
// The ID to verify against - always verify the actual bytes we received
|
|
115
|
+
const verificationId = headerDataId || headerResolvedId || txId;
|
|
116
|
+
// Determine if we need to use raw verification:
|
|
117
|
+
// - raw=true explicitly set AND we're not looking at resolved manifest content
|
|
118
|
+
// - For manifests (dataId !== resolvedId), we received index content, verify normally
|
|
119
|
+
// - For raw manifest fetch (raw=true, no manifest resolution), use /raw/ endpoint
|
|
120
|
+
const isRawVerification = raw && !isManifest;
|
|
121
|
+
this.logger.debug('Starting hash verification', {
|
|
122
|
+
txId,
|
|
123
|
+
headerDataId,
|
|
124
|
+
headerResolvedId,
|
|
125
|
+
verificationId,
|
|
126
|
+
isManifest,
|
|
127
|
+
raw,
|
|
128
|
+
isRawVerification,
|
|
129
|
+
});
|
|
130
|
+
// Always verify against trusted gateways - never trust source gateway headers
|
|
131
|
+
const [computedHash, expectedHash] = await Promise.all([
|
|
94
132
|
hashDataStreamToB64Url({ stream: data }),
|
|
95
|
-
this.getDigest({ txId }),
|
|
133
|
+
this.getDigest({ txId: verificationId, raw: isRawVerification }),
|
|
96
134
|
]);
|
|
97
|
-
// await on the hash promise and compare to get a little concurrency when computing hashes over larger data
|
|
98
135
|
if (computedHash === undefined) {
|
|
99
136
|
throw new Error('Hash could not be computed');
|
|
100
137
|
}
|
|
101
|
-
if (computedHash !==
|
|
138
|
+
if (computedHash !== expectedHash.hash) {
|
|
102
139
|
throw new Error('Hash does not match', {
|
|
103
|
-
cause: {
|
|
140
|
+
cause: {
|
|
141
|
+
computedHash,
|
|
142
|
+
trustedHash: expectedHash,
|
|
143
|
+
txId,
|
|
144
|
+
verificationId,
|
|
145
|
+
isManifest,
|
|
146
|
+
raw: isRawVerification,
|
|
147
|
+
},
|
|
104
148
|
});
|
|
105
149
|
}
|
|
106
150
|
}
|
|
@@ -1,19 +1,3 @@
|
|
|
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
1
|
import { DataStream, VerificationStrategy } from '../types.js';
|
|
18
2
|
/**
|
|
19
3
|
* This strategy is used to verify data by checking the 'x-ar-io-verified' header from the original response.
|
|
@@ -28,6 +12,7 @@ export declare class RemoteVerificationStrategy implements VerificationStrategy
|
|
|
28
12
|
headers: Record<string, string>;
|
|
29
13
|
txId?: string;
|
|
30
14
|
data?: DataStream;
|
|
15
|
+
raw?: boolean;
|
|
31
16
|
}): Promise<void>;
|
|
32
17
|
}
|
|
33
18
|
//# sourceMappingURL=remote-verification.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-verification.d.ts","sourceRoot":"","sources":["../../src/verification/remote-verification.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"remote-verification.d.ts","sourceRoot":"","sources":["../../src/verification/remote-verification.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAG/D;;;;;;GAMG;AACH,qBAAa,0BAA2B,YAAW,oBAAoB;IACrE,eAAe,EAAE,GAAG,EAAE,CAAM;IAEtB,UAAU,CAAC,MAAM,EAAE;QACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAChC,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,UAAU,CAAC;QAClB,GAAG,CAAC,EAAE,OAAO,CAAC;KACf;CAcF"}
|
|
@@ -1,3 +1,21 @@
|
|
|
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 { arioHeaderNames } from '../constants.js';
|
|
18
|
+
import { normalizeHeaders } from '../utils/ario.js';
|
|
1
19
|
/**
|
|
2
20
|
* This strategy is used to verify data by checking the 'x-ar-io-verified' header from the original response.
|
|
3
21
|
* It does not require any client side computation, but it does require the gateway to set the header.
|
|
@@ -8,13 +26,12 @@
|
|
|
8
26
|
export class RemoteVerificationStrategy {
|
|
9
27
|
trustedGateways = []; // no trusted gateways for remote verification, we just check the headers of the gateway that returned the data
|
|
10
28
|
async verifyData(params) {
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
]));
|
|
29
|
+
// Note: The raw parameter doesn't affect remote verification since we only
|
|
30
|
+
// check the x-ar-io-verified header. The parameter is accepted for interface
|
|
31
|
+
// compatibility but ignored.
|
|
32
|
+
const headers = normalizeHeaders(params.headers);
|
|
16
33
|
// we don't use the data at all, just the headers
|
|
17
|
-
const remoteVerified = headers[
|
|
34
|
+
const remoteVerified = headers[arioHeaderNames.verified.toLowerCase()] === 'true';
|
|
18
35
|
if (!remoteVerified) {
|
|
19
36
|
throw new Error(`Data was not verified by gateway.`);
|
|
20
37
|
}
|
|
@@ -47,10 +47,14 @@ export declare class Ans104SignatureVerificationStrategy implements Verification
|
|
|
47
47
|
*
|
|
48
48
|
* @param data - The data stream to verify
|
|
49
49
|
* @param txId - The transaction ID of the data
|
|
50
|
+
* @param headers - Optional response headers (not used in signature verification)
|
|
51
|
+
* @param raw - Optional flag for raw verification (not applicable for signature verification)
|
|
50
52
|
*/
|
|
51
|
-
verifyData({ data, txId, }: {
|
|
53
|
+
verifyData({ data, txId, headers: _headers, raw: _raw, }: {
|
|
52
54
|
data: DataStream;
|
|
53
55
|
txId: string;
|
|
56
|
+
headers?: Record<string, string>;
|
|
57
|
+
raw?: boolean;
|
|
54
58
|
}): Promise<void>;
|
|
55
59
|
}
|
|
56
60
|
/**
|
|
@@ -89,9 +93,11 @@ export declare class TransactionSignatureVerificationStrategy implements Verific
|
|
|
89
93
|
}[];
|
|
90
94
|
signature: string;
|
|
91
95
|
}>;
|
|
92
|
-
verifyData({ data, txId, }: {
|
|
96
|
+
verifyData({ data, txId, headers: _headers, raw: _raw, }: {
|
|
93
97
|
data: DataStream;
|
|
94
98
|
txId: string;
|
|
99
|
+
headers?: Record<string, string>;
|
|
100
|
+
raw?: boolean;
|
|
95
101
|
}): Promise<void>;
|
|
96
102
|
}
|
|
97
103
|
export declare const SignatureVerificationStrategies: {
|
|
@@ -109,9 +115,11 @@ export declare class SignatureVerificationStrategy {
|
|
|
109
115
|
logger?: Logger;
|
|
110
116
|
classifier?: DataClassifier;
|
|
111
117
|
});
|
|
112
|
-
verifyData({ data, txId, }: {
|
|
118
|
+
verifyData({ data, txId, headers, raw, }: {
|
|
113
119
|
data: DataStream;
|
|
114
120
|
txId: string;
|
|
121
|
+
headers?: Record<string, string>;
|
|
122
|
+
raw?: boolean;
|
|
115
123
|
}): Promise<void>;
|
|
116
124
|
}
|
|
117
125
|
//# sourceMappingURL=signature-verification.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signature-verification.d.ts","sourceRoot":"","sources":["../../src/verification/signature-verification.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,MAAM,EACN,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAarB;;;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;QAAE,eAAe,EAAE,GAAG,EAAE,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAMvE;;;;;OAKG;YACW,qBAAqB;IA+GnC;;;;;OAKG;IACG,gBAAgB,CAAC,EACrB,IAAI,GACL,EAAE;QACD,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC;QACV,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,UAAU,CAAC;QACtB,KAAK,EAAE,UAAU,CAAC;QAClB,MAAM,EAAE,UAAU,CAAC;QACnB,MAAM,EAAE,UAAU,CAAC;QACnB,IAAI,EAAE,UAAU,CAAC;KAClB,CAAC;IA0EF
|
|
1
|
+
{"version":3,"file":"signature-verification.d.ts","sourceRoot":"","sources":["../../src/verification/signature-verification.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EACV,cAAc,EACd,UAAU,EACV,MAAM,EACN,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAarB;;;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;QAAE,eAAe,EAAE,GAAG,EAAE,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAMvE;;;;;OAKG;YACW,qBAAqB;IA+GnC;;;;;OAKG;IACG,gBAAgB,CAAC,EACrB,IAAI,GACL,EAAE;QACD,IAAI,EAAE,MAAM,CAAC;KACd,G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194
194
|
* @param data - The data stream to verify
|
|
195
195
|
* @param txId - The transaction ID of the data
|
|
196
|
+
* @param headers - Optional response headers (not used in signature verification)
|
|
197
|
+
* @param raw - Optional flag for raw verification (not applicable for signature verification)
|
|
196
198
|
*/
|
|
197
|
-
async verifyData({ data, txId, }) {
|
|
199
|
+
async verifyData({ data, txId, headers: _headers = {}, raw: _raw = false, }) {
|
|
198
200
|
// fetch signature data from trusted gateway
|
|
199
201
|
const trustedSignatureData = await this.getSignatureData({ txId });
|
|
200
202
|
if (!DataItem.isDataItem(trustedSignatureData)) {
|
|
@@ -296,7 +298,10 @@ export class TransactionSignatureVerificationStrategy {
|
|
|
296
298
|
cause: { txId },
|
|
297
299
|
});
|
|
298
300
|
}
|
|
299
|
-
async verifyData({ data, txId, }) {
|
|
301
|
+
async verifyData({ data, txId, headers: _headers = {}, raw: _raw = false, }) {
|
|
302
|
+
// Note: The raw parameter is not applicable for transaction signature verification
|
|
303
|
+
// as this strategy verifies the cryptographic signature of the transaction itself.
|
|
304
|
+
// The parameter is accepted for interface compatibility but ignored.
|
|
300
305
|
const { format, owner, target, quantity, reward, dataSize, lastTx, tags, signature, } = await this.getSignatureData({ txId });
|
|
301
306
|
const tagList = tags.map((tag) => [
|
|
302
307
|
fromB64Url(tag.name),
|
|
@@ -350,13 +355,13 @@ export class SignatureVerificationStrategy {
|
|
|
350
355
|
});
|
|
351
356
|
this.classifier = classifier;
|
|
352
357
|
}
|
|
353
|
-
async verifyData({ data, txId, }) {
|
|
358
|
+
async verifyData({ data, txId, headers = {}, raw = false, }) {
|
|
354
359
|
const dataType = await this.classifier.classify({ txId });
|
|
355
360
|
switch (dataType) {
|
|
356
361
|
case 'ans104':
|
|
357
|
-
return this.ans104.verifyData({ data, txId });
|
|
362
|
+
return this.ans104.verifyData({ data, txId, headers, raw });
|
|
358
363
|
case 'transaction':
|
|
359
|
-
return this.transaction.verifyData({ data, txId });
|
|
364
|
+
return this.transaction.verifyData({ data, txId, headers, raw });
|
|
360
365
|
default:
|
|
361
366
|
throw new Error('Unknown data type', {
|
|
362
367
|
cause: { dataType },
|
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.9.
|
|
17
|
+
export declare const WAYFINDER_CORE_VERSION = "v1.9.2";
|
|
18
18
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
package/dist/wayfinder.d.ts
CHANGED
|
@@ -119,7 +119,7 @@ export declare class Wayfinder {
|
|
|
119
119
|
* const wayfinder = new Wayfinder({
|
|
120
120
|
* verificationSettings: {
|
|
121
121
|
* strategy: new HashVerificationStrategy({
|
|
122
|
-
* trustedGateways: [new URL('https://
|
|
122
|
+
* trustedGateways: [new URL('https://turbo-gateway.com')],
|
|
123
123
|
* }),
|
|
124
124
|
* events: {
|
|
125
125
|
* onVerificationProgress: (event) => {
|
|
@@ -189,7 +189,7 @@ export declare class Wayfinder {
|
|
|
189
189
|
* @example
|
|
190
190
|
* const wayfinder = new Wayfinder();
|
|
191
191
|
* wayfinder.setVerificationStrategy(new HashVerificationStrategy({
|
|
192
|
-
* trustedGateways: [new URL('https://
|
|
192
|
+
* trustedGateways: [new URL('https://turbo-gateway.com')],
|
|
193
193
|
* }));
|
|
194
194
|
*
|
|
195
195
|
* @param strategy - The verification strategy to use
|
|
@@ -240,7 +240,7 @@ export declare class Wayfinder {
|
|
|
240
240
|
* @example
|
|
241
241
|
* const wayfinder = new Wayfinder({
|
|
242
242
|
* verificationStrategy: new HashVerificationStrategy({
|
|
243
|
-
* trustedGateways: [new URL('https://
|
|
243
|
+
* trustedGateways: [new URL('https://turbo-gateway.com')],
|
|
244
244
|
* }),
|
|
245
245
|
* })
|
|
246
246
|
*
|
package/dist/wayfinder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"w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;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,UAAU,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC;CAgD3D"}
|
package/dist/wayfinder.js
CHANGED
|
@@ -209,7 +209,7 @@ export class Wayfinder {
|
|
|
209
209
|
* const wayfinder = new Wayfinder({
|
|
210
210
|
* verificationSettings: {
|
|
211
211
|
* strategy: new HashVerificationStrategy({
|
|
212
|
-
* trustedGateways: [new URL('https://
|
|
212
|
+
* trustedGateways: [new URL('https://turbo-gateway.com')],
|
|
213
213
|
* }),
|
|
214
214
|
* events: {
|
|
215
215
|
* onVerificationProgress: (event) => {
|
|
@@ -263,7 +263,7 @@ export class Wayfinder {
|
|
|
263
263
|
this.gatewaysProvider =
|
|
264
264
|
gatewaysProvider ??
|
|
265
265
|
new TrustedPeersGatewaysProvider({
|
|
266
|
-
trustedGateway: 'https://
|
|
266
|
+
trustedGateway: 'https://turbo-gateway.com',
|
|
267
267
|
logger: this.logger,
|
|
268
268
|
});
|
|
269
269
|
// default verification settings
|
|
@@ -272,10 +272,11 @@ export class Wayfinder {
|
|
|
272
272
|
verificationSettings?.strategy !== undefined,
|
|
273
273
|
events: {},
|
|
274
274
|
strict: false,
|
|
275
|
+
raw: false,
|
|
275
276
|
strategy: (verificationSettings?.strategy ?? verificationSettings?.enabled)
|
|
276
277
|
? new HashVerificationStrategy({
|
|
277
278
|
logger,
|
|
278
|
-
trustedGateways: [new URL('https://
|
|
279
|
+
trustedGateways: [new URL('https://turbo-gateway.com')],
|
|
279
280
|
})
|
|
280
281
|
: undefined,
|
|
281
282
|
// overwrite the default settings with the provided ones
|
|
@@ -390,7 +391,7 @@ export class Wayfinder {
|
|
|
390
391
|
* @example
|
|
391
392
|
* const wayfinder = new Wayfinder();
|
|
392
393
|
* wayfinder.setVerificationStrategy(new HashVerificationStrategy({
|
|
393
|
-
* trustedGateways: [new URL('https://
|
|
394
|
+
* trustedGateways: [new URL('https://turbo-gateway.com')],
|
|
394
395
|
* }));
|
|
395
396
|
*
|
|
396
397
|
* @param strategy - The verification strategy to use
|
|
@@ -442,7 +443,7 @@ export class Wayfinder {
|
|
|
442
443
|
this.verificationSettings.strategy ??
|
|
443
444
|
new HashVerificationStrategy({
|
|
444
445
|
logger: this.logger,
|
|
445
|
-
trustedGateways: [new URL('https://
|
|
446
|
+
trustedGateways: [new URL('https://turbo-gateway.com')],
|
|
446
447
|
});
|
|
447
448
|
}
|
|
448
449
|
/**
|
|
@@ -452,7 +453,7 @@ export class Wayfinder {
|
|
|
452
453
|
* @example
|
|
453
454
|
* const wayfinder = new Wayfinder({
|
|
454
455
|
* verificationStrategy: new HashVerificationStrategy({
|
|
455
|
-
* trustedGateways: [new URL('https://
|
|
456
|
+
* trustedGateways: [new URL('https://turbo-gateway.com')],
|
|
456
457
|
* }),
|
|
457
458
|
* })
|
|
458
459
|
*
|