From 8a17afbd2d25bf6648b847634b360f06ea0f3841 Mon Sep 17 00:00:00 2001 From: Chaitanya Potti Date: Thu, 25 Jan 2024 17:18:06 +0800 Subject: [PATCH] fix usage of useCoreKitKey --- packages/adapters/openlogin-adapter/src/interface.ts | 4 +--- .../adapters/openlogin-adapter/src/openloginAdapter.ts | 7 ++----- packages/base/src/adapter/IAdapter.ts | 6 ++++++ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/adapters/openlogin-adapter/src/interface.ts b/packages/adapters/openlogin-adapter/src/interface.ts index 51e730096..2e4505c2c 100644 --- a/packages/adapters/openlogin-adapter/src/interface.ts +++ b/packages/adapters/openlogin-adapter/src/interface.ts @@ -8,9 +8,7 @@ type MakeOptional = Omit & Partial; export interface OpenloginAdapterOptions extends BaseAdapterSettings { - adapterSettings?: MakeOptional & { - useCoreKitKey?: boolean; - }; + adapterSettings?: MakeOptional; loginSettings?: LoginSettings; privateKeyProvider?: PrivateKeyProvider; } diff --git a/packages/adapters/openlogin-adapter/src/openloginAdapter.ts b/packages/adapters/openlogin-adapter/src/openloginAdapter.ts index c10e206e7..3fa753a70 100644 --- a/packages/adapters/openlogin-adapter/src/openloginAdapter.ts +++ b/packages/adapters/openlogin-adapter/src/openloginAdapter.ts @@ -187,9 +187,6 @@ export class OpenloginAdapter extends BaseAdapter { if (adapterSettings.web3AuthNetwork) { this.openloginOptions.network = adapterSettings.web3AuthNetwork; } - if (adapterSettings.useCoreKitKey !== undefined) { - this.openloginOptions.useCoreKitKey = adapterSettings.useCoreKitKey; - } if (adapterSettings.privateKeyProvider) { this.privateKeyProvider = adapterSettings.privateKeyProvider; } @@ -211,7 +208,7 @@ export class OpenloginAdapter extends BaseAdapter { if (!this.openloginInstance) return ""; let finalPrivKey = this.openloginInstance.privKey; // coreKitKey is available only for custom verifiers by default - if (this.openloginOptions?.useCoreKitKey) { + if (this.useCoreKitKey) { // this is to check if the user has already logged in but coreKitKey is not available. // when useCoreKitKey is set to true. // This is to ensure that when there is no user session active, we don't throw an exception. @@ -227,7 +224,7 @@ export class OpenloginAdapter extends BaseAdapter { if (!this.openloginInstance) return ""; let finalPrivKey = this.openloginInstance.ed25519PrivKey; // coreKitKey is available only for custom verifiers by default - if (this.openloginOptions?.useCoreKitKey) { + if (this.useCoreKitKey) { // this is to check if the user has already logged in but coreKitKey is not available. // when useCoreKitKey is set to true. // This is to ensure that when there is no user session active, we don't throw an exception. diff --git a/packages/base/src/adapter/IAdapter.ts b/packages/base/src/adapter/IAdapter.ts index f67b5e048..03fe7ffea 100644 --- a/packages/base/src/adapter/IAdapter.ts +++ b/packages/base/src/adapter/IAdapter.ts @@ -82,6 +82,7 @@ export interface IAdapter extends SafeEventEmitter { name: string; sessionTime: number; web3AuthNetwork: OPENLOGIN_NETWORK_TYPE; + useCoreKitKey: boolean | undefined; clientId: string; status: ADAPTER_STATUS_TYPE; provider: IProvider | null; @@ -106,6 +107,8 @@ export abstract class BaseAdapter extends SafeEventEmitter implements IAdapte public web3AuthNetwork: OPENLOGIN_NETWORK_TYPE = OPENLOGIN_NETWORK.MAINNET; + public useCoreKitKey: boolean = undefined; + protected rehydrated = false; // should be added in constructor or from setAdapterSettings function @@ -150,6 +153,9 @@ export abstract class BaseAdapter extends SafeEventEmitter implements IAdapte if (options?.web3AuthNetwork) { this.web3AuthNetwork = options.web3AuthNetwork; } + if (options?.useCoreKitKey !== undefined) { + this.useCoreKitKey = options.useCoreKitKey; + } const customChainConfig = options.chainConfig; if (customChainConfig) { if (!customChainConfig.chainNamespace) throw WalletInitializationError.notReady("ChainNamespace is required while setting chainConfig");