@iexec/web3mail 0.6.0 → 1.0.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.
- package/package.json +9 -5
- package/src/index.ts +1 -0
- package/src/utils/errors.ts +24 -6
- package/src/utils/index.ts +1 -0
- package/src/utils/subgraphQuery.ts +8 -8
- package/src/utils/validators.ts +13 -1
- package/src/web3mail/IExecWeb3mail.ts +16 -7
- package/src/web3mail/fetchMyContacts.ts +18 -18
- package/src/web3mail/fetchUserContacts.ts +22 -6
- package/src/web3mail/sendEmail.ts +16 -4
- package/src/web3mail/types.ts +9 -2
- package/dist/config/config.d.ts +0 -11
- package/dist/config/config.js +0 -12
- package/dist/config/config.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -4
- package/dist/index.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -5
- package/dist/utils/errors.js +0 -9
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/generateUniqueId.d.ts +0 -1
- package/dist/utils/generateUniqueId.js +0 -6
- package/dist/utils/generateUniqueId.js.map +0 -1
- package/dist/utils/getWeb3Provider.d.ts +0 -2
- package/dist/utils/getWeb3Provider.js +0 -3
- package/dist/utils/getWeb3Provider.js.map +0 -1
- package/dist/utils/ipfs-service.d.ts +0 -9
- package/dist/utils/ipfs-service.js +0 -29
- package/dist/utils/ipfs-service.js.map +0 -1
- package/dist/utils/paginate.d.ts +0 -5
- package/dist/utils/paginate.js +0 -23
- package/dist/utils/paginate.js.map +0 -1
- package/dist/utils/subgraphQuery.d.ts +0 -4
- package/dist/utils/subgraphQuery.js +0 -90
- package/dist/utils/subgraphQuery.js.map +0 -1
- package/dist/utils/validators.d.ts +0 -10
- package/dist/utils/validators.js +0 -27
- package/dist/utils/validators.js.map +0 -1
- package/dist/web3mail/IExecWeb3mail.d.ts +0 -15
- package/dist/web3mail/IExecWeb3mail.js +0 -40
- package/dist/web3mail/IExecWeb3mail.js.map +0 -1
- package/dist/web3mail/fetchMyContacts.d.ts +0 -2
- package/dist/web3mail/fetchMyContacts.js +0 -28
- package/dist/web3mail/fetchMyContacts.js.map +0 -1
- package/dist/web3mail/fetchUserContacts.d.ts +0 -2
- package/dist/web3mail/fetchUserContacts.js +0 -82
- package/dist/web3mail/fetchUserContacts.js.map +0 -1
- package/dist/web3mail/sendEmail.d.ts +0 -2
- package/dist/web3mail/sendEmail.js +0 -193
- package/dist/web3mail/sendEmail.js.map +0 -1
- package/dist/web3mail/types.d.ts +0 -96
- package/dist/web3mail/types.js +0 -2
- package/dist/web3mail/types.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iexec/web3mail",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "This product enables users to confidentially store data–such as mail address, documents, personal information ...",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,10 @@
|
|
|
23
23
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --coverage",
|
|
24
24
|
"lint": "eslint .",
|
|
25
25
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
26
|
-
"check-format": "prettier --check \"src/**/*.ts\""
|
|
26
|
+
"check-format": "prettier --check \"src/**/*.ts\"",
|
|
27
|
+
"prepare-test-env": "cd tests && node prepare-test-env.js",
|
|
28
|
+
"stop-test-stack": "cd tests && docker compose down --volumes --remove-orphans",
|
|
29
|
+
"start-test-stack": "cd tests && npm run stop-test-stack && npm run prepare-test-env && docker compose build && docker compose up -d"
|
|
27
30
|
},
|
|
28
31
|
"repository": {
|
|
29
32
|
"type": "git",
|
|
@@ -41,14 +44,15 @@
|
|
|
41
44
|
"dependencies": {
|
|
42
45
|
"@ethersproject/bytes": "^5.7.0",
|
|
43
46
|
"@ethersproject/random": "^5.7.0",
|
|
47
|
+
"buffer": "^6.0.3",
|
|
44
48
|
"ethers": "^6.8.1",
|
|
45
49
|
"graphql-request": "^6.1.0",
|
|
46
|
-
"iexec": "^8.
|
|
50
|
+
"iexec": "^8.9.1",
|
|
47
51
|
"kubo-rpc-client": "^3.0.1",
|
|
48
52
|
"yup": "^1.1.1"
|
|
49
53
|
},
|
|
50
54
|
"devDependencies": {
|
|
51
|
-
"@iexec/dataprotector": "^0.
|
|
55
|
+
"@iexec/dataprotector": "^0.5.3",
|
|
52
56
|
"@jest/globals": "^29.7.0",
|
|
53
57
|
"@swc/core": "^1.3.96",
|
|
54
58
|
"@swc/jest": "^0.2.29",
|
|
@@ -63,7 +67,7 @@
|
|
|
63
67
|
"eslint-plugin-sonarjs": "^0.21.0",
|
|
64
68
|
"jest": "^29.7.0",
|
|
65
69
|
"prettier": "^2.8.4",
|
|
66
|
-
"typescript": "^
|
|
70
|
+
"typescript": "^5.5.2",
|
|
67
71
|
"whitelist-smart-contract": "github:iExecBlockchainComputing/whitelist-smart-contract#0.2.0"
|
|
68
72
|
}
|
|
69
73
|
}
|
package/src/index.ts
CHANGED
package/src/utils/errors.ts
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ApiCallError } from 'iexec/errors';
|
|
2
|
+
export class WorkflowError extends Error {
|
|
3
|
+
isProtocolError: boolean;
|
|
3
4
|
|
|
4
|
-
constructor(
|
|
5
|
-
|
|
5
|
+
constructor({
|
|
6
|
+
message,
|
|
7
|
+
errorCause,
|
|
8
|
+
isProtocolError = false,
|
|
9
|
+
}: {
|
|
10
|
+
message: string;
|
|
11
|
+
errorCause: Error;
|
|
12
|
+
isProtocolError?: boolean;
|
|
13
|
+
}) {
|
|
14
|
+
super(message, { cause: errorCause });
|
|
6
15
|
this.name = this.constructor.name;
|
|
7
|
-
this.
|
|
16
|
+
this.isProtocolError = isProtocolError;
|
|
8
17
|
}
|
|
9
18
|
}
|
|
10
19
|
|
|
11
|
-
export
|
|
20
|
+
export function handleIfProtocolError(error: Error) {
|
|
21
|
+
if (error instanceof ApiCallError) {
|
|
22
|
+
throw new WorkflowError({
|
|
23
|
+
message:
|
|
24
|
+
"A service in the iExec protocol appears to be unavailable. You can retry later or contact iExec's technical support for help.",
|
|
25
|
+
errorCause: error,
|
|
26
|
+
isProtocolError: true,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WorkflowError } from './errors.js';
|
|
@@ -74,10 +74,10 @@ export const getValidContact = async (
|
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
76
|
} catch (error) {
|
|
77
|
-
throw new WorkflowError(
|
|
78
|
-
|
|
79
|
-
error
|
|
80
|
-
);
|
|
77
|
+
throw new WorkflowError({
|
|
78
|
+
message: 'Failed to fetch subgraph',
|
|
79
|
+
errorCause: error,
|
|
80
|
+
});
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
83
|
|
|
@@ -100,9 +100,9 @@ export const checkProtectedDataValidity = async (
|
|
|
100
100
|
|
|
101
101
|
return protectedDatas.length === 1;
|
|
102
102
|
} catch (error) {
|
|
103
|
-
throw new WorkflowError(
|
|
104
|
-
|
|
105
|
-
error
|
|
106
|
-
);
|
|
103
|
+
throw new WorkflowError({
|
|
104
|
+
message: 'Failed to fetch subgraph',
|
|
105
|
+
errorCause: error,
|
|
106
|
+
});
|
|
107
107
|
}
|
|
108
108
|
};
|
package/src/utils/validators.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { isAddress } from 'ethers';
|
|
2
|
-
import {
|
|
2
|
+
import { IExec } from 'iexec';
|
|
3
|
+
import { ValidationError, boolean, number, string } from 'yup';
|
|
4
|
+
|
|
5
|
+
export const isValidProvider = async (iexec: IExec) => {
|
|
6
|
+
const client = await iexec.config.resolveContractsClient();
|
|
7
|
+
if (!client.signer) {
|
|
8
|
+
throw new Error(
|
|
9
|
+
'Unauthorized method. Please log in with your wallet, you must set a valid provider with a signer.'
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
3
13
|
|
|
4
14
|
export const throwIfMissing = (): never => {
|
|
5
15
|
throw new ValidationError('Missing parameter');
|
|
@@ -48,3 +58,5 @@ export const labelSchema = () => string().trim().min(3).max(10).optional();
|
|
|
48
58
|
|
|
49
59
|
export const positiveNumberSchema = () =>
|
|
50
60
|
number().integer().min(0).typeError('${path} must be a non-negative number');
|
|
61
|
+
|
|
62
|
+
export const booleanSchema = () => boolean();
|
|
@@ -7,9 +7,10 @@ import {
|
|
|
7
7
|
Contact,
|
|
8
8
|
FetchUserContactsParams,
|
|
9
9
|
SendEmailParams,
|
|
10
|
-
Web3SignerProvider,
|
|
11
10
|
AddressOrENS,
|
|
12
11
|
Web3MailConfigOptions,
|
|
12
|
+
SendEmailResponse,
|
|
13
|
+
Web3SignerProvider,
|
|
13
14
|
} from './types.js';
|
|
14
15
|
import { GraphQLClient } from 'graphql-request';
|
|
15
16
|
import {
|
|
@@ -19,6 +20,7 @@ import {
|
|
|
19
20
|
DATAPROTECTOR_SUBGRAPH_ENDPOINT,
|
|
20
21
|
WHITELIST_SMART_CONTRACT_ADDRESS,
|
|
21
22
|
} from '../config/config.js';
|
|
23
|
+
import { isValidProvider } from '../utils/validators.js';
|
|
22
24
|
|
|
23
25
|
export class IExecWeb3mail {
|
|
24
26
|
private iexec: IExec;
|
|
@@ -36,11 +38,14 @@ export class IExecWeb3mail {
|
|
|
36
38
|
private graphQLClient: GraphQLClient;
|
|
37
39
|
|
|
38
40
|
constructor(
|
|
39
|
-
ethProvider
|
|
41
|
+
ethProvider?: Eip1193Provider | Web3SignerProvider | string,
|
|
40
42
|
options?: Web3MailConfigOptions
|
|
41
43
|
) {
|
|
42
44
|
try {
|
|
43
|
-
this.iexec = new IExec(
|
|
45
|
+
this.iexec = new IExec(
|
|
46
|
+
{ ethProvider: ethProvider || 'bellecour' },
|
|
47
|
+
options?.iexecOptions
|
|
48
|
+
);
|
|
44
49
|
} catch (e) {
|
|
45
50
|
throw Error('Unsupported ethProvider');
|
|
46
51
|
}
|
|
@@ -60,13 +65,15 @@ export class IExecWeb3mail {
|
|
|
60
65
|
options?.dappWhitelistAddress || WHITELIST_SMART_CONTRACT_ADDRESS;
|
|
61
66
|
}
|
|
62
67
|
|
|
63
|
-
fetchMyContacts
|
|
64
|
-
|
|
68
|
+
async fetchMyContacts(): Promise<Contact[]> {
|
|
69
|
+
await isValidProvider(this.iexec);
|
|
70
|
+
return fetchMyContacts({
|
|
65
71
|
iexec: this.iexec,
|
|
66
72
|
graphQLClient: this.graphQLClient,
|
|
67
73
|
dappAddressOrENS: this.dappAddressOrENS,
|
|
68
74
|
dappWhitelistAddress: this.dappWhitelistAddress,
|
|
69
75
|
});
|
|
76
|
+
}
|
|
70
77
|
|
|
71
78
|
fetchUserContacts(args?: FetchUserContactsParams): Promise<Contact[]> {
|
|
72
79
|
return fetchUserContacts({
|
|
@@ -78,8 +85,9 @@ export class IExecWeb3mail {
|
|
|
78
85
|
});
|
|
79
86
|
}
|
|
80
87
|
|
|
81
|
-
sendEmail
|
|
82
|
-
|
|
88
|
+
async sendEmail(args: SendEmailParams): Promise<SendEmailResponse> {
|
|
89
|
+
await isValidProvider(this.iexec);
|
|
90
|
+
return sendEmail({
|
|
83
91
|
...args,
|
|
84
92
|
iexec: this.iexec,
|
|
85
93
|
ipfsNode: this.ipfsNode,
|
|
@@ -88,4 +96,5 @@ export class IExecWeb3mail {
|
|
|
88
96
|
dappWhitelistAddress: this.dappWhitelistAddress,
|
|
89
97
|
graphQLClient: this.graphQLClient,
|
|
90
98
|
});
|
|
99
|
+
}
|
|
91
100
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { throwIfMissing } from '../utils/validators.js';
|
|
1
|
+
import { booleanSchema, throwIfMissing } from '../utils/validators.js';
|
|
3
2
|
import { fetchUserContacts } from './fetchUserContacts.js';
|
|
4
3
|
import {
|
|
5
4
|
Contact,
|
|
6
5
|
DappAddressConsumer,
|
|
7
6
|
DappWhitelistAddressConsumer,
|
|
7
|
+
FetchMyContactsParams,
|
|
8
8
|
IExecConsumer,
|
|
9
9
|
SubgraphConsumer,
|
|
10
10
|
} from './types.js';
|
|
@@ -14,23 +14,23 @@ export const fetchMyContacts = async ({
|
|
|
14
14
|
iexec = throwIfMissing(),
|
|
15
15
|
dappAddressOrENS = throwIfMissing(),
|
|
16
16
|
dappWhitelistAddress = throwIfMissing(),
|
|
17
|
+
isUserStrict = false,
|
|
17
18
|
}: IExecConsumer &
|
|
18
19
|
SubgraphConsumer &
|
|
19
20
|
DappAddressConsumer &
|
|
20
|
-
DappWhitelistAddressConsumer
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
21
|
+
DappWhitelistAddressConsumer &
|
|
22
|
+
FetchMyContactsParams): Promise<Contact[]> => {
|
|
23
|
+
const vIsUserStrict = booleanSchema()
|
|
24
|
+
.label('isUserStrict')
|
|
25
|
+
.validateSync(isUserStrict);
|
|
26
|
+
|
|
27
|
+
const userAddress = await iexec.wallet.getAddress();
|
|
28
|
+
return fetchUserContacts({
|
|
29
|
+
iexec,
|
|
30
|
+
graphQLClient,
|
|
31
|
+
dappAddressOrENS,
|
|
32
|
+
dappWhitelistAddress,
|
|
33
|
+
userAddress,
|
|
34
|
+
isUserStrict: vIsUserStrict,
|
|
35
|
+
});
|
|
36
36
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ANY_DATASET_ADDRESS } from '../config/config.js';
|
|
2
|
-
import { WorkflowError } from '../utils/errors.js';
|
|
2
|
+
import { handleIfProtocolError, WorkflowError } from '../utils/errors.js';
|
|
3
3
|
import { autoPaginateRequest } from '../utils/paginate.js';
|
|
4
4
|
import { getValidContact } from '../utils/subgraphQuery.js';
|
|
5
5
|
import {
|
|
6
6
|
addressOrEnsSchema,
|
|
7
7
|
addressSchema,
|
|
8
|
+
booleanSchema,
|
|
8
9
|
isEnsTest,
|
|
9
10
|
throwIfMissing,
|
|
10
11
|
} from '../utils/validators.js';
|
|
@@ -23,6 +24,7 @@ export const fetchUserContacts = async ({
|
|
|
23
24
|
dappAddressOrENS = throwIfMissing(),
|
|
24
25
|
dappWhitelistAddress = throwIfMissing(),
|
|
25
26
|
userAddress,
|
|
27
|
+
isUserStrict = false,
|
|
26
28
|
}: IExecConsumer &
|
|
27
29
|
SubgraphConsumer &
|
|
28
30
|
DappAddressConsumer &
|
|
@@ -41,17 +43,22 @@ export const fetchUserContacts = async ({
|
|
|
41
43
|
.required()
|
|
42
44
|
.label('userAddress')
|
|
43
45
|
.validateSync(userAddress);
|
|
46
|
+
const vIsUserStrict = booleanSchema()
|
|
47
|
+
.label('isUserStrict')
|
|
48
|
+
.validateSync(isUserStrict);
|
|
44
49
|
|
|
45
50
|
const [dappOrders, whitelistOrders] = await Promise.all([
|
|
46
51
|
fetchAllOrdersByApp({
|
|
47
52
|
iexec,
|
|
48
53
|
userAddress: vUserAddress,
|
|
49
54
|
appAddress: vDappAddressOrENS,
|
|
55
|
+
isUserStrict: vIsUserStrict,
|
|
50
56
|
}),
|
|
51
57
|
fetchAllOrdersByApp({
|
|
52
58
|
iexec,
|
|
53
59
|
userAddress: vUserAddress,
|
|
54
60
|
appAddress: vDappWhitelistAddress,
|
|
61
|
+
isUserStrict: vIsUserStrict,
|
|
55
62
|
}),
|
|
56
63
|
]);
|
|
57
64
|
|
|
@@ -81,19 +88,28 @@ export const fetchUserContacts = async ({
|
|
|
81
88
|
//keeping the most recent one
|
|
82
89
|
return await getValidContact(graphQLClient, myContacts);
|
|
83
90
|
} catch (error) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
91
|
+
handleIfProtocolError(error);
|
|
92
|
+
|
|
93
|
+
throw new WorkflowError({
|
|
94
|
+
message: 'Failed to fetch user contacts',
|
|
95
|
+
errorCause: error,
|
|
96
|
+
});
|
|
88
97
|
}
|
|
89
98
|
};
|
|
90
99
|
|
|
91
|
-
async function fetchAllOrdersByApp({
|
|
100
|
+
async function fetchAllOrdersByApp({
|
|
101
|
+
iexec,
|
|
102
|
+
userAddress,
|
|
103
|
+
appAddress,
|
|
104
|
+
isUserStrict,
|
|
105
|
+
}) {
|
|
92
106
|
const ordersFirstPage = iexec.orderbook.fetchDatasetOrderbook(
|
|
93
107
|
ANY_DATASET_ADDRESS,
|
|
94
108
|
{
|
|
95
109
|
app: appAddress,
|
|
96
110
|
requester: userAddress,
|
|
111
|
+
isAppStrict: true,
|
|
112
|
+
isRequesterStrict: isUserStrict,
|
|
97
113
|
// Use maxPageSize here to avoid too many round-trips (we want everything anyway)
|
|
98
114
|
pageSize: 1000,
|
|
99
115
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
1
2
|
import {
|
|
2
3
|
DEFAULT_CONTENT_TYPE,
|
|
3
4
|
MAX_DESIRED_APP_ORDER_PRICE,
|
|
@@ -5,7 +6,7 @@ import {
|
|
|
5
6
|
MAX_DESIRED_WORKERPOOL_ORDER_PRICE,
|
|
6
7
|
PROD_WORKERPOOL_ADDRESS,
|
|
7
8
|
} from '../config/config.js';
|
|
8
|
-
import { WorkflowError } from '../utils/errors.js';
|
|
9
|
+
import { handleIfProtocolError, WorkflowError } from '../utils/errors.js';
|
|
9
10
|
import { generateSecureUniqueId } from '../utils/generateUniqueId.js';
|
|
10
11
|
import * as ipfs from '../utils/ipfs-service.js';
|
|
11
12
|
import { checkProtectedDataValidity } from '../utils/subgraphQuery.js';
|
|
@@ -202,7 +203,10 @@ export const sendEmail = async ({
|
|
|
202
203
|
const encryptedFile = await iexec.dataset
|
|
203
204
|
.encrypt(Buffer.from(vEmailContent, 'utf8'), emailContentEncryptionKey)
|
|
204
205
|
.catch((e) => {
|
|
205
|
-
throw new WorkflowError(
|
|
206
|
+
throw new WorkflowError({
|
|
207
|
+
message: 'Failed to encrypt email content',
|
|
208
|
+
errorCause: e,
|
|
209
|
+
});
|
|
206
210
|
});
|
|
207
211
|
const cid = await ipfs
|
|
208
212
|
.add(encryptedFile, {
|
|
@@ -210,7 +214,10 @@ export const sendEmail = async ({
|
|
|
210
214
|
ipfsGateway: ipfsGateway,
|
|
211
215
|
})
|
|
212
216
|
.catch((e) => {
|
|
213
|
-
throw new WorkflowError(
|
|
217
|
+
throw new WorkflowError({
|
|
218
|
+
message: 'Failed to upload encrypted email content',
|
|
219
|
+
errorCause: e,
|
|
220
|
+
});
|
|
214
221
|
});
|
|
215
222
|
const multiaddr = `/ipfs/${cid}`;
|
|
216
223
|
|
|
@@ -257,6 +264,11 @@ export const sendEmail = async ({
|
|
|
257
264
|
taskId,
|
|
258
265
|
};
|
|
259
266
|
} catch (error) {
|
|
260
|
-
|
|
267
|
+
handleIfProtocolError(error);
|
|
268
|
+
|
|
269
|
+
throw new WorkflowError({
|
|
270
|
+
message: 'Failed to sendEmail',
|
|
271
|
+
errorCause: error,
|
|
272
|
+
});
|
|
261
273
|
}
|
|
262
274
|
};
|
package/src/web3mail/types.ts
CHANGED
|
@@ -35,15 +35,22 @@ export type SendEmailParams = {
|
|
|
35
35
|
workerpoolMaxPrice?: number;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
+
export type FetchMyContactsParams = {
|
|
39
|
+
/**
|
|
40
|
+
* Get contacts for this specific user only
|
|
41
|
+
*/
|
|
42
|
+
isUserStrict?: boolean;
|
|
43
|
+
};
|
|
44
|
+
|
|
38
45
|
export type FetchUserContactsParams = {
|
|
39
46
|
/**
|
|
40
47
|
* Address of the user
|
|
41
48
|
*/
|
|
42
49
|
userAddress: Address;
|
|
43
|
-
};
|
|
50
|
+
} & FetchMyContactsParams;
|
|
44
51
|
|
|
45
52
|
export type SendEmailResponse = {
|
|
46
|
-
taskId:
|
|
53
|
+
taskId: string;
|
|
47
54
|
};
|
|
48
55
|
|
|
49
56
|
/**
|
package/dist/config/config.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare const WEB3_MAIL_DAPP_ADDRESS = "web3mail.apps.iexec.eth";
|
|
2
|
-
export declare const PROD_WORKERPOOL_ADDRESS = "prod-v8-bellecour.main.pools.iexec.eth";
|
|
3
|
-
export declare const DATAPROTECTOR_SUBGRAPH_ENDPOINT = "https://thegraph-product.iex.ec/subgraphs/name/bellecour/dataprotector";
|
|
4
|
-
export declare const MAX_DESIRED_DATA_ORDER_PRICE = 0;
|
|
5
|
-
export declare const MAX_DESIRED_APP_ORDER_PRICE = 0;
|
|
6
|
-
export declare const MAX_DESIRED_WORKERPOOL_ORDER_PRICE = 0;
|
|
7
|
-
export declare const DEFAULT_CONTENT_TYPE = "text/plain";
|
|
8
|
-
export declare const IPFS_UPLOAD_URL = "/dns4/ipfs-upload.v8-bellecour.iex.ec/https";
|
|
9
|
-
export declare const DEFAULT_IPFS_GATEWAY = "https://ipfs-gateway.v8-bellecour.iex.ec";
|
|
10
|
-
export declare const WHITELIST_SMART_CONTRACT_ADDRESS = "0x781482C39CcE25546583EaC4957Fb7Bf04C277D2";
|
|
11
|
-
export declare const ANY_DATASET_ADDRESS = "any";
|
package/dist/config/config.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const WEB3_MAIL_DAPP_ADDRESS = 'web3mail.apps.iexec.eth';
|
|
2
|
-
export const PROD_WORKERPOOL_ADDRESS = 'prod-v8-bellecour.main.pools.iexec.eth';
|
|
3
|
-
export const DATAPROTECTOR_SUBGRAPH_ENDPOINT = 'https://thegraph-product.iex.ec/subgraphs/name/bellecour/dataprotector';
|
|
4
|
-
export const MAX_DESIRED_DATA_ORDER_PRICE = 0;
|
|
5
|
-
export const MAX_DESIRED_APP_ORDER_PRICE = 0;
|
|
6
|
-
export const MAX_DESIRED_WORKERPOOL_ORDER_PRICE = 0;
|
|
7
|
-
export const DEFAULT_CONTENT_TYPE = 'text/plain';
|
|
8
|
-
export const IPFS_UPLOAD_URL = '/dns4/ipfs-upload.v8-bellecour.iex.ec/https';
|
|
9
|
-
export const DEFAULT_IPFS_GATEWAY = 'https://ipfs-gateway.v8-bellecour.iex.ec';
|
|
10
|
-
export const WHITELIST_SMART_CONTRACT_ADDRESS = '0x781482C39CcE25546583EaC4957Fb7Bf04C277D2';
|
|
11
|
-
export const ANY_DATASET_ADDRESS = 'any';
|
|
12
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;AAChE,MAAM,CAAC,MAAM,uBAAuB,GAAG,wCAAwC,CAAC;AAChF,MAAM,CAAC,MAAM,+BAA+B,GAC1C,wEAAwE,CAAC;AAC3E,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAC9C,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,oBAAoB,GAAG,YAAY,CAAC;AACjD,MAAM,CAAC,MAAM,eAAe,GAAG,6CAA6C,CAAC;AAC7E,MAAM,CAAC,MAAM,oBAAoB,GAAG,0CAA0C,CAAC;AAC/E,MAAM,CAAC,MAAM,gCAAgC,GAC3C,4CAA4C,CAAC;AAC/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC"}
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/utils/errors.d.ts
DELETED
package/dist/utils/errors.js
DELETED
package/dist/utils/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,MAAM,aAAc,SAAQ,KAAK;IAG/B,YAAY,OAAe,EAAE,aAAoB;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;CACF;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function generateSecureUniqueId(length: any): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generateUniqueId.js","sourceRoot":"","sources":["../../src/utils/generateUniqueId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,MAAM,UAAU,sBAAsB,CAAC,MAAM;IAC3C,OAAO,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getWeb3Provider.js","sourceRoot":"","sources":["../../src/utils/getWeb3Provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAGtD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,UAAkB,EAAsB,EAAE,CACxE,uBAAuB,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
interface GetOptions {
|
|
2
|
-
ipfsGateway?: string;
|
|
3
|
-
}
|
|
4
|
-
interface AddOptions extends GetOptions {
|
|
5
|
-
ipfsNode?: string;
|
|
6
|
-
}
|
|
7
|
-
declare const get: (cid: any, { ipfsGateway }?: GetOptions) => Promise<Uint8Array>;
|
|
8
|
-
declare const add: (content: any, { ipfsNode, ipfsGateway, }?: AddOptions) => Promise<any>;
|
|
9
|
-
export { add, get };
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { create } from 'kubo-rpc-client';
|
|
11
|
-
import { IPFS_UPLOAD_URL, DEFAULT_IPFS_GATEWAY } from '../config/config.js';
|
|
12
|
-
const get = (cid, { ipfsGateway = DEFAULT_IPFS_GATEWAY } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
-
const multiaddr = `/ipfs/${cid.toString()}`;
|
|
14
|
-
const publicUrl = `${ipfsGateway}${multiaddr}`;
|
|
15
|
-
const res = yield fetch(publicUrl);
|
|
16
|
-
if (!res.ok) {
|
|
17
|
-
throw Error(`Failed to load content from ${publicUrl}`);
|
|
18
|
-
}
|
|
19
|
-
const arrayBuffer = yield res.arrayBuffer();
|
|
20
|
-
return new Uint8Array(arrayBuffer);
|
|
21
|
-
});
|
|
22
|
-
const add = (content, { ipfsNode = IPFS_UPLOAD_URL, ipfsGateway = DEFAULT_IPFS_GATEWAY, } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
const ipfsClient = create(ipfsNode);
|
|
24
|
-
const { cid } = yield ipfsClient.add(content);
|
|
25
|
-
yield get(cid.toString(), { ipfsGateway });
|
|
26
|
-
return cid.toString();
|
|
27
|
-
});
|
|
28
|
-
export { add, get };
|
|
29
|
-
//# sourceMappingURL=ipfs-service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ipfs-service.js","sourceRoot":"","sources":["../../src/utils/ipfs-service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAS5E,MAAM,GAAG,GAAG,CACV,GAAG,EACH,EAAE,WAAW,GAAG,oBAAoB,KAAiB,EAAE,EACvD,EAAE;IACF,MAAM,SAAS,GAAG,SAAS,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC5C,MAAM,SAAS,GAAG,GAAG,WAAW,GAAG,SAAS,EAAE,CAAC;IAC/C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,CAAC;IACnC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;QACX,MAAM,KAAK,CAAC,+BAA+B,SAAS,EAAE,CAAC,CAAC;KACzD;IACD,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,WAAW,EAAE,CAAC;IAC5C,OAAO,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AAEF,MAAM,GAAG,GAAG,CACV,OAAO,EACP,EACE,QAAQ,GAAG,eAAe,EAC1B,WAAW,GAAG,oBAAoB,MACpB,EAAE,EAClB,EAAE;IACF,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACpC,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;IAC3C,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC,CAAA,CAAC;AAEF,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC"}
|
package/dist/utils/paginate.d.ts
DELETED
package/dist/utils/paginate.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export const autoPaginateRequest = ({ request }, { orders = [] } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
11
|
-
const res = yield request;
|
|
12
|
-
const totalCount = res.count;
|
|
13
|
-
if (res.orders.length > 0) {
|
|
14
|
-
orders.push(...res.orders);
|
|
15
|
-
if (res.more && typeof res.more === 'function') {
|
|
16
|
-
return autoPaginateRequest({
|
|
17
|
-
request: res.more(),
|
|
18
|
-
}, { orders });
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return { orders, count: totalCount };
|
|
22
|
-
});
|
|
23
|
-
//# sourceMappingURL=paginate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"paginate.js","sourceRoot":"","sources":["../../src/utils/paginate.ts"],"names":[],"mappings":";;;;;;;;;AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,EAAE,OAAO,EAAE,EACX,EAAE,MAAM,GAAG,EAAE,EAAE,GAAG,EAAE,EACpB,EAAE;IACF,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC;IAC1B,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC;IAC7B,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QACzB,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAI,GAAG,CAAC,IAAI,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,EAAE;YAC9C,OAAO,mBAAmB,CACxB;gBACE,OAAO,EAAE,GAAG,CAAC,IAAI,EAAE;aACpB,EACD,EAAE,MAAM,EAAE,CACX,CAAC;SACH;KACF;IACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;AACvC,CAAC,CAAA,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { GraphQLClient } from 'graphql-request';
|
|
2
|
-
import { Contact } from '../index.js';
|
|
3
|
-
export declare const getValidContact: (graphQLClient: GraphQLClient, contacts: Contact[]) => Promise<Contact[]>;
|
|
4
|
-
export declare const checkProtectedDataValidity: (graphQLClient: GraphQLClient, protectedData: string) => Promise<boolean>;
|