@oceanprotocol/lib 5.1.3 → 6.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,4 +1,5 @@
1
- import { Metadata, MetadataAlgorithm, ConsumerParameter } from '@oceanprotocol/ddo-js';
1
+ import { MetadataAlgorithm, ConsumerParameter } from '@oceanprotocol/ddo-js';
2
+ import { StorageObject, EncryptMethod } from './File';
2
3
  export type ComputeResultType = 'algorithmLog' | 'output' | 'configrationLog' | 'publishLog';
3
4
  export interface RunningPlatform {
4
5
  architecture: string;
@@ -94,48 +95,16 @@ export interface ComputeJob {
94
95
  OOMKilled?: boolean;
95
96
  };
96
97
  }
98
+ export interface ComputeOutputEncryption {
99
+ encryptMethod: EncryptMethod.AES;
100
+ key: string;
101
+ }
97
102
  export interface ComputeOutput {
98
- publishAlgorithmLog?: boolean;
99
- publishOutput?: boolean;
100
- providerAddress?: string;
101
- providerUri?: string;
102
- metadata?: Metadata;
103
- metadataUri?: string;
104
- nodeUri?: string;
105
- owner?: string;
106
- secretStoreUri?: string;
107
- whitelist?: string[];
108
- }
109
- export declare enum FileObjectType {
110
- URL = "url",
111
- IPFS = "ipfs",
112
- ARWEAVE = "arweave"
113
- }
114
- export declare enum EncryptMethod {
115
- AES = "AES",
116
- ECIES = "ECIES"
117
- }
118
- export interface HeadersObject {
119
- [key: string]: string;
120
- }
121
- export interface BaseFileObject {
122
- type: string;
123
- encryptedBy?: string;
124
- encryptMethod?: EncryptMethod;
125
- }
126
- export interface UrlFileObject extends BaseFileObject {
127
- url: string;
128
- method: string;
129
- headers?: [HeadersObject];
130
- }
131
- export interface IpfsFileObject extends BaseFileObject {
132
- hash: string;
133
- }
134
- export interface ArweaveFileObject extends BaseFileObject {
135
- transactionId: string;
103
+ remoteStorage?: StorageObject;
104
+ encryption?: ComputeOutputEncryption;
136
105
  }
137
106
  export interface ComputeAsset {
138
- fileObject?: BaseFileObject;
107
+ fileObject?: StorageObject;
139
108
  documentId: string;
140
109
  serviceId: string;
141
110
  transferTxId?: string;
@@ -157,7 +126,7 @@ export interface ExtendedMetadataAlgorithm extends MetadataAlgorithm {
157
126
  };
158
127
  }
159
128
  export interface ComputeAlgorithm {
160
- fileObject?: BaseFileObject;
129
+ fileObject?: StorageObject;
161
130
  documentId?: string;
162
131
  serviceId?: string;
163
132
  meta?: ExtendedMetadataAlgorithm;
@@ -181,3 +150,8 @@ export interface ValidationResponse {
181
150
  isValid: boolean;
182
151
  message: string;
183
152
  }
153
+ export interface dockerRegistryAuth {
154
+ username?: string;
155
+ password?: string;
156
+ auth?: string;
157
+ }
@@ -1,4 +1,9 @@
1
- import { ProviderFees } from '.';
1
+ import { ProviderFees, StorageObject } from '.';
2
+ export interface AssetFiles {
3
+ nftAddress: string;
4
+ datatokenAddress: string;
5
+ files: StorageObject[];
6
+ }
2
7
  export interface DatatokenCreateParams {
3
8
  templateIndex: number;
4
9
  minter: string;
@@ -9,7 +14,7 @@ export interface DatatokenCreateParams {
9
14
  cap: string;
10
15
  name?: string;
11
16
  symbol?: string;
12
- filesObject?: any;
17
+ filesObject?: AssetFiles;
13
18
  accessListFactory?: string;
14
19
  allowAccessList?: string;
15
20
  denyAccessList?: string;
@@ -1,48 +1,41 @@
1
- interface FileTypeHeaders {
1
+ export interface HeadersObject {
2
2
  [key: string]: string;
3
3
  }
4
- export interface UrlFile {
5
- type: 'url';
6
- /**
7
- * File index.
8
- * @type {number}
9
- */
10
- index?: number;
11
- /**
12
- * File URL.
13
- * @type {string}
14
- */
4
+ export declare enum EncryptMethod {
5
+ AES = "AES",
6
+ ECIES = "ECIES"
7
+ }
8
+ export interface BaseFileObject {
9
+ type: string;
10
+ encryptedBy?: string;
11
+ encryptMethod?: EncryptMethod;
12
+ }
13
+ export interface UrlFileObject extends BaseFileObject {
15
14
  url: string;
16
- /**
17
- * HTTP method used
18
- * @type {string}
19
- */
20
15
  method: string;
21
- /**
22
- * Headers key value pairs associated with the asset GET request
23
- * @type {string}
24
- */
25
- headers?: FileTypeHeaders;
26
- }
27
- export interface Arweave {
28
- type: 'arweave';
29
- /**
30
- * transactionId
31
- * @type {string}
32
- */
33
- transactionId: string;
16
+ headers?: HeadersObject;
34
17
  }
35
- export interface Ipfs {
36
- type: 'ipfs';
37
- /**
38
- * hash
39
- * @type {string}
40
- */
18
+ export interface IpfsFileObject extends BaseFileObject {
41
19
  hash: string;
42
20
  }
43
- export interface Files {
44
- nftAddress: string;
45
- datatokenAddress: string;
46
- files: UrlFile[] | Arweave[] | Ipfs[];
21
+ export interface ArweaveFileObject extends BaseFileObject {
22
+ transactionId: string;
23
+ }
24
+ export interface S3Object {
25
+ endpoint: string;
26
+ region?: string;
27
+ objectKey: string;
28
+ bucket: string;
29
+ accessKeyId: string;
30
+ secretAccessKey: string;
31
+ /** If true, use path-style addressing (e.g. endpoint/bucket/key). Required for some S3-compatible services (e.g. MinIO). Default false (virtual-host style, e.g. bucket.endpoint/key). */
32
+ forcePathStyle?: boolean;
33
+ }
34
+ export interface S3FileObject extends BaseFileObject {
35
+ s3Access: S3Object;
36
+ }
37
+ export interface FtpFileObject extends BaseFileObject {
38
+ /** Full FTP or FTPS URL: ftp://[user:password@]host[:port]/path or ftps://... */
39
+ url: string;
47
40
  }
48
- export {};
41
+ export type StorageObject = UrlFileObject | IpfsFileObject | ArweaveFileObject | S3FileObject | FtpFileObject;
@@ -40,3 +40,42 @@ export interface ServiceEndpoint {
40
40
  export interface UserCustomParameters {
41
41
  [key: string]: any;
42
42
  }
43
+ export declare const PROTOCOL_COMMANDS: {
44
+ DOWNLOAD: string;
45
+ ENCRYPT: string;
46
+ ENCRYPT_FILE: string;
47
+ DECRYPT_DDO: string;
48
+ GET_DDO: string;
49
+ QUERY: string;
50
+ NONCE: string;
51
+ STATUS: string;
52
+ DETAILED_STATUS: string;
53
+ FIND_DDO: string;
54
+ GET_FEES: string;
55
+ FILE_INFO: string;
56
+ VALIDATE_DDO: string;
57
+ COMPUTE_GET_ENVIRONMENTS: string;
58
+ COMPUTE_START: string;
59
+ FREE_COMPUTE_START: string;
60
+ COMPUTE_STOP: string;
61
+ COMPUTE_GET_STATUS: string;
62
+ COMPUTE_GET_STREAMABLE_LOGS: string;
63
+ COMPUTE_GET_RESULT: string;
64
+ COMPUTE_INITIALIZE: string;
65
+ STOP_NODE: string;
66
+ REINDEX_TX: string;
67
+ REINDEX_CHAIN: string;
68
+ HANDLE_INDEXING_THREAD: string;
69
+ COLLECT_FEES: string;
70
+ POLICY_SERVER_PASSTHROUGH: string;
71
+ GET_P2P_PEER: string;
72
+ GET_P2P_PEERS: string;
73
+ GET_P2P_NETWORK_STATS: string;
74
+ FIND_PEER: string;
75
+ CREATE_AUTH_TOKEN: string;
76
+ INVALIDATE_AUTH_TOKEN: string;
77
+ FETCH_CONFIG: string;
78
+ PUSH_CONFIG: string;
79
+ GET_LOGS: string;
80
+ JOBS: string;
81
+ };
@@ -16,6 +16,7 @@ export declare class Aquarius {
16
16
  * @param {String} aquariusURL
17
17
  */
18
18
  constructor(aquariusURL: string);
19
+ private getAuthorization;
19
20
  /** Resolves a DID
20
21
  * @param {string} did DID of the asset.
21
22
  * @param {AbortSignal} signal abort signal
@@ -1,5 +1,5 @@
1
1
  import { Signer } from 'ethers';
2
- import { Arweave, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, ServiceEndpoint, UrlFile, UserCustomParameters, Ipfs, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand } from '../@types';
2
+ import { StorageObject, FileInfo, ComputeJob, ComputeOutput, ComputeAlgorithm, ComputeAsset, ComputeEnvironment, ProviderInitialize, ProviderComputeInitializeResults, ServiceEndpoint, UserCustomParameters, ComputeResourceRequest, ComputeJobMetadata, PolicyServerInitializeCommand, PolicyServerPassthroughCommand, dockerRegistryAuth } from '../@types';
3
3
  export declare class Provider {
4
4
  private getConsumerAddress;
5
5
  private getSignature;
@@ -10,6 +10,11 @@ export declare class Provider {
10
10
  * @return {Promise<any>}
11
11
  */
12
12
  getEndpoints(providerUri: string, authorization?: string): Promise<any>;
13
+ /**
14
+ * Returns the node public key
15
+ * @return {string} The node public key
16
+ */
17
+ private getNodePublicKey;
13
18
  /**
14
19
  * This function returns the endpoint URL for a given service name.
15
20
  * @param {ServiceEndpoint[]} servicesEndpoints - The array of service endpoints
@@ -34,13 +39,6 @@ export declare class Provider {
34
39
  * @return {Promise<string>} urlDetails
35
40
  */
36
41
  getNonce(providerUri: string, consumerAddress: string, signal?: AbortSignal, providerEndpoints?: any, serviceEndpoints?: ServiceEndpoint[]): Promise<number>;
37
- /**
38
- * Sign a provider request with a signer.
39
- * @param {Signer} signer - The signer to use.
40
- * @param {string} message - The message to sign.
41
- * @returns {Promise<string>} A promise that resolves with the signature.
42
- */
43
- signProviderRequest(signer: Signer, message: string): Promise<string>;
44
42
  /**
45
43
  * Encrypt data using the Provider's own symmetric key
46
44
  * @param {string} data data in json format that needs to be sent , it can either be a DDO or a File array
@@ -62,13 +60,13 @@ export declare class Provider {
62
60
  checkDidFiles(did: string, serviceId: string, providerUri: string, withChecksum?: boolean, signal?: AbortSignal): Promise<FileInfo[]>;
63
61
  /**
64
62
  * Get File details (if possible)
65
- * @param {UrlFile | Arweave | Ipfs | GraphqlQuery | Smartcontract} file one of the supported file structures
63
+ * @param {StorageObject} file one of the supported file structures
66
64
  * @param {string} providerUri uri of the provider that will be used to check the file
67
65
  * @param {boolean} [withChecksum=false] - Whether or not to include a checksum.
68
66
  * @param {AbortSignal} [signal] - An optional abort signal.
69
67
  * @returns {Promise<FileInfo[]>} A promise that resolves with an array of file info objects.
70
68
  */
71
- getFileInfo(file: UrlFile | Arweave | Ipfs, providerUri: string, withChecksum?: boolean, signal?: AbortSignal): Promise<FileInfo[]>;
69
+ getFileInfo(file: StorageObject, providerUri: string, withChecksum?: boolean, signal?: AbortSignal): Promise<FileInfo[]>;
72
70
  /**
73
71
  * Returns compute environments from a provider.
74
72
  * @param {string} providerUri - The URI of the provider.
@@ -115,9 +113,10 @@ export declare class Provider {
115
113
  * @param {number} chainId The chain used to do payments
116
114
  * @param {any} policyServer Policy server data.
117
115
  * @param {AbortSignal} signal abort signal
116
+ * @param {dockerRegistryAuth} dockerRegistryAuth Docker registry authentication data.
118
117
  * @return {Promise<ProviderComputeInitialize>} ProviderComputeInitialize data
119
118
  */
120
- initializeCompute(assets: ComputeAsset[], algorithm: ComputeAlgorithm, computeEnv: string, token: string, validUntil: number, providerUri: string, signerOrAuthToken: Signer | string, resources: ComputeResourceRequest[], chainId: number, policyServer?: any, signal?: AbortSignal): Promise<ProviderComputeInitializeResults>;
119
+ initializeCompute(assets: ComputeAsset[], algorithm: ComputeAlgorithm, computeEnv: string, token: string, validUntil: number, providerUri: string, signerOrAuthToken: Signer | string, resources: ComputeResourceRequest[], chainId: number, policyServer?: any, signal?: AbortSignal, dockerRegistryAuth?: dockerRegistryAuth): Promise<ProviderComputeInitializeResults>;
121
120
  /**
122
121
  * Gets the download URL.
123
122
  * @param {string} did - The DID.
@@ -131,20 +130,7 @@ export declare class Provider {
131
130
  * @returns {Promise<any>} The download URL.
132
131
  */
133
132
  getDownloadUrl(did: string, serviceId: string, fileIndex: number, transferTxId: string, providerUri: string, signerOrAuthToken: Signer | string, policyServer?: any, userCustomParameters?: UserCustomParameters): Promise<any>;
134
- /** Instruct the provider to start a compute job (Old C2D V1) Kept for now, for backwards compatibility
135
- * @param {string} providerUri The provider URI.
136
- * @param {Signer} consumer The consumer signer object.
137
- * @param {string} computeEnv The compute environment.
138
- * @param {ComputeAsset} dataset The dataset to start compute on
139
- * @param {ComputeAlgorithm} algorithm The algorithm to start compute with.
140
- * @param {AbortSignal} signal abort signal
141
- * @param {ComputeAsset[]} additionalDatasets The additional datasets if that is the case.
142
- * @param {ComputeOutput} output The compute job output settings.
143
- * @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs.
144
- * @deprecated Use {@link computeStart} instead.
145
- */
146
- computeStartV1(providerUri: string, consumer: Signer, computeEnv: string, dataset: ComputeAsset, algorithm: ComputeAlgorithm, signal?: AbortSignal, additionalDatasets?: ComputeAsset[], output?: ComputeOutput): Promise<ComputeJob | ComputeJob[]>;
147
- /** Instruct the provider to start a PAYED compute job (new C2D V2)
133
+ /** Instruct the provider to start a PAYED compute job
148
134
  * @param {string} providerUri The provider URI.
149
135
  * @param {SignerOrAuthToken} signerOrAuthToken The consumer signer object or auth token.
150
136
  * @param {string} computeEnv The compute environment.
@@ -159,11 +145,12 @@ export declare class Provider {
159
145
  * @param {any} policyServer Policy server data.
160
146
  * @param {AbortSignal} signal abort signal
161
147
  * @param {number} queueMaxWaitTime Maximum time in seconds to wait in the compute queue if resources are not available
148
+ * @param {dockerRegistryAuth} dockerRegistryAuth Docker registry authentication data.
162
149
  * @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs.
163
150
  */
164
151
  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)
165
- metadata?: ComputeJobMetadata, additionalViewers?: string[], output?: ComputeOutput, policyServer?: any, signal?: AbortSignal, queueMaxWaitTime?: number): Promise<ComputeJob | ComputeJob[]>;
166
- /** Instruct the provider to start a FREE compute job (new C2D V2)
152
+ metadata?: ComputeJobMetadata, additionalViewers?: string[], output?: ComputeOutput, policyServer?: any, signal?: AbortSignal, queueMaxWaitTime?: number, dockerRegistryAuth?: dockerRegistryAuth): Promise<ComputeJob | ComputeJob[]>;
153
+ /** Instruct the provider to start a FREE compute job
167
154
  * @param {string} providerUri The provider URI.
168
155
  * @param {SignerOrAuthToken} signerOrAuthToken The consumer signer object or auth token.
169
156
  * @param {string} computeEnv The compute environment.
@@ -175,9 +162,10 @@ export declare class Provider {
175
162
  * @param {any} policyServer Policy server data.
176
163
  * @param {AbortSignal} signal abort signal
177
164
  * @param {number} queueMaxWaitTime Maximum time in seconds to wait in the compute queue if resources are not available
165
+ * @param {dockerRegistryAuth} dockerRegistryAuth Docker registry authentication data.
178
166
  * @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs.
179
167
  */
180
- freeComputeStart(providerUri: string, signerOrAuthToken: Signer | string, computeEnv: string, datasets: ComputeAsset[], algorithm: ComputeAlgorithm, resources?: ComputeResourceRequest[], metadata?: ComputeJobMetadata, additionalViewers?: string[], output?: ComputeOutput, policyServer?: any, signal?: AbortSignal, queueMaxWaitTime?: number): Promise<ComputeJob | ComputeJob[]>;
168
+ freeComputeStart(providerUri: string, signerOrAuthToken: Signer | string, computeEnv: string, datasets: ComputeAsset[], algorithm: ComputeAlgorithm, resources?: ComputeResourceRequest[], metadata?: ComputeJobMetadata, additionalViewers?: string[], output?: ComputeOutput, policyServer?: any, signal?: AbortSignal, queueMaxWaitTime?: number, dockerRegistryAuth?: dockerRegistryAuth): Promise<ComputeJob | ComputeJob[]>;
181
169
  /**
182
170
  *
183
171
  * @param providerUri provider URL
@@ -214,15 +202,6 @@ export declare class Provider {
214
202
  * @return {Promise<string>}
215
203
  */
216
204
  getComputeResultUrl(providerUri: string, signerOrAuthToken: Signer | string, jobId: string, index: number): Promise<string>;
217
- /** Deletes a compute job.
218
- * @param {string} did asset did
219
- * @param {SignerOrAuthToken} signerOrAuthToken signer or auth token
220
- * @param {string} jobId the compute job ID
221
- * @param {string} providerUri The URI of the provider we want to query
222
- * @param {AbortSignal} signal abort signal
223
- * @return {Promise<ComputeJob | ComputeJob[]>}
224
- */
225
- computeDelete(did: string, signerOrAuthToken: Signer | string, jobId: string, providerUri: string, signal?: AbortSignal): Promise<ComputeJob | ComputeJob[]>;
226
205
  /** Generates an auth token
227
206
  * @param {Signer} consumer consumer Signer wallet object
228
207
  * @param {string} providerUri The URI of the provider we want to query
@@ -1,6 +1,7 @@
1
1
  import { Signer } from 'ethers';
2
2
  import { Aquarius } from '../services/Aquarius.js';
3
3
  import { DDO } from '@oceanprotocol/ddo-js';
4
+ import { StorageObject } from '../@types/File.js';
4
5
  export declare const DEVELOPMENT_CHAIN_ID = 8996;
5
6
  export declare function useOasisSDK(network: string | number): boolean;
6
7
  /**
@@ -8,7 +9,7 @@ export declare function useOasisSDK(network: string | number): boolean;
8
9
  * @param name asset name
9
10
  * @param symbol asse symbol
10
11
  * @param owner owner address
11
- * @param assetUrl asset url, if present and confidential evm, add it to token create params
12
+ * @param assetUrl An array of StorageObjects
12
13
  * @param templateIDorAddress either template address or id
13
14
  * @param ddo ddo
14
15
  * @param encryptDDO encrypt or not?
@@ -19,7 +20,7 @@ export declare function useOasisSDK(network: string | number): boolean;
19
20
  * @param denyAccessList?: string
20
21
  * @returns ddo id as string
21
22
  */
22
- export declare function createAsset(name: string, symbol: string, owner: Signer, assetUrl: any, // files object
23
+ export declare function createAsset(name: string, symbol: string, owner: Signer, assetUrls: StorageObject[], // files object
23
24
  templateIDorAddress: string | number, // If string, it's template address , otherwise, it's templateId
24
25
  ddo: DDO, encryptDDO: boolean, // default is true
25
26
  providerUrl: string, providerFeeToken: string, aquariusInstance: Aquarius, accessListFactory?: string, // access list factory address
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @dev eciesencrypt
3
+ * Encrypt content using ECIES and return the encrypted content as a hex string
4
+ *
5
+ * @param publicKey public key string '0x...'
6
+ * @param content content to encrypt
7
+ */
8
+ export declare function eciesencrypt(publicKey: string, content: string): string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oceanprotocol/lib",
3
3
  "source": "./src/index.ts",
4
- "version": "5.1.3",
4
+ "version": "6.1.0",
5
5
  "description": "JavaScript client library for Ocean Protocol",
6
6
  "main": "./dist/lib.cjs",
7
7
  "umd:main": "dist/lib.umd.js",
@@ -57,7 +57,7 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "@oasisprotocol/sapphire-paratime": "^1.3.2",
60
- "@oceanprotocol/contracts": "^2.5.0",
60
+ "@oceanprotocol/contracts": "^2.6.0",
61
61
  "@oceanprotocol/ddo-js": "^0.1.4",
62
62
  "@rdfjs/dataset": "^2.0.2",
63
63
  "@rdfjs/formats-common": "^3.1.0",
@@ -66,6 +66,7 @@
66
66
  "cross-fetch": "^4.0.0",
67
67
  "crypto-js": "^4.1.1",
68
68
  "decimal.js": "^10.4.1",
69
+ "eciesjs": "^0.4.5",
69
70
  "ethers": "^6.15.0",
70
71
  "form-data": "^2.3.3",
71
72
  "jsonwebtoken": "^9.0.2"