@oceanprotocol/lib 6.0.0 → 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;
@@ -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;
@@ -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, dockerRegistryAuth } 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;
@@ -60,13 +60,13 @@ export declare class Provider {
60
60
  checkDidFiles(did: string, serviceId: string, providerUri: string, withChecksum?: boolean, signal?: AbortSignal): Promise<FileInfo[]>;
61
61
  /**
62
62
  * Get File details (if possible)
63
- * @param {UrlFile | Arweave | Ipfs | GraphqlQuery | Smartcontract} file one of the supported file structures
63
+ * @param {StorageObject} file one of the supported file structures
64
64
  * @param {string} providerUri uri of the provider that will be used to check the file
65
65
  * @param {boolean} [withChecksum=false] - Whether or not to include a checksum.
66
66
  * @param {AbortSignal} [signal] - An optional abort signal.
67
67
  * @returns {Promise<FileInfo[]>} A promise that resolves with an array of file info objects.
68
68
  */
69
- 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[]>;
70
70
  /**
71
71
  * Returns compute environments from a provider.
72
72
  * @param {string} providerUri - The URI of the provider.
@@ -112,11 +112,11 @@ export declare class Provider {
112
112
  * @param {ComputeResourceRequest[]} resources The resources to start compute job with.
113
113
  * @param {number} chainId The chain used to do payments
114
114
  * @param {any} policyServer Policy server data.
115
- * @param {dockerRegistryAuth} dockerRegistryAuth Docker registry authentication data.
116
115
  * @param {AbortSignal} signal abort signal
116
+ * @param {dockerRegistryAuth} dockerRegistryAuth Docker registry authentication data.
117
117
  * @return {Promise<ProviderComputeInitialize>} ProviderComputeInitialize data
118
118
  */
119
- initializeCompute(assets: ComputeAsset[], algorithm: ComputeAlgorithm, computeEnv: string, token: string, validUntil: number, providerUri: string, signerOrAuthToken: Signer | string, resources: ComputeResourceRequest[], chainId: number, policyServer?: any, dockerRegistryAuth?: dockerRegistryAuth, 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>;
120
120
  /**
121
121
  * Gets the download URL.
122
122
  * @param {string} did - The DID.
@@ -130,20 +130,7 @@ export declare class Provider {
130
130
  * @returns {Promise<any>} The download URL.
131
131
  */
132
132
  getDownloadUrl(did: string, serviceId: string, fileIndex: number, transferTxId: string, providerUri: string, signerOrAuthToken: Signer | string, policyServer?: any, userCustomParameters?: UserCustomParameters): Promise<any>;
133
- /** Instruct the provider to start a compute job (Old C2D V1) Kept for now, for backwards compatibility
134
- * @param {string} providerUri The provider URI.
135
- * @param {Signer} consumer The consumer signer object.
136
- * @param {string} computeEnv The compute environment.
137
- * @param {ComputeAsset} dataset The dataset to start compute on
138
- * @param {ComputeAlgorithm} algorithm The algorithm to start compute with.
139
- * @param {AbortSignal} signal abort signal
140
- * @param {ComputeAsset[]} additionalDatasets The additional datasets if that is the case.
141
- * @param {ComputeOutput} output The compute job output settings.
142
- * @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs.
143
- * @deprecated Use {@link computeStart} instead.
144
- */
145
- computeStartV1(providerUri: string, consumer: Signer, computeEnv: string, dataset: ComputeAsset, algorithm: ComputeAlgorithm, signal?: AbortSignal, additionalDatasets?: ComputeAsset[], output?: ComputeOutput): Promise<ComputeJob | ComputeJob[]>;
146
- /** Instruct the provider to start a PAYED compute job (new C2D V2)
133
+ /** Instruct the provider to start a PAYED compute job
147
134
  * @param {string} providerUri The provider URI.
148
135
  * @param {SignerOrAuthToken} signerOrAuthToken The consumer signer object or auth token.
149
136
  * @param {string} computeEnv The compute environment.
@@ -158,11 +145,12 @@ export declare class Provider {
158
145
  * @param {any} policyServer Policy server data.
159
146
  * @param {AbortSignal} signal abort signal
160
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.
161
149
  * @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs.
162
150
  */
163
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)
164
- metadata?: ComputeJobMetadata, additionalViewers?: string[], output?: ComputeOutput, policyServer?: any, signal?: AbortSignal, queueMaxWaitTime?: number): Promise<ComputeJob | ComputeJob[]>;
165
- /** 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
166
154
  * @param {string} providerUri The provider URI.
167
155
  * @param {SignerOrAuthToken} signerOrAuthToken The consumer signer object or auth token.
168
156
  * @param {string} computeEnv The compute environment.
@@ -174,9 +162,10 @@ export declare class Provider {
174
162
  * @param {any} policyServer Policy server data.
175
163
  * @param {AbortSignal} signal abort signal
176
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.
177
166
  * @return {Promise<ComputeJob | ComputeJob[]>} The compute job or jobs.
178
167
  */
179
- 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[]>;
180
169
  /**
181
170
  *
182
171
  * @param providerUri provider URL
@@ -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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oceanprotocol/lib",
3
3
  "source": "./src/index.ts",
4
- "version": "6.0.0",
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",