@learncard/chapi-plugin 1.0.79 → 1.1.1
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/dist/chapi-plugin.cjs.development.js +401 -150
- package/dist/chapi-plugin.cjs.development.js.map +1 -1
- package/dist/chapi-plugin.cjs.production.min.js +121 -77
- package/dist/chapi-plugin.cjs.production.min.js.map +2 -2
- package/dist/chapi-plugin.esm.js +398 -147
- package/dist/chapi-plugin.esm.js.map +1 -1
- package/package.json +8 -8
|
@@ -19,11 +19,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
20
|
|
|
21
21
|
// src/index.ts
|
|
22
|
-
var
|
|
23
|
-
__export(
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
24
|
getCHAPIPlugin: () => getCHAPIPlugin
|
|
25
25
|
});
|
|
26
|
-
module.exports = __toCommonJS(
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
|
|
28
28
|
// ../../../node_modules/.pnpm/web-request-rpc@2.0.3/node_modules/web-request-rpc/utils.js
|
|
29
29
|
var RPC_ERRORS = {
|
|
@@ -86,6 +86,8 @@ function parseUrl(url, base) {
|
|
|
86
86
|
pathname = "/" + pathname;
|
|
87
87
|
}
|
|
88
88
|
return {
|
|
89
|
+
// TODO: is this safe for general use on every browser that doesn't
|
|
90
|
+
// support WHATWG URL?
|
|
89
91
|
host: parser.host || window.location.host,
|
|
90
92
|
hostname: parser.hostname,
|
|
91
93
|
origin,
|
|
@@ -95,8 +97,7 @@ function parseUrl(url, base) {
|
|
|
95
97
|
}
|
|
96
98
|
__name(parseUrl, "parseUrl");
|
|
97
99
|
function uuidv4(a, b) {
|
|
98
|
-
for (b = a = ""; a++ < 36; b += a * 51 & 52 ? (a ^ 15 ? 8 ^ Math.random() * (a ^ 20 ? 16 : 4) : 4).toString(16) : "-")
|
|
99
|
-
;
|
|
100
|
+
for (b = a = ""; a++ < 36; b += a * 51 & 52 ? (a ^ 15 ? 8 ^ Math.random() * (a ^ 20 ? 16 : 4) : 4).toString(16) : "-") ;
|
|
100
101
|
return b;
|
|
101
102
|
}
|
|
102
103
|
__name(uuidv4, "uuidv4");
|
|
@@ -185,13 +186,27 @@ __name(isHandlePromise, "isHandlePromise");
|
|
|
185
186
|
|
|
186
187
|
// ../../../node_modules/.pnpm/web-request-rpc@2.0.3/node_modules/web-request-rpc/Client.js
|
|
187
188
|
var RPC_CLIENT_CALL_TIMEOUT = 3e4;
|
|
188
|
-
var
|
|
189
|
+
var _Client = class _Client {
|
|
189
190
|
constructor() {
|
|
190
191
|
this.origin = null;
|
|
191
192
|
this._handle = null;
|
|
192
193
|
this._listener = null;
|
|
193
194
|
this._pending = /* @__PURE__ */ new Map();
|
|
194
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Connects to a Web Request RPC server.
|
|
198
|
+
*
|
|
199
|
+
* The Promise will resolve to an RPC injector that can be used to get or
|
|
200
|
+
* define APIs to enable communication with the server.
|
|
201
|
+
*
|
|
202
|
+
* @param origin the origin to send messages to.
|
|
203
|
+
* @param options the options to use:
|
|
204
|
+
* [handle] a handle to the window (or a Promise that resolves to
|
|
205
|
+
* a handle) to send messages to
|
|
206
|
+
* (defaults to `window.opener || window.parent`).
|
|
207
|
+
*
|
|
208
|
+
* @return a Promise that resolves to an RPC injector once connected.
|
|
209
|
+
*/
|
|
195
210
|
async connect(origin, options) {
|
|
196
211
|
if (this._listener) {
|
|
197
212
|
throw new Error("Already connected.");
|
|
@@ -205,7 +220,7 @@ var Client = class {
|
|
|
205
220
|
origin: self.origin,
|
|
206
221
|
handle: self._handle,
|
|
207
222
|
expectRequest: false,
|
|
208
|
-
listener: (message) => {
|
|
223
|
+
listener: /* @__PURE__ */ __name((message) => {
|
|
209
224
|
if (!pending.has(message.id)) {
|
|
210
225
|
return;
|
|
211
226
|
}
|
|
@@ -215,11 +230,23 @@ var Client = class {
|
|
|
215
230
|
return resolve(message.result);
|
|
216
231
|
}
|
|
217
232
|
reject(deserializeError(message.error));
|
|
218
|
-
}
|
|
233
|
+
}, "listener")
|
|
219
234
|
});
|
|
220
235
|
window.addEventListener("message", self._listener);
|
|
221
236
|
return new Injector(self);
|
|
222
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Performs a RPC by sending a message to the Web Request RPC server and
|
|
240
|
+
* awaiting a response.
|
|
241
|
+
*
|
|
242
|
+
* @param qualifiedMethodName the fully-qualified name of the method to call.
|
|
243
|
+
* @param parameters the parameters for the method.
|
|
244
|
+
* @param options the options to use:
|
|
245
|
+
* [timeout] a timeout, in milliseconds, for awaiting a response;
|
|
246
|
+
* a non-positive timeout (<= 0) will cause an indefinite wait.
|
|
247
|
+
*
|
|
248
|
+
* @return a Promise that resolves to the result (or error) of the call.
|
|
249
|
+
*/
|
|
223
250
|
async send(qualifiedMethodName, parameters, {
|
|
224
251
|
timeout = RPC_CLIENT_CALL_TIMEOUT
|
|
225
252
|
}) {
|
|
@@ -259,6 +286,10 @@ var Client = class {
|
|
|
259
286
|
pending.set(message.id, { resolve, reject, cancelTimeout });
|
|
260
287
|
});
|
|
261
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Disconnects from the remote Web Request RPC server and closes down this
|
|
291
|
+
* client.
|
|
292
|
+
*/
|
|
262
293
|
close() {
|
|
263
294
|
if (this._listener) {
|
|
264
295
|
window.removeEventListener("message", this._listener);
|
|
@@ -270,12 +301,31 @@ var Client = class {
|
|
|
270
301
|
}
|
|
271
302
|
}
|
|
272
303
|
};
|
|
273
|
-
__name(
|
|
274
|
-
var
|
|
304
|
+
__name(_Client, "Client");
|
|
305
|
+
var Client = _Client;
|
|
306
|
+
var _Injector = class _Injector {
|
|
275
307
|
constructor(client) {
|
|
276
308
|
this.client = client;
|
|
277
309
|
this._apis = /* @__PURE__ */ new Map();
|
|
278
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* Defines a named API that will use an RPC client to implement its
|
|
313
|
+
* functions. Each of these functions will be asynchronous and return a
|
|
314
|
+
* Promise with the result from the RPC server.
|
|
315
|
+
*
|
|
316
|
+
* This function will return an interface with functions defined according
|
|
317
|
+
* to those provided in the given `definition`. The `name` parameter can be
|
|
318
|
+
* used to obtain this cached interface via `.get(name)`.
|
|
319
|
+
*
|
|
320
|
+
* @param name the name of the API.
|
|
321
|
+
* @param definition the definition for the API, including:
|
|
322
|
+
* functions: an array of function names (as strings) or objects
|
|
323
|
+
* containing: {name: <functionName>, options: <rpcClientOptions>}.
|
|
324
|
+
*
|
|
325
|
+
* @return an interface with the functions provided via `definition` that
|
|
326
|
+
* will make RPC calls to an RPC server to provide their
|
|
327
|
+
* implementation.
|
|
328
|
+
*/
|
|
279
329
|
define(name, definition) {
|
|
280
330
|
if (!(name && typeof name === "string")) {
|
|
281
331
|
throw new TypeError("`name` must be a non-empty string.");
|
|
@@ -302,6 +352,15 @@ var Injector = class {
|
|
|
302
352
|
self._apis[name] = api;
|
|
303
353
|
return api;
|
|
304
354
|
}
|
|
355
|
+
/**
|
|
356
|
+
* Get a named API, defining it if necessary when a definition is provided.
|
|
357
|
+
*
|
|
358
|
+
* @param name the name of the API.
|
|
359
|
+
* @param [definition] the definition for the API; if the API is already
|
|
360
|
+
* defined, this definition is ignored.
|
|
361
|
+
*
|
|
362
|
+
* @return the interface.
|
|
363
|
+
*/
|
|
305
364
|
get(name, definition) {
|
|
306
365
|
const api = this._apis[name];
|
|
307
366
|
if (!api) {
|
|
@@ -313,10 +372,11 @@ var Injector = class {
|
|
|
313
372
|
return this._apis[name];
|
|
314
373
|
}
|
|
315
374
|
};
|
|
316
|
-
__name(
|
|
375
|
+
__name(_Injector, "Injector");
|
|
376
|
+
var Injector = _Injector;
|
|
317
377
|
|
|
318
378
|
// ../../../node_modules/.pnpm/web-request-rpc@2.0.3/node_modules/web-request-rpc/EventEmitter.js
|
|
319
|
-
var
|
|
379
|
+
var _EventEmitter = class _EventEmitter {
|
|
320
380
|
constructor({ deserialize = /* @__PURE__ */ __name((e) => e, "deserialize"), waitUntil = /* @__PURE__ */ __name(async () => {
|
|
321
381
|
}, "waitUntil") } = {}) {
|
|
322
382
|
this._listeners = [];
|
|
@@ -346,15 +406,23 @@ var EventEmitter = class {
|
|
|
346
406
|
}
|
|
347
407
|
}
|
|
348
408
|
};
|
|
349
|
-
__name(
|
|
409
|
+
__name(_EventEmitter, "EventEmitter");
|
|
410
|
+
var EventEmitter = _EventEmitter;
|
|
350
411
|
|
|
351
412
|
// ../../../node_modules/.pnpm/web-request-rpc@2.0.3/node_modules/web-request-rpc/Server.js
|
|
352
|
-
var
|
|
413
|
+
var _Server = class _Server {
|
|
353
414
|
constructor() {
|
|
354
415
|
this.origin = null;
|
|
355
416
|
this._handle = null;
|
|
356
417
|
this._apis = /* @__PURE__ */ new Map();
|
|
357
418
|
}
|
|
419
|
+
/**
|
|
420
|
+
* Provides an implementation for a named API. All functions in the given
|
|
421
|
+
* API will be made callable via RPC clients connected to this server.
|
|
422
|
+
*
|
|
423
|
+
* @param name the name of the API.
|
|
424
|
+
* @param api the API to add.
|
|
425
|
+
*/
|
|
358
426
|
define(name, api) {
|
|
359
427
|
if (!(name && typeof name === "string")) {
|
|
360
428
|
throw new TypeError("`name` must be a non-empty string.");
|
|
@@ -367,6 +435,26 @@ var Server = class {
|
|
|
367
435
|
}
|
|
368
436
|
this._apis[name] = api;
|
|
369
437
|
}
|
|
438
|
+
/**
|
|
439
|
+
* Listens for RPC messages from clients from a particular origin and
|
|
440
|
+
* window handle and uses them to execute API calls based on predefined
|
|
441
|
+
* APIs.
|
|
442
|
+
*
|
|
443
|
+
* If messages are not from the given origin or window handle, they are
|
|
444
|
+
* ignored. If the messages refer to named APIs that have not been defined
|
|
445
|
+
* then an error message is sent in response. These error messages can
|
|
446
|
+
* be suppressed by using the `ignoreUnknownApi` option.
|
|
447
|
+
*
|
|
448
|
+
* If a message refers to an unknown method on a known named API, then an
|
|
449
|
+
* error message is sent in response.
|
|
450
|
+
*
|
|
451
|
+
* @param origin the origin to listen for.
|
|
452
|
+
* @param options the options to use:
|
|
453
|
+
* [handle] a handle to the window (or a Promise that resolves to
|
|
454
|
+
* a handle) to listen for messages from
|
|
455
|
+
* (defaults to `window.opener || window.parent`).
|
|
456
|
+
* [ignoreUnknownApi] `true` to ignore unknown API messages.
|
|
457
|
+
*/
|
|
370
458
|
async listen(origin, options) {
|
|
371
459
|
if (this._listener) {
|
|
372
460
|
throw new Error("Already listening.");
|
|
@@ -380,7 +468,7 @@ var Server = class {
|
|
|
380
468
|
origin: self.origin,
|
|
381
469
|
handle: self._handle,
|
|
382
470
|
expectRequest: true,
|
|
383
|
-
listener: (message) => {
|
|
471
|
+
listener: /* @__PURE__ */ __name((message) => {
|
|
384
472
|
const { name, method } = destructureMethodName(message.method);
|
|
385
473
|
const api = self._apis[name];
|
|
386
474
|
if (method && method.startsWith("_")) {
|
|
@@ -411,7 +499,7 @@ var Server = class {
|
|
|
411
499
|
}
|
|
412
500
|
}
|
|
413
501
|
})();
|
|
414
|
-
}
|
|
502
|
+
}, "listener")
|
|
415
503
|
});
|
|
416
504
|
window.addEventListener("message", self._listener);
|
|
417
505
|
}
|
|
@@ -422,7 +510,8 @@ var Server = class {
|
|
|
422
510
|
}
|
|
423
511
|
}
|
|
424
512
|
};
|
|
425
|
-
__name(
|
|
513
|
+
__name(_Server, "Server");
|
|
514
|
+
var Server = _Server;
|
|
426
515
|
function sendMethodNotFound(handle, origin, message) {
|
|
427
516
|
const response = {
|
|
428
517
|
jsonrpc: "2.0",
|
|
@@ -438,7 +527,7 @@ function sendMethodNotFound(handle, origin, message) {
|
|
|
438
527
|
__name(sendMethodNotFound, "sendMethodNotFound");
|
|
439
528
|
|
|
440
529
|
// ../../../node_modules/.pnpm/web-request-rpc@2.0.3/node_modules/web-request-rpc/WebApp.js
|
|
441
|
-
var
|
|
530
|
+
var _WebApp = class _WebApp {
|
|
442
531
|
constructor(relyingOrigin) {
|
|
443
532
|
this.relyingOrigin = parseUrl(relyingOrigin).origin;
|
|
444
533
|
this.client = null;
|
|
@@ -448,6 +537,13 @@ var WebApp = class {
|
|
|
448
537
|
this._control = null;
|
|
449
538
|
this._connected = false;
|
|
450
539
|
}
|
|
540
|
+
/**
|
|
541
|
+
* Connects this WebApp to the relying origin that instantiated it. Once
|
|
542
|
+
* connected, the WebApp can start servicing calls from that origin.
|
|
543
|
+
*
|
|
544
|
+
* @return a Promise that resolves to an injector for creating custom client
|
|
545
|
+
* APIs once the connection is ready.
|
|
546
|
+
*/
|
|
451
547
|
async connect() {
|
|
452
548
|
this.injector = await this.client.connect(this.relyingOrigin);
|
|
453
549
|
this._connected = true;
|
|
@@ -457,6 +553,10 @@ var WebApp = class {
|
|
|
457
553
|
this.server.listen(this.relyingOrigin);
|
|
458
554
|
return this.injector;
|
|
459
555
|
}
|
|
556
|
+
/**
|
|
557
|
+
* Must be called after `connect` when this WebApp is ready to start
|
|
558
|
+
* receiving calls from the remote end.
|
|
559
|
+
*/
|
|
460
560
|
async ready() {
|
|
461
561
|
if (!this._connected) {
|
|
462
562
|
throw new Error('WebApp not connected. Did you call ".connect()"?');
|
|
@@ -464,6 +564,9 @@ var WebApp = class {
|
|
|
464
564
|
await this._control.ready();
|
|
465
565
|
return this;
|
|
466
566
|
}
|
|
567
|
+
/**
|
|
568
|
+
* Closes this WebApp's connection to the relying origin.
|
|
569
|
+
*/
|
|
467
570
|
close() {
|
|
468
571
|
if (this._connected) {
|
|
469
572
|
this.server.close();
|
|
@@ -471,6 +574,9 @@ var WebApp = class {
|
|
|
471
574
|
this._connected = false;
|
|
472
575
|
}
|
|
473
576
|
}
|
|
577
|
+
/**
|
|
578
|
+
* Shows the UI for this WebApp on the relying origin.
|
|
579
|
+
*/
|
|
474
580
|
async show() {
|
|
475
581
|
if (!this._connected) {
|
|
476
582
|
throw new Error(
|
|
@@ -479,6 +585,9 @@ var WebApp = class {
|
|
|
479
585
|
}
|
|
480
586
|
return this._control.show();
|
|
481
587
|
}
|
|
588
|
+
/**
|
|
589
|
+
* Hides the UI for this WebApp on the relying origin.
|
|
590
|
+
*/
|
|
482
591
|
async hide() {
|
|
483
592
|
if (!this._connected) {
|
|
484
593
|
throw new Error(
|
|
@@ -488,10 +597,11 @@ var WebApp = class {
|
|
|
488
597
|
return this._control.hide();
|
|
489
598
|
}
|
|
490
599
|
};
|
|
491
|
-
__name(
|
|
600
|
+
__name(_WebApp, "WebApp");
|
|
601
|
+
var WebApp = _WebApp;
|
|
492
602
|
|
|
493
603
|
// ../../../node_modules/.pnpm/web-request-rpc@2.0.3/node_modules/web-request-rpc/WebAppWindowDialog.js
|
|
494
|
-
var
|
|
604
|
+
var _WebAppWindowDialog = class _WebAppWindowDialog {
|
|
495
605
|
constructor() {
|
|
496
606
|
this._closeEventListeners = /* @__PURE__ */ new Set();
|
|
497
607
|
}
|
|
@@ -524,10 +634,11 @@ var WebAppWindowDialog = class {
|
|
|
524
634
|
this._closeEventListeners.clear();
|
|
525
635
|
}
|
|
526
636
|
};
|
|
527
|
-
__name(
|
|
637
|
+
__name(_WebAppWindowDialog, "WebAppWindowDialog");
|
|
638
|
+
var WebAppWindowDialog = _WebAppWindowDialog;
|
|
528
639
|
|
|
529
640
|
// ../../../node_modules/.pnpm/web-request-rpc@2.0.3/node_modules/web-request-rpc/WebAppWindowInlineDialog.js
|
|
530
|
-
var
|
|
641
|
+
var _WebAppWindowInlineDialog = class _WebAppWindowInlineDialog extends WebAppWindowDialog {
|
|
531
642
|
constructor({ url, handle, className }) {
|
|
532
643
|
super();
|
|
533
644
|
this.url = url;
|
|
@@ -549,6 +660,7 @@ var WebAppWindowInlineDialog = class extends WebAppWindowDialog {
|
|
|
549
660
|
color: "black",
|
|
550
661
|
"box-sizing": "border-box",
|
|
551
662
|
overflow: "hidden",
|
|
663
|
+
// prevent focus bug in chrome
|
|
552
664
|
"user-select": "none",
|
|
553
665
|
"z-index": 1e6
|
|
554
666
|
});
|
|
@@ -588,6 +700,7 @@ var WebAppWindowInlineDialog = class extends WebAppWindowDialog {
|
|
|
588
700
|
margin: 0,
|
|
589
701
|
padding: 0,
|
|
590
702
|
"flex-grow": 1,
|
|
703
|
+
// prevent focus bug in chrome
|
|
591
704
|
"user-select": "none"
|
|
592
705
|
});
|
|
593
706
|
this.dialog.appendChild(style);
|
|
@@ -632,7 +745,8 @@ var WebAppWindowInlineDialog = class extends WebAppWindowDialog {
|
|
|
632
745
|
super.destroy();
|
|
633
746
|
}
|
|
634
747
|
};
|
|
635
|
-
__name(
|
|
748
|
+
__name(_WebAppWindowInlineDialog, "WebAppWindowInlineDialog");
|
|
749
|
+
var WebAppWindowInlineDialog = _WebAppWindowInlineDialog;
|
|
636
750
|
function applyStyle(element, style) {
|
|
637
751
|
for (const name in style) {
|
|
638
752
|
element.style[name] = style[name];
|
|
@@ -641,7 +755,7 @@ function applyStyle(element, style) {
|
|
|
641
755
|
__name(applyStyle, "applyStyle");
|
|
642
756
|
|
|
643
757
|
// ../../../node_modules/.pnpm/web-request-rpc@2.0.3/node_modules/web-request-rpc/WebAppWindowPopupDialog.js
|
|
644
|
-
var
|
|
758
|
+
var _WebAppWindowPopupDialog = class _WebAppWindowPopupDialog extends WebAppWindowDialog {
|
|
645
759
|
constructor({ url, handle, bounds = { width: 500, height: 400 } }) {
|
|
646
760
|
super();
|
|
647
761
|
this.url = url;
|
|
@@ -717,11 +831,12 @@ var WebAppWindowPopupDialog = class extends WebAppWindowDialog {
|
|
|
717
831
|
};
|
|
718
832
|
}
|
|
719
833
|
};
|
|
720
|
-
__name(
|
|
834
|
+
__name(_WebAppWindowPopupDialog, "WebAppWindowPopupDialog");
|
|
835
|
+
var WebAppWindowPopupDialog = _WebAppWindowPopupDialog;
|
|
721
836
|
|
|
722
837
|
// ../../../node_modules/.pnpm/web-request-rpc@2.0.3/node_modules/web-request-rpc/WebAppWindow.js
|
|
723
838
|
var LOAD_WINDOW_TIMEOUT = 6e4;
|
|
724
|
-
var
|
|
839
|
+
var _WebAppWindow = class _WebAppWindow {
|
|
725
840
|
constructor(url, {
|
|
726
841
|
timeout = LOAD_WINDOW_TIMEOUT,
|
|
727
842
|
dialog = null,
|
|
@@ -729,6 +844,7 @@ var WebAppWindow = class {
|
|
|
729
844
|
popup = false,
|
|
730
845
|
className = null,
|
|
731
846
|
customize = null,
|
|
847
|
+
// top, left, width, height
|
|
732
848
|
bounds
|
|
733
849
|
} = {}) {
|
|
734
850
|
this.visible = false;
|
|
@@ -779,7 +895,7 @@ var WebAppWindow = class {
|
|
|
779
895
|
}
|
|
780
896
|
};
|
|
781
897
|
if (customize) {
|
|
782
|
-
if (
|
|
898
|
+
if (false) {
|
|
783
899
|
throw new TypeError("`options.customize` must be a function.");
|
|
784
900
|
}
|
|
785
901
|
}
|
|
@@ -813,10 +929,16 @@ var WebAppWindow = class {
|
|
|
813
929
|
}
|
|
814
930
|
}
|
|
815
931
|
}
|
|
932
|
+
/**
|
|
933
|
+
* Called by the client when it is ready to receive messages.
|
|
934
|
+
*/
|
|
816
935
|
ready() {
|
|
817
936
|
this._ready = true;
|
|
818
937
|
this._private._resolveReady(true);
|
|
819
938
|
}
|
|
939
|
+
/**
|
|
940
|
+
* Called by the client when it wants to show UI.
|
|
941
|
+
*/
|
|
820
942
|
show() {
|
|
821
943
|
if (!this.visible) {
|
|
822
944
|
this.visible = true;
|
|
@@ -830,6 +952,9 @@ var WebAppWindow = class {
|
|
|
830
952
|
}
|
|
831
953
|
}
|
|
832
954
|
}
|
|
955
|
+
/**
|
|
956
|
+
* Called by the client when it wants to hide UI.
|
|
957
|
+
*/
|
|
833
958
|
hide() {
|
|
834
959
|
if (this.visible) {
|
|
835
960
|
this.visible = false;
|
|
@@ -847,11 +972,12 @@ var WebAppWindow = class {
|
|
|
847
972
|
}
|
|
848
973
|
}
|
|
849
974
|
};
|
|
850
|
-
__name(
|
|
975
|
+
__name(_WebAppWindow, "WebAppWindow");
|
|
976
|
+
var WebAppWindow = _WebAppWindow;
|
|
851
977
|
|
|
852
978
|
// ../../../node_modules/.pnpm/web-request-rpc@2.0.3/node_modules/web-request-rpc/WebAppContext.js
|
|
853
979
|
var WEB_APP_CONTEXT_LOAD_TIMEOUT = 1e4;
|
|
854
|
-
var
|
|
980
|
+
var _WebAppContext = class _WebAppContext {
|
|
855
981
|
constructor() {
|
|
856
982
|
this.client = new Client();
|
|
857
983
|
this.server = new Server();
|
|
@@ -860,6 +986,32 @@ var WebAppContext = class {
|
|
|
860
986
|
this.loaded = false;
|
|
861
987
|
this.closed = false;
|
|
862
988
|
}
|
|
989
|
+
/**
|
|
990
|
+
* Creates a window (or attaches to an existing one) that loads a page that
|
|
991
|
+
* is expected to understand the web request RPC protocol. This method
|
|
992
|
+
* returns a Promise that will resolve once the page uses RPC to indicate
|
|
993
|
+
* that it is ready to be communicated with or once a timeout occurs.
|
|
994
|
+
*
|
|
995
|
+
* The Promise will resolve to an RPC injector that can be used to get or
|
|
996
|
+
* define APIs to enable communication with the WebApp running in the
|
|
997
|
+
* WebAppContext.
|
|
998
|
+
*
|
|
999
|
+
* @param url the URL to the page to connect to.
|
|
1000
|
+
* @param options the options to use:
|
|
1001
|
+
* [timeout] the timeout for waiting for the client to be ready.
|
|
1002
|
+
* [handle] a window handle to connect to; may be a Promise that
|
|
1003
|
+
* that resolves to a handle.
|
|
1004
|
+
* [iframe] an iframe element to connect to.
|
|
1005
|
+
* [windowControl] a window control interface to connect to.
|
|
1006
|
+
* [className] a className to assign to the window for CSS purposes.
|
|
1007
|
+
* [customize(options)] a function to customize the dialog that
|
|
1008
|
+
* loads the window after its construction.
|
|
1009
|
+
* [bounds] a bounding rectangle (top, left, width, height) to
|
|
1010
|
+
* use when creating a popup window.
|
|
1011
|
+
*
|
|
1012
|
+
* @return a Promise that resolves to an RPC injector once the window is
|
|
1013
|
+
* ready.
|
|
1014
|
+
*/
|
|
863
1015
|
async createWindow(url, {
|
|
864
1016
|
timeout = WEB_APP_CONTEXT_LOAD_TIMEOUT,
|
|
865
1017
|
iframe,
|
|
@@ -869,6 +1021,7 @@ var WebAppContext = class {
|
|
|
869
1021
|
windowControl,
|
|
870
1022
|
className,
|
|
871
1023
|
customize,
|
|
1024
|
+
// top, left, width, height
|
|
872
1025
|
bounds
|
|
873
1026
|
} = {}) {
|
|
874
1027
|
if (this.loaded) {
|
|
@@ -908,10 +1061,11 @@ var WebAppContext = class {
|
|
|
908
1061
|
}
|
|
909
1062
|
}
|
|
910
1063
|
};
|
|
911
|
-
__name(
|
|
1064
|
+
__name(_WebAppContext, "WebAppContext");
|
|
1065
|
+
var WebAppContext = _WebAppContext;
|
|
912
1066
|
|
|
913
1067
|
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.2.1/node_modules/credential-handler-polyfill/CredentialRequestEvent.js
|
|
914
|
-
var
|
|
1068
|
+
var _CredentialRequestEvent = class _CredentialRequestEvent {
|
|
915
1069
|
constructor({
|
|
916
1070
|
credentialHandler,
|
|
917
1071
|
credentialRequestOrigin,
|
|
@@ -938,10 +1092,11 @@ var CredentialRequestEvent = class {
|
|
|
938
1092
|
this._promise = handlerResponse;
|
|
939
1093
|
}
|
|
940
1094
|
};
|
|
941
|
-
__name(
|
|
1095
|
+
__name(_CredentialRequestEvent, "CredentialRequestEvent");
|
|
1096
|
+
var CredentialRequestEvent = _CredentialRequestEvent;
|
|
942
1097
|
|
|
943
1098
|
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.2.1/node_modules/credential-handler-polyfill/CredentialStoreEvent.js
|
|
944
|
-
var
|
|
1099
|
+
var _CredentialStoreEvent = class _CredentialStoreEvent {
|
|
945
1100
|
constructor({
|
|
946
1101
|
credentialHandler,
|
|
947
1102
|
credentialRequestOrigin,
|
|
@@ -966,10 +1121,11 @@ var CredentialStoreEvent = class {
|
|
|
966
1121
|
this._promise = handlerResponse;
|
|
967
1122
|
}
|
|
968
1123
|
};
|
|
969
|
-
__name(
|
|
1124
|
+
__name(_CredentialStoreEvent, "CredentialStoreEvent");
|
|
1125
|
+
var CredentialStoreEvent = _CredentialStoreEvent;
|
|
970
1126
|
|
|
971
1127
|
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.2.1/node_modules/credential-handler-polyfill/CredentialHandlerService.js
|
|
972
|
-
var
|
|
1128
|
+
var _CredentialHandlerService = class _CredentialHandlerService {
|
|
973
1129
|
constructor(credentialHandler) {
|
|
974
1130
|
this._credentialHandler = credentialHandler;
|
|
975
1131
|
}
|
|
@@ -990,11 +1146,12 @@ var CredentialHandlerService = class {
|
|
|
990
1146
|
);
|
|
991
1147
|
}
|
|
992
1148
|
};
|
|
993
|
-
__name(
|
|
1149
|
+
__name(_CredentialHandlerService, "CredentialHandlerService");
|
|
1150
|
+
var CredentialHandlerService = _CredentialHandlerService;
|
|
994
1151
|
|
|
995
1152
|
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.2.1/node_modules/credential-handler-polyfill/CredentialHandler.js
|
|
996
1153
|
var EVENT_TYPES = ["credentialrequest", "credentialstore"];
|
|
997
|
-
var
|
|
1154
|
+
var _CredentialHandler = class _CredentialHandler extends WebApp {
|
|
998
1155
|
constructor(mediatorOrigin, inline = false) {
|
|
999
1156
|
if (typeof mediatorOrigin !== "string") {
|
|
1000
1157
|
throw new TypeError('"mediatorOrigin" must be a string.');
|
|
@@ -1036,10 +1193,11 @@ var CredentialHandler = class extends WebApp {
|
|
|
1036
1193
|
return this._emitter.removeEventListener(eventType, fn);
|
|
1037
1194
|
}
|
|
1038
1195
|
};
|
|
1039
|
-
__name(
|
|
1196
|
+
__name(_CredentialHandler, "CredentialHandler");
|
|
1197
|
+
var CredentialHandler = _CredentialHandler;
|
|
1040
1198
|
|
|
1041
1199
|
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.2.1/node_modules/credential-handler-polyfill/CredentialHints.js
|
|
1042
|
-
var
|
|
1200
|
+
var _CredentialHints = class _CredentialHints {
|
|
1043
1201
|
constructor(url, injector) {
|
|
1044
1202
|
const remote = injector.get("credentialHints", {
|
|
1045
1203
|
functions: ["delete", "get", "keys", "has", "set", "clear"]
|
|
@@ -1068,7 +1226,8 @@ var CredentialHints = class {
|
|
|
1068
1226
|
console.warn("Credential hints are deprecated and no longer used.");
|
|
1069
1227
|
}
|
|
1070
1228
|
};
|
|
1071
|
-
__name(
|
|
1229
|
+
__name(_CredentialHints, "CredentialHints");
|
|
1230
|
+
var CredentialHints = _CredentialHints;
|
|
1072
1231
|
function imageToDataUrl(url) {
|
|
1073
1232
|
return new Promise((resolve) => {
|
|
1074
1233
|
const img = new Image();
|
|
@@ -1090,13 +1249,20 @@ function imageToDataUrl(url) {
|
|
|
1090
1249
|
__name(imageToDataUrl, "imageToDataUrl");
|
|
1091
1250
|
|
|
1092
1251
|
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.2.1/node_modules/credential-handler-polyfill/CredentialManager.js
|
|
1093
|
-
var
|
|
1252
|
+
var _CredentialManager = class _CredentialManager {
|
|
1094
1253
|
constructor(url, injector) {
|
|
1095
1254
|
if (!(url && typeof url === "string")) {
|
|
1096
1255
|
throw new TypeError('"url" must be a non-empty string.');
|
|
1097
1256
|
}
|
|
1098
1257
|
this.hints = new CredentialHints(url, injector);
|
|
1099
1258
|
}
|
|
1259
|
+
/**
|
|
1260
|
+
* Requests that the user grant 'credentialhandler' permission to the current
|
|
1261
|
+
* origin.
|
|
1262
|
+
*
|
|
1263
|
+
* @return a Promise that resolves to the new PermissionState of the
|
|
1264
|
+
* permission (e.g. 'granted'/'denied').
|
|
1265
|
+
*/
|
|
1100
1266
|
static async requestPermission() {
|
|
1101
1267
|
const status = await navigator.credentialsPolyfill.permissions.request(
|
|
1102
1268
|
{ name: "credentialhandler" }
|
|
@@ -1104,10 +1270,11 @@ var CredentialManager = class {
|
|
|
1104
1270
|
return status.state;
|
|
1105
1271
|
}
|
|
1106
1272
|
};
|
|
1107
|
-
__name(
|
|
1273
|
+
__name(_CredentialManager, "CredentialManager");
|
|
1274
|
+
var CredentialManager = _CredentialManager;
|
|
1108
1275
|
|
|
1109
1276
|
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.2.1/node_modules/credential-handler-polyfill/CredentialHandlerRegistration.js
|
|
1110
|
-
var
|
|
1277
|
+
var _CredentialHandlerRegistration = class _CredentialHandlerRegistration {
|
|
1111
1278
|
constructor(url, injector) {
|
|
1112
1279
|
if (!(url && typeof url === "string")) {
|
|
1113
1280
|
throw new TypeError('"url" must be a non-empty string.');
|
|
@@ -1115,10 +1282,11 @@ var CredentialHandlerRegistration = class {
|
|
|
1115
1282
|
this.credentialManager = new CredentialManager(url, injector);
|
|
1116
1283
|
}
|
|
1117
1284
|
};
|
|
1118
|
-
__name(
|
|
1285
|
+
__name(_CredentialHandlerRegistration, "CredentialHandlerRegistration");
|
|
1286
|
+
var CredentialHandlerRegistration = _CredentialHandlerRegistration;
|
|
1119
1287
|
|
|
1120
1288
|
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.2.1/node_modules/credential-handler-polyfill/CredentialHandlers.js
|
|
1121
|
-
var
|
|
1289
|
+
var _CredentialHandlers = class _CredentialHandlers {
|
|
1122
1290
|
constructor(injector) {
|
|
1123
1291
|
this._init = (async () => {
|
|
1124
1292
|
this._injector = await injector;
|
|
@@ -1132,17 +1300,40 @@ var CredentialHandlers = class {
|
|
|
1132
1300
|
});
|
|
1133
1301
|
})();
|
|
1134
1302
|
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Creates a credential handler registration.
|
|
1305
|
+
*
|
|
1306
|
+
* @param url the unique URL for the credential handler.
|
|
1307
|
+
*
|
|
1308
|
+
* @return a Promise that resolves to the CredentialHandlerRegistration.
|
|
1309
|
+
*/
|
|
1135
1310
|
async register(url) {
|
|
1136
1311
|
this._deprecateNotice();
|
|
1137
1312
|
await this._init;
|
|
1138
1313
|
url = await this._remote.register("credential", url);
|
|
1139
1314
|
return new CredentialHandlerRegistration(url, this._injector);
|
|
1140
1315
|
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Unregisters a credential handler, destroying its registration.
|
|
1318
|
+
*
|
|
1319
|
+
* @param url the unique URL for the credential handler.
|
|
1320
|
+
*
|
|
1321
|
+
* @return a Promise that resolves to `true` if the handler was registered
|
|
1322
|
+
* and `false` if not.
|
|
1323
|
+
*/
|
|
1141
1324
|
async unregister(url) {
|
|
1142
1325
|
this._deprecateNotice();
|
|
1143
1326
|
await this._init;
|
|
1144
1327
|
return this._remote.unregister("credential", url);
|
|
1145
1328
|
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Gets an existing credential handler registration.
|
|
1331
|
+
*
|
|
1332
|
+
* @param url the URL for the credential handler.
|
|
1333
|
+
*
|
|
1334
|
+
* @return a Promise that resolves to the CredentialHandlerRegistration or
|
|
1335
|
+
* `null` if no such registration exists.
|
|
1336
|
+
*/
|
|
1146
1337
|
async getRegistration(url) {
|
|
1147
1338
|
this._deprecateNotice();
|
|
1148
1339
|
await this._init;
|
|
@@ -1152,6 +1343,15 @@ var CredentialHandlers = class {
|
|
|
1152
1343
|
}
|
|
1153
1344
|
return new CredentialHandlerRegistration(url, this._injector);
|
|
1154
1345
|
}
|
|
1346
|
+
/**
|
|
1347
|
+
* Returns true if the given credential handler has been registered and
|
|
1348
|
+
* false if not.
|
|
1349
|
+
*
|
|
1350
|
+
* @param url the URL for the credential handler.
|
|
1351
|
+
*
|
|
1352
|
+
* @return a Promise that resolves to `true` if the registration exists and
|
|
1353
|
+
* `false` if not.
|
|
1354
|
+
*/
|
|
1155
1355
|
async hasRegistration(url) {
|
|
1156
1356
|
this._deprecateNotice();
|
|
1157
1357
|
await this._init;
|
|
@@ -1163,10 +1363,11 @@ var CredentialHandlers = class {
|
|
|
1163
1363
|
);
|
|
1164
1364
|
}
|
|
1165
1365
|
};
|
|
1166
|
-
__name(
|
|
1366
|
+
__name(_CredentialHandlers, "CredentialHandlers");
|
|
1367
|
+
var CredentialHandlers = _CredentialHandlers;
|
|
1167
1368
|
|
|
1168
1369
|
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.2.1/node_modules/credential-handler-polyfill/WebCredential.js
|
|
1169
|
-
var
|
|
1370
|
+
var _WebCredential = class _WebCredential {
|
|
1170
1371
|
constructor(dataType, data, {
|
|
1171
1372
|
recommendedHandlerOrigins = [],
|
|
1172
1373
|
protocols = {}
|
|
@@ -1180,12 +1381,13 @@ var WebCredential2 = class {
|
|
|
1180
1381
|
this.options = { recommendedHandlerOrigins, protocols };
|
|
1181
1382
|
}
|
|
1182
1383
|
};
|
|
1183
|
-
__name(
|
|
1384
|
+
__name(_WebCredential, "WebCredential");
|
|
1385
|
+
var WebCredential2 = _WebCredential;
|
|
1184
1386
|
|
|
1185
1387
|
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.2.1/node_modules/credential-handler-polyfill/CredentialsContainer.js
|
|
1186
1388
|
var CREDENTIAL_GET_TIMEOUT = 0;
|
|
1187
1389
|
var CREDENTIAL_STORE_TIMEOUT = 0;
|
|
1188
|
-
var
|
|
1390
|
+
var _CredentialsContainer = class _CredentialsContainer {
|
|
1189
1391
|
constructor(injector) {
|
|
1190
1392
|
this._nativeCredentialsContainer = {
|
|
1191
1393
|
get: navigator.credentials && navigator.credentials.get && navigator.credentials.get.bind(navigator.credentials),
|
|
@@ -1229,11 +1431,12 @@ var CredentialsContainer = class {
|
|
|
1229
1431
|
throw new DOMException("Not implemented.", "NotSupportedError");
|
|
1230
1432
|
}
|
|
1231
1433
|
};
|
|
1232
|
-
__name(
|
|
1434
|
+
__name(_CredentialsContainer, "CredentialsContainer");
|
|
1435
|
+
var CredentialsContainer = _CredentialsContainer;
|
|
1233
1436
|
|
|
1234
1437
|
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.2.1/node_modules/credential-handler-polyfill/PermissionManager.js
|
|
1235
1438
|
var PERMISSION_REQUEST_TIMEOUT = 0;
|
|
1236
|
-
var
|
|
1439
|
+
var _PermissionManager = class _PermissionManager {
|
|
1237
1440
|
constructor(injector) {
|
|
1238
1441
|
this._init = (async () => {
|
|
1239
1442
|
this._remote = (await injector).get("permissionManager", {
|
|
@@ -1258,7 +1461,8 @@ var PermissionManager = class {
|
|
|
1258
1461
|
return await this._remote.revoke(permissionDesc);
|
|
1259
1462
|
}
|
|
1260
1463
|
};
|
|
1261
|
-
__name(
|
|
1464
|
+
__name(_PermissionManager, "PermissionManager");
|
|
1465
|
+
var PermissionManager = _PermissionManager;
|
|
1262
1466
|
|
|
1263
1467
|
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.2.1/node_modules/credential-handler-polyfill/index.js
|
|
1264
1468
|
var DEFAULT_MEDIATOR_ORIGIN = "https://authn.io";
|
|
@@ -1288,6 +1492,7 @@ async function load(options = {
|
|
|
1288
1492
|
const appContext = new WebAppContext();
|
|
1289
1493
|
const injector = appContext.createWindow(mediatorUrl, {
|
|
1290
1494
|
className: "credential-mediator",
|
|
1495
|
+
// 30 second timeout for loading the mediator
|
|
1291
1496
|
timeout: 3e4
|
|
1292
1497
|
});
|
|
1293
1498
|
const style = document.createElement("style");
|
|
@@ -1343,7 +1548,7 @@ __name(_assertSecureContext, "_assertSecureContext");
|
|
|
1343
1548
|
|
|
1344
1549
|
// ../../../node_modules/.pnpm/web-credential-handler@2.0.2/node_modules/web-credential-handler/CredentialEventProxy.js
|
|
1345
1550
|
var PROXY_EVENT_TIMEOUT = 6e4;
|
|
1346
|
-
var
|
|
1551
|
+
var _CredentialEventProxy = class _CredentialEventProxy extends WebApp {
|
|
1347
1552
|
constructor() {
|
|
1348
1553
|
super(window.location.origin);
|
|
1349
1554
|
}
|
|
@@ -1355,6 +1560,7 @@ var CredentialEventProxy = class extends WebApp {
|
|
|
1355
1560
|
rejectReceive(new Error("Timed out waiting to receive event."));
|
|
1356
1561
|
}, PROXY_EVENT_TIMEOUT);
|
|
1357
1562
|
self.server.define("credentialEventProxy", {
|
|
1563
|
+
// called by credential handler to send event to UI window
|
|
1358
1564
|
async send(event) {
|
|
1359
1565
|
resolveReceive(event);
|
|
1360
1566
|
clearTimeout(timeoutId);
|
|
@@ -1373,7 +1579,8 @@ var CredentialEventProxy = class extends WebApp {
|
|
|
1373
1579
|
});
|
|
1374
1580
|
}
|
|
1375
1581
|
};
|
|
1376
|
-
__name(
|
|
1582
|
+
__name(_CredentialEventProxy, "CredentialEventProxy");
|
|
1583
|
+
var CredentialEventProxy = _CredentialEventProxy;
|
|
1377
1584
|
|
|
1378
1585
|
// ../../../node_modules/.pnpm/web-credential-handler@2.0.2/node_modules/web-credential-handler/index.js
|
|
1379
1586
|
var DEFAULT_MEDIATOR = "https://authn.io";
|
|
@@ -1435,6 +1642,8 @@ async function createResponse({ event, get, store }) {
|
|
|
1435
1642
|
const windowReady = appContext.createWindow(result.url, {
|
|
1436
1643
|
handle,
|
|
1437
1644
|
popup: false,
|
|
1645
|
+
// default to 10 minute timeout for loading other window on same site
|
|
1646
|
+
// to allow for authentication pages and similar
|
|
1438
1647
|
timeout: 6e5
|
|
1439
1648
|
});
|
|
1440
1649
|
const injector = await windowReady;
|
|
@@ -1461,21 +1670,21 @@ var getCHAPIPlugin = /* @__PURE__ */ __name(async () => {
|
|
|
1461
1670
|
return {
|
|
1462
1671
|
name: "CHAPI",
|
|
1463
1672
|
methods: {
|
|
1464
|
-
installChapiHandler: async () => {
|
|
1673
|
+
installChapiHandler: /* @__PURE__ */ __name(async () => {
|
|
1465
1674
|
throw new Error("CHAPI is only available inside of a browser!");
|
|
1466
|
-
},
|
|
1467
|
-
activateChapiHandler: async () => {
|
|
1675
|
+
}, "installChapiHandler"),
|
|
1676
|
+
activateChapiHandler: /* @__PURE__ */ __name(async () => {
|
|
1468
1677
|
throw new Error("CHAPI is only available inside of a browser!");
|
|
1469
|
-
},
|
|
1470
|
-
receiveChapiEvent: async () => {
|
|
1678
|
+
}, "activateChapiHandler"),
|
|
1679
|
+
receiveChapiEvent: /* @__PURE__ */ __name(async () => {
|
|
1471
1680
|
throw new Error("CHAPI is only available inside of a browser!");
|
|
1472
|
-
},
|
|
1473
|
-
storeCredentialViaChapiDidAuth: async () => {
|
|
1681
|
+
}, "receiveChapiEvent"),
|
|
1682
|
+
storeCredentialViaChapiDidAuth: /* @__PURE__ */ __name(async () => {
|
|
1474
1683
|
throw new Error("CHAPI is only available inside of a browser!");
|
|
1475
|
-
},
|
|
1476
|
-
storePresentationViaChapi: async () => {
|
|
1684
|
+
}, "storeCredentialViaChapiDidAuth"),
|
|
1685
|
+
storePresentationViaChapi: /* @__PURE__ */ __name(async () => {
|
|
1477
1686
|
throw new Error("CHAPI is only available inside of a browser!");
|
|
1478
|
-
}
|
|
1687
|
+
}, "storePresentationViaChapi")
|
|
1479
1688
|
}
|
|
1480
1689
|
};
|
|
1481
1690
|
}
|
|
@@ -1489,8 +1698,8 @@ var getCHAPIPlugin = /* @__PURE__ */ __name(async () => {
|
|
|
1489
1698
|
displayName: "CHAPI",
|
|
1490
1699
|
description: "Credential Handler API. Allows sending/retrieving credentials across wallets and issuers",
|
|
1491
1700
|
methods: {
|
|
1492
|
-
installChapiHandler: async () => installHandler(),
|
|
1493
|
-
activateChapiHandler: async (_learnCard, {
|
|
1701
|
+
installChapiHandler: /* @__PURE__ */ __name(async () => installHandler(), "installChapiHandler"),
|
|
1702
|
+
activateChapiHandler: /* @__PURE__ */ __name(async (_learnCard, {
|
|
1494
1703
|
mediatorOrigin = `https://authn.io/mediator?${encodeURIComponent(
|
|
1495
1704
|
window.location.origin
|
|
1496
1705
|
)}`,
|
|
@@ -1498,9 +1707,9 @@ var getCHAPIPlugin = /* @__PURE__ */ __name(async () => {
|
|
|
1498
1707
|
store
|
|
1499
1708
|
}) => {
|
|
1500
1709
|
return activateHandler({ mediatorOrigin, get, store });
|
|
1501
|
-
},
|
|
1502
|
-
receiveChapiEvent: async () => receiveCredentialEvent(),
|
|
1503
|
-
storeCredentialViaChapiDidAuth: async (_learnCard, credential) => {
|
|
1710
|
+
}, "activateChapiHandler"),
|
|
1711
|
+
receiveChapiEvent: /* @__PURE__ */ __name(async () => receiveCredentialEvent(), "receiveChapiEvent"),
|
|
1712
|
+
storeCredentialViaChapiDidAuth: /* @__PURE__ */ __name(async (_learnCard, credential) => {
|
|
1504
1713
|
const challenge = crypto.randomUUID();
|
|
1505
1714
|
const domain = window.location.origin;
|
|
1506
1715
|
const vpr = {
|
|
@@ -1513,8 +1722,7 @@ var getCHAPIPlugin = /* @__PURE__ */ __name(async () => {
|
|
|
1513
1722
|
}
|
|
1514
1723
|
};
|
|
1515
1724
|
const res = await navigator.credentials.get(vpr);
|
|
1516
|
-
if (!res)
|
|
1517
|
-
return { success: false, reason: "did not auth" };
|
|
1725
|
+
if (!res) return { success: false, reason: "did not auth" };
|
|
1518
1726
|
const verification = await _learnCard.invoke.verifyPresentation(res.data, {
|
|
1519
1727
|
challenge,
|
|
1520
1728
|
domain,
|
|
@@ -1542,89 +1750,132 @@ var getCHAPIPlugin = /* @__PURE__ */ __name(async () => {
|
|
|
1542
1750
|
const vp = await _learnCard.invoke.getTestVp();
|
|
1543
1751
|
vp.verifiableCredential = issuedCredentials;
|
|
1544
1752
|
const success = await _learnCard.invoke.storePresentationViaChapi(vp);
|
|
1545
|
-
if (success)
|
|
1546
|
-
return { success: true };
|
|
1753
|
+
if (success) return { success: true };
|
|
1547
1754
|
return { success: false, reason: "did not store" };
|
|
1548
|
-
},
|
|
1549
|
-
storePresentationViaChapi: async (_learnCard, presentation) => {
|
|
1755
|
+
}, "storeCredentialViaChapiDidAuth"),
|
|
1756
|
+
storePresentationViaChapi: /* @__PURE__ */ __name(async (_learnCard, presentation) => {
|
|
1550
1757
|
const wc = new WebCredential("VerifiablePresentation", presentation);
|
|
1551
1758
|
return window.navigator.credentials.store(wc);
|
|
1552
|
-
}
|
|
1759
|
+
}, "storePresentationViaChapi")
|
|
1553
1760
|
}
|
|
1554
1761
|
};
|
|
1555
1762
|
}, "getCHAPIPlugin");
|
|
1556
|
-
/*!
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1763
|
+
/*! Bundled license information:
|
|
1764
|
+
|
|
1765
|
+
web-request-rpc/utils.js:
|
|
1766
|
+
(*!
|
|
1767
|
+
* Utilities for Web Request RPC.
|
|
1768
|
+
*
|
|
1769
|
+
* Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
|
|
1770
|
+
*)
|
|
1771
|
+
|
|
1772
|
+
web-request-rpc/Client.js:
|
|
1773
|
+
web-request-rpc/EventEmitter.js:
|
|
1774
|
+
web-request-rpc/Server.js:
|
|
1775
|
+
(*!
|
|
1776
|
+
* Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
|
|
1777
|
+
*)
|
|
1778
|
+
|
|
1779
|
+
web-request-rpc/WebApp.js:
|
|
1780
|
+
(*!
|
|
1781
|
+
* A WebApp is a remote application that runs in a WebAppContext.
|
|
1782
|
+
*
|
|
1783
|
+
* Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
|
|
1784
|
+
*)
|
|
1785
|
+
|
|
1786
|
+
web-request-rpc/WebAppWindowDialog.js:
|
|
1787
|
+
web-request-rpc/WebAppWindowInlineDialog.js:
|
|
1788
|
+
(*!
|
|
1789
|
+
* Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
|
|
1790
|
+
*)
|
|
1791
|
+
|
|
1792
|
+
web-request-rpc/WebAppWindowPopupDialog.js:
|
|
1793
|
+
(*!
|
|
1794
|
+
* Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
|
|
1795
|
+
*)
|
|
1796
|
+
|
|
1797
|
+
web-request-rpc/WebAppWindow.js:
|
|
1798
|
+
(*!
|
|
1799
|
+
* Copyright (c) 2017-2023 Digital Bazaar, Inc. All rights reserved.
|
|
1800
|
+
*)
|
|
1801
|
+
|
|
1802
|
+
web-request-rpc/WebAppContext.js:
|
|
1803
|
+
credential-handler-polyfill/CredentialHandlerService.js:
|
|
1804
|
+
credential-handler-polyfill/CredentialHints.js:
|
|
1805
|
+
credential-handler-polyfill/CredentialManager.js:
|
|
1806
|
+
credential-handler-polyfill/CredentialHandlers.js:
|
|
1807
|
+
credential-handler-polyfill/PermissionManager.js:
|
|
1808
|
+
(*!
|
|
1809
|
+
* Copyright (c) 2017-2022 Digital Bazaar, Inc. All rights reserved.
|
|
1810
|
+
*)
|
|
1811
|
+
|
|
1812
|
+
web-request-rpc/index.js:
|
|
1813
|
+
(*!
|
|
1814
|
+
* JSON-RPC for Web Request Polyfills.
|
|
1815
|
+
*
|
|
1816
|
+
* Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
|
|
1817
|
+
*)
|
|
1818
|
+
|
|
1819
|
+
credential-handler-polyfill/CredentialRequestEvent.js:
|
|
1820
|
+
(*!
|
|
1821
|
+
* A CredentialRequestEvent is emitted when a request has been made for
|
|
1822
|
+
* credentials.
|
|
1823
|
+
*
|
|
1824
|
+
* Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
|
|
1825
|
+
*)
|
|
1826
|
+
|
|
1827
|
+
credential-handler-polyfill/CredentialStoreEvent.js:
|
|
1828
|
+
(*!
|
|
1829
|
+
* A CredentialStoreEvent is emitted when a request has been made to
|
|
1830
|
+
* store a credential.
|
|
1831
|
+
*
|
|
1832
|
+
* Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
|
|
1833
|
+
*)
|
|
1834
|
+
|
|
1835
|
+
credential-handler-polyfill/CredentialHandler.js:
|
|
1836
|
+
(*!
|
|
1837
|
+
* The core CredentialHandler class.
|
|
1838
|
+
*
|
|
1839
|
+
* Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
|
|
1840
|
+
*)
|
|
1841
|
+
|
|
1842
|
+
credential-handler-polyfill/CredentialHandlerRegistration.js:
|
|
1843
|
+
(*!
|
|
1844
|
+
* A CredentialHandlerRegistration provides a CredentialManager to enable Web
|
|
1845
|
+
* apps to register Profiles that can be presented to websites.
|
|
1846
|
+
*
|
|
1847
|
+
* Copyright (c) 2017 Digital Bazaar, Inc. All rights reserved.
|
|
1848
|
+
*)
|
|
1849
|
+
|
|
1850
|
+
credential-handler-polyfill/WebCredential.js:
|
|
1851
|
+
(*!
|
|
1852
|
+
* A WebCredential is a Credential that can be retrieved from or stored by a
|
|
1853
|
+
* "credential handler" that runs in a third party Web application.
|
|
1854
|
+
*
|
|
1855
|
+
* Copyright (c) 2017-2023 Digital Bazaar, Inc. All rights reserved.
|
|
1856
|
+
*)
|
|
1857
|
+
|
|
1858
|
+
credential-handler-polyfill/CredentialsContainer.js:
|
|
1859
|
+
(*!
|
|
1860
|
+
* Wrapper for native CredentialsContainer that uses remote Credential Mediator
|
|
1861
|
+
* for WebCredential-related operations.
|
|
1862
|
+
*
|
|
1863
|
+
* Copyright (c) 2017-2018 Digital Bazaar, Inc. All rights reserved.
|
|
1864
|
+
*)
|
|
1865
|
+
|
|
1866
|
+
credential-handler-polyfill/index.js:
|
|
1867
|
+
(*!
|
|
1868
|
+
* Copyright (c) 2017-2024 Digital Bazaar, Inc. All rights reserved.
|
|
1869
|
+
*)
|
|
1870
|
+
|
|
1871
|
+
web-credential-handler/CredentialEventProxy.js:
|
|
1872
|
+
(*!
|
|
1873
|
+
* Copyright (c) 2017-2018 Digital Bazaar, Inc. All rights reserved.
|
|
1874
|
+
*)
|
|
1875
|
+
|
|
1876
|
+
web-credential-handler/index.js:
|
|
1877
|
+
(*!
|
|
1878
|
+
* Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
|
|
1879
|
+
*)
|
|
1880
|
+
*/
|
|
1630
1881
|
//# sourceMappingURL=chapi-plugin.cjs.development.js.map
|