Skip to content

Commit a58930b

Browse files
taneltmmrts
authored andcommitted
fix: native quit command should not be sent when using safari
* When using Safari, the native version is returned without executing web-eid-app, so there's nothing to "quit". This should partially fix backwards compatibility issues with hwcrypto when using Safari. * Fixed a TypeScript type error, doesn't affect the compiled JavaScript code. Signed-off-by: Tanel Metsar <[email protected]>
1 parent 342317d commit a58930b

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/background-safari/services/NativeAppService.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { deserializeError } from "@web-eid/web-eid-library/utils/errorSerializer
2626

2727
import config from "../../config";
2828
import { objectByteSize } from "../../shared/utils";
29+
import { NativeAppMessage } from "../../models/NativeAppMessage";
2930

3031
type NativeAppPendingRequest = { reject?: Function; resolve?: Function } | null;
3132

@@ -68,7 +69,7 @@ export default class NativeAppService {
6869
} else {
6970
throw new NativeUnavailableError("unexpected error");
7071
}
71-
} catch (error) {
72+
} catch (error: any) {
7273
if (error instanceof NativeUnavailableError) {
7374
throw error;
7475
} else if (error?.message) {
@@ -87,7 +88,12 @@ export default class NativeAppService {
8788
this.pending = null;
8889
}
8990

90-
send<T extends object>(message: object): Promise<T> {
91+
send<T extends any>(message: NativeAppMessage): Promise<T> {
92+
93+
if (message.command == "quit") {
94+
return Promise.resolve({} as T);
95+
}
96+
9197
switch (this.state) {
9298
case NativeAppState.CONNECTED: {
9399
return new Promise((resolve, reject) => {

src/background/services/NativeAppService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default class NativeAppService {
7474
} else {
7575
throw new NativeUnavailableError("unexpected error");
7676
}
77-
} catch (error) {
77+
} catch (error: any) {
7878
if (this.port.error) {
7979
console.error(this.port.error);
8080
}

0 commit comments

Comments
 (0)