@oceanprotocol/lib 9.0.0-next.10 → 9.0.0-next.12

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.
@@ -1,5 +1,6 @@
1
1
  import { MetadataAlgorithm, ConsumerParameter } from '@oceanprotocol/ddo-js';
2
- import { StorageObject, EncryptMethod } from './File';
2
+ import { StorageObject, EncryptMethod } from './File.js';
3
+ import { NodeP2P } from './Provider.js';
3
4
  export type ComputeResultType = 'algorithmLog' | 'output' | 'configrationLog' | 'publishLog';
4
5
  export interface RunningPlatform {
5
6
  architecture: string;
@@ -239,3 +240,68 @@ export interface dockerRegistryAuth {
239
240
  auth?: string;
240
241
  }
241
242
  export type ComputeResultStream = AsyncIterable<Uint8Array>;
243
+ /**
244
+ * One resource dimension of a compute-provider search, e.g. `{ resource: 'cpu', value: 4 }`.
245
+ * `resource` is deliberately an open string here too, matching the underlying capability
246
+ * format — a caller can ask for a resource type this package has no built-in knowledge of
247
+ * (`'fpga'`, `'pcie'`, anything a compute engine reports) and still get a well-typed request.
248
+ */
249
+ export interface ComputeSearchDimension {
250
+ resource: string;
251
+ value: number;
252
+ }
253
+ /**
254
+ * A typed request to `BaseProvider.findComputeProviders`. Built entirely from ordinary typed
255
+ * values — never a hand-built JSON string, never a content id.
256
+ */
257
+ export interface FindComputeProvidersRequest {
258
+ free: boolean;
259
+ /** One entry per resource dimension. The result is the intersection of all of them. */
260
+ resources: ComputeSearchDimension[];
261
+ /**
262
+ * Optional per-resource qualifier (e.g. `{ gpu: 'A100' }`) applied only at the verification
263
+ * step, against a candidate's real compute environments. Never hashed and never part of a
264
+ * lookup string — nothing that discriminates within a resource is.
265
+ */
266
+ models?: Record<string, string>;
267
+ signal?: AbortSignal;
268
+ }
269
+ /**
270
+ * A compute provider that announced a matching bucket for every requested dimension *and*
271
+ * whose real compute environments (fetched during verification) actually satisfy the request.
272
+ * `node` is directly usable as the `node` argument to other typed calls on this SDK's provider
273
+ * client (e.g. `getComputeEnvironments`, `initializeCompute`).
274
+ */
275
+ export interface ComputeProviderMatch {
276
+ node: NodeP2P;
277
+ environments: ComputeEnvironment[];
278
+ }
279
+ /**
280
+ * The outcome of one requested dimension's provider lookup, before verification and before it
281
+ * is intersected with any other requested dimension. Carried on the result specifically so an
282
+ * empty search is never a mystery — a caller can see exactly which dimension(s) had nothing,
283
+ * instead of a single opaque empty list.
284
+ */
285
+ export interface ComputeSearchDimensionResult {
286
+ resource: string;
287
+ /** The value as requested, before bucketing. */
288
+ value: number;
289
+ /** The bucket this dimension's lookup actually used. */
290
+ bucket: number;
291
+ /** Provider ids that announced this bucket, before verification or intersection with other dimensions. */
292
+ providerIds: string[];
293
+ /** Set when this dimension's lookup ended early. `providerIds` is still real, just possibly incomplete. */
294
+ partial?: true;
295
+ /** Present alongside `partial`, describing why the lookup ended early. */
296
+ error?: string;
297
+ }
298
+ /**
299
+ * Result of `BaseProvider.findComputeProviders`. Always a typed value, even when nothing
300
+ * matched — "nothing found" is a normal outcome here, never a thrown error.
301
+ */
302
+ export interface FindComputeProvidersResult {
303
+ /** Providers that satisfy every requested dimension, verified against their real environments. */
304
+ providers: ComputeProviderMatch[];
305
+ /** One entry per requested dimension, in request order. */
306
+ dimensions: ComputeSearchDimensionResult[];
307
+ }
@@ -1,4 +1,4 @@
1
- import { ProviderFees, StorageObject } from '.';
1
+ import { ProviderFees, StorageObject } from './index.js';
2
2
  export interface AssetFiles {
3
3
  nftAddress: string;
4
4
  datatokenAddress: string;
@@ -1,4 +1,4 @@
1
- import { AccessList } from './AccessList';
1
+ import { AccessList } from './AccessList.js';
2
2
  export interface HeadersObject {
3
3
  [key: string]: string;
4
4
  }
@@ -1,4 +1,4 @@
1
- import { ConsumeMarketFee, ProviderFees } from '.';
1
+ import { ConsumeMarketFee, ProviderFees } from './index.js';
2
2
  export interface Template {
3
3
  templateAddress: string;
4
4
  isActive: boolean;
@@ -43,16 +43,16 @@ export interface ServiceJobEndpoint {
43
43
  url: string;
44
44
  }
45
45
  export declare enum ServiceStatusNumber {
46
- Starting = 10,
47
- PullImage = 11,
46
+ Starting = 10,// DB record created by the start handler; awaits background processing
47
+ PullImage = 11,// pulling pre-built image from registry
48
48
  PullImageFailed = 12,
49
- BuildImage = 13,
49
+ BuildImage = 13,// building from Dockerfile
50
50
  BuildImageFailed = 14,
51
- VulnerableImage = 15,
52
- Locking = 20,
53
- Claiming = 30,
51
+ VulnerableImage = 15,// image scan found critical vulnerabilities
52
+ Locking = 20,// escrow createLock in progress (funds locked, not yet claimed)
53
+ Claiming = 30,// payment phase: claimLock on success, or cancelLock if the image step failed
54
54
  Running = 40,
55
- Restarting = 45,
55
+ Restarting = 45,// SERVICE_RESTART accepted; teardown + re-pull/build + new container in progress
56
56
  Stopping = 50,
57
57
  Stopped = 70,
58
58
  Expired = 75,
@@ -1,5 +1,5 @@
1
- import { AbiItem } from '../@types';
2
- import { LogLevel } from '../utils';
1
+ import { AbiItem } from '../@types/index.js';
2
+ import { LogLevel } from '../utils/index.js';
3
3
  type SDK = 'evm' | 'oasis';
4
4
  export declare class Config {
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { Config } from '.';
1
+ import { Config } from './index.js';
2
2
  export declare const configHelperNetworks: Config[];
3
3
  export declare const KNOWN_CONFIDENTIAL_EVMS: number[];
4
4
  export declare const getNodeEndpointConfig: () => Partial<Config>;
@@ -76,5 +76,5 @@ export declare class Dispenser extends SmartContractWithAddress {
76
76
  * @param {String} amount amount of datatokens required.
77
77
  * @return {Promise<Boolean>}
78
78
  */
79
- isDispensable(dtAddress: string, datatoken: Datatoken, address: string, amount?: string): Promise<Boolean>;
79
+ isDispensable(dtAddress: string, datatoken: Datatoken, address: string, amount?: string): Promise<boolean>;
80
80
  }
@@ -1,7 +1,7 @@
1
1
  import { Signer } from 'ethers';
2
- import { AbiItem } from '../@types';
3
- import { Config } from '../config';
4
- import { SmartContractWithAddress } from './SmartContractWithAddress';
2
+ import { AbiItem } from '../@types/index.js';
3
+ import { Config } from '../config/index.js';
4
+ import { SmartContractWithAddress } from './SmartContractWithAddress.js';
5
5
  export declare class EnterpriseFeeCollectorContract extends SmartContractWithAddress {
6
6
  getDefaultAbi(): AbiItem[];
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  import { Signer, TransactionRequest } from 'ethers';
2
- import { AbiItem, ReceiptOrEstimate, ValidationResponse, DepositData, PermitData, AuthData, LockData } from '../@types';
3
- import { Config } from '../config';
4
- import { SmartContractWithAddress } from './SmartContractWithAddress';
2
+ import { AbiItem, ReceiptOrEstimate, ValidationResponse, DepositData, PermitData, AuthData, LockData } from '../@types/index.js';
3
+ import { Config } from '../config/index.js';
4
+ import { SmartContractWithAddress } from './SmartContractWithAddress.js';
5
5
  export declare class EscrowContract extends SmartContractWithAddress {
6
6
  abiEnterprise: AbiItem[];
7
7
  getDefaultAbi(): AbiItem[];
@@ -20,7 +20,7 @@ export declare class Nft extends SmartContract {
20
20
  * @param {Boolean} estimateGas if True, return gas estimate
21
21
  * @return {Promise<string>} ERC20 Datatoken address
22
22
  */
23
- createDatatoken<G extends boolean = false>(nftAddress: string, address: string, minter: string, paymentCollector: string, mpFeeAddress: string, feeToken: string, feeAmount: string, cap: string, name?: string, symbol?: string, templateIndex?: number, filesObject?: string, accessListContract?: string, allowAccessList?: string, denyAccessList?: string, estimateGas?: G): Promise<G extends false ? string : BigInt>;
23
+ createDatatoken<G extends boolean = false>(nftAddress: string, address: string, minter: string, paymentCollector: string, mpFeeAddress: string, feeToken: string, feeAmount: string, cap: string, name?: string, symbol?: string, templateIndex?: number, filesObject?: string, accessListContract?: string, allowAccessList?: string, denyAccessList?: string, estimateGas?: G): Promise<G extends false ? string : bigint>;
24
24
  createDatatokenTx(nftAddress: string, address: string, minter: string, paymentCollector: string, mpFeeAddress: string, feeToken: string, feeAmount: string, cap: string, name?: string, symbol?: string, templateIndex?: number, filesObject?: string, accessListContract?: string, allowAccessList?: string, denyAccessList?: string): Promise<TransactionRequest>;
25
25
  /**
26
26
  * Add Manager for NFT Contract (only NFT Owner can succeed)
@@ -201,7 +201,7 @@ export declare class Nft extends SmartContract {
201
201
  * @param {String} nftAddress NFT contract address
202
202
  * @return {Promise<Objecta>}
203
203
  */
204
- getMetadata(nftAddress: string): Promise<Object>;
204
+ getMetadata(nftAddress: string): Promise<object>;
205
205
  /**
206
206
  * Checks if user has DatatokenDeployer role
207
207
  * @param {String} nftAddress NFT contract address
@@ -56,13 +56,13 @@ export declare class NftFactory extends SmartContractWithAddress {
56
56
  * @param {String} datatoken Datatoken address to check
57
57
  * @return {Promise<Boolean>} return true if deployed from this factory
58
58
  */
59
- checkDatatoken(datatoken: string): Promise<Boolean>;
59
+ checkDatatoken(datatoken: string): Promise<boolean>;
60
60
  /**
61
61
  * Check if NFT is deployed from the factory
62
62
  * @param {String} nftAddress nftAddress address to check
63
63
  * @return {Promise<String>} return address(0) if it's not, or the nftAddress if true
64
64
  */
65
- checkNFT(nftAddress: string): Promise<String>;
65
+ checkNFT(nftAddress: string): Promise<string>;
66
66
  /**
67
67
  * Add a new NFT token template - only factory Owner
68
68
  * @param {String} address caller address
@@ -1,3 +1,3 @@
1
1
  import { BaseProvider } from './providers/BaseProvider.js';
2
- export { BaseProvider as Provider, isP2pUri, OCEAN_P2P_PROTOCOL, type P2PConfig } from './providers/BaseProvider.js';
2
+ export { BaseProvider as Provider, isP2pUri, OCEAN_P2P_PROTOCOL, type P2PConfig, type P2pProviderRecord, type Multiaddr, P2pError, type P2pErrorType, classifyP2pError, isRetryableP2pError } from './providers/BaseProvider.js';
3
3
  export declare const ProviderInstance: BaseProvider;
@@ -1,8 +1,8 @@
1
1
  import { Signer } from 'ethers';
2
- import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ComputeResultStream, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, DownloadResponse, NodeStatus, NodeComputeJob, NodeLogEntry, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, OceanNode, CompleteSignature, SignerOrAuthTokenOrSignature } from '../../@types/index.js';
2
+ import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ComputeResultStream, FindComputeProvidersRequest, FindComputeProvidersResult, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, DownloadResponse, NodeStatus, NodeComputeJob, NodeLogEntry, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, OceanNode, CompleteSignature, SignerOrAuthTokenOrSignature } from '../../@types/index.js';
3
3
  import { type DDO, type ValidateMetadata } from '@oceanprotocol/ddo-js';
4
- import { P2pProvider, type P2PConfig, type P2PRequestBodyStream } from './P2pProvider.js';
5
- export { OCEAN_P2P_PROTOCOL, type P2PConfig } from './P2pProvider.js';
4
+ import { type P2pProvider, type P2PConfig, type P2PRequestBodyStream } from './P2pProvider.js';
5
+ export { OCEAN_P2P_PROTOCOL, type P2PConfig, type P2pProviderRecord, type Multiaddr, P2pError, type P2pErrorType, classifyP2pError, isRetryableP2pError } from './P2pProvider.js';
6
6
  export declare function getConsumerAddress(signerOrAuthToken: SignerOrAuthTokenOrSignature): Promise<string>;
7
7
  export declare function getSignature(signerOrAuthToken: SignerOrAuthTokenOrSignature, nonce: string, command: string, issuerPeerId?: string): Promise<string | null>;
8
8
  export declare function getAuthorization(signerOrAuthToken: SignerOrAuthTokenOrSignature): string | undefined;
@@ -18,9 +18,42 @@ export declare class BaseProvider {
18
18
  checkDidFiles(did: string, serviceId: string, nodeUri: OceanNode, withChecksum?: boolean, signal?: AbortSignal): Promise<FileInfo[]>;
19
19
  getFileInfo(file: StorageObject, nodeUri: OceanNode, withChecksum?: boolean, signal?: AbortSignal): Promise<FileInfo[]>;
20
20
  getComputeEnvironments(nodeUri: OceanNode, signal?: AbortSignal): Promise<ComputeEnvironment[]>;
21
+ /**
22
+ * Searches for compute providers that can satisfy a typed resource request — a caller never
23
+ * builds a lookup string, computes a bucket, or sees a content id; it passes ordinary typed
24
+ * values in and gets typed providers back.
25
+ *
26
+ * `node` selects the transport the same way every other method on this class does. Provider
27
+ * discovery here is a DHT lookup, so it must identify the P2P network — a peer id, a
28
+ * multiaddr, or a {@link NodeP2P} — rather than a plain HTTP provider URL; there is no HTTP
29
+ * equivalent for it (yet).
30
+ *
31
+ * A multi-dimension request (e.g. `cpu` *and* `ram`) is handled as an intersection of one
32
+ * lookup per dimension, never as a single wider lookup string. Because bucketing rounds down
33
+ * on both the announcing and the querying side, a bucket match is a prefilter, not proof of
34
+ * anything: a request for `cpu: 9` buckets to `8` and matches a provider whose real maximum
35
+ * is exactly `8`. Every candidate surviving the intersection is therefore verified here
36
+ * against its real compute environments before it is returned; `models` — a per-resource
37
+ * qualifier such as a GPU name — is applied only at that step, never as part of a lookup
38
+ * string, because nothing that discriminates within a resource is ever hashed.
39
+ *
40
+ * Never throws for "nothing found". A fleet that has not heard of a requested resource (or,
41
+ * dimension by dimension, any resource) simply yields no providers for it, and `dimensions`
42
+ * says exactly which requested resource that was — a caller is never left staring at a
43
+ * silently empty result with no way to tell which part of the request came up short.
44
+ */
45
+ findComputeProviders(node: OceanNode, request: FindComputeProvidersRequest): Promise<FindComputeProvidersResult>;
21
46
  initialize(did: string, serviceId: string, fileIndex: number, consumerAddress: string, nodeUri: OceanNode, signal?: AbortSignal, userCustomParameters?: UserCustomParameters, computeEnv?: string, validUntil?: number): Promise<ProviderInitialize>;
22
47
  initializeCompute(assets: ComputeAsset[], algorithm: ComputeAlgorithm, computeEnv: string, token: string, validUntil: number, nodeUri: OceanNode, consumerAddress: string, resources: ComputeResourceRequest[], chainId: number, policyServer?: any, signal?: AbortSignal, queueMaxWaitTime?: number, dockerRegistryAuthData?: dockerRegistryAuth, output?: ComputeOutput): Promise<ProviderComputeInitializeResults>;
23
- getDownloadUrl(did: string, serviceId: string, fileIndex: number, transferTxId: string, nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, policyServer?: any, userCustomParameters?: UserCustomParameters): Promise<string | DownloadResponse>;
48
+ /**
49
+ * @param signal Cancels the operation. On the P2P transport it covers the whole
50
+ * transfer — the nonce round-trip, the dial and every frame of the body — so a
51
+ * download already running stops when it fires. The HTTP transport returns a URL for
52
+ * the caller to fetch and so performs no transfer here, but building that URL from a
53
+ * `Signer` does fetch a nonce from the node, and the signal covers that request.
54
+ * Optional; omitting it keeps the previous behaviour.
55
+ */
56
+ getDownloadUrl(did: string, serviceId: string, fileIndex: number, transferTxId: string, nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, policyServer?: any, userCustomParameters?: UserCustomParameters, signal?: AbortSignal): Promise<string | DownloadResponse>;
24
57
  computeStart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, computeEnv: string, datasets: ComputeAsset[], algorithm: ComputeAlgorithm, maxJobDuration: number, token: string, resources: ComputeResourceRequest[], chainId: number, metadata?: ComputeJobMetadata, additionalViewers?: string[], output?: ComputeOutput, policyServer?: any, signal?: AbortSignal, queueMaxWaitTime?: number, dockerRegistryAuth?: dockerRegistryAuth, outputBucketId?: string): Promise<ComputeJob | ComputeJob[]>;
25
58
  freeComputeStart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, computeEnv: string, datasets: ComputeAsset[], algorithm: ComputeAlgorithm, resources?: ComputeResourceRequest[], metadata?: ComputeJobMetadata, additionalViewers?: string[], output?: ComputeOutput, policyServer?: any, signal?: AbortSignal, queueMaxWaitTime?: number, dockerRegistryAuth?: dockerRegistryAuth, outputBucketId?: string): Promise<ComputeJob | ComputeJob[]>;
26
59
  /**
@@ -58,8 +91,28 @@ export declare class BaseProvider {
58
91
  * credentials don't verify. `false`: metrics are never attached.
59
92
  */
60
93
  computeStatus(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId?: string, agreementId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<NodeComputeJob | NodeComputeJob[]>;
61
- getComputeResultUrl(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number): Promise<string>;
62
- getComputeResult(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number, offset?: number): Promise<ComputeResultStream>;
94
+ /**
95
+ * A fetchable URL for a compute result.
96
+ *
97
+ * HTTP-transport only. A P2P peer answers with the result bytes themselves and the
98
+ * protocol carries no location for them, so this rejects for a P2P target — use
99
+ * {@link getComputeResult} there, which returns the bytes as an async iterable.
100
+ *
101
+ * @param signal Cancels the nonce round-trip the URL is built from. Only reaches the
102
+ * network when `signerOrAuthToken` is a `Signer`; a token or a pre-made signature
103
+ * needs no nonce and this becomes pure string assembly. Optional; omitting it keeps
104
+ * the previous behaviour.
105
+ */
106
+ getComputeResultUrl(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number, signal?: AbortSignal): Promise<string>;
107
+ /**
108
+ * @param signal Cancels the operation. On the P2P transport it covers the whole
109
+ * transfer — the nonce round-trip, the dial and every frame the returned generator
110
+ * reads — so a result already being transferred stops when it fires. The HTTP
111
+ * transport covers the same ground: the nonce round-trip, the request and the
112
+ * response body. On both, aborting mid-transfer makes the iterable throw rather than
113
+ * end quietly. Optional; omitting it keeps the previous behaviour.
114
+ */
115
+ getComputeResult(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number, offset?: number, signal?: AbortSignal): Promise<ComputeResultStream>;
63
116
  generateAuthToken(consumer: Signer, nodeUri: OceanNode, signal?: AbortSignal): Promise<string>;
64
117
  generateSignedAuthToken(address: string, signature: string, nonce: string, nodeUri: OceanNode, validUntil?: number, signal?: AbortSignal): Promise<string>;
65
118
  invalidateAuthToken(consumer: Signer, token: string, nodeUri: OceanNode, signal?: AbortSignal): Promise<{
@@ -75,11 +128,51 @@ export declare class BaseProvider {
75
128
  getNodeJobs(nodeUri: OceanNode, fromTimestamp?: number, signal?: AbortSignal): Promise<NodeComputeJob[]>;
76
129
  setupP2P(config: P2PConfig): Promise<void>;
77
130
  getLibp2pNode(): import("libp2p").Libp2p<import("@libp2p/interface").ServiceMap>;
78
- getDiscoveredNodes(): Promise<Array<{
79
- peerId: string;
80
- multiaddrs: string[];
81
- }>>;
131
+ /**
132
+ * Stop the shared libp2p node: close connections and release the node, so nothing
133
+ * keeps the process alive. Long-lived Node.js processes should call this on
134
+ * shutdown. There is no relay reservation to release — ocean.js listens on nothing
135
+ * and only ever *dials* through a relay. Safe to call when P2P was never started,
136
+ * and safe to call twice.
137
+ */
138
+ stopP2P(): Promise<void>;
139
+ /** Alias for {@link stopP2P}. */
140
+ dispose(): Promise<void>;
141
+ /**
142
+ * Every peer this client knows about, with the state of the connection to it.
143
+ *
144
+ * `peerId` and `multiaddrs` are unchanged; the connection fields are added. They are
145
+ * what tells a known peer apart from a reachable one — a peer can sit in the peer store
146
+ * with three addresses and be unreachable, or be connected only over a circuit relay
147
+ * that will cut the connection off after a byte budget.
148
+ */
149
+ getDiscoveredNodes(): Promise<Awaited<ReturnType<P2pProvider['getDiscoveredNodes']>>>;
150
+ /**
151
+ * Whether P2P can do anything, as opposed to whether it is switched on: routing-table
152
+ * size, DHT mode, the peer store lifetimes the running node applies, and the resolution
153
+ * lanes.
154
+ *
155
+ * The routing table is the one to read first. A DHT lookup against an empty table finds
156
+ * nothing however many connections are open, because a connection to a peer that does
157
+ * not speak the DHT protocol is not a place a walk can start.
158
+ */
159
+ getP2pDiagnostics(): ReturnType<P2pProvider['getP2pDiagnostics']>;
82
160
  getMultiaddrFromPeerId(peerId: string): Promise<string>;
161
+ /**
162
+ * Which tier answered each peer-address resolution — an open connection, the peer
163
+ * store, or a DHT walk — plus cache hits, misses and invalidations.
164
+ *
165
+ * Read this to see whether the peer store is doing its job: an address now lives
166
+ * there as long as the DHT provider record that names it, and the visible effect of
167
+ * that should be resolutions moving out of the `dht` lane and into `peer-store`.
168
+ */
169
+ getPeerResolutionStats(): Record<string, number>;
170
+ /**
171
+ * Forgets the cached addresses for a peer, so the next call to it resolves afresh.
172
+ * Failed dials already do this; call it directly when something outside the library
173
+ * knows a node has moved.
174
+ */
175
+ invalidatePeerResolution(peerId: string): void;
83
176
  createPersistentStorageBucket(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, payload: PersistentStorageCreateBucketRequest, signal?: AbortSignal): Promise<{
84
177
  bucketId: string;
85
178
  owner: string;
@@ -104,7 +104,12 @@ export declare class HttpProvider {
104
104
  * @param {UserCustomParameters} userCustomParameters - The user custom parameters.
105
105
  * @returns {Promise<any>} The download URL.
106
106
  */
107
- getDownloadUrl(did: string, serviceId: string, fileIndex: number, transferTxId: string, nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, policyServer?: any, userCustomParameters?: UserCustomParameters): Promise<any>;
107
+ /**
108
+ * @param {AbortSignal} signal Cancels the nonce round-trip. No download is performed
109
+ * here — the return value is a URL the caller fetches itself — but building that URL
110
+ * from a `Signer` requires a nonce from the node, and that request was uncancellable.
111
+ */
112
+ getDownloadUrl(did: string, serviceId: string, fileIndex: number, transferTxId: string, nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, policyServer?: any, userCustomParameters?: UserCustomParameters, signal?: AbortSignal): Promise<any>;
108
113
  /** Instruct the provider to start a PAYED compute job
109
114
  * @param {string} nodeUri The provider URI.
110
115
  * @param {SignerOrAuthToken} signerOrAuthToken The consumer signer object or auth token.
@@ -183,10 +188,20 @@ export declare class HttpProvider {
183
188
  * @param {SignerOrAuthToken} signerOrAuthToken signer or auth token
184
189
  * @param {string} jobId The ID of a compute job.
185
190
  * @param {number} index Result index
191
+ * @param {AbortSignal} signal Cancels the nonce round-trip. This method is often
192
+ * described as pure string assembly, and that is only true when a token or a
193
+ * pre-made signature is supplied: given a `Signer` it fetches a nonce from the node
194
+ * first, and that request had no cancellation at all.
186
195
  * @return {Promise<string>}
187
196
  */
188
- getComputeResultUrl(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number): Promise<string>;
189
- getComputeResult(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number, offset?: number): Promise<ComputeResultStream>;
197
+ getComputeResultUrl(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number, signal?: AbortSignal): Promise<string>;
198
+ /**
199
+ * @param {AbortSignal} signal Cancels the whole operation: the nonce round-trip, the
200
+ * request, and the response body. Aborting mid-transfer makes the returned iterable
201
+ * throw rather than end quietly, so a partially read result is never mistaken for a
202
+ * complete one.
203
+ */
204
+ getComputeResult(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number, offset?: number, signal?: AbortSignal): Promise<ComputeResultStream>;
190
205
  /** Generates an auth token
191
206
  * @param {Signer} consumer consumer Signer wallet object
192
207
  * @param {string} nodeUri The URI of the provider we want to query