@human-protocol/sdk 5.2.0 → 6.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 (63) hide show
  1. package/dist/base.d.ts +4 -5
  2. package/dist/base.d.ts.map +1 -1
  3. package/dist/base.js +4 -5
  4. package/dist/constants.js +6 -6
  5. package/dist/encryption.d.ts +68 -203
  6. package/dist/encryption.d.ts.map +1 -1
  7. package/dist/encryption.js +66 -202
  8. package/dist/error.d.ts +0 -24
  9. package/dist/error.d.ts.map +1 -1
  10. package/dist/error.js +2 -26
  11. package/dist/escrow.d.ts +427 -780
  12. package/dist/escrow.d.ts.map +1 -1
  13. package/dist/escrow.js +314 -684
  14. package/dist/graphql/queries/operator.d.ts.map +1 -1
  15. package/dist/graphql/queries/operator.js +3 -1
  16. package/dist/graphql/types.d.ts.map +1 -1
  17. package/dist/index.d.ts +3 -4
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +2 -4
  20. package/dist/kvstore.d.ts +119 -181
  21. package/dist/kvstore.d.ts.map +1 -1
  22. package/dist/kvstore.js +119 -182
  23. package/dist/operator.d.ts +59 -30
  24. package/dist/operator.d.ts.map +1 -1
  25. package/dist/operator.js +59 -30
  26. package/dist/staking.d.ts +135 -134
  27. package/dist/staking.d.ts.map +1 -1
  28. package/dist/staking.js +135 -134
  29. package/dist/statistics.d.ts +104 -134
  30. package/dist/statistics.d.ts.map +1 -1
  31. package/dist/statistics.js +119 -144
  32. package/dist/transaction.d.ts +36 -15
  33. package/dist/transaction.d.ts.map +1 -1
  34. package/dist/transaction.js +36 -15
  35. package/dist/types.d.ts +0 -54
  36. package/dist/types.d.ts.map +1 -1
  37. package/dist/utils.d.ts +31 -17
  38. package/dist/utils.d.ts.map +1 -1
  39. package/dist/utils.js +31 -17
  40. package/dist/worker.d.ts +35 -14
  41. package/dist/worker.d.ts.map +1 -1
  42. package/dist/worker.js +35 -14
  43. package/package.json +7 -24
  44. package/src/base.ts +4 -5
  45. package/src/constants.ts +6 -6
  46. package/src/encryption.ts +69 -203
  47. package/src/error.ts +0 -36
  48. package/src/escrow.ts +425 -780
  49. package/src/graphql/queries/operator.ts +3 -1
  50. package/src/graphql/types.ts +4 -2
  51. package/src/index.ts +4 -5
  52. package/src/kvstore.ts +120 -183
  53. package/src/operator.ts +59 -30
  54. package/src/staking.ts +135 -134
  55. package/src/statistics.ts +125 -146
  56. package/src/transaction.ts +36 -15
  57. package/src/types.ts +0 -57
  58. package/src/utils.ts +31 -17
  59. package/src/worker.ts +35 -14
  60. package/dist/storage.d.ts +0 -186
  61. package/dist/storage.d.ts.map +0 -1
  62. package/dist/storage.js +0 -319
  63. package/src/storage.ts +0 -313
package/src/encryption.ts CHANGED
@@ -4,8 +4,10 @@ import { IKeyPair } from './interfaces';
4
4
  /**
5
5
  * Type representing the data type of a message.
6
6
  * It can be either a string or a Uint8Array.
7
+ *
8
+ * @public
7
9
  */
8
- type MessageDataType = string | Uint8Array;
10
+ export type MessageDataType = string | Uint8Array;
9
11
 
10
12
  function makeMessageDataBinary(message: MessageDataType): Uint8Array {
11
13
  if (typeof message === 'string') {
@@ -16,44 +18,11 @@ function makeMessageDataBinary(message: MessageDataType): Uint8Array {
16
18
  }
17
19
 
18
20
  /**
19
- * ## Introduction
20
- *
21
21
  * Class for signing and decrypting messages.
22
22
  *
23
23
  * The algorithm includes the implementation of the [PGP encryption algorithm](https://github.com/openpgpjs/openpgpjs) multi-public key encryption on typescript, and uses the vanilla [ed25519](https://en.wikipedia.org/wiki/EdDSA#Ed25519) implementation Schnorr signature for signatures and [curve25519](https://en.wikipedia.org/wiki/Curve25519) for encryption. [Learn more](https://wiki.polkadot.network/docs/learn-cryptography).
24
24
  *
25
- * To get an instance of this class, initialization is recommended using the static `build` method.
26
- *
27
- * ```ts
28
- * static async build(privateKeyArmored: string, passphrase?: string): Promise<Encryption>
29
- * ```
30
- *
31
- * ## Installation
32
- *
33
- * ### npm
34
- * ```bash
35
- * npm install @human-protocol/sdk
36
- * ```
37
- *
38
- * ### yarn
39
- * ```bash
40
- * yarn install @human-protocol/sdk
41
- * ```
42
- *
43
- * ## Input parameters
44
- *
45
- * - `privateKeyArmored` - The encrypted private key in armored format.
46
- * - `passphrase` - The passphrase for the private key.
47
- *
48
- * ## Code example
49
- *
50
- * ```ts
51
- * import { Encryption } from '@human-protocol/sdk';
52
- *
53
- * const privateKey = 'Armored_priv_key';
54
- * const passphrase = 'example_passphrase';
55
- * const encryption = await Encryption.build(privateKey, passphrase);
56
- * ```
25
+ * To get an instance of this class, initialization is recommended using the static [`build`](/ts/classes/Encryption/#build) method.
57
26
  */
58
27
  export class Encryption {
59
28
  private privateKey: openpgp.PrivateKey;
@@ -61,7 +30,7 @@ export class Encryption {
61
30
  /**
62
31
  * Constructor for the Encryption class.
63
32
  *
64
- * @param {PrivateKey} privateKey - The private key.
33
+ * @param privateKey - The private key.
65
34
  */
66
35
  constructor(privateKey: openpgp.PrivateKey) {
67
36
  this.privateKey = privateKey;
@@ -70,9 +39,18 @@ export class Encryption {
70
39
  /**
71
40
  * Builds an Encryption instance by decrypting the private key from an encrypted private key and passphrase.
72
41
  *
73
- * @param {string} privateKeyArmored - The encrypted private key in armored format.
74
- * @param {string} passphrase - Optional: The passphrase for the private key.
75
- * @returns {Promise<Encryption>} - The Encryption instance.
42
+ * @param privateKeyArmored - The encrypted private key in armored format.
43
+ * @param passphrase - The passphrase for the private key (optional).
44
+ * @returns The Encryption instance.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * import { Encryption } from '@human-protocol/sdk';
49
+ *
50
+ * const privateKey = 'Armored_priv_key';
51
+ * const passphrase = 'example_passphrase';
52
+ * const encryption = await Encryption.build(privateKey, passphrase);
53
+ * ```
76
54
  */
77
55
  public static async build(
78
56
  privateKeyArmored: string,
@@ -98,45 +76,18 @@ export class Encryption {
98
76
  /**
99
77
  * This function signs and encrypts a message using the private key used to initialize the client and the specified public keys.
100
78
  *
101
- * @param {MessageDataType} message Message to sign and encrypt.
102
- * @param {string[]} publicKeys Array of public keys to use for encryption.
103
- * @returns {Promise<string>} Message signed and encrypted.
104
- *
105
- * **Code example**
79
+ * @param message - Message to sign and encrypt.
80
+ * @param publicKeys - Array of public keys to use for encryption.
81
+ * @returns Message signed and encrypted.
106
82
  *
83
+ * @example
107
84
  * ```ts
108
- * import { Encryption } from '@human-protocol/sdk';
109
- * import { EscrowClient } from '@human-protocol/sdk';
110
- *
111
- * const privateKey = 'Armored_priv_key';
112
- * const passphrase = 'example_passphrase';
113
- * const encryption = await Encryption.build(privateKey, passphrase);
114
- * const publicKey1 = `-----BEGIN PGP PUBLIC KEY BLOCK-----
115
- * xjMEZKQEMxYJKwYBBAHaRw8BAQdA5oZTq4UPlS0IXn4kEaSqQdAa9+Cq522v
116
- * WYxJQn3vo1/NFEh1bWFuIDxodW1hbkBobXQuYWk+wowEEBYKAD4FAmSkBDME
117
- * CwkHCAkQJBFPuuhtQo4DFQgKBBYAAgECGQECGwMCHgEWIQTQ5fbVPB9CWIdf
118
- * XdYkEU+66G1CjgAAKYYA/jMyDCtJtqu6hj22kq9SW6fuV1FCT2ySJ9vBhumF
119
- * X8wWAP433zVFl4VECOkgGk8qFr8BgkYxaz16GOFAqYbfO6oMBc44BGSkBDMS
120
- * CisGAQQBl1UBBQEBB0AKR+A48zVVYZWQvgu7Opn2IGvzI9jePB/J8pzqRhg2
121
- * YAMBCAfCeAQYFggAKgUCZKQEMwkQJBFPuuhtQo4CGwwWIQTQ5fbVPB9CWIdf
122
- * XdYkEU+66G1CjgAA0xgBAK4AIahFFnmWR2Mp6A3q021cZXpGklc0Xw1Hfswc
123
- * UYLqAQDfdym4kiUvKO1+REKASt0Gwykndl7hra9txqlUL5DXBQ===Vwgv
124
- * -----END PGP PUBLIC KEY BLOCK-----`;
125
- *
126
- * const publicKey2 = `-----BEGIN PGP PUBLIC KEY BLOCK-----
127
- * xjMEZKQEMxYJKwYBBAHaRw8BAQdAG6h+E+6T/RV2tIHer3FP/jKThAyGcoVx
128
- * FzhnP0hncPzNFEh1bWFuIDxodW1hbkBobXQuYWk+wowEEBYKAD4FAmSkBDME
129
- * CwkHCAkQPIq5xLhlTYkDFQgKBBYAAgECGQECGwMCHgEWIQTcxtMgul/AeUvH
130
- * bio8irnEuGVNiQAA/HsBANpfFkxNYixpsBk8LlaaCaPy5f1/cWNPgODM9uzo
131
- * ciSTAQDtAYynu4dSJO9GbMuDuc0FaUHRWJK3mS6JkvedYL4oBM44BGSkBDMS
132
- * CisGAQQBl1UBBQEBB0DWbEG7DMhkeSc8ZPzrH8XNSCqS3t9y/oQidFR+xN3Z
133
- * bAMBCAfCeAQYFggAKgUCZKQEMwkQPIq5xLhlTYkCGwwWIQTcxtMgul/AeUvH
134
- * bio8irnEuGVNiQAAqt8BAM/4Lw0RVOb0L5Ki9CyxO/6AKvRg4ra3Q3WR+duP
135
- * s/88AQCDErzvn+SOX4s3gvZcM3Vr4wh4Q2syHV8Okgx8STYPDg===DsVk
136
- * -----END PGP PUBLIC KEY BLOCK-----`;
85
+ * const publicKey1 = '-----BEGIN PGP PUBLIC KEY BLOCK-----...';
86
+ * const publicKey2 = '-----BEGIN PGP PUBLIC KEY BLOCK-----...';
137
87
  *
138
88
  * const publicKeys = [publicKey1, publicKey2];
139
89
  * const resultMessage = await encryption.signAndEncrypt('message', publicKeys);
90
+ * console.log('Encrypted message:', resultMessage);
140
91
  * ```
141
92
  */
142
93
  public async signAndEncrypt(
@@ -163,32 +114,17 @@ export class Encryption {
163
114
  /**
164
115
  * This function decrypts messages using the private key. In addition, the public key can be added for signature verification.
165
116
  *
166
- * @param {string} message Message to decrypt.
167
- * @param {string} publicKey Public key used to verify signature if needed. This is optional.
168
- * @returns {Promise<Uint8Array>} Message decrypted.
169
- *
170
- * **Code example**
117
+ * @param message - Message to decrypt.
118
+ * @param publicKey - Public key used to verify signature if needed (optional).
119
+ * @returns Message decrypted.
120
+ * @throws Error If signature could not be verified when public key is provided
171
121
  *
122
+ * @example
172
123
  * ```ts
173
- * import { Encryption } from '@human-protocol/sdk';
174
- *
175
- * const privateKey = 'Armored_priv_key';
176
- * const passphrase = 'example_passphrase';
177
- * const encryption = await Encryption.build(privateKey, passphrase);
178
- *
179
- * const publicKey = `-----BEGIN PGP PUBLIC KEY BLOCK-----
180
- * xjMEZKQEMxYJKwYBBAHaRw8BAQdA5oZTq4UPlS0IXn4kEaSqQdAa9+Cq522v
181
- * WYxJQn3vo1/NFEh1bWFuIDxodW1hbkBobXQuYWk+wowEEBYKAD4FAmSkBDME
182
- * CwkHCAkQJBFPuuhtQo4DFQgKBBYAAgECGQECGwMCHgEWIQTQ5fbVPB9CWIdf
183
- * XdYkEU+66G1CjgAAKYYA/jMyDCtJtqu6hj22kq9SW6fuV1FCT2ySJ9vBhumF
184
- * X8wWAP433zVFl4VECOkgGk8qFr8BgkYxaz16GOFAqYbfO6oMBc44BGSkBDMS
185
- * CisGAQQBl1UBBQEBB0AKR+A48zVVYZWQvgu7Opn2IGvzI9jePB/J8pzqRhg2
186
- * YAMBCAfCeAQYFggAKgUCZKQEMwkQJBFPuuhtQo4CGwwWIQTQ5fbVPB9CWIdf
187
- * XdYkEU+66G1CjgAA0xgBAK4AIahFFnmWR2Mp6A3q021cZXpGklc0Xw1Hfswc
188
- * UYLqAQDfdym4kiUvKO1+REKASt0Gwykndl7hra9txqlUL5DXBQ===Vwgv
189
- * -----END PGP PUBLIC KEY BLOCK-----`;
124
+ * const publicKey = '-----BEGIN PGP PUBLIC KEY BLOCK-----...';
190
125
  *
191
- * const resultMessage = await encryption.decrypt('message');
126
+ * const resultMessage = await encryption.decrypt('message', publicKey);
127
+ * console.log('Decrypted message:', resultMessage);
192
128
  * ```
193
129
  */
194
130
  public async decrypt(
@@ -233,19 +169,13 @@ export class Encryption {
233
169
  /**
234
170
  * This function signs a message using the private key used to initialize the client.
235
171
  *
236
- * @param {string} message Message to sign.
237
- * @returns {Promise<string>} Message signed.
238
- *
239
- * **Code example**
172
+ * @param message - Message to sign.
173
+ * @returns Message signed.
240
174
  *
175
+ * @example
241
176
  * ```ts
242
- * import { Encryption } from '@human-protocol/sdk';
243
- *
244
- * const privateKey = 'Armored_priv_key';
245
- * const passphrase = 'example_passphrase';
246
- * const encryption = await Encryption.build(privateKey, passphrase);
247
- *
248
177
  * const resultMessage = await encryption.sign('message');
178
+ * console.log('Signed message:', resultMessage);
249
179
  * ```
250
180
  */
251
181
  public async sign(message: string): Promise<string> {
@@ -263,56 +193,23 @@ export class Encryption {
263
193
  }
264
194
 
265
195
  /**
266
- * ## Introduction
267
- *
268
196
  * Utility class for encryption-related operations.
269
- *
270
- * ## Installation
271
- *
272
- * ### npm
273
- * ```bash
274
- * npm install @human-protocol/sdk
275
- * ```
276
- *
277
- * ### yarn
278
- * ```bash
279
- * yarn install @human-protocol/sdk
280
- * ```
281
- *
282
- * ## Code example
283
- *
284
- * ```ts
285
- * import { EncryptionUtils } from '@human-protocol/sdk';
286
- *
287
- * const keyPair = await EncryptionUtils.generateKeyPair('Human', 'human@hmt.ai');
288
- * ```
289
197
  */
290
198
  export class EncryptionUtils {
291
199
  /**
292
200
  * This function verifies the signature of a signed message using the public key.
293
201
  *
294
- * @param {string} message Message to verify.
295
- * @param {string} publicKey Public key to verify that the message was signed by a specific source.
296
- * @returns {Promise<boolean>} True if verified. False if not verified.
297
- *
298
- * **Code example**
202
+ * @param message - Message to verify.
203
+ * @param publicKey - Public key to verify that the message was signed by a specific source.
204
+ * @returns True if verified. False if not verified.
299
205
  *
206
+ * @example
300
207
  * ```ts
301
208
  * import { EncryptionUtils } from '@human-protocol/sdk';
302
209
  *
303
- * const publicKey = `-----BEGIN PGP PUBLIC KEY BLOCK-----
304
- * xjMEZKQEMxYJKwYBBAHaRw8BAQdA5oZTq4UPlS0IXn4kEaSqQdAa9+Cq522v
305
- * WYxJQn3vo1/NFEh1bWFuIDxodW1hbkBobXQuYWk+wowEEBYKAD4FAmSkBDME
306
- * CwkHCAkQJBFPuuhtQo4DFQgKBBYAAgECGQECGwMCHgEWIQTQ5fbVPB9CWIdf
307
- * XdYkEU+66G1CjgAAKYYA/jMyDCtJtqu6hj22kq9SW6fuV1FCT2ySJ9vBhumF
308
- * X8wWAP433zVFl4VECOkgGk8qFr8BgkYxaz16GOFAqYbfO6oMBc44BGSkBDMS
309
- * CisGAQQBl1UBBQEBB0AKR+A48zVVYZWQvgu7Opn2IGvzI9jePB/J8pzqRhg2
310
- * YAMBCAfCeAQYFggAKgUCZKQEMwkQJBFPuuhtQo4CGwwWIQTQ5fbVPB9CWIdf
311
- * XdYkEU+66G1CjgAA0xgBAK4AIahFFnmWR2Mp6A3q021cZXpGklc0Xw1Hfswc
312
- * UYLqAQDfdym4kiUvKO1+REKASt0Gwykndl7hra9txqlUL5DXBQ===Vwgv
313
- * -----END PGP PUBLIC KEY BLOCK-----`;
314
- *
210
+ * const publicKey = '-----BEGIN PGP PUBLIC KEY BLOCK-----...';
315
211
  * const result = await EncryptionUtils.verify('message', publicKey);
212
+ * console.log('Verification result:', result);
316
213
  * ```
317
214
  */
318
215
  public static async verify(
@@ -337,15 +234,16 @@ export class EncryptionUtils {
337
234
  /**
338
235
  * This function gets signed data from a signed message.
339
236
  *
340
- * @param {string} message Message.
341
- * @returns {Promise<string>} Signed data.
342
- *
343
- * **Code example**
237
+ * @param message - Message.
238
+ * @returns Signed data.
239
+ * @throws Error If data could not be extracted from the message
344
240
  *
241
+ * @example
345
242
  * ```ts
346
243
  * import { EncryptionUtils } from '@human-protocol/sdk';
347
244
  *
348
245
  * const signedData = await EncryptionUtils.getSignedData('message');
246
+ * console.log('Signed data:', signedData);
349
247
  * ```
350
248
  */
351
249
  public static async getSignedData(message: string): Promise<string> {
@@ -363,20 +261,20 @@ export class EncryptionUtils {
363
261
  /**
364
262
  * This function generates a key pair for encryption and decryption.
365
263
  *
366
- * @param {string} name Name for the key pair.
367
- * @param {string} email Email for the key pair.
368
- * @param {string} passphrase Passphrase to encrypt the private key. Optional.
369
- * @returns {Promise<IKeyPair>} Key pair generated.
370
- *
371
- * **Code example**
264
+ * @param name - Name for the key pair.
265
+ * @param email - Email for the key pair.
266
+ * @param passphrase - Passphrase to encrypt the private key (optional, defaults to empty string).
267
+ * @returns Key pair generated.
372
268
  *
269
+ * @example
373
270
  * ```ts
374
271
  * import { EncryptionUtils } from '@human-protocol/sdk';
375
272
  *
376
273
  * const name = 'YOUR_NAME';
377
274
  * const email = 'YOUR_EMAIL';
378
275
  * const passphrase = 'YOUR_PASSPHRASE';
379
- * const result = await EncryptionUtils.generateKeyPair(name, email, passphrase);
276
+ * const keyPair = await EncryptionUtils.generateKeyPair(name, email, passphrase);
277
+ * console.log('Public key:', keyPair.publicKey);
380
278
  * ```
381
279
  */
382
280
  public static async generateKeyPair(
@@ -404,41 +302,19 @@ export class EncryptionUtils {
404
302
  /**
405
303
  * This function encrypts a message using the specified public keys.
406
304
  *
407
- * @param {MessageDataType} message Message to encrypt.
408
- * @param {string[]} publicKeys Array of public keys to use for encryption.
409
- * @returns {Promise<string>} Message encrypted.
410
- *
411
- * **Code example**
305
+ * @param message - Message to encrypt.
306
+ * @param publicKeys - Array of public keys to use for encryption.
307
+ * @returns Message encrypted.
412
308
  *
309
+ * @example
413
310
  * ```ts
414
311
  * import { EncryptionUtils } from '@human-protocol/sdk';
415
312
  *
416
- * const publicKey1 = `-----BEGIN PGP PUBLIC KEY BLOCK-----
417
- * xjMEZKQEMxYJKwYBBAHaRw8BAQdA5oZTq4UPlS0IXn4kEaSqQdAa9+Cq522v
418
- * WYxJQn3vo1/NFEh1bWFuIDxodW1hbkBobXQuYWk+wowEEBYKAD4FAmSkBDME
419
- * CwkHCAkQJBFPuuhtQo4DFQgKBBYAAgECGQECGwMCHgEWIQTQ5fbVPB9CWIdf
420
- * XdYkEU+66G1CjgAAKYYA/jMyDCtJtqu6hj22kq9SW6fuV1FCT2ySJ9vBhumF
421
- * X8wWAP433zVFl4VECOkgGk8qFr8BgkYxaz16GOFAqYbfO6oMBc44BGSkBDMS
422
- * CisGAQQBl1UBBQEBB0AKR+A48zVVYZWQvgu7Opn2IGvzI9jePB/J8pzqRhg2
423
- * YAMBCAfCeAQYFggAKgUCZKQEMwkQJBFPuuhtQo4CGwwWIQTQ5fbVPB9CWIdf
424
- * XdYkEU+66G1CjgAA0xgBAK4AIahFFnmWR2Mp6A3q021cZXpGklc0Xw1Hfswc
425
- * UYLqAQDfdym4kiUvKO1+REKASt0Gwykndl7hra9txqlUL5DXBQ===Vwgv
426
- * -----END PGP PUBLIC KEY BLOCK-----`;
427
- *
428
- * const publicKey2 = `-----BEGIN PGP PUBLIC KEY BLOCK-----
429
- * xjMEZKQEMxYJKwYBBAHaRw8BAQdAG6h+E+6T/RV2tIHer3FP/jKThAyGcoVx
430
- * FzhnP0hncPzNFEh1bWFuIDxodW1hbkBobXQuYWk+wowEEBYKAD4FAmSkBDME
431
- * CwkHCAkQPIq5xLhlTYkDFQgKBBYAAgECGQECGwMCHgEWIQTcxtMgul/AeUvH
432
- * bio8irnEuGVNiQAA/HsBANpfFkxNYixpsBk8LlaaCaPy5f1/cWNPgODM9uzo
433
- * ciSTAQDtAYynu4dSJO9GbMuDuc0FaUHRWJK3mS6JkvedYL4oBM44BGSkBDMS
434
- * CisGAQQBl1UBBQEBB0DWbEG7DMhkeSc8ZPzrH8XNSCqS3t9y/oQidFR+xN3Z
435
- * bAMBCAfCeAQYFggAKgUCZKQEMwkQPIq5xLhlTYkCGwwWIQTcxtMgul/AeUvH
436
- * bio8irnEuGVNiQAAqt8BAM/4Lw0RVOb0L5Ki9CyxO/6AKvRg4ra3Q3WR+duP
437
- * s/88AQCDErzvn+SOX4s3gvZcM3Vr4wh4Q2syHV8Okgx8STYPDg===DsVk
438
- * -----END PGP PUBLIC KEY BLOCK-----`;
439
- *
440
- * const publicKeys = [publicKey1, publicKey2]
441
- * const result = await EncryptionUtils.encrypt('message', publicKeys);
313
+ * const publicKey1 = '-----BEGIN PGP PUBLIC KEY BLOCK-----...';
314
+ * const publicKey2 = '-----BEGIN PGP PUBLIC KEY BLOCK-----...';
315
+ * const publicKeys = [publicKey1, publicKey2];
316
+ * const encryptedMessage = await EncryptionUtils.encrypt('message', publicKeys);
317
+ * console.log('Encrypted message:', encryptedMessage);
442
318
  * ```
443
319
  */
444
320
  public static async encrypt(
@@ -464,25 +340,15 @@ export class EncryptionUtils {
464
340
  /**
465
341
  * Verifies if a message appears to be encrypted with OpenPGP.
466
342
  *
467
- * @param {string} message Message to verify.
468
- * @returns {Promise<boolean>} `true` if the message appears to be encrypted, `false` if not.
469
- *
470
- * **Code example:**
343
+ * @param message - Message to verify.
344
+ * @returns `true` if the message appears to be encrypted, `false` if not.
471
345
  *
346
+ * @example
472
347
  * ```ts
473
- * const message = `-----BEGIN PGP MESSAGE-----
474
- *
475
- * wV4DqdeRpqH+jaISAQdAsvBFxikvjxRqC7ZlDe98cLd7/aeCEI/AcL8PpVKK
476
- * mC0wKlwxNg/ADi55z9jcYFuMC4kKE+C/teM+JqiI8DO9AwassQUvKFtULnpx
477
- * h2jaOjC/0sAQASjUsIFK8zbuDgk/P8T9Npn6px+GlJPg9K90iwtPWiIp0eyW
478
- * 4zXamJZT51k2DyaUX/Rsc6P4PYhQRKjt0yxtH0jHPmKkLC/9eBeFf4GP0zlZ
479
- * 18xMZ8uCpQCma708Gz0sJYxEz3u/eZdHD7Mc7tWQKyJG8MsTwM1P+fdK1X75
480
- * L9UryJG2AY+6kKZhG4dqjNxiO4fWluiB2u7iMF+iLEyE3SQCEYorWMC+NDWi
481
- * QIJZ7oQ2w7BaPo1a991gvTOSNm5v2x44KfqPI1uj859BjsQTCA==
482
- * =tsmI
483
- * -----END PGP MESSAGE-----`;
348
+ * import { EncryptionUtils } from '@human-protocol/sdk';
484
349
  *
485
- * const isEncrypted = await EncryptionUtils.isEncrypted(message);
350
+ * const message = '-----BEGIN PGP MESSAGE-----...';
351
+ * const isEncrypted = EncryptionUtils.isEncrypted(message);
486
352
  *
487
353
  * if (isEncrypted) {
488
354
  * console.log('The message is encrypted with OpenPGP.');
package/src/error.ts CHANGED
@@ -3,42 +3,6 @@
3
3
  */
4
4
  export const ErrorStakingMissing = new Error('Staking contract is missing');
5
5
 
6
- /**
7
- * @constant {Error} - The Storage client not initialized.
8
- */
9
- export const ErrorStorageClientNotInitialized = new Error(
10
- 'Storage client not initialized'
11
- );
12
-
13
- /**
14
- * @constant {Error} - The Storage client does not exist.
15
- */
16
- export const ErrorStorageClientNotExists = new Error(
17
- 'Storage client does not exist'
18
- );
19
-
20
- /**
21
- * @constant {Error} - The Storage credentials are missing.
22
- */
23
- export const ErrorStorageCredentialsMissing = new Error(
24
- 'Storage credentials are missing'
25
- );
26
-
27
- /**
28
- * @constant {Error} - The Storage bucket not found.
29
- */
30
- export const ErrorStorageBucketNotFound = new Error('Bucket not found');
31
-
32
- /**
33
- * @constant {Error} - The Storage file not found.
34
- */
35
- export const ErrorStorageFileNotFound = new Error('File not found');
36
-
37
- /**
38
- * @constant {Error} - The Storage file not uploaded.
39
- */
40
- export const ErrorStorageFileNotUploaded = new Error('File not uploaded');
41
-
42
6
  /**
43
7
  * @constant {Error} - The KVStore key cannot be empty.
44
8
  */