@proxy-checkout/server-js 0.0.4-pr-76.31.1 → 0.0.4-pr-76.33.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.
Files changed (39) hide show
  1. package/dist/cjs/cart.d.cts +17 -0
  2. package/dist/cjs/cart.d.ts +17 -0
  3. package/dist/cjs/client.d.cts +19 -0
  4. package/dist/cjs/client.d.ts +19 -0
  5. package/dist/cjs/consistency.d.cts +20 -0
  6. package/dist/cjs/consistency.d.ts +20 -0
  7. package/dist/cjs/errors.d.cts +32 -0
  8. package/dist/cjs/errors.d.ts +32 -0
  9. package/dist/cjs/events.d.cts +89 -0
  10. package/dist/cjs/events.d.ts +89 -0
  11. package/dist/cjs/http-client.d.cts +16 -0
  12. package/dist/cjs/http-client.d.ts +16 -0
  13. package/dist/cjs/index.d.cts +13 -0
  14. package/dist/cjs/index.d.ts +13 -0
  15. package/dist/cjs/lifecycle.d.cts +47 -0
  16. package/dist/cjs/lifecycle.d.ts +47 -0
  17. package/dist/cjs/response-validators.d.cts +8 -0
  18. package/dist/cjs/response-validators.d.ts +8 -0
  19. package/dist/cjs/sessions.d.cts +152 -0
  20. package/dist/cjs/sessions.d.ts +152 -0
  21. package/dist/cjs/subscriptions.d.cts +54 -0
  22. package/dist/cjs/subscriptions.d.ts +54 -0
  23. package/dist/cjs/types.d.cts +16 -0
  24. package/dist/cjs/types.d.ts +16 -0
  25. package/dist/cjs/version.d.cts +3 -0
  26. package/dist/cjs/version.d.ts +3 -0
  27. package/dist/cjs/version.js +1 -1
  28. package/dist/cjs/webhook-events.d.cts +29 -0
  29. package/dist/cjs/webhook-events.d.ts +29 -0
  30. package/dist/cjs/webhook-events.js +0 -10
  31. package/dist/cjs/webhook-handler.d.cts +89 -0
  32. package/dist/cjs/webhook-handler.d.ts +89 -0
  33. package/dist/cjs/webhooks.d.cts +84 -0
  34. package/dist/cjs/webhooks.d.ts +84 -0
  35. package/dist/esm/version.d.ts +2 -2
  36. package/dist/esm/version.js +1 -1
  37. package/dist/esm/webhook-events.d.ts +0 -5
  38. package/dist/esm/webhook-events.js +0 -10
  39. package/package.json +9 -4
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Typed cart-snapshot validation.
3
+ *
4
+ * The cart snapshot is merchant-defined and opaque to Proxy, so the SDK keeps
5
+ * the shape app-owned but standardizes the parse step: pass a zod-style schema
6
+ * (or a plain validator function) and get a typed cart or a structured error.
7
+ */
8
+ /** A zod-style schema (`{ parse }`) or a plain validator function. */
9
+ export type ProxyCartValidator<TCart> = {
10
+ parse: (value: unknown) => TCart;
11
+ } | ((value: unknown) => TCart);
12
+ /** Run a cart snapshot through a validator, wrapping failures in a structured SDK error. */
13
+ export declare function parseProxyCart<TCart>(cartSnapshot: unknown, validator: ProxyCartValidator<TCart>): TCart;
14
+ /** Optional extraction of a buyer reference embedded in the typed cart, for consistency checks. */
15
+ export interface ProxyCartParseOptions<TCart> {
16
+ readonly getBuyerReference?: (cart: TCart) => string | null | undefined;
17
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Typed cart-snapshot validation.
3
+ *
4
+ * The cart snapshot is merchant-defined and opaque to Proxy, so the SDK keeps
5
+ * the shape app-owned but standardizes the parse step: pass a zod-style schema
6
+ * (or a plain validator function) and get a typed cart or a structured error.
7
+ */
8
+ /** A zod-style schema (`{ parse }`) or a plain validator function. */
9
+ export type ProxyCartValidator<TCart> = {
10
+ parse: (value: unknown) => TCart;
11
+ } | ((value: unknown) => TCart);
12
+ /** Run a cart snapshot through a validator, wrapping failures in a structured SDK error. */
13
+ export declare function parseProxyCart<TCart>(cartSnapshot: unknown, validator: ProxyCartValidator<TCart>): TCart;
14
+ /** Optional extraction of a buyer reference embedded in the typed cart, for consistency checks. */
15
+ export interface ProxyCartParseOptions<TCart> {
16
+ readonly getBuyerReference?: (cart: TCart) => string | null | undefined;
17
+ }
@@ -0,0 +1,19 @@
1
+ import { ProxyEventsResource } from "./events.js";
2
+ import { ProxySessionsResource } from "./sessions.js";
3
+ import { ProxySubscriptionsResource } from "./subscriptions.js";
4
+ import type { ProxyCheckoutServerClientOptions } from "./types.js";
5
+ import { ProxyWebhooksResource } from "./webhook-handler.js";
6
+ import { ProxyWebhookEndpointsResource } from "./webhooks.js";
7
+ export declare class ProxyCheckoutServerClient {
8
+ readonly apiHost: string;
9
+ readonly sessions: ProxySessionsResource;
10
+ readonly subscriptions: ProxySubscriptionsResource;
11
+ /** Current-state lifecycle resolver for signed webhook events. */
12
+ readonly events: ProxyEventsResource;
13
+ /** Webhook delivery handling: `handle`, `process`, `constructEvent`. */
14
+ readonly webhooks: ProxyWebhooksResource;
15
+ /** Webhook endpoint management API (create/list/rotate). */
16
+ readonly webhookEndpoints: ProxyWebhookEndpointsResource;
17
+ constructor(options: ProxyCheckoutServerClientOptions);
18
+ }
19
+ export declare function createProxyCheckoutServerClient(options: ProxyCheckoutServerClientOptions): ProxyCheckoutServerClient;
@@ -0,0 +1,19 @@
1
+ import { ProxyEventsResource } from "./events.js";
2
+ import { ProxySessionsResource } from "./sessions.js";
3
+ import { ProxySubscriptionsResource } from "./subscriptions.js";
4
+ import type { ProxyCheckoutServerClientOptions } from "./types.js";
5
+ import { ProxyWebhooksResource } from "./webhook-handler.js";
6
+ import { ProxyWebhookEndpointsResource } from "./webhooks.js";
7
+ export declare class ProxyCheckoutServerClient {
8
+ readonly apiHost: string;
9
+ readonly sessions: ProxySessionsResource;
10
+ readonly subscriptions: ProxySubscriptionsResource;
11
+ /** Current-state lifecycle resolver for signed webhook events. */
12
+ readonly events: ProxyEventsResource;
13
+ /** Webhook delivery handling: `handle`, `process`, `constructEvent`. */
14
+ readonly webhooks: ProxyWebhooksResource;
15
+ /** Webhook endpoint management API (create/list/rotate). */
16
+ readonly webhookEndpoints: ProxyWebhookEndpointsResource;
17
+ constructor(options: ProxyCheckoutServerClientOptions);
18
+ }
19
+ export declare function createProxyCheckoutServerClient(options: ProxyCheckoutServerClientOptions): ProxyCheckoutServerClient;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Buyer-reference and session linkage consistency checks.
3
+ *
4
+ * Proxy current-state retrieval is the source of truth, but the SDK still
5
+ * guards that the records it stitches together actually belong to the same
6
+ * buyer and session before a merchant acts on them.
7
+ */
8
+ import type { MerchantProxySession } from "./sessions.js";
9
+ import type { MerchantProxySubscription } from "./subscriptions.js";
10
+ /**
11
+ * Assert that a subscription belongs to the given original session and that the
12
+ * buyer references agree. Throws {@link ProxyCheckoutValidationError} otherwise.
13
+ */
14
+ export declare function assertSubscriptionMatchesSession(subscription: Pick<MerchantProxySubscription, "buyerReference" | "id" | "originalProxySessionId">, session: Pick<MerchantProxySession, "buyerReference" | "id">): void;
15
+ /**
16
+ * Assert that a cart-embedded buyer reference, when present, matches the session
17
+ * buyer reference. A `null`/`undefined` cart buyer reference is allowed (the
18
+ * cart simply does not carry one).
19
+ */
20
+ export declare function assertCartBuyerReference(cartBuyerReference: string | null | undefined, session: Pick<MerchantProxySession, "buyerReference" | "id">): void;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Buyer-reference and session linkage consistency checks.
3
+ *
4
+ * Proxy current-state retrieval is the source of truth, but the SDK still
5
+ * guards that the records it stitches together actually belong to the same
6
+ * buyer and session before a merchant acts on them.
7
+ */
8
+ import type { MerchantProxySession } from "./sessions.js";
9
+ import type { MerchantProxySubscription } from "./subscriptions.js";
10
+ /**
11
+ * Assert that a subscription belongs to the given original session and that the
12
+ * buyer references agree. Throws {@link ProxyCheckoutValidationError} otherwise.
13
+ */
14
+ export declare function assertSubscriptionMatchesSession(subscription: Pick<MerchantProxySubscription, "buyerReference" | "id" | "originalProxySessionId">, session: Pick<MerchantProxySession, "buyerReference" | "id">): void;
15
+ /**
16
+ * Assert that a cart-embedded buyer reference, when present, matches the session
17
+ * buyer reference. A `null`/`undefined` cart buyer reference is allowed (the
18
+ * cart simply does not carry one).
19
+ */
20
+ export declare function assertCartBuyerReference(cartBuyerReference: string | null | undefined, session: Pick<MerchantProxySession, "buyerReference" | "id">): void;
@@ -0,0 +1,32 @@
1
+ export interface ProxyCheckoutApiErrorDetails {
2
+ readonly code?: string;
3
+ readonly requestId?: string;
4
+ readonly responseBody: unknown;
5
+ readonly statusCode: number;
6
+ }
7
+ export type ProxyCheckoutValidationCode = "buyer_reference_mismatch" | "cart_invalid" | "invalid_date" | "provider_binding_mismatch" | "subscription_session_mismatch";
8
+ /**
9
+ * Raised when the SDK receives Proxy data it cannot safely normalize, for
10
+ * example an invalid date string, a cart snapshot that fails the merchant
11
+ * schema, or a buyer-reference / provider-binding consistency violation.
12
+ */
13
+ export declare class ProxyCheckoutValidationError extends Error {
14
+ readonly name = "ProxyCheckoutValidationError";
15
+ readonly code: ProxyCheckoutValidationCode;
16
+ readonly field: string | undefined;
17
+ readonly cause: unknown;
18
+ constructor(message: string, details: {
19
+ code: ProxyCheckoutValidationCode;
20
+ field?: string;
21
+ cause?: unknown;
22
+ });
23
+ }
24
+ export declare class ProxyCheckoutApiError extends Error {
25
+ readonly name = "ProxyCheckoutApiError";
26
+ readonly code: string | undefined;
27
+ readonly requestId: string | undefined;
28
+ readonly responseBody: unknown;
29
+ readonly statusCode: number;
30
+ constructor(message: string, details: ProxyCheckoutApiErrorDetails);
31
+ }
32
+ export declare function toApiError(statusCode: number, responseBody: unknown, headerRequestId?: string): ProxyCheckoutApiError;
@@ -0,0 +1,32 @@
1
+ export interface ProxyCheckoutApiErrorDetails {
2
+ readonly code?: string;
3
+ readonly requestId?: string;
4
+ readonly responseBody: unknown;
5
+ readonly statusCode: number;
6
+ }
7
+ export type ProxyCheckoutValidationCode = "buyer_reference_mismatch" | "cart_invalid" | "invalid_date" | "provider_binding_mismatch" | "subscription_session_mismatch";
8
+ /**
9
+ * Raised when the SDK receives Proxy data it cannot safely normalize, for
10
+ * example an invalid date string, a cart snapshot that fails the merchant
11
+ * schema, or a buyer-reference / provider-binding consistency violation.
12
+ */
13
+ export declare class ProxyCheckoutValidationError extends Error {
14
+ readonly name = "ProxyCheckoutValidationError";
15
+ readonly code: ProxyCheckoutValidationCode;
16
+ readonly field: string | undefined;
17
+ readonly cause: unknown;
18
+ constructor(message: string, details: {
19
+ code: ProxyCheckoutValidationCode;
20
+ field?: string;
21
+ cause?: unknown;
22
+ });
23
+ }
24
+ export declare class ProxyCheckoutApiError extends Error {
25
+ readonly name = "ProxyCheckoutApiError";
26
+ readonly code: string | undefined;
27
+ readonly requestId: string | undefined;
28
+ readonly responseBody: unknown;
29
+ readonly statusCode: number;
30
+ constructor(message: string, details: ProxyCheckoutApiErrorDetails);
31
+ }
32
+ export declare function toApiError(statusCode: number, responseBody: unknown, headerRequestId?: string): ProxyCheckoutApiError;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Current-state lifecycle resolver for signed Proxy webhook events.
3
+ *
4
+ * A webhook is only a wakeup: this resolver re-reads the authoritative session
5
+ * and subscription state with the merchant secret key and returns a typed
6
+ * lifecycle decision. It never grants from webhook payload fields, and it
7
+ * classifies subscription events from current state rather than event order.
8
+ */
9
+ import type { MerchantProxySession, ProxySessionsResource } from "./sessions.js";
10
+ import type { MerchantProxySubscription, ProxySubscriptionsResource } from "./subscriptions.js";
11
+ import type { ProxyCheckoutServerRequestOptions } from "./types.js";
12
+ import type { ProxyWebhookEvent } from "./webhooks.js";
13
+ export interface ResolveProxyEventOptions extends ProxyCheckoutServerRequestOptions {
14
+ }
15
+ interface ResolvedBase {
16
+ readonly event: ProxyWebhookEvent;
17
+ }
18
+ /**
19
+ * First paid/provisionable wakeup for a session. `subscription` is present when
20
+ * the event carried a subscription id; otherwise the merchant computes initial
21
+ * access from its own cart policy (`accessEndsAt`/`willRenew` are then null).
22
+ */
23
+ export interface ResolvedInitialProvision extends ResolvedBase {
24
+ readonly accessEndsAt: Date | null;
25
+ readonly kind: "initial_provision";
26
+ readonly session: MerchantProxySession;
27
+ readonly subscription: MerchantProxySubscription | null;
28
+ readonly willRenew: boolean | null;
29
+ }
30
+ export interface ResolvedSubscriptionRenewed extends ResolvedBase {
31
+ readonly accessEndsAt: Date | null;
32
+ readonly kind: "subscription_renewed";
33
+ readonly session: MerchantProxySession;
34
+ readonly subscription: MerchantProxySubscription;
35
+ readonly willRenew: boolean;
36
+ }
37
+ export interface ResolvedSubscriptionCancelScheduled extends ResolvedBase {
38
+ readonly accessEndsAt: Date | null;
39
+ readonly kind: "subscription_cancel_scheduled";
40
+ readonly session: MerchantProxySession;
41
+ readonly subscription: MerchantProxySubscription;
42
+ readonly willRenew: false;
43
+ }
44
+ export interface ResolvedSubscriptionCancelled extends ResolvedBase {
45
+ readonly accessEndsAt: Date | null;
46
+ readonly kind: "subscription_cancelled";
47
+ readonly session: MerchantProxySession;
48
+ readonly subscription: MerchantProxySubscription;
49
+ readonly willRenew: false;
50
+ }
51
+ export interface ResolvedPaymentRisk extends ResolvedBase {
52
+ readonly accessEndsAt: Date | null;
53
+ readonly kind: "payment_risk";
54
+ readonly latestPaymentStatus: string | null;
55
+ readonly session: MerchantProxySession;
56
+ readonly subscription: MerchantProxySubscription;
57
+ readonly willRenew: boolean;
58
+ }
59
+ export interface ResolvedTerminalSession extends ResolvedBase {
60
+ readonly kind: "terminal_session";
61
+ readonly session: MerchantProxySession;
62
+ }
63
+ export interface ResolvedPaymentAttempt extends ResolvedBase {
64
+ readonly kind: "payment_attempt";
65
+ readonly paymentAttemptId: string | null;
66
+ readonly sessionId: string | null;
67
+ readonly subscriptionId: string | null;
68
+ }
69
+ export interface ResolvedIgnored extends ResolvedBase {
70
+ readonly kind: "ignored";
71
+ readonly reason: string;
72
+ readonly sessionId: string | null;
73
+ readonly subscriptionId: string | null;
74
+ }
75
+ export type ResolvedProxyEvent = ResolvedInitialProvision | ResolvedSubscriptionRenewed | ResolvedSubscriptionCancelScheduled | ResolvedSubscriptionCancelled | ResolvedPaymentRisk | ResolvedTerminalSession | ResolvedPaymentAttempt | ResolvedIgnored;
76
+ export type ResolvedProxyEventKind = ResolvedProxyEvent["kind"];
77
+ export declare class ProxyEventsResource {
78
+ private readonly sessions;
79
+ private readonly subscriptions;
80
+ constructor(sessions: ProxySessionsResource, subscriptions: ProxySubscriptionsResource);
81
+ /**
82
+ * Resolve a signed webhook event into a current-state lifecycle decision by
83
+ * re-reading the authoritative session/subscription with the secret key.
84
+ */
85
+ resolveCurrentState(event: ProxyWebhookEvent, options?: ResolveProxyEventOptions): Promise<ResolvedProxyEvent>;
86
+ private resolveSessionEvent;
87
+ private resolveSubscriptionEvent;
88
+ }
89
+ export {};
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Current-state lifecycle resolver for signed Proxy webhook events.
3
+ *
4
+ * A webhook is only a wakeup: this resolver re-reads the authoritative session
5
+ * and subscription state with the merchant secret key and returns a typed
6
+ * lifecycle decision. It never grants from webhook payload fields, and it
7
+ * classifies subscription events from current state rather than event order.
8
+ */
9
+ import type { MerchantProxySession, ProxySessionsResource } from "./sessions.js";
10
+ import type { MerchantProxySubscription, ProxySubscriptionsResource } from "./subscriptions.js";
11
+ import type { ProxyCheckoutServerRequestOptions } from "./types.js";
12
+ import type { ProxyWebhookEvent } from "./webhooks.js";
13
+ export interface ResolveProxyEventOptions extends ProxyCheckoutServerRequestOptions {
14
+ }
15
+ interface ResolvedBase {
16
+ readonly event: ProxyWebhookEvent;
17
+ }
18
+ /**
19
+ * First paid/provisionable wakeup for a session. `subscription` is present when
20
+ * the event carried a subscription id; otherwise the merchant computes initial
21
+ * access from its own cart policy (`accessEndsAt`/`willRenew` are then null).
22
+ */
23
+ export interface ResolvedInitialProvision extends ResolvedBase {
24
+ readonly accessEndsAt: Date | null;
25
+ readonly kind: "initial_provision";
26
+ readonly session: MerchantProxySession;
27
+ readonly subscription: MerchantProxySubscription | null;
28
+ readonly willRenew: boolean | null;
29
+ }
30
+ export interface ResolvedSubscriptionRenewed extends ResolvedBase {
31
+ readonly accessEndsAt: Date | null;
32
+ readonly kind: "subscription_renewed";
33
+ readonly session: MerchantProxySession;
34
+ readonly subscription: MerchantProxySubscription;
35
+ readonly willRenew: boolean;
36
+ }
37
+ export interface ResolvedSubscriptionCancelScheduled extends ResolvedBase {
38
+ readonly accessEndsAt: Date | null;
39
+ readonly kind: "subscription_cancel_scheduled";
40
+ readonly session: MerchantProxySession;
41
+ readonly subscription: MerchantProxySubscription;
42
+ readonly willRenew: false;
43
+ }
44
+ export interface ResolvedSubscriptionCancelled extends ResolvedBase {
45
+ readonly accessEndsAt: Date | null;
46
+ readonly kind: "subscription_cancelled";
47
+ readonly session: MerchantProxySession;
48
+ readonly subscription: MerchantProxySubscription;
49
+ readonly willRenew: false;
50
+ }
51
+ export interface ResolvedPaymentRisk extends ResolvedBase {
52
+ readonly accessEndsAt: Date | null;
53
+ readonly kind: "payment_risk";
54
+ readonly latestPaymentStatus: string | null;
55
+ readonly session: MerchantProxySession;
56
+ readonly subscription: MerchantProxySubscription;
57
+ readonly willRenew: boolean;
58
+ }
59
+ export interface ResolvedTerminalSession extends ResolvedBase {
60
+ readonly kind: "terminal_session";
61
+ readonly session: MerchantProxySession;
62
+ }
63
+ export interface ResolvedPaymentAttempt extends ResolvedBase {
64
+ readonly kind: "payment_attempt";
65
+ readonly paymentAttemptId: string | null;
66
+ readonly sessionId: string | null;
67
+ readonly subscriptionId: string | null;
68
+ }
69
+ export interface ResolvedIgnored extends ResolvedBase {
70
+ readonly kind: "ignored";
71
+ readonly reason: string;
72
+ readonly sessionId: string | null;
73
+ readonly subscriptionId: string | null;
74
+ }
75
+ export type ResolvedProxyEvent = ResolvedInitialProvision | ResolvedSubscriptionRenewed | ResolvedSubscriptionCancelScheduled | ResolvedSubscriptionCancelled | ResolvedPaymentRisk | ResolvedTerminalSession | ResolvedPaymentAttempt | ResolvedIgnored;
76
+ export type ResolvedProxyEventKind = ResolvedProxyEvent["kind"];
77
+ export declare class ProxyEventsResource {
78
+ private readonly sessions;
79
+ private readonly subscriptions;
80
+ constructor(sessions: ProxySessionsResource, subscriptions: ProxySubscriptionsResource);
81
+ /**
82
+ * Resolve a signed webhook event into a current-state lifecycle decision by
83
+ * re-reading the authoritative session/subscription with the secret key.
84
+ */
85
+ resolveCurrentState(event: ProxyWebhookEvent, options?: ResolveProxyEventOptions): Promise<ResolvedProxyEvent>;
86
+ private resolveSessionEvent;
87
+ private resolveSubscriptionEvent;
88
+ }
89
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { JsonValue, ProxyCheckoutFetch } from "./types.js";
2
+ export interface ProxyCheckoutRequestOptions {
3
+ readonly idempotencyKey?: string;
4
+ readonly requestId?: string;
5
+ }
6
+ export declare class ProxyCheckoutHttpClient {
7
+ readonly apiHost: string;
8
+ private readonly apiKey;
9
+ private readonly fetchImpl;
10
+ constructor({ apiHost, apiKey, fetchImpl, }: {
11
+ apiHost?: string;
12
+ apiKey: string;
13
+ fetchImpl?: ProxyCheckoutFetch;
14
+ });
15
+ request(method: "GET" | "PATCH" | "POST" | "PUT", path: string, body?: JsonValue, options?: ProxyCheckoutRequestOptions): Promise<unknown>;
16
+ }
@@ -0,0 +1,16 @@
1
+ import type { JsonValue, ProxyCheckoutFetch } from "./types.js";
2
+ export interface ProxyCheckoutRequestOptions {
3
+ readonly idempotencyKey?: string;
4
+ readonly requestId?: string;
5
+ }
6
+ export declare class ProxyCheckoutHttpClient {
7
+ readonly apiHost: string;
8
+ private readonly apiKey;
9
+ private readonly fetchImpl;
10
+ constructor({ apiHost, apiKey, fetchImpl, }: {
11
+ apiHost?: string;
12
+ apiKey: string;
13
+ fetchImpl?: ProxyCheckoutFetch;
14
+ });
15
+ request(method: "GET" | "PATCH" | "POST" | "PUT", path: string, body?: JsonValue, options?: ProxyCheckoutRequestOptions): Promise<unknown>;
16
+ }
@@ -0,0 +1,13 @@
1
+ export { type ProxyCartParseOptions, type ProxyCartValidator, parseProxyCart, } from "./cart.js";
2
+ export { createProxyCheckoutServerClient, ProxyCheckoutServerClient, } from "./client.js";
3
+ export { assertCartBuyerReference, assertSubscriptionMatchesSession, } from "./consistency.js";
4
+ export { ProxyCheckoutApiError, type ProxyCheckoutApiErrorDetails, type ProxyCheckoutValidationCode, ProxyCheckoutValidationError, } from "./errors.js";
5
+ export { ProxyEventsResource, type ResolvedIgnored, type ResolvedInitialProvision, type ResolvedPaymentAttempt, type ResolvedPaymentRisk, type ResolvedProxyEvent, type ResolvedProxyEventKind, type ResolvedSubscriptionCancelled, type ResolvedSubscriptionCancelScheduled, type ResolvedSubscriptionRenewed, type ResolvedTerminalSession, type ResolveProxyEventOptions, } from "./events.js";
6
+ export { AT_RISK_SUBSCRIPTION_STATUSES, ENDED_SUBSCRIPTION_STATUSES, isSessionProvisionable, isSessionTerminal, isSubscriptionEnded, isSubscriptionPaymentAtRisk, PROVISIONABLE_SESSION_STATUSES, parseOptionalProxyDate, requireProxyDate, subscriptionAccessEndsAt, subscriptionWillRenew, TERMINAL_SESSION_STATUSES, } from "./lifecycle.js";
7
+ export { type CreateProxySessionHandoffInput, type CreateProxySessionInput, type CreateProxySessionOptions, type MerchantProxySession, type PayerHandoffResult, type PayerOpenedResult, type ProxySession, ProxySessionCartResource, type ProxySessionCartResult, type ProxySessionHandoff, type ProxySessionProviderBinding, ProxySessionsResource, proxyCheckoutServerEndpoints, type RecordProviderBindingInput, type SetProxySessionCartInput, type TypedMerchantProxySession, } from "./sessions.js";
8
+ export { type MerchantProxySubscription, ProxySubscriptionsResource, type ProxySubscriptionWithSession, type ProxySubscriptionWithUntypedSession, proxyCheckoutSubscriptionEndpoints, } from "./subscriptions.js";
9
+ export type { JsonObject, JsonPrimitive, JsonValue, ProxyCheckoutFetch, ProxyCheckoutServerClientOptions, ProxyCheckoutServerRequestOptions, } from "./types.js";
10
+ export { proxyCheckoutServerSdkName, proxyCheckoutServerSdkUserAgent, proxyCheckoutServerSdkVersion, } from "./version.js";
11
+ export { isProxyPaymentAttemptEvent, isProxySessionEvent, isProxySubscriptionEvent, PROXY_WEBHOOK_EVENT_TYPES, type ProxyWebhookEventType, } from "./webhook-events.js";
12
+ export { PROXY_WEBHOOK_RETRY_AFTER_SECONDS, type ProxyWebhookClaimResult, type ProxyWebhookHandlerOptions, type ProxyWebhookOutcome, type ProxyWebhookPayloadInput, type ProxyWebhookProcessRecord, type ProxyWebhookProcessResult, type ProxyWebhookRequestInput, type ProxyWebhookStore, ProxyWebhooksResource, } from "./webhook-handler.js";
13
+ export { type ConstructProxyWebhookEventInput, type CreateWebhookEndpointInput, constructProxyWebhookEvent, PROXY_SIGNATURE_HEADER, ProxyWebhookEndpointsResource, type ProxyWebhookEvent, ProxyWebhookSignatureVerificationError, proxyCheckoutWebhookEndpointEndpoints, type RotateWebhookEndpointSecretInput, type UpdateWebhookEndpointInput, type VerifyProxyWebhookSignatureInput, verifyProxyWebhookSignature, type WebhookEndpoint, type WebhookEndpointSecretResult, } from "./webhooks.js";
@@ -0,0 +1,13 @@
1
+ export { type ProxyCartParseOptions, type ProxyCartValidator, parseProxyCart, } from "./cart.js";
2
+ export { createProxyCheckoutServerClient, ProxyCheckoutServerClient, } from "./client.js";
3
+ export { assertCartBuyerReference, assertSubscriptionMatchesSession, } from "./consistency.js";
4
+ export { ProxyCheckoutApiError, type ProxyCheckoutApiErrorDetails, type ProxyCheckoutValidationCode, ProxyCheckoutValidationError, } from "./errors.js";
5
+ export { ProxyEventsResource, type ResolvedIgnored, type ResolvedInitialProvision, type ResolvedPaymentAttempt, type ResolvedPaymentRisk, type ResolvedProxyEvent, type ResolvedProxyEventKind, type ResolvedSubscriptionCancelled, type ResolvedSubscriptionCancelScheduled, type ResolvedSubscriptionRenewed, type ResolvedTerminalSession, type ResolveProxyEventOptions, } from "./events.js";
6
+ export { AT_RISK_SUBSCRIPTION_STATUSES, ENDED_SUBSCRIPTION_STATUSES, isSessionProvisionable, isSessionTerminal, isSubscriptionEnded, isSubscriptionPaymentAtRisk, PROVISIONABLE_SESSION_STATUSES, parseOptionalProxyDate, requireProxyDate, subscriptionAccessEndsAt, subscriptionWillRenew, TERMINAL_SESSION_STATUSES, } from "./lifecycle.js";
7
+ export { type CreateProxySessionHandoffInput, type CreateProxySessionInput, type CreateProxySessionOptions, type MerchantProxySession, type PayerHandoffResult, type PayerOpenedResult, type ProxySession, ProxySessionCartResource, type ProxySessionCartResult, type ProxySessionHandoff, type ProxySessionProviderBinding, ProxySessionsResource, proxyCheckoutServerEndpoints, type RecordProviderBindingInput, type SetProxySessionCartInput, type TypedMerchantProxySession, } from "./sessions.js";
8
+ export { type MerchantProxySubscription, ProxySubscriptionsResource, type ProxySubscriptionWithSession, type ProxySubscriptionWithUntypedSession, proxyCheckoutSubscriptionEndpoints, } from "./subscriptions.js";
9
+ export type { JsonObject, JsonPrimitive, JsonValue, ProxyCheckoutFetch, ProxyCheckoutServerClientOptions, ProxyCheckoutServerRequestOptions, } from "./types.js";
10
+ export { proxyCheckoutServerSdkName, proxyCheckoutServerSdkUserAgent, proxyCheckoutServerSdkVersion, } from "./version.js";
11
+ export { isProxyPaymentAttemptEvent, isProxySessionEvent, isProxySubscriptionEvent, PROXY_WEBHOOK_EVENT_TYPES, type ProxyWebhookEventType, } from "./webhook-events.js";
12
+ export { PROXY_WEBHOOK_RETRY_AFTER_SECONDS, type ProxyWebhookClaimResult, type ProxyWebhookHandlerOptions, type ProxyWebhookOutcome, type ProxyWebhookPayloadInput, type ProxyWebhookProcessRecord, type ProxyWebhookProcessResult, type ProxyWebhookRequestInput, type ProxyWebhookStore, ProxyWebhooksResource, } from "./webhook-handler.js";
13
+ export { type ConstructProxyWebhookEventInput, type CreateWebhookEndpointInput, constructProxyWebhookEvent, PROXY_SIGNATURE_HEADER, ProxyWebhookEndpointsResource, type ProxyWebhookEvent, ProxyWebhookSignatureVerificationError, proxyCheckoutWebhookEndpointEndpoints, type RotateWebhookEndpointSecretInput, type UpdateWebhookEndpointInput, type VerifyProxyWebhookSignatureInput, verifyProxyWebhookSignature, type WebhookEndpoint, type WebhookEndpointSecretResult, } from "./webhooks.js";
@@ -0,0 +1,47 @@
1
+ /**
2
+ * SDK-owned normalization of Proxy session and subscription lifecycle.
3
+ *
4
+ * These helpers turn raw Proxy state into the small set of derived facts a
5
+ * merchant entitlement layer actually needs (`willRenew`, `accessEndsAt`,
6
+ * terminal/provisionable predicates) so every customer does not re-encode
7
+ * Proxy lifecycle semantics by hand.
8
+ */
9
+ import type { MerchantProxySession } from "./sessions.js";
10
+ import type { MerchantProxySubscription } from "./subscriptions.js";
11
+ /** Session statuses that mean the payer has paid and entitlement may be granted. */
12
+ export declare const PROVISIONABLE_SESSION_STATUSES: Set<string>;
13
+ /**
14
+ * Session statuses that are terminal from the SDK's lifecycle perspective — the
15
+ * automatic flow has stopped and the merchant must observe the outcome. This
16
+ * includes `merchant_action_required`, which halts the session pending merchant
17
+ * intervention; classifying it here keeps a `proxy_session.merchant_action_required`
18
+ * event from silently resolving to `ignored` and being marked processed.
19
+ */
20
+ export declare const TERMINAL_SESSION_STATUSES: Set<string>;
21
+ /** Subscription statuses that mean the subscription is no longer active. */
22
+ export declare const ENDED_SUBSCRIPTION_STATUSES: Set<string>;
23
+ /** Subscription statuses that indicate a payment problem on an otherwise live subscription. */
24
+ export declare const AT_RISK_SUBSCRIPTION_STATUSES: Set<string>;
25
+ /** Parse a required ISO date from Proxy, throwing a structured error when missing/invalid. */
26
+ export declare function requireProxyDate(value: string | null | undefined, field: string): Date;
27
+ /** Parse an optional ISO date from Proxy, returning null when absent and throwing when invalid. */
28
+ export declare function parseOptionalProxyDate(value: string | null | undefined, field?: string): Date | null;
29
+ /** True once the payer has paid / the session is provisionable for entitlement. */
30
+ export declare function isSessionProvisionable(session: Pick<MerchantProxySession, "status">): boolean;
31
+ /** True once the session has reached a terminal state. */
32
+ export declare function isSessionTerminal(session: Pick<MerchantProxySession, "status">): boolean;
33
+ /**
34
+ * Whether the subscription is expected to renew at the end of the current period.
35
+ * A subscription will not renew once it is scheduled to cancel or has ended.
36
+ */
37
+ export declare function subscriptionWillRenew(subscription: Pick<MerchantProxySubscription, "cancelAtPeriodEnd" | "endedAt" | "status">): boolean;
38
+ /**
39
+ * The instant at which paid access should end given current subscription state.
40
+ * Prefers an explicit `endedAt` (hard stop) over the current period boundary.
41
+ * Returns null when neither is known.
42
+ */
43
+ export declare function subscriptionAccessEndsAt(subscription: Pick<MerchantProxySubscription, "currentPeriodEnd" | "endedAt">): Date | null;
44
+ /** True when the subscription has ended (cancelled / expired / explicitly ended). */
45
+ export declare function isSubscriptionEnded(subscription: Pick<MerchantProxySubscription, "endedAt" | "status">): boolean;
46
+ /** True when the subscription is live but has a payment problem (past_due / unpaid / failed). */
47
+ export declare function isSubscriptionPaymentAtRisk(subscription: Pick<MerchantProxySubscription, "latestPaymentStatus" | "status">): boolean;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * SDK-owned normalization of Proxy session and subscription lifecycle.
3
+ *
4
+ * These helpers turn raw Proxy state into the small set of derived facts a
5
+ * merchant entitlement layer actually needs (`willRenew`, `accessEndsAt`,
6
+ * terminal/provisionable predicates) so every customer does not re-encode
7
+ * Proxy lifecycle semantics by hand.
8
+ */
9
+ import type { MerchantProxySession } from "./sessions.js";
10
+ import type { MerchantProxySubscription } from "./subscriptions.js";
11
+ /** Session statuses that mean the payer has paid and entitlement may be granted. */
12
+ export declare const PROVISIONABLE_SESSION_STATUSES: Set<string>;
13
+ /**
14
+ * Session statuses that are terminal from the SDK's lifecycle perspective — the
15
+ * automatic flow has stopped and the merchant must observe the outcome. This
16
+ * includes `merchant_action_required`, which halts the session pending merchant
17
+ * intervention; classifying it here keeps a `proxy_session.merchant_action_required`
18
+ * event from silently resolving to `ignored` and being marked processed.
19
+ */
20
+ export declare const TERMINAL_SESSION_STATUSES: Set<string>;
21
+ /** Subscription statuses that mean the subscription is no longer active. */
22
+ export declare const ENDED_SUBSCRIPTION_STATUSES: Set<string>;
23
+ /** Subscription statuses that indicate a payment problem on an otherwise live subscription. */
24
+ export declare const AT_RISK_SUBSCRIPTION_STATUSES: Set<string>;
25
+ /** Parse a required ISO date from Proxy, throwing a structured error when missing/invalid. */
26
+ export declare function requireProxyDate(value: string | null | undefined, field: string): Date;
27
+ /** Parse an optional ISO date from Proxy, returning null when absent and throwing when invalid. */
28
+ export declare function parseOptionalProxyDate(value: string | null | undefined, field?: string): Date | null;
29
+ /** True once the payer has paid / the session is provisionable for entitlement. */
30
+ export declare function isSessionProvisionable(session: Pick<MerchantProxySession, "status">): boolean;
31
+ /** True once the session has reached a terminal state. */
32
+ export declare function isSessionTerminal(session: Pick<MerchantProxySession, "status">): boolean;
33
+ /**
34
+ * Whether the subscription is expected to renew at the end of the current period.
35
+ * A subscription will not renew once it is scheduled to cancel or has ended.
36
+ */
37
+ export declare function subscriptionWillRenew(subscription: Pick<MerchantProxySubscription, "cancelAtPeriodEnd" | "endedAt" | "status">): boolean;
38
+ /**
39
+ * The instant at which paid access should end given current subscription state.
40
+ * Prefers an explicit `endedAt` (hard stop) over the current period boundary.
41
+ * Returns null when neither is known.
42
+ */
43
+ export declare function subscriptionAccessEndsAt(subscription: Pick<MerchantProxySubscription, "currentPeriodEnd" | "endedAt">): Date | null;
44
+ /** True when the subscription has ended (cancelled / expired / explicitly ended). */
45
+ export declare function isSubscriptionEnded(subscription: Pick<MerchantProxySubscription, "endedAt" | "status">): boolean;
46
+ /** True when the subscription is live but has a payment problem (past_due / unpaid / failed). */
47
+ export declare function isSubscriptionPaymentAtRisk(subscription: Pick<MerchantProxySubscription, "latestPaymentStatus" | "status">): boolean;
@@ -0,0 +1,8 @@
1
+ import type { JsonObject } from "./types.js";
2
+ export declare function requireJsonObject(value: unknown, operation: string): JsonObject;
3
+ export declare function requireString(value: unknown, field: string): string;
4
+ export declare function requireNullableString(value: unknown, field: string): string | null;
5
+ export declare function requireInteger(value: unknown, field: string): number;
6
+ export declare function requireNullableInteger(value: unknown, field: string): number | null;
7
+ export declare function requireBoolean(value: unknown, field: string): boolean;
8
+ export declare function requireStringArrayOrNull(value: unknown, field: string): string[] | null;
@@ -0,0 +1,8 @@
1
+ import type { JsonObject } from "./types.js";
2
+ export declare function requireJsonObject(value: unknown, operation: string): JsonObject;
3
+ export declare function requireString(value: unknown, field: string): string;
4
+ export declare function requireNullableString(value: unknown, field: string): string | null;
5
+ export declare function requireInteger(value: unknown, field: string): number;
6
+ export declare function requireNullableInteger(value: unknown, field: string): number | null;
7
+ export declare function requireBoolean(value: unknown, field: string): boolean;
8
+ export declare function requireStringArrayOrNull(value: unknown, field: string): string[] | null;