@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.
Files changed (68) hide show
  1. package/README.md +28 -1
  2. package/bundles/web.bundle.min.js +142 -147
  3. package/lib/cjs/cli/commands/arnsPurchaseCommands.js +10 -0
  4. package/lib/cjs/cli/options.js +5 -0
  5. package/lib/cjs/cli/utils.js +4 -0
  6. package/lib/cjs/common/index.js +2 -0
  7. package/lib/cjs/common/io.js +4 -0
  8. package/lib/cjs/common/turbo.js +2 -1
  9. package/lib/cjs/common/wayfinder/gateways/network.js +48 -0
  10. package/lib/cjs/common/wayfinder/gateways/simple-cache.js +35 -0
  11. package/lib/cjs/common/wayfinder/gateways/static.js +13 -0
  12. package/lib/cjs/common/wayfinder/index.js +48 -0
  13. package/lib/cjs/common/wayfinder/routing/strategies/ping.js +72 -0
  14. package/lib/cjs/common/wayfinder/routing/strategies/preferred-with-fallback.js +50 -0
  15. package/lib/cjs/common/wayfinder/routing/strategies/random.js +13 -0
  16. package/lib/cjs/common/wayfinder/routing/strategies/round-robin.js +42 -0
  17. package/lib/cjs/common/wayfinder/routing/strategies/static.js +29 -0
  18. package/lib/cjs/common/wayfinder/verification/strategies/data-root-verifier.js +110 -0
  19. package/lib/cjs/common/wayfinder/verification/strategies/hash-verifier.js +27 -0
  20. package/lib/cjs/common/wayfinder/verification/trusted.js +125 -0
  21. package/lib/cjs/common/wayfinder/wayfinder.js +508 -0
  22. package/lib/cjs/types/wayfinder.js +3 -0
  23. package/lib/cjs/utils/hash.js +83 -31
  24. package/lib/cjs/version.js +1 -1
  25. package/lib/esm/cli/commands/arnsPurchaseCommands.js +11 -1
  26. package/lib/esm/cli/options.js +5 -0
  27. package/lib/esm/cli/utils.js +3 -0
  28. package/lib/esm/common/index.js +2 -0
  29. package/lib/esm/common/io.js +4 -0
  30. package/lib/esm/common/turbo.js +2 -1
  31. package/lib/esm/common/wayfinder/gateways/network.js +44 -0
  32. package/lib/esm/common/wayfinder/gateways/simple-cache.js +31 -0
  33. package/lib/esm/common/wayfinder/gateways/static.js +9 -0
  34. package/lib/esm/common/wayfinder/index.js +32 -0
  35. package/lib/esm/common/wayfinder/routing/strategies/ping.js +68 -0
  36. package/lib/esm/common/wayfinder/routing/strategies/preferred-with-fallback.js +46 -0
  37. package/lib/esm/common/wayfinder/routing/strategies/random.js +9 -0
  38. package/lib/esm/common/wayfinder/routing/strategies/round-robin.js +38 -0
  39. package/lib/esm/common/wayfinder/routing/strategies/static.js +25 -0
  40. package/lib/esm/common/wayfinder/verification/strategies/data-root-verifier.js +102 -0
  41. package/lib/esm/common/wayfinder/verification/strategies/hash-verifier.js +23 -0
  42. package/lib/esm/common/wayfinder/verification/trusted.js +121 -0
  43. package/lib/esm/common/wayfinder/wayfinder.js +499 -0
  44. package/lib/esm/types/wayfinder.js +2 -0
  45. package/lib/esm/utils/hash.js +74 -27
  46. package/lib/esm/version.js +1 -1
  47. package/lib/types/cli/options.d.ts +4 -0
  48. package/lib/types/cli/utils.d.ts +3 -0
  49. package/lib/types/common/index.d.ts +1 -0
  50. package/lib/types/common/turbo.d.ts +2 -1
  51. package/lib/types/common/wayfinder/gateways/network.d.ts +33 -0
  52. package/lib/types/common/wayfinder/gateways/simple-cache.d.ts +31 -0
  53. package/lib/types/common/wayfinder/gateways/static.d.ts +23 -0
  54. package/lib/types/common/wayfinder/index.d.ts +27 -0
  55. package/lib/types/common/wayfinder/routing/strategies/ping.d.ts +27 -0
  56. package/lib/types/common/wayfinder/routing/strategies/preferred-with-fallback.d.ts +31 -0
  57. package/lib/types/common/wayfinder/routing/strategies/random.d.ts +21 -0
  58. package/lib/types/common/wayfinder/routing/strategies/round-robin.d.ts +29 -0
  59. package/lib/types/common/wayfinder/routing/strategies/static.d.ts +29 -0
  60. package/lib/types/common/wayfinder/verification/strategies/data-root-verifier.d.ts +27 -0
  61. package/lib/types/common/wayfinder/verification/strategies/hash-verifier.d.ts +26 -0
  62. package/lib/types/common/wayfinder/verification/trusted.d.ts +51 -0
  63. package/lib/types/common/wayfinder/wayfinder.d.ts +257 -0
  64. package/lib/types/types/io.d.ts +4 -0
  65. package/lib/types/types/wayfinder.d.ts +66 -0
  66. package/lib/types/utils/hash.d.ts +8 -4
  67. package/lib/types/version.d.ts +1 -1
  68. 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 { 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;
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>;
@@ -13,4 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const version = "3.12.1";
16
+ export declare const version = "3.13.0-alpha.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.12.2",
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"