-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdid.ts
94 lines (87 loc) · 2.22 KB
/
did.ts
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { sign } from "crypto";
import { cryptoHash } from "./hash"
export class Did{
scheme:string
method:string
methodSpecificId:string
constructor(scheme:string,method:string,methodSpecificId:string){
this.scheme=scheme
this.method=method
this.methodSpecificId=methodSpecificId
}
static createMid(pkey:PublicKey){
const Mid:string=cryptoHash(pkey.publicKey)
return Mid
}
}
export class PublicKey {
type: string;
publicKey: string;
constructor(type: string, publicKey: string) {
this.type = type;
this.publicKey = publicKey;
}
}
// export class Authentication {
// type: string;
// publicKey: PublicKey;
// constructor(type: string, publicKey: PublicKey) {
// this.type = type;
// this.publicKey = publicKey;
// }
// }
// export class ServiceEndpoint {
// id: string;
// type: string;
// serviceURL: string;
// constructor(id: string, type: string, serviceURL: string) {
// this.id = id;
// this.type = type;
// this.serviceURL = serviceURL;
// }
// }
export class DidDocument {
did: Did;
publicKey: PublicKey;
// authentication: Authentication;
// services?: ServiceEndpoint[];
createdAt: Date;
isValid:boolean
constructor(
did: Did,
publicKey: PublicKey,
// authentication: Authentication,
createdAt: Date,
isValid:boolean
// services?: ServiceEndpoint[]
) {
this.did = did;
this.publicKey = publicKey;
this.isValid=isValid
// this.authentication = authentication;
// this.services = services;
this.createdAt = createdAt;
}
}
export class Signature{
r:string
s:string
constructor(r:string,s:string){
this.r=r
this.s=s
}
}
export class Transaction{
signature:Signature
createdAt:Date
did:Did|null
publicKey:string
createdBy:string
constructor(signature:Signature,createdBy:string,createdAt:Date,publicKey:string,did:Did|null){
this.signature=signature
this.createdAt=createdAt
this.publicKey=publicKey
this.createdBy=createdBy
this.did=did || null
}
}