@carrierllc/mcp 0.13.68 → 0.13.70

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrierllc/mcp",
3
- "version": "0.13.68",
3
+ "version": "0.13.70",
4
4
  "description": "Carrier MCP — natural-language control of MVNO/eSIM fleets via the network OCS. Stdio mode for direct integration with Claude Desktop, Cursor, Windsurf, and MCP-compatible clients. Ships the `carrier` CLI (plugin install + white-label eSIM storefront scaffold).",
5
5
  "license": "MIT",
6
6
  "author": "Carrier (Lifecycle Innovations Limited)",
@@ -494,7 +494,7 @@ export function ActivateClient({ orderId }: Props) {
494
494
  </div>
495
495
 
496
496
  {submitted ? (
497
- <p className="text-sm text-emerald-300 text-center py-2">
497
+ <p className="text-sm text-emerald-800 dark:text-emerald-300 text-center py-2">
498
498
  ✓ Phone number saved. We&apos;ll send updates to {phone}.
499
499
  </p>
500
500
  ) : (
@@ -516,7 +516,7 @@ export function ActivateClient({ orderId }: Props) {
516
516
  {saving ? "Saving…" : "Save"}
517
517
  </button>
518
518
  </div>
519
- {saveError && <p className="text-xs text-red-300">{saveError}</p>}
519
+ {saveError && <p className="text-xs text-red-700 dark:text-red-300">{saveError}</p>}
520
520
  <button
521
521
  type="button"
522
522
  onClick={() => setSubmitted(true)}
@@ -24,7 +24,7 @@
24
24
  * problem is not something a shopper can act on, and printing it makes a store
25
25
  * look broken rather than busy.
26
26
  */
27
- import { useCallback, useEffect, useRef, useState } from "react";
27
+ import { useCallback, useEffect, useRef, useState, type ReactNode } from "react";
28
28
  import { useAuth } from "@clerk/nextjs";
29
29
  import { useRouter } from "next/navigation";
30
30
  import {
@@ -34,6 +34,7 @@ import {
34
34
  import {
35
35
  BuyerCopyError,
36
36
  checkoutErrorCopy,
37
+ checkoutRefusalCopy,
37
38
  GENERIC_CHECKOUT_ERROR,
38
39
  readCheckoutJson,
39
40
  } from "@/lib/checkout-client-error";
@@ -110,8 +111,7 @@ export function CheckoutClient({ plan, session }: Props) {
110
111
  }
111
112
  if (!res.ok) {
112
113
  if (embed && body.code === "embed_unavailable") throw new EmbedUnavailable();
113
- if (body.code && body.error) throw new BuyerCopyError(body.error);
114
- throw new BuyerCopyError(GENERIC_CHECKOUT_ERROR);
114
+ throw new BuyerCopyError(checkoutRefusalCopy(body.code) ?? GENERIC_CHECKOUT_ERROR);
115
115
  }
116
116
  return body;
117
117
  })
@@ -199,62 +199,81 @@ export function CheckoutClient({ plan, session }: Props) {
199
199
  startGuestCheckout(false);
200
200
  }, [startGuestCheckout]);
201
201
 
202
- if (plan.price_unavailable === true) {
202
+ const view: ReactNode = (() => {
203
+ if (plan.price_unavailable === true) {
204
+ return (
205
+ <div className="mx-auto max-w-lg px-4 py-32 text-center">
206
+ <p className="text-sand-700 dark:text-sand-200">
207
+ We can&apos;t show a price for this plan right now, so it can&apos;t be bought yet.
208
+ </p>
209
+ <a
210
+ href="/shop"
211
+ className="mt-6 inline-flex min-h-11 items-center rounded-full border border-sand-300 px-6 text-base text-sand-900 dark:border-sand-700 dark:text-sand-50"
212
+ >
213
+ ← Back to shop
214
+ </a>
215
+ </div>
216
+ );
217
+ }
218
+
219
+ if (checkoutError) {
220
+ return (
221
+ <div className="mx-auto max-w-lg px-4 py-32 text-center">
222
+ <p role="alert" className="text-sand-700 dark:text-sand-200">{checkoutError}</p>
223
+ <p className="mt-2 text-base dark:text-sand-200 text-sand-600">{plan.name}</p>
224
+ <a
225
+ href="/shop"
226
+ className="mt-6 inline-flex min-h-11 items-center rounded-full border border-sand-300 px-6 text-base text-sand-900 dark:border-sand-700 dark:text-sand-50"
227
+ >
228
+ ← Back to shop
229
+ </a>
230
+ </div>
231
+ );
232
+ }
233
+
234
+ if (clientSecret) {
235
+ return (
236
+ <div className="mx-auto max-w-2xl px-4 py-16">
237
+ <h1 className="text-2xl font-semibold tracking-tight text-sand-900 dark:text-sand-50">
238
+ Almost there.
239
+ </h1>
240
+ <p className="mt-2 mb-8 text-base text-sand-700 dark:text-sand-200">
241
+ {plan.name} — your QR code is ready the moment this clears.
242
+ </p>
243
+ <EmbeddedStripeCheckout
244
+ clientSecret={clientSecret}
245
+ onComplete={handleComplete}
246
+ onUnavailable={handleEmbedUnavailable}
247
+ />
248
+ </div>
249
+ );
250
+ }
251
+
203
252
  return (
204
253
  <div className="mx-auto max-w-lg px-4 py-32 text-center">
254
+ <div className="mx-auto mb-4 h-8 w-8 animate-spin rounded-full border-2 border-[var(--brand-accent)] border-t-transparent" />
205
255
  <p className="text-sand-700 dark:text-sand-200">
206
- We can&apos;t show a price for this plan right now, so it can&apos;t be bought yet.
256
+ {loading ? "Preparing your checkout…" : "Redirecting to payment…"}
207
257
  </p>
208
- <a
209
- href="/shop"
210
- className="mt-6 inline-flex min-h-11 items-center rounded-full border border-sand-300 px-6 text-base text-sand-900 dark:border-sand-700 dark:text-sand-50"
211
- >
212
- ← Back to shop
213
- </a>
214
- </div>
215
- );
216
- }
217
-
218
- if (checkoutError) {
219
- return (
220
- <div className="mx-auto max-w-lg px-4 py-32 text-center">
221
- <p role="alert" className="text-sand-700 dark:text-sand-200">{checkoutError}</p>
222
258
  <p className="mt-2 text-base dark:text-sand-200 text-sand-600">{plan.name}</p>
223
- <a
224
- href="/shop"
225
- className="mt-6 inline-flex min-h-11 items-center rounded-full border border-sand-300 px-6 text-base text-sand-900 dark:border-sand-700 dark:text-sand-50"
226
- >
227
- ← Back to shop
228
- </a>
229
259
  </div>
230
260
  );
231
- }
261
+ })();
232
262
 
233
- if (clientSecret) {
234
- return (
235
- <div className="mx-auto max-w-2xl px-4 py-16">
236
- <h1 className="text-2xl font-semibold tracking-tight text-sand-900 dark:text-sand-50">
237
- Almost there.
238
- </h1>
239
- <p className="mt-2 mb-8 text-base text-sand-700 dark:text-sand-200">
240
- {plan.name} — your QR code is ready the moment this clears.
241
- </p>
242
- <EmbeddedStripeCheckout
243
- clientSecret={clientSecret}
244
- onComplete={handleComplete}
245
- onUnavailable={handleEmbedUnavailable}
246
- />
247
- </div>
248
- );
249
- }
263
+ // Always mounted, so a screen reader is already watching it when the text
264
+ // changes. A region that appears together with its text is often not read.
265
+ const status = loading
266
+ ? "Preparing your checkout…"
267
+ : clientSecret
268
+ ? "The payment form is ready."
269
+ : "";
250
270
 
251
271
  return (
252
- <div className="mx-auto max-w-lg px-4 py-32 text-center">
253
- <div className="mx-auto mb-4 h-8 w-8 animate-spin rounded-full border-2 border-[var(--brand-accent)] border-t-transparent" />
254
- <p className="text-sand-700 dark:text-sand-200">
255
- {loading ? "Preparing your checkout…" : "Redirecting to payment…"}
256
- </p>
257
- <p className="mt-2 text-base dark:text-sand-200 text-sand-600">{plan.name}</p>
258
- </div>
272
+ <>
273
+ <div role="status" aria-live="polite" className="sr-only">
274
+ {status}
275
+ </div>
276
+ {view}
277
+ </>
259
278
  );
260
279
  }
@@ -79,7 +79,7 @@ function Confirmation({ reference, supportHref }: { reference: string; supportHr
79
79
  </p>
80
80
  <a
81
81
  href={supportHref}
82
- className="mt-4 inline-flex min-h-11 items-center justify-center text-base text-[var(--brand-accent-text)]"
82
+ className="mt-4 inline-flex min-h-11 items-center justify-center text-base text-[var(--brand-accent-text)] underline underline-offset-4"
83
83
  >
84
84
  Contact support
85
85
  </a>
@@ -31,7 +31,7 @@ interface Props {
31
31
  const filledLinkClass =
32
32
  "mt-8 inline-flex min-h-11 items-center justify-center rounded-full px-6 text-base font-semibold";
33
33
  const supportLinkClass =
34
- "mt-4 inline-flex min-h-11 items-center justify-center text-base text-[var(--brand-accent-text)]";
34
+ "mt-6 inline-flex min-h-11 items-center justify-center text-base text-[var(--brand-accent-text)] underline underline-offset-4";
35
35
 
36
36
  const PROCESSING_STATUS =
37
37
  "You don't need to pay again. Refresh in a minute to check again. Use Check again any time.";
@@ -18,9 +18,8 @@ import { buyerFacingError } from "@/lib/buyer-error";
18
18
  import {
19
19
  daysUntil,
20
20
  formatBytes,
21
- formatDataAllowance,
21
+ formatPlanSummary,
22
22
  formatPrice,
23
- formatValidity,
24
23
  } from "@/vendor/geo";
25
24
  import type { EsimUsage, TopUpOption } from "@/vendor/carrier/types";
26
25
 
@@ -167,9 +166,11 @@ export function EsimControls({ orderId, cancelled: initiallyCancelled }: Props)
167
166
  <p className="text-sm font-medium text-sand-900 dark:text-sand-50">
168
167
  {option.name}
169
168
  </p>
170
- <p className="text-xs text-sand-500">
171
- {formatDataAllowance(option.dataGb, option.unlimited)} · {formatValidity(option.validityDays)}
172
- </p>
169
+ {formatPlanSummary(option.dataGb, option.validityDays, option.unlimited) ? (
170
+ <p className="text-xs text-sand-500">
171
+ {formatPlanSummary(option.dataGb, option.validityDays, option.unlimited)}
172
+ </p>
173
+ ) : null}
173
174
  </div>
174
175
  <button
175
176
  type="button"
@@ -126,3 +126,12 @@ html[data-theme="dark"] {
126
126
  outline: 2px solid var(--brand-focus);
127
127
  outline-offset: 2px;
128
128
  }
129
+
130
+ /* A heading that takes focus from script (tabIndex -1) is not a control.
131
+ Without this the ring above draws around the outcome title after payment.
132
+ The ring is made clear, not removed, so forced-colours mode still shows it.
133
+ Controls keep the full ring. */
134
+ h1[tabindex="-1"]:focus,
135
+ h1[tabindex="-1"]:focus-visible {
136
+ outline-color: transparent;
137
+ }
@@ -0,0 +1,27 @@
1
+ import Link from "next/link";
2
+ import brand from "@/brand.config";
3
+ import { filledAccentClass, textLinkClass } from "@/lib/tap-target";
4
+
5
+ export const metadata = { title: "Page not found" };
6
+
7
+ /** Shown for any address the shop does not have. Brand styles come from the root layout. */
8
+ export default function NotFound() {
9
+ return (
10
+ <div className="mx-auto max-w-lg px-4 py-32 text-center">
11
+ <h1 className="text-3xl font-semibold tracking-tight text-sand-900 dark:text-sand-50">
12
+ We can&apos;t find that page
13
+ </h1>
14
+ <p className="mt-3 text-base text-sand-700 dark:text-sand-200">
15
+ The link may be old or mistyped. Your plans are one tap away.
16
+ </p>
17
+ <div className="mt-8 flex flex-wrap items-center justify-center gap-4">
18
+ <Link href="/shop" className={filledAccentClass}>
19
+ Browse plans
20
+ </Link>
21
+ <Link href={brand.supportUrl} className={textLinkClass}>
22
+ Contact support
23
+ </Link>
24
+ </div>
25
+ </div>
26
+ );
27
+ }
@@ -19,7 +19,7 @@ import { conversionEvents } from "@/lib/conversion-events";
19
19
  import { countryCatalogMode, plansForCountry } from "@/lib/catalog-countries";
20
20
  import { filledAccentClass, textLinkClass } from "@/lib/tap-target";
21
21
  import { presentTierCatalog, speedTierOf } from "@/vendor/carrier/tiers";
22
- import { formatDataAllowance, formatPrice, formatValidity } from "@/vendor/geo";
22
+ import { formatPlanSummary, formatPrice } from "@/vendor/geo";
23
23
  import type { SkuTemplate } from "@/vendor/carrier/types";
24
24
 
25
25
  const secondary = "text-sand-700 dark:text-sand-200";
@@ -120,7 +120,7 @@ export function ShopClient({ plans, country = "" }: { plans: SkuTemplate[]; coun
120
120
  </h2>
121
121
  <p className={`mt-1 text-sm ${secondary}`}>
122
122
  {selected
123
- ? `${formatDataAllowance(selected.dataGb, selected.unlimited)} · ${formatValidity(selected.validityDays)}`
123
+ ? formatPlanSummary(selected.dataGb, selected.validityDays, selected.unlimited)
124
124
  : "Choose a speed tier and the total appears here."}
125
125
  </p>
126
126
 
@@ -55,7 +55,7 @@ export function StorefrontFooter() {
55
55
  <ul className="space-y-2">
56
56
  {links.map((link) => (
57
57
  <li key={link.href}>
58
- <Link href={link.href} className="inline-flex min-h-11 items-center text-base text-sand-400 transition-colors hover:text-sand-50">
58
+ <Link href={link.href} className="inline-flex min-h-11 items-center text-base text-sand-400 underline underline-offset-4 transition-colors hover:text-sand-50">
59
59
  {link.label}
60
60
  </Link>
61
61
  </li>
@@ -44,10 +44,10 @@ export function HeroSection() {
44
44
  How it works
45
45
  </Link>
46
46
  </div>
47
- <dl className="mt-12 grid max-w-md grid-cols-3 gap-4">
47
+ <dl className="mt-12 flex max-w-md flex-wrap gap-x-8 gap-y-4">
48
48
  {STATS.map((stat) => (
49
49
  <div key={stat.label}>
50
- <dt className="text-2xl font-semibold text-sand-900 dark:text-sand-50">{stat.value}</dt>
50
+ <dt className="whitespace-nowrap text-2xl font-semibold text-sand-900 dark:text-sand-50">{stat.value}</dt>
51
51
  <dd className="text-xs text-sand-500">{stat.label}</dd>
52
52
  </div>
53
53
  ))}
@@ -42,7 +42,7 @@ export function TierPlanBoard({
42
42
  const view = presentTierCatalog(plans, { lightningEnabled });
43
43
 
44
44
  return (
45
- <div role="radiogroup" aria-label="Speed tier" className="grid grid-cols-1 gap-8 lg:grid-cols-3">
45
+ <div role="group" aria-label="Speed tier" className="grid grid-cols-1 gap-8 lg:grid-cols-3">
46
46
  {view.tiers.map((group) => (
47
47
  <TierCard
48
48
  key={group.tier}
@@ -1,12 +1,19 @@
1
1
  const STORAGE_KEY = "carrier-theme";
2
2
 
3
- const themeScript = `
3
+ /**
4
+ * Runs before first paint. A saved "system" preference is resolved here, from
5
+ * the browser, so the page never paints light first and flips to dark when
6
+ * the provider mounts. The provider resolves it the same way.
7
+ */
8
+ export const themeScript = `
4
9
  (function () {
5
10
  try {
6
11
  var pref = localStorage.getItem("${STORAGE_KEY}");
7
12
  var theme = (pref === "light" || pref === "dark")
8
13
  ? pref
9
- : "light";
14
+ : pref === "system"
15
+ ? (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light")
16
+ : "light";
10
17
  var root = document.documentElement;
11
18
  root.setAttribute("data-theme", theme);
12
19
  root.style.colorScheme = theme;
@@ -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);
@@ -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";