@sudoplatform/sudo-common 6.0.2 → 6.2.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.
Files changed (193) hide show
  1. package/.gitignore +1 -0
  2. package/.yarn/releases/yarn-1.22.18.cjs +147520 -0
  3. package/.yarnrc +5 -0
  4. package/bin/outdated-with-suppression.sh +86 -9
  5. package/bin/suppress-outdated.sh +21 -3
  6. package/dependencies-report.json +118 -8
  7. package/docs/assets/highlight.css +1 -1
  8. package/docs/assets/main.js +2 -2
  9. package/docs/assets/search.js +1 -1
  10. package/docs/assets/style.css +32 -2
  11. package/docs/classes/AccountLockedError.html +3 -3
  12. package/docs/classes/AuthenticationError.html +3 -3
  13. package/docs/classes/Base64.html +2 -2
  14. package/docs/classes/Buffer.html +2 -2
  15. package/docs/classes/ConfigurationNotSetError.html +3 -3
  16. package/docs/classes/ConfigurationSetNotFoundError.html +3 -3
  17. package/docs/classes/DecodeError.html +3 -3
  18. package/docs/classes/DefaultConfigurationManager.html +13 -6
  19. package/docs/classes/DefaultLogger.html +7 -7
  20. package/docs/classes/DefaultSudoKeyArchive.html +13 -13
  21. package/docs/classes/DefaultSudoKeyManager.html +28 -28
  22. package/docs/classes/FatalError.html +3 -3
  23. package/docs/classes/IllegalArgumentError.html +3 -3
  24. package/docs/classes/IllegalStateError.html +3 -3
  25. package/docs/classes/InsufficientEntitlementsError.html +3 -3
  26. package/docs/classes/InvalidOwnershipProofError.html +3 -3
  27. package/docs/classes/InvalidTokenError.html +3 -3
  28. package/docs/classes/KeyArchiveDecodingError.html +3 -3
  29. package/docs/classes/KeyArchiveIncorrectPasswordError.html +3 -3
  30. package/docs/classes/KeyArchiveMissingError.html +3 -3
  31. package/docs/classes/KeyArchiveNoPasswordRequiredError.html +3 -3
  32. package/docs/classes/KeyArchivePasswordRequiredError.html +3 -3
  33. package/docs/classes/KeyArchiveTypeError.html +3 -3
  34. package/docs/classes/KeyArchiveUnknownKeyTypeError.html +3 -3
  35. package/docs/classes/KeyArchiveVersionError.html +3 -3
  36. package/docs/classes/KeyNotFoundError.html +3 -3
  37. package/docs/classes/KeyStoreNotExportableError.html +3 -3
  38. package/docs/classes/LimitExceededError.html +3 -3
  39. package/docs/classes/NoEntitlementsError.html +3 -3
  40. package/docs/classes/NotAuthorizedError.html +3 -3
  41. package/docs/classes/NotRegisteredError.html +3 -3
  42. package/docs/classes/NotSignedInError.html +3 -3
  43. package/docs/classes/OperationNotImplementedError.html +3 -3
  44. package/docs/classes/RegisterError.html +3 -3
  45. package/docs/classes/RequestFailedError.html +5 -5
  46. package/docs/classes/ServiceError.html +3 -3
  47. package/docs/classes/SignOutError.html +3 -3
  48. package/docs/classes/SudoCryptoProviderDefaults.html +1 -1
  49. package/docs/classes/UnknownGraphQLError.html +3 -3
  50. package/docs/classes/UnrecognizedAlgorithmError.html +3 -3
  51. package/docs/classes/UserNotConfirmedError.html +3 -3
  52. package/docs/classes/VersionMismatchError.html +3 -3
  53. package/docs/enums/CachePolicy.html +2 -2
  54. package/docs/enums/EncryptionAlgorithm.html +2 -2
  55. package/docs/enums/KeyArchiveKeyType.html +2 -2
  56. package/docs/enums/KeyDataKeyFormat.html +3 -3
  57. package/docs/enums/KeyDataKeyType.html +2 -2
  58. package/docs/enums/ListOperationResultStatus.html +4 -4
  59. package/docs/enums/PublicKeyFormat.html +1 -1
  60. package/docs/index.html +2 -2
  61. package/docs/interfaces/AsymmetricEncryptionOptions.html +2 -2
  62. package/docs/interfaces/BooleanFilter.html +2 -2
  63. package/docs/interfaces/ConfigurationManager.html +13 -6
  64. package/docs/interfaces/KeyData.html +2 -2
  65. package/docs/interfaces/ListOperationFailureResult.html +2 -2
  66. package/docs/interfaces/ListOperationPartialResult.html +4 -4
  67. package/docs/interfaces/ListOperationSuccessResult.html +3 -3
  68. package/docs/interfaces/ListOutput.html +2 -2
  69. package/docs/interfaces/Logger.html +7 -7
  70. package/docs/interfaces/Owner.html +1 -1
  71. package/docs/interfaces/PublicKey.html +1 -1
  72. package/docs/interfaces/ServiceCompatibilityInfo.html +17 -0
  73. package/docs/interfaces/StringFilter.html +2 -2
  74. package/docs/interfaces/SudoCryptoProvider.html +28 -28
  75. package/docs/interfaces/SudoKeyArchive.html +10 -10
  76. package/docs/interfaces/SudoKeyManager.html +28 -28
  77. package/docs/interfaces/SymmetricEncryptionOptions.html +2 -2
  78. package/docs/interfaces/ValidationResult.html +11 -0
  79. package/docs/modules.html +6 -6
  80. package/github/.gitignore +1 -0
  81. package/github/.yarn/releases/yarn-1.22.18.cjs +147520 -0
  82. package/github/.yarnrc +5 -0
  83. package/github/bin/outdated-with-suppression.sh +86 -9
  84. package/github/bin/suppress-outdated.sh +21 -3
  85. package/github/docs/assets/highlight.css +1 -1
  86. package/github/docs/assets/main.js +2 -2
  87. package/github/docs/assets/search.js +1 -1
  88. package/github/docs/assets/style.css +32 -2
  89. package/github/docs/classes/AccountLockedError.html +3 -3
  90. package/github/docs/classes/AuthenticationError.html +3 -3
  91. package/github/docs/classes/Base64.html +2 -2
  92. package/github/docs/classes/Buffer.html +2 -2
  93. package/github/docs/classes/ConfigurationNotSetError.html +3 -3
  94. package/github/docs/classes/ConfigurationSetNotFoundError.html +3 -3
  95. package/github/docs/classes/DecodeError.html +3 -3
  96. package/github/docs/classes/DefaultConfigurationManager.html +13 -6
  97. package/github/docs/classes/DefaultLogger.html +7 -7
  98. package/github/docs/classes/DefaultSudoKeyArchive.html +13 -13
  99. package/github/docs/classes/DefaultSudoKeyManager.html +28 -28
  100. package/github/docs/classes/FatalError.html +3 -3
  101. package/github/docs/classes/IllegalArgumentError.html +3 -3
  102. package/github/docs/classes/IllegalStateError.html +3 -3
  103. package/github/docs/classes/InsufficientEntitlementsError.html +3 -3
  104. package/github/docs/classes/InvalidOwnershipProofError.html +3 -3
  105. package/github/docs/classes/InvalidTokenError.html +3 -3
  106. package/github/docs/classes/KeyArchiveDecodingError.html +3 -3
  107. package/github/docs/classes/KeyArchiveIncorrectPasswordError.html +3 -3
  108. package/github/docs/classes/KeyArchiveMissingError.html +3 -3
  109. package/github/docs/classes/KeyArchiveNoPasswordRequiredError.html +3 -3
  110. package/github/docs/classes/KeyArchivePasswordRequiredError.html +3 -3
  111. package/github/docs/classes/KeyArchiveTypeError.html +3 -3
  112. package/github/docs/classes/KeyArchiveUnknownKeyTypeError.html +3 -3
  113. package/github/docs/classes/KeyArchiveVersionError.html +3 -3
  114. package/github/docs/classes/KeyNotFoundError.html +3 -3
  115. package/github/docs/classes/KeyStoreNotExportableError.html +3 -3
  116. package/github/docs/classes/LimitExceededError.html +3 -3
  117. package/github/docs/classes/NoEntitlementsError.html +3 -3
  118. package/github/docs/classes/NotAuthorizedError.html +3 -3
  119. package/github/docs/classes/NotRegisteredError.html +3 -3
  120. package/github/docs/classes/NotSignedInError.html +3 -3
  121. package/github/docs/classes/OperationNotImplementedError.html +3 -3
  122. package/github/docs/classes/RegisterError.html +3 -3
  123. package/github/docs/classes/RequestFailedError.html +5 -5
  124. package/github/docs/classes/ServiceError.html +3 -3
  125. package/github/docs/classes/SignOutError.html +3 -3
  126. package/github/docs/classes/SudoCryptoProviderDefaults.html +1 -1
  127. package/github/docs/classes/UnknownGraphQLError.html +3 -3
  128. package/github/docs/classes/UnrecognizedAlgorithmError.html +3 -3
  129. package/github/docs/classes/UserNotConfirmedError.html +3 -3
  130. package/github/docs/classes/VersionMismatchError.html +3 -3
  131. package/github/docs/enums/CachePolicy.html +2 -2
  132. package/github/docs/enums/EncryptionAlgorithm.html +2 -2
  133. package/github/docs/enums/KeyArchiveKeyType.html +2 -2
  134. package/github/docs/enums/KeyDataKeyFormat.html +3 -3
  135. package/github/docs/enums/KeyDataKeyType.html +2 -2
  136. package/github/docs/enums/ListOperationResultStatus.html +4 -4
  137. package/github/docs/enums/PublicKeyFormat.html +1 -1
  138. package/github/docs/index.html +2 -2
  139. package/github/docs/interfaces/AsymmetricEncryptionOptions.html +2 -2
  140. package/github/docs/interfaces/BooleanFilter.html +2 -2
  141. package/github/docs/interfaces/ConfigurationManager.html +13 -6
  142. package/github/docs/interfaces/KeyData.html +2 -2
  143. package/github/docs/interfaces/ListOperationFailureResult.html +2 -2
  144. package/github/docs/interfaces/ListOperationPartialResult.html +4 -4
  145. package/github/docs/interfaces/ListOperationSuccessResult.html +3 -3
  146. package/github/docs/interfaces/ListOutput.html +2 -2
  147. package/github/docs/interfaces/Logger.html +7 -7
  148. package/github/docs/interfaces/Owner.html +1 -1
  149. package/github/docs/interfaces/PublicKey.html +1 -1
  150. package/github/docs/interfaces/ServiceCompatibilityInfo.html +17 -0
  151. package/github/docs/interfaces/StringFilter.html +2 -2
  152. package/github/docs/interfaces/SudoCryptoProvider.html +28 -28
  153. package/github/docs/interfaces/SudoKeyArchive.html +10 -10
  154. package/github/docs/interfaces/SudoKeyManager.html +28 -28
  155. package/github/docs/interfaces/SymmetricEncryptionOptions.html +2 -2
  156. package/github/docs/interfaces/ValidationResult.html +11 -0
  157. package/github/docs/modules.html +6 -6
  158. package/github/package.json +30 -25
  159. package/github/src/configurationManager/defaultConfigurationManager.ts +156 -7
  160. package/github/src/errors/error.ts +5 -1
  161. package/github/test/integration/defaultConfigurationManager.spec.ts +85 -0
  162. package/github/test/unit/configurationManager/defaultConfigurationManager.spec.ts +506 -0
  163. package/{test → github/test/unit}/errors/error.spec.ts +4 -19
  164. package/github/test/{sudoKeyArchive → unit}/keyType.spec.ts +0 -0
  165. package/{test → github/test/unit}/logging/logger.spec.ts +1 -1
  166. package/github/test/{sudoKeyArchive → unit}/sudoKeyArchive.spec.ts +0 -0
  167. package/github/test/{sudoKeyManager → unit}/sudoKeyManager.spec.ts +0 -0
  168. package/github/test/{utils → unit/utils}/base64.spec.ts +1 -1
  169. package/github/test/{utils → unit/utils}/buffer.spec.ts +1 -1
  170. package/{test → github/test/unit}/utils/listOperationResult.spec.ts +1 -1
  171. package/github/tsconfig.test.json +3 -1
  172. package/github/yarn.lock +1852 -1342
  173. package/lib/configurationManager/defaultConfigurationManager.d.ts +57 -0
  174. package/lib/configurationManager/defaultConfigurationManager.js +102 -7
  175. package/lib/errors/error.d.ts +1 -1
  176. package/lib/errors/error.js +3 -0
  177. package/package.json +30 -25
  178. package/src/configurationManager/defaultConfigurationManager.ts +156 -7
  179. package/src/errors/error.ts +5 -1
  180. package/test/integration/defaultConfigurationManager.spec.ts +85 -0
  181. package/test/unit/configurationManager/defaultConfigurationManager.spec.ts +506 -0
  182. package/{github/test → test/unit}/errors/error.spec.ts +4 -19
  183. package/test/{sudoKeyArchive → unit}/keyType.spec.ts +0 -0
  184. package/{github/test → test/unit}/logging/logger.spec.ts +1 -1
  185. package/test/{sudoKeyArchive → unit}/sudoKeyArchive.spec.ts +0 -0
  186. package/test/{sudoKeyManager → unit}/sudoKeyManager.spec.ts +0 -0
  187. package/test/{utils → unit/utils}/base64.spec.ts +1 -1
  188. package/test/{utils → unit/utils}/buffer.spec.ts +1 -1
  189. package/{github/test → test/unit}/utils/listOperationResult.spec.ts +1 -1
  190. package/tsconfig.test.json +3 -1
  191. package/yarn.lock +1852 -1342
  192. package/github/test/configurationManager/defaultConfigurationManager.spec.ts +0 -185
  193. 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
- })