@oceanprotocol/lib 9.0.0-next.9 → 9.1.0

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,17 +1,17 @@
1
1
  import { Signer } from 'ethers';
2
- import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, ServiceEndpoint, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, ComputeResultStream, NodeStatus, NodeComputeJob, NodeLogEntry, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, SignerOrAuthTokenOrSignature } from '../../@types/index.js';
2
+ import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, ComputeResultStream, NodeStatus, NodeComputeJob, NodeLogEntry, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, SignerOrAuthTokenOrSignature } from '../../@types/index.js';
3
3
  import { type DDO, type ValidateMetadata } from '@oceanprotocol/ddo-js';
4
4
  import { type P2PRequestBodyStream } from './P2pProvider.js';
5
5
  export declare class HttpProvider {
6
6
  protected getAuthorization(s: SignerOrAuthTokenOrSignature): string;
7
+ private baseUrl;
7
8
  private getSignedCommandParams;
8
- private resolvePersistentStorageRoute;
9
9
  /**
10
- * Returns the provider endpoints
10
+ * Returns the node's root info document (nodeId, chainIds, providerAddress, nodePublicKey, ...).
11
11
  * @param {string} nodeUri - the provider url
12
12
  * @return {Promise<any>}
13
13
  */
14
- getEndpoints(nodeUri: string, authorization?: string): Promise<any>;
14
+ private getNodeInfo;
15
15
  getNodeStatus(nodeUri: string, signal?: AbortSignal): Promise<NodeStatus>;
16
16
  getNodeJobs(nodeUri: string, fromTimestamp?: number, signal?: AbortSignal): Promise<NodeComputeJob[]>;
17
17
  /**
@@ -19,30 +19,14 @@ export declare class HttpProvider {
19
19
  * @return {string} The node public key
20
20
  */
21
21
  private getNodePublicKey;
22
- /**
23
- * This function returns the endpoint URL for a given service name.
24
- * @param {ServiceEndpoint[]} servicesEndpoints - The array of service endpoints
25
- * @param {string} serviceName - The name of the service
26
- * @returns {ServiceEndpoint} The endpoint URL for the given service name
27
- */
28
- getEndpointURL(servicesEndpoints: ServiceEndpoint[], serviceName: string): ServiceEndpoint;
29
- /**
30
- * This function returns an array of service endpoints for a given provider endpoint.
31
- * @param {string} providerEndpoint - The provider endpoint
32
- * @param {any} endpoints - The endpoints object
33
- * @returns {ServiceEndpoint[]} An array of service endpoints
34
- */
35
- getServiceEndpoints(providerEndpoint: string, endpoints: any): Promise<ServiceEndpoint[]>;
36
22
  /**
37
23
  * Get current nonce from the provider.
38
24
  * @param {string} nodeUri provider uri address
39
25
  * @param {string} consumerAddress Publisher address
40
26
  * @param {AbortSignal} signal abort signal
41
- * @param {string} providerEndpoints Identifier of the asset to be registered in ocean
42
- * @param {string} serviceEndpoints document description object (DDO)=
43
27
  * @return {Promise<string>} urlDetails
44
28
  */
45
- getNonce(nodeUri: string, consumerAddress: string, signal?: AbortSignal, providerEndpoints?: any, serviceEndpoints?: ServiceEndpoint[]): Promise<number>;
29
+ getNonce(nodeUri: string, consumerAddress: string, signal?: AbortSignal): Promise<number>;
46
30
  /**
47
31
  * Encrypt data using the Provider's own symmetric key
48
32
  * @param {string} data data in json format that needs to be sent , it can either be a DDO or a File array
@@ -120,7 +104,12 @@ export declare class HttpProvider {
120
104
  * @param {UserCustomParameters} userCustomParameters - The user custom parameters.
121
105
  * @returns {Promise<any>} The download URL.
122
106
  */
123
- 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>;
124
113
  /** Instruct the provider to start a PAYED compute job
125
114
  * @param {string} nodeUri The provider URI.
126
115
  * @param {SignerOrAuthToken} signerOrAuthToken The consumer signer object or auth token.
@@ -181,18 +170,38 @@ export declare class HttpProvider {
181
170
  * @param {string} jobId The ID of a compute job.
182
171
  * @param {string} agreementId The ID of the service agreement (tx id)
183
172
  * @param {AbortSignal} signal abort signal
184
- * @return {Promise<ComputeJob | ComputeJob[]>}
173
+ * @param {boolean} includeMetrics Owner-only runtime metrics (`runtimeMetrics`) on the
174
+ * returned job(s). To receive them, the node needs owner credentials: an auth token
175
+ * (`signerOrAuthToken` as a string) is ALWAYS sent, regardless of this flag; a `Signer`'s
176
+ * nonce+signature is only computed and sent when this flag is `true` (skipped otherwise
177
+ * to avoid an extra nonce round-trip on every plain status poll). Omitted (default): the
178
+ * node attaches metrics silently if valid owner credentials made it into the request
179
+ * (true automatically for token callers, false for `Signer` callers unless this flag is
180
+ * set), and returns exactly today's response otherwise. `true`: metrics are required —
181
+ * this method also computes the `Signer`'s signature, and the node answers 400/401 if
182
+ * credentials don't verify. `false`: metrics are never attached.
183
+ * @return {Promise<NodeComputeJob | NodeComputeJob[]>}
185
184
  */
186
- computeStatus(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId?: string, agreementId?: string, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
185
+ computeStatus(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId?: string, agreementId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<NodeComputeJob | NodeComputeJob[]>;
187
186
  /** Get compute result url
188
187
  * @param {string} nodeUri The URI of the provider we want to query
189
188
  * @param {SignerOrAuthToken} signerOrAuthToken signer or auth token
190
189
  * @param {string} jobId The ID of a compute job.
191
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.
192
195
  * @return {Promise<string>}
193
196
  */
194
- getComputeResultUrl(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number): Promise<string>;
195
- 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>;
196
205
  /** Generates an auth token
197
206
  * @param {Signer} consumer consumer Signer wallet object
198
207
  * @param {string} nodeUri The URI of the provider we want to query
@@ -223,11 +232,17 @@ export declare class HttpProvider {
223
232
  */
224
233
  PolicyServerPassthrough(nodeUri: string, request: PolicyServerPassthroughCommand, signal?: AbortSignal): Promise<any>;
225
234
  /** Initialize Policy Server verification
235
+ *
236
+ * Authenticated exactly like `PolicyServerPassthrough`, but it is a distinct command, so
237
+ * the signed message uses its own command string:
238
+ * `consumerAddress + nonce + "PolicyServerInitialize"`. A signature is therefore scoped to
239
+ * one endpoint and cannot be replayed against the other.
226
240
  * @param {string} nodeUri The provider URI.
241
+ * @param {SignerOrAuthTokenOrSignature} signerOrAuthToken The consumer signer object, auth token or signature.
227
242
  * @param {PolicyServerInitializeCommand} request The request to be sent to the Policy Server.
228
243
  * @param {AbortSignal} signal abort signal
229
244
  */
230
- initializePSVerification(nodeUri: string, request: PolicyServerInitializeCommand, signal?: AbortSignal): Promise<any>;
245
+ initializePSVerification(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, request: PolicyServerInitializeCommand, signal?: AbortSignal): Promise<any>;
231
246
  /**
232
247
  * Download node logs as an admin.
233
248
  * @param {string} nodeUri - The provider URI.
@@ -260,7 +275,6 @@ export declare class HttpProvider {
260
275
  uploadPersistentStorageFile(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, bucketId: string, fileName: string, content: P2PRequestBodyStream, signal?: AbortSignal): Promise<PersistentStorageFileEntry>;
261
276
  deletePersistentStorageFile(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, bucketId: string, fileName: string, signal?: AbortSignal): Promise<PersistentStorageDeleteFileResponse>;
262
277
  updatePersistentStorageBucket(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, bucketId: string, label: string | null, signal?: AbortSignal): Promise<PersistentStorageUpdateBucketResponse>;
263
- private resolveServiceRoute;
264
278
  private encryptServiceUserData;
265
279
  private buildQuery;
266
280
  /**
@@ -302,15 +316,22 @@ export declare class HttpProvider {
302
316
  * the env (else the node replies 403). `userData`/`dockerCmd`/`dockerEntrypoint` are only
303
317
  * sent when supplied — an omitted override reuses the node's stored value, whereas an
304
318
  * explicit value (including `[]`) REPLACES it (matches ocean-node's restartService semantics).
319
+ *
320
+ * `params.metadata` is an optional owner-supplied label bag that, when supplied, REPLACES the
321
+ * stored metadata (and does NOT force RESPEC mode). Unlike `userData`, it is transmitted
322
+ * WITHOUT application-level encryption, so it must not contain sensitive values.
305
323
  * @return {Promise<ServiceJob[]>} The restarted service job (single-element array).
306
324
  */
307
325
  serviceRestart(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, params?: ServiceRestartParams, signal?: AbortSignal): Promise<ServiceJob[]>;
308
326
  /**
309
327
  * Returns the caller's service jobs (userData stripped). Filter by `serviceId`,
310
328
  * or omit it to list all of the caller's services. Requires a signature.
329
+ * @param {boolean} includeMetrics Owner-only runtime metrics (`runtimeMetrics`) on the
330
+ * returned service(s). This command is already authenticated, so metrics are included
331
+ * BY DEFAULT (omitted / `undefined`); pass `false` to opt out.
311
332
  * @return {Promise<ServiceJob[]>} The matching service jobs.
312
333
  */
313
- getServiceStatus(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId?: string, signal?: AbortSignal): Promise<ServiceJob[]>;
334
+ getServiceStatus(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<ServiceJob[]>;
314
335
  /**
315
336
  * Node-wide service listing (SERVICE_LIST). Authenticated but NOT owner-scoped: any
316
337
  * consumer identity sees every owner's services, listing-sanitized (no userData, no