@sudoplatform/sudo-common 6.3.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +96 -20
- package/github/test/unit/sudoKeyManager.spec.ts +59 -18
- 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 +32 -4
- package/package.json +26 -18
- package/src/sudoKeyArchive/sudoKeyArchive.ts +1 -1
- package/src/sudoKeyManager/sudoCryptoProvider.ts +61 -1
- package/src/sudoKeyManager/sudoKeyManager.ts +96 -20
- package/test/unit/sudoKeyManager.spec.ts +59 -18
- 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
|
@@ -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,17 +494,34 @@ 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,
|
|
435
519
|
ivOrOptions?: ArrayBuffer | SymmetricEncryptionOptions,
|
|
436
520
|
): Promise<ArrayBuffer> {
|
|
437
521
|
if (BufferUtil.isArrayBuffer(ivOrOptions)) {
|
|
438
|
-
return this.sudoCryptoProvider.encryptWithSymmetricKey(
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
ivOrOptions,
|
|
442
|
-
)
|
|
522
|
+
return this.sudoCryptoProvider.encryptWithSymmetricKey(key, data, {
|
|
523
|
+
iv: ivOrOptions,
|
|
524
|
+
})
|
|
443
525
|
} else {
|
|
444
526
|
return this.sudoCryptoProvider.encryptWithSymmetricKey(
|
|
445
527
|
key,
|
|
@@ -455,11 +537,9 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
455
537
|
ivOrOptions?: ArrayBuffer | SymmetricEncryptionOptions,
|
|
456
538
|
): Promise<ArrayBuffer> {
|
|
457
539
|
if (BufferUtil.isArrayBuffer(ivOrOptions)) {
|
|
458
|
-
return this.sudoCryptoProvider.decryptWithSymmetricKey(
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
ivOrOptions,
|
|
462
|
-
)
|
|
540
|
+
return this.sudoCryptoProvider.decryptWithSymmetricKey(key, data, {
|
|
541
|
+
iv: ivOrOptions,
|
|
542
|
+
})
|
|
463
543
|
} else {
|
|
464
544
|
return this.sudoCryptoProvider.decryptWithSymmetricKey(
|
|
465
545
|
key,
|
|
@@ -475,11 +555,9 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
475
555
|
ivOrOptions?: ArrayBuffer | SymmetricEncryptionOptions,
|
|
476
556
|
): Promise<ArrayBuffer> {
|
|
477
557
|
if (BufferUtil.isArrayBuffer(ivOrOptions)) {
|
|
478
|
-
return this.sudoCryptoProvider.encryptWithSymmetricKeyName(
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
ivOrOptions,
|
|
482
|
-
)
|
|
558
|
+
return this.sudoCryptoProvider.encryptWithSymmetricKeyName(name, data, {
|
|
559
|
+
iv: ivOrOptions,
|
|
560
|
+
})
|
|
483
561
|
} else {
|
|
484
562
|
return this.sudoCryptoProvider.encryptWithSymmetricKeyName(
|
|
485
563
|
name,
|
|
@@ -495,11 +573,9 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
495
573
|
ivOrOptions?: ArrayBuffer | SymmetricEncryptionOptions,
|
|
496
574
|
): Promise<ArrayBuffer> {
|
|
497
575
|
if (BufferUtil.isArrayBuffer(ivOrOptions)) {
|
|
498
|
-
return this.sudoCryptoProvider.decryptWithSymmetricKeyName(
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
ivOrOptions,
|
|
502
|
-
)
|
|
576
|
+
return this.sudoCryptoProvider.decryptWithSymmetricKeyName(name, data, {
|
|
577
|
+
iv: ivOrOptions,
|
|
578
|
+
})
|
|
503
579
|
} else {
|
|
504
580
|
return this.sudoCryptoProvider.decryptWithSymmetricKeyName(
|
|
505
581
|
name,
|
|
@@ -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
|
|
|
@@ -393,8 +434,8 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
393
434
|
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
394
435
|
expect(actualData).toStrictEqual(decrypted)
|
|
395
436
|
expect(actualOptions).toBeDefined()
|
|
396
|
-
expect(actualOptions
|
|
397
|
-
expect(actualOptions
|
|
437
|
+
expect(actualOptions!.iv).toStrictEqual(iv)
|
|
438
|
+
expect(actualOptions!.algorithm).toBeUndefined()
|
|
398
439
|
|
|
399
440
|
verify(
|
|
400
441
|
sudoCryptoProviderMock.encryptWithSymmetricKeyName(
|
|
@@ -430,8 +471,8 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
430
471
|
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
431
472
|
expect(actualData).toStrictEqual(decrypted)
|
|
432
473
|
expect(actualOptions).toBeDefined()
|
|
433
|
-
expect(actualOptions
|
|
434
|
-
expect(actualOptions
|
|
474
|
+
expect(actualOptions!.iv).toStrictEqual(options.iv)
|
|
475
|
+
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
435
476
|
|
|
436
477
|
verify(
|
|
437
478
|
sudoCryptoProviderMock.encryptWithSymmetricKeyName(
|
|
@@ -492,8 +533,8 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
492
533
|
expect(actualKey).toStrictEqual(symmetricKey)
|
|
493
534
|
expect(actualData).toStrictEqual(encrypted)
|
|
494
535
|
expect(actualOptions).toBeDefined()
|
|
495
|
-
expect(actualOptions
|
|
496
|
-
expect(actualOptions
|
|
536
|
+
expect(actualOptions!.iv).toStrictEqual(iv)
|
|
537
|
+
expect(actualOptions!.algorithm).toBeUndefined()
|
|
497
538
|
|
|
498
539
|
verify(
|
|
499
540
|
sudoCryptoProviderMock.encryptWithSymmetricKey(
|
|
@@ -530,8 +571,8 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
530
571
|
expect(actualKey).toStrictEqual(symmetricKey)
|
|
531
572
|
expect(actualData).toStrictEqual(encrypted)
|
|
532
573
|
expect(actualOptions).toBeDefined()
|
|
533
|
-
expect(actualOptions
|
|
534
|
-
expect(actualOptions
|
|
574
|
+
expect(actualOptions!.iv).toBeUndefined()
|
|
575
|
+
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
535
576
|
|
|
536
577
|
verify(
|
|
537
578
|
sudoCryptoProviderMock.encryptWithSymmetricKey(
|
|
@@ -599,8 +640,8 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
599
640
|
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
600
641
|
expect(actualData).toStrictEqual(encrypted)
|
|
601
642
|
expect(actualOptions).toBeDefined()
|
|
602
|
-
expect(actualOptions
|
|
603
|
-
expect(actualOptions
|
|
643
|
+
expect(actualOptions!.iv).toStrictEqual(options.iv)
|
|
644
|
+
expect(actualOptions!.algorithm).toBeUndefined()
|
|
604
645
|
|
|
605
646
|
verify(
|
|
606
647
|
sudoCryptoProviderMock.decryptWithSymmetricKeyName(
|
|
@@ -638,8 +679,8 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
638
679
|
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
639
680
|
expect(actualData).toStrictEqual(encrypted)
|
|
640
681
|
expect(actualOptions).toBeDefined()
|
|
641
|
-
expect(actualOptions
|
|
642
|
-
expect(actualOptions
|
|
682
|
+
expect(actualOptions!.iv).toStrictEqual(options.iv)
|
|
683
|
+
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
643
684
|
|
|
644
685
|
verify(
|
|
645
686
|
sudoCryptoProviderMock.decryptWithSymmetricKeyName(
|
|
@@ -707,8 +748,8 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
707
748
|
expect(actualKey).toStrictEqual(symmetricKey)
|
|
708
749
|
expect(actualData).toStrictEqual(encrypted)
|
|
709
750
|
expect(actualOptions).toBeDefined()
|
|
710
|
-
expect(actualOptions
|
|
711
|
-
expect(actualOptions
|
|
751
|
+
expect(actualOptions!.iv).toStrictEqual(iv)
|
|
752
|
+
expect(actualOptions!.algorithm).toBeUndefined()
|
|
712
753
|
|
|
713
754
|
verify(
|
|
714
755
|
sudoCryptoProviderMock.decryptWithSymmetricKey(
|
|
@@ -746,8 +787,8 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
746
787
|
expect(actualKey).toStrictEqual(symmetricKey)
|
|
747
788
|
expect(actualData).toStrictEqual(encrypted)
|
|
748
789
|
expect(actualOptions).toBeDefined()
|
|
749
|
-
expect(actualOptions
|
|
750
|
-
expect(actualOptions
|
|
790
|
+
expect(actualOptions!.iv).toStrictEqual(iv)
|
|
791
|
+
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
751
792
|
|
|
752
793
|
verify(
|
|
753
794
|
sudoCryptoProviderMock.decryptWithSymmetricKey(
|
|
@@ -811,7 +852,7 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
811
852
|
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
812
853
|
expect(actualData).toStrictEqual(decrypted)
|
|
813
854
|
expect(actualOptions).toBeDefined()
|
|
814
|
-
expect(actualOptions
|
|
855
|
+
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
815
856
|
|
|
816
857
|
verify(
|
|
817
858
|
sudoCryptoProviderMock.encryptWithPublicKey(
|
|
@@ -875,7 +916,7 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
875
916
|
expect(actualKeyName).toStrictEqual('VpnKey')
|
|
876
917
|
expect(actualData).toStrictEqual(encrypted)
|
|
877
918
|
expect(actualOptions).toBeDefined()
|
|
878
|
-
expect(actualOptions
|
|
919
|
+
expect(actualOptions!.algorithm).toStrictEqual(options.algorithm)
|
|
879
920
|
|
|
880
921
|
verify(
|
|
881
922
|
sudoCryptoProviderMock.decryptWithPrivateKey(
|