@iexec/web3mail 1.5.0 → 1.6.0-nightly-8729cd2

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,161 +1,53 @@
1
1
  import { Buffer } from 'buffer';
2
- import { CALLBACK_WEB3MAIL, DEFAULT_CONTENT_TYPE, MAX_DESIRED_APP_ORDER_PRICE, MAX_DESIRED_DATA_ORDER_PRICE, MAX_DESIRED_WORKERPOOL_ORDER_PRICE, } from '../config/config.js';
2
+ import { DEFAULT_CONTENT_TYPE, MAX_DESIRED_APP_ORDER_PRICE, MAX_DESIRED_DATA_ORDER_PRICE, MAX_DESIRED_WORKERPOOL_ORDER_PRICE, } from '../config/config.js';
3
3
  import { handleIfProtocolError, WorkflowError } from '../utils/errors.js';
4
- import { generateSecureUniqueId } from '../utils/generateUniqueId.js';
5
4
  import * as ipfs from '../utils/ipfs-service.js';
6
5
  import { checkProtectedDataValidity } from '../utils/subgraphQuery.js';
7
- import { addressOrEnsSchema, addressSchema, booleanSchema, contentTypeSchema, emailContentSchema, emailSubjectSchema, labelSchema, positiveNumberSchema, senderNameSchema, throwIfMissing, } from '../utils/validators.js';
8
- import { checkUserVoucher, filterWorkerpoolOrders, } from './sendEmail.models.js';
9
- export const sendEmail = async ({ graphQLClient = throwIfMissing(), iexec = throwIfMissing(), workerpoolAddressOrEns, dappAddressOrENS, dappWhitelistAddress, ipfsNode, ipfsGateway, emailSubject, emailContent, contentType = DEFAULT_CONTENT_TYPE, label, dataMaxPrice = MAX_DESIRED_DATA_ORDER_PRICE, appMaxPrice = MAX_DESIRED_APP_ORDER_PRICE, workerpoolMaxPrice = MAX_DESIRED_WORKERPOOL_ORDER_PRICE, senderName, protectedData, useVoucher = false, }) => {
10
- const vDatasetAddress = addressOrEnsSchema()
11
- .required()
12
- .label('protectedData')
13
- .validateSync(protectedData);
14
- const vEmailSubject = emailSubjectSchema()
15
- .required()
16
- .label('emailSubject')
17
- .validateSync(emailSubject);
18
- const vEmailContent = emailContentSchema()
19
- .required()
20
- .label('emailContent')
21
- .validateSync(emailContent);
22
- const vContentType = contentTypeSchema()
23
- .required()
24
- .label('contentType')
25
- .validateSync(contentType);
26
- const vSenderName = senderNameSchema()
27
- .label('senderName')
28
- .validateSync(senderName);
29
- const vLabel = labelSchema().label('label').validateSync(label);
30
- const vWorkerpoolAddressOrEns = addressOrEnsSchema()
31
- .required()
32
- .label('WorkerpoolAddressOrEns')
33
- .validateSync(workerpoolAddressOrEns);
34
- const vDappAddressOrENS = addressOrEnsSchema()
35
- .required()
36
- .label('dappAddressOrENS')
37
- .validateSync(dappAddressOrENS);
38
- const vDappWhitelistAddress = addressSchema()
39
- .required()
40
- .label('dappWhitelistAddress')
41
- .validateSync(dappWhitelistAddress);
42
- const vDataMaxPrice = positiveNumberSchema()
43
- .label('dataMaxPrice')
44
- .validateSync(dataMaxPrice);
45
- const vAppMaxPrice = positiveNumberSchema()
46
- .label('appMaxPrice')
47
- .validateSync(appMaxPrice);
48
- const vWorkerpoolMaxPrice = positiveNumberSchema()
49
- .label('workerpoolMaxPrice')
50
- .validateSync(workerpoolMaxPrice);
51
- const vUseVoucher = booleanSchema()
52
- .label('useVoucher')
53
- .validateSync(useVoucher);
54
- // Check protected data schema through subgraph
55
- const isValidProtectedData = await checkProtectedDataValidity(graphQLClient, vDatasetAddress);
56
- if (!isValidProtectedData) {
57
- throw new Error('This protected data does not contain "email:string" in its schema.');
58
- }
59
- const requesterAddress = await iexec.wallet.getAddress();
60
- let userVoucher;
61
- if (vUseVoucher) {
62
- try {
63
- userVoucher = await iexec.voucher.showUserVoucher(requesterAddress);
64
- checkUserVoucher({ userVoucher });
65
- }
66
- catch (err) {
67
- if (err?.message?.startsWith('No Voucher found for address')) {
68
- throw new Error('Oops, it seems your wallet is not associated with any voucher. Check on https://builder.iex.ec/');
69
- }
70
- throw err;
71
- }
72
- }
6
+ import { addressOrEnsSchema, booleanSchema, contentTypeSchema, emailContentSchema, emailSubjectSchema, labelSchema, positiveNumberSchema, senderNameSchema, throwIfMissing, } from '../utils/validators.js';
7
+ export const sendEmail = async ({ graphQLClient = throwIfMissing(), iexec = throwIfMissing(), dataProtector = throwIfMissing(), workerpoolAddressOrEns = throwIfMissing(), dappAddressOrENS, ipfsNode, ipfsGateway, emailSubject, emailContent, contentType = DEFAULT_CONTENT_TYPE, label, dataMaxPrice = MAX_DESIRED_DATA_ORDER_PRICE, appMaxPrice = MAX_DESIRED_APP_ORDER_PRICE, workerpoolMaxPrice = MAX_DESIRED_WORKERPOOL_ORDER_PRICE, senderName, protectedData, grantedAccess, maxProtectedDataPerTask, useVoucher = false, }) => {
73
8
  try {
74
- const [datasetorderForApp, datasetorderForWhitelist, apporder, workerpoolorder,] = await Promise.all([
75
- // Fetch dataset order for web3mail app
76
- iexec.orderbook
77
- .fetchDatasetOrderbook(vDatasetAddress, {
78
- app: dappAddressOrENS,
79
- requester: requesterAddress,
80
- })
81
- .then((datasetOrderbook) => {
82
- const desiredPriceDataOrderbook = datasetOrderbook.orders.filter((order) => order.order.datasetprice <= vDataMaxPrice);
83
- return desiredPriceDataOrderbook[0]?.order; // may be undefined
84
- }),
85
- // Fetch dataset order for web3mail whitelist
86
- iexec.orderbook
87
- .fetchDatasetOrderbook(vDatasetAddress, {
88
- app: vDappWhitelistAddress,
89
- requester: requesterAddress,
90
- })
91
- .then((datasetOrderbook) => {
92
- const desiredPriceDataOrderbook = datasetOrderbook.orders.filter((order) => order.order.datasetprice <= vDataMaxPrice);
93
- return desiredPriceDataOrderbook[0]?.order; // may be undefined
94
- }),
95
- // Fetch app order
96
- iexec.orderbook
97
- .fetchAppOrderbook(dappAddressOrENS, {
98
- minTag: ['tee', 'scone'],
99
- maxTag: ['tee', 'scone'],
100
- workerpool: workerpoolAddressOrEns,
101
- })
102
- .then((appOrderbook) => {
103
- const desiredPriceAppOrderbook = appOrderbook.orders.filter((order) => order.order.appprice <= vAppMaxPrice);
104
- const desiredPriceAppOrder = desiredPriceAppOrderbook[0]?.order;
105
- if (!desiredPriceAppOrder) {
106
- throw new Error('No App order found for the desired price');
107
- }
108
- return desiredPriceAppOrder;
109
- }),
110
- // Fetch workerpool order for App or AppWhitelist
111
- Promise.all([
112
- // for app
113
- iexec.orderbook.fetchWorkerpoolOrderbook({
114
- workerpool: workerpoolAddressOrEns,
115
- app: vDappAddressOrENS,
116
- dataset: vDatasetAddress,
117
- requester: requesterAddress, // public orders + user specific orders
118
- isRequesterStrict: useVoucher, // If voucher, we only want user specific orders
119
- minTag: ['tee', 'scone'],
120
- maxTag: ['tee', 'scone'],
121
- category: 0,
122
- }),
123
- // for app whitelist
124
- iexec.orderbook.fetchWorkerpoolOrderbook({
125
- workerpool: workerpoolAddressOrEns,
126
- app: vDappWhitelistAddress,
127
- dataset: vDatasetAddress,
128
- requester: requesterAddress, // public orders + user specific orders
129
- isRequesterStrict: useVoucher, // If voucher, we only want user specific orders
130
- minTag: ['tee', 'scone'],
131
- maxTag: ['tee', 'scone'],
132
- category: 0,
133
- }),
134
- ]).then(([workerpoolOrderbookForApp, workerpoolOrderbookForAppWhitelist]) => {
135
- const desiredPriceWorkerpoolOrder = filterWorkerpoolOrders({
136
- workerpoolOrders: [
137
- ...workerpoolOrderbookForApp.orders,
138
- ...workerpoolOrderbookForAppWhitelist.orders,
139
- ],
140
- workerpoolMaxPrice: vWorkerpoolMaxPrice,
141
- useVoucher: vUseVoucher,
142
- userVoucher,
143
- });
144
- if (!desiredPriceWorkerpoolOrder) {
145
- throw new Error('No Workerpool order found for the desired price');
146
- }
147
- return desiredPriceWorkerpoolOrder;
148
- }),
149
- ]);
150
- if (!workerpoolorder) {
151
- throw new Error('No Workerpool order found for the desired price');
152
- }
153
- const datasetorder = datasetorderForApp || datasetorderForWhitelist;
154
- if (!datasetorder) {
155
- throw new Error('No Dataset order found for the desired price');
156
- }
157
- // Push requester secrets
158
- const requesterSecretId = generateSecureUniqueId(16);
9
+ const vUseVoucher = booleanSchema()
10
+ .label('useVoucher')
11
+ .validateSync(useVoucher);
12
+ const vWorkerpoolAddressOrEns = addressOrEnsSchema()
13
+ .required()
14
+ .label('WorkerpoolAddressOrEns')
15
+ .validateSync(workerpoolAddressOrEns);
16
+ const vSenderName = senderNameSchema()
17
+ .label('senderName')
18
+ .validateSync(senderName);
19
+ const vEmailSubject = emailSubjectSchema()
20
+ .required()
21
+ .label('emailSubject')
22
+ .validateSync(emailSubject);
23
+ const vEmailContent = emailContentSchema()
24
+ .required()
25
+ .label('emailContent')
26
+ .validateSync(emailContent);
27
+ const vContentType = contentTypeSchema()
28
+ .required()
29
+ .label('contentType')
30
+ .validateSync(contentType);
31
+ const vLabel = labelSchema().label('label').validateSync(label);
32
+ const vDappAddressOrENS = addressOrEnsSchema()
33
+ .required()
34
+ .label('dappAddressOrENS')
35
+ .validateSync(dappAddressOrENS);
36
+ // TODO: remove this once we have a way to pass appWhitelist to processProtectedData function
37
+ // const vDappWhitelistAddress = addressSchema()
38
+ // .required()
39
+ // .label('dappWhitelistAddress')
40
+ // .validateSync(dappWhitelistAddress);
41
+ const vDataMaxPrice = positiveNumberSchema()
42
+ .label('dataMaxPrice')
43
+ .validateSync(dataMaxPrice);
44
+ const vAppMaxPrice = positiveNumberSchema()
45
+ .label('appMaxPrice')
46
+ .validateSync(appMaxPrice);
47
+ const vWorkerpoolMaxPrice = positiveNumberSchema()
48
+ .label('workerpoolMaxPrice')
49
+ .validateSync(workerpoolMaxPrice);
50
+ // Encrypt email content
159
51
  const emailContentEncryptionKey = iexec.dataset.generateEncryptionKey();
160
52
  const encryptedFile = await iexec.dataset
161
53
  .encrypt(Buffer.from(vEmailContent, 'utf8'), emailContentEncryptionKey)
@@ -165,10 +57,11 @@ export const sendEmail = async ({ graphQLClient = throwIfMissing(), iexec = thro
165
57
  errorCause: e,
166
58
  });
167
59
  });
60
+ // Push email message to IPFS
168
61
  const cid = await ipfs
169
62
  .add(encryptedFile, {
170
- ipfsNode: ipfsNode,
171
- ipfsGateway: ipfsGateway,
63
+ ipfsNode,
64
+ ipfsGateway,
172
65
  })
173
66
  .catch((e) => {
174
67
  throw new WorkflowError({
@@ -177,46 +70,95 @@ export const sendEmail = async ({ graphQLClient = throwIfMissing(), iexec = thro
177
70
  });
178
71
  });
179
72
  const multiaddr = `/ipfs/${cid}`;
180
- await iexec.secrets.pushRequesterSecret(requesterSecretId, JSON.stringify({
181
- emailSubject: vEmailSubject,
182
- emailContentMultiAddr: multiaddr,
183
- contentType: vContentType,
184
- senderName: vSenderName,
185
- emailContentEncryptionKey,
186
- useCallback: true,
187
- }));
188
- const requestorderToSign = await iexec.order.createRequestorder({
73
+ // Prepare secrets for the requester
74
+ // Use a positive integer as secret ID (required by iexec)
75
+ // Using "1" as a fixed ID for the requester secret
76
+ const requesterSecretId = 1;
77
+ const secrets = {
78
+ [requesterSecretId]: JSON.stringify({
79
+ senderName: vSenderName,
80
+ emailSubject: vEmailSubject,
81
+ emailContentMultiAddr: multiaddr,
82
+ contentType: vContentType,
83
+ emailContentEncryptionKey,
84
+ }),
85
+ };
86
+ // Bulk processing
87
+ if (grantedAccess) {
88
+ const vMaxProtectedDataPerTask = positiveNumberSchema()
89
+ .label('maxProtectedDataPerTask')
90
+ .validateSync(maxProtectedDataPerTask);
91
+ const bulkRequest = await dataProtector.prepareBulkRequest({
92
+ app: vDappAddressOrENS,
93
+ appMaxPrice: vAppMaxPrice,
94
+ workerpoolMaxPrice: vWorkerpoolMaxPrice,
95
+ workerpool: vWorkerpoolAddressOrEns,
96
+ args: vLabel,
97
+ inputFiles: [],
98
+ secrets,
99
+ bulkOrders: grantedAccess,
100
+ maxProtectedDataPerTask: vMaxProtectedDataPerTask,
101
+ });
102
+ const processBulkRequestResponse = await dataProtector.processBulkRequest({
103
+ bulkRequest: bulkRequest.bulkRequest,
104
+ useVoucher: vUseVoucher,
105
+ workerpool: vWorkerpoolAddressOrEns,
106
+ });
107
+ return processBulkRequestResponse;
108
+ }
109
+ // Single processing mode - protectedData is required
110
+ const vDatasetAddress = addressOrEnsSchema()
111
+ .required()
112
+ .label('protectedData')
113
+ .validateSync(protectedData);
114
+ // Check protected data validity through subgraph
115
+ const isValidProtectedData = await checkProtectedDataValidity(graphQLClient, vDatasetAddress);
116
+ if (!isValidProtectedData) {
117
+ throw new Error('This protected data does not contain "email:string" in its schema.');
118
+ }
119
+ // Use processProtectedData from dataprotector
120
+ const result = await dataProtector.processProtectedData({
121
+ defaultWorkerpool: vWorkerpoolAddressOrEns,
122
+ protectedData: vDatasetAddress,
189
123
  app: vDappAddressOrENS,
190
- category: workerpoolorder.category,
191
- dataset: vDatasetAddress,
192
- datasetmaxprice: datasetorder.datasetprice,
193
- appmaxprice: apporder.appprice,
194
- workerpoolmaxprice: workerpoolorder.workerpoolprice,
195
- tag: ['tee', 'scone'],
124
+ // userWhitelist: vDappWhitelistAddress, // Removed due to bug in dataprotector v2.0.0-beta.20
125
+ dataMaxPrice: vDataMaxPrice,
126
+ appMaxPrice: vAppMaxPrice,
127
+ workerpoolMaxPrice: vWorkerpoolMaxPrice,
196
128
  workerpool: vWorkerpoolAddressOrEns,
197
- callback: CALLBACK_WEB3MAIL,
198
- params: {
199
- iexec_secrets: {
200
- 1: requesterSecretId,
201
- },
202
- iexec_args: vLabel,
203
- },
129
+ args: vLabel,
130
+ inputFiles: [],
131
+ secrets,
132
+ useVoucher: vUseVoucher,
133
+ waitForResult: false,
204
134
  });
205
- const requestorder = await iexec.order.signRequestorder(requestorderToSign);
206
- // Match orders and compute task ID
207
- const { dealid } = await iexec.order.matchOrders({
208
- apporder: apporder,
209
- datasetorder: datasetorder,
210
- workerpoolorder: workerpoolorder,
211
- requestorder: requestorder,
212
- }, { useVoucher: vUseVoucher });
213
- const taskId = await iexec.deal.computeTaskId(dealid, 0);
214
135
  return {
215
- taskId,
136
+ taskId: result.taskId,
216
137
  };
217
138
  }
218
139
  catch (error) {
140
+ // Protocol error detected, re-throwing as-is
141
+ if (error?.isProtocolError === true) {
142
+ throw error;
143
+ }
144
+ // Handle protocol errors - this will throw if it's an ApiCallError
145
+ // handleIfProtocolError transforms ApiCallError into a WorkflowError with isProtocolError=true
219
146
  handleIfProtocolError(error);
147
+ // If we reach here, it's not a protocol error
148
+ // Check if it's a WorkflowError from processProtectedData by checking the message
149
+ const isProcessProtectedDataError = error instanceof Error &&
150
+ error.message === 'Failed to process protected data';
151
+ if (isProcessProtectedDataError) {
152
+ const cause = error?.cause;
153
+ // Return unwrapped cause (the actual Error object)
154
+ // error.cause should be an Error, but ensure it is
155
+ const unwrappedCause = cause instanceof Error ? cause : error;
156
+ throw new WorkflowError({
157
+ message: 'Failed to sendEmail',
158
+ errorCause: unwrappedCause,
159
+ });
160
+ }
161
+ // For all other errors
220
162
  throw new WorkflowError({
221
163
  message: 'Failed to sendEmail',
222
164
  errorCause: error,
@@ -1 +1 @@
1
- {"version":3,"file":"sendEmail.js","sourceRoot":"","sources":["../../src/web3mail/sendEmail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,2BAA2B,EAC3B,4BAA4B,EAC5B,kCAAkC,GACnC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,IAAI,MAAM,0BAA0B,CAAC;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAa/B,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,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= string;
7
7
  export type TimeStamp = string;
8
+ export type GrantedAccess = {
9
+ dataset: string;
10
+ datasetprice: string;
11
+ volume: string;
12
+ tag: string;
13
+ apprestrict: string;
14
+ workerpoolrestrict: string;
15
+ requesterrestrict: string;
16
+ salt: string;
17
+ sign: string;
18
+ remainingAccess: number;
19
+ };
8
20
  export type Contact = {
9
21
  address: Address;
10
22
  owner: Address;
11
23
  accessGrantTimestamp: TimeStamp;
12
24
  isUserStrict: boolean;
13
- name: string;
25
+ name?: string;
14
26
  remainingAccess: number;
15
27
  accessPrice: number;
28
+ grantedAccess: GrantedAccess;
16
29
  };
17
30
  export type SendEmailParams = {
18
31
  emailSubject: string;
19
32
  emailContent: string;
20
- protectedData: Address;
33
+ protectedData?: Address;
34
+ /**
35
+ * Granted access to process.
36
+ * use prepareBulkRequest of dataprotector to create a bulk request.
37
+ * if not provided, the single message will be processed.
38
+ */
39
+ grantedAccess?: GrantedAccess[];
40
+ maxProtectedDataPerTask?: number;
21
41
  contentType?: string;
22
42
  senderName?: string;
23
43
  label?: string;
@@ -32,6 +52,7 @@ export type FetchMyContactsParams = {
32
52
  * Get contacts for this specific user only
33
53
  */
34
54
  isUserStrict?: boolean;
55
+ bulkOnly?: boolean;
35
56
  };
36
57
  export type FetchUserContactsParams = {
37
58
  /**
@@ -39,7 +60,7 @@ export type FetchUserContactsParams = {
39
60
  */
40
61
  userAddress: Address;
41
62
  } & FetchMyContactsParams;
42
- export type SendEmailResponse = {
63
+ export type SendEmailSingleResponse = {
43
64
  taskId: string;
44
65
  };
45
66
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iexec/web3mail",
3
- "version": "1.5.0",
3
+ "version": "1.6.0-nightly-8729cd2",
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",
@@ -49,15 +49,15 @@
49
49
  "dependencies": {
50
50
  "@ethersproject/bytes": "^5.7.0",
51
51
  "@ethersproject/random": "^5.7.0",
52
+ "@iexec/dataprotector": "2.0.0-beta.20-feat-add-bulk-processing-support-094df1e",
52
53
  "buffer": "^6.0.3",
53
54
  "ethers": "^6.13.2",
54
55
  "graphql-request": "^6.1.0",
55
- "iexec": "^8.18.0",
56
+ "iexec": "8.20.0-feat-bulk-processing-62e7c5f",
56
57
  "kubo-rpc-client": "^4.1.1",
57
58
  "yup": "^1.1.1"
58
59
  },
59
60
  "devDependencies": {
60
- "@iexec/dataprotector": "^2.0.0-beta.18",
61
61
  "@jest/globals": "^29.7.0",
62
62
  "@swc/core": "^1.3.96",
63
63
  "@swc/jest": "^0.2.29",
@@ -38,7 +38,6 @@ const CHAIN_CONFIG: Record<number, ChainConfig> = {
38
38
  ipfsGateway: 'https://ipfs-gateway.arbitrum-sepolia-testnet.iex.ec',
39
39
  ipfsUploadUrl: 'https://ipfs-upload.arbitrum-sepolia-testnet.iex.ec',
40
40
  whitelistSmartContract: '0x8d46d40840f1Aa2264F96184Ffadf04e5D573B9B',
41
- isExperimental: true,
42
41
  },
43
42
  42161: {
44
43
  name: 'arbitrum-mainnet',
@@ -71,20 +71,24 @@ export const getValidContact = async (
71
71
  );
72
72
 
73
73
  // Convert protectedData[] into Contact[] using the map for constant time lookups
74
- return protectedDataList.map(({ id, name }) => {
75
- const contact = contactsMap.get(id);
76
- if (contact) {
77
- return {
78
- address: id,
79
- name: name,
80
- remainingAccess: contact.remainingAccess,
81
- accessPrice: contact.accessPrice,
82
- owner: contact.owner,
83
- accessGrantTimestamp: contact.accessGrantTimestamp,
84
- isUserStrict: contact.isUserStrict,
85
- };
86
- }
87
- });
74
+ return protectedDataList
75
+ .map(({ id, name }) => {
76
+ const contact = contactsMap.get(id);
77
+ if (contact) {
78
+ return {
79
+ address: id,
80
+ name: name,
81
+ remainingAccess: contact.remainingAccess,
82
+ accessPrice: contact.accessPrice,
83
+ owner: contact.owner,
84
+ accessGrantTimestamp: contact.accessGrantTimestamp,
85
+ isUserStrict: contact.isUserStrict,
86
+ grantedAccess: contact.grantedAccess,
87
+ };
88
+ }
89
+ return null;
90
+ })
91
+ .filter((contact) => contact !== null && contact !== undefined);
88
92
  } catch (error) {
89
93
  throw new WorkflowError({
90
94
  message: 'Failed to fetch subgraph',
@@ -1,5 +1,9 @@
1
1
  import { AbstractProvider, AbstractSigner, Eip1193Provider } from 'ethers';
2
2
  import { IExec } from 'iexec';
3
+ import {
4
+ IExecDataProtectorCore,
5
+ ProcessBulkRequestResponse,
6
+ } from '@iexec/dataprotector';
3
7
  import { GraphQLClient } from 'graphql-request';
4
8
  import { fetchUserContacts } from './fetchUserContacts.js';
5
9
  import { fetchMyContacts } from './fetchMyContacts.js';
@@ -10,7 +14,7 @@ import {
10
14
  SendEmailParams,
11
15
  AddressOrENS,
12
16
  Web3MailConfigOptions,
13
- SendEmailResponse,
17
+ SendEmailSingleResponse,
14
18
  Web3SignerProvider,
15
19
  FetchMyContactsParams,
16
20
  } from './types.js';
@@ -34,6 +38,7 @@ interface Web3mailResolvedConfig {
34
38
  ipfsGateway: string;
35
39
  defaultWorkerpool: string;
36
40
  iexec: IExec;
41
+ dataProtector: IExecDataProtectorCore;
37
42
  }
38
43
 
39
44
  export class IExecWeb3mail {
@@ -51,6 +56,8 @@ export class IExecWeb3mail {
51
56
 
52
57
  private iexec!: IExec;
53
58
 
59
+ private dataProtector!: IExecDataProtectorCore;
60
+
54
61
  private initPromise: Promise<void> | null = null;
55
62
 
56
63
  private ethProvider: EthersCompatibleProvider;
@@ -75,6 +82,7 @@ export class IExecWeb3mail {
75
82
  this.ipfsGateway = config.ipfsGateway;
76
83
  this.defaultWorkerpool = config.defaultWorkerpool;
77
84
  this.iexec = config.iexec;
85
+ this.dataProtector = config.dataProtector;
78
86
  });
79
87
  }
80
88
  return this.initPromise;
@@ -105,7 +113,9 @@ export class IExecWeb3mail {
105
113
  });
106
114
  }
107
115
 
108
- async sendEmail(args: SendEmailParams): Promise<SendEmailResponse> {
116
+ async sendEmail(
117
+ args: SendEmailParams
118
+ ): Promise<ProcessBulkRequestResponse | SendEmailSingleResponse> {
109
119
  await this.init();
110
120
  await isValidProvider(this.iexec);
111
121
  return sendEmail({
@@ -113,6 +123,7 @@ export class IExecWeb3mail {
113
123
  workerpoolAddressOrEns:
114
124
  args.workerpoolAddressOrEns || this.defaultWorkerpool,
115
125
  iexec: this.iexec,
126
+ dataProtector: this.dataProtector,
116
127
  ipfsNode: this.ipfsNode,
117
128
  ipfsGateway: this.ipfsGateway,
118
129
  dappAddressOrENS: this.dappAddressOrENS,
@@ -184,6 +195,17 @@ export class IExecWeb3mail {
184
195
  throw new Error(`Failed to create GraphQLClient: ${error.message}`);
185
196
  }
186
197
 
198
+ const dataProtector = new IExecDataProtectorCore(this.ethProvider, {
199
+ iexecOptions: {
200
+ ipfsGatewayURL: ipfsGateway,
201
+ ...this.options?.iexecOptions,
202
+ allowExperimentalNetworks: this.options.allowExperimentalNetworks,
203
+ },
204
+ ipfsGateway,
205
+ ipfsNode,
206
+ subgraphUrl,
207
+ });
208
+
187
209
  return {
188
210
  dappAddressOrENS,
189
211
  dappWhitelistAddress: dappWhitelistAddress.toLowerCase(),
@@ -192,6 +214,7 @@ export class IExecWeb3mail {
192
214
  ipfsNode,
193
215
  ipfsGateway,
194
216
  iexec,
217
+ dataProtector,
195
218
  };
196
219
  }
197
220
  }
@@ -16,6 +16,7 @@ export const fetchMyContacts = async ({
16
16
  dappAddressOrENS = throwIfMissing(),
17
17
  dappWhitelistAddress = throwIfMissing(),
18
18
  isUserStrict = false,
19
+ bulkOnly = false,
19
20
  }: IExecConsumer &
20
21
  SubgraphConsumer &
21
22
  DappAddressConsumer &
@@ -33,5 +34,6 @@ export const fetchMyContacts = async ({
33
34
  dappWhitelistAddress,
34
35
  userAddress,
35
36
  isUserStrict: vIsUserStrict,
37
+ bulkOnly,
36
38
  });
37
39
  };