-
Notifications
You must be signed in to change notification settings - Fork 0
/
vc.js
48 lines (42 loc) · 1.08 KB
/
vc.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
const { agent } = require('./agent');
let anArr = [];
const vc = async (data) => {
try {
const { did } = data;
delete data.did;
delete data.uri;
for (let p in data) {
if (!data.hasOwnProperty(p)) {
// The current property is not a direct property of p
continue;
}
let obj = {
[p]: data[p]
}
await vcGenerator(did, obj);
}
console.log(anArr);
return anArr;
} catch (error) {
console.log(error);
}
};
const vcGenerator = async (did, obj) => {
let vc = await agent.createVerifiableCredential({
credential: {
issuer: { id: did },
'@context': ['https://www.w3.org/2018/credentials/v1'],
type: ['VerifiableCredential'],
issuanceDate: new Date().toISOString(),
credentialSubject: {
id: did,
...obj
},
},
proofFormat: 'jwt',
});
anArr.push(vc);
}
module.exports = {
vc,
}