-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetCredentials.js
28 lines (26 loc) · 942 Bytes
/
setCredentials.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
let cred = require('./cred.json')
function setCredentials(credentials) {
for (key in credentials) {
for (microkey in credentials[key]) {
if (!["client_id", "client_secret", "response_type", "scope", "redirect_uri", "grant_type", "tenant"].includes(microkey)) {
throw `You cannot set ${microkey.charAt(0).toUpperCase() + microkey.slice(1)} as a credential for ${key.charAt(0).toUpperCase() + key.slice(1)} stupid!`
}
}
}
for (key in credentials) {
for (microkey in credentials[key]) {
const miniCredObject = cred[key]
const miniCredentialsObject = credentials[key]
miniCredObject[microkey] = miniCredentialsObject[microkey]
}
}
for (key in cred) {
if (Array.isArray(cred[key].scope)) {
cred[key].scope = cred[key].scope.join(' ')
}
}
}
module.exports = {
cred,
setCredentials
}