@sudoplatform/sudo-common 5.10.1 → 6.1.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/bin/outdated-with-suppression.sh +97 -0
- package/bin/suppress-outdated.sh +33 -0
- package/docs/assets/search.js +1 -1
- package/docs/classes/DefaultSudoKeyManager.html +31 -27
- package/docs/interfaces/SudoCryptoProvider.html +33 -25
- package/docs/interfaces/SudoKeyManager.html +33 -25
- package/github/bin/outdated-with-suppression.sh +97 -0
- package/github/bin/suppress-outdated.sh +33 -0
- package/github/docs/assets/search.js +1 -1
- package/github/docs/classes/DefaultSudoKeyManager.html +31 -27
- package/github/docs/interfaces/SudoCryptoProvider.html +33 -25
- package/github/docs/interfaces/SudoKeyManager.html +33 -25
- package/github/package.json +5 -2
- package/github/src/sudoKeyManager/sudoCryptoProvider.ts +14 -0
- package/github/src/sudoKeyManager/sudoKeyManager.ts +22 -0
- package/github/test/sudoKeyManager/sudoKeyManager.spec.ts +37 -0
- package/lib/errors/error.js +14 -16
- package/lib/sudoKeyManager/sudoCryptoProvider.d.ts +12 -0
- package/lib/sudoKeyManager/sudoKeyManager.d.ts +14 -0
- package/lib/sudoKeyManager/sudoKeyManager.js +8 -0
- package/package.json +5 -2
- package/src/sudoKeyManager/sudoCryptoProvider.ts +14 -0
- package/src/sudoKeyManager/sudoKeyManager.ts +22 -0
- package/test/sudoKeyManager/sudoKeyManager.spec.ts +37 -0
|
@@ -63,6 +63,13 @@ export interface SudoKeyManager {
|
|
|
63
63
|
*/
|
|
64
64
|
getSymmetricKey(name: string): Promise<ArrayBuffer | undefined>
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Checks to see if the specified symmetric key exists.
|
|
68
|
+
*
|
|
69
|
+
* @param name The name of the symmetric key.
|
|
70
|
+
*/
|
|
71
|
+
doesSymmetricKeyExists(name: string): Promise<boolean>
|
|
72
|
+
|
|
66
73
|
/**
|
|
67
74
|
* Deletes a symmetric key from the secure store.
|
|
68
75
|
*
|
|
@@ -87,6 +94,13 @@ export interface SudoKeyManager {
|
|
|
87
94
|
*/
|
|
88
95
|
getPrivateKey(name: string): Promise<ArrayBuffer | undefined>
|
|
89
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Checks to see if the specified private key exists.
|
|
99
|
+
*
|
|
100
|
+
* @param name The name of the private key.
|
|
101
|
+
*/
|
|
102
|
+
doesPrivateKeyExists(name: string): Promise<boolean>
|
|
103
|
+
|
|
90
104
|
/**
|
|
91
105
|
* Adds a public key to the secure store.
|
|
92
106
|
*
|
|
@@ -379,6 +393,10 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
379
393
|
return this.sudoCryptoProvider.getSymmetricKey(name)
|
|
380
394
|
}
|
|
381
395
|
|
|
396
|
+
public doesSymmetricKeyExists(name: string): Promise<boolean> {
|
|
397
|
+
return this.sudoCryptoProvider.doesSymmetricKeyExists(name)
|
|
398
|
+
}
|
|
399
|
+
|
|
382
400
|
public deleteSymmetricKey(name: string): Promise<void> {
|
|
383
401
|
return this.sudoCryptoProvider.deleteSymmetricKey(name)
|
|
384
402
|
}
|
|
@@ -395,6 +413,10 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
395
413
|
return this.sudoCryptoProvider.getPrivateKey(name)
|
|
396
414
|
}
|
|
397
415
|
|
|
416
|
+
public doesPrivateKeyExists(name: string): Promise<boolean> {
|
|
417
|
+
return this.sudoCryptoProvider.doesPrivateKeyExists(name)
|
|
418
|
+
}
|
|
419
|
+
|
|
398
420
|
public addPublicKey(key: ArrayBuffer, name: string): Promise<void> {
|
|
399
421
|
return this.sudoCryptoProvider.addPublicKey(key, name)
|
|
400
422
|
}
|
|
@@ -177,6 +177,24 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
177
177
|
})
|
|
178
178
|
})
|
|
179
179
|
|
|
180
|
+
describe('doesSymmetricKeyExists', () => {
|
|
181
|
+
it('should call crypto provider doesSymmetricKeyExists', async () => {
|
|
182
|
+
when(
|
|
183
|
+
sudoCryptoProviderMock.doesSymmetricKeyExists(anything()),
|
|
184
|
+
).thenResolve(true)
|
|
185
|
+
|
|
186
|
+
await expect(
|
|
187
|
+
sudoKeyManager.doesSymmetricKeyExists('VpnKey'),
|
|
188
|
+
).resolves.toEqual(true)
|
|
189
|
+
const [actualKey] = capture(
|
|
190
|
+
sudoCryptoProviderMock.doesSymmetricKeyExists,
|
|
191
|
+
).first()
|
|
192
|
+
expect(actualKey).toStrictEqual('VpnKey')
|
|
193
|
+
|
|
194
|
+
verify(sudoCryptoProviderMock.doesSymmetricKeyExists(anything())).once()
|
|
195
|
+
})
|
|
196
|
+
})
|
|
197
|
+
|
|
180
198
|
describe('deleteSymmetricKey', () => {
|
|
181
199
|
it('should call crypto provider deleteSymmetricKey', async () => {
|
|
182
200
|
when(sudoCryptoProviderMock.deleteSymmetricKey(anything())).thenResolve()
|
|
@@ -263,6 +281,25 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
263
281
|
})
|
|
264
282
|
})
|
|
265
283
|
|
|
284
|
+
describe('doesPrivateKeyExists', () => {
|
|
285
|
+
it('should call crypto provider doesPrivateKeyExists', async () => {
|
|
286
|
+
when(sudoCryptoProviderMock.doesPrivateKeyExists(anything())).thenResolve(
|
|
287
|
+
true,
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
await expect(
|
|
291
|
+
sudoKeyManager.doesPrivateKeyExists('VpnKeyPair'),
|
|
292
|
+
).resolves.toBeTruthy()
|
|
293
|
+
|
|
294
|
+
const [actualKeyName] = capture(
|
|
295
|
+
sudoCryptoProviderMock.doesPrivateKeyExists,
|
|
296
|
+
).first()
|
|
297
|
+
expect(actualKeyName).toStrictEqual('VpnKeyPair')
|
|
298
|
+
|
|
299
|
+
verify(sudoCryptoProviderMock.doesPrivateKeyExists(anything())).once()
|
|
300
|
+
})
|
|
301
|
+
})
|
|
302
|
+
|
|
266
303
|
describe('addPublicKey', () => {
|
|
267
304
|
it('should call crypto provider addPublicKey', async () => {
|
|
268
305
|
when(
|
package/lib/errors/error.js
CHANGED
|
@@ -141,7 +141,7 @@ exports.RegisterError = RegisterError;
|
|
|
141
141
|
|
|
142
142
|
class NotRegisteredError extends Error {
|
|
143
143
|
constructor(message) {
|
|
144
|
-
super(message
|
|
144
|
+
super(message ?? 'User is not registered.');
|
|
145
145
|
this.name = 'NotRegisteredError';
|
|
146
146
|
}
|
|
147
147
|
|
|
@@ -156,7 +156,7 @@ exports.NotRegisteredError = NotRegisteredError;
|
|
|
156
156
|
|
|
157
157
|
class NotAuthorizedError extends Error {
|
|
158
158
|
constructor(message) {
|
|
159
|
-
super(message
|
|
159
|
+
super(message ?? 'User is not authorized perform the requested operation.');
|
|
160
160
|
this.name = 'NotAuthorizedError';
|
|
161
161
|
}
|
|
162
162
|
|
|
@@ -276,7 +276,7 @@ exports.ServiceError = ServiceError;
|
|
|
276
276
|
|
|
277
277
|
class IllegalArgumentError extends Error {
|
|
278
278
|
constructor(message) {
|
|
279
|
-
super(message
|
|
279
|
+
super(message ?? 'Invalid arguments were specified');
|
|
280
280
|
this.name = 'IllegalArgumentError';
|
|
281
281
|
}
|
|
282
282
|
|
|
@@ -328,9 +328,7 @@ class RequestFailedError extends Error {
|
|
|
328
328
|
* status code.
|
|
329
329
|
*/
|
|
330
330
|
constructor(cause, statusCode) {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
super(`API request failed. cause: ${(_cause$message = cause === null || cause === void 0 ? void 0 : cause.message) !== null && _cause$message !== void 0 ? _cause$message : '<none>'}, statusCode: ${statusCode !== null && statusCode !== void 0 ? statusCode : '<none>'}`);
|
|
331
|
+
super(`API request failed. cause: ${(cause === null || cause === void 0 ? void 0 : cause.message) ?? '<none>'}, statusCode: ${statusCode ?? '<none>'}`);
|
|
334
332
|
|
|
335
333
|
_defineProperty(this, "cause", void 0);
|
|
336
334
|
|
|
@@ -394,7 +392,7 @@ exports.InvalidTokenError = InvalidTokenError;
|
|
|
394
392
|
|
|
395
393
|
class KeyNotFoundError extends Error {
|
|
396
394
|
constructor(message) {
|
|
397
|
-
super(message
|
|
395
|
+
super(message ?? 'Key not found.');
|
|
398
396
|
this.name = 'KeyNotFoundError';
|
|
399
397
|
}
|
|
400
398
|
|
|
@@ -408,7 +406,7 @@ exports.KeyNotFoundError = KeyNotFoundError;
|
|
|
408
406
|
|
|
409
407
|
class KeyStoreNotExportableError extends Error {
|
|
410
408
|
constructor(message) {
|
|
411
|
-
super(message
|
|
409
|
+
super(message ?? 'Key store not exportable.');
|
|
412
410
|
this.name = 'KeyStoreNotExportableError';
|
|
413
411
|
}
|
|
414
412
|
|
|
@@ -422,7 +420,7 @@ exports.KeyStoreNotExportableError = KeyStoreNotExportableError;
|
|
|
422
420
|
|
|
423
421
|
class KeyArchiveMissingError extends Error {
|
|
424
422
|
constructor(message) {
|
|
425
|
-
super(message
|
|
423
|
+
super(message ?? 'No key archive provided prior to unarchiving');
|
|
426
424
|
this.name = 'KeyArchiveMissingError';
|
|
427
425
|
}
|
|
428
426
|
|
|
@@ -436,7 +434,7 @@ exports.KeyArchiveMissingError = KeyArchiveMissingError;
|
|
|
436
434
|
|
|
437
435
|
class KeyArchivePasswordRequiredError extends Error {
|
|
438
436
|
constructor(message) {
|
|
439
|
-
super(message
|
|
437
|
+
super(message ?? 'No password provided to unarchive secure archive');
|
|
440
438
|
this.name = 'KeyArchivePasswordRequiredError';
|
|
441
439
|
}
|
|
442
440
|
|
|
@@ -450,7 +448,7 @@ exports.KeyArchivePasswordRequiredError = KeyArchivePasswordRequiredError;
|
|
|
450
448
|
|
|
451
449
|
class KeyArchiveNoPasswordRequiredError extends Error {
|
|
452
450
|
constructor(message) {
|
|
453
|
-
super(message
|
|
451
|
+
super(message ?? 'No password required to unarchive insecure archive');
|
|
454
452
|
this.name = 'KeyArchiveNoPasswordRequiredError';
|
|
455
453
|
}
|
|
456
454
|
|
|
@@ -464,7 +462,7 @@ exports.KeyArchiveNoPasswordRequiredError = KeyArchiveNoPasswordRequiredError;
|
|
|
464
462
|
|
|
465
463
|
class KeyArchiveDecodingError extends Error {
|
|
466
464
|
constructor(message) {
|
|
467
|
-
super(message
|
|
465
|
+
super(message ?? 'Key archive data could not be decoded as expected');
|
|
468
466
|
this.name = 'KeyArchiveDecodingError';
|
|
469
467
|
}
|
|
470
468
|
|
|
@@ -478,7 +476,7 @@ exports.KeyArchiveDecodingError = KeyArchiveDecodingError;
|
|
|
478
476
|
|
|
479
477
|
class KeyArchiveIncorrectPasswordError extends Error {
|
|
480
478
|
constructor(message) {
|
|
481
|
-
super(message
|
|
479
|
+
super(message ?? 'Key archive was unable to be decrypted using the provided password');
|
|
482
480
|
this.name = 'KeyArchiveIncorrectPasswordError';
|
|
483
481
|
}
|
|
484
482
|
|
|
@@ -520,7 +518,7 @@ exports.KeyArchiveVersionError = KeyArchiveVersionError;
|
|
|
520
518
|
|
|
521
519
|
class KeyArchiveUnknownKeyTypeError extends Error {
|
|
522
520
|
constructor(message) {
|
|
523
|
-
super(message
|
|
521
|
+
super(message ?? 'Key type is not recognized');
|
|
524
522
|
this.name = 'KeyArchiveUnknownKeyTypeError';
|
|
525
523
|
}
|
|
526
524
|
|
|
@@ -534,7 +532,7 @@ exports.KeyArchiveUnknownKeyTypeError = KeyArchiveUnknownKeyTypeError;
|
|
|
534
532
|
|
|
535
533
|
class OperationNotImplementedError extends Error {
|
|
536
534
|
constructor(message) {
|
|
537
|
-
super(message
|
|
535
|
+
super(message ?? 'Operation is not implemented');
|
|
538
536
|
this.name = 'OperationNotImplementedError';
|
|
539
537
|
}
|
|
540
538
|
|
|
@@ -548,7 +546,7 @@ exports.OperationNotImplementedError = OperationNotImplementedError;
|
|
|
548
546
|
|
|
549
547
|
class UnrecognizedAlgorithmError extends Error {
|
|
550
548
|
constructor(message) {
|
|
551
|
-
super(message
|
|
549
|
+
super(message ?? 'Unrecognized encryption algorithm name.');
|
|
552
550
|
this.name = 'UnrecognizedAlgorithmError';
|
|
553
551
|
}
|
|
554
552
|
|
|
@@ -69,6 +69,12 @@ export interface SudoCryptoProvider {
|
|
|
69
69
|
* @returns The symmetric key or undefined if not found.
|
|
70
70
|
*/
|
|
71
71
|
getSymmetricKey(name: string): Promise<ArrayBuffer | undefined>;
|
|
72
|
+
/**
|
|
73
|
+
* Checks to see if the specified symmetric key exists.
|
|
74
|
+
*
|
|
75
|
+
* @param name The name of the symmetric key.
|
|
76
|
+
*/
|
|
77
|
+
doesSymmetricKeyExists(name: string): Promise<boolean>;
|
|
72
78
|
/**
|
|
73
79
|
* Deletes a symmetric key from the secure store.
|
|
74
80
|
*
|
|
@@ -122,6 +128,12 @@ export interface SudoCryptoProvider {
|
|
|
122
128
|
* @returns Requested private key or undefined if the key was not found.
|
|
123
129
|
*/
|
|
124
130
|
getPrivateKey(name: string): Promise<ArrayBuffer | undefined>;
|
|
131
|
+
/**
|
|
132
|
+
* Checks to see if the specified private key exists.
|
|
133
|
+
*
|
|
134
|
+
* @param name The name of the private key.
|
|
135
|
+
*/
|
|
136
|
+
doesPrivateKeyExists(name: string): Promise<boolean>;
|
|
125
137
|
/**
|
|
126
138
|
* Adds a public key to the secure store.
|
|
127
139
|
*
|
|
@@ -51,6 +51,12 @@ export interface SudoKeyManager {
|
|
|
51
51
|
* @returns The symmetric key or undefined if not found.
|
|
52
52
|
*/
|
|
53
53
|
getSymmetricKey(name: string): Promise<ArrayBuffer | undefined>;
|
|
54
|
+
/**
|
|
55
|
+
* Checks to see if the specified symmetric key exists.
|
|
56
|
+
*
|
|
57
|
+
* @param name The name of the symmetric key.
|
|
58
|
+
*/
|
|
59
|
+
doesSymmetricKeyExists(name: string): Promise<boolean>;
|
|
54
60
|
/**
|
|
55
61
|
* Deletes a symmetric key from the secure store.
|
|
56
62
|
*
|
|
@@ -72,6 +78,12 @@ export interface SudoKeyManager {
|
|
|
72
78
|
* @returns Requested private key or undefined if the key was not found.
|
|
73
79
|
*/
|
|
74
80
|
getPrivateKey(name: string): Promise<ArrayBuffer | undefined>;
|
|
81
|
+
/**
|
|
82
|
+
* Checks to see if the specified private key exists.
|
|
83
|
+
*
|
|
84
|
+
* @param name The name of the private key.
|
|
85
|
+
*/
|
|
86
|
+
doesPrivateKeyExists(name: string): Promise<boolean>;
|
|
75
87
|
/**
|
|
76
88
|
* Adds a public key to the secure store.
|
|
77
89
|
*
|
|
@@ -278,10 +290,12 @@ export declare class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
278
290
|
updatePassword(password: ArrayBuffer, name: string): Promise<void>;
|
|
279
291
|
addSymmetricKey(key: ArrayBuffer, name: string): Promise<void>;
|
|
280
292
|
getSymmetricKey(name: string): Promise<ArrayBuffer | undefined>;
|
|
293
|
+
doesSymmetricKeyExists(name: string): Promise<boolean>;
|
|
281
294
|
deleteSymmetricKey(name: string): Promise<void>;
|
|
282
295
|
generateKeyPair(name: string): Promise<void>;
|
|
283
296
|
addPrivateKey(key: ArrayBuffer, name: string): Promise<void>;
|
|
284
297
|
getPrivateKey(name: string): Promise<ArrayBuffer | undefined>;
|
|
298
|
+
doesPrivateKeyExists(name: string): Promise<boolean>;
|
|
285
299
|
addPublicKey(key: ArrayBuffer, name: string): Promise<void>;
|
|
286
300
|
getPublicKey(name: string): Promise<PublicKey | undefined>;
|
|
287
301
|
deleteKeyPair(name: string): Promise<void>;
|
|
@@ -49,6 +49,10 @@ class DefaultSudoKeyManager {
|
|
|
49
49
|
return this.sudoCryptoProvider.getSymmetricKey(name);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
doesSymmetricKeyExists(name) {
|
|
53
|
+
return this.sudoCryptoProvider.doesSymmetricKeyExists(name);
|
|
54
|
+
}
|
|
55
|
+
|
|
52
56
|
deleteSymmetricKey(name) {
|
|
53
57
|
return this.sudoCryptoProvider.deleteSymmetricKey(name);
|
|
54
58
|
}
|
|
@@ -65,6 +69,10 @@ class DefaultSudoKeyManager {
|
|
|
65
69
|
return this.sudoCryptoProvider.getPrivateKey(name);
|
|
66
70
|
}
|
|
67
71
|
|
|
72
|
+
doesPrivateKeyExists(name) {
|
|
73
|
+
return this.sudoCryptoProvider.doesPrivateKeyExists(name);
|
|
74
|
+
}
|
|
75
|
+
|
|
68
76
|
addPublicKey(key, name) {
|
|
69
77
|
return this.sudoCryptoProvider.addPublicKey(key, name);
|
|
70
78
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sudoplatform/sudo-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"author": "Anonyome Labs, Inc.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"license": "Apache-2.0",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"audit-with-suppressions": "bin/yarn-audit-with-suppression.sh",
|
|
12
|
+
"outdated-with-suppressions": "bin/outdated-with-suppression.sh",
|
|
12
13
|
"clean": "rimraf ./lib ./test-lib",
|
|
13
14
|
"lint": "yarn lint:eslint && yarn lint:prettier",
|
|
14
15
|
"lint:eslint": "eslint \"{bin,integration-tests,src,test}/**/*.{ts,tsx}\"",
|
|
@@ -24,7 +25,9 @@
|
|
|
24
25
|
"types": "./lib/index.d.ts",
|
|
25
26
|
"bin": {
|
|
26
27
|
"audit-with-suppressions": "bin/yarn-audit-with-suppression.sh",
|
|
27
|
-
"suppress-audit": "bin/suppress-audit.sh"
|
|
28
|
+
"suppress-audit": "bin/suppress-audit.sh",
|
|
29
|
+
"outdated-with-suppressions": "bin/outdated-with-suppression.sh",
|
|
30
|
+
"suppress-outdated": "bin/suppress-outdated.sh"
|
|
28
31
|
},
|
|
29
32
|
"files": [
|
|
30
33
|
"lib",
|
|
@@ -85,6 +85,13 @@ export interface SudoCryptoProvider {
|
|
|
85
85
|
*/
|
|
86
86
|
getSymmetricKey(name: string): Promise<ArrayBuffer | undefined>
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Checks to see if the specified symmetric key exists.
|
|
90
|
+
*
|
|
91
|
+
* @param name The name of the symmetric key.
|
|
92
|
+
*/
|
|
93
|
+
doesSymmetricKeyExists(name: string): Promise<boolean>
|
|
94
|
+
|
|
88
95
|
/**
|
|
89
96
|
* Deletes a symmetric key from the secure store.
|
|
90
97
|
*
|
|
@@ -147,6 +154,13 @@ export interface SudoCryptoProvider {
|
|
|
147
154
|
*/
|
|
148
155
|
getPrivateKey(name: string): Promise<ArrayBuffer | undefined>
|
|
149
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Checks to see if the specified private key exists.
|
|
159
|
+
*
|
|
160
|
+
* @param name The name of the private key.
|
|
161
|
+
*/
|
|
162
|
+
doesPrivateKeyExists(name: string): Promise<boolean>
|
|
163
|
+
|
|
150
164
|
/**
|
|
151
165
|
* Adds a public key to the secure store.
|
|
152
166
|
*
|
|
@@ -63,6 +63,13 @@ export interface SudoKeyManager {
|
|
|
63
63
|
*/
|
|
64
64
|
getSymmetricKey(name: string): Promise<ArrayBuffer | undefined>
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Checks to see if the specified symmetric key exists.
|
|
68
|
+
*
|
|
69
|
+
* @param name The name of the symmetric key.
|
|
70
|
+
*/
|
|
71
|
+
doesSymmetricKeyExists(name: string): Promise<boolean>
|
|
72
|
+
|
|
66
73
|
/**
|
|
67
74
|
* Deletes a symmetric key from the secure store.
|
|
68
75
|
*
|
|
@@ -87,6 +94,13 @@ export interface SudoKeyManager {
|
|
|
87
94
|
*/
|
|
88
95
|
getPrivateKey(name: string): Promise<ArrayBuffer | undefined>
|
|
89
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Checks to see if the specified private key exists.
|
|
99
|
+
*
|
|
100
|
+
* @param name The name of the private key.
|
|
101
|
+
*/
|
|
102
|
+
doesPrivateKeyExists(name: string): Promise<boolean>
|
|
103
|
+
|
|
90
104
|
/**
|
|
91
105
|
* Adds a public key to the secure store.
|
|
92
106
|
*
|
|
@@ -379,6 +393,10 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
379
393
|
return this.sudoCryptoProvider.getSymmetricKey(name)
|
|
380
394
|
}
|
|
381
395
|
|
|
396
|
+
public doesSymmetricKeyExists(name: string): Promise<boolean> {
|
|
397
|
+
return this.sudoCryptoProvider.doesSymmetricKeyExists(name)
|
|
398
|
+
}
|
|
399
|
+
|
|
382
400
|
public deleteSymmetricKey(name: string): Promise<void> {
|
|
383
401
|
return this.sudoCryptoProvider.deleteSymmetricKey(name)
|
|
384
402
|
}
|
|
@@ -395,6 +413,10 @@ export class DefaultSudoKeyManager implements SudoKeyManager {
|
|
|
395
413
|
return this.sudoCryptoProvider.getPrivateKey(name)
|
|
396
414
|
}
|
|
397
415
|
|
|
416
|
+
public doesPrivateKeyExists(name: string): Promise<boolean> {
|
|
417
|
+
return this.sudoCryptoProvider.doesPrivateKeyExists(name)
|
|
418
|
+
}
|
|
419
|
+
|
|
398
420
|
public addPublicKey(key: ArrayBuffer, name: string): Promise<void> {
|
|
399
421
|
return this.sudoCryptoProvider.addPublicKey(key, name)
|
|
400
422
|
}
|
|
@@ -177,6 +177,24 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
177
177
|
})
|
|
178
178
|
})
|
|
179
179
|
|
|
180
|
+
describe('doesSymmetricKeyExists', () => {
|
|
181
|
+
it('should call crypto provider doesSymmetricKeyExists', async () => {
|
|
182
|
+
when(
|
|
183
|
+
sudoCryptoProviderMock.doesSymmetricKeyExists(anything()),
|
|
184
|
+
).thenResolve(true)
|
|
185
|
+
|
|
186
|
+
await expect(
|
|
187
|
+
sudoKeyManager.doesSymmetricKeyExists('VpnKey'),
|
|
188
|
+
).resolves.toEqual(true)
|
|
189
|
+
const [actualKey] = capture(
|
|
190
|
+
sudoCryptoProviderMock.doesSymmetricKeyExists,
|
|
191
|
+
).first()
|
|
192
|
+
expect(actualKey).toStrictEqual('VpnKey')
|
|
193
|
+
|
|
194
|
+
verify(sudoCryptoProviderMock.doesSymmetricKeyExists(anything())).once()
|
|
195
|
+
})
|
|
196
|
+
})
|
|
197
|
+
|
|
180
198
|
describe('deleteSymmetricKey', () => {
|
|
181
199
|
it('should call crypto provider deleteSymmetricKey', async () => {
|
|
182
200
|
when(sudoCryptoProviderMock.deleteSymmetricKey(anything())).thenResolve()
|
|
@@ -263,6 +281,25 @@ describe('DefaultSudoKeyManager', () => {
|
|
|
263
281
|
})
|
|
264
282
|
})
|
|
265
283
|
|
|
284
|
+
describe('doesPrivateKeyExists', () => {
|
|
285
|
+
it('should call crypto provider doesPrivateKeyExists', async () => {
|
|
286
|
+
when(sudoCryptoProviderMock.doesPrivateKeyExists(anything())).thenResolve(
|
|
287
|
+
true,
|
|
288
|
+
)
|
|
289
|
+
|
|
290
|
+
await expect(
|
|
291
|
+
sudoKeyManager.doesPrivateKeyExists('VpnKeyPair'),
|
|
292
|
+
).resolves.toBeTruthy()
|
|
293
|
+
|
|
294
|
+
const [actualKeyName] = capture(
|
|
295
|
+
sudoCryptoProviderMock.doesPrivateKeyExists,
|
|
296
|
+
).first()
|
|
297
|
+
expect(actualKeyName).toStrictEqual('VpnKeyPair')
|
|
298
|
+
|
|
299
|
+
verify(sudoCryptoProviderMock.doesPrivateKeyExists(anything())).once()
|
|
300
|
+
})
|
|
301
|
+
})
|
|
302
|
+
|
|
266
303
|
describe('addPublicKey', () => {
|
|
267
304
|
it('should call crypto provider addPublicKey', async () => {
|
|
268
305
|
when(
|