@salesforce/b2c-tooling-sdk / cli / AuthSessionStoreHook
Type Alias: AuthSessionStoreHook
AuthSessionStoreHook =
Hook<"b2c:auth-session-store">
Defined in: packages/b2c-tooling-sdk/src/cli/hooks.ts:407
Hook type for b2c:auth-session-store.
Implement this hook in your oclif plugin to store auth sessions somewhere other than the default file in the CLI data directory, such as an OS keychain or a secrets manager.
The hook is called during command initialization, before any authentication is performed. Only one store is used: if several plugins return a backend, the first plugin by name wins and the others are ignored with a warning.
AuthSessionBackend is synchronous because session lookups happen while commands initialize. Backends over async storage should load their sessions inside the hook (which may be async), serve reads from memory, write in the background, and implement flush() so the CLI can wait for pending writes before exiting.
Plugin Registration
{
"oclif": {
"hooks": {
"b2c:auth-session-store": "./dist/hooks/auth-session-store.js"
}
}
}Example
import type { AuthSessionStoreHook } from '@salesforce/b2c-tooling-sdk/cli';
const hook: AuthSessionStoreHook = async function() {
if (process.platform !== 'darwin') return {};
return { backend: new KeychainAuthSessionBackend() };
};
export default hook;