Skip to content

Commit 1cbf723

Browse files
committed
patch, return data for successful, cancelled and errored applicants
1 parent fe92c71 commit 1cbf723

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

packages/core/src/elements/iframe.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
import { iframeStyles } from "../styles/styles";
2-
import {verificationUrl} from "../helpers/defaultConfig";
32

43
import {ORBA_ONE_MESSAGE_CHANNEL,ORBA_ONE_SUCCESS,ORBA_ONE_CANCEL} from "./constants";
54

65
type State = "loading" | "success" | "error" | "idle";
76

87
export function createIframe(
98
url: string,
9+
applicantId: string,
1010
onSuccess: (...args) => void,
1111
onCancelled: (...args) => void,
1212
onError: (...args) => void,
1313
onChange: (state: State) => void,
1414
) {
1515
const frame = document.createElement("iframe");
16-
frame.allow = "geolocation; microphone; camera";
16+
frame.allow = "geolocation; microphone; camera; fullscreen;";
1717
frame.src = url;
1818
frame.setAttribute("style", iframeStyles);
1919

2020
//Set Test Id for DOM checking
2121
frame.dataset.testid = "orba-iframe";
22-
return iframeManager(frame, onSuccess, onCancelled, onError, onChange);
22+
return iframeManager(frame, applicantId, onSuccess, onCancelled, onError, onChange);
2323
}
2424

2525
export function iframeManager(
2626
iframe: HTMLIFrameElement,
27+
applicantId,
2728
onSuccess: (...args) => void,
2829
onCancelled: (...args) => void,
2930
onError: (...args) => void,
@@ -52,18 +53,14 @@ export function iframeManager(
5253
}
5354

5455
function handler(event: any) {
55-
console.log(event)
56-
if (event.origin != verificationUrl) {
57-
const json = JSON.parse(event.data)
58-
if (json.status === ORBA_ONE_SUCCESS) {
59-
onSuccess(json);
60-
disconnect();
61-
} else if (json.status === ORBA_ONE_CANCEL) {
62-
onCancelled(json);
63-
disconnect();
64-
} else {
65-
onError(json);
66-
}
56+
if (event.data === ORBA_ONE_SUCCESS) {
57+
onSuccess({applicantId, status:"success"});
58+
disconnect();
59+
} else if (event.data === ORBA_ONE_CANCEL) {
60+
onCancelled({applicantId, status:"cancelled"});
61+
disconnect();
62+
} else {
63+
onError({applicantId, status:"error"});
6764
}
6865

6966
}

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function initializeVerification(config: OrbaOneConfig, button: ReturnType<typeof
1212
button.setState("loading");
1313

1414
const url = getSessionUrl(verificationUrl, apiKey, applicantId, steps);
15-
const iframe = createIframe(url, onSuccess, onCancelled, onError, (state) => {
15+
const iframe = createIframe(url, applicantId, onSuccess, onCancelled, onError, (state) => {
1616
button.setState(state);
1717
});
1818
iframe.connect();

0 commit comments

Comments
 (0)