@sudoplatform/sudo-common 5.10.0 → 6.0.2

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 (160) hide show
  1. package/.eslintrc.js +2 -4
  2. package/bin/outdated-with-suppression.sh +20 -0
  3. package/bin/suppress-outdated.sh +15 -0
  4. package/dependencies-report.json +1 -1
  5. package/docs/assets/search.js +1 -1
  6. package/docs/classes/AccountLockedError.html +4 -3
  7. package/docs/classes/AuthenticationError.html +4 -3
  8. package/docs/classes/Base64.html +2 -2
  9. package/docs/classes/Buffer.html +2 -2
  10. package/docs/classes/ConfigurationNotSetError.html +4 -3
  11. package/docs/classes/ConfigurationSetNotFoundError.html +4 -3
  12. package/docs/classes/DecodeError.html +4 -3
  13. package/docs/classes/DefaultConfigurationManager.html +6 -6
  14. package/docs/classes/DefaultLogger.html +7 -7
  15. package/docs/classes/DefaultSudoKeyArchive.html +13 -13
  16. package/docs/classes/DefaultSudoKeyManager.html +31 -27
  17. package/docs/classes/FatalError.html +4 -3
  18. package/docs/classes/IllegalArgumentError.html +4 -3
  19. package/docs/classes/IllegalStateError.html +4 -3
  20. package/docs/classes/InsufficientEntitlementsError.html +4 -3
  21. package/docs/classes/InvalidOwnershipProofError.html +4 -3
  22. package/docs/classes/InvalidTokenError.html +4 -3
  23. package/docs/classes/KeyArchiveDecodingError.html +4 -3
  24. package/docs/classes/KeyArchiveIncorrectPasswordError.html +4 -3
  25. package/docs/classes/KeyArchiveMissingError.html +4 -3
  26. package/docs/classes/KeyArchiveNoPasswordRequiredError.html +4 -3
  27. package/docs/classes/KeyArchivePasswordRequiredError.html +4 -3
  28. package/docs/classes/KeyArchiveTypeError.html +4 -3
  29. package/docs/classes/KeyArchiveUnknownKeyTypeError.html +4 -3
  30. package/docs/classes/KeyArchiveVersionError.html +4 -3
  31. package/docs/classes/KeyNotFoundError.html +4 -3
  32. package/docs/classes/KeyStoreNotExportableError.html +4 -3
  33. package/docs/classes/LimitExceededError.html +4 -3
  34. package/docs/classes/NoEntitlementsError.html +4 -3
  35. package/docs/classes/NotAuthorizedError.html +4 -3
  36. package/docs/classes/NotRegisteredError.html +4 -3
  37. package/docs/classes/NotSignedInError.html +4 -3
  38. package/docs/classes/OperationNotImplementedError.html +4 -3
  39. package/docs/classes/RegisterError.html +4 -3
  40. package/docs/classes/RequestFailedError.html +6 -5
  41. package/docs/classes/ServiceError.html +4 -3
  42. package/docs/classes/SignOutError.html +4 -3
  43. package/docs/classes/SudoCryptoProviderDefaults.html +1 -1
  44. package/docs/classes/UnknownGraphQLError.html +6 -4
  45. package/docs/classes/UnrecognizedAlgorithmError.html +4 -3
  46. package/docs/classes/UserNotConfirmedError.html +4 -3
  47. package/docs/classes/VersionMismatchError.html +4 -3
  48. package/docs/enums/CachePolicy.html +2 -2
  49. package/docs/enums/EncryptionAlgorithm.html +2 -2
  50. package/docs/enums/KeyArchiveKeyType.html +2 -2
  51. package/docs/enums/KeyDataKeyFormat.html +3 -3
  52. package/docs/enums/KeyDataKeyType.html +2 -2
  53. package/docs/enums/ListOperationResultStatus.html +4 -4
  54. package/docs/enums/PublicKeyFormat.html +1 -1
  55. package/docs/index.html +1 -1
  56. package/docs/interfaces/AsymmetricEncryptionOptions.html +2 -2
  57. package/docs/interfaces/BooleanFilter.html +2 -2
  58. package/docs/interfaces/ConfigurationManager.html +5 -5
  59. package/docs/interfaces/KeyData.html +2 -2
  60. package/docs/interfaces/ListOperationFailureResult.html +2 -2
  61. package/docs/interfaces/ListOperationPartialResult.html +4 -4
  62. package/docs/interfaces/ListOperationSuccessResult.html +3 -3
  63. package/docs/interfaces/ListOutput.html +2 -2
  64. package/docs/interfaces/Logger.html +7 -7
  65. package/docs/interfaces/Owner.html +1 -1
  66. package/docs/interfaces/PublicKey.html +1 -1
  67. package/docs/interfaces/StringFilter.html +2 -2
  68. package/docs/interfaces/SudoCryptoProvider.html +39 -31
  69. package/docs/interfaces/SudoKeyArchive.html +10 -10
  70. package/docs/interfaces/SudoKeyManager.html +39 -31
  71. package/docs/interfaces/SymmetricEncryptionOptions.html +2 -2
  72. package/docs/modules.html +4 -4
  73. package/github/.eslintrc.js +2 -4
  74. package/github/bin/outdated-with-suppression.sh +20 -0
  75. package/github/bin/suppress-outdated.sh +15 -0
  76. package/github/docs/assets/search.js +1 -1
  77. package/github/docs/classes/AccountLockedError.html +4 -3
  78. package/github/docs/classes/AuthenticationError.html +4 -3
  79. package/github/docs/classes/Base64.html +2 -2
  80. package/github/docs/classes/Buffer.html +2 -2
  81. package/github/docs/classes/ConfigurationNotSetError.html +4 -3
  82. package/github/docs/classes/ConfigurationSetNotFoundError.html +4 -3
  83. package/github/docs/classes/DecodeError.html +4 -3
  84. package/github/docs/classes/DefaultConfigurationManager.html +6 -6
  85. package/github/docs/classes/DefaultLogger.html +7 -7
  86. package/github/docs/classes/DefaultSudoKeyArchive.html +13 -13
  87. package/github/docs/classes/DefaultSudoKeyManager.html +31 -27
  88. package/github/docs/classes/FatalError.html +4 -3
  89. package/github/docs/classes/IllegalArgumentError.html +4 -3
  90. package/github/docs/classes/IllegalStateError.html +4 -3
  91. package/github/docs/classes/InsufficientEntitlementsError.html +4 -3
  92. package/github/docs/classes/InvalidOwnershipProofError.html +4 -3
  93. package/github/docs/classes/InvalidTokenError.html +4 -3
  94. package/github/docs/classes/KeyArchiveDecodingError.html +4 -3
  95. package/github/docs/classes/KeyArchiveIncorrectPasswordError.html +4 -3
  96. package/github/docs/classes/KeyArchiveMissingError.html +4 -3
  97. package/github/docs/classes/KeyArchiveNoPasswordRequiredError.html +4 -3
  98. package/github/docs/classes/KeyArchivePasswordRequiredError.html +4 -3
  99. package/github/docs/classes/KeyArchiveTypeError.html +4 -3
  100. package/github/docs/classes/KeyArchiveUnknownKeyTypeError.html +4 -3
  101. package/github/docs/classes/KeyArchiveVersionError.html +4 -3
  102. package/github/docs/classes/KeyNotFoundError.html +4 -3
  103. package/github/docs/classes/KeyStoreNotExportableError.html +4 -3
  104. package/github/docs/classes/LimitExceededError.html +4 -3
  105. package/github/docs/classes/NoEntitlementsError.html +4 -3
  106. package/github/docs/classes/NotAuthorizedError.html +4 -3
  107. package/github/docs/classes/NotRegisteredError.html +4 -3
  108. package/github/docs/classes/NotSignedInError.html +4 -3
  109. package/github/docs/classes/OperationNotImplementedError.html +4 -3
  110. package/github/docs/classes/RegisterError.html +4 -3
  111. package/github/docs/classes/RequestFailedError.html +6 -5
  112. package/github/docs/classes/ServiceError.html +4 -3
  113. package/github/docs/classes/SignOutError.html +4 -3
  114. package/github/docs/classes/SudoCryptoProviderDefaults.html +1 -1
  115. package/github/docs/classes/UnknownGraphQLError.html +6 -4
  116. package/github/docs/classes/UnrecognizedAlgorithmError.html +4 -3
  117. package/github/docs/classes/UserNotConfirmedError.html +4 -3
  118. package/github/docs/classes/VersionMismatchError.html +4 -3
  119. package/github/docs/enums/CachePolicy.html +2 -2
  120. package/github/docs/enums/EncryptionAlgorithm.html +2 -2
  121. package/github/docs/enums/KeyArchiveKeyType.html +2 -2
  122. package/github/docs/enums/KeyDataKeyFormat.html +3 -3
  123. package/github/docs/enums/KeyDataKeyType.html +2 -2
  124. package/github/docs/enums/ListOperationResultStatus.html +4 -4
  125. package/github/docs/enums/PublicKeyFormat.html +1 -1
  126. package/github/docs/index.html +1 -1
  127. package/github/docs/interfaces/AsymmetricEncryptionOptions.html +2 -2
  128. package/github/docs/interfaces/BooleanFilter.html +2 -2
  129. package/github/docs/interfaces/ConfigurationManager.html +5 -5
  130. package/github/docs/interfaces/KeyData.html +2 -2
  131. package/github/docs/interfaces/ListOperationFailureResult.html +2 -2
  132. package/github/docs/interfaces/ListOperationPartialResult.html +4 -4
  133. package/github/docs/interfaces/ListOperationSuccessResult.html +3 -3
  134. package/github/docs/interfaces/ListOutput.html +2 -2
  135. package/github/docs/interfaces/Logger.html +7 -7
  136. package/github/docs/interfaces/Owner.html +1 -1
  137. package/github/docs/interfaces/PublicKey.html +1 -1
  138. package/github/docs/interfaces/StringFilter.html +2 -2
  139. package/github/docs/interfaces/SudoCryptoProvider.html +39 -31
  140. package/github/docs/interfaces/SudoKeyArchive.html +10 -10
  141. package/github/docs/interfaces/SudoKeyManager.html +39 -31
  142. package/github/docs/interfaces/SymmetricEncryptionOptions.html +2 -2
  143. package/github/docs/modules.html +4 -4
  144. package/github/package.json +13 -10
  145. package/github/src/errors/error.ts +17 -8
  146. package/github/src/sudoKeyManager/sudoCryptoProvider.ts +14 -0
  147. package/github/src/sudoKeyManager/sudoKeyManager.ts +22 -0
  148. package/github/test/sudoKeyManager/sudoKeyManager.spec.ts +37 -0
  149. package/github/yarn.lock +566 -687
  150. package/lib/errors/error.d.ts +3 -2
  151. package/lib/errors/error.js +30 -20
  152. package/lib/sudoKeyManager/sudoCryptoProvider.d.ts +12 -0
  153. package/lib/sudoKeyManager/sudoKeyManager.d.ts +14 -0
  154. package/lib/sudoKeyManager/sudoKeyManager.js +8 -0
  155. package/package.json +13 -10
  156. package/src/errors/error.ts +17 -8
  157. package/src/sudoKeyManager/sudoCryptoProvider.ts +14 -0
  158. package/src/sudoKeyManager/sudoKeyManager.ts +22 -0
  159. package/test/sudoKeyManager/sudoKeyManager.spec.ts +37 -0
  160. package/yarn.lock +566 -687
@@ -9,10 +9,11 @@ export declare type AppSyncNetworkError = Error & {
9
9
  };
10
10
  export declare function isAppSyncNetworkError(u: Error): u is AppSyncNetworkError;
11
11
  /**
12
- * Indicates the GraphQL API returned an error that's not recognized by the client.
12
+ * Indicates the GraphQL API returned an error that's not recognized by
13
+ * the client.
13
14
  */
14
15
  export declare class UnknownGraphQLError extends Error {
15
- constructor(cause: AppSyncError);
16
+ constructor(cause: unknown);
16
17
  }
17
18
  /**
18
19
  * The configuration set was not found by the given key
@@ -15,16 +15,28 @@ function isAppSyncNetworkError(u) {
15
15
  return !!u.networkError;
16
16
  }
17
17
  /**
18
- * Indicates the GraphQL API returned an error that's not recognized by the client.
18
+ * Indicates the GraphQL API returned an error that's not recognized by
19
+ * the client.
19
20
  */
20
21
 
21
22
 
22
23
  class UnknownGraphQLError extends Error {
23
24
  constructor(cause) {
24
- var _cause$errorType;
25
+ const maybeAppSyncError = cause;
26
+ let message;
27
+
28
+ if (maybeAppSyncError !== null && maybeAppSyncError !== void 0 && maybeAppSyncError.errorType) {
29
+ message = `type: ${maybeAppSyncError.errorType}, message: ${maybeAppSyncError.message}`;
30
+ } else if (maybeAppSyncError !== null && maybeAppSyncError !== void 0 && maybeAppSyncError.message) {
31
+ message = maybeAppSyncError === null || maybeAppSyncError === void 0 ? void 0 : maybeAppSyncError.message;
32
+ } else if (maybeAppSyncError !== null && maybeAppSyncError !== void 0 && maybeAppSyncError.name) {
33
+ message = maybeAppSyncError.name;
34
+ } else {
35
+ message = 'unknown cause';
36
+ }
25
37
 
26
- super(`type: ${(_cause$errorType = cause.errorType) !== null && _cause$errorType !== void 0 ? _cause$errorType : '<cause type not specified>'}, message: ${cause.message}`);
27
- this.name = 'GraphQLError';
38
+ super(message);
39
+ this.name = 'UnknownGraphQLError';
28
40
  }
29
41
 
30
42
  }
@@ -129,7 +141,7 @@ exports.RegisterError = RegisterError;
129
141
 
130
142
  class NotRegisteredError extends Error {
131
143
  constructor(message) {
132
- super(message !== null && message !== void 0 ? message : 'User is not registered.');
144
+ super(message ?? 'User is not registered.');
133
145
  this.name = 'NotRegisteredError';
134
146
  }
135
147
 
@@ -144,7 +156,7 @@ exports.NotRegisteredError = NotRegisteredError;
144
156
 
145
157
  class NotAuthorizedError extends Error {
146
158
  constructor(message) {
147
- super(message !== null && message !== void 0 ? message : 'User is not authorized perform the requested operation.');
159
+ super(message ?? 'User is not authorized perform the requested operation.');
148
160
  this.name = 'NotAuthorizedError';
149
161
  }
150
162
 
@@ -264,7 +276,7 @@ exports.ServiceError = ServiceError;
264
276
 
265
277
  class IllegalArgumentError extends Error {
266
278
  constructor(message) {
267
- super(message !== null && message !== void 0 ? message : 'Invalid arguments were specified');
279
+ super(message ?? 'Invalid arguments were specified');
268
280
  this.name = 'IllegalArgumentError';
269
281
  }
270
282
 
@@ -316,9 +328,7 @@ class RequestFailedError extends Error {
316
328
  * status code.
317
329
  */
318
330
  constructor(cause, statusCode) {
319
- var _cause$message;
320
-
321
- super(`API request failed. cause: ${(_cause$message = cause === null || cause === void 0 ? void 0 : cause.message) !== null && _cause$message !== void 0 ? _cause$message : '<none>'}, statusCode: ${statusCode !== null && statusCode !== void 0 ? statusCode : '<none>'}`);
331
+ super(`API request failed. cause: ${(cause === null || cause === void 0 ? void 0 : cause.message) ?? '<none>'}, statusCode: ${statusCode ?? '<none>'}`);
322
332
 
323
333
  _defineProperty(this, "cause", void 0);
324
334
 
@@ -382,7 +392,7 @@ exports.InvalidTokenError = InvalidTokenError;
382
392
 
383
393
  class KeyNotFoundError extends Error {
384
394
  constructor(message) {
385
- super(message !== null && message !== void 0 ? message : 'Key not found.');
395
+ super(message ?? 'Key not found.');
386
396
  this.name = 'KeyNotFoundError';
387
397
  }
388
398
 
@@ -396,7 +406,7 @@ exports.KeyNotFoundError = KeyNotFoundError;
396
406
 
397
407
  class KeyStoreNotExportableError extends Error {
398
408
  constructor(message) {
399
- super(message !== null && message !== void 0 ? message : 'Key store not exportable.');
409
+ super(message ?? 'Key store not exportable.');
400
410
  this.name = 'KeyStoreNotExportableError';
401
411
  }
402
412
 
@@ -410,7 +420,7 @@ exports.KeyStoreNotExportableError = KeyStoreNotExportableError;
410
420
 
411
421
  class KeyArchiveMissingError extends Error {
412
422
  constructor(message) {
413
- super(message !== null && message !== void 0 ? message : 'No key archive provided prior to unarchiving');
423
+ super(message ?? 'No key archive provided prior to unarchiving');
414
424
  this.name = 'KeyArchiveMissingError';
415
425
  }
416
426
 
@@ -424,7 +434,7 @@ exports.KeyArchiveMissingError = KeyArchiveMissingError;
424
434
 
425
435
  class KeyArchivePasswordRequiredError extends Error {
426
436
  constructor(message) {
427
- super(message !== null && message !== void 0 ? message : 'No password provided to unarchive secure archive');
437
+ super(message ?? 'No password provided to unarchive secure archive');
428
438
  this.name = 'KeyArchivePasswordRequiredError';
429
439
  }
430
440
 
@@ -438,7 +448,7 @@ exports.KeyArchivePasswordRequiredError = KeyArchivePasswordRequiredError;
438
448
 
439
449
  class KeyArchiveNoPasswordRequiredError extends Error {
440
450
  constructor(message) {
441
- super(message !== null && message !== void 0 ? message : 'No password required to unarchive insecure archive');
451
+ super(message ?? 'No password required to unarchive insecure archive');
442
452
  this.name = 'KeyArchiveNoPasswordRequiredError';
443
453
  }
444
454
 
@@ -452,7 +462,7 @@ exports.KeyArchiveNoPasswordRequiredError = KeyArchiveNoPasswordRequiredError;
452
462
 
453
463
  class KeyArchiveDecodingError extends Error {
454
464
  constructor(message) {
455
- super(message !== null && message !== void 0 ? message : 'Key archive data could not be decoded as expected');
465
+ super(message ?? 'Key archive data could not be decoded as expected');
456
466
  this.name = 'KeyArchiveDecodingError';
457
467
  }
458
468
 
@@ -466,7 +476,7 @@ exports.KeyArchiveDecodingError = KeyArchiveDecodingError;
466
476
 
467
477
  class KeyArchiveIncorrectPasswordError extends Error {
468
478
  constructor(message) {
469
- super(message !== null && message !== void 0 ? message : 'Key archive was unable to be decrypted using the provided password');
479
+ super(message ?? 'Key archive was unable to be decrypted using the provided password');
470
480
  this.name = 'KeyArchiveIncorrectPasswordError';
471
481
  }
472
482
 
@@ -508,7 +518,7 @@ exports.KeyArchiveVersionError = KeyArchiveVersionError;
508
518
 
509
519
  class KeyArchiveUnknownKeyTypeError extends Error {
510
520
  constructor(message) {
511
- super(message !== null && message !== void 0 ? message : 'Key type is not recognized');
521
+ super(message ?? 'Key type is not recognized');
512
522
  this.name = 'KeyArchiveUnknownKeyTypeError';
513
523
  }
514
524
 
@@ -522,7 +532,7 @@ exports.KeyArchiveUnknownKeyTypeError = KeyArchiveUnknownKeyTypeError;
522
532
 
523
533
  class OperationNotImplementedError extends Error {
524
534
  constructor(message) {
525
- super(message !== null && message !== void 0 ? message : 'Operation is not implemented');
535
+ super(message ?? 'Operation is not implemented');
526
536
  this.name = 'OperationNotImplementedError';
527
537
  }
528
538
 
@@ -536,7 +546,7 @@ exports.OperationNotImplementedError = OperationNotImplementedError;
536
546
 
537
547
  class UnrecognizedAlgorithmError extends Error {
538
548
  constructor(message) {
539
- super(message !== null && message !== void 0 ? message : 'Unrecognized encryption algorithm name.');
549
+ super(message ?? 'Unrecognized encryption algorithm name.');
540
550
  this.name = 'UnrecognizedAlgorithmError';
541
551
  }
542
552
 
@@ -69,6 +69,12 @@ export interface SudoCryptoProvider {
69
69
  * @returns The symmetric key or undefined if not found.
70
70
  */
71
71
  getSymmetricKey(name: string): Promise<ArrayBuffer | undefined>;
72
+ /**
73
+ * Checks to see if the specified symmetric key exists.
74
+ *
75
+ * @param name The name of the symmetric key.
76
+ */
77
+ doesSymmetricKeyExists(name: string): Promise<boolean>;
72
78
  /**
73
79
  * Deletes a symmetric key from the secure store.
74
80
  *
@@ -122,6 +128,12 @@ export interface SudoCryptoProvider {
122
128
  * @returns Requested private key or undefined if the key was not found.
123
129
  */
124
130
  getPrivateKey(name: string): Promise<ArrayBuffer | undefined>;
131
+ /**
132
+ * Checks to see if the specified private key exists.
133
+ *
134
+ * @param name The name of the private key.
135
+ */
136
+ doesPrivateKeyExists(name: string): Promise<boolean>;
125
137
  /**
126
138
  * Adds a public key to the secure store.
127
139
  *
@@ -51,6 +51,12 @@ export interface SudoKeyManager {
51
51
  * @returns The symmetric key or undefined if not found.
52
52
  */
53
53
  getSymmetricKey(name: string): Promise<ArrayBuffer | undefined>;
54
+ /**
55
+ * Checks to see if the specified symmetric key exists.
56
+ *
57
+ * @param name The name of the symmetric key.
58
+ */
59
+ doesSymmetricKeyExists(name: string): Promise<boolean>;
54
60
  /**
55
61
  * Deletes a symmetric key from the secure store.
56
62
  *
@@ -72,6 +78,12 @@ export interface SudoKeyManager {
72
78
  * @returns Requested private key or undefined if the key was not found.
73
79
  */
74
80
  getPrivateKey(name: string): Promise<ArrayBuffer | undefined>;
81
+ /**
82
+ * Checks to see if the specified private key exists.
83
+ *
84
+ * @param name The name of the private key.
85
+ */
86
+ doesPrivateKeyExists(name: string): Promise<boolean>;
75
87
  /**
76
88
  * Adds a public key to the secure store.
77
89
  *
@@ -278,10 +290,12 @@ export declare class DefaultSudoKeyManager implements SudoKeyManager {
278
290
  updatePassword(password: ArrayBuffer, name: string): Promise<void>;
279
291
  addSymmetricKey(key: ArrayBuffer, name: string): Promise<void>;
280
292
  getSymmetricKey(name: string): Promise<ArrayBuffer | undefined>;
293
+ doesSymmetricKeyExists(name: string): Promise<boolean>;
281
294
  deleteSymmetricKey(name: string): Promise<void>;
282
295
  generateKeyPair(name: string): Promise<void>;
283
296
  addPrivateKey(key: ArrayBuffer, name: string): Promise<void>;
284
297
  getPrivateKey(name: string): Promise<ArrayBuffer | undefined>;
298
+ doesPrivateKeyExists(name: string): Promise<boolean>;
285
299
  addPublicKey(key: ArrayBuffer, name: string): Promise<void>;
286
300
  getPublicKey(name: string): Promise<PublicKey | undefined>;
287
301
  deleteKeyPair(name: string): Promise<void>;
@@ -49,6 +49,10 @@ class DefaultSudoKeyManager {
49
49
  return this.sudoCryptoProvider.getSymmetricKey(name);
50
50
  }
51
51
 
52
+ doesSymmetricKeyExists(name) {
53
+ return this.sudoCryptoProvider.doesSymmetricKeyExists(name);
54
+ }
55
+
52
56
  deleteSymmetricKey(name) {
53
57
  return this.sudoCryptoProvider.deleteSymmetricKey(name);
54
58
  }
@@ -65,6 +69,10 @@ class DefaultSudoKeyManager {
65
69
  return this.sudoCryptoProvider.getPrivateKey(name);
66
70
  }
67
71
 
72
+ doesPrivateKeyExists(name) {
73
+ return this.sudoCryptoProvider.doesPrivateKeyExists(name);
74
+ }
75
+
68
76
  addPublicKey(key, name) {
69
77
  return this.sudoCryptoProvider.addPublicKey(key, name);
70
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudoplatform/sudo-common",
3
- "version": "5.10.0",
3
+ "version": "6.0.2",
4
4
  "author": "Anonyome Labs, Inc.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,6 +9,7 @@
9
9
  "license": "Apache-2.0",
10
10
  "scripts": {
11
11
  "audit-with-suppressions": "bin/yarn-audit-with-suppression.sh",
12
+ "outdated-with-suppressions": "bin/outdated-with-suppression.sh",
12
13
  "clean": "rimraf ./lib ./test-lib",
13
14
  "lint": "yarn lint:eslint && yarn lint:prettier",
14
15
  "lint:eslint": "eslint \"{bin,integration-tests,src,test}/**/*.{ts,tsx}\"",
@@ -24,7 +25,9 @@
24
25
  "types": "./lib/index.d.ts",
25
26
  "bin": {
26
27
  "audit-with-suppressions": "bin/yarn-audit-with-suppression.sh",
27
- "suppress-audit": "bin/suppress-audit.sh"
28
+ "suppress-audit": "bin/suppress-audit.sh",
29
+ "outdated-with-suppressions": "bin/outdated-with-suppression.sh",
30
+ "suppress-outdated": "bin/suppress-outdated.sh"
28
31
  },
29
32
  "files": [
30
33
  "lib",
@@ -53,23 +56,23 @@
53
56
  "@babel/preset-env": "^7.15.8",
54
57
  "@babel/preset-typescript": "^7.15.0",
55
58
  "@types/jest": "^27.0.2",
56
- "@typescript-eslint/eslint-plugin": "^4.33.0",
57
- "@typescript-eslint/parser": "^4.33.0",
58
- "eslint": "^7.32.0",
59
+ "@typescript-eslint/eslint-plugin": "^5.1.0",
60
+ "@typescript-eslint/parser": "^5.1.0",
61
+ "eslint": "^8.0.1",
59
62
  "eslint-config-prettier": "^8.3.0",
60
- "eslint-plugin-import": "^2.24.2",
63
+ "eslint-plugin-import": "^2.25.2",
61
64
  "eslint-plugin-prettier": "^4.0.0",
62
- "fp-ts": "^2.11.4",
65
+ "fp-ts": "^2.11.5",
63
66
  "io-ts": "^2.2.16",
64
67
  "io-ts-types": "^0.5.16",
65
68
  "isomorphic-webcrypto": "^2.3.8",
66
- "jest": "^27.2.4",
69
+ "jest": "^27.3.1",
67
70
  "monocle-ts": "^2.3.11",
68
71
  "newtype-ts": "^0.3.2",
69
72
  "prettier": "^2.4.1",
70
73
  "rimraf": "^3.0.2",
71
74
  "ts-mockito": "^2.6.1",
72
- "typedoc": "^0.22.5",
73
- "typescript": "^4.4.3"
75
+ "typedoc": "^0.22.6",
76
+ "typescript": "^4.4.4"
74
77
  }
75
78
  }
@@ -16,16 +16,25 @@ export function isAppSyncNetworkError(u: Error): u is AppSyncNetworkError {
16
16
  }
17
17
 
18
18
  /**
19
- * Indicates the GraphQL API returned an error that's not recognized by the client.
19
+ * Indicates the GraphQL API returned an error that's not recognized by
20
+ * the client.
20
21
  */
21
22
  export class UnknownGraphQLError extends Error {
22
- constructor(cause: AppSyncError) {
23
- super(
24
- `type: ${cause.errorType ?? '<cause type not specified>'}, message: ${
25
- cause.message
26
- }`,
27
- )
28
- this.name = 'GraphQLError'
23
+ constructor(cause: unknown) {
24
+ const maybeAppSyncError = cause as AppSyncError
25
+ let message: string
26
+ if (maybeAppSyncError?.errorType) {
27
+ message = `type: ${maybeAppSyncError.errorType}, message: ${maybeAppSyncError.message}`
28
+ } else if (maybeAppSyncError?.message) {
29
+ message = maybeAppSyncError?.message
30
+ } else if (maybeAppSyncError?.name) {
31
+ message = maybeAppSyncError.name
32
+ } else {
33
+ message = 'unknown cause'
34
+ }
35
+ super(message)
36
+
37
+ this.name = 'UnknownGraphQLError'
29
38
  }
30
39
  }
31
40
 
@@ -85,6 +85,13 @@ export interface SudoCryptoProvider {
85
85
  */
86
86
  getSymmetricKey(name: string): Promise<ArrayBuffer | undefined>
87
87
 
88
+ /**
89
+ * Checks to see if the specified symmetric key exists.
90
+ *
91
+ * @param name The name of the symmetric key.
92
+ */
93
+ doesSymmetricKeyExists(name: string): Promise<boolean>
94
+
88
95
  /**
89
96
  * Deletes a symmetric key from the secure store.
90
97
  *
@@ -147,6 +154,13 @@ export interface SudoCryptoProvider {
147
154
  */
148
155
  getPrivateKey(name: string): Promise<ArrayBuffer | undefined>
149
156
 
157
+ /**
158
+ * Checks to see if the specified private key exists.
159
+ *
160
+ * @param name The name of the private key.
161
+ */
162
+ doesPrivateKeyExists(name: string): Promise<boolean>
163
+
150
164
  /**
151
165
  * Adds a public key to the secure store.
152
166
  *
@@ -63,6 +63,13 @@ export interface SudoKeyManager {
63
63
  */
64
64
  getSymmetricKey(name: string): Promise<ArrayBuffer | undefined>
65
65
 
66
+ /**
67
+ * Checks to see if the specified symmetric key exists.
68
+ *
69
+ * @param name The name of the symmetric key.
70
+ */
71
+ doesSymmetricKeyExists(name: string): Promise<boolean>
72
+
66
73
  /**
67
74
  * Deletes a symmetric key from the secure store.
68
75
  *
@@ -87,6 +94,13 @@ export interface SudoKeyManager {
87
94
  */
88
95
  getPrivateKey(name: string): Promise<ArrayBuffer | undefined>
89
96
 
97
+ /**
98
+ * Checks to see if the specified private key exists.
99
+ *
100
+ * @param name The name of the private key.
101
+ */
102
+ doesPrivateKeyExists(name: string): Promise<boolean>
103
+
90
104
  /**
91
105
  * Adds a public key to the secure store.
92
106
  *
@@ -379,6 +393,10 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
379
393
  return this.sudoCryptoProvider.getSymmetricKey(name)
380
394
  }
381
395
 
396
+ public doesSymmetricKeyExists(name: string): Promise<boolean> {
397
+ return this.sudoCryptoProvider.doesSymmetricKeyExists(name)
398
+ }
399
+
382
400
  public deleteSymmetricKey(name: string): Promise<void> {
383
401
  return this.sudoCryptoProvider.deleteSymmetricKey(name)
384
402
  }
@@ -395,6 +413,10 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
395
413
  return this.sudoCryptoProvider.getPrivateKey(name)
396
414
  }
397
415
 
416
+ public doesPrivateKeyExists(name: string): Promise<boolean> {
417
+ return this.sudoCryptoProvider.doesPrivateKeyExists(name)
418
+ }
419
+
398
420
  public addPublicKey(key: ArrayBuffer, name: string): Promise<void> {
399
421
  return this.sudoCryptoProvider.addPublicKey(key, name)
400
422
  }
@@ -177,6 +177,24 @@ describe('DefaultSudoKeyManager', () => {
177
177
  })
178
178
  })
179
179
 
180
+ describe('doesSymmetricKeyExists', () => {
181
+ it('should call crypto provider doesSymmetricKeyExists', async () => {
182
+ when(
183
+ sudoCryptoProviderMock.doesSymmetricKeyExists(anything()),
184
+ ).thenResolve(true)
185
+
186
+ await expect(
187
+ sudoKeyManager.doesSymmetricKeyExists('VpnKey'),
188
+ ).resolves.toEqual(true)
189
+ const [actualKey] = capture(
190
+ sudoCryptoProviderMock.doesSymmetricKeyExists,
191
+ ).first()
192
+ expect(actualKey).toStrictEqual('VpnKey')
193
+
194
+ verify(sudoCryptoProviderMock.doesSymmetricKeyExists(anything())).once()
195
+ })
196
+ })
197
+
180
198
  describe('deleteSymmetricKey', () => {
181
199
  it('should call crypto provider deleteSymmetricKey', async () => {
182
200
  when(sudoCryptoProviderMock.deleteSymmetricKey(anything())).thenResolve()
@@ -263,6 +281,25 @@ describe('DefaultSudoKeyManager', () => {
263
281
  })
264
282
  })
265
283
 
284
+ describe('doesPrivateKeyExists', () => {
285
+ it('should call crypto provider doesPrivateKeyExists', async () => {
286
+ when(sudoCryptoProviderMock.doesPrivateKeyExists(anything())).thenResolve(
287
+ true,
288
+ )
289
+
290
+ await expect(
291
+ sudoKeyManager.doesPrivateKeyExists('VpnKeyPair'),
292
+ ).resolves.toBeTruthy()
293
+
294
+ const [actualKeyName] = capture(
295
+ sudoCryptoProviderMock.doesPrivateKeyExists,
296
+ ).first()
297
+ expect(actualKeyName).toStrictEqual('VpnKeyPair')
298
+
299
+ verify(sudoCryptoProviderMock.doesPrivateKeyExists(anything())).once()
300
+ })
301
+ })
302
+
266
303
  describe('addPublicKey', () => {
267
304
  it('should call crypto provider addPublicKey', async () => {
268
305
  when(