@privy-io/js-sdk-core
Version:
Vanilla JS client for the Privy Auth API
2 lines (1 loc) • 1.64 kB
JavaScript
import{PasswordlessSmsInit as e,PasswordlessSmsAuthenticate as t,PasswordlessSmsLink as r,PasswordlessSmsUpdate as i,PasswordlessSmsUnlink as n}from"@privy-io/public-api";import{maybeCreateWalletOnLogin as s}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 o{async sendCode(t,r){return this._privyInternal.fetch(e,{body:{phoneNumber:t,token:r}})}async loginWithCode(e,r,i,n){let o=await this._privyInternal.fetch(t,{body:{phoneNumber:e,code:r,mode:i}});await this._privyInternal.session.updateWithTokensResponse(o);let a=await s(this._embedded,o,n?.embedded);return this._privyInternal.callbacks?.setUser?.(a.user),a}async linkWithCode(e,t){await this._privyInternal.fetch(r,{body:{phoneNumber:e,code:t}});let i=await this._privyInternal.refreshSession();return{user:i.user,identity_token:i.identity_token}}async updatePhone({oldPhoneNumber:e,newPhoneNumber:t,code:r}){await this._privyInternal.fetch(i,{body:{old_phone_number:e,new_phone_number:t,code:r}});let n=await this._privyInternal.refreshSession();return{user:n.user,identity_token:n.identity_token}}async unlink(e){await this._privyInternal.fetch(n,{body:{phoneNumber: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{o as default};