@cimplify/cli 0.7.11 → 0.7.12
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-3CEDUXNO.mjs → add-BCQCRULA.mjs} +1 -1
- package/dist/{chunk-ZFCWAYK2.mjs → chunk-NYRKS2ZC.mjs} +1 -1
- package/dist/{chunk-DAE3YSKU.mjs → chunk-R6TUXVFC.mjs} +320 -8
- package/dist/{chunk-XB4MMPXC.mjs → chunk-ZSO64OIW.mjs} +2 -2
- package/dist/dispatcher.mjs +9 -9
- package/dist/{doctor-A3YU5YOX.mjs → doctor-4FTJFRJK.mjs} +2 -2
- package/dist/{explain-WZQTCB3C.mjs → explain-6FFAG3OD.mjs} +1 -1
- package/dist/{introspect-2GJIQ6CP.mjs → introspect-2I2MHUMW.mjs} +2 -2
- package/dist/{list-F3LBI7HF.mjs → list-Y7AZYDWJ.mjs} +1 -1
- package/dist/{update-PINBW3NG.mjs → update-SBYEU77K.mjs} +1 -1
- package/package.json +2 -2
- package/templates/storefront-auto/middleware.ts +39 -0
- package/templates/storefront-auto/package.json +1 -1
- package/templates/storefront-bakery/middleware.ts +39 -0
- package/templates/storefront-bakery/package.json +1 -1
- package/templates/storefront-fashion/middleware.ts +39 -0
- package/templates/storefront-fashion/package.json +1 -1
- package/templates/storefront-grocery/middleware.ts +39 -0
- package/templates/storefront-grocery/package.json +1 -1
- package/templates/storefront-pharmacy/middleware.ts +39 -0
- package/templates/storefront-pharmacy/package.json +1 -1
- package/templates/storefront-restaurant/middleware.ts +39 -0
- package/templates/storefront-restaurant/package.json +1 -1
- package/templates/storefront-retail/middleware.ts +39 -0
- package/templates/storefront-retail/package.json +1 -1
- package/templates/storefront-services/middleware.ts +39 -0
- package/templates/storefront-services/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// package.json
|
|
3
3
|
var package_default = {
|
|
4
4
|
name: "@cimplify/cli",
|
|
5
|
-
version: "0.7.
|
|
5
|
+
version: "0.7.12",
|
|
6
6
|
description: "Cimplify CLI \u2014 deploy, manage env vars, link projects, and scaffold storefronts",
|
|
7
7
|
keywords: [
|
|
8
8
|
"cimplify",
|
|
@@ -47,7 +47,7 @@ var package_default = {
|
|
|
47
47
|
vitest: "^4.1.5"
|
|
48
48
|
},
|
|
49
49
|
dependencies: {
|
|
50
|
-
"@cimplify/sdk": "^0.
|
|
50
|
+
"@cimplify/sdk": "^0.67.0"
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
|
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-R6TUXVFC.mjs';
|
|
3
|
+
import { package_default } from './chunk-ZSO64OIW.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-2I2MHUMW.mjs'),
|
|
142
142
|
inspect: () => import('./inspect-CGYX4DDF.mjs'),
|
|
143
|
-
doctor: () => import('./doctor-
|
|
144
|
-
explain: () => import('./explain-
|
|
143
|
+
doctor: () => import('./doctor-4FTJFRJK.mjs'),
|
|
144
|
+
explain: () => import('./explain-6FFAG3OD.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-Y7AZYDWJ.mjs'),
|
|
148
|
+
add: () => import('./add-BCQCRULA.mjs'),
|
|
149
|
+
update: () => import('./update-SBYEU77K.mjs'),
|
|
150
|
+
upgrade: () => import('./update-SBYEU77K.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-NYRKS2ZC.mjs';
|
|
3
3
|
import './chunk-K5464A3L.mjs';
|
|
4
4
|
import './chunk-DBZ3UOQ2.mjs';
|
|
5
|
-
import './chunk-
|
|
5
|
+
import './chunk-ZSO64OIW.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-ZSO64OIW.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-NYRKS2ZC.mjs';
|
|
3
3
|
import './chunk-K5464A3L.mjs';
|
|
4
4
|
import './chunk-DBZ3UOQ2.mjs';
|
|
5
|
-
import './chunk-
|
|
5
|
+
import './chunk-ZSO64OIW.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-R6TUXVFC.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-ZSO64OIW.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.12",
|
|
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.67.0"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { NextResponse, type NextRequest } from "next/server";
|
|
2
|
+
import { handleTokenRefresh, type OidcConfig } from "@cimplify/sdk/server";
|
|
3
|
+
|
|
4
|
+
function oidcConfig(): OidcConfig | null {
|
|
5
|
+
const clientId =
|
|
6
|
+
process.env.CIMPLIFY_CLIENT_ID?.trim() ||
|
|
7
|
+
process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID?.trim() ||
|
|
8
|
+
"";
|
|
9
|
+
if (!clientId) return null;
|
|
10
|
+
return {
|
|
11
|
+
clientId,
|
|
12
|
+
issuer: process.env.CIMPLIFY_ISSUER?.trim() || undefined,
|
|
13
|
+
authUrl: process.env.CIMPLIFY_AUTH_URL?.trim() || undefined,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Keeps the access token fresh before account pages render. Server Components
|
|
18
|
+
// can't write cookies, so this is the one place the rotated token can be both
|
|
19
|
+
// persisted (browser) and forwarded onto the current request (this render).
|
|
20
|
+
export async function middleware(request: NextRequest) {
|
|
21
|
+
const cfg = oidcConfig();
|
|
22
|
+
if (!cfg) return NextResponse.next();
|
|
23
|
+
|
|
24
|
+
const { outcome, setCookies, cookies } = await handleTokenRefresh(request, cfg);
|
|
25
|
+
if (outcome === "noop") return NextResponse.next();
|
|
26
|
+
|
|
27
|
+
for (const { name, value } of cookies) {
|
|
28
|
+
request.cookies.set(name, value);
|
|
29
|
+
}
|
|
30
|
+
const response = NextResponse.next({ request });
|
|
31
|
+
for (const cookie of setCookies) {
|
|
32
|
+
response.headers.append("set-cookie", cookie);
|
|
33
|
+
}
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const config = {
|
|
38
|
+
matcher: ["/account/:path*"],
|
|
39
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { NextResponse, type NextRequest } from "next/server";
|
|
2
|
+
import { handleTokenRefresh, type OidcConfig } from "@cimplify/sdk/server";
|
|
3
|
+
|
|
4
|
+
function oidcConfig(): OidcConfig | null {
|
|
5
|
+
const clientId =
|
|
6
|
+
process.env.CIMPLIFY_CLIENT_ID?.trim() ||
|
|
7
|
+
process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID?.trim() ||
|
|
8
|
+
"";
|
|
9
|
+
if (!clientId) return null;
|
|
10
|
+
return {
|
|
11
|
+
clientId,
|
|
12
|
+
issuer: process.env.CIMPLIFY_ISSUER?.trim() || undefined,
|
|
13
|
+
authUrl: process.env.CIMPLIFY_AUTH_URL?.trim() || undefined,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Keeps the access token fresh before account pages render. Server Components
|
|
18
|
+
// can't write cookies, so this is the one place the rotated token can be both
|
|
19
|
+
// persisted (browser) and forwarded onto the current request (this render).
|
|
20
|
+
export async function middleware(request: NextRequest) {
|
|
21
|
+
const cfg = oidcConfig();
|
|
22
|
+
if (!cfg) return NextResponse.next();
|
|
23
|
+
|
|
24
|
+
const { outcome, setCookies, cookies } = await handleTokenRefresh(request, cfg);
|
|
25
|
+
if (outcome === "noop") return NextResponse.next();
|
|
26
|
+
|
|
27
|
+
for (const { name, value } of cookies) {
|
|
28
|
+
request.cookies.set(name, value);
|
|
29
|
+
}
|
|
30
|
+
const response = NextResponse.next({ request });
|
|
31
|
+
for (const cookie of setCookies) {
|
|
32
|
+
response.headers.append("set-cookie", cookie);
|
|
33
|
+
}
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const config = {
|
|
38
|
+
matcher: ["/account/:path*"],
|
|
39
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { NextResponse, type NextRequest } from "next/server";
|
|
2
|
+
import { handleTokenRefresh, type OidcConfig } from "@cimplify/sdk/server";
|
|
3
|
+
|
|
4
|
+
function oidcConfig(): OidcConfig | null {
|
|
5
|
+
const clientId =
|
|
6
|
+
process.env.CIMPLIFY_CLIENT_ID?.trim() ||
|
|
7
|
+
process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID?.trim() ||
|
|
8
|
+
"";
|
|
9
|
+
if (!clientId) return null;
|
|
10
|
+
return {
|
|
11
|
+
clientId,
|
|
12
|
+
issuer: process.env.CIMPLIFY_ISSUER?.trim() || undefined,
|
|
13
|
+
authUrl: process.env.CIMPLIFY_AUTH_URL?.trim() || undefined,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Keeps the access token fresh before account pages render. Server Components
|
|
18
|
+
// can't write cookies, so this is the one place the rotated token can be both
|
|
19
|
+
// persisted (browser) and forwarded onto the current request (this render).
|
|
20
|
+
export async function middleware(request: NextRequest) {
|
|
21
|
+
const cfg = oidcConfig();
|
|
22
|
+
if (!cfg) return NextResponse.next();
|
|
23
|
+
|
|
24
|
+
const { outcome, setCookies, cookies } = await handleTokenRefresh(request, cfg);
|
|
25
|
+
if (outcome === "noop") return NextResponse.next();
|
|
26
|
+
|
|
27
|
+
for (const { name, value } of cookies) {
|
|
28
|
+
request.cookies.set(name, value);
|
|
29
|
+
}
|
|
30
|
+
const response = NextResponse.next({ request });
|
|
31
|
+
for (const cookie of setCookies) {
|
|
32
|
+
response.headers.append("set-cookie", cookie);
|
|
33
|
+
}
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const config = {
|
|
38
|
+
matcher: ["/account/:path*"],
|
|
39
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { NextResponse, type NextRequest } from "next/server";
|
|
2
|
+
import { handleTokenRefresh, type OidcConfig } from "@cimplify/sdk/server";
|
|
3
|
+
|
|
4
|
+
function oidcConfig(): OidcConfig | null {
|
|
5
|
+
const clientId =
|
|
6
|
+
process.env.CIMPLIFY_CLIENT_ID?.trim() ||
|
|
7
|
+
process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID?.trim() ||
|
|
8
|
+
"";
|
|
9
|
+
if (!clientId) return null;
|
|
10
|
+
return {
|
|
11
|
+
clientId,
|
|
12
|
+
issuer: process.env.CIMPLIFY_ISSUER?.trim() || undefined,
|
|
13
|
+
authUrl: process.env.CIMPLIFY_AUTH_URL?.trim() || undefined,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Keeps the access token fresh before account pages render. Server Components
|
|
18
|
+
// can't write cookies, so this is the one place the rotated token can be both
|
|
19
|
+
// persisted (browser) and forwarded onto the current request (this render).
|
|
20
|
+
export async function middleware(request: NextRequest) {
|
|
21
|
+
const cfg = oidcConfig();
|
|
22
|
+
if (!cfg) return NextResponse.next();
|
|
23
|
+
|
|
24
|
+
const { outcome, setCookies, cookies } = await handleTokenRefresh(request, cfg);
|
|
25
|
+
if (outcome === "noop") return NextResponse.next();
|
|
26
|
+
|
|
27
|
+
for (const { name, value } of cookies) {
|
|
28
|
+
request.cookies.set(name, value);
|
|
29
|
+
}
|
|
30
|
+
const response = NextResponse.next({ request });
|
|
31
|
+
for (const cookie of setCookies) {
|
|
32
|
+
response.headers.append("set-cookie", cookie);
|
|
33
|
+
}
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const config = {
|
|
38
|
+
matcher: ["/account/:path*"],
|
|
39
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { NextResponse, type NextRequest } from "next/server";
|
|
2
|
+
import { handleTokenRefresh, type OidcConfig } from "@cimplify/sdk/server";
|
|
3
|
+
|
|
4
|
+
function oidcConfig(): OidcConfig | null {
|
|
5
|
+
const clientId =
|
|
6
|
+
process.env.CIMPLIFY_CLIENT_ID?.trim() ||
|
|
7
|
+
process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID?.trim() ||
|
|
8
|
+
"";
|
|
9
|
+
if (!clientId) return null;
|
|
10
|
+
return {
|
|
11
|
+
clientId,
|
|
12
|
+
issuer: process.env.CIMPLIFY_ISSUER?.trim() || undefined,
|
|
13
|
+
authUrl: process.env.CIMPLIFY_AUTH_URL?.trim() || undefined,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Keeps the access token fresh before account pages render. Server Components
|
|
18
|
+
// can't write cookies, so this is the one place the rotated token can be both
|
|
19
|
+
// persisted (browser) and forwarded onto the current request (this render).
|
|
20
|
+
export async function middleware(request: NextRequest) {
|
|
21
|
+
const cfg = oidcConfig();
|
|
22
|
+
if (!cfg) return NextResponse.next();
|
|
23
|
+
|
|
24
|
+
const { outcome, setCookies, cookies } = await handleTokenRefresh(request, cfg);
|
|
25
|
+
if (outcome === "noop") return NextResponse.next();
|
|
26
|
+
|
|
27
|
+
for (const { name, value } of cookies) {
|
|
28
|
+
request.cookies.set(name, value);
|
|
29
|
+
}
|
|
30
|
+
const response = NextResponse.next({ request });
|
|
31
|
+
for (const cookie of setCookies) {
|
|
32
|
+
response.headers.append("set-cookie", cookie);
|
|
33
|
+
}
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const config = {
|
|
38
|
+
matcher: ["/account/:path*"],
|
|
39
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { NextResponse, type NextRequest } from "next/server";
|
|
2
|
+
import { handleTokenRefresh, type OidcConfig } from "@cimplify/sdk/server";
|
|
3
|
+
|
|
4
|
+
function oidcConfig(): OidcConfig | null {
|
|
5
|
+
const clientId =
|
|
6
|
+
process.env.CIMPLIFY_CLIENT_ID?.trim() ||
|
|
7
|
+
process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID?.trim() ||
|
|
8
|
+
"";
|
|
9
|
+
if (!clientId) return null;
|
|
10
|
+
return {
|
|
11
|
+
clientId,
|
|
12
|
+
issuer: process.env.CIMPLIFY_ISSUER?.trim() || undefined,
|
|
13
|
+
authUrl: process.env.CIMPLIFY_AUTH_URL?.trim() || undefined,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Keeps the access token fresh before account pages render. Server Components
|
|
18
|
+
// can't write cookies, so this is the one place the rotated token can be both
|
|
19
|
+
// persisted (browser) and forwarded onto the current request (this render).
|
|
20
|
+
export async function middleware(request: NextRequest) {
|
|
21
|
+
const cfg = oidcConfig();
|
|
22
|
+
if (!cfg) return NextResponse.next();
|
|
23
|
+
|
|
24
|
+
const { outcome, setCookies, cookies } = await handleTokenRefresh(request, cfg);
|
|
25
|
+
if (outcome === "noop") return NextResponse.next();
|
|
26
|
+
|
|
27
|
+
for (const { name, value } of cookies) {
|
|
28
|
+
request.cookies.set(name, value);
|
|
29
|
+
}
|
|
30
|
+
const response = NextResponse.next({ request });
|
|
31
|
+
for (const cookie of setCookies) {
|
|
32
|
+
response.headers.append("set-cookie", cookie);
|
|
33
|
+
}
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const config = {
|
|
38
|
+
matcher: ["/account/:path*"],
|
|
39
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { NextResponse, type NextRequest } from "next/server";
|
|
2
|
+
import { handleTokenRefresh, type OidcConfig } from "@cimplify/sdk/server";
|
|
3
|
+
|
|
4
|
+
function oidcConfig(): OidcConfig | null {
|
|
5
|
+
const clientId =
|
|
6
|
+
process.env.CIMPLIFY_CLIENT_ID?.trim() ||
|
|
7
|
+
process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID?.trim() ||
|
|
8
|
+
"";
|
|
9
|
+
if (!clientId) return null;
|
|
10
|
+
return {
|
|
11
|
+
clientId,
|
|
12
|
+
issuer: process.env.CIMPLIFY_ISSUER?.trim() || undefined,
|
|
13
|
+
authUrl: process.env.CIMPLIFY_AUTH_URL?.trim() || undefined,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Keeps the access token fresh before account pages render. Server Components
|
|
18
|
+
// can't write cookies, so this is the one place the rotated token can be both
|
|
19
|
+
// persisted (browser) and forwarded onto the current request (this render).
|
|
20
|
+
export async function middleware(request: NextRequest) {
|
|
21
|
+
const cfg = oidcConfig();
|
|
22
|
+
if (!cfg) return NextResponse.next();
|
|
23
|
+
|
|
24
|
+
const { outcome, setCookies, cookies } = await handleTokenRefresh(request, cfg);
|
|
25
|
+
if (outcome === "noop") return NextResponse.next();
|
|
26
|
+
|
|
27
|
+
for (const { name, value } of cookies) {
|
|
28
|
+
request.cookies.set(name, value);
|
|
29
|
+
}
|
|
30
|
+
const response = NextResponse.next({ request });
|
|
31
|
+
for (const cookie of setCookies) {
|
|
32
|
+
response.headers.append("set-cookie", cookie);
|
|
33
|
+
}
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const config = {
|
|
38
|
+
matcher: ["/account/:path*"],
|
|
39
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { NextResponse, type NextRequest } from "next/server";
|
|
2
|
+
import { handleTokenRefresh, type OidcConfig } from "@cimplify/sdk/server";
|
|
3
|
+
|
|
4
|
+
function oidcConfig(): OidcConfig | null {
|
|
5
|
+
const clientId =
|
|
6
|
+
process.env.CIMPLIFY_CLIENT_ID?.trim() ||
|
|
7
|
+
process.env.NEXT_PUBLIC_CIMPLIFY_CLIENT_ID?.trim() ||
|
|
8
|
+
"";
|
|
9
|
+
if (!clientId) return null;
|
|
10
|
+
return {
|
|
11
|
+
clientId,
|
|
12
|
+
issuer: process.env.CIMPLIFY_ISSUER?.trim() || undefined,
|
|
13
|
+
authUrl: process.env.CIMPLIFY_AUTH_URL?.trim() || undefined,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Keeps the access token fresh before account pages render. Server Components
|
|
18
|
+
// can't write cookies, so this is the one place the rotated token can be both
|
|
19
|
+
// persisted (browser) and forwarded onto the current request (this render).
|
|
20
|
+
export async function middleware(request: NextRequest) {
|
|
21
|
+
const cfg = oidcConfig();
|
|
22
|
+
if (!cfg) return NextResponse.next();
|
|
23
|
+
|
|
24
|
+
const { outcome, setCookies, cookies } = await handleTokenRefresh(request, cfg);
|
|
25
|
+
if (outcome === "noop") return NextResponse.next();
|
|
26
|
+
|
|
27
|
+
for (const { name, value } of cookies) {
|
|
28
|
+
request.cookies.set(name, value);
|
|
29
|
+
}
|
|
30
|
+
const response = NextResponse.next({ request });
|
|
31
|
+
for (const cookie of setCookies) {
|
|
32
|
+
response.headers.append("set-cookie", cookie);
|
|
33
|
+
}
|
|
34
|
+
return response;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const config = {
|
|
38
|
+
matcher: ["/account/:path*"],
|
|
39
|
+
};
|