-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjwks.js
52 lines (48 loc) · 1.44 KB
/
jwks.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*!
=========================================================
* © 2018-2022 Ronan LE MEILLAT for Association Highcanfly
=========================================================
This website use:
- Vite, Vue3, FontAwesome 6, TailwindCss 3
- Vue Notus theme from Creative Tim (MIT License)
- And many others
*/
import fs from 'fs'
import https from 'https'
function listDir(dir) {
fs.readdir(dir, (err, files) => {
files.forEach(file => {
console.log(file);
});
});
}
async function getJwks() {
console.log(`retrieve https://${process.env.AUTH0_DOMAIN}/.well-known/jwks.json`)
const url = `https://${process.env.AUTH0_DOMAIN}/.well-known/jwks.json`;
return new Promise((resolve, reject) => {
https.get(url, res => {
let data = '';
res.on('data', chunk => {
data += chunk;
});
res.on('end', () => {
data = JSON.parse(data);
data.domain = process.env.AUTH0_DOMAIN;
data.namespace = process.env.AUTH0_CUSTOM_NAMESPACE;
resolve(data);
})
}).on('error', err => {
console.log(err.message);
reject(err);
})
});
}
(async () => {
const jwks = await getJwks();
fs.writeFile('./src/config/jwks.json',
JSON.stringify(jwks),
'utf8', function (err) {
//listDir('.');
if (err) return console.log(err);
});
})();