diff --git a/example/docker-compose.yml b/example/docker-compose.yml
index 403f9c6c..0a44da32 100644
--- a/example/docker-compose.yml
+++ b/example/docker-compose.yml
@@ -4,7 +4,7 @@
version: '2'
services:
web-eid-springboot-example:
- image: web-eid-springboot-example:3.2.2
+ image: web-eid-springboot-example:3.2.3
restart: always
environment:
JAVA_TOOL_OPTIONS: '-Dspring.profiles.active=prod'
diff --git a/example/pom.xml b/example/pom.xml
index 59daad1b..1d34b7c5 100644
--- a/example/pom.xml
+++ b/example/pom.xml
@@ -20,13 +20,16 @@
17
- 3.6.0
- 3.2.2
+ 3.6.1
+ 3.2.3
6.2.0
- 1.86
+
+ 2.23.0
+ 2.0.20
+ 1.87
1.44
3.5.2
- 3.6.3
+ 3.7.0
@@ -57,10 +60,10 @@
${webeid.version}
org.bouncycastle
diff --git a/example/src/main/resources/static/js/web-eid.js b/example/src/main/resources/static/js/web-eid.js
index dc5ecd00..99a6e2f7 100644
--- a/example/src/main/resources/static/js/web-eid.js
+++ b/example/src/main/resources/static/js/web-eid.js
@@ -62,19 +62,17 @@ var ErrorCode;
})(ErrorCode || (ErrorCode = {}));
var ErrorCode$1 = ErrorCode;
-class MissingParameterError extends Error {
+class DeveloperError extends Error {
constructor(message) {
super(message);
- this.name = this.constructor.name;
- this.code = ErrorCode$1.ERR_WEBEID_MISSING_PARAMETER;
}
}
-class ActionPendingError extends Error {
- constructor(message = "same action for Web-eID browser extension is already pending") {
+class MissingParameterError extends DeveloperError {
+ constructor(message) {
super(message);
this.name = this.constructor.name;
- this.code = ErrorCode$1.ERR_WEBEID_ACTION_PENDING;
+ this.code = ErrorCode$1.ERR_WEBEID_MISSING_PARAMETER;
}
}
@@ -103,14 +101,6 @@ class ExtensionUnavailableError extends Error {
}
}
-var config = Object.freeze({
- VERSION: "2.0.2",
- EXTENSION_HANDSHAKE_TIMEOUT: 1000,
- NATIVE_APP_HANDSHAKE_TIMEOUT: 5 * 1000,
- DEFAULT_USER_INTERACTION_TIMEOUT: 2 * 60 * 1000,
- MAX_EXTENSION_LOAD_DELAY: 1000,
-});
-
class NativeFatalError extends Error {
constructor(message = "native application terminated with a fatal error") {
super(message);
@@ -119,14 +109,6 @@ class NativeFatalError extends Error {
}
}
-class NativeInvalidArgumentError extends Error {
- constructor(message = "native application received an invalid argument") {
- super(message);
- this.name = this.constructor.name;
- this.code = ErrorCode$1.ERR_WEBEID_NATIVE_INVALID_ARGUMENT;
- }
-}
-
class NativeUnavailableError extends Error {
constructor(message = "Web-eID native application is not available") {
super(message);
@@ -189,7 +171,7 @@ class VersionMismatchError extends Error {
super(message);
this.name = this.constructor.name;
this.code = ErrorCode$1.ERR_WEBEID_VERSION_MISMATCH;
- this.requiresUpdate = requiresUpdate;
+ this.requiresUpdate = requiresUpdate ?? { nativeApp: false, extension: false };
if (versions) {
const { library, extension, nativeApp } = versions;
Object.assign(this, { library, extension, nativeApp });
@@ -197,11 +179,36 @@ class VersionMismatchError extends Error {
}
}
+class ActionPendingError extends DeveloperError {
+ constructor(message = "same action for Web-eID browser extension is already pending") {
+ super(message);
+ this.name = this.constructor.name;
+ this.code = ErrorCode$1.ERR_WEBEID_ACTION_PENDING;
+ }
+}
+
+var config = Object.freeze({
+ VERSION: "2.2.0",
+ EXTENSION_HANDSHAKE_TIMEOUT: 1000,
+ NATIVE_APP_HANDSHAKE_TIMEOUT: 5 * 1000,
+ DEFAULT_USER_INTERACTION_TIMEOUT: 2 * 60 * 1000,
+ MAX_EXTENSION_LOAD_DELAY: 1000,
+});
+
+class NativeInvalidArgumentError extends DeveloperError {
+ constructor(message = "native application received an invalid argument") {
+ super(message);
+ this.name = this.constructor.name;
+ this.code = ErrorCode$1.ERR_WEBEID_NATIVE_INVALID_ARGUMENT;
+ }
+}
+
const errorCodeToErrorClass = {
[ErrorCode$1.ERR_WEBEID_ACTION_PENDING]: ActionPendingError,
[ErrorCode$1.ERR_WEBEID_ACTION_TIMEOUT]: ActionTimeoutError,
[ErrorCode$1.ERR_WEBEID_CONTEXT_INSECURE]: ContextInsecureError,
[ErrorCode$1.ERR_WEBEID_EXTENSION_UNAVAILABLE]: ExtensionUnavailableError,
+ [ErrorCode$1.ERR_WEBEID_MISSING_PARAMETER]: MissingParameterError,
[ErrorCode$1.ERR_WEBEID_NATIVE_INVALID_ARGUMENT]: NativeInvalidArgumentError,
[ErrorCode$1.ERR_WEBEID_NATIVE_FATAL]: NativeFatalError,
[ErrorCode$1.ERR_WEBEID_NATIVE_UNAVAILABLE]: NativeUnavailableError,
@@ -209,18 +216,33 @@ const errorCodeToErrorClass = {
[ErrorCode$1.ERR_WEBEID_USER_TIMEOUT]: UserTimeoutError,
[ErrorCode$1.ERR_WEBEID_VERSION_INVALID]: VersionInvalidError,
[ErrorCode$1.ERR_WEBEID_VERSION_MISMATCH]: VersionMismatchError,
+ [ErrorCode$1.ERR_WEBEID_UNKNOWN_ERROR]: UnknownError,
};
+function isSerializedError(obj) {
+ if (typeof obj !== "object" || obj === null) {
+ return false;
+ }
+ const errorObject = obj;
+ return (typeof errorObject.code === "string" &&
+ typeof errorObject.message === "string" &&
+ errorCodeToErrorClass[errorObject.code] != null);
+}
function deserializeError(errorObject) {
let error;
- if (typeof errorObject.code == "string" && errorObject.code in errorCodeToErrorClass) {
+ if (isSerializedError(errorObject)) {
const CustomError = errorCodeToErrorClass[errorObject.code];
error = new CustomError();
+ Object.entries(errorObject).forEach(([key, value]) => {
+ Reflect.set(error, key, value);
+ });
}
else {
error = new UnknownError();
- }
- for (const [key, value] of Object.entries(errorObject)) {
- error[key] = value;
+ const unknownObject = errorObject;
+ if (unknownObject?.stack)
+ error.stack = unknownObject.stack;
+ if (unknownObject?.message)
+ error.message = unknownObject.message;
}
return error;
}
@@ -232,15 +254,20 @@ class WebExtensionService {
window.addEventListener("message", (event) => this.receive(event));
}
receive(event) {
- var _a, _b, _c, _d, _e, _f;
- if (!/^web-eid:/.test((_a = event.data) === null || _a === void 0 ? void 0 : _a.action))
+ if (event.source !== window)
+ return;
+ if (event.origin !== window.location.origin)
return;
const message = event.data;
- const suffix = (_c = (_b = message.action) === null || _b === void 0 ? void 0 : _b.match(/success$|failure$|ack$/)) === null || _c === void 0 ? void 0 : _c[0];
+ if (typeof message?.action !== "string")
+ return;
+ if (!message.action.startsWith("web-eid:"))
+ return;
+ const suffix = ["success", "failure", "ack"].find((s) => message.action.endsWith(s));
const initialAction = this.getInitialAction(message.action);
const pending = this.getPendingMessage(initialAction);
if (message.action === Action$1.WARNING) {
- (_d = message.warnings) === null || _d === void 0 ? void 0 : _d.forEach((warning) => {
+ message.warnings?.forEach((warning) => {
if (!this.loggedWarnings.includes(warning)) {
this.loggedWarnings.push(warning);
console.warn(warning.replace(/\n|\r/g, ""));
@@ -255,13 +282,13 @@ class WebExtensionService {
}
case "success": {
this.removeFromQueue(initialAction);
- (_e = pending.resolve) === null || _e === void 0 ? void 0 : _e.call(pending, message);
+ pending.resolve?.(message);
break;
}
case "failure": {
const failureMessage = message;
this.removeFromQueue(initialAction);
- (_f = pending.reject) === null || _f === void 0 ? void 0 : _f.call(pending, failureMessage.error ? deserializeError(failureMessage.error) : failureMessage);
+ pending.reject?.(deserializeError(failureMessage.error));
break;
}
}
@@ -288,15 +315,13 @@ class WebExtensionService {
}
}
onReplyTimeout(pending) {
- var _a;
this.removeFromQueue(pending.message.action);
- (_a = pending.reject) === null || _a === void 0 ? void 0 : _a.call(pending, new ActionTimeoutError());
+ pending.reject?.(new ActionTimeoutError());
}
onAckTimeout(pending) {
- var _a;
clearTimeout(pending.replyTimer);
this.removeFromQueue(pending.message.action);
- (_a = pending.reject) === null || _a === void 0 ? void 0 : _a.call(pending, new ExtensionUnavailableError());
+ pending.reject?.(new ExtensionUnavailableError());
}
getPendingMessage(action) {
return this.queue.find((pm) => {
@@ -308,7 +333,7 @@ class WebExtensionService {
}
removeFromQueue(action) {
const pending = this.getPendingMessage(action);
- clearTimeout(pending === null || pending === void 0 ? void 0 : pending.replyTimer);
+ clearTimeout(pending?.replyTimer);
this.queue = this.queue.filter((pending) => (pending.message.action !== action));
}
}
@@ -348,7 +373,9 @@ async function status() {
};
}
catch (error) {
- error.library = config.VERSION;
+ if (error instanceof Error) {
+ Reflect.set(error, "library", config.VERSION);
+ }
throw error;
}
}
@@ -359,7 +386,7 @@ async function authenticate(challengeNonce, options) {
}
const timeout = (config.EXTENSION_HANDSHAKE_TIMEOUT +
config.NATIVE_APP_HANDSHAKE_TIMEOUT +
- ((options === null || options === void 0 ? void 0 : options.userInteractionTimeout) || config.DEFAULT_USER_INTERACTION_TIMEOUT));
+ (options?.userInteractionTimeout ?? config.DEFAULT_USER_INTERACTION_TIMEOUT));
const message = {
action: Action$1.AUTHENTICATE,
libraryVersion: config.VERSION,
@@ -379,7 +406,7 @@ async function getSigningCertificate(options) {
await extensionLoadDelay();
const timeout = (config.EXTENSION_HANDSHAKE_TIMEOUT +
config.NATIVE_APP_HANDSHAKE_TIMEOUT +
- ((options === null || options === void 0 ? void 0 : options.userInteractionTimeout) || config.DEFAULT_USER_INTERACTION_TIMEOUT) * 2);
+ (options?.userInteractionTimeout ?? config.DEFAULT_USER_INTERACTION_TIMEOUT) * 2);
const message = {
action: Action$1.GET_SIGNING_CERTIFICATE,
libraryVersion: config.VERSION,
@@ -404,7 +431,7 @@ async function sign(certificate, hash, hashFunction, options) {
}
const timeout = (config.EXTENSION_HANDSHAKE_TIMEOUT +
config.NATIVE_APP_HANDSHAKE_TIMEOUT +
- ((options === null || options === void 0 ? void 0 : options.userInteractionTimeout) || config.DEFAULT_USER_INTERACTION_TIMEOUT) * 2);
+ (options?.userInteractionTimeout ?? config.DEFAULT_USER_INTERACTION_TIMEOUT) * 2);
const message = {
action: Action$1.SIGN,
libraryVersion: config.VERSION,
@@ -420,4 +447,4 @@ async function sign(certificate, hash, hashFunction, options) {
};
}
-export { Action$1 as Action, ErrorCode$1 as ErrorCode, authenticate, config, getSigningCertificate, sign, status };
+export { Action$1 as Action, ActionTimeoutError, ContextInsecureError, DeveloperError, ErrorCode$1 as ErrorCode, ExtensionUnavailableError, NativeFatalError, NativeUnavailableError, UnknownError, UserCancelledError, UserTimeoutError, VersionInvalidError, VersionMismatchError, authenticate, config, getSigningCertificate, sign, status };
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 6cb00045..4411bf90 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
4.0.0
authtoken-validation
eu.webeid.security
- 3.2.2
+ 3.2.3
jar
authtoken-validation
Web eID authentication token validation library for Java
@@ -15,17 +15,17 @@
11
0.13.0
- 1.86
- 2.22.3
- 2.0.19
- 5.14.4
+ 1.87
+ 2.23.0
+ 2.0.20
+ 5.14.5
3.27.7
- 5.23.0
- 3.6.0
+ 5.25.0
+ 3.6.1
3.4.0
3.12.0
- 3.6.3
- 0.8.15
+ 3.7.0
+ 0.8.16
${project.basedir}/../jacoco-coverage-report/target/site/jacoco-aggregate/jacoco.xml