UNPKG

@privy-io/react-auth

Version:

React client for the Privy Auth API

2 lines (1 loc) 757 B
import{P as t,aj as s,ak as i,f as a}from"./paths-j39vuJt8.mjs";class e{async init(){if(!this.api)throw new t("Auth flow has no API instance");let{nonce:i,expires_at:a}=await this.api.post(s,{});return{nonce:i,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(i,{message:this.message,signature:this.signature,fid:this.fid});if(!s)throw new t("No response from authentication");return s}catch(t){throw a(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};