@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
package/dist/chapi-plugin.esm.js
CHANGED
@@ -257,9 +257,7 @@ var Injector = class {
|
|
257
257
|
throw new TypeError("`name` must be a non-empty string.");
|
258
258
|
}
|
259
259
|
if (!(definition && typeof definition === "object" && Array.isArray(definition.functions))) {
|
260
|
-
throw new TypeError(
|
261
|
-
"`definition.function` must be an array of function names or function definition objects to be defined."
|
262
|
-
);
|
260
|
+
throw new TypeError("`definition.function` must be an array of function names or function definition objects to be defined.");
|
263
261
|
}
|
264
262
|
const self = this;
|
265
263
|
const api = {};
|
@@ -268,11 +266,7 @@ var Injector = class {
|
|
268
266
|
fn = { name: fn, options: {} };
|
269
267
|
}
|
270
268
|
api[fn.name] = async function() {
|
271
|
-
return self.client.send(
|
272
|
-
name + "." + fn.name,
|
273
|
-
[...arguments],
|
274
|
-
fn.options
|
275
|
-
);
|
269
|
+
return self.client.send(name + "." + fn.name, [...arguments], fn.options);
|
276
270
|
};
|
277
271
|
});
|
278
272
|
self._apis[name] = api;
|
@@ -449,17 +443,13 @@ var WebApp = class {
|
|
449
443
|
}
|
450
444
|
async show() {
|
451
445
|
if (!this._connected) {
|
452
|
-
throw new Error(
|
453
|
-
'Cannot "show" yet; not connected. Did you call ".connect()"?'
|
454
|
-
);
|
446
|
+
throw new Error('Cannot "show" yet; not connected. Did you call ".connect()"?');
|
455
447
|
}
|
456
448
|
return this._control.show();
|
457
449
|
}
|
458
450
|
async hide() {
|
459
451
|
if (!this._connected) {
|
460
|
-
throw new Error(
|
461
|
-
'Cannot "hide" yet; not connected. Did you call ".connect()?"'
|
462
|
-
);
|
452
|
+
throw new Error('Cannot "hide" yet; not connected. Did you call ".connect()?"');
|
463
453
|
}
|
464
454
|
return this._control.hide();
|
465
455
|
}
|
@@ -533,11 +523,9 @@ var WebAppWindowInlineDialog = class extends WebAppWindowDialog {
|
|
533
523
|
this.dialog.className = this.dialog.className + " " + className;
|
534
524
|
}
|
535
525
|
const style = document.createElement("style");
|
536
|
-
style.appendChild(
|
537
|
-
document.createTextNode(`dialog.web-app-window::backdrop {
|
526
|
+
style.appendChild(document.createTextNode(`dialog.web-app-window::backdrop {
|
538
527
|
background-color: transparent;
|
539
|
-
}`)
|
540
|
-
);
|
528
|
+
}`));
|
541
529
|
this.container = document.createElement("div");
|
542
530
|
applyStyle(this.container, {
|
543
531
|
position: "relative",
|
@@ -720,13 +708,7 @@ var WebAppWindow = class {
|
|
720
708
|
this.dialog = dialog = handle._dialog;
|
721
709
|
}
|
722
710
|
this._private._readyPromise = new Promise((resolve, reject) => {
|
723
|
-
this._timeoutId = setTimeout(
|
724
|
-
() => reject(new DOMException(
|
725
|
-
"Loading Web application window timed out.",
|
726
|
-
"TimeoutError"
|
727
|
-
)),
|
728
|
-
timeout
|
729
|
-
);
|
711
|
+
this._timeoutId = setTimeout(() => reject(new DOMException("Loading Web application window timed out.", "TimeoutError")), timeout);
|
730
712
|
this._private._resolveReady = (value) => {
|
731
713
|
clearTimeout(this.timeoutId);
|
732
714
|
this._timeoutId = null;
|
@@ -743,10 +725,7 @@ var WebAppWindow = class {
|
|
743
725
|
};
|
744
726
|
this._private.destroy = () => {
|
745
727
|
if (this._timeoutId) {
|
746
|
-
this._private._rejectReady(new DOMException(
|
747
|
-
"Web application window closed before ready.",
|
748
|
-
"AbortError"
|
749
|
-
));
|
728
|
+
this._private._rejectReady(new DOMException("Web application window closed before ready.", "AbortError"));
|
750
729
|
}
|
751
730
|
if (!this._destroyed) {
|
752
731
|
this.dialog.destroy();
|
@@ -886,7 +865,7 @@ var WebAppContext = class {
|
|
886
865
|
};
|
887
866
|
__name(WebAppContext, "WebAppContext");
|
888
867
|
|
889
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
868
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialRequestEvent.js
|
890
869
|
var CredentialRequestEvent = class {
|
891
870
|
constructor({
|
892
871
|
credentialHandler,
|
@@ -916,7 +895,7 @@ var CredentialRequestEvent = class {
|
|
916
895
|
};
|
917
896
|
__name(CredentialRequestEvent, "CredentialRequestEvent");
|
918
897
|
|
919
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
898
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialStoreEvent.js
|
920
899
|
var CredentialStoreEvent = class {
|
921
900
|
constructor({
|
922
901
|
credentialHandler,
|
@@ -944,31 +923,21 @@ var CredentialStoreEvent = class {
|
|
944
923
|
};
|
945
924
|
__name(CredentialStoreEvent, "CredentialStoreEvent");
|
946
925
|
|
947
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
926
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandlerService.js
|
948
927
|
var CredentialHandlerService = class {
|
949
928
|
constructor(credentialHandler) {
|
950
929
|
this._credentialHandler = credentialHandler;
|
951
930
|
}
|
952
931
|
async request(credentialRequestEvent) {
|
953
|
-
return await this._credentialHandler._emitter.emit(
|
954
|
-
new CredentialRequestEvent(Object.assign(
|
955
|
-
{ credentialHandler: this._credentialHandler },
|
956
|
-
credentialRequestEvent
|
957
|
-
))
|
958
|
-
);
|
932
|
+
return await this._credentialHandler._emitter.emit(new CredentialRequestEvent(Object.assign({ credentialHandler: this._credentialHandler }, credentialRequestEvent)));
|
959
933
|
}
|
960
934
|
async store(credentialStoreEvent) {
|
961
|
-
return await this._credentialHandler._emitter.emit(
|
962
|
-
new CredentialStoreEvent(Object.assign(
|
963
|
-
{ credentialHandler: this._credentialHandler },
|
964
|
-
credentialStoreEvent
|
965
|
-
))
|
966
|
-
);
|
935
|
+
return await this._credentialHandler._emitter.emit(new CredentialStoreEvent(Object.assign({ credentialHandler: this._credentialHandler }, credentialStoreEvent)));
|
967
936
|
}
|
968
937
|
};
|
969
938
|
__name(CredentialHandlerService, "CredentialHandlerService");
|
970
939
|
|
971
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
940
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandler.js
|
972
941
|
var EVENT_TYPES = ["credentialrequest", "credentialstore"];
|
973
942
|
var CredentialHandler = class extends WebApp {
|
974
943
|
constructor(mediatorOrigin, inline = false) {
|
@@ -978,12 +947,7 @@ var CredentialHandler = class extends WebApp {
|
|
978
947
|
super(mediatorOrigin, inline);
|
979
948
|
this._emitter = new EventEmitter({
|
980
949
|
async waitUntil(event) {
|
981
|
-
return event._promise || Promise.reject(
|
982
|
-
new DOMException(
|
983
|
-
'No "credentialrequest" event handler found.',
|
984
|
-
"NotFoundError"
|
985
|
-
)
|
986
|
-
);
|
950
|
+
return event._promise || Promise.reject(new DOMException('No "credentialrequest" event handler found.', "NotFoundError"));
|
987
951
|
}
|
988
952
|
});
|
989
953
|
}
|
@@ -995,26 +959,20 @@ var CredentialHandler = class extends WebApp {
|
|
995
959
|
}
|
996
960
|
addEventListener(eventType, fn) {
|
997
961
|
if (!EVENT_TYPES.includes(eventType)) {
|
998
|
-
throw new DOMException(
|
999
|
-
`Unsupported event type "${eventType}"`,
|
1000
|
-
"NotSupportedError"
|
1001
|
-
);
|
962
|
+
throw new DOMException(`Unsupported event type "${eventType}"`, "NotSupportedError");
|
1002
963
|
}
|
1003
964
|
return this._emitter.addEventListener(eventType, fn);
|
1004
965
|
}
|
1005
966
|
removeEventListener(eventType, fn) {
|
1006
967
|
if (!EVENT_TYPES.includes(eventType)) {
|
1007
|
-
throw new DOMException(
|
1008
|
-
`Unsupported event type "${eventType}"`,
|
1009
|
-
"NotSupportedError"
|
1010
|
-
);
|
968
|
+
throw new DOMException(`Unsupported event type "${eventType}"`, "NotSupportedError");
|
1011
969
|
}
|
1012
970
|
return this._emitter.removeEventListener(eventType, fn);
|
1013
971
|
}
|
1014
972
|
};
|
1015
973
|
__name(CredentialHandler, "CredentialHandler");
|
1016
974
|
|
1017
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
975
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHints.js
|
1018
976
|
var CredentialHints = class {
|
1019
977
|
constructor(url, injector) {
|
1020
978
|
const remote = injector.get("credentialHints", {
|
@@ -1065,7 +1023,7 @@ function imageToDataUrl(url) {
|
|
1065
1023
|
}
|
1066
1024
|
__name(imageToDataUrl, "imageToDataUrl");
|
1067
1025
|
|
1068
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
1026
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialManager.js
|
1069
1027
|
var CredentialManager = class {
|
1070
1028
|
constructor(url, injector) {
|
1071
1029
|
if (!(url && typeof url === "string")) {
|
@@ -1074,15 +1032,13 @@ var CredentialManager = class {
|
|
1074
1032
|
this.hints = new CredentialHints(url, injector);
|
1075
1033
|
}
|
1076
1034
|
static async requestPermission() {
|
1077
|
-
const status = await navigator.credentialsPolyfill.permissions.request(
|
1078
|
-
{ name: "credentialhandler" }
|
1079
|
-
);
|
1035
|
+
const status = await navigator.credentialsPolyfill.permissions.request({ name: "credentialhandler" });
|
1080
1036
|
return status.state;
|
1081
1037
|
}
|
1082
1038
|
};
|
1083
1039
|
__name(CredentialManager, "CredentialManager");
|
1084
1040
|
|
1085
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
1041
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandlerRegistration.js
|
1086
1042
|
var CredentialHandlerRegistration = class {
|
1087
1043
|
constructor(url, injector) {
|
1088
1044
|
if (!(url && typeof url === "string")) {
|
@@ -1093,7 +1049,7 @@ var CredentialHandlerRegistration = class {
|
|
1093
1049
|
};
|
1094
1050
|
__name(CredentialHandlerRegistration, "CredentialHandlerRegistration");
|
1095
1051
|
|
1096
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
1052
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialHandlers.js
|
1097
1053
|
var CredentialHandlers = class {
|
1098
1054
|
constructor(injector) {
|
1099
1055
|
this._init = (async () => {
|
@@ -1134,14 +1090,12 @@ var CredentialHandlers = class {
|
|
1134
1090
|
return await this._remote.hasRegistration("credential", url);
|
1135
1091
|
}
|
1136
1092
|
_deprecateNotice() {
|
1137
|
-
console.warn(
|
1138
|
-
'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()".'
|
1139
|
-
);
|
1093
|
+
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()".');
|
1140
1094
|
}
|
1141
1095
|
};
|
1142
1096
|
__name(CredentialHandlers, "CredentialHandlers");
|
1143
1097
|
|
1144
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
1098
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/WebCredential.js
|
1145
1099
|
var WebCredential2 = class {
|
1146
1100
|
constructor(dataType, data, { recommendedHandlerOrigins = [] } = {}) {
|
1147
1101
|
if (typeof dataType !== "string") {
|
@@ -1155,7 +1109,7 @@ var WebCredential2 = class {
|
|
1155
1109
|
};
|
1156
1110
|
__name(WebCredential2, "WebCredential");
|
1157
1111
|
|
1158
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
1112
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/CredentialsContainer.js
|
1159
1113
|
var CREDENTIAL_GET_TIMEOUT = 0;
|
1160
1114
|
var CREDENTIAL_STORE_TIMEOUT = 0;
|
1161
1115
|
var CredentialsContainer = class {
|
@@ -1204,7 +1158,7 @@ var CredentialsContainer = class {
|
|
1204
1158
|
};
|
1205
1159
|
__name(CredentialsContainer, "CredentialsContainer");
|
1206
1160
|
|
1207
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
1161
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/PermissionManager.js
|
1208
1162
|
var PERMISSION_REQUEST_TIMEOUT = 0;
|
1209
1163
|
var PermissionManager = class {
|
1210
1164
|
constructor(injector) {
|
@@ -1233,7 +1187,7 @@ var PermissionManager = class {
|
|
1233
1187
|
};
|
1234
1188
|
__name(PermissionManager, "PermissionManager");
|
1235
1189
|
|
1236
|
-
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.
|
1190
|
+
// ../../../node_modules/.pnpm/credential-handler-polyfill@3.0.0/node_modules/credential-handler-polyfill/index.js
|
1237
1191
|
var DEFAULT_MEDIATOR_ORIGIN = "https://authn.io";
|
1238
1192
|
var loaded;
|
1239
1193
|
async function loadOnce(options) {
|
@@ -1247,16 +1201,13 @@ __name(loadOnce, "loadOnce");
|
|
1247
1201
|
async function load(options = {
|
1248
1202
|
mediatorOrigin: DEFAULT_MEDIATOR_ORIGIN
|
1249
1203
|
}) {
|
1250
|
-
_assertSecureContext();
|
1251
1204
|
let mediatorUrl;
|
1252
1205
|
if (typeof options === "string") {
|
1253
1206
|
mediatorUrl = options;
|
1254
1207
|
} else if (options && typeof options === "object" && typeof options.mediatorOrigin === "string") {
|
1255
1208
|
mediatorUrl = `${options.mediatorOrigin}/mediator`;
|
1256
1209
|
} else {
|
1257
|
-
throw new Error(
|
1258
|
-
'"options.mediatorOrigin" must be a string expressing the origin of the mediator.'
|
1259
|
-
);
|
1210
|
+
throw new Error('"options.mediatorOrigin" must be a string expressing the origin of the mediator.');
|
1260
1211
|
}
|
1261
1212
|
const appContext = new WebAppContext();
|
1262
1213
|
const injector = appContext.createWindow(mediatorUrl, {
|
@@ -1264,11 +1215,9 @@ async function load(options = {
|
|
1264
1215
|
timeout: 3e4
|
1265
1216
|
});
|
1266
1217
|
const style = document.createElement("style");
|
1267
|
-
style.appendChild(document.createTextNode(
|
1268
|
-
`dialog.web-app-window.credential-mediator > .web-app-window-backdrop {
|
1218
|
+
style.appendChild(document.createTextNode(`dialog.web-app-window.credential-mediator > .web-app-window-backdrop {
|
1269
1219
|
background-color: rgba(0, 0, 0, 0.25);
|
1270
|
-
}`
|
1271
|
-
));
|
1220
|
+
}`));
|
1272
1221
|
document.body.appendChild(style);
|
1273
1222
|
const polyfill = {};
|
1274
1223
|
polyfill.permissions = new PermissionManager(injector);
|
@@ -1279,12 +1228,8 @@ async function load(options = {
|
|
1279
1228
|
polyfill.WebCredential = WebCredential2;
|
1280
1229
|
navigator.credentialsPolyfill = polyfill;
|
1281
1230
|
if ("credentials" in navigator) {
|
1282
|
-
navigator.credentials.get = polyfill.credentials.get.bind(
|
1283
|
-
|
1284
|
-
);
|
1285
|
-
navigator.credentials.store = polyfill.credentials.store.bind(
|
1286
|
-
polyfill.credentials
|
1287
|
-
);
|
1231
|
+
navigator.credentials.get = polyfill.credentials.get.bind(polyfill.credentials);
|
1232
|
+
navigator.credentials.store = polyfill.credentials.store.bind(polyfill.credentials);
|
1288
1233
|
} else {
|
1289
1234
|
navigator.credentials = polyfill.credentials;
|
1290
1235
|
}
|
@@ -1293,14 +1238,8 @@ async function load(options = {
|
|
1293
1238
|
return polyfill;
|
1294
1239
|
}
|
1295
1240
|
__name(load, "load");
|
1296
|
-
function _assertSecureContext() {
|
1297
|
-
if (!window.isSecureContext) {
|
1298
|
-
throw new DOMException("SecurityError", "The operation is insecure.");
|
1299
|
-
}
|
1300
|
-
}
|
1301
|
-
__name(_assertSecureContext, "_assertSecureContext");
|
1302
1241
|
|
1303
|
-
// ../../../node_modules/.pnpm/web-credential-handler@2.0.
|
1242
|
+
// ../../../node_modules/.pnpm/web-credential-handler@2.0.0/node_modules/web-credential-handler/CredentialEventProxy.js
|
1304
1243
|
var PROXY_EVENT_TIMEOUT = 6e4;
|
1305
1244
|
var CredentialEventProxy = class extends WebApp {
|
1306
1245
|
constructor() {
|
@@ -1334,7 +1273,7 @@ var CredentialEventProxy = class extends WebApp {
|
|
1334
1273
|
};
|
1335
1274
|
__name(CredentialEventProxy, "CredentialEventProxy");
|
1336
1275
|
|
1337
|
-
// ../../../node_modules/.pnpm/web-credential-handler@2.0.
|
1276
|
+
// ../../../node_modules/.pnpm/web-credential-handler@2.0.0/node_modules/web-credential-handler/index.js
|
1338
1277
|
var DEFAULT_MEDIATOR = "https://authn.io";
|
1339
1278
|
async function installHandler() {
|
1340
1279
|
const CredentialManager2 = navigator.credentialsPolyfill.CredentialManager;
|
@@ -1381,9 +1320,7 @@ __name(listener, "listener");
|
|
1381
1320
|
async function createResponse({ event, get, store }) {
|
1382
1321
|
const result = await (get || store)({ event });
|
1383
1322
|
if (!(result && typeof result === "object")) {
|
1384
|
-
throw new TypeError(
|
1385
|
-
'Return value of "get" or "store" hook must be an object.'
|
1386
|
-
);
|
1323
|
+
throw new TypeError('Return value of "get" or "store" hook must be an object.');
|
1387
1324
|
}
|
1388
1325
|
if (result.type === "response") {
|
1389
1326
|
return { dataType: result.dataType, data: result.data };
|
@@ -1408,9 +1345,7 @@ async function createResponse({ event, get, store }) {
|
|
1408
1345
|
hintKey: event.hintKey
|
1409
1346
|
});
|
1410
1347
|
}
|
1411
|
-
throw new Error(
|
1412
|
-
'Return value of "get" or "store" must have a type of "response" or "redirect".'
|
1413
|
-
);
|
1348
|
+
throw new Error('Return value of "get" or "store" must have a type of "response" or "redirect".');
|
1414
1349
|
}
|
1415
1350
|
__name(createResponse, "createResponse");
|
1416
1351
|
|
@@ -1446,9 +1381,7 @@ var getCHAPIPlugin = /* @__PURE__ */ __name(async () => {
|
|
1446
1381
|
methods: {
|
1447
1382
|
installChapiHandler: async () => installHandler(),
|
1448
1383
|
activateChapiHandler: async (_learnCard, {
|
1449
|
-
mediatorOrigin = `https://authn.io/mediator?${encodeURIComponent(
|
1450
|
-
window.location.origin
|
1451
|
-
)}`,
|
1384
|
+
mediatorOrigin = `https://authn.io/mediator?${encodeURIComponent(window.location.origin)}`,
|
1452
1385
|
get,
|
1453
1386
|
store
|
1454
1387
|
}) => {
|
@@ -1482,9 +1415,7 @@ var getCHAPIPlugin = /* @__PURE__ */ __name(async () => {
|
|
1482
1415
|
if (!Array.isArray(credential.credentialSubject)) {
|
1483
1416
|
credential.credentialSubject.id = subject;
|
1484
1417
|
}
|
1485
|
-
const vp = await _learnCard.invoke.getTestVp(
|
1486
|
-
await _learnCard.invoke.issueCredential(credential)
|
1487
|
-
);
|
1418
|
+
const vp = await _learnCard.invoke.getTestVp(await _learnCard.invoke.issueCredential(credential));
|
1488
1419
|
const success = await _learnCard.invoke.storePresentationViaChapi(vp);
|
1489
1420
|
if (success)
|
1490
1421
|
return { success: true };
|