@idos-network/client 1.0.0-rc.1.0
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 +11 -0
- package/dist/index.d.ts +322 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5633 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
- package/src/enclave/iframe-enclave.ts +237 -0
- package/src/enclave/index.ts +3 -0
- package/src/enclave/metamask-snap-enclave.ts +91 -0
- package/src/enclave/types.ts +44 -0
- package/src/index.ts +472 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
import {
|
|
2
|
+
base64Decode,
|
|
3
|
+
base64Encode,
|
|
4
|
+
hexEncodeSha256Hash,
|
|
5
|
+
utf8Decode,
|
|
6
|
+
utf8Encode,
|
|
7
|
+
} from "@idos-network/core/codecs";
|
|
8
|
+
import {
|
|
9
|
+
type AddWalletParams,
|
|
10
|
+
type GetGrantsParams,
|
|
11
|
+
type ShareableCredential,
|
|
12
|
+
addWallet,
|
|
13
|
+
addWallets,
|
|
14
|
+
createAttribute,
|
|
15
|
+
createCredentialCopy,
|
|
16
|
+
getAccessGrantsOwned,
|
|
17
|
+
getAllCredentials,
|
|
18
|
+
getAttributes,
|
|
19
|
+
getCredentialById,
|
|
20
|
+
getCredentialOwned,
|
|
21
|
+
getGrants,
|
|
22
|
+
getGrantsCount,
|
|
23
|
+
getSharedCredential,
|
|
24
|
+
getUserProfile,
|
|
25
|
+
getWallets,
|
|
26
|
+
hasProfile,
|
|
27
|
+
type idOSDAGSignatureParams,
|
|
28
|
+
removeCredential,
|
|
29
|
+
removeWallet,
|
|
30
|
+
removeWallets,
|
|
31
|
+
requestDAGMessage,
|
|
32
|
+
requestDWGMessage,
|
|
33
|
+
revokeAccessGrant,
|
|
34
|
+
shareCredential,
|
|
35
|
+
} from "@idos-network/core/kwil-actions";
|
|
36
|
+
import {
|
|
37
|
+
type KwilActionClient,
|
|
38
|
+
createClientKwilSigner,
|
|
39
|
+
createWebKwilClient,
|
|
40
|
+
} from "@idos-network/core/kwil-infra";
|
|
41
|
+
import { Store } from "@idos-network/core/store";
|
|
42
|
+
import type {
|
|
43
|
+
DelegatedWriteGrant,
|
|
44
|
+
Wallet,
|
|
45
|
+
idOSCredential,
|
|
46
|
+
idOSGrant,
|
|
47
|
+
idOSUser,
|
|
48
|
+
idOSUserAttribute,
|
|
49
|
+
idOSWallet,
|
|
50
|
+
} from "@idos-network/core/types";
|
|
51
|
+
import { buildInsertableIDOSCredential } from "@idos-network/core/utils";
|
|
52
|
+
import type { KwilSigner } from "@kwilteam/kwil-js";
|
|
53
|
+
import { negate } from "es-toolkit";
|
|
54
|
+
import { every, get } from "es-toolkit/compat";
|
|
55
|
+
import invariant from "tiny-invariant";
|
|
56
|
+
import { type EnclaveOptions, type EnclaveProvider, IframeEnclave } from "./enclave";
|
|
57
|
+
|
|
58
|
+
type Properties<T> = {
|
|
59
|
+
// biome-ignore lint/complexity/noBannedTypes: All functions are to be removed.
|
|
60
|
+
[K in keyof T as Exclude<T[K], Function> extends never ? never : K]: T[K];
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type idOSClient =
|
|
64
|
+
| idOSClientConfiguration
|
|
65
|
+
| idOSClientIdle
|
|
66
|
+
| idOSClientWithUserSigner
|
|
67
|
+
| idOSClientLoggedIn;
|
|
68
|
+
|
|
69
|
+
export class idOSClientConfiguration {
|
|
70
|
+
readonly state: "configuration";
|
|
71
|
+
readonly chainId?: string;
|
|
72
|
+
readonly nodeUrl: string;
|
|
73
|
+
readonly enclaveOptions: Omit<EnclaveOptions, "mode">;
|
|
74
|
+
|
|
75
|
+
constructor(params: {
|
|
76
|
+
chainId?: string;
|
|
77
|
+
nodeUrl: string;
|
|
78
|
+
enclaveOptions: Omit<EnclaveOptions, "mode">;
|
|
79
|
+
}) {
|
|
80
|
+
this.state = "configuration";
|
|
81
|
+
this.chainId = params.chainId;
|
|
82
|
+
this.nodeUrl = params.nodeUrl;
|
|
83
|
+
this.enclaveOptions = params.enclaveOptions;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async createClient(): Promise<idOSClientIdle> {
|
|
87
|
+
return idOSClientIdle.fromConfig(this);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export class idOSClientIdle {
|
|
92
|
+
readonly state: "idle";
|
|
93
|
+
readonly store: Store;
|
|
94
|
+
readonly kwilClient: KwilActionClient;
|
|
95
|
+
readonly enclaveProvider: EnclaveProvider;
|
|
96
|
+
|
|
97
|
+
constructor(store: Store, kwilClient: KwilActionClient, enclaveProvider: EnclaveProvider) {
|
|
98
|
+
this.state = "idle";
|
|
99
|
+
this.store = store;
|
|
100
|
+
this.kwilClient = kwilClient;
|
|
101
|
+
this.enclaveProvider = enclaveProvider;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static async fromConfig(params: idOSClientConfiguration): Promise<idOSClientIdle> {
|
|
105
|
+
const store = new Store(window.localStorage);
|
|
106
|
+
const kwilClient = await createWebKwilClient({
|
|
107
|
+
nodeUrl: params.nodeUrl,
|
|
108
|
+
chainId: params.chainId,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const enclaveProvider = new IframeEnclave({ ...params.enclaveOptions });
|
|
112
|
+
await enclaveProvider.load();
|
|
113
|
+
|
|
114
|
+
return new idOSClientIdle(store, kwilClient, enclaveProvider);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async addressHasProfile(address: string): Promise<boolean> {
|
|
118
|
+
return hasProfile(this.kwilClient, address);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async withUserSigner(signer: Wallet): Promise<idOSClientWithUserSigner> {
|
|
122
|
+
const [kwilSigner, walletIdentifier] = await createClientKwilSigner(
|
|
123
|
+
this.store,
|
|
124
|
+
this.kwilClient,
|
|
125
|
+
signer,
|
|
126
|
+
);
|
|
127
|
+
this.kwilClient.setSigner(kwilSigner);
|
|
128
|
+
|
|
129
|
+
return new idOSClientWithUserSigner(this, signer, kwilSigner, walletIdentifier);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async logOut(): Promise<idOSClientIdle> {
|
|
133
|
+
return this;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export class idOSClientWithUserSigner implements Omit<Properties<idOSClientIdle>, "state"> {
|
|
138
|
+
readonly state: "with-user-signer";
|
|
139
|
+
readonly store: Store;
|
|
140
|
+
readonly kwilClient: KwilActionClient;
|
|
141
|
+
readonly enclaveProvider: EnclaveProvider;
|
|
142
|
+
readonly signer: Wallet;
|
|
143
|
+
readonly kwilSigner: KwilSigner;
|
|
144
|
+
readonly walletIdentifier: string;
|
|
145
|
+
|
|
146
|
+
constructor(
|
|
147
|
+
idOSClientIdle: idOSClientIdle,
|
|
148
|
+
signer: Wallet,
|
|
149
|
+
kwilSigner: KwilSigner,
|
|
150
|
+
walletIdentifier: string,
|
|
151
|
+
) {
|
|
152
|
+
this.state = "with-user-signer";
|
|
153
|
+
this.store = idOSClientIdle.store;
|
|
154
|
+
this.kwilClient = idOSClientIdle.kwilClient;
|
|
155
|
+
this.enclaveProvider = idOSClientIdle.enclaveProvider;
|
|
156
|
+
this.signer = signer;
|
|
157
|
+
this.kwilSigner = kwilSigner;
|
|
158
|
+
this.walletIdentifier = walletIdentifier;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async logOut(): Promise<idOSClientIdle> {
|
|
162
|
+
this.kwilClient.setSigner(undefined);
|
|
163
|
+
return new idOSClientIdle(this.store, this.kwilClient, this.enclaveProvider);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async hasProfile(): Promise<boolean> {
|
|
167
|
+
return hasProfile(this.kwilClient, this.walletIdentifier);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async getUserEncryptionPublicKey(userId: string): Promise<string> {
|
|
171
|
+
await this.enclaveProvider.reconfigure({ mode: "new" });
|
|
172
|
+
const { userEncryptionPublicKey } =
|
|
173
|
+
await this.enclaveProvider.discoverUserEncryptionPublicKey(userId);
|
|
174
|
+
return userEncryptionPublicKey;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async logIn(): Promise<idOSClientLoggedIn> {
|
|
178
|
+
if (!(await this.hasProfile())) throw new Error("User does not have a profile");
|
|
179
|
+
|
|
180
|
+
await this.enclaveProvider.reconfigure({ mode: "existing" });
|
|
181
|
+
const kwilUser = await getUserProfile(this.kwilClient);
|
|
182
|
+
|
|
183
|
+
return new idOSClientLoggedIn(this, kwilUser);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export class idOSClientLoggedIn implements Omit<Properties<idOSClientWithUserSigner>, "state"> {
|
|
188
|
+
readonly state: "logged-in";
|
|
189
|
+
readonly store: Store;
|
|
190
|
+
readonly kwilClient: KwilActionClient;
|
|
191
|
+
readonly enclaveProvider: EnclaveProvider;
|
|
192
|
+
readonly signer: Wallet;
|
|
193
|
+
readonly kwilSigner: KwilSigner;
|
|
194
|
+
readonly walletIdentifier: string;
|
|
195
|
+
readonly user: idOSUser;
|
|
196
|
+
|
|
197
|
+
constructor(idOSClientWithUserSigner: idOSClientWithUserSigner, user: idOSUser) {
|
|
198
|
+
this.state = "logged-in";
|
|
199
|
+
this.store = idOSClientWithUserSigner.store;
|
|
200
|
+
this.kwilClient = idOSClientWithUserSigner.kwilClient;
|
|
201
|
+
this.enclaveProvider = idOSClientWithUserSigner.enclaveProvider;
|
|
202
|
+
this.signer = idOSClientWithUserSigner.signer;
|
|
203
|
+
this.kwilSigner = idOSClientWithUserSigner.kwilSigner;
|
|
204
|
+
this.walletIdentifier = idOSClientWithUserSigner.walletIdentifier;
|
|
205
|
+
this.user = user;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
async logOut(): Promise<idOSClientIdle> {
|
|
209
|
+
this.kwilClient.setSigner(undefined);
|
|
210
|
+
return new idOSClientIdle(this.store, this.kwilClient, this.enclaveProvider);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async requestDWGMessage(params: DelegatedWriteGrant): Promise<string> {
|
|
214
|
+
return requestDWGMessage(this.kwilClient, params);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async removeCredential(id: string): Promise<{ id: string }> {
|
|
218
|
+
return await removeCredential(this.kwilClient, id);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
async getCredentialById(id: string): Promise<idOSCredential | undefined> {
|
|
222
|
+
return getCredentialById(this.kwilClient, id);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async shareCredential(credential: ShareableCredential): Promise<ShareableCredential> {
|
|
226
|
+
return shareCredential(this.kwilClient, credential);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
async getAllCredentials(): Promise<idOSCredential[]> {
|
|
230
|
+
return getAllCredentials(this.kwilClient);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
async getAccessGrantsOwned(): Promise<idOSGrant[]> {
|
|
234
|
+
return getAccessGrantsOwned(this.kwilClient);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
async getCredentialOwned(id: string): Promise<idOSCredential | undefined> {
|
|
238
|
+
return getCredentialOwned(this.kwilClient, id);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
async getAttributes(): Promise<idOSUserAttribute[]> {
|
|
242
|
+
return getAttributes(this.kwilClient);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
async createAttribute(attribute: idOSUserAttribute): Promise<idOSUserAttribute> {
|
|
246
|
+
return createAttribute(this.kwilClient, attribute);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
async getCredentialContentSha256Hash(id: string): Promise<string> {
|
|
250
|
+
const credential = await getCredentialById(this.kwilClient, id);
|
|
251
|
+
|
|
252
|
+
invariant(credential, `"idOSCredential" with id ${id} not found`);
|
|
253
|
+
|
|
254
|
+
await this.enclaveProvider.ready(this.user.id, this.user.recipient_encryption_public_key);
|
|
255
|
+
|
|
256
|
+
const plaintext = await this.enclaveProvider.decrypt(
|
|
257
|
+
base64Decode(credential.content),
|
|
258
|
+
base64Decode(credential.encryptor_public_key),
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
return hexEncodeSha256Hash(plaintext);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
async createCredentialCopy(
|
|
265
|
+
id: string,
|
|
266
|
+
consumerRecipientEncryptionPublicKey: string,
|
|
267
|
+
consumerAddress: string,
|
|
268
|
+
lockedUntil: number,
|
|
269
|
+
): Promise<{ id: string }> {
|
|
270
|
+
const originalCredential = await getCredentialById(this.kwilClient, id);
|
|
271
|
+
invariant(originalCredential, `"idOSCredential" with id ${id} not found`);
|
|
272
|
+
|
|
273
|
+
await this.enclaveProvider.ready(this.user.id, this.user.recipient_encryption_public_key);
|
|
274
|
+
|
|
275
|
+
const decryptedContent = await this.enclaveProvider.decrypt(
|
|
276
|
+
base64Decode(originalCredential.content),
|
|
277
|
+
base64Decode(originalCredential.encryptor_public_key),
|
|
278
|
+
);
|
|
279
|
+
const { content, encryptorPublicKey } = await this.enclaveProvider.encrypt(
|
|
280
|
+
decryptedContent,
|
|
281
|
+
base64Decode(consumerRecipientEncryptionPublicKey),
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
const insertableCredential = {
|
|
285
|
+
...(await buildInsertableIDOSCredential(
|
|
286
|
+
originalCredential.user_id,
|
|
287
|
+
"",
|
|
288
|
+
base64Encode(content),
|
|
289
|
+
consumerRecipientEncryptionPublicKey,
|
|
290
|
+
base64Encode(encryptorPublicKey),
|
|
291
|
+
)),
|
|
292
|
+
grantee_wallet_identifier: consumerAddress,
|
|
293
|
+
locked_until: lockedUntil,
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const copyId = crypto.randomUUID();
|
|
297
|
+
|
|
298
|
+
await createCredentialCopy(this.kwilClient, {
|
|
299
|
+
original_credential_id: originalCredential.id,
|
|
300
|
+
...originalCredential,
|
|
301
|
+
...insertableCredential,
|
|
302
|
+
id: copyId,
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
return { id: copyId };
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
async requestDAGMessage(params: idOSDAGSignatureParams): Promise<string> {
|
|
309
|
+
return requestDAGMessage(this.kwilClient, params);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
async getGrants(params: GetGrantsParams): Promise<{ grants: idOSGrant[]; totalCount: number }> {
|
|
313
|
+
return {
|
|
314
|
+
grants: await getGrants(this.kwilClient, params),
|
|
315
|
+
totalCount: await this.getGrantsCount(),
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
async addWallets(params: AddWalletParams[]): Promise<AddWalletParams[]> {
|
|
320
|
+
return addWallets(this.kwilClient, params);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
async getGrantsCount(): Promise<number> {
|
|
324
|
+
return getGrantsCount(this.kwilClient);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
async getSharedCredential(id: string): Promise<idOSCredential | undefined> {
|
|
328
|
+
return getSharedCredential(this.kwilClient, id);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
async revokeAccessGrant(grantId: string): Promise<{ id: string }> {
|
|
332
|
+
return revokeAccessGrant(this.kwilClient, grantId);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
async addWallet(params: AddWalletParams): Promise<AddWalletParams> {
|
|
336
|
+
return addWallet(this.kwilClient, params);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
async getWallets(): Promise<idOSWallet[]> {
|
|
340
|
+
return getWallets(this.kwilClient);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
async removeWallet(id: string): Promise<{ id: string }> {
|
|
344
|
+
return removeWallet(this.kwilClient, id);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
async removeWallets(ids: string[]): Promise<string[]> {
|
|
348
|
+
return removeWallets(this.kwilClient, ids);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
async filterCredentials(requirements: {
|
|
352
|
+
acceptedIssuers: {
|
|
353
|
+
authPublicKey: string;
|
|
354
|
+
}[];
|
|
355
|
+
publicNotesFieldFilters?: {
|
|
356
|
+
pick: Record<string, unknown[]>;
|
|
357
|
+
omit: Record<string, unknown[]>;
|
|
358
|
+
};
|
|
359
|
+
privateFieldFilters?: {
|
|
360
|
+
pick: Record<string, unknown[]>;
|
|
361
|
+
omit: Record<string, unknown[]>;
|
|
362
|
+
};
|
|
363
|
+
}): Promise<idOSCredential[]> {
|
|
364
|
+
const matchCriteria = (content: Record<string, unknown>, criteria: Record<string, unknown[]>) =>
|
|
365
|
+
every(Object.entries(criteria), ([path, targetSet]) =>
|
|
366
|
+
targetSet.includes(get(content, path)),
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
const credentials = await this.getAllCredentials();
|
|
370
|
+
const originalCredentials = credentials.filter(
|
|
371
|
+
(cred) => !cred.original_id && !!cred.public_notes,
|
|
372
|
+
);
|
|
373
|
+
|
|
374
|
+
invariant(originalCredentials.length, "No original credentials found");
|
|
375
|
+
let result = originalCredentials.filter((cred) => {
|
|
376
|
+
return requirements.acceptedIssuers?.some(
|
|
377
|
+
(issuer) => issuer.authPublicKey === cred.issuer_auth_public_key,
|
|
378
|
+
);
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
const publicNotesFieldFilters = requirements.publicNotesFieldFilters;
|
|
382
|
+
if (publicNotesFieldFilters) {
|
|
383
|
+
result = result.filter((credential) => {
|
|
384
|
+
let publicNotes: Record<string, string>;
|
|
385
|
+
try {
|
|
386
|
+
publicNotes = JSON.parse(credential.public_notes);
|
|
387
|
+
} catch (_) {
|
|
388
|
+
throw new Error(`Credential ${credential.id} has non-JSON public notes".replace("{}`);
|
|
389
|
+
}
|
|
390
|
+
return (
|
|
391
|
+
matchCriteria(publicNotes, publicNotesFieldFilters.pick) &&
|
|
392
|
+
negate(() => matchCriteria(publicNotes, publicNotesFieldFilters.omit))
|
|
393
|
+
);
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
const privateFieldFilters = requirements.privateFieldFilters;
|
|
398
|
+
if (privateFieldFilters) {
|
|
399
|
+
result = await this.enclaveProvider.filterCredentials(result, privateFieldFilters);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
return result;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
async requestAccessGrant(
|
|
406
|
+
credentialId: string,
|
|
407
|
+
{
|
|
408
|
+
consumerEncryptionPublicKey,
|
|
409
|
+
consumerAuthPublicKey,
|
|
410
|
+
}: { consumerEncryptionPublicKey: string; consumerAuthPublicKey: string },
|
|
411
|
+
): Promise<idOSCredential> {
|
|
412
|
+
const credential = await getCredentialById(this.kwilClient, credentialId);
|
|
413
|
+
const contentHash = await this.getCredentialContentSha256Hash(credentialId);
|
|
414
|
+
|
|
415
|
+
invariant(credential, `"idOSCredential" with id ${credentialId} not found`);
|
|
416
|
+
|
|
417
|
+
const plaintextContent = utf8Decode(
|
|
418
|
+
await this.enclaveProvider.decrypt(
|
|
419
|
+
base64Decode(credential.content),
|
|
420
|
+
base64Decode(credential.encryptor_public_key),
|
|
421
|
+
),
|
|
422
|
+
);
|
|
423
|
+
|
|
424
|
+
await this.enclaveProvider.ready(this.user.id, this.user.recipient_encryption_public_key);
|
|
425
|
+
|
|
426
|
+
const { content, encryptorPublicKey } = await this.enclaveProvider.encrypt(
|
|
427
|
+
utf8Encode(plaintextContent),
|
|
428
|
+
base64Decode(consumerEncryptionPublicKey),
|
|
429
|
+
);
|
|
430
|
+
|
|
431
|
+
const insertableCredential = {
|
|
432
|
+
...credential,
|
|
433
|
+
...(await buildInsertableIDOSCredential(
|
|
434
|
+
credential.user_id,
|
|
435
|
+
"",
|
|
436
|
+
base64Encode(content),
|
|
437
|
+
consumerAuthPublicKey,
|
|
438
|
+
base64Encode(encryptorPublicKey),
|
|
439
|
+
)),
|
|
440
|
+
original_credential_id: credential.id,
|
|
441
|
+
id: crypto.randomUUID(),
|
|
442
|
+
grantee_wallet_identifier: consumerAuthPublicKey,
|
|
443
|
+
locked_until: 0,
|
|
444
|
+
content_hash: contentHash,
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
await this.shareCredential(insertableCredential);
|
|
448
|
+
|
|
449
|
+
return insertableCredential;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export type {
|
|
454
|
+
DelegatedWriteGrant,
|
|
455
|
+
idOSCredential,
|
|
456
|
+
idOSGrant,
|
|
457
|
+
idOSUser,
|
|
458
|
+
idOSUserAttribute,
|
|
459
|
+
idOSWallet,
|
|
460
|
+
EnclaveOptions,
|
|
461
|
+
EnclaveProvider,
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
export function createIDOSClient(params: {
|
|
465
|
+
nodeUrl: string;
|
|
466
|
+
enclaveOptions: Omit<EnclaveOptions, "mode">;
|
|
467
|
+
}): idOSClientConfiguration {
|
|
468
|
+
return new idOSClientConfiguration({
|
|
469
|
+
nodeUrl: params.nodeUrl,
|
|
470
|
+
enclaveOptions: params.enclaveOptions,
|
|
471
|
+
});
|
|
472
|
+
}
|