mirror of
https://github.com/logto-io/logto.git
synced 2025-03-10 22:22:45 -05:00
refactor(schemas): sync cloud m2m credential to logto config (#4115)
This commit is contained in:
parent
3c14d046c6
commit
759adf0f18
2 changed files with 34 additions and 1 deletions
|
@ -1,7 +1,9 @@
|
||||||
import { type CreateLogtoConfig } from '../db-entries/index.js';
|
import { type CreateLogtoConfig } from '../db-entries/index.js';
|
||||||
import type { AdminConsoleData } from '../types/index.js';
|
import type { AdminConsoleData, CloudConnectionData } from '../types/index.js';
|
||||||
import { LogtoTenantConfigKey } from '../types/index.js';
|
import { LogtoTenantConfigKey } from '../types/index.js';
|
||||||
|
|
||||||
|
import { cloudApiIndicator } from './cloud-api.js';
|
||||||
|
|
||||||
export const createDefaultAdminConsoleConfig = (
|
export const createDefaultAdminConsoleConfig = (
|
||||||
forTenantId: string
|
forTenantId: string
|
||||||
): Readonly<{
|
): Readonly<{
|
||||||
|
@ -23,3 +25,22 @@ export const createDefaultAdminConsoleConfig = (
|
||||||
m2mApplicationCreated: false,
|
m2mApplicationCreated: false,
|
||||||
},
|
},
|
||||||
} satisfies CreateLogtoConfig);
|
} satisfies CreateLogtoConfig);
|
||||||
|
|
||||||
|
export const createDefaultCloudConnectionConfig = (
|
||||||
|
forTenantId: string,
|
||||||
|
appId: string,
|
||||||
|
appSecret: string
|
||||||
|
): Readonly<{
|
||||||
|
tenantId: string;
|
||||||
|
key: LogtoTenantConfigKey;
|
||||||
|
value: CloudConnectionData;
|
||||||
|
}> =>
|
||||||
|
Object.freeze({
|
||||||
|
tenantId: forTenantId,
|
||||||
|
key: LogtoTenantConfigKey.CloudConnection,
|
||||||
|
value: {
|
||||||
|
appId,
|
||||||
|
appSecret,
|
||||||
|
resource: cloudApiIndicator,
|
||||||
|
},
|
||||||
|
} satisfies CreateLogtoConfig);
|
||||||
|
|
|
@ -34,13 +34,24 @@ export const adminConsoleDataGuard = z.object({
|
||||||
|
|
||||||
export type AdminConsoleData = z.infer<typeof adminConsoleDataGuard>;
|
export type AdminConsoleData = z.infer<typeof adminConsoleDataGuard>;
|
||||||
|
|
||||||
|
/* --- Logto tenant cloud connection config --- */
|
||||||
|
export const cloudConnectionDataGuard = z.object({
|
||||||
|
appId: z.string(),
|
||||||
|
appSecret: z.string(),
|
||||||
|
resource: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type CloudConnectionData = z.infer<typeof cloudConnectionDataGuard>;
|
||||||
|
|
||||||
export enum LogtoTenantConfigKey {
|
export enum LogtoTenantConfigKey {
|
||||||
AdminConsole = 'adminConsole',
|
AdminConsole = 'adminConsole',
|
||||||
|
CloudConnection = 'cloudConnection',
|
||||||
/** The URL to redirect when session not found in Sign-in Experience. */
|
/** The URL to redirect when session not found in Sign-in Experience. */
|
||||||
SessionNotFoundRedirectUrl = 'sessionNotFoundRedirectUrl',
|
SessionNotFoundRedirectUrl = 'sessionNotFoundRedirectUrl',
|
||||||
}
|
}
|
||||||
export type LogtoTenantConfigType = {
|
export type LogtoTenantConfigType = {
|
||||||
[LogtoTenantConfigKey.AdminConsole]: AdminConsoleData;
|
[LogtoTenantConfigKey.AdminConsole]: AdminConsoleData;
|
||||||
|
[LogtoTenantConfigKey.CloudConnection]: CloudConnectionData;
|
||||||
[LogtoTenantConfigKey.SessionNotFoundRedirectUrl]: { url: string };
|
[LogtoTenantConfigKey.SessionNotFoundRedirectUrl]: { url: string };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -48,6 +59,7 @@ export const logtoTenantConfigGuard: Readonly<{
|
||||||
[key in LogtoTenantConfigKey]: ZodType<LogtoTenantConfigType[key]>;
|
[key in LogtoTenantConfigKey]: ZodType<LogtoTenantConfigType[key]>;
|
||||||
}> = Object.freeze({
|
}> = Object.freeze({
|
||||||
[LogtoTenantConfigKey.AdminConsole]: adminConsoleDataGuard,
|
[LogtoTenantConfigKey.AdminConsole]: adminConsoleDataGuard,
|
||||||
|
[LogtoTenantConfigKey.CloudConnection]: cloudConnectionDataGuard,
|
||||||
[LogtoTenantConfigKey.SessionNotFoundRedirectUrl]: z.object({ url: z.string() }),
|
[LogtoTenantConfigKey.SessionNotFoundRedirectUrl]: z.object({ url: z.string() }),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue