@sudoplatform/sudo-common 6.0.1 → 6.2.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 +1 -0
- package/bin/outdated-with-suppression.sh +86 -9
- package/bin/suppress-outdated.sh +21 -3
- package/dependencies-report.json +117 -7
- package/docs/assets/highlight.css +1 -1
- package/docs/assets/main.js +2 -2
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +29 -0
- package/docs/classes/AccountLockedError.html +3 -3
- package/docs/classes/AuthenticationError.html +3 -3
- package/docs/classes/Base64.html +2 -2
- package/docs/classes/Buffer.html +2 -2
- package/docs/classes/ConfigurationNotSetError.html +3 -3
- package/docs/classes/ConfigurationSetNotFoundError.html +3 -3
- package/docs/classes/DecodeError.html +3 -3
- package/docs/classes/DefaultConfigurationManager.html +13 -6
- package/docs/classes/DefaultLogger.html +7 -7
- package/docs/classes/DefaultSudoKeyArchive.html +13 -13
- package/docs/classes/DefaultSudoKeyManager.html +28 -28
- package/docs/classes/FatalError.html +3 -3
- package/docs/classes/IllegalArgumentError.html +3 -3
- package/docs/classes/IllegalStateError.html +3 -3
- package/docs/classes/InsufficientEntitlementsError.html +3 -3
- package/docs/classes/InvalidOwnershipProofError.html +3 -3
- package/docs/classes/InvalidTokenError.html +3 -3
- package/docs/classes/KeyArchiveDecodingError.html +3 -3
- package/docs/classes/KeyArchiveIncorrectPasswordError.html +3 -3
- package/docs/classes/KeyArchiveMissingError.html +3 -3
- package/docs/classes/KeyArchiveNoPasswordRequiredError.html +3 -3
- package/docs/classes/KeyArchivePasswordRequiredError.html +3 -3
- package/docs/classes/KeyArchiveTypeError.html +3 -3
- package/docs/classes/KeyArchiveUnknownKeyTypeError.html +3 -3
- package/docs/classes/KeyArchiveVersionError.html +3 -3
- package/docs/classes/KeyNotFoundError.html +3 -3
- package/docs/classes/KeyStoreNotExportableError.html +3 -3
- package/docs/classes/LimitExceededError.html +3 -3
- package/docs/classes/NoEntitlementsError.html +3 -3
- package/docs/classes/NotAuthorizedError.html +3 -3
- package/docs/classes/NotRegisteredError.html +3 -3
- package/docs/classes/NotSignedInError.html +3 -3
- package/docs/classes/OperationNotImplementedError.html +3 -3
- package/docs/classes/RegisterError.html +3 -3
- package/docs/classes/RequestFailedError.html +5 -5
- package/docs/classes/ServiceError.html +3 -3
- package/docs/classes/SignOutError.html +3 -3
- package/docs/classes/SudoCryptoProviderDefaults.html +1 -1
- package/docs/classes/UnknownGraphQLError.html +3 -3
- package/docs/classes/UnrecognizedAlgorithmError.html +3 -3
- package/docs/classes/UserNotConfirmedError.html +3 -3
- package/docs/classes/VersionMismatchError.html +3 -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 +2 -2
- package/docs/interfaces/AsymmetricEncryptionOptions.html +2 -2
- package/docs/interfaces/BooleanFilter.html +2 -2
- package/docs/interfaces/ConfigurationManager.html +13 -6
- 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 +7 -7
- package/docs/interfaces/Owner.html +1 -1
- package/docs/interfaces/PublicKey.html +1 -1
- package/docs/interfaces/ServiceCompatibilityInfo.html +17 -0
- package/docs/interfaces/StringFilter.html +2 -2
- package/docs/interfaces/SudoCryptoProvider.html +28 -28
- package/docs/interfaces/SudoKeyArchive.html +10 -10
- package/docs/interfaces/SudoKeyManager.html +28 -28
- package/docs/interfaces/SymmetricEncryptionOptions.html +2 -2
- package/docs/interfaces/ValidationResult.html +11 -0
- package/docs/modules.html +5 -5
- package/github/.gitignore +1 -0
- package/github/bin/outdated-with-suppression.sh +86 -9
- package/github/bin/suppress-outdated.sh +21 -3
- package/github/docs/assets/highlight.css +1 -1
- package/github/docs/assets/main.js +2 -2
- package/github/docs/assets/search.js +1 -1
- package/github/docs/assets/style.css +29 -0
- package/github/docs/classes/AccountLockedError.html +3 -3
- package/github/docs/classes/AuthenticationError.html +3 -3
- package/github/docs/classes/Base64.html +2 -2
- package/github/docs/classes/Buffer.html +2 -2
- package/github/docs/classes/ConfigurationNotSetError.html +3 -3
- package/github/docs/classes/ConfigurationSetNotFoundError.html +3 -3
- package/github/docs/classes/DecodeError.html +3 -3
- package/github/docs/classes/DefaultConfigurationManager.html +13 -6
- package/github/docs/classes/DefaultLogger.html +7 -7
- package/github/docs/classes/DefaultSudoKeyArchive.html +13 -13
- package/github/docs/classes/DefaultSudoKeyManager.html +28 -28
- package/github/docs/classes/FatalError.html +3 -3
- package/github/docs/classes/IllegalArgumentError.html +3 -3
- package/github/docs/classes/IllegalStateError.html +3 -3
- package/github/docs/classes/InsufficientEntitlementsError.html +3 -3
- package/github/docs/classes/InvalidOwnershipProofError.html +3 -3
- package/github/docs/classes/InvalidTokenError.html +3 -3
- package/github/docs/classes/KeyArchiveDecodingError.html +3 -3
- package/github/docs/classes/KeyArchiveIncorrectPasswordError.html +3 -3
- package/github/docs/classes/KeyArchiveMissingError.html +3 -3
- package/github/docs/classes/KeyArchiveNoPasswordRequiredError.html +3 -3
- package/github/docs/classes/KeyArchivePasswordRequiredError.html +3 -3
- package/github/docs/classes/KeyArchiveTypeError.html +3 -3
- package/github/docs/classes/KeyArchiveUnknownKeyTypeError.html +3 -3
- package/github/docs/classes/KeyArchiveVersionError.html +3 -3
- package/github/docs/classes/KeyNotFoundError.html +3 -3
- package/github/docs/classes/KeyStoreNotExportableError.html +3 -3
- package/github/docs/classes/LimitExceededError.html +3 -3
- package/github/docs/classes/NoEntitlementsError.html +3 -3
- package/github/docs/classes/NotAuthorizedError.html +3 -3
- package/github/docs/classes/NotRegisteredError.html +3 -3
- package/github/docs/classes/NotSignedInError.html +3 -3
- package/github/docs/classes/OperationNotImplementedError.html +3 -3
- package/github/docs/classes/RegisterError.html +3 -3
- package/github/docs/classes/RequestFailedError.html +5 -5
- package/github/docs/classes/ServiceError.html +3 -3
- package/github/docs/classes/SignOutError.html +3 -3
- package/github/docs/classes/SudoCryptoProviderDefaults.html +1 -1
- package/github/docs/classes/UnknownGraphQLError.html +3 -3
- package/github/docs/classes/UnrecognizedAlgorithmError.html +3 -3
- package/github/docs/classes/UserNotConfirmedError.html +3 -3
- package/github/docs/classes/VersionMismatchError.html +3 -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 +2 -2
- package/github/docs/interfaces/AsymmetricEncryptionOptions.html +2 -2
- package/github/docs/interfaces/BooleanFilter.html +2 -2
- package/github/docs/interfaces/ConfigurationManager.html +13 -6
- 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 +7 -7
- package/github/docs/interfaces/Owner.html +1 -1
- package/github/docs/interfaces/PublicKey.html +1 -1
- package/github/docs/interfaces/ServiceCompatibilityInfo.html +17 -0
- package/github/docs/interfaces/StringFilter.html +2 -2
- package/github/docs/interfaces/SudoCryptoProvider.html +28 -28
- package/github/docs/interfaces/SudoKeyArchive.html +10 -10
- package/github/docs/interfaces/SudoKeyManager.html +28 -28
- package/github/docs/interfaces/SymmetricEncryptionOptions.html +2 -2
- package/github/docs/interfaces/ValidationResult.html +11 -0
- package/github/docs/modules.html +5 -5
- package/github/package.json +29 -25
- package/github/src/configurationManager/defaultConfigurationManager.ts +156 -7
- package/github/test/integration/defaultConfigurationManager.spec.ts +85 -0
- package/github/test/unit/configurationManager/defaultConfigurationManager.spec.ts +506 -0
- package/{test → github/test/unit}/errors/error.spec.ts +1 -1
- package/github/test/{sudoKeyArchive → unit}/keyType.spec.ts +0 -0
- package/{test → github/test/unit}/logging/logger.spec.ts +1 -1
- package/github/test/{sudoKeyArchive → unit}/sudoKeyArchive.spec.ts +0 -0
- package/github/test/{sudoKeyManager → unit}/sudoKeyManager.spec.ts +0 -0
- package/github/test/{utils → unit/utils}/base64.spec.ts +1 -1
- package/github/test/{utils → unit/utils}/buffer.spec.ts +1 -1
- package/{test → github/test/unit}/utils/listOperationResult.spec.ts +1 -1
- package/github/tsconfig.test.json +3 -1
- package/github/yarn.lock +1628 -1299
- package/lib/configurationManager/defaultConfigurationManager.d.ts +57 -0
- package/lib/configurationManager/defaultConfigurationManager.js +102 -7
- package/package.json +29 -25
- package/src/configurationManager/defaultConfigurationManager.ts +156 -7
- package/test/integration/defaultConfigurationManager.spec.ts +85 -0
- package/test/unit/configurationManager/defaultConfigurationManager.spec.ts +506 -0
- package/{github/test → test/unit}/errors/error.spec.ts +1 -1
- package/test/{sudoKeyArchive → unit}/keyType.spec.ts +0 -0
- package/{github/test → test/unit}/logging/logger.spec.ts +1 -1
- package/test/{sudoKeyArchive → unit}/sudoKeyArchive.spec.ts +0 -0
- package/test/{sudoKeyManager → unit}/sudoKeyManager.spec.ts +0 -0
- package/test/{utils → unit/utils}/base64.spec.ts +1 -1
- package/test/{utils → unit/utils}/buffer.spec.ts +1 -1
- package/{github/test → test/unit}/utils/listOperationResult.spec.ts +1 -1
- package/tsconfig.test.json +3 -1
- package/yarn.lock +1628 -1299
- package/github/test/configurationManager/defaultConfigurationManager.spec.ts +0 -185
- package/test/configurationManager/defaultConfigurationManager.spec.ts +0 -185
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { DefaultConfigurationManager } from '../../src/configurationManager/defaultConfigurationManager'
|
|
2
|
-
import * as t from 'io-ts'
|
|
3
|
-
import {
|
|
4
|
-
DecodeError,
|
|
5
|
-
ConfigurationSetNotFoundError,
|
|
6
|
-
} from '../../src/errors/error'
|
|
7
|
-
|
|
8
|
-
describe('configuration manager', () => {
|
|
9
|
-
const config = {
|
|
10
|
-
federatedSignIn: {
|
|
11
|
-
appClientId: '120q904mra9d5l4psmvdbrgm49',
|
|
12
|
-
signInRedirectUri: 'http://localhost:3000/callback',
|
|
13
|
-
signOutRedirectUri: 'http://localhost:3000/',
|
|
14
|
-
webDomain: 'id-dev-fsso-sudoplatform.auth.us-east-1.amazoncognito.com',
|
|
15
|
-
identityProvider: 'Auth0',
|
|
16
|
-
},
|
|
17
|
-
apiService: {
|
|
18
|
-
apiUrl:
|
|
19
|
-
'https://xy7zw5ys7rahrponv7h26vjn6y.appsync-api.us-east-1.amazonaws.com/graphql',
|
|
20
|
-
region: 'us-east-1',
|
|
21
|
-
},
|
|
22
|
-
identityService: {
|
|
23
|
-
region: 'us-east-1',
|
|
24
|
-
poolId: 'us-east-1_ZiPDToF73',
|
|
25
|
-
clientId: '120q904mra9d5l4psmvdbrgm49',
|
|
26
|
-
identityPoolId: 'us-east-1:8fe6d8ed-cd77-4622-b1bb-3f0c147638ad',
|
|
27
|
-
apiUrl:
|
|
28
|
-
'https://mqn7cjrzcrd75jpsma3xw4744a.appsync-api.us-east-1.amazonaws.com/graphql',
|
|
29
|
-
apiKey: 'da2-xejsa343urfifmzkycmz3rqdom',
|
|
30
|
-
bucket: 'ids-userdata-id-dev-fsso-userdatabucket2d841c35-j9x47k5042fk',
|
|
31
|
-
transientBucket:
|
|
32
|
-
'ids-userdata-id-dev-fsso-transientuserdatabucket0-1enoeyoho1sjl',
|
|
33
|
-
},
|
|
34
|
-
secureVaultService: {
|
|
35
|
-
region: 'us-east-1',
|
|
36
|
-
poolId: 'us-east-1_6NalHLdlq',
|
|
37
|
-
clientId: 'pcg1ma18cluamqrif79viaj04',
|
|
38
|
-
apiUrl:
|
|
39
|
-
'https://u2ysyzwojzaahbsq5toulhdt4e.appsync-api.us-east-1.amazonaws.com/graphql',
|
|
40
|
-
pbkdfRounds: 100000,
|
|
41
|
-
},
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const IdentityServiceConfig = t.type({
|
|
45
|
-
region: t.string,
|
|
46
|
-
poolId: t.string,
|
|
47
|
-
clientId: t.string,
|
|
48
|
-
apiUrl: t.string,
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
const ApiServiceConfig = t.type({
|
|
52
|
-
apiUrl: t.string,
|
|
53
|
-
region: t.string,
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
const SdkConfig = t.type({
|
|
57
|
-
identityService: IdentityServiceConfig,
|
|
58
|
-
apiService: ApiServiceConfig,
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
type IdentityServiceConfig = t.TypeOf<typeof IdentityServiceConfig>
|
|
62
|
-
type ApiServiceConfig = t.TypeOf<typeof ApiServiceConfig>
|
|
63
|
-
type SdkConfig = t.TypeOf<typeof SdkConfig>
|
|
64
|
-
|
|
65
|
-
describe('getConfigSet', () => {
|
|
66
|
-
it('should return entire config set when empty namespace supplied', () => {
|
|
67
|
-
const configSet = DefaultConfigurationManager.getInstance()
|
|
68
|
-
.setConfig(JSON.stringify(config))
|
|
69
|
-
.getConfigSet()
|
|
70
|
-
|
|
71
|
-
expect(configSet).toStrictEqual(config)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it('should return subset of configuration when matching namespace supplied', () => {
|
|
75
|
-
const expected = {
|
|
76
|
-
region: 'us-east-1',
|
|
77
|
-
poolId: 'us-east-1_ZiPDToF73',
|
|
78
|
-
clientId: '120q904mra9d5l4psmvdbrgm49',
|
|
79
|
-
identityPoolId: 'us-east-1:8fe6d8ed-cd77-4622-b1bb-3f0c147638ad',
|
|
80
|
-
apiUrl:
|
|
81
|
-
'https://mqn7cjrzcrd75jpsma3xw4744a.appsync-api.us-east-1.amazonaws.com/graphql',
|
|
82
|
-
apiKey: 'da2-xejsa343urfifmzkycmz3rqdom',
|
|
83
|
-
bucket: 'ids-userdata-id-dev-fsso-userdatabucket2d841c35-j9x47k5042fk',
|
|
84
|
-
transientBucket:
|
|
85
|
-
'ids-userdata-id-dev-fsso-transientuserdatabucket0-1enoeyoho1sjl',
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const configSet = DefaultConfigurationManager.getInstance()
|
|
89
|
-
.setConfig(JSON.stringify(config))
|
|
90
|
-
.getConfigSet('identityService')
|
|
91
|
-
|
|
92
|
-
expect(configSet).toStrictEqual(expected)
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it('should return nothing when no matching namespace supplied', () => {
|
|
96
|
-
const configSet = DefaultConfigurationManager.getInstance()
|
|
97
|
-
.setConfig(JSON.stringify(config))
|
|
98
|
-
.getConfigSet('randomNoMatchingNamespace')
|
|
99
|
-
|
|
100
|
-
expect(configSet).toBeFalsy()
|
|
101
|
-
})
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
describe('bindConfigSet<T>', () => {
|
|
105
|
-
it('should find config set then bind to given type', () => {
|
|
106
|
-
const result = DefaultConfigurationManager.getInstance()
|
|
107
|
-
.setConfig(JSON.stringify(config))
|
|
108
|
-
.bindConfigSet<IdentityServiceConfig>(
|
|
109
|
-
IdentityServiceConfig,
|
|
110
|
-
'identityService',
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
expect(result).toBeTruthy()
|
|
114
|
-
expect(result['apiUrl']).toBeTruthy()
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
it('should throw when configuration set not found', () => {
|
|
118
|
-
expect(() => {
|
|
119
|
-
DefaultConfigurationManager.getInstance()
|
|
120
|
-
.setConfig(JSON.stringify(config))
|
|
121
|
-
.bindConfigSet<IdentityServiceConfig>(
|
|
122
|
-
IdentityServiceConfig,
|
|
123
|
-
'randomNamespace',
|
|
124
|
-
)
|
|
125
|
-
}).toThrow(ConfigurationSetNotFoundError)
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
it('should still bind when no nampespace provided', () => {
|
|
129
|
-
const result = DefaultConfigurationManager.getInstance()
|
|
130
|
-
.setConfig(JSON.stringify(config))
|
|
131
|
-
.bindConfigSet<SdkConfig>(SdkConfig)
|
|
132
|
-
|
|
133
|
-
expect(result).toBeTruthy()
|
|
134
|
-
expect(result['identityService'].apiUrl).toBeTruthy()
|
|
135
|
-
})
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
describe('bind<T>', () => {
|
|
139
|
-
it('should bind configuration set to a type', () => {
|
|
140
|
-
const expected = {
|
|
141
|
-
region: 'us-east-1',
|
|
142
|
-
poolId: 'us-east-1_ZiPDToF73',
|
|
143
|
-
clientId: '120q904mra9d5l4psmvdbrgm49',
|
|
144
|
-
identityPoolId: 'us-east-1:8fe6d8ed-cd77-4622-b1bb-3f0c147638ad',
|
|
145
|
-
apiUrl:
|
|
146
|
-
'https://mqn7cjrzcrd75jpsma3xw4744a.appsync-api.us-east-1.amazonaws.com/graphql',
|
|
147
|
-
apiKey: 'da2-xejsa343urfifmzkycmz3rqdom',
|
|
148
|
-
bucket: 'ids-userdata-id-dev-fsso-userdatabucket2d841c35-j9x47k5042fk',
|
|
149
|
-
transientBucket:
|
|
150
|
-
'ids-userdata-id-dev-fsso-transientuserdatabucket0-1enoeyoho1sjl',
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const configSet = DefaultConfigurationManager.getInstance()
|
|
154
|
-
.setConfig(JSON.stringify(config))
|
|
155
|
-
.getConfigSet('identityService')
|
|
156
|
-
|
|
157
|
-
expect(configSet).toStrictEqual(expected)
|
|
158
|
-
|
|
159
|
-
const result =
|
|
160
|
-
DefaultConfigurationManager.getInstance().bind<IdentityServiceConfig>(
|
|
161
|
-
configSet,
|
|
162
|
-
IdentityServiceConfig,
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
expect(result).toBeTruthy()
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
it('should fail when trying to bind incorrect config to type', () => {
|
|
169
|
-
const wrongConfig = {
|
|
170
|
-
foo: 'bar',
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const configSet = DefaultConfigurationManager.getInstance()
|
|
174
|
-
.setConfig(JSON.stringify(wrongConfig))
|
|
175
|
-
.getConfigSet()
|
|
176
|
-
|
|
177
|
-
expect(() => {
|
|
178
|
-
DefaultConfigurationManager.getInstance().bind<IdentityServiceConfig>(
|
|
179
|
-
configSet,
|
|
180
|
-
IdentityServiceConfig,
|
|
181
|
-
)
|
|
182
|
-
}).toThrow(DecodeError)
|
|
183
|
-
})
|
|
184
|
-
})
|
|
185
|
-
})
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { DefaultConfigurationManager } from '../../src/configurationManager/defaultConfigurationManager'
|
|
2
|
-
import * as t from 'io-ts'
|
|
3
|
-
import {
|
|
4
|
-
DecodeError,
|
|
5
|
-
ConfigurationSetNotFoundError,
|
|
6
|
-
} from '../../src/errors/error'
|
|
7
|
-
|
|
8
|
-
describe('configuration manager', () => {
|
|
9
|
-
const config = {
|
|
10
|
-
federatedSignIn: {
|
|
11
|
-
appClientId: '120q904mra9d5l4psmvdbrgm49',
|
|
12
|
-
signInRedirectUri: 'http://localhost:3000/callback',
|
|
13
|
-
signOutRedirectUri: 'http://localhost:3000/',
|
|
14
|
-
webDomain: 'id-dev-fsso-sudoplatform.auth.us-east-1.amazoncognito.com',
|
|
15
|
-
identityProvider: 'Auth0',
|
|
16
|
-
},
|
|
17
|
-
apiService: {
|
|
18
|
-
apiUrl:
|
|
19
|
-
'https://xy7zw5ys7rahrponv7h26vjn6y.appsync-api.us-east-1.amazonaws.com/graphql',
|
|
20
|
-
region: 'us-east-1',
|
|
21
|
-
},
|
|
22
|
-
identityService: {
|
|
23
|
-
region: 'us-east-1',
|
|
24
|
-
poolId: 'us-east-1_ZiPDToF73',
|
|
25
|
-
clientId: '120q904mra9d5l4psmvdbrgm49',
|
|
26
|
-
identityPoolId: 'us-east-1:8fe6d8ed-cd77-4622-b1bb-3f0c147638ad',
|
|
27
|
-
apiUrl:
|
|
28
|
-
'https://mqn7cjrzcrd75jpsma3xw4744a.appsync-api.us-east-1.amazonaws.com/graphql',
|
|
29
|
-
apiKey: 'da2-xejsa343urfifmzkycmz3rqdom',
|
|
30
|
-
bucket: 'ids-userdata-id-dev-fsso-userdatabucket2d841c35-j9x47k5042fk',
|
|
31
|
-
transientBucket:
|
|
32
|
-
'ids-userdata-id-dev-fsso-transientuserdatabucket0-1enoeyoho1sjl',
|
|
33
|
-
},
|
|
34
|
-
secureVaultService: {
|
|
35
|
-
region: 'us-east-1',
|
|
36
|
-
poolId: 'us-east-1_6NalHLdlq',
|
|
37
|
-
clientId: 'pcg1ma18cluamqrif79viaj04',
|
|
38
|
-
apiUrl:
|
|
39
|
-
'https://u2ysyzwojzaahbsq5toulhdt4e.appsync-api.us-east-1.amazonaws.com/graphql',
|
|
40
|
-
pbkdfRounds: 100000,
|
|
41
|
-
},
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const IdentityServiceConfig = t.type({
|
|
45
|
-
region: t.string,
|
|
46
|
-
poolId: t.string,
|
|
47
|
-
clientId: t.string,
|
|
48
|
-
apiUrl: t.string,
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
const ApiServiceConfig = t.type({
|
|
52
|
-
apiUrl: t.string,
|
|
53
|
-
region: t.string,
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
const SdkConfig = t.type({
|
|
57
|
-
identityService: IdentityServiceConfig,
|
|
58
|
-
apiService: ApiServiceConfig,
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
type IdentityServiceConfig = t.TypeOf<typeof IdentityServiceConfig>
|
|
62
|
-
type ApiServiceConfig = t.TypeOf<typeof ApiServiceConfig>
|
|
63
|
-
type SdkConfig = t.TypeOf<typeof SdkConfig>
|
|
64
|
-
|
|
65
|
-
describe('getConfigSet', () => {
|
|
66
|
-
it('should return entire config set when empty namespace supplied', () => {
|
|
67
|
-
const configSet = DefaultConfigurationManager.getInstance()
|
|
68
|
-
.setConfig(JSON.stringify(config))
|
|
69
|
-
.getConfigSet()
|
|
70
|
-
|
|
71
|
-
expect(configSet).toStrictEqual(config)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it('should return subset of configuration when matching namespace supplied', () => {
|
|
75
|
-
const expected = {
|
|
76
|
-
region: 'us-east-1',
|
|
77
|
-
poolId: 'us-east-1_ZiPDToF73',
|
|
78
|
-
clientId: '120q904mra9d5l4psmvdbrgm49',
|
|
79
|
-
identityPoolId: 'us-east-1:8fe6d8ed-cd77-4622-b1bb-3f0c147638ad',
|
|
80
|
-
apiUrl:
|
|
81
|
-
'https://mqn7cjrzcrd75jpsma3xw4744a.appsync-api.us-east-1.amazonaws.com/graphql',
|
|
82
|
-
apiKey: 'da2-xejsa343urfifmzkycmz3rqdom',
|
|
83
|
-
bucket: 'ids-userdata-id-dev-fsso-userdatabucket2d841c35-j9x47k5042fk',
|
|
84
|
-
transientBucket:
|
|
85
|
-
'ids-userdata-id-dev-fsso-transientuserdatabucket0-1enoeyoho1sjl',
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const configSet = DefaultConfigurationManager.getInstance()
|
|
89
|
-
.setConfig(JSON.stringify(config))
|
|
90
|
-
.getConfigSet('identityService')
|
|
91
|
-
|
|
92
|
-
expect(configSet).toStrictEqual(expected)
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it('should return nothing when no matching namespace supplied', () => {
|
|
96
|
-
const configSet = DefaultConfigurationManager.getInstance()
|
|
97
|
-
.setConfig(JSON.stringify(config))
|
|
98
|
-
.getConfigSet('randomNoMatchingNamespace')
|
|
99
|
-
|
|
100
|
-
expect(configSet).toBeFalsy()
|
|
101
|
-
})
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
describe('bindConfigSet<T>', () => {
|
|
105
|
-
it('should find config set then bind to given type', () => {
|
|
106
|
-
const result = DefaultConfigurationManager.getInstance()
|
|
107
|
-
.setConfig(JSON.stringify(config))
|
|
108
|
-
.bindConfigSet<IdentityServiceConfig>(
|
|
109
|
-
IdentityServiceConfig,
|
|
110
|
-
'identityService',
|
|
111
|
-
)
|
|
112
|
-
|
|
113
|
-
expect(result).toBeTruthy()
|
|
114
|
-
expect(result['apiUrl']).toBeTruthy()
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
it('should throw when configuration set not found', () => {
|
|
118
|
-
expect(() => {
|
|
119
|
-
DefaultConfigurationManager.getInstance()
|
|
120
|
-
.setConfig(JSON.stringify(config))
|
|
121
|
-
.bindConfigSet<IdentityServiceConfig>(
|
|
122
|
-
IdentityServiceConfig,
|
|
123
|
-
'randomNamespace',
|
|
124
|
-
)
|
|
125
|
-
}).toThrow(ConfigurationSetNotFoundError)
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
it('should still bind when no nampespace provided', () => {
|
|
129
|
-
const result = DefaultConfigurationManager.getInstance()
|
|
130
|
-
.setConfig(JSON.stringify(config))
|
|
131
|
-
.bindConfigSet<SdkConfig>(SdkConfig)
|
|
132
|
-
|
|
133
|
-
expect(result).toBeTruthy()
|
|
134
|
-
expect(result['identityService'].apiUrl).toBeTruthy()
|
|
135
|
-
})
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
describe('bind<T>', () => {
|
|
139
|
-
it('should bind configuration set to a type', () => {
|
|
140
|
-
const expected = {
|
|
141
|
-
region: 'us-east-1',
|
|
142
|
-
poolId: 'us-east-1_ZiPDToF73',
|
|
143
|
-
clientId: '120q904mra9d5l4psmvdbrgm49',
|
|
144
|
-
identityPoolId: 'us-east-1:8fe6d8ed-cd77-4622-b1bb-3f0c147638ad',
|
|
145
|
-
apiUrl:
|
|
146
|
-
'https://mqn7cjrzcrd75jpsma3xw4744a.appsync-api.us-east-1.amazonaws.com/graphql',
|
|
147
|
-
apiKey: 'da2-xejsa343urfifmzkycmz3rqdom',
|
|
148
|
-
bucket: 'ids-userdata-id-dev-fsso-userdatabucket2d841c35-j9x47k5042fk',
|
|
149
|
-
transientBucket:
|
|
150
|
-
'ids-userdata-id-dev-fsso-transientuserdatabucket0-1enoeyoho1sjl',
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const configSet = DefaultConfigurationManager.getInstance()
|
|
154
|
-
.setConfig(JSON.stringify(config))
|
|
155
|
-
.getConfigSet('identityService')
|
|
156
|
-
|
|
157
|
-
expect(configSet).toStrictEqual(expected)
|
|
158
|
-
|
|
159
|
-
const result =
|
|
160
|
-
DefaultConfigurationManager.getInstance().bind<IdentityServiceConfig>(
|
|
161
|
-
configSet,
|
|
162
|
-
IdentityServiceConfig,
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
expect(result).toBeTruthy()
|
|
166
|
-
})
|
|
167
|
-
|
|
168
|
-
it('should fail when trying to bind incorrect config to type', () => {
|
|
169
|
-
const wrongConfig = {
|
|
170
|
-
foo: 'bar',
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const configSet = DefaultConfigurationManager.getInstance()
|
|
174
|
-
.setConfig(JSON.stringify(wrongConfig))
|
|
175
|
-
.getConfigSet()
|
|
176
|
-
|
|
177
|
-
expect(() => {
|
|
178
|
-
DefaultConfigurationManager.getInstance().bind<IdentityServiceConfig>(
|
|
179
|
-
configSet,
|
|
180
|
-
IdentityServiceConfig,
|
|
181
|
-
)
|
|
182
|
-
}).toThrow(DecodeError)
|
|
183
|
-
})
|
|
184
|
-
})
|
|
185
|
-
})
|