@payloadcms/next 3.31.0-canary.0 → 3.31.0-internal.f644499
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/utilities/getSafeRedirect.d.ts +2 -0
- package/dist/utilities/getSafeRedirect.d.ts.map +1 -0
- package/dist/utilities/getSafeRedirect.js +18 -0
- package/dist/utilities/getSafeRedirect.js.map +1 -0
- package/dist/views/Login/LoginForm/index.d.ts.map +1 -1
- package/dist/views/Login/LoginForm/index.js +5 -13
- package/dist/views/Login/LoginForm/index.js.map +1 -1
- package/dist/views/Login/index.d.ts.map +1 -1
- package/dist/views/Login/index.js +2 -3
- package/dist/views/Login/index.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSafeRedirect.d.ts","sourceRoot":"","sources":["../../src/utilities/getSafeRedirect.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,kBACX,MAAM,GAAG,MAAM,EAAE,aACtB,MAAM,KACf,MAmBF,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const getSafeRedirect = (redirectParam, fallback = '/') => {
|
|
2
|
+
if (typeof redirectParam !== 'string') {
|
|
3
|
+
return fallback;
|
|
4
|
+
}
|
|
5
|
+
// Ensures that any leading or trailing whitespace doesn’t affect the checks
|
|
6
|
+
const redirectPath = redirectParam.trim();
|
|
7
|
+
const isSafeRedirect =
|
|
8
|
+
// Must start with a single forward slash (e.g., "/admin")
|
|
9
|
+
redirectPath.startsWith('/') &&
|
|
10
|
+
// Prevent protocol-relative URLs (e.g., "//evil.com")
|
|
11
|
+
!redirectPath.startsWith('//') &&
|
|
12
|
+
// Prevent javascript-based schemes (e.g., "/javascript:alert(1)")
|
|
13
|
+
!redirectPath.toLowerCase().startsWith('/javascript:') &&
|
|
14
|
+
// Prevent attempts to redirect to full URLs using "/http:" or "/https:"
|
|
15
|
+
!redirectPath.toLowerCase().startsWith('/http');
|
|
16
|
+
return isSafeRedirect ? redirectPath : fallback;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=getSafeRedirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getSafeRedirect.js","names":["getSafeRedirect","redirectParam","fallback","redirectPath","trim","isSafeRedirect","startsWith","toLowerCase"],"sources":["../../src/utilities/getSafeRedirect.ts"],"sourcesContent":["export const getSafeRedirect = (\n redirectParam: string | string[],\n fallback: string = '/',\n): string => {\n if (typeof redirectParam !== 'string') {\n return fallback\n }\n\n // Ensures that any leading or trailing whitespace doesn’t affect the checks\n const redirectPath = redirectParam.trim()\n\n const isSafeRedirect =\n // Must start with a single forward slash (e.g., \"/admin\")\n redirectPath.startsWith('/') &&\n // Prevent protocol-relative URLs (e.g., \"//evil.com\")\n !redirectPath.startsWith('//') &&\n // Prevent javascript-based schemes (e.g., \"/javascript:alert(1)\")\n !redirectPath.toLowerCase().startsWith('/javascript:') &&\n // Prevent attempts to redirect to full URLs using \"/http:\" or \"/https:\"\n !redirectPath.toLowerCase().startsWith('/http')\n\n return isSafeRedirect ? redirectPath : fallback\n}\n"],"mappings":"AAAA,OAAO,MAAMA,eAAA,GAAkBA,CAC7BC,aAAA,EACAC,QAAA,GAAmB,GAAG;EAEtB,IAAI,OAAOD,aAAA,KAAkB,UAAU;IACrC,OAAOC,QAAA;EACT;EAEA;EACA,MAAMC,YAAA,GAAeF,aAAA,CAAcG,IAAI;EAEvC,MAAMC,cAAA;EACJ;EACAF,YAAA,CAAaG,UAAU,CAAC;EACxB;EACA,CAACH,YAAA,CAAaG,UAAU,CAAC;EACzB;EACA,CAACH,YAAA,CAAaI,WAAW,GAAGD,UAAU,CAAC;EACvC;EACA,CAACH,YAAA,CAAaI,WAAW,GAAGD,UAAU,CAAC;EAEzC,OAAOD,cAAA,GAAiBF,YAAA,GAAeD,QAAA;AACzC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Login/LoginForm/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/Login/LoginForm/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAsBzB,OAAO,cAAc,CAAA;AAErB,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;KAAE,CAAA;CAC/D,CAyFA,CAAA"}
|
|
@@ -6,9 +6,10 @@ import React from 'react';
|
|
|
6
6
|
const baseClass = 'login__form';
|
|
7
7
|
import { Form, FormSubmit, Link, PasswordField, useAuth, useConfig, useTranslation } from '@payloadcms/ui';
|
|
8
8
|
import { formatAdminURL, getLoginOptions } from 'payload/shared';
|
|
9
|
+
import { getSafeRedirect } from '../../../utilities/getSafeRedirect.js';
|
|
9
10
|
import { LoginField } from '../LoginField/index.js';
|
|
10
11
|
export const LoginForm = t0 => {
|
|
11
|
-
const $ = _c(
|
|
12
|
+
const $ = _c(23);
|
|
12
13
|
const {
|
|
13
14
|
prefillEmail,
|
|
14
15
|
prefillPassword,
|
|
@@ -84,7 +85,7 @@ export const LoginForm = t0 => {
|
|
|
84
85
|
const t6 = prefillPassword ?? undefined;
|
|
85
86
|
const t7 = prefillPassword ?? undefined;
|
|
86
87
|
let t8;
|
|
87
|
-
if ($[7] !== adminRoute || $[8] !== apiRoute || $[9] !== forgotRoute || $[10] !== loginType || $[11] !== loginWithUsername || $[12] !== prefillEmail || $[13] !== prefillUsername || $[14] !== searchParams || $[15] !== setUser || $[16] !== t || $[17] !== t6 || $[18] !== t7 || $[19] !== userSlug) {
|
|
88
|
+
if ($[7] !== adminRoute || $[8] !== apiRoute || $[9] !== forgotRoute || $[10] !== loginType || $[11] !== loginWithUsername || $[12] !== prefillEmail || $[13] !== prefillUsername || $[14] !== searchParams?.redirect || $[15] !== setUser || $[16] !== t || $[17] !== t6 || $[18] !== t7 || $[19] !== userSlug) {
|
|
88
89
|
const initialState = {
|
|
89
90
|
password: {
|
|
90
91
|
initialValue: t6,
|
|
@@ -116,15 +117,6 @@ export const LoginForm = t0 => {
|
|
|
116
117
|
t9 = $[22];
|
|
117
118
|
}
|
|
118
119
|
const handleLogin = t9;
|
|
119
|
-
let t10;
|
|
120
|
-
if ($[23] !== adminRoute || $[24] !== searchParams) {
|
|
121
|
-
t10 = typeof searchParams?.redirect === "string" ? searchParams.redirect.startsWith("/") ? searchParams.redirect : encodeURIComponent(searchParams.redirect) : adminRoute;
|
|
122
|
-
$[23] = adminRoute;
|
|
123
|
-
$[24] = searchParams;
|
|
124
|
-
$[25] = t10;
|
|
125
|
-
} else {
|
|
126
|
-
t10 = $[25];
|
|
127
|
-
}
|
|
128
120
|
t8 = _jsxs(Form, {
|
|
129
121
|
action: `${apiRoute}/${userSlug}/login`,
|
|
130
122
|
className: baseClass,
|
|
@@ -132,7 +124,7 @@ export const LoginForm = t0 => {
|
|
|
132
124
|
initialState,
|
|
133
125
|
method: "POST",
|
|
134
126
|
onSuccess: handleLogin,
|
|
135
|
-
redirect:
|
|
127
|
+
redirect: getSafeRedirect(searchParams?.redirect, adminRoute),
|
|
136
128
|
waitForAutocomplete: true,
|
|
137
129
|
children: [_jsxs("div", {
|
|
138
130
|
className: `${baseClass}__inputWrap`,
|
|
@@ -165,7 +157,7 @@ export const LoginForm = t0 => {
|
|
|
165
157
|
$[11] = loginWithUsername;
|
|
166
158
|
$[12] = prefillEmail;
|
|
167
159
|
$[13] = prefillUsername;
|
|
168
|
-
$[14] = searchParams;
|
|
160
|
+
$[14] = searchParams?.redirect;
|
|
169
161
|
$[15] = setUser;
|
|
170
162
|
$[16] = t;
|
|
171
163
|
$[17] = t6;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","React","baseClass","Form","FormSubmit","Link","PasswordField","useAuth","useConfig","useTranslation","formatAdminURL","getLoginOptions","LoginField","LoginForm","t0","$","prefillEmail","prefillPassword","prefillUsername","searchParams","config","getEntityConfig","admin","t1","routes","t2","t3","user","userSlug","forgot","forgotRoute","adminRoute","api","apiRoute","loginWithUsername","t4","collectionConfig","collectionSlug","auth","authOptions","canLoginWithEmail","canLoginWithUsername","t5","loginType","useState","t","setUser","t6","undefined","t7","t8","initialState","password","initialValue","valid","value","username","email","t9","data","handleLogin","
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","React","baseClass","Form","FormSubmit","Link","PasswordField","useAuth","useConfig","useTranslation","formatAdminURL","getLoginOptions","getSafeRedirect","LoginField","LoginForm","t0","$","prefillEmail","prefillPassword","prefillUsername","searchParams","config","getEntityConfig","admin","t1","routes","t2","t3","user","userSlug","forgot","forgotRoute","adminRoute","api","apiRoute","loginWithUsername","t4","collectionConfig","collectionSlug","auth","authOptions","canLoginWithEmail","canLoginWithUsername","t5","loginType","useState","t","setUser","t6","undefined","t7","t8","redirect","initialState","password","initialValue","valid","value","username","email","t9","data","handleLogin","_jsxs","action","className","disableSuccessStatus","method","onSuccess","waitForAutocomplete","children","_jsx","type","field","name","label","required","path","href","prefetch","size"],"sources":["../../../../src/views/Login/LoginForm/index.tsx"],"sourcesContent":["'use client'\n\nimport React from 'react'\n\nconst baseClass = 'login__form'\n\nimport type { UserWithToken } from '@payloadcms/ui'\nimport type { FormState } from 'payload'\n\nimport {\n Form,\n FormSubmit,\n Link,\n PasswordField,\n useAuth,\n useConfig,\n useTranslation,\n} from '@payloadcms/ui'\nimport { formatAdminURL, getLoginOptions } from 'payload/shared'\n\nimport type { LoginFieldProps } from '../LoginField/index.js'\n\nimport { getSafeRedirect } from '../../../utilities/getSafeRedirect.js'\nimport { LoginField } from '../LoginField/index.js'\nimport './index.scss'\n\nexport const LoginForm: React.FC<{\n prefillEmail?: string\n prefillPassword?: string\n prefillUsername?: string\n searchParams: { [key: string]: string | string[] | undefined }\n}> = ({ prefillEmail, prefillPassword, prefillUsername, searchParams }) => {\n const { config, getEntityConfig } = useConfig()\n\n const {\n admin: {\n routes: { forgot: forgotRoute },\n user: userSlug,\n },\n routes: { admin: adminRoute, api: apiRoute },\n } = config\n\n const collectionConfig = getEntityConfig({ collectionSlug: userSlug })\n const { auth: authOptions } = collectionConfig\n const loginWithUsername = authOptions.loginWithUsername\n const { canLoginWithEmail, canLoginWithUsername } = getLoginOptions(loginWithUsername)\n\n const [loginType] = React.useState<LoginFieldProps['type']>(() => {\n if (canLoginWithEmail && canLoginWithUsername) {\n return 'emailOrUsername'\n }\n if (canLoginWithUsername) {\n return 'username'\n }\n return 'email'\n })\n\n const { t } = useTranslation()\n const { setUser } = useAuth()\n\n const initialState: FormState = {\n password: {\n initialValue: prefillPassword ?? undefined,\n valid: true,\n value: prefillPassword ?? undefined,\n },\n }\n\n if (loginWithUsername) {\n initialState.username = {\n initialValue: prefillUsername ?? undefined,\n valid: true,\n value: prefillUsername ?? undefined,\n }\n } else {\n initialState.email = {\n initialValue: prefillEmail ?? undefined,\n valid: true,\n value: prefillEmail ?? undefined,\n }\n }\n\n const handleLogin = (data: UserWithToken) => {\n setUser(data)\n }\n\n return (\n <Form\n action={`${apiRoute}/${userSlug}/login`}\n className={baseClass}\n disableSuccessStatus\n initialState={initialState}\n method=\"POST\"\n onSuccess={handleLogin}\n redirect={getSafeRedirect(searchParams?.redirect, adminRoute)}\n waitForAutocomplete\n >\n <div className={`${baseClass}__inputWrap`}>\n <LoginField type={loginType} />\n <PasswordField\n field={{\n name: 'password',\n label: t('general:password'),\n required: true,\n }}\n path=\"password\"\n />\n </div>\n <Link\n href={formatAdminURL({\n adminRoute,\n path: forgotRoute,\n })}\n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EE9C;QAAA,CACR;QAAAgD,QAAA;QAAAT,QAAA,EAGCxB,CAAA,CAAE;MAAA,C,GAELyB,IAAA,CAAAnE,UAAA;QAAA4E,IAAA,EAAiB;QAAAV,QAAA,EAASxB,CAAA,CAAE;MAAA,C;;;;;;;;;;;;;;;;;;;SA9B9BK,E;CAiCJ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Login/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAe,MAAM,SAAS,CAAA;AAIhE,OAAO,KAAmB,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/Login/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAe,MAAM,SAAS,CAAA;AAIhE,OAAO,KAAmB,MAAM,OAAO,CAAA;AAKvC,OAAO,cAAc,CAAA;AACrB,eAAO,MAAM,cAAc,UAAU,CAAA;AAErC,wBAAgB,SAAS,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,oBAAoB,qBA0FvF"}
|
|
@@ -3,6 +3,7 @@ import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerCompo
|
|
|
3
3
|
import { redirect } from 'next/navigation.js';
|
|
4
4
|
import React, { Fragment } from 'react';
|
|
5
5
|
import { Logo } from '../../elements/Logo/index.js';
|
|
6
|
+
import { getSafeRedirect } from '../../utilities/getSafeRedirect.js';
|
|
6
7
|
import { LoginForm } from './LoginForm/index.js';
|
|
7
8
|
export const loginBaseClass = 'login';
|
|
8
9
|
export function LoginView({
|
|
@@ -35,9 +36,7 @@ export function LoginView({
|
|
|
35
36
|
admin
|
|
36
37
|
}
|
|
37
38
|
} = config;
|
|
38
|
-
const redirectUrl =
|
|
39
|
-
? searchParams.redirect : encodeURIComponent(searchParams.redirect) // Otherwise, encode it
|
|
40
|
-
: admin;
|
|
39
|
+
const redirectUrl = getSafeRedirect(searchParams.redirect, admin);
|
|
41
40
|
if (user) {
|
|
42
41
|
redirect(redirectUrl);
|
|
43
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["RenderServerComponent","redirect","React","Fragment","Logo","LoginForm","loginBaseClass","LoginView","initPageResult","params","searchParams","locale","permissions","req","i18n","payload","config","user","admin","components","afterLogin","beforeLogin","userSlug","routes","redirectUrl","
|
|
1
|
+
{"version":3,"file":"index.js","names":["RenderServerComponent","redirect","React","Fragment","Logo","getSafeRedirect","LoginForm","loginBaseClass","LoginView","initPageResult","params","searchParams","locale","permissions","req","i18n","payload","config","user","admin","components","afterLogin","beforeLogin","userSlug","routes","redirectUrl","collectionConfig","collections","prefillAutoLogin","autoLogin","prefillOnly","prefillUsername","username","undefined","prefillEmail","email","prefillPassword","password","_jsxs","_jsx","className","Component","importMap","serverProps","auth","disableLocalStrategy"],"sources":["../../../src/views/Login/index.tsx"],"sourcesContent":["import type { AdminViewServerProps, ServerProps } from 'payload'\n\nimport { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent'\nimport { redirect } from 'next/navigation.js'\nimport React, { Fragment } from 'react'\n\nimport { Logo } from '../../elements/Logo/index.js'\nimport { getSafeRedirect } from '../../utilities/getSafeRedirect.js'\nimport { LoginForm } from './LoginForm/index.js'\nimport './index.scss'\nexport const loginBaseClass = 'login'\n\nexport function LoginView({ initPageResult, params, searchParams }: AdminViewServerProps) {\n const { locale, permissions, req } = initPageResult\n\n const {\n i18n,\n payload: { config },\n payload,\n user,\n } = req\n\n const {\n admin: { components: { afterLogin, beforeLogin } = {}, user: userSlug },\n routes: { admin },\n } = config\n\n const redirectUrl = getSafeRedirect(searchParams.redirect, admin)\n\n if (user) {\n redirect(redirectUrl)\n }\n\n const collectionConfig = payload?.collections?.[userSlug]?.config\n\n const prefillAutoLogin =\n typeof config.admin?.autoLogin === 'object' && config.admin?.autoLogin.prefillOnly\n\n const prefillUsername =\n prefillAutoLogin && typeof config.admin?.autoLogin === 'object'\n ? config.admin?.autoLogin.username\n : undefined\n\n const prefillEmail =\n prefillAutoLogin && typeof config.admin?.autoLogin === 'object'\n ? config.admin?.autoLogin.email\n : undefined\n\n const prefillPassword =\n prefillAutoLogin && typeof config.admin?.autoLogin === 'object'\n ? config.admin?.autoLogin.password\n : undefined\n\n return (\n <Fragment>\n <div className={`${loginBaseClass}__brand`}>\n <Logo\n i18n={i18n}\n locale={locale}\n params={params}\n payload={payload}\n permissions={permissions}\n searchParams={searchParams}\n user={user}\n />\n </div>\n {RenderServerComponent({\n Component: beforeLogin,\n importMap: payload.importMap,\n serverProps: {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n } satisfies ServerProps,\n })}\n {!collectionConfig?.auth?.disableLocalStrategy && (\n <LoginForm\n prefillEmail={prefillEmail}\n prefillPassword={prefillPassword}\n prefillUsername={prefillUsername}\n searchParams={searchParams}\n />\n )}\n {RenderServerComponent({\n Component: afterLogin,\n importMap: payload.importMap,\n serverProps: {\n i18n,\n locale,\n params,\n payload,\n permissions,\n searchParams,\n user,\n } satisfies ServerProps,\n })}\n </Fragment>\n )\n}\n"],"mappings":";AAEA,SAASA,qBAAqB,QAAQ;AACtC,SAASC,QAAQ,QAAQ;AACzB,OAAOC,KAAA,IAASC,QAAQ,QAAQ;AAEhC,SAASC,IAAI,QAAQ;AACrB,SAASC,eAAe,QAAQ;AAChC,SAASC,SAAS,QAAQ;AAE1B,OAAO,MAAMC,cAAA,GAAiB;AAE9B,OAAO,SAASC,UAAU;EAAEC,cAAc;EAAEC,MAAM;EAAEC;AAAY,CAAwB;EACtF,MAAM;IAAEC,MAAM;IAAEC,WAAW;IAAEC;EAAG,CAAE,GAAGL,cAAA;EAErC,MAAM;IACJM,IAAI;IACJC,OAAA,EAAS;MAAEC;IAAM,CAAE;IACnBD,OAAO;IACPE;EAAI,CACL,GAAGJ,GAAA;EAEJ,MAA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AAaA,WAAA;QACbF,YAAA,EAAcA,YAAA;QACdO,IAAA,EAAMA;;QAGTlB,qBAAA,CAAsB;MACrByC,SAAA,EAAWnB,WAAA;MACXoB,SAAA,EAAW1B,OAAA,CAAQ0B,SAAS;MAC5BC,WAAA,EAAa;QACX5B,IAAA;QACAH,MAAA;QACAF,MAAA;QACAM,OAAA;QACAH,WAAA;QACAF,YAAA;QACAO;MACF;IACF,IACC,CAACQ,gBAAA,EAAkBkB,IAAA,EAAMC,oBAAA,iBACxBN,IAAA,CAACjC,SAAA;MACC4B,YAAA,EAAcA,YAAA;MACdE,eAAA,EAAiBA,eAAA;MACjBL,eAAA,EAAiBA,eAAA;MACjBpB,YAAA,EAAcA;QAGjBX,qBAAA,CAAsB;MACrByC,SAAA,EAAWpB,UAAA;MACXqB,SAAA,EAAW1B,OAAA,CAAQ0B,SAAS;MAC5BC,WAAA,EAAa;QACX5B,IAAA;QACAH,MAAA;QACAF,MAAA;QACAM,OAAA;QACAH,WAAA;QACAF,YAAA;QACAO;MACF;IACF;;AAGN","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/next",
|
|
3
|
-
"version": "3.31.0-
|
|
3
|
+
"version": "3.31.0-internal.f644499",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -79,9 +79,9 @@
|
|
|
79
79
|
"react-diff-viewer-continued": "4.0.5",
|
|
80
80
|
"sass": "1.77.4",
|
|
81
81
|
"uuid": "10.0.0",
|
|
82
|
-
"@payloadcms/graphql": "3.31.0-
|
|
83
|
-
"@payloadcms/ui": "3.31.0-
|
|
84
|
-
"@payloadcms/translations": "3.31.0-
|
|
82
|
+
"@payloadcms/graphql": "3.31.0-internal.f644499",
|
|
83
|
+
"@payloadcms/ui": "3.31.0-internal.f644499",
|
|
84
|
+
"@payloadcms/translations": "3.31.0-internal.f644499"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@babel/cli": "7.26.4",
|
|
@@ -100,12 +100,12 @@
|
|
|
100
100
|
"eslint-plugin-react-compiler": "19.0.0-beta-714736e-20250131",
|
|
101
101
|
"swc-plugin-transform-remove-imports": "3.1.0",
|
|
102
102
|
"@payloadcms/eslint-config": "3.28.0",
|
|
103
|
-
"payload": "3.31.0-
|
|
103
|
+
"payload": "3.31.0-internal.f644499"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
106
|
"graphql": "^16.8.1",
|
|
107
107
|
"next": "^15.2.3",
|
|
108
|
-
"payload": "3.31.0-
|
|
108
|
+
"payload": "3.31.0-internal.f644499"
|
|
109
109
|
},
|
|
110
110
|
"engines": {
|
|
111
111
|
"node": "^18.20.2 || >=20.9.0"
|