@ar.io/sdk 3.10.0-alpha.6 → 3.10.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 +66 -125
- package/bundles/web.bundle.min.js +147 -126
- package/lib/cjs/cli/commands/antCommands.js +3 -4
- package/lib/cjs/cli/commands/arnsPurchaseCommands.js +5 -6
- package/lib/cjs/cli/commands/gatewayWriteCommands.js +11 -12
- package/lib/cjs/cli/commands/readCommands.js +21 -22
- package/lib/cjs/cli/commands/transfer.js +6 -7
- package/lib/cjs/cli/options.js +0 -12
- package/lib/cjs/cli/utils.js +52 -74
- package/lib/cjs/common/ant-versions.js +5 -5
- package/lib/cjs/common/faucet.js +2 -2
- package/lib/cjs/common/index.js +0 -2
- package/lib/cjs/common/io.js +5 -64
- package/lib/cjs/types/ant.js +2 -13
- package/lib/cjs/types/index.js +0 -1
- package/lib/cjs/types/io.js +5 -5
- package/lib/cjs/utils/ao.js +9 -14
- package/lib/cjs/utils/arweave.js +4 -4
- package/lib/cjs/utils/base64.js +4 -5
- package/lib/cjs/utils/json.js +1 -2
- package/lib/cjs/utils/schema.js +1 -2
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/web/index.js +1 -3
- package/lib/esm/cli/options.js +0 -12
- package/lib/esm/cli/utils.js +10 -31
- package/lib/esm/common/ant-versions.js +5 -5
- package/lib/esm/common/index.js +0 -2
- package/lib/esm/common/io.js +5 -64
- package/lib/esm/types/ant.js +0 -11
- package/lib/esm/types/index.js +0 -1
- package/lib/esm/types/io.js +1 -1
- package/lib/esm/utils/ao.js +0 -5
- package/lib/esm/version.js +1 -1
- package/lib/esm/web/index.js +1 -1
- package/lib/types/cli/commands/antCommands.d.ts +3 -3
- package/lib/types/cli/commands/arnsPurchaseCommands.d.ts +1 -1
- package/lib/types/cli/commands/gatewayWriteCommands.d.ts +9 -9
- package/lib/types/cli/commands/readCommands.d.ts +3 -4
- package/lib/types/cli/commands/transfer.d.ts +3 -3
- package/lib/types/cli/options.d.ts +0 -9
- package/lib/types/cli/types.d.ts +0 -3
- package/lib/types/cli/utils.d.ts +0 -4
- package/lib/types/common/ant-versions.d.ts +6 -3
- package/lib/types/common/http.d.ts +0 -1
- package/lib/types/common/index.d.ts +0 -1
- package/lib/types/common/io.d.ts +9 -15
- package/lib/types/types/ant.d.ts +1 -53
- package/lib/types/types/common.d.ts +2 -8
- package/lib/types/types/index.d.ts +0 -1
- package/lib/types/types/io.d.ts +7 -9
- package/lib/types/types/token.d.ts +0 -2
- package/lib/types/utils/ao.d.ts +12 -1
- package/lib/types/utils/base64.d.ts +0 -2
- package/lib/types/version.d.ts +1 -1
- package/lib/types/web/index.d.ts +1 -1
- package/package.json +3 -5
- package/lib/cjs/common/turbo.js +0 -208
- package/lib/cjs/common/wayfinder/gateways.js +0 -75
- package/lib/cjs/common/wayfinder/index.js +0 -36
- package/lib/cjs/common/wayfinder/routers/fixed.js +0 -14
- package/lib/cjs/common/wayfinder/routers/fixed.test.js +0 -14
- package/lib/cjs/common/wayfinder/routers/priority.js +0 -38
- package/lib/cjs/common/wayfinder/routers/priority.test.js +0 -155
- package/lib/cjs/common/wayfinder/routers/random.js +0 -23
- package/lib/cjs/common/wayfinder/routers/random.test.js +0 -104
- package/lib/cjs/common/wayfinder/routers/simple-cache.js +0 -25
- package/lib/cjs/common/wayfinder/routers/simple-cache.test.js +0 -41
- package/lib/cjs/common/wayfinder/wayfinder.js +0 -194
- package/lib/cjs/common/wayfinder/wayfinder.test.js +0 -254
- package/lib/cjs/types/wayfinder.js +0 -2
- package/lib/cjs/utils/url.js +0 -28
- package/lib/cjs/utils/url.test.js +0 -24
- package/lib/esm/common/turbo.js +0 -200
- package/lib/esm/common/wayfinder/gateways.js +0 -69
- package/lib/esm/common/wayfinder/index.js +0 -20
- package/lib/esm/common/wayfinder/routers/fixed.js +0 -10
- package/lib/esm/common/wayfinder/routers/fixed.test.js +0 -12
- package/lib/esm/common/wayfinder/routers/priority.js +0 -34
- package/lib/esm/common/wayfinder/routers/priority.test.js +0 -153
- package/lib/esm/common/wayfinder/routers/random.js +0 -19
- package/lib/esm/common/wayfinder/routers/random.test.js +0 -102
- package/lib/esm/common/wayfinder/routers/simple-cache.js +0 -21
- package/lib/esm/common/wayfinder/routers/simple-cache.test.js +0 -39
- package/lib/esm/common/wayfinder/wayfinder.js +0 -187
- package/lib/esm/common/wayfinder/wayfinder.test.js +0 -249
- package/lib/esm/types/wayfinder.js +0 -1
- package/lib/esm/utils/url.js +0 -24
- package/lib/esm/utils/url.test.js +0 -19
- package/lib/types/common/turbo.d.ts +0 -62
- package/lib/types/common/wayfinder/gateways.d.ts +0 -44
- package/lib/types/common/wayfinder/index.d.ts +0 -19
- package/lib/types/common/wayfinder/routers/fixed.d.ts +0 -25
- package/lib/types/common/wayfinder/routers/fixed.test.d.ts +0 -1
- package/lib/types/common/wayfinder/routers/priority.d.ts +0 -34
- package/lib/types/common/wayfinder/routers/priority.test.d.ts +0 -1
- package/lib/types/common/wayfinder/routers/random.d.ts +0 -28
- package/lib/types/common/wayfinder/routers/random.test.d.ts +0 -1
- package/lib/types/common/wayfinder/routers/simple-cache.d.ts +0 -29
- package/lib/types/common/wayfinder/routers/simple-cache.test.d.ts +0 -1
- package/lib/types/common/wayfinder/wayfinder.d.ts +0 -106
- package/lib/types/common/wayfinder/wayfinder.test.d.ts +0 -1
- package/lib/types/types/wayfinder.d.ts +0 -20
- package/lib/types/utils/url.d.ts +0 -19
- package/lib/types/utils/url.test.d.ts +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { WayfinderRouter } from '../../../types/wayfinder.js';
|
|
18
|
-
import { GatewaysProvider } from '../gateways.js';
|
|
19
|
-
export declare class RandomGatewayRouter implements WayfinderRouter {
|
|
20
|
-
readonly name = "random";
|
|
21
|
-
private gatewaysProvider;
|
|
22
|
-
private blocklist;
|
|
23
|
-
constructor({ gatewaysProvider, blocklist, }: {
|
|
24
|
-
gatewaysProvider: GatewaysProvider;
|
|
25
|
-
blocklist?: string[];
|
|
26
|
-
});
|
|
27
|
-
getTargetGateway(): Promise<URL>;
|
|
28
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
import { WayfinderRouter } from '../../../types/wayfinder.js';
|
|
18
|
-
export declare class SimpleCacheRouter implements WayfinderRouter {
|
|
19
|
-
readonly name: 'simple-cache';
|
|
20
|
-
private lastUpdatedTimestamp;
|
|
21
|
-
private ttlSeconds;
|
|
22
|
-
private targetGateway;
|
|
23
|
-
private router;
|
|
24
|
-
constructor({ router, ttlSeconds, }: {
|
|
25
|
-
router: WayfinderRouter;
|
|
26
|
-
ttlSeconds?: number;
|
|
27
|
-
});
|
|
28
|
-
getTargetGateway(): Promise<URL>;
|
|
29
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { WayfinderRouter } from '../../types/wayfinder.js';
|
|
3
|
-
type AnyFunction = (...args: [string, ...unknown[]]) => unknown;
|
|
4
|
-
type WayfinderHttpClient<T extends AnyFunction> = T;
|
|
5
|
-
export declare const arnsRegex: RegExp;
|
|
6
|
-
export declare const txIdRegex: RegExp;
|
|
7
|
-
/**
|
|
8
|
-
* Cryptographically secure helper for randomness, does not support seeding
|
|
9
|
-
* @param min - the minimum value
|
|
10
|
-
* @param max - the maximum value
|
|
11
|
-
* @returns a random integer between min and max
|
|
12
|
-
*/
|
|
13
|
-
export declare const randomInt: (min: number, max: number) => number;
|
|
14
|
-
/**
|
|
15
|
-
* Core function to resolve a wayfinder url against a target gateway
|
|
16
|
-
* @param originalUrl - the wayfinder url to resolve
|
|
17
|
-
* @param targetGateway - the target gateway to resolve the url against
|
|
18
|
-
* @returns the resolved url that can be used to make a request
|
|
19
|
-
*/
|
|
20
|
-
export declare const resolveWayfinderUrl: ({ originalUrl, targetGateway, }: {
|
|
21
|
-
originalUrl: string | URL;
|
|
22
|
-
targetGateway: string | URL;
|
|
23
|
-
}) => URL;
|
|
24
|
-
/**
|
|
25
|
-
* Creates a wrapped http client that supports ar:// protocol
|
|
26
|
-
*
|
|
27
|
-
* This function leverages a Proxy to intercept calls to the http client
|
|
28
|
-
* and redirects them to the target gateway using the resolveUrl function url.
|
|
29
|
-
* It also supports the http client methods like get(), post(), put(), delete(), etc.
|
|
30
|
-
*
|
|
31
|
-
* Any URLs provided that are not wayfinder urls will be returned as is.
|
|
32
|
-
*
|
|
33
|
-
* @param httpClient - the http client to wrap (e.g. axios, fetch, got, etc.)
|
|
34
|
-
* @param resolveUrl - the function to construct the redirect url for ar:// requests
|
|
35
|
-
* @returns a wrapped http client that supports ar:// protocol
|
|
36
|
-
*/
|
|
37
|
-
export declare const createWayfinderClient: <T extends AnyFunction>({ httpClient, resolveUrl, }: {
|
|
38
|
-
httpClient: T;
|
|
39
|
-
resolveUrl: (params: {
|
|
40
|
-
originalUrl: string | URL;
|
|
41
|
-
}) => Promise<URL>;
|
|
42
|
-
}) => WayfinderHttpClient<T>;
|
|
43
|
-
/**
|
|
44
|
-
* The main class for the wayfinder
|
|
45
|
-
* @param router - the router to use for requests
|
|
46
|
-
* @param httpClient - the http client to use for requests
|
|
47
|
-
* @param blocklist - the blocklist of gateways to avoid
|
|
48
|
-
*/
|
|
49
|
-
export declare class Wayfinder<T extends AnyFunction> {
|
|
50
|
-
/**
|
|
51
|
-
* The router to use for requests
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* const wayfinder = new Wayfinder({
|
|
55
|
-
* router: new RandomGatewayRouter({ ario: ARIO.mainnet() }),
|
|
56
|
-
* });
|
|
57
|
-
*/
|
|
58
|
-
readonly router: WayfinderRouter;
|
|
59
|
-
/**
|
|
60
|
-
* The http client to use for requests
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* const wayfinder = new Wayfinder({
|
|
64
|
-
* router: new RandomGatewayRouter({ ario: ARIO.mainnet() }),
|
|
65
|
-
* httpClient: axios,
|
|
66
|
-
* });
|
|
67
|
-
*/
|
|
68
|
-
readonly httpClient: T;
|
|
69
|
-
/**
|
|
70
|
-
* The function that resolves the redirect url for ar:// requests to a target gateway
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* const wayfinder = new Wayfinder({
|
|
74
|
-
* router: new RandomGatewayRouter({ ario: ARIO.mainnet() }),
|
|
75
|
-
* httpClient: axios,
|
|
76
|
-
* });
|
|
77
|
-
*
|
|
78
|
-
* const redirectUrl = await wayfinder.resolveUrl({ originalUrl: 'ar://example' });
|
|
79
|
-
*/
|
|
80
|
-
readonly resolveUrl: (params: {
|
|
81
|
-
originalUrl: string;
|
|
82
|
-
}) => Promise<URL>;
|
|
83
|
-
/**
|
|
84
|
-
* A wrapped http client that supports ar:// protocol
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* const { request: wayfind } = new Wayfinder({
|
|
88
|
-
* router: new RandomGatewayRouter({ ario: ARIO.mainnet() }),
|
|
89
|
-
* httpClient: axios,
|
|
90
|
-
* });;
|
|
91
|
-
*
|
|
92
|
-
* TODO: consider a top level function that supports wayfinder routing under the hood
|
|
93
|
-
* const response = await wayfind('ar://', {
|
|
94
|
-
* method: 'POST',
|
|
95
|
-
* data: {
|
|
96
|
-
* name: 'John Doe',
|
|
97
|
-
* },
|
|
98
|
-
* })
|
|
99
|
-
*/
|
|
100
|
-
readonly request: WayfinderHttpClient<T>;
|
|
101
|
-
constructor({ router, httpClient, }: {
|
|
102
|
-
router: WayfinderRouter;
|
|
103
|
-
httpClient: T;
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
export interface WayfinderRouter {
|
|
18
|
-
readonly name: string;
|
|
19
|
-
getTargetGateway: () => Promise<URL>;
|
|
20
|
-
}
|
package/lib/types/utils/url.d.ts
DELETED
|
@@ -1,19 +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 declare const urlWithSearchParams: ({ baseUrl, params, }: {
|
|
17
|
-
baseUrl: string;
|
|
18
|
-
params: Record<string, string | number | boolean | null | undefined>;
|
|
19
|
-
}) => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|