Files
khb_microservices/packages/qbo_auth/src/settings.ts
2026-11-23 09:28:24 +03:00

25 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { z } from "zod";
/**
* Секция `qbo_auth` в settings.json5. Секреты (clientSecret, encryptionKey, token) - только здесь, не в Git.
* Ключи приложения Intuit: development-ключи работают только с sandbox, production - после проверки Intuit.
*/
export const qboAuthSchema = z.object({
http: z.object({ host: z.string().default("0.0.0.0"), port: z.number().default(8095), token: z.string().min(1) }),
environment: z.enum(["sandbox", "production"]).default("sandbox"),
clientId: z.string().min(1),
clientSecret: z.string().min(1),
/** Должен совпадать со значением в разделе Redirect URIs приложения Intuit. */
redirectUri: z.string().url(),
scope: z.string().default("com.intuit.quickbooks.accounting"),
/** 32 байта в hex (64 символа) или base64: ключ шифрования токенов в БД (AES-256-GCM). */
encryptionKey: z.string().min(32),
/** Обновлять токены, если последнее обновление старше, часов (refresh token скользящий, до 100 дней). */
keepAliveHours: z.number().default(20),
/** Verifier token вебхуков Intuit (раздел Webhooks приложения: отдельный для development и production); пусто - вебхуки отклоняются. */
/** Компании QuickBooks (realmId), которые разрешено подключать (sandbox и production); пусто - без ограничения. */
allowedRealmIds: z.array(z.string().min(1)).default([]),
webhookVerifierTokens: z.array(z.string().min(1)).default([]),
});
export type QboAuthSettings = z.infer<typeof qboAuthSchema>;