UNPKG

@replyke/core

Version:

Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.

36 lines (34 loc) 1.42 kB
import axios from "../../config/axios"; import { handleError } from "../../utils/handleError"; const WARNING = ` WARNING: You are using a testing function to generate JWTs in your client application. This is NOT secure and should ONLY be used for initial development and testing purposes. In production: - NEVER expose your secret key in client-side code. - Refer to the documentation at https://docs.replyke.com to implement JWT signing on your backend. - Rotate your secret key periodically, especially after moving from testing to production. Failure to follow these practices can lead to security vulnerabilities. `; function useSignTestingJwt() { const signTestingJwt = async ({ projectId, privateKey, userData, }) => { try { if (!projectId) { throw new Error("No project specified"); } // Warn developers about the security risks console.warn(WARNING); const response = await axios.post(`/${projectId}/crypto/sign-testing-jwt/v2`, { projectId, privateKey, userData, }); return response.data; } catch (err) { handleError(err, "Failed to sign testing jwt: "); } }; return signTestingJwt; } export default useSignTestingJwt; //# sourceMappingURL=useSignTestingJwt.js.map