Merge pull request #6 from jesse-ux/codex/fix-dynamic-rectification-token
fix: restore dynamic birth-time questions in production
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { createHash } from "node:crypto";
|
||||
|
||||
export function resolveDynamicRectificationToken(
|
||||
configuredToken: string | undefined,
|
||||
serviceRoleKey: string | undefined,
|
||||
): string | null {
|
||||
const configured = configuredToken?.trim();
|
||||
if (configured) return configured;
|
||||
const serviceRole = serviceRoleKey?.trim();
|
||||
if (!serviceRole) return null;
|
||||
return createHash("sha256")
|
||||
.update(`jyotisha-dynamic-rectification-v1:${serviceRole}`)
|
||||
.digest("hex");
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
createJourneyEngineWire,
|
||||
} from "./birth-time-journey-engine-model.ts";
|
||||
import type { BirthTimeJourneyEngine } from "./birth-time-journey-service.ts";
|
||||
import { resolveDynamicRectificationToken } from "./birth-time-dynamic-token.ts";
|
||||
|
||||
export {
|
||||
BirthTimeJourneyEngineConfigurationError,
|
||||
@@ -16,7 +17,10 @@ export function createJyotishBirthTimeJourneyEngine(
|
||||
): BirthTimeJourneyEngine {
|
||||
return createJourneyEngineMethods(createJourneyEngineWire({
|
||||
apiBase,
|
||||
dynamicToken: process.env.JYOTISH_DYNAMIC_RECTIFICATION_TOKEN ?? null,
|
||||
dynamicToken: resolveDynamicRectificationToken(
|
||||
process.env.JYOTISH_DYNAMIC_RECTIFICATION_TOKEN,
|
||||
process.env.SUPABASE_SERVICE_ROLE_KEY,
|
||||
),
|
||||
fetchImpl: fetch,
|
||||
}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user