-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathPluto.ts
183 lines (153 loc) · 4.48 KB
/
Pluto.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import { CredentialMetadata, DID, LinkSecret, PrismDID } from "../models";
import { DIDPair } from "../models/DIDPair";
import { PrivateKey } from "../models";
import { Mediator } from "../models/Mediator";
import { Message } from "../models/Message";
import { Credential } from "../models/Credential";
import { PeerDID } from "../../peer-did/PeerDID";
import { uuid } from "@stablelib/uuid";
import { Arrayable } from "../../utils";
import * as Backup from "../backup";
export namespace Pluto {
/**
* Storable
* define properties a Domain object must implement to be compatible with Pluto
*/
export interface Storable {
/**
* Universally Unique Identifier.
* should be unique across all items.
*/
uuid: string;
}
export const makeUUID = (): string => {
return uuid();
};
}
/**
* Pluto is a storage interface describing storage requirements of the edge agents
* which will be implemented using this SDK. Implement this interface using your
* preferred underlying storage technology, most appropriate for your use case.
*/
export interface Pluto {
// TODO apply breaking change below
// export interface Pluto extends Startable.IController {
/**
* Pluto initialise function
*/
start(): Promise<void>;
stop?(): Promise<void>;
/**
* create a Backup object from the stored data
*/
backup(version?: Backup.Version): Promise<Backup.Schema>;
/**
* load the given data into the store
* @param backup
*/
restore(backup: Backup.Schema): Promise<void>;
/**
* Store the Credential Metadata
*/
storeCredentialMetadata(metadata: CredentialMetadata): Promise<void>;
/**
* Fetch the Credential Metadata by its name
* @param name
*/
getCredentialMetadata(name: string): Promise<CredentialMetadata | null>;
/**
* Store a DID
* with optional private key(s) and alias
*/
storeDID(did: DID, keys?: Arrayable<PrivateKey>, alias?: string): Promise<void>;
/**
* Store a PRISM DID and its private key with given metadata.
* @deprecated use storeDID instead
*/
storePrismDID(did: DID, privateKey: PrivateKey, alias?: string): Promise<void>;
/**
* Store a Peer DID and an array of its privateKeys.
* @deprecated use storeDID instead
*/
storePeerDID(did: DID, privateKeys: Array<PrivateKey>): Promise<void>;
/**
* Store a named pair of DIDs representing a DIDComm connection.
*/
storeDIDPair(host: DID, receiver: DID, name: string): Promise<void>;
/**
* Store a DIDComm message.
*/
storeMessage(message: Message): Promise<void>;
/**
* Store an array of DIDComm messages
*/
storeMessages(messages: Array<Message>): Promise<void>;
/**
* Store a list of private keys with its metadata and a reference to the DID it belongs to.
*/
storePrivateKey(privateKey: PrivateKey): Promise<void>;
/**
* Store a mediator information.
*/
storeMediator(mediator: Mediator): Promise<void>;
/**
* Store a Credential into the Database
*/
storeCredential(credential: Credential): Promise<void>;
/**
* Retrieve all stored PRISM DIDs.
*/
getAllPrismDIDs(): Promise<PrismDID[]>;
/**
* Retrieve all stored Peer DIDs.
*/
getAllPeerDIDs(): Promise<Array<PeerDID>>;
/**
* Retrieve available private keys for a given DID.
*/
getDIDPrivateKeysByDID(did: DID): Promise<Array<PrivateKey>>;
/**
* Retrieve all stored DID pairs (DIDComm connections).
*/
getAllDidPairs(): Promise<Array<DIDPair>>;
/**
* Retrieve a DID pair containing a given DID as either host or receiver.
*/
getPairByDID(did: DID): Promise<DIDPair | null>;
/**
* Retrieve a DID pair by a given pair name.
*/
getPairByName(name: string): Promise<DIDPair | null>;
/**
* Retrieve all stored DIDComm messages.
*/
getAllMessages(): Promise<Array<Message>>;
/**
* Retrieve a DIDComm message by ID.
*/
getMessage(id: string): Promise<Message | null>;
/**
* Retrieve all stored mediators.
*/
getAllMediators(): Promise<Array<Mediator>>;
/**
* Retrieve all the stored credentials
*/
getAllCredentials(): Promise<Array<Credential>>;
/**
* Retrieve the stored link secret by its name
*/
getLinkSecret(name?: string): Promise<LinkSecret | null>;
/**
* Store a new linkSecret
*/
storeLinkSecret(linkSecret: LinkSecret): Promise<void>;
/**
* Revoke a Credential
*/
revokeCredential(credential: Credential): Promise<void>;
/**
* Delete a previously stored messages
*/
deleteMessage(uuid: string): Promise<void>;
}