-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.js
53 lines (46 loc) · 1.46 KB
/
generate.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
53
'use strict';
const fs = require('fs');
const jose = require('node-jose');
const prettyjson = require('prettyjson');
const Federation = require('./lib/Federation');
const MetadataStatement = require('./lib/MetadataStatement');
const MetadataStatementEncoded = require('./lib/MetadataStatementEncoded');
const Logger = require('./lib/Logger');
const log = Logger.getLogger();
const f = new Federation();
f.setupKeys()
.then(() => {
return f.getMS();
})
.then((signed) => {
log.info('---- Signed MS ----');
signed.forEach((ms) => {
log.info(prettyjson.render(ms.getPlainSingle()), 'Metadata Statement');
});
})
.catch((err) => {
log.error(err, 'Error');
});
// const ms = fs.readFileSync('./var/example-ms.txt', 'utf8');
// const jwks = JSON.parse(fs.readFileSync('./var/example-jwks.json', 'utf8'));
// const keystore = jose.JWK.createKeyStore();
// const msEncoded = new MetadataStatementEncoded(ms);
// const m = new MetadataStatement('x', MetadataStatement.getPayload(ms), keystore);
// m.getKeystore()
// .then((k) => {
// console.log('----- Result ----');
// console.log(k);
// });
// console.log("----");
// console.log(msEncoded);
//
// Promise.all(jwks.map(k => keystore.add(k)))
// .then(() => msEncoded.decode(keystore))
// .then((result) => {
// console.log('----- Result ----');
// console.log(keystore.all());
// console.log(result);
// })
// .catch((err) => {
// console.error('Error', err);
// });