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