@privy-io/js-sdk-core
Version:
Vanilla JS client for the Privy Auth API
2 lines (1 loc) • 1.68 kB
JavaScript
import{PrivyClientError as e}from"../../Error.mjs";import t from"./MfaPasskeyApi.mjs";import r from"./MfaSmsApi.mjs";import"@privy-io/routes";class i{setProxy(e){this.proxy=e}async getAccessTokenInternal(){let t=await this.privyInternal.getAccessTokenInternal();if(!t)throw new e({error:"Missing access token",code:"attempted_rpc_call_before_logged_in"});return t}async verifyMfa(){if(!this.proxy)throw new e({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return await this.proxy.verifyMfa({accessToken:await this.getAccessTokenInternal()})}async initEnrollMfa(t){if(!this.proxy)throw new e({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return await this.proxy.initEnrollMfa({...t,accessToken:await this.getAccessTokenInternal()})}async submitEnrollMfa(t){if(!this.proxy)throw new e({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});let r=await this.proxy.submitEnrollMfa({...t,accessToken:await this.getAccessTokenInternal()});return await this.privyInternal.refreshSession(),r}async unenrollMfa(t){if(!this.proxy)throw new e({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});let r=await this.proxy.unenrollMfa({method:t,accessToken:await this.getAccessTokenInternal()});return await this.privyInternal.refreshSession(),r}async clearMfa(t){if(!this.proxy)throw new e({error:"Embedded wallet proxy not initialized",code:"embedded_wallet_webview_not_loaded"});return await this.proxy.clearMfa(t)}constructor(e,i){this.proxy=i,this.privyInternal=e,this.sms=new r(e),this.passkey=new t(e)}}export{i as default};