'use server'; import { z } from "zod"; import { getSDKForCurrentUser } from "../../getSDKForCurrentUser"; import { CreateUserSchema } from "./schema"; import { User } from "./types"; export const _CreateEmailToken = async (email: string): Promise => { try { //@ts-ignore const token = createEmailToken(email); return token; } catch (error) { throw new Error("Error in SDK : " + error); } }; export const _GetEmailFromEmailToken = async (token: string): Promise => { try { //@ts-ignore const email = getEmailFromEmailToken(token); return email; } catch (error) { throw new Error("Error in SDK : " + error); } } export const _CreateUser = async (params: z.infer): Promise<{ data?: User, serverError?: string }> => { try { const { userId, email, password, name } = params; const { accounts } = await getSDKForCurrentUser(); return await accounts.create(userId as string, email, password, name) as any } catch (error) { throw new Error("Error in SDK : " + error); } }; export const _CreateVerification = async (url: string, body: string) => { try { const { accounts } = await getSDKForCurrentUser(); return await accounts.createVerification(url, body); } catch (error) { throw new Error("Error in SDK icinde hata oldu : " + error); } }; export const _UpdateVerification = async (userId: string, secret: string) => { try { const { accounts } = await getSDKForCurrentUser(); return await accounts.updateVerification(userId, secret); } catch (error) { throw new Error("Error in SDK icinde hata oldu : " + error); } };