forked from TBD54566975/vc-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (23 loc) · 970 Bytes
/
index.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
import { VerifiableCredential } from "@web5/credentials";
import { DidDht } from "@web5/dids";
import { loadDID, storeDID } from "./utils.js";
// STEP 0: Set filepath to use or store DID
const filename = "./did.json";
let attendeeDid;
//STEP 1: Creates and stores new DID if one doesn't exist
const existingDID = await loadDID(filename);
if(!existingDID) {
// creates a DID
attendeeDid = await DidDht.create({
options:{ publish: true }
});
console.log("DID:", attendeeDid);
await storeDID(filename, attendeeDid);
} else {
attendeeDid = await DidDht.import({ portableDid: existingDID });
console.log('attendee', attendeeDid);
}
// TODO: STEP 2: Create a verifiable credential
// TODO: STEP 3: Cryptographically sign VC with DID and get JWT
// TODO: STEP 4: Examine VC: https://jwt.io/
// TODO: STEP 5: Present VC: https://web5-vc.netlify.app/