@iexec/web3mail 0.6.1 → 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.
Files changed (53) hide show
  1. package/package.json +8 -5
  2. package/src/index.ts +1 -0
  3. package/src/utils/errors.ts +24 -6
  4. package/src/utils/index.ts +1 -0
  5. package/src/utils/subgraphQuery.ts +8 -8
  6. package/src/utils/validators.ts +13 -1
  7. package/src/web3mail/IExecWeb3mail.ts +15 -7
  8. package/src/web3mail/fetchMyContacts.ts +18 -18
  9. package/src/web3mail/fetchUserContacts.ts +21 -6
  10. package/src/web3mail/sendEmail.ts +15 -4
  11. package/src/web3mail/types.ts +8 -1
  12. package/dist/config/config.d.ts +0 -11
  13. package/dist/config/config.js +0 -12
  14. package/dist/config/config.js.map +0 -1
  15. package/dist/index.d.ts +0 -3
  16. package/dist/index.js +0 -4
  17. package/dist/index.js.map +0 -1
  18. package/dist/utils/errors.d.ts +0 -5
  19. package/dist/utils/errors.js +0 -9
  20. package/dist/utils/errors.js.map +0 -1
  21. package/dist/utils/generateUniqueId.d.ts +0 -1
  22. package/dist/utils/generateUniqueId.js +0 -6
  23. package/dist/utils/generateUniqueId.js.map +0 -1
  24. package/dist/utils/getWeb3Provider.d.ts +0 -2
  25. package/dist/utils/getWeb3Provider.js +0 -3
  26. package/dist/utils/getWeb3Provider.js.map +0 -1
  27. package/dist/utils/ipfs-service.d.ts +0 -9
  28. package/dist/utils/ipfs-service.js +0 -29
  29. package/dist/utils/ipfs-service.js.map +0 -1
  30. package/dist/utils/paginate.d.ts +0 -5
  31. package/dist/utils/paginate.js +0 -23
  32. package/dist/utils/paginate.js.map +0 -1
  33. package/dist/utils/subgraphQuery.d.ts +0 -4
  34. package/dist/utils/subgraphQuery.js +0 -90
  35. package/dist/utils/subgraphQuery.js.map +0 -1
  36. package/dist/utils/validators.d.ts +0 -10
  37. package/dist/utils/validators.js +0 -27
  38. package/dist/utils/validators.js.map +0 -1
  39. package/dist/web3mail/IExecWeb3mail.d.ts +0 -15
  40. package/dist/web3mail/IExecWeb3mail.js +0 -40
  41. package/dist/web3mail/IExecWeb3mail.js.map +0 -1
  42. package/dist/web3mail/fetchMyContacts.d.ts +0 -2
  43. package/dist/web3mail/fetchMyContacts.js +0 -28
  44. package/dist/web3mail/fetchMyContacts.js.map +0 -1
  45. package/dist/web3mail/fetchUserContacts.d.ts +0 -2
  46. package/dist/web3mail/fetchUserContacts.js +0 -83
  47. package/dist/web3mail/fetchUserContacts.js.map +0 -1
  48. package/dist/web3mail/sendEmail.d.ts +0 -2
  49. package/dist/web3mail/sendEmail.js +0 -194
  50. package/dist/web3mail/sendEmail.js.map +0 -1
  51. package/dist/web3mail/types.d.ts +0 -96
  52. package/dist/web3mail/types.js +0 -2
  53. 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.6.1",
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",
@@ -44,12 +47,12 @@
44
47
  "buffer": "^6.0.3",
45
48
  "ethers": "^6.8.1",
46
49
  "graphql-request": "^6.1.0",
47
- "iexec": "^8.7.0",
50
+ "iexec": "^8.9.1",
48
51
  "kubo-rpc-client": "^3.0.1",
49
52
  "yup": "^1.1.1"
50
53
  },
51
54
  "devDependencies": {
52
- "@iexec/dataprotector": "^0.4.1",
55
+ "@iexec/dataprotector": "^0.5.3",
53
56
  "@jest/globals": "^29.7.0",
54
57
  "@swc/core": "^1.3.96",
55
58
  "@swc/jest": "^0.2.29",
@@ -64,7 +67,7 @@
64
67
  "eslint-plugin-sonarjs": "^0.21.0",
65
68
  "jest": "^29.7.0",
66
69
  "prettier": "^2.8.4",
67
- "typescript": "^4.9.5",
70
+ "typescript": "^5.5.2",
68
71
  "whitelist-smart-contract": "github:iExecBlockchainComputing/whitelist-smart-contract#0.2.0"
69
72
  }
70
73
  }
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { IExecWeb3mail } from './web3mail/IExecWeb3mail.js';
2
2
  export * from './web3mail/types.js';
3
+ export * from './utils/index.js';
3
4
  export { getWeb3Provider } from './utils/getWeb3Provider.js';
@@ -1,11 +1,29 @@
1
- class WorkflowError extends Error {
2
- originalError: Error;
1
+ import { ApiCallError } from 'iexec/errors';
2
+ export class WorkflowError extends Error {
3
+ isProtocolError: boolean;
3
4
 
4
- constructor(message: string, originalError: Error) {
5
- super(message);
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.originalError = originalError;
16
+ this.isProtocolError = isProtocolError;
8
17
  }
9
18
  }
10
19
 
11
- export { WorkflowError };
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
- `Failed to fetch subgraph: ${error.message}`,
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
- `Failed to fetch subgraph: ${error.message}`,
105
- error
106
- );
103
+ throw new WorkflowError({
104
+ message: 'Failed to fetch subgraph',
105
+ errorCause: error,
106
+ });
107
107
  }
108
108
  };
@@ -1,5 +1,15 @@
1
1
  import { isAddress } from 'ethers';
2
- import { ValidationError, number, string } from 'yup';
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,10 +7,10 @@ import {
7
7
  Contact,
8
8
  FetchUserContactsParams,
9
9
  SendEmailParams,
10
- Web3SignerProvider,
11
10
  AddressOrENS,
12
11
  Web3MailConfigOptions,
13
12
  SendEmailResponse,
13
+ Web3SignerProvider,
14
14
  } from './types.js';
15
15
  import { GraphQLClient } from 'graphql-request';
16
16
  import {
@@ -20,6 +20,7 @@ import {
20
20
  DATAPROTECTOR_SUBGRAPH_ENDPOINT,
21
21
  WHITELIST_SMART_CONTRACT_ADDRESS,
22
22
  } from '../config/config.js';
23
+ import { isValidProvider } from '../utils/validators.js';
23
24
 
24
25
  export class IExecWeb3mail {
25
26
  private iexec: IExec;
@@ -37,11 +38,14 @@ export class IExecWeb3mail {
37
38
  private graphQLClient: GraphQLClient;
38
39
 
39
40
  constructor(
40
- ethProvider: Eip1193Provider | Web3SignerProvider,
41
+ ethProvider?: Eip1193Provider | Web3SignerProvider | string,
41
42
  options?: Web3MailConfigOptions
42
43
  ) {
43
44
  try {
44
- this.iexec = new IExec({ ethProvider }, options?.iexecOptions);
45
+ this.iexec = new IExec(
46
+ { ethProvider: ethProvider || 'bellecour' },
47
+ options?.iexecOptions
48
+ );
45
49
  } catch (e) {
46
50
  throw Error('Unsupported ethProvider');
47
51
  }
@@ -61,13 +65,15 @@ export class IExecWeb3mail {
61
65
  options?.dappWhitelistAddress || WHITELIST_SMART_CONTRACT_ADDRESS;
62
66
  }
63
67
 
64
- fetchMyContacts = (): Promise<Contact[]> =>
65
- fetchMyContacts({
68
+ async fetchMyContacts(): Promise<Contact[]> {
69
+ await isValidProvider(this.iexec);
70
+ return fetchMyContacts({
66
71
  iexec: this.iexec,
67
72
  graphQLClient: this.graphQLClient,
68
73
  dappAddressOrENS: this.dappAddressOrENS,
69
74
  dappWhitelistAddress: this.dappWhitelistAddress,
70
75
  });
76
+ }
71
77
 
72
78
  fetchUserContacts(args?: FetchUserContactsParams): Promise<Contact[]> {
73
79
  return fetchUserContacts({
@@ -79,8 +85,9 @@ export class IExecWeb3mail {
79
85
  });
80
86
  }
81
87
 
82
- sendEmail = (args: SendEmailParams): Promise<SendEmailResponse> =>
83
- sendEmail({
88
+ async sendEmail(args: SendEmailParams): Promise<SendEmailResponse> {
89
+ await isValidProvider(this.iexec);
90
+ return sendEmail({
84
91
  ...args,
85
92
  iexec: this.iexec,
86
93
  ipfsNode: this.ipfsNode,
@@ -89,4 +96,5 @@ export class IExecWeb3mail {
89
96
  dappWhitelistAddress: this.dappWhitelistAddress,
90
97
  graphQLClient: this.graphQLClient,
91
98
  });
99
+ }
92
100
  }
@@ -1,10 +1,10 @@
1
- import { WorkflowError } from '../utils/errors.js';
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): Promise<Contact[]> => {
21
- try {
22
- const userAddress = await iexec.wallet.getAddress();
23
- return await fetchUserContacts({
24
- iexec,
25
- graphQLClient,
26
- dappAddressOrENS,
27
- dappWhitelistAddress,
28
- userAddress,
29
- });
30
- } catch (error) {
31
- throw new WorkflowError(
32
- `Failed to fetch my contacts: ${error.message}`,
33
- error
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,20 +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
- throw new WorkflowError(
85
- `Failed to fetch my contacts: ${error.message}`,
86
- error
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({ iexec, userAddress, appAddress }) {
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,
97
111
  isAppStrict: true,
112
+ isRequesterStrict: isUserStrict,
98
113
  // Use maxPageSize here to avoid too many round-trips (we want everything anyway)
99
114
  pageSize: 1000,
100
115
  }
@@ -6,7 +6,7 @@ import {
6
6
  MAX_DESIRED_WORKERPOOL_ORDER_PRICE,
7
7
  PROD_WORKERPOOL_ADDRESS,
8
8
  } from '../config/config.js';
9
- import { WorkflowError } from '../utils/errors.js';
9
+ import { handleIfProtocolError, WorkflowError } from '../utils/errors.js';
10
10
  import { generateSecureUniqueId } from '../utils/generateUniqueId.js';
11
11
  import * as ipfs from '../utils/ipfs-service.js';
12
12
  import { checkProtectedDataValidity } from '../utils/subgraphQuery.js';
@@ -203,7 +203,10 @@ export const sendEmail = async ({
203
203
  const encryptedFile = await iexec.dataset
204
204
  .encrypt(Buffer.from(vEmailContent, 'utf8'), emailContentEncryptionKey)
205
205
  .catch((e) => {
206
- throw new WorkflowError('Failed to encrypt email content', e);
206
+ throw new WorkflowError({
207
+ message: 'Failed to encrypt email content',
208
+ errorCause: e,
209
+ });
207
210
  });
208
211
  const cid = await ipfs
209
212
  .add(encryptedFile, {
@@ -211,7 +214,10 @@ export const sendEmail = async ({
211
214
  ipfsGateway: ipfsGateway,
212
215
  })
213
216
  .catch((e) => {
214
- throw new WorkflowError('Failed to upload encrypted email content', e);
217
+ throw new WorkflowError({
218
+ message: 'Failed to upload encrypted email content',
219
+ errorCause: e,
220
+ });
215
221
  });
216
222
  const multiaddr = `/ipfs/${cid}`;
217
223
 
@@ -258,6 +264,11 @@ export const sendEmail = async ({
258
264
  taskId,
259
265
  };
260
266
  } catch (error) {
261
- throw new WorkflowError(`${error.message}`, error);
267
+ handleIfProtocolError(error);
268
+
269
+ throw new WorkflowError({
270
+ message: 'Failed to sendEmail',
271
+ errorCause: error,
272
+ });
262
273
  }
263
274
  };
@@ -35,12 +35,19 @@ 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
53
  taskId: string;
@@ -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";
@@ -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
@@ -1,3 +0,0 @@
1
- export { IExecWeb3mail } from './web3mail/IExecWeb3mail.js';
2
- export * from './web3mail/types.js';
3
- export { getWeb3Provider } from './utils/getWeb3Provider.js';
package/dist/index.js DELETED
@@ -1,4 +0,0 @@
1
- export { IExecWeb3mail } from './web3mail/IExecWeb3mail.js';
2
- export * from './web3mail/types.js';
3
- export { getWeb3Provider } from './utils/getWeb3Provider.js';
4
- //# sourceMappingURL=index.js.map
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"}
@@ -1,5 +0,0 @@
1
- declare class WorkflowError extends Error {
2
- originalError: Error;
3
- constructor(message: string, originalError: Error);
4
- }
5
- export { WorkflowError };
@@ -1,9 +0,0 @@
1
- class WorkflowError extends Error {
2
- constructor(message, originalError) {
3
- super(message);
4
- this.name = this.constructor.name;
5
- this.originalError = originalError;
6
- }
7
- }
8
- export { WorkflowError };
9
- //# sourceMappingURL=errors.js.map
@@ -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,6 +0,0 @@
1
- import { randomBytes } from '@ethersproject/random';
2
- import { hexlify } from '@ethersproject/bytes';
3
- export function generateSecureUniqueId(length) {
4
- return hexlify(randomBytes(length));
5
- }
6
- //# sourceMappingURL=generateUniqueId.js.map
@@ -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,2 +0,0 @@
1
- import { Web3SignerProvider } from '../web3mail/types.js';
2
- export declare const getWeb3Provider: (privateKey: string) => Web3SignerProvider;
@@ -1,3 +0,0 @@
1
- import { getSignerFromPrivateKey } from 'iexec/utils';
2
- export const getWeb3Provider = (privateKey) => getSignerFromPrivateKey('bellecour', privateKey);
3
- //# sourceMappingURL=getWeb3Provider.js.map
@@ -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"}
@@ -1,5 +0,0 @@
1
- export declare const autoPaginateRequest: ({ request }: {
2
- request: any;
3
- }, { orders }?: {
4
- orders?: any[];
5
- }) => any;
@@ -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>;