@privy-io/js-sdk-core
Version:
Vanilla JS client for the Privy Auth API
2 lines (1 loc) • 1.59 kB
JavaScript
import{PasswordlessInit as e,PasswordlessAuthenticate as t,PasswordlessLink as i,PasswordlessUpdate as s,PasswordlessUnlink as r}from"@privy-io/public-api";import{maybeCreateWalletOnLogin as a}from"./maybeCreateWalletOnLogin.mjs";import"../../utils/getUserEmbeddedEthereumWallet.mjs";import"../../utils/getAllUserEmbeddedEthereumWallets.mjs";import"../../utils/getUserEmbeddedSolanaWallet.mjs";import"../../utils/getAllUserEmbeddedSolanaWallets.mjs";import"../../utils/shouldCreateEmbeddedEthWallet.mjs";import"../../utils/shouldCreateEmbeddedSolWallet.mjs";class d{async sendCode(t,i){return this._privyInternal.fetch(e,{body:{email:t,token:i}})}async loginWithCode(e,i,s,r){let d=await this._privyInternal.fetch(t,{body:{email:e,code:i,mode:s}});await this._privyInternal.session.updateWithTokensResponse(d);let n=await a(this._embedded,d,r?.embedded);return this._privyInternal.callbacks?.setUser?.(n.user),n}async linkWithCode(e,t){await this._privyInternal.fetch(i,{body:{email:e,code:t}});let s=await this._privyInternal.refreshSession();return{user:s.user,identity_token:s.identity_token}}async updateEmail({oldEmailAddress:e,newEmailAddress:t,code:i}){await this._privyInternal.fetch(s,{body:{oldAddress:e,newAddress:t,code:i}});let r=await this._privyInternal.refreshSession();return{user:r.user,identity_token:r.identity_token}}async unlink(e){await this._privyInternal.fetch(r,{body:{address:e}});let t=await this._privyInternal.refreshSession();return{user:t.user,identity_token:t.identity_token}}constructor(e,t){this._privyInternal=e,this._embedded=t}}export{d as default};