@adyen/kyc-components 2.6.1 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/adyen-kyc-components.es.js +478 -396
- package/dist/types/components/BankVerification/verification/widget/iframeWidget.d.ts +2 -1
- package/dist/types/components/UIElement.d.ts +2 -1
- package/dist/types/core/Context/AuthContext/AuthContext.d.ts +14 -0
- package/dist/types/core/Context/AuthContext/AuthProvider.d.ts +9 -0
- package/dist/types/core/Context/AuthContext/useAuthContext.d.ts +2 -0
- package/dist/types/core/Context/ConfigurationApiContext/ConfigurationApiContext.d.ts +1 -0
- package/dist/types/core/Context/CoreContext.d.ts +2 -13
- package/dist/types/core/Context/CoreProvider.d.ts +3 -29
- package/dist/types/core/Services/auth/refresh-sdkToken.d.ts +6 -0
- package/dist/types/core/Services/types.d.ts +4 -2
- package/dist/types/core/hooks/useComponentApi.d.ts +1 -0
- package/dist/types/core/hooks/useSdkToken.d.ts +5 -0
- package/dist/types/core/types.d.ts +1 -0
- package/package.json +8 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useContext, useState, useCallback, useEffect, useMemo, useReducer, useLayoutEffect, useRef as useRef$1, useId as useId$1 } from "preact/hooks";
|
|
2
|
-
import { createContext, createElement,
|
|
2
|
+
import { createContext, createElement, toChildArray, render } from "preact";
|
|
3
3
|
import cx from "classnames";
|
|
4
4
|
import { jsx, jsxs, Fragment } from "preact/jsx-runtime";
|
|
5
5
|
import { useId, useRef, useMemo as useMemo$1, forwardRef, memo } from "preact/compat";
|
|
@@ -499,7 +499,7 @@ const createLogger = (namespace) => {
|
|
|
499
499
|
});
|
|
500
500
|
return methods;
|
|
501
501
|
};
|
|
502
|
-
const logger$
|
|
502
|
+
const logger$j = createLogger("Link");
|
|
503
503
|
const getIconClass = (icon, external) => {
|
|
504
504
|
if (external) {
|
|
505
505
|
return "adl-link__icon adyen-kyc-icon-external-link";
|
|
@@ -511,7 +511,7 @@ const getIconClass = (icon, external) => {
|
|
|
511
511
|
};
|
|
512
512
|
const isValidLink = (href) => {
|
|
513
513
|
if (href === "#") {
|
|
514
|
-
logger$
|
|
514
|
+
logger$j.error('Links must include a valid href. If your href is "#", consider using a Button instead');
|
|
515
515
|
return false;
|
|
516
516
|
}
|
|
517
517
|
return true;
|
|
@@ -1104,7 +1104,7 @@ class ValidationResult {
|
|
|
1104
1104
|
return this.validationResults.filter((result) => result.hasError);
|
|
1105
1105
|
}
|
|
1106
1106
|
}
|
|
1107
|
-
const logger$
|
|
1107
|
+
const logger$i = createLogger("useAsyncValidator");
|
|
1108
1108
|
const useAsyncValidator = (asyncRules) => {
|
|
1109
1109
|
const [asyncValidationResults, setAsyncValidationResults] = useState({});
|
|
1110
1110
|
const clearAsyncValidationResults = useCallback(() => setAsyncValidationResults({}), []);
|
|
@@ -1127,7 +1127,7 @@ const useAsyncValidator = (asyncRules) => {
|
|
|
1127
1127
|
hasError: !isValid
|
|
1128
1128
|
}])
|
|
1129
1129
|
});
|
|
1130
|
-
}).catch(logger$
|
|
1130
|
+
}).catch(logger$i.error);
|
|
1131
1131
|
}, [asyncRules, clearAsyncValidationResults]);
|
|
1132
1132
|
return {
|
|
1133
1133
|
asyncValidationResults,
|
|
@@ -5146,7 +5146,7 @@ function datasetUtilities(locale) {
|
|
|
5146
5146
|
getDatasetKey: (identifier) => createDatasetKey(identifier, locale)
|
|
5147
5147
|
};
|
|
5148
5148
|
}
|
|
5149
|
-
const logger$
|
|
5149
|
+
const logger$h = createLogger("CountryField");
|
|
5150
5150
|
function CountryField({
|
|
5151
5151
|
allowedCountries = [],
|
|
5152
5152
|
classNameModifiers = [],
|
|
@@ -5167,7 +5167,7 @@ function CountryField({
|
|
|
5167
5167
|
dataset: countriesFromApi
|
|
5168
5168
|
} = useDataset(datasetIdentifier.country);
|
|
5169
5169
|
useEffect(() => {
|
|
5170
|
-
loadFlags2().catch(logger$
|
|
5170
|
+
loadFlags2().catch(logger$h.error);
|
|
5171
5171
|
}, [loadFlags2]);
|
|
5172
5172
|
const countries = countriesFromApi.filter((country2) => allowedCountries.length ? allowedCountries.includes(country2.id) : true).map((item) => ({
|
|
5173
5173
|
...item,
|
|
@@ -6293,7 +6293,7 @@ const accountHolderValidationRules = {
|
|
|
6293
6293
|
}
|
|
6294
6294
|
};
|
|
6295
6295
|
const accountHolderFields = ["accountHolder"];
|
|
6296
|
-
const logger$
|
|
6296
|
+
const logger$g = createLogger("AccountHolder");
|
|
6297
6297
|
function getAvailableAccountHolderOptions(legalEntityType, isChangeOfLegalEntityTypeAllowed, isTrustFlowEnabled, isSoleProprietorshipAllowed, isChangeToMyNameAllowed) {
|
|
6298
6298
|
switch (legalEntityType) {
|
|
6299
6299
|
case LegalEntityType.ORGANIZATION: {
|
|
@@ -6303,7 +6303,7 @@ function getAvailableAccountHolderOptions(legalEntityType, isChangeOfLegalEntity
|
|
|
6303
6303
|
return [...isChangeToMyNameAllowed ? ["myName"] : [], ...isChangeOfLegalEntityTypeAllowed ? ["theCompanyIWorkFor"] : [], ...isTrustFlowEnabled ? ["aTrust"] : [], ...isSoleProprietorshipAllowed ? ["mySoleTraderName"] : []];
|
|
6304
6304
|
}
|
|
6305
6305
|
default:
|
|
6306
|
-
logger$
|
|
6306
|
+
logger$g.error(`No available account holder options for legal entity type '${legalEntityType}'`);
|
|
6307
6307
|
return [];
|
|
6308
6308
|
}
|
|
6309
6309
|
}
|
|
@@ -6633,184 +6633,19 @@ const getDocumentGuidancePrefix = (documentType2, isIcon = false, isFront = true
|
|
|
6633
6633
|
}
|
|
6634
6634
|
};
|
|
6635
6635
|
const _documentGuidance_component = "";
|
|
6636
|
-
const getFontFaceRule = (fontFamily, fontStyle, fontWeight, fontSrc, additionalFormats) => {
|
|
6637
|
-
const ruleLines = [`font-family: '${fontFamily}'`, `font-style: ${fontStyle}`, `font-weight: ${fontWeight}`, `src: url(${fontSrc})`];
|
|
6638
|
-
const additionalSources = [];
|
|
6639
|
-
if (additionalFormats.eot) {
|
|
6640
|
-
additionalSources.push(`url(${additionalFormats.eot}) format('embedded-opentype')`);
|
|
6641
|
-
}
|
|
6642
|
-
if (additionalFormats.woff) {
|
|
6643
|
-
additionalSources.push(`url(${additionalFormats.woff}) format('woff')`);
|
|
6644
|
-
}
|
|
6645
|
-
if (additionalFormats.woff2) {
|
|
6646
|
-
additionalSources.push(`url(${additionalFormats.woff2}) format('woff2')`);
|
|
6647
|
-
}
|
|
6648
|
-
if (additionalFormats.ttf) {
|
|
6649
|
-
additionalSources.push(`url(${additionalFormats.ttf}) format('truetype')`);
|
|
6650
|
-
}
|
|
6651
|
-
if (additionalFormats.otf) {
|
|
6652
|
-
additionalSources.push(`url(${additionalFormats.otf}) format('opentype')`);
|
|
6653
|
-
}
|
|
6654
|
-
if (additionalSources.length > 0) {
|
|
6655
|
-
ruleLines.push(`src: ${additionalSources.join(",")};`);
|
|
6656
|
-
}
|
|
6657
|
-
return `@font-face {${ruleLines.join(";")}}`;
|
|
6658
|
-
};
|
|
6659
|
-
const loadFont = (fontFamily, fontStyle, fontWeight, fontSrc, additionalFormats) => {
|
|
6660
|
-
const style = document.createElement("style");
|
|
6661
|
-
style.setAttribute("type", "text/css");
|
|
6662
|
-
style.innerText = getFontFaceRule(fontFamily, fontStyle, fontWeight, fontSrc, additionalFormats);
|
|
6663
|
-
document.body.insertBefore(style, document.body.firstChild);
|
|
6664
|
-
};
|
|
6665
|
-
const loadADLIconFont = (loadingContext) => {
|
|
6666
|
-
const fontPath = `${loadingContext}static/fonts`;
|
|
6667
|
-
const iconFontPath = `${fontPath}/adyen-kyc-icons`;
|
|
6668
|
-
loadFont("adyen-kyc-icons", "normal", "normal", `${iconFontPath}.eot`, {
|
|
6669
|
-
eot: `${iconFontPath}.eot`,
|
|
6670
|
-
woff: `${iconFontPath}.woff`,
|
|
6671
|
-
woff2: `${iconFontPath}.woff2`,
|
|
6672
|
-
ttf: `${iconFontPath}.ttf`,
|
|
6673
|
-
otf: `${iconFontPath}.otf`
|
|
6674
|
-
});
|
|
6675
|
-
};
|
|
6676
|
-
const logger$e = createLogger("Fetch");
|
|
6677
|
-
const getRequestObject = (options, data) => {
|
|
6678
|
-
const {
|
|
6679
|
-
headers = [],
|
|
6680
|
-
method = "GET",
|
|
6681
|
-
sdkToken
|
|
6682
|
-
} = options;
|
|
6683
|
-
let authHeaders;
|
|
6684
|
-
if (options.sdkToken) {
|
|
6685
|
-
authHeaders = {
|
|
6686
|
-
Authorization: `Bearer ${sdkToken}`,
|
|
6687
|
-
Origin: window.location.origin
|
|
6688
|
-
};
|
|
6689
|
-
}
|
|
6690
|
-
return {
|
|
6691
|
-
method,
|
|
6692
|
-
mode: "cors",
|
|
6693
|
-
cache: "default",
|
|
6694
|
-
credentials: "same-origin",
|
|
6695
|
-
headers: {
|
|
6696
|
-
Accept: "application/json, text/plain, */*",
|
|
6697
|
-
"Content-Type": method === "POST" ? "application/json" : "text/plain",
|
|
6698
|
-
...authHeaders,
|
|
6699
|
-
...headers
|
|
6700
|
-
},
|
|
6701
|
-
redirect: "follow",
|
|
6702
|
-
referrerPolicy: "no-referrer-when-downgrade",
|
|
6703
|
-
...data && {
|
|
6704
|
-
body: JSON.stringify(data)
|
|
6705
|
-
}
|
|
6706
|
-
};
|
|
6707
|
-
};
|
|
6708
|
-
const getRequestUrl = (loadingContext, path, clientKey) => {
|
|
6709
|
-
let url = `${loadingContext}${path}`;
|
|
6710
|
-
if (clientKey) {
|
|
6711
|
-
url += `?clientKey=${clientKey}`;
|
|
6712
|
-
}
|
|
6713
|
-
return url;
|
|
6714
|
-
};
|
|
6715
|
-
const handleFetchError = (message, level) => {
|
|
6716
|
-
switch (level) {
|
|
6717
|
-
case "silent":
|
|
6718
|
-
break;
|
|
6719
|
-
case "info":
|
|
6720
|
-
case "warn":
|
|
6721
|
-
case "error":
|
|
6722
|
-
return logger$e[level](message);
|
|
6723
|
-
default:
|
|
6724
|
-
throw new Error(message);
|
|
6725
|
-
}
|
|
6726
|
-
};
|
|
6727
|
-
const handleFetchResponse = async (response, responseType) => {
|
|
6728
|
-
switch (responseType) {
|
|
6729
|
-
case "arraybuffer":
|
|
6730
|
-
return response.arrayBuffer();
|
|
6731
|
-
case "blob":
|
|
6732
|
-
return response.blob();
|
|
6733
|
-
case "json":
|
|
6734
|
-
return response.json();
|
|
6735
|
-
case "text":
|
|
6736
|
-
return response.text();
|
|
6737
|
-
}
|
|
6738
|
-
};
|
|
6739
|
-
const http = async (options, data, responseType = "json") => {
|
|
6740
|
-
const {
|
|
6741
|
-
errorLevel = "warn",
|
|
6742
|
-
loadingContext = "",
|
|
6743
|
-
path,
|
|
6744
|
-
clientKey = ""
|
|
6745
|
-
} = options;
|
|
6746
|
-
const request = getRequestObject(options, data);
|
|
6747
|
-
const url = getRequestUrl(loadingContext, path, clientKey);
|
|
6748
|
-
return fetch(url, request).then((response) => {
|
|
6749
|
-
if (response.ok)
|
|
6750
|
-
return handleFetchResponse(response, responseType);
|
|
6751
|
-
const errorMessage = options.errorMessage || `Service at ${url} is not available`;
|
|
6752
|
-
if (options.errorHandler) {
|
|
6753
|
-
return options.errorHandler(handleFetchResponse(response, responseType));
|
|
6754
|
-
}
|
|
6755
|
-
return handleFetchError(errorMessage, errorLevel);
|
|
6756
|
-
}).catch((e) => {
|
|
6757
|
-
const errorMessage = options.errorMessage || `Call to ${url} failed. Error= ${e}`;
|
|
6758
|
-
return handleFetchError(errorMessage, errorLevel);
|
|
6759
|
-
});
|
|
6760
|
-
};
|
|
6761
|
-
const httpGet = async (options, data) => http({
|
|
6762
|
-
...options,
|
|
6763
|
-
method: "GET"
|
|
6764
|
-
}, data);
|
|
6765
|
-
const httpPost = async (options, data) => http({
|
|
6766
|
-
...options,
|
|
6767
|
-
method: "POST"
|
|
6768
|
-
}, data);
|
|
6769
|
-
let isFlagsLoaded = false;
|
|
6770
|
-
let isDocumentGuidanceLoaded = false;
|
|
6771
|
-
const getIconContainer = () => {
|
|
6772
|
-
const container = document.createElement("div");
|
|
6773
|
-
container.setAttribute("aria-hidden", "true");
|
|
6774
|
-
container.setAttribute("id", "adl-icon-container");
|
|
6775
|
-
container.style.height = "0";
|
|
6776
|
-
return container;
|
|
6777
|
-
};
|
|
6778
|
-
const buildSpriteDOMFromResponse = (responseData) => {
|
|
6779
|
-
const iconContainer = getIconContainer();
|
|
6780
|
-
iconContainer.innerHTML = responseData;
|
|
6781
|
-
return iconContainer;
|
|
6782
|
-
};
|
|
6783
|
-
const loadFlags = async (loadingContext) => {
|
|
6784
|
-
if (isFlagsLoaded)
|
|
6785
|
-
return;
|
|
6786
|
-
isFlagsLoaded = true;
|
|
6787
|
-
const responseData = await http({
|
|
6788
|
-
loadingContext,
|
|
6789
|
-
path: "static/images/country-flags.svg"
|
|
6790
|
-
}, null, "text");
|
|
6791
|
-
document.body.insertBefore(buildSpriteDOMFromResponse(responseData), document.body.firstChild);
|
|
6792
|
-
};
|
|
6793
|
-
const loadDocumentGuidance = async (loadingContext) => {
|
|
6794
|
-
if (isDocumentGuidanceLoaded)
|
|
6795
|
-
return;
|
|
6796
|
-
isDocumentGuidanceLoaded = true;
|
|
6797
|
-
const responseData = await http({
|
|
6798
|
-
loadingContext,
|
|
6799
|
-
path: "static/images/document-guidance.svg"
|
|
6800
|
-
}, null, "text");
|
|
6801
|
-
document.body.insertBefore(buildSpriteDOMFromResponse(responseData), document.body.firstChild);
|
|
6802
|
-
};
|
|
6803
6636
|
function DocumentGuidance({
|
|
6804
6637
|
type,
|
|
6805
6638
|
className
|
|
6806
6639
|
}) {
|
|
6807
6640
|
const {
|
|
6808
|
-
loadingContext,
|
|
6809
6641
|
i18n
|
|
6810
6642
|
} = useCoreContext();
|
|
6643
|
+
const {
|
|
6644
|
+
loadDocumentGuidance: loadDocumentGuidance2
|
|
6645
|
+
} = useConfigurationApi();
|
|
6811
6646
|
const [guidancePrefix, setGuidancePrefix] = useState(null);
|
|
6812
6647
|
useEffect(() => {
|
|
6813
|
-
|
|
6648
|
+
loadDocumentGuidance2();
|
|
6814
6649
|
}, []);
|
|
6815
6650
|
useEffect(() => {
|
|
6816
6651
|
setGuidancePrefix(getDocumentGuidancePrefix(type));
|
|
@@ -7198,7 +7033,7 @@ function Dropzone(props) {
|
|
|
7198
7033
|
})]
|
|
7199
7034
|
});
|
|
7200
7035
|
}
|
|
7201
|
-
const logger$
|
|
7036
|
+
const logger$f = createLogger("TextArea");
|
|
7202
7037
|
function TextArea(props) {
|
|
7203
7038
|
const {
|
|
7204
7039
|
classNameModifiers,
|
|
@@ -7219,7 +7054,7 @@ function TextArea(props) {
|
|
|
7219
7054
|
} = useCoreContext();
|
|
7220
7055
|
const [value, setValue] = useState("");
|
|
7221
7056
|
if (Object.prototype.hasOwnProperty.call(props, "onChange")) {
|
|
7222
|
-
logger$
|
|
7057
|
+
logger$f.error("Error: Form fields that rely on InputBase may not have an onChange property");
|
|
7223
7058
|
}
|
|
7224
7059
|
const handleInput = (e) => {
|
|
7225
7060
|
var _a;
|
|
@@ -7614,7 +7449,7 @@ function FieldContainer(props) {
|
|
|
7614
7449
|
}
|
|
7615
7450
|
return renderField(fieldName);
|
|
7616
7451
|
}
|
|
7617
|
-
const logger$
|
|
7452
|
+
const logger$e = createLogger("SearchAddress");
|
|
7618
7453
|
const SearchAddress = ({
|
|
7619
7454
|
data,
|
|
7620
7455
|
legalEntityId,
|
|
@@ -7640,7 +7475,7 @@ const SearchAddress = ({
|
|
|
7640
7475
|
const response = await handleFindAddress(selectedAddressId);
|
|
7641
7476
|
autocompleteAddressForm(response);
|
|
7642
7477
|
} catch (e) {
|
|
7643
|
-
logger$
|
|
7478
|
+
logger$e.error(e);
|
|
7644
7479
|
}
|
|
7645
7480
|
};
|
|
7646
7481
|
const onDrilldown = async (selectedAddress) => {
|
|
@@ -7652,7 +7487,7 @@ const SearchAddress = ({
|
|
|
7652
7487
|
}, legalEntityId);
|
|
7653
7488
|
setItems((response == null ? void 0 : response.results) || []);
|
|
7654
7489
|
} catch (e) {
|
|
7655
|
-
logger$
|
|
7490
|
+
logger$e.error(e);
|
|
7656
7491
|
}
|
|
7657
7492
|
};
|
|
7658
7493
|
const onChange = (e) => {
|
|
@@ -7707,7 +7542,7 @@ const SearchAddress = ({
|
|
|
7707
7542
|
setItems([]);
|
|
7708
7543
|
}
|
|
7709
7544
|
} catch (e) {
|
|
7710
|
-
logger$
|
|
7545
|
+
logger$e.error(e);
|
|
7711
7546
|
}
|
|
7712
7547
|
setLoading(false);
|
|
7713
7548
|
}
|
|
@@ -10859,7 +10694,7 @@ const initOnfido = async ({
|
|
|
10859
10694
|
language: getOnfidoLocaleConfig(i18n)
|
|
10860
10695
|
});
|
|
10861
10696
|
};
|
|
10862
|
-
const logger$
|
|
10697
|
+
const logger$d = createLogger("IdVerificationComponent");
|
|
10863
10698
|
function IdVerificationComponent({
|
|
10864
10699
|
userDetails,
|
|
10865
10700
|
handleGetIdVerificationToken,
|
|
@@ -10890,7 +10725,7 @@ function IdVerificationComponent({
|
|
|
10890
10725
|
onIdVerificationError,
|
|
10891
10726
|
onIdVerificationComplete
|
|
10892
10727
|
});
|
|
10893
|
-
})().catch(logger$
|
|
10728
|
+
})().catch(logger$d.error);
|
|
10894
10729
|
return () => {
|
|
10895
10730
|
if (onfidoSdk.current)
|
|
10896
10731
|
onfidoSdk.current.tearDown();
|
|
@@ -10942,7 +10777,7 @@ function IdDocumentAlreadyUpload(props) {
|
|
|
10942
10777
|
})]
|
|
10943
10778
|
});
|
|
10944
10779
|
}
|
|
10945
|
-
const logger$
|
|
10780
|
+
const logger$c = createLogger("IdDocumentInstantVerificationComponent");
|
|
10946
10781
|
const idVerificationSchema = ["instantIdVerificationData", "idDocumentType"];
|
|
10947
10782
|
const documentTypeValidationRules = {
|
|
10948
10783
|
instantIdVerificationData: {
|
|
@@ -11023,7 +10858,7 @@ function IdDocumentInstantVerificationComponent(props) {
|
|
|
11023
10858
|
handleGetIdVerificationToken: props.handleGetIdVerificationToken,
|
|
11024
10859
|
userDetails: props.userDetails,
|
|
11025
10860
|
onIdVerificationComplete: handleIdVerificationComplete,
|
|
11026
|
-
onIdVerificationError: logger$
|
|
10861
|
+
onIdVerificationError: logger$c.error
|
|
11027
10862
|
}), jsxs("div", {
|
|
11028
10863
|
className: "adyen-kyc-document-upload__manual-upload",
|
|
11029
10864
|
children: [i18n.get("canNotCompleteInstantVerification"), " ", jsx("button", {
|
|
@@ -11170,15 +11005,17 @@ const IdVerificationMethodOptionFooter = ({
|
|
|
11170
11005
|
const idVerificationMethodFields = ["idVerificationMethod"];
|
|
11171
11006
|
function IdVerificationMethodComponent(props) {
|
|
11172
11007
|
const {
|
|
11173
|
-
i18n
|
|
11174
|
-
loadingContext
|
|
11008
|
+
i18n
|
|
11175
11009
|
} = useCoreContext();
|
|
11010
|
+
const {
|
|
11011
|
+
getImageUrl
|
|
11012
|
+
} = useConfigurationApi();
|
|
11176
11013
|
const verificationMethodFormId = props.id;
|
|
11177
11014
|
const schema = idVerificationMethodFields;
|
|
11178
11015
|
const stateRef = useRef$1({
|
|
11179
11016
|
setState: null
|
|
11180
11017
|
});
|
|
11181
|
-
const svgPath = `${
|
|
11018
|
+
const svgPath = `${getImageUrl()}id-verification-method`;
|
|
11182
11019
|
const methodsMetadata = makeIdVerificationMethodsMetadata(svgPath);
|
|
11183
11020
|
const {
|
|
11184
11021
|
handleChangeFor,
|
|
@@ -13523,6 +13360,14 @@ const bankVerificationValidationRules = {
|
|
|
13523
13360
|
}
|
|
13524
13361
|
};
|
|
13525
13362
|
const BankVerificationWidget$1 = "";
|
|
13363
|
+
const AuthContext = createContext(void 0);
|
|
13364
|
+
const useAuthContext = () => {
|
|
13365
|
+
const authContext = useContext(AuthContext);
|
|
13366
|
+
if (!authContext) {
|
|
13367
|
+
throw new Error("Cannot use authContext without <AuthProvider>");
|
|
13368
|
+
}
|
|
13369
|
+
return authContext;
|
|
13370
|
+
};
|
|
13526
13371
|
class AdyenKycSdkError extends Error {
|
|
13527
13372
|
constructor(message, sourceError) {
|
|
13528
13373
|
super(message);
|
|
@@ -13550,6 +13395,99 @@ const removeAnimationStartListener = (element, listener) => {
|
|
|
13550
13395
|
element.removeEventListener("MSAnimationStart", listener, false);
|
|
13551
13396
|
element.removeEventListener("webkitAnimationStart", listener, false);
|
|
13552
13397
|
};
|
|
13398
|
+
const logger$b = createLogger("Fetch");
|
|
13399
|
+
const getRequestObject = (options, data) => {
|
|
13400
|
+
const {
|
|
13401
|
+
headers = [],
|
|
13402
|
+
method = "GET",
|
|
13403
|
+
sdkToken
|
|
13404
|
+
} = options;
|
|
13405
|
+
let authHeaders;
|
|
13406
|
+
if (options.sdkToken) {
|
|
13407
|
+
authHeaders = {
|
|
13408
|
+
Authorization: `Bearer ${sdkToken}`,
|
|
13409
|
+
Origin: window.location.origin
|
|
13410
|
+
};
|
|
13411
|
+
}
|
|
13412
|
+
return {
|
|
13413
|
+
method,
|
|
13414
|
+
mode: "cors",
|
|
13415
|
+
cache: "default",
|
|
13416
|
+
credentials: "same-origin",
|
|
13417
|
+
headers: {
|
|
13418
|
+
Accept: "application/json, text/plain, */*",
|
|
13419
|
+
"Content-Type": method === "POST" ? "application/json" : "text/plain",
|
|
13420
|
+
...authHeaders,
|
|
13421
|
+
...headers
|
|
13422
|
+
},
|
|
13423
|
+
redirect: "follow",
|
|
13424
|
+
referrerPolicy: "no-referrer-when-downgrade",
|
|
13425
|
+
...data && {
|
|
13426
|
+
body: JSON.stringify(data)
|
|
13427
|
+
}
|
|
13428
|
+
};
|
|
13429
|
+
};
|
|
13430
|
+
const getRequestUrl = (loadingContext, path, clientKey) => {
|
|
13431
|
+
let url = `${loadingContext}${path}`;
|
|
13432
|
+
if (clientKey) {
|
|
13433
|
+
url += `?clientKey=${clientKey}`;
|
|
13434
|
+
}
|
|
13435
|
+
return url;
|
|
13436
|
+
};
|
|
13437
|
+
const handleFetchError = (message, level) => {
|
|
13438
|
+
switch (level) {
|
|
13439
|
+
case "silent":
|
|
13440
|
+
break;
|
|
13441
|
+
case "info":
|
|
13442
|
+
case "warn":
|
|
13443
|
+
case "error":
|
|
13444
|
+
return logger$b[level](message);
|
|
13445
|
+
default:
|
|
13446
|
+
throw new Error(message);
|
|
13447
|
+
}
|
|
13448
|
+
};
|
|
13449
|
+
const handleFetchResponse = async (response, responseType) => {
|
|
13450
|
+
switch (responseType) {
|
|
13451
|
+
case "arraybuffer":
|
|
13452
|
+
return response.arrayBuffer();
|
|
13453
|
+
case "blob":
|
|
13454
|
+
return response.blob();
|
|
13455
|
+
case "json":
|
|
13456
|
+
return response.json();
|
|
13457
|
+
case "text":
|
|
13458
|
+
return response.text();
|
|
13459
|
+
}
|
|
13460
|
+
};
|
|
13461
|
+
const http = async (options, data, responseType = "json") => {
|
|
13462
|
+
const {
|
|
13463
|
+
errorLevel = "warn",
|
|
13464
|
+
loadingContext = "",
|
|
13465
|
+
path,
|
|
13466
|
+
clientKey = ""
|
|
13467
|
+
} = options;
|
|
13468
|
+
const request = getRequestObject(options, data);
|
|
13469
|
+
const url = getRequestUrl(loadingContext, path, clientKey);
|
|
13470
|
+
return fetch(url, request).then((response) => {
|
|
13471
|
+
if (response.ok)
|
|
13472
|
+
return handleFetchResponse(response, responseType);
|
|
13473
|
+
const errorMessage = options.errorMessage || `Service at ${url} is not available`;
|
|
13474
|
+
if (options.errorHandler) {
|
|
13475
|
+
return options.errorHandler(handleFetchResponse(response, responseType));
|
|
13476
|
+
}
|
|
13477
|
+
return handleFetchError(errorMessage, errorLevel);
|
|
13478
|
+
}).catch((e) => {
|
|
13479
|
+
const errorMessage = options.errorMessage || `Call to ${url} failed. Error= ${e}`;
|
|
13480
|
+
return handleFetchError(errorMessage, errorLevel);
|
|
13481
|
+
});
|
|
13482
|
+
};
|
|
13483
|
+
const httpGet = async (options, data) => http({
|
|
13484
|
+
...options,
|
|
13485
|
+
method: "GET"
|
|
13486
|
+
}, data);
|
|
13487
|
+
const httpPost = async (options, data) => http({
|
|
13488
|
+
...options,
|
|
13489
|
+
method: "POST"
|
|
13490
|
+
}, data);
|
|
13553
13491
|
const removeElementSiblings = (element) => {
|
|
13554
13492
|
const parent = element.parentNode;
|
|
13555
13493
|
let child = parent.firstChild;
|
|
@@ -13563,7 +13501,7 @@ const RELEVANT_MESSAGE_TYPES = ["account_verification_report_id", "error"];
|
|
|
13563
13501
|
const TERMINAL_DATA_PROPS = ["accounts", "error", "reference"];
|
|
13564
13502
|
const MOUNT_TIMEOUT = 10 * 1e3;
|
|
13565
13503
|
const TINK_VENDOR = "Tink";
|
|
13566
|
-
const logger$
|
|
13504
|
+
const logger$a = createLogger("iframeWidget");
|
|
13567
13505
|
const isObjectData = (data) => typeof data === "object" && !Array.isArray(data) && data !== null;
|
|
13568
13506
|
const isTerminalMessageData = (data) => Object.entries(data).some(([prop]) => TERMINAL_DATA_PROPS.includes(prop));
|
|
13569
13507
|
const parseMessageJson = (message) => {
|
|
@@ -13582,7 +13520,7 @@ const callbackErrorHandler = async (response) => {
|
|
|
13582
13520
|
try {
|
|
13583
13521
|
await response;
|
|
13584
13522
|
} catch (ex) {
|
|
13585
|
-
logger$
|
|
13523
|
+
logger$a.error(ex);
|
|
13586
13524
|
}
|
|
13587
13525
|
return {
|
|
13588
13526
|
error: "UNKNOWN_ERROR",
|
|
@@ -13591,7 +13529,7 @@ const callbackErrorHandler = async (response) => {
|
|
|
13591
13529
|
};
|
|
13592
13530
|
let activeWidget;
|
|
13593
13531
|
class IFrameWidget {
|
|
13594
|
-
constructor(iframeElement, url, vendor) {
|
|
13532
|
+
constructor(iframeElement, url, vendor, sdkToken) {
|
|
13595
13533
|
this.mountInProgress = false;
|
|
13596
13534
|
this.waitForResponse = async () => new Promise((resolve, reject) => {
|
|
13597
13535
|
this.listener = async (message) => {
|
|
@@ -13614,6 +13552,7 @@ class IFrameWidget {
|
|
|
13614
13552
|
this.iframeElement = iframeElement;
|
|
13615
13553
|
this.iframeWindow = iframeElement.contentWindow;
|
|
13616
13554
|
this.vendor = vendor;
|
|
13555
|
+
this.sdkToken = sdkToken;
|
|
13617
13556
|
}
|
|
13618
13557
|
removeMessageEventListener() {
|
|
13619
13558
|
if (!this.listener)
|
|
@@ -13642,7 +13581,8 @@ class IFrameWidget {
|
|
|
13642
13581
|
const httpOptions = {
|
|
13643
13582
|
errorHandler: callbackErrorHandler,
|
|
13644
13583
|
errorLevel: null,
|
|
13645
|
-
loadingContext: ""
|
|
13584
|
+
loadingContext: "",
|
|
13585
|
+
sdkToken: this.sdkToken
|
|
13646
13586
|
};
|
|
13647
13587
|
const redirectUrl = new URL(this.iframeUrl.searchParams.get("redirect_uri"));
|
|
13648
13588
|
const redirectQueryParams = redirectUrl.searchParams;
|
|
@@ -13686,7 +13626,7 @@ class IFrameWidget {
|
|
|
13686
13626
|
message = responseData.errorMessage;
|
|
13687
13627
|
}
|
|
13688
13628
|
} catch (ex) {
|
|
13689
|
-
logger$
|
|
13629
|
+
logger$a.error(ex);
|
|
13690
13630
|
}
|
|
13691
13631
|
throw new AdyenKycSdkError(message);
|
|
13692
13632
|
}
|
|
@@ -13762,6 +13702,8 @@ function BankVerificationWidget({
|
|
|
13762
13702
|
widgetCallback
|
|
13763
13703
|
}) {
|
|
13764
13704
|
const widgetContainerRef = useRef$1(null);
|
|
13705
|
+
const context = useAuthContext();
|
|
13706
|
+
const sdkToken = context.isEmbeddedDropin ? context.sdkToken : void 0;
|
|
13765
13707
|
useEffect(
|
|
13766
13708
|
() => {
|
|
13767
13709
|
const container = widgetContainerRef.current;
|
|
@@ -13776,7 +13718,7 @@ function BankVerificationWidget({
|
|
|
13776
13718
|
evt.target.appendChild(iFrame);
|
|
13777
13719
|
requestAnimationFrame(async () => {
|
|
13778
13720
|
try {
|
|
13779
|
-
iFrameWidget = new IFrameWidget(iFrame, url, vendor);
|
|
13721
|
+
iFrameWidget = new IFrameWidget(iFrame, url, vendor, sdkToken);
|
|
13780
13722
|
const result = await iFrameWidget.mountAndWaitForResponse();
|
|
13781
13723
|
widgetCallback({
|
|
13782
13724
|
action: "verification_success",
|
|
@@ -13824,7 +13766,7 @@ function BankVerificationWidget({
|
|
|
13824
13766
|
ref: widgetContainerRef
|
|
13825
13767
|
});
|
|
13826
13768
|
}
|
|
13827
|
-
const logger$
|
|
13769
|
+
const logger$9 = createLogger("BankVerification");
|
|
13828
13770
|
const accountVerificationFields = ["verifiedAccountHolder", "verifiedBankCountry", "verifiedBankName", "verifiedCurrencyCode", "verifiedBankAccountNumber"];
|
|
13829
13771
|
const InstantVerificationErrorContext = createContext(null);
|
|
13830
13772
|
const useInstantVerificationErrorNotification = (notificationVisibilityDuration) => {
|
|
@@ -13858,7 +13800,7 @@ const usePreferredVendorForCountry = (country2, getBankVerificationVendors) => {
|
|
|
13858
13800
|
const preferredVendor2 = vendors[0];
|
|
13859
13801
|
setPreferredVendor(preferredVendor2.name ? preferredVendor2 : null);
|
|
13860
13802
|
};
|
|
13861
|
-
getPreferredVendor().catch(logger$
|
|
13803
|
+
getPreferredVendor().catch(logger$9.error);
|
|
13862
13804
|
}, [country2, getBankVerificationVendors]);
|
|
13863
13805
|
return preferredVendor;
|
|
13864
13806
|
};
|
|
@@ -15323,9 +15265,11 @@ const getInstantVerificationProvider = (bankVerificationProviders, bankCountry2)
|
|
|
15323
15265
|
function PayoutVerificationMethod(props) {
|
|
15324
15266
|
var _a;
|
|
15325
15267
|
const {
|
|
15326
|
-
i18n
|
|
15327
|
-
loadingContext
|
|
15268
|
+
i18n
|
|
15328
15269
|
} = useCoreContext();
|
|
15270
|
+
const {
|
|
15271
|
+
getImageUrl
|
|
15272
|
+
} = useConfigurationApi();
|
|
15329
15273
|
const instantVerificationError = useContext(InstantVerificationErrorContext);
|
|
15330
15274
|
const {
|
|
15331
15275
|
isSettingEnabled
|
|
@@ -15364,7 +15308,7 @@ function PayoutVerificationMethod(props) {
|
|
|
15364
15308
|
}), [data, errors, fieldProblems, valid]);
|
|
15365
15309
|
const providerName = getInstantVerificationProvider(props.bankVerificationVendors, data.bankCountry);
|
|
15366
15310
|
const instantVerificationAvailable = Boolean(props.instantVerificationAllowed && providerName && providerName !== "loading");
|
|
15367
|
-
const svgPath = `${
|
|
15311
|
+
const svgPath = `${getImageUrl()}payout-verification-method`;
|
|
15368
15312
|
const methodsMetadata = makePayoutVerificationMethodsMetadata(svgPath, providerName === "loading" ? void 0 : providerName);
|
|
15369
15313
|
useEffect(() => {
|
|
15370
15314
|
if (!hasSelectedMethod && instantVerificationAvailable && data.payoutVerificationMethod !== "instantVerification") {
|
|
@@ -16210,7 +16154,6 @@ const remediationActionMappings = {
|
|
|
16210
16154
|
}]
|
|
16211
16155
|
};
|
|
16212
16156
|
const dataMissingRemediationsToFieldsMap = {
|
|
16213
|
-
"1_501": [DocumentType.REGISTRATION_DOCUMENT],
|
|
16214
16157
|
"2_158": ["vatNumber", "exemptedFromVat", "vatAbsenceReason"]
|
|
16215
16158
|
};
|
|
16216
16159
|
var EntityType = /* @__PURE__ */ ((EntityType2) => {
|
|
@@ -17026,7 +16969,7 @@ const defaultPayoutAccountFormat = {
|
|
|
17026
16969
|
[CountryCodes.Sweden]: "local",
|
|
17027
16970
|
[CountryCodes.UnitedKingdom]: "local"
|
|
17028
16971
|
};
|
|
17029
|
-
const logger$
|
|
16972
|
+
const logger$8 = createLogger("useScenarioConfiguration");
|
|
17030
16973
|
const useScenarioConfiguration = ({
|
|
17031
16974
|
getConfigurationData,
|
|
17032
16975
|
getPayoutAccountFormatData,
|
|
@@ -17048,12 +16991,12 @@ const useScenarioConfiguration = ({
|
|
|
17048
16991
|
const configurationResponse2 = await getConfigurationData();
|
|
17049
16992
|
setConfigurationResponse(configurationResponse2);
|
|
17050
16993
|
} catch (err) {
|
|
17051
|
-
logger$
|
|
16994
|
+
logger$8.warn("WARNING: Configuration request failed - error:", err);
|
|
17052
16995
|
} finally {
|
|
17053
16996
|
setLoadingStatus("success");
|
|
17054
16997
|
}
|
|
17055
16998
|
};
|
|
17056
|
-
makeConfigCallAndSave().catch(logger$
|
|
16999
|
+
makeConfigCallAndSave().catch(logger$8.error);
|
|
17057
17000
|
}, [getConfigurationData, setLoadingStatus]);
|
|
17058
17001
|
useEffect(() => {
|
|
17059
17002
|
setLoadingStatus("loading");
|
|
@@ -17069,12 +17012,12 @@ const useScenarioConfiguration = ({
|
|
|
17069
17012
|
const defaultAccountFormat = defaultPayoutAccountFormat[country2] ?? allowedBankAccountFormats[0];
|
|
17070
17013
|
setAccountFormat(defaultAccountFormat);
|
|
17071
17014
|
} catch (err) {
|
|
17072
|
-
logger$
|
|
17015
|
+
logger$8.warn("WARNING: Payout format request failed - error:", err);
|
|
17073
17016
|
} finally {
|
|
17074
17017
|
setLoadingStatus("success");
|
|
17075
17018
|
}
|
|
17076
17019
|
};
|
|
17077
|
-
makePayoutFormatCallAndSave().catch(logger$
|
|
17020
|
+
makePayoutFormatCallAndSave().catch(logger$8.error);
|
|
17078
17021
|
}, [country2, setAccountFormat, getPayoutAccountFormatData, setLoadingStatus]);
|
|
17079
17022
|
const {
|
|
17080
17023
|
fieldConfigurations,
|
|
@@ -17703,7 +17646,7 @@ var ToastType = /* @__PURE__ */ ((ToastType2) => {
|
|
|
17703
17646
|
return ToastType2;
|
|
17704
17647
|
})(ToastType || {});
|
|
17705
17648
|
const FormComposer = "";
|
|
17706
|
-
const logger$
|
|
17649
|
+
const logger$7 = createLogger("FormRouterContextProvider");
|
|
17707
17650
|
function FormRouterContextProvider({
|
|
17708
17651
|
children,
|
|
17709
17652
|
forms,
|
|
@@ -17723,7 +17666,7 @@ function FormRouterContextProvider({
|
|
|
17723
17666
|
if (formIndex > -1) {
|
|
17724
17667
|
setFormIndex(formIndex);
|
|
17725
17668
|
} else {
|
|
17726
|
-
logger$
|
|
17669
|
+
logger$7.error("No form was found to have that field so form navigation failed.");
|
|
17727
17670
|
}
|
|
17728
17671
|
}
|
|
17729
17672
|
}), [forms, handleGetIdVerificationToken, setFormIndex]);
|
|
@@ -18318,7 +18261,7 @@ function CompanyDropinComponent({
|
|
|
18318
18261
|
})
|
|
18319
18262
|
});
|
|
18320
18263
|
}
|
|
18321
|
-
const logger$
|
|
18264
|
+
const logger$6 = createLogger("useExemptSettlor");
|
|
18322
18265
|
const useExemptSettlor = ({
|
|
18323
18266
|
trust,
|
|
18324
18267
|
handleGetLegalEntity
|
|
@@ -18330,7 +18273,7 @@ const useExemptSettlor = ({
|
|
|
18330
18273
|
setExemptSettlor(exemptSettlorLE);
|
|
18331
18274
|
}, [handleGetLegalEntity]);
|
|
18332
18275
|
useEffect(() => {
|
|
18333
|
-
updateExemptSettlor(trust).catch(logger$
|
|
18276
|
+
updateExemptSettlor(trust).catch(logger$6.error);
|
|
18334
18277
|
}, [trust, updateExemptSettlor]);
|
|
18335
18278
|
return exemptSettlor;
|
|
18336
18279
|
};
|
|
@@ -20301,11 +20244,12 @@ function IndividualDropinComponent({
|
|
|
20301
20244
|
const formattedDocuments = await mapIndividualDocumentToApiDocument(dataSubmitted, legalEntity.id);
|
|
20302
20245
|
const uploadedDocuments = await documentUtils.uploadDocuments(formattedDocuments, legalEntity.id);
|
|
20303
20246
|
uploadedDocuments == null ? void 0 : uploadedDocuments.forEach((doc) => {
|
|
20247
|
+
var _a2;
|
|
20304
20248
|
userEvents.addEvent("Saved document", {
|
|
20305
20249
|
segmentation: {
|
|
20306
20250
|
...baseTrackingPayload,
|
|
20307
20251
|
documentType: doc.type,
|
|
20308
|
-
fileExtention: doc.attachments.map((item) => getFileExtention(item.pageName))
|
|
20252
|
+
fileExtention: (_a2 = doc == null ? void 0 : doc.attachments) == null ? void 0 : _a2.map((item) => getFileExtention(item.pageName))
|
|
20309
20253
|
}
|
|
20310
20254
|
});
|
|
20311
20255
|
});
|
|
@@ -21265,8 +21209,8 @@ function ContentElements({
|
|
|
21265
21209
|
}
|
|
21266
21210
|
};
|
|
21267
21211
|
const elements = contentElements.map((contentElement) => {
|
|
21268
|
-
const
|
|
21269
|
-
return jsx(
|
|
21212
|
+
const Component = components[contentElement.type];
|
|
21213
|
+
return jsx(Component, {
|
|
21270
21214
|
...getProps(contentElement)
|
|
21271
21215
|
}, getKey(contentElement.type));
|
|
21272
21216
|
});
|
|
@@ -21980,7 +21924,7 @@ const serviceAgreementValidationRules = {
|
|
|
21980
21924
|
errorMessage: "fieldIsRequired"
|
|
21981
21925
|
}
|
|
21982
21926
|
};
|
|
21983
|
-
const logger$
|
|
21927
|
+
const logger$5 = createLogger("useServiceAgreement");
|
|
21984
21928
|
const FALLBACK_LANGUAGE_CODE = "en";
|
|
21985
21929
|
const useServiceAgreement = ({
|
|
21986
21930
|
handleGetServiceAgreement,
|
|
@@ -22009,7 +21953,7 @@ const useServiceAgreement = ({
|
|
|
22009
21953
|
language: agreementLanguage
|
|
22010
21954
|
});
|
|
22011
21955
|
if (!document2) {
|
|
22012
|
-
logger$
|
|
21956
|
+
logger$5.log('"document" field was missing in response');
|
|
22013
21957
|
return;
|
|
22014
21958
|
}
|
|
22015
21959
|
const contract = JSON.parse(decodeURIComponent(escape(window.atob(document2))));
|
|
@@ -22027,7 +21971,7 @@ const useServiceAgreement = ({
|
|
|
22027
21971
|
throw err;
|
|
22028
21972
|
}
|
|
22029
21973
|
};
|
|
22030
|
-
requestServiceAgreement().catch(logger$
|
|
21974
|
+
requestServiceAgreement().catch(logger$5.error);
|
|
22031
21975
|
}, [handleGetServiceAgreement, handleServiceAgreementIsNotAvailableInThatLanguage, agreementLanguage, legalEntityId, serviceAgreementType]);
|
|
22032
21976
|
return {
|
|
22033
21977
|
loading: loading2,
|
|
@@ -22461,6 +22405,80 @@ const labels = (data, country2) => ({
|
|
|
22461
22405
|
}
|
|
22462
22406
|
}
|
|
22463
22407
|
});
|
|
22408
|
+
const getFontFaceRule = (fontFamily, fontStyle, fontWeight, fontSrc, additionalFormats) => {
|
|
22409
|
+
const ruleLines = [`font-family: '${fontFamily}'`, `font-style: ${fontStyle}`, `font-weight: ${fontWeight}`, `src: url(${fontSrc})`];
|
|
22410
|
+
const additionalSources = [];
|
|
22411
|
+
if (additionalFormats.eot) {
|
|
22412
|
+
additionalSources.push(`url(${additionalFormats.eot}) format('embedded-opentype')`);
|
|
22413
|
+
}
|
|
22414
|
+
if (additionalFormats.woff) {
|
|
22415
|
+
additionalSources.push(`url(${additionalFormats.woff}) format('woff')`);
|
|
22416
|
+
}
|
|
22417
|
+
if (additionalFormats.woff2) {
|
|
22418
|
+
additionalSources.push(`url(${additionalFormats.woff2}) format('woff2')`);
|
|
22419
|
+
}
|
|
22420
|
+
if (additionalFormats.ttf) {
|
|
22421
|
+
additionalSources.push(`url(${additionalFormats.ttf}) format('truetype')`);
|
|
22422
|
+
}
|
|
22423
|
+
if (additionalFormats.otf) {
|
|
22424
|
+
additionalSources.push(`url(${additionalFormats.otf}) format('opentype')`);
|
|
22425
|
+
}
|
|
22426
|
+
if (additionalSources.length > 0) {
|
|
22427
|
+
ruleLines.push(`src: ${additionalSources.join(",")};`);
|
|
22428
|
+
}
|
|
22429
|
+
return `@font-face {${ruleLines.join(";")}}`;
|
|
22430
|
+
};
|
|
22431
|
+
const loadFont = (fontFamily, fontStyle, fontWeight, fontSrc, additionalFormats) => {
|
|
22432
|
+
const style = document.createElement("style");
|
|
22433
|
+
style.setAttribute("type", "text/css");
|
|
22434
|
+
style.innerText = getFontFaceRule(fontFamily, fontStyle, fontWeight, fontSrc, additionalFormats);
|
|
22435
|
+
document.body.insertBefore(style, document.body.firstChild);
|
|
22436
|
+
};
|
|
22437
|
+
const loadADLIconFont = (loadingContext) => {
|
|
22438
|
+
const fontPath = `${loadingContext}static/fonts`;
|
|
22439
|
+
const iconFontPath = `${fontPath}/adyen-kyc-icons`;
|
|
22440
|
+
loadFont("adyen-kyc-icons", "normal", "normal", `${iconFontPath}.eot`, {
|
|
22441
|
+
eot: `${iconFontPath}.eot`,
|
|
22442
|
+
woff: `${iconFontPath}.woff`,
|
|
22443
|
+
woff2: `${iconFontPath}.woff2`,
|
|
22444
|
+
ttf: `${iconFontPath}.ttf`,
|
|
22445
|
+
otf: `${iconFontPath}.otf`
|
|
22446
|
+
});
|
|
22447
|
+
};
|
|
22448
|
+
let isFlagsLoaded = false;
|
|
22449
|
+
let isDocumentGuidanceLoaded = false;
|
|
22450
|
+
const getIconContainer = () => {
|
|
22451
|
+
const container = document.createElement("div");
|
|
22452
|
+
container.setAttribute("aria-hidden", "true");
|
|
22453
|
+
container.setAttribute("id", "adl-icon-container");
|
|
22454
|
+
container.style.height = "0";
|
|
22455
|
+
return container;
|
|
22456
|
+
};
|
|
22457
|
+
const buildSpriteDOMFromResponse = (responseData) => {
|
|
22458
|
+
const iconContainer = getIconContainer();
|
|
22459
|
+
iconContainer.innerHTML = responseData;
|
|
22460
|
+
return iconContainer;
|
|
22461
|
+
};
|
|
22462
|
+
const loadFlags = async (loadingContext) => {
|
|
22463
|
+
if (isFlagsLoaded)
|
|
22464
|
+
return;
|
|
22465
|
+
isFlagsLoaded = true;
|
|
22466
|
+
const responseData = await http({
|
|
22467
|
+
loadingContext,
|
|
22468
|
+
path: "static/images/country-flags.svg"
|
|
22469
|
+
}, null, "text");
|
|
22470
|
+
document.body.insertBefore(buildSpriteDOMFromResponse(responseData), document.body.firstChild);
|
|
22471
|
+
};
|
|
22472
|
+
const loadDocumentGuidance = async (loadingContext) => {
|
|
22473
|
+
if (isDocumentGuidanceLoaded)
|
|
22474
|
+
return;
|
|
22475
|
+
isDocumentGuidanceLoaded = true;
|
|
22476
|
+
const responseData = await http({
|
|
22477
|
+
loadingContext,
|
|
22478
|
+
path: "static/images/document-guidance.svg"
|
|
22479
|
+
}, null, "text");
|
|
22480
|
+
document.body.insertBefore(buildSpriteDOMFromResponse(responseData), document.body.firstChild);
|
|
22481
|
+
};
|
|
22464
22482
|
const getOpeningStep = (forms, remediationActions) => {
|
|
22465
22483
|
var _a;
|
|
22466
22484
|
if (remediationActions && Object.keys(remediationActions).length > 0) {
|
|
@@ -22492,11 +22510,13 @@ function withFormComposer(WrappedComponent, {
|
|
|
22492
22510
|
var _a, _b, _c;
|
|
22493
22511
|
const {
|
|
22494
22512
|
i18n,
|
|
22495
|
-
loadingContext,
|
|
22496
22513
|
contextCountry: initialContextCountry,
|
|
22497
22514
|
setContextCountry: setInitialContextCountry,
|
|
22498
22515
|
isReview
|
|
22499
22516
|
} = useCoreContext();
|
|
22517
|
+
const {
|
|
22518
|
+
loadingContext
|
|
22519
|
+
} = useAuthContext();
|
|
22500
22520
|
const {
|
|
22501
22521
|
getConfiguration: getConfiguration2,
|
|
22502
22522
|
getPayoutAccountFormat: getPayoutAccountFormat2
|
|
@@ -23270,7 +23290,7 @@ function TrustDropinComponent(props) {
|
|
|
23270
23290
|
}
|
|
23271
23291
|
const PAGES_WITH_STATUS = [TaskTypes.DECISION_MAKER_OVERVIEW, TaskTypes.TASKS_OVERVIEW];
|
|
23272
23292
|
const POLLING_INTERVAL = 3e3;
|
|
23273
|
-
const logger$
|
|
23293
|
+
const logger$4 = createLogger("DropinComposerComponent");
|
|
23274
23294
|
function DropinComposerComponent({
|
|
23275
23295
|
capabilities,
|
|
23276
23296
|
legalEntityResponse,
|
|
@@ -23338,7 +23358,7 @@ function DropinComposerComponent({
|
|
|
23338
23358
|
setPciStatus(response);
|
|
23339
23359
|
return response;
|
|
23340
23360
|
} catch (e) {
|
|
23341
|
-
logger$
|
|
23361
|
+
logger$4.warn(i18n.get("failedToGetPciStatus"));
|
|
23342
23362
|
}
|
|
23343
23363
|
}
|
|
23344
23364
|
return void 0;
|
|
@@ -23369,7 +23389,7 @@ function DropinComposerComponent({
|
|
|
23369
23389
|
const response = await args.handleGetServiceAgreementAcceptanceInfos(legalEntity.id);
|
|
23370
23390
|
setServiceAgreementAcceptanceInfos(response.data);
|
|
23371
23391
|
} catch (e) {
|
|
23372
|
-
logger$
|
|
23392
|
+
logger$4.warn(i18n.get("failedToGetServiceAgreementStatus"));
|
|
23373
23393
|
}
|
|
23374
23394
|
}
|
|
23375
23395
|
};
|
|
@@ -23379,7 +23399,7 @@ function DropinComposerComponent({
|
|
|
23379
23399
|
const response = await args.handleGetServiceAgreementStatus(legalEntity.id);
|
|
23380
23400
|
setServiceAgreementTypes(response.termsOfServiceTypes);
|
|
23381
23401
|
} catch (e) {
|
|
23382
|
-
logger$
|
|
23402
|
+
logger$4.warn(i18n.get("failedToGetServiceAgreementStatus"));
|
|
23383
23403
|
}
|
|
23384
23404
|
}
|
|
23385
23405
|
};
|
|
@@ -23418,7 +23438,7 @@ function DropinComposerComponent({
|
|
|
23418
23438
|
setCapabilityProblems(getCapabilityProblems(response));
|
|
23419
23439
|
return response;
|
|
23420
23440
|
} catch (e) {
|
|
23421
|
-
logger$
|
|
23441
|
+
logger$4.warn(i18n.get("failedToFetchLegalEntityDetails"));
|
|
23422
23442
|
}
|
|
23423
23443
|
}
|
|
23424
23444
|
return void 0;
|
|
@@ -23430,7 +23450,7 @@ function DropinComposerComponent({
|
|
|
23430
23450
|
setTrust(response);
|
|
23431
23451
|
return response;
|
|
23432
23452
|
} catch (e) {
|
|
23433
|
-
logger$
|
|
23453
|
+
logger$4.warn(i18n.get("failedToFetchTrustDetails"));
|
|
23434
23454
|
}
|
|
23435
23455
|
}
|
|
23436
23456
|
return void 0;
|
|
@@ -23480,7 +23500,7 @@ function DropinComposerComponent({
|
|
|
23480
23500
|
label: i18n.get("successFullyRemovedTrustMember")
|
|
23481
23501
|
});
|
|
23482
23502
|
} catch (err) {
|
|
23483
|
-
logger$
|
|
23503
|
+
logger$4.error(`Failed to delete trust member`, err);
|
|
23484
23504
|
showToast({
|
|
23485
23505
|
type: ToastType.ERROR,
|
|
23486
23506
|
label: i18n.get("failedToRemoveTrustMember")
|
|
@@ -23532,7 +23552,7 @@ function DropinComposerComponent({
|
|
|
23532
23552
|
break;
|
|
23533
23553
|
case "rootTrustee":
|
|
23534
23554
|
default:
|
|
23535
|
-
logger$
|
|
23555
|
+
logger$4.warn(`Updating trust member type "${trustMember.trustMemberType}" is not implemented.`);
|
|
23536
23556
|
}
|
|
23537
23557
|
showToast({
|
|
23538
23558
|
label: i18n.get("successfullyUpdatedDetails"),
|
|
@@ -23540,7 +23560,7 @@ function DropinComposerComponent({
|
|
|
23540
23560
|
});
|
|
23541
23561
|
await refreshTrustAndRunOnSubmit(trust, 1);
|
|
23542
23562
|
} catch (err) {
|
|
23543
|
-
logger$
|
|
23563
|
+
logger$4.error(err);
|
|
23544
23564
|
showToast({
|
|
23545
23565
|
label: i18n.get("failedToUpdateDetails"),
|
|
23546
23566
|
type: ToastType.ERROR
|
|
@@ -23763,7 +23783,7 @@ function DropinComposerComponent({
|
|
|
23763
23783
|
}
|
|
23764
23784
|
};
|
|
23765
23785
|
setIsLoadingConfiguration(true);
|
|
23766
|
-
fetchConfiguration().catch(logger$
|
|
23786
|
+
fetchConfiguration().catch(logger$4.error).finally(() => {
|
|
23767
23787
|
setIsLoadingConfiguration(false);
|
|
23768
23788
|
onLoad();
|
|
23769
23789
|
});
|
|
@@ -24330,6 +24350,38 @@ const updateTransferInstrument = async (context, transferInstrument, transferIns
|
|
|
24330
24350
|
}, transferInstrument);
|
|
24331
24351
|
};
|
|
24332
24352
|
const COMPONENTS_API_VERSION = "v1";
|
|
24353
|
+
const useComponentApi = (rootLegalEntityId) => {
|
|
24354
|
+
const authContext = useAuthContext();
|
|
24355
|
+
if (!authContext.isEmbeddedDropin) {
|
|
24356
|
+
throw new Error("Cannot use component API outside an embedded dropin");
|
|
24357
|
+
}
|
|
24358
|
+
const {
|
|
24359
|
+
sdkToken,
|
|
24360
|
+
loadingContext: base
|
|
24361
|
+
} = authContext;
|
|
24362
|
+
return useMemo(() => {
|
|
24363
|
+
const loadingContext = `${base}api/${COMPONENTS_API_VERSION}/`;
|
|
24364
|
+
const loadingContextWithRootLEAuth = `${loadingContext}legalEntities/`;
|
|
24365
|
+
const baseRequestContext = {
|
|
24366
|
+
loadingContext: loadingContextWithRootLEAuth,
|
|
24367
|
+
legalEntityId: rootLegalEntityId,
|
|
24368
|
+
sdkToken
|
|
24369
|
+
};
|
|
24370
|
+
return {
|
|
24371
|
+
getLegalEntity: async (legalEntityId) => getLegalEntity({
|
|
24372
|
+
...baseRequestContext,
|
|
24373
|
+
legalEntityId
|
|
24374
|
+
}),
|
|
24375
|
+
getTransferInstrument: async (transferInstrumentId) => getTransferInstrument(baseRequestContext, transferInstrumentId),
|
|
24376
|
+
getBankVerificationVendor: async (country2) => getBankVerificationVendor(baseRequestContext, country2),
|
|
24377
|
+
getDocument: async (documentId) => getDocument(baseRequestContext, documentId),
|
|
24378
|
+
createDocument: async (document2, ownerId) => createDocument(baseRequestContext, document2, ownerId),
|
|
24379
|
+
updateDocument: async (document2, documentId, ownerId) => updateDocument(baseRequestContext, document2, documentId, ownerId),
|
|
24380
|
+
createTransferInstrument: async (transferInstrument) => createTransferInstrument(baseRequestContext, transferInstrument),
|
|
24381
|
+
updateTransferInstrument: async (transferInstrument, transferInstrumentId) => updateTransferInstrument(baseRequestContext, transferInstrument, transferInstrumentId)
|
|
24382
|
+
};
|
|
24383
|
+
}, [base, rootLegalEntityId, sdkToken]);
|
|
24384
|
+
};
|
|
24333
24385
|
const getEmbeddedApi = ({
|
|
24334
24386
|
base,
|
|
24335
24387
|
sdkToken,
|
|
@@ -24362,6 +24414,7 @@ const getEmbeddedApi = ({
|
|
|
24362
24414
|
}, datasetIdentifier2, locale),
|
|
24363
24415
|
loadFlags: async () => loadFlags(base),
|
|
24364
24416
|
loadDocumentGuidance: async () => loadDocumentGuidance(base),
|
|
24417
|
+
getImageUrl: () => `${base}static/images/`,
|
|
24365
24418
|
getAllowedCountries: () => {
|
|
24366
24419
|
throw new Error("getAllowedCountries: Not implemented in onboarding component api");
|
|
24367
24420
|
},
|
|
@@ -24467,7 +24520,7 @@ const validatePhoneNumber = async (context, phoneNumber2) => {
|
|
|
24467
24520
|
number: phoneNumber2
|
|
24468
24521
|
});
|
|
24469
24522
|
};
|
|
24470
|
-
const logger$
|
|
24523
|
+
const logger$3 = createLogger("verify-id-number");
|
|
24471
24524
|
const verifyIdNumber = async (context, request) => {
|
|
24472
24525
|
const {
|
|
24473
24526
|
loadingContext,
|
|
@@ -24494,13 +24547,13 @@ const verifyIdNumber = async (context, request) => {
|
|
|
24494
24547
|
message: "Service did not respond, do not block verification"
|
|
24495
24548
|
};
|
|
24496
24549
|
}
|
|
24497
|
-
return logger$
|
|
24550
|
+
return logger$3.warn(`Unexpected response status ${responseData.status}`);
|
|
24498
24551
|
},
|
|
24499
24552
|
path: "v1/verification/idNumber",
|
|
24500
24553
|
clientKey
|
|
24501
24554
|
}, request);
|
|
24502
24555
|
} catch (e) {
|
|
24503
|
-
logger$
|
|
24556
|
+
logger$3.warn("WARNING: idNumber verification failed - error:", e);
|
|
24504
24557
|
}
|
|
24505
24558
|
};
|
|
24506
24559
|
const getKycExternalApi = ({
|
|
@@ -24536,57 +24589,27 @@ const getKycExternalApi = ({
|
|
|
24536
24589
|
validatePhoneNumber: async (phoneNumber2) => validatePhoneNumber({
|
|
24537
24590
|
loadingContext,
|
|
24538
24591
|
clientKey
|
|
24539
|
-
}, phoneNumber2)
|
|
24592
|
+
}, phoneNumber2),
|
|
24593
|
+
getImageUrl: () => `${loadingContext}static/images/`
|
|
24540
24594
|
});
|
|
24541
24595
|
const ConfigurationApiProvider = ({
|
|
24542
24596
|
children,
|
|
24543
24597
|
rootLegalEntityId
|
|
24544
24598
|
}) => {
|
|
24545
|
-
const
|
|
24546
|
-
const contextValue = useMemo(() =>
|
|
24547
|
-
base:
|
|
24548
|
-
sdkToken:
|
|
24599
|
+
const authContext = useAuthContext();
|
|
24600
|
+
const contextValue = useMemo(() => authContext.isEmbeddedDropin && rootLegalEntityId ? getEmbeddedApi({
|
|
24601
|
+
base: authContext.loadingContext,
|
|
24602
|
+
sdkToken: authContext.sdkToken,
|
|
24549
24603
|
rootLegalEntityId
|
|
24550
24604
|
}) : getKycExternalApi({
|
|
24551
|
-
loadingContext:
|
|
24552
|
-
clientKey:
|
|
24553
|
-
}), [
|
|
24605
|
+
loadingContext: authContext.loadingContext,
|
|
24606
|
+
clientKey: authContext.clientKey
|
|
24607
|
+
}), [authContext, rootLegalEntityId]);
|
|
24554
24608
|
return jsx(ConfigurationApiContext.Provider, {
|
|
24555
24609
|
value: contextValue,
|
|
24556
24610
|
children
|
|
24557
24611
|
});
|
|
24558
24612
|
};
|
|
24559
|
-
const useComponentApi = (rootLegalEntityId) => {
|
|
24560
|
-
const coreContext = useCoreContext();
|
|
24561
|
-
if (!coreContext.isEmbeddedDropin) {
|
|
24562
|
-
throw new Error("Cannot use component API outside an embedded dropin");
|
|
24563
|
-
}
|
|
24564
|
-
const {
|
|
24565
|
-
loadingContext: base,
|
|
24566
|
-
sdkToken = ""
|
|
24567
|
-
} = coreContext;
|
|
24568
|
-
const apiVersion = "v1";
|
|
24569
|
-
const loadingContext = `${base}api/${apiVersion}/`;
|
|
24570
|
-
const loadingContextWithRootLEAuth = `${loadingContext}legalEntities/`;
|
|
24571
|
-
const baseRequestContext = {
|
|
24572
|
-
loadingContext: loadingContextWithRootLEAuth,
|
|
24573
|
-
legalEntityId: rootLegalEntityId,
|
|
24574
|
-
sdkToken
|
|
24575
|
-
};
|
|
24576
|
-
return {
|
|
24577
|
-
getLegalEntity: async (legalEntityId) => getLegalEntity({
|
|
24578
|
-
...baseRequestContext,
|
|
24579
|
-
legalEntityId
|
|
24580
|
-
}),
|
|
24581
|
-
getTransferInstrument: async (transferInstrumentId) => getTransferInstrument(baseRequestContext, transferInstrumentId),
|
|
24582
|
-
getBankVerificationVendor: async (country2) => getBankVerificationVendor(baseRequestContext, country2),
|
|
24583
|
-
getDocument: async (documentId) => getDocument(baseRequestContext, documentId),
|
|
24584
|
-
createDocument: async (document2, ownerId) => createDocument(baseRequestContext, document2, ownerId),
|
|
24585
|
-
updateDocument: async (document2, documentId, ownerId) => updateDocument(baseRequestContext, document2, documentId, ownerId),
|
|
24586
|
-
createTransferInstrument: async (transferInstrument) => createTransferInstrument(baseRequestContext, transferInstrument),
|
|
24587
|
-
updateTransferInstrument: async (transferInstrument, transferInstrumentId) => updateTransferInstrument(baseRequestContext, transferInstrument, transferInstrumentId)
|
|
24588
|
-
};
|
|
24589
|
-
};
|
|
24590
24613
|
class EventEmitter {
|
|
24591
24614
|
constructor() {
|
|
24592
24615
|
this.listeners = {
|
|
@@ -24668,6 +24691,102 @@ const componentsMap = {
|
|
|
24668
24691
|
pci: PciDropinComponent,
|
|
24669
24692
|
payoutEmbeddedDropin: PayoutEmbeddedDropin
|
|
24670
24693
|
};
|
|
24694
|
+
const refreshSdkToken = async (context, refreshToken) => {
|
|
24695
|
+
const {
|
|
24696
|
+
loadingContext,
|
|
24697
|
+
sdkToken
|
|
24698
|
+
} = context;
|
|
24699
|
+
return httpPost({
|
|
24700
|
+
loadingContext,
|
|
24701
|
+
errorLevel: "warn",
|
|
24702
|
+
errorMessage: `Failed to refresh token`,
|
|
24703
|
+
path: `sessions/refresh`,
|
|
24704
|
+
sdkToken,
|
|
24705
|
+
headers: {
|
|
24706
|
+
"Content-Type": "application/json"
|
|
24707
|
+
}
|
|
24708
|
+
}, {
|
|
24709
|
+
refreshToken
|
|
24710
|
+
});
|
|
24711
|
+
};
|
|
24712
|
+
const SDK_TOKEN_TTL = 6e4;
|
|
24713
|
+
const REFRESH_INTERVAL = SDK_TOKEN_TTL - 5e3;
|
|
24714
|
+
const RETRY_LIMIT = 2;
|
|
24715
|
+
const logger$2 = createLogger("useSdkToken");
|
|
24716
|
+
const useSdkToken = ({
|
|
24717
|
+
initialSdkToken,
|
|
24718
|
+
refreshToken,
|
|
24719
|
+
autheBase
|
|
24720
|
+
}) => {
|
|
24721
|
+
const [sdkToken, setSdkToken] = useState(initialSdkToken);
|
|
24722
|
+
const doRefresh = async (sdkToken2, refreshToken2, retries) => {
|
|
24723
|
+
try {
|
|
24724
|
+
const {
|
|
24725
|
+
token: newSdkToken
|
|
24726
|
+
} = await refreshSdkToken({
|
|
24727
|
+
loadingContext: autheBase,
|
|
24728
|
+
sdkToken: sdkToken2
|
|
24729
|
+
}, refreshToken2);
|
|
24730
|
+
setSdkToken(newSdkToken);
|
|
24731
|
+
} catch (e) {
|
|
24732
|
+
if (!retries) {
|
|
24733
|
+
throw new Error("Unable to refresh token after retries", e);
|
|
24734
|
+
}
|
|
24735
|
+
logger$2.warn("Failed to refresh token. Retrying..", e);
|
|
24736
|
+
await doRefresh(sdkToken2, refreshToken2, retries - 1);
|
|
24737
|
+
}
|
|
24738
|
+
};
|
|
24739
|
+
useEffect(() => {
|
|
24740
|
+
if (!sdkToken || !refreshToken) {
|
|
24741
|
+
return;
|
|
24742
|
+
}
|
|
24743
|
+
const refreshHandler = setInterval(() => {
|
|
24744
|
+
doRefresh(sdkToken, refreshToken, RETRY_LIMIT).catch(() => {
|
|
24745
|
+
clearInterval(refreshHandler);
|
|
24746
|
+
});
|
|
24747
|
+
}, REFRESH_INTERVAL);
|
|
24748
|
+
return () => {
|
|
24749
|
+
clearInterval(refreshHandler);
|
|
24750
|
+
};
|
|
24751
|
+
}, [sdkToken]);
|
|
24752
|
+
return sdkToken;
|
|
24753
|
+
};
|
|
24754
|
+
const AUTHE_API_VERSION = "v1";
|
|
24755
|
+
const AuthProvider = ({
|
|
24756
|
+
children,
|
|
24757
|
+
sdkToken: initialSdkToken,
|
|
24758
|
+
refreshToken,
|
|
24759
|
+
clientKey,
|
|
24760
|
+
loadingContext
|
|
24761
|
+
}) => {
|
|
24762
|
+
const autheBase = `${loadingContext}authe/api/${AUTHE_API_VERSION}/`;
|
|
24763
|
+
const sdkToken = useSdkToken({
|
|
24764
|
+
initialSdkToken,
|
|
24765
|
+
refreshToken,
|
|
24766
|
+
autheBase
|
|
24767
|
+
});
|
|
24768
|
+
const contextValue = useMemo(() => {
|
|
24769
|
+
if (sdkToken && refreshToken) {
|
|
24770
|
+
return {
|
|
24771
|
+
isEmbeddedDropin: true,
|
|
24772
|
+
sdkToken,
|
|
24773
|
+
loadingContext: `${loadingContext}onboardingcomponents/`
|
|
24774
|
+
};
|
|
24775
|
+
}
|
|
24776
|
+
if (clientKey) {
|
|
24777
|
+
return {
|
|
24778
|
+
isEmbeddedDropin: false,
|
|
24779
|
+
clientKey,
|
|
24780
|
+
loadingContext
|
|
24781
|
+
};
|
|
24782
|
+
}
|
|
24783
|
+
throw new Error("Must provide either `sdkToken` and `refreshToken` or `clientKey`");
|
|
24784
|
+
}, [sdkToken, clientKey]);
|
|
24785
|
+
return jsx(AuthContext.Provider, {
|
|
24786
|
+
value: contextValue,
|
|
24787
|
+
children
|
|
24788
|
+
});
|
|
24789
|
+
};
|
|
24671
24790
|
const close = "Close";
|
|
24672
24791
|
const individual = "Individual";
|
|
24673
24792
|
const payoutAccount = "Payout account";
|
|
@@ -26886,91 +27005,23 @@ class Language {
|
|
|
26886
27005
|
}
|
|
26887
27006
|
}
|
|
26888
27007
|
const logger = createLogger("CoreProvider");
|
|
26889
|
-
|
|
26890
|
-
|
|
26891
|
-
|
|
26892
|
-
|
|
26893
|
-
|
|
26894
|
-
|
|
26895
|
-
|
|
26896
|
-
|
|
26897
|
-
|
|
26898
|
-
|
|
26899
|
-
|
|
26900
|
-
|
|
26901
|
-
|
|
26902
|
-
|
|
26903
|
-
|
|
26904
|
-
|
|
26905
|
-
|
|
26906
|
-
clientKey: this.props.clientKey
|
|
26907
|
-
}).then(() => {
|
|
26908
|
-
userEvents.addEvent("Changed page language", {
|
|
26909
|
-
segmentation: {
|
|
26910
|
-
originalLanguage,
|
|
26911
|
-
newLanguage: locale
|
|
26912
|
-
}
|
|
26913
|
-
});
|
|
26914
|
-
this.setState({
|
|
26915
|
-
loaded: true
|
|
26916
|
-
});
|
|
26917
|
-
});
|
|
26918
|
-
};
|
|
26919
|
-
this.setAccountHolder = (accountHolder2) => {
|
|
26920
|
-
this.setState({
|
|
26921
|
-
accountHolder: accountHolder2
|
|
26922
|
-
});
|
|
26923
|
-
};
|
|
26924
|
-
this.setAccountFormat = (accountFormat) => {
|
|
26925
|
-
this.setState({
|
|
26926
|
-
accountFormat
|
|
26927
|
-
});
|
|
26928
|
-
};
|
|
26929
|
-
this.getContextValue = () => {
|
|
26930
|
-
const baseContext = {
|
|
26931
|
-
i18n: this.state.i18n,
|
|
26932
|
-
setLocale: this.setLocale,
|
|
26933
|
-
loadingContext: this.props.loadingContext,
|
|
26934
|
-
translations: this.props.translations,
|
|
26935
|
-
setContextCountry: this.setContextCountry,
|
|
26936
|
-
contextCountry: this.state.contextCountry,
|
|
26937
|
-
isReview: this.props.isReview ?? false,
|
|
26938
|
-
setAccountHolder: this.setAccountHolder,
|
|
26939
|
-
accountHolder: this.state.accountHolder,
|
|
26940
|
-
setAccountFormat: this.setAccountFormat,
|
|
26941
|
-
accountFormat: this.state.accountFormat
|
|
26942
|
-
};
|
|
26943
|
-
if (this.props.sdkToken) {
|
|
26944
|
-
return {
|
|
26945
|
-
...baseContext,
|
|
26946
|
-
isEmbeddedDropin: true,
|
|
26947
|
-
sdkToken: this.props.sdkToken
|
|
26948
|
-
};
|
|
26949
|
-
}
|
|
26950
|
-
if (this.props.clientKey) {
|
|
26951
|
-
return {
|
|
26952
|
-
...baseContext,
|
|
26953
|
-
isEmbeddedDropin: false,
|
|
26954
|
-
clientKey: this.props.clientKey
|
|
26955
|
-
};
|
|
26956
|
-
}
|
|
26957
|
-
throw new Error("Must provide either `sdkToken` or `clientKey`");
|
|
26958
|
-
};
|
|
26959
|
-
this.state = {
|
|
26960
|
-
loaded: false,
|
|
26961
|
-
contextCountry: this.props.contextCountry,
|
|
26962
|
-
i18n: new Language(),
|
|
26963
|
-
accountHolder: null,
|
|
26964
|
-
accountFormat: "local"
|
|
26965
|
-
};
|
|
26966
|
-
}
|
|
26967
|
-
async componentDidMount() {
|
|
26968
|
-
const {
|
|
26969
|
-
contextCountry,
|
|
26970
|
-
locale,
|
|
26971
|
-
loadingContext,
|
|
26972
|
-
clientKey
|
|
26973
|
-
} = this.props;
|
|
27008
|
+
const CoreProvider = ({
|
|
27009
|
+
contextCountry: initialContextCountry,
|
|
27010
|
+
locale,
|
|
27011
|
+
clientKey,
|
|
27012
|
+
children,
|
|
27013
|
+
translations,
|
|
27014
|
+
isReview
|
|
27015
|
+
}) => {
|
|
27016
|
+
const {
|
|
27017
|
+
loadingContext
|
|
27018
|
+
} = useAuthContext();
|
|
27019
|
+
const [loaded, setLoaded] = useState(false);
|
|
27020
|
+
const [contextCountry, setContextCountry] = useState(initialContextCountry);
|
|
27021
|
+
const [i18n] = useState(new Language());
|
|
27022
|
+
const [accountHolder2, setAccountHolder] = useState(null);
|
|
27023
|
+
const [accountFormat, setAccountFormat] = useState("local");
|
|
27024
|
+
const init2 = async () => {
|
|
26974
27025
|
loadADLIconFont(loadingContext);
|
|
26975
27026
|
try {
|
|
26976
27027
|
let initializationLocale = locale;
|
|
@@ -27000,32 +27051,59 @@ class CoreProvider extends Component {
|
|
|
27000
27051
|
- ${listify(locales)}. falling back to "${FALLBACK_LOCALE}"`);
|
|
27001
27052
|
initializationLocale = FALLBACK_LOCALE;
|
|
27002
27053
|
}
|
|
27003
|
-
await
|
|
27054
|
+
await i18n.initialize({
|
|
27004
27055
|
locale: initializationLocale,
|
|
27005
|
-
loadingContext
|
|
27006
|
-
clientKey
|
|
27007
|
-
customTranslations:
|
|
27056
|
+
loadingContext,
|
|
27057
|
+
clientKey,
|
|
27058
|
+
customTranslations: translations,
|
|
27008
27059
|
allowedLocales: locales
|
|
27009
27060
|
});
|
|
27010
|
-
|
|
27011
|
-
loaded: true
|
|
27012
|
-
});
|
|
27061
|
+
setLoaded(true);
|
|
27013
27062
|
} catch (e) {
|
|
27014
27063
|
logger.log(e);
|
|
27015
27064
|
}
|
|
27016
|
-
}
|
|
27017
|
-
|
|
27018
|
-
|
|
27019
|
-
|
|
27020
|
-
|
|
27021
|
-
|
|
27022
|
-
|
|
27023
|
-
|
|
27024
|
-
|
|
27025
|
-
|
|
27065
|
+
};
|
|
27066
|
+
const setLocale = (locale2) => {
|
|
27067
|
+
setLoaded(false);
|
|
27068
|
+
const originalLanguage = i18n == null ? void 0 : i18n.locale;
|
|
27069
|
+
i18n.loadTranslations({
|
|
27070
|
+
locale: locale2,
|
|
27071
|
+
loadingContext,
|
|
27072
|
+
clientKey
|
|
27073
|
+
}).then(() => {
|
|
27074
|
+
userEvents.addEvent("Changed page language", {
|
|
27075
|
+
segmentation: {
|
|
27076
|
+
originalLanguage,
|
|
27077
|
+
newLanguage: locale2
|
|
27078
|
+
}
|
|
27079
|
+
});
|
|
27080
|
+
setLoaded(true);
|
|
27026
27081
|
});
|
|
27082
|
+
};
|
|
27083
|
+
useEffect(() => {
|
|
27084
|
+
init2();
|
|
27085
|
+
});
|
|
27086
|
+
const contextValue = useMemo(() => ({
|
|
27087
|
+
i18n,
|
|
27088
|
+
setLocale,
|
|
27089
|
+
loadingContext,
|
|
27090
|
+
isReview,
|
|
27091
|
+
translations,
|
|
27092
|
+
setContextCountry,
|
|
27093
|
+
contextCountry,
|
|
27094
|
+
setAccountHolder,
|
|
27095
|
+
accountHolder: accountHolder2,
|
|
27096
|
+
setAccountFormat,
|
|
27097
|
+
accountFormat
|
|
27098
|
+
}), [contextCountry, loaded, accountHolder2, accountFormat]);
|
|
27099
|
+
if (!loaded) {
|
|
27100
|
+
return null;
|
|
27027
27101
|
}
|
|
27028
|
-
|
|
27102
|
+
return jsx(CoreContext.Provider, {
|
|
27103
|
+
value: contextValue,
|
|
27104
|
+
children: children && toChildArray(children)
|
|
27105
|
+
});
|
|
27106
|
+
};
|
|
27029
27107
|
function ExperimentsContextProvider({
|
|
27030
27108
|
children,
|
|
27031
27109
|
experiments
|
|
@@ -27165,28 +27243,32 @@ class UIElement extends BaseElement {
|
|
|
27165
27243
|
constructor(props) {
|
|
27166
27244
|
super(props);
|
|
27167
27245
|
this.render = () => {
|
|
27168
|
-
const
|
|
27169
|
-
return jsx(
|
|
27170
|
-
locale: this.props.locale,
|
|
27171
|
-
loadingContext: this.props.loadingContext,
|
|
27172
|
-
translations: this.props.translations,
|
|
27173
|
-
clientKey: this.props.clientKey,
|
|
27174
|
-
contextCountry: this.props.contextCountry,
|
|
27175
|
-
isReview: this.props.isReview,
|
|
27246
|
+
const Component = this.props.component;
|
|
27247
|
+
return jsx(AuthProvider, {
|
|
27176
27248
|
sdkToken: this.props.sdkToken,
|
|
27249
|
+
refreshToken: this.props.refreshToken,
|
|
27250
|
+
clientKey: this.props.clientKey,
|
|
27251
|
+
loadingContext: this.props.loadingContext,
|
|
27177
27252
|
children: jsx(ConfigurationApiProvider, {
|
|
27178
|
-
children: jsx(
|
|
27179
|
-
|
|
27180
|
-
|
|
27181
|
-
|
|
27182
|
-
|
|
27183
|
-
|
|
27184
|
-
|
|
27185
|
-
|
|
27186
|
-
|
|
27187
|
-
|
|
27188
|
-
|
|
27189
|
-
|
|
27253
|
+
children: jsx(CoreProvider, {
|
|
27254
|
+
locale: this.props.locale,
|
|
27255
|
+
translations: this.props.translations,
|
|
27256
|
+
clientKey: this.props.clientKey,
|
|
27257
|
+
contextCountry: this.props.contextCountry,
|
|
27258
|
+
isReview: this.props.isReview,
|
|
27259
|
+
children: jsx(SettingsContextProvider, {
|
|
27260
|
+
settings: this.props.settings,
|
|
27261
|
+
children: jsx(ExperimentsContextProvider, {
|
|
27262
|
+
experiments: this.props.experiments,
|
|
27263
|
+
children: jsx("div", {
|
|
27264
|
+
className: "adyen-kyc-dropin-container adl-u-position-relative",
|
|
27265
|
+
children: jsx(AutoResizer, {
|
|
27266
|
+
children: jsx(ToastContextProvider, {
|
|
27267
|
+
children: jsx(StateProvider, {
|
|
27268
|
+
children: jsx(Component, {
|
|
27269
|
+
...this.props.componentProps,
|
|
27270
|
+
eventEmitter: this.eventEmitter
|
|
27271
|
+
})
|
|
27190
27272
|
})
|
|
27191
27273
|
})
|
|
27192
27274
|
})
|
|
@@ -27733,10 +27815,10 @@ const validateComponentName = (componentName) => {
|
|
|
27733
27815
|
const validateCoreOptions = (coreOptions) => {
|
|
27734
27816
|
const requiredOptions = ["locale", "environment", "country"];
|
|
27735
27817
|
const missing = requiredOptions.filter((option) => !coreOptions[option]);
|
|
27736
|
-
if (!coreOptions.sdkToken && !coreOptions.clientKey) {
|
|
27818
|
+
if (!(coreOptions.sdkToken && coreOptions.refreshToken) && !coreOptions.clientKey) {
|
|
27737
27819
|
throw new Error(`
|
|
27738
27820
|
|
|
27739
|
-
Please specify
|
|
27821
|
+
Please specify either sdkToken and a refreshToken or a clientKey for the SDK to initialize!
|
|
27740
27822
|
|
|
27741
27823
|
|
|
27742
27824
|
- For more information please check: https://github.com/Adyen/adyen-kyc-components#configuration.`);
|