Files
paseo/packages/expo-two-way-audio/examples/flow-api/auth.ts
2026-03-14 16:46:35 +07:00

16 lines
530 B
TypeScript

import { createSpeechmaticsJWT } from "@speechmatics/auth";
// WARNING: This function is used for the purpose of this example only.
// In a real-world scenario, you should not expose your API key in your client-side code.
// Instead, you should create a server-side endpoint that generates the JWT for you.
export async function getFlowAPIJwt(apiKey: string) {
if (!apiKey) {
throw new Error("API key is required.");
}
return await createSpeechmaticsJWT({
type: "flow",
apiKey,
ttl: 60, // 1 minute
});
}