Skip to content

Commit 76a3318

Browse files
committed
fix: making sessionkey wallet optional
fix: handling case where login is called primaryWallet is defined
1 parent 3c3843f commit 76a3318

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/kit.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,15 @@ export class SessionKit {
170170
// Initialize session key support if configured
171171
if (options.sessionKey) {
172172
this.sessionKeyManager = new SessionKeyManager(options.sessionKey, this.ui)
173-
this.walletPlugins = [
174-
...this.walletPlugins,
175-
new SessionKeyWalletPlugin({
176-
walletPlugins: this.walletPlugins,
177-
}),
178-
]
173+
// Only add SessionKeyWalletPlugin to wallet picker if not disabled
174+
if (!options.sessionKey.disableWalletPlugin) {
175+
this.walletPlugins = [
176+
...this.walletPlugins,
177+
new SessionKeyWalletPlugin({
178+
walletPlugins: this.walletPlugins,
179+
}),
180+
]
181+
}
179182
}
180183
}
181184

src/sessionkey/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ export interface SessionKeyConfig {
3333
) => Promise<API.v1.AccountPermission | undefined>
3434
/** Skip showing consent UI to user during setup. Default is false. */
3535
skipConsent?: boolean
36+
/** Disable SessionKeyWalletPlugin from appearing in the wallet picker. Default is false. */
37+
disableWalletPlugin?: boolean
3638
}
3739

3840
/**

src/sessionkey/wallet.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ export class SessionKeyWalletPlugin
222222
}
223223

224224
login(context: LoginContext): Promise<WalletPluginLoginResponse> {
225+
if (!this.primaryWallet) {
226+
throw new Error(
227+
'Session key wallet is not configured. Please log in with a regular wallet first to set up a session key.'
228+
)
229+
}
225230
return this.primaryWallet.login(context)
226231
}
227232

0 commit comments

Comments
 (0)