{t('jwt_claims.jwt_claims_description')}
- {tokenType === JwtTokenType.UserAccessToken && (
+ {tokenType === LogtoJwtTokenPath.AccessToken && (
- tokenType === JwtTokenType.UserAccessToken
+ tokenType === LogtoJwtTokenPath.AccessToken
? userTokenModelSettings
: machineToMachineTokenModelSettings,
[tokenType]
diff --git a/packages/console/src/pages/JwtClaims/config.tsx b/packages/console/src/pages/JwtClaims/config.tsx
index 2cdadc324..da7d1e697 100644
--- a/packages/console/src/pages/JwtClaims/config.tsx
+++ b/packages/console/src/pages/JwtClaims/config.tsx
@@ -5,14 +5,6 @@ import UserFileIcon from '@/assets/icons/user-file-icon.svg';
import type { ModelSettings } from './MonacoCodeEditor/type.js';
-/**
- * JWT token types
- */
-export enum JwtTokenType {
- UserAccessToken = 'user-access-token',
- MachineToMachineAccessToken = 'm2m-access-token',
-}
-
/**
* JWT token code editor configuration
*/
diff --git a/packages/console/src/pages/JwtClaims/index.tsx b/packages/console/src/pages/JwtClaims/index.tsx
index aaaefe6ee..2ebe9c1a2 100644
--- a/packages/console/src/pages/JwtClaims/index.tsx
+++ b/packages/console/src/pages/JwtClaims/index.tsx
@@ -1,4 +1,5 @@
import { withAppInsights } from '@logto/app-insights/react/AppInsightsReact';
+import { LogtoJwtTokenPath } from '@logto/schemas';
import classNames from 'classnames';
import { useMemo } from 'react';
import { useForm, FormProvider } from 'react-hook-form';
@@ -11,21 +12,18 @@ import TabNav, { TabNavItem } from '@/ds-components/TabNav';
import ScriptSection from './ScriptSection';
import SettingsSection from './SettingsSection';
-import { JwtTokenType } from './config';
import * as styles from './index.module.scss';
import { type JwtClaimsFormType } from './type';
-export { JwtTokenType } from './config';
-
const tabPhrases = Object.freeze({
- [JwtTokenType.UserAccessToken]: 'user_jwt_tab',
- [JwtTokenType.MachineToMachineAccessToken]: 'machine_to_machine_jwt_tab',
+ [LogtoJwtTokenPath.AccessToken]: 'user_jwt_tab',
+ [LogtoJwtTokenPath.ClientCredentials]: 'machine_to_machine_jwt_tab',
});
-const getPath = (tab: JwtTokenType) => `/jwt-claims/${tab}`;
+const getPath = (tab: LogtoJwtTokenPath) => `/jwt-claims/${tab}`;
type Props = {
- tab: JwtTokenType;
+ tab: LogtoJwtTokenPath;
};
// TODO: API integration
@@ -34,21 +32,21 @@ function JwtClaims({ tab }: Props) {
const userJwtClaimsForm = useForm({
defaultValues: {
- tokenType: JwtTokenType.UserAccessToken,
+ tokenType: LogtoJwtTokenPath.AccessToken,
environmentVariables: [{ key: '', value: '' }],
},
});
const machineToMachineJwtClaimsForm = useForm({
defaultValues: {
- tokenType: JwtTokenType.MachineToMachineAccessToken,
+ tokenType: LogtoJwtTokenPath.ClientCredentials,
environmentVariables: [{ key: '', value: '' }],
},
});
const activeForm = useMemo(
() =>
- tab === JwtTokenType.UserAccessToken ? userJwtClaimsForm : machineToMachineJwtClaimsForm,
+ tab === LogtoJwtTokenPath.AccessToken ? userJwtClaimsForm : machineToMachineJwtClaimsForm,
[machineToMachineJwtClaimsForm, tab, userJwtClaimsForm]
);
@@ -70,7 +68,7 @@ function JwtClaims({ tab }: Props) {
className={styles.header}
/>
- {Object.values(JwtTokenType).map((tokenType) => (
+ {Object.values(LogtoJwtTokenPath).map((tokenType) => (
{t(`jwt_claims.${tabPhrases[tokenType]}`)}
diff --git a/packages/console/src/pages/JwtClaims/type.ts b/packages/console/src/pages/JwtClaims/type.ts
index 4d633154a..a4f0aa187 100644
--- a/packages/console/src/pages/JwtClaims/type.ts
+++ b/packages/console/src/pages/JwtClaims/type.ts
@@ -1,7 +1,7 @@
-import { type JwtTokenType } from './config.js';
+import type { LogtoJwtTokenPath } from '@logto/schemas';
export type JwtClaimsFormType = {
- tokenType: JwtTokenType;
+ tokenType: LogtoJwtTokenPath;
script?: string;
environmentVariables?: Array<{ key: string; value: string }>;
testSample?: {
diff --git a/packages/core/src/routes/logto-config.ts b/packages/core/src/routes/logto-config.ts
index 335bbc0aa..18c53b635 100644
--- a/packages/core/src/routes/logto-config.ts
+++ b/packages/core/src/routes/logto-config.ts
@@ -15,6 +15,7 @@ import {
jwtCustomizerAccessTokenGuard,
jwtCustomizerClientCredentialsGuard,
LogtoJwtTokenKey,
+ LogtoJwtTokenPath,
} from '@logto/schemas';
import { z } from 'zod';
@@ -24,11 +25,6 @@ import { exportJWK } from '#src/utils/jwks.js';
import type { AuthedRouter, RouterInitArgs } from './types.js';
-enum LogtoJwtTokenPath {
- AccessToken = 'access-token',
- ClientCredentials = 'client-credentials',
-}
-
/**
* Provide a simple API router key type and DB config key mapping
*/
diff --git a/packages/schemas/src/types/jwt-customizer.ts b/packages/schemas/src/types/jwt-customizer.ts
index ea28c2827..6ceaa4c1a 100644
--- a/packages/schemas/src/types/jwt-customizer.ts
+++ b/packages/schemas/src/types/jwt-customizer.ts
@@ -54,3 +54,7 @@ export const customJwtFetcherGuard = jwtCustomizerGuard
token: jsonObjectGuard,
context: jsonObjectGuard.optional(),
});
+export enum LogtoJwtTokenPath {
+ AccessToken = 'access-token',
+ ClientCredentials = 'client-credentials',
+}