@adyen/kyc-components 2.14.0 → 2.15.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.
Files changed (38) hide show
  1. package/dist/es/adyen-kyc-components.es.js +506 -438
  2. package/dist/types/components/DocumentUpload/types.d.ts +2 -1
  3. package/dist/types/components/IdDocumentUpload/types.d.ts +4 -3
  4. package/dist/types/components/PayoutBankStatement/types.d.ts +2 -1
  5. package/dist/types/components/PersonalDetails/component/IdentityComponent/IdentityAu/component/ProofOfIdentityCard.d.ts +1 -1
  6. package/dist/types/components/internal/Address/utils.d.ts +1 -1
  7. package/dist/types/components/internal/CountryField/CountryField.d.ts +2 -2
  8. package/dist/types/components/internal/FormFields/Dropzone/FilePicker.d.ts +3 -2
  9. package/dist/types/components/internal/FormFields/Dropzone/types.d.ts +2 -6
  10. package/dist/types/components/internal/FormFields/Dropzone/validate.d.ts +2 -1
  11. package/dist/types/components/internal/LegalCompanyNameField/LegalCompanyNameField.d.ts +2 -3
  12. package/dist/types/components/internal/Remove/Remove.d.ts +1 -1
  13. package/dist/types/components/internal/Remove/types.d.ts +6 -4
  14. package/dist/types/components/internal/StateField/StateField.d.ts +2 -2
  15. package/dist/types/core/Context/AuthContext/AuthContext.d.ts +0 -1
  16. package/dist/types/core/Context/AuthContext/AuthProvider.d.ts +5 -2
  17. package/dist/types/core/Context/ConfigurationApiContext/getEmbeddedApi.d.ts +1 -2
  18. package/dist/types/core/Context/StateContext/types.d.ts +1 -0
  19. package/dist/types/core/Services/session.d.ts +5 -0
  20. package/dist/types/core/Services/types.d.ts +1 -2
  21. package/dist/types/core/Services/utils.d.ts +1 -0
  22. package/dist/types/core/core.d.ts +1 -0
  23. package/dist/types/core/hooks/useForm/types.d.ts +23 -8
  24. package/dist/types/core/hooks/useForm/useForm.d.ts +2 -1
  25. package/dist/types/core/hooks/useForm/utils.d.ts +12 -1
  26. package/dist/types/core/models/file.d.ts +8 -0
  27. package/dist/types/core/types.d.ts +2 -1
  28. package/dist/types/language/config.d.ts +16 -14
  29. package/dist/types/utils/api/documentUtils.d.ts +3 -2
  30. package/dist/types/utils/company-util.d.ts +2 -1
  31. package/dist/types/utils/decision-maker-roles.d.ts +1 -1
  32. package/dist/types/utils/entity-status-util.d.ts +2 -2
  33. package/dist/types/utils/formUtils.d.ts +11 -3
  34. package/dist/types/utils/mapping/mapping.d.ts +2 -0
  35. package/dist/types/utils/trust-util.d.ts +1 -1
  36. package/package.json +1 -1
  37. package/dist/types/core/Services/auth/refresh-sdkToken.d.ts +0 -6
  38. package/dist/types/core/hooks/useSdkToken.d.ts +0 -5
@@ -62,6 +62,7 @@ const uploadDocument = "Upload Document";
62
62
  const individualDetails = "Individual details";
63
63
  const socialSecurityNumber = "Last 4 digits of Social Security Number (SSN)";
64
64
  const socialSecurityNumber9Digits = "Social Security Number (SSN)";
65
+ const socialInsuranceNumber = "Social Insurance Number (SIN)";
65
66
  const codiceFiscale = "Codice fiscale";
66
67
  const personnummer = "Personnummer";
67
68
  const dni = "DNI";
@@ -121,6 +122,8 @@ const nationality$1 = "Nationality";
121
122
  const dateOfIncorporation = "Date of incorporation";
122
123
  const passportExpiryDate = "Passport expiry date";
123
124
  const proofOfNationality = "Proof of nationality";
125
+ const identityNumberExempt__US = "I don't have an SSN";
126
+ const identityNumberExempt__CA = "I don't have an SIN";
124
127
  const uploadDocumentForSsn = "Upload an ID document instead of SSN";
125
128
  const uploadDocumentForNric = "Upload an ID document instead of NRIC";
126
129
  const operationalAddressHeader = "Additional address";
@@ -224,13 +227,6 @@ const pleaseNote = "Please note:";
224
227
  const byClickingSubmitReview = "By clicking 'Submit review', you confirm that all of your information has been reviewed, and that all newly provided or already existing data is accurate and up-to-date.";
225
228
  const nameAndCountry = "Name and country";
226
229
  const companyCountry = "Where is your business located?";
227
- const legalCompanyName = "Legal name of the company";
228
- const legalCompanyNameHelper = "Enter the name exactly as it is on your company's official registration documents.";
229
- const legalCompanyNameHelper__AU = "Enter the name exactly as it is on your Australian Securities and Investment Commission's (ASIC)";
230
- const legalCompanyNameHelper__NL = "Enter the name exactly as it is on your Chamber of Commerce registration.";
231
- const legalCompanyNameHelper__US = "Enter the name exactly as it is on on your Secretary of State registration.";
232
- const legalCompanyNameHelper__SG = "Enter the name exactly as it is on your Accounting and Corporate Regulatory Authority (ACRA) BizFile";
233
- const legalCompanyNameHelper__HK = "Enter the name exactly as it is on your Hong Kong Companies Registry's Certificate of Incorporation";
234
230
  const accountDetailsDescription = "Provide a few details about you to start accepting live payments.";
235
231
  const provideDetails = "Provide details";
236
232
  const payoutAccountsDescription = "To set up your account, let us know where to send your payouts.";
@@ -676,12 +672,12 @@ const documentIssuedWithinLastYear = "Note! The document needs to be issued with
676
672
  const learnMore = "Learn more";
677
673
  const doingBusinessAsNameFiling = "Doing business as-name filling";
678
674
  const taxFiling = "Tax-filling";
679
- const continueAsCompany = "Continue as a company?";
680
- const continueAsIndividual = "Continue as an individual?";
681
- const indicatedPayoutToCompany = "You indicated that you want to be paid out to a bank account that is owned by a company, such as a private company, public company, partnership, or non-profit organization. This means that we need to collect some information about your company too.";
682
- const continueSigningUpAsCompany = "Do you want to continue signing up with your company information?";
683
- const indicatedPayoutToPersonalAccount = "You indicated that you want to be paid out to a bank account that is owned by you personally. This means you will continue as an individual, not a company. However, if you operate as a private company, public company, partnership, or non-profit organization, then you cannot continue as an individual.";
684
- const continueSigningUpAsIndividual = "Do you want to continue signing up as an individual?";
675
+ const areYouACompany = "Are you a company?";
676
+ const singingUpAsIndividualButLooksLikeYouAreACompany = "You’re now signing up as an individual. But it looks like you’re a company that uses a company bank account to receive payouts.";
677
+ const wouldYouLikeToSignUpAsCompanyInstead = "Would you like to sign up as a company instead? (You’ll have to re-enter some information from before.)";
678
+ const areYouAnIndividual = "Are you an individual?";
679
+ const singingUpAsCompanyButLooksLikeYouAreAnIndividual = "You’re now signing up as an company. But it looks like you’re an individual who uses your personal bank account to receive payouts.";
680
+ const wouldYouLikeToSignUpAsIndividualInstead = "Would you like to sign up as an individual instead? (You’ll have to re-enter some information from before.)";
685
681
  const noGoBack = "No, go back";
686
682
  const continueCompany = "Continue as company";
687
683
  const continueIndividual = "Continue as individual";
@@ -692,7 +688,6 @@ const addresses = "Addresses";
692
688
  const loading = "Loading";
693
689
  const businessIncorporationNumber = "Business incorporation number";
694
690
  const doNotHaveBusinessIncorporationNumber = "I do not have a Business incorporation number";
695
- const socialInsuranceNumber = "Social insurance number";
696
691
  const verificationMethod = "Verification method";
697
692
  const verifyViaMobileBankAppOrBankWebsite = "Verify the account via mobile bank app or bank website";
698
693
  const provideAccountDetailsAndUploadBankStatement = "Provide account details and upload a scan of a bank statement";
@@ -761,6 +756,13 @@ const passportPhotoPage = "Passport photo page";
761
756
  const residencePermitBack = "Residence permit (back)";
762
757
  const residencePermitFront = "Residence permit (front)";
763
758
  const manualUpload = "Manual upload";
759
+ const legalCompanyName = "Legal name of the company";
760
+ const legalCompanyName__helperText = "Enter the name exactly as it is on your company's official registration documents.";
761
+ const legalCompanyName__helperText__AU = "Enter the name exactly as it is on your Australian Securities and Investment Commission's (ASIC).";
762
+ const legalCompanyName__helperText__NL = "Enter the name exactly as it is on your Chamber of Commerce registration.";
763
+ const legalCompanyName__helperText__US = "Enter the name exactly as it appears on your Secretary of State Registration.";
764
+ const legalCompanyName__helperText__SG = "Enter the name exactly as it is on your Accounting and Corporate Regulatory Authority (ACRA) BizFile.";
765
+ const legalCompanyName__helperText__HK = "Enter the name exactly as it is on your Hong Kong Companies Registry's Certificate of Incorporation.";
764
766
  const errorMessage_1_10 = "Information couldn’t be verified";
765
767
  const errorMessage_1_11 = "Document didn’t meet requirements";
766
768
  const errorMessage_1_12 = "Legal entity declined";
@@ -1119,6 +1121,7 @@ const defaultTrans = {
1119
1121
  individualDetails,
1120
1122
  socialSecurityNumber,
1121
1123
  socialSecurityNumber9Digits,
1124
+ socialInsuranceNumber,
1122
1125
  codiceFiscale,
1123
1126
  personnummer,
1124
1127
  dni,
@@ -1178,6 +1181,8 @@ const defaultTrans = {
1178
1181
  dateOfIncorporation,
1179
1182
  passportExpiryDate,
1180
1183
  proofOfNationality,
1184
+ identityNumberExempt__US,
1185
+ identityNumberExempt__CA,
1181
1186
  uploadDocumentForSsn,
1182
1187
  uploadDocumentForNric,
1183
1188
  operationalAddressHeader,
@@ -1281,13 +1286,6 @@ const defaultTrans = {
1281
1286
  byClickingSubmitReview,
1282
1287
  nameAndCountry,
1283
1288
  companyCountry,
1284
- legalCompanyName,
1285
- legalCompanyNameHelper,
1286
- legalCompanyNameHelper__AU,
1287
- legalCompanyNameHelper__NL,
1288
- legalCompanyNameHelper__US,
1289
- legalCompanyNameHelper__SG,
1290
- legalCompanyNameHelper__HK,
1291
1289
  accountDetailsDescription,
1292
1290
  provideDetails,
1293
1291
  payoutAccountsDescription,
@@ -1747,12 +1745,12 @@ const defaultTrans = {
1747
1745
  learnMore,
1748
1746
  doingBusinessAsNameFiling,
1749
1747
  taxFiling,
1750
- continueAsCompany,
1751
- continueAsIndividual,
1752
- indicatedPayoutToCompany,
1753
- continueSigningUpAsCompany,
1754
- indicatedPayoutToPersonalAccount,
1755
- continueSigningUpAsIndividual,
1748
+ areYouACompany,
1749
+ singingUpAsIndividualButLooksLikeYouAreACompany,
1750
+ wouldYouLikeToSignUpAsCompanyInstead,
1751
+ areYouAnIndividual,
1752
+ singingUpAsCompanyButLooksLikeYouAreAnIndividual,
1753
+ wouldYouLikeToSignUpAsIndividualInstead,
1756
1754
  "continue": "Continue",
1757
1755
  noGoBack,
1758
1756
  continueCompany,
@@ -1764,7 +1762,6 @@ const defaultTrans = {
1764
1762
  loading,
1765
1763
  businessIncorporationNumber,
1766
1764
  doNotHaveBusinessIncorporationNumber,
1767
- socialInsuranceNumber,
1768
1765
  verificationMethod,
1769
1766
  verifyViaMobileBankAppOrBankWebsite,
1770
1767
  provideAccountDetailsAndUploadBankStatement,
@@ -1835,6 +1832,13 @@ const defaultTrans = {
1835
1832
  residencePermitBack,
1836
1833
  residencePermitFront,
1837
1834
  manualUpload,
1835
+ legalCompanyName,
1836
+ legalCompanyName__helperText,
1837
+ legalCompanyName__helperText__AU,
1838
+ legalCompanyName__helperText__NL,
1839
+ legalCompanyName__helperText__US,
1840
+ legalCompanyName__helperText__SG,
1841
+ legalCompanyName__helperText__HK,
1838
1842
  errorMessage_1_10,
1839
1843
  errorMessage_1_11,
1840
1844
  errorMessage_1_12,
@@ -2363,12 +2367,26 @@ const useCoreContext = () => {
2363
2367
  return context;
2364
2368
  };
2365
2369
  const Summary$1 = "";
2370
+ const omitKeys = (obj, omit) => Object.keys(obj).filter((k) => !omit.includes(k)).reduce((a, c) => {
2371
+ a[c] = obj[c];
2372
+ return a;
2373
+ }, {});
2374
+ const addKeys = (obj, add2, initialValue, defaultData, pendingData) => add2.reduce((a, c) => ({
2375
+ ...a,
2376
+ [c]: a[c] ?? (pendingData == null ? void 0 : pendingData[c]) ?? (defaultData == null ? void 0 : defaultData[c]) ?? initialValue
2377
+ }), obj);
2378
+ function getDataByFields(formData, fieldKeys) {
2379
+ return entriesOf(formData).reduce((acc, [key, val]) => {
2380
+ if (fieldKeys.includes(key)) {
2381
+ return {
2382
+ ...acc,
2383
+ [key]: val
2384
+ };
2385
+ }
2386
+ return acc;
2387
+ }, {});
2388
+ }
2366
2389
  const formUtilities = (props, i18n) => ({
2367
- getPlaceholder: (field, fallbackPlaceholderKey) => {
2368
- var _a, _b;
2369
- const translationKey = fallbackPlaceholderKey ? ((_a = props.placeholders) == null ? void 0 : _a[field]) ?? fallbackPlaceholderKey : (_b = props.placeholders) == null ? void 0 : _b[field];
2370
- return translationKey ? i18n.get(translationKey) : "";
2371
- },
2372
2390
  getLabel: (field, fallbackLabelKey) => {
2373
2391
  var _a, _b;
2374
2392
  let translationKey = ((_a = props.labels) == null ? void 0 : _a[field]) ?? fallbackLabelKey ?? field;
@@ -2384,6 +2402,11 @@ const formUtilities = (props, i18n) => ({
2384
2402
  }
2385
2403
  return i18n.get(translationKey);
2386
2404
  },
2405
+ getPlaceholder: (field, fallbackPlaceholderKey) => {
2406
+ var _a, _b;
2407
+ const translationKey = fallbackPlaceholderKey ? ((_a = props.placeholders) == null ? void 0 : _a[field]) ?? fallbackPlaceholderKey : (_b = props.placeholders) == null ? void 0 : _b[field];
2408
+ return translationKey ? i18n.get(translationKey) : "";
2409
+ },
2387
2410
  getHelperText: (field, fallbackHelperTextKey) => {
2388
2411
  var _a, _b;
2389
2412
  const translationKey = fallbackHelperTextKey ? ((_a = props.helperText) == null ? void 0 : _a[field]) ?? fallbackHelperTextKey : (_b = props.helperText) == null ? void 0 : _b[field];
@@ -2423,7 +2446,70 @@ const formUtilities = (props, i18n) => ({
2423
2446
  return i18n.get(translationKey, translationObject);
2424
2447
  }
2425
2448
  return errorMessage ? i18n.get(errorMessage) : Boolean(fieldProblems == null ? void 0 : fieldProblems[field]);
2426
- }
2449
+ },
2450
+ getFieldData: (formData, fieldKeys) => getDataByFields(formData, fieldKeys),
2451
+ getFieldValid: (formValid, fieldKeys) => entriesOf(formValid).reduce((acc, [key, val]) => fieldKeys.includes(key) ? {
2452
+ ...acc,
2453
+ [key]: val
2454
+ } : acc, {}),
2455
+ getFieldErrors: (formErrors, fieldProblems, fieldKeys) => Object.keys(formErrors).reduce((acc, key) => {
2456
+ var _a;
2457
+ if (fieldKeys.includes(key)) {
2458
+ const error = (_a = formErrors == null ? void 0 : formErrors[key]) == null ? void 0 : _a.errorMessage;
2459
+ if (typeof error === "object") {
2460
+ const {
2461
+ translationKey,
2462
+ translationObject
2463
+ } = error;
2464
+ return {
2465
+ ...acc,
2466
+ [key]: i18n.get(translationKey, translationObject)
2467
+ };
2468
+ }
2469
+ return error ? {
2470
+ ...acc,
2471
+ [key]: i18n.get(error)
2472
+ } : {
2473
+ ...acc,
2474
+ [key]: Boolean(fieldProblems == null ? void 0 : fieldProblems[key])
2475
+ };
2476
+ }
2477
+ return acc;
2478
+ }, {}),
2479
+ getFieldLabels: (fieldKeys, fallbackLabelKeys) => fieldKeys.reduce((acc, field) => {
2480
+ var _a, _b;
2481
+ let translationKey = ((_a = props.labels) == null ? void 0 : _a[field]) ?? (fallbackLabelKeys == null ? void 0 : fallbackLabelKeys[field]) ?? field;
2482
+ if (props.labels && !((_b = props.labels) == null ? void 0 : _b[field]) && Object.keys(props.labels).length) {
2483
+ const parentKey = Object.keys(props.labels).find((fieldKey) => {
2484
+ var _a2;
2485
+ return typeof ((_a2 = props.labels) == null ? void 0 : _a2[fieldKey]) === "object";
2486
+ });
2487
+ if (parentKey) {
2488
+ const nestedLabel = props.labels[parentKey][field];
2489
+ translationKey = nestedLabel ?? translationKey;
2490
+ }
2491
+ }
2492
+ return {
2493
+ ...acc,
2494
+ [field]: i18n.get(translationKey)
2495
+ };
2496
+ }, {}),
2497
+ getFieldPlaceholders: (fieldKeys, fallbackPlaceholderKeys) => fieldKeys.reduce((acc, field) => {
2498
+ var _a, _b;
2499
+ const translationKey = (fallbackPlaceholderKeys == null ? void 0 : fallbackPlaceholderKeys[field]) ? ((_a = props.placeholders) == null ? void 0 : _a[field]) ?? (fallbackPlaceholderKeys == null ? void 0 : fallbackPlaceholderKeys[field]) : (_b = props.placeholders) == null ? void 0 : _b[field];
2500
+ return translationKey ? {
2501
+ ...acc,
2502
+ [field]: i18n.get(translationKey)
2503
+ } : acc;
2504
+ }, {}),
2505
+ getFieldHelperText: (fieldKeys, fallbackHelperTextKeys) => fieldKeys.reduce((acc, field) => {
2506
+ var _a, _b;
2507
+ const translationKey = (fallbackHelperTextKeys == null ? void 0 : fallbackHelperTextKeys[field]) ? ((_a = props.helperText) == null ? void 0 : _a[field]) ?? (fallbackHelperTextKeys == null ? void 0 : fallbackHelperTextKeys[field]) : (_b = props.helperText) == null ? void 0 : _b[field];
2508
+ return translationKey ? {
2509
+ ...acc,
2510
+ [field]: i18n.get(translationKey)
2511
+ } : acc;
2512
+ }, {})
2427
2513
  });
2428
2514
  const MAX_LENGTH = 30;
2429
2515
  const getMaxLengthByFormatRuleset = (formattingRules, field) => {
@@ -3041,14 +3127,6 @@ function useResetGlobalData(caller) {
3041
3127
  }
3042
3128
  }), [dispatch, caller]);
3043
3129
  }
3044
- const omitKeys = (obj, omit) => Object.keys(obj).filter((k) => !omit.includes(k)).reduce((a, c) => {
3045
- a[c] = obj[c];
3046
- return a;
3047
- }, {});
3048
- const addKeys = (obj, add2, initialValue, defaultData, pendingData) => add2.reduce((a, c) => ({
3049
- ...a,
3050
- [c]: a[c] ?? (pendingData == null ? void 0 : pendingData[c]) ?? (defaultData == null ? void 0 : defaultData[c]) ?? initialValue
3051
- }), obj);
3052
3130
  const processField = ({
3053
3131
  key,
3054
3132
  value = null,
@@ -3463,6 +3541,7 @@ function useForm({
3463
3541
  asyncRules,
3464
3542
  fieldProblems,
3465
3543
  maskedFields,
3544
+ optionalFields,
3466
3545
  formatters,
3467
3546
  shouldValidate = false
3468
3547
  }) {
@@ -3474,20 +3553,26 @@ function useForm({
3474
3553
  asyncValidationResults
3475
3554
  } = useAsyncValidator(asyncRules);
3476
3555
  const getRequiredFields = useMemo(() => typeof schema === "function" ? schema : () => schema, [schema]);
3556
+ const getSchema = useMemo(() => {
3557
+ if (optionalFields) {
3558
+ return defaultData ? [...getRequiredFields(defaultData), ...optionalFields] : [];
3559
+ }
3560
+ return defaultData ? getRequiredFields(defaultData) : [];
3561
+ }, [optionalFields, defaultData, getRequiredFields]);
3477
3562
  const getReducer = useCallback(() => reducer({
3478
3563
  staticValidate: triggerStaticValidation,
3479
3564
  asyncValidate: triggerAsyncValidation,
3480
3565
  formatters
3481
3566
  }), [triggerStaticValidation, triggerAsyncValidation, formatters]);
3482
3567
  const getInitialData = useCallback(() => ({
3483
- schema: defaultData ? getRequiredFields(defaultData) : [],
3568
+ schema: getSchema,
3484
3569
  defaultData,
3485
3570
  fieldProblems,
3486
3571
  maskedFields,
3487
3572
  formatters,
3488
3573
  staticValidate: triggerStaticValidation,
3489
3574
  asyncValidate: triggerAsyncValidation
3490
- }), [defaultData, fieldProblems, maskedFields, formatters, getRequiredFields, triggerStaticValidation, triggerAsyncValidation]);
3575
+ }), [getSchema, defaultData, fieldProblems, maskedFields, formatters, triggerStaticValidation, triggerAsyncValidation]);
3491
3576
  const [state2, dispatch] = useReducer(getReducer(), getInitialData(), init);
3492
3577
  const isValid = useMemo(() => {
3493
3578
  var _a;
@@ -4822,12 +4907,12 @@ const Select = ({
4822
4907
  });
4823
4908
  };
4824
4909
  const logger$k = createLogger("CountryField");
4825
- const COUNTRY_FIELD = "country";
4910
+ const COUNTRY_FIELD = ["country"];
4826
4911
  function CountryField({
4827
4912
  data,
4828
4913
  valid,
4829
- error,
4830
- label,
4914
+ errors,
4915
+ labels: labels2,
4831
4916
  readonly,
4832
4917
  handleChangeFor,
4833
4918
  helperText,
@@ -4850,27 +4935,21 @@ function CountryField({
4850
4935
  ...item,
4851
4936
  sprite: `#adl-flag-${item.id.toLowerCase()}`
4852
4937
  }));
4853
- const handleCompanyChangeFor = useCallback((e) => {
4854
- const {
4855
- value
4856
- } = e.target;
4857
- handleChangeFor(COUNTRY_FIELD)(value);
4858
- }, [handleChangeFor]);
4859
4938
  return jsx(Field, {
4860
- name: COUNTRY_FIELD,
4861
- label: label || i18n.get(COUNTRY_FIELD),
4862
- errorMessage: error,
4939
+ name: "country",
4940
+ label: (labels2 == null ? void 0 : labels2.country) || i18n.get("country"),
4941
+ errorMessage: errors.country,
4863
4942
  classNameModifiers,
4864
- isValid: valid,
4865
- helper: helperText,
4943
+ isValid: valid.country,
4944
+ helper: helperText == null ? void 0 : helperText.country,
4866
4945
  children: (childProps) => jsx(Select, {
4867
4946
  ...childProps,
4868
- name: COUNTRY_FIELD,
4947
+ name: "country",
4869
4948
  placeholder: i18n.get("selectCountry"),
4870
- selected: data,
4949
+ selected: data.country,
4871
4950
  items: countries,
4872
4951
  readonly: (countries.length === 1 || readonly) && !!data,
4873
- onChange: handleCompanyChangeFor
4952
+ onChange: handleChangeFor("country")
4874
4953
  })
4875
4954
  });
4876
4955
  }
@@ -5002,46 +5081,34 @@ const InputText = forwardRef(({
5002
5081
  );
5003
5082
  });
5004
5083
  InputText.displayName = "InputText";
5005
- const LEGAL_COMPANY_NAME_FIELD = "legalCompanyName";
5084
+ const LEGAL_COMPANY_NAME_FIELD = ["legalCompanyName"];
5006
5085
  function LegalCompanyNameField({
5007
5086
  data,
5008
5087
  valid,
5009
- error,
5010
- label,
5088
+ errors,
5089
+ labels: labels2,
5011
5090
  helperText,
5012
5091
  readonly,
5013
5092
  handleChangeFor
5014
5093
  }) {
5015
- const handleLegalCompanyNameInput = useCallback((e) => {
5016
- const {
5017
- value
5018
- } = e.target;
5019
- handleChangeFor(LEGAL_COMPANY_NAME_FIELD, "input")(value);
5020
- }, [handleChangeFor]);
5021
- const handleLegalCompanyNameBlur = useCallback((e) => {
5022
- const {
5023
- value
5024
- } = e.target;
5025
- handleChangeFor(LEGAL_COMPANY_NAME_FIELD, "blur")(value);
5026
- }, [handleChangeFor]);
5027
5094
  return jsx(Field, {
5028
- name: LEGAL_COMPANY_NAME_FIELD,
5029
- label,
5030
- helper: helperText,
5031
- classNameModifiers: [LEGAL_COMPANY_NAME_FIELD],
5032
- errorMessage: error,
5033
- isValid: valid,
5095
+ name: "legalCompanyName",
5096
+ label: labels2.legalCompanyName,
5097
+ helper: helperText == null ? void 0 : helperText.legalCompanyName,
5098
+ errorMessage: errors.legalCompanyName,
5099
+ isValid: valid.legalCompanyName,
5100
+ classNameModifiers: ["legalCompanyName"],
5034
5101
  children: (childProps) => jsx(InputText, {
5035
5102
  ...childProps,
5036
5103
  "aria-required": true,
5037
- "aria-label": label,
5038
- "aria-invalid": !valid,
5039
- name: LEGAL_COMPANY_NAME_FIELD,
5040
- value: data,
5104
+ "aria-label": labels2.legalCompanyName,
5105
+ "aria-invalid": !valid.legalCompanyName,
5106
+ name: "legalCompanyName",
5107
+ value: data.legalCompanyName,
5041
5108
  readonly,
5042
- classNameModifiers: [LEGAL_COMPANY_NAME_FIELD],
5043
- onInput: handleLegalCompanyNameInput,
5044
- onBlur: handleLegalCompanyNameBlur
5109
+ classNameModifiers: ["legalCompanyName"],
5110
+ onInput: handleChangeFor("legalCompanyName", "input"),
5111
+ onBlur: handleChangeFor("legalCompanyName", "blur")
5045
5112
  })
5046
5113
  });
5047
5114
  }
@@ -5084,7 +5151,7 @@ const companyCountryValidationRules = {
5084
5151
  errorMessage: "fieldIsRequired"
5085
5152
  }
5086
5153
  };
5087
- const companyNameAndCountryFields = [LEGAL_COMPANY_NAME_FIELD, COUNTRY_FIELD];
5154
+ const companyNameAndCountryFields = [...LEGAL_COMPANY_NAME_FIELD, ...COUNTRY_FIELD];
5088
5155
  function CompanyNameAndCountry(props) {
5089
5156
  const {
5090
5157
  i18n
@@ -5133,22 +5200,24 @@ function CompanyNameAndCountry(props) {
5133
5200
  validationErrors: props == null ? void 0 : props.fieldValidationErrors,
5134
5201
  formUtils,
5135
5202
  id: "ariaErrorField"
5136
- }), formData.country === "US" ? jsx(PatriotActDisclosure, {}) : void 0, formUtils.isRequiredField(COUNTRY_FIELD) && jsx(CountryField, {
5137
- data: formData.country,
5138
- valid: formValid.country,
5139
- error: formUtils.getErrorMessage(COUNTRY_FIELD, formErrors, formFieldProblems),
5140
- label: formUtils.getLabel(COUNTRY_FIELD),
5203
+ }), formData.country === "US" ? jsx(PatriotActDisclosure, {}) : void 0, formUtils.isRequiredField("country") && jsx(CountryField, {
5204
+ data: formUtils.getFieldData(formData, COUNTRY_FIELD),
5205
+ valid: formUtils.getFieldValid(formValid, COUNTRY_FIELD),
5206
+ errors: formUtils.getFieldErrors(formErrors, formFieldProblems, COUNTRY_FIELD),
5207
+ labels: formUtils.getFieldLabels(COUNTRY_FIELD),
5141
5208
  readonly: !isAllowedEditPrefilledCountry || Boolean(props == null ? void 0 : props.disableCountry),
5142
- classNameModifiers: [COUNTRY_FIELD],
5209
+ classNameModifiers: ["country"],
5143
5210
  allowedCountries: [],
5144
5211
  handleChangeFor
5145
- }), formUtils.isRequiredField(LEGAL_COMPANY_NAME_FIELD) && jsx(LegalCompanyNameField, {
5146
- data: formData.legalCompanyName,
5147
- valid: formValid.legalCompanyName,
5148
- error: formUtils.getErrorMessage(LEGAL_COMPANY_NAME_FIELD, formErrors, formFieldProblems),
5149
- label: formUtils.getLabel(LEGAL_COMPANY_NAME_FIELD),
5150
- helperText: formUtils.getHelperText(LEGAL_COMPANY_NAME_FIELD, "legalCompanyNameHelper"),
5151
- readonly: formUtils.isReadOnly(LEGAL_COMPANY_NAME_FIELD),
5212
+ }), formUtils.isRequiredField("legalCompanyName") && jsx(LegalCompanyNameField, {
5213
+ data: formUtils.getFieldData(formData, LEGAL_COMPANY_NAME_FIELD),
5214
+ valid: formUtils.getFieldValid(formValid, LEGAL_COMPANY_NAME_FIELD),
5215
+ errors: formUtils.getFieldErrors(formErrors, formFieldProblems, LEGAL_COMPANY_NAME_FIELD),
5216
+ labels: formUtils.getFieldLabels(LEGAL_COMPANY_NAME_FIELD),
5217
+ helperText: formUtils.getFieldHelperText(LEGAL_COMPANY_NAME_FIELD, {
5218
+ legalCompanyName: "legalCompanyName__helperText"
5219
+ }),
5220
+ readonly: formUtils.isReadOnly("legalCompanyName"),
5152
5221
  handleChangeFor
5153
5222
  })]
5154
5223
  });
@@ -7860,7 +7929,7 @@ const fieldsPerScenario$3 = {
7860
7929
  const countryConfig$4 = {
7861
7930
  [CountryCodes.Australia]: {
7862
7931
  legalCompanyName: {
7863
- helperText: "legalCompanyNameHelper__AU"
7932
+ helperText: "legalCompanyName__helperText__AU"
7864
7933
  },
7865
7934
  legalEntityType: {
7866
7935
  label: "companyType"
@@ -8056,7 +8125,7 @@ const countryConfig$4 = {
8056
8125
  },
8057
8126
  [CountryCodes.HongKong]: {
8058
8127
  legalCompanyName: {
8059
- helperText: "legalCompanyNameHelper__HK"
8128
+ helperText: "legalCompanyName__helperText__HK"
8060
8129
  },
8061
8130
  legalEntityType: {
8062
8131
  label: "typeOfCompany"
@@ -8215,7 +8284,7 @@ const countryConfig$4 = {
8215
8284
  label: "chamberOfCommerceRegistrationNumber"
8216
8285
  },
8217
8286
  legalCompanyName: {
8218
- helperText: "legalCompanyNameHelper__NL"
8287
+ helperText: "legalCompanyName__helperText__NL"
8219
8288
  },
8220
8289
  exemptedFromVat: {
8221
8290
  label: "vatNumberExempted"
@@ -8346,7 +8415,7 @@ const countryConfig$4 = {
8346
8415
  label: "uen"
8347
8416
  },
8348
8417
  legalCompanyName: {
8349
- helperText: "legalCompanyNameHelper__SG"
8418
+ helperText: "legalCompanyName__helperText__SG"
8350
8419
  },
8351
8420
  legalEntityType: {
8352
8421
  label: "companyType"
@@ -8402,7 +8471,7 @@ const countryConfig$4 = {
8402
8471
  },
8403
8472
  [CountryCodes.UnitedStates]: {
8404
8473
  legalCompanyName: {
8405
- helperText: "legalCompanyNameHelper__US"
8474
+ helperText: "legalCompanyName__helperText__US"
8406
8475
  },
8407
8476
  tradingName: {
8408
8477
  label: "doingBusinessAs"
@@ -8619,14 +8688,14 @@ const rules$3 = ({
8619
8688
  }
8620
8689
  },
8621
8690
  isProofOfResidenceRequired: () => {
8622
- var _a;
8623
- if ((_a = data.proofOfResidence) == null ? void 0 : _a.proofOfResidence) {
8691
+ var _a, _b;
8692
+ if ((_b = (_a = data.proofOfResidence) == null ? void 0 : _a.proofOfResidence) == null ? void 0 : _b.length) {
8624
8693
  return REQUIRED;
8625
8694
  }
8626
8695
  },
8627
8696
  isProofOfNationalIdRequired: () => {
8628
- var _a;
8629
- if ((_a = data.proofOfNationalId) == null ? void 0 : _a.proofOfNationalId) {
8697
+ var _a, _b;
8698
+ if ((_b = (_a = data.proofOfNationalId) == null ? void 0 : _a.proofOfNationalId) == null ? void 0 : _b.length) {
8630
8699
  return REQUIRED;
8631
8700
  }
8632
8701
  },
@@ -9127,6 +9196,8 @@ function bytesToSize(bytes) {
9127
9196
  return `${(bytes / 1024 ** i).toFixed()} ${sizes[i]}`;
9128
9197
  }
9129
9198
  const DropzoneFile$1 = "";
9199
+ const isExistingFile = (file) => "existing" in file && file.existing;
9200
+ const isNewlyUploadedFile = (file) => !isExistingFile(file);
9130
9201
  function DropzoneFile(props) {
9131
9202
  const {
9132
9203
  file,
@@ -9176,7 +9247,7 @@ function DropzoneFile(props) {
9176
9247
  className: "adyen-kyc-dropzone-file__size",
9177
9248
  children: [jsxs("span", {
9178
9249
  children: [i18n.get("complete"), " "]
9179
- }), formatSize(file.size)]
9250
+ }), isNewlyUploadedFile(file) ? formatSize(file.size) : void 0]
9180
9251
  })]
9181
9252
  }), jsx("button", {
9182
9253
  type: "button",
@@ -9196,6 +9267,7 @@ const defaultFileValidationOptions = {
9196
9267
  // 4MB by default
9197
9268
  isOptional: false
9198
9269
  };
9270
+ const filterOnlyNewlyUploadedFiles = (files) => files.filter(isNewlyUploadedFile);
9199
9271
  const fileValidationRules = ({
9200
9272
  allowedFileTypes,
9201
9273
  maxNumberOfFiles,
@@ -9229,7 +9301,7 @@ const fileValidationRules = ({
9229
9301
  validate: (files) => {
9230
9302
  if (!files)
9231
9303
  return true;
9232
- return files.every((file) => allowedFileTypes.some((filetype) => file.name.toLowerCase().endsWith(filetype.toLowerCase())));
9304
+ return filterOnlyNewlyUploadedFiles(files).every((file) => allowedFileTypes.some((filetype) => file.name.toLowerCase().endsWith(filetype.toLowerCase())));
9233
9305
  },
9234
9306
  errorMessage: "unsupportedFiletype",
9235
9307
  modes: ["blur", "input"]
@@ -9237,7 +9309,7 @@ const fileValidationRules = ({
9237
9309
  validate: (files) => {
9238
9310
  if (!files)
9239
9311
  return true;
9240
- return files.every((file) => !file.size || file.size < maxSize);
9312
+ return filterOnlyNewlyUploadedFiles(files).every((file) => !file.size || file.size < maxSize);
9241
9313
  },
9242
9314
  errorMessage: "maximumFileSizeExceeded",
9243
9315
  modes: ["blur", "input"]
@@ -9734,12 +9806,11 @@ const mapAddressLabels = (data, datasetUtils) => {
9734
9806
  }
9735
9807
  return data;
9736
9808
  };
9737
- const STATE_FIELD = "stateOrProvince";
9738
9809
  function StateField({
9739
9810
  data,
9740
9811
  valid,
9741
- error,
9742
- label,
9812
+ errors,
9813
+ labels: labels2,
9743
9814
  readonly,
9744
9815
  handleChangeFor,
9745
9816
  selectedCountry,
@@ -9752,30 +9823,24 @@ function StateField({
9752
9823
  dataset: states,
9753
9824
  loaded
9754
9825
  } = useDataset(datasetIdentifier.state(selectedCountry), !selectedCountry || !COUNTRIES_WITH_STATES_DATASET.includes(selectedCountry));
9755
- const handleStateChangeFor = useCallback((e) => {
9756
- const {
9757
- value
9758
- } = e.target;
9759
- handleChangeFor(STATE_FIELD)(value);
9760
- }, [handleChangeFor]);
9761
- const labelKey = getKeyForField(STATE_FIELD, selectedCountry);
9826
+ const labelKey = getKeyForField("stateOrProvince", selectedCountry);
9762
9827
  const placeholderKey = getKeyForField("stateOrProvincePlaceholder", selectedCountry);
9763
9828
  if (!loaded || !states.length)
9764
9829
  return null;
9765
9830
  return jsx(Field, {
9766
- name: STATE_FIELD,
9767
- label: label || i18n.get(labelKey),
9831
+ name: "stateOrProvince",
9832
+ label: (labels2 == null ? void 0 : labels2.stateOrProvince) || i18n.get(labelKey),
9768
9833
  classNameModifiers,
9769
- errorMessage: error,
9770
- isValid: valid,
9834
+ errorMessage: errors.stateOrProvince,
9835
+ isValid: valid.stateOrProvince,
9771
9836
  children: (childProps) => jsx(Select, {
9772
9837
  ...childProps,
9773
- name: STATE_FIELD,
9774
- selected: data,
9838
+ name: "stateOrProvince",
9839
+ selected: data.stateOrProvince,
9775
9840
  placeholder: i18n.get(placeholderKey),
9776
9841
  items: states,
9777
- readonly: readonly && !!data,
9778
- onChange: handleStateChangeFor
9842
+ readonly: readonly && !!data.stateOrProvince,
9843
+ onChange: handleChangeFor("stateOrProvince")
9779
9844
  })
9780
9845
  });
9781
9846
  }
@@ -9804,10 +9869,18 @@ function FieldContainer(props) {
9804
9869
  switch (field) {
9805
9870
  case "country":
9806
9871
  return jsx(CountryField, {
9807
- data: value,
9808
- valid: valid == null ? void 0 : valid.country,
9809
- error: errorMessage,
9810
- label: formUtils.getLabel(field),
9872
+ data: {
9873
+ country: value
9874
+ },
9875
+ valid: {
9876
+ country: valid == null ? void 0 : valid.country
9877
+ },
9878
+ errors: {
9879
+ country: errorMessage
9880
+ },
9881
+ labels: {
9882
+ country: formUtils.getLabel(field)
9883
+ },
9811
9884
  readonly: formUtils.isReadOnly(field),
9812
9885
  classNameModifiers,
9813
9886
  allowedCountries,
@@ -9816,10 +9889,18 @@ function FieldContainer(props) {
9816
9889
  });
9817
9890
  case "stateOrProvince":
9818
9891
  return jsx(StateField, {
9819
- data: value,
9820
- valid: valid == null ? void 0 : valid.stateOrProvince,
9821
- error: errorMessage,
9822
- label: formUtils.getLabel(field),
9892
+ data: {
9893
+ stateOrProvince: value
9894
+ },
9895
+ valid: {
9896
+ stateOrProvince: valid == null ? void 0 : valid.stateOrProvince
9897
+ },
9898
+ errors: {
9899
+ stateOrProvince: errorMessage
9900
+ },
9901
+ labels: {
9902
+ stateOrProvince: formUtils.getLabel(field)
9903
+ },
9823
9904
  readonly: formUtils.isReadOnly(field),
9824
9905
  classNameModifiers,
9825
9906
  selectedCountry: data.country,
@@ -10689,7 +10770,8 @@ function RegistrationAddressComponent(props) {
10689
10770
  heading,
10690
10771
  description: description2,
10691
10772
  handleAddressSearch,
10692
- handleFindAddress
10773
+ handleFindAddress,
10774
+ optionalFields
10693
10775
  } = props;
10694
10776
  const {
10695
10777
  data: formData,
@@ -10702,7 +10784,8 @@ function RegistrationAddressComponent(props) {
10702
10784
  schema: ["operationalAddressIsSame"],
10703
10785
  defaultData: data,
10704
10786
  rules: validators || registrationAddressValidationRules,
10705
- maskedFields: []
10787
+ maskedFields: [],
10788
+ optionalFields
10706
10789
  });
10707
10790
  const formUtils = formUtilities(props, i18n);
10708
10791
  const stateRef = useRef({
@@ -11079,9 +11162,10 @@ const createDocumentRequest = async ({
11079
11162
  description: description2,
11080
11163
  existingDocument
11081
11164
  }) => {
11082
- const promises = [fileToBase64(page1), fileToBase64(page2)].filter(Boolean);
11083
- const [encodedFront, encodedBack] = await Promise.all(promises);
11084
- if (!encodedFront) {
11165
+ const pagesToUpload = [page1, page2].filter((page) => page !== void 0 && isNewlyUploadedFile(page));
11166
+ const [page1ToUpload, page2ToUpload] = pagesToUpload;
11167
+ const [encodedPage1, encodedPage2] = await Promise.all(pagesToUpload.map(fileToBase64));
11168
+ if (!encodedPage1) {
11085
11169
  if (existingDocument && existingDocument.description !== description2) {
11086
11170
  return {
11087
11171
  owner: {
@@ -11101,7 +11185,7 @@ const createDocumentRequest = async ({
11101
11185
  },
11102
11186
  type: documentType2,
11103
11187
  description: description2 || `Document type: ${documentType2}`,
11104
- attachments: [...page1 && page2 && encodedFront && encodedBack ? [createAttachment(encodedFront, page1.name, "front"), createAttachment(encodedBack, page2.name, "back")] : [createAttachment(encodedFront, page1.name)]]
11188
+ attachments: [...page1ToUpload && page2ToUpload && encodedPage1 && encodedPage2 ? [createAttachment(encodedPage1, page1ToUpload.name, "front"), createAttachment(encodedPage2, page2ToUpload.name, "back")] : [createAttachment(encodedPage1, page1ToUpload.name)]]
11105
11189
  };
11106
11190
  };
11107
11191
  const createAttachment = (content, pageName, pageType) => ({
@@ -11122,15 +11206,10 @@ const hasDocumentChanged = (newDocument, entityId) => {
11122
11206
  return true;
11123
11207
  };
11124
11208
  const fileToBase64 = (file) => new Promise((resolve, reject) => {
11125
- if (!file || !(file instanceof Blob)) {
11126
- resolve();
11127
- return;
11128
- }
11129
11209
  const reader = new FileReader();
11130
11210
  reader.readAsDataURL(file);
11131
11211
  reader.onload = () => {
11132
- var _a;
11133
- const base64String = (_a = reader.result) == null ? void 0 : _a.toString().split(";base64,")[1];
11212
+ const base64String = reader.result.toString().split(";base64,")[1];
11134
11213
  resolve(base64String);
11135
11214
  };
11136
11215
  reader.onerror = (error) => reject(error);
@@ -11529,10 +11608,17 @@ const isPartOfTrustFromLegalEntity = (legalEntity) => {
11529
11608
  var _a;
11530
11609
  return (_a = legalEntity == null ? void 0 : legalEntity.entityAssociations) == null ? void 0 : _a.some((ea) => ea.entityType === LegalEntityType.TRUST && ea.associatorId === legalEntity.id);
11531
11610
  };
11611
+ const getRootTrusteeLegalEntityId = (trustEntity) => {
11612
+ var _a;
11613
+ if (!trustEntity.entityAssociations)
11614
+ return "";
11615
+ return (_a = trustEntity.entityAssociations.filter((entityAssociation) => entityAssociation.type === LegalEntityType.TRUST)[0]) == null ? void 0 : _a.legalEntityId;
11616
+ };
11532
11617
  const getOwnTrustMembers = (trustEntity) => {
11533
11618
  if (!trustEntity.entityAssociations)
11534
11619
  return [];
11535
- return trustEntity.entityAssociations.filter((entityAssociation) => Object.values(TrustMemberTypes).includes(entityAssociation.type) && entityAssociation.associatorId === trustEntity.id);
11620
+ const rootTrusteeLegalEntityId = getRootTrusteeLegalEntityId(trustEntity);
11621
+ return trustEntity.entityAssociations.filter((entityAssociation) => Object.values(TrustMemberTypes).includes(entityAssociation.type) && rootTrusteeLegalEntityId === (entityAssociation == null ? void 0 : entityAssociation.associatorId));
11536
11622
  };
11537
11623
  const getOwnTrustMembersLegalEntityIds = (legalEntity) => getOwnTrustMembers(legalEntity).map((ea) => ea.legalEntityId).filter((id2) => id2 !== void 0);
11538
11624
  const getOwnTrustLegalEntityId = (legalEntity) => {
@@ -12390,6 +12476,10 @@ const mapIndividualDocumentToApiDocument = async (data, entityId) => {
12390
12476
  return documents2.filter(Boolean);
12391
12477
  }
12392
12478
  };
12479
+ const mapExistingFile = (name) => ({
12480
+ name,
12481
+ existing: true
12482
+ });
12393
12483
  const mapApiIdDocumentToSchema = (idDocument2) => {
12394
12484
  const {
12395
12485
  hasBackPage
@@ -12400,14 +12490,10 @@ const mapApiIdDocumentToSchema = (idDocument2) => {
12400
12490
  const backPage2 = hasBackPage ? getPage(idDocument2, "back") : void 0;
12401
12491
  return {
12402
12492
  ...frontPage2 ? {
12403
- idFrontPage: [{
12404
- name: frontPage2.pageName
12405
- }]
12493
+ idFrontPage: [mapExistingFile(frontPage2.pageName)]
12406
12494
  } : {},
12407
12495
  ...backPage2 ? {
12408
- idBackPage: [{
12409
- name: backPage2.pageName
12410
- }]
12496
+ idBackPage: [mapExistingFile(backPage2.pageName)]
12411
12497
  } : {},
12412
12498
  idDocumentType: idDocument2.type
12413
12499
  };
@@ -12418,12 +12504,12 @@ const mapApiDocumentToIndividualDocuments = (entityId) => {
12418
12504
  const proofOfNationalId2 = getDocument$1(entityId, DocumentType.PROOF_OF_NATIONAL_ID_NUMBER) || null;
12419
12505
  return {
12420
12506
  idDocument: idDocument2 ? mapApiIdDocumentToSchema(idDocument2) : null,
12421
- proofOfResidence: proofOfResidence2 ? [{
12422
- name: getPageName(proofOfResidence2)
12423
- }] : null,
12424
- proofOfNationalId: proofOfNationalId2 ? [{
12425
- name: getPageName(proofOfNationalId2)
12426
- }] : null
12507
+ proofOfResidence: proofOfResidence2 ? {
12508
+ proofOfResidence: [mapExistingFile(getPageName(proofOfResidence2))]
12509
+ } : null,
12510
+ proofOfNationalId: proofOfNationalId2 ? {
12511
+ proofOfNationalId: [mapExistingFile(getPageName(proofOfNationalId2))]
12512
+ } : null
12427
12513
  };
12428
12514
  };
12429
12515
  const mapCompanyDocumentToApiDocument = async (data, entityId) => {
@@ -12460,14 +12546,10 @@ const mapApiDocumentToCompanyDocuments = (entityId) => {
12460
12546
  const taxDocument2 = getDocument$1(entityId, DocumentType.VAT_DOCUMENT) ?? getDocument$1(entityId, DocumentType.PROOF_OF_ORGANIZATION_TAX_INFO) ?? null;
12461
12547
  return {
12462
12548
  companyRegistrationDocument: registrationDocument2 ? {
12463
- registrationDocument: [{
12464
- name: getPageName(registrationDocument2)
12465
- }]
12549
+ registrationDocument: [mapExistingFile(getPageName(registrationDocument2))]
12466
12550
  } : null,
12467
12551
  companyTaxDocument: taxDocument2 ? {
12468
- taxDocument: [{
12469
- name: getPageName(taxDocument2)
12470
- }]
12552
+ taxDocument: [mapExistingFile(getPageName(taxDocument2))]
12471
12553
  } : null
12472
12554
  };
12473
12555
  };
@@ -12487,9 +12569,7 @@ const mapApiDocumentToTrustDocument = (entityId) => {
12487
12569
  const constitutionalDocument2 = getDocument$1(entityId, DocumentType.CONSTITUTIONAL_DOCUMENT) || null;
12488
12570
  return {
12489
12571
  trustConstitutionalDocument: constitutionalDocument2 ? {
12490
- constitutionalDocument: [{
12491
- name: getPageName(constitutionalDocument2)
12492
- }]
12572
+ constitutionalDocument: [mapExistingFile(getPageName(constitutionalDocument2))]
12493
12573
  } : null
12494
12574
  };
12495
12575
  };
@@ -12509,9 +12589,7 @@ const mapApiDocumentToSolePropDocuments = (entityId) => {
12509
12589
  const constitutionalDocument2 = getDocument$1(entityId, DocumentType.CONSTITUTIONAL_DOCUMENT) || null;
12510
12590
  return {
12511
12591
  solePropConstitutionalDocument: constitutionalDocument2 ? {
12512
- constitutionalDocument: [{
12513
- name: getPageName(constitutionalDocument2)
12514
- }]
12592
+ constitutionalDocument: [mapExistingFile(getPageName(constitutionalDocument2))]
12515
12593
  } : null
12516
12594
  };
12517
12595
  };
@@ -12538,9 +12616,7 @@ const mapPayoutDocumentsToApiDocuments = async (data, entityId) => {
12538
12616
  const mapApiDocumentToPayoutDocuments = (entityId) => {
12539
12617
  const bankStatement2 = getDocument$1(entityId, DocumentType.BANK_STATEMENT) || null;
12540
12618
  return {
12541
- bankStatementDocument: bankStatement2 ? [{
12542
- name: getPageName(bankStatement2)
12543
- }] : null,
12619
+ bankStatementDocument: bankStatement2 ? [mapExistingFile(getPageName(bankStatement2))] : null,
12544
12620
  description: bankStatement2.description
12545
12621
  };
12546
12622
  };
@@ -12633,27 +12709,21 @@ function IdDocumentManualUploadComponent(props) {
12633
12709
  const document2 = idDocumentType ? getDocument$1(props.legalEntityId, idDocumentType) : void 0;
12634
12710
  if (!document2) {
12635
12711
  setIdFrontPage({
12636
- idFrontPage: null
12712
+ idFrontPage: void 0
12637
12713
  });
12638
12714
  setIdBackPage({
12639
- idBackPage: null
12715
+ idBackPage: void 0
12640
12716
  });
12641
12717
  } else if (hasBackPage(idDocumentType)) {
12642
12718
  setIdFrontPage({
12643
- idFrontPage: [{
12644
- name: getPageName(document2, "front")
12645
- }]
12719
+ idFrontPage: [mapExistingFile(getPageName(document2, "front"))]
12646
12720
  });
12647
12721
  setIdBackPage({
12648
- idBackPage: [{
12649
- name: getPageName(document2, "back")
12650
- }]
12722
+ idBackPage: [mapExistingFile(getPageName(document2, "back"))]
12651
12723
  });
12652
12724
  } else {
12653
12725
  setIdFrontPage({
12654
- idFrontPage: [{
12655
- name: getPageName(document2)
12656
- }]
12726
+ idFrontPage: [mapExistingFile(getPageName(document2))]
12657
12727
  });
12658
12728
  }
12659
12729
  }
@@ -12755,7 +12825,7 @@ const useIdVerificationToken = ({
12755
12825
  lastName: lastName2,
12756
12826
  residencyCountry: residencyCountry2
12757
12827
  } = userDetails;
12758
- const [sdkToken, setSdkToken] = useState();
12828
+ const [sdkToken2, setSdkToken2] = useState();
12759
12829
  const [loadingStatus, setLoadingStatus] = useState();
12760
12830
  const hasAllUserDetails = userDetails && Object.values(userDetails).every(Boolean);
12761
12831
  useEffect(() => {
@@ -12781,9 +12851,9 @@ const useIdVerificationToken = ({
12781
12851
  // Do not include legalEntityId if we don't know yet. Eg.: decision-makers flow the associated legalEntityId.
12782
12852
  };
12783
12853
  const {
12784
- sdkToken: sdkToken2
12854
+ sdkToken: sdkToken22
12785
12855
  } = await handleGetIdVerificationToken("", data);
12786
- setSdkToken(sdkToken2);
12856
+ setSdkToken2(sdkToken22);
12787
12857
  } catch (e) {
12788
12858
  onIdVerificationError == null ? void 0 : onIdVerificationError(e);
12789
12859
  } finally {
@@ -12792,7 +12862,7 @@ const useIdVerificationToken = ({
12792
12862
  })().catch(console.error);
12793
12863
  }, [firstName2, lastName2, residencyCountry2, hasAllUserDetails]);
12794
12864
  return {
12795
- sdkToken,
12865
+ sdkToken: sdkToken2,
12796
12866
  loadingStatus
12797
12867
  };
12798
12868
  };
@@ -13336,7 +13406,7 @@ function IdVerificationComponent({
13336
13406
  i18n
13337
13407
  } = useI18nContext();
13338
13408
  const {
13339
- sdkToken,
13409
+ sdkToken: sdkToken2,
13340
13410
  loadingStatus
13341
13411
  } = useIdVerificationToken({
13342
13412
  userDetails,
@@ -13347,10 +13417,10 @@ function IdVerificationComponent({
13347
13417
  const onfidoSdk = useRef();
13348
13418
  useEffect(() => {
13349
13419
  (async () => {
13350
- if (!sdkToken)
13420
+ if (!sdkToken2)
13351
13421
  return;
13352
13422
  onfidoSdk.current = await initOnfido({
13353
- token: sdkToken,
13423
+ token: sdkToken2,
13354
13424
  i18n,
13355
13425
  onIdVerificationClose,
13356
13426
  onIdVerificationError,
@@ -13361,7 +13431,7 @@ function IdVerificationComponent({
13361
13431
  if (onfidoSdk.current)
13362
13432
  onfidoSdk.current.tearDown();
13363
13433
  };
13364
- }, [sdkToken]);
13434
+ }, [sdkToken2]);
13365
13435
  useEffect(() => {
13366
13436
  if (!onfidoSdk.current)
13367
13437
  return;
@@ -15652,10 +15722,18 @@ function PersonalDetailsComponent(props) {
15652
15722
  max: formatDateObj(/* @__PURE__ */ new Date())
15653
15723
  })
15654
15724
  }), formUtils.isRequiredField("residencyCountry") && jsx(CountryField, {
15655
- data: data.residencyCountry,
15656
- valid: valid == null ? void 0 : valid.residencyCountry,
15657
- error: formUtils.getErrorMessage("residencyCountry", errors, fieldProblems),
15658
- label: formUtils.getLabel("residencyCountry"),
15725
+ data: {
15726
+ country: data.residencyCountry
15727
+ },
15728
+ valid: {
15729
+ country: valid.residencyCountry
15730
+ },
15731
+ errors: {
15732
+ country: formUtils.getErrorMessage("residencyCountry", errors, fieldProblems)
15733
+ },
15734
+ labels: {
15735
+ country: formUtils.getLabel("residencyCountry")
15736
+ },
15659
15737
  readonly: !isAllowedEditPrefilledCountry && !isDecisionMakerTask,
15660
15738
  allowedCountries: [],
15661
15739
  classNameModifiers: ["country"],
@@ -15665,10 +15743,18 @@ function PersonalDetailsComponent(props) {
15665
15743
  country: data.residencyCountry,
15666
15744
  errors: externalErrors
15667
15745
  }), (data.residencyCountry === "SG" || data.residencyCountry === "HK") && formUtils.isRequiredField("nationality") && jsx(CountryField, {
15668
- data: data.nationality,
15669
- valid: valid == null ? void 0 : valid.nationality,
15670
- error: formUtils.getErrorMessage("nationality", errors, fieldProblems),
15671
- label: formUtils.getLabel("nationality"),
15746
+ data: {
15747
+ country: data.nationality
15748
+ },
15749
+ valid: {
15750
+ country: valid.nationality
15751
+ },
15752
+ errors: {
15753
+ country: formUtils.getErrorMessage("nationality", errors, fieldProblems)
15754
+ },
15755
+ labels: {
15756
+ country: formUtils.getLabel("nationality")
15757
+ },
15672
15758
  readonly: formUtils.isReadOnly("nationality"),
15673
15759
  classNameModifiers: ["nationality"],
15674
15760
  handleChangeFor: () => handleChangeFor("nationality", "input")
@@ -16162,6 +16248,29 @@ class AdyenKycSdkError extends Error {
16162
16248
  this.stack = stack.join("\n");
16163
16249
  }
16164
16250
  }
16251
+ let sdkToken;
16252
+ let fetchSdkToken;
16253
+ const logger$e = createLogger("Session");
16254
+ const setSdkToken = (token) => {
16255
+ sdkToken = token;
16256
+ };
16257
+ const setSdkTokenHandler = (handler) => {
16258
+ fetchSdkToken = handler;
16259
+ };
16260
+ const getSdkToken = () => sdkToken;
16261
+ const refreshSession = async () => {
16262
+ if (!fetchSdkToken) {
16263
+ throw Error("Not able to extend session, fetch handler not provided ");
16264
+ }
16265
+ try {
16266
+ const {
16267
+ token
16268
+ } = await fetchSdkToken();
16269
+ setSdkToken(token);
16270
+ } catch (e) {
16271
+ logger$e.error("Failed to fetch sdk token", e);
16272
+ }
16273
+ };
16165
16274
  const OpenBankingSDKStyles = "";
16166
16275
  const WIDGET_IFRAME_CLASS$1 = "adyen-open-banking-sdk-widget";
16167
16276
  const WIDGET_CONTAINER_CLASS$1 = `${WIDGET_IFRAME_CLASS$1}-container`;
@@ -16227,17 +16336,18 @@ const removeAnimationStartListener = (element, listener) => {
16227
16336
  element.removeEventListener("MSAnimationStart", listener, false);
16228
16337
  element.removeEventListener("webkitAnimationStart", listener, false);
16229
16338
  };
16230
- const logger$e = createLogger("Fetch");
16339
+ const logger$d = createLogger("Fetch");
16231
16340
  const getRequestObject = (options, data) => {
16232
16341
  const {
16233
16342
  headers = [],
16234
16343
  method = "GET",
16235
- sdkToken
16344
+ authentication
16236
16345
  } = options;
16237
16346
  let authHeaders;
16238
- if (options.sdkToken) {
16347
+ if (authentication === "jwt") {
16348
+ const sdkToken2 = getSdkToken();
16239
16349
  authHeaders = {
16240
- Authorization: `Bearer ${sdkToken}`,
16350
+ Authorization: `Bearer ${sdkToken2}`,
16241
16351
  Origin: window.location.origin
16242
16352
  };
16243
16353
  }
@@ -16273,10 +16383,10 @@ const logFetchError = (message, level) => {
16273
16383
  case "info":
16274
16384
  case "warn":
16275
16385
  case "error":
16276
- logger$e[level](message);
16386
+ logger$d[level](message);
16277
16387
  break;
16278
16388
  default:
16279
- logger$e.error(message);
16389
+ logger$d.error(message);
16280
16390
  }
16281
16391
  };
16282
16392
  const handleFetchResponse = async (response, responseType) => {
@@ -16292,6 +16402,7 @@ const handleFetchResponse = async (response, responseType) => {
16292
16402
  }
16293
16403
  };
16294
16404
  const isValidationErrorResponse = (response) => (response == null ? void 0 : response.status) === 422;
16405
+ const isSessionExpiredResponse = (response) => (response == null ? void 0 : response.status) === 401;
16295
16406
  const processValidationErrors$1 = async (response) => {
16296
16407
  const responseData = await response.json();
16297
16408
  throw new ValidationError(responseData.errorCode, responseData);
@@ -16313,6 +16424,7 @@ const http = async (options, data, responseType = "json") => {
16313
16424
  } = options;
16314
16425
  const request = getRequestObject(options, data);
16315
16426
  const url = getRequestUrl(loadingContext, path, clientKey);
16427
+ const needsAuthGuard = options.authentication === "jwt";
16316
16428
  let response;
16317
16429
  try {
16318
16430
  response = await fetch(url, request);
@@ -16335,6 +16447,10 @@ const http = async (options, data, responseType = "json") => {
16335
16447
  if (isValidationErrorResponse(response)) {
16336
16448
  return processValidationErrors$1(response);
16337
16449
  }
16450
+ if (needsAuthGuard && isSessionExpiredResponse(response)) {
16451
+ await refreshSession();
16452
+ return http(options, data, responseType);
16453
+ }
16338
16454
  logFetchError(errorMessage, errorLevel);
16339
16455
  throw new Error(errorMessage);
16340
16456
  };
@@ -16359,7 +16475,7 @@ const RELEVANT_MESSAGE_TYPES = ["account_verification_report_id", "error"];
16359
16475
  const TERMINAL_DATA_PROPS = ["accounts", "error", "reference"];
16360
16476
  const MOUNT_TIMEOUT = 10 * 1e3;
16361
16477
  const TINK_VENDOR = "Tink";
16362
- const logger$d = createLogger("iframeWidget");
16478
+ const logger$c = createLogger("iframeWidget");
16363
16479
  const isObjectData = (data) => typeof data === "object" && !Array.isArray(data) && data !== null;
16364
16480
  const isTerminalMessageData = (data) => Object.entries(data).some(([prop]) => TERMINAL_DATA_PROPS.includes(prop));
16365
16481
  const parseMessageJson = (message) => {
@@ -16378,7 +16494,7 @@ const callbackErrorHandler = async (response) => {
16378
16494
  try {
16379
16495
  await response;
16380
16496
  } catch (ex) {
16381
- logger$d.error(ex);
16497
+ logger$c.error(ex);
16382
16498
  }
16383
16499
  return {
16384
16500
  error: "UNKNOWN_ERROR",
@@ -16387,7 +16503,7 @@ const callbackErrorHandler = async (response) => {
16387
16503
  };
16388
16504
  let activeWidget;
16389
16505
  class IFrameWidget {
16390
- constructor(iframeElement, url, vendor, sdkToken) {
16506
+ constructor(iframeElement, url, vendor, sdkToken2) {
16391
16507
  this.mountInProgress = false;
16392
16508
  this.waitForResponse = async () => new Promise((resolve, reject) => {
16393
16509
  this.listener = async (message) => {
@@ -16410,7 +16526,7 @@ class IFrameWidget {
16410
16526
  this.iframeElement = iframeElement;
16411
16527
  this.iframeWindow = iframeElement.contentWindow;
16412
16528
  this.vendor = vendor;
16413
- this.sdkToken = sdkToken;
16529
+ this.sdkToken = sdkToken2;
16414
16530
  }
16415
16531
  removeMessageEventListener() {
16416
16532
  if (!this.listener)
@@ -16484,7 +16600,7 @@ class IFrameWidget {
16484
16600
  message = responseData.errorMessage;
16485
16601
  }
16486
16602
  } catch (ex) {
16487
- logger$d.error(ex);
16603
+ logger$c.error(ex);
16488
16604
  }
16489
16605
  throw new AdyenKycSdkError(reason, jsonData.error);
16490
16606
  }
@@ -16570,7 +16686,7 @@ function BankVerificationWidget({
16570
16686
  const {
16571
16687
  isEmbeddedDropin
16572
16688
  } = context;
16573
- const sdkToken = isEmbeddedDropin ? context.sdkToken : void 0;
16689
+ const sdkToken2 = isEmbeddedDropin ? getSdkToken() : void 0;
16574
16690
  useEffect(
16575
16691
  () => {
16576
16692
  const container = widgetContainerRef.current;
@@ -16613,7 +16729,7 @@ function BankVerificationWidget({
16613
16729
  requestAnimationFrame(async () => {
16614
16730
  var _a, _b;
16615
16731
  try {
16616
- iFrameWidget = new IFrameWidget(iFrame, url, vendor, sdkToken);
16732
+ iFrameWidget = new IFrameWidget(iFrame, url, vendor, sdkToken2);
16617
16733
  const result = await iFrameWidget.mountAndWaitForResponse();
16618
16734
  widgetCallback({
16619
16735
  action: "verification_success",
@@ -16670,7 +16786,7 @@ function BankVerificationWidget({
16670
16786
  ref: widgetContainerRef
16671
16787
  });
16672
16788
  }
16673
- const logger$c = createLogger("BankVerification");
16789
+ const logger$b = createLogger("BankVerification");
16674
16790
  const accountVerificationFields = ["verifiedAccountHolder", "verifiedBankCountry", "verifiedBankName", "verifiedCurrencyCode", "verifiedBankAccountNumber"];
16675
16791
  const InstantVerificationErrorContext = createContext(null);
16676
16792
  const useInstantVerificationErrorNotification = (notificationVisibilityDuration) => {
@@ -16704,7 +16820,7 @@ const usePreferredVendorForCountry = (country2, getBankVerificationVendors) => {
16704
16820
  const preferredVendor2 = vendors[0];
16705
16821
  setPreferredVendor(preferredVendor2.name ? preferredVendor2 : null);
16706
16822
  };
16707
- getPreferredVendor().catch(logger$c.error);
16823
+ getPreferredVendor().catch(logger$b.error);
16708
16824
  }, [country2, getBankVerificationVendors]);
16709
16825
  return preferredVendor;
16710
16826
  };
@@ -18278,15 +18394,25 @@ function PayoutVerificationMethod(props) {
18278
18394
  }
18279
18395
  })]
18280
18396
  }), jsx(CountryField, {
18281
- data: data.bankCountry,
18282
- valid: valid == null ? void 0 : valid.bankCountry,
18283
- error: formUtils.getErrorMessage("bankCountry", errors, fieldProblems),
18284
- label: formUtils.getLabel("bankCountry", "bankAccountCountry"),
18397
+ data: {
18398
+ country: data.bankCountry
18399
+ },
18400
+ valid: {
18401
+ country: valid == null ? void 0 : valid.bankCountry
18402
+ },
18403
+ errors: {
18404
+ country: formUtils.getErrorMessage("bankCountry", errors, fieldProblems)
18405
+ },
18406
+ labels: {
18407
+ country: formUtils.getLabel("bankCountry", "bankAccountCountry")
18408
+ },
18285
18409
  readonly: !intraRegionCrossBorderPayoutsAllowed || allowedBankCountries.length === 1,
18286
18410
  allowedCountries: allowedBankCountries,
18287
18411
  classNameModifiers: ["country"],
18288
18412
  handleChangeFor: () => handleChangeFor("bankCountry", "input"),
18289
- helperText: intraRegionCrossBorderPayoutsAllowed ? void 0 : i18n.get(props.legalEntityType === LegalEntityType.INDIVIDUAL ? "youCanOnlyUseABankAccountInTheCountryWhereYouLive" : "youCanOnlyUseABankAccountInTheCountryWhereYourCompanyIsRegistered")
18413
+ helperText: {
18414
+ country: intraRegionCrossBorderPayoutsAllowed ? void 0 : i18n.get(props.legalEntityType === LegalEntityType.INDIVIDUAL ? "youCanOnlyUseABankAccountInTheCountryWhereYouLive" : "youCanOnlyUseABankAccountInTheCountryWhereYourCompanyIsRegistered")
18415
+ }
18290
18416
  }), jsx(Field, {
18291
18417
  name: "verificationMethods",
18292
18418
  label: formUtils.getLabel("payoutVerificationMethod", "verificationMethod"),
@@ -18783,14 +18909,16 @@ function TrustRegistrationDetailsComponent(props) {
18783
18909
  id: "ariaErrorField"
18784
18910
  }), jsx(ContextHelper, {
18785
18911
  content: i18n.get("makeSureToHaveYourTrustDeed")
18786
- }), formUtils.isRequiredField(COUNTRY_FIELD) && jsx(CountryField, {
18787
- data: country2,
18788
- valid: valid == null ? void 0 : valid.country,
18789
- error: formUtils.getErrorMessage(COUNTRY_FIELD, errors, fieldProblems),
18790
- label: formUtils.getLabel(COUNTRY_FIELD, "countryOfEstablishment"),
18791
- readonly: formUtils.isReadOnly(COUNTRY_FIELD),
18912
+ }), formUtils.isRequiredField("country") && jsx(CountryField, {
18913
+ data: formUtils.getFieldData(data, COUNTRY_FIELD),
18914
+ valid: formUtils.getFieldValid(valid, COUNTRY_FIELD),
18915
+ errors: formUtils.getFieldErrors(errors, fieldProblems, COUNTRY_FIELD),
18916
+ labels: formUtils.getFieldLabels(COUNTRY_FIELD, {
18917
+ country: "countryOfEstablishment"
18918
+ }),
18919
+ readonly: formUtils.isReadOnly("country"),
18792
18920
  allowedCountries: ALLOWED_TRUST_COUNTRIES,
18793
- classNameModifiers: [COUNTRY_FIELD],
18921
+ classNameModifiers: ["country"],
18794
18922
  handleChangeFor: () => (e) => {
18795
18923
  handleChangeFor("country", "input")(e);
18796
18924
  if (onCountryChange)
@@ -19891,7 +20019,7 @@ const defaultPayoutAccountFormat = {
19891
20019
  [CountryCodes.Sweden]: "local",
19892
20020
  [CountryCodes.UnitedKingdom]: "local"
19893
20021
  };
19894
- const logger$b = createLogger("useScenarioConfiguration");
20022
+ const logger$a = createLogger("useScenarioConfiguration");
19895
20023
  const useScenarioConfiguration = ({
19896
20024
  getConfigurationData,
19897
20025
  getPayoutAccountFormatData,
@@ -19913,12 +20041,12 @@ const useScenarioConfiguration = ({
19913
20041
  const response = await getConfigurationData();
19914
20042
  setConfigurationResponse(response);
19915
20043
  } catch (err) {
19916
- logger$b.warn("WARNING: Configuration request failed - error:", err);
20044
+ logger$a.warn("WARNING: Configuration request failed - error:", err);
19917
20045
  } finally {
19918
20046
  setLoadingStatus("success");
19919
20047
  }
19920
20048
  };
19921
- makeConfigCallAndSave().catch(logger$b.error);
20049
+ makeConfigCallAndSave().catch(logger$a.error);
19922
20050
  }, [getConfigurationData, setLoadingStatus]);
19923
20051
  useEffect(() => {
19924
20052
  setLoadingStatus("loading");
@@ -19934,12 +20062,12 @@ const useScenarioConfiguration = ({
19934
20062
  const defaultAccountFormat = defaultPayoutAccountFormat[country2] ?? allowedBankAccountFormats[0];
19935
20063
  setAccountFormat(defaultAccountFormat);
19936
20064
  } catch (err) {
19937
- logger$b.warn("WARNING: Payout format request failed - error:", err);
20065
+ logger$a.warn("WARNING: Payout format request failed - error:", err);
19938
20066
  } finally {
19939
20067
  setLoadingStatus("success");
19940
20068
  }
19941
20069
  };
19942
- makePayoutFormatCallAndSave().catch(logger$b.error);
20070
+ makePayoutFormatCallAndSave().catch(logger$a.error);
19943
20071
  }, [country2, setAccountFormat, getPayoutAccountFormatData, setLoadingStatus]);
19944
20072
  const {
19945
20073
  fieldConfigurations,
@@ -20106,7 +20234,7 @@ const countryConfig$1 = {
20106
20234
  placeholder: "SSNFormatUS"
20107
20235
  },
20108
20236
  idNumberExempt: {
20109
- label: "uploadDocumentForSsn"
20237
+ label: "identityNumberExempt__US"
20110
20238
  }
20111
20239
  },
20112
20240
  CA: {
@@ -20115,7 +20243,7 @@ const countryConfig$1 = {
20115
20243
  placeholder: "SINFormatCA"
20116
20244
  },
20117
20245
  idNumberExempt: {
20118
- label: "uploadDocumentForSsn"
20246
+ label: "identityNumberExempt__CA"
20119
20247
  }
20120
20248
  },
20121
20249
  IT: {
@@ -20595,7 +20723,7 @@ var ToastType = /* @__PURE__ */ ((ToastType2) => {
20595
20723
  return ToastType2;
20596
20724
  })(ToastType || {});
20597
20725
  const FormComposer = "";
20598
- const logger$a = createLogger("FormRouterContextProvider");
20726
+ const logger$9 = createLogger("FormRouterContextProvider");
20599
20727
  function FormRouterContextProvider({
20600
20728
  children,
20601
20729
  forms,
@@ -20615,7 +20743,7 @@ function FormRouterContextProvider({
20615
20743
  if (formIndex > -1) {
20616
20744
  setFormIndex(formIndex);
20617
20745
  } else {
20618
- logger$a.error("No form was found to have that field so form navigation failed.");
20746
+ logger$9.error("No form was found to have that field so form navigation failed.");
20619
20747
  }
20620
20748
  }
20621
20749
  }), [forms, handleGetIdVerificationToken, setFormIndex]);
@@ -20859,16 +20987,18 @@ const canSubmit = (data) => mandatoryApiFields.ORGANIZATION.every((detail) => {
20859
20987
  });
20860
20988
  const isDocumentsRequired = (forms) => forms.some((form) => [companyForms.companyRegistrationDocument.formId, companyForms.companyTaxDocument.formId].includes(form.formId));
20861
20989
  const formatFileSummaryData = (companyRegistrationDocument2, companyTaxDocument) => {
20862
- var _a, _b, _c, _d;
20990
+ var _a, _b;
20991
+ const registrationDocument2 = (_a = companyRegistrationDocument2 == null ? void 0 : companyRegistrationDocument2.registrationDocument) == null ? void 0 : _a[0];
20992
+ const taxDocument2 = (_b = companyTaxDocument == null ? void 0 : companyTaxDocument.taxDocument) == null ? void 0 : _b[0];
20863
20993
  return {
20864
- ...(companyRegistrationDocument2 == null ? void 0 : companyRegistrationDocument2.registrationDocument) && {
20994
+ ...registrationDocument2 && {
20865
20995
  companyRegistrationDocument: {
20866
- fileName: (_b = (_a = companyRegistrationDocument2.registrationDocument) == null ? void 0 : _a[0]) == null ? void 0 : _b.name
20996
+ fileName: registrationDocument2.name
20867
20997
  }
20868
20998
  },
20869
- ...(companyTaxDocument == null ? void 0 : companyTaxDocument.taxDocument) && {
20999
+ ...taxDocument2 && {
20870
21000
  companyTaxDocument: {
20871
- fileName: (_d = (_c = companyTaxDocument.taxDocument) == null ? void 0 : _c[0]) == null ? void 0 : _d.name
21001
+ fileName: taxDocument2.name
20872
21002
  }
20873
21003
  }
20874
21004
  };
@@ -21212,7 +21342,7 @@ function CompanyDropinComponent({
21212
21342
  })
21213
21343
  });
21214
21344
  }
21215
- const logger$9 = createLogger("useLocalStorage");
21345
+ const logger$8 = createLogger("useLocalStorage");
21216
21346
  function useLocalStorage(key, defaultValue, options) {
21217
21347
  const {
21218
21348
  serializer,
@@ -21233,7 +21363,7 @@ function useLocalStorage(key, defaultValue, options) {
21233
21363
  const res = rawValueRef.current ? parser(rawValueRef.current) : defaultValue;
21234
21364
  return res;
21235
21365
  } catch (err) {
21236
- logger$9.error(err);
21366
+ logger$8.error(err);
21237
21367
  return defaultValue;
21238
21368
  }
21239
21369
  });
@@ -21265,7 +21395,7 @@ function useLocalStorage(key, defaultValue, options) {
21265
21395
  try {
21266
21396
  updateLocalStorage();
21267
21397
  } catch (err) {
21268
- logger$9.error(err);
21398
+ logger$8.error(err);
21269
21399
  }
21270
21400
  }, [value]);
21271
21401
  useEffect(() => {
@@ -21280,7 +21410,7 @@ function useLocalStorage(key, defaultValue, options) {
21280
21410
  setValue(event.newValue ? parser(event.newValue) : void 0);
21281
21411
  }
21282
21412
  } catch (err) {
21283
- logger$9.error(err);
21413
+ logger$8.error(err);
21284
21414
  }
21285
21415
  };
21286
21416
  if (typeof window === "undefined")
@@ -21316,7 +21446,7 @@ const useShouldShowIntro = (legalEntity) => {
21316
21446
  } = useHasSeenIntro(legalEntity.id);
21317
21447
  return canSeeIntro && !hasSeenIntro;
21318
21448
  };
21319
- const logger$8 = createLogger("useExemptSettlor");
21449
+ const logger$7 = createLogger("useExemptSettlor");
21320
21450
  const useExemptSettlor = ({
21321
21451
  trust,
21322
21452
  handleGetLegalEntity
@@ -21328,7 +21458,7 @@ const useExemptSettlor = ({
21328
21458
  setExemptSettlor(exemptSettlorLE);
21329
21459
  }, [handleGetLegalEntity]);
21330
21460
  useEffect(() => {
21331
- updateExemptSettlor(trust).catch(logger$8.error);
21461
+ updateExemptSettlor(trust).catch(logger$7.error);
21332
21462
  }, [trust, updateExemptSettlor]);
21333
21463
  return exemptSettlor;
21334
21464
  };
@@ -21962,14 +22092,16 @@ const ActionsMenu = ({
21962
22092
  const Remove = ({
21963
22093
  onRemove,
21964
22094
  onRemoveStatusChange,
21965
- isRemoveDisabled,
21966
- handleIsRemoveDisabled
22095
+ isRemoveDisabled = false,
22096
+ handleIsRemoveDisabled,
22097
+ label
21967
22098
  }) => {
21968
22099
  const {
21969
22100
  i18n
21970
22101
  } = useI18nContext();
21971
22102
  const [undoTimer, setUndoTimer] = useState(5);
21972
22103
  const [isRemoving, setIsRemoving] = useState(false);
22104
+ const hasLabel = Boolean(label);
21973
22105
  useEffect(() => {
21974
22106
  let undoInterval;
21975
22107
  if (isRemoving && undoTimer > 0) {
@@ -21986,27 +22118,30 @@ const Remove = ({
21986
22118
  event.preventDefault();
21987
22119
  if (!isRemoving) {
21988
22120
  setIsRemoving(true);
21989
- onRemoveStatusChange(true);
21990
- handleIsRemoveDisabled(true);
22121
+ onRemoveStatusChange == null ? void 0 : onRemoveStatusChange(true);
22122
+ handleIsRemoveDisabled == null ? void 0 : handleIsRemoveDisabled(true);
21991
22123
  } else {
21992
22124
  setUndoTimer(5);
21993
22125
  setIsRemoving(false);
21994
- onRemoveStatusChange(false);
21995
- handleIsRemoveDisabled(false);
22126
+ onRemoveStatusChange == null ? void 0 : onRemoveStatusChange(false);
22127
+ handleIsRemoveDisabled == null ? void 0 : handleIsRemoveDisabled(false);
21996
22128
  }
21997
22129
  };
21998
22130
  useEffect(() => {
21999
22131
  if (undoTimer === 0 && isRemoving) {
22000
- setIsRemoving(false);
22001
- onRemoveStatusChange(false);
22002
- handleIsRemoveDisabled(false);
22003
- onRemove();
22132
+ (async () => {
22133
+ setIsRemoving(false);
22134
+ await onRemove();
22135
+ onRemoveStatusChange == null ? void 0 : onRemoveStatusChange(false);
22136
+ handleIsRemoveDisabled == null ? void 0 : handleIsRemoveDisabled(false);
22137
+ })();
22004
22138
  }
22005
22139
  }, [undoTimer, isRemoving, onRemoveStatusChange, handleIsRemoveDisabled, onRemove]);
22006
22140
  return isRemoving ? jsx(Button, {
22007
- showAsLink: isRemoving,
22141
+ showAsLink: !hasLabel && isRemoving,
22008
22142
  type: "button",
22009
- ghost: true,
22143
+ ghost: !hasLabel,
22144
+ secondary: hasLabel,
22010
22145
  onClick: onClickHandler,
22011
22146
  onKeyDown: handleKeys(["Enter"], noop),
22012
22147
  label: i18n.get("undoWithTimer", {
@@ -22016,11 +22151,14 @@ const Remove = ({
22016
22151
  })
22017
22152
  }) : jsx(Button, {
22018
22153
  type: "button",
22019
- icon: "bin",
22020
- ghost: true,
22154
+ icon: !hasLabel ? "bin" : "",
22155
+ ghost: !hasLabel,
22156
+ secondary: hasLabel,
22157
+ negative: hasLabel,
22021
22158
  onClick: onClickHandler,
22022
22159
  onKeyDown: handleKeys(["Enter"], noop),
22023
- disabled: isRemoveDisabled
22160
+ disabled: isRemoveDisabled,
22161
+ label: label ? i18n.get(label) : ""
22024
22162
  });
22025
22163
  };
22026
22164
  const EntityAssociation = ({
@@ -22410,11 +22548,11 @@ function LegalEntityTypeSwitcher({
22410
22548
  children: [jsx("h2", {
22411
22549
  className: "adyen-kyc-form-header__heading",
22412
22550
  "data-testid": LegalEntityType.ORGANIZATION,
22413
- children: i18n.get("continueAsCompany")
22551
+ children: i18n.get("areYouACompany")
22414
22552
  }), jsx("span", {
22415
- children: i18n.get("indicatedPayoutToCompany")
22553
+ children: i18n.get("singingUpAsIndividualButLooksLikeYouAreACompany")
22416
22554
  }), jsx("p", {
22417
- children: i18n.get("continueSigningUpAsCompany")
22555
+ children: i18n.get("wouldYouLikeToSignUpAsCompanyInstead")
22418
22556
  })]
22419
22557
  });
22420
22558
  case LegalEntityType.INDIVIDUAL:
@@ -22422,11 +22560,11 @@ function LegalEntityTypeSwitcher({
22422
22560
  children: [jsx("h2", {
22423
22561
  className: "adyen-kyc-form-header__heading",
22424
22562
  "data-testid": LegalEntityType.INDIVIDUAL,
22425
- children: i18n.get("continueAsIndividual")
22563
+ children: i18n.get("areYouAnIndividual")
22426
22564
  }), jsx("span", {
22427
- children: i18n.get("indicatedPayoutToPersonalAccount")
22565
+ children: i18n.get("singingUpAsCompanyButLooksLikeYouAreAnIndividual")
22428
22566
  }), jsx("p", {
22429
- children: i18n.get("continueSigningUpAsIndividual")
22567
+ children: i18n.get("wouldYouLikeToSignUpAsIndividualInstead")
22430
22568
  })]
22431
22569
  });
22432
22570
  default:
@@ -23671,42 +23809,50 @@ function IndividualDropinComponent({
23671
23809
  };
23672
23810
  const datasetUtils = datasetUtilities(i18n.locale);
23673
23811
  const formatIdDocument = (idDocument2) => {
23674
- var _a2, _b2, _c2, _d2, _e, _f;
23675
- if (idDocument2) {
23676
- const documentType2 = hasInstantIdVerification({
23677
- idDocument: idDocument2
23678
- }) ? onfidoDocumentTypeMapping.find((document2) => idDocument2.instantIdVerificationData.document_front.type === document2.id) : idDocumentTypeOptions.find(({
23679
- id: id2
23680
- }) => (idDocument2 == null ? void 0 : idDocument2.idDocumentType) === id2);
23681
- return {
23682
- documentType: i18n.get(documentType2 == null ? void 0 : documentType2.name),
23683
- ...(documentType2 == null ? void 0 : documentType2.hasBackPage) ? {
23684
- frontPage: (_b2 = (_a2 = idDocument2 == null ? void 0 : idDocument2.idFrontPage) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.name,
23685
- backPage: (_d2 = (_c2 = idDocument2 == null ? void 0 : idDocument2.idBackPage) == null ? void 0 : _c2[0]) == null ? void 0 : _d2.name
23686
- } : {
23687
- fileName: (_f = (_e = idDocument2 == null ? void 0 : idDocument2.idFrontPage) == null ? void 0 : _e[0]) == null ? void 0 : _f.name
23688
- }
23689
- };
23690
- }
23812
+ var _a2, _b2;
23813
+ if (!idDocument2)
23814
+ return void 0;
23815
+ const documentType2 = hasInstantIdVerification({
23816
+ idDocument: idDocument2
23817
+ }) ? onfidoDocumentTypeMapping.find((document2) => idDocument2.instantIdVerificationData.document_front.type === document2.id) : idDocumentTypeOptions.find(({
23818
+ id: id2
23819
+ }) => idDocument2.idDocumentType === id2);
23820
+ if (!documentType2)
23821
+ return void 0;
23822
+ const frontPage2 = (_a2 = idDocument2.idFrontPage) == null ? void 0 : _a2[0];
23823
+ const backPage2 = (_b2 = idDocument2.idBackPage) == null ? void 0 : _b2[0];
23824
+ if (!frontPage2)
23825
+ return void 0;
23826
+ return {
23827
+ documentType: i18n.get(documentType2.name),
23828
+ ...backPage2 && documentType2.hasBackPage ? {
23829
+ frontPage: frontPage2.name,
23830
+ backPage: backPage2.name
23831
+ } : {
23832
+ fileName: frontPage2.name
23833
+ }
23834
+ };
23691
23835
  };
23692
23836
  const formatFileSummaryData2 = ({
23693
23837
  idDocument: idDocument2,
23694
23838
  proofOfNationalId: proofOfNationalId2,
23695
23839
  proofOfResidence: proofOfResidence2
23696
23840
  }) => {
23697
- var _a2, _b2, _c2, _d2;
23841
+ var _a2, _b2;
23842
+ const proofOfNationalIdFile = (_a2 = proofOfNationalId2 == null ? void 0 : proofOfNationalId2.proofOfNationalId) == null ? void 0 : _a2[0];
23843
+ const proofOfResidenceFile = (_b2 = proofOfResidence2 == null ? void 0 : proofOfResidence2.proofOfResidence) == null ? void 0 : _b2[0];
23698
23844
  return {
23699
23845
  ...((idDocument2 == null ? void 0 : idDocument2.idDocumentType) || (idDocument2 == null ? void 0 : idDocument2.instantIdVerificationData)) && {
23700
23846
  idDocument: formatIdDocument(idDocument2)
23701
23847
  },
23702
- ...(proofOfNationalId2 == null ? void 0 : proofOfNationalId2.proofOfNationalId) && {
23848
+ ...proofOfNationalIdFile && {
23703
23849
  proofOfNationalId: {
23704
- fileName: (_b2 = (_a2 = proofOfNationalId2.proofOfNationalId) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.name
23850
+ fileName: proofOfNationalIdFile.name
23705
23851
  }
23706
23852
  },
23707
- ...(proofOfResidence2 == null ? void 0 : proofOfResidence2.proofOfResidence) && {
23853
+ ...proofOfResidenceFile && {
23708
23854
  proofOfResidence: {
23709
- fileName: (_d2 = (_c2 = proofOfResidence2.proofOfResidence) == null ? void 0 : _c2[0]) == null ? void 0 : _d2.name
23855
+ fileName: proofOfResidenceFile.name
23710
23856
  }
23711
23857
  }
23712
23858
  };
@@ -24197,11 +24343,12 @@ function PayoutDetailsDropinComponent({
24197
24343
  };
24198
24344
  const isDocumentsRequired2 = (forms2) => forms2.some((form) => form.formId === payoutDetailsSteps.payoutAccountDocuments.formId);
24199
24345
  const formatFileSummaryData2 = (documents22) => {
24200
- var _a2, _b2;
24346
+ var _a2;
24347
+ const bankStatementDocument2 = (_a2 = documents22 == null ? void 0 : documents22.bankStatementDocument) == null ? void 0 : _a2[0];
24201
24348
  return {
24202
- ...(documents22 == null ? void 0 : documents22.bankStatementDocument) && {
24349
+ ...bankStatementDocument2 && {
24203
24350
  bankStatementDocument: {
24204
- fileName: (_b2 = (_a2 = documents22.bankStatementDocument) == null ? void 0 : _a2[0]) == null ? void 0 : _b2.name
24351
+ fileName: bankStatementDocument2.name
24205
24352
  }
24206
24353
  }
24207
24354
  };
@@ -25274,7 +25421,7 @@ const serviceAgreementValidationRules = {
25274
25421
  errorMessage: "fieldIsRequired"
25275
25422
  }
25276
25423
  };
25277
- const logger$7 = createLogger("useServiceAgreement");
25424
+ const logger$6 = createLogger("useServiceAgreement");
25278
25425
  const FALLBACK_LANGUAGE_CODE = "en";
25279
25426
  const useServiceAgreement = ({
25280
25427
  handleGetServiceAgreement,
@@ -25303,7 +25450,7 @@ const useServiceAgreement = ({
25303
25450
  language: agreementLanguage
25304
25451
  });
25305
25452
  if (!document2) {
25306
- logger$7.log('"document" field was missing in response');
25453
+ logger$6.log('"document" field was missing in response');
25307
25454
  return;
25308
25455
  }
25309
25456
  const contract = JSON.parse(decodeURIComponent(escape(window.atob(document2))));
@@ -25321,7 +25468,7 @@ const useServiceAgreement = ({
25321
25468
  throw err;
25322
25469
  }
25323
25470
  };
25324
- requestServiceAgreement().catch(logger$7.error);
25471
+ requestServiceAgreement().catch(logger$6.error);
25325
25472
  }, [handleGetServiceAgreement, handleServiceAgreementIsNotAvailableInThatLanguage, agreementLanguage, legalEntityId, serviceAgreementType]);
25326
25473
  return {
25327
25474
  loading: loading2,
@@ -26403,11 +26550,12 @@ function SolePropDropinComponent({
26403
26550
  return summaryData;
26404
26551
  };
26405
26552
  const formatFileSummaryData2 = (solePropConstitutionalDocument) => {
26406
- var _a2, _b;
26553
+ var _a2;
26554
+ const constitutionalDocument2 = (_a2 = solePropConstitutionalDocument == null ? void 0 : solePropConstitutionalDocument.constitutionalDocument) == null ? void 0 : _a2[0];
26407
26555
  return {
26408
- ...(solePropConstitutionalDocument == null ? void 0 : solePropConstitutionalDocument.constitutionalDocument) && {
26556
+ ...constitutionalDocument2 && {
26409
26557
  solePropConstitutionalDocument: {
26410
- fileName: (_b = (_a2 = solePropConstitutionalDocument.constitutionalDocument) == null ? void 0 : _a2[0]) == null ? void 0 : _b.name
26558
+ fileName: constitutionalDocument2.name
26411
26559
  }
26412
26560
  }
26413
26561
  };
@@ -26617,11 +26765,12 @@ function TrustDropinComponent(props) {
26617
26765
  return summaryData;
26618
26766
  };
26619
26767
  const formatFileSummaryData2 = (trustConstitutionalDocument) => {
26620
- var _a, _b;
26768
+ var _a;
26769
+ const constitutionalDocument2 = (_a = trustConstitutionalDocument == null ? void 0 : trustConstitutionalDocument.constitutionalDocument) == null ? void 0 : _a[0];
26621
26770
  return {
26622
- ...(trustConstitutionalDocument == null ? void 0 : trustConstitutionalDocument.constitutionalDocument) && {
26771
+ ...constitutionalDocument2 && {
26623
26772
  trustConstitutionalDocument: {
26624
- fileName: (_b = (_a = trustConstitutionalDocument.constitutionalDocument) == null ? void 0 : _a[0]) == null ? void 0 : _b.name
26773
+ fileName: constitutionalDocument2.name
26625
26774
  }
26626
26775
  }
26627
26776
  };
@@ -26657,7 +26806,7 @@ function TrustDropinComponent(props) {
26657
26806
  }
26658
26807
  const PAGES_WITH_STATUS = [TaskTypes.DECISION_MAKER_OVERVIEW, TaskTypes.TASKS_OVERVIEW];
26659
26808
  const POLLING_INTERVAL = 3e3;
26660
- const logger$6 = createLogger("DropinComposerComponent");
26809
+ const logger$5 = createLogger("DropinComposerComponent");
26661
26810
  function DropinComposerComponent({
26662
26811
  capabilities,
26663
26812
  legalEntityResponse,
@@ -26734,7 +26883,7 @@ function DropinComposerComponent({
26734
26883
  setPciStatus(response);
26735
26884
  return response;
26736
26885
  } catch (e) {
26737
- logger$6.warn(i18n.get("failedToGetPciStatus"));
26886
+ logger$5.warn(i18n.get("failedToGetPciStatus"));
26738
26887
  }
26739
26888
  }
26740
26889
  return void 0;
@@ -26763,7 +26912,7 @@ function DropinComposerComponent({
26763
26912
  useEffect(() => {
26764
26913
  if (!tasks.includes(TaskTypes.PCI_DSS))
26765
26914
  return;
26766
- getPciTemplate().catch(logger$6.error);
26915
+ getPciTemplate().catch(logger$5.error);
26767
26916
  }, [getPciTemplate, tasks]);
26768
26917
  const getServiceAgreementAcceptanceInfos = async () => {
26769
26918
  if (legalEntity.id && (args == null ? void 0 : args.handleGetServiceAgreementAcceptanceInfos)) {
@@ -26771,7 +26920,7 @@ function DropinComposerComponent({
26771
26920
  const response = await args.handleGetServiceAgreementAcceptanceInfos(legalEntity.id);
26772
26921
  setServiceAgreementAcceptanceInfos(response.data);
26773
26922
  } catch (e) {
26774
- logger$6.warn(i18n.get("failedToGetServiceAgreementStatus"));
26923
+ logger$5.warn(i18n.get("failedToGetServiceAgreementStatus"));
26775
26924
  }
26776
26925
  }
26777
26926
  };
@@ -26781,7 +26930,7 @@ function DropinComposerComponent({
26781
26930
  const response = await args.handleGetServiceAgreementStatus(legalEntity.id);
26782
26931
  setServiceAgreementTypes(response.termsOfServiceTypes);
26783
26932
  } catch (e) {
26784
- logger$6.warn(i18n.get("failedToGetServiceAgreementStatus"));
26933
+ logger$5.warn(i18n.get("failedToGetServiceAgreementStatus"));
26785
26934
  }
26786
26935
  }
26787
26936
  };
@@ -26820,7 +26969,7 @@ function DropinComposerComponent({
26820
26969
  setCapabilityProblems(getCapabilityProblems(response));
26821
26970
  return response;
26822
26971
  } catch (e) {
26823
- logger$6.warn(i18n.get("failedToFetchLegalEntityDetails"));
26972
+ logger$5.warn(i18n.get("failedToFetchLegalEntityDetails"));
26824
26973
  }
26825
26974
  }
26826
26975
  return void 0;
@@ -26832,7 +26981,7 @@ function DropinComposerComponent({
26832
26981
  setTrust(response);
26833
26982
  return response;
26834
26983
  } catch (e) {
26835
- logger$6.warn(i18n.get("failedToFetchTrustDetails"));
26984
+ logger$5.warn(i18n.get("failedToFetchTrustDetails"));
26836
26985
  }
26837
26986
  }
26838
26987
  return void 0;
@@ -26882,7 +27031,7 @@ function DropinComposerComponent({
26882
27031
  label: i18n.get("successFullyRemovedTrustMember")
26883
27032
  });
26884
27033
  } catch (err) {
26885
- logger$6.error(`Failed to delete trust member`, err);
27034
+ logger$5.error(`Failed to delete trust member`, err);
26886
27035
  showToast({
26887
27036
  type: ToastType.ERROR,
26888
27037
  label: i18n.get("failedToRemoveTrustMember")
@@ -26934,7 +27083,7 @@ function DropinComposerComponent({
26934
27083
  break;
26935
27084
  case "rootTrustee":
26936
27085
  default:
26937
- logger$6.warn(`Updating trust member type "${trustMember.trustMemberType}" is not implemented.`);
27086
+ logger$5.warn(`Updating trust member type "${trustMember.trustMemberType}" is not implemented.`);
26938
27087
  }
26939
27088
  showToast({
26940
27089
  label: i18n.get("successfullyUpdatedDetails"),
@@ -26942,7 +27091,7 @@ function DropinComposerComponent({
26942
27091
  });
26943
27092
  await refreshTrustAndRunOnSubmit(trust, 1);
26944
27093
  } catch (err) {
26945
- logger$6.error(err);
27094
+ logger$5.error(err);
26946
27095
  showToast({
26947
27096
  label: i18n.get("failedToUpdateDetails"),
26948
27097
  type: ToastType.ERROR
@@ -27165,7 +27314,7 @@ function DropinComposerComponent({
27165
27314
  }
27166
27315
  };
27167
27316
  setIsLoadingConfiguration(true);
27168
- fetchConfiguration().catch(logger$6.error).finally(() => {
27317
+ fetchConfiguration().catch(logger$5.error).finally(() => {
27169
27318
  setIsLoadingConfiguration(false);
27170
27319
  onLoad();
27171
27320
  });
@@ -27521,7 +27670,6 @@ function DropinComposerComponent({
27521
27670
  const createDocument = async (context, document2, ownerId) => {
27522
27671
  const {
27523
27672
  loadingContext,
27524
- sdkToken,
27525
27673
  legalEntityId
27526
27674
  } = context;
27527
27675
  return httpPost({
@@ -27529,7 +27677,7 @@ const createDocument = async (context, document2, ownerId) => {
27529
27677
  errorLevel: "warn",
27530
27678
  errorMessage: `Failed to create document`,
27531
27679
  path: `${legalEntityId}/documents/${ownerId}`,
27532
- sdkToken,
27680
+ authentication: "jwt",
27533
27681
  headers: {
27534
27682
  "Content-Type": "application/json"
27535
27683
  }
@@ -27538,7 +27686,6 @@ const createDocument = async (context, document2, ownerId) => {
27538
27686
  const createTransferInstrument = async (context, transferInstrument) => {
27539
27687
  const {
27540
27688
  loadingContext,
27541
- sdkToken,
27542
27689
  legalEntityId
27543
27690
  } = context;
27544
27691
  return httpPost({
@@ -27546,7 +27693,7 @@ const createTransferInstrument = async (context, transferInstrument) => {
27546
27693
  errorLevel: "warn",
27547
27694
  errorMessage: `Failed to create transferInstrument`,
27548
27695
  path: `${legalEntityId}/transferInstruments`,
27549
- sdkToken,
27696
+ authentication: "jwt",
27550
27697
  headers: {
27551
27698
  "Content-Type": "application/json"
27552
27699
  }
@@ -27555,7 +27702,6 @@ const createTransferInstrument = async (context, transferInstrument) => {
27555
27702
  const getBankVerificationVendor = async (context, country2) => {
27556
27703
  const {
27557
27704
  loadingContext,
27558
- sdkToken,
27559
27705
  legalEntityId
27560
27706
  } = context;
27561
27707
  return httpGet({
@@ -27563,7 +27709,7 @@ const getBankVerificationVendor = async (context, country2) => {
27563
27709
  errorLevel: "warn",
27564
27710
  errorMessage: `Bank verification vendor not available`,
27565
27711
  path: `${legalEntityId}/transferInstruments/trusted/providers?country=${country2}`,
27566
- sdkToken,
27712
+ authentication: "jwt",
27567
27713
  headers: {
27568
27714
  "Content-Type": "application/json"
27569
27715
  }
@@ -27571,8 +27717,7 @@ const getBankVerificationVendor = async (context, country2) => {
27571
27717
  };
27572
27718
  const getDataset$1 = async (context, name, locale) => {
27573
27719
  const {
27574
- loadingContext,
27575
- sdkToken
27720
+ loadingContext
27576
27721
  } = context;
27577
27722
  const datasetUtils = datasetUtilities(locale);
27578
27723
  const dataset = datasetUtils.getDataset(name);
@@ -27587,7 +27732,7 @@ const getDataset$1 = async (context, name, locale) => {
27587
27732
  errorLevel: "warn",
27588
27733
  errorMessage: `Dataset ${name} is not available`,
27589
27734
  path,
27590
- sdkToken,
27735
+ authentication: "jwt",
27591
27736
  headers: {
27592
27737
  "Content-Type": "application/json"
27593
27738
  }
@@ -27599,7 +27744,6 @@ const getDataset$1 = async (context, name, locale) => {
27599
27744
  const getDocument = async (context, documentId) => {
27600
27745
  const {
27601
27746
  loadingContext,
27602
- sdkToken,
27603
27747
  legalEntityId
27604
27748
  } = context;
27605
27749
  return httpGet({
@@ -27607,7 +27751,7 @@ const getDocument = async (context, documentId) => {
27607
27751
  errorLevel: "warn",
27608
27752
  errorMessage: `Failed to fetch document`,
27609
27753
  path: `${legalEntityId}/documents/${documentId}`,
27610
- sdkToken,
27754
+ authentication: "jwt",
27611
27755
  headers: {
27612
27756
  "Content-Type": "application/json"
27613
27757
  }
@@ -27616,7 +27760,6 @@ const getDocument = async (context, documentId) => {
27616
27760
  const getLegalEntity = async (context) => {
27617
27761
  const {
27618
27762
  loadingContext,
27619
- sdkToken,
27620
27763
  legalEntityId
27621
27764
  } = context;
27622
27765
  return httpGet({
@@ -27624,7 +27767,7 @@ const getLegalEntity = async (context) => {
27624
27767
  errorLevel: "warn",
27625
27768
  errorMessage: `LegalEntity not available`,
27626
27769
  path: `${legalEntityId}`,
27627
- sdkToken,
27770
+ authentication: "jwt",
27628
27771
  headers: {
27629
27772
  "Content-Type": "application/json"
27630
27773
  }
@@ -27633,7 +27776,6 @@ const getLegalEntity = async (context) => {
27633
27776
  const getScenarios = async (context) => {
27634
27777
  const {
27635
27778
  loadingContext,
27636
- sdkToken,
27637
27779
  legalEntityId
27638
27780
  } = context;
27639
27781
  return httpGet({
@@ -27641,7 +27783,7 @@ const getScenarios = async (context) => {
27641
27783
  errorLevel: "warn",
27642
27784
  errorMessage: `Scenarios not available`,
27643
27785
  path: `${legalEntityId}/configurations/scenarios`,
27644
- sdkToken,
27786
+ authentication: "jwt",
27645
27787
  headers: {
27646
27788
  "Content-Type": "application/json"
27647
27789
  }
@@ -27650,7 +27792,6 @@ const getScenarios = async (context) => {
27650
27792
  const getTasks = async (context) => {
27651
27793
  const {
27652
27794
  loadingContext,
27653
- sdkToken,
27654
27795
  legalEntityId
27655
27796
  } = context;
27656
27797
  return httpGet({
@@ -27658,7 +27799,7 @@ const getTasks = async (context) => {
27658
27799
  errorLevel: "warn",
27659
27800
  errorMessage: `Tasks not available`,
27660
27801
  path: `${legalEntityId}/configurations/tasks`,
27661
- sdkToken,
27802
+ authentication: "jwt",
27662
27803
  headers: {
27663
27804
  "Content-Type": "application/json"
27664
27805
  }
@@ -27667,7 +27808,6 @@ const getTasks = async (context) => {
27667
27808
  const getTransferInstrument = async (context, transferInstrumentId) => {
27668
27809
  const {
27669
27810
  loadingContext,
27670
- sdkToken,
27671
27811
  legalEntityId
27672
27812
  } = context;
27673
27813
  return httpGet({
@@ -27675,9 +27815,8 @@ const getTransferInstrument = async (context, transferInstrumentId) => {
27675
27815
  errorLevel: "warn",
27676
27816
  errorMessage: `TransferInstrument not available`,
27677
27817
  path: `${legalEntityId}/transferInstruments/${transferInstrumentId}`,
27818
+ authentication: "jwt",
27678
27819
  headers: {
27679
- Authorization: `Bearer ${sdkToken}`,
27680
- Origin: window.location.origin,
27681
27820
  "Content-Type": "application/json"
27682
27821
  }
27683
27822
  });
@@ -27685,7 +27824,6 @@ const getTransferInstrument = async (context, transferInstrumentId) => {
27685
27824
  const updateDocument = async (context, document2, documentId, ownerId) => {
27686
27825
  const {
27687
27826
  loadingContext,
27688
- sdkToken,
27689
27827
  legalEntityId
27690
27828
  } = context;
27691
27829
  return httpPost({
@@ -27693,7 +27831,7 @@ const updateDocument = async (context, document2, documentId, ownerId) => {
27693
27831
  errorLevel: "warn",
27694
27832
  errorMessage: `Failed to update document`,
27695
27833
  path: `${legalEntityId}/documents/${documentId}/${ownerId}`,
27696
- sdkToken,
27834
+ authentication: "jwt",
27697
27835
  headers: {
27698
27836
  "Content-Type": "application/json"
27699
27837
  }
@@ -27702,7 +27840,6 @@ const updateDocument = async (context, document2, documentId, ownerId) => {
27702
27840
  const updateTransferInstrument = async (context, transferInstrument, transferInstrumentId) => {
27703
27841
  const {
27704
27842
  loadingContext,
27705
- sdkToken,
27706
27843
  legalEntityId
27707
27844
  } = context;
27708
27845
  return httpPost({
@@ -27710,7 +27847,7 @@ const updateTransferInstrument = async (context, transferInstrument, transferIns
27710
27847
  errorLevel: "warn",
27711
27848
  errorMessage: `Failed to update transferInstrument`,
27712
27849
  path: `${legalEntityId}/transferInstruments/${transferInstrumentId}`,
27713
- sdkToken,
27850
+ authentication: "jwt",
27714
27851
  headers: {
27715
27852
  "Content-Type": "application/json"
27716
27853
  }
@@ -27719,7 +27856,6 @@ const updateTransferInstrument = async (context, transferInstrument, transferIns
27719
27856
  const createTrustedTransferInstrument = async (context, code2, state2) => {
27720
27857
  const {
27721
27858
  loadingContext,
27722
- sdkToken,
27723
27859
  legalEntityId
27724
27860
  } = context;
27725
27861
  const path = `${legalEntityId}/transferInstruments/trusted`;
@@ -27728,7 +27864,7 @@ const createTrustedTransferInstrument = async (context, code2, state2) => {
27728
27864
  errorLevel: "warn",
27729
27865
  errorMessage: `Failed to create trusted transferInstrument`,
27730
27866
  path,
27731
- sdkToken,
27867
+ authentication: "jwt",
27732
27868
  headers: {
27733
27869
  "Content-Type": "application/json"
27734
27870
  }
@@ -27740,7 +27876,6 @@ const createTrustedTransferInstrument = async (context, code2, state2) => {
27740
27876
  const handleBankVerificationError = async (context, errorCode, errorMessage, state2, metadata) => {
27741
27877
  const {
27742
27878
  loadingContext,
27743
- sdkToken,
27744
27879
  legalEntityId
27745
27880
  } = context;
27746
27881
  const path = `${legalEntityId}/transferInstruments/trusted/error`;
@@ -27749,7 +27884,7 @@ const handleBankVerificationError = async (context, errorCode, errorMessage, sta
27749
27884
  errorLevel: "warn",
27750
27885
  errorMessage: `Failed to create trusted transferInstrument`,
27751
27886
  path,
27752
- sdkToken,
27887
+ authentication: "jwt",
27753
27888
  headers: {
27754
27889
  "Content-Type": "application/json"
27755
27890
  }
@@ -27767,7 +27902,6 @@ const useComponentApi = (rootLegalEntityId) => {
27767
27902
  throw new Error("Cannot use component API outside an embedded dropin");
27768
27903
  }
27769
27904
  const {
27770
- sdkToken,
27771
27905
  loadingContext: base
27772
27906
  } = authContext;
27773
27907
  return useMemo(() => {
@@ -27775,8 +27909,7 @@ const useComponentApi = (rootLegalEntityId) => {
27775
27909
  const loadingContextWithRootLEAuth = `${loadingContext}legalEntities/`;
27776
27910
  const baseRequestContext = {
27777
27911
  loadingContext: loadingContextWithRootLEAuth,
27778
- legalEntityId: rootLegalEntityId,
27779
- sdkToken
27912
+ legalEntityId: rootLegalEntityId
27780
27913
  };
27781
27914
  return {
27782
27915
  getLegalEntity: async (legalEntityId) => getLegalEntity({
@@ -27793,7 +27926,7 @@ const useComponentApi = (rootLegalEntityId) => {
27793
27926
  createTrustedTransferInstrument: async (code2, state2) => createTrustedTransferInstrument(baseRequestContext, code2, state2),
27794
27927
  handleBankVerificationError: async (errorCode, errorMessage, state2, metadata) => handleBankVerificationError(baseRequestContext, errorCode, errorMessage, state2, metadata)
27795
27928
  };
27796
- }, [base, rootLegalEntityId, sdkToken]);
27929
+ }, [base, rootLegalEntityId]);
27797
27930
  };
27798
27931
  class EventEmitter {
27799
27932
  constructor() {
@@ -27814,7 +27947,7 @@ class EventEmitter {
27814
27947
  };
27815
27948
  }
27816
27949
  }
27817
- const logger$5 = createLogger("TransferInstrumentComponent");
27950
+ const logger$4 = createLogger("TransferInstrumentComponent");
27818
27951
  function TransferInstrumentComponent({
27819
27952
  legalEntityId,
27820
27953
  transferInstrumentId,
@@ -27849,8 +27982,8 @@ function TransferInstrumentComponent({
27849
27982
  const ti = await getTransferInstrument2(transferInstrumentId);
27850
27983
  setTransferInstrument(ti);
27851
27984
  }
27852
- })().catch(logger$5.error);
27853
- }, [transferInstrumentId]);
27985
+ })().catch(logger$4.error);
27986
+ }, [transferInstrumentId, fetchLegalEntity]);
27854
27987
  return legalEntity ? jsx(PayoutDetailsDropinComponent, {
27855
27988
  eventEmitter: eventEmitter ?? new EventEmitter(),
27856
27989
  transferInstrument,
@@ -27882,85 +28015,17 @@ const componentsMap = {
27882
28015
  pci: PciDropinComponent,
27883
28016
  transferInstrumentComponent: TransferInstrumentComponent
27884
28017
  };
27885
- const refreshSdkToken = async (context, refreshToken) => {
27886
- const {
27887
- loadingContext,
27888
- sdkToken
27889
- } = context;
27890
- return httpPost({
27891
- loadingContext,
27892
- errorLevel: "warn",
27893
- errorMessage: `Failed to refresh token`,
27894
- path: `sessions/refresh`,
27895
- sdkToken,
27896
- headers: {
27897
- "Content-Type": "application/json"
27898
- }
27899
- }, {
27900
- refreshToken
27901
- });
27902
- };
27903
- const SDK_TOKEN_TTL = 6e4;
27904
- const REFRESH_INTERVAL = SDK_TOKEN_TTL - 5e3;
27905
- const RETRY_LIMIT = 2;
27906
- const logger$4 = createLogger("useSdkToken");
27907
- const useSdkToken = ({
27908
- initialSdkToken,
27909
- refreshToken,
27910
- autheBase
27911
- }) => {
27912
- const [sdkToken, setSdkToken] = useState(initialSdkToken);
27913
- const doRefresh = async (sdkToken2, refreshToken2, retries) => {
27914
- try {
27915
- const {
27916
- token: newSdkToken
27917
- } = await refreshSdkToken({
27918
- loadingContext: autheBase,
27919
- sdkToken: sdkToken2
27920
- }, refreshToken2);
27921
- setSdkToken(newSdkToken);
27922
- } catch (e) {
27923
- if (!retries) {
27924
- throw new Error("Unable to refresh token after retries", e);
27925
- }
27926
- logger$4.warn("Failed to refresh token. Retrying..", e);
27927
- await doRefresh(sdkToken2, refreshToken2, retries - 1);
27928
- }
27929
- };
27930
- useEffect(() => {
27931
- if (!sdkToken || !refreshToken) {
27932
- return;
27933
- }
27934
- const refreshHandler = setInterval(() => {
27935
- doRefresh(sdkToken, refreshToken, RETRY_LIMIT).catch(() => {
27936
- clearInterval(refreshHandler);
27937
- });
27938
- }, REFRESH_INTERVAL);
27939
- return () => {
27940
- clearInterval(refreshHandler);
27941
- };
27942
- }, [sdkToken]);
27943
- return sdkToken;
27944
- };
27945
- const AUTHE_API_VERSION = "v1";
27946
28018
  const AuthProvider = ({
27947
28019
  children,
27948
- sdkToken: initialSdkToken,
27949
- refreshToken,
28020
+ sdkToken: sdkToken2,
28021
+ getSdkToken: getSdkToken2,
27950
28022
  clientKey,
27951
28023
  loadingContext
27952
28024
  }) => {
27953
- const autheBase = `${loadingContext}authe/api/${AUTHE_API_VERSION}/`;
27954
- const sdkToken = useSdkToken({
27955
- initialSdkToken,
27956
- refreshToken,
27957
- autheBase
27958
- });
27959
28025
  const contextValue = useMemo(() => {
27960
- if (sdkToken && refreshToken) {
28026
+ if (sdkToken2 && getSdkToken2) {
27961
28027
  return {
27962
28028
  isEmbeddedDropin: true,
27963
- sdkToken,
27964
28029
  loadingContext: `${loadingContext}onboardingcomponents/`
27965
28030
  };
27966
28031
  }
@@ -27971,8 +28036,8 @@ const AuthProvider = ({
27971
28036
  loadingContext
27972
28037
  };
27973
28038
  }
27974
- throw new Error("Must provide either `sdkToken` and `refreshToken` or `clientKey`");
27975
- }, [sdkToken, clientKey]);
28039
+ throw new Error("Must provide either `sdkToken` and `getSdkToken` or `clientKey`");
28040
+ }, [sdkToken2, clientKey]);
27976
28041
  return jsx(AuthContext.Provider, {
27977
28042
  value: contextValue,
27978
28043
  children
@@ -27990,7 +28055,6 @@ const getPayoutAccountFormat = async (country2) => getAccountFormatsForCountry(c
27990
28055
  const getAllowedLocales$1 = async (context) => {
27991
28056
  const {
27992
28057
  loadingContext,
27993
- sdkToken,
27994
28058
  legalEntityId
27995
28059
  } = context;
27996
28060
  return httpGet({
@@ -27998,7 +28062,7 @@ const getAllowedLocales$1 = async (context) => {
27998
28062
  errorLevel: "warn",
27999
28063
  errorMessage: `Supported locales not available`,
28000
28064
  path: `${legalEntityId}/configurations/supportedLocales`,
28001
- sdkToken,
28065
+ authentication: "jwt",
28002
28066
  headers: {
28003
28067
  "Content-Type": "application/json"
28004
28068
  }
@@ -28006,15 +28070,13 @@ const getAllowedLocales$1 = async (context) => {
28006
28070
  };
28007
28071
  const getEmbeddedApi = ({
28008
28072
  base,
28009
- sdkToken,
28010
28073
  rootLegalEntityId
28011
28074
  }) => {
28012
28075
  const loadingContext = `${base}api/${COMPONENTS_API_VERSION}/`;
28013
28076
  const loadingContextWithRootLEAuth = `${loadingContext}legalEntities/`;
28014
28077
  const baseRequestContext = {
28015
28078
  loadingContext: loadingContextWithRootLEAuth,
28016
- legalEntityId: rootLegalEntityId,
28017
- sdkToken
28079
+ legalEntityId: rootLegalEntityId
28018
28080
  };
28019
28081
  return {
28020
28082
  getConfiguration: async ({
@@ -28337,7 +28399,6 @@ const ConfigurationApiProvider = ({
28337
28399
  const authContext = useAuthContext();
28338
28400
  const contextValue = useMemo(() => authContext.isEmbeddedDropin ? getEmbeddedApi({
28339
28401
  base: authContext.loadingContext,
28340
- sdkToken: authContext.sdkToken,
28341
28402
  rootLegalEntityId
28342
28403
  }) : getKycExternalApi({
28343
28404
  loadingContext: authContext.loadingContext,
@@ -28621,7 +28682,7 @@ class UIElement extends BaseElement {
28621
28682
  const Component = this.props.component;
28622
28683
  return jsx(AuthProvider, {
28623
28684
  sdkToken: this.props.sdkToken,
28624
- refreshToken: this.props.refreshToken,
28685
+ getSdkToken: this.props.getSdkToken,
28625
28686
  clientKey: this.props.clientKey,
28626
28687
  loadingContext: this.props.loadingContext,
28627
28688
  children: jsx(ConfigurationApiProvider, {
@@ -29188,10 +29249,10 @@ const validateComponentName = (componentName) => {
29188
29249
  const validateCoreOptions = (coreOptions) => {
29189
29250
  const requiredOptions = ["locale", "environment", "country"];
29190
29251
  const missing = requiredOptions.filter((option) => !coreOptions[option]);
29191
- if (!(coreOptions.sdkToken && coreOptions.refreshToken) && !coreOptions.clientKey) {
29252
+ if (!(coreOptions.sdkToken && coreOptions.getSdkToken) && !coreOptions.clientKey) {
29192
29253
  throw new Error(`
29193
29254
 
29194
- Please specify either sdkToken and a refreshToken or a clientKey for the SDK to initialize!
29255
+ Please specify either sdkToken and getSdkToken handler or a clientKey for the SDK to initialize!
29195
29256
 
29196
29257
 
29197
29258
  - For more information please check: https://github.com/Adyen/adyen-kyc-components#configuration.`);
@@ -29328,7 +29389,14 @@ class Core {
29328
29389
  newOptions.locale = FALLBACK_LOCALE;
29329
29390
  return newOptions;
29330
29391
  };
29392
+ this.initializeSession = () => {
29393
+ if (this.options.sdkToken && this.options.getSdkToken) {
29394
+ setSdkToken(this.options.sdkToken);
29395
+ setSdkTokenHandler(this.options.getSdkToken);
29396
+ }
29397
+ };
29331
29398
  this.options = this.getUpdatedOptions(coreOptions);
29399
+ this.initializeSession();
29332
29400
  }
29333
29401
  }
29334
29402
  export {