UNPKG

@privy-io/react-auth

Version:

React client for the Privy Auth API

2 lines (1 loc) 802 B
import{a as t,f as s}from"./internal-context-e-Eni5bG.mjs";import{a5 as i,a6 as a}from"./paths-3HW55qZg.mjs";class e{async init(){if(!this.api)throw new t("Auth flow has no API instance");let{nonce:s,expires_at:a}=await this.api.post(i,{});return{nonce:s,expiresAt:a}}async authenticate(){if(!this.message||!this.signature||!this.fid)throw new t("Auth flow has no message, signature, or fid");if(!this.api)throw new t("Auth flow has no API instance");try{let s=await this.api.post(a,{message:this.message,signature:this.signature,fid:this.fid});if(!s)throw new t("No response from authentication");return s}catch(t){throw s(t)}}async link(){throw Error("Not implemented")}setAuthData({message:t,signature:s,fid:i}){this.message=t,this.signature=s,this.fid=i}constructor(){this.meta={}}}export{e as F};