✨ Customizable allowed origins
This commit is contained in:
@ -131,6 +131,10 @@ export const startSession = async ({
|
||||
dynamicTheme: parseDynamicThemeInState(typebot.theme),
|
||||
isStreamEnabled: startParams.isStreamEnabled,
|
||||
typingEmulation: typebot.settings.typingEmulation,
|
||||
allowedOrigins:
|
||||
startParams.type === 'preview'
|
||||
? undefined
|
||||
: typebot.settings.security?.allowedOrigins,
|
||||
...initialSessionState,
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,7 @@ const sessionStateSchemaV3 = sessionStateSchemaV2
|
||||
.extend({
|
||||
version: z.literal('3'),
|
||||
currentBlockId: z.string().optional(),
|
||||
allowedOrigins: z.array(z.string()).optional(),
|
||||
})
|
||||
|
||||
export type SessionState = z.infer<typeof sessionStateSchemaV3>
|
||||
|
@ -42,6 +42,11 @@ export const settingsSchema = z
|
||||
isEnabled: z.boolean().optional(),
|
||||
})
|
||||
.optional(),
|
||||
security: z
|
||||
.object({
|
||||
allowedOrigins: z.array(z.string()).optional(),
|
||||
})
|
||||
.optional(),
|
||||
})
|
||||
.openapi({
|
||||
title: 'Settings',
|
||||
|
@ -20,9 +20,11 @@ export const deepParseVariables =
|
||||
},
|
||||
parseVariablesOptions: ParseVariablesOptions = defaultParseVariablesOptions
|
||||
) =>
|
||||
<T extends Record<string, unknown>>(object: T): T =>
|
||||
Object.keys(object).reduce<T>((newObj, key) => {
|
||||
const currentValue = object[key]
|
||||
<T>(object: T): T => {
|
||||
if (!object) return object as T
|
||||
if (typeof object !== 'object') return object as T
|
||||
return Object.keys(object).reduce<T>((newObj, key) => {
|
||||
const currentValue = (object as Record<string, unknown>)[key]
|
||||
|
||||
if (typeof currentValue === 'string') {
|
||||
const parsedVariable = parseVariables(
|
||||
@ -63,3 +65,4 @@ export const deepParseVariables =
|
||||
|
||||
return { ...newObj, [key]: currentValue }
|
||||
}, {} as T)
|
||||
}
|
||||
|
Reference in New Issue
Block a user