@ar.io/sdk 3.11.0-alpha.6 → 3.11.0-alpha.8
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 +119 -116
- package/lib/cjs/common/io.js +8 -3
- package/lib/cjs/common/wayfinder/gateways/trusted-gateways.js +106 -0
- package/lib/cjs/common/wayfinder/gateways.js +19 -8
- package/lib/cjs/common/wayfinder/index.js +7 -1
- package/lib/cjs/common/wayfinder/routers/priority.js +11 -20
- package/lib/cjs/common/wayfinder/routers/priority.test.js +5 -5
- package/lib/cjs/common/wayfinder/routers/random.js +2 -2
- package/lib/cjs/common/wayfinder/routers/random.test.js +5 -84
- package/lib/cjs/common/wayfinder/routers/{fixed.js → static.js} +5 -5
- package/lib/cjs/common/wayfinder/routers/{fixed.test.js → static.test.js} +4 -4
- package/lib/cjs/common/wayfinder/verification/data-root-verifier.js +139 -0
- package/lib/cjs/common/wayfinder/verification/hash-verifier.js +50 -0
- package/lib/cjs/common/wayfinder/wayfinder.js +408 -19
- package/lib/cjs/common/wayfinder/wayfinder.test.js +296 -49
- package/lib/cjs/types/wayfinder.js +1 -0
- package/lib/cjs/utils/arweave.js +1 -1
- package/lib/cjs/utils/hash.js +56 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/io.js +8 -3
- package/lib/esm/common/wayfinder/gateways/trusted-gateways.js +102 -0
- package/lib/esm/common/wayfinder/gateways.js +17 -6
- package/lib/esm/common/wayfinder/index.js +7 -1
- package/lib/esm/common/wayfinder/routers/priority.js +11 -20
- package/lib/esm/common/wayfinder/routers/priority.test.js +5 -5
- package/lib/esm/common/wayfinder/routers/random.js +2 -2
- package/lib/esm/common/wayfinder/routers/random.test.js +5 -84
- package/lib/esm/common/wayfinder/routers/{fixed.js → static.js} +3 -3
- package/lib/esm/common/wayfinder/routers/{fixed.test.js → static.test.js} +4 -4
- package/lib/esm/common/wayfinder/verification/data-root-verifier.js +130 -0
- package/lib/esm/common/wayfinder/verification/hash-verifier.js +46 -0
- package/lib/esm/common/wayfinder/wayfinder.js +402 -19
- package/lib/esm/common/wayfinder/wayfinder.test.js +297 -50
- package/lib/esm/types/wayfinder.js +1 -0
- package/lib/esm/utils/arweave.js +1 -1
- package/lib/esm/utils/hash.js +50 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/common/wayfinder/gateways/trusted-gateways.d.ts +51 -0
- package/lib/types/common/wayfinder/gateways.d.ts +16 -7
- package/lib/types/common/wayfinder/index.d.ts +4 -1
- package/lib/types/common/wayfinder/routers/priority.d.ts +8 -12
- package/lib/types/common/wayfinder/routers/{fixed.d.ts → static.d.ts} +3 -3
- package/lib/types/common/wayfinder/verification/data-root-verifier.d.ts +31 -0
- package/lib/types/common/wayfinder/verification/hash-verifier.d.ts +27 -0
- package/lib/types/common/wayfinder/wayfinder.d.ts +148 -10
- package/lib/types/types/wayfinder.d.ts +43 -0
- package/lib/types/utils/hash.d.ts +4 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
- /package/lib/types/common/wayfinder/routers/{fixed.test.d.ts → static.test.d.ts} +0 -0
|
@@ -14,20 +14,16 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { WayfinderRouter } from '../../../types/wayfinder.js';
|
|
17
|
-
import {
|
|
17
|
+
import { AoARIORead } from '../../../web/index.js';
|
|
18
|
+
import { NetworkGatewaysProvider } from '../gateways.js';
|
|
18
19
|
export declare class PriorityGatewayRouter implements WayfinderRouter {
|
|
19
20
|
readonly name = "priority";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
gatewaysProvider: GatewaysProvider;
|
|
27
|
-
limit?: number;
|
|
28
|
-
sortBy?: 'totalDelegatedStake' | 'operatorStake' | 'startTimestamp';
|
|
29
|
-
sortOrder?: 'asc' | 'desc';
|
|
30
|
-
blocklist?: string[];
|
|
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;
|
|
31
27
|
});
|
|
32
28
|
getTargetGateway(): Promise<URL>;
|
|
33
29
|
}
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { WayfinderRouter } from '../../../types/wayfinder.js';
|
|
17
|
-
export declare class
|
|
18
|
-
readonly name = "
|
|
17
|
+
export declare class StaticGatewayRouter implements WayfinderRouter {
|
|
18
|
+
readonly name = "static";
|
|
19
19
|
private gateway;
|
|
20
20
|
constructor({ gateway }: {
|
|
21
|
-
gateway:
|
|
21
|
+
gateway: string;
|
|
22
22
|
});
|
|
23
23
|
getTargetGateway(): Promise<URL>;
|
|
24
24
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { DataRootProvider, DataVerifier } from '../../../types/wayfinder.js';
|
|
3
|
+
export declare function convertBufferToDataRoot({ buffer, }: {
|
|
4
|
+
buffer: Buffer;
|
|
5
|
+
}): Promise<string>;
|
|
6
|
+
export declare const convertReadableToDataRoot: <T extends AsyncIterable<Uint8Array>>({ iterable, }: {
|
|
7
|
+
iterable: T;
|
|
8
|
+
}) => Promise<string>;
|
|
9
|
+
export declare class DataRootVerifier implements DataVerifier {
|
|
10
|
+
private readonly trustedDataRootProvider;
|
|
11
|
+
constructor({ trustedDataRootProvider, }: {
|
|
12
|
+
trustedDataRootProvider: DataRootProvider;
|
|
13
|
+
});
|
|
14
|
+
verifyData({ data, txId, }: {
|
|
15
|
+
data: Buffer | Readable | ReadableStream;
|
|
16
|
+
txId: string;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* - when you get a signature of a data item, you can only verify the owner
|
|
21
|
+
* - you still need to verify it's going back to the bundle, unpack it, and verify the data item exists at the offset
|
|
22
|
+
* - you need to the location of the chunks for the data item, and prove it's in the chunk and then prove the data root of the bundle, then you have fully verified the data verifier
|
|
23
|
+
* - how to prove the data item is on arweave - verify the merkle hash that the chunks for the data item, fit within the expected tree of the parent bundle
|
|
24
|
+
*
|
|
25
|
+
* Composite verifier - you'll want to be very efficient with streams
|
|
26
|
+
* - hash verifier
|
|
27
|
+
* - parent chunks verifier --> for any range of data within a single transaction, tell me that it's correct
|
|
28
|
+
* - signature verifier
|
|
29
|
+
* - offset verifier
|
|
30
|
+
* - data item verifier
|
|
31
|
+
*/
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { Readable } from 'node:stream';
|
|
17
|
+
import { DataHashProvider, DataVerifier } from '../../../types/wayfinder.js';
|
|
18
|
+
export declare class HashVerifier implements DataVerifier {
|
|
19
|
+
private readonly trustedHashProvider;
|
|
20
|
+
constructor({ trustedHashProvider, }: {
|
|
21
|
+
trustedHashProvider: DataHashProvider;
|
|
22
|
+
});
|
|
23
|
+
verifyData({ data, txId, }: {
|
|
24
|
+
data: Buffer | Readable | ReadableStream;
|
|
25
|
+
txId: string;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
}
|
|
@@ -13,9 +13,11 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import
|
|
16
|
+
import EventEmitter from 'node:events';
|
|
17
|
+
import { PassThrough, Readable } from 'node:stream';
|
|
18
|
+
import { DataHashProvider, DataVerifier, WayfinderRouter } from '../../types/wayfinder.js';
|
|
17
19
|
import { Logger } from '../logger.js';
|
|
18
|
-
type HttpClientArgs =
|
|
20
|
+
type HttpClientArgs = unknown[];
|
|
19
21
|
type HttpClientFunction = (...args: HttpClientArgs) => unknown;
|
|
20
22
|
type WayfinderHttpClient<T extends HttpClientFunction> = T;
|
|
21
23
|
export declare const arnsRegex: RegExp;
|
|
@@ -31,6 +33,69 @@ export declare const resolveWayfinderUrl: ({ originalUrl, targetGateway, logger,
|
|
|
31
33
|
targetGateway: () => Promise<string | URL>;
|
|
32
34
|
logger?: Logger;
|
|
33
35
|
}) => Promise<URL>;
|
|
36
|
+
/**
|
|
37
|
+
* Wayfinder event emitter with verification events
|
|
38
|
+
*/
|
|
39
|
+
export type WayfinderEvent = {
|
|
40
|
+
type: 'verification-passed';
|
|
41
|
+
txId: string;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'verification-failed';
|
|
44
|
+
txId: string;
|
|
45
|
+
error: Error;
|
|
46
|
+
} | {
|
|
47
|
+
type: 'verification-skipped';
|
|
48
|
+
originalUrl: string;
|
|
49
|
+
} | {
|
|
50
|
+
type: 'verification-progress';
|
|
51
|
+
txId: string;
|
|
52
|
+
processedBytes: number;
|
|
53
|
+
totalBytes: number;
|
|
54
|
+
} | {
|
|
55
|
+
type: 'routing-started';
|
|
56
|
+
originalUrl: string;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'routing-succeeded';
|
|
59
|
+
originalUrl: string;
|
|
60
|
+
targetGateway: string;
|
|
61
|
+
} | {
|
|
62
|
+
type: 'routing-failed';
|
|
63
|
+
originalUrl: string;
|
|
64
|
+
error: Error;
|
|
65
|
+
} | {
|
|
66
|
+
type: 'identified-transaction-id';
|
|
67
|
+
originalUrl: string;
|
|
68
|
+
targetGateway: string;
|
|
69
|
+
txId: string;
|
|
70
|
+
};
|
|
71
|
+
export interface WayfinderEventArgs {
|
|
72
|
+
onVerificationPassed?: (payload: Omit<Extract<WayfinderEvent, {
|
|
73
|
+
type: 'verification-passed';
|
|
74
|
+
}>, 'type'>) => void;
|
|
75
|
+
onVerificationFailed?: (payload: Omit<Extract<WayfinderEvent, {
|
|
76
|
+
type: 'verification-failed';
|
|
77
|
+
}>, 'type'>) => void;
|
|
78
|
+
onVerificationProgress?: (payload: Omit<Extract<WayfinderEvent, {
|
|
79
|
+
type: 'verification-progress';
|
|
80
|
+
}>, 'type'>) => void;
|
|
81
|
+
}
|
|
82
|
+
export declare class WayfinderEmitter extends EventEmitter {
|
|
83
|
+
constructor({ onVerificationPassed, onVerificationFailed, onVerificationProgress, }?: WayfinderEventArgs);
|
|
84
|
+
emit<E extends WayfinderEvent['type']>(event: E, payload: Omit<Extract<WayfinderEvent, {
|
|
85
|
+
type: E;
|
|
86
|
+
}>, 'type'>): boolean;
|
|
87
|
+
on<E extends WayfinderEvent['type']>(event: E, listener: (payload: Omit<Extract<WayfinderEvent, {
|
|
88
|
+
type: E;
|
|
89
|
+
}>, 'type'>) => void): this;
|
|
90
|
+
}
|
|
91
|
+
export declare function tapAndVerifyStream<T extends Readable | ReadableStream>({ originalStream, contentLength, verifyData, txId, emitter, }: {
|
|
92
|
+
originalStream: T;
|
|
93
|
+
contentLength: number;
|
|
94
|
+
verifyData: DataVerifier['verifyData'];
|
|
95
|
+
txId: string;
|
|
96
|
+
emitter?: WayfinderEmitter;
|
|
97
|
+
}): T extends Readable ? PassThrough : T;
|
|
98
|
+
export declare function wrapVerifiedResponse(original: Response, newBody: ReadableStream<Uint8Array>, txId: string): Response;
|
|
34
99
|
/**
|
|
35
100
|
* Creates a wrapped http client that supports ar:// protocol
|
|
36
101
|
*
|
|
@@ -44,13 +109,18 @@ export declare const resolveWayfinderUrl: ({ originalUrl, targetGateway, logger,
|
|
|
44
109
|
* @param resolveUrl - the function to construct the redirect url for ar:// requests
|
|
45
110
|
* @returns a wrapped http client that supports ar:// protocol
|
|
46
111
|
*/
|
|
47
|
-
export declare const createWayfinderClient: <T extends HttpClientFunction>({ httpClient, resolveUrl, logger, }: {
|
|
112
|
+
export declare const createWayfinderClient: <T extends HttpClientFunction>({ httpClient, resolveUrl, verifyData, emitter, logger, }: {
|
|
48
113
|
httpClient: T;
|
|
49
114
|
resolveUrl: (params: {
|
|
50
115
|
originalUrl: string | URL;
|
|
51
116
|
logger?: Logger;
|
|
52
117
|
}) => Promise<URL>;
|
|
118
|
+
verifyData?: <T_1 extends Readable | ReadableStream | Buffer>({ data, txId, }: {
|
|
119
|
+
data: T_1;
|
|
120
|
+
txId: string;
|
|
121
|
+
}) => Promise<void>;
|
|
53
122
|
logger?: Logger;
|
|
123
|
+
emitter?: WayfinderEmitter;
|
|
54
124
|
}) => WayfinderHttpClient<T>;
|
|
55
125
|
/**
|
|
56
126
|
* The main class for the wayfinder
|
|
@@ -65,21 +135,31 @@ export declare class Wayfinder<T extends HttpClientFunction> {
|
|
|
65
135
|
* @example
|
|
66
136
|
* const wayfinder = new Wayfinder({
|
|
67
137
|
* router: new RandomGatewayRouter({
|
|
68
|
-
* gatewaysProvider: new
|
|
138
|
+
* gatewaysProvider: new SimpleCacheGatewaysProvider({
|
|
139
|
+
* gatewaysProvider: new NetworkGatewaysProvider({ ario: ARIO.mainnet() }),
|
|
140
|
+
* ttlSeconds: 60 * 60 * 24, // 1 day
|
|
141
|
+
* }),
|
|
69
142
|
* }),
|
|
70
143
|
* });
|
|
144
|
+
*
|
|
145
|
+
* // Returns a target gateway based on the routing strategy
|
|
146
|
+
* const targetGateway = await wayfinder.router.getTargetGateway();
|
|
71
147
|
*/
|
|
72
148
|
readonly router: WayfinderRouter;
|
|
73
149
|
/**
|
|
74
|
-
* The http client
|
|
150
|
+
* The native http client used by wayfinder
|
|
75
151
|
*
|
|
76
152
|
* @example
|
|
77
153
|
* const wayfinder = new Wayfinder({
|
|
78
154
|
* router: new RandomGatewayRouter({
|
|
79
|
-
* gatewaysProvider: new
|
|
155
|
+
* gatewaysProvider: new SimpleCacheGatewaysProvider({
|
|
156
|
+
* gatewaysProvider: new NetworkGatewaysProvider({ ario: ARIO.mainnet() }),
|
|
157
|
+
* ttlSeconds: 60 * 60 * 24, // 1 day
|
|
158
|
+
* }),
|
|
80
159
|
* }),
|
|
81
160
|
* httpClient: axios,
|
|
82
161
|
* });
|
|
162
|
+
*
|
|
83
163
|
*/
|
|
84
164
|
readonly httpClient: T;
|
|
85
165
|
/**
|
|
@@ -88,11 +168,15 @@ export declare class Wayfinder<T extends HttpClientFunction> {
|
|
|
88
168
|
* @example
|
|
89
169
|
* const wayfinder = new Wayfinder({
|
|
90
170
|
* router: new RandomGatewayRouter({
|
|
91
|
-
* gatewaysProvider: new
|
|
171
|
+
* gatewaysProvider: new SimpleCacheGatewaysProvider({
|
|
172
|
+
* gatewaysProvider: new NetworkGatewaysProvider({ ario: ARIO.mainnet() }),
|
|
173
|
+
* ttlSeconds: 60 * 60 * 24, // 1 day
|
|
174
|
+
* }),
|
|
92
175
|
* }),
|
|
93
176
|
* httpClient: axios,
|
|
94
177
|
* });
|
|
95
178
|
*
|
|
179
|
+
* // returns the redirected URL based on the routing strategy and the original url
|
|
96
180
|
* const redirectUrl = await wayfinder.resolveUrl({ originalUrl: 'ar://example' });
|
|
97
181
|
*/
|
|
98
182
|
readonly resolveUrl: (params: {
|
|
@@ -105,7 +189,10 @@ export declare class Wayfinder<T extends HttpClientFunction> {
|
|
|
105
189
|
* @example
|
|
106
190
|
* const { request: wayfind } = new Wayfinder({
|
|
107
191
|
* router: new RandomGatewayRouter({
|
|
108
|
-
* gatewaysProvider: new
|
|
192
|
+
* gatewaysProvider: new SimpleCacheGatewaysProvider({
|
|
193
|
+
* gatewaysProvider: new NetworkGatewaysProvider({ ario: ARIO.mainnet() }),
|
|
194
|
+
* ttlSeconds: 60 * 60 * 24, // 1 day
|
|
195
|
+
* }),
|
|
109
196
|
* }),
|
|
110
197
|
* httpClient: axios,
|
|
111
198
|
* });;
|
|
@@ -118,10 +205,61 @@ export declare class Wayfinder<T extends HttpClientFunction> {
|
|
|
118
205
|
* })
|
|
119
206
|
*/
|
|
120
207
|
readonly request: WayfinderHttpClient<T>;
|
|
121
|
-
|
|
122
|
-
|
|
208
|
+
readonly verifyData: DataVerifier['verifyData'];
|
|
209
|
+
/**
|
|
210
|
+
* The event emitter for wayfinder that emits verification events.
|
|
211
|
+
*
|
|
212
|
+
* const wayfinder = new Wayfinder()
|
|
213
|
+
*
|
|
214
|
+
* wayfinder.emitter.on('verification-passed', (event) => {
|
|
215
|
+
* console.log('Verification passed!', event);
|
|
216
|
+
* })
|
|
217
|
+
*
|
|
218
|
+
* wayfinder.emitter.on('verification-failed', (event) => {
|
|
219
|
+
* console.log('Verification failed!', event);
|
|
220
|
+
* })
|
|
221
|
+
*
|
|
222
|
+
* or implement the events interface and pass it in, using callback functions
|
|
223
|
+
*
|
|
224
|
+
* const wayfinder = new Wayfinder({
|
|
225
|
+
* events: {
|
|
226
|
+
* onVerificationPassed: (event) => {
|
|
227
|
+
* console.log('Verification passed!', event);
|
|
228
|
+
* },
|
|
229
|
+
* onVerificationFailed: (event) => {
|
|
230
|
+
* console.log('Verification failed!', event);
|
|
231
|
+
* },
|
|
232
|
+
* onVerificationProgress: (event) => {
|
|
233
|
+
* console.log('Verification progress!', event);
|
|
234
|
+
* },
|
|
235
|
+
* }
|
|
236
|
+
* })
|
|
237
|
+
*
|
|
238
|
+
* const response = await wayfind('ar://example');
|
|
239
|
+
*/
|
|
240
|
+
readonly emitter: WayfinderEmitter;
|
|
241
|
+
constructor({ httpClient, router, logger, verifier, events, }: {
|
|
123
242
|
httpClient: T;
|
|
243
|
+
router?: WayfinderRouter;
|
|
124
244
|
logger?: Logger;
|
|
245
|
+
verifier?: DataVerifier;
|
|
246
|
+
hashProvider?: DataHashProvider;
|
|
247
|
+
events?: WayfinderEventArgs;
|
|
125
248
|
});
|
|
126
249
|
}
|
|
127
250
|
export {};
|
|
251
|
+
/**
|
|
252
|
+
*
|
|
253
|
+
* type | complexity | performance | security
|
|
254
|
+
* ---------|------------|-------------|---------
|
|
255
|
+
* hash | low | high | low
|
|
256
|
+
* ---------|------------|-------------|---------
|
|
257
|
+
* data root | medium | medium | low | only L1
|
|
258
|
+
* ---------|------------|-------------|---------
|
|
259
|
+
* signature | medium | medium | medium
|
|
260
|
+
* ---------|------------|-------------|---------
|
|
261
|
+
* composite | high | low | high
|
|
262
|
+
* ---------|------------|-------------|---------
|
|
263
|
+
*
|
|
264
|
+
*
|
|
265
|
+
*/
|
|
@@ -13,7 +13,50 @@
|
|
|
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';
|
|
16
17
|
export interface WayfinderRouter {
|
|
17
18
|
readonly name: string;
|
|
18
19
|
getTargetGateway: () => Promise<URL>;
|
|
19
20
|
}
|
|
21
|
+
export interface DataVerifier {
|
|
22
|
+
/**
|
|
23
|
+
* Verifies the provided data for a given txId
|
|
24
|
+
*
|
|
25
|
+
* Depending on the implementation, the hash can be the computed data root of a transaction, the digest of the data, or some other hash of the data.
|
|
26
|
+
*
|
|
27
|
+
* The interface is intended to be vague in order to support various degrees of verification.
|
|
28
|
+
*
|
|
29
|
+
* @param data - The data to verify
|
|
30
|
+
* @param txId - The txId of the data
|
|
31
|
+
* @returns the hash of the data
|
|
32
|
+
*/
|
|
33
|
+
verifyData: ({ data, txId, }: {
|
|
34
|
+
data: Buffer | Readable | ReadableStream;
|
|
35
|
+
txId: string;
|
|
36
|
+
}) => Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export interface DataHashProvider {
|
|
39
|
+
/**
|
|
40
|
+
* Returns a hash for the provided txId using the specified algorithm.
|
|
41
|
+
*
|
|
42
|
+
* @param txId - The txId of the data
|
|
43
|
+
* @returns the hash of the data
|
|
44
|
+
*/
|
|
45
|
+
getHash: ({ txId, }: {
|
|
46
|
+
txId: string;
|
|
47
|
+
}) => Promise<{
|
|
48
|
+
hash: string;
|
|
49
|
+
algorithm: 'sha256';
|
|
50
|
+
}>;
|
|
51
|
+
}
|
|
52
|
+
export interface DataRootProvider {
|
|
53
|
+
/**
|
|
54
|
+
* Returns the data root for the provided txId
|
|
55
|
+
*
|
|
56
|
+
* @param txId - The txId of the data
|
|
57
|
+
* @returns the data root of the data
|
|
58
|
+
*/
|
|
59
|
+
getDataRoot: ({ txId }: {
|
|
60
|
+
txId: string;
|
|
61
|
+
}) => Promise<string>;
|
|
62
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Readable } from 'stream';
|
|
2
|
+
export declare const hashReadableToB64Url: (stream: Readable, algorithm?: string) => Promise<string>;
|
|
3
|
+
export declare const hashReadableStreamToB64Url: (stream: ReadableStream, algorithm?: string) => Promise<string>;
|
|
4
|
+
export declare const hashBufferToB64Url: (buffer: Buffer, algorithm?: string) => string;
|
package/lib/types/version.d.ts
CHANGED
package/package.json
CHANGED
|
File without changes
|