@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.
- package/dist/{chunk-W5DYFDVS.js → chunk-HGPV63X3.js} +2 -2
- package/dist/{chunk-W5DYFDVS.js.map → chunk-HGPV63X3.js.map} +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/storefront/src/app/activate/[orderId]/ActivateClient.tsx +5 -1
- package/templates/storefront/src/app/api/orders/[orderId]/email/route.ts +2 -1
- package/templates/storefront/src/app/api/orders/[orderId]/route.ts +2 -1
- package/templates/storefront/src/app/checkout/[templateId]/CheckoutClient.tsx +69 -50
- package/templates/storefront/src/app/checkout/success/CheckoutSuccessClient.tsx +1 -1
- package/templates/storefront/src/app/checkout/success/page.tsx +1 -1
- package/templates/storefront/src/app/dashboard/EsimControls.tsx +6 -5
- package/templates/storefront/src/app/globals.css +17 -0
- package/templates/storefront/src/app/not-found.tsx +27 -0
- package/templates/storefront/src/app/shop/ShopClient.tsx +16 -3
- package/templates/storefront/src/app/sign-in/[[...sign-in]]/StorefrontSignInClient.tsx +10 -5
- package/templates/storefront/src/app/sign-up/[[...sign-up]]/StorefrontSignUpClient.tsx +16 -12
- package/templates/storefront/src/components/footer/StorefrontFooter.tsx +1 -1
- package/templates/storefront/src/components/landing/FinalCTA.tsx +1 -1
- package/templates/storefront/src/components/landing/HeroSection.tsx +2 -2
- package/templates/storefront/src/components/landing/TierPlanBoard.tsx +1 -1
- package/templates/storefront/src/lib/buyer-auth-copy.ts +15 -0
- package/templates/storefront/src/lib/catalog-countries.ts +36 -5
- package/templates/storefront/src/lib/checkout-client-error.ts +26 -0
- package/templates/storefront/src/lib/log-safe.ts +10 -0
- package/templates/storefront/src/lib/order-route-guard.ts +3 -2
- package/templates/storefront/src/lib/request-origin.ts +7 -4
- package/templates/storefront/src/lib/tap-target.ts +1 -1
- package/templates/storefront/src/vendor/geo/index.ts +14 -0
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carrierllc/mcp",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.71",
|
|
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-
|
|
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.",
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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't show a price for this plan right now, so it can'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
|
-
|
|
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
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
|
|
253
|
-
<div
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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-
|
|
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
|
-
|
|
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
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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"
|
|
@@ -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,3 +128,18 @@ 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
|
+
}
|
|
137
|
+
|
|
138
|
+
/* A heading that takes focus from script (tabIndex -1) is not a control.
|
|
139
|
+
Without this the ring above draws around the outcome title after payment.
|
|
140
|
+
The ring is made clear, not removed, so forced-colours mode still shows it.
|
|
141
|
+
Controls keep the full ring. */
|
|
142
|
+
h1[tabindex="-1"]:focus,
|
|
143
|
+
h1[tabindex="-1"]:focus-visible {
|
|
144
|
+
outline-color: transparent;
|
|
145
|
+
}
|
|
@@ -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'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
|
+
}
|
|
@@ -16,10 +16,10 @@ 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
|
-
import {
|
|
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";
|
|
@@ -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 && (
|
|
@@ -120,7 +133,7 @@ export function ShopClient({ plans, country = "" }: { plans: SkuTemplate[]; coun
|
|
|
120
133
|
</h2>
|
|
121
134
|
<p className={`mt-1 text-sm ${secondary}`}>
|
|
122
135
|
{selected
|
|
123
|
-
?
|
|
136
|
+
? formatPlanSummary(selected.dataGb, selected.validityDays, selected.unlimited)
|
|
124
137
|
: "Choose a speed tier and the total appears here."}
|
|
125
138
|
</p>
|
|
126
139
|
|
|
@@ -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
|
-
|
|
99
|
-
|
|
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,
|
|
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}
|
|
@@ -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>
|
|
@@ -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>
|
|
@@ -44,10 +44,10 @@ export function HeroSection() {
|
|
|
44
44
|
How it works
|
|
45
45
|
</Link>
|
|
46
46
|
</div>
|
|
47
|
-
<dl className="mt-12
|
|
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="
|
|
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}
|
|
@@ -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
|
-
*
|
|
149
|
-
*
|
|
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`
|
|
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
|
|
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[],
|