@carrierllc/mcp 0.13.70 → 0.13.72

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/cli.js CHANGED
@@ -45,7 +45,7 @@ import {
45
45
  verifyStorefront,
46
46
  walletScreen,
47
47
  which
48
- } from "./chunk-2SCQOXDB.js";
48
+ } from "./chunk-NGNLWI7W.js";
49
49
  import {
50
50
  copyTree,
51
51
  exists,
package/dist/index.js CHANGED
@@ -91,7 +91,7 @@ import {
91
91
  verifyStorefront,
92
92
  withOcsListSummary,
93
93
  withTemplateResellerId
94
- } from "./chunk-2SCQOXDB.js";
94
+ } from "./chunk-NGNLWI7W.js";
95
95
  import "./chunk-SHKKVIIA.js";
96
96
 
97
97
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrierllc/mcp",
3
- "version": "0.13.70",
3
+ "version": "0.13.72",
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)",
@@ -499,8 +499,12 @@ export function ActivateClient({ orderId }: Props) {
499
499
  </p>
500
500
  ) : (
501
501
  <form onSubmit={handlePhoneSubmit} className="space-y-3">
502
+ <label htmlFor="activate-phone" className="block text-base font-medium text-sand-700 dark:text-sand-200">
503
+ WhatsApp number
504
+ </label>
502
505
  <div className="flex gap-2">
503
506
  <input
507
+ id="activate-phone"
504
508
  type="tel"
505
509
  autoComplete="tel"
506
510
  value={phone}
@@ -520,7 +524,7 @@ export function ActivateClient({ orderId }: Props) {
520
524
  <button
521
525
  type="button"
522
526
  onClick={() => setSubmitted(true)}
523
- className="w-full text-center text-xs text-sand-400 hover:text-sand-500 py-1"
527
+ className="min-h-11 w-full text-center text-base text-sand-400 hover:text-sand-500 py-1"
524
528
  >
525
529
  Skip for now
526
530
  </button>
@@ -21,6 +21,7 @@
21
21
  */
22
22
  import { NextResponse } from "next/server";
23
23
  import { markQrEmailSent, orderPurchaserEmail, qrEmailSentAt } from "@/lib/checkout-order-claim";
24
+ import { maskCheckoutIds } from "@/lib/log-safe";
24
25
  import { guardOrderRoute, fulfilmentFailureResponse } from "@/lib/order-route-guard";
25
26
  import { deliverQrEmail } from "@/lib/qr-delivery-email";
26
27
  import { fetchOrder } from "@/vendor/carrier/client";
@@ -63,7 +64,7 @@ export async function POST(_req: Request, ctx: Context): Promise<NextResponse> {
63
64
  const result = await deliverQrEmail(lookup.order, to);
64
65
  if (!result.sent) {
65
66
  if (result.detail) {
66
- console.error(`[email] QR delivery for ${orderId} failed (${result.reason}): ${result.detail}`);
67
+ console.error(maskCheckoutIds(`[email] QR delivery for ${orderId} failed (${result.reason}): ${result.detail}`));
67
68
  }
68
69
  return NextResponse.json({ sent: false, reason: result.reason });
69
70
  }
@@ -12,6 +12,7 @@
12
12
  import { NextResponse } from "next/server";
13
13
  import { buyerUserId } from "@/lib/buyer-session";
14
14
  import { userOwnsOrder } from "@/lib/checkout-order-claim";
15
+ import { maskCheckoutIds } from "@/lib/log-safe";
15
16
  import { fetchOrder } from "@/vendor/carrier/client";
16
17
 
17
18
  export const dynamic = "force-dynamic";
@@ -58,7 +59,7 @@ export async function GET(_req: Request, ctx: Context): Promise<NextResponse> {
58
59
  );
59
60
  }
60
61
 
61
- console.error(`[orders] order lookup failed for ${orderId}: ${lookup.reason}`);
62
+ console.error(maskCheckoutIds(`[orders] order lookup failed for ${orderId}: ${lookup.reason}`));
62
63
  return NextResponse.json(
63
64
  {
64
65
  error: "We could not reach your eSIM details right now. Please try again in a moment.",
@@ -43,6 +43,8 @@
43
43
  --brand-accent-text: #C2410C;
44
44
  /* #C2410C is 4.95:1 on the light page. Dark focus is set below. */
45
45
  --brand-focus: #C2410C;
46
+ /* The ring drawn over the accent fill. #111111 on #FF6B35 is 6.66:1. */
47
+ --brand-focus-on-accent: #111111;
46
48
  }
47
49
 
48
50
  html[data-theme="dark"] {
@@ -126,6 +128,12 @@ html[data-theme="dark"] {
126
128
  outline: 2px solid var(--brand-focus);
127
129
  outline-offset: 2px;
128
130
  }
131
+ /* Inside a filled accent panel the ring sits on #FF6B35, where the page ring
132
+ (#C2410C light, #FFB088 dark) is only about 2:1. Near-black reads on it in
133
+ both themes. Mark the panel with data-accent-panel. */
134
+ [data-accent-panel] :focus-visible {
135
+ outline-color: var(--brand-focus-on-accent);
136
+ }
129
137
 
130
138
  /* A heading that takes focus from script (tabIndex -1) is not a control.
131
139
  Without this the ring above draws around the outcome title after payment.
@@ -16,7 +16,7 @@ import { TierPlanBoard } from "@/components/landing/TierPlanBoard";
16
16
  import brand from "@/brand.config";
17
17
  import { CountrySearch } from "@/components/shop/CountrySearch";
18
18
  import { conversionEvents } from "@/lib/conversion-events";
19
- import { countryCatalogMode, plansForCountry } from "@/lib/catalog-countries";
19
+ import { countryCatalogMode, countryCoverageNote, plansForCountry } from "@/lib/catalog-countries";
20
20
  import { filledAccentClass, textLinkClass } from "@/lib/tap-target";
21
21
  import { presentTierCatalog, speedTierOf } from "@/vendor/carrier/tiers";
22
22
  import { formatPlanSummary, formatPrice } from "@/vendor/geo";
@@ -54,6 +54,11 @@ export function ShopClient({ plans, country = "" }: { plans: SkuTemplate[]; coun
54
54
  }
55
55
 
56
56
  const view = presentTierCatalog(visible, { lightningEnabled });
57
+ // Search is hidden for a catalog that lists regions, so the country in the
58
+ // link is not filtered on. Say what the plans on this page do and do not
59
+ // tell us: a plan the page hides (fixture, Lightning not enabled) is not named.
60
+ const shown = [...view.tiers.flatMap((group) => group.plans), ...view.untiered];
61
+ const note = coverage.search ? null : countryCoverageNote(shown, country);
57
62
  const total = !selected
58
63
  ? null
59
64
  : selected.price_unavailable
@@ -75,6 +80,14 @@ export function ShopClient({ plans, country = "" }: { plans: SkuTemplate[]; coun
75
80
  </div>
76
81
  )}
77
82
 
83
+ {note && (
84
+ <p role="status" className={`mb-8 text-base ${secondary}`}>
85
+ {note.planNames.length > 0
86
+ ? `${note.name} is covered by ${note.planNames.join(", ")}.`
87
+ : `These plans list their coverage by region, so we can't confirm ${note.name} here. Check the coverage on each plan.`}
88
+ </p>
89
+ )}
90
+
78
91
  <div className="grid grid-cols-1 items-start gap-8 lg:grid-cols-[minmax(0,1fr)_320px]">
79
92
  <div className="grid grid-cols-1 gap-8">
80
93
  {coverage.search && visible.length === 0 && (
@@ -5,7 +5,7 @@ import { FormEvent, useEffect, useRef, useState } from "react";
5
5
  import { useClerk, useSignIn } from "@clerk/nextjs";
6
6
  import { useRouter, useSearchParams } from "next/navigation";
7
7
  import brand from "@/brand.config";
8
- import { BUYER_AUTH_COPY, buyerCopyForClerkError, resetEmailOutcome, SIGN_IN_CLERK_CODES, signInStatusCopy } from "@/lib/buyer-auth-copy";
8
+ import { BUYER_AUTH_COPY, buyerCopyForClerkError, resetEmailOutcome, RESET_PASSWORD_CLERK_CODES, SIGN_IN_CLERK_CODES, signInStatusCopy } from "@/lib/buyer-auth-copy";
9
9
  import { sanitizeAuthRedirect } from "@/lib/sanitize-auth-redirect";
10
10
  import { fieldClass, primaryButtonClass, textLinkClass } from "@/lib/tap-target";
11
11
 
@@ -95,21 +95,26 @@ export function StorefrontSignInClient({ origin }: { origin: string }) {
95
95
  setError(null);
96
96
  setLoading(true);
97
97
  try {
98
- const attempt = await signIn.attemptFirstFactor({ strategy: "reset_password_email_code", code });
99
- if (attempt.status === "needs_new_password") {
98
+ // The emailed code works once. After it was accepted and the new password
99
+ // was refused (a password rule), a retry must not send the code again.
100
+ const codeAccepted = signIn.status === "needs_new_password";
101
+ const attempt = codeAccepted
102
+ ? null
103
+ : await signIn.attemptFirstFactor({ strategy: "reset_password_email_code", code });
104
+ if (codeAccepted || attempt?.status === "needs_new_password") {
100
105
  const reset = await signIn.resetPassword({ password: nextPassword });
101
106
  if (signInStatusCopy(reset.status) === "complete") {
102
107
  await finish(reset.createdSessionId);
103
108
  return;
104
109
  }
105
110
  }
106
- if (signInStatusCopy(attempt.status) === "complete") {
111
+ if (attempt && signInStatusCopy(attempt.status) === "complete") {
107
112
  await finish(attempt.createdSessionId);
108
113
  return;
109
114
  }
110
115
  setError(BUYER_AUTH_COPY.resetRejected);
111
116
  } catch (err) {
112
- setError(buyerCopyForClerkError(err, BUYER_AUTH_COPY.resetRejected, ["form_code_incorrect", "too_many_requests"]));
117
+ setError(buyerCopyForClerkError(err, BUYER_AUTH_COPY.resetRejected, RESET_PASSWORD_CLERK_CODES));
113
118
  } finally {
114
119
  setLoading(false);
115
120
  }
@@ -81,9 +81,24 @@ export function StorefrontSignUpClient({ origin }: { origin: string }) {
81
81
 
82
82
  return (
83
83
  <div className="w-full max-w-sm rounded-2xl border border-sand-200 dark:border-sand-800 bg-white dark:bg-sand-900 p-8 backdrop-blur">
84
+ {step !== "complete" && (
85
+ <h1 className="text-xl font-bold text-sand-900 dark:text-sand-50 mb-1">
86
+ {step === "credentials" ? "Create account" : "Check your email"}
87
+ </h1>
88
+ )}
89
+ {/* Always in the page, so a screen reader announces an error the moment
90
+ it appears. A region that is added together with its text is often
91
+ missed. Empty, it is visually hidden. */}
92
+ <p
93
+ id={SIGN_UP_ERROR_ID}
94
+ role="alert"
95
+ aria-live="assertive"
96
+ className={error ? "mb-4 rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-base text-red-700 dark:text-red-300" : "sr-only"}
97
+ >
98
+ {error}
99
+ </p>
84
100
  {step === "credentials" && (
85
101
  <>
86
- <h1 className="text-xl font-bold text-sand-900 dark:text-sand-50 mb-1">Create account</h1>
87
102
  <p className="mb-6 text-base text-sand-500">Email and password — no phone required.</p>
88
103
  <form onSubmit={handleCredentials} className="space-y-4">
89
104
  <div>
@@ -121,11 +136,6 @@ export function StorefrontSignUpClient({ origin }: { origin: string }) {
121
136
  aria-describedby={describedBy}
122
137
  />
123
138
  </div>
124
- {error && (
125
- <p id={SIGN_UP_ERROR_ID} role="alert" className="rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-base text-red-700 dark:text-red-300">
126
- {error}
127
- </p>
128
- )}
129
139
  <button
130
140
  type="submit"
131
141
  disabled={loading || !isLoaded}
@@ -145,7 +155,6 @@ export function StorefrontSignUpClient({ origin }: { origin: string }) {
145
155
 
146
156
  {step === "verify" && (
147
157
  <>
148
- <h1 className="text-xl font-bold text-sand-900 dark:text-sand-50 mb-1">Check your email</h1>
149
158
  <p className="mb-6 text-base text-sand-500">
150
159
  We sent a 6-digit code to <span className="text-sand-600 dark:text-sand-300">{email}</span>.
151
160
  </p>
@@ -169,11 +178,6 @@ export function StorefrontSignUpClient({ origin }: { origin: string }) {
169
178
  aria-describedby={describedBy}
170
179
  />
171
180
  </div>
172
- {error && (
173
- <p id={SIGN_UP_ERROR_ID} role="alert" className="rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-base text-red-700 dark:text-red-300">
174
- {error}
175
- </p>
176
- )}
177
181
  <button
178
182
  type="submit"
179
183
  disabled={loading || code.length < 6}
@@ -4,7 +4,7 @@ import brand from "@/brand.config";
4
4
  export function FinalCTA() {
5
5
  return (
6
6
  <section className="px-4 py-20">
7
- <div className="mx-auto max-w-6xl overflow-hidden rounded-[2rem] bg-[var(--brand-accent)] px-8 py-14 text-center text-[var(--brand-on-accent)] md:px-16">
7
+ <div data-accent-panel className="mx-auto max-w-6xl overflow-hidden rounded-[2rem] bg-[var(--brand-accent)] px-8 py-14 text-center text-[var(--brand-on-accent)] md:px-16">
8
8
  <h2 className="text-3xl font-semibold tracking-tight text-[var(--brand-on-accent)] md:text-4xl">
9
9
  Travel light. Land connected.
10
10
  </h2>
@@ -53,6 +53,21 @@ export const CLERK_ERROR_COPY: Record<string, string> = {
53
53
  identifier_already_signed_in: BUYER_AUTH_COPY.sessionExists,
54
54
  };
55
55
 
56
+ /**
57
+ * Codes the reset step may show. The code check and the new-password check
58
+ * run in one try block, so this holds both. A password-rule code only comes
59
+ * from the new-password call, which needs a code that already worked, so it
60
+ * does not tell a stranger whether an account exists.
61
+ */
62
+ export const RESET_PASSWORD_CLERK_CODES = [
63
+ "form_code_incorrect",
64
+ "too_many_requests",
65
+ "form_password_pwned",
66
+ "form_password_length_too_short",
67
+ "form_password_not_strong_enough",
68
+ "form_password_validation_failed",
69
+ ] as const;
70
+
56
71
  /** Codes that do not tell a stranger whether the account exists. */
57
72
  export const SIGN_IN_CLERK_CODES = [
58
73
  "form_identifier_not_found",
@@ -145,21 +145,52 @@ export function withCountryCodes<T extends { regions?: readonly string[] | null
145
145
  /**
146
146
  * Country search is honest only when every plan is already a list of countries.
147
147
  *
148
- * A region word such as Europe is not a country. In plan mode this template
149
- * does not invent the eSIMMY list for that word, so search would tell a buyer
148
+ * Every region a plan lists, once resolved, must be exactly two capital
149
+ * letters. A word such as Europe or Asia is not a country. In plan mode this
150
+ * template does not invent a country list for it, so search would tell a buyer
150
151
  * that Germany is uncovered. Hide search and show the plans instead.
151
- * `esimmy` has already expanded those words, so search can stay.
152
+ * `esimmy` expands Europe, Schengen and Global first, so search can stay.
152
153
  */
153
154
  export function catalogCanSearchCountries(
154
155
  plans: readonly { regions?: readonly string[] | null }[],
155
156
  mode: CountryCatalogMode,
156
157
  ): boolean {
157
- if (mode === "esimmy") return true;
158
158
  return plans.every((plan) =>
159
- (plan.regions ?? []).every((region) => REGION_LABELS[fold(region.trim())] === undefined),
159
+ resolvePlanRegions(Array.isArray(plan.regions) ? plan.regions : [], mode).every((region) =>
160
+ /^[A-Z]{2}$/.test(region),
161
+ ),
160
162
  );
161
163
  }
162
164
 
165
+ /**
166
+ * What to tell a buyer whose country is in the link while search is hidden.
167
+ *
168
+ * Only a plan that lists the country itself is named as covering it. A plan
169
+ * that lists a region word is not claimed to cover it: this template has no
170
+ * list of countries for that word. Returns null when `country` is not a
171
+ * two-letter code.
172
+ */
173
+ export function countryCoverageNote<T extends { name: string; regions?: readonly string[] | null }>(
174
+ plans: readonly T[],
175
+ country: string,
176
+ ): { code: string; name: string; planNames: string[] } | null {
177
+ if (!/^[A-Za-z]{2}$/.test(country)) return null;
178
+ const code = country.toUpperCase();
179
+ let name = code;
180
+ try {
181
+ const label = regionNames.of(code);
182
+ if (label && label.toUpperCase() !== code) name = label;
183
+ } catch {
184
+ // A runtime without that region still names the code.
185
+ }
186
+ const planNames = plans
187
+ .filter((plan) =>
188
+ resolvePlanRegions(Array.isArray(plan.regions) ? plan.regions : [], "plan").includes(code),
189
+ )
190
+ .map((plan) => plan.name);
191
+ return { code, name, planNames };
192
+ }
193
+
163
194
  /** Plans to show for a country query. Region plans are not filtered down to none. */
164
195
  export function plansForCountry<T extends { regions?: readonly string[] | null }>(
165
196
  plans: readonly T[],
@@ -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 {