Skip to content

Commit

Permalink
redesign: restrict events from host browser further (#230)
Browse files Browse the repository at this point in the history
* build: update package-lock.json for ci

* config: check for messages from host being strings
  • Loading branch information
tamssokari authored Mar 19, 2024
1 parent 575f0b3 commit 4d2c353
Show file tree
Hide file tree
Showing 9 changed files with 1,917 additions and 51 deletions.
1,904 changes: 1,865 additions & 39 deletions package-lock.json

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions packages/embed/src/js/basic-kyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ import { version as sdkVersion } from "../../package.json";
window.addEventListener(
"message",
async (event) => {
if (event.data && event.data.includes("SmileIdentity::Configuration")) {
if (
event.data &&
typeof event.data === "string" &&
event.data.includes("SmileIdentity::Configuration")
) {
config = JSON.parse(event.data);
activeScreen = LoadingScreen;

Expand Down Expand Up @@ -442,7 +446,10 @@ 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.postMessage(
"SmileIdentity::ConsentDenied::TOTP::ContactMethodsOutdated",
"*",
);
closeWindow();
},
false,
Expand Down
11 changes: 9 additions & 2 deletions packages/embed/src/js/biometric-kyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ import { version as sdkVersion } from "../../package.json";
window.addEventListener(
"message",
async (event) => {
if (event.data && event.data.includes("SmileIdentity::Configuration")) {
if (
event.data &&
typeof event.data === "string" &&
event.data.includes("SmileIdentity::Configuration")
) {
config = JSON.parse(event.data);
activeScreen = LoadingScreen;

Expand Down Expand Up @@ -487,7 +491,10 @@ 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.postMessage(
"SmileIdentity::ConsentDenied::TOTP::ContactMethodsOutdated",
"*",
);
closeWindow();
},
false,
Expand Down
6 changes: 5 additions & 1 deletion packages/embed/src/js/doc-verification.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ import { version as sdkVersion } from "../../package.json";
window.addEventListener(
"message",
async (event) => {
if (event.data && event.data.includes("SmileIdentity::Configuration")) {
if (
event.data &&
typeof event.data === "string" &&
event.data.includes("SmileIdentity::Configuration")
) {
config = JSON.parse(event.data);
activeScreen = LoadingScreen;

Expand Down
6 changes: 5 additions & 1 deletion packages/embed/src/js/e-signature.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ function getHumanSize(numberOfBytes) {
window.addEventListener(
"message",
async (event) => {
if (event.data && event.data.includes("SmileIdentity::Configuration")) {
if (
event.data &&
typeof event.data === "string" &&
event.data.includes("SmileIdentity::Configuration")
) {
config = JSON.parse(event.data);
activeScreen = LoadingScreen;
getPartnerParams();
Expand Down
12 changes: 9 additions & 3 deletions packages/embed/src/js/ekyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ import { version as sdkVersion } from "../../package.json";
window.addEventListener(
"message",
async (event) => {
if (event.data && event.data.includes("SmileIdentity::Configuration")) {
if (
event.data &&
typeof event.data === "string" &&
event.data.includes("SmileIdentity::Configuration")
) {
config = JSON.parse(event.data);
activeScreen = LoadingScreen;
getPartnerParams();
Expand Down Expand Up @@ -402,7 +406,6 @@ import { version as sdkVersion } from "../../package.json";
false,
);


EndUserConsent.addEventListener(
"end-user-consent.granted",
(event) => {
Expand Down Expand Up @@ -443,7 +446,10 @@ 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.postMessage(
"SmileIdentity::ConsentDenied::TOTP::ContactMethodsOutdated",
"*",
);
closeWindow();
},
false,
Expand Down
6 changes: 5 additions & 1 deletion packages/embed/src/js/enhanced-document-verification.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ import { version as sdkVersion } from "../../package.json";
window.addEventListener(
"message",
async (event) => {
if (event.data && event.data.includes("SmileIdentity::Configuration")) {
if (
event.data &&
typeof event.data === "string" &&
event.data.includes("SmileIdentity::Configuration")
) {
config = JSON.parse(event.data);
activeScreen = LoadingScreen;

Expand Down
6 changes: 5 additions & 1 deletion packages/embed/src/js/product-selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,11 @@
window.addEventListener(
"message",
async (event) => {
if (event.data) {
if (
event.data &&
typeof event.data === "string" &&
event.data.includes("SmileIdentity")
) {
if (event.data.includes("SmileIdentity::Configuration")) {
config = JSON.parse(event.data);
activeScreen = LoadingScreen;
Expand Down
6 changes: 5 additions & 1 deletion packages/embed/src/js/smartselfie-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ import { version as sdkVersion } from "../../package.json";
window.addEventListener(
"message",
async (event) => {
if (event.data && event.data.includes("SmileIdentity::Configuration")) {
if (
event.data &&
typeof event.data === "string" &&
event.data.includes("SmileIdentity::Configuration")
) {
config = JSON.parse(event.data);
partner_params = getPartnerParams();
id_info = {};
Expand Down

0 comments on commit 4d2c353

Please sign in to comment.