Skip to content

Commit e9bddf5

Browse files
committed
fix: proper way to hide session key from list of wallet plugin options
1 parent 2b035f7 commit e9bddf5

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

src/kit.ts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,14 @@ export class SessionKit {
170170
// Initialize session key support if configured
171171
if (options.sessionKey) {
172172
this.sessionKeyManager = new SessionKeyManager(options.sessionKey, this.ui)
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-
}
173+
// Always add SessionKeyWalletPlugin so restore works
174+
// Use disableWalletPlugin to hide from picker UI only
175+
this.walletPlugins = [
176+
...this.walletPlugins,
177+
new SessionKeyWalletPlugin({
178+
walletPlugins: this.walletPlugins,
179+
}),
180+
]
182181
}
183182
}
184183

@@ -372,13 +371,24 @@ export class SessionKit {
372371
fetch: this.fetch,
373372
loginPlugins: this.loginPlugins,
374373
ui: this.ui,
375-
walletPlugins: this.walletPlugins.map((plugin): UserInterfaceWalletPlugin => {
376-
return {
377-
config: plugin.config,
378-
metadata: WalletPluginMetadata.from(plugin.metadata),
379-
retrievePublicKey: plugin.retrievePublicKey?.bind(plugin),
380-
}
381-
}),
374+
walletPlugins: this.walletPlugins
375+
.filter((plugin) => {
376+
// Hide session key wallet from picker if disableWalletPlugin is set
377+
if (
378+
this.sessionKeyManager?.config.disableWalletPlugin &&
379+
plugin.id === 'session-key-wallet'
380+
) {
381+
return false
382+
}
383+
return true
384+
})
385+
.map((plugin): UserInterfaceWalletPlugin => {
386+
return {
387+
config: plugin.config,
388+
metadata: WalletPluginMetadata.from(plugin.metadata),
389+
retrievePublicKey: plugin.retrievePublicKey?.bind(plugin),
390+
}
391+
}),
382392
sessionKeyManager: this.sessionKeyManager,
383393
})
384394

src/sessionkey/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ 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. */
36+
/** Hide SessionKeyWalletPlugin from the wallet picker UI. Default is false. */
3737
disableWalletPlugin?: boolean
3838
}
3939

0 commit comments

Comments
 (0)