@adyen/kyc-components
Version:
This guide assumes that you have already an account with Adyen. A legalEntity needs to be created, and you need to have a `legalEntityId` to instatiate a Component.
269 lines (268 loc) • 13.4 kB
JavaScript
try {
let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "54f6b608-cc1e-4059-aeae-82d42db961d3", e._sentryDebugIdIdentifier = "sentry-dbid-54f6b608-cc1e-4059-aeae-82d42db961d3");
} catch (e) {}
import { p as TaskTypes } from "./entityAssociationUtil-BEzUdPbm.js";
import { lazy } from "preact/compat";
import { matchRoute, useLocation } from "wouter-preact";
//#region src/router/getDefaultTask.ts
var getDefaultTask = ({ legalEntity, canSeeEntitySelection, canChangeEntityType, showIntroduction, shouldShowSingpassSelection, showServiceAgreementsFirst, showBusinessFinancingFirst }) => {
const hasLegalEntityProgressedBeyondEntitySelection = hasProgressedBeyondEntitySelection(legalEntity);
if (showServiceAgreementsFirst) return TaskTypes.SERVICE_AGREEMENT;
if (showBusinessFinancingFirst) return TaskTypes.BUSINESS_FINANCING;
if (canChangeEntityType && canSeeEntitySelection && !hasLegalEntityProgressedBeyondEntitySelection) return TaskTypes.BUSINESS_TYPE_SELECTION;
if (showIntroduction) return TaskTypes.INTRODUCTION;
if (shouldShowSingpassSelection) return TaskTypes.SINGPASS_SELECTION;
return TaskTypes.TASKS_OVERVIEW;
};
/**
* Determine if the LE has data beyond entity selection.
*/
var hasProgressedBeyondEntitySelection = (legalEntity) => {
const hasOwnEntityAssocation = legalEntity.entityAssociations?.some((ea) => ea.associatorId === legalEntity.id);
const hasOrganizationType = legalEntity.organization?.type;
return hasOwnEntityAssocation || !!hasOrganizationType;
};
//#endregion
//#region src/router/routeConfig.ts
var Introduction = lazy(async () => (await import("./Introduction-DIfncKsI.js")).Introduction);
var BusinessTypeSelectionPage = lazy(async () => (await import("./BusinessTypeSelectionPage-CR-GoUfd.js")).BusinessTypeSelectionPage);
var SingpassSelection = lazy(async () => (await import("./SingpassSelection-CB1J2MS6.js")).SingpassSelection);
var AccountSetupRejected = lazy(async () => (await import("./AccountSetupRejected-CFihsePp.js")).AccountSetupRejected);
var DecisionMakers = lazy(async () => (await import("./DecisionMakers-CvQB-65l.js")).DecisionMakers);
var CustomerSupport = lazy(async () => (await import("./CustomerSupport-mAYocjaE.js")).CustomerSupport);
var Review = lazy(async () => (await import("./Review-nNDDLyLy.js")).Review);
var SignPCIComponent = lazy(async () => (await import("./SignPCIComponent-DygENf2d.js")).SignPCIComponent);
var AcceptTermsOfService = lazy(async () => (await import("./AcceptTermsOfServiceComponent-DUEllUW-.js")).AcceptTermsOfServiceComponent);
var TaxReportingDropin = lazy(async () => (await import("./TaxReportingDropin-53cxCQA-.js")).TaxReportingDropin);
var PayoutDetailsPage = lazy(async () => (await import("./PayoutDetailsPage-Cykyoqxm.js")).PayoutDetailsPage);
var RootBusinessDetailsPage = lazy(async () => (await import("./RootBusinessDetailsPage-DinhHQY-.js")).RootBusinessDetailsPage);
var RootBusinessLinesPage = lazy(async () => (await import("./RootBusinessLinesPage-Cq8HSU7U.js")).RootBusinessLinesPage);
var SoleProprietorshipPage = lazy(async () => (await import("./SoleProprietorshipPage-CpL77xpx.js")).SoleProprietorshipPage);
var TrustMemberCompanyPage = lazy(async () => (await import("./TrustMemberCompanyPage-f0ig0gr4.js")).TrustMemberCompanyPage);
var TrustMemberIndividualPage = lazy(async () => (await import("./TrustMemberIndividualPage-BT092bYS.js")).TrustMemberIndividualPage);
var TrustMemberRoleAndTypePage = lazy(async () => (await import("./TrustMemberRoleAndTypePage-qA2YQHNk.js")).TrustMemberRoleAndTypePage);
var TrustMembersOverview = lazy(async () => (await import("./TrustMembersOverview-BtX5x5Qn.js")).TrustMembersOverview);
var UnincorporatedPartnershipMemberCompanyPage = lazy(async () => (await import("./UnincorporatedPartnershipMemberCompanyPage-rDuqBAW0.js")).UnincorporatedPartnershipMemberCompanyPage);
var UnincorporatedPartnershipIndividualPage = lazy(async () => (await import("./UnincorporatedPartnershipIndividualPage-Dr6ap4ao.js")).UnincorporatedPartnershipIndividualPage);
var UnincorporatedPartnershipMemberRoleAndTypePage = lazy(async () => (await import("./UnincorporatedPartnershipMemberRoleAndTypePage-FGooutwg.js")).UnincorporatedPartnershipMemberRoleAndTypePage);
var UnincorporatedPartnershipMembersOverview = lazy(async () => (await import("./UnincorporatedPartnershipMembersOverview-CYv76pOg.js")).UnincorporatedPartnershipMembersOverview);
var BusinessFinancingPage = lazy(async () => (await import("./BusinessFinancingPage-RQvWOuzI.js")).BusinessFinancingPage);
var TrustDetailsPage = lazy(async () => (await import("./TrustDetailsPage-D-_3lCEz.js")).TrustDetailsPage);
var SourceOfFundsPage = lazy(async () => (await import("./SourceOfFundsPage-D0TFuyNy.js")).SourceOfFundsPage);
var RootIndividualDetailsPage = lazy(async () => (await import("./RootIndividualDetailsPage-D1j0wZoW.js")).RootIndividualDetailsPage);
var LegalRepresentativeDetailsPage = lazy(async () => (await import("./LegalRepresentativeDetailsPage-Cq6G8Lj1.js")).LegalRepresentativeDetailsPage);
var DecisionMakerDetailsPage = lazy(async () => (await import("./DecisionMakerDetailsPage-EF_IDRkz.js")).DecisionMakerDetailsPage);
var InvitedDecisionMakerComponent = lazy(async () => (await import("./InvitedDecisionMakerComponent-hScE7oD3.js")).InvitedDecisionMakerComponent);
var ROUTE_CONFIG = {
[]: { path: "/tasks" },
[]: {
path: "/introduction",
Component: Introduction
},
[]: {
path: "/business-type-selection",
Component: BusinessTypeSelectionPage
},
[]: {
path: "/singpass-selection",
Component: SingpassSelection
},
[]: {
path: "/individual",
Component: RootIndividualDetailsPage
},
[]: {
path: "/business",
Component: RootBusinessDetailsPage
},
[]: {
path: "/business-lines",
Component: RootBusinessLinesPage
},
[]: {
path: "/decision-makers",
Component: DecisionMakers
},
[]: {
path: "/decision-maker/:parentId/:decisionMakerId?",
Component: DecisionMakerDetailsPage
},
[]: {
path: "/payout/:transferInstrumentId?",
Component: PayoutDetailsPage
},
[]: {
path: "/payin/:transferInstrumentId?",
Component: PayoutDetailsPage
},
[]: {
path: "/service-agreement",
Component: AcceptTermsOfService
},
[]: {
path: "/pci-dss",
Component: SignPCIComponent
},
[]: {
path: "/review",
Component: Review
},
[]: {
path: "/customer-support",
Component: CustomerSupport
},
[]: {
path: "/capability-rejected",
Component: AccountSetupRejected
},
[]: {
path: "/legal-representative",
Component: LegalRepresentativeDetailsPage
},
[]: {
path: "/source-of-funds",
Component: SourceOfFundsPage
},
[]: {
path: "/business-financing",
Component: BusinessFinancingPage
},
[]: {
path: "/tax-reporting",
Component: TaxReportingDropin
},
[]: {
path: "/sole-proprietor",
Component: SoleProprietorshipPage
},
[]: {
path: "/trust",
Component: TrustDetailsPage
},
[]: { path: "/trust/member" },
[]: {
path: "/trust/members",
Component: TrustMembersOverview
},
[]: {
path: "/trust/member/role-and-type/:memberId?",
Component: TrustMemberRoleAndTypePage
},
[]: {
path: "/trust/member/:memberId?/individual",
Component: TrustMemberIndividualPage
},
[]: {
path: "/trust/member/:memberId?/company",
Component: TrustMemberCompanyPage
},
[]: {
path: "/trust/member/:memberId/company-owner/:parentId/:decisionMakerId?",
Component: DecisionMakerDetailsPage
},
[]: {
path: "/partnership",
Component: TrustDetailsPage
},
[]: {
path: "/partnership/members",
Component: UnincorporatedPartnershipMembersOverview
},
[]: {
path: "/partnership/member/role-and-type/:memberId?",
Component: UnincorporatedPartnershipMemberRoleAndTypePage
},
[]: {
path: "/partnership/member/:memberId?/individual",
Component: UnincorporatedPartnershipIndividualPage
},
[]: {
path: "/partnership/member/:memberId?/company",
Component: UnincorporatedPartnershipMemberCompanyPage
},
[]: {
path: "/partnership/member/:memberId/company-owner/:parentId/:decisionMakerId?",
Component: DecisionMakerDetailsPage
},
[]: {
path: "/invited-individual",
Component: InvitedDecisionMakerComponent
}
};
/**
* Maps each TaskType to its URL path pattern.
* Derived from ROUTE_CONFIG — do not edit directly.
*/
var ROUTE_PATHS = Object.fromEntries(Object.entries(ROUTE_CONFIG).map(([key, entry]) => [key, entry.path]));
/**
* Build a concrete URL path from a TaskType and optional params.
* Replaces `:paramName` placeholders with actual values.
* Optional params (`:paramName?`) are omitted if not provided.
*/
var buildPath = (task, params) => {
return "/" + ROUTE_PATHS[task].split("/").filter(Boolean).map((seg) => {
const isOptional = seg.endsWith("?");
if (!seg.startsWith(":")) return seg;
const paramName = seg.slice(1, isOptional ? -1 : void 0);
const value = params?.[paramName];
if (!value && isOptional) return null;
if (!value) throw new Error(`Missing required param "${paramName}" for route "${task}"`);
return value;
}).filter((s) => s !== null).join("/");
};
/**
* Detect the base path by stripping any known route suffix from the current
* `window.location.pathname`. This lets deep-links and reloads work correctly
* because the base is the host-page mount point, not the full URL.
*
* Examples (playground):
* `/onboardingDropinComponent` → base `/onboardingDropinComponent`
* `/onboardingDropinComponent/individual` → base `/onboardingDropinComponent`
*
* Examples (production — /balanceplatform/uo/form/{legalEntityId}/{sessionToken}):
* `/balanceplatform/uo/form/xtl-LE123/TOKEN` → base `/balanceplatform/uo/form/xtl-LE123/TOKEN`
* `/balanceplatform/uo/form/xtl-LE123/TOKEN/individual` → base `/balanceplatform/uo/form/xtl-LE123/TOKEN`
* `/balanceplatform/uo/form/xtl-LE123/TOKEN/tasks` → base `/balanceplatform/uo/form/xtl-LE123/TOKEN`
*/
var detectBasePath = (parser, pathname = window.location.pathname) => {
const pathSegments = pathname.split("/").filter(Boolean);
const sortedRoutes = Object.values(ROUTE_PATHS).sort((a, b) => b.split("/").filter(Boolean).length - a.split("/").filter(Boolean).length);
for (let i = 0; i < pathSegments.length; i++) {
const candidatePath = "/" + pathSegments.slice(i).join("/");
for (const routePath of sortedRoutes) {
const [match] = matchRoute(parser, routePath, candidatePath);
if (match) {
const baseSegments = pathSegments.slice(0, i);
return baseSegments.length > 0 ? "/" + baseSegments.join("/") : "/";
}
}
}
return (pathname.endsWith("/") ? pathname.slice(0, -1) : pathname) || "/";
};
//#endregion
//#region src/router/useNavigate.ts
var useNavigate = () => {
const [, setLocation] = useLocation();
const withSearch = (path) => path + window.location.search;
const to = (task, params) => {
if (task === "default") {
setLocation(withSearch("/"));
return;
}
setLocation(withSearch(buildPath(task, params)));
};
const back = (stepCount = 1) => {
window.history.go(-stepCount);
};
const replace = (task, params) => {
setLocation(withSearch(buildPath(task, params)), { replace: true });
};
return {
to,
back,
replace
};
};
//#endregion
export { UnincorporatedPartnershipMembersOverview as A, TrustMemberCompanyPage as C, UnincorporatedPartnershipIndividualPage as D, TrustMembersOverview as E, getDefaultTask as M, UnincorporatedPartnershipMemberCompanyPage as O, TrustDetailsPage as S, TrustMemberRoleAndTypePage as T, SignPCIComponent as _, BusinessTypeSelectionPage as a, SourceOfFundsPage as b, DecisionMakers as c, PayoutDetailsPage as d, ROUTE_PATHS as f, RootIndividualDetailsPage as g, RootBusinessLinesPage as h, BusinessFinancingPage as i, detectBasePath as j, UnincorporatedPartnershipMemberRoleAndTypePage as k, Introduction as l, RootBusinessDetailsPage as m, AcceptTermsOfService as n, CustomerSupport as o, Review as p, AccountSetupRejected as r, DecisionMakerDetailsPage as s, useNavigate as t, LegalRepresentativeDetailsPage as u, SingpassSelection as v, TrustMemberIndividualPage as w, TaxReportingDropin as x, SoleProprietorshipPage as y };