@lydianpay/sdk-web 3.15.5 → 3.17.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 (31) hide show
  1. package/dist/chunks/{browser-CH7eaWyg.js → browser-D7hYBJ05.js} +1 -1
  2. package/dist/chunks/{connect-multichain-DUlpFu-U.js → connect-multichain-Cq0nfkUh.js} +9 -9
  3. package/dist/chunks/{index-DwADRT3v.js → index-CA1kNBo-.js} +203 -139
  4. package/dist/chunks/{index-B0KsTd4q.js → index-CXIhRfTO.js} +2 -2
  5. package/dist/chunks/{index-C3_NkCKr.js → index-Cg9sFEhj.js} +1 -1
  6. package/dist/chunks/{index-BWDzkEUT.js → index-D4W8-w8-.js} +1 -1
  7. package/dist/chunks/{index-Dgq02q9R.js → index-eNQBuUBY.js} +2 -2
  8. package/dist/chunks/{index-DLmUAaTw.js → index-iy5xf-sU.js} +3 -3
  9. package/dist/chunks/{mountEngine-Bk-qJ-ZC.js → mountEngine-CBqqdixh.js} +14567 -14251
  10. package/dist/lydian.js +1 -1
  11. package/dist/types/.tsbuildinfo +1 -1
  12. package/dist/types/network/gatewayRequestError.d.ts +9 -0
  13. package/dist/types/network/session/index.d.ts +2 -1
  14. package/dist/types/types.d.ts +27 -9
  15. package/dist/types/ui/flowConfig.d.ts +1 -0
  16. package/dist/types/ui/kycFlow.d.ts +6 -5
  17. package/dist/types/ui/kycValidation.d.ts +51 -18
  18. package/dist/types/ui/kycVerificationRequest.d.ts +5 -7
  19. package/dist/types/ui/otpValidation.d.ts +0 -4
  20. package/dist/types/ui/react/AlertBanner.d.ts +1 -1
  21. package/dist/types/ui/react/CheckboxField.d.ts +8 -0
  22. package/dist/types/ui/react/EmailReceiptCard/EmailReceiptCard.d.ts +4 -0
  23. package/dist/types/ui/react/EmailReceiptCard/EmailReceiptForm.d.ts +7 -0
  24. package/dist/types/ui/react/EmailReceiptCard/emailReceiptHelpers.d.ts +7 -0
  25. package/dist/types/ui/react/EmailReceiptCard/useEmailReceiptSender.d.ts +7 -0
  26. package/dist/types/ui/react/FormField.d.ts +2 -1
  27. package/dist/types/ui/react/KycDocumentFields.d.ts +11 -0
  28. package/dist/types/ui/react/KycFields.d.ts +15 -0
  29. package/dist/types/ui/react/checkoutActions.d.ts +1 -3
  30. package/dist/types/ui/react/checkoutStore.d.ts +10 -8
  31. package/package.json +1 -1
@@ -0,0 +1,9 @@
1
+ export declare class GatewayRequestError extends Error {
2
+ readonly errorCode: number | undefined;
3
+ constructor({ statusText, errorCode, response, }: {
4
+ statusText: string;
5
+ errorCode: number | undefined;
6
+ response?: Response;
7
+ });
8
+ }
9
+ export declare function toGatewayRequestError(response: Response): Promise<GatewayRequestError>;
@@ -1,8 +1,9 @@
1
1
  import { Base } from '../base';
2
- import { CreateSessionRequest, CreateSessionResponse, CreateSessionTransactionRequest, CreateTransactionResponse, GetSessionResponse } from '../../types';
2
+ import { CreateSessionRequest, CreateSessionResponse, CreateSessionTransactionRequest, CreateTransactionResponse, GetSessionResponse, SendReceiptRequest } from '../../types';
3
3
  export declare class Sessions extends Base {
4
4
  createSession(newSession: CreateSessionRequest): Promise<CreateSessionResponse>;
5
5
  getSession(sessionID: string): Promise<GetSessionResponse>;
6
6
  createSessionTransaction(sessionID: string, sessionTransaction: CreateSessionTransactionRequest): Promise<CreateTransactionResponse>;
7
7
  cancelSession(sessionID: string): Promise<string>;
8
+ sendReceipt(sessionID: string, receipt: SendReceiptRequest): Promise<void>;
8
9
  }
@@ -193,6 +193,11 @@ export type CreateSessionTransactionRequest = {
193
193
  network: string;
194
194
  customerUUID?: string;
195
195
  };
196
+ export type SendReceiptRequest = {
197
+ email: string;
198
+ marketingOptIn: boolean;
199
+ consentTextVersion: string;
200
+ };
196
201
  export type CalculatedTotals = {
197
202
  cryptoCurrency: string;
198
203
  baseAmountCrypto: number;
@@ -209,8 +214,12 @@ export type CreateTransactionResponse = {
209
214
  additionalCustomerFee: number;
210
215
  address: string;
211
216
  status: number;
212
- requiredFields: string[];
213
217
  supportedDocumentTypes: string[];
218
+ combinedRequiredFields?: string[];
219
+ kycGroupFields?: string[];
220
+ kycGroupCount?: number;
221
+ travelGroupFields?: string[];
222
+ travelGroupCount?: number;
214
223
  expiration?: string;
215
224
  calculatedTotals?: CalculatedTotals;
216
225
  cryptoFXRate?: number;
@@ -233,14 +242,22 @@ export type BroadcastTransferResponse = {
233
242
  export type KYCVerificationRequest = {
234
243
  asset: string;
235
244
  network: string;
236
- firstName: string;
237
- lastName: string;
238
- email: string;
239
- street: string;
240
- city: string;
241
- region: string;
242
- postalCode: string;
243
- country: string;
245
+ firstName?: string;
246
+ lastName?: string;
247
+ email?: string;
248
+ street?: string;
249
+ city?: string;
250
+ region?: string;
251
+ postalCode?: string;
252
+ country?: string;
253
+ yearOfBirth?: string;
254
+ monthOfBirth?: string;
255
+ dayOfBirth?: string;
256
+ cityOfBirth?: string;
257
+ regionOfBirth?: string;
258
+ countryOfBirth?: string;
259
+ nationalIDNumber?: string;
260
+ customerIDNumber?: string;
244
261
  storeKYC: boolean;
245
262
  documentType: string | undefined;
246
263
  documentFiles: File[];
@@ -346,6 +363,7 @@ export type CheckoutFlow = {
346
363
  hideNoWalletOption?: boolean;
347
364
  showApprovalPage?: boolean;
348
365
  hideChangePaymentMethod?: boolean;
366
+ hideEmailReceipt?: boolean;
349
367
  };
350
368
  export type CheckoutConfig = {
351
369
  logoURL?: string;
@@ -6,5 +6,6 @@ export type CheckoutFlowSettings = {
6
6
  showApprovalPage: boolean;
7
7
  hideOtherWallets: boolean;
8
8
  hideChangePaymentMethod: boolean;
9
+ hideEmailReceipt: boolean;
9
10
  };
10
11
  export declare function resolveFlow(accountFlow?: CheckoutFlow, embedFlow?: InitFlowOptions): CheckoutFlowSettings;
@@ -1,7 +1,7 @@
1
1
  import { type CheckoutStore } from './react/checkoutStore';
2
2
  import type { API } from '../network';
3
3
  import type { CheckoutPresentation } from './checkoutPresentation';
4
- import type { KycFieldValues } from './kycValidation';
4
+ import type { KycFormValues } from './kycValidation';
5
5
  import type { PaymentFlow } from './paymentFlow';
6
6
  import type { ScreenNavigator } from './screenNavigator';
7
7
  import type { SessionLifecycle } from './sessionLifecycle';
@@ -12,15 +12,16 @@ export interface KycFlow {
12
12
  /** The -3 screen. No-op without a transaction to attach the details to. */
13
13
  showScreen(): void;
14
14
  submit(submission: {
15
- values: KycFieldValues;
15
+ values: KycFormValues;
16
16
  documentFront: File | null;
17
17
  documentBack: File | null;
18
18
  storeKyc: boolean;
19
19
  }): Promise<void>;
20
- /** A recognised customer needs only documents; the form never renders. */
21
- showDocumentOnlyScreen(customerUUID: string, country: string): void;
22
20
  /** Re-promote the same session against a stored customer record. */
23
- restoreWithCustomerUUID(customerUUID: string): Promise<void>;
21
+ restoreWithCustomerUUID(restored: {
22
+ customerUUID: string;
23
+ country: string;
24
+ }): Promise<void>;
24
25
  }
25
26
  export interface KycFlowSeams {
26
27
  reportFailure(message: string, reason: PaymentFailureReason, options?: {
@@ -1,23 +1,56 @@
1
- export type KycStep = 'basic' | 'address' | 'document';
2
- export type KycFieldValues = {
3
- email: string;
4
- firstName: string;
5
- lastName: string;
6
- street: string;
7
- city: string;
8
- region: string;
9
- postalCode: string;
10
- country: string;
1
+ import type { CreateTransactionResponse } from '../types';
2
+ export declare const KYC_FIELD_PARTS: {
3
+ readonly firstName: readonly ["firstName"];
4
+ readonly lastName: readonly ["lastName"];
5
+ readonly email: readonly ["email"];
6
+ readonly walletAddress: readonly ["walletAddress"];
7
+ readonly dateAndPlaceOfBirth: readonly ["dateOfBirth", "cityOfBirth", "regionOfBirth", "countryOfBirth"];
8
+ readonly dateOfBirth: readonly ["dateOfBirth"];
9
+ readonly nationalIDNumber: readonly ["nationalIDNumber"];
10
+ readonly customerIDNumber: readonly ["customerIDNumber"];
11
+ readonly physicalAddress: readonly ["street", "city", "region", "postalCode", "country"];
12
+ readonly country: readonly ["country"];
13
+ };
14
+ export type KycField = keyof typeof KYC_FIELD_PARTS;
15
+ export type KycFieldPart = (typeof KYC_FIELD_PARTS)[KycField][number];
16
+ declare const KYC_DOCUMENT_TYPES: readonly ["ID_CARD", "PASSPORT", "RESIDENCE_PERMIT", "DRIVERS"];
17
+ export type KycDocumentType = (typeof KYC_DOCUMENT_TYPES)[number];
18
+ export type KycFormValues = Record<KycFieldPart, string> & {
11
19
  documentType: string;
12
20
  hasDocumentFront: boolean;
13
21
  hasDocumentBack: boolean;
14
22
  };
15
- export type KycFieldError = {
16
- fieldId: string;
17
- message: string;
23
+ export type KycFieldGroup = {
24
+ fields: KycField[];
25
+ count: number;
26
+ shownParts: KycFieldPart[];
27
+ };
28
+ export type KycRequirements = {
29
+ requiredFields: KycField[];
30
+ requiredParts: KycFieldPart[];
31
+ fieldGroups: KycFieldGroup[];
32
+ documentTypes: KycDocumentType[];
33
+ unsupportedFields: string[];
34
+ };
35
+ export declare function getKycRequirements({ transaction, hasConnectedWallet, }: {
36
+ transaction: Partial<CreateTransactionResponse>;
37
+ hasConnectedWallet: boolean;
38
+ }): KycRequirements;
39
+ export declare function canFulfillKycRequirements({ requiredFields, fieldGroups, documentTypes, unsupportedFields, }: KycRequirements): boolean;
40
+ export declare function isKycEmailCollected({ requiredParts, fieldGroups }: KycRequirements): boolean;
41
+ export declare function getKycPartError(part: KycFieldPart, values: KycFormValues): string | null;
42
+ export declare function isKycFieldComplete(field: KycField, values: KycFormValues): boolean;
43
+ export declare function documentHasTwoSides(documentType: string): boolean;
44
+ export declare function getKycGroupGuidance({ group, values, }: {
45
+ group: KycFieldGroup;
46
+ values: KycFormValues;
47
+ }): {
48
+ requiredCount: number;
49
+ totalCount: number;
50
+ completedCount: number;
18
51
  };
19
- export declare const BASIC_FIELDS: readonly ["email", "firstName", "lastName"];
20
- export declare function computeKycSteps(requiredFields: string[], supportedDocumentTypes: string[], { documentOnly }?: {
21
- documentOnly?: boolean;
22
- }): KycStep[];
23
- export declare function validateKycStep(step: KycStep, values: KycFieldValues, requiredFields: string[], supportedDocumentTypes: string[]): KycFieldError | null;
52
+ export declare function isKycFormComplete({ requirements, values, }: {
53
+ requirements: KycRequirements;
54
+ values: KycFormValues;
55
+ }): boolean;
56
+ export {};
@@ -1,18 +1,16 @@
1
- import type { KycFieldValues } from './kycValidation';
1
+ import { type KycFormValues, type KycRequirements } from './kycValidation';
2
2
  import type { KYCVerificationRequest } from '../types';
3
- export declare function kycVerificationRequest({ values, asset, network, storeKyc, documentFront, documentBack, supportsDocuments, restoring, walletAddress, }: {
4
- values: KycFieldValues;
3
+ export declare function getKycVerificationRequest({ requirements, values, asset, network, storeKyc, documentFront, documentBack, restoring, connectedWalletAddress, }: {
4
+ requirements: KycRequirements;
5
+ values: KycFormValues;
5
6
  asset: string;
6
7
  network: string;
7
8
  storeKyc: boolean;
8
9
  documentFront: File | null;
9
10
  documentBack: File | null;
10
- /** False when the transaction names no document types; nothing is attached. */
11
- supportsDocuments: boolean;
12
- /** Non-null only while finishing a recognised customer's KYC — see restoreContextFor. */
13
11
  restoring: {
14
12
  customerUUID: string;
15
13
  country: string;
16
14
  } | null;
17
- walletAddress?: string | null;
15
+ connectedWalletAddress: string | null;
18
16
  }): KYCVerificationRequest;
@@ -6,9 +6,6 @@ export declare function validateRestoreDetails(email: string, country: string):
6
6
  export type OtpVerificationOutcome = {
7
7
  status: 'ok';
8
8
  customerUUID: string;
9
- } | {
10
- status: 'documentRequired';
11
- customerUUID: string;
12
9
  } | {
13
10
  status: 'error';
14
11
  message: string;
@@ -16,5 +13,4 @@ export type OtpVerificationOutcome = {
16
13
  };
17
14
  export declare function resolveOtpVerification(result: {
18
15
  customerUUID?: string;
19
- kycValidated?: boolean;
20
16
  }): OtpVerificationOutcome;
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- export type AlertVariant = 'warning' | 'error';
2
+ export type AlertVariant = 'warning' | 'error' | 'success';
3
3
  export default function AlertBanner({ message, variant, }: {
4
4
  message: string;
5
5
  variant?: AlertVariant;
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ export default function CheckboxField({ id, isChecked, onChange, describedBy, children, }: {
3
+ id: string;
4
+ isChecked: boolean;
5
+ onChange: (isChecked: boolean) => void;
6
+ describedBy?: string;
7
+ children: React.ReactNode;
8
+ }): React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ export default function EmailReceiptCard({ sessionID }: {
3
+ sessionID: string;
4
+ }): React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { type ReceiptDetails } from './emailReceiptHelpers';
3
+ export default function EmailReceiptForm({ isSending, failureMessage, onSend, }: {
4
+ isSending: boolean;
5
+ failureMessage: string | null;
6
+ onSend: (receipt: ReceiptDetails) => void;
7
+ }): React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ import type { GetSessionResponse, SendReceiptRequest } from '../../../types';
2
+ export declare const RECEIPT_MARKETING_CONSENT_VERSION = "receipt-marketing-v1";
3
+ export declare const MAX_EMAIL_ADDRESS_LENGTH = 254;
4
+ export type ReceiptDetails = Omit<SendReceiptRequest, 'consentTextVersion'>;
5
+ export declare function isEmailReceiptOffered(session: GetSessionResponse | null): session is GetSessionResponse;
6
+ export declare function buildReceiptRequest({ email, marketingOptIn }: ReceiptDetails): SendReceiptRequest;
7
+ export declare function getReceiptFailureMessage(error: unknown): string;
@@ -0,0 +1,7 @@
1
+ import { type ReceiptDetails } from './emailReceiptHelpers';
2
+ export declare function useEmailReceiptSender(sessionID: string): {
3
+ send: (receipt: ReceiptDetails) => Promise<void>;
4
+ isSending: boolean;
5
+ hasSent: boolean;
6
+ failureMessage: string | null;
7
+ };
@@ -6,7 +6,7 @@ export declare function FieldShell({ id, label, labelFor, error, children, }: {
6
6
  error?: string;
7
7
  children: React.ReactNode;
8
8
  }): React.JSX.Element;
9
- export default function FormField({ id, label, placeholder, value, onChange, type, autoComplete, error, inputRef, }: {
9
+ export default function FormField({ id, label, placeholder, value, onChange, type, autoComplete, maxLength, error, inputRef, }: {
10
10
  id: string;
11
11
  label: string;
12
12
  placeholder: string;
@@ -14,6 +14,7 @@ export default function FormField({ id, label, placeholder, value, onChange, typ
14
14
  onChange: (value: string) => void;
15
15
  type?: string;
16
16
  autoComplete?: string;
17
+ maxLength?: number;
17
18
  error?: string;
18
19
  inputRef?: React.Ref<HTMLInputElement>;
19
20
  }): React.JSX.Element;
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { type KycDocumentType } from '../kycValidation';
3
+ export default function KycDocumentFields({ documentTypes, documentType, documentFront, documentBack, onDocumentType, onDocumentFront, onDocumentBack, }: {
4
+ documentTypes: KycDocumentType[];
5
+ documentType: string;
6
+ documentFront: File | null;
7
+ documentBack: File | null;
8
+ onDocumentType: (documentType: string) => void;
9
+ onDocumentFront: (file: File | null) => void;
10
+ onDocumentBack: (file: File | null) => void;
11
+ }): React.JSX.Element;
@@ -0,0 +1,15 @@
1
+ import * as React from 'react';
2
+ import { type KycFieldGroup, type KycFieldPart, type KycFormValues } from '../kycValidation';
3
+ import type { SelectOption } from '../optionFilter';
4
+ type KycInputProps = {
5
+ values: KycFormValues;
6
+ countries: SelectOption[];
7
+ onChange: (part: KycFieldPart, value: string) => void;
8
+ };
9
+ export declare function KycFieldList({ parts, ...inputProps }: KycInputProps & {
10
+ parts: KycFieldPart[];
11
+ }): React.JSX.Element;
12
+ export declare function KycFieldGroupCard({ group, ...inputProps }: KycInputProps & {
13
+ group: KycFieldGroup;
14
+ }): React.JSX.Element;
15
+ export {};
@@ -94,8 +94,6 @@ export type CheckoutAction = {
94
94
  } | {
95
95
  type: 'connect/balances';
96
96
  balances: WalletBalances | null;
97
- } | {
98
- type: 'kyc/show';
99
97
  } | {
100
98
  type: 'kyc/formReset';
101
99
  } | {
@@ -115,4 +113,4 @@ export type CheckoutAction = {
115
113
  type: 'mode/applied';
116
114
  isEmbedded: boolean;
117
115
  };
118
- export declare const PRESERVED_ON_RESET: readonly ["brandLogoUrl", "brandLogoAlt", "termNoticeHtml", "session", "flowOverride", "isEmbedded", "walletConnectFlow", "assetFirstFlow", "isLDKEnabled", "hideOtherWallets", "showApprovalPage", "restoreDialogSession", "kycStepSession", "kycFormSession"];
116
+ export declare const PRESERVED_ON_RESET: readonly ["brandLogoUrl", "brandLogoAlt", "termNoticeHtml", "session", "flowOverride", "isEmbedded", "walletConnectFlow", "assetFirstFlow", "isLDKEnabled", "hideOtherWallets", "showApprovalPage", "restoreDialogSession", "kycFormSession"];
@@ -1,7 +1,7 @@
1
- import type { CreateTransactionResponse, DisplayAsset, GetSessionResponse, GetTransactionResponse, InitFlowOptions, WalletConnectWallet } from '../../types';
1
+ import type { CreateTransactionResponse, DisplayAsset, GetSessionResponse, GetTransactionResponse, InitFlowOptions, SendReceiptRequest, WalletConnectWallet } from '../../types';
2
2
  import type { CheckoutWallet } from '../../constants';
3
3
  import type { RestoreContext } from '../sessionHelpers';
4
- import type { KycFieldValues } from '../kycValidation';
4
+ import type { KycFormValues } from '../kycValidation';
5
5
  export declare const SCREEN_NAMES: {
6
6
  readonly PAY_BUTTONS: "payButtons";
7
7
  readonly WALLETS: "wallets";
@@ -71,7 +71,6 @@ export interface CheckoutState {
71
71
  headerAmount: string;
72
72
  changeMethodVisible: boolean;
73
73
  failureMessage: string;
74
- kycStepSession: number;
75
74
  kycFormSession: number;
76
75
  kycDraft: KycDraft | null;
77
76
  restoreContext: RestoreContext | null;
@@ -83,7 +82,7 @@ export type WalletBalances = {
83
82
  account: string;
84
83
  balances: Record<string, bigint>;
85
84
  };
86
- export type KycTextFields = Omit<KycFieldValues, 'documentType' | 'hasDocumentFront' | 'hasDocumentBack'>;
85
+ export type KycTextFields = Omit<KycFormValues, 'documentType' | 'hasDocumentFront' | 'hasDocumentBack'>;
87
86
  export interface KycDraft {
88
87
  text: KycTextFields;
89
88
  documentType: string;
@@ -110,6 +109,7 @@ export interface CheckoutCallbacks {
110
109
  onSelectAsset(assetCode: string): void;
111
110
  onSelectWallet(wallet: CheckoutWallet): void;
112
111
  onDoneSuccess(): void;
112
+ onSendReceipt(sessionID: string, receipt: SendReceiptRequest): Promise<void>;
113
113
  /** Cancels the active wallet connection attempt. */
114
114
  onCancelConnect(): void;
115
115
  /** Retries discovery for the selected wallet. */
@@ -132,20 +132,22 @@ export interface CheckoutCallbacks {
132
132
  otp: string;
133
133
  }): Promise<{
134
134
  customerUUID?: string;
135
- kycValidated?: boolean;
136
135
  }>;
137
- onRestoreVerified(customerUUID: string): Promise<void>;
138
- onRestoreDocumentRequired(customerUUID: string, country: string): void;
136
+ onRestoreVerified(restored: {
137
+ customerUUID: string;
138
+ country: string;
139
+ }): Promise<void>;
139
140
  onRestoreClose(): void;
140
141
  onRestoreDetails(): void;
141
142
  onKycSubmit(submission: {
142
- values: KycFieldValues;
143
+ values: KycFormValues;
143
144
  documentFront: File | null;
144
145
  documentBack: File | null;
145
146
  storeKyc: boolean;
146
147
  }): void;
147
148
  onKycCancel(): void;
148
149
  onKycDraftSource(getDraft: (() => KycDraft) | null): void;
150
+ getConnectedWalletAddress(): string | null;
149
151
  onKycWalletSummaryRow(): void;
150
152
  onKycNetworkSummaryRow(): void;
151
153
  onKycCoinSummaryRow(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lydianpay/sdk-web",
3
- "version": "3.15.5",
3
+ "version": "3.17.0",
4
4
  "description": "Drop-in crypto payment checkout for the web — a <lydian-checkout> web component and window.Lydian API across 20+ chains and major stablecoins.",
5
5
  "license": "MIT",
6
6
  "repository": {