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