@flopay/shared 1.16.3 → 1.16.5

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.
@@ -1,3 +1,4 @@
1
+ import type { CardFieldsEvent } from './card-fields.js';
1
2
  import type { FloInstrumentEvent } from './instruments.js';
2
3
  import type { TelemetryErrorCode, TelemetryLogName, TelemetryProviderInput, TelemetryRequestCategory } from './telemetry.js';
3
4
  /**
@@ -12,6 +13,9 @@ export declare function invokeMerchantCallback(callback: (() => unknown) | undef
12
13
  export type FloInstrumentSource = {
13
14
  class: 'lifecycle';
14
15
  name: TelemetryLogName;
16
+ /** Only on `vault.fields.ready` / `vault.fields.failed`. */
17
+ elapsedMs?: number;
18
+ loadFailureReason?: string;
15
19
  provider?: TelemetryProviderInput;
16
20
  } | {
17
21
  class: 'technical_error';
@@ -24,6 +28,16 @@ export type FloInstrumentSource = {
24
28
  } | {
25
29
  class: 'more_options';
26
30
  };
31
+ /** The feed source for an adapter card-field event (the same shape telemetry observes). */
32
+ export declare function cardFieldsInstrumentSource(event: CardFieldsEvent): FloInstrumentSource;
33
+ /**
34
+ * Whether an observation is a card-field lifecycle event. UI bindings feed those from the
35
+ * card-capture adapter subscription, so they leave the telemetry copy out of the feed.
36
+ */
37
+ export declare function isCardFieldsInstrumentSource(source: {
38
+ class: string;
39
+ name?: unknown;
40
+ }): boolean;
27
41
  /** Project the closed internal taxonomy onto the smaller merchant-safe v1 contract. */
28
42
  export declare function projectFloInstrument(source: FloInstrumentSource): FloInstrumentEvent | null;
29
43
  /** Instruments a checkout emits at most once per checkout identity. */
@@ -1,3 +1,4 @@
1
+ import type { CardFieldsFailureReason } from './card-fields.js';
1
2
  import type { BillingProvider } from './types.js';
2
3
  /** Schema version for the privacy-safe instrument callback contract. */
3
4
  export declare const FLO_INSTRUMENT_SCHEMA_VERSION: 1;
@@ -44,10 +45,27 @@ interface FloInstrumentCommonFields {
44
45
  /** Gateway selected for this transition, when the checkout has selected one. */
45
46
  gateway?: BillingProvider;
46
47
  }
48
+ /**
49
+ * Card-field lifecycle events on the merchant instrument feed, emitted once per card form
50
+ * (never once per checkout). `reason` is the closed `CardFieldsFailureReason` set.
51
+ */
52
+ export type FloCardFieldsInstrumentEvent = (FloInstrumentCommonFields & {
53
+ name: 'card_fields_ready';
54
+ elapsedMs: number;
55
+ }) | (FloInstrumentCommonFields & {
56
+ name: 'card_fields_failed';
57
+ reason: CardFieldsFailureReason;
58
+ elapsedMs: number;
59
+ });
60
+ /**
61
+ * Every event on the merchant instrument feed: the catalogued checkout funnel signals, plus the
62
+ * per-card-form lifecycle events (issue #539), which are not catalogue entries because they fire
63
+ * once per card form rather than once per checkout.
64
+ */
47
65
  export type FloInstrumentEvent = (FloInstrumentCommonFields & {
48
66
  name: FloInstrumentLifecycleName;
49
67
  }) | (FloInstrumentCommonFields & {
50
68
  name: 'checkout_error';
51
69
  phase: FloInstrumentErrorPhase;
52
- });
70
+ }) | FloCardFieldsInstrumentEvent;
53
71
  export {};
@@ -0,0 +1,27 @@
1
+ import type { CreateSessionParams } from './types.js';
2
+ /**
3
+ * Error code a demoted session create carries when the billing API refused a
4
+ * keyless Auto/Confirm create and downgraded it to a Full checkout.
5
+ */
6
+ export declare const MERCHANT_AUTH_REQUIRED_CODE: 'merchant_auth_required';
7
+ /** Merchant credentials a server holds to mint a credentialed one-click session. */
8
+ export interface MerchantCredentials {
9
+ clientUuid: string;
10
+ apiToken: string;
11
+ }
12
+ /** A server-minted one-click session the browser charges with `sessionId` + `nonce`. */
13
+ export interface OneClickSession {
14
+ sessionId: string;
15
+ nonce: string;
16
+ }
17
+ /** Parameters for `checkout.sessions.createOneClick`. The mode is always `'confirm'`. */
18
+ export type CreateOneClickSessionParams = CreateSessionParams;
19
+ /**
20
+ * Whether a billing API failure (a `/process` refusal body, an
21
+ * `autoProcessingError` or a `FloPayError`) is the merchant-authentication
22
+ * refusal. It is never a decline and never starts 3DS recovery.
23
+ */
24
+ export declare function isMerchantAuthRequired(error: {
25
+ readonly code?: unknown;
26
+ readonly gatewayErrorCode?: unknown;
27
+ } | null | undefined): boolean;
@@ -40,7 +40,7 @@ export type TelemetryErrorReason = (typeof TELEMETRY_ERROR_REASONS)[number];
40
40
  /** Closed catalog of SDK-authored lifecycle and operational log names. */
41
41
  export declare const TELEMETRY_LOG_NAMES: readonly ['sdk.initialize.started', 'sdk.initialize.ready', 'sdk.cache.hit', 'sdk.cache.miss', 'checkout.mount', 'session.create.started', 'session.shell.ready', 'session.claim.started', 'session.claim.completed', 'session.read.started', 'session.request.first_byte', 'session.request.completed', 'checkout.data.ready', 'checkout.rendered', 'checkout.recovery.started', 'checkout.recovery.completed', 'checkout.unmount', 'provider.load.started', 'provider.eligibility.checked', 'provider.availability.checked', 'provider.ready', 'provider.handoff.requested', 'provider.popup.opened', 'provider.overlay.opened', 'provider.overlay.returned', 'provider.callback.ignored', 'provider.redirect.started', 'provider.redirect.resumed', 'vault.capture.requested', 'vault.widget.mounted', 'vault.widget.ready', 'vault.submission.started', 'vault.action.required', 'vault.three_ds.handoff', 'vault.three_ds.returned', 'vault.terminal', 'payment.method.selected', 'payment.intent.started', 'payment.intent.completed', 'payment.provider_confirmation.started', 'payment.provider_confirmation.returned', 'payment.tokenization.started', 'payment.tokenization.completed', 'payment.processing.started', 'payment.processing.completed', 'payment.three_ds.handoff', 'payment.three_ds.returned', 'operation.retry', 'operation.deduplicated', 'operation.fallback', 'operation.cache.hit', 'operation.cache.miss', 'operation.recovery.started', 'operation.recovery.completed', 'operation.state_transition',
42
42
  /** One closed 3DS challenge lifecycle record (`ThreeDsChallengeRecord` fields). */
43
- 'three_ds.challenge'];
43
+ 'three_ds.challenge', 'vault.fields.ready', 'vault.fields.failed'];
44
44
  export type TelemetryLogName = (typeof TELEMETRY_LOG_NAMES)[number];
45
45
  /**
46
46
  * Closed reasons a provider callback was ignored instead of reaching checkout
@@ -142,6 +142,10 @@ export interface TelemetryLogEvent extends TelemetryCommonFields {
142
142
  evidenceBasis?: ThreeDsEvidenceBasis;
143
143
  terminalSource?: ThreeDsTerminalSource;
144
144
  providerOutcome?: ThreeDsProviderOutcome;
145
+ /** Only on `vault.fields.ready` / `vault.fields.failed`: the checkout session UUID. */
146
+ checkoutSessionId?: string;
147
+ /** Only on `vault.fields.failed`, from the closed `CardFieldsFailureReason` set. */
148
+ loadFailureReason?: import('./card-fields.js').CardFieldsFailureReason;
145
149
  }
146
150
  export interface BuildTelemetryLogEventInput extends BuildTelemetryCommonInput {
147
151
  name: TelemetryLogName;
@@ -153,6 +157,8 @@ export interface BuildTelemetryLogEventInput extends BuildTelemetryCommonInput {
153
157
  evidenceBasis?: string;
154
158
  terminalSource?: string;
155
159
  providerOutcome?: string;
160
+ checkoutSessionId?: string;
161
+ loadFailureReason?: string;
156
162
  }
157
163
  export interface TelemetryExpectedOutcomeEvent extends TelemetryCommonFields {
158
164
  class: 'expected_outcome';
package/dist/types.d.ts CHANGED
@@ -906,6 +906,13 @@ export interface VaultCaptureResultMessage {
906
906
  nextActionRedirectUrl?: string;
907
907
  /** Display-only saved card produced by a successful setup, when supplied. */
908
908
  paymentMethod?: SavedCardDisplay;
909
+ /**
910
+ * Optional protocol features the hosted form announces on its `ready`. A form that lists
911
+ * `'fields_interactive'` posts a separate `fields_interactive` message once the buyer can type
912
+ * in the card fields. A form that announces nothing is an older widget: its `ready` stands in
913
+ * as the card-fields-ready signal (backwards-compatible fallback, issue #539).
914
+ */
915
+ capabilities?: readonly string[];
909
916
  }
910
917
  /** Options for mounting the hosted vault widget into a container element. */
911
918
  export interface CardCaptureMountOptions {
@@ -1127,6 +1134,12 @@ export interface CardCaptureAdapter {
1127
1134
  * widget (it focuses the first AVS field itself). Re-applied on `ready`.
1128
1135
  */
1129
1136
  setCardFieldOrder?(order: VaultCardFieldKey[] | null, autoFocus: boolean): void;
1137
+ /**
1138
+ * Subscribe to the card-field lifecycle: `card_fields_ready` once per card form when the
1139
+ * fields are interactive, `card_fields_failed` when they fail to load or time out. Returns
1140
+ * an unsubscribe fn.
1141
+ */
1142
+ onCardFields?(handler: (event: import('./card-fields.js').CardFieldsEvent) => void): () => void;
1130
1143
  /**
1131
1144
  * Set the hosted card form's final submit wording (live, billing API
1132
1145
  * v1.9.35+). The text replaces the button label in place, so the widget is
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flopay/shared",
3
- "version": "1.16.3",
3
+ "version": "1.16.5",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "publishConfig": {