@learncard/chapi-plugin 1.0.3 → 1.0.5
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 +38 -108
- package/dist/chapi-plugin.cjs.development.js.map +4 -4
- package/dist/chapi-plugin.cjs.production.min.js +3 -3
- package/dist/chapi-plugin.cjs.production.min.js.map +4 -4
- package/dist/chapi-plugin.esm.js +38 -107
- package/dist/chapi-plugin.esm.js.map +4 -4
- package/package.json +4 -4
@@ -1,4 +1,3 @@
|
|
1
|
-
"use strict";
|
2
1
|
var __defProp = Object.defineProperty;
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
@@ -281,9 +280,7 @@ var Injector = class {
|
|
281
280
|
throw new TypeError("`name` must be a non-empty string.");
|
282
281
|
}
|
283
282
|
if (!(definition && typeof definition === "object" && Array.isArray(definition.functions))) {
|
284
|
-
throw new TypeError(
|
285
|
-
"`definition.function` must be an array of function names or function definition objects to be defined."
|
286
|
-
);
|
283
|
+
throw new TypeError("`definition.function` must be an array of function names or function definition objects to be defined.");
|
287
284
|
}
|
288
285
|
const self = this;
|
289
286
|
const api = {};
|
@@ -292,11 +289,7 @@ var Injector = class {
|
|
292
289
|
fn = { name: fn, options: {} };
|
293
290
|
}
|
294
291
|
api[fn.name] = async function() {
|
295
|
-
return self.client.send(
|
296
|
-
name + "." + fn.name,
|
297
|
-
[...arguments],
|
298
|
-
fn.options
|
299
|
-
);
|
292
|
+
return self.client.send(name + "." + fn.name, [...arguments], fn.options);
|
300
293
|
};
|
301
294
|
});
|
302
295
|
self._apis[name] = api;
|
@@ -473,17 +466,13 @@ var WebApp = class {
|
|
473
466
|
}
|
474
467
|
async show() {
|
475
468
|
if (!this._connected) {
|
476
|
-
throw new Error(
|
477
|
-
'Cannot "show" yet; not connected. Did you call ".connect()"?'
|
478
|
-
);
|
469
|
+
throw new Error('Cannot "show" yet; not connected. Did you call ".connect()"?');
|
479
470
|
}
|
480
471
|
return this._control.show();
|
481
472
|
}
|
482
473
|
async hide() {
|
483
474
|
if (!this._connected) {
|
484
|
-
throw new Error(
|
485
|
-
'Cannot "hide" yet; not connected. Did you call ".connect()?"'
|
486
|
-
);
|
475
|
+
throw new Error('Cannot "hide" yet; not connected. Did you call ".connect()?"');
|
487
476
|
}
|
488
477
|
return this._control.hide();
|
489
478
|
}
|
@@ -557,11 +546,9 @@ var WebAppWindowInlineDialog = class extends WebAppWindowDialog {
|
|
557
546
|
this.dialog.className = this.dialog.className + " " + className;
|
558
547
|
}
|
559
548
|
const style = document.createElement("style");
|
560
|
-
style.appendChild(
|
561
|
-
document.createTextNode(`dialog.web-app-window::backdrop {
|
549
|
+
style.appendChild(document.createTextNode(`dialog.web-app-window::backdrop {
|
562
550
|
background-color: transparent;
|
563
|
-
}`)
|
564
|
-
);
|
551
|
+
}`));
|
565
552
|
this.container = document.createElement("div");
|
566
553
|
applyStyle(this.container, {
|
567
554
|
position: "relative",
|
@@ -744,13 +731,7 @@ var WebAppWindow = class {
|
|
744
731
|
this.dialog = dialog = handle._dialog;
|
745
732
|
}
|
746
733
|
this._private._readyPromise = new Promise((resolve, reject) => {
|
747
|
-
this._timeoutId = setTimeout(
|
748
|
-
() => reject(new DOMException(
|
749
|
-
"Loading Web application window timed out.",
|
750
|
-
"TimeoutError"
|
751
|
-
)),
|
752
|
-
timeout
|
753
|
-
);
|
734
|
+
this._timeoutId = setTimeout(() => reject(new DOMException("Loading Web application window timed out.", "TimeoutError")), timeout);
|
754
735
|
this._private._resolveReady = (value) => {
|
755
736
|
clearTimeout(this.timeoutId);
|
756
737
|
this._timeoutId = null;
|
@@ -767,10 +748,7 @@ var WebAppWindow = class {
|
|
767
748
|
};
|
768
749
|
this._private.destroy = () => {
|
769
750
|
if (this._timeoutId) {
|
770
|
-
this._private._rejectReady(new DOMException(
|
771
|
-
"Web application window closed before ready.",
|
772
|
-
"AbortError"
|
773
|
-
));
|
751
|
+
this._private._rejectReady(new DOMException("Web application window closed before ready.", "AbortError"));
|
774
752
|
}
|
775
753
|
if (!this._destroyed) {
|
776
754
|
this.dialog.destroy();
|
@@ -910,7 +888,7 @@ var WebAppContext = class {
|
|
910
888
|
};
|
911
889
|
__name(WebAppContext, "WebAppContext");
|
912
890
|
|
913
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
891
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialRequestEvent.js
|
914
892
|
var CredentialRequestEvent = class {
|
915
893
|
constructor({
|
916
894
|
credentialHandler,
|
@@ -940,7 +918,7 @@ var CredentialRequestEvent = class {
|
|
940
918
|
};
|
941
919
|
__name(CredentialRequestEvent, "CredentialRequestEvent");
|
942
920
|
|
943
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
921
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialStoreEvent.js
|
944
922
|
var CredentialStoreEvent = class {
|
945
923
|
constructor({
|
946
924
|
credentialHandler,
|
@@ -968,31 +946,21 @@ var CredentialStoreEvent = class {
|
|
968
946
|
};
|
969
947
|
__name(CredentialStoreEvent, "CredentialStoreEvent");
|
970
948
|
|
971
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
949
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandlerService.js
|
972
950
|
var CredentialHandlerService = class {
|
973
951
|
constructor(credentialHandler) {
|
974
952
|
this._credentialHandler = credentialHandler;
|
975
953
|
}
|
976
954
|
async request(credentialRequestEvent) {
|
977
|
-
return await this._credentialHandler._emitter.emit(
|
978
|
-
new CredentialRequestEvent(Object.assign(
|
979
|
-
{ credentialHandler: this._credentialHandler },
|
980
|
-
credentialRequestEvent
|
981
|
-
))
|
982
|
-
);
|
955
|
+
return await this._credentialHandler._emitter.emit(new CredentialRequestEvent(Object.assign({ credentialHandler: this._credentialHandler }, credentialRequestEvent)));
|
983
956
|
}
|
984
957
|
async store(credentialStoreEvent) {
|
985
|
-
return await this._credentialHandler._emitter.emit(
|
986
|
-
new CredentialStoreEvent(Object.assign(
|
987
|
-
{ credentialHandler: this._credentialHandler },
|
988
|
-
credentialStoreEvent
|
989
|
-
))
|
990
|
-
);
|
958
|
+
return await this._credentialHandler._emitter.emit(new CredentialStoreEvent(Object.assign({ credentialHandler: this._credentialHandler }, credentialStoreEvent)));
|
991
959
|
}
|
992
960
|
};
|
993
961
|
__name(CredentialHandlerService, "CredentialHandlerService");
|
994
962
|
|
995
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
963
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandler.js
|
996
964
|
var EVENT_TYPES = ["credentialrequest", "credentialstore"];
|
997
965
|
var CredentialHandler = class extends WebApp {
|
998
966
|
constructor(mediatorOrigin, inline = false) {
|
@@ -1002,12 +970,7 @@ var CredentialHandler = class extends WebApp {
|
|
1002
970
|
super(mediatorOrigin, inline);
|
1003
971
|
this._emitter = new EventEmitter({
|
1004
972
|
async waitUntil(event) {
|
1005
|
-
return event._promise || Promise.reject(
|
1006
|
-
new DOMException(
|
1007
|
-
'No "credentialrequest" event handler found.',
|
1008
|
-
"NotFoundError"
|
1009
|
-
)
|
1010
|
-
);
|
973
|
+
return event._promise || Promise.reject(new DOMException('No "credentialrequest" event handler found.', "NotFoundError"));
|
1011
974
|
}
|
1012
975
|
});
|
1013
976
|
}
|
@@ -1019,26 +982,20 @@ var CredentialHandler = class extends WebApp {
|
|
1019
982
|
}
|
1020
983
|
addEventListener(eventType, fn) {
|
1021
984
|
if (!EVENT_TYPES.includes(eventType)) {
|
1022
|
-
throw new DOMException(
|
1023
|
-
`Unsupported event type "${eventType}"`,
|
1024
|
-
"NotSupportedError"
|
1025
|
-
);
|
985
|
+
throw new DOMException(`Unsupported event type "${eventType}"`, "NotSupportedError");
|
1026
986
|
}
|
1027
987
|
return this._emitter.addEventListener(eventType, fn);
|
1028
988
|
}
|
1029
989
|
removeEventListener(eventType, fn) {
|
1030
990
|
if (!EVENT_TYPES.includes(eventType)) {
|
1031
|
-
throw new DOMException(
|
1032
|
-
`Unsupported event type "${eventType}"`,
|
1033
|
-
"NotSupportedError"
|
1034
|
-
);
|
991
|
+
throw new DOMException(`Unsupported event type "${eventType}"`, "NotSupportedError");
|
1035
992
|
}
|
1036
993
|
return this._emitter.removeEventListener(eventType, fn);
|
1037
994
|
}
|
1038
995
|
};
|
1039
996
|
__name(CredentialHandler, "CredentialHandler");
|
1040
997
|
|
1041
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
998
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHints.js
|
1042
999
|
var CredentialHints = class {
|
1043
1000
|
constructor(url, injector) {
|
1044
1001
|
const remote = injector.get("credentialHints", {
|
@@ -1089,7 +1046,7 @@ function imageToDataUrl(url) {
|
|
1089
1046
|
}
|
1090
1047
|
__name(imageToDataUrl, "imageToDataUrl");
|
1091
1048
|
|
1092
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
1049
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialManager.js
|
1093
1050
|
var CredentialManager = class {
|
1094
1051
|
constructor(url, injector) {
|
1095
1052
|
if (!(url && typeof url === "string")) {
|
@@ -1098,15 +1055,13 @@ var CredentialManager = class {
|
|
1098
1055
|
this.hints = new CredentialHints(url, injector);
|
1099
1056
|
}
|
1100
1057
|
static async requestPermission() {
|
1101
|
-
const status = await navigator.credentialsPolyfill.permissions.request(
|
1102
|
-
{ name: "credentialhandler" }
|
1103
|
-
);
|
1058
|
+
const status = await navigator.credentialsPolyfill.permissions.request({ name: "credentialhandler" });
|
1104
1059
|
return status.state;
|
1105
1060
|
}
|
1106
1061
|
};
|
1107
1062
|
__name(CredentialManager, "CredentialManager");
|
1108
1063
|
|
1109
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
1064
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandlerRegistration.js
|
1110
1065
|
var CredentialHandlerRegistration = class {
|
1111
1066
|
constructor(url, injector) {
|
1112
1067
|
if (!(url && typeof url === "string")) {
|
@@ -1117,7 +1072,7 @@ var CredentialHandlerRegistration = class {
|
|
1117
1072
|
};
|
1118
1073
|
__name(CredentialHandlerRegistration, "CredentialHandlerRegistration");
|
1119
1074
|
|
1120
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
1075
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandlers.js
|
1121
1076
|
var CredentialHandlers = class {
|
1122
1077
|
constructor(injector) {
|
1123
1078
|
this._init = (async () => {
|
@@ -1158,14 +1113,12 @@ var CredentialHandlers = class {
|
|
1158
1113
|
return await this._remote.hasRegistration("credential", url);
|
1159
1114
|
}
|
1160
1115
|
_deprecateNotice() {
|
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
|
-
);
|
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()".');
|
1164
1117
|
}
|
1165
1118
|
};
|
1166
1119
|
__name(CredentialHandlers, "CredentialHandlers");
|
1167
1120
|
|
1168
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
1121
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/WebCredential.js
|
1169
1122
|
var WebCredential2 = class {
|
1170
1123
|
constructor(dataType, data, { recommendedHandlerOrigins = [] } = {}) {
|
1171
1124
|
if (typeof dataType !== "string") {
|
@@ -1179,7 +1132,7 @@ var WebCredential2 = class {
|
|
1179
1132
|
};
|
1180
1133
|
__name(WebCredential2, "WebCredential");
|
1181
1134
|
|
1182
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
1135
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialsContainer.js
|
1183
1136
|
var CREDENTIAL_GET_TIMEOUT = 0;
|
1184
1137
|
var CREDENTIAL_STORE_TIMEOUT = 0;
|
1185
1138
|
var CredentialsContainer = class {
|
@@ -1228,7 +1181,7 @@ var CredentialsContainer = class {
|
|
1228
1181
|
};
|
1229
1182
|
__name(CredentialsContainer, "CredentialsContainer");
|
1230
1183
|
|
1231
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
1184
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/PermissionManager.js
|
1232
1185
|
var PERMISSION_REQUEST_TIMEOUT = 0;
|
1233
1186
|
var PermissionManager = class {
|
1234
1187
|
constructor(injector) {
|
@@ -1257,7 +1210,7 @@ var PermissionManager = class {
|
|
1257
1210
|
};
|
1258
1211
|
__name(PermissionManager, "PermissionManager");
|
1259
1212
|
|
1260
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
1213
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/index.js
|
1261
1214
|
var DEFAULT_MEDIATOR_ORIGIN = "https://authn.io";
|
1262
1215
|
var loaded;
|
1263
1216
|
async function loadOnce(options) {
|
@@ -1271,16 +1224,13 @@ __name(loadOnce, "loadOnce");
|
|
1271
1224
|
async function load(options = {
|
1272
1225
|
mediatorOrigin: DEFAULT_MEDIATOR_ORIGIN
|
1273
1226
|
}) {
|
1274
|
-
_assertSecureContext();
|
1275
1227
|
let mediatorUrl;
|
1276
1228
|
if (typeof options === "string") {
|
1277
1229
|
mediatorUrl = options;
|
1278
1230
|
} else if (options && typeof options === "object" && typeof options.mediatorOrigin === "string") {
|
1279
1231
|
mediatorUrl = `${options.mediatorOrigin}/mediator`;
|
1280
1232
|
} else {
|
1281
|
-
throw new Error(
|
1282
|
-
'"options.mediatorOrigin" must be a string expressing the origin of the mediator.'
|
1283
|
-
);
|
1233
|
+
throw new Error('"options.mediatorOrigin" must be a string expressing the origin of the mediator.');
|
1284
1234
|
}
|
1285
1235
|
const appContext = new WebAppContext();
|
1286
1236
|
const injector = appContext.createWindow(mediatorUrl, {
|
@@ -1288,11 +1238,9 @@ async function load(options = {
|
|
1288
1238
|
timeout: 3e4
|
1289
1239
|
});
|
1290
1240
|
const style = document.createElement("style");
|
1291
|
-
style.appendChild(document.createTextNode(
|
1292
|
-
`dialog.web-app-window.credential-mediator > .web-app-window-backdrop {
|
1241
|
+
style.appendChild(document.createTextNode(`dialog.web-app-window.credential-mediator > .web-app-window-backdrop {
|
1293
1242
|
background-color: rgba(0, 0, 0, 0.25);
|
1294
|
-
}`
|
1295
|
-
));
|
1243
|
+
}`));
|
1296
1244
|
document.body.appendChild(style);
|
1297
1245
|
const polyfill = {};
|
1298
1246
|
polyfill.permissions = new PermissionManager(injector);
|
@@ -1303,12 +1251,8 @@ async function load(options = {
|
|
1303
1251
|
polyfill.WebCredential = WebCredential2;
|
1304
1252
|
navigator.credentialsPolyfill = polyfill;
|
1305
1253
|
if ("credentials" in navigator) {
|
1306
|
-
navigator.credentials.get = polyfill.credentials.get.bind(
|
1307
|
-
|
1308
|
-
);
|
1309
|
-
navigator.credentials.store = polyfill.credentials.store.bind(
|
1310
|
-
polyfill.credentials
|
1311
|
-
);
|
1254
|
+
navigator.credentials.get = polyfill.credentials.get.bind(polyfill.credentials);
|
1255
|
+
navigator.credentials.store = polyfill.credentials.store.bind(polyfill.credentials);
|
1312
1256
|
} else {
|
1313
1257
|
navigator.credentials = polyfill.credentials;
|
1314
1258
|
}
|
@@ -1317,14 +1261,8 @@ async function load(options = {
|
|
1317
1261
|
return polyfill;
|
1318
1262
|
}
|
1319
1263
|
__name(load, "load");
|
1320
|
-
function _assertSecureContext() {
|
1321
|
-
if (!window.isSecureContext) {
|
1322
|
-
throw new DOMException("SecurityError", "The operation is insecure.");
|
1323
|
-
}
|
1324
|
-
}
|
1325
|
-
__name(_assertSecureContext, "_assertSecureContext");
|
1326
1264
|
|
1327
|
-
// ../../../node_modules/.pnpm/web-credential-handler@2.0.
|
1265
|
+
// ../../../node_modules/.pnpm/web-credential-handler@2.0.0/node_modules/web-credential-handler/CredentialEventProxy.js
|
1328
1266
|
var PROXY_EVENT_TIMEOUT = 6e4;
|
1329
1267
|
var CredentialEventProxy = class extends WebApp {
|
1330
1268
|
constructor() {
|
@@ -1358,7 +1296,7 @@ var CredentialEventProxy = class extends WebApp {
|
|
1358
1296
|
};
|
1359
1297
|
__name(CredentialEventProxy, "CredentialEventProxy");
|
1360
1298
|
|
1361
|
-
// ../../../node_modules/.pnpm/web-credential-handler@2.0.
|
1299
|
+
// ../../../node_modules/.pnpm/web-credential-handler@2.0.0/node_modules/web-credential-handler/index.js
|
1362
1300
|
var DEFAULT_MEDIATOR = "https://authn.io";
|
1363
1301
|
async function installHandler() {
|
1364
1302
|
const CredentialManager2 = navigator.credentialsPolyfill.CredentialManager;
|
@@ -1405,9 +1343,7 @@ __name(listener, "listener");
|
|
1405
1343
|
async function createResponse({ event, get, store }) {
|
1406
1344
|
const result = await (get || store)({ event });
|
1407
1345
|
if (!(result && typeof result === "object")) {
|
1408
|
-
throw new TypeError(
|
1409
|
-
'Return value of "get" or "store" hook must be an object.'
|
1410
|
-
);
|
1346
|
+
throw new TypeError('Return value of "get" or "store" hook must be an object.');
|
1411
1347
|
}
|
1412
1348
|
if (result.type === "response") {
|
1413
1349
|
return { dataType: result.dataType, data: result.data };
|
@@ -1432,9 +1368,7 @@ async function createResponse({ event, get, store }) {
|
|
1432
1368
|
hintKey: event.hintKey
|
1433
1369
|
});
|
1434
1370
|
}
|
1435
|
-
throw new Error(
|
1436
|
-
'Return value of "get" or "store" must have a type of "response" or "redirect".'
|
1437
|
-
);
|
1371
|
+
throw new Error('Return value of "get" or "store" must have a type of "response" or "redirect".');
|
1438
1372
|
}
|
1439
1373
|
__name(createResponse, "createResponse");
|
1440
1374
|
|
@@ -1470,9 +1404,7 @@ var getCHAPIPlugin = /* @__PURE__ */ __name(async () => {
|
|
1470
1404
|
methods: {
|
1471
1405
|
installChapiHandler: async () => installHandler(),
|
1472
1406
|
activateChapiHandler: async (_learnCard, {
|
1473
|
-
mediatorOrigin = `https://authn.io/mediator?${encodeURIComponent(
|
1474
|
-
window.location.origin
|
1475
|
-
)}`,
|
1407
|
+
mediatorOrigin = `https://authn.io/mediator?${encodeURIComponent(window.location.origin)}`,
|
1476
1408
|
get,
|
1477
1409
|
store
|
1478
1410
|
}) => {
|
@@ -1506,9 +1438,7 @@ var getCHAPIPlugin = /* @__PURE__ */ __name(async () => {
|
|
1506
1438
|
if (!Array.isArray(credential.credentialSubject)) {
|
1507
1439
|
credential.credentialSubject.id = subject;
|
1508
1440
|
}
|
1509
|
-
const vp = await _learnCard.invoke.getTestVp(
|
1510
|
-
await _learnCard.invoke.issueCredential(credential)
|
1511
|
-
);
|
1441
|
+
const vp = await _learnCard.invoke.getTestVp(await _learnCard.invoke.issueCredential(credential));
|
1512
1442
|
const success = await _learnCard.invoke.storePresentationViaChapi(vp);
|
1513
1443
|
if (success)
|
1514
1444
|
return { success: true };
|