UNPKG

@privy-io/react-auth

Version:

React client for the Privy Auth API

2 lines (1 loc) 768 B
import{P as t,am as s,an as i,f as e}from"./internal-context-D5bEplez.mjs";class a{async init(){if(!this.api)throw new t("Auth flow has no API instance");let{nonce:i,expires_at:e}=await this.api.post(s,{});return{nonce:i,expiresAt:e}}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 e(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{a as F};