Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/Web3Auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
import { decodeToken } from "./utils";

export class Web3Auth extends SafeEventEmitter<Web3AuthSfaEvents> implements IWeb3Auth {
readonly coreOptions: Omit<Web3AuthOptions, "storage"> & { storage: IAsyncStorage | IStorage | ISecureStore };
readonly coreOptions: Omit<Web3AuthOptions, "storage"> & { storage: IAsyncStorage | IStorage | ISecureStore; sessionKey?: string };

readonly connectedAdapterName = WALLET_ADAPTERS.SFA;

Expand Down Expand Up @@ -73,7 +73,7 @@ export class Web3Auth extends SafeEventEmitter<Web3AuthSfaEvents> implements IWe

private plugins: Record<string, IPlugin> = {};

constructor(options: Web3AuthOptions) {
constructor(options: Web3AuthOptions & { sessionKey?: string }) {
super();
if (!options.clientId) throw WalletInitializationError.invalidParams("Please provide a valid clientId in constructor");
if (!options.privateKeyProvider) throw WalletInitializationError.invalidParams("Please provide a valid privateKeyProvider in constructor");
Expand Down Expand Up @@ -126,7 +126,7 @@ export class Web3Auth extends SafeEventEmitter<Web3AuthSfaEvents> implements IWe
throw WalletInitializationError.invalidParams("provider should have chainConfig and should be initialized with chainId and chainNamespace");
}

const storageKey = `${this.baseStorageKey}_${this.coreOptions.chainConfig.chainNamespace === CHAIN_NAMESPACES.SOLANA ? "solana" : "eip"}_${this.coreOptions.usePnPKey ? "pnp" : "core_kit"}`;
const storageKey = this.coreOptions.sessionKey || `${this.baseStorageKey}_${this.coreOptions.usePnPKey ? "pnp" : "core_kit"}`;
this.currentStorage = new AsyncStorage(storageKey, this.coreOptions.storage);
this.nodeDetails = fetchLocalConfig(this.coreOptions.web3AuthNetwork, KEY_TYPE.SECP256K1);
this.authInstance = new Torus({
Expand Down Expand Up @@ -159,7 +159,8 @@ export class Web3Auth extends SafeEventEmitter<Web3AuthSfaEvents> implements IWe
});
if (data && data.privKey) {
this.torusPrivKey = data.basePrivKey;
await this.privKeyProvider.setupProvider(data.privKey);
const finalPrivKey = await this.getFinalPrivKey(data.basePrivKey);
await this.privKeyProvider.setupProvider(finalPrivKey);
// setup aa provider after private key provider is setup
if (this.accountAbstractionProvider) {
await this.accountAbstractionProvider.setupProvider(this.privKeyProvider);
Expand Down