Skip to content

Commit

Permalink
fix usage of useCoreKitKey
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyapotti committed Jan 25, 2024
1 parent 55a147d commit 8a17afb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 1 addition & 3 deletions packages/adapters/openlogin-adapter/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ type MakeOptional<Type, Key extends keyof Type> = Omit<Type, Key> & Partial<Pick
export type PrivateKeyProvider = IBaseProvider<string>;

export interface OpenloginAdapterOptions extends BaseAdapterSettings {
adapterSettings?: MakeOptional<OpenLoginOptions, "clientId" | "network"> & {
useCoreKitKey?: boolean;
};
adapterSettings?: MakeOptional<OpenLoginOptions, "clientId" | "network">;
loginSettings?: LoginSettings;
privateKeyProvider?: PrivateKeyProvider;
}
Expand Down
7 changes: 2 additions & 5 deletions packages/adapters/openlogin-adapter/src/openloginAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ export class OpenloginAdapter extends BaseAdapter<OpenloginLoginParams> {
if (adapterSettings.web3AuthNetwork) {
this.openloginOptions.network = adapterSettings.web3AuthNetwork;
}
if (adapterSettings.useCoreKitKey !== undefined) {
this.openloginOptions.useCoreKitKey = adapterSettings.useCoreKitKey;
}
if (adapterSettings.privateKeyProvider) {
this.privateKeyProvider = adapterSettings.privateKeyProvider;
}
Expand All @@ -211,7 +208,7 @@ export class OpenloginAdapter extends BaseAdapter<OpenloginLoginParams> {
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.
Expand All @@ -227,7 +224,7 @@ export class OpenloginAdapter extends BaseAdapter<OpenloginLoginParams> {
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.
Expand Down
6 changes: 6 additions & 0 deletions packages/base/src/adapter/IAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export interface IAdapter<T> extends SafeEventEmitter {
name: string;
sessionTime: number;
web3AuthNetwork: OPENLOGIN_NETWORK_TYPE;
useCoreKitKey: boolean | undefined;
clientId: string;
status: ADAPTER_STATUS_TYPE;
provider: IProvider | null;
Expand All @@ -106,6 +107,8 @@ export abstract class BaseAdapter<T> 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
Expand Down Expand Up @@ -150,6 +153,9 @@ export abstract class BaseAdapter<T> 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");
Expand Down

0 comments on commit 8a17afb

Please sign in to comment.