@ar.io/sdk 3.12.2 → 3.13.0-beta.1
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/README.md +28 -1
- package/bundles/web.bundle.min.js +142 -147
- package/lib/cjs/cli/commands/arnsPurchaseCommands.js +10 -0
- package/lib/cjs/cli/options.js +5 -0
- package/lib/cjs/cli/utils.js +4 -0
- package/lib/cjs/common/index.js +2 -0
- package/lib/cjs/common/io.js +4 -0
- package/lib/cjs/common/turbo.js +2 -1
- package/lib/cjs/common/wayfinder/gateways/network.js +48 -0
- package/lib/cjs/common/wayfinder/gateways/simple-cache.js +35 -0
- package/lib/cjs/common/wayfinder/gateways/static.js +13 -0
- package/lib/cjs/common/wayfinder/index.js +48 -0
- package/lib/cjs/common/wayfinder/routing/strategies/ping.js +72 -0
- package/lib/cjs/common/wayfinder/routing/strategies/preferred-with-fallback.js +50 -0
- package/lib/cjs/common/wayfinder/routing/strategies/random.js +13 -0
- package/lib/cjs/common/wayfinder/routing/strategies/round-robin.js +42 -0
- package/lib/cjs/common/wayfinder/routing/strategies/static.js +29 -0
- package/lib/cjs/common/wayfinder/verification/strategies/data-root-verifier.js +110 -0
- package/lib/cjs/common/wayfinder/verification/strategies/hash-verifier.js +27 -0
- package/lib/cjs/common/wayfinder/verification/trusted.js +125 -0
- package/lib/cjs/common/wayfinder/wayfinder.js +508 -0
- package/lib/cjs/types/wayfinder.js +3 -0
- package/lib/cjs/utils/hash.js +83 -31
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/commands/arnsPurchaseCommands.js +11 -1
- package/lib/esm/cli/options.js +5 -0
- package/lib/esm/cli/utils.js +3 -0
- package/lib/esm/common/index.js +2 -0
- package/lib/esm/common/io.js +4 -0
- package/lib/esm/common/turbo.js +2 -1
- package/lib/esm/common/wayfinder/gateways/network.js +44 -0
- package/lib/esm/common/wayfinder/gateways/simple-cache.js +31 -0
- package/lib/esm/common/wayfinder/gateways/static.js +9 -0
- package/lib/esm/common/wayfinder/index.js +32 -0
- package/lib/esm/common/wayfinder/routing/strategies/ping.js +68 -0
- package/lib/esm/common/wayfinder/routing/strategies/preferred-with-fallback.js +46 -0
- package/lib/esm/common/wayfinder/routing/strategies/random.js +9 -0
- package/lib/esm/common/wayfinder/routing/strategies/round-robin.js +38 -0
- package/lib/esm/common/wayfinder/routing/strategies/static.js +25 -0
- package/lib/esm/common/wayfinder/verification/strategies/data-root-verifier.js +102 -0
- package/lib/esm/common/wayfinder/verification/strategies/hash-verifier.js +23 -0
- package/lib/esm/common/wayfinder/verification/trusted.js +121 -0
- package/lib/esm/common/wayfinder/wayfinder.js +499 -0
- package/lib/esm/types/wayfinder.js +2 -0
- package/lib/esm/utils/hash.js +74 -27
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/options.d.ts +4 -0
- package/lib/types/cli/utils.d.ts +3 -0
- package/lib/types/common/index.d.ts +1 -0
- package/lib/types/common/turbo.d.ts +2 -1
- package/lib/types/common/wayfinder/gateways/network.d.ts +33 -0
- package/lib/types/common/wayfinder/gateways/simple-cache.d.ts +31 -0
- package/lib/types/common/wayfinder/gateways/static.d.ts +23 -0
- package/lib/types/common/wayfinder/index.d.ts +27 -0
- package/lib/types/common/wayfinder/routing/strategies/ping.d.ts +27 -0
- package/lib/types/common/wayfinder/routing/strategies/preferred-with-fallback.d.ts +31 -0
- package/lib/types/common/wayfinder/routing/strategies/random.d.ts +21 -0
- package/lib/types/common/wayfinder/routing/strategies/round-robin.d.ts +29 -0
- package/lib/types/common/wayfinder/routing/strategies/static.d.ts +29 -0
- package/lib/types/common/wayfinder/verification/strategies/data-root-verifier.d.ts +27 -0
- package/lib/types/common/wayfinder/verification/strategies/hash-verifier.d.ts +26 -0
- package/lib/types/common/wayfinder/verification/trusted.d.ts +51 -0
- package/lib/types/common/wayfinder/wayfinder.d.ts +257 -0
- package/lib/types/types/io.d.ts +4 -0
- package/lib/types/types/wayfinder.d.ts +66 -0
- package/lib/types/utils/hash.d.ts +8 -4
- package/lib/types/version.d.ts +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,66 @@
|
|
|
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 interface RoutingStrategy {
|
|
17
|
+
selectGateway: ({ gateways }: {
|
|
18
|
+
gateways: URL[];
|
|
19
|
+
}) => Promise<URL>;
|
|
20
|
+
}
|
|
21
|
+
export interface GatewaysProvider {
|
|
22
|
+
getGateways: () => Promise<URL[]>;
|
|
23
|
+
}
|
|
24
|
+
export type DataStream = AsyncIterable<Uint8Array> | ReadableStream<Uint8Array>;
|
|
25
|
+
export interface DataVerificationStrategy {
|
|
26
|
+
/**
|
|
27
|
+
* Verifies the provided data for a given txId
|
|
28
|
+
*
|
|
29
|
+
* 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.
|
|
30
|
+
*
|
|
31
|
+
* The interface is intended to be vague in order to support various degrees of verification.
|
|
32
|
+
*
|
|
33
|
+
* @param data - The data to verify
|
|
34
|
+
* @param txId - The txId of the data
|
|
35
|
+
* @returns the hash of the data
|
|
36
|
+
*/
|
|
37
|
+
verifyData: ({ data, txId, }: {
|
|
38
|
+
data: DataStream;
|
|
39
|
+
txId: string;
|
|
40
|
+
}) => Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export interface DataHashProvider {
|
|
43
|
+
/**
|
|
44
|
+
* Returns a hash for the provided txId using the specified algorithm.
|
|
45
|
+
*
|
|
46
|
+
* @param txId - The txId of the data
|
|
47
|
+
* @returns the hash of the data
|
|
48
|
+
*/
|
|
49
|
+
getHash: ({ txId, }: {
|
|
50
|
+
txId: string;
|
|
51
|
+
}) => Promise<{
|
|
52
|
+
hash: string;
|
|
53
|
+
algorithm: 'sha256';
|
|
54
|
+
}>;
|
|
55
|
+
}
|
|
56
|
+
export interface DataRootProvider {
|
|
57
|
+
/**
|
|
58
|
+
* Returns the data root for the provided txId
|
|
59
|
+
*
|
|
60
|
+
* @param txId - The txId of the data
|
|
61
|
+
* @returns the data root of the data
|
|
62
|
+
*/
|
|
63
|
+
getDataRoot: ({ txId }: {
|
|
64
|
+
txId: string;
|
|
65
|
+
}) => Promise<string>;
|
|
66
|
+
}
|
|
@@ -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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ar.io/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0-beta.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/ar-io/ar-io-sdk.git"
|
|
@@ -136,6 +136,7 @@
|
|
|
136
136
|
"eventemitter3": "^5.0.1",
|
|
137
137
|
"plimit-lit": "^3.0.1",
|
|
138
138
|
"prompts": "^2.4.2",
|
|
139
|
+
"rfc4648": "^1.5.4",
|
|
139
140
|
"uuid": "^11.1.0",
|
|
140
141
|
"winston": "^3.13.0",
|
|
141
142
|
"zod": "^3.23.8"
|