Skip to content

Commit

Permalink
This fixes onError not propagated to grandparent of the window (#349)
Browse files Browse the repository at this point in the history
* This fixes onError not probagated to grandparent of the window

* update message sending to parent window
  • Loading branch information
ayinloya authored Oct 10, 2024
1 parent 69376ca commit 39ae5c9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
14 changes: 9 additions & 5 deletions packages/embed/src/js/basic-kyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,9 @@ import { version as sdkVersion } from '../../package.json';
EndUserConsent.addEventListener(
'end-user-consent.denied',
() => {
referenceWindow.postMessage('SmileIdentity::ConsentDenied', '*');
[referenceWindow.parent, referenceWindow].forEach((win) => {
win.postMessage('SmileIdentity::ConsentDenied', '*');
});
closeWindow();
},
false,
Expand All @@ -475,10 +477,12 @@ import { version as sdkVersion } from '../../package.json';
EndUserConsent.addEventListener(
'end-user-consent.totp.denied.contact-methods-outdated',
(event) => {
referenceWindow.postMessage(
'SmileIdentity::ConsentDenied::TOTP::ContactMethodsOutdated',
'*',
);
[referenceWindow.parent, referenceWindow].forEach((win) => {
win.postMessage(
'SmileIdentity::ConsentDenied::TOTP::ContactMethodsOutdated',
'*',
);
});
closeWindow();
},
false,
Expand Down
5 changes: 4 additions & 1 deletion packages/embed/src/js/biometric-kyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,10 @@ import { version as sdkVersion } from '../../package.json';
EndUserConsent.addEventListener(
'end-user-consent.denied',
() => {
referenceWindow.postMessage('SmileIdentity::ConsentDenied', '*');
(referenceWindow.parent || referenceWindow).postMessage(
'SmileIdentity::ConsentDenied',
'*',
);
closeWindow();
},
false,
Expand Down
21 changes: 12 additions & 9 deletions packages/embed/src/js/ekyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,9 @@ import { version as sdkVersion } from '../../package.json';
EndUserConsent.addEventListener(
'end-user-consent.denied',
() => {
referenceWindow.postMessage('SmileIdentity::ConsentDenied', '*');
[referenceWindow.parent || referenceWindow].forEach((win) => {
win.postMessage('SmileIdentity::ConsentDenied', '*');
});
closeWindow();
},
false,
Expand All @@ -471,10 +473,12 @@ import { version as sdkVersion } from '../../package.json';
EndUserConsent.addEventListener(
'end-user-consent.totp.denied.contact-methods-outdated',
(event) => {
(referenceWindow.parent || referenceWindow).postMessage(
'SmileIdentity::ConsentDenied::TOTP::ContactMethodsOutdated',
'*',
);
[referenceWindow.parent || referenceWindow].forEach((win) => {
win.postMessage(
'SmileIdentity::ConsentDenied::TOTP::ContactMethodsOutdated',
'*',
);
});
closeWindow();
},
false,
Expand Down Expand Up @@ -861,9 +865,8 @@ import { version as sdkVersion } from '../../package.json';
}

function handleSuccess() {
(referenceWindow.parent || referenceWindow).postMessage(
'SmileIdentity::Success',
'*',
);
[referenceWindow.parent, referenceWindow].forEach((win) => {
win.postMessage('SmileIdentity::Success', '*');
});
}
})();
4 changes: 2 additions & 2 deletions packages/embed/src/js/product-selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@

if (!validIdType) {
const legacyValidIdType =
legacyProductConstraints.doc_verification[country].id_types[id_type] ||
legacyProductConstraints.enhanced_kyc[country].id_types[id_type];
legacyProductConstraints.doc_verification[country]?.id_types[id_type] ||
legacyProductConstraints.enhanced_kyc[country]?.id_types[id_type];
if (legacyValidIdType) {
validIdType = {
name: legacyValidIdType.label,
Expand Down

0 comments on commit 39ae5c9

Please sign in to comment.