@cimplify/cli 0.7.3 → 0.7.4
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-4PBCFGM3.mjs} +1 -1
- package/dist/{chunk-YYG5WE4A.mjs → chunk-LRTPNNQG.mjs} +1 -1
- package/dist/{chunk-ZKMI5E23.mjs → chunk-NTY7JESF.mjs} +2 -2
- package/dist/chunk-QOPMMTVI.mjs +5763 -0
- package/dist/dispatcher.mjs +9 -9
- package/dist/{doctor-DN6RLS6E.mjs → doctor-ZVYWEE53.mjs} +2 -2
- package/dist/{explain-J4JB5QGW.mjs → explain-S6S33HPN.mjs} +1 -1
- package/dist/{introspect-45RASBRH.mjs → introspect-FFB7TA2E.mjs} +2 -2
- package/dist/{list-O47PO4UQ.mjs → list-RLWFTEP4.mjs} +1 -1
- package/dist/{update-CSUNW4RV.mjs → update-WH6NDWIM.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/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
package/dist/dispatcher.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { TEMPLATES } from './chunk-
|
|
3
|
-
import { package_default } from './chunk-
|
|
2
|
+
import { TEMPLATES } from './chunk-QOPMMTVI.mjs';
|
|
3
|
+
import { package_default } from './chunk-NTY7JESF.mjs';
|
|
4
4
|
|
|
5
5
|
// src/dispatcher.ts
|
|
6
6
|
var VERSION = package_default.version ?? "unknown";
|
|
@@ -138,16 +138,16 @@ var COMMANDS = {
|
|
|
138
138
|
logs: () => import('./logs-YNN2PQ24.mjs'),
|
|
139
139
|
status: () => import('./status-JSYXM5RT.mjs'),
|
|
140
140
|
dev: () => import('./dev-ONW2S77K.mjs'),
|
|
141
|
-
introspect: () => import('./introspect-
|
|
141
|
+
introspect: () => import('./introspect-FFB7TA2E.mjs'),
|
|
142
142
|
inspect: () => import('./inspect-CGYX4DDF.mjs'),
|
|
143
|
-
doctor: () => import('./doctor-
|
|
144
|
-
explain: () => import('./explain-
|
|
143
|
+
doctor: () => import('./doctor-ZVYWEE53.mjs'),
|
|
144
|
+
explain: () => import('./explain-S6S33HPN.mjs'),
|
|
145
145
|
assets: () => import('./assets-74SK63TR.mjs'),
|
|
146
146
|
repo: () => import('./repo-KNQMSPVV.mjs'),
|
|
147
|
-
list: () => import('./list-
|
|
148
|
-
add: () => import('./add-
|
|
149
|
-
update: () => import('./update-
|
|
150
|
-
upgrade: () => import('./update-
|
|
147
|
+
list: () => import('./list-RLWFTEP4.mjs'),
|
|
148
|
+
add: () => import('./add-4PBCFGM3.mjs'),
|
|
149
|
+
update: () => import('./update-WH6NDWIM.mjs'),
|
|
150
|
+
upgrade: () => import('./update-WH6NDWIM.mjs'),
|
|
151
151
|
"auth-step-up": () => import('./auth-step-up-BIUYQJP6.mjs')
|
|
152
152
|
};
|
|
153
153
|
var COMMAND_PREFIXES = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { gatherIntrospection } from './chunk-
|
|
2
|
+
import { gatherIntrospection } from './chunk-LRTPNNQG.mjs';
|
|
3
3
|
import './chunk-K5464A3L.mjs';
|
|
4
4
|
import './chunk-DBZ3UOQ2.mjs';
|
|
5
|
-
import './chunk-
|
|
5
|
+
import './chunk-NTY7JESF.mjs';
|
|
6
6
|
import { parseArgs, flagBool } from './chunk-C4M3DXKC.mjs';
|
|
7
7
|
import { ApiClient } from './chunk-MAOO6ZZ5.mjs';
|
|
8
8
|
import { readAuthOrNull } from './chunk-UBAI443T.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { package_default } from './chunk-
|
|
2
|
+
import { package_default } from './chunk-NTY7JESF.mjs';
|
|
3
3
|
import { parseArgs } from './chunk-C4M3DXKC.mjs';
|
|
4
4
|
import { bold, dim, info, result, CliError, CLI_ERROR_CODE } from './chunk-E2T2SBP5.mjs';
|
|
5
5
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export { run as default, extractMockSeed, gatherIntrospection, renderIntrospection } from './chunk-
|
|
2
|
+
export { run as default, extractMockSeed, gatherIntrospection, renderIntrospection } from './chunk-LRTPNNQG.mjs';
|
|
3
3
|
import './chunk-K5464A3L.mjs';
|
|
4
4
|
import './chunk-DBZ3UOQ2.mjs';
|
|
5
|
-
import './chunk-
|
|
5
|
+
import './chunk-NTY7JESF.mjs';
|
|
6
6
|
import './chunk-C4M3DXKC.mjs';
|
|
7
7
|
import './chunk-UBAI443T.mjs';
|
|
8
8
|
import './chunk-E2T2SBP5.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { REGISTRY_INDEX } from './chunk-
|
|
2
|
+
import { REGISTRY_INDEX } from './chunk-QOPMMTVI.mjs';
|
|
3
3
|
import { parseArgs, flagBool } from './chunk-C4M3DXKC.mjs';
|
|
4
4
|
import { CliError, CLI_ERROR_CODE, info, bold, dim, green, result } from './chunk-E2T2SBP5.mjs';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { package_default } from './chunk-
|
|
2
|
+
import { package_default } from './chunk-NTY7JESF.mjs';
|
|
3
3
|
import { promptYesNo } from './chunk-ITAFAORS.mjs';
|
|
4
4
|
import { parseArgs, flagBool, flagString } from './chunk-C4M3DXKC.mjs';
|
|
5
5
|
import { success, bold, info, dim, result, failure, CliError, CLI_ERROR_CODE, step, isJsonMode } from './chunk-E2T2SBP5.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cimplify/cli",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "Cimplify CLI — deploy, manage env vars, link projects, and scaffold storefronts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cimplify",
|
|
@@ -45,6 +45,6 @@
|
|
|
45
45
|
"vitest": "^4.1.5"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@cimplify/sdk": "^0.
|
|
48
|
+
"@cimplify/sdk": "^0.56.0"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -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";
|
|
@@ -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";
|
|
@@ -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";
|