@adyen/kyc-components 2.8.0 → 2.8.1

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 (23) hide show
  1. package/dist/es/adyen-kyc-components.es.js +293 -223
  2. package/dist/types/components/Company/types.d.ts +0 -1
  3. package/dist/types/components/DecisionMakers/types.d.ts +0 -1
  4. package/dist/types/components/Dropins/PciDropin/components/PciDropinComponent.d.ts +1 -1
  5. package/dist/types/components/Dropins/PciDropin/types.d.ts +2 -2
  6. package/dist/types/components/Dropins/ServiceAgreementDropinComponent/components/ServiceAgreementDropinComponent.d.ts +1 -1
  7. package/dist/types/components/Dropins/ServiceAgreementDropinComponent/types.d.ts +1 -1
  8. package/dist/types/components/Dropins/types.d.ts +2 -3
  9. package/dist/types/components/EmbeddedDropins/PayoutEmbeddedDropin/PayoutEmbeddedDropin.d.ts +2 -1
  10. package/dist/types/components/Individual/types.d.ts +2 -2
  11. package/dist/types/components/PayoutDetails/types.d.ts +2 -2
  12. package/dist/types/components/SoleProp/types.d.ts +0 -1
  13. package/dist/types/components/internal/Address/utils.d.ts +1 -1
  14. package/dist/types/core/Context/ConfigurationApiContext/ConfigurationApiProvider.d.ts +1 -1
  15. package/dist/types/core/Context/StateContext/types.d.ts +24 -11
  16. package/dist/types/core/Services/agnostic/get-fonts.d.ts +2 -2
  17. package/dist/types/core/hooks/useBankConfigurationHandlers.d.ts +24 -0
  18. package/dist/types/core/models/api/organization.d.ts +1 -1
  19. package/dist/types/language/config.d.ts +3 -0
  20. package/dist/types/utils/decision-maker-roles.d.ts +1 -1
  21. package/dist/types/utils/entity-status-util.d.ts +2 -2
  22. package/dist/types/utils/trust-util.d.ts +1 -1
  23. package/package.json +1 -1
@@ -181,6 +181,7 @@ const validationPleaseEnterAValidRegistrationNumberWithFormat = "Please enter a
181
181
  const validationPleaseEnterAValidVatNumber = "Please enter a valid Tax id number";
182
182
  const validationPleaseEnterAValidVatNumberWithFormat = "Please enter a valid Tax id number. Expected format: %{format}";
183
183
  const validationPleaseEnterAValidTaxIdNumberWithFormat = "Please enter a valid Tax id number. Expected format: %{format}";
184
+ const validationPleaseEnterAValidIRDNumber = "Please enter a valid IRD number. Expected format: 8 - 9 digits";
184
185
  const aValidAbnShouldBe11Digits = "A valid ABN should be 11 digits.";
185
186
  const aValidUenOrGstShouldBe9To10Characters = "A valid UEN/GST should be 9 to 10 characters.";
186
187
  const aValidBrnShouldBe8Digits = "A valid BRN should be 8 digits.";
@@ -426,6 +427,7 @@ const irdDocument = "IRD document";
426
427
  const irdNumber = "IRD number";
427
428
  const australianBusinessNumberAbn = "Australian business number (ABN)";
428
429
  const australianBusinessNumberAcn = "Australian company number (ACN)";
430
+ const companyNumber__NZ = "New Zealand Business Number (NZBN) / Company Number (NCN)";
429
431
  const enterpriseNumber = "Enterprise Number";
430
432
  const NIP = "NIP (Numer identyfikacji podatkowej)";
431
433
  const NIPC = "NIPC (Número de Identificação de Pessoa Colectiva)";
@@ -710,6 +712,7 @@ const businessRegistrationNumber = "Business registration number";
710
712
  const businessRegistrationNumber__HK = "Business Registration number (BRN)";
711
713
  const doNotHaveBusinessNumber = "I do not have a Business number";
712
714
  const UEN = "Unique Entity Number (UEN)/Goods and Services Tax (GST)";
715
+ const IRD = "Inland Revenue Department Number (IRD No)";
713
716
  const enterNameExactlyAsAppearInID = "Enter your first name(s) exactly as it appears on your identity document";
714
717
  const enterLastNameExactlyAsAppearInID = "Enter your last name(s) exactly as it appears on your identity document";
715
718
  const takePhotoOriginalDocumentWithPhone = "Take a photo of the original ID document with your phone";
@@ -1222,6 +1225,7 @@ const defaultTrans = {
1222
1225
  validationPleaseEnterAValidVatNumber,
1223
1226
  validationPleaseEnterAValidVatNumberWithFormat,
1224
1227
  validationPleaseEnterAValidTaxIdNumberWithFormat,
1228
+ validationPleaseEnterAValidIRDNumber,
1225
1229
  aValidAbnShouldBe11Digits,
1226
1230
  aValidUenOrGstShouldBe9To10Characters,
1227
1231
  aValidBrnShouldBe8Digits,
@@ -1467,6 +1471,7 @@ const defaultTrans = {
1467
1471
  irdNumber,
1468
1472
  australianBusinessNumberAbn,
1469
1473
  australianBusinessNumberAcn,
1474
+ companyNumber__NZ,
1470
1475
  enterpriseNumber,
1471
1476
  NIP,
1472
1477
  NIPC,
@@ -1767,6 +1772,7 @@ const defaultTrans = {
1767
1772
  "UEN/GST": "Unique Entity Number (UEN)/Goods and Services Tax (GST)",
1768
1773
  UEN,
1769
1774
  "IRD/GST": "Inland Revenue Department Number (IRD No)/Goods and Services Tax (GST)",
1775
+ IRD,
1770
1776
  enterNameExactlyAsAppearInID,
1771
1777
  enterLastNameExactlyAsAppearInID,
1772
1778
  takePhotoOriginalDocumentWithPhone,
@@ -4419,10 +4425,11 @@ const businessRegistrationNumberPatterns = {
4419
4425
  },
4420
4426
  [CountryCodes.NewZealand]: {
4421
4427
  default: {
4422
- regex: /^\d{13}$/,
4423
- format: "Xdigits",
4428
+ regex: /^\d{9,13}$/,
4429
+ format: "XtoYdigits",
4424
4430
  values: {
4425
- digits: 13
4431
+ x: 9,
4432
+ y: 13
4426
4433
  }
4427
4434
  }
4428
4435
  },
@@ -5377,6 +5384,13 @@ const countryBasedValidatorRules$1 = {
5377
5384
  validate: (taxId2) => validateTaxId(taxId2, "HK"),
5378
5385
  errorMessage: "aValidBrnShouldBe8Digits"
5379
5386
  }]
5387
+ },
5388
+ NZ: {
5389
+ taxId: [{
5390
+ modes: ["blur"],
5391
+ validate: (taxId2) => validateTaxId(taxId2, "NZ"),
5392
+ errorMessage: "validationPleaseEnterAValidIRDNumber"
5393
+ }]
5380
5394
  }
5381
5395
  };
5382
5396
  const taxIdFields = ["taxId", "exemptedFromTax"];
@@ -8191,10 +8205,10 @@ const countryConfig$4 = {
8191
8205
  label: "irdDocument"
8192
8206
  },
8193
8207
  registrationNumber: {
8194
- label: "companyNumber"
8208
+ label: "companyNumber__NZ"
8195
8209
  },
8196
8210
  taxId: {
8197
- label: "IRD/GST"
8211
+ label: "IRD"
8198
8212
  },
8199
8213
  exemptedFromVat: {
8200
8214
  label: "vatNumberExempted"
@@ -11563,7 +11577,8 @@ const getDefaultAccountHolderType = (legalEntityResponse, isTypeChanging = false
11563
11577
  };
11564
11578
  const countryToTaxInfoTypeMap = {
11565
11579
  US: "EIN",
11566
- AU: "ABN"
11580
+ AU: "ABN",
11581
+ NZ: "IRD"
11567
11582
  };
11568
11583
  const updateTaxInformation = ({
11569
11584
  taxId: taxId2,
@@ -23189,6 +23204,45 @@ function IndividualDropinComponent({
23189
23204
  })
23190
23205
  });
23191
23206
  }
23207
+ const useBankConfigurationHandlers = ({
23208
+ isEmbeddedDropin,
23209
+ handleGetBankVerificationVendors,
23210
+ bankAccountCountry: bankAccountCountry2,
23211
+ getConfiguration: getConfiguration2,
23212
+ legalEntityType,
23213
+ capabilities
23214
+ }) => {
23215
+ const [bankVerificationVendorsResponse, setBankVerificationVendorsResponse] = useState();
23216
+ const callBankVerificationVendorsUpfront = isEmbeddedDropin && handleGetBankVerificationVendors;
23217
+ useEffect(() => {
23218
+ (async () => {
23219
+ const bankVerificationVendorsResponse2 = callBankVerificationVendorsUpfront ? await handleGetBankVerificationVendors(bankAccountCountry2) : [];
23220
+ setBankVerificationVendorsResponse(bankVerificationVendorsResponse2);
23221
+ })();
23222
+ }, [bankAccountCountry2]);
23223
+ const getConfigurationData = useCallback(async () => {
23224
+ var _a;
23225
+ const configuration = await getConfiguration2({
23226
+ legalEntityType,
23227
+ capabilities,
23228
+ country: bankAccountCountry2
23229
+ });
23230
+ if (!callBankVerificationVendorsUpfront || !((_a = bankVerificationVendorsResponse == null ? void 0 : bankVerificationVendorsResponse[0]) == null ? void 0 : _a.name)) {
23231
+ return configuration;
23232
+ }
23233
+ return {
23234
+ ...configuration,
23235
+ bankVerificationProviders: {
23236
+ [bankAccountCountry2]: bankVerificationVendorsResponse[0].name
23237
+ }
23238
+ };
23239
+ }, [bankAccountCountry2, capabilities, bankVerificationVendorsResponse]);
23240
+ const getBankVerificationVendorsHandler = useMemo(() => callBankVerificationVendorsUpfront ? (data) => data && Promise.resolve(bankVerificationVendorsResponse) : handleGetBankVerificationVendors, [bankVerificationVendorsResponse, callBankVerificationVendorsUpfront]);
23241
+ return {
23242
+ getConfigurationData,
23243
+ getBankVerificationVendorsHandler
23244
+ };
23245
+ };
23192
23246
  const isInstantVerificationAvailable = ({
23193
23247
  country: country2,
23194
23248
  verificationVendorsCallback,
@@ -23288,6 +23342,9 @@ function PayoutDetailsDropinComponent({
23288
23342
  handleBankVerificationError: handleBankVerificationError2
23289
23343
  }) {
23290
23344
  var _a, _b, _c;
23345
+ const {
23346
+ isEmbeddedDropin
23347
+ } = useAuthContext();
23291
23348
  const {
23292
23349
  i18n,
23293
23350
  setLocale
@@ -23349,11 +23406,17 @@ function PayoutDetailsDropinComponent({
23349
23406
  }
23350
23407
  });
23351
23408
  }, []);
23352
- const getConfigurationData = useCallback(() => getConfiguration2({
23409
+ const {
23410
+ getConfigurationData,
23411
+ getBankVerificationVendorsHandler
23412
+ } = useBankConfigurationHandlers({
23413
+ isEmbeddedDropin,
23414
+ handleGetBankVerificationVendors,
23415
+ bankAccountCountry: bankAccountCountry2 ?? defaultPayoutCountry,
23416
+ getConfiguration: getConfiguration2,
23353
23417
  legalEntityType: legalEntityResponse.type,
23354
- capabilities,
23355
- country: bankAccountCountry2 ?? defaultPayoutCountry
23356
- }), [bankAccountCountry2, capabilities]);
23418
+ capabilities
23419
+ });
23357
23420
  const getPayoutAccountFormatData = useCallback(async () => getPayoutAccountFormat2(bankAccountCountry2 ?? defaultPayoutCountry), [bankAccountCountry2]);
23358
23421
  const {
23359
23422
  fieldConfigurations,
@@ -23633,7 +23696,7 @@ function PayoutDetailsDropinComponent({
23633
23696
  setSkipSubmit,
23634
23697
  onChange,
23635
23698
  legalEntityResponse,
23636
- handleGetBankVerificationVendors,
23699
+ handleGetBankVerificationVendors: getBankVerificationVendorsHandler,
23637
23700
  instantVerificationEnabled,
23638
23701
  refreshLegalEntity,
23639
23702
  shouldValidate,
@@ -23948,7 +24011,7 @@ const pciValidationRules = {
23948
24011
  };
23949
24012
  const PciFields = ["signer", "acceptPci"];
23950
24013
  function PciDropinComponent({
23951
- legalEntity,
24014
+ legalEntityResponse,
23952
24015
  pciTemplateResponse,
23953
24016
  handleHomeClick,
23954
24017
  handleLanguageChange,
@@ -23965,7 +24028,7 @@ function PciDropinComponent({
23965
24028
  } = useToastContext();
23966
24029
  const baseTrackingPayload = getBaseTrackingPayload({
23967
24030
  trackingConfig,
23968
- legalEntity,
24031
+ legalEntity: legalEntityResponse,
23969
24032
  task: taskType
23970
24033
  });
23971
24034
  const [loadingStatus, setLoadingStatus] = useState(null);
@@ -23984,16 +24047,16 @@ function PciDropinComponent({
23984
24047
  pciTemplateReferences
23985
24048
  } = pciTemplateResponse;
23986
24049
  const pciQuestionnaire = JSON.parse(decodeURIComponent(escape(window.atob(pciTemplateResponse.content))));
23987
- const uniqueEntityAssociations = [...new Map(getOwnDecisionMakers(legalEntity).map((entityAssociation) => [entityAssociation.legalEntityId, entityAssociation])).values()];
23988
- const signers = legalEntity.type === LegalEntityType.ORGANIZATION ? uniqueEntityAssociations.map(({
24050
+ const uniqueEntityAssociations = [...new Map(getOwnDecisionMakers(legalEntityResponse).map((entityAssociation) => [entityAssociation.legalEntityId, entityAssociation])).values()];
24051
+ const signers = legalEntityResponse.type === LegalEntityType.ORGANIZATION ? uniqueEntityAssociations.map(({
23989
24052
  legalEntityId: id2,
23990
24053
  name
23991
24054
  }) => ({
23992
24055
  id: id2,
23993
24056
  name
23994
24057
  })) : [{
23995
- id: legalEntity == null ? void 0 : legalEntity.id,
23996
- name: `${(_a = legalEntity == null ? void 0 : legalEntity.individual) == null ? void 0 : _a.name.firstName} ${(_b = legalEntity == null ? void 0 : legalEntity.individual) == null ? void 0 : _b.name.lastName}`
24058
+ id: legalEntityResponse == null ? void 0 : legalEntityResponse.id,
24059
+ name: `${(_a = legalEntityResponse == null ? void 0 : legalEntityResponse.individual) == null ? void 0 : _a.name.firstName} ${(_b = legalEntityResponse == null ? void 0 : legalEntityResponse.individual) == null ? void 0 : _b.name.lastName}`
23997
24060
  }];
23998
24061
  const handleSignClick = async () => {
23999
24062
  if (loadingStatus === "loading")
@@ -24007,7 +24070,7 @@ function PciDropinComponent({
24007
24070
  if (isValid) {
24008
24071
  try {
24009
24072
  setLoadingStatus("loading");
24010
- await handleSign(legalEntity.id, {
24073
+ await handleSign(legalEntityResponse.id, {
24011
24074
  signedBy: data.signer,
24012
24075
  pciTemplateReferences
24013
24076
  });
@@ -24679,7 +24742,7 @@ const serviceAgreementTypesTranslationMapping = {
24679
24742
  adyenFranchisee: "franchiseesTAndCs"
24680
24743
  };
24681
24744
  function ServiceAgreementDropinComponent({
24682
- legalEntity,
24745
+ legalEntityResponse,
24683
24746
  handleGetServiceAgreement,
24684
24747
  handleHomeClick,
24685
24748
  handleSign,
@@ -24697,7 +24760,7 @@ function ServiceAgreementDropinComponent({
24697
24760
  } = useToastContext();
24698
24761
  const baseTrackingPayload = getBaseTrackingPayload({
24699
24762
  trackingConfig,
24700
- legalEntity,
24763
+ legalEntity: legalEntityResponse,
24701
24764
  task: taskType
24702
24765
  });
24703
24766
  const [loadingStatus, setLoadingStatus] = useState();
@@ -24726,7 +24789,7 @@ function ServiceAgreementDropinComponent({
24726
24789
  } = useServiceAgreement({
24727
24790
  handleGetServiceAgreement,
24728
24791
  handleServiceAgreementIsNotAvailableInThatLanguage,
24729
- legalEntityId: legalEntity.id,
24792
+ legalEntityId: legalEntityResponse.id,
24730
24793
  serviceAgreementType: activeForm.formId,
24731
24794
  language: i18n.languageCode
24732
24795
  });
@@ -24741,15 +24804,15 @@ function ServiceAgreementDropinComponent({
24741
24804
  schema: ["signer", "acceptServiceAgreement"],
24742
24805
  rules: serviceAgreementValidationRules
24743
24806
  });
24744
- const signers = legalEntity.type === LegalEntityType.ORGANIZATION ? getOwnSignatories(legalEntity).map(({
24807
+ const signers = legalEntityResponse.type === LegalEntityType.ORGANIZATION ? getOwnSignatories(legalEntityResponse).map(({
24745
24808
  legalEntityId: id2,
24746
24809
  name
24747
24810
  }) => ({
24748
24811
  id: id2 ?? "",
24749
24812
  name: name ?? ""
24750
24813
  })) : [{
24751
- id: legalEntity == null ? void 0 : legalEntity.id,
24752
- name: `${(_a = legalEntity == null ? void 0 : legalEntity.individual) == null ? void 0 : _a.name.firstName} ${(_b = legalEntity == null ? void 0 : legalEntity.individual) == null ? void 0 : _b.name.lastName}`
24814
+ id: legalEntityResponse == null ? void 0 : legalEntityResponse.id,
24815
+ name: `${(_a = legalEntityResponse == null ? void 0 : legalEntityResponse.individual) == null ? void 0 : _a.name.firstName} ${(_b = legalEntityResponse == null ? void 0 : legalEntityResponse.individual) == null ? void 0 : _b.name.lastName}`
24753
24816
  }];
24754
24817
  const handleSignClick = async () => {
24755
24818
  userEvents.addEvent("Clicked ToS signing", {
@@ -24763,7 +24826,7 @@ function ServiceAgreementDropinComponent({
24763
24826
  if (isValid) {
24764
24827
  try {
24765
24828
  setLoadingStatus("loading");
24766
- await handleSign(legalEntity.id, serviceAgreement.id, {
24829
+ await handleSign(legalEntityResponse.id, serviceAgreement.id, {
24767
24830
  acceptedBy: data.signer
24768
24831
  });
24769
24832
  setLoadingStatus("success");
@@ -25119,16 +25182,16 @@ const getFontFaceRule = (fontFamily, fontStyle, fontWeight, fontSrc, additionalF
25119
25182
  }
25120
25183
  return `@font-face {${ruleLines.join(";")}}`;
25121
25184
  };
25122
- const loadFont = (fontFamily, fontStyle, fontWeight, fontSrc, additionalFormats) => {
25185
+ const addStyleTagForFont = (fontFamily, fontStyle, fontWeight, fontSrc, additionalFormats) => {
25123
25186
  const style = document.createElement("style");
25124
25187
  style.setAttribute("type", "text/css");
25125
25188
  style.innerText = getFontFaceRule(fontFamily, fontStyle, fontWeight, fontSrc, additionalFormats);
25126
25189
  document.body.insertBefore(style, document.body.firstChild);
25127
25190
  };
25128
- const loadADLIconFont = (loadingContext) => {
25191
+ const addStyleTagForADLIconFont = (loadingContext) => {
25129
25192
  const fontPath = `${loadingContext}static/fonts`;
25130
25193
  const iconFontPath = `${fontPath}/adyen-kyc-icons`;
25131
- loadFont("adyen-kyc-icons", "normal", "normal", `${iconFontPath}.eot`, {
25194
+ addStyleTagForFont("adyen-kyc-icons", "normal", "normal", `${iconFontPath}.eot`, {
25132
25195
  eot: `${iconFontPath}.eot`,
25133
25196
  woff: `${iconFontPath}.woff`,
25134
25197
  woff2: `${iconFontPath}.woff2`,
@@ -25198,7 +25261,7 @@ function withFormComposer(WrappedComponent, {
25198
25261
  getConfigFor = "contextCountry"
25199
25262
  }) {
25200
25263
  const WithFormComposer = (props) => {
25201
- var _a, _b, _c;
25264
+ var _a, _b, _c, _d;
25202
25265
  const {
25203
25266
  i18n
25204
25267
  } = useI18nContext();
@@ -25502,7 +25565,7 @@ function withFormComposer(WrappedComponent, {
25502
25565
  evaluateConfiguration: (data) => evaluateConfiguration(fieldConfigurations, configCountry, data, isSettingEnabled, requiredFields),
25503
25566
  country: contextCountry,
25504
25567
  onCountryChange,
25505
- legalEntityId: props.legalEntityId,
25568
+ legalEntityId: (_c = props.legalEntityResponse) == null ? void 0 : _c.id,
25506
25569
  problems: props == null ? void 0 : props.problems,
25507
25570
  shouldValidate,
25508
25571
  onNext: handleNextClick,
@@ -25545,7 +25608,7 @@ function withFormComposer(WrappedComponent, {
25545
25608
  validateForm: validateCurrentForm,
25546
25609
  taskName,
25547
25610
  trackNavigation: trackNavigation2,
25548
- verificationErrors: (_c = props == null ? void 0 : props.problems) == null ? void 0 : _c.verificationErrors
25611
+ verificationErrors: (_d = props == null ? void 0 : props.problems) == null ? void 0 : _d.verificationErrors
25549
25612
  })
25550
25613
  });
25551
25614
  const content = jsxs(Fragment, {
@@ -26771,7 +26834,7 @@ function DropinComposerComponent({
26771
26834
  });
26772
26835
  case TaskTypes.PCI_DSS:
26773
26836
  return jsx(PciDropinComponent, {
26774
- legalEntity,
26837
+ legalEntityResponse: legalEntity,
26775
26838
  pciTemplateResponse,
26776
26839
  trackingConfig: {
26777
26840
  topLevelLegalEntity: legalEntityResponse
@@ -26804,7 +26867,7 @@ function DropinComposerComponent({
26804
26867
  });
26805
26868
  case TaskTypes.SERVICE_AGREEMENT:
26806
26869
  return jsx(ServiceAgreementDropinComponent, {
26807
- legalEntity,
26870
+ legalEntityResponse: legalEntity,
26808
26871
  trackingConfig: {
26809
26872
  topLevelLegalEntity: legalEntityResponse
26810
26873
  },
@@ -27146,6 +27209,184 @@ const useComponentApi = (rootLegalEntityId) => {
27146
27209
  };
27147
27210
  }, [base, rootLegalEntityId, sdkToken]);
27148
27211
  };
27212
+ class EventEmitter {
27213
+ constructor() {
27214
+ this.listeners = {
27215
+ next: [],
27216
+ back: [],
27217
+ validate: [],
27218
+ updateLocale: []
27219
+ };
27220
+ this.on = (eventName, listener) => {
27221
+ this.listeners[eventName].push(listener);
27222
+ };
27223
+ this.off = (eventName, toRemove) => {
27224
+ this.listeners[eventName] = this.listeners[eventName].filter((listener) => listener !== toRemove);
27225
+ };
27226
+ this.emit = (eventName, ...data) => {
27227
+ this.listeners[eventName].forEach((listener) => listener(data[0]));
27228
+ };
27229
+ }
27230
+ }
27231
+ function PayoutEmbeddedDropin({
27232
+ legalEntityId,
27233
+ transferInstrumentId,
27234
+ onChange,
27235
+ onSubmit,
27236
+ eventEmitter
27237
+ }) {
27238
+ const {
27239
+ getLegalEntity: getLegalEntity2,
27240
+ getTransferInstrument: getTransferInstrument2,
27241
+ getBankVerificationVendor: getBankVerificationVendor2,
27242
+ getDocument: getDocument2,
27243
+ createDocument: createDocument2,
27244
+ updateDocument: updateDocument2,
27245
+ createTransferInstrument: createTransferInstrument2,
27246
+ updateTransferInstrument: updateTransferInstrument2,
27247
+ createTrustedTransferInstrument: createTrustedTransferInstrument2,
27248
+ handleBankVerificationError: handleBankVerificationError2
27249
+ } = useComponentApi(legalEntityId);
27250
+ const [legalEntity, setLegalEntity] = useState();
27251
+ const [transferInstrument, setTransferInstrument] = useState();
27252
+ const fetchLegalEntity = useCallback(async () => {
27253
+ const le = await getLegalEntity2(legalEntityId);
27254
+ setLegalEntity(le);
27255
+ return le;
27256
+ }, [getLegalEntity2, legalEntityId]);
27257
+ useEffect(() => {
27258
+ (async () => {
27259
+ await fetchLegalEntity();
27260
+ if (transferInstrumentId) {
27261
+ const ti = await getTransferInstrument2(transferInstrumentId);
27262
+ setTransferInstrument(ti);
27263
+ }
27264
+ })();
27265
+ }, [fetchLegalEntity, getTransferInstrument2, transferInstrumentId]);
27266
+ return legalEntity ? jsx(PayoutDetailsDropinComponent, {
27267
+ eventEmitter: eventEmitter ?? new EventEmitter(),
27268
+ transferInstrument,
27269
+ legalEntityResponse: legalEntity,
27270
+ handleGetTransferInstrument: getTransferInstrument2,
27271
+ handleGetBankVerificationVendors: getBankVerificationVendor2,
27272
+ handleGetDocument: getDocument2,
27273
+ handleCreateDocument: createDocument2,
27274
+ handleUpdateDocument: updateDocument2,
27275
+ handleCreateTransferInstrument: createTransferInstrument2,
27276
+ handleUpdateTransferInstrument: updateTransferInstrument2,
27277
+ refreshLegalEntity: fetchLegalEntity,
27278
+ onChange,
27279
+ onSubmit,
27280
+ createTrustedTransferInstrument: createTrustedTransferInstrument2,
27281
+ handleBankVerificationError: handleBankVerificationError2
27282
+ }) : null;
27283
+ }
27284
+ const componentsMap = {
27285
+ individualDropin: IndividualDropinComponent,
27286
+ companyDropin: CompanyDropinComponent,
27287
+ taskList: DropinComposerComponent,
27288
+ payoutAccount: PayoutDetailsDropinComponent,
27289
+ trustDropin: TrustDropinComponent,
27290
+ soleProprietorDropin: SolePropDropinComponent,
27291
+ pci: PciDropinComponent,
27292
+ payoutEmbeddedDropin: PayoutEmbeddedDropin
27293
+ };
27294
+ const refreshSdkToken = async (context, refreshToken) => {
27295
+ const {
27296
+ loadingContext,
27297
+ sdkToken
27298
+ } = context;
27299
+ return httpPost({
27300
+ loadingContext,
27301
+ errorLevel: "warn",
27302
+ errorMessage: `Failed to refresh token`,
27303
+ path: `sessions/refresh`,
27304
+ sdkToken,
27305
+ headers: {
27306
+ "Content-Type": "application/json"
27307
+ }
27308
+ }, {
27309
+ refreshToken
27310
+ });
27311
+ };
27312
+ const SDK_TOKEN_TTL = 6e4;
27313
+ const REFRESH_INTERVAL = SDK_TOKEN_TTL - 5e3;
27314
+ const RETRY_LIMIT = 2;
27315
+ const logger$4 = createLogger("useSdkToken");
27316
+ const useSdkToken = ({
27317
+ initialSdkToken,
27318
+ refreshToken,
27319
+ autheBase
27320
+ }) => {
27321
+ const [sdkToken, setSdkToken] = useState(initialSdkToken);
27322
+ const doRefresh = async (sdkToken2, refreshToken2, retries) => {
27323
+ try {
27324
+ const {
27325
+ token: newSdkToken
27326
+ } = await refreshSdkToken({
27327
+ loadingContext: autheBase,
27328
+ sdkToken: sdkToken2
27329
+ }, refreshToken2);
27330
+ setSdkToken(newSdkToken);
27331
+ } catch (e) {
27332
+ if (!retries) {
27333
+ throw new Error("Unable to refresh token after retries", e);
27334
+ }
27335
+ logger$4.warn("Failed to refresh token. Retrying..", e);
27336
+ await doRefresh(sdkToken2, refreshToken2, retries - 1);
27337
+ }
27338
+ };
27339
+ useEffect(() => {
27340
+ if (!sdkToken || !refreshToken) {
27341
+ return;
27342
+ }
27343
+ const refreshHandler = setInterval(() => {
27344
+ doRefresh(sdkToken, refreshToken, RETRY_LIMIT).catch(() => {
27345
+ clearInterval(refreshHandler);
27346
+ });
27347
+ }, REFRESH_INTERVAL);
27348
+ return () => {
27349
+ clearInterval(refreshHandler);
27350
+ };
27351
+ }, [sdkToken]);
27352
+ return sdkToken;
27353
+ };
27354
+ const AUTHE_API_VERSION = "v1";
27355
+ const AuthProvider = ({
27356
+ children,
27357
+ sdkToken: initialSdkToken,
27358
+ refreshToken,
27359
+ clientKey,
27360
+ loadingContext
27361
+ }) => {
27362
+ const autheBase = `${loadingContext}authe/api/${AUTHE_API_VERSION}/`;
27363
+ const sdkToken = useSdkToken({
27364
+ initialSdkToken,
27365
+ refreshToken,
27366
+ autheBase
27367
+ });
27368
+ const contextValue = useMemo(() => {
27369
+ if (sdkToken && refreshToken) {
27370
+ return {
27371
+ isEmbeddedDropin: true,
27372
+ sdkToken,
27373
+ loadingContext: `${loadingContext}onboardingcomponents/`
27374
+ };
27375
+ }
27376
+ if (clientKey) {
27377
+ return {
27378
+ isEmbeddedDropin: false,
27379
+ clientKey,
27380
+ loadingContext
27381
+ };
27382
+ }
27383
+ throw new Error("Must provide either `sdkToken` and `refreshToken` or `clientKey`");
27384
+ }, [sdkToken, clientKey]);
27385
+ return jsx(AuthContext.Provider, {
27386
+ value: contextValue,
27387
+ children
27388
+ });
27389
+ };
27149
27390
  const getEmbeddedApi = ({
27150
27391
  base,
27151
27392
  sdkToken,
@@ -27363,7 +27604,7 @@ const validatePhoneNumber = async (context, phoneNumber2) => {
27363
27604
  number: phoneNumber2
27364
27605
  });
27365
27606
  };
27366
- const logger$4 = createLogger("verify-id-number");
27607
+ const logger$3 = createLogger("verify-id-number");
27367
27608
  const verifyIdNumber = async (context, request) => {
27368
27609
  const {
27369
27610
  loadingContext,
@@ -27390,13 +27631,13 @@ const verifyIdNumber = async (context, request) => {
27390
27631
  message: "Service did not respond, do not block verification"
27391
27632
  };
27392
27633
  }
27393
- return logger$4.warn(`Unexpected response status ${responseData.status}`);
27634
+ return logger$3.warn(`Unexpected response status ${responseData.status}`);
27394
27635
  },
27395
27636
  path: "v1/verification/idNumber",
27396
27637
  clientKey
27397
27638
  }, request);
27398
27639
  } catch (e) {
27399
- logger$4.warn("WARNING: idNumber verification failed - error:", e);
27640
+ logger$3.warn("WARNING: idNumber verification failed - error:", e);
27400
27641
  }
27401
27642
  };
27402
27643
  const verifyTin = async (context, data) => {
@@ -27476,7 +27717,7 @@ const ConfigurationApiProvider = ({
27476
27717
  rootLegalEntityId
27477
27718
  }) => {
27478
27719
  const authContext = useAuthContext();
27479
- const contextValue = useMemo(() => authContext.isEmbeddedDropin && rootLegalEntityId ? getEmbeddedApi({
27720
+ const contextValue = useMemo(() => authContext.isEmbeddedDropin ? getEmbeddedApi({
27480
27721
  base: authContext.loadingContext,
27481
27722
  sdkToken: authContext.sdkToken,
27482
27723
  rootLegalEntityId
@@ -27489,187 +27730,6 @@ const ConfigurationApiProvider = ({
27489
27730
  children
27490
27731
  });
27491
27732
  };
27492
- class EventEmitter {
27493
- constructor() {
27494
- this.listeners = {
27495
- next: [],
27496
- back: [],
27497
- validate: [],
27498
- updateLocale: []
27499
- };
27500
- this.on = (eventName, listener) => {
27501
- this.listeners[eventName].push(listener);
27502
- };
27503
- this.off = (eventName, toRemove) => {
27504
- this.listeners[eventName] = this.listeners[eventName].filter((listener) => listener !== toRemove);
27505
- };
27506
- this.emit = (eventName, ...data) => {
27507
- this.listeners[eventName].forEach((listener) => listener(data[0]));
27508
- };
27509
- }
27510
- }
27511
- function PayoutEmbeddedDropin({
27512
- legalEntityId,
27513
- transferInstrumentId,
27514
- onChange,
27515
- onSubmit,
27516
- eventEmitter
27517
- }) {
27518
- const {
27519
- getLegalEntity: getLegalEntity2,
27520
- getTransferInstrument: getTransferInstrument2,
27521
- getBankVerificationVendor: getBankVerificationVendor2,
27522
- getDocument: getDocument2,
27523
- createDocument: createDocument2,
27524
- updateDocument: updateDocument2,
27525
- createTransferInstrument: createTransferInstrument2,
27526
- updateTransferInstrument: updateTransferInstrument2,
27527
- createTrustedTransferInstrument: createTrustedTransferInstrument2,
27528
- handleBankVerificationError: handleBankVerificationError2
27529
- } = useComponentApi(legalEntityId);
27530
- const [legalEntity, setLegalEntity] = useState();
27531
- const [transferInstrument, setTransferInstrument] = useState();
27532
- const fetchLegalEntity = useCallback(async () => {
27533
- const le = await getLegalEntity2(legalEntityId);
27534
- setLegalEntity(le);
27535
- return le;
27536
- }, [getLegalEntity2, legalEntityId]);
27537
- useEffect(() => {
27538
- (async () => {
27539
- await fetchLegalEntity();
27540
- if (transferInstrumentId) {
27541
- const ti = await getTransferInstrument2(transferInstrumentId);
27542
- setTransferInstrument(ti);
27543
- }
27544
- })();
27545
- }, [fetchLegalEntity, getTransferInstrument2, transferInstrumentId]);
27546
- return legalEntity ? jsx(ConfigurationApiProvider, {
27547
- rootLegalEntityId: legalEntityId,
27548
- children: jsx(PayoutDetailsDropinComponent, {
27549
- eventEmitter: eventEmitter ?? new EventEmitter(),
27550
- transferInstrument,
27551
- legalEntityResponse: legalEntity,
27552
- handleGetTransferInstrument: getTransferInstrument2,
27553
- handleGetBankVerificationVendors: getBankVerificationVendor2,
27554
- handleGetDocument: getDocument2,
27555
- handleCreateDocument: createDocument2,
27556
- handleUpdateDocument: updateDocument2,
27557
- handleCreateTransferInstrument: createTransferInstrument2,
27558
- handleUpdateTransferInstrument: updateTransferInstrument2,
27559
- refreshLegalEntity: fetchLegalEntity,
27560
- onChange,
27561
- onSubmit,
27562
- createTrustedTransferInstrument: createTrustedTransferInstrument2,
27563
- handleBankVerificationError: handleBankVerificationError2
27564
- })
27565
- }) : null;
27566
- }
27567
- const componentsMap = {
27568
- individualDropin: IndividualDropinComponent,
27569
- companyDropin: CompanyDropinComponent,
27570
- taskList: DropinComposerComponent,
27571
- payoutAccount: PayoutDetailsDropinComponent,
27572
- trustDropin: TrustDropinComponent,
27573
- soleProprietorDropin: SolePropDropinComponent,
27574
- pci: PciDropinComponent,
27575
- payoutEmbeddedDropin: PayoutEmbeddedDropin
27576
- };
27577
- const refreshSdkToken = async (context, refreshToken) => {
27578
- const {
27579
- loadingContext,
27580
- sdkToken
27581
- } = context;
27582
- return httpPost({
27583
- loadingContext,
27584
- errorLevel: "warn",
27585
- errorMessage: `Failed to refresh token`,
27586
- path: `sessions/refresh`,
27587
- sdkToken,
27588
- headers: {
27589
- "Content-Type": "application/json"
27590
- }
27591
- }, {
27592
- refreshToken
27593
- });
27594
- };
27595
- const SDK_TOKEN_TTL = 6e4;
27596
- const REFRESH_INTERVAL = SDK_TOKEN_TTL - 5e3;
27597
- const RETRY_LIMIT = 2;
27598
- const logger$3 = createLogger("useSdkToken");
27599
- const useSdkToken = ({
27600
- initialSdkToken,
27601
- refreshToken,
27602
- autheBase
27603
- }) => {
27604
- const [sdkToken, setSdkToken] = useState(initialSdkToken);
27605
- const doRefresh = async (sdkToken2, refreshToken2, retries) => {
27606
- try {
27607
- const {
27608
- token: newSdkToken
27609
- } = await refreshSdkToken({
27610
- loadingContext: autheBase,
27611
- sdkToken: sdkToken2
27612
- }, refreshToken2);
27613
- setSdkToken(newSdkToken);
27614
- } catch (e) {
27615
- if (!retries) {
27616
- throw new Error("Unable to refresh token after retries", e);
27617
- }
27618
- logger$3.warn("Failed to refresh token. Retrying..", e);
27619
- await doRefresh(sdkToken2, refreshToken2, retries - 1);
27620
- }
27621
- };
27622
- useEffect(() => {
27623
- if (!sdkToken || !refreshToken) {
27624
- return;
27625
- }
27626
- const refreshHandler = setInterval(() => {
27627
- doRefresh(sdkToken, refreshToken, RETRY_LIMIT).catch(() => {
27628
- clearInterval(refreshHandler);
27629
- });
27630
- }, REFRESH_INTERVAL);
27631
- return () => {
27632
- clearInterval(refreshHandler);
27633
- };
27634
- }, [sdkToken]);
27635
- return sdkToken;
27636
- };
27637
- const AUTHE_API_VERSION = "v1";
27638
- const AuthProvider = ({
27639
- children,
27640
- sdkToken: initialSdkToken,
27641
- refreshToken,
27642
- clientKey,
27643
- loadingContext
27644
- }) => {
27645
- const autheBase = `${loadingContext}authe/api/${AUTHE_API_VERSION}/`;
27646
- const sdkToken = useSdkToken({
27647
- initialSdkToken,
27648
- refreshToken,
27649
- autheBase
27650
- });
27651
- const contextValue = useMemo(() => {
27652
- if (sdkToken && refreshToken) {
27653
- return {
27654
- isEmbeddedDropin: true,
27655
- sdkToken,
27656
- loadingContext: `${loadingContext}onboardingcomponents/`
27657
- };
27658
- }
27659
- if (clientKey) {
27660
- return {
27661
- isEmbeddedDropin: false,
27662
- clientKey,
27663
- loadingContext
27664
- };
27665
- }
27666
- throw new Error("Must provide either `sdkToken` and `refreshToken` or `clientKey`");
27667
- }, [sdkToken, clientKey]);
27668
- return jsx(AuthContext.Provider, {
27669
- value: contextValue,
27670
- children
27671
- });
27672
- };
27673
27733
  const logger$2 = createLogger("CoreProvider");
27674
27734
  const CoreProvider = ({
27675
27735
  contextCountry: initialContextCountry,
@@ -27687,7 +27747,7 @@ const CoreProvider = ({
27687
27747
  const [accountHolder2, setAccountHolder] = useState(null);
27688
27748
  const [accountFormat, setAccountFormat] = useState("local");
27689
27749
  const init2 = async () => {
27690
- loadADLIconFont(loadingContext);
27750
+ addStyleTagForADLIconFont(loadingContext);
27691
27751
  try {
27692
27752
  const allowedCountries = (await getAllowedCountries2()).countries;
27693
27753
  if (!allowedCountries.includes(contextCountry)) {
@@ -27697,9 +27757,10 @@ const CoreProvider = ({
27697
27757
  - ${listify(allowedCountries)}.
27698
27758
  `);
27699
27759
  }
27700
- setLoaded(true);
27701
27760
  } catch (e) {
27702
- logger$2.log(e);
27761
+ logger$2.warn(e);
27762
+ } finally {
27763
+ setLoaded(true);
27703
27764
  }
27704
27765
  };
27705
27766
  useEffect(() => {
@@ -27938,6 +27999,13 @@ class BaseElement {
27938
27999
  }
27939
28000
  }
27940
28001
  }
28002
+ const getRootLegalEntityId = (componentProps) => {
28003
+ if ("legalEntityId" in componentProps)
28004
+ return componentProps.legalEntityId;
28005
+ if ("legalEntityResponse" in componentProps)
28006
+ return componentProps.legalEntityResponse.id;
28007
+ throw new Error("You must provide either `legalEntityId` or `legalEntityResponse`");
28008
+ };
27941
28009
  class UIElement extends BaseElement {
27942
28010
  constructor(props) {
27943
28011
  super(props);
@@ -27949,6 +28017,7 @@ class UIElement extends BaseElement {
27949
28017
  clientKey: this.props.clientKey,
27950
28018
  loadingContext: this.props.loadingContext,
27951
28019
  children: jsx(ConfigurationApiProvider, {
28020
+ rootLegalEntityId: getRootLegalEntityId(this.props.componentProps),
27952
28021
  children: jsx(CoreProvider, {
27953
28022
  contextCountry: this.props.contextCountry,
27954
28023
  isReview: this.props.isReview,
@@ -28447,7 +28516,7 @@ const pciDropinSchema = {
28447
28516
  taskType: {
28448
28517
  type: "string"
28449
28518
  },
28450
- legalEntity: {
28519
+ legalEntityResponse: {
28451
28520
  type: "object",
28452
28521
  required: true,
28453
28522
  propertiesSchema: {
@@ -28480,7 +28549,8 @@ const payoutEmbeddedDropinSchema = {
28480
28549
  type: "function"
28481
28550
  },
28482
28551
  legalEntityId: {
28483
- type: "string"
28552
+ type: "string",
28553
+ required: true
28484
28554
  }
28485
28555
  };
28486
28556
  const componentsSchemaMap = {