@oceanprotocol/lib 6.0.0 → 6.1.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 +18 -2
- package/ComputeExamples.md +20 -27
- 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/Compute.d.ts +10 -41
- package/dist/types/@types/Datatoken.d.ts +7 -2
- package/dist/types/@types/File.d.ts +33 -40
- package/dist/types/services/Provider.d.ts +11 -22
- package/dist/types/utils/Assets.d.ts +3 -2
- package/dist/types/utils/eciesencrypt.d.ts +4 -2
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
99
|
-
|
|
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?:
|
|
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?:
|
|
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?:
|
|
17
|
+
filesObject?: AssetFiles;
|
|
13
18
|
accessListFactory?: string;
|
|
14
19
|
allowAccessList?: string;
|
|
15
20
|
denyAccessList?: string;
|
|
@@ -1,48 +1,41 @@
|
|
|
1
|
-
interface
|
|
1
|
+
export interface HeadersObject {
|
|
2
2
|
[key: string]: string;
|
|
3
3
|
}
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
|
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
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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 {
|
|
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 {
|
|
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:
|
|
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,
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
type PublicKeyInput = string | Uint8Array | number[] | Record<number, number>;
|
|
1
2
|
/**
|
|
2
3
|
* @dev eciesencrypt
|
|
3
4
|
* Encrypt content using ECIES and return the encrypted content as a hex string
|
|
4
5
|
*
|
|
5
|
-
* @param publicKey public key string
|
|
6
|
+
* @param publicKey public key as hex string, byte array, or numeric-key object
|
|
6
7
|
* @param content content to encrypt
|
|
7
8
|
*/
|
|
8
|
-
export declare function eciesencrypt(publicKey:
|
|
9
|
+
export declare function eciesencrypt(publicKey: PublicKeyInput, content: string): string;
|
|
10
|
+
export {};
|