@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.
- package/dist/{add-ZD5FOTC7.mjs → add-JHVJ5RGL.mjs} +1 -1
- package/dist/{chunk-ZKMI5E23.mjs → chunk-6CIWEADS.mjs} +2 -2
- package/dist/{chunk-YYG5WE4A.mjs → chunk-HGFCYWS2.mjs} +1 -1
- package/dist/chunk-NOMGIGNO.mjs +5763 -0
- package/dist/dispatcher.mjs +9 -9
- package/dist/{doctor-DN6RLS6E.mjs → doctor-YC7H2JXR.mjs} +2 -2
- package/dist/{explain-J4JB5QGW.mjs → explain-YRRYXXE2.mjs} +2 -2
- package/dist/{introspect-45RASBRH.mjs → introspect-2HEJ7EGB.mjs} +2 -2
- package/dist/{list-O47PO4UQ.mjs → list-FCWEQPDR.mjs} +1 -1
- package/dist/{update-CSUNW4RV.mjs → update-GVWXFVB3.mjs} +1 -1
- package/package.json +2 -2
- package/templates/storefront-auto/app/auth/signout/route.ts +6 -6
- package/templates/storefront-auto/components/account-pill.tsx +2 -9
- package/templates/storefront-auto/lib/auth.ts +24 -5
- package/templates/storefront-auto/package.json +1 -1
- package/templates/storefront-bakery/app/auth/signout/route.ts +6 -6
- package/templates/storefront-bakery/components/account-pill.tsx +2 -9
- package/templates/storefront-bakery/components/signed-out-prompt.tsx +32 -0
- package/templates/storefront-bakery/lib/auth.ts +24 -5
- package/templates/storefront-bakery/package.json +1 -1
- package/templates/storefront-fashion/app/auth/signout/route.ts +6 -6
- package/templates/storefront-fashion/components/account-pill.tsx +2 -9
- package/templates/storefront-fashion/lib/auth.ts +24 -5
- package/templates/storefront-fashion/package.json +1 -1
- package/templates/storefront-grocery/app/auth/signout/route.ts +6 -6
- package/templates/storefront-grocery/components/account-pill.tsx +2 -9
- package/templates/storefront-grocery/lib/auth.ts +24 -5
- package/templates/storefront-grocery/package.json +1 -1
- package/templates/storefront-pharmacy/app/auth/signout/route.ts +6 -6
- package/templates/storefront-pharmacy/components/account-pill.tsx +2 -9
- package/templates/storefront-pharmacy/lib/auth.ts +24 -5
- package/templates/storefront-pharmacy/package.json +1 -1
- package/templates/storefront-restaurant/app/auth/signout/route.ts +6 -6
- package/templates/storefront-restaurant/components/account-pill.tsx +2 -9
- package/templates/storefront-restaurant/lib/auth.ts +24 -5
- package/templates/storefront-restaurant/package.json +1 -1
- package/templates/storefront-retail/app/auth/signout/route.ts +6 -6
- package/templates/storefront-retail/components/account-pill.tsx +2 -9
- package/templates/storefront-retail/lib/auth.ts +24 -5
- package/templates/storefront-retail/package.json +1 -1
- package/templates/storefront-services/app/auth/signout/route.ts +6 -6
- package/templates/storefront-services/components/account-pill.tsx +2 -9
- package/templates/storefront-services/lib/auth.ts +24 -5
- package/templates/storefront-services/package.json +1 -1
- 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
|
-
|
|
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 {
|
|
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
|
-
|
|
12
|
-
|
|
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";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
12
|
-
|
|
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";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
12
|
-
|
|
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";
|