@sudoplatform/sudo-common 5.9.0 → 6.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/.eslintrc.js +2 -4
- package/bin/outdated-with-suppression.sh +20 -0
- package/bin/suppress-outdated.sh +15 -0
- package/dependencies-report.json +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/AccountLockedError.html +4 -3
- package/docs/classes/AuthenticationError.html +4 -3
- package/docs/classes/Base64.html +2 -2
- package/docs/classes/Buffer.html +2 -2
- package/docs/classes/ConfigurationNotSetError.html +4 -3
- package/docs/classes/ConfigurationSetNotFoundError.html +4 -3
- package/docs/classes/DecodeError.html +4 -3
- package/docs/classes/DefaultConfigurationManager.html +6 -6
- package/docs/classes/DefaultLogger.html +13 -7
- package/docs/classes/DefaultSudoKeyArchive.html +13 -13
- package/docs/classes/DefaultSudoKeyManager.html +31 -27
- package/docs/classes/FatalError.html +4 -3
- package/docs/classes/IllegalArgumentError.html +4 -3
- package/docs/classes/IllegalStateError.html +4 -3
- package/docs/classes/InsufficientEntitlementsError.html +4 -3
- package/docs/classes/InvalidOwnershipProofError.html +4 -3
- package/docs/classes/InvalidTokenError.html +4 -3
- package/docs/classes/KeyArchiveDecodingError.html +4 -3
- package/docs/classes/KeyArchiveIncorrectPasswordError.html +4 -3
- package/docs/classes/KeyArchiveMissingError.html +4 -3
- package/docs/classes/KeyArchiveNoPasswordRequiredError.html +4 -3
- package/docs/classes/KeyArchivePasswordRequiredError.html +4 -3
- package/docs/classes/KeyArchiveTypeError.html +4 -3
- package/docs/classes/KeyArchiveUnknownKeyTypeError.html +4 -3
- package/docs/classes/KeyArchiveVersionError.html +4 -3
- package/docs/classes/KeyNotFoundError.html +4 -3
- package/docs/classes/KeyStoreNotExportableError.html +4 -3
- package/docs/classes/LimitExceededError.html +4 -3
- package/docs/classes/NoEntitlementsError.html +4 -3
- package/docs/classes/NotAuthorizedError.html +4 -3
- package/docs/classes/NotRegisteredError.html +4 -3
- package/docs/classes/NotSignedInError.html +4 -3
- package/docs/classes/OperationNotImplementedError.html +4 -3
- package/docs/classes/RegisterError.html +4 -3
- package/docs/classes/RequestFailedError.html +6 -5
- package/docs/classes/ServiceError.html +4 -3
- package/docs/classes/SignOutError.html +4 -3
- package/docs/classes/SudoCryptoProviderDefaults.html +1 -1
- package/docs/classes/UnknownGraphQLError.html +6 -4
- package/docs/classes/UnrecognizedAlgorithmError.html +4 -3
- package/docs/classes/UserNotConfirmedError.html +4 -3
- package/docs/classes/VersionMismatchError.html +4 -3
- package/docs/enums/CachePolicy.html +2 -2
- package/docs/enums/EncryptionAlgorithm.html +2 -2
- package/docs/enums/KeyArchiveKeyType.html +2 -2
- package/docs/enums/KeyDataKeyFormat.html +3 -3
- package/docs/enums/KeyDataKeyType.html +2 -2
- package/docs/enums/ListOperationResultStatus.html +4 -4
- package/docs/enums/PublicKeyFormat.html +1 -1
- package/docs/index.html +1 -1
- package/docs/interfaces/AsymmetricEncryptionOptions.html +2 -2
- package/docs/interfaces/BooleanFilter.html +2 -2
- package/docs/interfaces/ConfigurationManager.html +5 -5
- package/docs/interfaces/KeyData.html +2 -2
- package/docs/interfaces/ListOperationFailureResult.html +2 -2
- package/docs/interfaces/ListOperationPartialResult.html +4 -4
- package/docs/interfaces/ListOperationSuccessResult.html +3 -3
- package/docs/interfaces/ListOutput.html +2 -2
- package/docs/interfaces/Logger.html +13 -7
- package/docs/interfaces/Owner.html +1 -1
- package/docs/interfaces/PublicKey.html +1 -1
- package/docs/interfaces/StringFilter.html +2 -2
- package/docs/interfaces/SudoCryptoProvider.html +39 -31
- package/docs/interfaces/SudoKeyArchive.html +10 -10
- package/docs/interfaces/SudoKeyManager.html +39 -31
- package/docs/interfaces/SymmetricEncryptionOptions.html +2 -2
- package/docs/modules.html +4 -4
- package/github/.eslintrc.js +2 -4
- package/github/bin/outdated-with-suppression.sh +20 -0
- package/github/bin/suppress-outdated.sh +15 -0
- package/github/docs/assets/search.js +1 -1
- package/github/docs/classes/AccountLockedError.html +4 -3
- package/github/docs/classes/AuthenticationError.html +4 -3
- package/github/docs/classes/Base64.html +2 -2
- package/github/docs/classes/Buffer.html +2 -2
- package/github/docs/classes/ConfigurationNotSetError.html +4 -3
- package/github/docs/classes/ConfigurationSetNotFoundError.html +4 -3
- package/github/docs/classes/DecodeError.html +4 -3
- package/github/docs/classes/DefaultConfigurationManager.html +6 -6
- package/github/docs/classes/DefaultLogger.html +13 -7
- package/github/docs/classes/DefaultSudoKeyArchive.html +13 -13
- package/github/docs/classes/DefaultSudoKeyManager.html +31 -27
- package/github/docs/classes/FatalError.html +4 -3
- package/github/docs/classes/IllegalArgumentError.html +4 -3
- package/github/docs/classes/IllegalStateError.html +4 -3
- package/github/docs/classes/InsufficientEntitlementsError.html +4 -3
- package/github/docs/classes/InvalidOwnershipProofError.html +4 -3
- package/github/docs/classes/InvalidTokenError.html +4 -3
- package/github/docs/classes/KeyArchiveDecodingError.html +4 -3
- package/github/docs/classes/KeyArchiveIncorrectPasswordError.html +4 -3
- package/github/docs/classes/KeyArchiveMissingError.html +4 -3
- package/github/docs/classes/KeyArchiveNoPasswordRequiredError.html +4 -3
- package/github/docs/classes/KeyArchivePasswordRequiredError.html +4 -3
- package/github/docs/classes/KeyArchiveTypeError.html +4 -3
- package/github/docs/classes/KeyArchiveUnknownKeyTypeError.html +4 -3
- package/github/docs/classes/KeyArchiveVersionError.html +4 -3
- package/github/docs/classes/KeyNotFoundError.html +4 -3
- package/github/docs/classes/KeyStoreNotExportableError.html +4 -3
- package/github/docs/classes/LimitExceededError.html +4 -3
- package/github/docs/classes/NoEntitlementsError.html +4 -3
- package/github/docs/classes/NotAuthorizedError.html +4 -3
- package/github/docs/classes/NotRegisteredError.html +4 -3
- package/github/docs/classes/NotSignedInError.html +4 -3
- package/github/docs/classes/OperationNotImplementedError.html +4 -3
- package/github/docs/classes/RegisterError.html +4 -3
- package/github/docs/classes/RequestFailedError.html +6 -5
- package/github/docs/classes/ServiceError.html +4 -3
- package/github/docs/classes/SignOutError.html +4 -3
- package/github/docs/classes/SudoCryptoProviderDefaults.html +1 -1
- package/github/docs/classes/UnknownGraphQLError.html +6 -4
- package/github/docs/classes/UnrecognizedAlgorithmError.html +4 -3
- package/github/docs/classes/UserNotConfirmedError.html +4 -3
- package/github/docs/classes/VersionMismatchError.html +4 -3
- package/github/docs/enums/CachePolicy.html +2 -2
- package/github/docs/enums/EncryptionAlgorithm.html +2 -2
- package/github/docs/enums/KeyArchiveKeyType.html +2 -2
- package/github/docs/enums/KeyDataKeyFormat.html +3 -3
- package/github/docs/enums/KeyDataKeyType.html +2 -2
- package/github/docs/enums/ListOperationResultStatus.html +4 -4
- package/github/docs/enums/PublicKeyFormat.html +1 -1
- package/github/docs/index.html +1 -1
- package/github/docs/interfaces/AsymmetricEncryptionOptions.html +2 -2
- package/github/docs/interfaces/BooleanFilter.html +2 -2
- package/github/docs/interfaces/ConfigurationManager.html +5 -5
- package/github/docs/interfaces/KeyData.html +2 -2
- package/github/docs/interfaces/ListOperationFailureResult.html +2 -2
- package/github/docs/interfaces/ListOperationPartialResult.html +4 -4
- package/github/docs/interfaces/ListOperationSuccessResult.html +3 -3
- package/github/docs/interfaces/ListOutput.html +2 -2
- package/github/docs/interfaces/Logger.html +13 -7
- package/github/docs/interfaces/Owner.html +1 -1
- package/github/docs/interfaces/PublicKey.html +1 -1
- package/github/docs/interfaces/StringFilter.html +2 -2
- package/github/docs/interfaces/SudoCryptoProvider.html +39 -31
- package/github/docs/interfaces/SudoKeyArchive.html +10 -10
- package/github/docs/interfaces/SudoKeyManager.html +39 -31
- package/github/docs/interfaces/SymmetricEncryptionOptions.html +2 -2
- package/github/docs/modules.html +4 -4
- package/github/package.json +13 -10
- package/github/src/errors/error.ts +17 -8
- package/github/src/logging/logger.ts +65 -6
- package/github/src/sudoKeyManager/sudoCryptoProvider.ts +14 -0
- package/github/src/sudoKeyManager/sudoKeyManager.ts +22 -0
- package/github/test/logging/logger.spec.ts +122 -0
- package/github/test/sudoKeyManager/sudoKeyManager.spec.ts +37 -0
- package/github/yarn.lock +566 -687
- package/lib/errors/error.d.ts +3 -2
- package/lib/errors/error.js +30 -20
- package/lib/logging/logger.d.ts +30 -0
- package/lib/logging/logger.js +12 -0
- 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 +13 -10
- package/src/errors/error.ts +17 -8
- package/src/logging/logger.ts +65 -6
- package/src/sudoKeyManager/sudoCryptoProvider.ts +14 -0
- package/src/sudoKeyManager/sudoKeyManager.ts +22 -0
- package/test/logging/logger.spec.ts +122 -0
- package/test/sudoKeyManager/sudoKeyManager.spec.ts +37 -0
- package/yarn.lock +566 -687
|
@@ -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
|
}
|
|
@@ -57,4 +57,126 @@ describe('Logging utility test suite', () => {
|
|
|
57
57
|
),
|
|
58
58
|
)
|
|
59
59
|
})
|
|
60
|
+
|
|
61
|
+
it('should log with logger name at level set by environment variables', () => {
|
|
62
|
+
process.env.PROJECT_NAME = 'DummyProject'
|
|
63
|
+
process.env.LOG_LEVEL = 'debug'
|
|
64
|
+
const logger = new DefaultLogger()
|
|
65
|
+
console.log = jest.fn()
|
|
66
|
+
logger.debug('logger name at level set by environment variables')
|
|
67
|
+
expect(console.log).toBeCalledTimes(1)
|
|
68
|
+
expect(console.log).toBeCalledWith(
|
|
69
|
+
expect.stringContaining(
|
|
70
|
+
'DEBUG: DummyProject: logger name at level set by environment variables',
|
|
71
|
+
),
|
|
72
|
+
)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it.each`
|
|
76
|
+
level | traceEnabled
|
|
77
|
+
${'trace'} | ${true}
|
|
78
|
+
${'debug'} | ${false}
|
|
79
|
+
${'info'} | ${false}
|
|
80
|
+
${'warn'} | ${false}
|
|
81
|
+
${'error'} | ${false}
|
|
82
|
+
${'fatal'} | ${false}
|
|
83
|
+
`(
|
|
84
|
+
'should return trace enabled $traceEnabled when level is $level',
|
|
85
|
+
({ level, traceEnabled }) => {
|
|
86
|
+
process.env.PROJECT_NAME = 'DummyProject'
|
|
87
|
+
process.env.LOG_LEVEL = level
|
|
88
|
+
const logger = new DefaultLogger()
|
|
89
|
+
expect(logger.trace()).toEqual(traceEnabled)
|
|
90
|
+
},
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
it.each`
|
|
94
|
+
level | debugEnabled
|
|
95
|
+
${'trace'} | ${true}
|
|
96
|
+
${'debug'} | ${true}
|
|
97
|
+
${'info'} | ${false}
|
|
98
|
+
${'warn'} | ${false}
|
|
99
|
+
${'error'} | ${false}
|
|
100
|
+
${'fatal'} | ${false}
|
|
101
|
+
`(
|
|
102
|
+
'should return debug enabled $debugEnabled when level is $level',
|
|
103
|
+
({ level, debugEnabled }) => {
|
|
104
|
+
process.env.PROJECT_NAME = 'DummyProject'
|
|
105
|
+
process.env.LOG_LEVEL = level
|
|
106
|
+
const logger = new DefaultLogger()
|
|
107
|
+
expect(logger.debug()).toEqual(debugEnabled)
|
|
108
|
+
},
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
it.each`
|
|
112
|
+
level | infoEnabled
|
|
113
|
+
${'trace'} | ${true}
|
|
114
|
+
${'debug'} | ${true}
|
|
115
|
+
${'info'} | ${true}
|
|
116
|
+
${'warn'} | ${false}
|
|
117
|
+
${'error'} | ${false}
|
|
118
|
+
${'fatal'} | ${false}
|
|
119
|
+
`(
|
|
120
|
+
'should return info enabled $infoEnabled when level is $level',
|
|
121
|
+
({ level, infoEnabled }) => {
|
|
122
|
+
process.env.PROJECT_NAME = 'DummyProject'
|
|
123
|
+
process.env.LOG_LEVEL = level
|
|
124
|
+
const logger = new DefaultLogger()
|
|
125
|
+
expect(logger.info()).toEqual(infoEnabled)
|
|
126
|
+
},
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
it.each`
|
|
130
|
+
level | warnEnabled
|
|
131
|
+
${'trace'} | ${true}
|
|
132
|
+
${'debug'} | ${true}
|
|
133
|
+
${'info'} | ${true}
|
|
134
|
+
${'warn'} | ${true}
|
|
135
|
+
${'error'} | ${false}
|
|
136
|
+
${'fatal'} | ${false}
|
|
137
|
+
`(
|
|
138
|
+
'should return warn enabled $warnEnabled when level is $level',
|
|
139
|
+
({ level, warnEnabled }) => {
|
|
140
|
+
process.env.PROJECT_NAME = 'DummyProject'
|
|
141
|
+
process.env.LOG_LEVEL = level
|
|
142
|
+
const logger = new DefaultLogger()
|
|
143
|
+
expect(logger.warn()).toEqual(warnEnabled)
|
|
144
|
+
},
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
it.each`
|
|
148
|
+
level | errorEnabled
|
|
149
|
+
${'trace'} | ${true}
|
|
150
|
+
${'debug'} | ${true}
|
|
151
|
+
${'info'} | ${true}
|
|
152
|
+
${'warn'} | ${true}
|
|
153
|
+
${'error'} | ${true}
|
|
154
|
+
${'fatal'} | ${false}
|
|
155
|
+
`(
|
|
156
|
+
'should return error enabled $errorEnabled when level is $level',
|
|
157
|
+
({ level, errorEnabled }) => {
|
|
158
|
+
process.env.PROJECT_NAME = 'DummyProject'
|
|
159
|
+
process.env.LOG_LEVEL = level
|
|
160
|
+
const logger = new DefaultLogger()
|
|
161
|
+
expect(logger.error()).toEqual(errorEnabled)
|
|
162
|
+
},
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
it.each`
|
|
166
|
+
level | fatalEnabled
|
|
167
|
+
${'trace'} | ${true}
|
|
168
|
+
${'debug'} | ${true}
|
|
169
|
+
${'info'} | ${true}
|
|
170
|
+
${'warn'} | ${true}
|
|
171
|
+
${'error'} | ${true}
|
|
172
|
+
${'fatal'} | ${true}
|
|
173
|
+
`(
|
|
174
|
+
'should return fatal enabled $fatalEnabled when level is $level',
|
|
175
|
+
({ level, fatalEnabled }) => {
|
|
176
|
+
process.env.PROJECT_NAME = 'DummyProject'
|
|
177
|
+
process.env.LOG_LEVEL = level
|
|
178
|
+
const logger = new DefaultLogger()
|
|
179
|
+
expect(logger.fatal()).toEqual(fatalEnabled)
|
|
180
|
+
},
|
|
181
|
+
)
|
|
60
182
|
})
|
|
@@ -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(
|