@sudoplatform/sudo-common 5.6.0 → 5.9.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 (197) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/bin/yarn-audit-with-suppression.sh +1 -1
  3. package/dependencies-report.json +2 -2
  4. package/docs/.nojekyll +1 -0
  5. package/docs/assets/highlight.css +57 -0
  6. package/docs/assets/icons.css +1043 -0
  7. package/docs/assets/{images/icons.png → icons.png} +0 -0
  8. package/docs/assets/{images/icons@2x.png → icons@2x.png} +0 -0
  9. package/docs/assets/main.js +52 -0
  10. package/docs/assets/search.js +1 -0
  11. package/docs/assets/style.css +1384 -0
  12. package/docs/assets/{images/widgets.png → widgets.png} +0 -0
  13. package/docs/assets/{images/widgets@2x.png → widgets@2x.png} +0 -0
  14. package/docs/classes/AccountLockedError.html +7 -332
  15. package/docs/classes/AuthenticationError.html +8 -339
  16. package/docs/classes/Base64.html +3 -283
  17. package/docs/classes/Buffer.html +3 -324
  18. package/docs/classes/ConfigurationNotSetError.html +8 -333
  19. package/docs/classes/ConfigurationSetNotFoundError.html +7 -338
  20. package/docs/classes/DecodeError.html +7 -338
  21. package/docs/classes/DefaultConfigurationManager.html +18 -333
  22. package/docs/classes/DefaultLogger.html +19 -417
  23. package/docs/classes/DefaultSudoKeyArchive.html +61 -598
  24. package/docs/classes/DefaultSudoKeyManager.html +60 -1110
  25. package/docs/classes/FatalError.html +8 -339
  26. package/docs/classes/IllegalArgumentError.html +7 -338
  27. package/docs/classes/IllegalStateError.html +8 -339
  28. package/docs/classes/InsufficientEntitlementsError.html +8 -333
  29. package/docs/classes/InvalidOwnershipProofError.html +7 -332
  30. package/docs/classes/InvalidTokenError.html +7 -332
  31. package/docs/classes/KeyArchiveDecodingError.html +7 -338
  32. package/docs/classes/KeyArchiveIncorrectPasswordError.html +7 -338
  33. package/docs/classes/KeyArchiveMissingError.html +7 -338
  34. package/docs/classes/KeyArchiveNoPasswordRequiredError.html +7 -338
  35. package/docs/classes/KeyArchivePasswordRequiredError.html +7 -338
  36. package/docs/classes/KeyArchiveTypeError.html +7 -338
  37. package/docs/classes/KeyArchiveUnknownKeyTypeError.html +7 -338
  38. package/docs/classes/KeyArchiveVersionError.html +7 -338
  39. package/docs/classes/KeyNotFoundError.html +7 -338
  40. package/docs/classes/KeyStoreNotExportableError.html +7 -338
  41. package/docs/classes/LimitExceededError.html +8 -333
  42. package/docs/classes/NoEntitlementsError.html +7 -332
  43. package/docs/classes/NotAuthorizedError.html +8 -339
  44. package/docs/classes/NotRegisteredError.html +7 -338
  45. package/docs/classes/NotSignedInError.html +8 -333
  46. package/docs/classes/OperationNotImplementedError.html +7 -338
  47. package/docs/classes/RegisterError.html +8 -339
  48. package/docs/classes/RequestFailedError.html +12 -380
  49. package/docs/classes/ServiceError.html +9 -340
  50. package/docs/classes/SignOutError.html +7 -338
  51. package/docs/classes/SudoCryptoProviderDefaults.html +1 -224
  52. package/docs/classes/UnknownGraphQLError.html +7 -338
  53. package/docs/classes/UnrecognizedAlgorithmError.html +7 -0
  54. package/docs/classes/UserNotConfirmedError.html +8 -333
  55. package/docs/classes/VersionMismatchError.html +10 -335
  56. package/docs/enums/CachePolicy.html +4 -170
  57. package/docs/enums/EncryptionAlgorithm.html +5 -171
  58. package/docs/enums/KeyArchiveKeyType.html +4 -198
  59. package/docs/enums/KeyDataKeyFormat.html +18 -202
  60. package/docs/enums/KeyDataKeyType.html +3 -197
  61. package/docs/enums/ListOperationResultStatus.html +10 -0
  62. package/docs/enums/PublicKeyFormat.html +1 -162
  63. package/docs/index.html +14 -369
  64. package/docs/interfaces/AsymmetricEncryptionOptions.html +3 -163
  65. package/docs/interfaces/BooleanFilter.html +3 -177
  66. package/docs/interfaces/ConfigurationManager.html +37 -349
  67. package/docs/interfaces/KeyData.html +8 -236
  68. package/docs/interfaces/ListOperationFailureResult.html +5 -0
  69. package/docs/interfaces/ListOperationPartialResult.html +10 -0
  70. package/docs/interfaces/ListOperationSuccessResult.html +7 -0
  71. package/docs/interfaces/ListOutput.html +3 -185
  72. package/docs/interfaces/Logger.html +39 -401
  73. package/docs/interfaces/Owner.html +1 -170
  74. package/docs/interfaces/PublicKey.html +1 -170
  75. package/docs/interfaces/StringFilter.html +3 -191
  76. package/docs/interfaces/SudoCryptoProvider.html +172 -1305
  77. package/docs/interfaces/SudoKeyArchive.html +54 -490
  78. package/docs/interfaces/SudoKeyManager.html +167 -1298
  79. package/docs/interfaces/SymmetricEncryptionOptions.html +3 -177
  80. package/docs/modules.html +33 -895
  81. package/github/CHANGELOG.md +5 -1
  82. package/github/bin/yarn-audit-with-suppression.sh +1 -1
  83. package/github/docs/.nojekyll +1 -0
  84. package/github/docs/assets/highlight.css +57 -0
  85. package/github/docs/assets/icons.css +1043 -0
  86. package/github/docs/assets/{images/icons.png → icons.png} +0 -0
  87. package/github/docs/assets/{images/icons@2x.png → icons@2x.png} +0 -0
  88. package/github/docs/assets/main.js +52 -0
  89. package/github/docs/assets/search.js +1 -0
  90. package/github/docs/assets/style.css +1384 -0
  91. package/github/docs/assets/{images/widgets.png → widgets.png} +0 -0
  92. package/github/docs/assets/{images/widgets@2x.png → widgets@2x.png} +0 -0
  93. package/github/docs/classes/AccountLockedError.html +7 -332
  94. package/github/docs/classes/AuthenticationError.html +8 -339
  95. package/github/docs/classes/Base64.html +3 -283
  96. package/github/docs/classes/Buffer.html +3 -324
  97. package/github/docs/classes/ConfigurationNotSetError.html +8 -333
  98. package/github/docs/classes/ConfigurationSetNotFoundError.html +7 -338
  99. package/github/docs/classes/DecodeError.html +7 -338
  100. package/github/docs/classes/DefaultConfigurationManager.html +18 -333
  101. package/github/docs/classes/DefaultLogger.html +19 -417
  102. package/github/docs/classes/DefaultSudoKeyArchive.html +61 -598
  103. package/github/docs/classes/DefaultSudoKeyManager.html +60 -1110
  104. package/github/docs/classes/FatalError.html +8 -339
  105. package/github/docs/classes/IllegalArgumentError.html +7 -338
  106. package/github/docs/classes/IllegalStateError.html +8 -339
  107. package/github/docs/classes/InsufficientEntitlementsError.html +8 -333
  108. package/github/docs/classes/InvalidOwnershipProofError.html +7 -332
  109. package/github/docs/classes/InvalidTokenError.html +7 -332
  110. package/github/docs/classes/KeyArchiveDecodingError.html +7 -338
  111. package/github/docs/classes/KeyArchiveIncorrectPasswordError.html +7 -338
  112. package/github/docs/classes/KeyArchiveMissingError.html +7 -338
  113. package/github/docs/classes/KeyArchiveNoPasswordRequiredError.html +7 -338
  114. package/github/docs/classes/KeyArchivePasswordRequiredError.html +7 -338
  115. package/github/docs/classes/KeyArchiveTypeError.html +7 -338
  116. package/github/docs/classes/KeyArchiveUnknownKeyTypeError.html +7 -338
  117. package/github/docs/classes/KeyArchiveVersionError.html +7 -338
  118. package/github/docs/classes/KeyNotFoundError.html +7 -338
  119. package/github/docs/classes/KeyStoreNotExportableError.html +7 -338
  120. package/github/docs/classes/LimitExceededError.html +8 -333
  121. package/github/docs/classes/NoEntitlementsError.html +7 -332
  122. package/github/docs/classes/NotAuthorizedError.html +8 -339
  123. package/github/docs/classes/NotRegisteredError.html +7 -338
  124. package/github/docs/classes/NotSignedInError.html +8 -333
  125. package/github/docs/classes/OperationNotImplementedError.html +7 -338
  126. package/github/docs/classes/RegisterError.html +8 -339
  127. package/github/docs/classes/RequestFailedError.html +12 -380
  128. package/github/docs/classes/ServiceError.html +9 -340
  129. package/github/docs/classes/SignOutError.html +7 -338
  130. package/github/docs/classes/SudoCryptoProviderDefaults.html +1 -224
  131. package/github/docs/classes/UnknownGraphQLError.html +7 -338
  132. package/github/docs/classes/UnrecognizedAlgorithmError.html +7 -0
  133. package/github/docs/classes/UserNotConfirmedError.html +8 -333
  134. package/github/docs/classes/VersionMismatchError.html +10 -335
  135. package/github/docs/enums/CachePolicy.html +4 -170
  136. package/github/docs/enums/EncryptionAlgorithm.html +5 -171
  137. package/github/docs/enums/KeyArchiveKeyType.html +4 -198
  138. package/github/docs/enums/KeyDataKeyFormat.html +18 -202
  139. package/github/docs/enums/KeyDataKeyType.html +3 -197
  140. package/github/docs/enums/ListOperationResultStatus.html +10 -0
  141. package/github/docs/enums/PublicKeyFormat.html +1 -162
  142. package/github/docs/index.html +14 -369
  143. package/github/docs/interfaces/AsymmetricEncryptionOptions.html +3 -163
  144. package/github/docs/interfaces/BooleanFilter.html +3 -177
  145. package/github/docs/interfaces/ConfigurationManager.html +37 -349
  146. package/github/docs/interfaces/KeyData.html +8 -236
  147. package/github/docs/interfaces/ListOperationFailureResult.html +5 -0
  148. package/github/docs/interfaces/ListOperationPartialResult.html +10 -0
  149. package/github/docs/interfaces/ListOperationSuccessResult.html +7 -0
  150. package/github/docs/interfaces/ListOutput.html +3 -185
  151. package/github/docs/interfaces/Logger.html +39 -401
  152. package/github/docs/interfaces/Owner.html +1 -170
  153. package/github/docs/interfaces/PublicKey.html +1 -170
  154. package/github/docs/interfaces/StringFilter.html +3 -191
  155. package/github/docs/interfaces/SudoCryptoProvider.html +172 -1305
  156. package/github/docs/interfaces/SudoKeyArchive.html +54 -490
  157. package/github/docs/interfaces/SudoKeyManager.html +167 -1298
  158. package/github/docs/interfaces/SymmetricEncryptionOptions.html +3 -177
  159. package/github/docs/modules.html +33 -895
  160. package/github/package.json +19 -16
  161. package/github/src/errors/error.ts +10 -0
  162. package/github/src/sudoKeyArchive/sudoKeyArchive.ts +1 -1
  163. package/github/src/sudoKeyManager/sudoCryptoProvider.ts +12 -0
  164. package/github/src/sudoKeyManager/sudoKeyManager.ts +12 -0
  165. package/github/src/types/types.ts +78 -0
  166. package/github/test/utils/listOperationResult.spec.ts +84 -0
  167. package/github/yarn.lock +871 -1264
  168. package/lib/errors/error.d.ts +6 -0
  169. package/lib/errors/error.js +16 -2
  170. package/lib/logging/bunyanLogger.js +1 -1
  171. package/lib/sudoKeyArchive/keyArchive.js +2 -2
  172. package/lib/sudoKeyArchive/keyInfo.js +1 -1
  173. package/lib/sudoKeyArchive/sudoKeyArchive.d.ts +1 -2
  174. package/lib/sudoKeyArchive/sudoKeyArchive.js +1 -1
  175. package/lib/sudoKeyManager/keyData.js +1 -1
  176. package/lib/sudoKeyManager/sudoCryptoProvider.d.ts +12 -0
  177. package/lib/sudoKeyManager/sudoKeyManager.d.ts +12 -0
  178. package/lib/types/types.d.ts +71 -0
  179. package/lib/types/types.js +14 -2
  180. package/package.json +20 -17
  181. package/src/errors/error.ts +10 -0
  182. package/src/sudoKeyArchive/sudoKeyArchive.ts +1 -1
  183. package/src/sudoKeyManager/sudoCryptoProvider.ts +12 -0
  184. package/src/sudoKeyManager/sudoKeyManager.ts +12 -0
  185. package/src/types/types.ts +78 -0
  186. package/test/utils/listOperationResult.spec.ts +84 -0
  187. package/yarn.lock +871 -1264
  188. package/docs/assets/css/main.css +0 -2660
  189. package/docs/assets/js/main.js +0 -248
  190. package/docs/assets/js/search.js +0 -1
  191. package/github/docs/assets/css/main.css +0 -2660
  192. package/github/docs/assets/js/main.js +0 -248
  193. package/github/docs/assets/js/search.js +0 -1
  194. package/github/src/sudoKeyManager/encryptionAlgorithmTransformer.ts +0 -21
  195. package/lib/sudoKeyManager/encryptionAlgorithmTransformer.d.ts +0 -9
  196. package/lib/sudoKeyManager/encryptionAlgorithmTransformer.js +0 -28
  197. package/src/sudoKeyManager/encryptionAlgorithmTransformer.ts +0 -21
@@ -236,6 +236,12 @@ export declare class KeyArchiveUnknownKeyTypeError extends Error {
236
236
  export declare class OperationNotImplementedError extends Error {
237
237
  constructor(message?: string);
238
238
  }
239
+ /**
240
+ * Encryption algorithm is not recognized
241
+ */
242
+ export declare class UnrecognizedAlgorithmError extends Error {
243
+ constructor(message?: string);
244
+ }
239
245
  /**
240
246
  * Helper method for mapping an App Sync error to common errors.
241
247
  *
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.VersionMismatchError = exports.UserNotConfirmedError = exports.UnrecognizedAlgorithmError = exports.UnknownGraphQLError = exports.SignOutError = exports.ServiceError = exports.RequestFailedError = exports.RegisterError = exports.OperationNotImplementedError = exports.NotSignedInError = exports.NotRegisteredError = exports.NotAuthorizedError = exports.NoEntitlementsError = exports.LimitExceededError = exports.KeyStoreNotExportableError = exports.KeyNotFoundError = exports.KeyArchiveVersionError = exports.KeyArchiveUnknownKeyTypeError = exports.KeyArchiveTypeError = exports.KeyArchivePasswordRequiredError = exports.KeyArchiveNoPasswordRequiredError = exports.KeyArchiveMissingError = exports.KeyArchiveIncorrectPasswordError = exports.KeyArchiveDecodingError = exports.InvalidTokenError = exports.InvalidOwnershipProofError = exports.InsufficientEntitlementsError = exports.IllegalStateError = exports.IllegalArgumentError = exports.FatalError = exports.DecodeError = exports.ConfigurationSetNotFoundError = exports.ConfigurationNotSetError = exports.AuthenticationError = exports.AccountLockedError = void 0;
6
7
  exports.isAppSyncNetworkError = isAppSyncNetworkError;
7
8
  exports.mapGraphQLToClientError = mapGraphQLToClientError;
8
9
  exports.mapNetworkErrorToClientError = mapNetworkErrorToClientError;
9
- exports.OperationNotImplementedError = exports.KeyArchiveUnknownKeyTypeError = exports.KeyArchiveVersionError = exports.KeyArchiveTypeError = exports.KeyArchiveIncorrectPasswordError = exports.KeyArchiveDecodingError = exports.KeyArchiveNoPasswordRequiredError = exports.KeyArchivePasswordRequiredError = exports.KeyArchiveMissingError = exports.KeyStoreNotExportableError = exports.KeyNotFoundError = exports.InvalidTokenError = exports.NoEntitlementsError = exports.FatalError = exports.RequestFailedError = exports.LimitExceededError = exports.IllegalStateError = exports.IllegalArgumentError = exports.ServiceError = exports.AccountLockedError = exports.InsufficientEntitlementsError = exports.InvalidOwnershipProofError = exports.VersionMismatchError = exports.UserNotConfirmedError = exports.NotSignedInError = exports.NotAuthorizedError = exports.NotRegisteredError = exports.RegisterError = exports.SignOutError = exports.AuthenticationError = exports.DecodeError = exports.ConfigurationNotSetError = exports.ConfigurationSetNotFoundError = exports.UnknownGraphQLError = void 0;
10
10
 
11
11
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
12
 
@@ -526,6 +526,20 @@ class OperationNotImplementedError extends Error {
526
526
  this.name = 'OperationNotImplementedError';
527
527
  }
528
528
 
529
+ }
530
+ /**
531
+ * Encryption algorithm is not recognized
532
+ */
533
+
534
+
535
+ exports.OperationNotImplementedError = OperationNotImplementedError;
536
+
537
+ class UnrecognizedAlgorithmError extends Error {
538
+ constructor(message) {
539
+ super(message !== null && message !== void 0 ? message : 'Unrecognized encryption algorithm name.');
540
+ this.name = 'UnrecognizedAlgorithmError';
541
+ }
542
+
529
543
  }
530
544
  /**
531
545
  * Helper method for mapping an App Sync error to common errors.
@@ -537,7 +551,7 @@ class OperationNotImplementedError extends Error {
537
551
  */
538
552
 
539
553
 
540
- exports.OperationNotImplementedError = OperationNotImplementedError;
554
+ exports.UnrecognizedAlgorithmError = UnrecognizedAlgorithmError;
541
555
 
542
556
  function mapGraphQLToClientError(error) {
543
557
  switch (error.errorType) {
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getLogLevel = getLogLevel;
7
6
  exports.createBunyanLogger = createBunyanLogger;
7
+ exports.getLogLevel = getLogLevel;
8
8
 
9
9
  var _browserBunyan = require("browser-bunyan");
10
10
 
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isSecureKeyArchive = isSecureKeyArchive;
6
+ exports.UnrecognizedKeyArchiveCodec = exports.SecureKeyArchiveType = exports.SecureKeyArchiveCodec = exports.KeyArchiveCodec = exports.InsecureKeyArchiveType = exports.InsecureKeyArchiveCodec = exports.CURRENT_ARCHIVE_VERSION = void 0;
7
7
  exports.isInsecureKeyArchive = isInsecureKeyArchive;
8
+ exports.isSecureKeyArchive = isSecureKeyArchive;
8
9
  exports.isUnrecognizedKeyArchive = isUnrecognizedKeyArchive;
9
- exports.KeyArchiveCodec = exports.SecureKeyArchiveCodec = exports.UnrecognizedKeyArchiveCodec = exports.SecureKeyArchiveType = exports.InsecureKeyArchiveCodec = exports.InsecureKeyArchiveType = exports.CURRENT_ARCHIVE_VERSION = void 0;
10
10
 
11
11
  var t = _interopRequireWildcard(require("io-ts"));
12
12
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.KeyArchiveKeyInfoArrayCodec = exports.KeyArchiveKeyInfoCodec = void 0;
6
+ exports.KeyArchiveKeyInfoCodec = exports.KeyArchiveKeyInfoArrayCodec = void 0;
7
7
 
8
8
  var t = _interopRequireWildcard(require("io-ts"));
9
9
 
@@ -80,7 +80,7 @@ export interface SudoKeyArchive {
80
80
  /** @return the meta-information associated with this archive in an unmodifiable map. */
81
81
  getMetaInfo(): ReadonlyMap<string, string>;
82
82
  }
83
- declare type KeyArchiveKeyInfoDecoded = KeyArchiveKeyInfo & {
83
+ export declare type KeyArchiveKeyInfoDecoded = KeyArchiveKeyInfo & {
84
84
  Decoded: ArrayBuffer;
85
85
  };
86
86
  export declare class DefaultSudoKeyArchive implements SudoKeyArchive {
@@ -188,4 +188,3 @@ export declare class DefaultSudoKeyArchive implements SudoKeyArchive {
188
188
  }
189
189
  export declare function keyArchiveInfoFromKeyData(keyData: KeyData): KeyArchiveKeyInfoDecoded;
190
190
  export declare function keyArchiveKeyTypeFromKeyDataKeyType(keyDataKeyType: KeyDataKeyType): KeyArchiveKeyType;
191
- export {};
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.DefaultSudoKeyArchive = void 0;
6
7
  exports.keyArchiveInfoFromKeyData = keyArchiveInfoFromKeyData;
7
8
  exports.keyArchiveKeyTypeFromKeyDataKeyType = keyArchiveKeyTypeFromKeyDataKeyType;
8
- exports.DefaultSudoKeyArchive = void 0;
9
9
 
10
10
  var _fflate = require("fflate");
11
11
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.KeyDataKeyFormat = exports.KeyDataKeyType = void 0;
6
+ exports.KeyDataKeyType = exports.KeyDataKeyFormat = void 0;
7
7
 
8
8
  /**
9
9
  * Type of key
@@ -161,6 +161,8 @@ export interface SudoCryptoProvider {
161
161
  *
162
162
  *
163
163
  * @returns Encrypted data and IV
164
+ *
165
+ * @throws {@link UnrecognizedAlgorithmError}
164
166
  */
165
167
  encryptWithSymmetricKeyName(name: string, data: ArrayBuffer, options?: SymmetricEncryptionOptions): Promise<ArrayBuffer>;
166
168
  /**
@@ -182,6 +184,8 @@ export interface SudoCryptoProvider {
182
184
  * @param data The data to decrypt.
183
185
  *
184
186
  * @returns Decrypted data
187
+ *
188
+ * @throws {@link UnrecognizedAlgorithmError}
185
189
  */
186
190
  decryptWithSymmetricKeyName(name: string, data: ArrayBuffer, options?: SymmetricEncryptionOptions): Promise<ArrayBuffer>;
187
191
  /**
@@ -203,6 +207,8 @@ export interface SudoCryptoProvider {
203
207
  * @param data Data to encrypt.
204
208
  *
205
209
  * @returns Encrypted data and IV
210
+ *
211
+ * @throws {@link UnrecognizedAlgorithmError}
206
212
  */
207
213
  encryptWithSymmetricKey(key: ArrayBuffer, data: ArrayBuffer, options?: SymmetricEncryptionOptions): Promise<ArrayBuffer>;
208
214
  /**
@@ -224,6 +230,8 @@ export interface SudoCryptoProvider {
224
230
  * @param data The data to decrypt.
225
231
  *
226
232
  * @returns Decrypted data
233
+ *
234
+ * @throws {@link UnrecognizedAlgorithmError}
227
235
  */
228
236
  decryptWithSymmetricKey(key: ArrayBuffer, data: ArrayBuffer, options?: SymmetricEncryptionOptions): Promise<ArrayBuffer>;
229
237
  /**
@@ -233,6 +241,8 @@ export interface SudoCryptoProvider {
233
241
  * @param data The data to encrypt.
234
242
  *
235
243
  * @returns Encrypted data
244
+ *
245
+ * @throws {@link UnrecognizedAlgorithmError}
236
246
  */
237
247
  encryptWithPublicKey(name: string, data: ArrayBuffer, options?: AsymmetricEncryptionOptions): Promise<ArrayBuffer>;
238
248
  /**
@@ -242,6 +252,8 @@ export interface SudoCryptoProvider {
242
252
  * @param data The data to decrypt.
243
253
  *
244
254
  * @returns Decrypted data or undefined if the private key is not found.
255
+ *
256
+ * @throws {@link UnrecognizedAlgorithmError}
245
257
  */
246
258
  decryptWithPrivateKey(name: string, data: ArrayBuffer, options?: AsymmetricEncryptionOptions): Promise<ArrayBuffer>;
247
259
  /**
@@ -116,6 +116,8 @@ export interface SudoKeyManager {
116
116
  * @param data Data to encrypt.
117
117
  *
118
118
  * @returns Encrypted data and IV
119
+ *
120
+ * @throws {@link UnrecognizedAlgorithmError}
119
121
  */
120
122
  encryptWithSymmetricKey(key: ArrayBuffer, data: ArrayBuffer, options?: SymmetricEncryptionOptions): Promise<ArrayBuffer>;
121
123
  /**
@@ -137,6 +139,8 @@ export interface SudoKeyManager {
137
139
  * @param encryptedData The encrypted data.
138
140
  *
139
141
  * @returns Decrypted data
142
+ *
143
+ * @throws {@link UnrecognizedAlgorithmError}
140
144
  */
141
145
  decryptWithSymmetricKey(key: ArrayBuffer, data: ArrayBuffer, options?: SymmetricEncryptionOptions): Promise<ArrayBuffer>;
142
146
  /**
@@ -158,6 +162,8 @@ export interface SudoKeyManager {
158
162
  * @param data The data to decrypt.
159
163
  *
160
164
  * @returns Decrypted data
165
+ *
166
+ * @throws {@link UnrecognizedAlgorithmError}
161
167
  */
162
168
  encryptWithSymmetricKeyName(name: string, data: ArrayBuffer, options?: SymmetricEncryptionOptions): Promise<ArrayBuffer>;
163
169
  /**
@@ -178,6 +184,8 @@ export interface SudoKeyManager {
178
184
  * @param data The data to decrypt.
179
185
  *
180
186
  * @returns Decrypted data
187
+ *
188
+ * @throws {@link UnrecognizedAlgorithmError}
181
189
  */
182
190
  decryptWithSymmetricKeyName(name: string, data: ArrayBuffer, options?: SymmetricEncryptionOptions): Promise<ArrayBuffer>;
183
191
  /**
@@ -187,6 +195,8 @@ export interface SudoKeyManager {
187
195
  * @param data The data to encrypt.
188
196
  *
189
197
  * @returns Encrypted data
198
+ *
199
+ * @throws {@link UnrecognizedAlgorithmError}
190
200
  */
191
201
  encryptWithPublicKey(name: string, data: ArrayBuffer, options?: AsymmetricEncryptionOptions): Promise<ArrayBuffer>;
192
202
  /**
@@ -196,6 +206,8 @@ export interface SudoKeyManager {
196
206
  * @param data The data to decrypt.
197
207
  *
198
208
  * @returns Decrypted data or undefined if the private key is not found.
209
+ *
210
+ * @throws {@link UnrecognizedAlgorithmError}
199
211
  */
200
212
  decryptWithPrivateKey(name: string, data: ArrayBuffer, options?: AsymmetricEncryptionOptions): Promise<ArrayBuffer | undefined>;
201
213
  /**
@@ -41,3 +41,74 @@ export declare enum EncryptionAlgorithm {
41
41
  AesCbcPkcs7Padding = "AES/CBC/PKCS7Padding",
42
42
  RsaOaepSha1 = "RSA/OAEPWithSHA-1"
43
43
  }
44
+ export declare type Subset<T, S> = Pick<S, Extract<keyof T, keyof S>> & Partial<Record<Exclude<keyof T, keyof S>, never>>;
45
+ /**
46
+ * Status of the list operation result.
47
+ */
48
+ export declare enum ListOperationResultStatus {
49
+ /**
50
+ * The operation completed successfully.
51
+ */
52
+ Success = "Success",
53
+ /**
54
+ * The operation completed but some items had errors during
55
+ * processing.
56
+ */
57
+ Partial = "Partial",
58
+ /**
59
+ * The operation failed and no list item could be returned.
60
+ */
61
+ Failure = "Failure"
62
+ }
63
+ export interface ListOperationSuccessResult<T> {
64
+ /**
65
+ * Operation status.
66
+ */
67
+ status: ListOperationResultStatus.Success;
68
+ /**
69
+ * List of items that were successfully processed.
70
+ */
71
+ items: T[];
72
+ /**
73
+ * Pagination token.
74
+ */
75
+ nextToken?: string;
76
+ }
77
+ export interface ListOperationFailureResult {
78
+ /**
79
+ * Operation status.
80
+ */
81
+ status: ListOperationResultStatus.Failure;
82
+ /**
83
+ * The error that caused the failure.
84
+ */
85
+ cause: Error;
86
+ }
87
+ export interface ListOperationPartialResult<T, S extends Subset<S, T>> {
88
+ /**
89
+ * Operation status.
90
+ */
91
+ status: ListOperationResultStatus.Partial;
92
+ /**
93
+ * List of items that were successfully processed.
94
+ */
95
+ items: T[];
96
+ /**
97
+ * List of items that failed to be processed and the error
98
+ * that caused the failure.
99
+ */
100
+ failed: {
101
+ item: Omit<T, keyof S>;
102
+ cause: Error;
103
+ }[];
104
+ /**
105
+ * Pagination token.
106
+ */
107
+ nextToken?: string;
108
+ }
109
+ /**
110
+ * Result of a list operation. T is the expected item type and
111
+ * S is a subset of T's properties that won't be present if the
112
+ * additional processing after the item has been fetched fails.
113
+ */
114
+ export declare type ListOperationResult<T, S extends Subset<S, T> = T> = ListOperationSuccessResult<T> | ListOperationFailureResult | ListOperationPartialResult<T, S>;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.EncryptionAlgorithm = exports.CachePolicy = void 0;
6
+ exports.ListOperationResultStatus = exports.EncryptionAlgorithm = exports.CachePolicy = void 0;
7
7
 
8
8
  /**
9
9
  * Generic type for paginated results from list queries
@@ -32,4 +32,16 @@ exports.EncryptionAlgorithm = EncryptionAlgorithm;
32
32
  (function (EncryptionAlgorithm) {
33
33
  EncryptionAlgorithm["AesCbcPkcs7Padding"] = "AES/CBC/PKCS7Padding";
34
34
  EncryptionAlgorithm["RsaOaepSha1"] = "RSA/OAEPWithSHA-1";
35
- })(EncryptionAlgorithm || (exports.EncryptionAlgorithm = EncryptionAlgorithm = {}));
35
+ })(EncryptionAlgorithm || (exports.EncryptionAlgorithm = EncryptionAlgorithm = {}));
36
+
37
+ /**
38
+ * Status of the list operation result.
39
+ */
40
+ let ListOperationResultStatus;
41
+ exports.ListOperationResultStatus = ListOperationResultStatus;
42
+
43
+ (function (ListOperationResultStatus) {
44
+ ListOperationResultStatus["Success"] = "Success";
45
+ ListOperationResultStatus["Partial"] = "Partial";
46
+ ListOperationResultStatus["Failure"] = "Failure";
47
+ })(ListOperationResultStatus || (exports.ListOperationResultStatus = ListOperationResultStatus = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudoplatform/sudo-common",
3
- "version": "5.6.0",
3
+ "version": "5.9.0",
4
4
  "author": "Anonyome Labs, Inc.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,7 +18,7 @@
18
18
  "build:verify": "yarn audit-with-suppressions && yarn lint && yarn test --coverage",
19
19
  "build:transpile": "babel src --out-dir lib --extensions '.ts'",
20
20
  "build:declarations": "yarn tsc --emitDeclarationOnly",
21
- "build:doc": "typedoc --excludePrivate --out docs src/index.ts"
21
+ "build:doc": "typedoc --treatWarningsAsErrors --excludePrivate --out docs src/index.ts"
22
22
  },
23
23
  "main": "./lib/index.js",
24
24
  "types": "./lib/index.d.ts",
@@ -31,42 +31,45 @@
31
31
  "!*.spec.*"
32
32
  ],
33
33
  "resolutions": {
34
- "**/apollo-client": "^2.6.10"
34
+ "**/apollo-cache-inmemory": "^1.6.6",
35
+ "**/apollo-client": "^2.6.10",
36
+ "ansi-regex": "^5.0.1",
37
+ "tmpl": "^1.0.5"
35
38
  },
36
39
  "dependencies": {
37
40
  "apollo-client": "^2.6.10",
38
41
  "browser-bunyan": "^1.6.3",
39
- "fflate": "^0.7.1"
42
+ "fflate": "^0.7.1",
43
+ "graphql": "^15.6.1"
40
44
  },
41
45
  "peerDependencies": {
42
46
  "io-ts": "^2.2.10"
43
47
  },
44
48
  "devDependencies": {
45
- "@babel/cli": "^7.14.8",
46
- "@babel/core": "^7.15.0",
49
+ "@babel/cli": "^7.15.7",
50
+ "@babel/core": "^7.15.8",
47
51
  "@babel/plugin-proposal-class-properties": "^7.14.5",
48
52
  "@babel/plugin-proposal-private-methods": "^7.14.5",
49
- "@babel/preset-env": "^7.15.0",
53
+ "@babel/preset-env": "^7.15.8",
50
54
  "@babel/preset-typescript": "^7.15.0",
51
- "@types/jest": "^27.0.1",
52
- "@typescript-eslint/eslint-plugin": "^4.29.3",
53
- "@typescript-eslint/parser": "^4.29.3",
55
+ "@types/jest": "^27.0.2",
56
+ "@typescript-eslint/eslint-plugin": "^4.33.0",
57
+ "@typescript-eslint/parser": "^4.33.0",
54
58
  "eslint": "^7.32.0",
55
59
  "eslint-config-prettier": "^8.3.0",
56
60
  "eslint-plugin-import": "^2.24.2",
57
- "eslint-plugin-prettier": "^3.4.1",
58
- "fp-ts": "^2.11.1",
59
- "graphql": "^15.5.1",
61
+ "eslint-plugin-prettier": "^4.0.0",
62
+ "fp-ts": "^2.11.4",
60
63
  "io-ts": "^2.2.16",
61
64
  "io-ts-types": "^0.5.16",
62
65
  "isomorphic-webcrypto": "^2.3.8",
63
- "jest": "^27.0.6",
66
+ "jest": "^27.2.4",
64
67
  "monocle-ts": "^2.3.11",
65
68
  "newtype-ts": "^0.3.2",
66
- "prettier": "^2.3.2",
69
+ "prettier": "^2.4.1",
67
70
  "rimraf": "^3.0.2",
68
71
  "ts-mockito": "^2.6.1",
69
- "typedoc": "^0.21.6",
70
- "typescript": "^4.3.5"
72
+ "typedoc": "^0.22.5",
73
+ "typescript": "^4.4.3"
71
74
  }
72
75
  }
@@ -398,6 +398,16 @@ export class OperationNotImplementedError extends Error {
398
398
  }
399
399
  }
400
400
 
401
+ /**
402
+ * Encryption algorithm is not recognized
403
+ */
404
+ export class UnrecognizedAlgorithmError extends Error {
405
+ constructor(message?: string) {
406
+ super(message ?? 'Unrecognized encryption algorithm name.')
407
+ this.name = 'UnrecognizedAlgorithmError'
408
+ }
409
+ }
410
+
401
411
  /**
402
412
  * Helper method for mapping an App Sync error to common errors.
403
413
  *
@@ -124,7 +124,7 @@ export interface SudoKeyArchive {
124
124
  getMetaInfo(): ReadonlyMap<string, string>
125
125
  }
126
126
 
127
- type KeyArchiveKeyInfoDecoded = KeyArchiveKeyInfo & {
127
+ export type KeyArchiveKeyInfoDecoded = KeyArchiveKeyInfo & {
128
128
  Decoded: ArrayBuffer
129
129
  }
130
130
 
@@ -194,6 +194,8 @@ export interface SudoCryptoProvider {
194
194
  *
195
195
  *
196
196
  * @returns Encrypted data and IV
197
+ *
198
+ * @throws {@link UnrecognizedAlgorithmError}
197
199
  */
198
200
  encryptWithSymmetricKeyName(
199
201
  name: string,
@@ -225,6 +227,8 @@ export interface SudoCryptoProvider {
225
227
  * @param data The data to decrypt.
226
228
  *
227
229
  * @returns Decrypted data
230
+ *
231
+ * @throws {@link UnrecognizedAlgorithmError}
228
232
  */
229
233
  decryptWithSymmetricKeyName(
230
234
  name: string,
@@ -256,6 +260,8 @@ export interface SudoCryptoProvider {
256
260
  * @param data Data to encrypt.
257
261
  *
258
262
  * @returns Encrypted data and IV
263
+ *
264
+ * @throws {@link UnrecognizedAlgorithmError}
259
265
  */
260
266
  encryptWithSymmetricKey(
261
267
  key: ArrayBuffer,
@@ -287,6 +293,8 @@ export interface SudoCryptoProvider {
287
293
  * @param data The data to decrypt.
288
294
  *
289
295
  * @returns Decrypted data
296
+ *
297
+ * @throws {@link UnrecognizedAlgorithmError}
290
298
  */
291
299
  decryptWithSymmetricKey(
292
300
  key: ArrayBuffer,
@@ -301,6 +309,8 @@ export interface SudoCryptoProvider {
301
309
  * @param data The data to encrypt.
302
310
  *
303
311
  * @returns Encrypted data
312
+ *
313
+ * @throws {@link UnrecognizedAlgorithmError}
304
314
  */
305
315
  encryptWithPublicKey(
306
316
  name: string,
@@ -315,6 +325,8 @@ export interface SudoCryptoProvider {
315
325
  * @param data The data to decrypt.
316
326
  *
317
327
  * @returns Decrypted data or undefined if the private key is not found.
328
+ *
329
+ * @throws {@link UnrecognizedAlgorithmError}
318
330
  */
319
331
  decryptWithPrivateKey(
320
332
  name: string,
@@ -139,6 +139,8 @@ export interface SudoKeyManager {
139
139
  * @param data Data to encrypt.
140
140
  *
141
141
  * @returns Encrypted data and IV
142
+ *
143
+ * @throws {@link UnrecognizedAlgorithmError}
142
144
  */
143
145
  encryptWithSymmetricKey(
144
146
  key: ArrayBuffer,
@@ -170,6 +172,8 @@ export interface SudoKeyManager {
170
172
  * @param encryptedData The encrypted data.
171
173
  *
172
174
  * @returns Decrypted data
175
+ *
176
+ * @throws {@link UnrecognizedAlgorithmError}
173
177
  */
174
178
  decryptWithSymmetricKey(
175
179
  key: ArrayBuffer,
@@ -201,6 +205,8 @@ export interface SudoKeyManager {
201
205
  * @param data The data to decrypt.
202
206
  *
203
207
  * @returns Decrypted data
208
+ *
209
+ * @throws {@link UnrecognizedAlgorithmError}
204
210
  */
205
211
  encryptWithSymmetricKeyName(
206
212
  name: string,
@@ -231,6 +237,8 @@ export interface SudoKeyManager {
231
237
  * @param data The data to decrypt.
232
238
  *
233
239
  * @returns Decrypted data
240
+ *
241
+ * @throws {@link UnrecognizedAlgorithmError}
234
242
  */
235
243
  decryptWithSymmetricKeyName(
236
244
  name: string,
@@ -245,6 +253,8 @@ export interface SudoKeyManager {
245
253
  * @param data The data to encrypt.
246
254
  *
247
255
  * @returns Encrypted data
256
+ *
257
+ * @throws {@link UnrecognizedAlgorithmError}
248
258
  */
249
259
  encryptWithPublicKey(
250
260
  name: string,
@@ -259,6 +269,8 @@ export interface SudoKeyManager {
259
269
  * @param data The data to decrypt.
260
270
  *
261
271
  * @returns Decrypted data or undefined if the private key is not found.
272
+ *
273
+ * @throws {@link UnrecognizedAlgorithmError}
262
274
  */
263
275
  decryptWithPrivateKey(
264
276
  name: string,
@@ -48,3 +48,81 @@ export enum EncryptionAlgorithm {
48
48
  AesCbcPkcs7Padding = 'AES/CBC/PKCS7Padding',
49
49
  RsaOaepSha1 = 'RSA/OAEPWithSHA-1',
50
50
  }
51
+
52
+ export type Subset<T, S> = Pick<S, Extract<keyof T, keyof S>> &
53
+ Partial<Record<Exclude<keyof T, keyof S>, never>>
54
+
55
+ /**
56
+ * Status of the list operation result.
57
+ */
58
+ export enum ListOperationResultStatus {
59
+ /**
60
+ * The operation completed successfully.
61
+ */
62
+ Success = 'Success',
63
+ /**
64
+ * The operation completed but some items had errors during
65
+ * processing.
66
+ */
67
+ Partial = 'Partial',
68
+ /**
69
+ * The operation failed and no list item could be returned.
70
+ */
71
+ Failure = 'Failure',
72
+ }
73
+
74
+ export interface ListOperationSuccessResult<T> {
75
+ /**
76
+ * Operation status.
77
+ */
78
+ status: ListOperationResultStatus.Success
79
+ /**
80
+ * List of items that were successfully processed.
81
+ */
82
+ items: T[]
83
+ /**
84
+ * Pagination token.
85
+ */
86
+ nextToken?: string
87
+ }
88
+
89
+ export interface ListOperationFailureResult {
90
+ /**
91
+ * Operation status.
92
+ */
93
+ status: ListOperationResultStatus.Failure
94
+ /**
95
+ * The error that caused the failure.
96
+ */
97
+ cause: Error
98
+ }
99
+
100
+ export interface ListOperationPartialResult<T, S extends Subset<S, T>> {
101
+ /**
102
+ * Operation status.
103
+ */
104
+ status: ListOperationResultStatus.Partial
105
+ /**
106
+ * List of items that were successfully processed.
107
+ */
108
+ items: T[]
109
+ /**
110
+ * List of items that failed to be processed and the error
111
+ * that caused the failure.
112
+ */
113
+ failed: { item: Omit<T, keyof S>; cause: Error }[]
114
+ /**
115
+ * Pagination token.
116
+ */
117
+ nextToken?: string
118
+ }
119
+
120
+ /**
121
+ * Result of a list operation. T is the expected item type and
122
+ * S is a subset of T's properties that won't be present if the
123
+ * additional processing after the item has been fetched fails.
124
+ */
125
+ export type ListOperationResult<T, S extends Subset<S, T> = T> =
126
+ | ListOperationSuccessResult<T>
127
+ | ListOperationFailureResult
128
+ | ListOperationPartialResult<T, S>