Files
medreport_mrb2b/packages/billing/stripe/src/schema/stripe-server-env.schema.ts
Helena 9122acc89f MED-151: add profile view and working smoking dashboard card (#71)
* MED-151: add profile view and working smoking dashboard card

* update zod

* move some components to shared

* move some components to shared

* remove console.logs

* remove unused password form components

* only check null for variant

* use pathsconfig
2025-09-04 12:17:54 +03:00

40 lines
917 B
TypeScript

import { z } from 'zod';
export const StripeServerEnvSchema = z
.object({
secretKey: z
.string({
error: `Please provide the variable STRIPE_SECRET_KEY`,
})
.min(1),
webhooksSecret: z
.string({
error: `Please provide the variable STRIPE_WEBHOOK_SECRET`,
})
.min(1),
})
.refine(
(schema) => {
const key = schema.secretKey;
const secretKeyPrefix = 'sk_';
const restrictKeyPrefix = 'rk_';
return (
key.startsWith(secretKeyPrefix) || key.startsWith(restrictKeyPrefix)
);
},
{
path: ['STRIPE_SECRET_KEY'],
message: `Stripe secret key must start with 'sk_' or 'rk_'`,
},
)
.refine(
(schema) => {
return schema.webhooksSecret.startsWith('whsec_');
},
{
path: ['STRIPE_WEBHOOK_SECRET'],
message: `Stripe webhook secret must start with 'whsec_'`,
},
);