@learncard/chapi-plugin 1.0.27 → 1.0.29

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.
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -280,7 +281,9 @@ var Injector = class {
280
281
  throw new TypeError("`name` must be a non-empty string.");
281
282
  }
282
283
  if (!(definition && typeof definition === "object" && Array.isArray(definition.functions))) {
283
- throw new TypeError("`definition.function` must be an array of function names or function definition objects to be defined.");
284
+ throw new TypeError(
285
+ "`definition.function` must be an array of function names or function definition objects to be defined."
286
+ );
284
287
  }
285
288
  const self = this;
286
289
  const api = {};
@@ -289,7 +292,11 @@ var Injector = class {
289
292
  fn = { name: fn, options: {} };
290
293
  }
291
294
  api[fn.name] = async function() {
292
- return self.client.send(name + "." + fn.name, [...arguments], fn.options);
295
+ return self.client.send(
296
+ name + "." + fn.name,
297
+ [...arguments],
298
+ fn.options
299
+ );
293
300
  };
294
301
  });
295
302
  self._apis[name] = api;
@@ -466,13 +473,17 @@ var WebApp = class {
466
473
  }
467
474
  async show() {
468
475
  if (!this._connected) {
469
- throw new Error('Cannot "show" yet; not connected. Did you call ".connect()"?');
476
+ throw new Error(
477
+ 'Cannot "show" yet; not connected. Did you call ".connect()"?'
478
+ );
470
479
  }
471
480
  return this._control.show();
472
481
  }
473
482
  async hide() {
474
483
  if (!this._connected) {
475
- throw new Error('Cannot "hide" yet; not connected. Did you call ".connect()?"');
484
+ throw new Error(
485
+ 'Cannot "hide" yet; not connected. Did you call ".connect()?"'
486
+ );
476
487
  }
477
488
  return this._control.hide();
478
489
  }
@@ -546,9 +557,11 @@ var WebAppWindowInlineDialog = class extends WebAppWindowDialog {
546
557
  this.dialog.className = this.dialog.className + " " + className;
547
558
  }
548
559
  const style = document.createElement("style");
549
- style.appendChild(document.createTextNode(`dialog.web-app-window::backdrop {
560
+ style.appendChild(
561
+ document.createTextNode(`dialog.web-app-window::backdrop {
550
562
  background-color: transparent;
551
- }`));
563
+ }`)
564
+ );
552
565
  this.container = document.createElement("div");
553
566
  applyStyle(this.container, {
554
567
  position: "relative",
@@ -731,7 +744,13 @@ var WebAppWindow = class {
731
744
  this.dialog = dialog = handle._dialog;
732
745
  }
733
746
  this._private._readyPromise = new Promise((resolve, reject) => {
734
- this._timeoutId = setTimeout(() => reject(new DOMException("Loading Web application window timed out.", "TimeoutError")), timeout);
747
+ this._timeoutId = setTimeout(
748
+ () => reject(new DOMException(
749
+ "Loading Web application window timed out.",
750
+ "TimeoutError"
751
+ )),
752
+ timeout
753
+ );
735
754
  this._private._resolveReady = (value) => {
736
755
  clearTimeout(this.timeoutId);
737
756
  this._timeoutId = null;
@@ -748,7 +767,10 @@ var WebAppWindow = class {
748
767
  };
749
768
  this._private.destroy = () => {
750
769
  if (this._timeoutId) {
751
- this._private._rejectReady(new DOMException("Web application window closed before ready.", "AbortError"));
770
+ this._private._rejectReady(new DOMException(
771
+ "Web application window closed before ready.",
772
+ "AbortError"
773
+ ));
752
774
  }
753
775
  if (!this._destroyed) {
754
776
  this.dialog.destroy();
@@ -952,10 +974,20 @@ var CredentialHandlerService = class {
952
974
  this._credentialHandler = credentialHandler;
953
975
  }
954
976
  async request(credentialRequestEvent) {
955
- return await this._credentialHandler._emitter.emit(new CredentialRequestEvent(Object.assign({ credentialHandler: this._credentialHandler }, credentialRequestEvent)));
977
+ return await this._credentialHandler._emitter.emit(
978
+ new CredentialRequestEvent(Object.assign(
979
+ { credentialHandler: this._credentialHandler },
980
+ credentialRequestEvent
981
+ ))
982
+ );
956
983
  }
957
984
  async store(credentialStoreEvent) {
958
- return await this._credentialHandler._emitter.emit(new CredentialStoreEvent(Object.assign({ credentialHandler: this._credentialHandler }, credentialStoreEvent)));
985
+ return await this._credentialHandler._emitter.emit(
986
+ new CredentialStoreEvent(Object.assign(
987
+ { credentialHandler: this._credentialHandler },
988
+ credentialStoreEvent
989
+ ))
990
+ );
959
991
  }
960
992
  };
961
993
  __name(CredentialHandlerService, "CredentialHandlerService");
@@ -970,7 +1002,12 @@ var CredentialHandler = class extends WebApp {
970
1002
  super(mediatorOrigin, inline);
971
1003
  this._emitter = new EventEmitter({
972
1004
  async waitUntil(event) {
973
- return event._promise || Promise.reject(new DOMException('No "credentialrequest" event handler found.', "NotFoundError"));
1005
+ return event._promise || Promise.reject(
1006
+ new DOMException(
1007
+ 'No "credentialrequest" event handler found.',
1008
+ "NotFoundError"
1009
+ )
1010
+ );
974
1011
  }
975
1012
  });
976
1013
  }
@@ -982,13 +1019,19 @@ var CredentialHandler = class extends WebApp {
982
1019
  }
983
1020
  addEventListener(eventType, fn) {
984
1021
  if (!EVENT_TYPES.includes(eventType)) {
985
- throw new DOMException(`Unsupported event type "${eventType}"`, "NotSupportedError");
1022
+ throw new DOMException(
1023
+ `Unsupported event type "${eventType}"`,
1024
+ "NotSupportedError"
1025
+ );
986
1026
  }
987
1027
  return this._emitter.addEventListener(eventType, fn);
988
1028
  }
989
1029
  removeEventListener(eventType, fn) {
990
1030
  if (!EVENT_TYPES.includes(eventType)) {
991
- throw new DOMException(`Unsupported event type "${eventType}"`, "NotSupportedError");
1031
+ throw new DOMException(
1032
+ `Unsupported event type "${eventType}"`,
1033
+ "NotSupportedError"
1034
+ );
992
1035
  }
993
1036
  return this._emitter.removeEventListener(eventType, fn);
994
1037
  }
@@ -1055,7 +1098,9 @@ var CredentialManager = class {
1055
1098
  this.hints = new CredentialHints(url, injector);
1056
1099
  }
1057
1100
  static async requestPermission() {
1058
- const status = await navigator.credentialsPolyfill.permissions.request({ name: "credentialhandler" });
1101
+ const status = await navigator.credentialsPolyfill.permissions.request(
1102
+ { name: "credentialhandler" }
1103
+ );
1059
1104
  return status.state;
1060
1105
  }
1061
1106
  };
@@ -1113,7 +1158,9 @@ var CredentialHandlers = class {
1113
1158
  return await this._remote.hasRegistration("credential", url);
1114
1159
  }
1115
1160
  _deprecateNotice() {
1116
- console.warn('Credential handler registration APIs are deprecated. The credential handler specified in "manifest.json" is now automatically registered when a user grants permission to install a credential handler via "CredentialManager.requestPermission()".');
1161
+ console.warn(
1162
+ 'Credential handler registration APIs are deprecated. The credential handler specified in "manifest.json" is now automatically registered when a user grants permission to install a credential handler via "CredentialManager.requestPermission()".'
1163
+ );
1117
1164
  }
1118
1165
  };
1119
1166
  __name(CredentialHandlers, "CredentialHandlers");
@@ -1234,7 +1281,9 @@ async function load(options = {
1234
1281
  } else if (options && typeof options === "object" && typeof options.mediatorOrigin === "string") {
1235
1282
  mediatorUrl = `${options.mediatorOrigin}/mediator`;
1236
1283
  } else {
1237
- throw new Error('"options.mediatorOrigin" must be a string expressing the origin of the mediator.');
1284
+ throw new Error(
1285
+ '"options.mediatorOrigin" must be a string expressing the origin of the mediator.'
1286
+ );
1238
1287
  }
1239
1288
  const appContext = new WebAppContext();
1240
1289
  const injector = appContext.createWindow(mediatorUrl, {
@@ -1242,9 +1291,11 @@ async function load(options = {
1242
1291
  timeout: 3e4
1243
1292
  });
1244
1293
  const style = document.createElement("style");
1245
- style.appendChild(document.createTextNode(`dialog.web-app-window.credential-mediator > .web-app-window-backdrop {
1294
+ style.appendChild(document.createTextNode(
1295
+ `dialog.web-app-window.credential-mediator > .web-app-window-backdrop {
1246
1296
  background-color: rgba(0, 0, 0, 0.25);
1247
- }`));
1297
+ }`
1298
+ ));
1248
1299
  document.body.appendChild(style);
1249
1300
  const polyfill = {};
1250
1301
  polyfill.permissions = new PermissionManager(injector);
@@ -1255,8 +1306,12 @@ async function load(options = {
1255
1306
  polyfill.WebCredential = WebCredential2;
1256
1307
  navigator.credentialsPolyfill = polyfill;
1257
1308
  if ("credentials" in navigator) {
1258
- navigator.credentials.get = polyfill.credentials.get.bind(polyfill.credentials);
1259
- navigator.credentials.store = polyfill.credentials.store.bind(polyfill.credentials);
1309
+ navigator.credentials.get = polyfill.credentials.get.bind(
1310
+ polyfill.credentials
1311
+ );
1312
+ navigator.credentials.store = polyfill.credentials.store.bind(
1313
+ polyfill.credentials
1314
+ );
1260
1315
  } else {
1261
1316
  navigator.credentials = polyfill.credentials;
1262
1317
  }
@@ -1286,7 +1341,7 @@ function _assertSecureContext() {
1286
1341
  }
1287
1342
  __name(_assertSecureContext, "_assertSecureContext");
1288
1343
 
1289
- // ../../../node_modules/.pnpm/web-credential-handler@2.0.0/node_modules/web-credential-handler/CredentialEventProxy.js
1344
+ // ../../../node_modules/.pnpm/web-credential-handler@2.0.2/node_modules/web-credential-handler/CredentialEventProxy.js
1290
1345
  var PROXY_EVENT_TIMEOUT = 6e4;
1291
1346
  var CredentialEventProxy = class extends WebApp {
1292
1347
  constructor() {
@@ -1320,7 +1375,7 @@ var CredentialEventProxy = class extends WebApp {
1320
1375
  };
1321
1376
  __name(CredentialEventProxy, "CredentialEventProxy");
1322
1377
 
1323
- // ../../../node_modules/.pnpm/web-credential-handler@2.0.0/node_modules/web-credential-handler/index.js
1378
+ // ../../../node_modules/.pnpm/web-credential-handler@2.0.2/node_modules/web-credential-handler/index.js
1324
1379
  var DEFAULT_MEDIATOR = "https://authn.io";
1325
1380
  async function installHandler() {
1326
1381
  const CredentialManager2 = navigator.credentialsPolyfill.CredentialManager;
@@ -1367,7 +1422,9 @@ __name(listener, "listener");
1367
1422
  async function createResponse({ event, get, store }) {
1368
1423
  const result = await (get || store)({ event });
1369
1424
  if (!(result && typeof result === "object")) {
1370
- throw new TypeError('Return value of "get" or "store" hook must be an object.');
1425
+ throw new TypeError(
1426
+ 'Return value of "get" or "store" hook must be an object.'
1427
+ );
1371
1428
  }
1372
1429
  if (result.type === "response") {
1373
1430
  return { dataType: result.dataType, data: result.data };
@@ -1392,7 +1449,9 @@ async function createResponse({ event, get, store }) {
1392
1449
  hintKey: event.hintKey
1393
1450
  });
1394
1451
  }
1395
- throw new Error('Return value of "get" or "store" must have a type of "response" or "redirect".');
1452
+ throw new Error(
1453
+ 'Return value of "get" or "store" must have a type of "response" or "redirect".'
1454
+ );
1396
1455
  }
1397
1456
  __name(createResponse, "createResponse");
1398
1457
 
@@ -1432,7 +1491,9 @@ var getCHAPIPlugin = /* @__PURE__ */ __name(async () => {
1432
1491
  methods: {
1433
1492
  installChapiHandler: async () => installHandler(),
1434
1493
  activateChapiHandler: async (_learnCard, {
1435
- mediatorOrigin = `https://authn.io/mediator?${encodeURIComponent(window.location.origin)}`,
1494
+ mediatorOrigin = `https://authn.io/mediator?${encodeURIComponent(
1495
+ window.location.origin
1496
+ )}`,
1436
1497
  get,
1437
1498
  store
1438
1499
  }) => {