@cimplify/cli 0.7.3 → 0.7.5

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 (45) hide show
  1. package/dist/{add-ZD5FOTC7.mjs → add-JHVJ5RGL.mjs} +1 -1
  2. package/dist/{chunk-ZKMI5E23.mjs → chunk-6CIWEADS.mjs} +2 -2
  3. package/dist/{chunk-YYG5WE4A.mjs → chunk-HGFCYWS2.mjs} +1 -1
  4. package/dist/chunk-NOMGIGNO.mjs +5763 -0
  5. package/dist/dispatcher.mjs +9 -9
  6. package/dist/{doctor-DN6RLS6E.mjs → doctor-YC7H2JXR.mjs} +2 -2
  7. package/dist/{explain-J4JB5QGW.mjs → explain-YRRYXXE2.mjs} +2 -2
  8. package/dist/{introspect-45RASBRH.mjs → introspect-2HEJ7EGB.mjs} +2 -2
  9. package/dist/{list-O47PO4UQ.mjs → list-FCWEQPDR.mjs} +1 -1
  10. package/dist/{update-CSUNW4RV.mjs → update-GVWXFVB3.mjs} +1 -1
  11. package/package.json +2 -2
  12. package/templates/storefront-auto/app/auth/signout/route.ts +6 -6
  13. package/templates/storefront-auto/components/account-pill.tsx +2 -9
  14. package/templates/storefront-auto/lib/auth.ts +24 -5
  15. package/templates/storefront-auto/package.json +1 -1
  16. package/templates/storefront-bakery/app/auth/signout/route.ts +6 -6
  17. package/templates/storefront-bakery/components/account-pill.tsx +2 -9
  18. package/templates/storefront-bakery/components/signed-out-prompt.tsx +32 -0
  19. package/templates/storefront-bakery/lib/auth.ts +24 -5
  20. package/templates/storefront-bakery/package.json +1 -1
  21. package/templates/storefront-fashion/app/auth/signout/route.ts +6 -6
  22. package/templates/storefront-fashion/components/account-pill.tsx +2 -9
  23. package/templates/storefront-fashion/lib/auth.ts +24 -5
  24. package/templates/storefront-fashion/package.json +1 -1
  25. package/templates/storefront-grocery/app/auth/signout/route.ts +6 -6
  26. package/templates/storefront-grocery/components/account-pill.tsx +2 -9
  27. package/templates/storefront-grocery/lib/auth.ts +24 -5
  28. package/templates/storefront-grocery/package.json +1 -1
  29. package/templates/storefront-pharmacy/app/auth/signout/route.ts +6 -6
  30. package/templates/storefront-pharmacy/components/account-pill.tsx +2 -9
  31. package/templates/storefront-pharmacy/lib/auth.ts +24 -5
  32. package/templates/storefront-pharmacy/package.json +1 -1
  33. package/templates/storefront-restaurant/app/auth/signout/route.ts +6 -6
  34. package/templates/storefront-restaurant/components/account-pill.tsx +2 -9
  35. package/templates/storefront-restaurant/lib/auth.ts +24 -5
  36. package/templates/storefront-restaurant/package.json +1 -1
  37. package/templates/storefront-retail/app/auth/signout/route.ts +6 -6
  38. package/templates/storefront-retail/components/account-pill.tsx +2 -9
  39. package/templates/storefront-retail/lib/auth.ts +24 -5
  40. package/templates/storefront-retail/package.json +1 -1
  41. package/templates/storefront-services/app/auth/signout/route.ts +6 -6
  42. package/templates/storefront-services/components/account-pill.tsx +2 -9
  43. package/templates/storefront-services/lib/auth.ts +24 -5
  44. package/templates/storefront-services/package.json +1 -1
  45. package/dist/chunk-HDIDSQS4.mjs +0 -5763
@@ -7,15 +7,8 @@ import { signInSilent } from "@cimplify/sdk";
7
7
 
8
8
  const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
9
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
- */
10
+ // Attempts silent SSO on mount before showing the button so returning
11
+ // shoppers don't see a flash of "Sign in" before landing as signed in.
19
12
  export function AccountPill() {
20
13
  const { session, loading, refresh } = useCimplifySession();
21
14
  const triedSilent = useRef(false);
@@ -1,16 +1,35 @@
1
1
  import { headers } from "next/headers";
2
- import { getSessionFromCookieHeader, type CimplifySession } from "@cimplify/sdk/server";
2
+ import {
3
+ getAccessTokenFromCookieHeader,
4
+ getServerClient,
5
+ getSessionFromCookieHeader,
6
+ type CimplifyClient,
7
+ type CimplifySession,
8
+ } from "@cimplify/sdk/server";
3
9
 
4
10
  const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
5
11
  const AUTH_URL = process.env.CIMPLIFY_AUTH_URL;
6
12
 
13
+ const oidcConfig = { clientId: CLIENT_ID, authUrl: AUTH_URL };
14
+
7
15
  export async function getSession(): Promise<CimplifySession | null> {
8
16
  if (!CLIENT_ID) return null;
9
17
  const cookieHeader = (await headers()).get("cookie");
10
- return getSessionFromCookieHeader(
11
- { clientId: CLIENT_ID, authUrl: AUTH_URL },
12
- cookieHeader,
13
- );
18
+ return getSessionFromCookieHeader(oidcConfig, cookieHeader);
19
+ }
20
+
21
+ // Returns a Cimplify server client with the signed-in customer's access
22
+ // token attached (if any). Use this instead of getServerClient() on pages
23
+ // that need personalized data: orders, subscriptions, price-list pricing.
24
+ // Pages without `revalidate: 0` will share a cache across customers, so
25
+ // only use this on routes that opt out of static caching.
26
+ export async function getAuthenticatedServerClient(): Promise<CimplifyClient> {
27
+ const cookieHeader = (await headers()).get("cookie");
28
+ const accessToken =
29
+ CLIENT_ID && cookieHeader
30
+ ? getAccessTokenFromCookieHeader(oidcConfig, cookieHeader) ?? undefined
31
+ : undefined;
32
+ return getServerClient({ accessToken });
14
33
  }
15
34
 
16
35
  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.55.0",
20
+ "@cimplify/sdk": "^0.57.0",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"
@@ -1,11 +1,11 @@
1
- import { buildSignoutCookie } from "@cimplify/sdk/server";
1
+ import { buildSignoutCookies } from "@cimplify/sdk/server";
2
2
 
3
3
  const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
4
4
 
5
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
- });
6
+ const headers = new Headers({ "Content-Type": "application/json" });
7
+ for (const cookie of buildSignoutCookies({ clientId: CLIENT_ID })) {
8
+ headers.append("Set-Cookie", cookie);
9
+ }
10
+ return new Response(JSON.stringify({ ok: true }), { status: 200, headers });
11
11
  }
@@ -7,15 +7,8 @@ import { signInSilent } from "@cimplify/sdk";
7
7
 
8
8
  const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
9
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
- */
10
+ // Attempts silent SSO on mount before showing the button so returning
11
+ // shoppers don't see a flash of "Sign in" before landing as signed in.
19
12
  export function AccountPill() {
20
13
  const { session, loading, refresh } = useCimplifySession();
21
14
  const triedSilent = useRef(false);
@@ -1,16 +1,35 @@
1
1
  import { headers } from "next/headers";
2
- import { getSessionFromCookieHeader, type CimplifySession } from "@cimplify/sdk/server";
2
+ import {
3
+ getAccessTokenFromCookieHeader,
4
+ getServerClient,
5
+ getSessionFromCookieHeader,
6
+ type CimplifyClient,
7
+ type CimplifySession,
8
+ } from "@cimplify/sdk/server";
3
9
 
4
10
  const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
5
11
  const AUTH_URL = process.env.CIMPLIFY_AUTH_URL;
6
12
 
13
+ const oidcConfig = { clientId: CLIENT_ID, authUrl: AUTH_URL };
14
+
7
15
  export async function getSession(): Promise<CimplifySession | null> {
8
16
  if (!CLIENT_ID) return null;
9
17
  const cookieHeader = (await headers()).get("cookie");
10
- return getSessionFromCookieHeader(
11
- { clientId: CLIENT_ID, authUrl: AUTH_URL },
12
- cookieHeader,
13
- );
18
+ return getSessionFromCookieHeader(oidcConfig, cookieHeader);
19
+ }
20
+
21
+ // Returns a Cimplify server client with the signed-in customer's access
22
+ // token attached (if any). Use this instead of getServerClient() on pages
23
+ // that need personalized data: orders, subscriptions, price-list pricing.
24
+ // Pages without `revalidate: 0` will share a cache across customers, so
25
+ // only use this on routes that opt out of static caching.
26
+ export async function getAuthenticatedServerClient(): Promise<CimplifyClient> {
27
+ const cookieHeader = (await headers()).get("cookie");
28
+ const accessToken =
29
+ CLIENT_ID && cookieHeader
30
+ ? getAccessTokenFromCookieHeader(oidcConfig, cookieHeader) ?? undefined
31
+ : undefined;
32
+ return getServerClient({ accessToken });
14
33
  }
15
34
 
16
35
  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.55.0",
20
+ "@cimplify/sdk": "^0.57.0",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"
@@ -1,11 +1,11 @@
1
- import { buildSignoutCookie } from "@cimplify/sdk/server";
1
+ import { buildSignoutCookies } from "@cimplify/sdk/server";
2
2
 
3
3
  const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
4
4
 
5
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
- });
6
+ const headers = new Headers({ "Content-Type": "application/json" });
7
+ for (const cookie of buildSignoutCookies({ clientId: CLIENT_ID })) {
8
+ headers.append("Set-Cookie", cookie);
9
+ }
10
+ return new Response(JSON.stringify({ ok: true }), { status: 200, headers });
11
11
  }
@@ -7,15 +7,8 @@ import { signInSilent } from "@cimplify/sdk";
7
7
 
8
8
  const CLIENT_ID = process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID ?? "";
9
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
- */
10
+ // Attempts silent SSO on mount before showing the button so returning
11
+ // shoppers don't see a flash of "Sign in" before landing as signed in.
19
12
  export function AccountPill() {
20
13
  const { session, loading, refresh } = useCimplifySession();
21
14
  const triedSilent = useRef(false);
@@ -1,16 +1,35 @@
1
1
  import { headers } from "next/headers";
2
- import { getSessionFromCookieHeader, type CimplifySession } from "@cimplify/sdk/server";
2
+ import {
3
+ getAccessTokenFromCookieHeader,
4
+ getServerClient,
5
+ getSessionFromCookieHeader,
6
+ type CimplifyClient,
7
+ type CimplifySession,
8
+ } from "@cimplify/sdk/server";
3
9
 
4
10
  const CLIENT_ID = process.env.CIMPLIFY_CLIENT_ID ?? "";
5
11
  const AUTH_URL = process.env.CIMPLIFY_AUTH_URL;
6
12
 
13
+ const oidcConfig = { clientId: CLIENT_ID, authUrl: AUTH_URL };
14
+
7
15
  export async function getSession(): Promise<CimplifySession | null> {
8
16
  if (!CLIENT_ID) return null;
9
17
  const cookieHeader = (await headers()).get("cookie");
10
- return getSessionFromCookieHeader(
11
- { clientId: CLIENT_ID, authUrl: AUTH_URL },
12
- cookieHeader,
13
- );
18
+ return getSessionFromCookieHeader(oidcConfig, cookieHeader);
19
+ }
20
+
21
+ // Returns a Cimplify server client with the signed-in customer's access
22
+ // token attached (if any). Use this instead of getServerClient() on pages
23
+ // that need personalized data: orders, subscriptions, price-list pricing.
24
+ // Pages without `revalidate: 0` will share a cache across customers, so
25
+ // only use this on routes that opt out of static caching.
26
+ export async function getAuthenticatedServerClient(): Promise<CimplifyClient> {
27
+ const cookieHeader = (await headers()).get("cookie");
28
+ const accessToken =
29
+ CLIENT_ID && cookieHeader
30
+ ? getAccessTokenFromCookieHeader(oidcConfig, cookieHeader) ?? undefined
31
+ : undefined;
32
+ return getServerClient({ accessToken });
14
33
  }
15
34
 
16
35
  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.55.0",
20
+ "@cimplify/sdk": "^0.57.0",
21
21
  "next": "^16.2.6",
22
22
  "react": "^19.0.0",
23
23
  "react-dom": "^19.0.0"