@payos-inc/payos-react 1.2.0 → 1.2.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.
@@ -29,6 +29,10 @@ export declare class ApiClient {
29
29
  * Parse response body
30
30
  */
31
31
  private parseResponse;
32
+ /**
33
+ * The resolved API base URL (always ends with /api unless setBaseUrl changed it)
34
+ */
35
+ getBaseUrl(): string;
32
36
  /**
33
37
  * Update base URL
34
38
  */
@@ -1,4 +1,9 @@
1
- import { PasskeyResult, RegisterResult, OTPSubmitResult } from "./types";
1
+ import { PasskeyResult, RegisterResult, OTPSubmitResult, PasskeyFlowResult, PayOSPasskeyOptions } from "./types";
2
+ /**
3
+ * Diagnostics go to `/api/passkeys/diagnostics` so every SDK call stays under
4
+ * one prefix and a reseller proxy only has to forward `/api/passkeys/*`.
5
+ */
6
+ export declare function getDiagnosticsEndpointUrl(sandbox?: boolean, apiBaseUrl?: string): string;
2
7
  /**
3
8
  * Main PayOS Passkey SDK class
4
9
  * Provides simple methods for passkey authentication and registration
@@ -7,36 +12,115 @@ export declare class PayOSPasskey {
7
12
  private apiClient;
8
13
  private visaService;
9
14
  private mastercardService;
15
+ private simulatedVisa;
16
+ private simulatedMastercard;
17
+ /**
18
+ * The services of the most recently started public call, for the public
19
+ * helpers (showVisaIframe, closeMastercardWindow, ...); null once it ends.
20
+ * The flow itself only uses the services passed down to it, so an
21
+ * abandoned or concurrent call never affects another.
22
+ */
23
+ private currentCall;
24
+ /** Network SDKs /passkeys/configs listed that failed to load. */
25
+ private failedNetworkSdks;
26
+ private reportedUnavailableSdks;
10
27
  private logger;
11
28
  private sdkConfig;
12
29
  private isInitialized;
13
30
  private initPromise;
14
31
  private instanceId;
15
- constructor(linkToken: string, options?: {
16
- sandbox?: boolean;
17
- apiBaseUrl?: string;
18
- debug?: boolean;
19
- visaContainerId?: string;
20
- mastercardPopupDimensions?: {
21
- width: number;
22
- height: number;
23
- };
24
- });
32
+ private onStepUp;
33
+ private onOtp;
34
+ /** Base delay between complete-device-binding retries (ms); scaled by attempt. */
35
+ private bindRetryDelayMs;
36
+ /**
37
+ * @param linkToken - Session secret (from `POST /api/sessions/agentic-setup` or
38
+ * `/api/sessions/checkout`) or a link token.
39
+ */
40
+ constructor(linkToken: string, options?: PayOSPasskeyOptions);
25
41
  /**
26
42
  * Initialize SDK - fetch config and load SDKs
27
43
  * Called automatically in constructor
28
44
  */
29
45
  private initialize;
30
46
  private performInitialization;
47
+ /** The Visa service of the call in progress, for the public helpers. */
48
+ private get visa();
49
+ /** The Mastercard service of the call in progress, for the public helpers. */
50
+ private get mastercard();
51
+ /**
52
+ * Runs one public call on its own services: the network's own, switched
53
+ * to the simulated network for each network its input marks (a Visa
54
+ * context passed here, or a server response passed to selectServices
55
+ * during the call). Nothing is shared with any other call.
56
+ */
57
+ private withCall;
58
+ /** Switches the call to the simulated service for each network this server response marks. */
59
+ private selectServices;
60
+ private useSimulated;
61
+ /**
62
+ * A simulated ceremony needs no network script, so a network SDK that
63
+ * failed to load (often the page's Content-Security-Policy) would go
64
+ * unnoticed in sandbox and fail in production. Say so, once per network.
65
+ */
66
+ private reportUnavailableNetworkSdk;
67
+ /**
68
+ * Run the passkey flow.
69
+ *
70
+ * - `authenticate()` (no arguments): the server resolves what to do from the
71
+ * session secret (agentic setup for an enrollment, or a checkout intent)
72
+ * and the SDK follows its `flowType`. Visa step-up goes through the
73
+ * `onStepUp` / `onOtp` options.
74
+ * - `authenticate(paymentIntentId, paymentId?)`: authenticate a payment
75
+ * (unchanged wallet behaviour).
76
+ *
77
+ * Every result carries `{status, flowType, network, vicEnrolled, vicError?}`.
78
+ */
79
+ authenticate(): Promise<PasskeyFlowResult>;
80
+ authenticate(paymentIntentId: string, paymentId?: string): Promise<PasskeyFlowResult>;
81
+ private authenticateIntent;
82
+ /**
83
+ * Transaction authentication after the start call (wallet intent flow, and
84
+ * a checkout session secret used with authenticate()).
85
+ */
86
+ private continueTransactionAuthentication;
87
+ /**
88
+ * Visa session context ({ sessionContext, browserData }) for the start call.
89
+ * Empty when the Visa SDK is not loaded; the backend handles that.
90
+ */
91
+ private collectVisaSessionContext;
92
+ /** Adds the common flow fields to a transaction-authentication result. */
93
+ private decorateTransactionResult;
94
+ /**
95
+ * authenticate() with no arguments: the session secret decides the subject.
96
+ */
97
+ private authenticateWithSession;
98
+ /**
99
+ * Registration subject (agentic setup): passkey ceremony, then
100
+ * complete-device-binding, which runs VIC enrollment on the server.
101
+ */
102
+ private runRegistrationSubject;
103
+ private runVisaRegistrationSubject;
104
+ private visaCeremonyThenBind;
105
+ private runMastercardRegistrationSubject;
106
+ /**
107
+ * Visa step-up through the reseller's callbacks. Returns the registration
108
+ * context on success, or the terminal result.
109
+ */
110
+ private runStepUp;
111
+ /** Shows the Visa frame, runs one AUTHENTICATE command, hides the frame. */
112
+ private runVisaCeremony;
31
113
  /**
32
- * Authenticate a payment using passkeys - handles complete flow internally
114
+ * complete-device-binding, retried while another request holds the VIC lock
115
+ * (409 agentic_enrollment_in_progress). The result reports the VIC outcome.
33
116
  */
34
- authenticate(paymentIntentId: string, paymentId?: string): Promise<PasskeyResult>;
117
+ private bindAndReport;
35
118
  /**
36
119
  * Register a card for passkey authentication
37
120
  * Returns unified RegisterResult for both networks
38
121
  */
39
122
  register(cardId: string): Promise<RegisterResult>;
123
+ private registerCard;
40
124
  /**
41
125
  * Complete VIC enrollment using assurance data from passkey authentication
42
126
  * Called when passkey exists but VIC enrollment was not completed
@@ -49,21 +133,25 @@ export declare class PayOSPasskey {
49
133
  * @param authenticationContext - The authentication context from Visa for passkey assertion
50
134
  */
51
135
  authenticateForVicEnrollment(enrollmentId: string, authenticationContext: any): Promise<PasskeyResult>;
136
+ private assertForVicEnrollment;
52
137
  /**
53
138
  * Submit step-up method selection for Visa registration
54
139
  */
55
140
  submitStepUpMethod(enrollmentId: string, methodIndex: number): Promise<OTPSubmitResult>;
141
+ private submitStepUpChoice;
56
142
  /**
57
143
  * Validate OTP for step-up authentication
58
144
  * Returns registrationContext for the caller to trigger SDK registration
59
145
  * (This allows React to render the iframe container first)
60
146
  */
61
147
  validateStepUpOTP(enrollmentId: string, otpValue: string): Promise<PasskeyResult>;
148
+ private validateStepUpCode;
62
149
  /**
63
150
  * Complete Visa passkey registration after OTP validation
64
151
  * Call this AFTER the iframe container has been rendered
65
152
  */
66
153
  completeVisaRegistration(enrollmentId: string, registrationContext: any): Promise<PasskeyResult>;
154
+ private registerVisaPasskey;
67
155
  private getMastercardStatusFailure;
68
156
  /**
69
157
  * Internal method to complete authentication
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Pure helpers for the session-driven passkey flow.
3
+ *
4
+ * The server resolves the subject (enrollment / intent / card) from the
5
+ * session secret, so `authenticate()` with no arguments only has to read the
6
+ * server's answer and turn it into one result shape.
7
+ */
8
+ import { AgenticEnrollmentError, PasskeyFlowResult, PasskeyFlowStatus, PasskeyFlowType, PasskeyNetwork, PasskeyResult, StepUpMethodOption } from "./types";
9
+ /** Server error code for a concurrent VIC enrollment (409, retryable). */
10
+ export declare const AGENTIC_ENROLLMENT_IN_PROGRESS = "agentic_enrollment_in_progress";
11
+ export declare function resolveNetwork(authResponse: any): PasskeyNetwork | undefined;
12
+ export declare function passkeyActionOf(authResponse: any): string | undefined;
13
+ /** Server `transaction_authentication` maps to the public `authentication`. */
14
+ export declare function isRegistrationFlow(authResponse: any): boolean;
15
+ export declare function normalizeStepUpMethods(raw: unknown): StepUpMethodOption[];
16
+ /** `onStepUp` may return the option, its index, or nothing (cancel). */
17
+ export declare function resolveStepUpChoice(choice: unknown, methods: StepUpMethodOption[]): number | null;
18
+ /**
19
+ * Read the VIC outcome from a complete-device-binding response `data`.
20
+ * Visa: `vicEnrollment.success` (or `vicEnrolled`) must be true.
21
+ * Other networks: binding success is the agentic outcome.
22
+ */
23
+ export declare function agenticOutcomeFromBinding(network: PasskeyNetwork | undefined, data: any): {
24
+ vicEnrolled: boolean;
25
+ vicError?: AgenticEnrollmentError;
26
+ };
27
+ /** VIC outcome of a WAIVED start response (the server enrolls VIC itself). */
28
+ export declare function agenticOutcomeFromWaiver(network: PasskeyNetwork | undefined, authResponse: any): {
29
+ vicEnrolled: boolean;
30
+ vicError?: AgenticEnrollmentError;
31
+ };
32
+ export declare function withFlowFields(base: PasskeyResult, fields: {
33
+ status: PasskeyFlowStatus;
34
+ flowType: PasskeyFlowType;
35
+ network?: PasskeyNetwork | undefined;
36
+ vicEnrolled: boolean;
37
+ vicError?: AgenticEnrollmentError | undefined;
38
+ }): PasskeyFlowResult;
39
+ /**
40
+ * Registration-subject result: `success` only when the passkey step worked
41
+ * AND agentic enrollment finished, so a VIC failure is never reported as success.
42
+ */
43
+ export declare function registrationResult(status: PasskeyFlowStatus, flowType: PasskeyFlowType, network: PasskeyNetwork | undefined, outcome: {
44
+ vicEnrolled: boolean;
45
+ vicError?: AgenticEnrollmentError;
46
+ }, extra?: Partial<PasskeyResult>): PasskeyFlowResult;
47
+ export declare function failedResult(flowType: PasskeyFlowType, network: PasskeyNetwork | undefined, code: string, message: string, status?: PasskeyFlowStatus): PasskeyFlowResult;
48
+ export declare function isAgenticInProgressError(error: any): boolean;
@@ -6,7 +6,7 @@ export interface PasskeyAuthResponse {
6
6
  enrollmentId: string;
7
7
  enrollmentStatus: 'enrolled' | 'pending' | 'failed';
8
8
  cardBrand: string;
9
- network: 'visa' | 'mastercard';
9
+ network: PasskeyNetwork;
10
10
  flowType: 'registration' | 'transaction_authentication';
11
11
  passkeyAction?: 'REGISTER' | 'AUTHENTICATE' | 'WAIVED';
12
12
  vProvisionedTokenID?: string;
@@ -17,6 +17,89 @@ export interface PasskeyAuthResponse {
17
17
  paymentAmount?: number;
18
18
  paymentCurrency?: string;
19
19
  }
20
+ export type PasskeyNetwork = 'visa' | 'mastercard' | 'discover';
21
+ /**
22
+ * Outcome of a passkey flow.
23
+ * - REGISTERED: a new passkey was created and bound to the card
24
+ * - AUTHENTICATED: an existing passkey was used
25
+ * - WAIVED: no passkey ceremony was needed (organization waiver or network)
26
+ * - CANCELLED: the customer (or a callback) stopped the flow
27
+ * - PENDING: the card's network enrollment is still pending; try again later
28
+ * - FAILED: anything else; see `error`
29
+ */
30
+ export type PasskeyFlowStatus = 'REGISTERED' | 'AUTHENTICATED' | 'WAIVED' | 'CANCELLED' | 'PENDING' | 'FAILED';
31
+ /** `registration` for a new passkey, `authentication` when the customer already had one. */
32
+ export type PasskeyFlowType = 'registration' | 'authentication';
33
+ /** Why agentic (VIC) enrollment did not finish. */
34
+ export interface AgenticEnrollmentError {
35
+ code: string;
36
+ message?: string;
37
+ /** True when creating a new session and running authenticate() again may succeed. */
38
+ retryable: boolean;
39
+ }
40
+ /**
41
+ * Fields every authenticate() result carries.
42
+ * `success` is never true when agentic enrollment was attempted and failed.
43
+ */
44
+ export interface PasskeyFlowFields {
45
+ status: PasskeyFlowStatus;
46
+ flowType: PasskeyFlowType;
47
+ /**
48
+ * True when the card is ready for agentic purchases
49
+ * (Visa: VIC enrolled; Mastercard / Discover: passkey bound or waived).
50
+ */
51
+ vicEnrolled: boolean;
52
+ /** Present when agentic enrollment was attempted and did not finish. */
53
+ vicError?: AgenticEnrollmentError;
54
+ /** Alias of `vicEnrolled` (network-neutral name used in the public docs). */
55
+ agenticEnrolled: boolean;
56
+ /** Alias of `vicError`. */
57
+ agenticError?: AgenticEnrollmentError;
58
+ }
59
+ export type PasskeyFlowResult = PasskeyResult & PasskeyFlowFields;
60
+ /** A Visa step-up verification method, as passed to `onStepUp`. */
61
+ export interface StepUpMethodOption {
62
+ /** Position in the list; return this (or the object) from `onStepUp`. */
63
+ index: number;
64
+ /** Raw Visa method name, e.g. `OTP_SMS`, `OTP_EMAIL`. */
65
+ method: string;
66
+ type: 'sms' | 'email' | 'other';
67
+ /** Masked destination, e.g. `***-***-1234` or `j***@example.com`. */
68
+ maskedValue?: string;
69
+ }
70
+ /** Context passed to `onOtp`. */
71
+ export interface OtpPromptContext {
72
+ /** 1 for the first prompt, 2+ after a wrong code. */
73
+ attempt: number;
74
+ method: StepUpMethodOption;
75
+ /** Set on retries: why the previous code was refused. */
76
+ previousError?: string;
77
+ attemptsRemaining?: number;
78
+ }
79
+ /**
80
+ * Return the chosen method (or its index). Return null/undefined to cancel.
81
+ */
82
+ export type StepUpHandler = (methods: StepUpMethodOption[]) => Promise<StepUpMethodOption | number | null | undefined> | StepUpMethodOption | number | null | undefined;
83
+ /** Return the code the customer typed. Return null/undefined/empty to cancel. */
84
+ export type OtpHandler = (context: OtpPromptContext) => Promise<string | null | undefined> | string | null | undefined;
85
+ export interface PayOSPasskeyOptions {
86
+ /** true for sandbox, false/undefined for production */
87
+ sandbox?: boolean;
88
+ /** Override API base URL (your subdomain or proxy). All calls go to `<base>/api/passkeys/*`. */
89
+ apiBaseUrl?: string;
90
+ debug?: boolean;
91
+ /** ID of element where the Visa iframe should be placed */
92
+ visaContainerId?: string;
93
+ /** Custom Mastercard popup dimensions */
94
+ mastercardPopupDimensions?: {
95
+ width: number;
96
+ height: number;
97
+ };
98
+ /** Visa step-up: show your method picker. Used by authenticate() with no arguments. */
99
+ onStepUp?: StepUpHandler;
100
+ /** Visa step-up: show your code-entry screen. Used by authenticate() with no arguments. */
101
+ onOtp?: OtpHandler;
102
+ }
20
103
  export interface SDKConfig {
21
104
  visa: {
22
105
  sdkUrl: string;
@@ -35,7 +118,7 @@ export interface PasskeyResult {
35
118
  /** Success status */
36
119
  success: boolean;
37
120
  /** Network type */
38
- network?: 'visa' | 'mastercard';
121
+ network?: PasskeyNetwork;
39
122
  /** Optional message */
40
123
  message?: string;
41
124
  /** Whether OTP was valid (for step-up flow) */
@@ -64,7 +147,7 @@ export interface RegisterResult {
64
147
  /** Success status - true if registration complete, false if step-up needed or failed */
65
148
  success: boolean;
66
149
  /** Network type */
67
- network?: 'visa' | 'mastercard';
150
+ network?: PasskeyNetwork;
68
151
  /** Step-up required (Visa only) */
69
152
  requiresStepUp?: boolean;
70
153
  /** VIC enrollment required (Visa only - passkey exists but VIC not enrolled) */
@@ -3,7 +3,8 @@
3
3
  * Browser SDK for passkey authentication operations
4
4
  */
5
5
  export { PayOSPasskey } from './core/PayOSPasskey';
6
- export type { PasskeyAuthResponse, SDKConfig, PasskeyResult, RegisterResult, SDKSessionData, OTPSubmitResult, PasskeyErrorCode, } from './core/types';
6
+ export type { PasskeyAuthResponse, SDKConfig, PasskeyResult, RegisterResult, SDKSessionData, OTPSubmitResult, PasskeyErrorCode, PasskeyNetwork, PasskeyFlowStatus, PasskeyFlowType, PasskeyFlowFields, PasskeyFlowResult, AgenticEnrollmentError, StepUpMethodOption, OtpPromptContext, StepUpHandler, OtpHandler, PayOSPasskeyOptions, } from './core/types';
7
+ export { SDK_VERSION } from './version';
7
8
  export { PasskeyError } from './core/types';
8
9
  import { PayOSPasskey } from './core/PayOSPasskey';
9
10
  export default PayOSPasskey;
@@ -0,0 +1,9 @@
1
+ import type { VisaSDKService } from "./visa/VisaSDKService";
2
+ import type { MastercardSDKService } from "./mastercard/MastercardSDKService";
3
+ /**
4
+ * What PayOSPasskey needs from a Visa ceremony service: the network's own
5
+ * (VisaSDKService) or the sandbox's simulated one.
6
+ */
7
+ export type VisaCeremonyService = Pick<VisaSDKService, "isLoaded" | "loadSDK" | "getSessionContext" | "authenticate" | "showIframe" | "hideIframe" | "removeIframeOnly" | "getIframe" | "setContainerId" | "cleanup">;
8
+ /** What PayOSPasskey needs from a Mastercard ceremony service. */
9
+ export type MastercardCeremonyService = Pick<MastercardSDKService, "isLoaded" | "loadSDK" | "authenticate" | "setPopupDimensions" | "getAuthWindow" | "closeAuthWindow" | "cleanup">;
@@ -0,0 +1,47 @@
1
+ import type { MastercardCeremonyService } from "../services/types";
2
+ /**
3
+ * The popup ceremony the server puts on a simulated card's authRequest: a
4
+ * challenge and expiry, and the opener origin and ticket that bind them.
5
+ */
6
+ interface MastercardSandboxCeremony {
7
+ challenge: string;
8
+ exp: number;
9
+ origin: string;
10
+ ticket: string;
11
+ }
12
+ /**
13
+ * The hosted page's URL: on the API host the SDK already talks to, i.e. the
14
+ * ApiClient's base URL with its trailing /api removed, keeping any path
15
+ * prefix a host proxies the API under.
16
+ */
17
+ export declare function simulatedMastercardPopupUrl(apiBaseUrl: string, srcCorrelationId: string, ceremony: MastercardSandboxCeremony): URL;
18
+ /**
19
+ * The PayOS simulated network in place of the Mastercard SDK, for sandbox
20
+ * test cards. Same interface as MastercardSDKService. It
21
+ * opens the hosted simulated page in a popup with window.open, as the live
22
+ * SDK does, and resolves with the Mastercard result shape the page posts
23
+ * back: only from that popup and only from the API's origin. A popup closed
24
+ * without a result (by the user, or closeAuthWindow) resolves the live
25
+ * cancel.
26
+ */
27
+ export declare class SimulatedMastercardService implements MastercardCeremonyService {
28
+ private apiBaseUrl;
29
+ private authWindow;
30
+ private popupWidth;
31
+ private popupHeight;
32
+ private cancelPending;
33
+ /** @param apiBaseUrl - the ApiClient's resolved base URL, read when a ceremony starts */
34
+ constructor(apiBaseUrl: () => string);
35
+ isLoaded(): boolean;
36
+ loadSDK(): Promise<void>;
37
+ setPopupDimensions(width: number, height: number): void;
38
+ authenticate(authRequest: any, popupOptions?: {
39
+ width?: number;
40
+ height?: number;
41
+ }): Promise<any>;
42
+ getAuthWindow(): Window | null;
43
+ /** Closes the popup and resolves the pending ceremony as cancelled. */
44
+ closeAuthWindow(): void;
45
+ cleanup(): void;
46
+ }
47
+ export {};
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The PayOS simulated network's passkey screen, shown for sandbox test cards
3
+ * in place of the network's own.
4
+ *
5
+ * Framework-free DOM, styled only through CSSOM (`element.style`), never a
6
+ * <style> element or a style attribute, so it runs under a
7
+ * Content-Security-Policy that forbids inline styles. Text is set with
8
+ * textContent only. No network branding.
9
+ */
10
+ export type SimulatedCeremonyKind = "registration" | "purchase";
11
+ export type SimulatedDecision = "approved" | "declined" | "cancelled";
12
+ /**
13
+ * One modal at a time. `open` renders it into `container` (inline) or, with
14
+ * none, as a centred overlay, first answering any modal still showing as
15
+ * cancelled, and returns a function that closes that modal only (not one
16
+ * opened after it); `close` removes the modal showing and releases the
17
+ * focus trap without reporting a decision.
18
+ */
19
+ export declare class SimulatedNetworkModal {
20
+ private root;
21
+ private previousFocus;
22
+ private releaseTrap;
23
+ private onDecision;
24
+ /** The modal's outermost element while it is open. */
25
+ get element(): HTMLElement | null;
26
+ open(kind: SimulatedCeremonyKind, container: HTMLElement | null, onDecision: (decision: SimulatedDecision) => void): () => void;
27
+ close(): void;
28
+ }
@@ -0,0 +1,35 @@
1
+ import type { VisaCeremonyService } from "../services/types";
2
+ /**
3
+ * The PayOS simulated network in place of the Visa SDK, for sandbox test
4
+ * cards. Same interface and result shapes as VisaSDKService:
5
+ * - Approve resolves AUTH_COMPLETE with the live assurance shape
6
+ * {identifier, fidoBlob, dfpSessionID}; fidoBlob is base64url of
7
+ * {challenge, exp, decision}, which the simulated network checks;
8
+ * - Decline rejects with an Error, as Visa's AUTH_FAILED does;
9
+ * - the modal's close (× or Esc) resolves AUTH_CANCELLED;
10
+ * - no answer within 2 minutes rejects, as Visa's timeout does.
11
+ * hideIframe / removeIframeOnly remove the modal without settling a pending
12
+ * authenticate, exactly as the live ones leave Visa's frame waiting until
13
+ * that timeout.
14
+ */
15
+ export declare class SimulatedVisaService implements VisaCeremonyService {
16
+ private containerId;
17
+ private shownContainerId;
18
+ private modal;
19
+ isLoaded(): boolean;
20
+ loadSDK(): Promise<void>;
21
+ getSessionContext(): Promise<{
22
+ sessionContext: any;
23
+ browserData: any;
24
+ }>;
25
+ setContainerId(containerId: string): void;
26
+ authenticate(authenticationContext: any): Promise<any>;
27
+ /** Where the next modal renders; as live, the call's container wins over the configured one. */
28
+ showIframe(containerId?: string): void;
29
+ hideIframe(): void;
30
+ removeIframeOnly(): void;
31
+ /** There is no frame: the modal is a div, so callers get null, as live does without one. */
32
+ getIframe(): HTMLIFrameElement | null;
33
+ cleanup(): void;
34
+ private container;
35
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Which networks a server response (or a ceremony context) asks to run on
3
+ * the PayOS simulated network. The server marks simulated
4
+ * subjects only, with an undocumented `sandboxCeremony` block:
5
+ * - `{network}` on `actionData`, present before any context exists (a Visa
6
+ * STEP_UP response);
7
+ * - a block inside each ceremony context: Visa's registration /
8
+ * authentication contexts, and Mastercard's authRequest.
9
+ */
10
+ export type SimulatedNetwork = "visa" | "mastercard";
11
+ /** Whether a ceremony context (Visa context, Mastercard authRequest) is simulated. */
12
+ export declare function isSimulatedContext(context: any): boolean;
13
+ /**
14
+ * @param response - a /passkeys/authenticate response, or a
15
+ * validate-stepup-otp / submit-stepup-method response's data
16
+ */
17
+ export declare function simulatedNetworksOf(response: any): Set<SimulatedNetwork>;
@@ -17,6 +17,7 @@ declare global {
17
17
  __PAYOS_PASSKEY_DIAGNOSTICS__?: (entry: DiagnosticEntry) => void;
18
18
  }
19
19
  }
20
+ export declare const NETWORK_SDK_UNAVAILABLE_HINT = "Check your Content-Security-Policy allows this origin; production will fail with SDK_LOAD_FAILED";
20
21
  export declare function nowMs(): number;
21
22
  export declare function elapsedMs(startedAt: number): number;
22
23
  export declare function createDiagnosticId(prefix: string): string;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * SDK version sent as `X-SDK-Version` on every request.
3
+ * Must equal package.json "version" (test/session-flow.test.cjs enforces it).
4
+ */
5
+ export declare const SDK_VERSION = "1.6.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payos-inc/payos-react",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "PayOS React SDK - Drawer checkout component for React",
5
5
  "main": "dist/payos-react.cjs",
6
6
  "module": "dist/payos-react.mjs",
@@ -27,7 +27,7 @@
27
27
  "build:css": "tailwindcss -i ./src/styles/base.css -o ./dist/payos-react.css --minify",
28
28
  "lint": "eslint src --ext .ts,.tsx",
29
29
  "type-check": "tsc --noEmit",
30
- "test:passkey": "NODE_PATH=./node_modules node --test ../payos-passkey-js/test/security.test.cjs",
30
+ "test:passkey": "NODE_PATH=./node_modules node --test ../payos-passkey-js/test/security.test.cjs ../payos-passkey-js/test/session-flow.test.cjs ../payos-passkey-js/test/simulated-network.test.cjs",
31
31
  "prepack": "npm run build",
32
32
  "verify:package": "node scripts/verify-package.cjs"
33
33
  },