@didcid/keymaster 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +109 -0
- package/dist/cjs/db/abstract-base.cjs +25 -0
- package/dist/cjs/db/cache.cjs +27 -0
- package/dist/cjs/db/chrome.cjs +32 -0
- package/dist/cjs/db/json-memory.cjs +24 -0
- package/dist/cjs/db/json.cjs +35 -0
- package/dist/cjs/db/mongo.cjs +57 -0
- package/dist/cjs/db/redis.cjs +55 -0
- package/dist/cjs/db/sqlite.cjs +69 -0
- package/dist/cjs/db/typeGuards.cjs +11 -0
- package/dist/cjs/db/web.cjs +29 -0
- package/dist/cjs/encryption.cjs +59 -0
- package/dist/cjs/index.cjs +32 -0
- package/dist/cjs/keymaster-client.cjs +1139 -0
- package/dist/cjs/keymaster.cjs +3787 -0
- package/dist/cjs/node.cjs +45 -0
- package/dist/cjs/search-client.cjs +87 -0
- package/dist/esm/db/abstract-base.js +22 -0
- package/dist/esm/db/abstract-base.js.map +1 -0
- package/dist/esm/db/cache.js +21 -0
- package/dist/esm/db/cache.js.map +1 -0
- package/dist/esm/db/chrome.js +26 -0
- package/dist/esm/db/chrome.js.map +1 -0
- package/dist/esm/db/json-memory.js +18 -0
- package/dist/esm/db/json-memory.js.map +1 -0
- package/dist/esm/db/json.js +29 -0
- package/dist/esm/db/json.js.map +1 -0
- package/dist/esm/db/mongo.js +51 -0
- package/dist/esm/db/mongo.js.map +1 -0
- package/dist/esm/db/redis.js +49 -0
- package/dist/esm/db/redis.js.map +1 -0
- package/dist/esm/db/sqlite.js +63 -0
- package/dist/esm/db/sqlite.js.map +1 -0
- package/dist/esm/db/typeGuards.js +7 -0
- package/dist/esm/db/typeGuards.js.map +1 -0
- package/dist/esm/db/web.js +23 -0
- package/dist/esm/db/web.js.map +1 -0
- package/dist/esm/encryption.js +55 -0
- package/dist/esm/encryption.js.map +1 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/keymaster-client.js +1133 -0
- package/dist/esm/keymaster-client.js.map +1 -0
- package/dist/esm/keymaster.js +2733 -0
- package/dist/esm/keymaster.js.map +1 -0
- package/dist/esm/node.js +7 -0
- package/dist/esm/node.js.map +1 -0
- package/dist/esm/search-client.js +81 -0
- package/dist/esm/search-client.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/types/db/abstract-base.d.ts +7 -0
- package/dist/types/db/cache.d.ts +9 -0
- package/dist/types/db/chrome.d.ts +8 -0
- package/dist/types/db/json-memory.d.ts +7 -0
- package/dist/types/db/json.d.ts +9 -0
- package/dist/types/db/mongo.d.ts +15 -0
- package/dist/types/db/redis.d.ts +13 -0
- package/dist/types/db/sqlite.d.ts +12 -0
- package/dist/types/db/typeGuards.d.ts +3 -0
- package/dist/types/db/web.d.ts +8 -0
- package/dist/types/encryption.d.ts +10 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/keymaster-client.d.ts +134 -0
- package/dist/types/keymaster.d.ts +211 -0
- package/dist/types/node.d.ts +6 -0
- package/dist/types/search-client.d.ts +9 -0
- package/dist/types/types.d.ts +373 -0
- package/package.json +171 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { DidCidDocument, ResolveDIDOptions, Operation } from '@didcid/gatekeeper/types';
|
|
2
|
+
import { Challenge, ChallengeResponse, CheckWalletResult, CreateAssetOptions, FileAssetOptions, CreateResponseOptions, DmailItem, DmailMessage, EncryptOptions, FileAsset, FixWalletResult, Group, GroupVault, GroupVaultOptions, IDInfo, ImageAsset, IssueCredentialsOptions, KeymasterInterface, KeymasterOptions, NoticeMessage, Poll, PossiblySigned, Signature, StoredWallet, VerifiableCredential, ViewPollResult, WalletFile, WalletEncFile } from '@didcid/keymaster/types';
|
|
3
|
+
import { EcdsaJwkPair, EcdsaJwkPublic } from '@didcid/cipher/types';
|
|
4
|
+
export declare enum DmailTags {
|
|
5
|
+
DMAIL = "dmail",
|
|
6
|
+
INBOX = "inbox",
|
|
7
|
+
DRAFT = "draft",
|
|
8
|
+
SENT = "sent",
|
|
9
|
+
ARCHIVED = "archived",
|
|
10
|
+
DELETED = "deleted",
|
|
11
|
+
UNREAD = "unread"
|
|
12
|
+
}
|
|
13
|
+
export declare enum NoticeTags {
|
|
14
|
+
DMAIL = "dmail",
|
|
15
|
+
BALLOT = "ballot",
|
|
16
|
+
POLL = "poll",
|
|
17
|
+
CREDENTIAL = "credential"
|
|
18
|
+
}
|
|
19
|
+
export default class Keymaster implements KeymasterInterface {
|
|
20
|
+
private readonly passphrase;
|
|
21
|
+
private gatekeeper;
|
|
22
|
+
private db;
|
|
23
|
+
private cipher;
|
|
24
|
+
private searchEngine;
|
|
25
|
+
private readonly defaultRegistry;
|
|
26
|
+
private readonly ephemeralRegistry;
|
|
27
|
+
private readonly maxNameLength;
|
|
28
|
+
private readonly maxDataLength;
|
|
29
|
+
private _walletCache?;
|
|
30
|
+
private _hdkeyCache?;
|
|
31
|
+
constructor(options: KeymasterOptions);
|
|
32
|
+
listRegistries(): Promise<string[]>;
|
|
33
|
+
private mutateWallet;
|
|
34
|
+
loadWallet(): Promise<WalletFile>;
|
|
35
|
+
saveWallet(wallet: StoredWallet, overwrite?: boolean): Promise<boolean>;
|
|
36
|
+
newWallet(mnemonic?: string, overwrite?: boolean): Promise<WalletFile>;
|
|
37
|
+
decryptMnemonic(): Promise<string>;
|
|
38
|
+
getMnemonicForDerivation(wallet: WalletFile): Promise<string>;
|
|
39
|
+
checkWallet(): Promise<CheckWalletResult>;
|
|
40
|
+
fixWallet(): Promise<FixWalletResult>;
|
|
41
|
+
resolveSeedBank(): Promise<DidCidDocument>;
|
|
42
|
+
updateSeedBank(doc: DidCidDocument): Promise<boolean>;
|
|
43
|
+
backupWallet(registry?: string, wallet?: WalletFile): Promise<string>;
|
|
44
|
+
recoverWallet(did?: string): Promise<WalletFile>;
|
|
45
|
+
listIds(): Promise<string[]>;
|
|
46
|
+
getCurrentId(): Promise<string | undefined>;
|
|
47
|
+
setCurrentId(name: string): Promise<boolean>;
|
|
48
|
+
didMatch(did1: string, did2: string): boolean;
|
|
49
|
+
fetchIdInfo(id?: string, wallet?: WalletFile): Promise<IDInfo>;
|
|
50
|
+
hdKeyPair(): Promise<EcdsaJwkPair>;
|
|
51
|
+
getPublicKeyJwk(doc: DidCidDocument): EcdsaJwkPublic;
|
|
52
|
+
fetchKeyPair(name?: string): Promise<EcdsaJwkPair | null>;
|
|
53
|
+
createAsset(data: unknown, options?: CreateAssetOptions): Promise<string>;
|
|
54
|
+
cloneAsset(id: string, options?: CreateAssetOptions): Promise<string>;
|
|
55
|
+
generateImageAsset(buffer: Buffer): Promise<ImageAsset>;
|
|
56
|
+
createImage(buffer: Buffer, options?: CreateAssetOptions): Promise<string>;
|
|
57
|
+
updateImage(id: string, buffer: Buffer): Promise<boolean>;
|
|
58
|
+
getImage(id: string): Promise<ImageAsset | null>;
|
|
59
|
+
testImage(id: string): Promise<boolean>;
|
|
60
|
+
getMimeType(buffer: Buffer): Promise<string>;
|
|
61
|
+
generateFileAsset(filename: string, buffer: Buffer): Promise<FileAsset>;
|
|
62
|
+
createDocument(buffer: Buffer, options?: FileAssetOptions): Promise<string>;
|
|
63
|
+
updateDocument(id: string, buffer: Buffer, options?: FileAssetOptions): Promise<boolean>;
|
|
64
|
+
getDocument(id: string): Promise<FileAsset | null>;
|
|
65
|
+
testDocument(id: string): Promise<boolean>;
|
|
66
|
+
encryptMessage(msg: string, receiver: string, options?: EncryptOptions): Promise<string>;
|
|
67
|
+
private decryptWithDerivedKeys;
|
|
68
|
+
decryptMessage(did: string): Promise<string>;
|
|
69
|
+
encryptJSON(json: unknown, did: string, options?: EncryptOptions): Promise<string>;
|
|
70
|
+
decryptJSON(did: string): Promise<unknown>;
|
|
71
|
+
addSignature<T extends object>(obj: T, controller?: string): Promise<T & {
|
|
72
|
+
signature: Signature;
|
|
73
|
+
}>;
|
|
74
|
+
verifySignature<T extends PossiblySigned>(obj: T): Promise<boolean>;
|
|
75
|
+
updateDID(id: string, doc: DidCidDocument): Promise<boolean>;
|
|
76
|
+
revokeDID(id: string): Promise<boolean>;
|
|
77
|
+
addToOwned(did: string, owner?: string): Promise<boolean>;
|
|
78
|
+
removeFromOwned(did: string, owner: string): Promise<boolean>;
|
|
79
|
+
addToHeld(did: string): Promise<boolean>;
|
|
80
|
+
removeFromHeld(did: string): Promise<boolean>;
|
|
81
|
+
lookupDID(name: string): Promise<string>;
|
|
82
|
+
resolveDID(did: string, options?: ResolveDIDOptions): Promise<DidCidDocument>;
|
|
83
|
+
idInWallet(did?: string): Promise<boolean>;
|
|
84
|
+
resolveAsset(did: string, options?: ResolveDIDOptions): Promise<any>;
|
|
85
|
+
updateAsset(did: string, data: Record<string, unknown>): Promise<boolean>;
|
|
86
|
+
transferAsset(id: string, controller: string): Promise<boolean>;
|
|
87
|
+
listAssets(owner?: string): Promise<string[]>;
|
|
88
|
+
validateName(name: string, wallet?: WalletFile): string;
|
|
89
|
+
createId(name: string, options?: {
|
|
90
|
+
registry?: string;
|
|
91
|
+
}): Promise<string>;
|
|
92
|
+
createIdOperation(name: string, account?: number, options?: {
|
|
93
|
+
registry?: string;
|
|
94
|
+
}): Promise<Operation>;
|
|
95
|
+
removeId(name: string): Promise<boolean>;
|
|
96
|
+
renameId(id: string, name: string): Promise<boolean>;
|
|
97
|
+
backupId(id?: string): Promise<boolean>;
|
|
98
|
+
recoverId(did: string): Promise<string>;
|
|
99
|
+
rotateKeys(): Promise<boolean>;
|
|
100
|
+
listNames(options?: {
|
|
101
|
+
includeIDs?: boolean;
|
|
102
|
+
}): Promise<Record<string, string>>;
|
|
103
|
+
addName(name: string, did: string): Promise<boolean>;
|
|
104
|
+
getName(name: string): Promise<string | null>;
|
|
105
|
+
removeName(name: string): Promise<boolean>;
|
|
106
|
+
testAgent(id: string): Promise<boolean>;
|
|
107
|
+
bindCredential(schemaId: string, subjectId: string, options?: {
|
|
108
|
+
validFrom?: string;
|
|
109
|
+
validUntil?: string;
|
|
110
|
+
credential?: Record<string, unknown>;
|
|
111
|
+
}): Promise<VerifiableCredential>;
|
|
112
|
+
issueCredential(credential: Partial<VerifiableCredential>, options?: IssueCredentialsOptions): Promise<string>;
|
|
113
|
+
sendCredential(did: string, options?: CreateAssetOptions): Promise<string | null>;
|
|
114
|
+
private isVerifiableCredential;
|
|
115
|
+
updateCredential(did: string, credential: VerifiableCredential): Promise<boolean>;
|
|
116
|
+
revokeCredential(credential: string): Promise<boolean>;
|
|
117
|
+
listIssued(issuer?: string): Promise<string[]>;
|
|
118
|
+
acceptCredential(did: string): Promise<boolean>;
|
|
119
|
+
getCredential(id: string): Promise<VerifiableCredential | null>;
|
|
120
|
+
removeCredential(id: string): Promise<boolean>;
|
|
121
|
+
listCredentials(id?: string): Promise<string[]>;
|
|
122
|
+
publishCredential(did: string, options?: {
|
|
123
|
+
reveal?: boolean;
|
|
124
|
+
}): Promise<VerifiableCredential>;
|
|
125
|
+
unpublishCredential(did: string): Promise<string>;
|
|
126
|
+
createChallenge(challenge?: Challenge, options?: CreateAssetOptions): Promise<string>;
|
|
127
|
+
private findMatchingCredential;
|
|
128
|
+
createResponse(challengeDID: string, options?: CreateResponseOptions): Promise<string>;
|
|
129
|
+
verifyResponse(responseDID: string, options?: {
|
|
130
|
+
retries?: number;
|
|
131
|
+
delay?: number;
|
|
132
|
+
}): Promise<ChallengeResponse>;
|
|
133
|
+
createGroup(name: string, options?: CreateAssetOptions): Promise<string>;
|
|
134
|
+
getGroup(id: string): Promise<Group | null>;
|
|
135
|
+
addGroupMember(groupId: string, memberId: string): Promise<boolean>;
|
|
136
|
+
removeGroupMember(groupId: string, memberId: string): Promise<boolean>;
|
|
137
|
+
testGroup(groupId: string, memberId?: string): Promise<boolean>;
|
|
138
|
+
listGroups(owner?: string): Promise<string[]>;
|
|
139
|
+
private validateSchema;
|
|
140
|
+
private generateSchema;
|
|
141
|
+
createSchema(schema?: unknown, options?: CreateAssetOptions): Promise<string>;
|
|
142
|
+
getSchema(id: string): Promise<unknown | null>;
|
|
143
|
+
setSchema(id: string, schema: unknown): Promise<boolean>;
|
|
144
|
+
testSchema(id: string): Promise<boolean>;
|
|
145
|
+
listSchemas(owner?: string): Promise<string[]>;
|
|
146
|
+
createTemplate(schemaId: string): Promise<Record<string, unknown>>;
|
|
147
|
+
pollTemplate(): Promise<Poll>;
|
|
148
|
+
createPoll(poll: Poll, options?: CreateAssetOptions): Promise<string>;
|
|
149
|
+
getPoll(id: string): Promise<Poll | null>;
|
|
150
|
+
testPoll(id: string): Promise<boolean>;
|
|
151
|
+
listPolls(owner?: string): Promise<string[]>;
|
|
152
|
+
viewPoll(pollId: string): Promise<ViewPollResult>;
|
|
153
|
+
votePoll(pollId: string, vote: number, options?: {
|
|
154
|
+
spoil?: boolean;
|
|
155
|
+
registry?: string;
|
|
156
|
+
validUntil?: string;
|
|
157
|
+
}): Promise<string>;
|
|
158
|
+
updatePoll(ballot: string): Promise<boolean>;
|
|
159
|
+
publishPoll(pollId: string, options?: {
|
|
160
|
+
reveal?: boolean;
|
|
161
|
+
}): Promise<boolean>;
|
|
162
|
+
unpublishPoll(pollId: string): Promise<boolean>;
|
|
163
|
+
createGroupVault(options?: GroupVaultOptions): Promise<string>;
|
|
164
|
+
getGroupVault(groupVaultId: string, options?: ResolveDIDOptions): Promise<GroupVault>;
|
|
165
|
+
testGroupVault(id: string, options?: ResolveDIDOptions): Promise<boolean>;
|
|
166
|
+
private generateSaltedId;
|
|
167
|
+
private decryptGroupVault;
|
|
168
|
+
private checkGroupVaultOwner;
|
|
169
|
+
private addMemberKey;
|
|
170
|
+
private checkVaultVersion;
|
|
171
|
+
getAgentDID(doc: DidCidDocument): string;
|
|
172
|
+
addGroupVaultMember(vaultId: string, memberId: string): Promise<boolean>;
|
|
173
|
+
removeGroupVaultMember(vaultId: string, memberId: string): Promise<boolean>;
|
|
174
|
+
listGroupVaultMembers(vaultId: string): Promise<Record<string, any>>;
|
|
175
|
+
addGroupVaultItem(vaultId: string, name: string, buffer: Buffer): Promise<boolean>;
|
|
176
|
+
removeGroupVaultItem(vaultId: string, name: string): Promise<boolean>;
|
|
177
|
+
listGroupVaultItems(vaultId: string, options?: ResolveDIDOptions): Promise<Record<string, any>>;
|
|
178
|
+
getGroupVaultItem(vaultId: string, name: string, options?: ResolveDIDOptions): Promise<Buffer | null>;
|
|
179
|
+
listDmail(): Promise<Record<string, DmailItem>>;
|
|
180
|
+
verifyTagList(tags: string[]): string[];
|
|
181
|
+
fileDmail(did: string, tags: string[]): Promise<boolean>;
|
|
182
|
+
removeDmail(did: string): Promise<boolean>;
|
|
183
|
+
verifyRecipientList(list: string[]): Promise<string[]>;
|
|
184
|
+
verifyDmail(message: DmailMessage): Promise<DmailMessage>;
|
|
185
|
+
createDmail(message: DmailMessage, options?: GroupVaultOptions): Promise<string>;
|
|
186
|
+
updateDmail(did: string, message: DmailMessage): Promise<boolean>;
|
|
187
|
+
sendDmail(did: string): Promise<string | null>;
|
|
188
|
+
getDmailMessage(did: string, options?: ResolveDIDOptions): Promise<DmailMessage | null>;
|
|
189
|
+
listDmailAttachments(did: string, options?: ResolveDIDOptions): Promise<Record<string, any>>;
|
|
190
|
+
addDmailAttachment(did: string, name: string, buffer: Buffer): Promise<boolean>;
|
|
191
|
+
removeDmailAttachment(did: string, name: string): Promise<boolean>;
|
|
192
|
+
getDmailAttachment(did: string, name: string): Promise<Buffer | null>;
|
|
193
|
+
importDmail(did: string): Promise<boolean>;
|
|
194
|
+
verifyDIDList(didList: string[]): Promise<string[]>;
|
|
195
|
+
verifyNotice(notice: NoticeMessage): Promise<NoticeMessage>;
|
|
196
|
+
createNotice(message: NoticeMessage, options?: CreateAssetOptions): Promise<string>;
|
|
197
|
+
updateNotice(id: string, message: NoticeMessage): Promise<boolean>;
|
|
198
|
+
addToNotices(did: string, tags: string[]): Promise<boolean>;
|
|
199
|
+
importNotice(did: string): Promise<boolean>;
|
|
200
|
+
searchNotices(): Promise<boolean>;
|
|
201
|
+
cleanupNotices(): Promise<boolean>;
|
|
202
|
+
refreshNotices(): Promise<boolean>;
|
|
203
|
+
exportEncryptedWallet(): Promise<WalletEncFile>;
|
|
204
|
+
private isBallot;
|
|
205
|
+
private addUnnamedPoll;
|
|
206
|
+
private getHDKeyFromCacheOrMnemonic;
|
|
207
|
+
private encryptWalletForStorage;
|
|
208
|
+
private decryptWalletFromStorage;
|
|
209
|
+
private decryptWallet;
|
|
210
|
+
private upgradeWallet;
|
|
211
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './index.js';
|
|
2
|
+
export { default } from './index.js';
|
|
3
|
+
export { default as WalletJson } from './db/json.js';
|
|
4
|
+
export { default as WalletRedis } from './db/redis.js';
|
|
5
|
+
export { default as WalletMongo } from './db/mongo.js';
|
|
6
|
+
export { default as WalletSQLite } from './db/sqlite.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WaitUntilReadyOptions, SearchClientOptions, SearchEngine } from './types.js';
|
|
2
|
+
export default class SearchClient implements SearchEngine {
|
|
3
|
+
private API;
|
|
4
|
+
static create(options: SearchClientOptions): Promise<SearchClient>;
|
|
5
|
+
connect(options?: SearchClientOptions): Promise<void>;
|
|
6
|
+
waitUntilReady(options?: WaitUntilReadyOptions): Promise<void>;
|
|
7
|
+
isReady(): Promise<boolean>;
|
|
8
|
+
search(where: object): Promise<string[]>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { Cipher, EcdsaJwkPublic } from '@didcid/cipher/types';
|
|
2
|
+
import { GatekeeperInterface, DidCidDocument, ResolveDIDOptions } from '@didcid/gatekeeper/types';
|
|
3
|
+
export interface Seed {
|
|
4
|
+
/** Passphrase-encrypted mnemonic */
|
|
5
|
+
mnemonicEnc?: {
|
|
6
|
+
salt: string;
|
|
7
|
+
iv: string;
|
|
8
|
+
data: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export interface IDInfo {
|
|
12
|
+
did: string;
|
|
13
|
+
account: number;
|
|
14
|
+
index: number;
|
|
15
|
+
held?: string[];
|
|
16
|
+
owned?: string[];
|
|
17
|
+
dmail?: Record<string, any>;
|
|
18
|
+
notices?: Record<string, any>;
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}
|
|
21
|
+
export interface WalletEncFile {
|
|
22
|
+
version: number;
|
|
23
|
+
seed: Seed;
|
|
24
|
+
enc: string;
|
|
25
|
+
}
|
|
26
|
+
export interface WalletFile {
|
|
27
|
+
version?: number;
|
|
28
|
+
seed: Seed;
|
|
29
|
+
counter: number;
|
|
30
|
+
ids: Record<string, IDInfo>;
|
|
31
|
+
current?: string;
|
|
32
|
+
names?: Record<string, string>;
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}
|
|
35
|
+
export interface CheckWalletResult {
|
|
36
|
+
checked: number;
|
|
37
|
+
invalid: number;
|
|
38
|
+
deleted: number;
|
|
39
|
+
}
|
|
40
|
+
export interface FixWalletResult {
|
|
41
|
+
idsRemoved: number;
|
|
42
|
+
ownedRemoved: number;
|
|
43
|
+
heldRemoved: number;
|
|
44
|
+
namesRemoved: number;
|
|
45
|
+
}
|
|
46
|
+
export interface CreateAssetOptions {
|
|
47
|
+
registry?: string;
|
|
48
|
+
controller?: string;
|
|
49
|
+
validUntil?: string;
|
|
50
|
+
name?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface FileAssetOptions extends CreateAssetOptions {
|
|
53
|
+
filename?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface EncryptOptions extends CreateAssetOptions {
|
|
56
|
+
encryptForSender?: boolean;
|
|
57
|
+
includeHash?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface Group {
|
|
60
|
+
name: string;
|
|
61
|
+
members: string[];
|
|
62
|
+
}
|
|
63
|
+
export interface Signature {
|
|
64
|
+
signer?: string;
|
|
65
|
+
signed: string;
|
|
66
|
+
hash: string;
|
|
67
|
+
value: string;
|
|
68
|
+
}
|
|
69
|
+
export interface VerifiableCredential {
|
|
70
|
+
"@context": string[];
|
|
71
|
+
type: string[];
|
|
72
|
+
issuer: string;
|
|
73
|
+
validFrom: string;
|
|
74
|
+
validUntil?: string;
|
|
75
|
+
credentialSubject?: {
|
|
76
|
+
id: string;
|
|
77
|
+
};
|
|
78
|
+
credential?: Record<string, unknown> | null;
|
|
79
|
+
signature?: Signature;
|
|
80
|
+
}
|
|
81
|
+
export interface IssueCredentialsOptions extends EncryptOptions {
|
|
82
|
+
schema?: string;
|
|
83
|
+
subject?: string;
|
|
84
|
+
validFrom?: string;
|
|
85
|
+
credential?: Record<string, unknown>;
|
|
86
|
+
}
|
|
87
|
+
export interface Challenge {
|
|
88
|
+
credentials?: {
|
|
89
|
+
schema: string;
|
|
90
|
+
issuers?: string[];
|
|
91
|
+
}[];
|
|
92
|
+
[key: string]: any;
|
|
93
|
+
}
|
|
94
|
+
export interface ChallengeResponse {
|
|
95
|
+
challenge: string;
|
|
96
|
+
credentials: {
|
|
97
|
+
vc: string;
|
|
98
|
+
vp: string;
|
|
99
|
+
}[];
|
|
100
|
+
requested: number;
|
|
101
|
+
fulfilled: number;
|
|
102
|
+
match: boolean;
|
|
103
|
+
vps?: unknown[];
|
|
104
|
+
responder?: string;
|
|
105
|
+
}
|
|
106
|
+
export interface CreateResponseOptions {
|
|
107
|
+
registry?: string;
|
|
108
|
+
validUntil?: string;
|
|
109
|
+
retries?: number;
|
|
110
|
+
delay?: number;
|
|
111
|
+
}
|
|
112
|
+
export interface PollResults {
|
|
113
|
+
tally: Array<{
|
|
114
|
+
vote: number;
|
|
115
|
+
option: string;
|
|
116
|
+
count: number;
|
|
117
|
+
}>;
|
|
118
|
+
ballots?: Array<{
|
|
119
|
+
ballot: string;
|
|
120
|
+
received: string;
|
|
121
|
+
voter: string;
|
|
122
|
+
vote: number;
|
|
123
|
+
option: string;
|
|
124
|
+
}>;
|
|
125
|
+
votes?: {
|
|
126
|
+
eligible: number;
|
|
127
|
+
received: number;
|
|
128
|
+
pending: number;
|
|
129
|
+
};
|
|
130
|
+
final?: boolean;
|
|
131
|
+
}
|
|
132
|
+
export interface Poll {
|
|
133
|
+
type: string;
|
|
134
|
+
version: number;
|
|
135
|
+
description: string;
|
|
136
|
+
roster: string;
|
|
137
|
+
options: string[];
|
|
138
|
+
deadline: string;
|
|
139
|
+
ballots?: Record<string, {
|
|
140
|
+
ballot: string;
|
|
141
|
+
received: string;
|
|
142
|
+
}>;
|
|
143
|
+
results?: PollResults;
|
|
144
|
+
}
|
|
145
|
+
export interface ViewPollResult {
|
|
146
|
+
description: string;
|
|
147
|
+
options: string[];
|
|
148
|
+
deadline: string;
|
|
149
|
+
isOwner: boolean;
|
|
150
|
+
isEligible: boolean;
|
|
151
|
+
voteExpired: boolean;
|
|
152
|
+
hasVoted: boolean;
|
|
153
|
+
results?: PollResults;
|
|
154
|
+
}
|
|
155
|
+
export interface BinaryAsset {
|
|
156
|
+
cid: string;
|
|
157
|
+
type: string;
|
|
158
|
+
bytes: number;
|
|
159
|
+
data?: Buffer;
|
|
160
|
+
}
|
|
161
|
+
export interface ImageAsset extends BinaryAsset {
|
|
162
|
+
width: number;
|
|
163
|
+
height: number;
|
|
164
|
+
}
|
|
165
|
+
export interface FileAsset extends BinaryAsset {
|
|
166
|
+
filename: string;
|
|
167
|
+
}
|
|
168
|
+
export interface GroupVault {
|
|
169
|
+
version?: number;
|
|
170
|
+
publicJwk: EcdsaJwkPublic;
|
|
171
|
+
salt: string;
|
|
172
|
+
config: string;
|
|
173
|
+
members: string;
|
|
174
|
+
keys: Record<string, string>;
|
|
175
|
+
items: string;
|
|
176
|
+
sha256: string;
|
|
177
|
+
}
|
|
178
|
+
export interface GroupVaultOptions extends CreateAssetOptions {
|
|
179
|
+
secretMembers?: boolean;
|
|
180
|
+
version?: number;
|
|
181
|
+
}
|
|
182
|
+
export interface GroupVaultLogin {
|
|
183
|
+
service: string;
|
|
184
|
+
username: string;
|
|
185
|
+
password: string;
|
|
186
|
+
}
|
|
187
|
+
export type StoredWallet = WalletFile | WalletEncFile | null;
|
|
188
|
+
export interface WalletBase {
|
|
189
|
+
saveWallet(wallet: StoredWallet, overwrite?: boolean): Promise<boolean>;
|
|
190
|
+
loadWallet(): Promise<StoredWallet | null>;
|
|
191
|
+
updateWallet(mutator: (wallet: StoredWallet) => void | Promise<void>): Promise<void>;
|
|
192
|
+
}
|
|
193
|
+
export interface SearchEngine {
|
|
194
|
+
search(query: object): Promise<string[]>;
|
|
195
|
+
}
|
|
196
|
+
export interface KeymasterOptions {
|
|
197
|
+
passphrase: string;
|
|
198
|
+
gatekeeper: GatekeeperInterface;
|
|
199
|
+
wallet: WalletBase;
|
|
200
|
+
cipher: Cipher;
|
|
201
|
+
search?: SearchEngine;
|
|
202
|
+
defaultRegistry?: string;
|
|
203
|
+
maxNameLength?: number;
|
|
204
|
+
}
|
|
205
|
+
export interface EncryptedMessage {
|
|
206
|
+
sender: string;
|
|
207
|
+
created: string;
|
|
208
|
+
cipher_hash?: string | null;
|
|
209
|
+
cipher_sender?: string | null;
|
|
210
|
+
cipher_receiver?: string | null;
|
|
211
|
+
}
|
|
212
|
+
export interface PossiblySigned {
|
|
213
|
+
signature?: Signature;
|
|
214
|
+
}
|
|
215
|
+
export interface RestClientOptions {
|
|
216
|
+
url?: string;
|
|
217
|
+
console?: any;
|
|
218
|
+
waitUntilReady?: boolean;
|
|
219
|
+
intervalSeconds?: number;
|
|
220
|
+
chatty?: boolean;
|
|
221
|
+
becomeChattyAfter?: number;
|
|
222
|
+
maxRetries?: number;
|
|
223
|
+
}
|
|
224
|
+
export interface KeymasterClientOptions extends RestClientOptions {
|
|
225
|
+
}
|
|
226
|
+
export interface SearchClientOptions extends RestClientOptions {
|
|
227
|
+
}
|
|
228
|
+
export interface WaitUntilReadyOptions {
|
|
229
|
+
intervalSeconds?: number;
|
|
230
|
+
chatty?: boolean;
|
|
231
|
+
becomeChattyAfter?: number;
|
|
232
|
+
maxRetries?: number;
|
|
233
|
+
}
|
|
234
|
+
export interface DmailMessage {
|
|
235
|
+
to: string[];
|
|
236
|
+
cc: string[];
|
|
237
|
+
subject: string;
|
|
238
|
+
body: string;
|
|
239
|
+
reference?: string;
|
|
240
|
+
}
|
|
241
|
+
export interface DmailItem {
|
|
242
|
+
message: DmailMessage;
|
|
243
|
+
to: string[];
|
|
244
|
+
cc: string[];
|
|
245
|
+
sender: string;
|
|
246
|
+
date: string;
|
|
247
|
+
tags: string[];
|
|
248
|
+
attachments?: any;
|
|
249
|
+
docs?: any;
|
|
250
|
+
}
|
|
251
|
+
export interface NoticeMessage {
|
|
252
|
+
to: string[];
|
|
253
|
+
dids: string[];
|
|
254
|
+
}
|
|
255
|
+
export interface KeymasterInterface {
|
|
256
|
+
loadWallet(): Promise<WalletFile>;
|
|
257
|
+
saveWallet(wallet: StoredWallet, overwrite?: boolean): Promise<boolean>;
|
|
258
|
+
newWallet(mnemonic?: string, overwrite?: boolean): Promise<WalletFile>;
|
|
259
|
+
backupWallet(): Promise<boolean | string>;
|
|
260
|
+
recoverWallet(): Promise<WalletFile>;
|
|
261
|
+
checkWallet(): Promise<CheckWalletResult>;
|
|
262
|
+
fixWallet(): Promise<FixWalletResult>;
|
|
263
|
+
decryptMnemonic(): Promise<string>;
|
|
264
|
+
exportEncryptedWallet(): Promise<WalletEncFile>;
|
|
265
|
+
listIds(): Promise<string[]>;
|
|
266
|
+
getCurrentId(): Promise<string | undefined>;
|
|
267
|
+
setCurrentId(name: string): Promise<boolean>;
|
|
268
|
+
createId(name: string, options?: {
|
|
269
|
+
registry?: string;
|
|
270
|
+
}): Promise<string>;
|
|
271
|
+
removeId(id: string): Promise<boolean>;
|
|
272
|
+
renameId(id: string, newName: string): Promise<boolean>;
|
|
273
|
+
backupId(id?: string): Promise<boolean>;
|
|
274
|
+
recoverId(did: string): Promise<string>;
|
|
275
|
+
listNames(): Promise<Record<string, string>>;
|
|
276
|
+
addName(name: string, did: string): Promise<boolean>;
|
|
277
|
+
getName(name: string): Promise<string | null>;
|
|
278
|
+
removeName(name: string): Promise<boolean>;
|
|
279
|
+
resolveDID(did: string, options?: ResolveDIDOptions): Promise<DidCidDocument>;
|
|
280
|
+
createAsset(data: unknown, options?: CreateAssetOptions): Promise<string>;
|
|
281
|
+
listAssets(owner?: string): Promise<string[]>;
|
|
282
|
+
resolveAsset(did: string, options?: ResolveDIDOptions): Promise<unknown | null>;
|
|
283
|
+
updateAsset(did: string, data: Record<string, unknown>): Promise<boolean>;
|
|
284
|
+
encryptMessage(msg: string, receiver: string, options?: EncryptOptions): Promise<string>;
|
|
285
|
+
decryptMessage(did: string): Promise<string>;
|
|
286
|
+
encryptJSON(json: unknown, receiver: string, options?: EncryptOptions): Promise<string>;
|
|
287
|
+
decryptJSON(did: string): Promise<unknown>;
|
|
288
|
+
createGroup(name: string, options?: CreateAssetOptions): Promise<string>;
|
|
289
|
+
getGroup(group: string): Promise<Group | null>;
|
|
290
|
+
addGroupMember(group: string, member: string): Promise<boolean>;
|
|
291
|
+
removeGroupMember(group: string, member: string): Promise<boolean>;
|
|
292
|
+
testGroup(group: string, member?: string): Promise<boolean>;
|
|
293
|
+
listGroups(owner?: string): Promise<string[]>;
|
|
294
|
+
createSchema(schema?: unknown, options?: CreateAssetOptions): Promise<string>;
|
|
295
|
+
getSchema(did: string): Promise<unknown | null>;
|
|
296
|
+
setSchema(did: string, schema: unknown): Promise<boolean>;
|
|
297
|
+
testSchema(did: string): Promise<boolean>;
|
|
298
|
+
listSchemas(owner?: string): Promise<string[]>;
|
|
299
|
+
testAgent(did: string): Promise<boolean>;
|
|
300
|
+
bindCredential(schema: string, subject: string, options?: {
|
|
301
|
+
validFrom?: string;
|
|
302
|
+
validUntil?: string;
|
|
303
|
+
credential?: Record<string, unknown>;
|
|
304
|
+
}): Promise<VerifiableCredential>;
|
|
305
|
+
issueCredential(credential: Partial<VerifiableCredential>, options?: IssueCredentialsOptions): Promise<string>;
|
|
306
|
+
sendCredential(did: string, options?: CreateAssetOptions): Promise<string | null>;
|
|
307
|
+
updateCredential(did: string, credential: VerifiableCredential): Promise<boolean>;
|
|
308
|
+
revokeCredential(did: string): Promise<boolean>;
|
|
309
|
+
listIssued(issuer?: string): Promise<string[]>;
|
|
310
|
+
acceptCredential(did: string): Promise<boolean>;
|
|
311
|
+
getCredential(did: string): Promise<VerifiableCredential | null>;
|
|
312
|
+
removeCredential(did: string): Promise<boolean>;
|
|
313
|
+
listCredentials(id?: string): Promise<string[]>;
|
|
314
|
+
publishCredential(did: string, options?: {
|
|
315
|
+
reveal?: boolean;
|
|
316
|
+
}): Promise<VerifiableCredential | boolean>;
|
|
317
|
+
unpublishCredential(did: string): Promise<string | boolean>;
|
|
318
|
+
createChallenge(challenge?: Challenge, options?: {
|
|
319
|
+
registry?: string;
|
|
320
|
+
validUntil?: string;
|
|
321
|
+
}): Promise<string>;
|
|
322
|
+
createResponse(challengeDid: string, options?: CreateResponseOptions): Promise<string>;
|
|
323
|
+
verifyResponse(responseDid: string, options?: {
|
|
324
|
+
retries?: number;
|
|
325
|
+
delay?: number;
|
|
326
|
+
}): Promise<ChallengeResponse>;
|
|
327
|
+
pollTemplate(): Promise<Poll>;
|
|
328
|
+
createPoll(poll: Poll, options?: CreateAssetOptions): Promise<string>;
|
|
329
|
+
getPoll(pollId: string): Promise<Poll | null>;
|
|
330
|
+
viewPoll(pollId: string): Promise<ViewPollResult>;
|
|
331
|
+
votePoll(pollId: string, vote: number, options?: {
|
|
332
|
+
spoil?: boolean;
|
|
333
|
+
registry?: string;
|
|
334
|
+
validUntil?: string;
|
|
335
|
+
}): Promise<string>;
|
|
336
|
+
updatePoll(ballot: string): Promise<boolean>;
|
|
337
|
+
publishPoll(pollId: string, options?: {
|
|
338
|
+
reveal?: boolean;
|
|
339
|
+
}): Promise<boolean>;
|
|
340
|
+
unpublishPoll(pollId: string): Promise<boolean>;
|
|
341
|
+
createImage(data: Buffer, options?: CreateAssetOptions): Promise<string>;
|
|
342
|
+
updateImage(did: string, data: Buffer): Promise<boolean>;
|
|
343
|
+
getImage(id: string): Promise<ImageAsset | null>;
|
|
344
|
+
testImage(id: string): Promise<boolean>;
|
|
345
|
+
createDocument(data: Buffer, options?: FileAssetOptions): Promise<string>;
|
|
346
|
+
updateDocument(did: string, data: Buffer, options?: FileAssetOptions): Promise<boolean>;
|
|
347
|
+
getDocument(id: string): Promise<FileAsset | null>;
|
|
348
|
+
testDocument(id: string): Promise<boolean>;
|
|
349
|
+
createGroupVault(options?: CreateAssetOptions): Promise<string>;
|
|
350
|
+
getGroupVault(vaultId: string, options?: ResolveDIDOptions): Promise<GroupVault>;
|
|
351
|
+
testGroupVault(vaultId: string, options?: ResolveDIDOptions): Promise<boolean>;
|
|
352
|
+
addGroupVaultMember(vaultId: string, memberId: string): Promise<boolean>;
|
|
353
|
+
removeGroupVaultMember(vaultId: string, memberId: string): Promise<boolean>;
|
|
354
|
+
addGroupVaultItem(vaultId: string, name: string, buffer: Buffer): Promise<boolean>;
|
|
355
|
+
removeGroupVaultItem(vaultId: string, name: string): Promise<boolean>;
|
|
356
|
+
listGroupVaultItems(vaultId: string, options?: ResolveDIDOptions): Promise<Record<string, any>>;
|
|
357
|
+
getGroupVaultItem(vaultId: string, name: string, options?: ResolveDIDOptions): Promise<Buffer | null>;
|
|
358
|
+
createDmail(message: DmailMessage, options?: CreateAssetOptions): Promise<string>;
|
|
359
|
+
updateDmail(did: string, message: DmailMessage): Promise<boolean>;
|
|
360
|
+
fileDmail(did: string, tags: string[]): Promise<boolean>;
|
|
361
|
+
removeDmail(did: string): Promise<boolean>;
|
|
362
|
+
importDmail(did: string): Promise<boolean>;
|
|
363
|
+
getDmailMessage(did: string, options?: ResolveDIDOptions): Promise<DmailMessage | null>;
|
|
364
|
+
listDmail(): Promise<Record<string, DmailItem>>;
|
|
365
|
+
sendDmail(did: string): Promise<string | null>;
|
|
366
|
+
addDmailAttachment(did: string, name: string, buffer: Buffer): Promise<boolean>;
|
|
367
|
+
removeDmailAttachment(did: string, name: string): Promise<boolean>;
|
|
368
|
+
listDmailAttachments(did: string, options?: ResolveDIDOptions): Promise<Record<string, any>>;
|
|
369
|
+
getDmailAttachment(did: string, name: string): Promise<Buffer | null>;
|
|
370
|
+
createNotice(message: NoticeMessage, options: CreateAssetOptions): Promise<string>;
|
|
371
|
+
updateNotice(did: string, message: NoticeMessage): Promise<boolean>;
|
|
372
|
+
refreshNotices(): Promise<boolean>;
|
|
373
|
+
}
|