@cimplify/cli 0.7.2 → 0.7.3

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 (75) hide show
  1. package/dist/{add-5NW7N5CJ.mjs → add-ZD5FOTC7.mjs} +1 -1
  2. package/dist/{chunk-CVQRL2VH.mjs → chunk-HDIDSQS4.mjs} +22 -22
  3. package/dist/{chunk-26ETGFW6.mjs → chunk-YYG5WE4A.mjs} +1 -1
  4. package/dist/{chunk-ZVEQGQ2Z.mjs → chunk-ZKMI5E23.mjs} +2 -2
  5. package/dist/dispatcher.mjs +9 -9
  6. package/dist/{doctor-XLBDC6NO.mjs → doctor-DN6RLS6E.mjs} +2 -2
  7. package/dist/{explain-PKTL7ZR6.mjs → explain-J4JB5QGW.mjs} +1 -1
  8. package/dist/{introspect-FPBV3O4N.mjs → introspect-45RASBRH.mjs} +2 -2
  9. package/dist/{list-N7FKBQ3Y.mjs → list-O47PO4UQ.mjs} +1 -1
  10. package/dist/{update-ZC3JGKLI.mjs → update-CSUNW4RV.mjs} +1 -1
  11. package/package.json +2 -2
  12. package/templates/storefront-auto/app/auth/callback/route.ts +16 -0
  13. package/templates/storefront-auto/app/auth/session/route.ts +11 -0
  14. package/templates/storefront-auto/app/auth/signout/route.ts +11 -0
  15. package/templates/storefront-auto/components/account-iframe.tsx +7 -1
  16. package/templates/storefront-auto/components/account-pill.tsx +56 -0
  17. package/templates/storefront-auto/components/header.tsx +2 -0
  18. package/templates/storefront-auto/lib/auth.ts +16 -0
  19. package/templates/storefront-auto/package.json +1 -1
  20. package/templates/storefront-bakery/app/auth/callback/route.ts +16 -0
  21. package/templates/storefront-bakery/app/auth/session/route.ts +11 -0
  22. package/templates/storefront-bakery/app/auth/signout/route.ts +11 -0
  23. package/templates/storefront-bakery/components/account-iframe.tsx +7 -1
  24. package/templates/storefront-bakery/components/account-pill.tsx +56 -0
  25. package/templates/storefront-bakery/components/header.tsx +2 -0
  26. package/templates/storefront-bakery/lib/auth.ts +16 -0
  27. package/templates/storefront-bakery/package.json +1 -1
  28. package/templates/storefront-fashion/app/auth/callback/route.ts +16 -0
  29. package/templates/storefront-fashion/app/auth/session/route.ts +11 -0
  30. package/templates/storefront-fashion/app/auth/signout/route.ts +11 -0
  31. package/templates/storefront-fashion/components/account-iframe.tsx +7 -1
  32. package/templates/storefront-fashion/components/account-pill.tsx +56 -0
  33. package/templates/storefront-fashion/components/header.tsx +2 -0
  34. package/templates/storefront-fashion/lib/auth.ts +16 -0
  35. package/templates/storefront-fashion/package.json +1 -1
  36. package/templates/storefront-grocery/app/auth/callback/route.ts +16 -0
  37. package/templates/storefront-grocery/app/auth/session/route.ts +11 -0
  38. package/templates/storefront-grocery/app/auth/signout/route.ts +11 -0
  39. package/templates/storefront-grocery/components/account-iframe.tsx +7 -1
  40. package/templates/storefront-grocery/components/account-pill.tsx +56 -0
  41. package/templates/storefront-grocery/components/header.tsx +2 -0
  42. package/templates/storefront-grocery/lib/auth.ts +16 -0
  43. package/templates/storefront-grocery/package.json +1 -1
  44. package/templates/storefront-pharmacy/app/auth/callback/route.ts +16 -0
  45. package/templates/storefront-pharmacy/app/auth/session/route.ts +11 -0
  46. package/templates/storefront-pharmacy/app/auth/signout/route.ts +11 -0
  47. package/templates/storefront-pharmacy/components/account-iframe.tsx +7 -1
  48. package/templates/storefront-pharmacy/components/account-pill.tsx +56 -0
  49. package/templates/storefront-pharmacy/components/header.tsx +2 -0
  50. package/templates/storefront-pharmacy/lib/auth.ts +16 -0
  51. package/templates/storefront-pharmacy/package.json +1 -1
  52. package/templates/storefront-restaurant/app/auth/callback/route.ts +16 -0
  53. package/templates/storefront-restaurant/app/auth/session/route.ts +11 -0
  54. package/templates/storefront-restaurant/app/auth/signout/route.ts +11 -0
  55. package/templates/storefront-restaurant/components/account-iframe.tsx +7 -1
  56. package/templates/storefront-restaurant/components/account-pill.tsx +56 -0
  57. package/templates/storefront-restaurant/components/header.tsx +2 -0
  58. package/templates/storefront-restaurant/lib/auth.ts +16 -0
  59. package/templates/storefront-restaurant/package.json +1 -1
  60. package/templates/storefront-retail/app/auth/callback/route.ts +16 -0
  61. package/templates/storefront-retail/app/auth/session/route.ts +11 -0
  62. package/templates/storefront-retail/app/auth/signout/route.ts +11 -0
  63. package/templates/storefront-retail/components/account-iframe.tsx +7 -1
  64. package/templates/storefront-retail/components/account-pill.tsx +56 -0
  65. package/templates/storefront-retail/components/header.tsx +2 -0
  66. package/templates/storefront-retail/lib/auth.ts +16 -0
  67. package/templates/storefront-retail/package.json +1 -1
  68. package/templates/storefront-services/app/auth/callback/route.ts +16 -0
  69. package/templates/storefront-services/app/auth/session/route.ts +11 -0
  70. package/templates/storefront-services/app/auth/signout/route.ts +11 -0
  71. package/templates/storefront-services/components/account-iframe.tsx +7 -1
  72. package/templates/storefront-services/components/account-pill.tsx +56 -0
  73. package/templates/storefront-services/components/header.tsx +2 -0
  74. package/templates/storefront-services/lib/auth.ts +16 -0
  75. package/templates/storefront-services/package.json +1 -1
@@ -0,0 +1,11 @@
1
+ import { handleSessionRequest } from "@cimplify/sdk/server";
2
+
3
+ const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
4
+ const AUTH_URL = process.env.CIMPLIFY_AUTH_URL;
5
+
6
+ export async function GET(req: Request): Promise<Response> {
7
+ if (!CLIENT_ID) {
8
+ return Response.json({ sub: null }, { status: 200 });
9
+ }
10
+ return handleSessionRequest(req, { clientId: CLIENT_ID, authUrl: AUTH_URL });
11
+ }
@@ -0,0 +1,11 @@
1
+ import { buildSignoutCookie } from "@cimplify/sdk/server";
2
+
3
+ const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
4
+
5
+ export async function POST(): Promise<Response> {
6
+ const cookie = buildSignoutCookie({ clientId: CLIENT_ID });
7
+ return new Response(JSON.stringify({ ok: true }), {
8
+ status: 200,
9
+ headers: { "Content-Type": "application/json", "Set-Cookie": cookie },
10
+ });
11
+ }
@@ -1,13 +1,19 @@
1
1
  "use client";
2
2
 
3
3
  import { CimplifyAccount } from "@cimplify/sdk/react";
4
+ import { brand } from "@/lib/brand";
4
5
 
5
6
  /**
6
7
  * Cimplify Account portal — iframe-mounted UI hosted by Cimplify Link.
7
8
  * Handles sign-in, sign-up, OTP, addresses, payment methods, sessions,
8
9
  * and order history. The iframe owns auth state; we just choose which
9
10
  * `section` to land on.
11
+ *
12
+ * `merchantName` is passed so the embedded widget can render scoping
13
+ * affordances ("Showing your account with {merchant} only.") and
14
+ * enforce the per-merchant data contract — orders/subs filter to this
15
+ * business, cross-merchant surfaces are hidden.
10
16
  */
11
17
  export function AccountIframe({ section }: { section?: string }) {
12
- return <CimplifyAccount section={section} />;
18
+ return <CimplifyAccount section={section} merchantName={brand.name} />;
13
19
  }
@@ -0,0 +1,56 @@
1
+ "use client";
2
+
3
+ import { useEffect, useRef } from "react";
4
+ import Link from "next/link";
5
+ import { CimplifySignInButton, useCimplifySession } from "@cimplify/sdk/react";
6
+ import { signInSilent } from "@cimplify/sdk";
7
+
8
+ const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
9
+
10
+ /**
11
+ * Header sign-in / signed-in pill.
12
+ *
13
+ * - Tries cross-storefront SSO once on mount. If the shopper signed
14
+ * into any other Cimplify storefront recently, this resolves
15
+ * silently and the session lands without any UI flicker.
16
+ * - When signed in, renders "Hi, {name}" linking to /account.
17
+ * - When not signed in, renders the Cimplify Sign-In button.
18
+ */
19
+ export function AccountPill() {
20
+ const { session, loading, refresh } = useCimplifySession();
21
+ const triedSilent = useRef(false);
22
+
23
+ useEffect(() => {
24
+ if (triedSilent.current || session || !CLIENT_ID) return;
25
+ triedSilent.current = true;
26
+ void signInSilent({
27
+ clientId: CLIENT_ID,
28
+ redirectUri: `${window.location.origin}/auth/callback`,
29
+ }).then((r) => {
30
+ if (r.ok) refresh();
31
+ });
32
+ }, [session, refresh]);
33
+
34
+ if (loading || !CLIENT_ID) return <span className="h-9 w-24" aria-hidden />;
35
+
36
+ if (session) {
37
+ const first = session.name?.split(/\s+/)[0] ?? "Account";
38
+ return (
39
+ <Link
40
+ href="/account"
41
+ className="text-[13px] font-medium tracking-wide text-foreground hover:text-primary transition-colors"
42
+ >
43
+ Hi, {first}
44
+ </Link>
45
+ );
46
+ }
47
+
48
+ return (
49
+ <CimplifySignInButton
50
+ clientId={CLIENT_ID}
51
+ redirectUri={`${typeof window !== "undefined" ? window.location.origin : ""}/auth/callback`}
52
+ variant="text"
53
+ onSuccess={() => refresh()}
54
+ />
55
+ );
56
+ }
@@ -3,6 +3,7 @@ import { Suspense } from "react";
3
3
  import { NavLink } from "./nav-link";
4
4
  import { CartPill, CartPillSkeleton } from "./cart-pill";
5
5
  import { MobileNav } from "./mobile-nav";
6
+ import { AccountPill } from "./account-pill";
6
7
  import { brand } from "@/lib/brand";
7
8
 
8
9
  /**
@@ -29,6 +30,7 @@ export function Header() {
29
30
  </Suspense>
30
31
  ))}
31
32
  </nav>
33
+ <AccountPill />
32
34
  <Suspense fallback={<CartPillSkeleton />}>
33
35
  <CartPill />
34
36
  </Suspense>
@@ -0,0 +1,16 @@
1
+ import { headers } from "next/headers";
2
+ import { getSessionFromCookieHeader, type CimplifySession } from "@cimplify/sdk/server";
3
+
4
+ const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
5
+ const AUTH_URL = process.env.CIMPLIFY_AUTH_URL;
6
+
7
+ export async function getSession(): Promise<CimplifySession | null> {
8
+ if (!CLIENT_ID) return null;
9
+ const cookieHeader = (await headers()).get("cookie");
10
+ return getSessionFromCookieHeader(
11
+ { clientId: CLIENT_ID, authUrl: AUTH_URL },
12
+ cookieHeader,
13
+ );
14
+ }
15
+
16
+ export type { CimplifySession } from "@cimplify/sdk/server";
@@ -17,7 +17,7 @@
17
17
  "check": "bun run typecheck && bun run test:run"
18
18
  },
19
19
  "dependencies": {
20
- "@cimplify/sdk": "^0.54.0",
20
+ "@cimplify/sdk": "^0.55.0",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"
@@ -0,0 +1,16 @@
1
+ import { handleOidcCallback } from "@cimplify/sdk/server";
2
+
3
+ const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
4
+ const AUTH_URL = process.env.CIMPLIFY_AUTH_URL;
5
+ const REDIRECT_URI = process.env.CIMPLIFY_REDIRECT_URI ?? "";
6
+
7
+ export async function POST(req: Request): Promise<Response> {
8
+ if (!CLIENT_ID || !REDIRECT_URI) {
9
+ return Response.json({ error: "oidc_not_configured" }, { status: 500 });
10
+ }
11
+ return handleOidcCallback(req, {
12
+ clientId: CLIENT_ID,
13
+ authUrl: AUTH_URL,
14
+ redirectUri: REDIRECT_URI,
15
+ });
16
+ }
@@ -0,0 +1,11 @@
1
+ import { handleSessionRequest } from "@cimplify/sdk/server";
2
+
3
+ const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
4
+ const AUTH_URL = process.env.CIMPLIFY_AUTH_URL;
5
+
6
+ export async function GET(req: Request): Promise<Response> {
7
+ if (!CLIENT_ID) {
8
+ return Response.json({ sub: null }, { status: 200 });
9
+ }
10
+ return handleSessionRequest(req, { clientId: CLIENT_ID, authUrl: AUTH_URL });
11
+ }
@@ -0,0 +1,11 @@
1
+ import { buildSignoutCookie } from "@cimplify/sdk/server";
2
+
3
+ const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
4
+
5
+ export async function POST(): Promise<Response> {
6
+ const cookie = buildSignoutCookie({ clientId: CLIENT_ID });
7
+ return new Response(JSON.stringify({ ok: true }), {
8
+ status: 200,
9
+ headers: { "Content-Type": "application/json", "Set-Cookie": cookie },
10
+ });
11
+ }
@@ -1,13 +1,19 @@
1
1
  "use client";
2
2
 
3
3
  import { CimplifyAccount } from "@cimplify/sdk/react";
4
+ import { brand } from "@/lib/brand";
4
5
 
5
6
  /**
6
7
  * Cimplify Account portal — iframe-mounted UI hosted by Cimplify Link.
7
8
  * Handles sign-in, sign-up, OTP, addresses, payment methods, sessions,
8
9
  * and order history. The iframe owns auth state; we just choose which
9
10
  * `section` to land on.
11
+ *
12
+ * `merchantName` is passed so the embedded widget can render scoping
13
+ * affordances ("Showing your account with {merchant} only.") and
14
+ * enforce the per-merchant data contract — orders/subs filter to this
15
+ * business, cross-merchant surfaces are hidden.
10
16
  */
11
17
  export function AccountIframe({ section }: { section?: string }) {
12
- return <CimplifyAccount section={section} />;
18
+ return <CimplifyAccount section={section} merchantName={brand.name} />;
13
19
  }
@@ -0,0 +1,56 @@
1
+ "use client";
2
+
3
+ import { useEffect, useRef } from "react";
4
+ import Link from "next/link";
5
+ import { CimplifySignInButton, useCimplifySession } from "@cimplify/sdk/react";
6
+ import { signInSilent } from "@cimplify/sdk";
7
+
8
+ const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
9
+
10
+ /**
11
+ * Header sign-in / signed-in pill.
12
+ *
13
+ * - Tries cross-storefront SSO once on mount. If the shopper signed
14
+ * into any other Cimplify storefront recently, this resolves
15
+ * silently and the session lands without any UI flicker.
16
+ * - When signed in, renders "Hi, {name}" linking to /account.
17
+ * - When not signed in, renders the Cimplify Sign-In button.
18
+ */
19
+ export function AccountPill() {
20
+ const { session, loading, refresh } = useCimplifySession();
21
+ const triedSilent = useRef(false);
22
+
23
+ useEffect(() => {
24
+ if (triedSilent.current || session || !CLIENT_ID) return;
25
+ triedSilent.current = true;
26
+ void signInSilent({
27
+ clientId: CLIENT_ID,
28
+ redirectUri: `${window.location.origin}/auth/callback`,
29
+ }).then((r) => {
30
+ if (r.ok) refresh();
31
+ });
32
+ }, [session, refresh]);
33
+
34
+ if (loading || !CLIENT_ID) return <span className="h-9 w-24" aria-hidden />;
35
+
36
+ if (session) {
37
+ const first = session.name?.split(/\s+/)[0] ?? "Account";
38
+ return (
39
+ <Link
40
+ href="/account"
41
+ className="text-[13px] font-medium tracking-wide text-foreground hover:text-primary transition-colors"
42
+ >
43
+ Hi, {first}
44
+ </Link>
45
+ );
46
+ }
47
+
48
+ return (
49
+ <CimplifySignInButton
50
+ clientId={CLIENT_ID}
51
+ redirectUri={`${typeof window !== "undefined" ? window.location.origin : ""}/auth/callback`}
52
+ variant="text"
53
+ onSuccess={() => refresh()}
54
+ />
55
+ );
56
+ }
@@ -3,6 +3,7 @@ import { Suspense } from "react";
3
3
  import { NavLink } from "./nav-link";
4
4
  import { CartPill, CartPillSkeleton } from "./cart-pill";
5
5
  import { MobileNav } from "./mobile-nav";
6
+ import { AccountPill } from "./account-pill";
6
7
  import { brand } from "@/lib/brand";
7
8
 
8
9
  /**
@@ -31,6 +32,7 @@ export function Header() {
31
32
  </Suspense>
32
33
  ))}
33
34
  </nav>
35
+ <AccountPill />
34
36
  <Suspense fallback={<CartPillSkeleton />}>
35
37
  <CartPill />
36
38
  </Suspense>
@@ -0,0 +1,16 @@
1
+ import { headers } from "next/headers";
2
+ import { getSessionFromCookieHeader, type CimplifySession } from "@cimplify/sdk/server";
3
+
4
+ const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
5
+ const AUTH_URL = process.env.CIMPLIFY_AUTH_URL;
6
+
7
+ export async function getSession(): Promise<CimplifySession | null> {
8
+ if (!CLIENT_ID) return null;
9
+ const cookieHeader = (await headers()).get("cookie");
10
+ return getSessionFromCookieHeader(
11
+ { clientId: CLIENT_ID, authUrl: AUTH_URL },
12
+ cookieHeader,
13
+ );
14
+ }
15
+
16
+ export type { CimplifySession } from "@cimplify/sdk/server";
@@ -17,7 +17,7 @@
17
17
  "check": "bun run typecheck && bun run test:run"
18
18
  },
19
19
  "dependencies": {
20
- "@cimplify/sdk": "^0.54.0",
20
+ "@cimplify/sdk": "^0.55.0",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"
@@ -0,0 +1,16 @@
1
+ import { handleOidcCallback } from "@cimplify/sdk/server";
2
+
3
+ const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
4
+ const AUTH_URL = process.env.CIMPLIFY_AUTH_URL;
5
+ const REDIRECT_URI = process.env.CIMPLIFY_REDIRECT_URI ?? "";
6
+
7
+ export async function POST(req: Request): Promise<Response> {
8
+ if (!CLIENT_ID || !REDIRECT_URI) {
9
+ return Response.json({ error: "oidc_not_configured" }, { status: 500 });
10
+ }
11
+ return handleOidcCallback(req, {
12
+ clientId: CLIENT_ID,
13
+ authUrl: AUTH_URL,
14
+ redirectUri: REDIRECT_URI,
15
+ });
16
+ }
@@ -0,0 +1,11 @@
1
+ import { handleSessionRequest } from "@cimplify/sdk/server";
2
+
3
+ const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
4
+ const AUTH_URL = process.env.CIMPLIFY_AUTH_URL;
5
+
6
+ export async function GET(req: Request): Promise<Response> {
7
+ if (!CLIENT_ID) {
8
+ return Response.json({ sub: null }, { status: 200 });
9
+ }
10
+ return handleSessionRequest(req, { clientId: CLIENT_ID, authUrl: AUTH_URL });
11
+ }
@@ -0,0 +1,11 @@
1
+ import { buildSignoutCookie } from "@cimplify/sdk/server";
2
+
3
+ const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
4
+
5
+ export async function POST(): Promise<Response> {
6
+ const cookie = buildSignoutCookie({ clientId: CLIENT_ID });
7
+ return new Response(JSON.stringify({ ok: true }), {
8
+ status: 200,
9
+ headers: { "Content-Type": "application/json", "Set-Cookie": cookie },
10
+ });
11
+ }
@@ -1,13 +1,19 @@
1
1
  "use client";
2
2
 
3
3
  import { CimplifyAccount } from "@cimplify/sdk/react";
4
+ import { brand } from "@/lib/brand";
4
5
 
5
6
  /**
6
7
  * Cimplify Account portal — iframe-mounted UI hosted by Cimplify Link.
7
8
  * Handles sign-in, sign-up, OTP, addresses, payment methods, sessions,
8
9
  * and order history. The iframe owns auth state; we just choose which
9
10
  * `section` to land on.
11
+ *
12
+ * `merchantName` is passed so the embedded widget can render scoping
13
+ * affordances ("Showing your account with {merchant} only.") and
14
+ * enforce the per-merchant data contract — orders/subs filter to this
15
+ * business, cross-merchant surfaces are hidden.
10
16
  */
11
17
  export function AccountIframe({ section }: { section?: string }) {
12
- return <CimplifyAccount section={section} />;
18
+ return <CimplifyAccount section={section} merchantName={brand.name} />;
13
19
  }
@@ -0,0 +1,56 @@
1
+ "use client";
2
+
3
+ import { useEffect, useRef } from "react";
4
+ import Link from "next/link";
5
+ import { CimplifySignInButton, useCimplifySession } from "@cimplify/sdk/react";
6
+ import { signInSilent } from "@cimplify/sdk";
7
+
8
+ const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
9
+
10
+ /**
11
+ * Header sign-in / signed-in pill.
12
+ *
13
+ * - Tries cross-storefront SSO once on mount. If the shopper signed
14
+ * into any other Cimplify storefront recently, this resolves
15
+ * silently and the session lands without any UI flicker.
16
+ * - When signed in, renders "Hi, {name}" linking to /account.
17
+ * - When not signed in, renders the Cimplify Sign-In button.
18
+ */
19
+ export function AccountPill() {
20
+ const { session, loading, refresh } = useCimplifySession();
21
+ const triedSilent = useRef(false);
22
+
23
+ useEffect(() => {
24
+ if (triedSilent.current || session || !CLIENT_ID) return;
25
+ triedSilent.current = true;
26
+ void signInSilent({
27
+ clientId: CLIENT_ID,
28
+ redirectUri: `${window.location.origin}/auth/callback`,
29
+ }).then((r) => {
30
+ if (r.ok) refresh();
31
+ });
32
+ }, [session, refresh]);
33
+
34
+ if (loading || !CLIENT_ID) return <span className="h-9 w-24" aria-hidden />;
35
+
36
+ if (session) {
37
+ const first = session.name?.split(/\s+/)[0] ?? "Account";
38
+ return (
39
+ <Link
40
+ href="/account"
41
+ className="text-[13px] font-medium tracking-wide text-foreground hover:text-primary transition-colors"
42
+ >
43
+ Hi, {first}
44
+ </Link>
45
+ );
46
+ }
47
+
48
+ return (
49
+ <CimplifySignInButton
50
+ clientId={CLIENT_ID}
51
+ redirectUri={`${typeof window !== "undefined" ? window.location.origin : ""}/auth/callback`}
52
+ variant="text"
53
+ onSuccess={() => refresh()}
54
+ />
55
+ );
56
+ }
@@ -3,6 +3,7 @@ import { Suspense } from "react";
3
3
  import { NavLink } from "./nav-link";
4
4
  import { CartPill, CartPillSkeleton } from "./cart-pill";
5
5
  import { MobileNav } from "./mobile-nav";
6
+ import { AccountPill } from "./account-pill";
6
7
  import { brand } from "@/lib/brand";
7
8
 
8
9
  /**
@@ -29,6 +30,7 @@ export function Header() {
29
30
  </Suspense>
30
31
  ))}
31
32
  </nav>
33
+ <AccountPill />
32
34
  <Suspense fallback={<CartPillSkeleton />}>
33
35
  <CartPill />
34
36
  </Suspense>
@@ -0,0 +1,16 @@
1
+ import { headers } from "next/headers";
2
+ import { getSessionFromCookieHeader, type CimplifySession } from "@cimplify/sdk/server";
3
+
4
+ const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
5
+ const AUTH_URL = process.env.CIMPLIFY_AUTH_URL;
6
+
7
+ export async function getSession(): Promise<CimplifySession | null> {
8
+ if (!CLIENT_ID) return null;
9
+ const cookieHeader = (await headers()).get("cookie");
10
+ return getSessionFromCookieHeader(
11
+ { clientId: CLIENT_ID, authUrl: AUTH_URL },
12
+ cookieHeader,
13
+ );
14
+ }
15
+
16
+ export type { CimplifySession } from "@cimplify/sdk/server";
@@ -17,7 +17,7 @@
17
17
  "check": "bun run typecheck && bun run test:run"
18
18
  },
19
19
  "dependencies": {
20
- "@cimplify/sdk": "^0.54.0",
20
+ "@cimplify/sdk": "^0.55.0",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"
@@ -0,0 +1,16 @@
1
+ import { handleOidcCallback } from "@cimplify/sdk/server";
2
+
3
+ const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
4
+ const AUTH_URL = process.env.CIMPLIFY_AUTH_URL;
5
+ const REDIRECT_URI = process.env.CIMPLIFY_REDIRECT_URI ?? "";
6
+
7
+ export async function POST(req: Request): Promise<Response> {
8
+ if (!CLIENT_ID || !REDIRECT_URI) {
9
+ return Response.json({ error: "oidc_not_configured" }, { status: 500 });
10
+ }
11
+ return handleOidcCallback(req, {
12
+ clientId: CLIENT_ID,
13
+ authUrl: AUTH_URL,
14
+ redirectUri: REDIRECT_URI,
15
+ });
16
+ }
@@ -0,0 +1,11 @@
1
+ import { handleSessionRequest } from "@cimplify/sdk/server";
2
+
3
+ const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
4
+ const AUTH_URL = process.env.CIMPLIFY_AUTH_URL;
5
+
6
+ export async function GET(req: Request): Promise<Response> {
7
+ if (!CLIENT_ID) {
8
+ return Response.json({ sub: null }, { status: 200 });
9
+ }
10
+ return handleSessionRequest(req, { clientId: CLIENT_ID, authUrl: AUTH_URL });
11
+ }
@@ -0,0 +1,11 @@
1
+ import { buildSignoutCookie } from "@cimplify/sdk/server";
2
+
3
+ const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
4
+
5
+ export async function POST(): Promise<Response> {
6
+ const cookie = buildSignoutCookie({ clientId: CLIENT_ID });
7
+ return new Response(JSON.stringify({ ok: true }), {
8
+ status: 200,
9
+ headers: { "Content-Type": "application/json", "Set-Cookie": cookie },
10
+ });
11
+ }
@@ -1,13 +1,19 @@
1
1
  "use client";
2
2
 
3
3
  import { CimplifyAccount } from "@cimplify/sdk/react";
4
+ import { brand } from "@/lib/brand";
4
5
 
5
6
  /**
6
7
  * Cimplify Account portal — iframe-mounted UI hosted by Cimplify Link.
7
8
  * Handles sign-in, sign-up, OTP, addresses, payment methods, sessions,
8
9
  * and order history. The iframe owns auth state; we just choose which
9
10
  * `section` to land on.
11
+ *
12
+ * `merchantName` is passed so the embedded widget can render scoping
13
+ * affordances ("Showing your account with {merchant} only.") and
14
+ * enforce the per-merchant data contract — orders/subs filter to this
15
+ * business, cross-merchant surfaces are hidden.
10
16
  */
11
17
  export function AccountIframe({ section }: { section?: string }) {
12
- return <CimplifyAccount section={section} />;
18
+ return <CimplifyAccount section={section} merchantName={brand.name} />;
13
19
  }
@@ -0,0 +1,56 @@
1
+ "use client";
2
+
3
+ import { useEffect, useRef } from "react";
4
+ import Link from "next/link";
5
+ import { CimplifySignInButton, useCimplifySession } from "@cimplify/sdk/react";
6
+ import { signInSilent } from "@cimplify/sdk";
7
+
8
+ const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
9
+
10
+ /**
11
+ * Header sign-in / signed-in pill.
12
+ *
13
+ * - Tries cross-storefront SSO once on mount. If the shopper signed
14
+ * into any other Cimplify storefront recently, this resolves
15
+ * silently and the session lands without any UI flicker.
16
+ * - When signed in, renders "Hi, {name}" linking to /account.
17
+ * - When not signed in, renders the Cimplify Sign-In button.
18
+ */
19
+ export function AccountPill() {
20
+ const { session, loading, refresh } = useCimplifySession();
21
+ const triedSilent = useRef(false);
22
+
23
+ useEffect(() => {
24
+ if (triedSilent.current || session || !CLIENT_ID) return;
25
+ triedSilent.current = true;
26
+ void signInSilent({
27
+ clientId: CLIENT_ID,
28
+ redirectUri: `${window.location.origin}/auth/callback`,
29
+ }).then((r) => {
30
+ if (r.ok) refresh();
31
+ });
32
+ }, [session, refresh]);
33
+
34
+ if (loading || !CLIENT_ID) return <span className="h-9 w-24" aria-hidden />;
35
+
36
+ if (session) {
37
+ const first = session.name?.split(/\s+/)[0] ?? "Account";
38
+ return (
39
+ <Link
40
+ href="/account"
41
+ className="text-[13px] font-medium tracking-wide text-foreground hover:text-primary transition-colors"
42
+ >
43
+ Hi, {first}
44
+ </Link>
45
+ );
46
+ }
47
+
48
+ return (
49
+ <CimplifySignInButton
50
+ clientId={CLIENT_ID}
51
+ redirectUri={`${typeof window !== "undefined" ? window.location.origin : ""}/auth/callback`}
52
+ variant="text"
53
+ onSuccess={() => refresh()}
54
+ />
55
+ );
56
+ }
@@ -3,6 +3,7 @@ import { Suspense } from "react";
3
3
  import { NavLink } from "./nav-link";
4
4
  import { CartPill, CartPillSkeleton } from "./cart-pill";
5
5
  import { MobileNav } from "./mobile-nav";
6
+ import { AccountPill } from "./account-pill";
6
7
  import { brand } from "@/lib/brand";
7
8
 
8
9
  /**
@@ -31,6 +32,7 @@ export function Header() {
31
32
  </Suspense>
32
33
  ))}
33
34
  </nav>
35
+ <AccountPill />
34
36
  <Suspense fallback={<CartPillSkeleton />}>
35
37
  <CartPill />
36
38
  </Suspense>
@@ -0,0 +1,16 @@
1
+ import { headers } from "next/headers";
2
+ import { getSessionFromCookieHeader, type CimplifySession } from "@cimplify/sdk/server";
3
+
4
+ const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
5
+ const AUTH_URL = process.env.CIMPLIFY_AUTH_URL;
6
+
7
+ export async function getSession(): Promise<CimplifySession | null> {
8
+ if (!CLIENT_ID) return null;
9
+ const cookieHeader = (await headers()).get("cookie");
10
+ return getSessionFromCookieHeader(
11
+ { clientId: CLIENT_ID, authUrl: AUTH_URL },
12
+ cookieHeader,
13
+ );
14
+ }
15
+
16
+ export type { CimplifySession } from "@cimplify/sdk/server";
@@ -17,7 +17,7 @@
17
17
  "check": "bun run typecheck && bun run test:run"
18
18
  },
19
19
  "dependencies": {
20
- "@cimplify/sdk": "^0.54.0",
20
+ "@cimplify/sdk": "^0.55.0",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"
@@ -0,0 +1,16 @@
1
+ import { handleOidcCallback } from "@cimplify/sdk/server";
2
+
3
+ const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
4
+ const AUTH_URL = process.env.CIMPLIFY_AUTH_URL;
5
+ const REDIRECT_URI = process.env.CIMPLIFY_REDIRECT_URI ?? "";
6
+
7
+ export async function POST(req: Request): Promise<Response> {
8
+ if (!CLIENT_ID || !REDIRECT_URI) {
9
+ return Response.json({ error: "oidc_not_configured" }, { status: 500 });
10
+ }
11
+ return handleOidcCallback(req, {
12
+ clientId: CLIENT_ID,
13
+ authUrl: AUTH_URL,
14
+ redirectUri: REDIRECT_URI,
15
+ });
16
+ }