@flopay/shared 1.14.4 → 1.14.6
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.
- package/dist/before-button-click.d.ts +11 -0
- package/dist/card-setup-overlay-theme.d.ts +34 -0
- package/dist/card-setup-surface.d.ts +24 -0
- package/dist/card-setup-theme.d.ts +62 -0
- package/dist/card-setup.d.ts +7 -0
- package/dist/checkout-gateway-rules.d.ts +50 -0
- package/dist/checkout-outcomes.d.ts +14 -0
- package/dist/checkout-payload.d.ts +86 -0
- package/dist/checkout-process-request.d.ts +57 -0
- package/dist/config.d.ts +29 -0
- package/dist/constants.d.ts +452 -0
- package/dist/display.d.ts +64 -0
- package/dist/email-validation.d.ts +2 -0
- package/dist/errors.d.ts +53 -0
- package/dist/external-method-recovery.d.ts +24 -0
- package/dist/friendly-message.d.ts +5 -0
- package/dist/future-use.d.ts +24 -0
- package/dist/idempotency.d.ts +55 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +67 -3739
- package/dist/index.mjs +1 -1
- package/dist/inline-session-cache.d.ts +20 -0
- package/dist/instrument-dispatch.d.ts +28 -0
- package/dist/instruments.d.ts +51 -0
- package/dist/payment-logos.generated.d.ts +1 -0
- package/dist/payment-method-setup-advertisement.d.ts +67 -0
- package/dist/paypal-buyer-identity.d.ts +46 -0
- package/dist/paypal-channel.d.ts +77 -0
- package/dist/paypal-environment.d.ts +14 -0
- package/dist/postal-code-lookup.d.ts +19 -0
- package/dist/postal-code-validation.d.ts +46 -0
- package/dist/primary-tile-style.d.ts +46 -0
- package/dist/recent-completion.d.ts +2 -0
- package/dist/saved-payment-methods.d.ts +96 -0
- package/dist/sentry-filter.d.ts +21 -0
- package/dist/stripe-appearance.d.ts +19 -0
- package/dist/stripe-paypal-presentation.d.ts +42 -0
- package/dist/telemetry-failure.d.ts +14 -0
- package/dist/telemetry.d.ts +161 -0
- package/dist/types.d.ts +1747 -0
- package/dist/uuid.d.ts +19 -0
- package/dist/validation.d.ts +19 -0
- package/dist/vault-submit-theme.d.ts +22 -0
- package/dist/vault-theme.d.ts +28 -0
- package/dist/vault-verification.d.ts +45 -0
- package/dist/wallet-elements-mode.d.ts +27 -0
- package/dist/wallet-sheet-window.d.ts +44 -0
- package/package.json +4 -3
- package/dist/index.d.cts +0 -3739
package/dist/uuid.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RFC 4122 v4 UUID shape (case-insensitive). Mirrors the backend's `@IsUUID()`
|
|
3
|
+
* acceptance for the fields the SDK fills, e.g. the session-intent
|
|
4
|
+
* `authorizationAttemptId`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const UUID_V4: RegExp;
|
|
7
|
+
/** True when `value` is a v4 UUID string. */
|
|
8
|
+
export declare function isUuidV4(value: unknown): value is string;
|
|
9
|
+
/**
|
|
10
|
+
* Generate a cryptographically-random v4 UUID.
|
|
11
|
+
*
|
|
12
|
+
* Prefers `crypto.randomUUID()`, falls back to `crypto.getRandomValues`, and
|
|
13
|
+
* only as a last resort to `Math.random`, so the SDK still produces a
|
|
14
|
+
* well-formed UUID in environments without a secure RNG. Unlike
|
|
15
|
+
* {@link generateIdempotencyKey} this never returns `undefined` or a non-UUID
|
|
16
|
+
* string, because callers send it to backend fields validated as `@IsUUID()`
|
|
17
|
+
* (a weak or missing value there is a hard `400`, not a silent downgrade).
|
|
18
|
+
*/
|
|
19
|
+
export declare function randomUuidV4(): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CurrencyInfo } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Look up currency information by ISO 3166-1 alpha-2 country code.
|
|
4
|
+
* Falls back to USD when the country is not in the map.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getCurrencyByCountry(countryCode: string): CurrencyInfo;
|
|
7
|
+
/** Returns `true` if the string looks like a Stripe publishable key. */
|
|
8
|
+
export declare function isValidPublishableKey(key: string): boolean;
|
|
9
|
+
/** Returns `true` if the string looks like a Stripe secret key. */
|
|
10
|
+
export declare function isValidSecretKey(key: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Returns `true` when the client secret belongs to a SetupIntent (`seti_…`).
|
|
13
|
+
* Trial-only / $0 checkouts confirm and retrieve a SetupIntent instead of a
|
|
14
|
+
* PaymentIntent, so callers must route those to `confirmCardSetup` /
|
|
15
|
+
* `retrieveSetupIntent` rather than the PaymentIntent equivalents.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isSetupIntentClientSecret(clientSecret: string | null | undefined): boolean;
|
|
18
|
+
/** Treat the checkout's normalized fallback cardholder sentinel as absent. */
|
|
19
|
+
export declare function isCardHolderNamePlaceholder(...nameParts: Array<string | null | undefined>): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ButtonsLayoutStyles, FloPayAppearance, VaultSubmitButtonTheme } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Darken a color by `amount` (0–1), preserving its alpha and notation family
|
|
4
|
+
* (`#rrggbb` stays hex, `rgba()` stays rgba). Returns the input unchanged when
|
|
5
|
+
* it is not a color the hosted contract accepts, so a merchant's custom value
|
|
6
|
+
* is never mangled.
|
|
7
|
+
*/
|
|
8
|
+
export declare function darkenColor(color: string, amount?: number): string;
|
|
9
|
+
/** Inputs for {@link computeVaultSubmitButtonTheme}. */
|
|
10
|
+
export interface VaultSubmitThemeSource {
|
|
11
|
+
appearance?: FloPayAppearance | undefined;
|
|
12
|
+
buttonsStyles: ButtonsLayoutStyles;
|
|
13
|
+
/** Flat `fontFamily` already resolved for the hosted inputs — the label's fallback stack. */
|
|
14
|
+
fontFamily: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Build the hosted submit snapshot from the resolved pane `submitButton` style.
|
|
18
|
+
* Returns undefined when the pane defines no `submitButton` treatment (the
|
|
19
|
+
* classic look and plain raw-color integrations), so those keep sending only
|
|
20
|
+
* the historical flat keys.
|
|
21
|
+
*/
|
|
22
|
+
export declare function computeVaultSubmitButtonTheme({ appearance, buttonsStyles, fontFamily, }: VaultSubmitThemeSource): VaultSubmitButtonTheme | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ButtonsLayoutStyles, FloPayAppearance, VaultCardThemeColors } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Darken a `#rrggbb` color by `amount` (0–1) — used to derive a flo-button hover
|
|
4
|
+
* shade from the primary when the theme doesn't supply an explicit
|
|
5
|
+
* `colorPrimaryHover`. Returns the input unchanged for non-hex values.
|
|
6
|
+
*/
|
|
7
|
+
export declare function darkenHex(hex: string, amount?: number): string;
|
|
8
|
+
/** Pass through CSS font-weight values; anything else resolves to undefined. */
|
|
9
|
+
export declare function toCssWeight(value: string | number | undefined): string | number | undefined;
|
|
10
|
+
/** Inputs for {@link computeVaultCardThemeColors}. */
|
|
11
|
+
export interface VaultThemeSource {
|
|
12
|
+
/** Stripe-side appearance (a theme bundle's, or the merchant's override). */
|
|
13
|
+
appearance?: FloPayAppearance | undefined;
|
|
14
|
+
/** Resolved buttons-layout styles (bundle + merchant overrides merged). */
|
|
15
|
+
buttonsStyles: ButtonsLayoutStyles;
|
|
16
|
+
/** Surrounding layout — affects the neutral border fallback. */
|
|
17
|
+
layout?: 'default' | 'buttons';
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Colors pushed into the hosted vault widget so the backend-rendered card form
|
|
21
|
+
* matches the merchant's theme. The SDK owns *all* theming here — every value
|
|
22
|
+
* resolves from the theme bundle / appearance overrides (same precedence the
|
|
23
|
+
* SDK uses for its merchant-hosted AVS inputs); the backend ships only neutral
|
|
24
|
+
* fallbacks for when a var is absent. Shared by `SplitCardForm` (checkout) and
|
|
25
|
+
* `FloPayCardSetup` (no-charge card setup) so one `theme` value renders the
|
|
26
|
+
* same hosted card form everywhere.
|
|
27
|
+
*/
|
|
28
|
+
export declare function computeVaultCardThemeColors({ appearance, buttonsStyles, layout, }: VaultThemeSource): VaultCardThemeColors;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { CardCaptureMountOptions, VaultCaptureBlock } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Production card-capture verification (TeamFloPay/backend#1920, sdk#414).
|
|
4
|
+
*
|
|
5
|
+
* While the backend enforces a human check before card capture, a vault block
|
|
6
|
+
* may arrive as a verification descriptor (`verification.required`) instead of
|
|
7
|
+
* a ready-to-inject `html` shell, and `POST …/vault/capture` answers
|
|
8
|
+
* `403 verification_required`. Both are a mountable state: the SDK mounts the
|
|
9
|
+
* billing API's hosted, credential-free form route, which runs the check inside
|
|
10
|
+
* the card area and then loads the credentialed card form in the same frame.
|
|
11
|
+
* The SDK never renders the challenge and never reads the descriptor's site
|
|
12
|
+
* key, action or `cData`.
|
|
13
|
+
*/
|
|
14
|
+
/** Path of the billing API's gated hosted card-form route. */
|
|
15
|
+
export declare const VAULT_CAPTURE_FORM_PATH = "/v1/vault/capture/form";
|
|
16
|
+
/** True when the vault block says a human check guards card capture. */
|
|
17
|
+
export declare function isVaultVerificationRequired(block: VaultCaptureBlock | null | undefined): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* True when the SDK can mount a card form from this block: either the shell
|
|
20
|
+
* `html` the backend rendered, or a verification descriptor the SDK builds the
|
|
21
|
+
* shell for. A block that is neither still needs the lazy recovery path.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isMountableVaultBlock(block: VaultCaptureBlock | null | undefined): boolean;
|
|
24
|
+
/** Session context a descriptor-built shell is addressed with. */
|
|
25
|
+
export interface VaultMountContext {
|
|
26
|
+
/** Billing API base URL (the hosted form's origin). */
|
|
27
|
+
billingApiUrl?: string;
|
|
28
|
+
/** Checkout session the form is bound to. */
|
|
29
|
+
sessionId?: string | null;
|
|
30
|
+
/** Session nonce the gated form route authenticates the frame with. */
|
|
31
|
+
nonce?: string | null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a vault block into the adapter's mount options.
|
|
35
|
+
*
|
|
36
|
+
* - A block with `html` mounts that html exactly as before (released adapters
|
|
37
|
+
* and the backend's own shell keep working unchanged).
|
|
38
|
+
* - A verification-required block without `html` mounts a credential-free
|
|
39
|
+
* iframe shell pointing at the billing API's hosted form route for this
|
|
40
|
+
* session. Its `expectedOrigin` defaults to the billing API origin, so a
|
|
41
|
+
* same-window forged outcome is rejected, and the block's `messageToken` is
|
|
42
|
+
* still enforced when present.
|
|
43
|
+
* - Anything else returns `null` (nothing to mount).
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveVaultMountOptions(block: VaultCaptureBlock | null | undefined, context: VaultMountContext): CardCaptureMountOptions | null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CaptureMethod } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Deferred Stripe Elements mode for the wallet / Express Checkout row
|
|
4
|
+
* (Apple Pay, Google Pay), from the cart total due today.
|
|
5
|
+
*
|
|
6
|
+
* A $0-today cart (free trial) cannot run in `payment` mode: Stripe rejects a
|
|
7
|
+
* `$0` amount with "amount must be greater than 0", and the historic
|
|
8
|
+
* `amount: totalAmount || 100` floor surfaced a misleading **$1.00** charge on
|
|
9
|
+
* the wallet sheet. Those carts run in `setup` mode instead — the wallet
|
|
10
|
+
* collects the card for the trial with no amount shown, matching the backend's
|
|
11
|
+
* SetupIntent. Any positive amount keeps `payment` mode with the real total.
|
|
12
|
+
*
|
|
13
|
+
* Moved from `@flopay/react`'s `resolveWalletElementsMode` so `@flopay/react`
|
|
14
|
+
* and `@flopay/vue` decide the wallet row's mode, amount and capture method
|
|
15
|
+
* with one implementation. Each caller adds its method list and the usage
|
|
16
|
+
* from `resolveSetupFutureUsage`.
|
|
17
|
+
*
|
|
18
|
+
* @param amountInMinorUnits cart total due today, in the smallest currency unit.
|
|
19
|
+
* @param captureMethod capture contract used by the subsequently created intent.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveWalletModeOptions(amountInMinorUnits: number | undefined, captureMethod?: CaptureMethod): {
|
|
22
|
+
mode: 'setup';
|
|
23
|
+
} | {
|
|
24
|
+
mode: 'payment';
|
|
25
|
+
amount: number;
|
|
26
|
+
captureMethod: 'automatic_async' | 'manual';
|
|
27
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** `details.providerCode` on the `external_payment_method_failed` error for this case. */
|
|
2
|
+
export declare const WALLET_SHEET_WINDOW_TOO_SMALL_CODE = "wallet_sheet_window_too_small";
|
|
3
|
+
interface BrowserWindowInput {
|
|
4
|
+
/** Defaults to `navigator.userAgent`; the string is read, never retained. */
|
|
5
|
+
userAgent?: string;
|
|
6
|
+
/** Defaults to `window.innerWidth` × `window.innerHeight`. */
|
|
7
|
+
viewport?: {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface WalletSheetCancelContext extends BrowserWindowInput {
|
|
13
|
+
/** Stripe express payment type of the cancelled attempt. */
|
|
14
|
+
method: string;
|
|
15
|
+
/** Milliseconds between the wallet click and the cancel callback. */
|
|
16
|
+
elapsedMs: number;
|
|
17
|
+
/** Whether the page lost focus or visibility after the click (a sheet really opened). */
|
|
18
|
+
handoffObserved: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Desktop Chromium in a viewport Chrome cannot fit its payment-handler window
|
|
22
|
+
* into: the one case where Google Pay must open in Google's own window.
|
|
23
|
+
*/
|
|
24
|
+
export declare function shouldPreferWalletPopup(input?: BrowserWindowInput): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* True only on positive evidence: a Google Pay attempt on desktop Chromium
|
|
27
|
+
* that was cancelled within the quick-cancel window, without the page ever
|
|
28
|
+
* yielding control, in a viewport Chrome cannot fit its handler window into.
|
|
29
|
+
* Time alone is never evidence; a slow cancel or an observed hand-off is the
|
|
30
|
+
* buyer dismissing a sheet that did open.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isWalletSheetRefusedForWindowSize(context: WalletSheetCancelContext): boolean;
|
|
33
|
+
/** Buyer copy for a wallet sheet the browser refused to open for lack of room. */
|
|
34
|
+
export declare function buildWalletSheetWindowMessage(displayName: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* From now until the returned function runs, every iframe created through
|
|
37
|
+
* `document.createElement` carries `allow="… payment 'none'"`, whatever its
|
|
38
|
+
* creator later sets, so none of those frames (or their children) can use
|
|
39
|
+
* the Payment Request API. Frames that already exist are untouched: a frame's
|
|
40
|
+
* policy is fixed when it is created. Stopping restores `createElement` when
|
|
41
|
+
* nothing else has wrapped it since; otherwise the hook just stops acting.
|
|
42
|
+
*/
|
|
43
|
+
export declare function denyPaymentPermissionToNewFrames(doc?: Document): () => void;
|
|
44
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flopay/shared",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -29,14 +29,15 @@
|
|
|
29
29
|
"@types/node": "^25.9.9",
|
|
30
30
|
"@types/validator": "^13.15.10",
|
|
31
31
|
"tsup": "^8.3.0",
|
|
32
|
-
"typescript": "^
|
|
32
|
+
"typescript": "^7.0.2",
|
|
33
|
+
"typescript-legacy": "npm:typescript@6.0.3",
|
|
33
34
|
"vitest": "4.1.12"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
37
|
"validator": "^13.15.35"
|
|
37
38
|
},
|
|
38
39
|
"scripts": {
|
|
39
|
-
"build": "tsup",
|
|
40
|
+
"build": "tsup && tsc -p tsconfig.build.json",
|
|
40
41
|
"dev": "tsup --watch",
|
|
41
42
|
"typecheck": "tsc --noEmit",
|
|
42
43
|
"test": "vitest run",
|