@oceanprotocol/lib 9.0.0-next.1 → 9.0.0-next.10
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/dist/lib.cjs +4 -4
- package/dist/lib.module.mjs +4 -4
- package/dist/lib.umd.js +4 -4
- package/dist/types/@types/Compute.d.ts +57 -0
- package/dist/types/@types/PolicyServer.d.ts +3 -1
- package/dist/types/@types/Provider.d.ts +3 -5
- package/dist/types/@types/Services.d.ts +27 -5
- package/dist/types/services/providers/BaseProvider.d.ts +34 -6
- package/dist/types/services/providers/HttpProvider.d.ts +49 -29
- package/dist/types/services/providers/P2pProvider.d.ts +36 -6
- package/dist/types/utils/General.d.ts +15 -0
- package/package.json +1 -1
|
@@ -81,6 +81,62 @@ export interface ComputeResult {
|
|
|
81
81
|
export type ComputeJobMetadata = {
|
|
82
82
|
[key: string]: string | number | boolean;
|
|
83
83
|
};
|
|
84
|
+
export type GpuVendor = 'nvidia' | 'amd' | 'intel';
|
|
85
|
+
export interface GpuMetricsSnapshot {
|
|
86
|
+
resourceId: string;
|
|
87
|
+
vendor: GpuVendor;
|
|
88
|
+
utilizationPercent: number | null;
|
|
89
|
+
memoryUsedBytes: number | null;
|
|
90
|
+
memoryTotalBytes: number | null;
|
|
91
|
+
temperatureC?: number;
|
|
92
|
+
powerWatts?: number;
|
|
93
|
+
shared?: boolean;
|
|
94
|
+
}
|
|
95
|
+
export interface ContainerMetricsSnapshot {
|
|
96
|
+
collectedAt: string;
|
|
97
|
+
containerState: {
|
|
98
|
+
status: string;
|
|
99
|
+
startedAt?: string;
|
|
100
|
+
finishedAt?: string;
|
|
101
|
+
exitCode?: number;
|
|
102
|
+
oomKilled: boolean;
|
|
103
|
+
error?: string;
|
|
104
|
+
restartCount: number;
|
|
105
|
+
health?: string;
|
|
106
|
+
};
|
|
107
|
+
cpu: {
|
|
108
|
+
usagePercent: number;
|
|
109
|
+
allocated: number;
|
|
110
|
+
usagePercentOfAllocated: number;
|
|
111
|
+
cumulativeSeconds: number;
|
|
112
|
+
throttledPeriods: number;
|
|
113
|
+
throttledSeconds: number;
|
|
114
|
+
};
|
|
115
|
+
memory: {
|
|
116
|
+
usageBytes: number;
|
|
117
|
+
limitBytes: number;
|
|
118
|
+
usagePercent: number;
|
|
119
|
+
peakUsageBytes: number;
|
|
120
|
+
};
|
|
121
|
+
disk: {
|
|
122
|
+
usedBytes: number;
|
|
123
|
+
quotaBytes?: number;
|
|
124
|
+
usagePercent?: number;
|
|
125
|
+
};
|
|
126
|
+
network?: {
|
|
127
|
+
rxBytes: number;
|
|
128
|
+
txBytes: number;
|
|
129
|
+
};
|
|
130
|
+
blockIO: {
|
|
131
|
+
readBytes: number;
|
|
132
|
+
writeBytes: number;
|
|
133
|
+
};
|
|
134
|
+
pids: {
|
|
135
|
+
current: number;
|
|
136
|
+
limit: number;
|
|
137
|
+
};
|
|
138
|
+
gpu?: GpuMetricsSnapshot[];
|
|
139
|
+
}
|
|
84
140
|
export interface ComputeJob {
|
|
85
141
|
owner: string;
|
|
86
142
|
did?: string;
|
|
@@ -120,6 +176,7 @@ export interface NodeComputeJob extends ComputeJob {
|
|
|
120
176
|
queueMaxWaitTime?: number;
|
|
121
177
|
jobIdHash?: string;
|
|
122
178
|
maxJobDuration?: number;
|
|
179
|
+
runtimeMetrics?: ContainerMetricsSnapshot;
|
|
123
180
|
}
|
|
124
181
|
export interface ComputeOutputEncryption {
|
|
125
182
|
encryptMethod: EncryptMethod.AES;
|
|
@@ -4,6 +4,8 @@ export interface PolicyServerPassthroughCommand {
|
|
|
4
4
|
export interface PolicyServerInitializeCommand {
|
|
5
5
|
documentId?: string;
|
|
6
6
|
serviceId?: string;
|
|
7
|
-
consumerAddress?: string;
|
|
8
7
|
policyServer?: any;
|
|
8
|
+
consumerAddress?: string;
|
|
9
|
+
nonce?: string;
|
|
10
|
+
signature?: string;
|
|
9
11
|
}
|
|
@@ -36,11 +36,6 @@ export interface ProviderComputeInitializeResults {
|
|
|
36
36
|
datasets?: ProviderComputeInitialize[];
|
|
37
37
|
payment?: ProviderComputeInitializePayment;
|
|
38
38
|
}
|
|
39
|
-
export interface ServiceEndpoint {
|
|
40
|
-
serviceName: string;
|
|
41
|
-
method: string;
|
|
42
|
-
urlPath: string;
|
|
43
|
-
}
|
|
44
39
|
export interface NodeP2P {
|
|
45
40
|
nodeId: string;
|
|
46
41
|
multiaddress?: Multiaddr[];
|
|
@@ -119,6 +114,7 @@ export declare const PROTOCOL_COMMANDS: {
|
|
|
119
114
|
HANDLE_INDEXING_THREAD: string;
|
|
120
115
|
COLLECT_FEES: string;
|
|
121
116
|
POLICY_SERVER_PASSTHROUGH: string;
|
|
117
|
+
POLICY_SERVER_INITIALIZE: string;
|
|
122
118
|
GET_P2P_PEER: string;
|
|
123
119
|
GET_P2P_PEERS: string;
|
|
124
120
|
GET_P2P_NETWORK_STATS: string;
|
|
@@ -141,7 +137,9 @@ export declare const PROTOCOL_COMMANDS: {
|
|
|
141
137
|
SERVICE_STOP: string;
|
|
142
138
|
SERVICE_RESTART: string;
|
|
143
139
|
SERVICE_GET_STATUS: string;
|
|
140
|
+
SERVICE_LIST: string;
|
|
144
141
|
SERVICE_EXTEND: string;
|
|
142
|
+
SERVICE_GET_STREAMABLE_LOGS: string;
|
|
145
143
|
};
|
|
146
144
|
export interface NodeLogsParams {
|
|
147
145
|
logId?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComputeResourceRequest } from './Compute.js';
|
|
1
|
+
import { ComputeResourceRequest, ContainerMetricsSnapshot } from './Compute.js';
|
|
2
2
|
export interface TemplateResourceRequirement {
|
|
3
3
|
id?: string;
|
|
4
4
|
kind?: 'discrete' | 'fungible';
|
|
@@ -13,6 +13,12 @@ export interface UserConfigurableEnvVar {
|
|
|
13
13
|
validation?: string;
|
|
14
14
|
sensitive?: boolean;
|
|
15
15
|
}
|
|
16
|
+
export interface ServiceTemplateWorkflow {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
graph?: unknown;
|
|
21
|
+
}
|
|
16
22
|
export interface ServiceTemplatePublic {
|
|
17
23
|
id: string;
|
|
18
24
|
name?: string;
|
|
@@ -29,6 +35,7 @@ export interface ServiceTemplatePublic {
|
|
|
29
35
|
entrypoint?: string[];
|
|
30
36
|
requiredResources?: TemplateResourceRequirement[];
|
|
31
37
|
recommendedResources?: TemplateResourceRequirement[];
|
|
38
|
+
workflows?: ServiceTemplateWorkflow[];
|
|
32
39
|
}
|
|
33
40
|
export interface ServiceJobEndpoint {
|
|
34
41
|
containerPort: number;
|
|
@@ -45,6 +52,7 @@ export declare enum ServiceStatusNumber {
|
|
|
45
52
|
Locking = 20,
|
|
46
53
|
Claiming = 30,
|
|
47
54
|
Running = 40,
|
|
55
|
+
Restarting = 45,
|
|
48
56
|
Stopping = 50,
|
|
49
57
|
Stopped = 70,
|
|
50
58
|
Expired = 75,
|
|
@@ -76,6 +84,7 @@ export interface ServiceJob {
|
|
|
76
84
|
status: ServiceStatusNumber;
|
|
77
85
|
statusText: string;
|
|
78
86
|
dateCreated: string;
|
|
87
|
+
updatedAt?: number;
|
|
79
88
|
expiresAt: number;
|
|
80
89
|
duration: number;
|
|
81
90
|
exposedPorts: number[];
|
|
@@ -83,24 +92,37 @@ export interface ServiceJob {
|
|
|
83
92
|
resources: any[];
|
|
84
93
|
payment: ServiceJobPayment;
|
|
85
94
|
extendPayments?: ServiceJobPayment[];
|
|
95
|
+
runtimeMetrics?: ContainerMetricsSnapshot;
|
|
96
|
+
}
|
|
97
|
+
export type ServiceJobListed = Omit<ServiceJob, 'dockerCmd' | 'dockerEntrypoint' | 'dockerfile' | 'additionalDockerFiles' | 'runtimeMetrics'>;
|
|
98
|
+
export interface ServiceListFilters {
|
|
99
|
+
status?: ServiceStatusNumber;
|
|
100
|
+
includeAllStatuses?: boolean;
|
|
101
|
+
fromTimestamp?: string;
|
|
102
|
+
updatedSince?: string;
|
|
86
103
|
}
|
|
87
104
|
export interface ServicePayment {
|
|
88
105
|
chainId: number;
|
|
89
106
|
token: string;
|
|
90
107
|
}
|
|
91
108
|
export type ServiceUserData = Record<string, unknown>;
|
|
92
|
-
export interface
|
|
93
|
-
|
|
94
|
-
image: string;
|
|
109
|
+
export interface ServiceContainerSpec {
|
|
110
|
+
image?: string;
|
|
95
111
|
tag?: string;
|
|
96
112
|
checksum?: string;
|
|
97
113
|
dockerfile?: string;
|
|
98
114
|
additionalDockerFiles?: Record<string, string>;
|
|
115
|
+
userData?: ServiceUserData;
|
|
99
116
|
dockerCmd?: string[];
|
|
100
117
|
dockerEntrypoint?: string[];
|
|
118
|
+
}
|
|
119
|
+
export type ServiceRestartParams = ServiceContainerSpec;
|
|
120
|
+
export interface ServiceStartParams extends ServiceContainerSpec {
|
|
121
|
+
environment: string;
|
|
122
|
+
image: string;
|
|
101
123
|
exposedPorts?: number[];
|
|
102
124
|
resources?: ComputeResourceRequest[];
|
|
103
125
|
duration: number;
|
|
104
|
-
userData?: ServiceUserData;
|
|
105
126
|
payment: ServicePayment;
|
|
127
|
+
outputBucketId?: string;
|
|
106
128
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ComputeResultStream, ProviderInitialize, ProviderComputeInitializeResults,
|
|
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';
|
|
3
3
|
import { type DDO, type ValidateMetadata } from '@oceanprotocol/ddo-js';
|
|
4
4
|
import { P2pProvider, type P2PConfig, type P2PRequestBodyStream } from './P2pProvider.js';
|
|
5
5
|
export { OCEAN_P2P_PROTOCOL, type P2PConfig } from './P2pProvider.js';
|
|
@@ -13,7 +13,7 @@ export declare class BaseProvider {
|
|
|
13
13
|
private p2pProvider;
|
|
14
14
|
protected getImpl(node: OceanNode): any;
|
|
15
15
|
getP2PProvider(): P2pProvider;
|
|
16
|
-
getNonce(nodeUri: OceanNode, consumerAddress: string, signal?: AbortSignal
|
|
16
|
+
getNonce(nodeUri: OceanNode, consumerAddress: string, signal?: AbortSignal): Promise<number>;
|
|
17
17
|
encrypt(data: any, chainId: number, nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, policyServer?: any, signal?: AbortSignal): Promise<string>;
|
|
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[]>;
|
|
@@ -36,9 +36,28 @@ export declare class BaseProvider {
|
|
|
36
36
|
* @param {ComputeJob} job The compute job just started.
|
|
37
37
|
*/
|
|
38
38
|
private notifyIncentiveBackendJobStarted;
|
|
39
|
+
/**
|
|
40
|
+
* @param {OceanNode} nodeUri The provider URI the service runs on.
|
|
41
|
+
* @param {ServiceJob} service The service job just started.
|
|
42
|
+
*/
|
|
43
|
+
private notifyIncentiveBackendServiceStarted;
|
|
44
|
+
private notifyIncentiveBackendServiceRestarted;
|
|
39
45
|
computeStreamableLogs(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, signal?: AbortSignal): Promise<any>;
|
|
40
46
|
computeStop(jobId: string, nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, agreementId?: string, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
41
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Get compute status for a specific jobId/documentId/owner.
|
|
49
|
+
* @param {boolean} includeMetrics Owner-only runtime metrics (`runtimeMetrics`) on the
|
|
50
|
+
* returned job(s). To receive them, the node needs owner credentials: an auth token
|
|
51
|
+
* (`signerOrAuthToken` as a string) is ALWAYS sent, regardless of this flag; a `Signer`'s
|
|
52
|
+
* nonce+signature is only computed and sent when this flag is `true` (skipped otherwise
|
|
53
|
+
* to avoid an extra nonce round-trip on every plain status poll). Omitted (default): the
|
|
54
|
+
* node attaches metrics silently if valid owner credentials made it into the request
|
|
55
|
+
* (true automatically for token callers, false for `Signer` callers unless this flag is
|
|
56
|
+
* set), and returns exactly today's response otherwise. `true`: metrics are required —
|
|
57
|
+
* this method also computes the `Signer`'s signature, and the node answers 400/401 if
|
|
58
|
+
* credentials don't verify. `false`: metrics are never attached.
|
|
59
|
+
*/
|
|
60
|
+
computeStatus(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId?: string, agreementId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<NodeComputeJob | NodeComputeJob[]>;
|
|
42
61
|
getComputeResultUrl(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number): Promise<string>;
|
|
43
62
|
getComputeResult(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId: string, index: number, offset?: number): Promise<ComputeResultStream>;
|
|
44
63
|
generateAuthToken(consumer: Signer, nodeUri: OceanNode, signal?: AbortSignal): Promise<string>;
|
|
@@ -50,7 +69,7 @@ export declare class BaseProvider {
|
|
|
50
69
|
validateDdo(nodeUri: OceanNode, ddo: DDO, signerOrAuthToken: SignerOrAuthTokenOrSignature, signal?: AbortSignal): Promise<ValidateMetadata>;
|
|
51
70
|
isValidProvider(url: OceanNode, signal?: AbortSignal): Promise<boolean>;
|
|
52
71
|
PolicyServerPassthrough(nodeUri: OceanNode, request: PolicyServerPassthroughCommand, signal?: AbortSignal): Promise<any>;
|
|
53
|
-
initializePSVerification(nodeUri: OceanNode, request: PolicyServerInitializeCommand, signal?: AbortSignal): Promise<any>;
|
|
72
|
+
initializePSVerification(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, request: PolicyServerInitializeCommand, signal?: AbortSignal): Promise<any>;
|
|
54
73
|
downloadNodeLogs(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, startTime: string, endTime: string, maxLogs?: number, moduleName?: string, level?: string, page?: number, signal?: AbortSignal): Promise<NodeLogEntry[]>;
|
|
55
74
|
getNodeStatus(nodeUri: OceanNode, signal?: AbortSignal): Promise<NodeStatus>;
|
|
56
75
|
getNodeJobs(nodeUri: OceanNode, fromTimestamp?: number, signal?: AbortSignal): Promise<NodeComputeJob[]>;
|
|
@@ -77,8 +96,17 @@ export declare class BaseProvider {
|
|
|
77
96
|
serviceStart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, params: ServiceStartParams, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
78
97
|
serviceStop(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
79
98
|
serviceExtend(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, additionalDuration: number, payment: ServicePayment, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
80
|
-
serviceRestart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string,
|
|
81
|
-
|
|
99
|
+
serviceRestart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, params?: ServiceRestartParams, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Returns the caller's service jobs (userData stripped). Filter by `serviceId`,
|
|
102
|
+
* or omit it to list all of the caller's services. Requires a signature.
|
|
103
|
+
* @param {boolean} includeMetrics Owner-only runtime metrics (`runtimeMetrics`) on the
|
|
104
|
+
* returned service(s). This command is already authenticated, so metrics are included
|
|
105
|
+
* BY DEFAULT (omitted / `undefined`); pass `false` to opt out.
|
|
106
|
+
*/
|
|
107
|
+
getServiceStatus(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<ServiceJob[]>;
|
|
108
|
+
getServices(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, filters?: ServiceListFilters, signal?: AbortSignal): Promise<ServiceJobListed[]>;
|
|
109
|
+
serviceGetStreamableLogs(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, since?: string, signal?: AbortSignal): Promise<any>;
|
|
82
110
|
fetchConfig(nodeUri: OceanNode, payload: Record<string, any>): Promise<any>;
|
|
83
111
|
pushConfig(nodeUri: OceanNode, payload: Record<string, any>): Promise<any>;
|
|
84
112
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults,
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
@@ -181,9 +165,19 @@ export declare class HttpProvider {
|
|
|
181
165
|
* @param {string} jobId The ID of a compute job.
|
|
182
166
|
* @param {string} agreementId The ID of the service agreement (tx id)
|
|
183
167
|
* @param {AbortSignal} signal abort signal
|
|
184
|
-
* @
|
|
168
|
+
* @param {boolean} includeMetrics Owner-only runtime metrics (`runtimeMetrics`) on the
|
|
169
|
+
* returned job(s). To receive them, the node needs owner credentials: an auth token
|
|
170
|
+
* (`signerOrAuthToken` as a string) is ALWAYS sent, regardless of this flag; a `Signer`'s
|
|
171
|
+
* nonce+signature is only computed and sent when this flag is `true` (skipped otherwise
|
|
172
|
+
* to avoid an extra nonce round-trip on every plain status poll). Omitted (default): the
|
|
173
|
+
* node attaches metrics silently if valid owner credentials made it into the request
|
|
174
|
+
* (true automatically for token callers, false for `Signer` callers unless this flag is
|
|
175
|
+
* set), and returns exactly today's response otherwise. `true`: metrics are required —
|
|
176
|
+
* this method also computes the `Signer`'s signature, and the node answers 400/401 if
|
|
177
|
+
* credentials don't verify. `false`: metrics are never attached.
|
|
178
|
+
* @return {Promise<NodeComputeJob | NodeComputeJob[]>}
|
|
185
179
|
*/
|
|
186
|
-
computeStatus(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId?: string, agreementId?: string, signal?: AbortSignal): Promise<
|
|
180
|
+
computeStatus(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId?: string, agreementId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<NodeComputeJob | NodeComputeJob[]>;
|
|
187
181
|
/** Get compute result url
|
|
188
182
|
* @param {string} nodeUri The URI of the provider we want to query
|
|
189
183
|
* @param {SignerOrAuthToken} signerOrAuthToken signer or auth token
|
|
@@ -223,11 +217,17 @@ export declare class HttpProvider {
|
|
|
223
217
|
*/
|
|
224
218
|
PolicyServerPassthrough(nodeUri: string, request: PolicyServerPassthroughCommand, signal?: AbortSignal): Promise<any>;
|
|
225
219
|
/** Initialize Policy Server verification
|
|
220
|
+
*
|
|
221
|
+
* Authenticated exactly like `PolicyServerPassthrough`, but it is a distinct command, so
|
|
222
|
+
* the signed message uses its own command string:
|
|
223
|
+
* `consumerAddress + nonce + "PolicyServerInitialize"`. A signature is therefore scoped to
|
|
224
|
+
* one endpoint and cannot be replayed against the other.
|
|
226
225
|
* @param {string} nodeUri The provider URI.
|
|
226
|
+
* @param {SignerOrAuthTokenOrSignature} signerOrAuthToken The consumer signer object, auth token or signature.
|
|
227
227
|
* @param {PolicyServerInitializeCommand} request The request to be sent to the Policy Server.
|
|
228
228
|
* @param {AbortSignal} signal abort signal
|
|
229
229
|
*/
|
|
230
|
-
initializePSVerification(nodeUri: string, request: PolicyServerInitializeCommand, signal?: AbortSignal): Promise<any>;
|
|
230
|
+
initializePSVerification(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, request: PolicyServerInitializeCommand, signal?: AbortSignal): Promise<any>;
|
|
231
231
|
/**
|
|
232
232
|
* Download node logs as an admin.
|
|
233
233
|
* @param {string} nodeUri - The provider URI.
|
|
@@ -260,7 +260,6 @@ export declare class HttpProvider {
|
|
|
260
260
|
uploadPersistentStorageFile(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, bucketId: string, fileName: string, content: P2PRequestBodyStream, signal?: AbortSignal): Promise<PersistentStorageFileEntry>;
|
|
261
261
|
deletePersistentStorageFile(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, bucketId: string, fileName: string, signal?: AbortSignal): Promise<PersistentStorageDeleteFileResponse>;
|
|
262
262
|
updatePersistentStorageBucket(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, bucketId: string, label: string | null, signal?: AbortSignal): Promise<PersistentStorageUpdateBucketResponse>;
|
|
263
|
-
private resolveServiceRoute;
|
|
264
263
|
private encryptServiceUserData;
|
|
265
264
|
private buildQuery;
|
|
266
265
|
/**
|
|
@@ -291,15 +290,36 @@ export declare class HttpProvider {
|
|
|
291
290
|
*/
|
|
292
291
|
serviceExtend(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, additionalDuration: number, payment: ServicePayment, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
293
292
|
/**
|
|
294
|
-
* Restarts a running service (recreates the container)
|
|
295
|
-
*
|
|
293
|
+
* Restarts a running service (recreates the container) while keeping the same serviceId,
|
|
294
|
+
* payment, resources, host port(s) and expiry.
|
|
295
|
+
*
|
|
296
|
+
* The node treats the restart atomically. Passing no container-spec fields in `params`
|
|
297
|
+
* (REUSE mode) bounces the container on its stored spec unchanged. Passing ANY of
|
|
298
|
+
* `image`/`tag`/`checksum`/`dockerfile`/`additionalDockerFiles` (RESPEC mode) rebuilds the
|
|
299
|
+
* container entirely from `params`: `image` becomes mandatory, exactly one of
|
|
300
|
+
* `tag`/`checksum`/`dockerfile` applies, and a `dockerfile` requires `allowImageBuild` on
|
|
301
|
+
* the env (else the node replies 403). `userData`/`dockerCmd`/`dockerEntrypoint` are only
|
|
302
|
+
* sent when supplied — an omitted override reuses the node's stored value, whereas an
|
|
303
|
+
* explicit value (including `[]`) REPLACES it (matches ocean-node's restartService semantics).
|
|
296
304
|
* @return {Promise<ServiceJob[]>} The restarted service job (single-element array).
|
|
297
305
|
*/
|
|
298
|
-
serviceRestart(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string,
|
|
306
|
+
serviceRestart(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, params?: ServiceRestartParams, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
299
307
|
/**
|
|
300
308
|
* Returns the caller's service jobs (userData stripped). Filter by `serviceId`,
|
|
301
309
|
* or omit it to list all of the caller's services. Requires a signature.
|
|
310
|
+
* @param {boolean} includeMetrics Owner-only runtime metrics (`runtimeMetrics`) on the
|
|
311
|
+
* returned service(s). This command is already authenticated, so metrics are included
|
|
312
|
+
* BY DEFAULT (omitted / `undefined`); pass `false` to opt out.
|
|
302
313
|
* @return {Promise<ServiceJob[]>} The matching service jobs.
|
|
303
314
|
*/
|
|
304
|
-
getServiceStatus(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId?: string, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
315
|
+
getServiceStatus(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<ServiceJob[]>;
|
|
316
|
+
/**
|
|
317
|
+
* Node-wide service listing (SERVICE_LIST). Authenticated but NOT owner-scoped: any
|
|
318
|
+
* consumer identity sees every owner's services, listing-sanitized (no userData, no
|
|
319
|
+
* dockerCmd/dockerEntrypoint, no Dockerfile). Default (no filters) returns only the
|
|
320
|
+
* services currently holding a resource reservation; see ServiceListFilters.
|
|
321
|
+
* @return {Promise<ServiceJobListed[]>} The matching service jobs.
|
|
322
|
+
*/
|
|
323
|
+
getServices(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, filters?: ServiceListFilters, signal?: AbortSignal): Promise<ServiceJobListed[]>;
|
|
324
|
+
serviceGetStreamableLogs(nodeUri: string, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, since?: string, signal?: AbortSignal): Promise<any>;
|
|
305
325
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Libp2p, type Libp2pOptions } from 'libp2p';
|
|
2
2
|
import { Signer } from 'ethers';
|
|
3
|
-
import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, DownloadResponse, ComputeResultStream, NodeStatus, NodeComputeJob, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceTemplatePublic, ServiceStartParams,
|
|
3
|
+
import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth, DownloadResponse, ComputeResultStream, NodeStatus, NodeComputeJob, PersistentStorageAccessList, PersistentStorageBucket, PersistentStorageCreateBucketRequest, PersistentStorageDeleteFileResponse, PersistentStorageFileEntry, PersistentStorageObject, PersistentStorageUpdateBucketResponse, ServiceJob, ServiceJobListed, ServiceListFilters, ServiceRestartParams, ServiceTemplatePublic, ServiceStartParams, ServicePayment, OceanNode, SignerOrAuthTokenOrSignature } from '../../@types/index.js';
|
|
4
4
|
import { NodeLogEntry } from '../../@types/Provider.js';
|
|
5
5
|
import { type DDO, type ValidateMetadata } from '@oceanprotocol/ddo-js';
|
|
6
6
|
import { CID } from 'multiformats/cid';
|
|
@@ -145,8 +145,18 @@ export declare class P2pProvider {
|
|
|
145
145
|
computeStop(jobId: string, nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, agreementId?: string, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
146
146
|
/**
|
|
147
147
|
* Get compute status via P2P.
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
* @param {boolean} includeMetrics Owner-only runtime metrics (`runtimeMetrics`) on the
|
|
149
|
+
* returned job(s). To receive them, the node needs owner credentials: an auth token
|
|
150
|
+
* (`signerOrAuthToken` as a string) is ALWAYS sent, regardless of this flag; a `Signer`'s
|
|
151
|
+
* nonce+signature is only computed and sent when this flag is `true` (skipped otherwise
|
|
152
|
+
* to avoid an extra nonce round-trip on every plain status poll). Omitted (default): the
|
|
153
|
+
* node attaches metrics silently if valid owner credentials made it into the request
|
|
154
|
+
* (true automatically for token callers, false for `Signer` callers unless this flag is
|
|
155
|
+
* set), and returns exactly today's response otherwise. `true`: metrics are required —
|
|
156
|
+
* this method also computes the `Signer`'s signature, and the node answers 400/401 if
|
|
157
|
+
* credentials don't verify. `false`: metrics are never attached.
|
|
158
|
+
*/
|
|
159
|
+
computeStatus(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, jobId?: string, agreementId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<NodeComputeJob | NodeComputeJob[]>;
|
|
150
160
|
/**
|
|
151
161
|
* Get compute result as an async generator of Uint8Array chunks via P2P.
|
|
152
162
|
* Supports resumable downloads via `offset` (byte position to resume from).
|
|
@@ -185,8 +195,11 @@ export declare class P2pProvider {
|
|
|
185
195
|
PolicyServerPassthrough(nodeUri: OceanNode, request: PolicyServerPassthroughCommand, signal?: AbortSignal): Promise<any>;
|
|
186
196
|
/**
|
|
187
197
|
* Initialize Policy Server verification via P2P.
|
|
198
|
+
*
|
|
199
|
+
* A distinct command from the passthrough, so the signed message uses its own command
|
|
200
|
+
* string: `consumerAddress + nonce + "PolicyServerInitialize"`.
|
|
188
201
|
*/
|
|
189
|
-
initializePSVerification(nodeUri: OceanNode, request: PolicyServerInitializeCommand, signal?: AbortSignal): Promise<any>;
|
|
202
|
+
initializePSVerification(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, request: PolicyServerInitializeCommand, signal?: AbortSignal): Promise<any>;
|
|
190
203
|
/**
|
|
191
204
|
* Download node logs via P2P.
|
|
192
205
|
*/
|
|
@@ -218,6 +231,23 @@ export declare class P2pProvider {
|
|
|
218
231
|
serviceStart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, params: ServiceStartParams, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
219
232
|
serviceStop(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
220
233
|
serviceExtend(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, additionalDuration: number, payment: ServicePayment, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
221
|
-
serviceRestart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string,
|
|
222
|
-
|
|
234
|
+
serviceRestart(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, params?: ServiceRestartParams, signal?: AbortSignal): Promise<ServiceJob[]>;
|
|
235
|
+
/**
|
|
236
|
+
* @param {boolean} includeMetrics Owner-only runtime metrics (`runtimeMetrics`) on the
|
|
237
|
+
* returned service(s). This command is already authenticated, so metrics are included
|
|
238
|
+
* BY DEFAULT (omitted / `undefined`); pass `false` to opt out.
|
|
239
|
+
*/
|
|
240
|
+
getServiceStatus(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId?: string, signal?: AbortSignal, includeMetrics?: boolean): Promise<ServiceJob[]>;
|
|
241
|
+
/**
|
|
242
|
+
* Node-wide service listing (SERVICE_LIST) via P2P. Authenticated but NOT owner-scoped:
|
|
243
|
+
* any consumer identity sees every owner's services, listing-sanitized (no userData, no
|
|
244
|
+
* dockerCmd/dockerEntrypoint, no Dockerfile). Default (no filters) returns only the
|
|
245
|
+
* services currently holding a resource reservation; see ServiceListFilters.
|
|
246
|
+
*/
|
|
247
|
+
getServices(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, filters?: ServiceListFilters, signal?: AbortSignal): Promise<ServiceJobListed[]>;
|
|
248
|
+
/**
|
|
249
|
+
* Stream a running service's container logs via P2P. `since` optionally bounds the lower time
|
|
250
|
+
* (Unix seconds, or a relative duration like '30s'/'2h'); omit for the full history then live.
|
|
251
|
+
*/
|
|
252
|
+
serviceGetStreamableLogs(nodeUri: OceanNode, signerOrAuthToken: SignerOrAuthTokenOrSignature, serviceId: string, since?: string, signal?: AbortSignal): Promise<any>;
|
|
223
253
|
}
|
|
@@ -4,3 +4,18 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export declare function sleep(ms: number): Promise<unknown>;
|
|
6
6
|
export declare function isDefined(something: any): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Returns a copy of the payload with every credential field redacted, at any depth.
|
|
9
|
+
*
|
|
10
|
+
* This must not mutate its input: the caller still needs the real credentials to send the
|
|
11
|
+
* request, and credentials also show up nested (the free-form `policyServer` /
|
|
12
|
+
* `policyServerPassthrough` blobs), so we rebuild containers instead of writing into them.
|
|
13
|
+
*
|
|
14
|
+
* Only plain objects and arrays are walked - Buffers, typed arrays, Dates, streams and the
|
|
15
|
+
* like are passed through untouched.
|
|
16
|
+
*
|
|
17
|
+
* @param {any} value - the payload to redact
|
|
18
|
+
* @param {WeakSet<object>} seen - internal cycle guard
|
|
19
|
+
* @return {any} a redacted copy, safe to log
|
|
20
|
+
*/
|
|
21
|
+
export declare function redactSensitiveFields(value: any, seen?: WeakSet<object>): any;
|
package/package.json
CHANGED