UNPKG

@privy-io/js-sdk-core

Version:

Vanilla JS client for the Privy Auth API

2 lines (1 loc) 1.16 kB
"use strict";var e=require("../../utils/getUserEmbeddedEthereumWallet.js"),t=require("../../utils/getUserEmbeddedSolanaWallet.js"),r=require("../../utils/shouldCreateEmbeddedEthWallet.js"),s=require("../../utils/shouldCreateEmbeddedSolWallet.js");require("../../utils/getAllUserEmbeddedEthereumWallets.js"),require("../../utils/embedded-wallets.js"),require("../../utils/getAllUserEmbeddedSolanaWallets.js");exports.maybeCreateWalletOnLogin=async(a,l,u)=>{let d=r.shouldCreateEmbeddedEthWallet(l.user,u?.ethereum?.createOnLogin??"off"),o=s.shouldCreateEmbeddedSolWallet(l.user,u?.solana?.createOnLogin??"off");if(d&&o){let t=await a.create({recoveryMethod:"privy",skipCallbacks:!0});return{...await a.createSolana({ethereumAccount:e.getUserEmbeddedEthereumWallet(t.user)??void 0}),is_new_user:l.is_new_user,oauth_tokens:l.oauth_tokens}}return d?{...await a.create({recoveryMethod:"privy",solanaAccount:t.getUserEmbeddedSolanaWallet(l.user)??void 0}),is_new_user:l.is_new_user,oauth_tokens:l.oauth_tokens}:o?{...await a.createSolana({ethereumAccount:e.getUserEmbeddedEthereumWallet(l.user)??void 0}),is_new_user:l.is_new_user,oauth_tokens:l.oauth_tokens}:l};