nextjs-cms 0.9.37 → 0.9.38
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/LICENSE +21 -21
- package/README.md +279 -279
- package/dist/api/actions/files.d.ts.map +1 -1
- package/dist/api/actions/pages.d.ts +1 -0
- package/dist/api/actions/pages.d.ts.map +1 -1
- package/dist/api/actions/pages.js +1 -0
- package/dist/api/axios/axiosInstance.d.ts +2 -0
- package/dist/api/axios/axiosInstance.d.ts.map +1 -0
- package/dist/api/axios/axiosInstance.js +8 -0
- package/dist/api/index.d.ts +975 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +13 -0
- package/dist/api/lib/serverActions.d.ts +374 -0
- package/dist/api/lib/serverActions.d.ts.map +1 -0
- package/dist/api/lib/serverActions.js +1445 -0
- package/dist/api/root.d.ts +1917 -0
- package/dist/api/root.d.ts.map +1 -0
- package/dist/api/root.js +115 -0
- package/dist/api/routers/accountSettings.d.ts +66 -0
- package/dist/api/routers/accountSettings.d.ts.map +1 -0
- package/dist/api/routers/accountSettings.js +202 -0
- package/dist/api/routers/admins.d.ts +112 -0
- package/dist/api/routers/admins.d.ts.map +1 -0
- package/dist/api/routers/admins.js +323 -0
- package/dist/api/routers/auth.d.ts +54 -0
- package/dist/api/routers/auth.d.ts.map +1 -0
- package/dist/api/routers/auth.js +50 -0
- package/dist/api/routers/categorySection.d.ts +105 -0
- package/dist/api/routers/categorySection.d.ts.map +1 -0
- package/dist/api/routers/categorySection.js +49 -0
- package/dist/api/routers/config.d.ts +48 -0
- package/dist/api/routers/config.d.ts.map +1 -0
- package/dist/api/routers/config.js +18 -0
- package/dist/api/routers/cpanel.d.ts +82 -0
- package/dist/api/routers/cpanel.d.ts.map +1 -0
- package/dist/api/routers/cpanel.js +216 -0
- package/dist/api/routers/fields.d.ts +35 -0
- package/dist/api/routers/fields.d.ts.map +1 -0
- package/dist/api/routers/fields.js +81 -0
- package/dist/api/routers/files.d.ts +34 -0
- package/dist/api/routers/files.d.ts.map +1 -0
- package/dist/api/routers/files.js +14 -0
- package/dist/api/routers/gallery.d.ts +34 -0
- package/dist/api/routers/gallery.d.ts.map +1 -0
- package/dist/api/routers/gallery.js +64 -0
- package/dist/api/routers/hasItemsSection.d.ts +219 -0
- package/dist/api/routers/hasItemsSection.d.ts.map +1 -0
- package/dist/api/routers/hasItemsSection.js +86 -0
- package/dist/api/routers/logs.d.ts +59 -0
- package/dist/api/routers/logs.d.ts.map +1 -0
- package/dist/api/routers/logs.js +76 -0
- package/dist/api/routers/navigation.d.ts +50 -0
- package/dist/api/routers/navigation.d.ts.map +1 -0
- package/dist/api/routers/navigation.js +11 -0
- package/dist/api/routers/simpleSection.d.ts +105 -0
- package/dist/api/routers/simpleSection.d.ts.map +1 -0
- package/dist/api/routers/simpleSection.js +54 -0
- package/dist/api/trpc/root.d.ts +41 -7
- package/dist/api/trpc/root.d.ts.map +1 -1
- package/dist/api/trpc/routers/config.d.ts.map +1 -1
- package/dist/api/trpc/routers/hasItemsSection.d.ts.map +1 -1
- package/dist/api/trpc/routers/logs.d.ts +37 -4
- package/dist/api/trpc/routers/logs.d.ts.map +1 -1
- package/dist/api/trpc/routers/logs.js +92 -43
- package/dist/api/trpc/routers/navigation.d.ts +1 -0
- package/dist/api/trpc/routers/navigation.d.ts.map +1 -1
- package/dist/api/trpc/routers/simpleSection.d.ts.map +1 -1
- package/dist/api/trpc/server.d.ts +123 -21
- package/dist/api/trpc/server.d.ts.map +1 -1
- package/dist/api/trpc.d.ts +111 -0
- package/dist/api/trpc.d.ts.map +1 -0
- package/dist/api/trpc.js +99 -0
- package/dist/auth/axios/axiosInstance.d.ts +2 -0
- package/dist/auth/axios/axiosInstance.d.ts.map +1 -0
- package/dist/auth/axios/axiosInstance.js +8 -0
- package/dist/auth/hooks/useAxiosPrivate.d.ts +5 -0
- package/dist/auth/hooks/useAxiosPrivate.d.ts.map +1 -0
- package/dist/auth/hooks/useAxiosPrivate.js +74 -0
- package/dist/auth/trpc.d.ts +6 -0
- package/dist/auth/trpc.d.ts.map +1 -0
- package/dist/auth/trpc.js +82 -0
- package/dist/cli/lib/db-config.js +10 -10
- package/dist/cli/lib/update-sections.js +24 -24
- package/dist/core/config/config-loader.d.ts +2 -2
- package/dist/core/db/table-checker/MysqlTable.js +10 -10
- package/dist/core/factories/section-factory-with-esbuild.js +9 -9
- package/dist/core/factories/section-factory-with-jiti.js +9 -9
- package/dist/core/fields/dateRange.d.ts +115 -0
- package/dist/core/fields/dateRange.d.ts.map +1 -0
- package/dist/core/fields/dateRange.js +149 -0
- package/dist/logging/event-labels.d.ts +11 -0
- package/dist/logging/event-labels.d.ts.map +1 -0
- package/dist/logging/event-labels.js +14 -0
- package/dist/logging/log.d.ts +1 -1
- package/dist/logging/log.d.ts.map +1 -1
- package/dist/translations/base/en.d.ts +33 -0
- package/dist/translations/base/en.d.ts.map +1 -1
- package/dist/translations/base/en.js +33 -0
- package/dist/translations/client.d.ts +400 -4
- package/dist/translations/client.d.ts.map +1 -1
- package/dist/translations/locale-cookie.d.ts +24 -0
- package/dist/translations/locale-cookie.d.ts.map +1 -0
- package/dist/translations/locale-cookie.js +44 -0
- package/dist/translations/locale-utils.d.ts +8 -0
- package/dist/translations/locale-utils.d.ts.map +1 -0
- package/dist/translations/locale-utils.js +11 -0
- package/dist/translations/localization.d.ts +40 -0
- package/dist/translations/localization.d.ts.map +1 -0
- package/dist/translations/localization.js +48 -0
- package/dist/translations/server.d.ts +400 -4
- package/dist/translations/server.d.ts.map +1 -1
- package/dist/validators/dateRange.d.ts +11 -0
- package/dist/validators/dateRange.d.ts.map +1 -0
- package/dist/validators/dateRange.js +16 -0
- package/package.json +6 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/api/trpc/server.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAtFj2B,OAAO,CAAC,SAAS,CAAC;EAqFvD"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import superjson from 'superjson';
|
|
2
|
+
/**
|
|
3
|
+
* Creates context for an incoming request
|
|
4
|
+
* @link https://trpc.io/docs/v11/context
|
|
5
|
+
*/
|
|
6
|
+
export declare const createTRPCContext: (opts: {
|
|
7
|
+
headers: Headers;
|
|
8
|
+
}) => Promise<{
|
|
9
|
+
headers: Headers;
|
|
10
|
+
db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
|
|
11
|
+
$client: import("mysql2/promise").Pool;
|
|
12
|
+
};
|
|
13
|
+
session: import("../index.js").Session | null;
|
|
14
|
+
}>;
|
|
15
|
+
type Context = Awaited<ReturnType<typeof createTRPCContext>>;
|
|
16
|
+
export type TRPCContext = Context;
|
|
17
|
+
export declare const transformer: {
|
|
18
|
+
input: typeof superjson;
|
|
19
|
+
output: typeof superjson;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Create a server-side caller
|
|
23
|
+
* @see https://trpc.io/docs/server/server-side-calls
|
|
24
|
+
*/
|
|
25
|
+
export declare const createCallerFactory: import("@trpc/server").TRPCRouterCallerFactory<{
|
|
26
|
+
ctx: {
|
|
27
|
+
headers: Headers;
|
|
28
|
+
db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
|
|
29
|
+
$client: import("mysql2/promise").Pool;
|
|
30
|
+
};
|
|
31
|
+
session: import("../index.js").Session | null;
|
|
32
|
+
};
|
|
33
|
+
meta: object;
|
|
34
|
+
errorShape: {
|
|
35
|
+
data: {
|
|
36
|
+
zodError: import("zod").ZodFlattenedError<unknown, string> | null;
|
|
37
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
|
|
38
|
+
httpStatus: number;
|
|
39
|
+
path?: string;
|
|
40
|
+
stack?: string;
|
|
41
|
+
};
|
|
42
|
+
message: string;
|
|
43
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
|
|
44
|
+
};
|
|
45
|
+
transformer: true;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* This is how you create new routers and sub-routers in your tRPC API
|
|
49
|
+
* @see https://trpc.io/docs/router
|
|
50
|
+
*/
|
|
51
|
+
export declare const router: import("@trpc/server").TRPCRouterBuilder<{
|
|
52
|
+
ctx: {
|
|
53
|
+
headers: Headers;
|
|
54
|
+
db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
|
|
55
|
+
$client: import("mysql2/promise").Pool;
|
|
56
|
+
};
|
|
57
|
+
session: import("../index.js").Session | null;
|
|
58
|
+
};
|
|
59
|
+
meta: object;
|
|
60
|
+
errorShape: {
|
|
61
|
+
data: {
|
|
62
|
+
zodError: import("zod").ZodFlattenedError<unknown, string> | null;
|
|
63
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_KEY;
|
|
64
|
+
httpStatus: number;
|
|
65
|
+
path?: string;
|
|
66
|
+
stack?: string;
|
|
67
|
+
};
|
|
68
|
+
message: string;
|
|
69
|
+
code: import("@trpc/server").TRPC_ERROR_CODE_NUMBER;
|
|
70
|
+
};
|
|
71
|
+
transformer: true;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Public procedure that doesn't require authentication
|
|
75
|
+
*/
|
|
76
|
+
export declare const publicProcedure: import("@trpc/server").TRPCProcedureBuilder<{
|
|
77
|
+
headers: Headers;
|
|
78
|
+
db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
|
|
79
|
+
$client: import("mysql2/promise").Pool;
|
|
80
|
+
};
|
|
81
|
+
session: import("../index.js").Session | null;
|
|
82
|
+
}, object, object, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, false>;
|
|
83
|
+
/**
|
|
84
|
+
* Private procedure that uses the `isAuthedMiddleware` middleware to require authentication
|
|
85
|
+
* @see https://trpc.io/docs/procedures
|
|
86
|
+
*/
|
|
87
|
+
export declare const privateProcedure: import("@trpc/server").TRPCProcedureBuilder<{
|
|
88
|
+
headers: Headers;
|
|
89
|
+
db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
|
|
90
|
+
$client: import("mysql2/promise").Pool;
|
|
91
|
+
};
|
|
92
|
+
session: import("../index.js").Session | null;
|
|
93
|
+
}, object, {
|
|
94
|
+
session: {
|
|
95
|
+
user: import("../index.js").User;
|
|
96
|
+
};
|
|
97
|
+
}, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, false>;
|
|
98
|
+
type PrivilegeOperation = 'C' | 'U' | 'D';
|
|
99
|
+
export declare const pluginProcedure: (sectionName: string, requiredRole?: PrivilegeOperation) => import("@trpc/server").TRPCProcedureBuilder<{
|
|
100
|
+
headers: Headers;
|
|
101
|
+
db: import("drizzle-orm/mysql2").MySql2Database<typeof import("../db/schema.js")> & {
|
|
102
|
+
$client: import("mysql2/promise").Pool;
|
|
103
|
+
};
|
|
104
|
+
session: import("../index.js").Session | null;
|
|
105
|
+
}, object, {
|
|
106
|
+
session: {
|
|
107
|
+
user: import("../index.js").User;
|
|
108
|
+
};
|
|
109
|
+
}, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, import("@trpc/server").TRPCUnsetMarker, false>;
|
|
110
|
+
export {};
|
|
111
|
+
//# sourceMappingURL=trpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trpc.d.ts","sourceRoot":"","sources":["../../src/api/trpc.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAA;AASjC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAU,MAAM;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE;aAAT,OAAO;;;;;EAQ/D,CAAA;AAED,KAAK,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAA;AAC5D,MAAM,MAAM,WAAW,GAAG,OAAO,CAAA;AAEjC,eAAO,MAAM,WAAW;;;CAGvB,CAAA;AAkBD;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;iBAtCyB,OAAO;;;;;;;;;;;;;;;;;;;EAsCR,CAAA;AAiBxD;;;GAGG;AACH,eAAO,MAAM,MAAM;;iBA3DsC,OAAO;;;;;;;;;;;;;;;;;;;EA2DlC,CAAA;AAE9B;;GAEG;AACH,eAAO,MAAM,eAAe;aAhE6B,OAAO;;;;;yLAgEtB,CAAA;AAE1C;;;GAGG;AACH,eAAO,MAAM,gBAAgB;aAtE4B,OAAO;;;;;;;;;yKAsEG,CAAA;AAEnE,KAAK,kBAAkB,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAoCzC,eAAO,MAAM,eAAe,GAAI,aAAa,MAAM,EAAE,eAAe,kBAAkB;aA5G7B,OAAO;;;;;;;;;yKA6GO,CAAA"}
|
package/dist/api/trpc.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { initTRPC, TRPCError } from '@trpc/server';
|
|
2
|
+
import superjson from 'superjson';
|
|
3
|
+
import { ZodError } from 'zod';
|
|
4
|
+
import auth from '../auth/index.js';
|
|
5
|
+
import { db } from '../db/client.js';
|
|
6
|
+
import { and, eq } from 'drizzle-orm';
|
|
7
|
+
import { AdminPrivilegesTable } from '../db/schema.js';
|
|
8
|
+
import getString from '../translations/index.js';
|
|
9
|
+
import { isDashboardOverridePlugin } from '../plugins/loader.js';
|
|
10
|
+
/**
|
|
11
|
+
* Creates context for an incoming request
|
|
12
|
+
* @link https://trpc.io/docs/v11/context
|
|
13
|
+
*/
|
|
14
|
+
export const createTRPCContext = async (opts) => {
|
|
15
|
+
const session = await auth();
|
|
16
|
+
return {
|
|
17
|
+
db,
|
|
18
|
+
session,
|
|
19
|
+
...opts,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export const transformer = {
|
|
23
|
+
input: superjson,
|
|
24
|
+
output: superjson,
|
|
25
|
+
};
|
|
26
|
+
const t = initTRPC.context().create({
|
|
27
|
+
transformer: transformer,
|
|
28
|
+
errorFormatter({ shape, error }) {
|
|
29
|
+
return {
|
|
30
|
+
...shape,
|
|
31
|
+
data: {
|
|
32
|
+
...shape.data,
|
|
33
|
+
zodError: error.cause instanceof ZodError ? error.cause.flatten() : null,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
/*errorFormatter({ shape }) {
|
|
38
|
+
return shape
|
|
39
|
+
},*/
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Create a server-side caller
|
|
43
|
+
* @see https://trpc.io/docs/server/server-side-calls
|
|
44
|
+
*/
|
|
45
|
+
export const createCallerFactory = t.createCallerFactory;
|
|
46
|
+
const isAuthedMiddleware = t.middleware(async ({ ctx, next }) => {
|
|
47
|
+
if (!ctx.session || !ctx.session.user)
|
|
48
|
+
throw new TRPCError({ code: 'UNAUTHORIZED', message: getString('noTokenProvided', 'en') });
|
|
49
|
+
return next({
|
|
50
|
+
/*ctx: {
|
|
51
|
+
user: user,
|
|
52
|
+
headers: ctx.opts.headers,
|
|
53
|
+
},*/
|
|
54
|
+
ctx: {
|
|
55
|
+
// infers the `session` as non-nullable
|
|
56
|
+
session: { ...ctx.session, user: ctx.session.user },
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* This is how you create new routers and sub-routers in your tRPC API
|
|
62
|
+
* @see https://trpc.io/docs/router
|
|
63
|
+
*/
|
|
64
|
+
export const router = t.router;
|
|
65
|
+
/**
|
|
66
|
+
* Public procedure that doesn't require authentication
|
|
67
|
+
*/
|
|
68
|
+
export const publicProcedure = t.procedure;
|
|
69
|
+
/**
|
|
70
|
+
* Private procedure that uses the `isAuthedMiddleware` middleware to require authentication
|
|
71
|
+
* @see https://trpc.io/docs/procedures
|
|
72
|
+
*/
|
|
73
|
+
export const privateProcedure = t.procedure.use(isAuthedMiddleware);
|
|
74
|
+
const accessControlMiddleware = (sectionName, requiredRole) => isAuthedMiddleware.unstable_pipe(async ({ ctx, next }) => {
|
|
75
|
+
// Bypass privilege check for dashboard override plugin
|
|
76
|
+
if (await isDashboardOverridePlugin(sectionName)) {
|
|
77
|
+
return next();
|
|
78
|
+
}
|
|
79
|
+
const privilege = await db
|
|
80
|
+
.select()
|
|
81
|
+
.from(AdminPrivilegesTable)
|
|
82
|
+
.where(and(eq(AdminPrivilegesTable.adminId, ctx.session.user.id), eq(AdminPrivilegesTable.sectionName, sectionName)))
|
|
83
|
+
.limit(1);
|
|
84
|
+
const allowed = privilege[0];
|
|
85
|
+
if (!allowed) {
|
|
86
|
+
throw new TRPCError({
|
|
87
|
+
code: 'NOT_FOUND',
|
|
88
|
+
message: getString('sectionNotFound', ctx.session.user.language),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (requiredRole && !allowed.operations.includes(requiredRole)) {
|
|
92
|
+
throw new TRPCError({
|
|
93
|
+
code: 'NOT_FOUND',
|
|
94
|
+
message: getString('noAccessToThisOperation', ctx.session.user.language),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return next();
|
|
98
|
+
});
|
|
99
|
+
export const pluginProcedure = (sectionName, requiredRole) => t.procedure.use(accessControlMiddleware(sectionName, requiredRole));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axiosInstance.d.ts","sourceRoot":"","sources":["../../../src/auth/axios/axiosInstance.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,+BAMvB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAxiosPrivate.d.ts","sourceRoot":"","sources":["../../../src/auth/hooks/useAxiosPrivate.tsx"],"names":[],"mappings":"AAMA,QAAA,MAAM,eAAe,GAAI,UAAU;IAAE,cAAc,CAAC,EAAE,GAAG,GAAG,GAAG,CAAA;CAAE,kCAgFhE,CAAA;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { axiosPrivate } from '../axios/axiosInstance.js';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import useRefreshToken from './useRefreshToken.js';
|
|
4
|
+
import axios from 'axios';
|
|
5
|
+
import { getCsrfToken } from '../react.js';
|
|
6
|
+
const useAxiosPrivate = (options) => {
|
|
7
|
+
const refresh = useRefreshToken();
|
|
8
|
+
const { refreshTokenOn = 401 } = options || {};
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
/**
|
|
11
|
+
* Add a request interceptor
|
|
12
|
+
*/
|
|
13
|
+
const requestIntercept = axiosPrivate.interceptors.request.use(
|
|
14
|
+
/**
|
|
15
|
+
* Do something before request is sent
|
|
16
|
+
* @param config The request config object
|
|
17
|
+
*/
|
|
18
|
+
async (config) => {
|
|
19
|
+
if (config.method && ['post', 'put', 'delete'].includes(config.method.toLowerCase())) {
|
|
20
|
+
/**
|
|
21
|
+
* If the request is a POST, PUT, or DELETE request, the XSRF-TOKEN header is added to the request.
|
|
22
|
+
*/
|
|
23
|
+
config.headers['x-csrf-token'] = await getCsrfToken();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Return the config object
|
|
27
|
+
*/
|
|
28
|
+
return config;
|
|
29
|
+
}, (error) => Promise.reject(error));
|
|
30
|
+
/**
|
|
31
|
+
* This is the response interceptor
|
|
32
|
+
*/
|
|
33
|
+
const responseIntercept = axiosPrivate.interceptors.response.use((response) => response, // Do nothing if the request is successful,
|
|
34
|
+
async (error) => {
|
|
35
|
+
// If the access token has expired, refresh it and retry the request
|
|
36
|
+
const prevRequest = error?.config; // The request that caused the error (the one that returned 401) is saved in the error object
|
|
37
|
+
if (error?.response?.status === refreshTokenOn && !prevRequest?.sent) {
|
|
38
|
+
// If the error is 401 and the request hasn't been sent before
|
|
39
|
+
prevRequest.sent = true; // Prevent infinite loops
|
|
40
|
+
const refreshStatus = await refresh(); // Refresh the access token cookie
|
|
41
|
+
if (refreshStatus === false)
|
|
42
|
+
return Promise.reject(error); // If the refresh failed, reject the promise
|
|
43
|
+
// NOTICE: This is needed to send the request as multipart form data,
|
|
44
|
+
// because resending the request with axios resets the Content-Type to application/json for some reason
|
|
45
|
+
// Use transformRequest to set Content-Type and include boundary for multipart form data
|
|
46
|
+
prevRequest.headers['Content-Type'] = 'multipart/form-data';
|
|
47
|
+
prevRequest.transformRequest = [
|
|
48
|
+
(data, headers) => {
|
|
49
|
+
// If the request data is FormData, set the boundary
|
|
50
|
+
if (data instanceof FormData) {
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
headers['Content-Type'] += `; boundary=${data._boundary}`;
|
|
53
|
+
}
|
|
54
|
+
return data;
|
|
55
|
+
},
|
|
56
|
+
...axios.defaults.transformRequest, // Keep the default transformRequest functions
|
|
57
|
+
];
|
|
58
|
+
return axiosPrivate(prevRequest); // The request that returned 401 is retried with the new access token
|
|
59
|
+
}
|
|
60
|
+
return Promise.reject(error);
|
|
61
|
+
});
|
|
62
|
+
// Remove the interceptors when the component unmounts
|
|
63
|
+
// This is needed to prevent memory leaks
|
|
64
|
+
return () => {
|
|
65
|
+
// Eject the interceptors
|
|
66
|
+
axiosPrivate.interceptors.request.eject(requestIntercept);
|
|
67
|
+
axiosPrivate.interceptors.response.eject(responseIntercept);
|
|
68
|
+
};
|
|
69
|
+
}, [
|
|
70
|
+
/*auth, refresh*/
|
|
71
|
+
]);
|
|
72
|
+
return axiosPrivate;
|
|
73
|
+
};
|
|
74
|
+
export default useAxiosPrivate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trpc.d.ts","sourceRoot":"","sources":["../../src/auth/trpc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAM5C;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAO,QAAQ,CAAC,aAAa,CAAC,GAAG,CA6E7D,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { observable } from '@trpc/server/observable';
|
|
2
|
+
// import type { AppRouter } from '../api'
|
|
3
|
+
import { logout, refreshSession } from './react.js';
|
|
4
|
+
/**
|
|
5
|
+
* tRPC link that refreshes the token if it's expired
|
|
6
|
+
*/
|
|
7
|
+
export const refreshTokenLink = () => {
|
|
8
|
+
/**
|
|
9
|
+
* Add a lock state to prevent multiple refreshes at the same time
|
|
10
|
+
*/
|
|
11
|
+
let isRefreshing = false;
|
|
12
|
+
let refreshPromise = null;
|
|
13
|
+
return () => {
|
|
14
|
+
return ({ next, op }) => {
|
|
15
|
+
return observable((observer) => {
|
|
16
|
+
let next$ = null;
|
|
17
|
+
let shouldRetry = true; // Flag to control the retry
|
|
18
|
+
function attempt() {
|
|
19
|
+
next$?.unsubscribe();
|
|
20
|
+
next$ = next(op).subscribe({
|
|
21
|
+
async error(err) {
|
|
22
|
+
if (err.data?.code === 'UNAUTHORIZED' && shouldRetry) {
|
|
23
|
+
if (!isRefreshing) {
|
|
24
|
+
isRefreshing = true;
|
|
25
|
+
refreshPromise = (async () => {
|
|
26
|
+
try {
|
|
27
|
+
const response = await fetch('/api/auth/refresh');
|
|
28
|
+
const data = await response.json();
|
|
29
|
+
if (response.status !== 200) {
|
|
30
|
+
await logout({
|
|
31
|
+
/**
|
|
32
|
+
* No need to delete the cookies, because they are both invalid.
|
|
33
|
+
*/
|
|
34
|
+
deleteCookies: false,
|
|
35
|
+
});
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
await refreshSession(data.session);
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
await logout({
|
|
42
|
+
/**
|
|
43
|
+
* No need to delete the cookies, because they are both invalid.
|
|
44
|
+
*/
|
|
45
|
+
deleteCookies: false,
|
|
46
|
+
});
|
|
47
|
+
throw e;
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
isRefreshing = false;
|
|
51
|
+
refreshPromise = null;
|
|
52
|
+
}
|
|
53
|
+
})();
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
await refreshPromise;
|
|
57
|
+
shouldRetry = false;
|
|
58
|
+
attempt();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
// Don't throw under-the-hood refresh flow's errors
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
observer.error(err);
|
|
66
|
+
},
|
|
67
|
+
next(value) {
|
|
68
|
+
observer.next(value);
|
|
69
|
+
},
|
|
70
|
+
complete() {
|
|
71
|
+
observer.complete();
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
attempt();
|
|
76
|
+
return () => {
|
|
77
|
+
next$?.unsubscribe();
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
@@ -140,16 +140,16 @@ export async function dbConfigSetup(options) {
|
|
|
140
140
|
/**
|
|
141
141
|
* Prepare new environment variables block
|
|
142
142
|
*/
|
|
143
|
-
const newEnvBlock = `
|
|
144
|
-
|
|
145
|
-
####
|
|
146
|
-
# generated by the init script
|
|
147
|
-
####
|
|
148
|
-
DB_HOST=${dbHost}
|
|
149
|
-
DB_PORT=${dbPort}
|
|
150
|
-
DB_NAME=${dbName}
|
|
151
|
-
DB_USER=${dbUser}
|
|
152
|
-
DB_PASSWORD='${dbPassword}'
|
|
143
|
+
const newEnvBlock = `
|
|
144
|
+
|
|
145
|
+
####
|
|
146
|
+
# generated by the init script
|
|
147
|
+
####
|
|
148
|
+
DB_HOST=${dbHost}
|
|
149
|
+
DB_PORT=${dbPort}
|
|
150
|
+
DB_NAME=${dbName}
|
|
151
|
+
DB_USER=${dbUser}
|
|
152
|
+
DB_PASSWORD='${dbPassword}'
|
|
153
153
|
`;
|
|
154
154
|
/**
|
|
155
155
|
* Append the new credentials to the .env file
|
|
@@ -508,17 +508,17 @@ function buildLocaleFieldConfig() {
|
|
|
508
508
|
});
|
|
509
509
|
}
|
|
510
510
|
async function createEditorPhotosTable(localized) {
|
|
511
|
-
await db.execute(sql `
|
|
512
|
-
CREATE TABLE IF NOT EXISTS \`editor_photos\` (
|
|
513
|
-
\`photo\` VARCHAR(100) NOT NULL PRIMARY KEY,
|
|
514
|
-
\`section\` VARCHAR(100) NOT NULL,
|
|
515
|
-
\`item_id\` VARCHAR(50) NOT NULL,
|
|
516
|
-
\`field\` VARCHAR(100) NOT NULL,
|
|
517
|
-
\`meta\` LONGTEXT,
|
|
518
|
-
${localized ? sql `\`locale\` VARCHAR(10) NOT NULL,` : sql ``}
|
|
519
|
-
\`linked\` BOOLEAN DEFAULT false,
|
|
520
|
-
\`created_at\` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
521
|
-
)
|
|
511
|
+
await db.execute(sql `
|
|
512
|
+
CREATE TABLE IF NOT EXISTS \`editor_photos\` (
|
|
513
|
+
\`photo\` VARCHAR(100) NOT NULL PRIMARY KEY,
|
|
514
|
+
\`section\` VARCHAR(100) NOT NULL,
|
|
515
|
+
\`item_id\` VARCHAR(50) NOT NULL,
|
|
516
|
+
\`field\` VARCHAR(100) NOT NULL,
|
|
517
|
+
\`meta\` LONGTEXT,
|
|
518
|
+
${localized ? sql `\`locale\` VARCHAR(10) NOT NULL,` : sql ``}
|
|
519
|
+
\`linked\` BOOLEAN DEFAULT false,
|
|
520
|
+
\`created_at\` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
521
|
+
)
|
|
522
522
|
`);
|
|
523
523
|
}
|
|
524
524
|
async function ensureEditorPhotosLocaleColumn(defaultLocaleCode, knownColumns) {
|
|
@@ -1134,24 +1134,24 @@ const main = async (spinnerObject) => {
|
|
|
1134
1134
|
* Let's see if the table `__nextjs_cms_tables` exists in the database.
|
|
1135
1135
|
* If it doesn't, we'll create it using the same schema as `NextJsCmsTablesTable`.
|
|
1136
1136
|
*/
|
|
1137
|
-
await db.execute(sql `
|
|
1138
|
-
CREATE TABLE IF NOT EXISTS __nextjs_cms_tables (
|
|
1139
|
-
name VARCHAR(100) NOT NULL PRIMARY KEY,
|
|
1140
|
-
section VARCHAR(200),
|
|
1141
|
-
config LONGTEXT,
|
|
1142
|
-
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
1143
|
-
)
|
|
1137
|
+
await db.execute(sql `
|
|
1138
|
+
CREATE TABLE IF NOT EXISTS __nextjs_cms_tables (
|
|
1139
|
+
name VARCHAR(100) NOT NULL PRIMARY KEY,
|
|
1140
|
+
section VARCHAR(200),
|
|
1141
|
+
config LONGTEXT,
|
|
1142
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
1143
|
+
)
|
|
1144
1144
|
`);
|
|
1145
1145
|
await ensureTableRegistryConfigColumn();
|
|
1146
1146
|
/**
|
|
1147
1147
|
* Persistent key/value store for CMS-level state that must survive config removal.
|
|
1148
1148
|
*/
|
|
1149
|
-
await db.execute(sql `
|
|
1150
|
-
CREATE TABLE IF NOT EXISTS __nextjs_cms_config (
|
|
1151
|
-
\`key\` VARCHAR(100) NOT NULL PRIMARY KEY,
|
|
1152
|
-
\`value\` LONGTEXT,
|
|
1153
|
-
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
1154
|
-
)
|
|
1149
|
+
await db.execute(sql `
|
|
1150
|
+
CREATE TABLE IF NOT EXISTS __nextjs_cms_config (
|
|
1151
|
+
\`key\` VARCHAR(100) NOT NULL PRIMARY KEY,
|
|
1152
|
+
\`value\` LONGTEXT,
|
|
1153
|
+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
1154
|
+
)
|
|
1155
1155
|
`);
|
|
1156
1156
|
await db.execute(sql `ALTER TABLE \`__nextjs_cms_config\` MODIFY COLUMN \`value\` LONGTEXT`);
|
|
1157
1157
|
/**
|