@adyen/kyc-components 3.46.1 → 3.46.3

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.
@@ -3054,12 +3054,23 @@ function useGlobalDataSlice(sliceId, caller) {
3054
3054
  }),
3055
3055
  [sliceId, caller]
3056
3056
  );
3057
+ const clearState = useCallback(
3058
+ () => dispatch({
3059
+ type: "removeFromState",
3060
+ value: { dataStoreId: sliceId, caller }
3061
+ }),
3062
+ [sliceId, caller]
3063
+ );
3057
3064
  const updateStateSlice = useMemo(
3058
3065
  // can this debounce be useDebounce?
3059
3066
  () => debounce$1(updateState, ON_CHANGE_DEBOUNCE_DURATION),
3060
3067
  [updateState]
3061
3068
  );
3062
- return { sliceData, updateStateSlice };
3069
+ const clearStateSlice = useMemo(
3070
+ () => debounce$1(clearState, ON_CHANGE_DEBOUNCE_DURATION),
3071
+ [clearState]
3072
+ );
3073
+ return { sliceData, updateStateSlice, clearStateSlice };
3063
3074
  }
3064
3075
  function useResetGlobalData(caller) {
3065
3076
  const { dispatch } = useStateContext();
@@ -22936,6 +22947,13 @@ function PayoutAccount(props) {
22936
22947
  const bankNameProps = getFieldProps(props, bankNameFields);
22937
22948
  const bankCodeProps = getFieldProps(props, bankCodeFields);
22938
22949
  const bankCityProps = getFieldProps(props, bankCityFields);
22950
+ const { clearStateSlice } = useGlobalDataSlice(
22951
+ "payoutAccountDetails"
22952
+ );
22953
+ const handleAccountFormatChange = (accountFormat2) => {
22954
+ clearStateSlice();
22955
+ setAccountFormat(accountFormat2);
22956
+ };
22939
22957
  return /* @__PURE__ */ jsxs("form", { className: "adyen-kyc-individual__payout-account", "aria-describedby": "ariaErrorField", children: [
22940
22958
  /* @__PURE__ */ jsx(
22941
22959
  FormHeader,
@@ -22958,7 +22976,7 @@ function PayoutAccount(props) {
22958
22976
  BankAccountFormat,
22959
22977
  {
22960
22978
  bankAccountFormat: accountFormat,
22961
- handleAccountFormatChange: setAccountFormat
22979
+ handleAccountFormatChange
22962
22980
  }
22963
22981
  ),
22964
22982
  formUtils.isRequiredField("branchCode") && /* @__PURE__ */ jsx(
@@ -26563,10 +26581,16 @@ function getPropsFromConfigurations(scenarioConfiguration, forms, remediationAct
26563
26581
  }
26564
26582
  case TrustedFieldsProvider.SINGPASS: {
26565
26583
  if (legalEntityType === "organization") {
26566
- return [...acc, ...trusted.fields.map((tf) => businessDetailsApiKeyMapping[tf])];
26584
+ const orgFields = trusted.fields.filter(
26585
+ (field) => (field == null ? void 0 : field.split(".")[0]) === "organization"
26586
+ );
26587
+ return [...acc, ...orgFields.map((tf) => businessDetailsApiKeyMapping[tf])];
26567
26588
  }
26568
26589
  if (legalEntityType === "individual") {
26569
- return [...acc, ...trusted.fields.map((tf) => individualApiKeyMapping[tf])];
26590
+ const individualFields = trusted.fields.filter(
26591
+ (field) => (field == null ? void 0 : field.split(".")[0]) === "individual"
26592
+ );
26593
+ return [...acc, ...individualFields.map((tf) => individualApiKeyMapping[tf])];
26570
26594
  }
26571
26595
  return acc;
26572
26596
  }
@@ -42103,6 +42127,26 @@ const verifyTin = async (context, data) => {
42103
42127
  data
42104
42128
  );
42105
42129
  };
42130
+ async function convertToSingpassLinkResponse(openIdInitiateResponse) {
42131
+ const response = await Promise.resolve(openIdInitiateResponse);
42132
+ const item = { authUrl: response.authUrl, success: true };
42133
+ return { item };
42134
+ }
42135
+ const openSingpassAuthorizationLink = async (context) => {
42136
+ const { loadingContext, legalEntityId } = context;
42137
+ return convertToSingpassLinkResponse(
42138
+ httpPost({
42139
+ loadingContext,
42140
+ errorLevel: "warn",
42141
+ errorMessage: `Failed to initiate`,
42142
+ path: `${legalEntityId}/openid/initiate`,
42143
+ authentication: "jwt",
42144
+ headers: {
42145
+ "Content-Type": "application/json"
42146
+ }
42147
+ })
42148
+ );
42149
+ };
42106
42150
  const COMPONENTS_API_VERSION = "v1";
42107
42151
  const makeComponentApi = (rootLegalEntityId, base) => {
42108
42152
  const loadingContext = `${base}api/${COMPONENTS_API_VERSION}/`;
@@ -42165,7 +42209,8 @@ const makeComponentApi = (rootLegalEntityId, base) => {
42165
42209
  getCompanyDataset: async (request) => getCompanyDataset(baseRequestContext, request),
42166
42210
  refreshCompanyDataset: async (request) => refreshCompanyDataset(baseRequestContext, request),
42167
42211
  clearCompanyData: async () => clearCompanyData(baseRequestContext),
42168
- verifyTin: async (request) => verifyTin(baseRequestContext, request)
42212
+ verifyTin: async (request) => verifyTin(baseRequestContext, request),
42213
+ openSingpassAuthorizationLink: async () => openSingpassAuthorizationLink(baseRequestContext)
42169
42214
  };
42170
42215
  };
42171
42216
  const useComponentApi = (rootLegalEntityId) => {
@@ -43115,7 +43160,8 @@ function OnboardingDropinComponent({
43115
43160
  getCompanyDataset: getCompanyDataset2,
43116
43161
  refreshCompanyDataset: refreshCompanyDataset2,
43117
43162
  clearCompanyData: clearCompanyData2,
43118
- verifyTin: verifyTin2
43163
+ verifyTin: verifyTin2,
43164
+ openSingpassAuthorizationLink: openSingpassAuthorizationLink2
43119
43165
  } = useComponentApi(legalEntityId);
43120
43166
  const [legalEntity, setLegalEntity] = useState();
43121
43167
  const [loadingStatus, setLoadingStatus] = useState("loading");
@@ -43180,7 +43226,8 @@ function OnboardingDropinComponent({
43180
43226
  handleGetCompanyDataset: getCompanyDataset2,
43181
43227
  handleRefreshCompanyDataset: refreshCompanyDataset2,
43182
43228
  handleClearCompanyData: clearCompanyData2,
43183
- handleVerifyTin: verifyTin2
43229
+ handleVerifyTin: verifyTin2,
43230
+ handleOpenSingpassAuthorizationLink: openSingpassAuthorizationLink2
43184
43231
  }
43185
43232
  );
43186
43233
  }
@@ -45780,7 +45827,7 @@ const ConfigurationApiProvider = ({
45780
45827
  }) => {
45781
45828
  const authContext = useAuthContext();
45782
45829
  const { isEmbeddedDropin, loadingContext } = authContext;
45783
- const sdkVersion = "3.46.1";
45830
+ const sdkVersion = "3.46.3";
45784
45831
  const rootLegalEntityId = useGlobalStore((store) => store.rootLegalEntity.id);
45785
45832
  useAnalytics({
45786
45833
  onUserEvent,
@@ -46113,6 +46160,44 @@ function StateReducer() {
46113
46160
  mergedState.initialData = structuredClone(state.initialData);
46114
46161
  return { currentState: mergedState, prevState: state, changeInitiatedBy: dataStoreId };
46115
46162
  }
46163
+ case "removeFromState": {
46164
+ const state = structuredClone(currState);
46165
+ const dataStoreId = action.value.dataStoreId ?? action.value.caller;
46166
+ const mergedState = {
46167
+ ...state,
46168
+ data: {
46169
+ ...state.data,
46170
+ [dataStoreId]: {}
46171
+ },
46172
+ // Add data in allData state prop in case we will need them later
46173
+ allData: {
46174
+ ...state.allData,
46175
+ [dataStoreId]: {}
46176
+ },
46177
+ errors: {
46178
+ ...state.errors,
46179
+ [dataStoreId]: {}
46180
+ },
46181
+ valid: {
46182
+ ...state.valid,
46183
+ [dataStoreId]: {}
46184
+ },
46185
+ fieldProblems: {
46186
+ ...state.fieldProblems,
46187
+ [dataStoreId]: {}
46188
+ }
46189
+ };
46190
+ mergedState.validityByForm = {
46191
+ ...mergedState.validityByForm,
46192
+ [dataStoreId]: {}
46193
+ };
46194
+ mergedState.allValid = Object.values(mergedState.validityByForm).every(
46195
+ (isValid) => isValid
46196
+ );
46197
+ mergedState.isValid = !activeForms.length ? mergedState.allValid : activeForms.every((item) => mergedState.validityByForm[item]);
46198
+ mergedState.initialData = structuredClone(state.initialData);
46199
+ return { currentState: mergedState, prevState: state, changeInitiatedBy: dataStoreId };
46200
+ }
46116
46201
  case "resetState": {
46117
46202
  const dataStoreId = ((_b = action.value) == null ? void 0 : _b.dataStoreId) ?? ((_c = action.value) == null ? void 0 : _c.caller);
46118
46203
  return {
@@ -46627,7 +46712,7 @@ const DebugModal = ({ onExit }) => {
46627
46712
  const [tab, setTab] = useState("metadata");
46628
46713
  const rootLegalEntity = useGlobalStore((store) => store.rootLegalEntity);
46629
46714
  const metadata = {
46630
- sdkVersion: "3.46.1",
46715
+ sdkVersion: "3.46.3",
46631
46716
  locale: i18n.locale,
46632
46717
  rootLegalEntityId: rootLegalEntity.id
46633
46718
  };
@@ -16,7 +16,7 @@ import type { BaseTrackingPayload } from '../../core/utils';
16
16
  import type { Language } from '../../language/Language';
17
17
  import type { TranslationKey } from '../../language/types';
18
18
  import type { TaskTypes } from '../../stores/globalStore/taskTypes';
19
- interface SingpassLinkResponseItem {
19
+ export interface SingpassLinkResponseItem {
20
20
  authUrl: string;
21
21
  success: boolean;
22
22
  }
@@ -87,4 +87,3 @@ export interface DropinProps {
87
87
  taskType?: TaskTypes;
88
88
  taskName?: TranslationKey;
89
89
  }
90
- export {};
@@ -19,7 +19,7 @@ export interface SFValue {
19
19
  dataStoreId?: string;
20
20
  }
21
21
  export interface SCAction {
22
- type: 'addToState' | 'resetState';
22
+ type: 'addToState' | 'resetState' | 'removeFromState';
23
23
  value?: SFValue;
24
24
  }
25
25
  export interface SCCurrent {
@@ -3,6 +3,7 @@ export declare function useGlobalData<TLDS extends TopLevelDataSchema>(): TLDS;
3
3
  interface UseGlobalDataSlice<TLDS extends TopLevelDataSchema, SliceName extends keyof TLDS, SliceData extends TLDS[SliceName]> {
4
4
  sliceData: SliceData | undefined;
5
5
  updateStateSlice: (updatedSlice: StateSlice<TLDS, SliceName, SliceData>) => void;
6
+ clearStateSlice: () => void;
6
7
  }
7
8
  export declare function useGlobalDataSlice<TLDS extends TopLevelDataSchema, SliceName extends keyof TLDS, SliceData extends TLDS[SliceName] = NonNullable<TLDS[SliceName]>>(sliceId: SliceName, caller?: string): UseGlobalDataSlice<TLDS, SliceName, SliceData>;
8
9
  export declare function useResetGlobalData<TLDS extends TopLevelDataSchema>(caller?: string): () => void;
@@ -45,6 +45,7 @@ export type ComponentApi = {
45
45
  refreshCompanyDataset: Required<DropinAPIHandlers>['handleRefreshCompanyDataset'];
46
46
  clearCompanyData: Required<DropinAPIHandlers>['handleClearCompanyData'];
47
47
  verifyTin: Required<DropinAPIHandlers>['handleVerifyTin'];
48
+ openSingpassAuthorizationLink: Required<DropinAPIHandlers>['handleOpenSingpassAuthorizationLink'];
48
49
  };
49
50
  export declare const COMPONENTS_API_VERSION = "v1";
50
51
  export declare const makeComponentApi: (rootLegalEntityId: string, base: string) => ComponentApi;
@@ -0,0 +1,3 @@
1
+ export interface OpenIdInitiateResponse {
2
+ authUrl: string;
3
+ }
@@ -0,0 +1,3 @@
1
+ import type { ComponentApiRequestContext } from '../types';
2
+ import type { SingpassLinkResponse } from '../../../components/Dropins/types';
3
+ export declare const openSingpassAuthorizationLink: (context: ComponentApiRequestContext) => Promise<SingpassLinkResponse>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adyen/kyc-components",
3
- "version": "3.46.1",
3
+ "version": "3.46.3",
4
4
  "keywords": [
5
5
  "adyen",
6
6
  "adyen-kyc",