@sudoplatform/sudo-common 6.3.1 → 7.0.1
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.
- package/.gitignore +2 -1
- package/.yarn/releases/{yarn-1.22.18.cjs → yarn-1.22.19.cjs} +13 -4
- package/.yarnrc +1 -1
- package/bin/outdated-with-suppression.sh +117 -11
- package/bin/suppress-outdated.sh +36 -9
- package/dependencies-report.json +388 -4
- package/docs/assets/highlight.css +11 -11
- package/docs/assets/main.js +4 -2
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +427 -617
- package/docs/classes/AccountLockedError.html +163 -8
- package/docs/classes/AuthenticationError.html +168 -8
- package/docs/classes/Base64.html +134 -3
- package/docs/classes/Buffer.html +158 -3
- package/docs/classes/ConfigurationNotSetError.html +163 -8
- package/docs/classes/ConfigurationSetNotFoundError.html +168 -8
- package/docs/classes/DecodeError.html +168 -8
- package/docs/classes/DefaultConfigurationManager.html +206 -18
- package/docs/classes/DefaultLogger.html +291 -25
- package/docs/classes/DefaultSudoKeyArchive.html +337 -39
- package/docs/classes/DefaultSudoKeyManager.html +857 -63
- package/docs/classes/FatalError.html +168 -8
- package/docs/classes/IllegalArgumentError.html +168 -8
- package/docs/classes/IllegalStateError.html +168 -8
- package/docs/classes/InsufficientEntitlementsError.html +163 -8
- package/docs/classes/InvalidOwnershipProofError.html +163 -8
- package/docs/classes/InvalidTokenError.html +163 -8
- package/docs/classes/KeyArchiveDecodingError.html +168 -8
- package/docs/classes/KeyArchiveIncorrectPasswordError.html +168 -8
- package/docs/classes/KeyArchiveMissingError.html +168 -8
- package/docs/classes/KeyArchiveNoPasswordRequiredError.html +168 -8
- package/docs/classes/KeyArchivePasswordRequiredError.html +168 -8
- package/docs/classes/KeyArchiveTypeError.html +168 -8
- package/docs/classes/KeyArchiveUnknownKeyTypeError.html +168 -8
- package/docs/classes/KeyArchiveVersionError.html +168 -8
- package/docs/classes/KeyNotFoundError.html +168 -8
- package/docs/classes/KeyStoreNotExportableError.html +168 -8
- package/docs/classes/LimitExceededError.html +163 -8
- package/docs/classes/NoEntitlementsError.html +163 -8
- package/docs/classes/NotAuthorizedError.html +168 -8
- package/docs/classes/NotRegisteredError.html +168 -8
- package/docs/classes/NotSignedInError.html +163 -8
- package/docs/classes/OperationNotImplementedError.html +168 -8
- package/docs/classes/RegisterError.html +168 -8
- package/docs/classes/RequestFailedError.html +188 -12
- package/docs/classes/ServiceError.html +168 -8
- package/docs/classes/SignOutError.html +168 -8
- package/docs/classes/SudoCryptoProviderDefaults.html +106 -1
- package/docs/classes/UnknownGraphQLError.html +168 -8
- package/docs/classes/UnrecognizedAlgorithmError.html +168 -8
- package/docs/classes/UserNotConfirmedError.html +163 -8
- package/docs/classes/VersionMismatchError.html +163 -8
- package/docs/enums/CachePolicy.html +71 -3
- package/docs/enums/EncryptionAlgorithm.html +78 -3
- package/docs/enums/KeyArchiveKeyType.html +86 -4
- package/docs/enums/KeyDataKeyFormat.html +84 -10
- package/docs/enums/KeyDataKeyType.html +85 -3
- package/docs/enums/ListOperationResultStatus.html +84 -9
- package/docs/enums/PublicKeyFormat.html +68 -1
- package/docs/functions/isAppSyncNetworkError.html +147 -0
- package/docs/functions/isInsecureKeyArchive.html +147 -0
- package/docs/functions/isSecureKeyArchive.html +147 -0
- package/docs/functions/isUnrecognizedKeyArchive.html +147 -0
- package/docs/functions/keyArchiveInfoFromKeyData.html +147 -0
- package/docs/functions/keyArchiveKeyTypeFromKeyDataKeyType.html +147 -0
- package/docs/functions/mapGraphQLToClientError.html +154 -0
- package/docs/functions/mapNetworkErrorToClientError.html +154 -0
- package/docs/index.html +134 -2
- package/docs/interfaces/AsymmetricEncryptionOptions.html +68 -3
- package/docs/interfaces/BooleanFilter.html +75 -3
- package/docs/interfaces/ConfigurationManager.html +191 -35
- package/docs/interfaces/KeyData.html +106 -8
- package/docs/interfaces/ListOperationFailureResult.html +76 -5
- package/docs/interfaces/ListOperationPartialResult.html +101 -9
- package/docs/interfaces/ListOperationSuccessResult.html +90 -7
- package/docs/interfaces/ListOutput.html +80 -3
- package/docs/interfaces/Logger.html +251 -45
- package/docs/interfaces/Owner.html +72 -1
- package/docs/interfaces/PublicKey.html +72 -1
- package/docs/interfaces/ServiceCompatibilityInfo.html +106 -13
- package/docs/interfaces/StringFilter.html +82 -3
- package/docs/interfaces/SudoCryptoProvider.html +902 -175
- package/docs/interfaces/SudoKeyArchive.html +245 -42
- package/docs/interfaces/SudoKeyManager.html +884 -169
- package/docs/interfaces/SymmetricEncryptionOptions.html +75 -3
- package/docs/interfaces/ValidationResult.html +79 -7
- package/docs/modules.html +248 -33
- package/docs/types/AppSyncError.html +138 -0
- package/docs/types/AppSyncNetworkError.html +138 -0
- package/docs/types/InsecureKeyArchive.html +138 -0
- package/docs/types/KeyArchive.html +138 -0
- package/docs/types/KeyArchiveKeyInfo.html +154 -0
- package/docs/types/KeyArchiveKeyInfoDecoded.html +138 -0
- package/docs/types/ListOperationResult.html +148 -0
- package/docs/types/SecureKeyArchive.html +138 -0
- package/docs/types/Subset.html +144 -0
- package/docs/types/UnrecognizedKeyArchive.html +138 -0
- package/docs/variables/CURRENT_ARCHIVE_VERSION.html +138 -0
- package/docs/variables/InsecureKeyArchiveCodec.html +138 -0
- package/docs/variables/InsecureKeyArchiveType.html +138 -0
- package/docs/variables/KeyArchiveCodec.html +138 -0
- package/docs/variables/KeyArchiveKeyInfoArrayCodec.html +138 -0
- package/docs/variables/KeyArchiveKeyInfoCodec.html +138 -0
- package/docs/variables/KeyArchiveKeyTypeCodec.html +138 -0
- package/docs/variables/SecureKeyArchiveCodec.html +138 -0
- package/docs/variables/SecureKeyArchiveType.html +138 -0
- package/docs/variables/UnrecognizedKeyArchiveCodec.html +138 -0
- package/github/.gitignore +2 -1
- package/github/.yarn/releases/{yarn-1.22.18.cjs → yarn-1.22.19.cjs} +13 -4
- package/github/.yarnrc +1 -1
- package/github/bin/outdated-with-suppression.sh +117 -11
- package/github/bin/suppress-outdated.sh +36 -9
- package/github/docs/assets/highlight.css +11 -11
- package/github/docs/assets/main.js +4 -2
- package/github/docs/assets/search.js +1 -1
- package/github/docs/assets/style.css +427 -617
- package/github/docs/classes/AccountLockedError.html +163 -8
- package/github/docs/classes/AuthenticationError.html +168 -8
- package/github/docs/classes/Base64.html +134 -3
- package/github/docs/classes/Buffer.html +158 -3
- package/github/docs/classes/ConfigurationNotSetError.html +163 -8
- package/github/docs/classes/ConfigurationSetNotFoundError.html +168 -8
- package/github/docs/classes/DecodeError.html +168 -8
- package/github/docs/classes/DefaultConfigurationManager.html +206 -18
- package/github/docs/classes/DefaultLogger.html +291 -25
- package/github/docs/classes/DefaultSudoKeyArchive.html +337 -39
- package/github/docs/classes/DefaultSudoKeyManager.html +857 -63
- package/github/docs/classes/FatalError.html +168 -8
- package/github/docs/classes/IllegalArgumentError.html +168 -8
- package/github/docs/classes/IllegalStateError.html +168 -8
- package/github/docs/classes/InsufficientEntitlementsError.html +163 -8
- package/github/docs/classes/InvalidOwnershipProofError.html +163 -8
- package/github/docs/classes/InvalidTokenError.html +163 -8
- package/github/docs/classes/KeyArchiveDecodingError.html +168 -8
- package/github/docs/classes/KeyArchiveIncorrectPasswordError.html +168 -8
- package/github/docs/classes/KeyArchiveMissingError.html +168 -8
- package/github/docs/classes/KeyArchiveNoPasswordRequiredError.html +168 -8
- package/github/docs/classes/KeyArchivePasswordRequiredError.html +168 -8
- package/github/docs/classes/KeyArchiveTypeError.html +168 -8
- package/github/docs/classes/KeyArchiveUnknownKeyTypeError.html +168 -8
- package/github/docs/classes/KeyArchiveVersionError.html +168 -8
- package/github/docs/classes/KeyNotFoundError.html +168 -8
- package/github/docs/classes/KeyStoreNotExportableError.html +168 -8
- package/github/docs/classes/LimitExceededError.html +163 -8
- package/github/docs/classes/NoEntitlementsError.html +163 -8
- package/github/docs/classes/NotAuthorizedError.html +168 -8
- package/github/docs/classes/NotRegisteredError.html +168 -8
- package/github/docs/classes/NotSignedInError.html +163 -8
- package/github/docs/classes/OperationNotImplementedError.html +168 -8
- package/github/docs/classes/RegisterError.html +168 -8
- package/github/docs/classes/RequestFailedError.html +188 -12
- package/github/docs/classes/ServiceError.html +168 -8
- package/github/docs/classes/SignOutError.html +168 -8
- package/github/docs/classes/SudoCryptoProviderDefaults.html +106 -1
- package/github/docs/classes/UnknownGraphQLError.html +168 -8
- package/github/docs/classes/UnrecognizedAlgorithmError.html +168 -8
- package/github/docs/classes/UserNotConfirmedError.html +163 -8
- package/github/docs/classes/VersionMismatchError.html +163 -8
- package/github/docs/enums/CachePolicy.html +71 -3
- package/github/docs/enums/EncryptionAlgorithm.html +78 -3
- package/github/docs/enums/KeyArchiveKeyType.html +86 -4
- package/github/docs/enums/KeyDataKeyFormat.html +84 -10
- package/github/docs/enums/KeyDataKeyType.html +85 -3
- package/github/docs/enums/ListOperationResultStatus.html +84 -9
- package/github/docs/enums/PublicKeyFormat.html +68 -1
- package/github/docs/functions/isAppSyncNetworkError.html +147 -0
- package/github/docs/functions/isInsecureKeyArchive.html +147 -0
- package/github/docs/functions/isSecureKeyArchive.html +147 -0
- package/github/docs/functions/isUnrecognizedKeyArchive.html +147 -0
- package/github/docs/functions/keyArchiveInfoFromKeyData.html +147 -0
- package/github/docs/functions/keyArchiveKeyTypeFromKeyDataKeyType.html +147 -0
- package/github/docs/functions/mapGraphQLToClientError.html +154 -0
- package/github/docs/functions/mapNetworkErrorToClientError.html +154 -0
- package/github/docs/index.html +134 -2
- package/github/docs/interfaces/AsymmetricEncryptionOptions.html +68 -3
- package/github/docs/interfaces/BooleanFilter.html +75 -3
- package/github/docs/interfaces/ConfigurationManager.html +191 -35
- package/github/docs/interfaces/KeyData.html +106 -8
- package/github/docs/interfaces/ListOperationFailureResult.html +76 -5
- package/github/docs/interfaces/ListOperationPartialResult.html +101 -9
- package/github/docs/interfaces/ListOperationSuccessResult.html +90 -7
- package/github/docs/interfaces/ListOutput.html +80 -3
- package/github/docs/interfaces/Logger.html +251 -45
- package/github/docs/interfaces/Owner.html +72 -1
- package/github/docs/interfaces/PublicKey.html +72 -1
- package/github/docs/interfaces/ServiceCompatibilityInfo.html +106 -13
- package/github/docs/interfaces/StringFilter.html +82 -3
- package/github/docs/interfaces/SudoCryptoProvider.html +902 -175
- package/github/docs/interfaces/SudoKeyArchive.html +245 -42
- package/github/docs/interfaces/SudoKeyManager.html +884 -169
- package/github/docs/interfaces/SymmetricEncryptionOptions.html +75 -3
- package/github/docs/interfaces/ValidationResult.html +79 -7
- package/github/docs/modules.html +248 -33
- package/github/docs/types/AppSyncError.html +138 -0
- package/github/docs/types/AppSyncNetworkError.html +138 -0
- package/github/docs/types/InsecureKeyArchive.html +138 -0
- package/github/docs/types/KeyArchive.html +138 -0
- package/github/docs/types/KeyArchiveKeyInfo.html +154 -0
- package/github/docs/types/KeyArchiveKeyInfoDecoded.html +138 -0
- package/github/docs/types/ListOperationResult.html +148 -0
- package/github/docs/types/SecureKeyArchive.html +138 -0
- package/github/docs/types/Subset.html +144 -0
- package/github/docs/types/UnrecognizedKeyArchive.html +138 -0
- package/github/docs/variables/CURRENT_ARCHIVE_VERSION.html +138 -0
- package/github/docs/variables/InsecureKeyArchiveCodec.html +138 -0
- package/github/docs/variables/InsecureKeyArchiveType.html +138 -0
- package/github/docs/variables/KeyArchiveCodec.html +138 -0
- package/github/docs/variables/KeyArchiveKeyInfoArrayCodec.html +138 -0
- package/github/docs/variables/KeyArchiveKeyInfoCodec.html +138 -0
- package/github/docs/variables/KeyArchiveKeyTypeCodec.html +138 -0
- package/github/docs/variables/SecureKeyArchiveCodec.html +138 -0
- package/github/docs/variables/SecureKeyArchiveType.html +138 -0
- package/github/docs/variables/UnrecognizedKeyArchiveCodec.html +138 -0
- package/github/package.json +25 -17
- package/github/src/sudoKeyArchive/sudoKeyArchive.ts +1 -1
- package/github/src/sudoKeyManager/sudoCryptoProvider.ts +61 -1
- package/github/src/sudoKeyManager/sudoKeyManager.ts +84 -0
- package/github/test/unit/sudoKeyManager.spec.ts +41 -0
- package/github/yarn.lock +1012 -735
- package/lib/sudoKeyArchive/sudoKeyArchive.d.ts +1 -1
- package/lib/sudoKeyArchive/sudoKeyArchive.js +1 -1
- package/lib/sudoKeyManager/sudoCryptoProvider.d.ts +49 -1
- package/lib/sudoKeyManager/sudoCryptoProvider.js +2 -0
- package/lib/sudoKeyManager/sudoKeyManager.d.ts +46 -0
- package/lib/sudoKeyManager/sudoKeyManager.js +20 -0
- package/package.json +26 -18
- package/src/sudoKeyArchive/sudoKeyArchive.ts +1 -1
- package/src/sudoKeyManager/sudoCryptoProvider.ts +61 -1
- package/src/sudoKeyManager/sudoKeyManager.ts +84 -0
- package/test/unit/sudoKeyManager.spec.ts +41 -0
- package/yarn.lock +1012 -735
- package/docs/assets/icons.css +0 -1043
- package/docs/assets/icons.png +0 -0
- package/docs/assets/icons@2x.png +0 -0
- package/github/docs/assets/icons.css +0 -1043
- package/github/docs/assets/icons.png +0 -0
- package/github/docs/assets/icons@2x.png +0 -0
|
@@ -142,7 +142,7 @@ export declare class DefaultSudoKeyArchive implements SudoKeyArchive {
|
|
|
142
142
|
*
|
|
143
143
|
* @param excludedKeyTypes
|
|
144
144
|
* Set of key types to exclude from archive or restore operation.
|
|
145
|
-
* Default: {
|
|
145
|
+
* Default: {@link KeyArchiveKeyType.PublicKey}
|
|
146
146
|
*
|
|
147
147
|
* @param metaInfo
|
|
148
148
|
* Meta information to include with the key archive
|
|
@@ -81,7 +81,7 @@ class DefaultSudoKeyArchive {
|
|
|
81
81
|
*
|
|
82
82
|
* @param excludedKeyTypes
|
|
83
83
|
* Set of key types to exclude from archive or restore operation.
|
|
84
|
-
* Default: {
|
|
84
|
+
* Default: {@link KeyArchiveKeyType.PublicKey}
|
|
85
85
|
*
|
|
86
86
|
* @param metaInfo
|
|
87
87
|
* Meta information to include with the key archive
|
|
@@ -4,6 +4,7 @@ import { PublicKey } from './publicKey';
|
|
|
4
4
|
export declare class SudoCryptoProviderDefaults {
|
|
5
5
|
static readonly aesIVSize = 16;
|
|
6
6
|
static readonly aesKeySize = 256;
|
|
7
|
+
static readonly rsaKeySize = 2048;
|
|
7
8
|
static readonly pbkdfRounds = 10000;
|
|
8
9
|
static readonly pbkdfSaltSize = 16;
|
|
9
10
|
}
|
|
@@ -74,6 +75,14 @@ export interface SudoCryptoProvider {
|
|
|
74
75
|
*
|
|
75
76
|
* @param name The name of the symmetric key.
|
|
76
77
|
*/
|
|
78
|
+
doesSymmetricKeyExist(name: string): Promise<boolean>;
|
|
79
|
+
/**
|
|
80
|
+
* Checks to see if the specified symmetric key exists.
|
|
81
|
+
*
|
|
82
|
+
* @param name The name of the symmetric key.
|
|
83
|
+
*
|
|
84
|
+
* @deprecated Use doesSymmetricKeyExist
|
|
85
|
+
*/
|
|
77
86
|
doesSymmetricKeyExists(name: string): Promise<boolean>;
|
|
78
87
|
/**
|
|
79
88
|
* Deletes a symmetric key from the secure store.
|
|
@@ -113,6 +122,27 @@ export interface SudoCryptoProvider {
|
|
|
113
122
|
* @param name The name of the key pair to be deleted.
|
|
114
123
|
*/
|
|
115
124
|
deleteKeyPair(name: string): Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* Generates a signature for the given data with the specified private key.
|
|
127
|
+
*
|
|
128
|
+
* @param name The name of the private key to use for generation.
|
|
129
|
+
* @param data The data to sign.
|
|
130
|
+
*
|
|
131
|
+
* @returns Data signature
|
|
132
|
+
*
|
|
133
|
+
* @throws {@link KeyNotFoundError}
|
|
134
|
+
*/
|
|
135
|
+
generateSignatureWithPrivateKey(name: string, data: ArrayBuffer): Promise<ArrayBuffer>;
|
|
136
|
+
/**
|
|
137
|
+
* Verifies the given data against the provided signature using the specified public key.
|
|
138
|
+
*
|
|
139
|
+
* @param name The name of the public key to use for validation.
|
|
140
|
+
* @param data The data to verify
|
|
141
|
+
* @param signature The signature to verify against
|
|
142
|
+
*
|
|
143
|
+
* @returns True if the data and signature could be successfully verified
|
|
144
|
+
*/
|
|
145
|
+
verifySignatureWithPublicKey(name: string, data: ArrayBuffer, signature: ArrayBuffer): Promise<boolean>;
|
|
116
146
|
/**
|
|
117
147
|
* Adds a private key to the secure store.
|
|
118
148
|
*
|
|
@@ -133,6 +163,14 @@ export interface SudoCryptoProvider {
|
|
|
133
163
|
*
|
|
134
164
|
* @param name The name of the private key.
|
|
135
165
|
*/
|
|
166
|
+
doesPrivateKeyExist(name: string): Promise<boolean>;
|
|
167
|
+
/**
|
|
168
|
+
* Checks to see if the specified private key exists.
|
|
169
|
+
*
|
|
170
|
+
* @param name The name of the private key.
|
|
171
|
+
*
|
|
172
|
+
* @deprecated Use doesPrivateKeyExist
|
|
173
|
+
*/
|
|
136
174
|
doesPrivateKeyExists(name: string): Promise<boolean>;
|
|
137
175
|
/**
|
|
138
176
|
* Adds a public key to the secure store.
|
|
@@ -141,6 +179,12 @@ export interface SudoCryptoProvider {
|
|
|
141
179
|
* @param name The name of the public key to be stored.
|
|
142
180
|
*/
|
|
143
181
|
addPublicKey(key: ArrayBuffer, name: string): Promise<void>;
|
|
182
|
+
/**
|
|
183
|
+
* Deletes the specified public key from the secure store.
|
|
184
|
+
*
|
|
185
|
+
* @param name The name of the public key to be removed.
|
|
186
|
+
*/
|
|
187
|
+
deletePublicKey(name: string): Promise<void>;
|
|
144
188
|
/**
|
|
145
189
|
* Retrieves the public key from the secure store.
|
|
146
190
|
*
|
|
@@ -175,6 +219,7 @@ export interface SudoCryptoProvider {
|
|
|
175
219
|
* @returns Encrypted data and IV
|
|
176
220
|
*
|
|
177
221
|
* @throws {@link UnrecognizedAlgorithmError}
|
|
222
|
+
* @throws {@link KeyNotFoundError}
|
|
178
223
|
*/
|
|
179
224
|
encryptWithSymmetricKeyName(name: string, data: ArrayBuffer, options?: SymmetricEncryptionOptions): Promise<ArrayBuffer>;
|
|
180
225
|
/**
|
|
@@ -198,6 +243,7 @@ export interface SudoCryptoProvider {
|
|
|
198
243
|
* @returns Decrypted data
|
|
199
244
|
*
|
|
200
245
|
* @throws {@link UnrecognizedAlgorithmError}
|
|
246
|
+
* @throws {@link KeyNotFoundError}
|
|
201
247
|
*/
|
|
202
248
|
decryptWithSymmetricKeyName(name: string, data: ArrayBuffer, options?: SymmetricEncryptionOptions): Promise<ArrayBuffer>;
|
|
203
249
|
/**
|
|
@@ -255,6 +301,7 @@ export interface SudoCryptoProvider {
|
|
|
255
301
|
* @returns Encrypted data
|
|
256
302
|
*
|
|
257
303
|
* @throws {@link UnrecognizedAlgorithmError}
|
|
304
|
+
* @throws {@link KeyNotFoundError}
|
|
258
305
|
*/
|
|
259
306
|
encryptWithPublicKey(name: string, data: ArrayBuffer, options?: AsymmetricEncryptionOptions): Promise<ArrayBuffer>;
|
|
260
307
|
/**
|
|
@@ -263,9 +310,10 @@ export interface SudoCryptoProvider {
|
|
|
263
310
|
* @param name The name of the private key to use for decryption.
|
|
264
311
|
* @param data The data to decrypt.
|
|
265
312
|
*
|
|
266
|
-
* @returns Decrypted data
|
|
313
|
+
* @returns Decrypted data.
|
|
267
314
|
*
|
|
268
315
|
* @throws {@link UnrecognizedAlgorithmError}
|
|
316
|
+
* @throws {@link KeyNotFoundError}
|
|
269
317
|
*/
|
|
270
318
|
decryptWithPrivateKey(name: string, data: ArrayBuffer, options?: AsymmetricEncryptionOptions): Promise<ArrayBuffer>;
|
|
271
319
|
/**
|
|
@@ -19,6 +19,8 @@ _defineProperty(SudoCryptoProviderDefaults, "aesIVSize", 16);
|
|
|
19
19
|
|
|
20
20
|
_defineProperty(SudoCryptoProviderDefaults, "aesKeySize", 256);
|
|
21
21
|
|
|
22
|
+
_defineProperty(SudoCryptoProviderDefaults, "rsaKeySize", 2048);
|
|
23
|
+
|
|
22
24
|
_defineProperty(SudoCryptoProviderDefaults, "pbkdfRounds", 10000);
|
|
23
25
|
|
|
24
26
|
_defineProperty(SudoCryptoProviderDefaults, "pbkdfSaltSize", 16);
|
|
@@ -56,6 +56,14 @@ export interface SudoKeyManager {
|
|
|
56
56
|
*
|
|
57
57
|
* @param name The name of the symmetric key.
|
|
58
58
|
*/
|
|
59
|
+
doesSymmetricKeyExist(name: string): Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Checks to see if the specified symmetric key exists.
|
|
62
|
+
*
|
|
63
|
+
* @param name The name of the symmetric key.
|
|
64
|
+
*
|
|
65
|
+
* @deprecated Use doesSymmetricKeyExist
|
|
66
|
+
*/
|
|
59
67
|
doesSymmetricKeyExists(name: string): Promise<boolean>;
|
|
60
68
|
/**
|
|
61
69
|
* Deletes a symmetric key from the secure store.
|
|
@@ -83,6 +91,14 @@ export interface SudoKeyManager {
|
|
|
83
91
|
*
|
|
84
92
|
* @param name The name of the private key.
|
|
85
93
|
*/
|
|
94
|
+
doesPrivateKeyExist(name: string): Promise<boolean>;
|
|
95
|
+
/**
|
|
96
|
+
* Checks to see if the specified private key exists.
|
|
97
|
+
*
|
|
98
|
+
* @param name The name of the private key.
|
|
99
|
+
*
|
|
100
|
+
* @deprecated Use doesPrivateKeyExist
|
|
101
|
+
*/
|
|
86
102
|
doesPrivateKeyExists(name: string): Promise<boolean>;
|
|
87
103
|
/**
|
|
88
104
|
* Adds a public key to the secure store.
|
|
@@ -93,6 +109,12 @@ export interface SudoKeyManager {
|
|
|
93
109
|
* @param name The name of the public key to be stored.
|
|
94
110
|
*/
|
|
95
111
|
addPublicKey(key: ArrayBuffer, name: string): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Deletes the specified public key from the secure store.
|
|
114
|
+
*
|
|
115
|
+
* @param name The name of the public key to be removed.
|
|
116
|
+
*/
|
|
117
|
+
deletePublicKey(name: string): Promise<void>;
|
|
96
118
|
/**
|
|
97
119
|
* Retrieves the public key from the secure store.
|
|
98
120
|
*
|
|
@@ -109,6 +131,25 @@ export interface SudoKeyManager {
|
|
|
109
131
|
* @param name The name of the key pair to be deleted.
|
|
110
132
|
*/
|
|
111
133
|
deleteKeyPair(name: string): Promise<void>;
|
|
134
|
+
/**
|
|
135
|
+
* Generates a signature for the given data with the specified private key.
|
|
136
|
+
*
|
|
137
|
+
* @param name The name of the private key to use for generation.
|
|
138
|
+
* @param data The data to sign.
|
|
139
|
+
*
|
|
140
|
+
* @returns Data signature or undefined if the private key is not found.
|
|
141
|
+
*/
|
|
142
|
+
generateSignatureWithPrivateKey(name: string, data: ArrayBuffer): Promise<ArrayBuffer>;
|
|
143
|
+
/**
|
|
144
|
+
* Verifies the given data against the provided signature using the specified public key.
|
|
145
|
+
*
|
|
146
|
+
* @param name The name of the public key to use for validation.
|
|
147
|
+
* @param data The data to verify
|
|
148
|
+
* @param signature The signature to verify against
|
|
149
|
+
*
|
|
150
|
+
* @returns True if the data and signature could be successfully verified
|
|
151
|
+
*/
|
|
152
|
+
verifySignatureWithPublicKey(name: string, data: ArrayBuffer, signature: ArrayBuffer): Promise<boolean>;
|
|
112
153
|
/**
|
|
113
154
|
* @deprecated Use version with `options` param.
|
|
114
155
|
*
|
|
@@ -290,15 +331,20 @@ export declare class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
290
331
|
updatePassword(password: ArrayBuffer, name: string): Promise<void>;
|
|
291
332
|
addSymmetricKey(key: ArrayBuffer, name: string): Promise<void>;
|
|
292
333
|
getSymmetricKey(name: string): Promise<ArrayBuffer | undefined>;
|
|
334
|
+
doesSymmetricKeyExist(name: string): Promise<boolean>;
|
|
293
335
|
doesSymmetricKeyExists(name: string): Promise<boolean>;
|
|
294
336
|
deleteSymmetricKey(name: string): Promise<void>;
|
|
295
337
|
generateKeyPair(name: string): Promise<void>;
|
|
296
338
|
addPrivateKey(key: ArrayBuffer, name: string): Promise<void>;
|
|
297
339
|
getPrivateKey(name: string): Promise<ArrayBuffer | undefined>;
|
|
340
|
+
doesPrivateKeyExist(name: string): Promise<boolean>;
|
|
298
341
|
doesPrivateKeyExists(name: string): Promise<boolean>;
|
|
299
342
|
addPublicKey(key: ArrayBuffer, name: string): Promise<void>;
|
|
343
|
+
deletePublicKey(name: string): Promise<void>;
|
|
300
344
|
getPublicKey(name: string): Promise<PublicKey | undefined>;
|
|
301
345
|
deleteKeyPair(name: string): Promise<void>;
|
|
346
|
+
generateSignatureWithPrivateKey(name: string, data: ArrayBuffer): Promise<ArrayBuffer>;
|
|
347
|
+
verifySignatureWithPublicKey(name: string, data: ArrayBuffer, signature: ArrayBuffer): Promise<boolean>;
|
|
302
348
|
encryptWithSymmetricKey(key: ArrayBuffer, data: ArrayBuffer, ivOrOptions?: ArrayBuffer | SymmetricEncryptionOptions): Promise<ArrayBuffer>;
|
|
303
349
|
decryptWithSymmetricKey(key: ArrayBuffer, data: ArrayBuffer, ivOrOptions?: ArrayBuffer | SymmetricEncryptionOptions): Promise<ArrayBuffer>;
|
|
304
350
|
encryptWithSymmetricKeyName(name: string, data: ArrayBuffer, ivOrOptions?: ArrayBuffer | SymmetricEncryptionOptions): Promise<ArrayBuffer>;
|
|
@@ -49,6 +49,10 @@ class DefaultSudoKeyManager {
|
|
|
49
49
|
return this.sudoCryptoProvider.getSymmetricKey(name);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
doesSymmetricKeyExist(name) {
|
|
53
|
+
return this.sudoCryptoProvider.doesSymmetricKeyExists(name);
|
|
54
|
+
}
|
|
55
|
+
|
|
52
56
|
doesSymmetricKeyExists(name) {
|
|
53
57
|
return this.sudoCryptoProvider.doesSymmetricKeyExists(name);
|
|
54
58
|
}
|
|
@@ -69,6 +73,10 @@ class DefaultSudoKeyManager {
|
|
|
69
73
|
return this.sudoCryptoProvider.getPrivateKey(name);
|
|
70
74
|
}
|
|
71
75
|
|
|
76
|
+
doesPrivateKeyExist(name) {
|
|
77
|
+
return this.sudoCryptoProvider.doesPrivateKeyExists(name);
|
|
78
|
+
}
|
|
79
|
+
|
|
72
80
|
doesPrivateKeyExists(name) {
|
|
73
81
|
return this.sudoCryptoProvider.doesPrivateKeyExists(name);
|
|
74
82
|
}
|
|
@@ -77,6 +85,10 @@ class DefaultSudoKeyManager {
|
|
|
77
85
|
return this.sudoCryptoProvider.addPublicKey(key, name);
|
|
78
86
|
}
|
|
79
87
|
|
|
88
|
+
deletePublicKey(name) {
|
|
89
|
+
return this.sudoCryptoProvider.deletePublicKey(name);
|
|
90
|
+
}
|
|
91
|
+
|
|
80
92
|
getPublicKey(name) {
|
|
81
93
|
return this.sudoCryptoProvider.getPublicKey(name);
|
|
82
94
|
}
|
|
@@ -85,6 +97,14 @@ class DefaultSudoKeyManager {
|
|
|
85
97
|
return this.sudoCryptoProvider.deleteKeyPair(name);
|
|
86
98
|
}
|
|
87
99
|
|
|
100
|
+
generateSignatureWithPrivateKey(name, data) {
|
|
101
|
+
return this.sudoCryptoProvider.generateSignatureWithPrivateKey(name, data);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
verifySignatureWithPublicKey(name, data, signature) {
|
|
105
|
+
return this.sudoCryptoProvider.verifySignatureWithPublicKey(name, data, signature);
|
|
106
|
+
}
|
|
107
|
+
|
|
88
108
|
encryptWithSymmetricKey(key, data, ivOrOptions) {
|
|
89
109
|
if (_buffer.Buffer.isArrayBuffer(ivOrOptions)) {
|
|
90
110
|
return this.sudoCryptoProvider.encryptWithSymmetricKey(key, data, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sudoplatform/sudo-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"author": "Anonyome Labs, Inc.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -44,40 +44,48 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"apollo-client": "^2.6.10",
|
|
47
|
-
"aws-sdk": "^2.
|
|
47
|
+
"aws-sdk": "^2.1181.0",
|
|
48
48
|
"browser-bunyan": "^1.8.0",
|
|
49
49
|
"fflate": "^0.7.3",
|
|
50
50
|
"graphql": "^15.8.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"io-ts": "^2.2.
|
|
53
|
+
"io-ts": "^2.2.16"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@babel/cli": "^7.
|
|
57
|
-
"@babel/core": "^7.
|
|
58
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
59
|
-
"@babel/plugin-proposal-private-methods": "^7.
|
|
60
|
-
"@babel/preset-env": "^7.
|
|
61
|
-
"@babel/preset-typescript": "^7.
|
|
62
|
-
"@types/jest": "^27.5.
|
|
63
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
64
|
-
"@typescript-eslint/parser": "^5.
|
|
56
|
+
"@babel/cli": "^7.18.9",
|
|
57
|
+
"@babel/core": "^7.18.9",
|
|
58
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
59
|
+
"@babel/plugin-proposal-private-methods": "^7.18.6",
|
|
60
|
+
"@babel/preset-env": "^7.18.9",
|
|
61
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
62
|
+
"@types/jest": "^27.5.2",
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
|
64
|
+
"@typescript-eslint/parser": "^5.30.7",
|
|
65
65
|
"aws-sdk-mock": "^5.7.0",
|
|
66
|
-
"eslint": "^8.
|
|
66
|
+
"eslint": "^8.20.0",
|
|
67
67
|
"eslint-config-prettier": "^8.5.0",
|
|
68
68
|
"eslint-plugin-import": "^2.26.0",
|
|
69
|
-
"eslint-plugin-prettier": "^4.
|
|
70
|
-
"fp-ts": "^2.
|
|
69
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
70
|
+
"fp-ts": "^2.12.1",
|
|
71
71
|
"io-ts": "^2.2.16",
|
|
72
72
|
"io-ts-types": "^0.5.16",
|
|
73
73
|
"isomorphic-webcrypto": "^2.3.8",
|
|
74
74
|
"jest": "^27.5.1",
|
|
75
75
|
"monocle-ts": "^2.3.13",
|
|
76
76
|
"newtype-ts": "^0.3.5",
|
|
77
|
-
"prettier": "^2.
|
|
77
|
+
"prettier": "^2.7.1",
|
|
78
78
|
"rimraf": "^3.0.2",
|
|
79
79
|
"ts-mockito": "^2.6.1",
|
|
80
|
-
"typedoc": "^0.
|
|
81
|
-
"typescript": "^4.
|
|
80
|
+
"typedoc": "^0.23.8",
|
|
81
|
+
"typescript": "^4.7.4"
|
|
82
|
+
},
|
|
83
|
+
"outdatedSuppressions": {
|
|
84
|
+
"major": {
|
|
85
|
+
"@types/jest": 1661135936,
|
|
86
|
+
"ansi-regex": 1661135937,
|
|
87
|
+
"graphql": 1661135937,
|
|
88
|
+
"jest": 1661135937
|
|
89
|
+
}
|
|
82
90
|
}
|
|
83
91
|
}
|
|
@@ -195,7 +195,7 @@ export class DefaultSudoKeyArchive implements SudoKeyArchive {
|
|
|
195
195
|
*
|
|
196
196
|
* @param excludedKeyTypes
|
|
197
197
|
* Set of key types to exclude from archive or restore operation.
|
|
198
|
-
* Default: {
|
|
198
|
+
* Default: {@link KeyArchiveKeyType.PublicKey}
|
|
199
199
|
*
|
|
200
200
|
* @param metaInfo
|
|
201
201
|
* Meta information to include with the key archive
|
|
@@ -5,6 +5,7 @@ import { PublicKey } from './publicKey'
|
|
|
5
5
|
export class SudoCryptoProviderDefaults {
|
|
6
6
|
public static readonly aesIVSize = 16
|
|
7
7
|
public static readonly aesKeySize = 256
|
|
8
|
+
public static readonly rsaKeySize = 2048
|
|
8
9
|
public static readonly pbkdfRounds = 10000
|
|
9
10
|
public static readonly pbkdfSaltSize = 16
|
|
10
11
|
}
|
|
@@ -90,6 +91,15 @@ export interface SudoCryptoProvider {
|
|
|
90
91
|
*
|
|
91
92
|
* @param name The name of the symmetric key.
|
|
92
93
|
*/
|
|
94
|
+
doesSymmetricKeyExist(name: string): Promise<boolean>
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Checks to see if the specified symmetric key exists.
|
|
98
|
+
*
|
|
99
|
+
* @param name The name of the symmetric key.
|
|
100
|
+
*
|
|
101
|
+
* @deprecated Use doesSymmetricKeyExist
|
|
102
|
+
*/
|
|
93
103
|
doesSymmetricKeyExists(name: string): Promise<boolean>
|
|
94
104
|
|
|
95
105
|
/**
|
|
@@ -137,6 +147,36 @@ export interface SudoCryptoProvider {
|
|
|
137
147
|
*/
|
|
138
148
|
deleteKeyPair(name: string): Promise<void>
|
|
139
149
|
|
|
150
|
+
/**
|
|
151
|
+
* Generates a signature for the given data with the specified private key.
|
|
152
|
+
*
|
|
153
|
+
* @param name The name of the private key to use for generation.
|
|
154
|
+
* @param data The data to sign.
|
|
155
|
+
*
|
|
156
|
+
* @returns Data signature
|
|
157
|
+
*
|
|
158
|
+
* @throws {@link KeyNotFoundError}
|
|
159
|
+
*/
|
|
160
|
+
generateSignatureWithPrivateKey(
|
|
161
|
+
name: string,
|
|
162
|
+
data: ArrayBuffer,
|
|
163
|
+
): Promise<ArrayBuffer>
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Verifies the given data against the provided signature using the specified public key.
|
|
167
|
+
*
|
|
168
|
+
* @param name The name of the public key to use for validation.
|
|
169
|
+
* @param data The data to verify
|
|
170
|
+
* @param signature The signature to verify against
|
|
171
|
+
*
|
|
172
|
+
* @returns True if the data and signature could be successfully verified
|
|
173
|
+
*/
|
|
174
|
+
verifySignatureWithPublicKey(
|
|
175
|
+
name: string,
|
|
176
|
+
data: ArrayBuffer,
|
|
177
|
+
signature: ArrayBuffer,
|
|
178
|
+
): Promise<boolean>
|
|
179
|
+
|
|
140
180
|
/**
|
|
141
181
|
* Adds a private key to the secure store.
|
|
142
182
|
*
|
|
@@ -159,6 +199,15 @@ export interface SudoCryptoProvider {
|
|
|
159
199
|
*
|
|
160
200
|
* @param name The name of the private key.
|
|
161
201
|
*/
|
|
202
|
+
doesPrivateKeyExist(name: string): Promise<boolean>
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Checks to see if the specified private key exists.
|
|
206
|
+
*
|
|
207
|
+
* @param name The name of the private key.
|
|
208
|
+
*
|
|
209
|
+
* @deprecated Use doesPrivateKeyExist
|
|
210
|
+
*/
|
|
162
211
|
doesPrivateKeyExists(name: string): Promise<boolean>
|
|
163
212
|
|
|
164
213
|
/**
|
|
@@ -169,6 +218,13 @@ export interface SudoCryptoProvider {
|
|
|
169
218
|
*/
|
|
170
219
|
addPublicKey(key: ArrayBuffer, name: string): Promise<void>
|
|
171
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Deletes the specified public key from the secure store.
|
|
223
|
+
*
|
|
224
|
+
* @param name The name of the public key to be removed.
|
|
225
|
+
*/
|
|
226
|
+
deletePublicKey(name: string): Promise<void>
|
|
227
|
+
|
|
172
228
|
/**
|
|
173
229
|
* Retrieves the public key from the secure store.
|
|
174
230
|
*
|
|
@@ -210,6 +266,7 @@ export interface SudoCryptoProvider {
|
|
|
210
266
|
* @returns Encrypted data and IV
|
|
211
267
|
*
|
|
212
268
|
* @throws {@link UnrecognizedAlgorithmError}
|
|
269
|
+
* @throws {@link KeyNotFoundError}
|
|
213
270
|
*/
|
|
214
271
|
encryptWithSymmetricKeyName(
|
|
215
272
|
name: string,
|
|
@@ -243,6 +300,7 @@ export interface SudoCryptoProvider {
|
|
|
243
300
|
* @returns Decrypted data
|
|
244
301
|
*
|
|
245
302
|
* @throws {@link UnrecognizedAlgorithmError}
|
|
303
|
+
* @throws {@link KeyNotFoundError}
|
|
246
304
|
*/
|
|
247
305
|
decryptWithSymmetricKeyName(
|
|
248
306
|
name: string,
|
|
@@ -325,6 +383,7 @@ export interface SudoCryptoProvider {
|
|
|
325
383
|
* @returns Encrypted data
|
|
326
384
|
*
|
|
327
385
|
* @throws {@link UnrecognizedAlgorithmError}
|
|
386
|
+
* @throws {@link KeyNotFoundError}
|
|
328
387
|
*/
|
|
329
388
|
encryptWithPublicKey(
|
|
330
389
|
name: string,
|
|
@@ -338,9 +397,10 @@ export interface SudoCryptoProvider {
|
|
|
338
397
|
* @param name The name of the private key to use for decryption.
|
|
339
398
|
* @param data The data to decrypt.
|
|
340
399
|
*
|
|
341
|
-
* @returns Decrypted data
|
|
400
|
+
* @returns Decrypted data.
|
|
342
401
|
*
|
|
343
402
|
* @throws {@link UnrecognizedAlgorithmError}
|
|
403
|
+
* @throws {@link KeyNotFoundError}
|
|
344
404
|
*/
|
|
345
405
|
decryptWithPrivateKey(
|
|
346
406
|
name: string,
|
|
@@ -68,6 +68,15 @@ export interface SudoKeyManager {
|
|
|
68
68
|
*
|
|
69
69
|
* @param name The name of the symmetric key.
|
|
70
70
|
*/
|
|
71
|
+
doesSymmetricKeyExist(name: string): Promise<boolean>
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Checks to see if the specified symmetric key exists.
|
|
75
|
+
*
|
|
76
|
+
* @param name The name of the symmetric key.
|
|
77
|
+
*
|
|
78
|
+
* @deprecated Use doesSymmetricKeyExist
|
|
79
|
+
*/
|
|
71
80
|
doesSymmetricKeyExists(name: string): Promise<boolean>
|
|
72
81
|
|
|
73
82
|
/**
|
|
@@ -99,6 +108,15 @@ export interface SudoKeyManager {
|
|
|
99
108
|
*
|
|
100
109
|
* @param name The name of the private key.
|
|
101
110
|
*/
|
|
111
|
+
doesPrivateKeyExist(name: string): Promise<boolean>
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Checks to see if the specified private key exists.
|
|
115
|
+
*
|
|
116
|
+
* @param name The name of the private key.
|
|
117
|
+
*
|
|
118
|
+
* @deprecated Use doesPrivateKeyExist
|
|
119
|
+
*/
|
|
102
120
|
doesPrivateKeyExists(name: string): Promise<boolean>
|
|
103
121
|
|
|
104
122
|
/**
|
|
@@ -111,6 +129,13 @@ export interface SudoKeyManager {
|
|
|
111
129
|
*/
|
|
112
130
|
addPublicKey(key: ArrayBuffer, name: string): Promise<void>
|
|
113
131
|
|
|
132
|
+
/**
|
|
133
|
+
* Deletes the specified public key from the secure store.
|
|
134
|
+
*
|
|
135
|
+
* @param name The name of the public key to be removed.
|
|
136
|
+
*/
|
|
137
|
+
deletePublicKey(name: string): Promise<void>
|
|
138
|
+
|
|
114
139
|
/**
|
|
115
140
|
* Retrieves the public key from the secure store.
|
|
116
141
|
*
|
|
@@ -129,6 +154,34 @@ export interface SudoKeyManager {
|
|
|
129
154
|
*/
|
|
130
155
|
deleteKeyPair(name: string): Promise<void>
|
|
131
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Generates a signature for the given data with the specified private key.
|
|
159
|
+
*
|
|
160
|
+
* @param name The name of the private key to use for generation.
|
|
161
|
+
* @param data The data to sign.
|
|
162
|
+
*
|
|
163
|
+
* @returns Data signature or undefined if the private key is not found.
|
|
164
|
+
*/
|
|
165
|
+
generateSignatureWithPrivateKey(
|
|
166
|
+
name: string,
|
|
167
|
+
data: ArrayBuffer,
|
|
168
|
+
): Promise<ArrayBuffer>
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Verifies the given data against the provided signature using the specified public key.
|
|
172
|
+
*
|
|
173
|
+
* @param name The name of the public key to use for validation.
|
|
174
|
+
* @param data The data to verify
|
|
175
|
+
* @param signature The signature to verify against
|
|
176
|
+
*
|
|
177
|
+
* @returns True if the data and signature could be successfully verified
|
|
178
|
+
*/
|
|
179
|
+
verifySignatureWithPublicKey(
|
|
180
|
+
name: string,
|
|
181
|
+
data: ArrayBuffer,
|
|
182
|
+
signature: ArrayBuffer,
|
|
183
|
+
): Promise<boolean>
|
|
184
|
+
|
|
132
185
|
/**
|
|
133
186
|
* @deprecated Use version with `options` param.
|
|
134
187
|
*
|
|
@@ -393,6 +446,10 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
393
446
|
return this.sudoCryptoProvider.getSymmetricKey(name)
|
|
394
447
|
}
|
|
395
448
|
|
|
449
|
+
public doesSymmetricKeyExist(name: string): Promise<boolean> {
|
|
450
|
+
return this.sudoCryptoProvider.doesSymmetricKeyExists(name)
|
|
451
|
+
}
|
|
452
|
+
|
|
396
453
|
public doesSymmetricKeyExists(name: string): Promise<boolean> {
|
|
397
454
|
return this.sudoCryptoProvider.doesSymmetricKeyExists(name)
|
|
398
455
|
}
|
|
@@ -413,6 +470,10 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
413
470
|
return this.sudoCryptoProvider.getPrivateKey(name)
|
|
414
471
|
}
|
|
415
472
|
|
|
473
|
+
public doesPrivateKeyExist(name: string): Promise<boolean> {
|
|
474
|
+
return this.sudoCryptoProvider.doesPrivateKeyExists(name)
|
|
475
|
+
}
|
|
476
|
+
|
|
416
477
|
public doesPrivateKeyExists(name: string): Promise<boolean> {
|
|
417
478
|
return this.sudoCryptoProvider.doesPrivateKeyExists(name)
|
|
418
479
|
}
|
|
@@ -421,6 +482,10 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
421
482
|
return this.sudoCryptoProvider.addPublicKey(key, name)
|
|
422
483
|
}
|
|
423
484
|
|
|
485
|
+
public deletePublicKey(name: string): Promise<void> {
|
|
486
|
+
return this.sudoCryptoProvider.deletePublicKey(name)
|
|
487
|
+
}
|
|
488
|
+
|
|
424
489
|
public getPublicKey(name: string): Promise<PublicKey | undefined> {
|
|
425
490
|
return this.sudoCryptoProvider.getPublicKey(name)
|
|
426
491
|
}
|
|
@@ -429,6 +494,25 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
429
494
|
return this.sudoCryptoProvider.deleteKeyPair(name)
|
|
430
495
|
}
|
|
431
496
|
|
|
497
|
+
public generateSignatureWithPrivateKey(
|
|
498
|
+
name: string,
|
|
499
|
+
data: ArrayBuffer,
|
|
500
|
+
): Promise<ArrayBuffer> {
|
|
501
|
+
return this.sudoCryptoProvider.generateSignatureWithPrivateKey(name, data)
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
verifySignatureWithPublicKey(
|
|
505
|
+
name: string,
|
|
506
|
+
data: ArrayBuffer,
|
|
507
|
+
signature: ArrayBuffer,
|
|
508
|
+
): Promise<boolean> {
|
|
509
|
+
return this.sudoCryptoProvider.verifySignatureWithPublicKey(
|
|
510
|
+
name,
|
|
511
|
+
data,
|
|
512
|
+
signature,
|
|
513
|
+
)
|
|
514
|
+
}
|
|
515
|
+
|
|
432
516
|
public encryptWithSymmetricKey(
|
|
433
517
|
key: ArrayBuffer,
|
|
434
518
|
data: ArrayBuffer,
|
|
@@ -177,6 +177,25 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
177
177
|
})
|
|
178
178
|
})
|
|
179
179
|
|
|
180
|
+
describe('doesSymmetricKeyExist', () => {
|
|
181
|
+
it('should call crypto provider doesSymmetricKeyExists', async () => {
|
|
182
|
+
when(
|
|
183
|
+
sudoCryptoProviderMock.doesSymmetricKeyExists(anything()),
|
|
184
|
+
).thenResolve(true)
|
|
185
|
+
|
|
186
|
+
await expect(
|
|
187
|
+
sudoKeyManager.doesSymmetricKeyExist('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
|
+
verify(sudoCryptoProviderMock.doesSymmetricKeyExist(anything())).never()
|
|
196
|
+
})
|
|
197
|
+
})
|
|
198
|
+
|
|
180
199
|
describe('doesSymmetricKeyExists', () => {
|
|
181
200
|
it('should call crypto provider doesSymmetricKeyExists', async () => {
|
|
182
201
|
when(
|
|
@@ -192,6 +211,7 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
192
211
|
expect(actualKey).toStrictEqual('VpnKey')
|
|
193
212
|
|
|
194
213
|
verify(sudoCryptoProviderMock.doesSymmetricKeyExists(anything())).once()
|
|
214
|
+
verify(sudoCryptoProviderMock.doesSymmetricKeyExist(anything())).never()
|
|
195
215
|
})
|
|
196
216
|
})
|
|
197
217
|
|
|
@@ -281,6 +301,26 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
281
301
|
})
|
|
282
302
|
})
|
|
283
303
|
|
|
304
|
+
describe('doesPrivateKeyExist', () => {
|
|
305
|
+
it('should call crypto provider doesPrivateKeyExists', async () => {
|
|
306
|
+
when(sudoCryptoProviderMock.doesPrivateKeyExists(anything())).thenResolve(
|
|
307
|
+
true,
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
await expect(
|
|
311
|
+
sudoKeyManager.doesPrivateKeyExist('VpnKeyPair'),
|
|
312
|
+
).resolves.toBeTruthy()
|
|
313
|
+
|
|
314
|
+
const [actualKeyName] = capture(
|
|
315
|
+
sudoCryptoProviderMock.doesPrivateKeyExists,
|
|
316
|
+
).first()
|
|
317
|
+
expect(actualKeyName).toStrictEqual('VpnKeyPair')
|
|
318
|
+
|
|
319
|
+
verify(sudoCryptoProviderMock.doesPrivateKeyExists(anything())).once()
|
|
320
|
+
verify(sudoCryptoProviderMock.doesPrivateKeyExist(anything())).never()
|
|
321
|
+
})
|
|
322
|
+
})
|
|
323
|
+
|
|
284
324
|
describe('doesPrivateKeyExists', () => {
|
|
285
325
|
it('should call crypto provider doesPrivateKeyExists', async () => {
|
|
286
326
|
when(sudoCryptoProviderMock.doesPrivateKeyExists(anything())).thenResolve(
|
|
@@ -297,6 +337,7 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
297
337
|
expect(actualKeyName).toStrictEqual('VpnKeyPair')
|
|
298
338
|
|
|
299
339
|
verify(sudoCryptoProviderMock.doesPrivateKeyExists(anything())).once()
|
|
340
|
+
verify(sudoCryptoProviderMock.doesPrivateKeyExist(anything())).never()
|
|
300
341
|
})
|
|
301
342
|
})
|
|
302
343
|
|