@oceanprotocol/lib 4.2.0 → 4.2.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/CHANGELOG.md +8 -0
- package/ComputeExamples.md +4 -1
- package/dist/lib.cjs +1 -1
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.modern.js +1 -1
- package/dist/lib.modern.js.map +1 -1
- package/dist/lib.module.mjs +1 -1
- package/dist/lib.module.mjs.map +1 -1
- package/dist/lib.umd.js +1 -1
- package/dist/lib.umd.js.map +1 -1
- package/dist/types/@types/Jwt.d.ts +5 -0
- package/dist/types/services/Provider.d.ts +31 -26
- package/dist/types/utils/Jwt.d.ts +2 -0
- package/package.json +4 -2
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
2
|
import { Arweave, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, ServiceEndpoint, UrlFile, UserCustomParameters, Ipfs, ComputeResourceRequest } from '../@types';
|
|
3
3
|
export declare class Provider {
|
|
4
|
+
private getConsumerAddress;
|
|
5
|
+
private getSignature;
|
|
6
|
+
private getAuthorization;
|
|
4
7
|
/**
|
|
5
8
|
* Returns the provider endpoints
|
|
6
9
|
* @param {string} providerUri - the provider url
|
|
@@ -30,7 +33,7 @@ export declare class Provider {
|
|
|
30
33
|
* @param {string} serviceEndpoints document description object (DDO)=
|
|
31
34
|
* @return {Promise<string>} urlDetails
|
|
32
35
|
*/
|
|
33
|
-
getNonce(providerUri: string, consumerAddress: string, signal?: AbortSignal, providerEndpoints?: any, serviceEndpoints?: ServiceEndpoint[]
|
|
36
|
+
getNonce(providerUri: string, consumerAddress: string, signal?: AbortSignal, providerEndpoints?: any, serviceEndpoints?: ServiceEndpoint[]): Promise<number>;
|
|
34
37
|
/**
|
|
35
38
|
* Sign a provider request with a signer.
|
|
36
39
|
* @param {Signer} signer - The signer to use.
|
|
@@ -46,7 +49,7 @@ export declare class Provider {
|
|
|
46
49
|
* @param {AbortSignal} signal abort signal
|
|
47
50
|
* @return {Promise<string>} urlDetails
|
|
48
51
|
*/
|
|
49
|
-
encrypt(data: any, chainId: number, providerUri: string, signal?: AbortSignal
|
|
52
|
+
encrypt(data: any, chainId: number, providerUri: string, signal?: AbortSignal): Promise<string>;
|
|
50
53
|
/**
|
|
51
54
|
* Get file details for a given DID and service ID.
|
|
52
55
|
* @param {string} did - The DID to check.
|
|
@@ -56,7 +59,7 @@ export declare class Provider {
|
|
|
56
59
|
* @param {AbortSignal} [signal] - An optional abort signal.
|
|
57
60
|
* @returns {Promise<FileInfo[]>} A promise that resolves with an array of file info objects.
|
|
58
61
|
*/
|
|
59
|
-
checkDidFiles(did: string, serviceId: string, providerUri: string, withChecksum?: boolean, signal?: AbortSignal
|
|
62
|
+
checkDidFiles(did: string, serviceId: string, providerUri: string, withChecksum?: boolean, signal?: AbortSignal): Promise<FileInfo[]>;
|
|
60
63
|
/**
|
|
61
64
|
* Get File details (if possible)
|
|
62
65
|
* @param {UrlFile | Arweave | Ipfs | GraphqlQuery | Smartcontract} file one of the supported file structures
|
|
@@ -65,14 +68,14 @@ export declare class Provider {
|
|
|
65
68
|
* @param {AbortSignal} [signal] - An optional abort signal.
|
|
66
69
|
* @returns {Promise<FileInfo[]>} A promise that resolves with an array of file info objects.
|
|
67
70
|
*/
|
|
68
|
-
getFileInfo(file: UrlFile | Arweave | Ipfs, providerUri: string, withChecksum?: boolean, signal?: AbortSignal
|
|
71
|
+
getFileInfo(file: UrlFile | Arweave | Ipfs, providerUri: string, withChecksum?: boolean, signal?: AbortSignal): Promise<FileInfo[]>;
|
|
69
72
|
/**
|
|
70
73
|
* Returns compute environments from a provider.
|
|
71
74
|
* @param {string} providerUri - The URI of the provider.
|
|
72
75
|
* @param {AbortSignal} [signal] - An optional abort signal.
|
|
73
76
|
* @returns {Promise<{[chainId: number]: ComputeEnvironment[]}>} A promise that resolves with an object containing compute environments for each chain ID.
|
|
74
77
|
*/
|
|
75
|
-
getComputeEnvironments(providerUri: string, signal?: AbortSignal
|
|
78
|
+
getComputeEnvironments(providerUri: string, signal?: AbortSignal): Promise<ComputeEnvironment[]>;
|
|
76
79
|
/**
|
|
77
80
|
* Initializes the provider for a service request.
|
|
78
81
|
* @param {string} did - The asset DID .
|
|
@@ -86,7 +89,7 @@ export declare class Provider {
|
|
|
86
89
|
* @param {number} [validUntil] - The validity time if any.
|
|
87
90
|
* @returns {Promise<ProviderInitialize>} A promise that resolves with ProviderInitialize response.
|
|
88
91
|
*/
|
|
89
|
-
initialize(did: string, serviceId: string, fileIndex: number, consumerAddress: string, providerUri: string, signal?: AbortSignal, userCustomParameters?: UserCustomParameters, computeEnv?: string, validUntil?: number
|
|
92
|
+
initialize(did: string, serviceId: string, fileIndex: number, consumerAddress: string, providerUri: string, signal?: AbortSignal, userCustomParameters?: UserCustomParameters, computeEnv?: string, validUntil?: number): Promise<ProviderInitialize>;
|
|
90
93
|
/** Initializes the provider for a compute request.
|
|
91
94
|
* @param {ComputeAsset[]} assets The datasets array to initialize compute request.
|
|
92
95
|
* @param {ComputeAlgorithmber} algorithm The algorithm to use.
|
|
@@ -97,7 +100,7 @@ export declare class Provider {
|
|
|
97
100
|
* @param {AbortSignal} signal abort signal
|
|
98
101
|
* @return {Promise<ProviderComputeInitialize>} ProviderComputeInitialize data
|
|
99
102
|
*/
|
|
100
|
-
initializeComputeV1(assets: ComputeAsset[], algorithm: ComputeAlgorithm, computeEnv: string, providerUri: string, accountId: string, chainId: number, token: string, maxJobDuration: number, signal?: AbortSignal
|
|
103
|
+
initializeComputeV1(assets: ComputeAsset[], algorithm: ComputeAlgorithm, computeEnv: string, providerUri: string, accountId: string, chainId: number, token: string, maxJobDuration: number, signal?: AbortSignal): Promise<ProviderComputeInitializeResults>;
|
|
101
104
|
/** Initializes the provider for a compute request.
|
|
102
105
|
* @param {ComputeAsset[]} assets The datasets array to initialize compute request.
|
|
103
106
|
* @param {ComputeAlgorithmber} algorithm The algorithm to use.
|
|
@@ -105,11 +108,13 @@ export declare class Provider {
|
|
|
105
108
|
* @param {string} token The payment token address.
|
|
106
109
|
* @param {number} validUntil The job expiration date.
|
|
107
110
|
* @param {string} providerUri The provider URI.
|
|
108
|
-
* @param {
|
|
111
|
+
* @param {SignerOrAuthToken} signerOrAuthToken Signer or auth token
|
|
112
|
+
* @param {ComputeResourceRequest[]} resources The resources to start compute job with.
|
|
113
|
+
* @param {number} chainId The chain used to do payments
|
|
109
114
|
* @param {AbortSignal} signal abort signal
|
|
110
115
|
* @return {Promise<ProviderComputeInitialize>} ProviderComputeInitialize data
|
|
111
116
|
*/
|
|
112
|
-
initializeCompute(assets: ComputeAsset[], algorithm: ComputeAlgorithm, computeEnv: string, token: string, validUntil: number, providerUri: string,
|
|
117
|
+
initializeCompute(assets: ComputeAsset[], algorithm: ComputeAlgorithm, computeEnv: string, token: string, validUntil: number, providerUri: string, signerOrAuthToken: Signer | string, resources: ComputeResourceRequest[], chainId: number, signal?: AbortSignal): Promise<ProviderComputeInitializeResults>;
|
|
113
118
|
/**
|
|
114
119
|
* Gets the download URL.
|
|
115
120
|
* @param {string} did - The DID.
|
|
@@ -117,12 +122,12 @@ export declare class Provider {
|
|
|
117
122
|
* @param {number} fileIndex - The file index.
|
|
118
123
|
* @param {string} transferTxId - The transfer transaction ID.
|
|
119
124
|
* @param {string} providerUri - The provider URI.
|
|
120
|
-
* @param {
|
|
125
|
+
* @param {SignerOrAuthToken} signerOrAuthToken - The signer or auth token.
|
|
121
126
|
* @param {any} policyServer - The policy server (if any is to be used).
|
|
122
127
|
* @param {UserCustomParameters} userCustomParameters - The user custom parameters.
|
|
123
128
|
* @returns {Promise<any>} The download URL.
|
|
124
129
|
*/
|
|
125
|
-
getDownloadUrl(did: string, serviceId: string, fileIndex: number, transferTxId: string, providerUri: string,
|
|
130
|
+
getDownloadUrl(did: string, serviceId: string, fileIndex: number, transferTxId: string, providerUri: string, signerOrAuthToken: Signer | string, policyServer?: any, userCustomParameters?: UserCustomParameters): Promise<any>;
|
|
126
131
|
/** Instruct the provider to start a compute job (Old C2D V1) Kept for now, for backwards compatibility
|
|
127
132
|
* @param {string} providerUri The provider URI.
|
|
128
133
|
* @param {Signer} signer The consumer signer object.
|
|
@@ -135,10 +140,10 @@ export declare class Provider {
|
|
|
135
140
|
* @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs.
|
|
136
141
|
* @deprecated Use {@link computeStart} instead.
|
|
137
142
|
*/
|
|
138
|
-
computeStartV1(providerUri: string, consumer: Signer, computeEnv: string, dataset: ComputeAsset, algorithm: ComputeAlgorithm, signal?: AbortSignal, additionalDatasets?: ComputeAsset[], output?: ComputeOutput
|
|
143
|
+
computeStartV1(providerUri: string, consumer: Signer, computeEnv: string, dataset: ComputeAsset, algorithm: ComputeAlgorithm, signal?: AbortSignal, additionalDatasets?: ComputeAsset[], output?: ComputeOutput): Promise<ComputeJob | ComputeJob[]>;
|
|
139
144
|
/** Instruct the provider to start a PAYED compute job (new C2D V2)
|
|
140
145
|
* @param {string} providerUri The provider URI.
|
|
141
|
-
* @param {
|
|
146
|
+
* @param {SignerOrAuthToken} signerOrAuthToken The consumer signer object or auth token.
|
|
142
147
|
* @param {string} computeEnv The compute environment.
|
|
143
148
|
* @param {ComputeAsset} datasets The dataset to start compute on + additionalDatasets (the additional datasets if that is the case)
|
|
144
149
|
* @param {ComputeAlgorithm} algorithm The algorithm to start compute with.
|
|
@@ -150,11 +155,11 @@ export declare class Provider {
|
|
|
150
155
|
* @param {AbortSignal} signal abort signal
|
|
151
156
|
* @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs.
|
|
152
157
|
*/
|
|
153
|
-
computeStart(providerUri: string,
|
|
154
|
-
output?: ComputeOutput, signal?: AbortSignal
|
|
158
|
+
computeStart(providerUri: string, signerOrAuthToken: Signer | string, computeEnv: string, datasets: ComputeAsset[], algorithm: ComputeAlgorithm, maxJobDuration: number, token: string, resources: ComputeResourceRequest[], chainId: number, // network used by payment (only for payed compute jobs)
|
|
159
|
+
output?: ComputeOutput, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
155
160
|
/** Instruct the provider to start a FREE compute job (new C2D V2)
|
|
156
161
|
* @param {string} providerUri The provider URI.
|
|
157
|
-
* @param {
|
|
162
|
+
* @param {SignerOrAuthToken} signerOrAuthToken The consumer signer object or auth token.
|
|
158
163
|
* @param {string} computeEnv The compute environment.
|
|
159
164
|
* @param {ComputeAsset} datasets The dataset to start compute on + additionalDatasets (the additional datasets if that is the case)
|
|
160
165
|
* @param {ComputeAlgorithm} algorithm The algorithm to start compute with.
|
|
@@ -163,27 +168,27 @@ export declare class Provider {
|
|
|
163
168
|
* @param {AbortSignal} signal abort signal
|
|
164
169
|
* @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs.
|
|
165
170
|
*/
|
|
166
|
-
freeComputeStart(providerUri: string,
|
|
171
|
+
freeComputeStart(providerUri: string, signerOrAuthToken: Signer | string, computeEnv: string, datasets: ComputeAsset[], algorithm: ComputeAlgorithm, resources?: ComputeResourceRequest[], output?: ComputeOutput, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
167
172
|
/**
|
|
168
173
|
*
|
|
169
174
|
* @param providerUri provider URL
|
|
170
|
-
* @param
|
|
175
|
+
* @param signerOrAuthToken signer or auth token
|
|
171
176
|
* @param jobId jobId
|
|
172
177
|
* @param signal abort signal
|
|
173
178
|
* @returns logs response
|
|
174
179
|
*/
|
|
175
|
-
computeStreamableLogs(providerUri: string,
|
|
180
|
+
computeStreamableLogs(providerUri: string, signerOrAuthToken: Signer | string, jobId: string, signal?: AbortSignal): Promise<any>;
|
|
176
181
|
getComputeStartRoutes(providerUri: string, isFreeCompute?: boolean): Promise<string | null>;
|
|
177
182
|
/** Instruct the provider to Stop the execution of a to stop a compute job.
|
|
178
183
|
* @param {string} did the asset did
|
|
179
184
|
* @param {string} consumerAddress The consumer address.
|
|
180
185
|
* @param {string} jobId the compute job id
|
|
181
186
|
* @param {string} providerUri The provider URI.
|
|
182
|
-
* @param {
|
|
187
|
+
* @param {SignerOrAuthToken} signerOrAuthToken The consumer signer or auth token.
|
|
183
188
|
* @param {AbortSignal} signal abort signal
|
|
184
189
|
* @return {Promise<ComputeJob | ComputeJob[]>}
|
|
185
190
|
*/
|
|
186
|
-
computeStop(did: string, consumerAddress: string, jobId: string, providerUri: string,
|
|
191
|
+
computeStop(did: string, consumerAddress: string, jobId: string, providerUri: string, signerOrAuthToken: Signer | string, agreementId?: string, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
187
192
|
/** Get compute status for a specific jobId/documentId/owner.
|
|
188
193
|
* @param {string} providerUri The URI of the provider we want to query
|
|
189
194
|
* @param {string} consumerAddress The consumer ethereum address
|
|
@@ -195,21 +200,21 @@ export declare class Provider {
|
|
|
195
200
|
computeStatus(providerUri: string, consumerAddress: string, jobId?: string, agreementId?: string, signal?: AbortSignal, authorization?: string): Promise<ComputeJob | ComputeJob[]>;
|
|
196
201
|
/** Get compute result url
|
|
197
202
|
* @param {string} providerUri The URI of the provider we want to query
|
|
198
|
-
* @param {
|
|
203
|
+
* @param {SignerOrAuthToken} signerOrAuthToken signer or auth token
|
|
199
204
|
* @param {string} jobId The ID of a compute job.
|
|
200
205
|
* @param {number} index Result index
|
|
201
206
|
* @return {Promise<string>}
|
|
202
207
|
*/
|
|
203
|
-
getComputeResultUrl(providerUri: string,
|
|
208
|
+
getComputeResultUrl(providerUri: string, signerOrAuthToken: Signer | string, jobId: string, index: number): Promise<string>;
|
|
204
209
|
/** Deletes a compute job.
|
|
205
210
|
* @param {string} did asset did
|
|
206
|
-
* @param {
|
|
211
|
+
* @param {SignerOrAuthToken} signerOrAuthToken signer or auth token
|
|
207
212
|
* @param {string} jobId the compute job ID
|
|
208
213
|
* @param {string} providerUri The URI of the provider we want to query
|
|
209
214
|
* @param {AbortSignal} signal abort signal
|
|
210
215
|
* @return {Promise<ComputeJob | ComputeJob[]>}
|
|
211
216
|
*/
|
|
212
|
-
computeDelete(did: string,
|
|
217
|
+
computeDelete(did: string, signerOrAuthToken: Signer | string, jobId: string, providerUri: string, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
|
|
213
218
|
/** Generates an auth token
|
|
214
219
|
* @param {Signer} consumer consumer Signer wallet object
|
|
215
220
|
* @param {string} providerUri The URI of the provider we want to query
|
|
@@ -232,7 +237,7 @@ export declare class Provider {
|
|
|
232
237
|
* @param {AbortSignal} signal abort signal
|
|
233
238
|
* @return {Promise<boolean>} valid or not
|
|
234
239
|
*/
|
|
235
|
-
isValidProvider(url: string, signal?: AbortSignal
|
|
240
|
+
isValidProvider(url: string, signal?: AbortSignal): Promise<boolean>;
|
|
236
241
|
/**
|
|
237
242
|
* Private method that removes the leading 0x from a string.
|
|
238
243
|
* @param {string} input - The input string.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oceanprotocol/lib",
|
|
3
3
|
"source": "./src/index.ts",
|
|
4
|
-
"version": "4.2.
|
|
4
|
+
"version": "4.2.1",
|
|
5
5
|
"description": "JavaScript client library for Ocean Protocol",
|
|
6
6
|
"main": "./dist/lib.cjs",
|
|
7
7
|
"umd:main": "dist/lib.umd.js",
|
|
@@ -66,7 +66,8 @@
|
|
|
66
66
|
"crypto-js": "^4.1.1",
|
|
67
67
|
"decimal.js": "^10.4.1",
|
|
68
68
|
"ethers": "^5.7.2",
|
|
69
|
-
"form-data": "^2.3.3"
|
|
69
|
+
"form-data": "^2.3.3",
|
|
70
|
+
"jsonwebtoken": "^9.0.2"
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|
|
72
73
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
@@ -74,6 +75,7 @@
|
|
|
74
75
|
"@types/chai": "^4.3.1",
|
|
75
76
|
"@types/chai-spies": "^1.0.3",
|
|
76
77
|
"@types/crypto-js": "^4.1.1",
|
|
78
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
77
79
|
"@types/mocha": "^10.0.10",
|
|
78
80
|
"@types/node": "^18.0.1",
|
|
79
81
|
"@types/node-fetch": "^3.0.3",
|