ac-awssecrets 2.0.5 → 2.1.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/CHANGELOG.md +30 -0
- package/index.js +46 -47
- package/package.json +6 -7
- package/test/config.js +4 -0
- package/test/test.js +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
<a name="2.1.1"></a>
|
|
2
|
+
|
|
3
|
+
## [2.1.1](https://github.com/admiralcloud/ac-awssecrets/compare/v2.1.0..v2.1.1) (2024-05-08 13:44:22)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fix
|
|
7
|
+
|
|
8
|
+
* **App:** Only set value from secret, if secret exists | MP | [ab1b8e87bd1e35c7eb4428c1aa90ad9a93597d9e](https://github.com/admiralcloud/ac-awssecrets/commit/ab1b8e87bd1e35c7eb4428c1aa90ad9a93597d9e)
|
|
9
|
+
Only set value from secret, if secret exists
|
|
10
|
+
Related issues: [undefined/undefined#master](undefined/browse/master)
|
|
11
|
+
### Chores
|
|
12
|
+
|
|
13
|
+
* **App:** Updated packages | MP | [57d506749cbcad5372c84952a8e7929dd62dca37](https://github.com/admiralcloud/ac-awssecrets/commit/57d506749cbcad5372c84952a8e7929dd62dca37)
|
|
14
|
+
Updated packages
|
|
15
|
+
Related issues: [undefined/undefined#master](undefined/browse/master)
|
|
16
|
+
<a name="2.1.0"></a>
|
|
17
|
+
|
|
18
|
+
# [2.1.0](https://github.com/admiralcloud/ac-awssecrets/compare/v2.0.5..v2.1.0) (2023-12-31 14:46:52)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Feature
|
|
22
|
+
|
|
23
|
+
* **App:** Do not use custom credentialprovider | MP | [9556a0fb87e15c8d1242585373a706853384d796](https://github.com/admiralcloud/ac-awssecrets/commit/9556a0fb87e15c8d1242585373a706853384d796)
|
|
24
|
+
It does not seem to speed up the process to use custom credential provider. It can also create compatibility issues
|
|
25
|
+
Related issues: [undefined/undefined#develop](undefined/browse/develop)
|
|
26
|
+
### Chores
|
|
27
|
+
|
|
28
|
+
* **App:** Updated packages | MP | [cd5c172c2ed8169f5927c4a7e6562b7a5a9b5899](https://github.com/admiralcloud/ac-awssecrets/commit/cd5c172c2ed8169f5927c4a7e6562b7a5a9b5899)
|
|
29
|
+
Updated packages
|
|
30
|
+
Related issues: [undefined/undefined#develop](undefined/browse/develop)
|
|
1
31
|
<a name="2.0.5"></a>
|
|
2
32
|
|
|
3
33
|
## [2.0.5](https://github.com/admiralcloud/ac-awssecrets/compare/v2.0.4..v2.0.5) (2023-06-24 09:11:54)
|
package/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const { SecretsManagerClient, GetSecretValueCommand } = require('@aws-sdk/client-secrets-manager')
|
|
2
|
-
const customCredentialProvider = require('ac-aws-customcredentialprovider')
|
|
3
2
|
|
|
4
3
|
const testConfig = require('./test/config');
|
|
5
4
|
|
|
@@ -36,8 +35,7 @@ const awsSecrets = () => {
|
|
|
36
35
|
const environment = config?.environment || 'development'
|
|
37
36
|
|
|
38
37
|
const awsConfig = {
|
|
39
|
-
region: 'eu-central-1'
|
|
40
|
-
credentials: customCredentialProvider({ localDevelopment: config.localDevelopment, debug })
|
|
38
|
+
region: 'eu-central-1'
|
|
41
39
|
}
|
|
42
40
|
const client = new SecretsManagerClient(awsConfig)
|
|
43
41
|
|
|
@@ -104,55 +102,56 @@ const awsSecrets = () => {
|
|
|
104
102
|
for (const secret of secrets) {
|
|
105
103
|
let existingValue = getKey(config, secret.key) || {}
|
|
106
104
|
let value = secret?.value
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
value[key] = val
|
|
124
|
-
})
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (secret.servers) {
|
|
128
|
-
if (typeof secret.servers === 'boolean') {
|
|
129
|
-
let servers = existingValue?.servers || []
|
|
130
|
-
config[secret.key].servers = servers.map(server => {
|
|
131
|
-
if (server.server === secret.serverName) {
|
|
132
|
-
server = { ...server, ...value }
|
|
105
|
+
if (value) {
|
|
106
|
+
// convert values
|
|
107
|
+
if (typeof value === 'object') {
|
|
108
|
+
Object.keys(value).forEach((key) => {
|
|
109
|
+
let val = value[key]
|
|
110
|
+
if (val === 'true') val = true
|
|
111
|
+
else if (val === 'false') val = false
|
|
112
|
+
else if (typeof val === 'string' && val.startsWith('JSON:')) {
|
|
113
|
+
try {
|
|
114
|
+
val = JSON.parse(val.substring(5))
|
|
115
|
+
}
|
|
116
|
+
catch(e) {
|
|
117
|
+
console.error('%s | %s | JSON could not be parsed %j', functionName, secret.name, val)
|
|
118
|
+
throw new Error('invalidJSON')
|
|
119
|
+
}
|
|
133
120
|
}
|
|
134
|
-
|
|
121
|
+
value[key] = val
|
|
135
122
|
})
|
|
136
123
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
124
|
+
|
|
125
|
+
if (secret.servers) {
|
|
126
|
+
if (typeof secret.servers === 'boolean') {
|
|
127
|
+
let servers = existingValue?.servers || []
|
|
128
|
+
config[secret.key].servers = servers.map(server => {
|
|
129
|
+
if (server.server === secret.serverName) {
|
|
130
|
+
server = { ...server, ...value }
|
|
131
|
+
}
|
|
132
|
+
return server
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
// NEW NOTATION AS OBJECT
|
|
137
|
+
/* TODO: Probably not used anywhere, so legacy is ok
|
|
138
|
+
let match = {}
|
|
139
|
+
_.set(match, _.get(secret.servers, 'identifier'), _.get(secret.servers, 'value'))
|
|
140
|
+
existingValue = _.find(_.get(config, key, []), match)
|
|
141
|
+
*/
|
|
142
|
+
}
|
|
144
143
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
144
|
+
else if (secret?.type === 'arrayObject') {
|
|
145
|
+
existingValue.push(value)
|
|
146
|
+
setKey(config, secret.key, existingValue)
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
if (Object.keys(existingValue).length === 0) {
|
|
150
|
+
setKey(config, secret.key, {})
|
|
151
|
+
}
|
|
152
|
+
existingValue = { ...existingValue, ...value }
|
|
153
|
+
setKey(config, secret.key, existingValue)
|
|
153
154
|
}
|
|
154
|
-
existingValue = { ...existingValue, ...value }
|
|
155
|
-
setKey(config, secret.key, existingValue)
|
|
156
155
|
}
|
|
157
156
|
|
|
158
157
|
if (secret?.log || debug) {
|
package/package.json
CHANGED
|
@@ -3,17 +3,16 @@
|
|
|
3
3
|
"author": "Mark Poepping (https://www.admiralcloud.com)",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "admiralcloud/ac-awssecrets",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.1.1",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
|
9
|
-
"ac-aws-customcredentialprovider": "^0.1.3"
|
|
8
|
+
"@aws-sdk/client-secrets-manager": "^3.569.0"
|
|
10
9
|
},
|
|
11
10
|
"devDependencies": {
|
|
12
|
-
"ac-semantic-release": "^0.4.
|
|
13
|
-
"c8": "^
|
|
14
|
-
"chai": "^4.
|
|
11
|
+
"ac-semantic-release": "^0.4.2",
|
|
12
|
+
"c8": "^9.1.0",
|
|
13
|
+
"chai": "^4.4.1",
|
|
15
14
|
"eslint": "8.x",
|
|
16
|
-
"mocha": "^10.
|
|
15
|
+
"mocha": "^10.4.0"
|
|
17
16
|
},
|
|
18
17
|
"scripts": {
|
|
19
18
|
"test": "mocha --reporter spec",
|
package/test/config.js
CHANGED
|
@@ -19,6 +19,9 @@ const config = {
|
|
|
19
19
|
},
|
|
20
20
|
aws: {
|
|
21
21
|
accessKeys: []
|
|
22
|
+
},
|
|
23
|
+
configVar7: {
|
|
24
|
+
level: 'info'
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
|
|
@@ -28,6 +31,7 @@ const secrets = [
|
|
|
28
31
|
{ key: 'configVar4', name: 'json' },
|
|
29
32
|
{ key: 'configVar5.path', name: 'path' },
|
|
30
33
|
{ key: 'configVar6', name: 'notExistingLocally' },
|
|
34
|
+
{ key: 'configVar7', name: 'notExistingKey' },
|
|
31
35
|
]
|
|
32
36
|
|
|
33
37
|
const availableSecrets = [{
|
package/test/test.js
CHANGED
|
@@ -61,6 +61,10 @@ describe('Reading secrets', () => {
|
|
|
61
61
|
expect(config.configVar6).to.have.property('prop2', 'abc')
|
|
62
62
|
})
|
|
63
63
|
|
|
64
|
+
it('Check non existing key - should fallback to existing value without error', async() => {
|
|
65
|
+
expect(config.configVar7).to.have.property('level', 'info')
|
|
66
|
+
})
|
|
67
|
+
|
|
64
68
|
it('Check multisecrets', async() => {
|
|
65
69
|
//console.log(50, config.aws.accessKeys)
|
|
66
70
|
expect(config.aws.accessKeys).to.have.length(2)
|