@ar.io/sdk 3.12.0-beta.6 → 3.12.0-beta.7
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/bundles/web.bundle.min.js +134 -134
- package/lib/cjs/common/wayfinder/verification/strategies/data-root-verifier.js +17 -46
- package/lib/cjs/common/wayfinder/verification/strategies/hash-verifier.js +7 -30
- package/lib/cjs/common/wayfinder/wayfinder.js +87 -184
- package/lib/cjs/utils/hash.js +83 -31
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/wayfinder/verification/strategies/data-root-verifier.js +15 -43
- package/lib/esm/common/wayfinder/verification/strategies/hash-verifier.js +8 -31
- package/lib/esm/common/wayfinder/wayfinder.js +85 -179
- package/lib/esm/utils/hash.js +74 -27
- package/lib/esm/version.js +1 -1
- package/lib/types/common/wayfinder/verification/strategies/data-root-verifier.d.ts +4 -8
- package/lib/types/common/wayfinder/verification/strategies/hash-verifier.d.ts +2 -3
- package/lib/types/common/wayfinder/wayfinder.d.ts +40 -58
- package/lib/types/types/wayfinder.d.ts +2 -2
- package/lib/types/utils/hash.d.ts +8 -4
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import EventEmitter from '
|
|
17
|
-
import { PassThrough, Readable } from 'node:stream';
|
|
16
|
+
import { EventEmitter } from 'eventemitter3';
|
|
18
17
|
import { DataVerificationStrategy, GatewaysProvider, RoutingStrategy } from '../../types/wayfinder.js';
|
|
19
18
|
import { Logger } from '../logger.js';
|
|
20
19
|
type WayfinderHttpClient = typeof fetch;
|
|
@@ -35,69 +34,52 @@ export declare const resolveWayfinderUrl: ({ originalUrl, selectedGateway, logge
|
|
|
35
34
|
* Wayfinder event emitter with verification events
|
|
36
35
|
*/
|
|
37
36
|
export type WayfinderEvent = {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
} | {
|
|
68
|
-
type: 'identified-transaction-id';
|
|
69
|
-
originalUrl: string;
|
|
70
|
-
selectedGateway: string;
|
|
71
|
-
txId: string;
|
|
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
|
+
};
|
|
72
66
|
};
|
|
73
67
|
export interface WayfinderEventArgs {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
onVerificationFailed?: (payload: Omit<Extract<WayfinderEvent, {
|
|
78
|
-
type: 'verification-failed';
|
|
79
|
-
}>, 'type'>) => void;
|
|
80
|
-
onVerificationProgress?: (payload: Omit<Extract<WayfinderEvent, {
|
|
81
|
-
type: 'verification-progress';
|
|
82
|
-
}>, 'type'>) => void;
|
|
68
|
+
onVerificationSucceeded?: (payload: WayfinderEvent['verification-succeeded']) => void;
|
|
69
|
+
onVerificationFailed?: (payload: WayfinderEvent['verification-failed']) => void;
|
|
70
|
+
onVerificationProgress?: (payload: WayfinderEvent['verification-progress']) => void;
|
|
83
71
|
}
|
|
84
|
-
export declare class WayfinderEmitter extends EventEmitter {
|
|
85
|
-
constructor({
|
|
86
|
-
emit<E extends WayfinderEvent['type']>(event: E, payload: Omit<Extract<WayfinderEvent, {
|
|
87
|
-
type: E;
|
|
88
|
-
}>, 'type'>): boolean;
|
|
89
|
-
on<E extends WayfinderEvent['type']>(event: E, listener: (payload: Omit<Extract<WayfinderEvent, {
|
|
90
|
-
type: E;
|
|
91
|
-
}>, 'type'>) => void): this;
|
|
72
|
+
export declare class WayfinderEmitter extends EventEmitter<WayfinderEvent> {
|
|
73
|
+
constructor({ onVerificationSucceeded, onVerificationFailed, onVerificationProgress, }?: WayfinderEventArgs);
|
|
92
74
|
}
|
|
93
|
-
export declare function
|
|
94
|
-
originalStream:
|
|
75
|
+
export declare function tapAndVerifyReadableStream({ originalStream, contentLength, verifyData, txId, emitter, strict, }: {
|
|
76
|
+
originalStream: ReadableStream;
|
|
95
77
|
contentLength: number;
|
|
96
78
|
verifyData: DataVerificationStrategy['verifyData'];
|
|
97
79
|
txId: string;
|
|
98
80
|
emitter?: WayfinderEmitter;
|
|
99
81
|
strict?: boolean;
|
|
100
|
-
}):
|
|
82
|
+
}): ReadableStream;
|
|
101
83
|
/**
|
|
102
84
|
* Gets the sandbox hash for a given transaction id
|
|
103
85
|
*/
|
|
@@ -124,7 +106,7 @@ export declare const createWayfinderClient: ({ resolveUrl, verifyData, selectGat
|
|
|
124
106
|
logger?: Logger;
|
|
125
107
|
emitter?: WayfinderEmitter;
|
|
126
108
|
strict?: boolean;
|
|
127
|
-
}) =>
|
|
109
|
+
}) => (url: string, init?: RequestInit) => Promise<Response>;
|
|
128
110
|
/**
|
|
129
111
|
* The main class for the wayfinder
|
|
130
112
|
*/
|
|
@@ -263,7 +245,7 @@ export declare class Wayfinder {
|
|
|
263
245
|
* @param logger - the logger to use for logging
|
|
264
246
|
* @param strict - if true, verification will be blocking and will fail requests if verification fails; if false, verification will be non-blocking
|
|
265
247
|
*/
|
|
266
|
-
constructor({ logger, gatewaysProvider, routingStrategy, verificationStrategy, events, strict, }
|
|
248
|
+
constructor({ logger, gatewaysProvider, routingStrategy, verificationStrategy, events, strict, }?: {
|
|
267
249
|
routingStrategy?: RoutingStrategy;
|
|
268
250
|
gatewaysProvider?: GatewaysProvider;
|
|
269
251
|
verificationStrategy?: DataVerificationStrategy;
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { Readable } from 'stream';
|
|
17
16
|
export interface RoutingStrategy {
|
|
18
17
|
selectGateway: ({ gateways }: {
|
|
19
18
|
gateways: URL[];
|
|
@@ -22,6 +21,7 @@ export interface RoutingStrategy {
|
|
|
22
21
|
export interface GatewaysProvider {
|
|
23
22
|
getGateways: () => Promise<URL[]>;
|
|
24
23
|
}
|
|
24
|
+
export type DataStream = AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>;
|
|
25
25
|
export interface DataVerificationStrategy {
|
|
26
26
|
/**
|
|
27
27
|
* Verifies the provided data for a given txId
|
|
@@ -35,7 +35,7 @@ export interface DataVerificationStrategy {
|
|
|
35
35
|
* @returns the hash of the data
|
|
36
36
|
*/
|
|
37
37
|
verifyData: ({ data, txId, }: {
|
|
38
|
-
data:
|
|
38
|
+
data: DataStream;
|
|
39
39
|
txId: string;
|
|
40
40
|
}) => Promise<void>;
|
|
41
41
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
1
|
+
import { DataStream } from '../types/wayfinder.js';
|
|
2
|
+
export declare const isAsyncIterable: <T = unknown>(x: any) => x is AsyncIterable<T>;
|
|
3
|
+
export declare const isReadableStream: <T = unknown>(x: any) => x is ReadableStream<T>;
|
|
4
|
+
export declare const readableStreamToAsyncIterable: (stream: ReadableStream<Uint8Array>) => AsyncIterable<Uint8Array>;
|
|
5
|
+
export declare const hashDataStreamToB64Url: (stream: DataStream, algorithm?: string) => Promise<string>;
|
|
6
|
+
export declare const convertDataStreamToDataRoot: ({ dataStream, }: {
|
|
7
|
+
dataStream: DataStream;
|
|
8
|
+
}) => Promise<string>;
|
package/lib/types/version.d.ts
CHANGED