@carrierllc/mcp 0.13.69 → 0.13.71

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 (29) hide show
  1. package/dist/{chunk-W5DYFDVS.js → chunk-HGPV63X3.js} +2 -2
  2. package/dist/{chunk-W5DYFDVS.js.map → chunk-HGPV63X3.js.map} +1 -1
  3. package/dist/cli.js +1 -1
  4. package/dist/index.js +1 -1
  5. package/package.json +1 -1
  6. package/templates/storefront/src/app/activate/[orderId]/ActivateClient.tsx +5 -1
  7. package/templates/storefront/src/app/api/orders/[orderId]/email/route.ts +2 -1
  8. package/templates/storefront/src/app/api/orders/[orderId]/route.ts +2 -1
  9. package/templates/storefront/src/app/checkout/[templateId]/CheckoutClient.tsx +69 -50
  10. package/templates/storefront/src/app/checkout/success/CheckoutSuccessClient.tsx +1 -1
  11. package/templates/storefront/src/app/checkout/success/page.tsx +1 -1
  12. package/templates/storefront/src/app/dashboard/EsimControls.tsx +6 -5
  13. package/templates/storefront/src/app/globals.css +17 -0
  14. package/templates/storefront/src/app/not-found.tsx +27 -0
  15. package/templates/storefront/src/app/shop/ShopClient.tsx +16 -3
  16. package/templates/storefront/src/app/sign-in/[[...sign-in]]/StorefrontSignInClient.tsx +10 -5
  17. package/templates/storefront/src/app/sign-up/[[...sign-up]]/StorefrontSignUpClient.tsx +16 -12
  18. package/templates/storefront/src/components/footer/StorefrontFooter.tsx +1 -1
  19. package/templates/storefront/src/components/landing/FinalCTA.tsx +1 -1
  20. package/templates/storefront/src/components/landing/HeroSection.tsx +2 -2
  21. package/templates/storefront/src/components/landing/TierPlanBoard.tsx +1 -1
  22. package/templates/storefront/src/lib/buyer-auth-copy.ts +15 -0
  23. package/templates/storefront/src/lib/catalog-countries.ts +36 -5
  24. package/templates/storefront/src/lib/checkout-client-error.ts +26 -0
  25. package/templates/storefront/src/lib/log-safe.ts +10 -0
  26. package/templates/storefront/src/lib/order-route-guard.ts +3 -2
  27. package/templates/storefront/src/lib/request-origin.ts +7 -4
  28. package/templates/storefront/src/lib/tap-target.ts +1 -1
  29. package/templates/storefront/src/vendor/geo/index.ts +14 -0
@@ -7,6 +7,32 @@
7
7
 
8
8
  export const GENERIC_CHECKOUT_ERROR = "Checkout is unavailable right now. Please try again in a moment.";
9
9
 
10
+ /**
11
+ * Refusal codes the guest route can send, each with copy we own. Only the
12
+ * `code` is read, never the server's `error` text, so a reworded or unexpected
13
+ * server message cannot reach a customer. An unknown code uses the fallback.
14
+ *
15
+ * Only a state that really passes by itself promises that it will. A plan that
16
+ * cannot be sold, or a store that cannot take payment, does not fix itself in a
17
+ * few minutes, so those lines say so and point to support.
18
+ */
19
+ const CHECKOUT_REFUSAL_COPY: Record<string, string> = {
20
+ catalog_degraded: "Plans are temporarily unavailable. Please try again in a few minutes.",
21
+ plan_not_found: "That plan is no longer available. Pick another plan.",
22
+ plan_not_sellable: "This plan can't be bought right now. Pick another plan or contact support.",
23
+ stripe_live_refused: "Checkout isn't available on this store right now. Contact support if this continues.",
24
+ stripe_unconfigured: "Checkout isn't available on this store right now. Contact support if this continues.",
25
+ stripe_error: "We could not start checkout. Please try again in a moment.",
26
+ };
27
+
28
+ /** Buyer copy for a coded refusal. Null when the code is not on the allow-list. */
29
+ export function checkoutRefusalCopy(code: unknown): string | null {
30
+ if (typeof code !== "string") return null;
31
+ return Object.prototype.hasOwnProperty.call(CHECKOUT_REFUSAL_COPY, code)
32
+ ? CHECKOUT_REFUSAL_COPY[code]
33
+ : null;
34
+ }
35
+
10
36
  export class BuyerCopyError extends Error {
11
37
  constructor(message: string) {
12
38
  super(message);
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Keep a Stripe Checkout session id (`cs_test_…`, `cs_live_…`) out of server logs.
3
+ *
4
+ * The id is the buyer's proof of purchase for the activate page, so it is
5
+ * treated like a credential. Logs keep the prefix, which still says test or
6
+ * live, and drop the rest. Other text passes through unchanged.
7
+ */
8
+ export function maskCheckoutIds(text: string): string {
9
+ return text.replace(/\bcs_(test_|live_)?[A-Za-z0-9]+/g, (_match, mode: string | undefined) => `cs_${mode ?? ""}…`);
10
+ }
@@ -13,6 +13,7 @@
13
13
  import { auth } from "@clerk/nextjs/server";
14
14
  import { NextResponse } from "next/server";
15
15
  import { userOwnsOrder } from "@/lib/checkout-order-claim";
16
+ import { maskCheckoutIds } from "@/lib/log-safe";
16
17
  import type { OrderLookupError } from "@/vendor/carrier/client";
17
18
 
18
19
  export type OrderRouteGuard =
@@ -97,7 +98,7 @@ export function fulfilmentFailureResponse(
97
98
 
98
99
  if (reason === "unconfigured") {
99
100
  console.error(
100
- `[orders] NEXT_PUBLIC_CARRIER_API_URL is unset — cannot ${action} for ${orderId}`,
101
+ maskCheckoutIds(`[orders] NEXT_PUBLIC_CARRIER_API_URL is unset — cannot ${action} for ${orderId}`),
101
102
  );
102
103
  return NextResponse.json(
103
104
  {
@@ -108,7 +109,7 @@ export function fulfilmentFailureResponse(
108
109
  );
109
110
  }
110
111
 
111
- console.error(`[orders] failed to ${action} for ${orderId}: ${reason}`);
112
+ console.error(maskCheckoutIds(`[orders] failed to ${action} for ${orderId}: ${reason}`));
112
113
  return NextResponse.json(
113
114
  {
114
115
  error: `We couldn't ${action} right now. Please try again in a moment.`,
@@ -1,8 +1,10 @@
1
1
  /**
2
2
  * Origin used to keep a sign-in return path on this shop.
3
3
  *
4
- * Built from the request, not from the browser. `NEXT_PUBLIC_APP_URL` wins
5
- * when it is set. Otherwise the forwarded host on this request is used.
4
+ * Built from the request, not from the browser. Order of preference:
5
+ * `NEXT_PUBLIC_APP_URL` when it is set and parses, then the `host` header,
6
+ * then `x-forwarded-host`. Only http and https are accepted as the scheme;
7
+ * anything else falls back to https. A value that does not parse gives "".
6
8
  */
7
9
  export function requestOrigin(headerStore: { get(name: string): string | null }): string {
8
10
  const configured = process.env.NEXT_PUBLIC_APP_URL?.trim();
@@ -13,9 +15,10 @@ export function requestOrigin(headerStore: { get(name: string): string | null })
13
15
  // A bad configured URL falls through to the request host.
14
16
  }
15
17
  }
16
- const host = firstHeader(headerStore.get("x-forwarded-host") ?? headerStore.get("host"));
18
+ const host = firstHeader(headerStore.get("host")) || firstHeader(headerStore.get("x-forwarded-host"));
17
19
  if (!host) return "";
18
- const proto = firstHeader(headerStore.get("x-forwarded-proto")) || "https";
20
+ const forwardedProto = firstHeader(headerStore.get("x-forwarded-proto")).toLowerCase();
21
+ const proto = forwardedProto === "http" || forwardedProto === "https" ? forwardedProto : "https";
19
22
  try {
20
23
  return new URL(`${proto}://${host}`).origin;
21
24
  } catch {
@@ -11,7 +11,7 @@ export const primaryButtonClass =
11
11
 
12
12
  /** Accent text and links use #C2410C on light surfaces. */
13
13
  export const textLinkClass =
14
- "inline-flex min-h-11 items-center text-base font-semibold text-[var(--brand-accent-text)] hover:underline";
14
+ "inline-flex min-h-11 items-center text-base font-semibold text-[var(--brand-accent-text)] underline underline-offset-4";
15
15
 
16
16
  export const filledAccentClass =
17
17
  "inline-flex min-h-11 items-center justify-center rounded-full bg-[var(--brand-accent)] px-4 text-base font-semibold text-[var(--brand-on-accent)] transition-opacity hover:opacity-90";
@@ -42,6 +42,20 @@ export function formatDataAllowance(dataGb: number, unlimited = false): string {
42
42
  return `${Number.isInteger(dataGb) ? dataGb : dataGb.toFixed(1)} GB data`;
43
43
  }
44
44
 
45
+ /**
46
+ * "Data · validity" for a plan, naming only what the plan really states.
47
+ *
48
+ * `formatDataAllowance` and `formatValidity` answer "not specified" for a
49
+ * missing value. That is right for a field of its own and wrong as a line of
50
+ * sales copy, so this leaves such a part out. Null when neither part is known.
51
+ */
52
+ export function formatPlanSummary(dataGb: number, validityDays: number, unlimited = false): string | null {
53
+ const parts: string[] = [];
54
+ if (unlimited === true || (Number.isFinite(dataGb) && dataGb > 0)) parts.push(formatDataAllowance(dataGb, unlimited));
55
+ if (Number.isFinite(validityDays) && validityDays > 0) parts.push(formatValidity(validityDays));
56
+ return parts.length > 0 ? parts.join(" · ") : null;
57
+ }
58
+
45
59
  /** A plan's validity window, singular-aware. */
46
60
  export function formatValidity(validityDays: number): string {
47
61
  if (!Number.isFinite(validityDays) || validityDays <= 0) return "Validity not specified";