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

chore(toolkit): add email service branding config guard (#4085)

This commit is contained in:
Darcy Ye 2023-06-27 11:21:28 +08:00 committed by GitHub
parent 752d39b2ab
commit 850cd3e342
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -209,6 +209,23 @@ export type EmailConnector = BaseConnector<ConnectorType.Email> & {
sendMessage: SendMessageFunction;
};
export const urlRegEx =
/(https?:\/\/)?(?:www\.)?[\w#%+.:=@~-]{1,256}\.[\d()A-Za-z]{1,6}\b[\w#%&()+./:=?@~-]*/;
export const emailServiceBrandingGuard = z
.object({
fromName: z
.string()
.refine((address) => !urlRegEx.test(address), 'DO NOT include URL in the sender name!'),
companyAddress: z
.string()
.refine((address) => !urlRegEx.test(address), 'DO NOT include URL in the company address!'),
appLogo: z.string().url(),
})
.partial();
export type EmailServiceBranding = z.infer<typeof emailServiceBrandingGuard>;
export const sendMessagePayloadGuard = z.object({
to: z.string(),
type: verificationCodeTypeGuard,