0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-27 21:39:16 -05:00

Merge pull request #5617 from logto-io/yemq-log-8449-log-8489-update-enum-type-name-and-field-name

chore(core,console,schemas): update variable name and field name
This commit is contained in:
Darcy Ye 2024-04-03 12:11:13 +08:00 committed by GitHub
commit 8e1713ffa7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 88 additions and 75 deletions

View file

@ -1,11 +1,11 @@
import { type LogtoJwtTokenPath } from '@logto/schemas';
import { type LogtoJwtTokenKeyType } from '@logto/schemas';
import Button from '@/ds-components/Button';
import useTenantPathname from '@/hooks/use-tenant-pathname';
import { getPagePath } from '@/pages/CustomizeJwt/utils/path';
type Props = {
tokenType: LogtoJwtTokenPath;
tokenType: LogtoJwtTokenKeyType;
};
function CreateButton({ tokenType }: Props) {

View file

@ -1,4 +1,4 @@
import { LogtoJwtTokenPath } from '@logto/schemas';
import { LogtoJwtTokenKeyType } from '@logto/schemas';
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
@ -15,7 +15,7 @@ import useJwtCustomizer from '../use-jwt-customizer';
import * as styles from './index.module.scss';
type Props = {
tokenType: LogtoJwtTokenPath;
tokenType: LogtoJwtTokenKeyType;
};
function CustomizerItem({ tokenType }: Props) {
@ -46,7 +46,7 @@ function CustomizerItem({ tokenType }: Props) {
<div className={styles.title}>
{t('jwt_claims.custom_jwt_item', {
for:
tokenType === LogtoJwtTokenPath.AccessToken
tokenType === LogtoJwtTokenKeyType.AccessToken
? t('jwt_claims.user_jwt.for')
: t('jwt_claims.machine_to_machine_jwt.for'),
})}

View file

@ -1,5 +1,5 @@
import { withAppInsights } from '@logto/app-insights/react/AppInsightsReact';
import { LogtoJwtTokenPath } from '@logto/schemas';
import { LogtoJwtTokenKeyType } from '@logto/schemas';
import { useTranslation } from 'react-i18next';
import FormCard, { FormCardSkeleton } from '@/components/FormCard';
@ -39,9 +39,9 @@ function CustomizeJwt() {
{t('jwt_claims.user_jwt.card_description')}
</div>
{accessTokenJwtCustomizer ? (
<CustomizerItem tokenType={LogtoJwtTokenPath.AccessToken} />
<CustomizerItem tokenType={LogtoJwtTokenKeyType.AccessToken} />
) : (
<CreateButton tokenType={LogtoJwtTokenPath.AccessToken} />
<CreateButton tokenType={LogtoJwtTokenKeyType.AccessToken} />
)}
</FormField>
</FormCard>
@ -51,9 +51,9 @@ function CustomizeJwt() {
{t('jwt_claims.machine_to_machine_jwt.card_description')}
</div>
{clientCredentialsJwtCustomizer ? (
<CustomizerItem tokenType={LogtoJwtTokenPath.ClientCredentials} />
<CustomizerItem tokenType={LogtoJwtTokenKeyType.ClientCredentials} />
) : (
<CreateButton tokenType={LogtoJwtTokenPath.ClientCredentials} />
<CreateButton tokenType={LogtoJwtTokenKeyType.ClientCredentials} />
)}
</FormField>
</FormCard>

View file

@ -1,8 +1,8 @@
import { type LogtoJwtTokenPath } from '@logto/schemas';
import { type LogtoJwtTokenKeyType } from '@logto/schemas';
import { type Action } from './type';
export const getApiPath = (tokenType?: LogtoJwtTokenPath) => {
export const getApiPath = (tokenType?: LogtoJwtTokenKeyType) => {
if (!tokenType) {
return 'api/configs/jwt-customizer';
}
@ -10,7 +10,7 @@ export const getApiPath = (tokenType?: LogtoJwtTokenPath) => {
return `api/configs/jwt-customizer/${tokenType}`;
};
export const getPagePath = (tokenType?: LogtoJwtTokenPath, action?: Action) => {
export const getPagePath = (tokenType?: LogtoJwtTokenKeyType, action?: Action) => {
if (!tokenType) {
return '/customize-jwt';
}

View file

@ -1,5 +1,5 @@
/* Code Editor for the custom JWT claims script. */
import { LogtoJwtTokenPath } from '@logto/schemas';
import { LogtoJwtTokenKeyType } from '@logto/schemas';
import classNames from 'classnames';
import { useCallback, useContext, useMemo } from 'react';
import { Controller, useFormContext, useWatch } from 'react-hook-form';
@ -43,7 +43,7 @@ function ScriptSection() {
// Get the active model based on the token type
const activeModel = useMemo<ModelSettings>(
() =>
tokenType === LogtoJwtTokenPath.AccessToken
tokenType === LogtoJwtTokenKeyType.AccessToken
? accessTokenJwtCustomizerModel
: clientCredentialsModel,
[tokenType]

View file

@ -1,4 +1,4 @@
import { LogtoJwtTokenPath } from '@logto/schemas';
import { LogtoJwtTokenKeyType } from '@logto/schemas';
import { Editor } from '@monaco-editor/react';
import classNames from 'classnames';
import { useState } from 'react';
@ -49,7 +49,7 @@ function InstructionTab({ isActive }: Props) {
language="typescript"
className={styles.sampleCode}
value={
tokenType === LogtoJwtTokenPath.AccessToken
tokenType === LogtoJwtTokenKeyType.AccessToken
? accessTokenPayloadTypeDefinition
: clientCredentialsPayloadTypeDefinition
}
@ -58,7 +58,7 @@ function InstructionTab({ isActive }: Props) {
options={typeDefinitionCodeEditorOptions}
/>
</GuideCard>
{tokenType === LogtoJwtTokenPath.AccessToken && (
{tokenType === LogtoJwtTokenKeyType.AccessToken && (
<GuideCard
name={CardType.UserData}
isExpanded={expendCard === CardType.UserData}

View file

@ -1,4 +1,4 @@
import { LogtoJwtTokenPath } from '@logto/schemas';
import { LogtoJwtTokenKeyType } from '@logto/schemas';
import { conditional } from '@silverhand/essentials';
import classNames from 'classnames';
import { useCallback, useEffect, useMemo, useState } from 'react';
@ -35,7 +35,7 @@ function TestTab({ isActive }: Props) {
const editorModels = useMemo(
() =>
tokenType === LogtoJwtTokenPath.AccessToken
tokenType === LogtoJwtTokenKeyType.AccessToken
? accessTokenModelSettings
: clientCredentialsModelSettings,
[tokenType]

View file

@ -1,4 +1,4 @@
import { type LogtoJwtTokenPath } from '@logto/schemas';
import { type LogtoJwtTokenKeyType } from '@logto/schemas';
import classNames from 'classnames';
import { FormProvider, useForm } from 'react-hook-form';
import { useNavigate } from 'react-router-dom';
@ -18,7 +18,7 @@ import ScriptSection from './ScriptSection';
import SettingsSection from './SettingsSection';
import * as styles from './index.module.scss';
type Props<T extends LogtoJwtTokenPath> = {
type Props<T extends LogtoJwtTokenKeyType> = {
className?: string;
token: T;
data?: JwtCustomizer<T>;
@ -26,7 +26,7 @@ type Props<T extends LogtoJwtTokenPath> = {
action: Action;
};
function MainContent<T extends LogtoJwtTokenPath>({
function MainContent<T extends LogtoJwtTokenKeyType>({
className,
token,
data,

View file

@ -1,4 +1,4 @@
import { LogtoJwtTokenPath } from '@logto/schemas';
import { LogtoJwtTokenKeyType } from '@logto/schemas';
import classNames from 'classnames';
import Card from '@/ds-components/Card';
@ -6,7 +6,7 @@ import Card from '@/ds-components/Card';
import * as styles from './index.module.scss';
type Props = {
tokenType: LogtoJwtTokenPath;
tokenType: LogtoJwtTokenKeyType;
};
function PageLoadingSkeleton({ tokenType }: Props) {
@ -27,7 +27,7 @@ function PageLoadingSkeleton({ tokenType }: Props) {
<div className={classNames(styles.textShimmer, styles.title)} />
<div className={styles.textShimmer} />
</Card>
{tokenType === LogtoJwtTokenPath.AccessToken && (
{tokenType === LogtoJwtTokenKeyType.AccessToken && (
<Card className={styles.card}>
<div className={styles.textShimmer} />
<div className={styles.textShimmer} />

View file

@ -1,5 +1,5 @@
import { withAppInsights } from '@logto/app-insights/react/AppInsightsReact';
import { type LogtoJwtTokenPath } from '@logto/schemas';
import { type LogtoJwtTokenKeyType } from '@logto/schemas';
import { useMemo, useState } from 'react';
import { useParams } from 'react-router-dom';
@ -14,7 +14,7 @@ import { pageParamsGuard, type Action } from './type';
import useDataFetch from './use-data-fetch';
type Props = {
tokenType: LogtoJwtTokenPath;
tokenType: LogtoJwtTokenKeyType;
action: Action;
};

View file

@ -1,9 +1,9 @@
import type { AccessTokenJwtCustomizer, ClientCredentialsJwtCustomizer } from '@logto/schemas';
import { LogtoJwtTokenPath } from '@logto/schemas';
import { LogtoJwtTokenKeyType } from '@logto/schemas';
import { z } from 'zod';
export type JwtCustomizerForm = {
tokenType: LogtoJwtTokenPath;
tokenType: LogtoJwtTokenKeyType;
script: string;
environmentVariables?: Array<{ key: string; value: string }>;
testSample: {
@ -14,11 +14,12 @@ export type JwtCustomizerForm = {
export type Action = 'create' | 'edit';
export type JwtCustomizer<T extends LogtoJwtTokenPath> = T extends LogtoJwtTokenPath.AccessToken
? AccessTokenJwtCustomizer
: ClientCredentialsJwtCustomizer;
export type JwtCustomizer<T extends LogtoJwtTokenKeyType> =
T extends LogtoJwtTokenKeyType.AccessToken
? AccessTokenJwtCustomizer
: ClientCredentialsJwtCustomizer;
export const pageParamsGuard = z.object({
tokenType: z.nativeEnum(LogtoJwtTokenPath),
tokenType: z.nativeEnum(LogtoJwtTokenKeyType),
action: z.union([z.literal('create'), z.literal('edit')]),
});

View file

@ -1,4 +1,4 @@
import { type LogtoJwtTokenPath } from '@logto/schemas';
import { type LogtoJwtTokenKeyType } from '@logto/schemas';
import { type ResponseError } from '@withtyped/client';
import useSWR from 'swr';
@ -9,7 +9,7 @@ import { shouldRetryOnError } from '@/utils/request';
import { type Action, type JwtCustomizer } from './type';
import { getApiPath } from './utils/path';
const useDataFetch = <T extends LogtoJwtTokenPath>(tokenType: T, action: Action) => {
const useDataFetch = <T extends LogtoJwtTokenKeyType>(tokenType: T, action: Action) => {
const apiPath = getApiPath(tokenType);
const fetchApi = useApi({ hideErrorToast: true });
const fetcher = useSwrFetcher<JwtCustomizer<T>>(fetchApi);

View file

@ -1,4 +1,4 @@
import { LogtoJwtTokenPath, type AccessTokenJwtCustomizer, type Json } from '@logto/schemas';
import { LogtoJwtTokenKeyType, type AccessTokenJwtCustomizer, type Json } from '@logto/schemas';
import type { JwtCustomizer, JwtCustomizerForm } from '../type';
@ -11,7 +11,7 @@ import {
} from './config';
const formatEnvVariablesResponseToFormData = (
enVariables?: AccessTokenJwtCustomizer['envVars']
enVariables?: AccessTokenJwtCustomizer['environmentVariables']
) => {
if (!enVariables) {
return;
@ -56,26 +56,26 @@ const formatSampleCodeStringToJson = (sampleCode?: string) => {
};
const defaultValues = Object.freeze({
[LogtoJwtTokenPath.AccessToken]: {
[LogtoJwtTokenKeyType.AccessToken]: {
script: defaultAccessTokenJwtCustomizerCode,
tokenSample: defaultAccessTokenPayload,
contextSample: defaultUserTokenContextData,
},
[LogtoJwtTokenPath.ClientCredentials]: {
[LogtoJwtTokenKeyType.ClientCredentials]: {
script: defaultClientCredentialsJwtCustomizerCode,
tokenSample: defaultClientCredentialsPayload,
contextSample: undefined,
},
});
export const formatResponseDataToFormData = <T extends LogtoJwtTokenPath>(
export const formatResponseDataToFormData = <T extends LogtoJwtTokenKeyType>(
tokenType: T,
data?: JwtCustomizer<T>
): JwtCustomizerForm => {
return {
tokenType,
script: data?.script ?? defaultValues[tokenType].script,
environmentVariables: formatEnvVariablesResponseToFormData(data?.envVars) ?? [
environmentVariables: formatEnvVariablesResponseToFormData(data?.environmentVariables) ?? [
{ key: '', value: '' },
],
testSample: {
@ -92,7 +92,7 @@ export const formatResponseDataToFormData = <T extends LogtoJwtTokenPath>(
export const formatFormDataToRequestData = (data: JwtCustomizerForm) => {
return {
script: data.script,
envVars: formatEnvVariablesFormDataToRequest(data.environmentVariables),
environmentVariables: formatEnvVariablesFormDataToRequest(data.environmentVariables),
tokenSample: formatSampleCodeStringToJson(data.testSample.tokenSample),
contextSample: formatSampleCodeStringToJson(data.testSample.contextSample),
};
@ -107,7 +107,7 @@ export const formatFormDataToTestRequestPayload = ({
return {
tokenType,
script,
envVars: formatEnvVariablesFormDataToRequest(environmentVariables),
environmentVariables: formatEnvVariablesFormDataToRequest(environmentVariables),
token:
formatSampleCodeStringToJson(testSample.tokenSample) ?? defaultValues[tokenType].tokenSample,
context:

View file

@ -1,4 +1,4 @@
import { type LogtoJwtTokenPath } from '@logto/schemas';
import { type LogtoJwtTokenKeyType } from '@logto/schemas';
export const getApiPath = (tokenType: LogtoJwtTokenPath) =>
export const getApiPath = (tokenType: LogtoJwtTokenKeyType) =>
`api/configs/jwt-customizer/${tokenType}`;

View file

@ -218,7 +218,7 @@ export const mockJwtCustomizerConfigForAccessToken = {
key: LogtoJwtTokenKey.AccessToken,
value: {
script: 'console.log("hello world");',
envVars: {
environmentVariables: {
API_KEY: '<api-key>',
},
contextSample: {
@ -234,7 +234,7 @@ export const mockJwtCustomizerConfigForClientCredentials = {
key: LogtoJwtTokenKey.ClientCredentials,
value: {
script: 'console.log("hello world");',
envVars: {
environmentVariables: {
API_KEY: '<api-key>',
},
},

View file

@ -14,11 +14,11 @@ import {
logtoCookieKey,
type LogtoUiCookie,
LogtoJwtTokenKey,
LogtoJwtTokenPath,
ExtraParamsKey,
type Json,
jwtCustomizer as jwtCustomizerLog,
LogResult,
LogtoJwtTokenPath,
} from '@logto/schemas';
import { generateStandardId } from '@logto/shared';
import { conditional, trySafe, tryThat } from '@silverhand/essentials';
@ -227,7 +227,7 @@ export default function initOidc(
* want to insert an error log every time the OIDC provider issues a token when the JWT
* customizer is not configured.
*/
const { script, envVars } =
const { script, environmentVariables } =
(await trySafe(
logtoConfigs.getJwtCustomizer(
isTokenClientCredentials
@ -253,7 +253,7 @@ export default function initOidc(
const commonPayload = {
script,
envVars,
environmentVariables,
token: readOnlyToken,
};
@ -269,10 +269,12 @@ export default function initOidc(
body: isTokenClientCredentials
? {
...commonPayload,
// TODO: update once cloud repo is ready.
tokenType: LogtoJwtTokenPath.ClientCredentials,
}
: {
...commonPayload,
// TODO: update once cloud repo is ready.
tokenType: LogtoJwtTokenPath.AccessToken,
// TODO (LOG-8555): the newly added `UserProfile` type includes undefined fields and can not be directly assigned to `Json` type. And the `undefined` fields should be removed by zod guard.
// eslint-disable-next-line no-restricted-syntax

View file

@ -2,11 +2,13 @@ import {
accessTokenJwtCustomizerGuard,
clientCredentialsJwtCustomizerGuard,
LogtoJwtTokenKey,
LogtoJwtTokenPath,
LogtoJwtTokenKeyType,
jsonObjectGuard,
adminTenantId,
jwtCustomizerConfigsGuard,
jwtCustomizerTestRequestBodyGuard,
type CustomJwtFetcher,
type LogtoJwtTokenPath,
} from '@logto/schemas';
import { ResponseError } from '@withtyped/client';
import { ZodError, z } from 'zod';
@ -17,8 +19,8 @@ import koaGuard, { parse } from '#src/middleware/koa-guard.js';
import type { AuthedRouter, RouterInitArgs } from '../types.js';
const getJwtTokenKeyAndBody = (tokenPath: LogtoJwtTokenPath, body: unknown) => {
if (tokenPath === LogtoJwtTokenPath.AccessToken) {
const getJwtTokenKeyAndBody = (tokenPath: LogtoJwtTokenKeyType, body: unknown) => {
if (tokenPath === LogtoJwtTokenKeyType.AccessToken) {
return {
key: LogtoJwtTokenKey.AccessToken,
body: parse('body', accessTokenJwtCustomizerGuard, body),
@ -41,7 +43,7 @@ export default function logtoConfigJwtCustomizerRoutes<T extends AuthedRouter>(
'/configs/jwt-customizer/:tokenTypePath',
koaGuard({
params: z.object({
tokenTypePath: z.nativeEnum(LogtoJwtTokenPath),
tokenTypePath: z.nativeEnum(LogtoJwtTokenKeyType),
}),
/**
* Use `z.unknown()` to guard the request body as a JSON object, since the actual guard depends
@ -87,7 +89,7 @@ export default function logtoConfigJwtCustomizerRoutes<T extends AuthedRouter>(
// See comments in the `PUT /configs/jwt-customizer/:tokenTypePath` route, handle the request body manually.
koaGuard({
params: z.object({
tokenTypePath: z.nativeEnum(LogtoJwtTokenPath),
tokenTypePath: z.nativeEnum(LogtoJwtTokenKeyType),
}),
body: z.unknown(),
response: accessTokenJwtCustomizerGuard.or(clientCredentialsJwtCustomizerGuard),
@ -125,7 +127,7 @@ export default function logtoConfigJwtCustomizerRoutes<T extends AuthedRouter>(
'/configs/jwt-customizer/:tokenTypePath',
koaGuard({
params: z.object({
tokenTypePath: z.nativeEnum(LogtoJwtTokenPath),
tokenTypePath: z.nativeEnum(LogtoJwtTokenKeyType),
}),
response: accessTokenJwtCustomizerGuard.or(clientCredentialsJwtCustomizerGuard),
status: [200, 404],
@ -135,7 +137,7 @@ export default function logtoConfigJwtCustomizerRoutes<T extends AuthedRouter>(
params: { tokenTypePath },
} = ctx.guard;
ctx.body = await getJwtCustomizer(
tokenTypePath === LogtoJwtTokenPath.AccessToken
tokenTypePath === LogtoJwtTokenKeyType.AccessToken
? LogtoJwtTokenKey.AccessToken
: LogtoJwtTokenKey.ClientCredentials
);
@ -147,7 +149,7 @@ export default function logtoConfigJwtCustomizerRoutes<T extends AuthedRouter>(
'/configs/jwt-customizer/:tokenTypePath',
koaGuard({
params: z.object({
tokenTypePath: z.nativeEnum(LogtoJwtTokenPath),
tokenTypePath: z.nativeEnum(LogtoJwtTokenKeyType),
}),
status: [204, 404],
}),
@ -157,7 +159,7 @@ export default function logtoConfigJwtCustomizerRoutes<T extends AuthedRouter>(
} = ctx.guard;
await deleteJwtCustomizer(
tokenTypePath === LogtoJwtTokenPath.AccessToken
tokenTypePath === LogtoJwtTokenKeyType.AccessToken
? LogtoJwtTokenKey.AccessToken
: LogtoJwtTokenKey.ClientCredentials
);
@ -189,7 +191,9 @@ export default function logtoConfigJwtCustomizerRoutes<T extends AuthedRouter>(
try {
ctx.body = await client.post(`/api/services/custom-jwt`, {
body,
// TODO: remove type casting once the cloud repo is updated.
// eslint-disable-next-line no-restricted-syntax
body: body as CustomJwtFetcher & { tokenType: LogtoJwtTokenPath },
});
} catch (error: unknown) {
/**

View file

@ -135,7 +135,7 @@
"script": {
"description": "The script of the JWT customizer."
},
"envVars": {
"environmentVariables": {
"description": "The environment variables for the JWT customizer."
},
"contextSample": {
@ -182,7 +182,7 @@
"script": {
"description": "The script of the JWT customizer."
},
"envVars": {
"environmentVariables": {
"description": "The environment variables for the JWT customizer."
},
"contextSample": {
@ -262,7 +262,7 @@
"script": {
"description": "The code snippet of the JWT customizer."
},
"envVars": {
"environmentVariables": {
"description": "The environment variables for the JWT customizer."
},
"contextSample": {

View file

@ -1,6 +1,6 @@
export const clientCredentialsJwtCustomizerPayload = {
script: '',
envVars: {},
environmentVariables: {},
contextSample: {},
};

View file

@ -6,11 +6,11 @@ import {
clientCredentialsJwtCustomizerGuard,
} from './jwt-customizer.js';
const allFields = ['script', 'envVars', 'contextSample', 'tokenSample'] as const;
const allFields = ['script', 'environmentVariables', 'contextSample', 'tokenSample'] as const;
const testClientCredentialsTokenPayload = {
script: '',
envVars: {},
environmentVariables: {},
contextSample: {},
tokenSample: {},
};

View file

@ -35,7 +35,7 @@ export type JwtCustomizerUserContext = z.infer<typeof jwtCustomizerUserContextGu
export const jwtCustomizerGuard = z
.object({
script: z.string(),
envVars: z.record(z.string()),
environmentVariables: z.record(z.string()),
contextSample: jsonObjectGuard,
})
.partial();
@ -59,32 +59,38 @@ export const clientCredentialsJwtCustomizerGuard = jwtCustomizerGuard
export type ClientCredentialsJwtCustomizer = z.infer<typeof clientCredentialsJwtCustomizerGuard>;
// TODO: Temporarily leave this and will remove it after the cloud repo is updated.
export enum LogtoJwtTokenPath {
AccessToken = 'access-token',
ClientCredentials = 'client-credentials',
}
export enum LogtoJwtTokenKeyType {
AccessToken = 'access-token',
ClientCredentials = 'client-credentials',
}
/**
* This guard is for the core JWT customizer testing API request body guard.
*/
export const jwtCustomizerTestRequestBodyGuard = z.discriminatedUnion('tokenType', [
z.object({
tokenType: z.literal(LogtoJwtTokenPath.AccessToken),
tokenType: z.literal(LogtoJwtTokenKeyType.AccessToken),
...accessTokenJwtCustomizerGuard
.required({
script: true,
})
.pick({ envVars: true, script: true }).shape,
.pick({ environmentVariables: true, script: true }).shape,
token: accessTokenJwtCustomizerGuard.required().shape.tokenSample,
context: accessTokenJwtCustomizerGuard.required().shape.contextSample,
}),
z.object({
tokenType: z.literal(LogtoJwtTokenPath.ClientCredentials),
tokenType: z.literal(LogtoJwtTokenKeyType.ClientCredentials),
...clientCredentialsJwtCustomizerGuard
.required({
script: true,
})
.pick({ envVars: true, script: true }).shape,
.pick({ environmentVariables: true, script: true }).shape,
token: clientCredentialsJwtCustomizerGuard.required().shape.tokenSample,
}),
]);
@ -97,7 +103,7 @@ export type JwtCustomizerTestRequestBody = z.infer<typeof jwtCustomizerTestReque
* The response guard for the cloud API is `jsonObjectGuard` since it extends the `token` with extra claims.
*/
const commonJwtCustomizerGuard = jwtCustomizerGuard
.pick({ script: true, envVars: true })
.pick({ script: true, environmentVariables: true })
.required({ script: true })
.extend({
token: jsonObjectGuard,
@ -105,11 +111,11 @@ const commonJwtCustomizerGuard = jwtCustomizerGuard
export const customJwtFetcherGuard = z.discriminatedUnion('tokenType', [
commonJwtCustomizerGuard.extend({
tokenType: z.literal(LogtoJwtTokenPath.AccessToken),
tokenType: z.literal(LogtoJwtTokenKeyType.AccessToken),
context: jsonObjectGuard,
}),
commonJwtCustomizerGuard.extend({
tokenType: z.literal(LogtoJwtTokenPath.ClientCredentials),
tokenType: z.literal(LogtoJwtTokenKeyType.ClientCredentials),
}),
]);