@openwallet-foundation/askar-react-native 0.7.0-alpha-20261028112522 → 0.7.0-alpha-20261028113056

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.
@@ -0,0 +1 @@
1
+ export * from "@openwallet-foundation/askar-shared";
@@ -0,0 +1,619 @@
1
+ import { AeadParams, ArcHandle, AskarError, EncryptedBuffer, EntryListHandle, Jwk, Key, KeyEntryListHandle, LocalKeyHandle, NativeAskar, ScanHandle, SessionHandle, StoreHandle, handleInvalidNullResponse } from "@openwallet-foundation/askar-shared";
2
+ import { NativeModules } from "react-native";
3
+ export * from "@openwallet-foundation/askar-shared";
4
+ // src/serialize.ts
5
+ const serialize = (arg) => {
6
+ switch (typeof arg) {
7
+ case "undefined": return arg;
8
+ case "string": return arg;
9
+ case "boolean": return Number(arg);
10
+ case "number": return arg;
11
+ case "function": return arg;
12
+ case "object":
13
+ if (arg instanceof Date) return arg.valueOf();
14
+ if (arg instanceof Uint8Array) return arg.buffer;
15
+ if (arg instanceof Jwk) return arg.toUint8Array().buffer;
16
+ if (arg instanceof Key) return arg.handle.handle;
17
+ if (arg instanceof StoreHandle || arg instanceof SessionHandle || arg instanceof ScanHandle || arg instanceof ArcHandle) return arg.handle;
18
+ return JSON.stringify(arg);
19
+ default: throw new Error(`Could not serialize value ${arg}`);
20
+ }
21
+ };
22
+ const serializeArguments = (args) => {
23
+ const retVal = {};
24
+ for (const [key, value] of Object.entries(args)) retVal[key] = serialize(value);
25
+ return retVal;
26
+ };
27
+ // src/ReactNativeAskar.ts
28
+ var ReactNativeAskar = class {
29
+ constructor(bindings) {
30
+ this.askar = bindings;
31
+ }
32
+ /**
33
+ * Fetch the error from the native library and return it as a JS error
34
+ *
35
+ * NOTE:
36
+ * Checks whether the error code of the returned error matches the error code that was passed to the function.
37
+ * If it doesn't, we throw an error with the original errorCode, and a custom message explaining we weren't able
38
+ * to retrieve the error message from the native library. This should however not break functionality as long as
39
+ * error codes are used rather than error messages for error handling.
40
+ *
41
+ */
42
+ getAskarError(errorCode) {
43
+ const error = this.getCurrentError();
44
+ if (error.code !== errorCode) return new AskarError({
45
+ code: errorCode,
46
+ message: "Error details have already been overwritten on the native side, unable to retrieve error message for the error"
47
+ });
48
+ return new AskarError(error);
49
+ }
50
+ handleError({ errorCode, value }) {
51
+ if (errorCode === 0) return value;
52
+ throw this.getAskarError(errorCode);
53
+ }
54
+ promisify(method) {
55
+ return new Promise((resolve, reject) => {
56
+ const _cb = ({ errorCode }) => {
57
+ try {
58
+ this.handleError({ errorCode });
59
+ resolve();
60
+ } catch (e) {
61
+ reject(e);
62
+ }
63
+ };
64
+ method(_cb);
65
+ });
66
+ }
67
+ promisifyWithResponse(method) {
68
+ return new Promise((resolve, reject) => {
69
+ const _cb = ({ errorCode, value }) => {
70
+ if (errorCode !== 0) reject(this.getAskarError(errorCode));
71
+ else if (value === void 0) reject(AskarError.customError({ message: "error code was 0 but no value found. This should not occur." }));
72
+ else resolve(value);
73
+ };
74
+ method(_cb);
75
+ });
76
+ }
77
+ version() {
78
+ return handleInvalidNullResponse(this.askar.version({}));
79
+ }
80
+ getCurrentError() {
81
+ const serializedError = handleInvalidNullResponse(this.askar.getCurrentError({}));
82
+ return JSON.parse(serializedError);
83
+ }
84
+ clearCustomLogger() {
85
+ throw new Error("Method not implemented. clearCustomLogger");
86
+ }
87
+ setCustomLogger() {
88
+ throw new Error("Method not implemented. setCustomLogger");
89
+ }
90
+ setDefaultLogger() {
91
+ this.askar.setDefaultLogger({});
92
+ }
93
+ setMaxLogLevel() {
94
+ throw new Error("Method not implemented. setMaxLogLevel");
95
+ }
96
+ argon2DerivePassword(options) {
97
+ const { config, ...rest } = options;
98
+ const buf = handleInvalidNullResponse(this.handleError(this.askar.argon2DerivePassword({
99
+ ...serializeArguments(rest),
100
+ ...config && { config }
101
+ })));
102
+ return new Uint8Array(buf);
103
+ }
104
+ entryListCount(options) {
105
+ const serializedOptions = serializeArguments(options);
106
+ return handleInvalidNullResponse(this.handleError(this.askar.entryListCount(serializedOptions)));
107
+ }
108
+ entryListFree(options) {
109
+ const serializedOptions = serializeArguments(options);
110
+ this.handleError(this.askar.entryListFree(serializedOptions));
111
+ }
112
+ entryListGetCategory(options) {
113
+ const serializedOptions = serializeArguments(options);
114
+ return handleInvalidNullResponse(this.handleError(this.askar.entryListGetCategory(serializedOptions)));
115
+ }
116
+ entryListGetName(options) {
117
+ const serializedOptions = serializeArguments(options);
118
+ return handleInvalidNullResponse(this.handleError(this.askar.entryListGetName(serializedOptions)));
119
+ }
120
+ entryListGetTags(options) {
121
+ const serializedOptions = serializeArguments(options);
122
+ return this.handleError(this.askar.entryListGetTags(serializedOptions));
123
+ }
124
+ entryListGetValue(options) {
125
+ const serializedOptions = serializeArguments(options);
126
+ const buf = handleInvalidNullResponse(this.handleError(this.askar.entryListGetValue(serializedOptions)));
127
+ return new Uint8Array(buf);
128
+ }
129
+ keyAeadDecrypt(options) {
130
+ const serializedOptions = serializeArguments(options);
131
+ const buf = handleInvalidNullResponse(this.handleError(this.askar.keyAeadDecrypt(serializedOptions)));
132
+ return new Uint8Array(buf);
133
+ }
134
+ keyAeadEncrypt(options) {
135
+ const serializedOptions = serializeArguments(options);
136
+ const ret = this.handleError(this.askar.keyAeadEncrypt(serializedOptions));
137
+ const { buffer, noncePos, tagPos } = handleInvalidNullResponse(ret);
138
+ return new EncryptedBuffer({
139
+ tagPos,
140
+ noncePos,
141
+ buffer: new Uint8Array(buffer)
142
+ });
143
+ }
144
+ keyAeadGetPadding(options) {
145
+ const serializedOptions = serializeArguments(options);
146
+ return handleInvalidNullResponse(this.handleError(this.askar.keyAeadGetPadding(serializedOptions)));
147
+ }
148
+ keyAeadGetParams(options) {
149
+ const serializedOptions = serializeArguments(options);
150
+ const ret = this.handleError(this.askar.keyAeadGetParams(serializedOptions));
151
+ const { tagLength, nonceLength } = handleInvalidNullResponse(ret);
152
+ return new AeadParams({
153
+ nonceLength,
154
+ tagLength
155
+ });
156
+ }
157
+ keyAeadRandomNonce(options) {
158
+ const serializedOptions = serializeArguments(options);
159
+ const buf = handleInvalidNullResponse(this.handleError(this.askar.keyAeadRandomNonce(serializedOptions)));
160
+ return new Uint8Array(buf);
161
+ }
162
+ keyConvert(options) {
163
+ const serializedOptions = serializeArguments(options);
164
+ const handle = handleInvalidNullResponse(this.handleError(this.askar.keyConvert(serializedOptions)));
165
+ return new LocalKeyHandle(handle);
166
+ }
167
+ keyCryptoBox(options) {
168
+ const serializedOptions = serializeArguments(options);
169
+ const buf = handleInvalidNullResponse(this.handleError(this.askar.keyCryptoBox(serializedOptions)));
170
+ return new Uint8Array(buf);
171
+ }
172
+ keyCryptoBoxOpen(options) {
173
+ const serializedOptions = serializeArguments(options);
174
+ const buf = handleInvalidNullResponse(this.handleError(this.askar.keyCryptoBoxOpen(serializedOptions)));
175
+ return new Uint8Array(buf);
176
+ }
177
+ keyCryptoBoxRandomNonce() {
178
+ const buf = handleInvalidNullResponse(this.handleError(this.askar.keyCryptoBoxRandomNonce({})));
179
+ return new Uint8Array(buf);
180
+ }
181
+ keyCryptoBoxSeal(options) {
182
+ const serializedOptions = serializeArguments(options);
183
+ const buf = handleInvalidNullResponse(this.handleError(this.askar.keyCryptoBoxSeal(serializedOptions)));
184
+ return new Uint8Array(buf);
185
+ }
186
+ keyCryptoBoxSealOpen(options) {
187
+ const serializedOptions = serializeArguments(options);
188
+ const buf = handleInvalidNullResponse(this.handleError(this.askar.keyCryptoBoxSealOpen(serializedOptions)));
189
+ return new Uint8Array(buf);
190
+ }
191
+ keyDeriveEcdh1pu(options) {
192
+ const serializedOptions = serializeArguments(options);
193
+ const handle = handleInvalidNullResponse(this.handleError(this.askar.keyDeriveEcdh1pu(serializedOptions)));
194
+ return new LocalKeyHandle(handle);
195
+ }
196
+ keyDeriveEcdhEs(options) {
197
+ const serializedOptions = serializeArguments(options);
198
+ const handle = handleInvalidNullResponse(this.handleError(this.askar.keyDeriveEcdhEs(serializedOptions)));
199
+ return new LocalKeyHandle(handle);
200
+ }
201
+ keyEntryListCount(options) {
202
+ const serializedOptions = serializeArguments(options);
203
+ return handleInvalidNullResponse(this.handleError(this.askar.keyEntryListCount(serializedOptions)));
204
+ }
205
+ keyEntryListFree(options) {
206
+ const serializedOptions = serializeArguments(options);
207
+ this.handleError(this.askar.keyEntryListFree(serializedOptions));
208
+ }
209
+ keyEntryListGetAlgorithm(options) {
210
+ const serializedOptions = serializeArguments(options);
211
+ return handleInvalidNullResponse(this.handleError(this.askar.keyEntryListGetAlgorithm(serializedOptions)));
212
+ }
213
+ keyEntryListGetMetadata(options) {
214
+ const serializedOptions = serializeArguments(options);
215
+ return this.handleError(this.askar.keyEntryListGetMetadata(serializedOptions));
216
+ }
217
+ keyEntryListGetName(options) {
218
+ const serializedOptions = serializeArguments(options);
219
+ return handleInvalidNullResponse(this.handleError(this.askar.keyEntryListGetName(serializedOptions)));
220
+ }
221
+ keyEntryListGetTags(options) {
222
+ const serializedOptions = serializeArguments(options);
223
+ return this.handleError(this.askar.keyEntryListGetTags(serializedOptions));
224
+ }
225
+ keyEntryListLoadLocal(options) {
226
+ const serializedOptions = serializeArguments(options);
227
+ const handle = handleInvalidNullResponse(this.handleError(this.askar.keyEntryListLoadLocal(serializedOptions)));
228
+ return new LocalKeyHandle(handle);
229
+ }
230
+ keyFree(options) {
231
+ const serializedOptions = serializeArguments(options);
232
+ this.handleError(this.askar.keyFree(serializedOptions));
233
+ }
234
+ keyFromJwk(options) {
235
+ const serializedOptions = serializeArguments(options);
236
+ const handle = handleInvalidNullResponse(this.handleError(this.askar.keyFromJwk(serializedOptions)));
237
+ return new LocalKeyHandle(handle);
238
+ }
239
+ keyFromKeyExchange(options) {
240
+ const serializedOptions = serializeArguments(options);
241
+ const handle = handleInvalidNullResponse(this.handleError(this.askar.keyFromKeyExchange(serializedOptions)));
242
+ return new LocalKeyHandle(handle);
243
+ }
244
+ keyFromPublicBytes(options) {
245
+ const serializedOptions = serializeArguments(options);
246
+ const handle = handleInvalidNullResponse(this.handleError(this.askar.keyFromPublicBytes(serializedOptions)));
247
+ return new LocalKeyHandle(handle);
248
+ }
249
+ keyFromSecretBytes(options) {
250
+ const serializedOptions = serializeArguments(options);
251
+ const handle = handleInvalidNullResponse(this.handleError(this.askar.keyFromSecretBytes(serializedOptions)));
252
+ return new LocalKeyHandle(handle);
253
+ }
254
+ keyFromSeed(options) {
255
+ const serializedOptions = serializeArguments(options);
256
+ const handle = handleInvalidNullResponse(this.handleError(this.askar.keyFromSeed(serializedOptions)));
257
+ return new LocalKeyHandle(handle);
258
+ }
259
+ keyGenerate(options) {
260
+ const serializedOptions = serializeArguments(options);
261
+ const handle = handleInvalidNullResponse(this.handleError(this.askar.keyGenerate(serializedOptions)));
262
+ return new LocalKeyHandle(handleInvalidNullResponse(handle));
263
+ }
264
+ keyGetAlgorithm(options) {
265
+ const serializedOptions = serializeArguments(options);
266
+ return handleInvalidNullResponse(this.handleError(this.askar.keyGetAlgorithm(serializedOptions)));
267
+ }
268
+ keyGetEphemeral(options) {
269
+ const serializedOptions = serializeArguments(options);
270
+ return handleInvalidNullResponse(this.handleError(this.askar.keyGetEphemeral(serializedOptions)));
271
+ }
272
+ keyGetJwkPublic(options) {
273
+ const serializedOptions = serializeArguments(options);
274
+ return handleInvalidNullResponse(this.handleError(this.askar.keyGetJwkPublic(serializedOptions)));
275
+ }
276
+ keyGetJwkSecret(options) {
277
+ const serializedOptions = serializeArguments(options);
278
+ const buf = handleInvalidNullResponse(this.handleError(this.askar.keyGetJwkSecret(serializedOptions)));
279
+ return new Uint8Array(buf);
280
+ }
281
+ keyGetJwkThumbprint(options) {
282
+ const serializedOptions = serializeArguments(options);
283
+ return handleInvalidNullResponse(this.handleError(this.askar.keyGetJwkThumbprint(serializedOptions)));
284
+ }
285
+ keyGetPublicBytes(options) {
286
+ const serializedOptions = serializeArguments(options);
287
+ const buf = handleInvalidNullResponse(this.handleError(this.askar.keyGetPublicBytes(serializedOptions)));
288
+ return new Uint8Array(buf);
289
+ }
290
+ keyGetSupportedBackends() {
291
+ const stringListHandle = handleInvalidNullResponse(this.handleError(this.askar.keyGetSupportedBackends({})));
292
+ return this.stringListToArray(stringListHandle);
293
+ }
294
+ keyGetSecretBytes(options) {
295
+ const serializedOptions = serializeArguments(options);
296
+ const buf = handleInvalidNullResponse(this.handleError(this.askar.keyGetSecretBytes(serializedOptions)));
297
+ return new Uint8Array(buf);
298
+ }
299
+ keySignMessage(options) {
300
+ const serializedOptions = serializeArguments(options);
301
+ const buf = handleInvalidNullResponse(this.handleError(this.askar.keySignMessage(serializedOptions)));
302
+ return new Uint8Array(buf);
303
+ }
304
+ keyUnwrapKey(options) {
305
+ const serializedOptions = serializeArguments(options);
306
+ const handle = handleInvalidNullResponse(this.handleError(this.askar.keyUnwrapKey(serializedOptions)));
307
+ return new LocalKeyHandle(handle);
308
+ }
309
+ keyVerifySignature(options) {
310
+ const serializedOptions = serializeArguments(options);
311
+ return !!this.handleError(this.askar.keyVerifySignature(serializedOptions));
312
+ }
313
+ keyWrapKey(options) {
314
+ const serializedOptions = serializeArguments(options);
315
+ const ret = this.handleError(this.askar.keyWrapKey(serializedOptions));
316
+ const { buffer, noncePos, tagPos } = handleInvalidNullResponse(ret);
317
+ return new EncryptedBuffer({
318
+ tagPos,
319
+ noncePos,
320
+ buffer: new Uint8Array(buffer)
321
+ });
322
+ }
323
+ scanFree(options) {
324
+ const serializedOptions = serializeArguments(options);
325
+ this.handleError(this.askar.scanFree(serializedOptions));
326
+ }
327
+ async scanNext(options) {
328
+ const serializedOptions = serializeArguments(options);
329
+ const handle = await this.promisifyWithResponse((cb) => this.handleError(this.askar.scanNext({
330
+ cb,
331
+ ...serializedOptions
332
+ })));
333
+ return EntryListHandle.fromHandle(handle);
334
+ }
335
+ async scanStart(options) {
336
+ const { category, storeHandle, limit, offset, profile, tagFilter, orderBy, descending } = serializeArguments(options);
337
+ const handle = await this.promisifyWithResponse((cb) => this.handleError(this.askar.scanStart({
338
+ cb,
339
+ category,
340
+ storeHandle,
341
+ offset: offset || 0,
342
+ limit: limit || -1,
343
+ orderBy,
344
+ descending,
345
+ profile,
346
+ tagFilter
347
+ })));
348
+ return ScanHandle.fromHandle(handle);
349
+ }
350
+ sessionClose(options) {
351
+ const serializedOptions = serializeArguments(options);
352
+ return this.promisify((cb) => this.handleError(this.askar.sessionClose({
353
+ cb,
354
+ ...serializedOptions
355
+ })));
356
+ }
357
+ async sessionCount(options) {
358
+ const serializedOptions = serializeArguments(options);
359
+ const response = await this.promisifyWithResponse((cb) => this.handleError(this.askar.sessionCount({
360
+ cb,
361
+ ...serializedOptions
362
+ })));
363
+ return handleInvalidNullResponse(response);
364
+ }
365
+ async sessionFetch(options) {
366
+ const serializedOptions = serializeArguments(options);
367
+ const handle = await this.promisifyWithResponse((cb) => this.handleError(this.askar.sessionFetch({
368
+ cb,
369
+ ...serializedOptions
370
+ })));
371
+ return EntryListHandle.fromHandle(handle);
372
+ }
373
+ async sessionFetchAll(options) {
374
+ const { category, sessionHandle, forUpdate, limit, tagFilter, descending, orderBy } = serializeArguments(options);
375
+ const handle = await this.promisifyWithResponse((cb) => this.handleError(this.askar.sessionFetchAll({
376
+ cb,
377
+ category,
378
+ sessionHandle,
379
+ forUpdate,
380
+ limit: limit || -1,
381
+ tagFilter,
382
+ orderBy,
383
+ descending
384
+ })));
385
+ return EntryListHandle.fromHandle(handle);
386
+ }
387
+ async sessionFetchAllKeys(options) {
388
+ const { sessionHandle, algorithm, forUpdate, limit, thumbprint, tagFilter } = serializeArguments(options);
389
+ const handle = await this.promisifyWithResponse((cb) => this.handleError(this.askar.sessionFetchAllKeys({
390
+ cb,
391
+ sessionHandle,
392
+ algorithm,
393
+ forUpdate: forUpdate || -1,
394
+ limit: limit || -1,
395
+ thumbprint,
396
+ tagFilter
397
+ })));
398
+ return KeyEntryListHandle.fromHandle(handle);
399
+ }
400
+ async sessionFetchKey(options) {
401
+ const serializedOptions = serializeArguments(options);
402
+ const handle = await this.promisifyWithResponse((cb) => this.handleError(this.askar.sessionFetchKey({
403
+ cb,
404
+ ...serializedOptions
405
+ })));
406
+ return KeyEntryListHandle.fromHandle(handle);
407
+ }
408
+ sessionInsertKey(options) {
409
+ const { sessionHandle, name, localKeyHandle, expiryMs, metadata, tags } = serializeArguments(options);
410
+ return this.promisify((cb) => this.handleError(this.askar.sessionInsertKey({
411
+ cb,
412
+ sessionHandle,
413
+ name,
414
+ localKeyHandle,
415
+ expiryMs: expiryMs || -1,
416
+ metadata,
417
+ tags
418
+ })));
419
+ }
420
+ async sessionRemoveAll(options) {
421
+ const serializedOptions = serializeArguments(options);
422
+ const response = await this.promisifyWithResponse((cb) => this.handleError(this.askar.sessionRemoveAll({
423
+ cb,
424
+ ...serializedOptions
425
+ })));
426
+ return handleInvalidNullResponse(response);
427
+ }
428
+ sessionRemoveKey(options) {
429
+ const serializedOptions = serializeArguments(options);
430
+ return this.promisify((cb) => this.handleError(this.askar.sessionRemoveKey({
431
+ cb,
432
+ ...serializedOptions
433
+ })));
434
+ }
435
+ async sessionStart(options) {
436
+ const serializedOptions = serializeArguments(options);
437
+ const handle = await this.promisifyWithResponse((cb) => this.handleError(this.askar.sessionStart({
438
+ cb,
439
+ ...serializedOptions
440
+ })));
441
+ return SessionHandle.fromHandle(handle);
442
+ }
443
+ sessionUpdate(options) {
444
+ const { category, name, operation, sessionHandle, expiryMs, tags, value } = serializeArguments(options);
445
+ return this.promisify((cb) => this.handleError(this.askar.sessionUpdate({
446
+ cb,
447
+ category,
448
+ name,
449
+ operation,
450
+ sessionHandle,
451
+ expiryMs: expiryMs || -1,
452
+ tags,
453
+ value
454
+ })));
455
+ }
456
+ sessionUpdateKey(options) {
457
+ const serializedOptions = serializeArguments({
458
+ ...options,
459
+ expiryMs: options.expiryMs ?? -1
460
+ });
461
+ return this.promisify((cb) => this.handleError(this.askar.sessionUpdateKey({
462
+ cb,
463
+ ...serializedOptions
464
+ })));
465
+ }
466
+ storeClose(options) {
467
+ const serializedOptions = serializeArguments(options);
468
+ return this.promisify((cb) => this.handleError(this.askar.storeClose({
469
+ cb,
470
+ ...serializedOptions
471
+ })));
472
+ }
473
+ async storeCopyTo(options) {
474
+ const serializedOptions = serializeArguments(options);
475
+ const handle = await this.promisifyWithResponse((cb) => {
476
+ this.handleError(this.askar.storeCopy({
477
+ cb,
478
+ ...serializedOptions
479
+ }));
480
+ });
481
+ return StoreHandle.fromHandle(handle);
482
+ }
483
+ async storeCreateProfile(options) {
484
+ const serializedOptions = serializeArguments(options);
485
+ const response = await this.promisifyWithResponse((cb) => this.handleError(this.askar.storeCreateProfile({
486
+ cb,
487
+ ...serializedOptions
488
+ })));
489
+ return handleInvalidNullResponse(response);
490
+ }
491
+ storeGenerateRawKey(options) {
492
+ const serializedOptions = serializeArguments(options);
493
+ return handleInvalidNullResponse(this.handleError(this.askar.storeGenerateRawKey(serializedOptions)));
494
+ }
495
+ async storeGetProfileName(options) {
496
+ const serializedOptions = serializeArguments(options);
497
+ const response = await this.promisifyWithResponse((cb) => this.handleError(this.askar.storeGetProfileName({
498
+ cb,
499
+ ...serializedOptions
500
+ })));
501
+ return handleInvalidNullResponse(response);
502
+ }
503
+ async storeGetDefaultProfile(options) {
504
+ const serializedOptions = serializeArguments(options);
505
+ const response = await this.promisifyWithResponse((cb) => this.handleError(this.askar.storeGetDefaultProfile({
506
+ cb,
507
+ ...serializedOptions
508
+ })));
509
+ return handleInvalidNullResponse(response);
510
+ }
511
+ async storeListProfiles(options) {
512
+ const serializedOptions = serializeArguments(options);
513
+ const stringListHandle = handleInvalidNullResponse(await this.promisifyWithResponse((cb) => this.handleError(this.askar.storeListProfiles({
514
+ cb,
515
+ ...serializedOptions
516
+ }))));
517
+ return this.stringListToArray(stringListHandle);
518
+ }
519
+ async storeListScans(options) {
520
+ const serializedOptions = serializeArguments(options);
521
+ const handles = await this.promisifyWithResponse((cb) => this.handleError(this.askar.storeListScans({
522
+ cb,
523
+ ...serializedOptions
524
+ })));
525
+ return handleInvalidNullResponse(handles).map((handle) => ScanHandle.fromHandle(handle));
526
+ }
527
+ async storeListSessions(options) {
528
+ const serializedOptions = serializeArguments(options);
529
+ const handles = await this.promisifyWithResponse((cb) => this.handleError(this.askar.storeListSessions({
530
+ cb,
531
+ ...serializedOptions
532
+ })));
533
+ return handleInvalidNullResponse(handles).map((handle) => SessionHandle.fromHandle(handle));
534
+ }
535
+ stringListToArray(stringListHandle) {
536
+ const items = [];
537
+ const count = this.handleError(this.askar.stringListCount({ stringListHandle }));
538
+ for (let index = 0; index < count; index++) items.push(this.handleError(this.askar.stringListGetItem({
539
+ stringListHandle,
540
+ index
541
+ })));
542
+ this.handleError(this.askar.stringListFree({ stringListHandle }));
543
+ return items;
544
+ }
545
+ async storeOpen(options) {
546
+ const serializedOptions = serializeArguments(options);
547
+ const handle = await this.promisifyWithResponse((cb) => this.handleError(this.askar.storeOpen({
548
+ cb,
549
+ ...serializedOptions
550
+ })));
551
+ return StoreHandle.fromHandle(handle);
552
+ }
553
+ async storeProvision(options) {
554
+ const serializedOptions = serializeArguments(options);
555
+ const handle = await this.promisifyWithResponse((cb) => this.handleError(this.askar.storeProvision({
556
+ cb,
557
+ ...serializedOptions
558
+ })));
559
+ return StoreHandle.fromHandle(handle);
560
+ }
561
+ storeRekey(options) {
562
+ const serializedOptions = serializeArguments(options);
563
+ return this.promisify((cb) => this.handleError(this.askar.storeRekey({
564
+ cb,
565
+ ...serializedOptions
566
+ })));
567
+ }
568
+ async storeRemove(options) {
569
+ const serializedOptions = serializeArguments(options);
570
+ const response = await this.promisifyWithResponse((cb) => this.handleError(this.askar.storeRemove({
571
+ cb,
572
+ ...serializedOptions
573
+ })));
574
+ return handleInvalidNullResponse(response);
575
+ }
576
+ async storeRemoveProfile(options) {
577
+ const serializedOptions = serializeArguments(options);
578
+ const response = await this.promisifyWithResponse((cb) => this.handleError(this.askar.storeRemoveProfile({
579
+ cb,
580
+ ...serializedOptions
581
+ })));
582
+ return handleInvalidNullResponse(response);
583
+ }
584
+ async storeRenameProfile(options) {
585
+ const serializedOptions = serializeArguments(options);
586
+ const response = await this.promisifyWithResponse((cb) => this.handleError(this.askar.storeRenameProfile({
587
+ cb,
588
+ ...serializedOptions
589
+ })));
590
+ return handleInvalidNullResponse(response);
591
+ }
592
+ async storeCopyProfile(options) {
593
+ const serializedOptions = serializeArguments(options);
594
+ return this.promisify((cb) => this.handleError(this.askar.storeCopyProfile({
595
+ cb,
596
+ ...serializedOptions
597
+ })));
598
+ }
599
+ async storeSetDefaultProfile(options) {
600
+ const serializedOptions = serializeArguments(options);
601
+ return this.promisify((cb) => this.handleError(this.askar.storeSetDefaultProfile({
602
+ cb,
603
+ ...serializedOptions
604
+ })));
605
+ }
606
+ async migrateIndySdk(options) {
607
+ const serializedOptions = serializeArguments(options);
608
+ return this.promisify((cb) => this.handleError(this.askar.migrateIndySdk({
609
+ cb,
610
+ ...serializedOptions
611
+ })));
612
+ }
613
+ };
614
+ // src/index.ts
615
+ if (!NativeModules.Askar.install()) throw Error("Unable to install the turboModule: askar");
616
+ if (!_askar) throw Error("_askar has not been exposed on global. Something went wrong while installing the turboModule");
617
+ NativeAskar.register(new ReactNativeAskar(_askar));
618
+
619
+ //# sourceMappingURL=index.mjs.map