@superwall/runtime 2.1.1 → 2.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.
@@ -21,13 +21,25 @@ export type SuperwallCheckoutMode = "external" | "sheet" | "applePay";
21
21
  * - `managedPayments` overrides the account's Stripe managed-payments
22
22
  * setting for this paywall: `true` forces it on, `false` forces it off.
23
23
  * Omitted, the account setting applies.
24
+ * - `prepaidCards` decides whether Stripe Checkout accepts prepaid cards.
25
+ * Default: `"allow"`. See `SuperwallPrepaidCards`.
24
26
  */
25
27
  export type SuperwallCheckoutConfig<TReference extends string = string> = SuperwallCheckoutMode | {
26
28
  mode: SuperwallCheckoutMode;
27
29
  prefetch?: TReference | false;
28
30
  managedPayments?: boolean;
31
+ prepaidCards?: SuperwallPrepaidCards;
29
32
  };
33
+ /**
34
+ * Whether a web checkout accepts prepaid cards: `"allow"` (the default) or
35
+ * `"block"`, which makes Stripe refuse them, a defence against free-trial
36
+ * abuse. It applies to the sheet and the hosted checkout page; an Apple Pay
37
+ * payment can't be filtered by card type, so in `applePay` mode only the
38
+ * sheet fallback refuses them. Store purchases ignore it.
39
+ */
40
+ export type SuperwallPrepaidCards = "allow" | "block";
30
41
  export type SuperwallManagedPaymentsOverride = "USE_MANAGED_PAYMENTS" | "USE_DEFAULT_PAYMENTS";
31
42
  export declare const checkoutModeOf: (checkout: SuperwallCheckoutConfig | undefined) => SuperwallCheckoutMode | undefined;
32
43
  export declare const checkoutPrefetchOf: (checkout: SuperwallCheckoutConfig | undefined) => string | false | undefined;
33
44
  export declare const checkoutManagedPaymentsOf: (checkout: SuperwallCheckoutConfig | undefined) => SuperwallManagedPaymentsOverride | undefined;
45
+ export declare const checkoutPrepaidCardsOf: (checkout: SuperwallCheckoutConfig | undefined) => SuperwallPrepaidCards;
@@ -6,3 +6,4 @@ export const checkoutManagedPaymentsOf = (checkout) => {
6
6
  return undefined;
7
7
  return override ? "USE_MANAGED_PAYMENTS" : "USE_DEFAULT_PAYMENTS";
8
8
  };
9
+ export const checkoutPrepaidCardsOf = (checkout) => (typeof checkout === "object" ? checkout.prepaidCards : undefined) ?? "allow";
@@ -92,7 +92,7 @@ export type SuperwallConfig<TLocale extends string = string, TStripeReference ex
92
92
  };
93
93
  export { allowedHostsOf, LOOPBACK_HOST, MAX_ALLOWED_HOSTS, type ResolvedAllowedHosts, type SuperwallAllowedHostsConfig, } from "./allowedHosts";
94
94
  export { backgroundOf, type ResolvedBackground, type SuperwallBackgroundConfig, } from "./background";
95
- export { checkoutManagedPaymentsOf, checkoutModeOf, checkoutPrefetchOf, type SuperwallCheckoutConfig, type SuperwallCheckoutMode, type SuperwallManagedPaymentsOverride, } from "./checkout";
95
+ export { checkoutManagedPaymentsOf, checkoutModeOf, checkoutPrefetchOf, checkoutPrepaidCardsOf, type SuperwallCheckoutConfig, type SuperwallCheckoutMode, type SuperwallManagedPaymentsOverride, type SuperwallPrepaidCards, } from "./checkout";
96
96
  export { INSET_EDGES, insetsOf, type InsetEdge, type ResolvedInsets, type SuperwallInsetSide, type SuperwallInsetsConfig, } from "./insets";
97
97
  export type { SuperwallLocalizationConfig, SuperwallMessages } from "./localization";
98
98
  export type { SuperwallNotificationsConfig, SuperwallTrialReminderConfig, SuperwallTrialReminderContext, SuperwallTrialReminderNotification, SuperwallTrialReminderStaticConfig, } from "./notifications";
@@ -1,6 +1,6 @@
1
1
  export { allowedHostsOf, LOOPBACK_HOST, MAX_ALLOWED_HOSTS, } from "./allowedHosts";
2
2
  export { backgroundOf, } from "./background";
3
- export { checkoutManagedPaymentsOf, checkoutModeOf, checkoutPrefetchOf, } from "./checkout";
3
+ export { checkoutManagedPaymentsOf, checkoutModeOf, checkoutPrefetchOf, checkoutPrepaidCardsOf, } from "./checkout";
4
4
  export { INSET_EDGES, insetsOf, } from "./insets";
5
5
  export { normalizePlatform, SUPERWALL_PLATFORMS } from "./platforms";
6
6
  export { dismissesOnPurchase } from "./postPurchase";
@@ -274,6 +274,7 @@ const createSession = (options) => {
274
274
  openUrl: (url, urlOptions = {}) => post(outgoing.openUrl(url, urlOptions.browserType)),
275
275
  openExternalUrl: (url) => post(outgoing.openExternalUrl(url)),
276
276
  openDeepLink: (link) => post(outgoing.openDeepLink(link)),
277
+ customAction: (name) => post(outgoing.custom(name)),
277
278
  customPlacement: (name, params = {}) => post(outgoing.customPlacement(name, params)),
278
279
  setUserAttributes: (attributes) => {
279
280
  const entries = Object.entries(attributes).map(([key, value]) => ({
@@ -10,6 +10,7 @@ export declare const restore: () => Outgoing<"restore">;
10
10
  export declare const openUrl: (url: string, browserType?: "payment_sheet") => Outgoing<"open_url">;
11
11
  export declare const openExternalUrl: (url: string) => Outgoing<"open_url_external">;
12
12
  export declare const openDeepLink: (link: string) => Outgoing<"open_deep_link">;
13
+ export declare const custom: (name: string) => Outgoing<"custom">;
13
14
  export declare const customPlacement: (name: string, params: Record<string, unknown>) => Outgoing<"custom_placement">;
14
15
  export declare const userAttributeUpdated: (attributes: Outgoing<"user_attribute_updated">["attributes"]) => Outgoing<"user_attribute_updated">;
15
16
  export declare const requestStoreReview: (reviewType: Outgoing<"request_store_review">["review_type"]) => Outgoing<"request_store_review">;
@@ -20,6 +20,7 @@ export const openDeepLink = (link) => ({
20
20
  event_name: "open_deep_link",
21
21
  link,
22
22
  });
23
+ export const custom = (name) => ({ event_name: "custom", data: name });
23
24
  export const customPlacement = (name, params) => ({ event_name: "custom_placement", name, params });
24
25
  export const userAttributeUpdated = (attributes) => ({ event_name: "user_attribute_updated", attributes });
25
26
  export const requestStoreReview = (reviewType) => ({
@@ -1,5 +1,5 @@
1
1
  import type { ITransport, TEventTrackingBehavior, TIncomingMessage, TIncomingMessageCallbackResult, TIncomingMessageTransactionAbandon, TIncomingMessageTransactionComplete, TOutgoingMessage, TPermissionStatus, TPermissionTypeMessage, TransportKind } from "@superwall/protocol";
2
- import type { SuperwallCheckoutMode, SuperwallConfig, SuperwallPostPurchase } from "../config";
2
+ import type { SuperwallCheckoutMode, SuperwallConfig, SuperwallPostPurchase, SuperwallPrepaidCards } from "../config";
3
3
  import type { SuperwallTranslateValues } from "../localization";
4
4
  import type { SuperwallProduct, SuperwallProductInput, SuperwallProductVariables } from "../products";
5
5
  import type { Outgoing, PageViewInput } from "./outgoing";
@@ -104,6 +104,13 @@ export type SuperwallPurchaseOptions = {
104
104
  * Default: the config's `checkout` mode.
105
105
  */
106
106
  checkout?: SuperwallCheckoutMode;
107
+ /**
108
+ * Whether this purchase's web checkout accepts prepaid cards, overriding
109
+ * the config's `checkout.prepaidCards` for this call. See
110
+ * `SuperwallPrepaidCards`. Ignored by store purchases.
111
+ * Default: the config's `checkout.prepaidCards`, else `"allow"`.
112
+ */
113
+ prepaidCards?: SuperwallPrepaidCards;
107
114
  };
108
115
  export type SuperwallCallbackOptions = {
109
116
  behavior?: CallbackBehavior;
@@ -144,6 +151,7 @@ export interface SuperwallSession<out TProduct extends SuperwallProduct = Superw
144
151
  }) => void;
145
152
  openExternalUrl: (url: string) => void;
146
153
  openDeepLink: (link: string) => void;
154
+ customAction: (name: string) => void;
147
155
  customPlacement: (name: string, params?: Record<string, unknown>) => void;
148
156
  setUserAttributes: (attributes: SuperwallUserAttributes) => void;
149
157
  requestStoreReview: (reviewType: Outgoing<"request_store_review">["review_type"]) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superwall/runtime",
3
- "version": "2.1.1",
3
+ "version": "2.2.1",
4
4
  "description": "Framework-agnostic runtime for headless Superwall paywalls: bridge, session, products, localization, mock host.",
5
5
  "keywords": [
6
6
  "paywall",
@@ -39,7 +39,7 @@
39
39
  "clean": "rm -rf dist coverage"
40
40
  },
41
41
  "dependencies": {
42
- "@superwall/protocol": "2.1.1"
42
+ "@superwall/protocol": "2.2.1"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@superwall/host": "workspace:*",
@@ -22,10 +22,26 @@ export type SuperwallCheckoutMode = "external" | "sheet" | "applePay";
22
22
  * - `managedPayments` overrides the account's Stripe managed-payments
23
23
  * setting for this paywall: `true` forces it on, `false` forces it off.
24
24
  * Omitted, the account setting applies.
25
+ * - `prepaidCards` decides whether Stripe Checkout accepts prepaid cards.
26
+ * Default: `"allow"`. See `SuperwallPrepaidCards`.
25
27
  */
26
28
  export type SuperwallCheckoutConfig<TReference extends string = string> =
27
29
  | SuperwallCheckoutMode
28
- | { mode: SuperwallCheckoutMode; prefetch?: TReference | false; managedPayments?: boolean };
30
+ | {
31
+ mode: SuperwallCheckoutMode;
32
+ prefetch?: TReference | false;
33
+ managedPayments?: boolean;
34
+ prepaidCards?: SuperwallPrepaidCards;
35
+ };
36
+
37
+ /**
38
+ * Whether a web checkout accepts prepaid cards: `"allow"` (the default) or
39
+ * `"block"`, which makes Stripe refuse them, a defence against free-trial
40
+ * abuse. It applies to the sheet and the hosted checkout page; an Apple Pay
41
+ * payment can't be filtered by card type, so in `applePay` mode only the
42
+ * sheet fallback refuses them. Store purchases ignore it.
43
+ */
44
+ export type SuperwallPrepaidCards = "allow" | "block";
29
45
 
30
46
  export type SuperwallManagedPaymentsOverride = "USE_MANAGED_PAYMENTS" | "USE_DEFAULT_PAYMENTS";
31
47
 
@@ -44,3 +60,8 @@ export const checkoutManagedPaymentsOf = (
44
60
  if (override === undefined) return undefined;
45
61
  return override ? "USE_MANAGED_PAYMENTS" : "USE_DEFAULT_PAYMENTS";
46
62
  };
63
+
64
+ export const checkoutPrepaidCardsOf = (
65
+ checkout: SuperwallCheckoutConfig | undefined,
66
+ ): SuperwallPrepaidCards =>
67
+ (typeof checkout === "object" ? checkout.prepaidCards : undefined) ?? "allow";
@@ -126,9 +126,11 @@ export {
126
126
  checkoutManagedPaymentsOf,
127
127
  checkoutModeOf,
128
128
  checkoutPrefetchOf,
129
+ checkoutPrepaidCardsOf,
129
130
  type SuperwallCheckoutConfig,
130
131
  type SuperwallCheckoutMode,
131
132
  type SuperwallManagedPaymentsOverride,
133
+ type SuperwallPrepaidCards,
132
134
  } from "./checkout";
133
135
  export {
134
136
  INSET_EDGES,
@@ -331,6 +331,7 @@ const createSession = (options: SuperwallSessionOptions): SuperwallSession => {
331
331
  openUrl: (url, urlOptions = {}) => post(outgoing.openUrl(url, urlOptions.browserType)),
332
332
  openExternalUrl: (url) => post(outgoing.openExternalUrl(url)),
333
333
  openDeepLink: (link) => post(outgoing.openDeepLink(link)),
334
+ customAction: (name) => post(outgoing.custom(name)),
334
335
  customPlacement: (name, params = {}) => post(outgoing.customPlacement(name, params)),
335
336
  setUserAttributes: (attributes) => {
336
337
  const entries = Object.entries(attributes).map(([key, value]) => ({
@@ -35,6 +35,8 @@ export const openDeepLink = (link: string): Outgoing<"open_deep_link"> => ({
35
35
  link,
36
36
  });
37
37
 
38
+ export const custom = (name: string): Outgoing<"custom"> => ({ event_name: "custom", data: name });
39
+
38
40
  export const customPlacement = (
39
41
  name: string,
40
42
  params: Record<string, unknown>,
@@ -10,7 +10,12 @@ import type {
10
10
  TPermissionTypeMessage,
11
11
  TransportKind,
12
12
  } from "@superwall/protocol";
13
- import type { SuperwallCheckoutMode, SuperwallConfig, SuperwallPostPurchase } from "../config";
13
+ import type {
14
+ SuperwallCheckoutMode,
15
+ SuperwallConfig,
16
+ SuperwallPostPurchase,
17
+ SuperwallPrepaidCards,
18
+ } from "../config";
14
19
  import type { SuperwallTranslateValues } from "../localization";
15
20
  import type {
16
21
  SuperwallProduct,
@@ -143,6 +148,13 @@ export type SuperwallPurchaseOptions = {
143
148
  * Default: the config's `checkout` mode.
144
149
  */
145
150
  checkout?: SuperwallCheckoutMode;
151
+ /**
152
+ * Whether this purchase's web checkout accepts prepaid cards, overriding
153
+ * the config's `checkout.prepaidCards` for this call. See
154
+ * `SuperwallPrepaidCards`. Ignored by store purchases.
155
+ * Default: the config's `checkout.prepaidCards`, else `"allow"`.
156
+ */
157
+ prepaidCards?: SuperwallPrepaidCards;
146
158
  };
147
159
 
148
160
  export type SuperwallCallbackOptions = {
@@ -191,6 +203,7 @@ export interface SuperwallSession<out TProduct extends SuperwallProduct = Superw
191
203
  openUrl: (url: string, options?: { browserType?: "payment_sheet" }) => void;
192
204
  openExternalUrl: (url: string) => void;
193
205
  openDeepLink: (link: string) => void;
206
+ customAction: (name: string) => void;
194
207
  customPlacement: (name: string, params?: Record<string, unknown>) => void;
195
208
  setUserAttributes: (attributes: SuperwallUserAttributes) => void;
196
209
  requestStoreReview: (reviewType: Outgoing<"request_store_review">["review_type"]) => void;