@adyen/kyc-components 2.4.1 → 2.4.2

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.
@@ -4539,7 +4539,7 @@ const lengthValidationPatterns = {
4539
4539
  message: "validationEnter9Or12Digits"
4540
4540
  }
4541
4541
  };
4542
- const bankStatementDescriptionPattern = /^[$\xA2-\xA5\u058F\u060B\u09F2\u09F3\u09FB\u0AF1\u0BF9\u0E3F\u17DB\u20A0-\u20BD\uA838\uFDFC\uFE69\uFF04\uFFE0\uFFE1\uFFE5\uFFE6a-zA-Z0-9-."_,:;'*!@#%()+?¿/&「」]*$/;
4542
+ const bankStatementDescriptionPattern = /^[\s+$\xA2-\xA5\u058F\u060B\u09F2\u09F3\u09FB\u0AF1\u0BF9\u0E3F\u17DB\u20A0-\u20BD\uA838\uFDFC\uFE69\uFF04\uFFE0\uFFE1\uFFE5\uFFE6a-zA-Z0-9-."_,:;'*!@#%()+?¿/&「」]*$/;
4543
4543
  const businessRegistrationNumberPatterns = {
4544
4544
  [CountryCodes.Australia]: {
4545
4545
  default: {
@@ -10406,6 +10406,55 @@ const SearchAddress = ({
10406
10406
  })
10407
10407
  });
10408
10408
  };
10409
+ const createRegExpByDigits = (digits) => new RegExp(`^\\d{${digits}}$`);
10410
+ const postalCodePatterns = {
10411
+ [CountryCodes.Australia]: createRegExpByDigits(4),
10412
+ [CountryCodes.Austria]: createRegExpByDigits(4),
10413
+ [CountryCodes.Belgium]: /^[1-9]\d{3}$/,
10414
+ [CountryCodes.Brazil]: createRegExpByDigits(8),
10415
+ [CountryCodes.Bulgaria]: createRegExpByDigits(4),
10416
+ [CountryCodes.Canada]: /^[ABCEGHJKLMNPRSTVXY]\d[A-Z][ -]?(?:\d[A-Z]\d)?$/,
10417
+ [CountryCodes.Croatia]: /^([1-5])\d{4}$/,
10418
+ [CountryCodes.Cyprus]: createRegExpByDigits(4),
10419
+ [CountryCodes.CzechRepublic]: /^\d{3} ?\d{2}$/,
10420
+ [CountryCodes.Denmark]: /^(?:DK-)?\d{4}$/,
10421
+ [CountryCodes.Estonia]: createRegExpByDigits(5),
10422
+ [CountryCodes.Finland]: createRegExpByDigits(5),
10423
+ [CountryCodes.France]: createRegExpByDigits(5),
10424
+ [CountryCodes.Georgia]: createRegExpByDigits(4),
10425
+ [CountryCodes.Germany]: createRegExpByDigits(5),
10426
+ [CountryCodes.Gibraltar]: /^GX11[ -]?1AA$/,
10427
+ [CountryCodes.Greece]: /^\d{3} ?\d{2}$/,
10428
+ [CountryCodes.Hungary]: createRegExpByDigits(4),
10429
+ [CountryCodes.Iceland]: createRegExpByDigits(3),
10430
+ [CountryCodes.Ireland]: /^(?:[ACDEFHKNPRTVWXY]\d{2}|D6W)[ -]?[0-9ACDEFHKNPRTVWXY]{4}$/,
10431
+ [CountryCodes.Italy]: createRegExpByDigits(5),
10432
+ [CountryCodes.Japan]: /^\d{3}-\d{4}$/,
10433
+ [CountryCodes.Latvia]: /^(?:LV-)?\d{4}$/,
10434
+ [CountryCodes.Liechtenstein]: createRegExpByDigits(4),
10435
+ [CountryCodes.Lithuania]: /^(?:LT-)?\d{4,5}$/,
10436
+ [CountryCodes.Luxembourg]: createRegExpByDigits(4),
10437
+ [CountryCodes.Malaysia]: createRegExpByDigits(5),
10438
+ [CountryCodes.Malta]: /^[A-Za-z]{2,3} ?\d{2}(?:\d{2})?$/,
10439
+ [CountryCodes.Monaco]: /^980\d{2}$/,
10440
+ [CountryCodes.Netherlands]: /^(?:NL-)?[1-9]\d{3} ?(?:[ABCDEFGHIJKLMNOPQRTUVWXYZ][A-Z]|S[BCEFGHIJKLMNOPQRTUVWXYZ])$/,
10441
+ [CountryCodes.NewZealand]: createRegExpByDigits(4),
10442
+ [CountryCodes.Norway]: createRegExpByDigits(4),
10443
+ [CountryCodes.Poland]: /^\d{2}-\d{3}$/,
10444
+ [CountryCodes.Portugal]: /^[1-9]\d{3}([- ]?\d{3})?$/,
10445
+ [CountryCodes.PuertoRico]: createRegExpByDigits(5),
10446
+ [CountryCodes.Romania]: createRegExpByDigits(6),
10447
+ [CountryCodes.Slovakia]: /^(SK-)?\d{5}$/,
10448
+ [CountryCodes.Slovenia]: /^(SI-)?\d{4}$/,
10449
+ [CountryCodes.Singapore]: createRegExpByDigits(6),
10450
+ [CountryCodes.Spain]: /(?:0[1-9]|[1-4]\d|5[0-2])\d{3}/,
10451
+ [CountryCodes.Sweden]: createRegExpByDigits(5),
10452
+ [CountryCodes.Switzerland]: /^[1-9]\d{3}$/,
10453
+ // https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Validation
10454
+ // follows most of the bullet points but not all the restrictions
10455
+ [CountryCodes.UnitedKingdom]: /^[ABCDEFGHIJKLMNOPRSTUWYZ](?:[ABCDEFGHKLMNOPQRSTUVWXY][0-9][ABEHMNPRVWXY0-9]?|[0-9][ABCDEFGHJKPSTUW0-9]?)(?: ?[0-9][ABDEFGHJLNPQRSTUWXYZ]{1,2})?$/,
10456
+ [CountryCodes.UnitedStates]: /^\d{5}(?:[ -]?\d{4})?$/
10457
+ };
10409
10458
  const createFormatByDigits = (digits) => {
10410
10459
  const format = new Array(digits).fill("9").join("");
10411
10460
  return {
@@ -10640,53 +10689,6 @@ const countrySpecificFormatters = {
10640
10689
  postalCode: createFormatByDigits(5)
10641
10690
  }
10642
10691
  };
10643
- const createPatternByDigits = (digits) => new RegExp(`\\d{${digits}}`);
10644
- const postalCodePatterns = {
10645
- [CountryCodes.Australia]: createPatternByDigits(4),
10646
- [CountryCodes.Austria]: createPatternByDigits(4),
10647
- [CountryCodes.Belgium]: /[1-9]\d{3}/,
10648
- [CountryCodes.Brazil]: createPatternByDigits(8),
10649
- [CountryCodes.Bulgaria]: createPatternByDigits(4),
10650
- [CountryCodes.Canada]: /[ABCEGHJ-NPRSTVXY]\d[A-Z][ -]?\d[A-Z]\d/,
10651
- [CountryCodes.Croatia]: /^([1-5])[0-9]{4}$/,
10652
- [CountryCodes.Cyprus]: createPatternByDigits(4),
10653
- [CountryCodes.CzechRepublic]: /\d{3}\s?\d{2}/,
10654
- [CountryCodes.Denmark]: /^(DK-)?[0-9]{4}$/,
10655
- [CountryCodes.Estonia]: createPatternByDigits(5),
10656
- [CountryCodes.Finland]: createPatternByDigits(5),
10657
- [CountryCodes.France]: createPatternByDigits(5),
10658
- [CountryCodes.Georgia]: createPatternByDigits(4),
10659
- [CountryCodes.Germany]: createPatternByDigits(5),
10660
- [CountryCodes.Gibraltar]: /^GX11[ -]?1AA$/,
10661
- [CountryCodes.Greece]: /^\d{3}\s?\d{2}$/,
10662
- [CountryCodes.Hungary]: createPatternByDigits(4),
10663
- [CountryCodes.Iceland]: createPatternByDigits(3),
10664
- [CountryCodes.Ireland]: /(?:^[AC-FHKNPRTV-Y][0-9]{2}|D6W)[ -]?[0-9AC-FHKNPRTV-Y]{4}/,
10665
- [CountryCodes.Italy]: createPatternByDigits(5),
10666
- [CountryCodes.Japan]: /^\d{3}-\d{4}$/,
10667
- [CountryCodes.Latvia]: /^(LV-)?[0-9]{4}$/,
10668
- [CountryCodes.Liechtenstein]: createPatternByDigits(4),
10669
- [CountryCodes.Lithuania]: /^(LT-)?[0-9]{4,5}$/,
10670
- [CountryCodes.Luxembourg]: createPatternByDigits(4),
10671
- [CountryCodes.Malaysia]: createPatternByDigits(5),
10672
- [CountryCodes.Malta]: /^[A-Za-z]{2,3} ?\d{2}(?:\d{2})?$/,
10673
- [CountryCodes.Monaco]: /^980\d{2}$/,
10674
- [CountryCodes.Netherlands]: /(?:NL-)?[1-9]\d{3} ?(?:[A-EGHJ-NPRTVWXZ][A-EGHJ-NPRSTVWXZ]|S[BCEGHJ-NPRTVWXZ])/,
10675
- [CountryCodes.NewZealand]: createPatternByDigits(4),
10676
- [CountryCodes.Norway]: createPatternByDigits(4),
10677
- [CountryCodes.Poland]: /^\d{2}-\d{3}$/,
10678
- [CountryCodes.Portugal]: /^([1-9]\d{3})([- ]?(\d{3})? *)$/,
10679
- [CountryCodes.PuertoRico]: createPatternByDigits(5),
10680
- [CountryCodes.Romania]: createPatternByDigits(6),
10681
- [CountryCodes.Slovakia]: /^(SK-)?[0-9]{5}$/,
10682
- [CountryCodes.Slovenia]: /^(SI-)?[0-9]{4}$/,
10683
- [CountryCodes.Singapore]: createPatternByDigits(6),
10684
- [CountryCodes.Spain]: /(?:0[1-9]|[1-4]\d|5[0-2])\d{3}/,
10685
- [CountryCodes.Sweden]: createPatternByDigits(5),
10686
- [CountryCodes.Switzerland]: /[1-9]\d{3}/,
10687
- [CountryCodes.UnitedKingdom]: /^([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$/,
10688
- [CountryCodes.UnitedStates]: /^(\d{5})(-?(\d{4})? *)$/
10689
- };
10690
10692
  const addressValidationRules = (country2) => {
10691
10693
  var _a, _b;
10692
10694
  const postalCodeFormat = (_b = (_a = countrySpecificFormatters[country2]) == null ? void 0 : _a.postalCode) == null ? void 0 : _b.format;
@@ -20989,6 +20991,7 @@ const getPayoutAccountHolderName = (legalEntity, i18n) => {
20989
20991
  }
20990
20992
  return getLegalEntityNameBasedOnType(legalEntity);
20991
20993
  };
20994
+ const isNewEntity = Symbol("isNewEntity");
20992
20995
  const splitAtFirstOccurrence = (str, separator) => {
20993
20996
  const firstOccurrence = str.indexOf(separator);
20994
20997
  if (firstOccurrence === -1)
@@ -21072,6 +21075,9 @@ const getTrustMembers = (trustLE, rootLegalEntity, exemptSettlorLE) => {
21072
21075
  return [mapRootLegalEntityToTrustMember(rootLegalEntity), ...mapEntityAssociationsToTrustMembers(trustLE.id, trustLE.entityAssociations ?? [], exemptSettlorLE), ...mapUndefinedBeneficiaryInfoToTrustMembers(((_a = trustLE.trust) == null ? void 0 : _a.undefinedBeneficiaryInfo) ?? [])];
21073
21076
  };
21074
21077
  const mapTrustMemberToEntityAssociations = (trustMember) => {
21078
+ if (trustMember.legalEntityId === isNewEntity) {
21079
+ throw Error("Cannot map a new trust member, you must create it first");
21080
+ }
21075
21081
  if (trustMember.trustMemberType === "exemptSettlor")
21076
21082
  return [{
21077
21083
  legalEntityId: trustMember.legalEntityId,
@@ -21106,7 +21112,9 @@ const addOrUpdateUndefinedBeneficiary = async ({
21106
21112
  const otherUndefinedBeneficiaries = ((_b = (_a = trust.trust) == null ? void 0 : _a.undefinedBeneficiaryInfo) == null ? void 0 : _b.filter((ub) => ub.reference !== newOrUpdated.reference)) ?? [];
21107
21113
  const patchLE = {
21108
21114
  trust: {
21109
- undefinedBeneficiaryInfo: [...otherUndefinedBeneficiaries, {
21115
+ undefinedBeneficiaryInfo: [...otherUndefinedBeneficiaries, newOrUpdated.reference === isNewEntity ? {
21116
+ description: newOrUpdated.description
21117
+ } : {
21110
21118
  reference: newOrUpdated.reference,
21111
21119
  description: newOrUpdated.description
21112
21120
  }]
@@ -24483,21 +24491,21 @@ const convertDataToTrustMember = (data, existingTrustMember) => {
24483
24491
  firstName: data.firstName ?? "",
24484
24492
  lastName: data.lastName ?? ""
24485
24493
  },
24486
- legalEntityId: existingId ?? ""
24494
+ legalEntityId: existingId ?? isNewEntity
24487
24495
  };
24488
24496
  if (data.role.includes("undefinedBeneficiary"))
24489
24497
  return {
24490
24498
  trustMemberType: "undefinedBeneficiary",
24491
24499
  roles: [TrustMemberTypes.UNDEFINED_BENEFICIARY],
24492
24500
  description: data.descriptionUndefinedBeneficiary ?? "",
24493
- reference: existingId ?? ""
24501
+ reference: existingId ?? isNewEntity
24494
24502
  };
24495
24503
  if (data.entityType === LegalEntityType.ORGANIZATION)
24496
24504
  return {
24497
24505
  trustMemberType: "company",
24498
24506
  roles: data.role,
24499
24507
  legalEntityType: LegalEntityType.ORGANIZATION,
24500
- legalEntityId: existingId ?? "",
24508
+ legalEntityId: existingId ?? isNewEntity,
24501
24509
  name: ""
24502
24510
  };
24503
24511
  if (data.entityType === LegalEntityType.INDIVIDUAL)
@@ -24505,7 +24513,7 @@ const convertDataToTrustMember = (data, existingTrustMember) => {
24505
24513
  trustMemberType: "regular",
24506
24514
  roles: data.role,
24507
24515
  legalEntityType: LegalEntityType.INDIVIDUAL,
24508
- legalEntityId: existingId ?? "",
24516
+ legalEntityId: existingId ?? isNewEntity,
24509
24517
  name: ""
24510
24518
  };
24511
24519
  }
@@ -26144,7 +26152,7 @@ function DropinComposerComponent({
26144
26152
  };
26145
26153
  const addOrUpdateTrustMember = async (updated, existing) => {
26146
26154
  if ((existing == null ? void 0 : existing.trustMemberType) === "undefinedBeneficiary" && updated.trustMemberType === "undefinedBeneficiary" && existing.description === updated.description) {
26147
- await refreshTrustAndRunOnSubmit(trust);
26155
+ await refreshTrustAndRunOnSubmit(trust, 1);
26148
26156
  return;
26149
26157
  }
26150
26158
  try {
@@ -26193,7 +26201,7 @@ function DropinComposerComponent({
26193
26201
  label: i18n.get("successfullyUpdatedDetails"),
26194
26202
  type: ToastType.SUCCESS
26195
26203
  });
26196
- await refreshTrustAndRunOnSubmit(trust);
26204
+ await refreshTrustAndRunOnSubmit(trust, 1);
26197
26205
  } catch (err) {
26198
26206
  logger$1.error(err);
26199
26207
  showToast({
@@ -26282,11 +26290,11 @@ function DropinComposerComponent({
26282
26290
  };
26283
26291
  const onNavigateToTrustMember = async (tm) => {
26284
26292
  try {
26285
- if (tm == null ? void 0 : tm.legalEntityId) {
26293
+ if (tm.legalEntityId === isNewEntity) {
26294
+ setAssociatedLegalEntity(null);
26295
+ } else {
26286
26296
  const response = await (args == null ? void 0 : args.handleGetLegalEntity(tm.legalEntityId));
26287
26297
  setAssociatedLegalEntity(response);
26288
- } else {
26289
- setAssociatedLegalEntity(null);
26290
26298
  }
26291
26299
  setTrustMember(tm);
26292
26300
  onNavigateTo(tm.trustMemberType === "company" ? TaskTypes.TRUST_MEMBER_COMPANY : TaskTypes.TRUST_MEMBER_INDIVIDUAL);
@@ -26363,9 +26371,9 @@ function DropinComposerComponent({
26363
26371
  await refreshLegalEntity();
26364
26372
  navigateBack(backStepCount);
26365
26373
  };
26366
- const refreshTrustAndRunOnSubmit = async (data) => {
26374
+ const refreshTrustAndRunOnSubmit = async (data, backSteps) => {
26367
26375
  await refreshTrust();
26368
- await componentOnSubmit(data, 2);
26376
+ await componentOnSubmit(data, backSteps);
26369
26377
  };
26370
26378
  const onPciDownload = async () => {
26371
26379
  const baseTrackingPayload = getBaseTrackingPayload({
@@ -26565,7 +26573,7 @@ function DropinComposerComponent({
26565
26573
  capabilities: Object.keys((legalEntityResponse == null ? void 0 : legalEntityResponse.capabilities) ?? {}),
26566
26574
  onChange: componentOnChange,
26567
26575
  eventEmitter,
26568
- onSubmit: refreshTrustAndRunOnSubmit,
26576
+ onSubmit: (data) => refreshTrustAndRunOnSubmit(data, 2),
26569
26577
  handleBackClick: navigateBack,
26570
26578
  handleHomeClick: () => onNavigateTo(TaskTypes.TRUST_MEMBER_OVERVIEW),
26571
26579
  homeButtonLabel: i18n.get("saveAndGoToOverview"),
@@ -26613,7 +26621,7 @@ function DropinComposerComponent({
26613
26621
  problems: (_a2 = capabilityProblems == null ? void 0 : capabilityProblems.LegalEntity) == null ? void 0 : _a2[legalEntity.id],
26614
26622
  onChange: componentOnChange,
26615
26623
  eventEmitter,
26616
- onSubmit: refreshTrustAndRunOnSubmit,
26624
+ onSubmit: (data) => refreshTrustAndRunOnSubmit(data, 2),
26617
26625
  handleBackClick: navigateBack,
26618
26626
  handleHomeClick: navigateBack,
26619
26627
  homeButtonLabel: i18n.get("saveAndGoToOverview"),
@@ -1,5 +1,6 @@
1
1
  import { LegalEntityType } from '../../core/models/api/legal-entity-type';
2
2
  import { TrustMemberType, TrustMemberTypes } from '../../core/models/api/trust-member-type';
3
+ import { IsNewEntity } from '../../utils/isNewEntity';
3
4
  import { SettlorExemptionReason, TrustMemberLegalEntityType } from '../TrustRoleAndEntityType/types';
4
5
  /**
5
6
  * The top level legal entity that the trust LE is associated to.
@@ -19,7 +20,7 @@ export interface RegularTrustMember {
19
20
  trustMemberType: 'regular';
20
21
  roles: TrustMemberType[];
21
22
  legalEntityType: LegalEntityType.INDIVIDUAL;
22
- legalEntityId: string;
23
+ legalEntityId: string | IsNewEntity;
23
24
  name: string;
24
25
  }
25
26
  /**
@@ -31,7 +32,7 @@ export interface CompanyTrustMember {
31
32
  trustMemberType: 'company';
32
33
  roles: TrustMemberType[];
33
34
  legalEntityType: LegalEntityType.ORGANIZATION;
34
- legalEntityId: string;
35
+ legalEntityId: string | IsNewEntity;
35
36
  name: string;
36
37
  ownerId?: string;
37
38
  }
@@ -43,7 +44,7 @@ export interface ExemptSettlor {
43
44
  trustMemberType: 'exemptSettlor';
44
45
  roles: [TrustMemberTypes.SETTLOR];
45
46
  legalEntityType: LegalEntityType.INDIVIDUAL;
46
- legalEntityId: string;
47
+ legalEntityId: string | IsNewEntity;
47
48
  settlorExemptionReason: SettlorExemptionReason[];
48
49
  exemptSettlorName: {
49
50
  firstName: string;
@@ -56,7 +57,7 @@ export interface ExemptSettlor {
56
57
  export interface UndefinedBeneficiary {
57
58
  trustMemberType: 'undefinedBeneficiary';
58
59
  roles: [TrustMemberTypes.UNDEFINED_BENEFICIARY];
59
- reference: string;
60
+ reference: string | IsNewEntity;
60
61
  description: string;
61
62
  }
62
63
  /**
@@ -0,0 +1,2 @@
1
+ export declare const isNewEntity: unique symbol;
2
+ export type IsNewEntity = typeof isNewEntity;
@@ -0,0 +1,2 @@
1
+ import { CountryCode } from '../../core/models/country-code';
2
+ export declare const postalCodePatterns: Partial<Record<CountryCode, RegExp>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adyen/kyc-components",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "files": [