@privy-io/js-sdk-core
Version:
Vanilla JS client for the Privy Auth API
2 lines (1 loc) • 1.58 kB
JavaScript
import{SiwsUnlink as e,SiwsLink as t,SiwsAuthenticate as s,SiwsInit as l}from"@privy-io/routes";import{maybeCreateWalletOnLogin as n}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 r{async unlink({address:t}){await this._privyInternal.fetch(e,{body:{address:t}});let s=await this._privyInternal.refreshSession();return{user:s.user,identity_token:s.identity_token}}async link({message:e,signature:s,walletClientType:l,connectorType:n}){await this._privyInternal.fetch(t,{body:{message:e,signature:s,walletClientType:l??null,connectorType:n??null}});let r=await this._privyInternal.refreshSession();return{user:r.user,identity_token:r.identity_token}}async login({mode:e,message:t,signature:l,walletClientType:r,connectorType:i,opts:a}){let d=await this._privyInternal.fetch(s,{body:{signature:l,message:t,walletClientType:r??null,connectorType:i??null,mode:e}});await this._privyInternal.session.updateWithTokensResponse(d);let o=await n(this._embedded,d,a?.embedded);return this._privyInternal.callbacks?.setUser?.(o.user),o}async fetchNonce({address:e}){let{nonce:t}=await this._privyInternal.fetch(l,{body:{address:e}});return{nonce:t}}constructor(e,t){this._privyInternal=e,this._embedded=t}}export{r as default};