@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.
- package/dist/{add-5NW7N5CJ.mjs → add-ZD5FOTC7.mjs} +1 -1
- package/dist/{chunk-CVQRL2VH.mjs → chunk-HDIDSQS4.mjs} +22 -22
- package/dist/{chunk-26ETGFW6.mjs → chunk-YYG5WE4A.mjs} +1 -1
- package/dist/{chunk-ZVEQGQ2Z.mjs → chunk-ZKMI5E23.mjs} +2 -2
- package/dist/dispatcher.mjs +9 -9
- package/dist/{doctor-XLBDC6NO.mjs → doctor-DN6RLS6E.mjs} +2 -2
- package/dist/{explain-PKTL7ZR6.mjs → explain-J4JB5QGW.mjs} +1 -1
- package/dist/{introspect-FPBV3O4N.mjs → introspect-45RASBRH.mjs} +2 -2
- package/dist/{list-N7FKBQ3Y.mjs → list-O47PO4UQ.mjs} +1 -1
- package/dist/{update-ZC3JGKLI.mjs → update-CSUNW4RV.mjs} +1 -1
- package/package.json +2 -2
- package/templates/storefront-auto/app/auth/callback/route.ts +16 -0
- package/templates/storefront-auto/app/auth/session/route.ts +11 -0
- package/templates/storefront-auto/app/auth/signout/route.ts +11 -0
- package/templates/storefront-auto/components/account-iframe.tsx +7 -1
- package/templates/storefront-auto/components/account-pill.tsx +56 -0
- package/templates/storefront-auto/components/header.tsx +2 -0
- package/templates/storefront-auto/lib/auth.ts +16 -0
- package/templates/storefront-auto/package.json +1 -1
- package/templates/storefront-bakery/app/auth/callback/route.ts +16 -0
- package/templates/storefront-bakery/app/auth/session/route.ts +11 -0
- package/templates/storefront-bakery/app/auth/signout/route.ts +11 -0
- package/templates/storefront-bakery/components/account-iframe.tsx +7 -1
- package/templates/storefront-bakery/components/account-pill.tsx +56 -0
- package/templates/storefront-bakery/components/header.tsx +2 -0
- package/templates/storefront-bakery/lib/auth.ts +16 -0
- package/templates/storefront-bakery/package.json +1 -1
- package/templates/storefront-fashion/app/auth/callback/route.ts +16 -0
- package/templates/storefront-fashion/app/auth/session/route.ts +11 -0
- package/templates/storefront-fashion/app/auth/signout/route.ts +11 -0
- package/templates/storefront-fashion/components/account-iframe.tsx +7 -1
- package/templates/storefront-fashion/components/account-pill.tsx +56 -0
- package/templates/storefront-fashion/components/header.tsx +2 -0
- package/templates/storefront-fashion/lib/auth.ts +16 -0
- package/templates/storefront-fashion/package.json +1 -1
- package/templates/storefront-grocery/app/auth/callback/route.ts +16 -0
- package/templates/storefront-grocery/app/auth/session/route.ts +11 -0
- package/templates/storefront-grocery/app/auth/signout/route.ts +11 -0
- package/templates/storefront-grocery/components/account-iframe.tsx +7 -1
- package/templates/storefront-grocery/components/account-pill.tsx +56 -0
- package/templates/storefront-grocery/components/header.tsx +2 -0
- package/templates/storefront-grocery/lib/auth.ts +16 -0
- package/templates/storefront-grocery/package.json +1 -1
- package/templates/storefront-pharmacy/app/auth/callback/route.ts +16 -0
- package/templates/storefront-pharmacy/app/auth/session/route.ts +11 -0
- package/templates/storefront-pharmacy/app/auth/signout/route.ts +11 -0
- package/templates/storefront-pharmacy/components/account-iframe.tsx +7 -1
- package/templates/storefront-pharmacy/components/account-pill.tsx +56 -0
- package/templates/storefront-pharmacy/components/header.tsx +2 -0
- package/templates/storefront-pharmacy/lib/auth.ts +16 -0
- package/templates/storefront-pharmacy/package.json +1 -1
- package/templates/storefront-restaurant/app/auth/callback/route.ts +16 -0
- package/templates/storefront-restaurant/app/auth/session/route.ts +11 -0
- package/templates/storefront-restaurant/app/auth/signout/route.ts +11 -0
- package/templates/storefront-restaurant/components/account-iframe.tsx +7 -1
- package/templates/storefront-restaurant/components/account-pill.tsx +56 -0
- package/templates/storefront-restaurant/components/header.tsx +2 -0
- package/templates/storefront-restaurant/lib/auth.ts +16 -0
- package/templates/storefront-restaurant/package.json +1 -1
- package/templates/storefront-retail/app/auth/callback/route.ts +16 -0
- package/templates/storefront-retail/app/auth/session/route.ts +11 -0
- package/templates/storefront-retail/app/auth/signout/route.ts +11 -0
- package/templates/storefront-retail/components/account-iframe.tsx +7 -1
- package/templates/storefront-retail/components/account-pill.tsx +56 -0
- package/templates/storefront-retail/components/header.tsx +2 -0
- package/templates/storefront-retail/lib/auth.ts +16 -0
- package/templates/storefront-retail/package.json +1 -1
- package/templates/storefront-services/app/auth/callback/route.ts +16 -0
- package/templates/storefront-services/app/auth/session/route.ts +11 -0
- package/templates/storefront-services/app/auth/signout/route.ts +11 -0
- package/templates/storefront-services/components/account-iframe.tsx +7 -1
- package/templates/storefront-services/components/account-pill.tsx +56 -0
- package/templates/storefront-services/components/header.tsx +2 -0
- package/templates/storefront-services/lib/auth.ts +16 -0
- 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";
|