@flopay/shared 1.14.11 → 1.14.13

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.
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Closed, privacy-safe lifecycle contract for one 3DS challenge attempt.
3
+ *
4
+ * The SDK emits these records as `three_ds.challenge` lifecycle events; ingestion sanitizes each
5
+ * one with {@link sanitizeThreeDsChallengeRecord} and support rebuilds an attempt's timeline with
6
+ * {@link reconstructThreeDsTimeline}. Every value comes from a closed set: no URL, identifier
7
+ * (other than the opaque attempt UUID), free text or nested payload ever reaches the record.
8
+ */
9
+ /** Ordered milestones and observations a challenge attempt can record. */
10
+ export declare const THREE_DS_CHALLENGE_PHASES: readonly ['handoff_planned', 'action_missing', 'action_invalid', 'render_attempted', 'render_failed', 'container_attached', 'container_visibility', 'navigation_assigned', 'iframe_load', 'load_unconfirmed', 'policy_violation', 'return_rejected', 'trusted_return', 'recovery_read_completed', 'cancel_requested', 'abort_observed', 'pagehide_observed', 'timer_expired', 'teardown', 'browser_terminal', 'provider_reconciled'];
11
+ export type ThreeDsChallengePhase = (typeof THREE_DS_CHALLENGE_PHASES)[number];
12
+ /** Milestones a stream must hold before it may be called complete. */
13
+ export declare const THREE_DS_REQUIRED_MILESTONES: readonly ["handoff_planned", "container_attached", "navigation_assigned", "browser_terminal"];
14
+ declare const THREE_DS_CHALLENGE_REASONS: readonly ['missing_url', 'invalid_url', 'hidden', 'visible', 'frame_src', 'child_src', 'buyer_cancel', 'component_unmount', 'navigation', 'unspecified', 'untrusted_origin', 'untrusted_source', 'malformed_message', 'window_elapsed', 'unknown'];
15
+ export type ThreeDsChallengeReason = (typeof THREE_DS_CHALLENGE_REASONS)[number];
16
+ /** What the browser actually observed. None of these claim issuer UI visibility or buyer interaction. */
17
+ declare const THREE_DS_EVIDENCE_BASES: readonly ['parent_computed_style', 'parent_csp_event', 'iframe_load_event', 'no_load_signal', 'message_origin_check', 'signal_reason', 'timer', 'page_lifecycle_event', 'server_status', 'provider_fact', 'none', 'unknown'];
18
+ export type ThreeDsEvidenceBasis = (typeof THREE_DS_EVIDENCE_BASES)[number];
19
+ declare const THREE_DS_TERMINAL_SOURCES: readonly ['trusted_return', 'status_poll', 'cancel', 'abort', 'timer'];
20
+ export type ThreeDsTerminalSource = (typeof THREE_DS_TERMINAL_SOURCES)[number];
21
+ declare const THREE_DS_PROVIDERS: readonly ['stripe', 'worldpay', 'unknown'];
22
+ export type ThreeDsProvider = (typeof THREE_DS_PROVIDERS)[number];
23
+ /** Authoritative provider facts, recorded separately from the browser terminal. */
24
+ declare const THREE_DS_PROVIDER_OUTCOMES: readonly ['succeeded', 'authorized', 'declined', 'timeout', 'unknown'];
25
+ export type ThreeDsProviderOutcome = (typeof THREE_DS_PROVIDER_OUTCOMES)[number];
26
+ export type ThreeDsChallengeClassification =
27
+ /** A trusted return or the status poll ended the browser window; the provider outcome is separate. */
28
+ 'returned' | 'presentation_hidden' | 'policy_blocked' | 'interrupted' | 'cancelled' | 'window_elapsed' | 'unknown';
29
+ /** An untrusted record as a producer or ingestion hands it over. */
30
+ export interface ThreeDsChallengeRecordInput {
31
+ attemptId: string;
32
+ phase: string;
33
+ attemptSequence: number;
34
+ elapsedMs: number;
35
+ provider?: string;
36
+ reason?: string;
37
+ evidenceBasis?: string;
38
+ terminalSource?: string;
39
+ providerOutcome?: string;
40
+ }
41
+ /** The sanitized, allowlisted record that reaches the wire and the retained store. */
42
+ export interface ThreeDsChallengeRecord {
43
+ attemptId: string;
44
+ phase: ThreeDsChallengePhase;
45
+ attemptSequence: number;
46
+ elapsedMs: number;
47
+ provider?: ThreeDsProvider;
48
+ reason?: ThreeDsChallengeReason;
49
+ evidenceBasis?: ThreeDsEvidenceBasis;
50
+ terminalSource?: ThreeDsTerminalSource;
51
+ providerOutcome?: ThreeDsProviderOutcome;
52
+ }
53
+ /** Upper bound for `attemptSequence`; one attempt never records anywhere near this many phases. */
54
+ export declare const THREE_DS_MAX_ATTEMPT_SEQUENCE = 1000;
55
+ /** Upper bound for `elapsedMs` (10 minutes); later observations are clamped, never dropped. */
56
+ export declare const THREE_DS_MAX_ELAPSED_MS = 600000;
57
+ /** True when `value` is a UUID v4, the only attempt id shape the contract accepts. */
58
+ export declare function isThreeDsChallengeAttemptId(value: unknown): value is string;
59
+ /**
60
+ * Reduce an untrusted record to the closed contract. Returns `null` when the attempt id is not a
61
+ * UUID v4 or the phase is not in the catalog; any other value outside its closed set becomes
62
+ * `unknown`; every field not in the contract is dropped.
63
+ */
64
+ export declare function sanitizeThreeDsChallengeRecord(input: ThreeDsChallengeRecordInput): ThreeDsChallengeRecord | null;
65
+ type ThreeDsCompletionEvidence = 'none' | 'browser_return_only' | 'provider_confirmed';
66
+ export interface ThreeDsChallengeTimeline {
67
+ attemptId: string | null;
68
+ /** Ordered by `attemptSequence`, whatever order the records arrived in. */
69
+ entries: ThreeDsChallengeRecord[];
70
+ /** True only with no sequence gap and every required milestone present. */
71
+ complete: boolean;
72
+ missingMilestones: ThreeDsChallengePhase[];
73
+ sequenceGaps: number[];
74
+ /** The lowest-sequence `browser_terminal` record, or null. */
75
+ browserTerminal: ThreeDsChallengeRecord | null;
76
+ duplicateBrowserTerminals: number;
77
+ /** Authoritative provider facts, kept apart from the browser terminal. */
78
+ providerOutcomes: ThreeDsChallengeRecord[];
79
+ classification: ThreeDsChallengeClassification;
80
+ completion: ThreeDsCompletionEvidence;
81
+ confidence: 'observed' | 'partial' | 'unknown';
82
+ }
83
+ /**
84
+ * Rebuild one attempt's support timeline from retained records. Missing evidence stays explicit
85
+ * (`unknown`, `missingMilestones`, `sequenceGaps`); it is never inferred as abandonment.
86
+ */
87
+ export declare function reconstructThreeDsTimeline(records: readonly ThreeDsChallengeRecord[]): ThreeDsChallengeTimeline;
88
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flopay/shared",
3
- "version": "1.14.11",
3
+ "version": "1.14.13",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "publishConfig": {
@@ -28,7 +28,7 @@
28
28
  "devDependencies": {
29
29
  "@types/node": "^25.9.9",
30
30
  "@types/validator": "^13.15.10",
31
- "tsup": "^8.3.0",
31
+ "tsup": "^9.0.0",
32
32
  "typescript": "^7.0.2",
33
33
  "typescript-legacy": "npm:typescript@6.0.3",
34
34
  "vitest": "4.1.12"