@ar.io/sdk 3.11.0-alpha.12 → 3.11.0-alpha.13

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 (59) hide show
  1. package/bundles/web.bundle.min.js +120 -123
  2. package/lib/cjs/common/index.js +0 -2
  3. package/lib/cjs/types/index.js +0 -1
  4. package/lib/cjs/version.js +1 -1
  5. package/lib/esm/common/index.js +0 -2
  6. package/lib/esm/types/index.js +0 -1
  7. package/lib/esm/version.js +1 -1
  8. package/lib/types/common/index.d.ts +0 -1
  9. package/lib/types/types/index.d.ts +0 -1
  10. package/lib/types/version.d.ts +1 -1
  11. package/package.json +1 -1
  12. package/lib/cjs/common/wayfinder/gateways/trusted-gateways.js +0 -106
  13. package/lib/cjs/common/wayfinder/gateways.js +0 -86
  14. package/lib/cjs/common/wayfinder/index.js +0 -44
  15. package/lib/cjs/common/wayfinder/routers/priority.js +0 -29
  16. package/lib/cjs/common/wayfinder/routers/priority.test.js +0 -155
  17. package/lib/cjs/common/wayfinder/routers/random.js +0 -23
  18. package/lib/cjs/common/wayfinder/routers/random.test.js +0 -25
  19. package/lib/cjs/common/wayfinder/routers/simple-cache.js +0 -25
  20. package/lib/cjs/common/wayfinder/routers/simple-cache.test.js +0 -41
  21. package/lib/cjs/common/wayfinder/routers/static.js +0 -14
  22. package/lib/cjs/common/wayfinder/routers/static.test.js +0 -14
  23. package/lib/cjs/common/wayfinder/verification/data-root-verifier.js +0 -139
  24. package/lib/cjs/common/wayfinder/verification/hash-verifier.js +0 -50
  25. package/lib/cjs/common/wayfinder/wayfinder.js +0 -596
  26. package/lib/cjs/common/wayfinder/wayfinder.test.js +0 -500
  27. package/lib/cjs/types/wayfinder.js +0 -3
  28. package/lib/esm/common/wayfinder/gateways/trusted-gateways.js +0 -102
  29. package/lib/esm/common/wayfinder/gateways.js +0 -80
  30. package/lib/esm/common/wayfinder/index.js +0 -28
  31. package/lib/esm/common/wayfinder/routers/priority.js +0 -25
  32. package/lib/esm/common/wayfinder/routers/priority.test.js +0 -153
  33. package/lib/esm/common/wayfinder/routers/random.js +0 -19
  34. package/lib/esm/common/wayfinder/routers/random.test.js +0 -23
  35. package/lib/esm/common/wayfinder/routers/simple-cache.js +0 -21
  36. package/lib/esm/common/wayfinder/routers/simple-cache.test.js +0 -39
  37. package/lib/esm/common/wayfinder/routers/static.js +0 -10
  38. package/lib/esm/common/wayfinder/routers/static.test.js +0 -12
  39. package/lib/esm/common/wayfinder/verification/data-root-verifier.js +0 -130
  40. package/lib/esm/common/wayfinder/verification/hash-verifier.js +0 -46
  41. package/lib/esm/common/wayfinder/wayfinder.js +0 -584
  42. package/lib/esm/common/wayfinder/wayfinder.test.js +0 -495
  43. package/lib/esm/types/wayfinder.js +0 -2
  44. package/lib/types/common/wayfinder/gateways/trusted-gateways.d.ts +0 -51
  45. package/lib/types/common/wayfinder/gateways.d.ts +0 -53
  46. package/lib/types/common/wayfinder/index.d.ts +0 -23
  47. package/lib/types/common/wayfinder/routers/priority.d.ts +0 -29
  48. package/lib/types/common/wayfinder/routers/priority.test.d.ts +0 -1
  49. package/lib/types/common/wayfinder/routers/random.d.ts +0 -27
  50. package/lib/types/common/wayfinder/routers/random.test.d.ts +0 -1
  51. package/lib/types/common/wayfinder/routers/simple-cache.d.ts +0 -28
  52. package/lib/types/common/wayfinder/routers/simple-cache.test.d.ts +0 -1
  53. package/lib/types/common/wayfinder/routers/static.d.ts +0 -24
  54. package/lib/types/common/wayfinder/routers/static.test.d.ts +0 -1
  55. package/lib/types/common/wayfinder/verification/data-root-verifier.d.ts +0 -31
  56. package/lib/types/common/wayfinder/verification/hash-verifier.d.ts +0 -27
  57. package/lib/types/common/wayfinder/wayfinder.d.ts +0 -265
  58. package/lib/types/common/wayfinder/wayfinder.test.d.ts +0 -1
  59. package/lib/types/types/wayfinder.d.ts +0 -62
@@ -1,495 +0,0 @@
1
- import axios from 'axios';
2
- import got from 'got';
3
- import assert from 'node:assert';
4
- import { EventEmitter } from 'node:events';
5
- import { Readable } from 'node:stream';
6
- import { buffer } from 'node:stream/consumers';
7
- import { before, describe, it } from 'node:test';
8
- import { Logger } from '../../common/logger.js';
9
- import { RandomGatewayRouter } from './routers/random.js';
10
- import { StaticGatewayRouter } from './routers/static.js';
11
- import { Wayfinder, tapAndVerifyStream } from './wayfinder.js';
12
- // TODO: replace with locally running gateway
13
- const gatewayUrl = 'permagate.io';
14
- const stubbedGatewaysProvider = {
15
- getGateways: async () => [new URL(`http://${gatewayUrl}`)],
16
- };
17
- Logger.default.setLogLevel('none');
18
- describe('Wayfinder', () => {
19
- describe.skip('http wrapper', () => {
20
- describe('fetch', () => {
21
- let wayfinder;
22
- before(() => {
23
- wayfinder = new Wayfinder({
24
- httpClient: fetch,
25
- router: new RandomGatewayRouter({
26
- gatewaysProvider: stubbedGatewaysProvider,
27
- }),
28
- });
29
- });
30
- it('should fetch the data using the selected gateway', async () => {
31
- const nativeFetch = await fetch(`https://ao.${gatewayUrl}`);
32
- const response = await wayfinder.request('ar://ao');
33
- assert.strictEqual(response.status, 200);
34
- assert.strictEqual(response.status, nativeFetch.status);
35
- // assert the arns headers are the same
36
- const arnsHeaders = Array.from(response.headers.entries()).filter(([key]) => key.startsWith('x-arns-'));
37
- const nativeFetchHeaders = Array.from(nativeFetch.headers.entries()).filter(([key]) => key.startsWith('x-arns-'));
38
- assert.deepStrictEqual(arnsHeaders, nativeFetchHeaders);
39
- });
40
- it('should fetch a tx id using the selected gateway', async () => {
41
- const nativeFetch = await fetch(`https://${gatewayUrl}/KKmRbIfrc7wiLcG0zvY1etlO0NBx1926dSCksxCIN3A`,
42
- // follow redirects
43
- { redirect: 'follow' });
44
- const response = await wayfinder.request('ar://KKmRbIfrc7wiLcG0zvY1etlO0NBx1926dSCksxCIN3A', { redirect: 'follow' });
45
- assert.strictEqual(response.status, 200);
46
- assert.strictEqual(response.status, nativeFetch.status);
47
- });
48
- it('should route a non-ar:// url as a normal fetch', async () => {
49
- const [nativeFetch, response] = await Promise.all([
50
- fetch(`https://${gatewayUrl}/`, {
51
- method: 'HEAD',
52
- }),
53
- wayfinder.request(`https://${gatewayUrl}/`, {
54
- method: 'HEAD',
55
- }),
56
- ]);
57
- assert.strictEqual(response.status, 200);
58
- assert.strictEqual(response.status, nativeFetch.status);
59
- // TODO: ensure the headers are the same excluding unique headers
60
- });
61
- for (const api of ['/info', '/block/current']) {
62
- it(`supports native arweave node apis ${api}`, async () => {
63
- const [nativeFetch, response] = await Promise.all([
64
- fetch(`https://${gatewayUrl}${api}`),
65
- wayfinder.request(`ar://${api}`),
66
- ]);
67
- assert.strictEqual(response.status, 200);
68
- assert.strictEqual(response.status, nativeFetch.status);
69
- // TODO: ensure the headers are the same excluding unique headers
70
- });
71
- }
72
- for (const api of ['/ar-io/info']) {
73
- it(`supports native ario node gateway apis ${api}`, async () => {
74
- const [nativeFetch, response] = await Promise.all([
75
- fetch(`https://${gatewayUrl}${api}`),
76
- wayfinder.request(`ar:///${api}`),
77
- ]);
78
- assert.strictEqual(response.status, 200);
79
- assert.strictEqual(response.status, nativeFetch.status);
80
- // TODO: ensure the headers are the same excluding unique headers
81
- });
82
- }
83
- it('supports a post request to graphql', async () => {
84
- const response = await wayfinder.request('ar:///graphql', {
85
- method: 'POST',
86
- headers: {
87
- 'Content-Type': 'application/json',
88
- },
89
- body: JSON.stringify({
90
- query: `
91
- query {
92
- transactions(
93
- ids: ["xf958qhCNGfDme1FtoiD6DtMfDENDbtxZpjOM_1tsMM"]
94
- ) {
95
- edges {
96
- cursor
97
- node {
98
- id
99
- tags {
100
- name
101
- value
102
- }
103
- block {
104
- height
105
- timestamp
106
- }
107
- }
108
- }
109
- pageInfo {
110
- hasNextPage
111
- }
112
- }
113
- }
114
- `,
115
- }),
116
- });
117
- assert.strictEqual(response.status, 200);
118
- });
119
- it.skip('returns the error from the target gateway if the route is not found', async () => {
120
- const [nativeFetch, response] = await Promise.all([
121
- fetch(`https://${gatewayUrl}/ar-io/not-found`),
122
- wayfinder.request('ar:///not-found'),
123
- ]);
124
- assert.strictEqual(response.status, nativeFetch.status);
125
- assert.strictEqual(response.statusText, nativeFetch.statusText);
126
- });
127
- });
128
- describe('axios', () => {
129
- let wayfinder;
130
- before(() => {
131
- wayfinder = new Wayfinder({
132
- httpClient: axios,
133
- router: new RandomGatewayRouter({
134
- gatewaysProvider: stubbedGatewaysProvider,
135
- }),
136
- });
137
- });
138
- it('should fetch the data using axios default function against the target gateway', async () => {
139
- const [nativeAxios, response] = await Promise.all([
140
- axios(`https://ao.${gatewayUrl}`),
141
- wayfinder.request('ar://ao'),
142
- ]);
143
- assert.strictEqual(response.status, 200);
144
- assert.strictEqual(response.status, nativeAxios.status);
145
- // assert the arns headers are the same
146
- const arnsHeaders = Object.entries(response.headers)
147
- .sort()
148
- .filter(([key]) => key.startsWith('x-arns-'));
149
- const nativeAxiosHeaders = Object.entries(nativeAxios.headers).filter(([key]) => key.startsWith('x-arns-'));
150
- assert.deepStrictEqual(arnsHeaders.sort(), nativeAxiosHeaders.sort());
151
- });
152
- it('should fetch the data using the axios.get method against the target gateway', async () => {
153
- const [nativeAxios, response] = await Promise.all([
154
- axios.get(`https://ao.${gatewayUrl}`),
155
- wayfinder.request.get('ar://ao'),
156
- ]);
157
- assert.strictEqual(response.status, 200);
158
- assert.strictEqual(response.status, nativeAxios.status);
159
- // assert the arns headers are the same
160
- const arnsHeaders = Object.entries(response.headers)
161
- .sort()
162
- .filter(([key]) => key.startsWith('x-arns-'));
163
- const nativeAxiosHeaders = Object.entries(nativeAxios.headers).filter(([key]) => key.startsWith('x-arns-'));
164
- assert.deepStrictEqual(arnsHeaders.sort(), nativeAxiosHeaders.sort());
165
- });
166
- it('should route a non-ar:// url as a normal axios request', async () => {
167
- const [nativeAxios, response] = await Promise.all([
168
- axios(`https://${gatewayUrl}/`),
169
- wayfinder.request(`https://${gatewayUrl}/`),
170
- ]);
171
- assert.strictEqual(response.status, 200);
172
- assert.strictEqual(response.status, nativeAxios.status);
173
- // TODO: ensure the headers are the same excluding unique headers
174
- });
175
- for (const api of ['/info', '/block/current']) {
176
- it(`supports native arweave node apis ${api}`, async () => {
177
- const [nativeAxios, response] = await Promise.all([
178
- axios(`https://${gatewayUrl}${api}`),
179
- wayfinder.request(`ar://${api}`),
180
- ]);
181
- assert.strictEqual(response.status, 200);
182
- assert.strictEqual(response.status, nativeAxios.status);
183
- // TODO: ensure the headers are the same excluding unique headers
184
- });
185
- }
186
- for (const api of ['/ar-io/info', '/ar-io/__gateway_metrics']) {
187
- it(`supports native ario node gateway apis ${api}`, async () => {
188
- const [nativeAxios, response] = await Promise.all([
189
- axios(`https://${gatewayUrl}${api}`),
190
- wayfinder.request(`ar:///${api}`),
191
- ]);
192
- assert.strictEqual(response.status, 200);
193
- assert.strictEqual(response.status, nativeAxios.status);
194
- // TODO: ensure the headers are the same excluding unique headers
195
- });
196
- }
197
- it.skip('should return the error from the target gateway if the route is not found', async () => {
198
- const axiosInstance = axios.create({
199
- validateStatus: () => true, // don't throw so we can compare axios result with wrapped axios result
200
- });
201
- const wayfinder = new Wayfinder({
202
- httpClient: axiosInstance,
203
- router: new RandomGatewayRouter({
204
- gatewaysProvider: stubbedGatewaysProvider,
205
- }),
206
- });
207
- const [nativeAxios, response] = await Promise.all([
208
- axiosInstance(`https://${gatewayUrl}/ar-io/not-found`),
209
- wayfinder.request('ar:///not-found'),
210
- ]);
211
- assert.strictEqual(response.status, nativeAxios.status);
212
- });
213
- });
214
- describe('got', () => {
215
- let wayfinder;
216
- before(() => {
217
- wayfinder = new Wayfinder({
218
- httpClient: got,
219
- router: new RandomGatewayRouter({
220
- gatewaysProvider: stubbedGatewaysProvider,
221
- }),
222
- });
223
- });
224
- it('should fetch the data using the got default function against the target gateway', async () => {
225
- const [nativeGot, response] = await Promise.all([
226
- got(`https://ao.${gatewayUrl}`),
227
- wayfinder.request('ar://ao'),
228
- ]);
229
- assert.strictEqual(response.statusCode, 200);
230
- assert.strictEqual(response.statusCode, nativeGot.statusCode);
231
- assert.deepStrictEqual(response.body, nativeGot.body);
232
- });
233
- it('should stream the data using got.stream against the selected target gateway', async () => {
234
- const nativeBuffer = await buffer(await got.stream(`https://ao.${gatewayUrl}`, { decompress: false }));
235
- const wayfinderBuffer = await buffer(await wayfinder.request.stream('ar://ao', { decompress: false }));
236
- assert.deepStrictEqual(wayfinderBuffer, nativeBuffer);
237
- });
238
- });
239
- });
240
- describe('events', () => {
241
- it('should emit events on the wayfinder event emitter', async () => {
242
- const wayfinder = new Wayfinder({
243
- httpClient: fetch,
244
- router: new StaticGatewayRouter({
245
- gateway: `http://${gatewayUrl}`,
246
- }),
247
- verifier: {
248
- // @ts-expect-error
249
- verifyData: async (params) => {
250
- return;
251
- },
252
- },
253
- });
254
- const events = [];
255
- wayfinder.emitter.on('verification-failed', (event) => {
256
- events.push({ type: 'verification-failed', ...event });
257
- });
258
- wayfinder.emitter.on('verification-progress', (event) => {
259
- events.push({ type: 'verification-progress', ...event });
260
- });
261
- wayfinder.emitter.on('verification-passed', (event) => {
262
- events.push({ type: 'verification-passed', ...event });
263
- });
264
- // request data and assert the event is emitted
265
- const response = await wayfinder.request('ar://c7wkwt6TKgcWJUfgvpJ5q5qi4DIZyJ1_TqhjXgURh0U', {
266
- redirect: 'follow',
267
- });
268
- // read the full response body to ensure the stream is fully consumed
269
- await response.text();
270
- assert.strictEqual(response.status, 200);
271
- assert.ok(events.find((e) => e.type === 'verification-passed'), 'Should emit at least one verification-passed');
272
- });
273
- it('should execute callbacks provided to the wayfinder constructor', async () => {
274
- let verificationFailed = false;
275
- let verificationProgress = false;
276
- let verificationPassed = false;
277
- const wayfinder = new Wayfinder({
278
- httpClient: fetch,
279
- router: new StaticGatewayRouter({
280
- gateway: `http://${gatewayUrl}`,
281
- }),
282
- events: {
283
- onVerificationFailed: () => {
284
- verificationFailed = true;
285
- },
286
- onVerificationProgress: () => {
287
- verificationProgress = true;
288
- },
289
- onVerificationPassed: () => {
290
- verificationPassed = true;
291
- },
292
- },
293
- });
294
- const response = await wayfinder.request('ar://c7wkwt6TKgcWJUfgvpJ5q5qi4DIZyJ1_TqhjXgURh0U', {
295
- redirect: 'follow',
296
- });
297
- // read the full response body to ensure the stream is fully consumed
298
- await response.text();
299
- assert.strictEqual(response.status, 200);
300
- assert.ok(verificationFailed === false, 'Should not emit verification-failed');
301
- assert.ok(verificationProgress, 'Should emit verification-progress');
302
- assert.ok(verificationPassed, 'Should emit verification-passed');
303
- });
304
- });
305
- describe.skip('tapAndVerifyRequest', () => {
306
- describe('Readable', () => {
307
- it('should duplicate the stream, verify the first and return the second if verification passes', async () => {
308
- // create a simple readable
309
- const chunks = [
310
- Buffer.from('foo'),
311
- Buffer.from('bar'),
312
- Buffer.from('baz'),
313
- ];
314
- const contentLength = chunks.reduce((sum, c) => sum + c.length, 0);
315
- // a stream that will emit chunks
316
- const originalStream = Readable.from(chunks);
317
- let seen = Buffer.alloc(0);
318
- const verifyData = async ({ data,
319
- // @ts-expect-error
320
- txId, }) => {
321
- return new Promise((resolve, reject) => {
322
- data.on('data', (chunk) => {
323
- seen = Buffer.concat([seen, chunk]);
324
- });
325
- data.on('end', () => {
326
- // Should have seen exactly the full payload
327
- assert.strictEqual(seen.length, contentLength);
328
- resolve();
329
- });
330
- data.on('error', reject);
331
- });
332
- };
333
- const txId = 'test-tx-1';
334
- const emitter = new EventEmitter();
335
- const events = [];
336
- emitter.on('verification-progress', (e) => {
337
- console.log('verification-progress', e);
338
- events.push({ type: 'verification-progress', ...e });
339
- });
340
- emitter.on('verification-passed', (e) => events.push({ type: 'verification-passed', ...e }));
341
- // tap with verification
342
- const tapped = tapAndVerifyStream({
343
- originalStream,
344
- contentLength,
345
- verifyData,
346
- txId,
347
- emitter,
348
- });
349
- // read the stream
350
- const out = [];
351
- for await (const chunk of tapped) {
352
- out.push(chunk);
353
- }
354
- // assert the stream is the same
355
- assert.strictEqual(Buffer.concat(out).toString(), Buffer.concat(chunks).toString(), 'The tapped stream should emit exactly the original data');
356
- assert.ok(events.find((e) => e.type === 'verification-progress'), 'Should emit at least one verification-progress');
357
- assert.ok(events.find((e) => e.type === 'verification-passed' && e.txId === txId), 'Should emit at least one verification-passed');
358
- });
359
- it('should throw an error on the client stream if verification fails', async () => {
360
- const chunks = [
361
- Buffer.from('foo'),
362
- Buffer.from('bar'),
363
- Buffer.from('baz'),
364
- ];
365
- const contentLength = chunks.reduce((sum, c) => sum + c.length, 0);
366
- // a stream that will emit chunks
367
- const originalStream = Readable.from(chunks);
368
- const verifyData = async ({
369
- // @ts-expect-error
370
- data, txId, }) => {
371
- throw new Error('Verification failed for txId: ' + txId);
372
- };
373
- const txId = 'test-tx-1';
374
- const emitter = new EventEmitter();
375
- const events = [];
376
- emitter.on('verification-progress', (e) => events.push({ type: 'verification-progress', ...e }));
377
- emitter.on('verification-failed', (e) => events.push({ type: 'verification-failed', ...e }));
378
- // tap with verification
379
- const tapped = tapAndVerifyStream({
380
- originalStream,
381
- contentLength,
382
- verifyData,
383
- txId,
384
- emitter,
385
- });
386
- // read the stream
387
- try {
388
- const out = [];
389
- for await (const chunk of tapped) {
390
- out.push(chunk);
391
- }
392
- }
393
- catch (error) {
394
- assert.ok(events.find((e) => e.type === 'verification-failed' && e.txId === txId), 'Should emit at least one verification-failed');
395
- // stream should be closed
396
- assert.ok(tapped.closed);
397
- }
398
- });
399
- });
400
- describe('ReadableStream', () => {
401
- it('should duplicate the ReadableStream, verify the first and return the second if verification passes', async () => {
402
- // create a simple readable
403
- const chunks = [
404
- Buffer.from('foo'),
405
- Buffer.from('bar'),
406
- Buffer.from('baz'),
407
- ];
408
- const contentLength = chunks.reduce((sum, c) => sum + c.length, 0);
409
- // a stream that will emit chunks
410
- const originalStream = ReadableStream.from(chunks);
411
- let seen = Buffer.alloc(0);
412
- const verifyData = async ({ data,
413
- // @ts-expect-error
414
- txId, }) => {
415
- return new Promise(async (resolve, reject) => {
416
- const reader = data.getReader();
417
- while (true) {
418
- try {
419
- const { done, value } = await reader.read();
420
- if (done) {
421
- resolve();
422
- break;
423
- }
424
- seen = Buffer.concat([seen, value]);
425
- }
426
- catch (error) {
427
- reject(error);
428
- }
429
- }
430
- });
431
- };
432
- const txId = 'test-tx-1';
433
- const emitter = new EventEmitter();
434
- const events = [];
435
- emitter.on('verification-progress', (e) => events.push({ type: 'verification-progress', ...e }));
436
- emitter.on('verification-passed', (e) => events.push({ type: 'verification-passed', ...e }));
437
- // tap with verification
438
- const tapped = tapAndVerifyStream({
439
- originalStream,
440
- contentLength,
441
- verifyData,
442
- txId,
443
- emitter,
444
- });
445
- // read the stream
446
- const out = [];
447
- for await (const chunk of tapped) {
448
- out.push(chunk);
449
- }
450
- // assert the stream is the same
451
- assert.strictEqual(Buffer.concat(out).toString(), Buffer.concat(chunks).toString(), 'The tapped stream should emit exactly the original data');
452
- assert.ok(events.find((e) => e.type === 'verification-progress'), 'Should emit at least one verification-progress');
453
- assert.ok(events.find((e) => e.type === 'verification-passed' && e.txId === txId), 'Should emit at least one verification-passed');
454
- });
455
- it('should throw an error on the client stream if verification fails', async () => {
456
- const chunks = [
457
- Buffer.from('foo'),
458
- Buffer.from('bar'),
459
- Buffer.from('baz'),
460
- ];
461
- const contentLength = chunks.reduce((sum, c) => sum + c.length, 0);
462
- // a stream that will emit chunks
463
- const originalStream = ReadableStream.from(chunks);
464
- const verifyData = async ({
465
- // @ts-expect-error
466
- data, txId, }) => {
467
- throw new Error('Verification failed for txId: ' + txId);
468
- };
469
- const txId = 'test-tx-1';
470
- const emitter = new EventEmitter();
471
- const events = [];
472
- emitter.on('verification-progress', (e) => events.push({ type: 'verification-progress', ...e }));
473
- emitter.on('verification-failed', (e) => events.push({ type: 'verification-failed', ...e }));
474
- // tap with verification
475
- const tapped = tapAndVerifyStream({
476
- originalStream,
477
- contentLength,
478
- verifyData,
479
- txId,
480
- emitter,
481
- });
482
- // read the stream
483
- try {
484
- const out = [];
485
- for await (const chunk of tapped) {
486
- out.push(chunk);
487
- }
488
- }
489
- catch (error) {
490
- assert.ok(events.find((e) => e.type === 'verification-failed' && e.txId === txId), 'Should emit at least one verification-failed');
491
- }
492
- });
493
- });
494
- });
495
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- // TODO: add an offset provider that returns offsets for data items so we can use them to verify the signatures of a data item within a bundle
@@ -1,51 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { DataHashProvider, DataRootProvider } from '../../../types/wayfinder.js';
17
- import { GatewaysProvider } from '../gateways.js';
18
- export declare class TrustedGatewaysHashProvider implements DataHashProvider, DataRootProvider {
19
- private gatewaysProvider;
20
- constructor({ gatewaysProvider, }: {
21
- gatewaysProvider: GatewaysProvider;
22
- });
23
- /**
24
- * Gets the digest for a given txId from all trusted gateways and ensures they all match.
25
- * @param txId - The txId to get the digest for.
26
- * @returns The digest for the given txId.
27
- */
28
- getHash({ txId, }: {
29
- txId: string;
30
- }): Promise<{
31
- hash: string;
32
- algorithm: 'sha256';
33
- }>;
34
- /**
35
- * Get the data root for a given txId from all trusted gateways and ensure they all match.
36
- * @param txId - The txId to get the data root for.
37
- * @returns The data root for the given txId.
38
- */
39
- getDataRoot({ txId }: {
40
- txId: string;
41
- }): Promise<string>;
42
- }
43
- /**
44
- * Note from @djwhitt
45
- *
46
- * Calculating data roots this way is fine, but it may not reproduce the original data root.
47
- * We could also implement a data root verifier that pulls all the chunks, checks that they
48
- * reproduce the expected data root, and then compares the concatenated chunk data to the
49
- * original data retrieved. That would take a while, but it should be able to verify any L1
50
- * data where we can find the chunks.
51
- */
@@ -1,53 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { AoARIORead, AoGatewayWithAddress } from '../../types/io.js';
17
- export interface GatewaysProvider {
18
- getGateways(): Promise<URL[]>;
19
- }
20
- export declare class NetworkGatewaysProvider implements GatewaysProvider {
21
- private ario;
22
- private sortBy;
23
- private sortOrder;
24
- private limit;
25
- private filter;
26
- constructor({ ario, sortBy, sortOrder, limit, filter, }: {
27
- ario: AoARIORead;
28
- sortBy?: 'totalDelegatedStake' | 'operatorStake' | 'startTimestamp';
29
- sortOrder?: 'asc' | 'desc';
30
- limit?: number;
31
- blocklist?: string[];
32
- filter?: (gateway: AoGatewayWithAddress) => boolean;
33
- });
34
- getGateways(): Promise<URL[]>;
35
- }
36
- export declare class StaticGatewaysProvider implements GatewaysProvider {
37
- private gateways;
38
- constructor({ gateways }: {
39
- gateways: string[];
40
- });
41
- getGateways(): Promise<URL[]>;
42
- }
43
- export declare class SimpleCacheGatewaysProvider implements GatewaysProvider {
44
- private gatewaysProvider;
45
- private ttlSeconds;
46
- private lastUpdated;
47
- private gatewaysCache;
48
- constructor({ gatewaysProvider, ttlSeconds, }: {
49
- gatewaysProvider: GatewaysProvider;
50
- ttlSeconds?: number;
51
- });
52
- getGateways(): Promise<URL[]>;
53
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- export * from './wayfinder.js';
17
- export * from './routers/random.js';
18
- export * from './routers/priority.js';
19
- export * from './routers/static.js';
20
- export * from './gateways.js';
21
- export * from './gateways/trusted-gateways.js';
22
- export * from './verification/data-root-verifier.js';
23
- export * from './verification/hash-verifier.js';
@@ -1,29 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import { WayfinderRouter } from '../../../types/wayfinder.js';
17
- import { AoARIORead } from '../../../web/index.js';
18
- import { NetworkGatewaysProvider } from '../gateways.js';
19
- export declare class PriorityGatewayRouter implements WayfinderRouter {
20
- readonly name = "priority";
21
- readonly gatewaysProvider: NetworkGatewaysProvider;
22
- constructor({ ario, sortBy, sortOrder, limit, }: {
23
- ario: AoARIORead;
24
- sortBy: 'operatorStake' | 'totalDelegatedStake' | 'startTimestamp';
25
- sortOrder: 'asc' | 'desc';
26
- limit: number;
27
- });
28
- getTargetGateway(): Promise<URL>;
29
- }
@@ -1 +0,0 @@
1
- export {};