Skip to content

Commit

Permalink
Add hide_attribution config (#318)
Browse files Browse the repository at this point in the history
* Add hide_attribution config

* Fix double declaration of powered-by-smile-id error

* fix lint

* Fix attribution not hidden in biometric flow

* Fix attribution not hidden in biometric
  • Loading branch information
ayinloya authored Aug 28, 2024
1 parent 18ea6cd commit 1631385
Show file tree
Hide file tree
Showing 20 changed files with 118 additions and 36 deletions.
1 change: 1 addition & 0 deletions example/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export default function setupForm() {
use_new_component: true,
//demo_mode: true,
// previewBVNMFA: true,
hide_attribution: true,
document_capture_modes: ['camera', 'upload'],
allow_agent_mode: true,
partner_details: {
Expand Down
2 changes: 1 addition & 1 deletion packages/embed/src/basic-kyc.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ <h1 style="--flow-space: 4rem">Setting up</h1>
We are setting up your verification flow
</p>

<p class="center credits">
<p class="center credits" hidden>
<span class="visually-hidden">Powered by SmileID</span>
<svg
aria-hidden="true"
Expand Down
2 changes: 1 addition & 1 deletion packages/embed/src/biometric-kyc.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ <h1 style="--flow-space: 4rem">Setting up</h1>
We are setting up your verification flow
</p>

<p class="center credits">
<p class="center credits" hidden>
<span class="visually-hidden">Powered by SmileID</span>
<svg
aria-hidden="true"
Expand Down
2 changes: 1 addition & 1 deletion packages/embed/src/doc-verification.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ <h1 style="--flow-space: 4rem">Setting up</h1>
We are setting up your verification flow
</p>

<p class="center credits">
<p class="center credits" hidden>
<span class="visually-hidden">Powered by SmileID</span>
<svg
aria-hidden="true"
Expand Down
2 changes: 1 addition & 1 deletion packages/embed/src/e-signature.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ <h1 style="--flow-space: 4rem">Setting up</h1>
We are setting up
</p>

<p class="center credits">
<p class="center credits" hidden>
<span class="visually-hidden">Powered by SmileID</span>
<svg
aria-hidden="true"
Expand Down
2 changes: 1 addition & 1 deletion packages/embed/src/ekyc.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ <h1 style="--flow-space: 4rem">Setting up</h1>
We are setting up your verification flow
</p>

<p class="center credits">
<p class="center credits" hidden>
<span class="visually-hidden">Powered by SmileID</span>
<svg
aria-hidden="true"
Expand Down
2 changes: 1 addition & 1 deletion packages/embed/src/enhanced-document-verification.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ <h1 style="--flow-space: 4rem">Setting up</h1>
We are setting up your verification flow
</p>

<p class="center credits">
<p class="center credits" hidden>
<span class="visually-hidden">Powered by SmileID</span>
<svg
aria-hidden="true"
Expand Down
11 changes: 11 additions & 0 deletions packages/embed/src/js/basic-kyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ import { version as sdkVersion } from '../../package.json';
event.data.includes('SmileIdentity::Configuration')
) {
config = JSON.parse(event.data);

LoadingScreen.querySelector('.credits').hidden =
config.hide_attribution;
const attributions = document.querySelectorAll('.credits');
Array.prototype.forEach.call(attributions, (attribution) => {
attribution.hidden = config.hide_attribution;
});

activeScreen = LoadingScreen;

getPartnerParams();
Expand Down Expand Up @@ -397,6 +405,9 @@ import { version as sdkVersion } from '../../package.json';
EndUserConsent.setAttribute('policy-url', partnerDetails.policy_url);
EndUserConsent.setAttribute('theme-color', partnerDetails.theme_color);
EndUserConsent.setAttribute('token', config.token);
if (config.hide_attribution) {
EndUserConsent.setAttribute('hide-attribution', true);
}
if (disableBackOnFirstScreen) {
EndUserConsent.setAttribute('hide-back-to-host', true);
}
Expand Down
19 changes: 19 additions & 0 deletions packages/embed/src/js/biometric-kyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ import { version as sdkVersion } from '../../package.json';
} else {
import('@smile_identity/smart-camera-web');
}

LoadingScreen.querySelector('.credits').hidden =
config.hide_attribution;
const attributions = document.querySelectorAll('.credits');
Array.prototype.forEach.call(attributions, (attribution) => {
attribution.hidden = config.hide_attribution;
});

activeScreen = LoadingScreen;

getPartnerParams();
Expand All @@ -143,6 +151,10 @@ import { version as sdkVersion } from '../../package.json';
function setInitialScreen(partnerConstraints) {
const { country: selectedCountry, id_type: selectedIDType } = id_info;

if (config.hide_attribution) {
SmartCameraWeb.setAttribute('hide-attribution', true);
}

const selectedIdRequiresConsent = partnerConstraints.consentRequired[
selectedCountry
]
Expand Down Expand Up @@ -191,6 +203,10 @@ import { version as sdkVersion } from '../../package.json';
);
}

if (config.hide_attribution) {
SmartCameraWeb.setAttribute('hide-attribution', true);
}

const supportedCountries = Object.keys(generalConstraints)
.map((countryCode) => ({
code: countryCode,
Expand Down Expand Up @@ -480,6 +496,9 @@ import { version as sdkVersion } from '../../package.json';
EndUserConsent.setAttribute('policy-url', partnerDetails.policy_url);
EndUserConsent.setAttribute('theme-color', partnerDetails.theme_color);
EndUserConsent.setAttribute('token', config.token);
if (config.hide_attribution) {
EndUserConsent.setAttribute('hide-attribution', true);
}
if (disableBackOnFirstScreen) {
EndUserConsent.setAttribute('hide-back-to-host', true);
}
Expand Down
12 changes: 12 additions & 0 deletions packages/embed/src/js/doc-verification.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ import { version as sdkVersion } from '../../package.json';
} else {
import('@smile_identity/smart-camera-web');
}

LoadingScreen.querySelector('.credits').hidden =
config.hide_attribution;
const attributions = document.querySelectorAll('.credits');
Array.prototype.forEach.call(attributions, (attribution) => {
attribution.hidden = config.hide_attribution;
});

activeScreen = LoadingScreen;

const productConstraints = await getProductConstraints();
Expand Down Expand Up @@ -223,6 +231,10 @@ import { version as sdkVersion } from '../../package.json';
);
}

if (config.hide_attribution) {
SmartCameraWeb.setAttribute('hide-attribution', true);
}

function loadIdTypes(countryCode) {
const countryIdTypes = constraints.find(
(item) => item.country.code === countryCode,
Expand Down
8 changes: 8 additions & 0 deletions packages/embed/src/js/e-signature.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ function getHumanSize(numberOfBytes) {
event.data.includes('SmileIdentity::Configuration')
) {
config = JSON.parse(event.data);

LoadingScreen.querySelector('.credits').hidden =
config.hide_attribution;
const attributions = document.querySelectorAll('.credits');
Array.prototype.forEach.call(attributions, (attribution) => {
attribution.hidden = config.hide_attribution;
});

activeScreen = LoadingScreen;
getPartnerParams();
const documents = (await getDocuments()).documents;
Expand Down
9 changes: 9 additions & 0 deletions packages/embed/src/js/ekyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ import { version as sdkVersion } from '../../package.json';
event.data.includes('SmileIdentity::Configuration')
) {
config = JSON.parse(event.data);
LoadingScreen.querySelector('.credits').hidden =
config.hide_attribution;
const attributions = document.querySelectorAll('.credits');
Array.prototype.forEach.call(attributions, (attribution) => {
attribution.hidden = config.hide_attribution;
});
activeScreen = LoadingScreen;
getPartnerParams();
const { partnerConstraints, generalConstraints } =
Expand Down Expand Up @@ -393,6 +399,9 @@ import { version as sdkVersion } from '../../package.json';
EndUserConsent.setAttribute('policy-url', partnerDetails.policy_url);
EndUserConsent.setAttribute('theme-color', partnerDetails.theme_color);
EndUserConsent.setAttribute('token', config.token);
if (config.hide_attribution) {
EndUserConsent.setAttribute('hide-attribution', true);
}
if (disableBackOnFirstScreen) {
EndUserConsent.setAttribute('hide-back-to-host', true);
}
Expand Down
9 changes: 9 additions & 0 deletions packages/embed/src/js/enhanced-document-verification.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ import { version as sdkVersion } from '../../package.json';
} else {
import('@smile_identity/smart-camera-web');
}
LoadingScreen.querySelector('.credits').hidden =
config.hide_attribution;
const attributions = document.querySelectorAll('.credits');
Array.prototype.forEach.call(attributions, (attribution) => {
attribution.hidden = config.hide_attribution;
});
activeScreen = LoadingScreen;

productConstraints = await getProductConstraints();
Expand All @@ -91,6 +97,9 @@ import { version as sdkVersion } from '../../package.json';
config.partner_details.theme_color,
);
}
if (config.hide_attribution) {
SmartCameraWeb.setAttribute('hide-attribution', true);
}
const supportedCountries = Object.keys(constraints)
.map((countryCode) => ({
code: countryCode,
Expand Down
8 changes: 8 additions & 0 deletions packages/embed/src/js/product-selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,14 @@
) {
if (event.data.includes('SmileIdentity::Configuration')) {
config = JSON.parse(event.data);

LoadingScreen.querySelector('.credits').hidden =
config.hide_attribution;
const attributions = document.querySelectorAll('.credits');
Array.prototype.forEach.call(attributions, (attribution) => {
attribution.hidden = config.hide_attribution;
});

activeScreen = LoadingScreen;

const constraintsPromises = [
Expand Down
9 changes: 9 additions & 0 deletions packages/embed/src/js/smartselfie-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,19 @@ import { version as sdkVersion } from '../../package.json';
}
partner_params = getPartnerParams();
id_info = {};

SmartCameraWeb.setAttribute(
'theme-color',
config.partner_details.theme_color,
);

if (config.hide_attribution) {
const attributions = document.querySelectorAll('.credits');
Array.prototype.forEach.call(attributions, (attribution) => {
attribution.hidden = config.hide_attribution;
});
SmartCameraWeb.setAttribute('hide-attribution', true);
}
setActiveScreen(SmartCameraWeb);
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/embed/src/product-selection.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ <h1 style="--flow-space: 4rem">Setting up</h1>
We are setting up your verification flow
</p>

<p class="center credits">
<p class="center credits" hidden>
<span class="visually-hidden">Powered by SmileID</span>
<svg
aria-hidden="true"
Expand Down
7 changes: 6 additions & 1 deletion packages/smart-camera-web/smart-camera-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,12 @@ function hasMoreThanNColors(data, n = 16) {
return false;
}

window.customElements.define('powered-by-smile-id', PoweredBySmileId);
if (
window.customElements &&
!window.customElements.get('powered-by-smile-id')
) {
window.customElements.define('powered-by-smile-id', PoweredBySmileId);
}

class SmartCameraWeb extends HTMLElement {
constructor() {
Expand Down
11 changes: 9 additions & 2 deletions packages/smart-camera-web/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import PoweredBySmileId from './PoweredBySmileId';
import SmartCameraWeb from './SmartCameraWeb';

window.customElements.define('powered-by-smile-id', PoweredBySmileId);
window.customElements.define('smart-camera-web', SmartCameraWeb);
if (
window.customElements &&
!window.customElements.get('powered-by-smile-id')
) {
window.customElements.define('powered-by-smile-id', PoweredBySmileId);
}
if (window.customElements && !window.customElements.get('smart-camera-web')) {
window.customElements.define('smart-camera-web', SmartCameraWeb);
}
Loading

0 comments on commit 1631385

Please sign in to comment.