@learncard/didkit-plugin 1.0.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.
@@ -0,0 +1,849 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var src_exports = {};
23
+ __export(src_exports, {
24
+ getDidKitPlugin: () => getDidKitPlugin
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+
28
+ // src/didkit/pkg/didkit_wasm.js
29
+ var wasm;
30
+ var heap = new Array(32).fill(void 0);
31
+ heap.push(void 0, null, true, false);
32
+ function getObject(idx) {
33
+ return heap[idx];
34
+ }
35
+ __name(getObject, "getObject");
36
+ var heap_next = heap.length;
37
+ function dropObject(idx) {
38
+ if (idx < 36)
39
+ return;
40
+ heap[idx] = heap_next;
41
+ heap_next = idx;
42
+ }
43
+ __name(dropObject, "dropObject");
44
+ function takeObject(idx) {
45
+ const ret = getObject(idx);
46
+ dropObject(idx);
47
+ return ret;
48
+ }
49
+ __name(takeObject, "takeObject");
50
+ var cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
51
+ cachedTextDecoder.decode();
52
+ var cachedUint8Memory0 = new Uint8Array();
53
+ function getUint8Memory0() {
54
+ if (cachedUint8Memory0.byteLength === 0) {
55
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
56
+ }
57
+ return cachedUint8Memory0;
58
+ }
59
+ __name(getUint8Memory0, "getUint8Memory0");
60
+ function getStringFromWasm0(ptr, len) {
61
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
62
+ }
63
+ __name(getStringFromWasm0, "getStringFromWasm0");
64
+ function addHeapObject(obj) {
65
+ if (heap_next === heap.length)
66
+ heap.push(heap.length + 1);
67
+ const idx = heap_next;
68
+ heap_next = heap[idx];
69
+ heap[idx] = obj;
70
+ return idx;
71
+ }
72
+ __name(addHeapObject, "addHeapObject");
73
+ var WASM_VECTOR_LEN = 0;
74
+ var cachedTextEncoder = new TextEncoder("utf-8");
75
+ var encodeString = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
76
+ return cachedTextEncoder.encodeInto(arg, view);
77
+ } : function(arg, view) {
78
+ const buf = cachedTextEncoder.encode(arg);
79
+ view.set(buf);
80
+ return {
81
+ read: arg.length,
82
+ written: buf.length
83
+ };
84
+ };
85
+ function passStringToWasm0(arg, malloc, realloc) {
86
+ if (realloc === void 0) {
87
+ const buf = cachedTextEncoder.encode(arg);
88
+ const ptr2 = malloc(buf.length);
89
+ getUint8Memory0().subarray(ptr2, ptr2 + buf.length).set(buf);
90
+ WASM_VECTOR_LEN = buf.length;
91
+ return ptr2;
92
+ }
93
+ let len = arg.length;
94
+ let ptr = malloc(len);
95
+ const mem = getUint8Memory0();
96
+ let offset = 0;
97
+ for (; offset < len; offset++) {
98
+ const code = arg.charCodeAt(offset);
99
+ if (code > 127)
100
+ break;
101
+ mem[ptr + offset] = code;
102
+ }
103
+ if (offset !== len) {
104
+ if (offset !== 0) {
105
+ arg = arg.slice(offset);
106
+ }
107
+ ptr = realloc(ptr, len, len = offset + arg.length * 3);
108
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
109
+ const ret = encodeString(arg, view);
110
+ offset += ret.written;
111
+ }
112
+ WASM_VECTOR_LEN = offset;
113
+ return ptr;
114
+ }
115
+ __name(passStringToWasm0, "passStringToWasm0");
116
+ function isLikeNone(x) {
117
+ return x === void 0 || x === null;
118
+ }
119
+ __name(isLikeNone, "isLikeNone");
120
+ var cachedInt32Memory0 = new Int32Array();
121
+ function getInt32Memory0() {
122
+ if (cachedInt32Memory0.byteLength === 0) {
123
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
124
+ }
125
+ return cachedInt32Memory0;
126
+ }
127
+ __name(getInt32Memory0, "getInt32Memory0");
128
+ function debugString(val) {
129
+ const type = typeof val;
130
+ if (type == "number" || type == "boolean" || val == null) {
131
+ return `${val}`;
132
+ }
133
+ if (type == "string") {
134
+ return `"${val}"`;
135
+ }
136
+ if (type == "symbol") {
137
+ const description = val.description;
138
+ if (description == null) {
139
+ return "Symbol";
140
+ } else {
141
+ return `Symbol(${description})`;
142
+ }
143
+ }
144
+ if (type == "function") {
145
+ const name = val.name;
146
+ if (typeof name == "string" && name.length > 0) {
147
+ return `Function(${name})`;
148
+ } else {
149
+ return "Function";
150
+ }
151
+ }
152
+ if (Array.isArray(val)) {
153
+ const length = val.length;
154
+ let debug = "[";
155
+ if (length > 0) {
156
+ debug += debugString(val[0]);
157
+ }
158
+ for (let i = 1; i < length; i++) {
159
+ debug += ", " + debugString(val[i]);
160
+ }
161
+ debug += "]";
162
+ return debug;
163
+ }
164
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
165
+ let className;
166
+ if (builtInMatches.length > 1) {
167
+ className = builtInMatches[1];
168
+ } else {
169
+ return toString.call(val);
170
+ }
171
+ if (className == "Object") {
172
+ try {
173
+ return "Object(" + JSON.stringify(val) + ")";
174
+ } catch (_) {
175
+ return "Object";
176
+ }
177
+ }
178
+ if (val instanceof Error) {
179
+ return `${val.name}: ${val.message}
180
+ ${val.stack}`;
181
+ }
182
+ return className;
183
+ }
184
+ __name(debugString, "debugString");
185
+ function makeMutClosure(arg0, arg1, dtor, f) {
186
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
187
+ const real = /* @__PURE__ */ __name((...args) => {
188
+ state.cnt++;
189
+ const a = state.a;
190
+ state.a = 0;
191
+ try {
192
+ return f(a, state.b, ...args);
193
+ } finally {
194
+ if (--state.cnt === 0) {
195
+ wasm.__wbindgen_export_2.get(state.dtor)(a, state.b);
196
+ } else {
197
+ state.a = a;
198
+ }
199
+ }
200
+ }, "real");
201
+ real.original = state;
202
+ return real;
203
+ }
204
+ __name(makeMutClosure, "makeMutClosure");
205
+ function __wbg_adapter_26(arg0, arg1, arg2) {
206
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hf6251ee6687a20b8(arg0, arg1, addHeapObject(arg2));
207
+ }
208
+ __name(__wbg_adapter_26, "__wbg_adapter_26");
209
+ function didResolver(did, input_metadata) {
210
+ const ptr0 = passStringToWasm0(did, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
211
+ const len0 = WASM_VECTOR_LEN;
212
+ const ptr1 = passStringToWasm0(input_metadata, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
213
+ const len1 = WASM_VECTOR_LEN;
214
+ const ret = wasm.didResolver(ptr0, len0, ptr1, len1);
215
+ return takeObject(ret);
216
+ }
217
+ __name(didResolver, "didResolver");
218
+ function resolveDID(did, input_metadata) {
219
+ const ptr0 = passStringToWasm0(did, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
220
+ const len0 = WASM_VECTOR_LEN;
221
+ const ptr1 = passStringToWasm0(input_metadata, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
222
+ const len1 = WASM_VECTOR_LEN;
223
+ const ret = wasm.resolveDID(ptr0, len0, ptr1, len1);
224
+ return takeObject(ret);
225
+ }
226
+ __name(resolveDID, "resolveDID");
227
+ function passArray8ToWasm0(arg, malloc) {
228
+ const ptr = malloc(arg.length * 1);
229
+ getUint8Memory0().set(arg, ptr / 1);
230
+ WASM_VECTOR_LEN = arg.length;
231
+ return ptr;
232
+ }
233
+ __name(passArray8ToWasm0, "passArray8ToWasm0");
234
+ function generateEd25519KeyFromBytes(bytes) {
235
+ try {
236
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
237
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
238
+ const len0 = WASM_VECTOR_LEN;
239
+ wasm.generateEd25519KeyFromBytes(retptr, ptr0, len0);
240
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
241
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
242
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
243
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
244
+ var ptr1 = r0;
245
+ var len1 = r1;
246
+ if (r3) {
247
+ ptr1 = 0;
248
+ len1 = 0;
249
+ throw takeObject(r2);
250
+ }
251
+ return getStringFromWasm0(ptr1, len1);
252
+ } finally {
253
+ wasm.__wbindgen_add_to_stack_pointer(16);
254
+ wasm.__wbindgen_free(ptr1, len1);
255
+ }
256
+ }
257
+ __name(generateEd25519KeyFromBytes, "generateEd25519KeyFromBytes");
258
+ function generateSecp256k1KeyFromBytes(bytes) {
259
+ try {
260
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
261
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
262
+ const len0 = WASM_VECTOR_LEN;
263
+ wasm.generateSecp256k1KeyFromBytes(retptr, ptr0, len0);
264
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
265
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
266
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
267
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
268
+ var ptr1 = r0;
269
+ var len1 = r1;
270
+ if (r3) {
271
+ ptr1 = 0;
272
+ len1 = 0;
273
+ throw takeObject(r2);
274
+ }
275
+ return getStringFromWasm0(ptr1, len1);
276
+ } finally {
277
+ wasm.__wbindgen_add_to_stack_pointer(16);
278
+ wasm.__wbindgen_free(ptr1, len1);
279
+ }
280
+ }
281
+ __name(generateSecp256k1KeyFromBytes, "generateSecp256k1KeyFromBytes");
282
+ function keyToDID(method_pattern, jwk) {
283
+ try {
284
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
285
+ const ptr0 = passStringToWasm0(method_pattern, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
286
+ const len0 = WASM_VECTOR_LEN;
287
+ const ptr1 = passStringToWasm0(jwk, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
288
+ const len1 = WASM_VECTOR_LEN;
289
+ wasm.keyToDID(retptr, ptr0, len0, ptr1, len1);
290
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
291
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
292
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
293
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
294
+ var ptr2 = r0;
295
+ var len2 = r1;
296
+ if (r3) {
297
+ ptr2 = 0;
298
+ len2 = 0;
299
+ throw takeObject(r2);
300
+ }
301
+ return getStringFromWasm0(ptr2, len2);
302
+ } finally {
303
+ wasm.__wbindgen_add_to_stack_pointer(16);
304
+ wasm.__wbindgen_free(ptr2, len2);
305
+ }
306
+ }
307
+ __name(keyToDID, "keyToDID");
308
+ function keyToVerificationMethod(method_pattern, jwk) {
309
+ const ptr0 = passStringToWasm0(method_pattern, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
310
+ const len0 = WASM_VECTOR_LEN;
311
+ const ptr1 = passStringToWasm0(jwk, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
312
+ const len1 = WASM_VECTOR_LEN;
313
+ const ret = wasm.keyToVerificationMethod(ptr0, len0, ptr1, len1);
314
+ return takeObject(ret);
315
+ }
316
+ __name(keyToVerificationMethod, "keyToVerificationMethod");
317
+ function didToVerificationMethod(did) {
318
+ const ptr0 = passStringToWasm0(did, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
319
+ const len0 = WASM_VECTOR_LEN;
320
+ const ret = wasm.didToVerificationMethod(ptr0, len0);
321
+ return takeObject(ret);
322
+ }
323
+ __name(didToVerificationMethod, "didToVerificationMethod");
324
+ function issueCredential(credential, proof_options, key) {
325
+ const ptr0 = passStringToWasm0(credential, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
326
+ const len0 = WASM_VECTOR_LEN;
327
+ const ptr1 = passStringToWasm0(proof_options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
328
+ const len1 = WASM_VECTOR_LEN;
329
+ const ptr2 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
330
+ const len2 = WASM_VECTOR_LEN;
331
+ const ret = wasm.issueCredential(ptr0, len0, ptr1, len1, ptr2, len2);
332
+ return takeObject(ret);
333
+ }
334
+ __name(issueCredential, "issueCredential");
335
+ function verifyCredential(vc, proof_options) {
336
+ const ptr0 = passStringToWasm0(vc, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
337
+ const len0 = WASM_VECTOR_LEN;
338
+ const ptr1 = passStringToWasm0(proof_options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
339
+ const len1 = WASM_VECTOR_LEN;
340
+ const ret = wasm.verifyCredential(ptr0, len0, ptr1, len1);
341
+ return takeObject(ret);
342
+ }
343
+ __name(verifyCredential, "verifyCredential");
344
+ function issuePresentation(presentation, proof_options, key) {
345
+ const ptr0 = passStringToWasm0(presentation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
346
+ const len0 = WASM_VECTOR_LEN;
347
+ const ptr1 = passStringToWasm0(proof_options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
348
+ const len1 = WASM_VECTOR_LEN;
349
+ const ptr2 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
350
+ const len2 = WASM_VECTOR_LEN;
351
+ const ret = wasm.issuePresentation(ptr0, len0, ptr1, len1, ptr2, len2);
352
+ return takeObject(ret);
353
+ }
354
+ __name(issuePresentation, "issuePresentation");
355
+ function verifyPresentation(vp, proof_options) {
356
+ const ptr0 = passStringToWasm0(vp, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
357
+ const len0 = WASM_VECTOR_LEN;
358
+ const ptr1 = passStringToWasm0(proof_options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
359
+ const len1 = WASM_VECTOR_LEN;
360
+ const ret = wasm.verifyPresentation(ptr0, len0, ptr1, len1);
361
+ return takeObject(ret);
362
+ }
363
+ __name(verifyPresentation, "verifyPresentation");
364
+ function contextLoader(url) {
365
+ const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
366
+ const len0 = WASM_VECTOR_LEN;
367
+ const ret = wasm.contextLoader(ptr0, len0);
368
+ return takeObject(ret);
369
+ }
370
+ __name(contextLoader, "contextLoader");
371
+ function handleError(f, args) {
372
+ try {
373
+ return f.apply(this, args);
374
+ } catch (e) {
375
+ wasm.__wbindgen_exn_store(addHeapObject(e));
376
+ }
377
+ }
378
+ __name(handleError, "handleError");
379
+ function getArrayU8FromWasm0(ptr, len) {
380
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
381
+ }
382
+ __name(getArrayU8FromWasm0, "getArrayU8FromWasm0");
383
+ function __wbg_adapter_133(arg0, arg1, arg2, arg3) {
384
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h63ffd509f6690aab(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
385
+ }
386
+ __name(__wbg_adapter_133, "__wbg_adapter_133");
387
+ async function load(module2, imports) {
388
+ if (typeof Response === "function" && module2 instanceof Response) {
389
+ if (typeof WebAssembly.instantiateStreaming === "function") {
390
+ try {
391
+ return await WebAssembly.instantiateStreaming(module2, imports);
392
+ } catch (e) {
393
+ if (module2.headers.get("Content-Type") != "application/wasm") {
394
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
395
+ } else {
396
+ throw e;
397
+ }
398
+ }
399
+ }
400
+ const bytes = await module2.arrayBuffer();
401
+ return await WebAssembly.instantiate(bytes, imports);
402
+ } else {
403
+ const instance = await WebAssembly.instantiate(module2, imports);
404
+ if (instance instanceof WebAssembly.Instance) {
405
+ return { instance, module: module2 };
406
+ } else {
407
+ return instance;
408
+ }
409
+ }
410
+ }
411
+ __name(load, "load");
412
+ function getImports() {
413
+ const imports = {};
414
+ imports.wbg = {};
415
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
416
+ takeObject(arg0);
417
+ };
418
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
419
+ const ret = getStringFromWasm0(arg0, arg1);
420
+ return addHeapObject(ret);
421
+ };
422
+ imports.wbg.__wbindgen_cb_drop = function(arg0) {
423
+ const obj = takeObject(arg0).original;
424
+ if (obj.cnt-- == 1) {
425
+ obj.a = 0;
426
+ return true;
427
+ }
428
+ const ret = false;
429
+ return ret;
430
+ };
431
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
432
+ const ret = getObject(arg0);
433
+ return addHeapObject(ret);
434
+ };
435
+ imports.wbg.__wbg_fetch_b1379d93c1e2b015 = function(arg0) {
436
+ const ret = fetch(getObject(arg0));
437
+ return addHeapObject(ret);
438
+ };
439
+ imports.wbg.__wbg_fetch_17b968b9c79d3c56 = function(arg0, arg1) {
440
+ const ret = getObject(arg0).fetch(getObject(arg1));
441
+ return addHeapObject(ret);
442
+ };
443
+ imports.wbg.__wbg_new_4cba26249c1686cd = function() {
444
+ return handleError(function() {
445
+ const ret = new Headers();
446
+ return addHeapObject(ret);
447
+ }, arguments);
448
+ };
449
+ imports.wbg.__wbg_append_9c6d4d7f71076e48 = function() {
450
+ return handleError(function(arg0, arg1, arg2, arg3, arg4) {
451
+ getObject(arg0).append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
452
+ }, arguments);
453
+ };
454
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
455
+ const obj = getObject(arg1);
456
+ const ret = typeof obj === "string" ? obj : void 0;
457
+ var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
458
+ var len0 = WASM_VECTOR_LEN;
459
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
460
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
461
+ };
462
+ imports.wbg.__wbg_instanceof_Response_240e67e5796c3c6b = function(arg0) {
463
+ const ret = getObject(arg0) instanceof Response;
464
+ return ret;
465
+ };
466
+ imports.wbg.__wbg_url_0f503b904b694ff5 = function(arg0, arg1) {
467
+ const ret = getObject(arg1).url;
468
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
469
+ const len0 = WASM_VECTOR_LEN;
470
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
471
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
472
+ };
473
+ imports.wbg.__wbg_status_9067c6a4fdd064c9 = function(arg0) {
474
+ const ret = getObject(arg0).status;
475
+ return ret;
476
+ };
477
+ imports.wbg.__wbg_headers_aa309e800cf75016 = function(arg0) {
478
+ const ret = getObject(arg0).headers;
479
+ return addHeapObject(ret);
480
+ };
481
+ imports.wbg.__wbg_arrayBuffer_ccd485f4d2929b08 = function() {
482
+ return handleError(function(arg0) {
483
+ const ret = getObject(arg0).arrayBuffer();
484
+ return addHeapObject(ret);
485
+ }, arguments);
486
+ };
487
+ imports.wbg.__wbg_newwithstrandinit_de7c409ec8538105 = function() {
488
+ return handleError(function(arg0, arg1, arg2) {
489
+ const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
490
+ return addHeapObject(ret);
491
+ }, arguments);
492
+ };
493
+ imports.wbg.__wbg_randomFillSync_91e2b39becca6147 = function() {
494
+ return handleError(function(arg0, arg1, arg2) {
495
+ getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
496
+ }, arguments);
497
+ };
498
+ imports.wbg.__wbg_getRandomValues_b14734aa289bc356 = function() {
499
+ return handleError(function(arg0, arg1) {
500
+ getObject(arg0).getRandomValues(getObject(arg1));
501
+ }, arguments);
502
+ };
503
+ imports.wbg.__wbg_process_e56fd54cf6319b6c = function(arg0) {
504
+ const ret = getObject(arg0).process;
505
+ return addHeapObject(ret);
506
+ };
507
+ imports.wbg.__wbindgen_is_object = function(arg0) {
508
+ const val = getObject(arg0);
509
+ const ret = typeof val === "object" && val !== null;
510
+ return ret;
511
+ };
512
+ imports.wbg.__wbg_versions_77e21455908dad33 = function(arg0) {
513
+ const ret = getObject(arg0).versions;
514
+ return addHeapObject(ret);
515
+ };
516
+ imports.wbg.__wbg_node_0dd25d832e4785d5 = function(arg0) {
517
+ const ret = getObject(arg0).node;
518
+ return addHeapObject(ret);
519
+ };
520
+ imports.wbg.__wbindgen_is_string = function(arg0) {
521
+ const ret = typeof getObject(arg0) === "string";
522
+ return ret;
523
+ };
524
+ imports.wbg.__wbg_crypto_b95d7173266618a9 = function(arg0) {
525
+ const ret = getObject(arg0).crypto;
526
+ return addHeapObject(ret);
527
+ };
528
+ imports.wbg.__wbg_msCrypto_5a86d77a66230f81 = function(arg0) {
529
+ const ret = getObject(arg0).msCrypto;
530
+ return addHeapObject(ret);
531
+ };
532
+ imports.wbg.__wbg_static_accessor_NODE_MODULE_26b231378c1be7dd = function() {
533
+ const ret = module;
534
+ return addHeapObject(ret);
535
+ };
536
+ imports.wbg.__wbg_require_0db1598d9ccecb30 = function() {
537
+ return handleError(function(arg0, arg1, arg2) {
538
+ const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
539
+ return addHeapObject(ret);
540
+ }, arguments);
541
+ };
542
+ imports.wbg.__wbg_randomFillSync_d2ba53160aec6aba = function(arg0, arg1, arg2) {
543
+ getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
544
+ };
545
+ imports.wbg.__wbg_getRandomValues_e57c9b75ddead065 = function(arg0, arg1) {
546
+ getObject(arg0).getRandomValues(getObject(arg1));
547
+ };
548
+ imports.wbg.__wbg_self_86b4b13392c7af56 = function() {
549
+ return handleError(function() {
550
+ const ret = self.self;
551
+ return addHeapObject(ret);
552
+ }, arguments);
553
+ };
554
+ imports.wbg.__wbg_crypto_b8c92eaac23d0d80 = function(arg0) {
555
+ const ret = getObject(arg0).crypto;
556
+ return addHeapObject(ret);
557
+ };
558
+ imports.wbg.__wbg_msCrypto_9ad6677321a08dd8 = function(arg0) {
559
+ const ret = getObject(arg0).msCrypto;
560
+ return addHeapObject(ret);
561
+ };
562
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
563
+ const ret = getObject(arg0) === void 0;
564
+ return ret;
565
+ };
566
+ imports.wbg.__wbg_static_accessor_MODULE_452b4680e8614c81 = function() {
567
+ const ret = module;
568
+ return addHeapObject(ret);
569
+ };
570
+ imports.wbg.__wbg_require_f5521a5b85ad2542 = function(arg0, arg1, arg2) {
571
+ const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
572
+ return addHeapObject(ret);
573
+ };
574
+ imports.wbg.__wbg_getRandomValues_dd27e6b0652b3236 = function(arg0) {
575
+ const ret = getObject(arg0).getRandomValues;
576
+ return addHeapObject(ret);
577
+ };
578
+ imports.wbg.__wbindgen_is_function = function(arg0) {
579
+ const ret = typeof getObject(arg0) === "function";
580
+ return ret;
581
+ };
582
+ imports.wbg.__wbg_newnoargs_971e9a5abe185139 = function(arg0, arg1) {
583
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
584
+ return addHeapObject(ret);
585
+ };
586
+ imports.wbg.__wbg_next_726d1c2255989269 = function(arg0) {
587
+ const ret = getObject(arg0).next;
588
+ return addHeapObject(ret);
589
+ };
590
+ imports.wbg.__wbg_next_3d0c4cc33e7418c9 = function() {
591
+ return handleError(function(arg0) {
592
+ const ret = getObject(arg0).next();
593
+ return addHeapObject(ret);
594
+ }, arguments);
595
+ };
596
+ imports.wbg.__wbg_done_e5655b169bb04f60 = function(arg0) {
597
+ const ret = getObject(arg0).done;
598
+ return ret;
599
+ };
600
+ imports.wbg.__wbg_value_8f901bca1014f843 = function(arg0) {
601
+ const ret = getObject(arg0).value;
602
+ return addHeapObject(ret);
603
+ };
604
+ imports.wbg.__wbg_iterator_22ed2b976832ff0c = function() {
605
+ const ret = Symbol.iterator;
606
+ return addHeapObject(ret);
607
+ };
608
+ imports.wbg.__wbg_get_72332cd2bc57924c = function() {
609
+ return handleError(function(arg0, arg1) {
610
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
611
+ return addHeapObject(ret);
612
+ }, arguments);
613
+ };
614
+ imports.wbg.__wbg_call_33d7bcddbbfa394a = function() {
615
+ return handleError(function(arg0, arg1) {
616
+ const ret = getObject(arg0).call(getObject(arg1));
617
+ return addHeapObject(ret);
618
+ }, arguments);
619
+ };
620
+ imports.wbg.__wbg_new_e6a9fecc2bf26696 = function() {
621
+ const ret = new Object();
622
+ return addHeapObject(ret);
623
+ };
624
+ imports.wbg.__wbg_self_fd00a1ef86d1b2ed = function() {
625
+ return handleError(function() {
626
+ const ret = self.self;
627
+ return addHeapObject(ret);
628
+ }, arguments);
629
+ };
630
+ imports.wbg.__wbg_window_6f6e346d8bbd61d7 = function() {
631
+ return handleError(function() {
632
+ const ret = window.window;
633
+ return addHeapObject(ret);
634
+ }, arguments);
635
+ };
636
+ imports.wbg.__wbg_globalThis_3348936ac49df00a = function() {
637
+ return handleError(function() {
638
+ const ret = globalThis.globalThis;
639
+ return addHeapObject(ret);
640
+ }, arguments);
641
+ };
642
+ imports.wbg.__wbg_global_67175caf56f55ca9 = function() {
643
+ return handleError(function() {
644
+ const ret = global.global;
645
+ return addHeapObject(ret);
646
+ }, arguments);
647
+ };
648
+ imports.wbg.__wbg_call_65af9f665ab6ade5 = function() {
649
+ return handleError(function(arg0, arg1, arg2) {
650
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
651
+ return addHeapObject(ret);
652
+ }, arguments);
653
+ };
654
+ imports.wbg.__wbg_getTime_58b0bdbebd4ef11d = function(arg0) {
655
+ const ret = getObject(arg0).getTime();
656
+ return ret;
657
+ };
658
+ imports.wbg.__wbg_new0_adda2d4bcb124f0a = function() {
659
+ const ret = new Date();
660
+ return addHeapObject(ret);
661
+ };
662
+ imports.wbg.__wbg_new_52205195aa880fc2 = function(arg0, arg1) {
663
+ try {
664
+ var state0 = { a: arg0, b: arg1 };
665
+ var cb0 = /* @__PURE__ */ __name((arg02, arg12) => {
666
+ const a = state0.a;
667
+ state0.a = 0;
668
+ try {
669
+ return __wbg_adapter_133(a, state0.b, arg02, arg12);
670
+ } finally {
671
+ state0.a = a;
672
+ }
673
+ }, "cb0");
674
+ const ret = new Promise(cb0);
675
+ return addHeapObject(ret);
676
+ } finally {
677
+ state0.a = state0.b = 0;
678
+ }
679
+ };
680
+ imports.wbg.__wbg_resolve_0107b3a501450ba0 = function(arg0) {
681
+ const ret = Promise.resolve(getObject(arg0));
682
+ return addHeapObject(ret);
683
+ };
684
+ imports.wbg.__wbg_then_18da6e5453572fc8 = function(arg0, arg1) {
685
+ const ret = getObject(arg0).then(getObject(arg1));
686
+ return addHeapObject(ret);
687
+ };
688
+ imports.wbg.__wbg_then_e5489f796341454b = function(arg0, arg1, arg2) {
689
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
690
+ return addHeapObject(ret);
691
+ };
692
+ imports.wbg.__wbg_buffer_34f5ec9f8a838ba0 = function(arg0) {
693
+ const ret = getObject(arg0).buffer;
694
+ return addHeapObject(ret);
695
+ };
696
+ imports.wbg.__wbg_newwithbyteoffsetandlength_88fdad741db1b182 = function(arg0, arg1, arg2) {
697
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
698
+ return addHeapObject(ret);
699
+ };
700
+ imports.wbg.__wbg_new_cda198d9dbc6d7ea = function(arg0) {
701
+ const ret = new Uint8Array(getObject(arg0));
702
+ return addHeapObject(ret);
703
+ };
704
+ imports.wbg.__wbg_set_1a930cfcda1a8067 = function(arg0, arg1, arg2) {
705
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
706
+ };
707
+ imports.wbg.__wbg_length_51f19f73d6d9eff3 = function(arg0) {
708
+ const ret = getObject(arg0).length;
709
+ return ret;
710
+ };
711
+ imports.wbg.__wbg_newwithlength_66e5530e7079ea1b = function(arg0) {
712
+ const ret = new Uint8Array(arg0 >>> 0);
713
+ return addHeapObject(ret);
714
+ };
715
+ imports.wbg.__wbg_subarray_270ff8dd5582c1ac = function(arg0, arg1, arg2) {
716
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
717
+ return addHeapObject(ret);
718
+ };
719
+ imports.wbg.__wbg_has_3be27932089d278e = function() {
720
+ return handleError(function(arg0, arg1) {
721
+ const ret = Reflect.has(getObject(arg0), getObject(arg1));
722
+ return ret;
723
+ }, arguments);
724
+ };
725
+ imports.wbg.__wbg_set_2762e698c2f5b7e0 = function() {
726
+ return handleError(function(arg0, arg1, arg2) {
727
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
728
+ return ret;
729
+ }, arguments);
730
+ };
731
+ imports.wbg.__wbg_stringify_d8d1ee75d5b55ce4 = function() {
732
+ return handleError(function(arg0) {
733
+ const ret = JSON.stringify(getObject(arg0));
734
+ return addHeapObject(ret);
735
+ }, arguments);
736
+ };
737
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
738
+ const ret = debugString(getObject(arg1));
739
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
740
+ const len0 = WASM_VECTOR_LEN;
741
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
742
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
743
+ };
744
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
745
+ throw new Error(getStringFromWasm0(arg0, arg1));
746
+ };
747
+ imports.wbg.__wbindgen_memory = function() {
748
+ const ret = wasm.memory;
749
+ return addHeapObject(ret);
750
+ };
751
+ imports.wbg.__wbindgen_closure_wrapper9508 = function(arg0, arg1, arg2) {
752
+ const ret = makeMutClosure(arg0, arg1, 2773, __wbg_adapter_26);
753
+ return addHeapObject(ret);
754
+ };
755
+ return imports;
756
+ }
757
+ __name(getImports, "getImports");
758
+ function initMemory(imports, maybe_memory) {
759
+ }
760
+ __name(initMemory, "initMemory");
761
+ function finalizeInit(instance, module2) {
762
+ wasm = instance.exports;
763
+ init.__wbindgen_wasm_module = module2;
764
+ cachedInt32Memory0 = new Int32Array();
765
+ cachedUint8Memory0 = new Uint8Array();
766
+ return wasm;
767
+ }
768
+ __name(finalizeInit, "finalizeInit");
769
+ async function init(input) {
770
+ if (typeof input === "undefined") {
771
+ }
772
+ const imports = getImports();
773
+ if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
774
+ input = fetch(input);
775
+ }
776
+ initMemory(imports);
777
+ const { instance, module: module2 } = await load(await input, imports);
778
+ return finalizeInit(instance, module2);
779
+ }
780
+ __name(init, "init");
781
+ var didkit_wasm_default = init;
782
+
783
+ // src/didkit/index.ts
784
+ var initialized = false;
785
+ var init2 = /* @__PURE__ */ __name(async (arg = "https://cdn.filestackcontent.com/mg9PANmSiRzqPDfNluAa") => {
786
+ if (initialized)
787
+ return;
788
+ initialized = true;
789
+ return didkit_wasm_default(arg);
790
+ }, "init");
791
+ var didkit_default = init2;
792
+
793
+ // src/plugin.ts
794
+ var getDidKitPlugin = /* @__PURE__ */ __name(async (input) => {
795
+ await didkit_default(input);
796
+ const memoizedDids = {};
797
+ return {
798
+ name: "DIDKit",
799
+ displayName: "DIDKit",
800
+ description: "Provides an interface to DIDKit, which allows for the generation of key material, as well as signing and verifying credentials and presentations",
801
+ methods: {
802
+ generateEd25519KeyFromBytes: (_learnCard, bytes) => JSON.parse(generateEd25519KeyFromBytes(bytes)),
803
+ generateSecp256k1KeyFromBytes: (_learnCard, bytes) => JSON.parse(generateSecp256k1KeyFromBytes(bytes)),
804
+ keyToDid: (_learnCard, type, keypair) => {
805
+ const memoizedDid = memoizedDids[type];
806
+ if (!memoizedDid) {
807
+ const did = keyToDID(type, JSON.stringify(keypair));
808
+ memoizedDids[type] = did;
809
+ return did;
810
+ }
811
+ return memoizedDid;
812
+ },
813
+ keyToVerificationMethod: async (_learnCard, type, keypair) => keyToVerificationMethod(type, JSON.stringify(keypair)),
814
+ didToVerificationMethod: async (_learnCard, did) => didToVerificationMethod(did),
815
+ issueCredential: async (_learnCard, credential, options, keypair) => JSON.parse(
816
+ await issueCredential(
817
+ JSON.stringify(credential),
818
+ JSON.stringify(options),
819
+ JSON.stringify(keypair)
820
+ )
821
+ ),
822
+ verifyCredential: async (_learnCard, credential, options = {}) => JSON.parse(
823
+ await verifyCredential(JSON.stringify(credential), JSON.stringify(options))
824
+ ),
825
+ issuePresentation: async (_learnCard, presentation, options, keypair) => {
826
+ const isJwt = options.proofFormat === "jwt";
827
+ const result = await issuePresentation(
828
+ JSON.stringify(presentation),
829
+ JSON.stringify(options),
830
+ JSON.stringify(keypair)
831
+ );
832
+ return isJwt ? result : JSON.parse(result);
833
+ },
834
+ verifyPresentation: async (_learnCard, presentation, options = {}) => {
835
+ const isJwt = typeof presentation === "string";
836
+ return JSON.parse(
837
+ await verifyPresentation(
838
+ isJwt ? presentation : JSON.stringify(presentation),
839
+ JSON.stringify(options)
840
+ )
841
+ );
842
+ },
843
+ contextLoader: async (_learnCard, url) => JSON.parse(await contextLoader(url)),
844
+ resolveDid: async (_learnCard, did, inputMetadata = {}) => JSON.parse(await resolveDID(did, JSON.stringify(inputMetadata))),
845
+ didResolver: async (_learnCard, did, inputMetadata = {}) => JSON.parse(await didResolver(did, JSON.stringify(inputMetadata)))
846
+ }
847
+ };
848
+ }, "getDidKitPlugin");
849
+ //# sourceMappingURL=didkit-plugin.cjs.development.js.map