@ar.io/sdk 3.11.0-alpha.8 → 3.11.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 +52 -0
- package/bundles/web.bundle.min.js +106 -106
- package/lib/cjs/cli/cli.js +137 -122
- package/lib/cjs/cli/commands/readCommands.js +6 -0
- package/lib/cjs/cli/utils.js +4 -1
- package/lib/cjs/common/ant.js +5 -5
- package/lib/cjs/common/contracts/ao-process.js +2 -1
- package/lib/cjs/common/io.js +37 -0
- package/lib/cjs/common/wayfinder/{gateways.js → gateways/network.js} +3 -41
- 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 +11 -8
- package/lib/cjs/common/wayfinder/routing/strategies/ping.js +72 -0
- package/lib/cjs/common/wayfinder/routing/strategies/ping.test.js +156 -0
- package/lib/cjs/common/wayfinder/routing/strategies/random.js +13 -0
- package/lib/cjs/common/wayfinder/routing/strategies/random.test.js +68 -0
- package/lib/cjs/common/wayfinder/routing/strategies/round-robin.js +42 -0
- package/lib/cjs/common/wayfinder/routing/strategies/round-robin.test.js +78 -0
- package/lib/cjs/common/wayfinder/routing/strategies/static.js +29 -0
- package/lib/cjs/common/wayfinder/routing/strategies/static.test.js +40 -0
- package/lib/cjs/common/wayfinder/verification/{data-root-verifier.js → strategies/data-root-verifier.js} +4 -4
- package/lib/cjs/common/wayfinder/verification/{hash-verifier.js → strategies/hash-verifier.js} +4 -4
- package/lib/cjs/common/wayfinder/{gateways/trusted-gateways.js → verification/trusted.js} +1 -1
- package/lib/cjs/common/wayfinder/wayfinder.js +397 -257
- package/lib/cjs/common/wayfinder/wayfinder.test.js +227 -208
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +138 -123
- package/lib/esm/cli/commands/readCommands.js +5 -0
- package/lib/esm/cli/utils.js +4 -1
- package/lib/esm/common/ant.js +5 -5
- package/lib/esm/common/contracts/ao-process.js +2 -1
- package/lib/esm/common/io.js +37 -0
- package/lib/esm/common/wayfinder/{gateways.js → gateways/network.js} +2 -38
- 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 +11 -8
- package/lib/esm/common/wayfinder/routing/strategies/ping.js +68 -0
- package/lib/esm/common/wayfinder/routing/strategies/ping.test.js +151 -0
- package/lib/esm/common/wayfinder/routing/strategies/random.js +9 -0
- package/lib/esm/common/wayfinder/routing/strategies/random.test.js +63 -0
- package/lib/esm/common/wayfinder/routing/strategies/round-robin.js +38 -0
- package/lib/esm/common/wayfinder/routing/strategies/round-robin.test.js +73 -0
- package/lib/esm/common/wayfinder/routing/strategies/static.js +25 -0
- package/lib/esm/common/wayfinder/routing/strategies/static.test.js +35 -0
- package/lib/esm/common/wayfinder/verification/{data-root-verifier.js → strategies/data-root-verifier.js} +2 -2
- package/lib/esm/common/wayfinder/verification/{hash-verifier.js → strategies/hash-verifier.js} +2 -2
- package/lib/esm/common/wayfinder/{gateways/trusted-gateways.js → verification/trusted.js} +1 -1
- package/lib/esm/common/wayfinder/wayfinder.js +395 -255
- package/lib/esm/common/wayfinder/wayfinder.test.js +227 -208
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/readCommands.d.ts +1 -0
- package/lib/types/common/io.d.ts +5 -2
- package/lib/types/common/wayfinder/{gateways.d.ts → gateways/network.d.ts} +3 -23
- package/lib/types/common/wayfinder/{routers/random.d.ts → gateways/simple-cache.d.ts} +12 -8
- package/lib/types/common/wayfinder/{routers → gateways}/static.d.ts +6 -7
- package/lib/types/common/wayfinder/index.d.ts +10 -7
- package/lib/types/common/wayfinder/{routers/simple-cache.d.ts → routing/strategies/ping.d.ts} +10 -11
- 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/{data-root-verifier.d.ts → strategies/data-root-verifier.d.ts} +2 -2
- package/lib/types/common/wayfinder/verification/{hash-verifier.d.ts → strategies/hash-verifier.d.ts} +2 -2
- package/lib/types/common/wayfinder/{gateways/trusted-gateways.d.ts → verification/trusted.d.ts} +1 -1
- package/lib/types/common/wayfinder/wayfinder.d.ts +111 -77
- package/lib/types/types/io.d.ts +16 -1
- package/lib/types/types/wayfinder.d.ts +8 -4
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/lib/cjs/common/wayfinder/routers/priority.js +0 -29
- 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 -25
- 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/routers/static.js +0 -14
- package/lib/cjs/common/wayfinder/routers/static.test.js +0 -14
- package/lib/esm/common/wayfinder/routers/priority.js +0 -25
- 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 -23
- 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/routers/static.js +0 -10
- package/lib/esm/common/wayfinder/routers/static.test.js +0 -12
- package/lib/types/common/wayfinder/routers/priority.d.ts +0 -29
- /package/lib/types/common/wayfinder/{routers/priority.test.d.ts → routing/strategies/ping.test.d.ts} +0 -0
- /package/lib/types/common/wayfinder/{routers → routing/strategies}/random.test.d.ts +0 -0
- /package/lib/types/common/wayfinder/{routers/simple-cache.test.d.ts → routing/strategies/round-robin.test.d.ts} +0 -0
- /package/lib/types/common/wayfinder/{routers → routing/strategies}/static.test.d.ts +0 -0
package/lib/types/common/io.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Arweave from 'arweave';
|
|
2
|
-
import { ARIOWithFaucet, AoARIORead, AoARIOWrite, AoAllDelegates, AoAllGatewayVaults, AoArNSNameData, AoArNSNameDataWithName, AoArNSPurchaseParams, AoArNSReservedNameData, AoArNSReservedNameDataWithName, AoBalanceWithAddress, AoBuyRecordParams, AoCreateVaultParams, AoDelegation, AoEligibleDistribution, AoEpochData, AoEpochDistributed, AoEpochDistributionData, AoEpochDistributionTotalsData, AoEpochObservationData, AoEpochSettings, AoExtendLeaseParams, AoExtendVaultParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGatewayWithAddress, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoIncreaseVaultParams, AoJoinNetworkParams, AoMessageResult, AoPaginatedAddressParams, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, AoRegistrationFees, AoReturnedName, AoRevokeVaultParams, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoVaultData, AoVaultedTransferParams, AoWalletVault, AoWeightedObserver, CostDetailsResult, DemandFactorSettings, EpochInput, OptionalArweave, OptionalPaymentUrl, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions, mARIOToken } from '../types/index.js';
|
|
2
|
+
import { ARIOWithFaucet, AoARIORead, AoARIOWrite, AoAllDelegates, AoAllGatewayVaults, AoArNSNameData, AoArNSNameDataWithName, AoArNSPurchaseParams, AoArNSReservedNameData, AoArNSReservedNameDataWithName, AoBalanceWithAddress, AoBuyRecordParams, AoCreateVaultParams, AoDelegation, AoEligibleDistribution, AoEpochData, AoEpochDistributed, AoEpochDistributionData, AoEpochDistributionTotalsData, AoEpochObservationData, AoEpochSettings, AoExtendLeaseParams, AoExtendVaultParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGatewayWithAddress, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoIncreaseVaultParams, AoJoinNetworkParams, AoMessageResult, AoPaginatedAddressParams, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, AoRegistrationFees, AoReturnedName, AoRevokeVaultParams, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoVaultData, AoVaultedTransferParams, AoWalletVault, AoWeightedObserver, ArNSNameResolutionData, ArNSNameResolver, CostDetailsResult, DemandFactorSettings, EpochInput, OptionalArweave, OptionalPaymentUrl, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions, mARIOToken } from '../types/index.js';
|
|
3
3
|
import { AOProcess } from './contracts/ao-process.js';
|
|
4
4
|
import { TurboArNSPaymentProviderAuthenticated, TurboArNSPaymentProviderUnauthenticated } from './turbo.js';
|
|
5
5
|
type ARIOConfigNoSigner = OptionalPaymentUrl<OptionalArweave<ProcessConfiguration>>;
|
|
@@ -19,7 +19,7 @@ export declare class ARIO {
|
|
|
19
19
|
faucetUrl?: string;
|
|
20
20
|
}): ARIOWithFaucet<AoARIOWrite>;
|
|
21
21
|
}
|
|
22
|
-
export declare class ARIOReadable implements AoARIORead {
|
|
22
|
+
export declare class ARIOReadable implements AoARIORead, ArNSNameResolver {
|
|
23
23
|
readonly process: AOProcess;
|
|
24
24
|
protected epochSettings: AoEpochSettings | undefined;
|
|
25
25
|
protected arweave: Arweave;
|
|
@@ -135,6 +135,9 @@ export declare class ARIOReadable implements AoARIORead {
|
|
|
135
135
|
getGatewayRegistrySettings(): Promise<AoGatewayRegistrySettings>;
|
|
136
136
|
getAllDelegates(params?: PaginationParams<AoAllDelegates>): Promise<PaginationResult<AoAllDelegates>>;
|
|
137
137
|
getAllGatewayVaults(params?: PaginationParams<AoAllGatewayVaults>): Promise<PaginationResult<AoAllGatewayVaults>>;
|
|
138
|
+
resolveArNSName({ name, }: {
|
|
139
|
+
name: string;
|
|
140
|
+
}): Promise<ArNSNameResolutionData>;
|
|
138
141
|
}
|
|
139
142
|
export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
|
|
140
143
|
private signer;
|
|
@@ -13,10 +13,8 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { AoARIORead, AoGatewayWithAddress } from '
|
|
17
|
-
|
|
18
|
-
getGateways(): Promise<URL[]>;
|
|
19
|
-
}
|
|
16
|
+
import { AoARIORead, AoGatewayWithAddress } from '../../../types/io.js';
|
|
17
|
+
import { GatewaysProvider } from '../../../types/wayfinder.js';
|
|
20
18
|
export declare class NetworkGatewaysProvider implements GatewaysProvider {
|
|
21
19
|
private ario;
|
|
22
20
|
private sortBy;
|
|
@@ -24,7 +22,7 @@ export declare class NetworkGatewaysProvider implements GatewaysProvider {
|
|
|
24
22
|
private limit;
|
|
25
23
|
private filter;
|
|
26
24
|
constructor({ ario, sortBy, sortOrder, limit, filter, }: {
|
|
27
|
-
ario
|
|
25
|
+
ario?: AoARIORead;
|
|
28
26
|
sortBy?: 'totalDelegatedStake' | 'operatorStake' | 'startTimestamp';
|
|
29
27
|
sortOrder?: 'asc' | 'desc';
|
|
30
28
|
limit?: number;
|
|
@@ -33,21 +31,3 @@ export declare class NetworkGatewaysProvider implements GatewaysProvider {
|
|
|
33
31
|
});
|
|
34
32
|
getGateways(): Promise<URL[]>;
|
|
35
33
|
}
|
|
36
|
-
export declare class StaticGatewaysProvider implements GatewaysProvider {
|
|
37
|
-
private gateways;
|
|
38
|
-
constructor({ gateways }: {
|
|
39
|
-
gateways: string[];
|
|
40
|
-
});
|
|
41
|
-
getGateways(): Promise<URL[]>;
|
|
42
|
-
}
|
|
43
|
-
export declare class SimpleCacheGatewaysProvider implements GatewaysProvider {
|
|
44
|
-
private gatewaysProvider;
|
|
45
|
-
private ttlSeconds;
|
|
46
|
-
private lastUpdated;
|
|
47
|
-
private gatewaysCache;
|
|
48
|
-
constructor({ gatewaysProvider, ttlSeconds, }: {
|
|
49
|
-
gatewaysProvider: GatewaysProvider;
|
|
50
|
-
ttlSeconds?: number;
|
|
51
|
-
});
|
|
52
|
-
getGateways(): Promise<URL[]>;
|
|
53
|
-
}
|
|
@@ -13,15 +13,19 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
export declare class
|
|
19
|
-
readonly name = "random";
|
|
16
|
+
import { GatewaysProvider } from '../../../types/wayfinder.js';
|
|
17
|
+
import { Logger } from '../../../web/index.js';
|
|
18
|
+
export declare class SimpleCacheGatewaysProvider implements GatewaysProvider {
|
|
20
19
|
private gatewaysProvider;
|
|
21
|
-
private
|
|
22
|
-
|
|
20
|
+
private ttlSeconds;
|
|
21
|
+
private lastUpdated;
|
|
22
|
+
private gatewaysCache;
|
|
23
|
+
private logger;
|
|
24
|
+
constructor({ gatewaysProvider, ttlSeconds, // 1 hour
|
|
25
|
+
logger, }: {
|
|
23
26
|
gatewaysProvider: GatewaysProvider;
|
|
24
|
-
|
|
27
|
+
ttlSeconds?: number;
|
|
28
|
+
logger?: Logger;
|
|
25
29
|
});
|
|
26
|
-
|
|
30
|
+
getGateways(): Promise<URL[]>;
|
|
27
31
|
}
|
|
@@ -13,12 +13,11 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
export declare class
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
gateway: string;
|
|
16
|
+
import { GatewaysProvider } from '../../../types/wayfinder.js';
|
|
17
|
+
export declare class StaticGatewaysProvider implements GatewaysProvider {
|
|
18
|
+
private gateways;
|
|
19
|
+
constructor({ gateways }: {
|
|
20
|
+
gateways: string[];
|
|
22
21
|
});
|
|
23
|
-
|
|
22
|
+
getGateways(): Promise<URL[]>;
|
|
24
23
|
}
|
|
@@ -14,10 +14,13 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export * from './wayfinder.js';
|
|
17
|
-
export * from './
|
|
18
|
-
export * from './
|
|
19
|
-
export * from './
|
|
20
|
-
export * from './
|
|
21
|
-
export * from './gateways/
|
|
22
|
-
export * from './
|
|
23
|
-
export * from './
|
|
17
|
+
export * from './routing/strategies/random.js';
|
|
18
|
+
export * from './routing/strategies/static.js';
|
|
19
|
+
export * from './routing/strategies/ping.js';
|
|
20
|
+
export * from './routing/strategies/round-robin.js';
|
|
21
|
+
export * from './gateways/network.js';
|
|
22
|
+
export * from './gateways/simple-cache.js';
|
|
23
|
+
export * from './gateways/static.js';
|
|
24
|
+
export * from './verification/trusted.js';
|
|
25
|
+
export * from './verification/strategies/data-root-verifier.js';
|
|
26
|
+
export * from './verification/strategies/hash-verifier.js';
|
package/lib/types/common/wayfinder/{routers/simple-cache.d.ts → routing/strategies/ping.d.ts}
RENAMED
|
@@ -13,16 +13,15 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
17
|
-
export declare class
|
|
18
|
-
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
constructor({ router, ttlSeconds, }: {
|
|
24
|
-
router: WayfinderRouter;
|
|
25
|
-
ttlSeconds?: number;
|
|
16
|
+
import { RoutingStrategy } from '../../../../types/wayfinder.js';
|
|
17
|
+
export declare class FastestPingRoutingStrategy implements RoutingStrategy {
|
|
18
|
+
private timeoutMs;
|
|
19
|
+
private probePath;
|
|
20
|
+
constructor({ timeoutMs, probePath, }?: {
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
probePath?: string;
|
|
26
23
|
});
|
|
27
|
-
|
|
24
|
+
selectGateway({ gateways }: {
|
|
25
|
+
gateways: URL[];
|
|
26
|
+
}): Promise<URL>;
|
|
28
27
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 { RoutingStrategy } from '../../../../types/wayfinder.js';
|
|
17
|
+
export declare class RandomRoutingStrategy implements RoutingStrategy {
|
|
18
|
+
selectGateway({ gateways }: {
|
|
19
|
+
gateways: URL[];
|
|
20
|
+
}): Promise<URL>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { Logger } from '../../../../common/logger.js';
|
|
17
|
+
import { RoutingStrategy } from '../../../../types/wayfinder.js';
|
|
18
|
+
export declare class RoundRobinRoutingStrategy implements RoutingStrategy {
|
|
19
|
+
private gateways;
|
|
20
|
+
private currentIndex;
|
|
21
|
+
private logger;
|
|
22
|
+
constructor({ gateways, logger, }: {
|
|
23
|
+
gateways: URL[];
|
|
24
|
+
logger?: Logger;
|
|
25
|
+
});
|
|
26
|
+
selectGateway({ gateways, }?: {
|
|
27
|
+
gateways?: URL[];
|
|
28
|
+
}): Promise<URL>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { RoutingStrategy } from '../../../../types/wayfinder.js';
|
|
17
|
+
import { Logger } from '../../../logger.js';
|
|
18
|
+
export declare class StaticRoutingStrategy implements RoutingStrategy {
|
|
19
|
+
readonly name = "static";
|
|
20
|
+
private gateway;
|
|
21
|
+
private logger;
|
|
22
|
+
constructor({ gateway, logger, }: {
|
|
23
|
+
gateway: string;
|
|
24
|
+
logger?: Logger;
|
|
25
|
+
});
|
|
26
|
+
selectGateway({ gateways, }?: {
|
|
27
|
+
gateways?: URL[];
|
|
28
|
+
}): Promise<URL>;
|
|
29
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
|
-
import { DataRootProvider,
|
|
2
|
+
import { DataRootProvider, DataVerificationStrategy } from '../../../../types/wayfinder.js';
|
|
3
3
|
export declare function convertBufferToDataRoot({ buffer, }: {
|
|
4
4
|
buffer: Buffer;
|
|
5
5
|
}): Promise<string>;
|
|
6
6
|
export declare const convertReadableToDataRoot: <T extends AsyncIterable<Uint8Array>>({ iterable, }: {
|
|
7
7
|
iterable: T;
|
|
8
8
|
}) => Promise<string>;
|
|
9
|
-
export declare class
|
|
9
|
+
export declare class DataRootVerificationStrategy implements DataVerificationStrategy {
|
|
10
10
|
private readonly trustedDataRootProvider;
|
|
11
11
|
constructor({ trustedDataRootProvider, }: {
|
|
12
12
|
trustedDataRootProvider: DataRootProvider;
|
package/lib/types/common/wayfinder/verification/{hash-verifier.d.ts → strategies/hash-verifier.d.ts}
RENAMED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { Readable } from 'node:stream';
|
|
17
|
-
import { DataHashProvider,
|
|
18
|
-
export declare class
|
|
17
|
+
import { DataHashProvider, DataVerificationStrategy } from '../../../../types/wayfinder.js';
|
|
18
|
+
export declare class HashVerificationStrategy implements DataVerificationStrategy {
|
|
19
19
|
private readonly trustedHashProvider;
|
|
20
20
|
constructor({ trustedHashProvider, }: {
|
|
21
21
|
trustedHashProvider: DataHashProvider;
|
package/lib/types/common/wayfinder/{gateways/trusted-gateways.d.ts → verification/trusted.d.ts}
RENAMED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { DataHashProvider, DataRootProvider } from '../../../types/wayfinder.js';
|
|
17
|
-
import { GatewaysProvider } from '
|
|
17
|
+
import { GatewaysProvider } from '../../../types/wayfinder.js';
|
|
18
18
|
export declare class TrustedGatewaysHashProvider implements DataHashProvider, DataRootProvider {
|
|
19
19
|
private gatewaysProvider;
|
|
20
20
|
constructor({ gatewaysProvider, }: {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import EventEmitter from 'node:events';
|
|
17
17
|
import { PassThrough, Readable } from 'node:stream';
|
|
18
|
-
import {
|
|
18
|
+
import { DataVerificationStrategy, GatewaysProvider, RoutingStrategy } from '../../types/wayfinder.js';
|
|
19
19
|
import { Logger } from '../logger.js';
|
|
20
20
|
type HttpClientArgs = unknown[];
|
|
21
21
|
type HttpClientFunction = (...args: HttpClientArgs) => unknown;
|
|
@@ -23,21 +23,21 @@ type WayfinderHttpClient<T extends HttpClientFunction> = T;
|
|
|
23
23
|
export declare const arnsRegex: RegExp;
|
|
24
24
|
export declare const txIdRegex: RegExp;
|
|
25
25
|
/**
|
|
26
|
-
* Core function
|
|
26
|
+
* Core function that converts a wayfinder url to the proper ar-io gateway URL
|
|
27
27
|
* @param originalUrl - the wayfinder url to resolve
|
|
28
|
-
* @param
|
|
28
|
+
* @param selectedGateway - the target gateway to resolve the url against
|
|
29
29
|
* @returns the resolved url that can be used to make a request
|
|
30
30
|
*/
|
|
31
|
-
export declare const resolveWayfinderUrl: ({ originalUrl,
|
|
31
|
+
export declare const resolveWayfinderUrl: ({ originalUrl, selectedGateway, logger, }: {
|
|
32
32
|
originalUrl: string | URL;
|
|
33
|
-
|
|
33
|
+
selectedGateway: URL;
|
|
34
34
|
logger?: Logger;
|
|
35
|
-
}) =>
|
|
35
|
+
}) => URL;
|
|
36
36
|
/**
|
|
37
37
|
* Wayfinder event emitter with verification events
|
|
38
38
|
*/
|
|
39
39
|
export type WayfinderEvent = {
|
|
40
|
-
type: 'verification-
|
|
40
|
+
type: 'verification-succeeded';
|
|
41
41
|
txId: string;
|
|
42
42
|
} | {
|
|
43
43
|
type: 'verification-failed';
|
|
@@ -54,10 +54,14 @@ export type WayfinderEvent = {
|
|
|
54
54
|
} | {
|
|
55
55
|
type: 'routing-started';
|
|
56
56
|
originalUrl: string;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'routing-skipped';
|
|
59
|
+
originalUrl: string;
|
|
57
60
|
} | {
|
|
58
61
|
type: 'routing-succeeded';
|
|
59
62
|
originalUrl: string;
|
|
60
|
-
|
|
63
|
+
selectedGateway: string;
|
|
64
|
+
redirectUrl: string;
|
|
61
65
|
} | {
|
|
62
66
|
type: 'routing-failed';
|
|
63
67
|
originalUrl: string;
|
|
@@ -65,12 +69,12 @@ export type WayfinderEvent = {
|
|
|
65
69
|
} | {
|
|
66
70
|
type: 'identified-transaction-id';
|
|
67
71
|
originalUrl: string;
|
|
68
|
-
|
|
72
|
+
selectedGateway: string;
|
|
69
73
|
txId: string;
|
|
70
74
|
};
|
|
71
75
|
export interface WayfinderEventArgs {
|
|
72
76
|
onVerificationPassed?: (payload: Omit<Extract<WayfinderEvent, {
|
|
73
|
-
type: 'verification-
|
|
77
|
+
type: 'verification-succeeded';
|
|
74
78
|
}>, 'type'>) => void;
|
|
75
79
|
onVerificationFailed?: (payload: Omit<Extract<WayfinderEvent, {
|
|
76
80
|
type: 'verification-failed';
|
|
@@ -88,12 +92,13 @@ export declare class WayfinderEmitter extends EventEmitter {
|
|
|
88
92
|
type: E;
|
|
89
93
|
}>, 'type'>) => void): this;
|
|
90
94
|
}
|
|
91
|
-
export declare function tapAndVerifyStream<T extends Readable | ReadableStream>({ originalStream, contentLength, verifyData, txId, emitter, }: {
|
|
95
|
+
export declare function tapAndVerifyStream<T extends Readable | ReadableStream>({ originalStream, contentLength, verifyData, txId, emitter, strict, }: {
|
|
92
96
|
originalStream: T;
|
|
93
97
|
contentLength: number;
|
|
94
|
-
verifyData:
|
|
98
|
+
verifyData: DataVerificationStrategy['verifyData'];
|
|
95
99
|
txId: string;
|
|
96
100
|
emitter?: WayfinderEmitter;
|
|
101
|
+
strict?: boolean;
|
|
97
102
|
}): T extends Readable ? PassThrough : T;
|
|
98
103
|
export declare function wrapVerifiedResponse(original: Response, newBody: ReadableStream<Uint8Array>, txId: string): Response;
|
|
99
104
|
/**
|
|
@@ -109,18 +114,21 @@ export declare function wrapVerifiedResponse(original: Response, newBody: Readab
|
|
|
109
114
|
* @param resolveUrl - the function to construct the redirect url for ar:// requests
|
|
110
115
|
* @returns a wrapped http client that supports ar:// protocol
|
|
111
116
|
*/
|
|
112
|
-
export declare const createWayfinderClient: <T extends HttpClientFunction>({ httpClient, resolveUrl, verifyData, emitter, logger, }: {
|
|
117
|
+
export declare const createWayfinderClient: <T extends HttpClientFunction>({ httpClient, resolveUrl, verifyData, selectGateway, emitter, logger, strict, }: {
|
|
113
118
|
httpClient: T;
|
|
119
|
+
selectGateway: () => Promise<URL>;
|
|
114
120
|
resolveUrl: (params: {
|
|
115
121
|
originalUrl: string | URL;
|
|
122
|
+
selectedGateway: URL;
|
|
116
123
|
logger?: Logger;
|
|
117
|
-
}) =>
|
|
124
|
+
}) => URL;
|
|
118
125
|
verifyData?: <T_1 extends Readable | ReadableStream | Buffer>({ data, txId, }: {
|
|
119
126
|
data: T_1;
|
|
120
127
|
txId: string;
|
|
121
128
|
}) => Promise<void>;
|
|
122
129
|
logger?: Logger;
|
|
123
130
|
emitter?: WayfinderEmitter;
|
|
131
|
+
strict?: boolean;
|
|
124
132
|
}) => WayfinderHttpClient<T>;
|
|
125
133
|
/**
|
|
126
134
|
* The main class for the wayfinder
|
|
@@ -130,88 +138,119 @@ export declare const createWayfinderClient: <T extends HttpClientFunction>({ htt
|
|
|
130
138
|
*/
|
|
131
139
|
export declare class Wayfinder<T extends HttpClientFunction> {
|
|
132
140
|
/**
|
|
133
|
-
* The
|
|
141
|
+
* The native http client used by wayfinder. By default, the native fetch api is used.
|
|
134
142
|
*
|
|
135
143
|
* @example
|
|
136
144
|
* const wayfinder = new Wayfinder({
|
|
137
|
-
*
|
|
138
|
-
* gatewaysProvider: new SimpleCacheGatewaysProvider({
|
|
139
|
-
* gatewaysProvider: new NetworkGatewaysProvider({ ario: ARIO.mainnet() }),
|
|
140
|
-
* ttlSeconds: 60 * 60 * 24, // 1 day
|
|
141
|
-
* }),
|
|
142
|
-
* }),
|
|
145
|
+
* httpClient: axios,
|
|
143
146
|
* });
|
|
144
147
|
*
|
|
145
|
-
* // Returns a target gateway based on the routing strategy
|
|
146
|
-
* const targetGateway = await wayfinder.router.getTargetGateway();
|
|
147
148
|
*/
|
|
148
|
-
readonly
|
|
149
|
+
readonly httpClient: T;
|
|
149
150
|
/**
|
|
150
|
-
* The
|
|
151
|
+
* The gateways provider is responsible for providing the list of gateways to use for routing requests.
|
|
151
152
|
*
|
|
152
153
|
* @example
|
|
153
154
|
* const wayfinder = new Wayfinder({
|
|
154
|
-
*
|
|
155
|
-
* gatewaysProvider: new
|
|
156
|
-
*
|
|
157
|
-
* ttlSeconds: 60 * 60 * 24, // 1 day
|
|
158
|
-
* }),
|
|
155
|
+
* gatewaysProvider: new SimpleCacheGatewaysProvider({
|
|
156
|
+
* gatewaysProvider: new NetworkGatewaysProvider({ ario: ARIO.mainnet() }),
|
|
157
|
+
* ttlSeconds: 60 * 60 * 24, // 1 day
|
|
159
158
|
* }),
|
|
160
|
-
* httpClient: axios,
|
|
161
159
|
* });
|
|
162
|
-
*
|
|
163
160
|
*/
|
|
164
|
-
readonly
|
|
161
|
+
readonly gatewaysProvider: GatewaysProvider;
|
|
165
162
|
/**
|
|
166
|
-
* The
|
|
163
|
+
* The routing strategy to use when routing requests.
|
|
167
164
|
*
|
|
168
165
|
* @example
|
|
169
166
|
* const wayfinder = new Wayfinder({
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
* gatewaysProvider: new NetworkGatewaysProvider({ ario: ARIO.mainnet() }),
|
|
173
|
-
* ttlSeconds: 60 * 60 * 24, // 1 day
|
|
174
|
-
* }),
|
|
167
|
+
* strategy: new FastestPingStrategy({
|
|
168
|
+
* timeoutMs: 1000,
|
|
175
169
|
* }),
|
|
176
|
-
* httpClient: axios,
|
|
177
170
|
* });
|
|
171
|
+
*/
|
|
172
|
+
readonly routingStrategy: RoutingStrategy;
|
|
173
|
+
/**
|
|
174
|
+
* A helper function that resolves the redirect url for ar:// requests to a target gateway.
|
|
175
|
+
*
|
|
176
|
+
* Note: no verification is done when resolving an ar://<path> url to a wayfinder route.
|
|
177
|
+
* In order to verify the data, you must use the `request` function or request the data and
|
|
178
|
+
* verify it yourself via the `verifyData` function.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* const { resolveUrl } = new Wayfinder();
|
|
178
182
|
*
|
|
179
183
|
* // returns the redirected URL based on the routing strategy and the original url
|
|
180
|
-
* const redirectUrl = await
|
|
184
|
+
* const redirectUrl = await resolveUrl({ originalUrl: 'ar://example' });
|
|
185
|
+
*
|
|
186
|
+
* window.open(redirectUrl.toString(), '_blank');
|
|
181
187
|
*/
|
|
182
188
|
readonly resolveUrl: (params: {
|
|
183
189
|
originalUrl: string;
|
|
184
190
|
logger?: Logger;
|
|
185
191
|
}) => Promise<URL>;
|
|
186
192
|
/**
|
|
187
|
-
*
|
|
193
|
+
*
|
|
194
|
+
* A wrapped http client that supports ar:// protocol. If a verification strategy is provided,
|
|
195
|
+
* the request will be verified and events will be emitted as the request is processed.
|
|
188
196
|
*
|
|
189
197
|
* @example
|
|
190
|
-
* const
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* gatewaysProvider: new
|
|
194
|
-
*
|
|
198
|
+
* const wayfinder = new Wayfinder({
|
|
199
|
+
* verificationStrategy: new HashVerificationStrategy({
|
|
200
|
+
* trustedHashProvider: new TrustedGatewaysHashProvider({
|
|
201
|
+
* gatewaysProvider: new StaticGatewaysProvider({
|
|
202
|
+
* gateways: ['https://permagate.io'],
|
|
203
|
+
* }),
|
|
195
204
|
* }),
|
|
196
205
|
* }),
|
|
197
|
-
* httpClient: axios,
|
|
198
|
-
* });;
|
|
199
|
-
*
|
|
200
|
-
* const response = await wayfind('ar://example', {
|
|
201
|
-
* method: 'POST',
|
|
202
|
-
* data: {
|
|
203
|
-
* name: 'John Doe',
|
|
204
|
-
* },
|
|
205
206
|
* })
|
|
207
|
+
*
|
|
208
|
+
* // request an arns name
|
|
209
|
+
* const response = await wayfinder.request('ar://ardrive')
|
|
210
|
+
*
|
|
211
|
+
* // request a transaction id
|
|
212
|
+
* const response = await wayfinder.request('ar://1234567890')
|
|
213
|
+
*
|
|
214
|
+
* // request a transaction id with a custom http client
|
|
215
|
+
* const response = await wayfinder.request('ar://1234567890')
|
|
216
|
+
*
|
|
217
|
+
* // Set strict mode to true to make verification blocking
|
|
218
|
+
* const wayfinder = new Wayfinder({
|
|
219
|
+
* strict: true,
|
|
220
|
+
* });
|
|
221
|
+
*
|
|
222
|
+
* // This will throw an error if verification fails
|
|
223
|
+
* try {
|
|
224
|
+
* const response = await wayfinder.request('ar://1234567890');
|
|
225
|
+
* } catch (error) {
|
|
226
|
+
* console.error('Verification failed', error);
|
|
227
|
+
* }
|
|
206
228
|
*/
|
|
207
229
|
readonly request: WayfinderHttpClient<T>;
|
|
208
|
-
|
|
230
|
+
/**
|
|
231
|
+
* The function that verifies the data hash for a given transaction id.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* const wayfinder = new Wayfinder({
|
|
235
|
+
* verifyData: (data, txId) => {
|
|
236
|
+
* // some custom verification logic
|
|
237
|
+
* return true;
|
|
238
|
+
* },
|
|
239
|
+
* });
|
|
240
|
+
*/
|
|
241
|
+
readonly verifyData: DataVerificationStrategy['verifyData'];
|
|
242
|
+
/**
|
|
243
|
+
* Whether verification should be strict (blocking) or not.
|
|
244
|
+
* If true, verification failures will cause requests to fail.
|
|
245
|
+
* If false, verification will be performed asynchronously and failures will only emit events.
|
|
246
|
+
*/
|
|
247
|
+
readonly strict: boolean;
|
|
209
248
|
/**
|
|
210
249
|
* The event emitter for wayfinder that emits verification events.
|
|
211
250
|
*
|
|
212
251
|
* const wayfinder = new Wayfinder()
|
|
213
252
|
*
|
|
214
|
-
* wayfinder.emitter.on('verification-
|
|
253
|
+
* wayfinder.emitter.on('verification-succeeded', (event) => {
|
|
215
254
|
* console.log('Verification passed!', event);
|
|
216
255
|
* })
|
|
217
256
|
*
|
|
@@ -238,28 +277,23 @@ export declare class Wayfinder<T extends HttpClientFunction> {
|
|
|
238
277
|
* const response = await wayfind('ar://example');
|
|
239
278
|
*/
|
|
240
279
|
readonly emitter: WayfinderEmitter;
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
280
|
+
/**
|
|
281
|
+
* The constructor for the wayfinder
|
|
282
|
+
* @param httpClient - the http client to use for requests
|
|
283
|
+
* @param routingStrategy - the routing strategy to use for requests
|
|
284
|
+
* @param verificationStrategy - the verification strategy to use for requests
|
|
285
|
+
* @param gatewaysProvider - the gateways provider to use for routing requests
|
|
286
|
+
* @param logger - the logger to use for logging
|
|
287
|
+
* @param strict - if true, verification will be blocking and will fail requests if verification fails; if false, verification will be non-blocking
|
|
288
|
+
*/
|
|
289
|
+
constructor({ httpClient, logger, gatewaysProvider, routingStrategy, verificationStrategy, events, strict, }: {
|
|
290
|
+
httpClient?: T;
|
|
291
|
+
routingStrategy?: RoutingStrategy;
|
|
292
|
+
gatewaysProvider?: GatewaysProvider;
|
|
293
|
+
verificationStrategy?: DataVerificationStrategy;
|
|
244
294
|
logger?: Logger;
|
|
245
|
-
verifier?: DataVerifier;
|
|
246
|
-
hashProvider?: DataHashProvider;
|
|
247
295
|
events?: WayfinderEventArgs;
|
|
296
|
+
strict?: boolean;
|
|
248
297
|
});
|
|
249
298
|
}
|
|
250
299
|
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
|
-
*/
|
package/lib/types/types/io.d.ts
CHANGED
|
@@ -420,7 +420,22 @@ export type DemandFactorSettings = {
|
|
|
420
420
|
maxPeriodsAtMinDemandFactor: number;
|
|
421
421
|
criteria: string;
|
|
422
422
|
};
|
|
423
|
-
export
|
|
423
|
+
export type ArNSNameResolutionData = {
|
|
424
|
+
name: string;
|
|
425
|
+
owner?: string;
|
|
426
|
+
txId: string;
|
|
427
|
+
type: 'lease' | 'permabuy';
|
|
428
|
+
processId: string;
|
|
429
|
+
ttlSeconds: number;
|
|
430
|
+
priority?: number;
|
|
431
|
+
undernameLimit: number;
|
|
432
|
+
};
|
|
433
|
+
export interface ArNSNameResolver {
|
|
434
|
+
resolveArNSName({ name }: {
|
|
435
|
+
name: string;
|
|
436
|
+
}): Promise<ArNSNameResolutionData>;
|
|
437
|
+
}
|
|
438
|
+
export interface AoARIORead extends ArNSNameResolver {
|
|
424
439
|
process: AOProcess;
|
|
425
440
|
getInfo(): Promise<{
|
|
426
441
|
Ticker: string;
|
|
@@ -14,11 +14,15 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { Readable } from 'stream';
|
|
17
|
-
export interface
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
export interface RoutingStrategy {
|
|
18
|
+
selectGateway: ({ gateways }: {
|
|
19
|
+
gateways: URL[];
|
|
20
|
+
}) => Promise<URL>;
|
|
20
21
|
}
|
|
21
|
-
export interface
|
|
22
|
+
export interface GatewaysProvider {
|
|
23
|
+
getGateways: () => Promise<URL[]>;
|
|
24
|
+
}
|
|
25
|
+
export interface DataVerificationStrategy {
|
|
22
26
|
/**
|
|
23
27
|
* Verifies the provided data for a given txId
|
|
24
28
|
*
|
package/lib/types/version.d.ts
CHANGED