mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 23:03:32 +00:00
[PM-11764] Implement account switching and sdk initialization (#11472)
* feat: update sdk service abstraction with documentation and new `userClient$` function * feat: add uninitialized user client with cache * feat: initialize user crypto * feat: initialize org keys * fix: org crypto not initializing properly * feat: avoid creating clients unnecessarily * chore: remove dev print/subscription * fix: clean up cache * chore: update sdk version * feat: implement clean-up logic (#11504) * chore: bump sdk version to fix build issues * chore: bump sdk version to fix build issues * fix: missing constructor parameters * refactor: simplify free() and delete() calls * refactor: use a named function for client creation * fix: client never freeing after refactor * fix: broken impl and race condition in tests
This commit is contained in:
@@ -2,9 +2,27 @@ import { Observable } from "rxjs";
|
||||
|
||||
import { BitwardenClient } from "@bitwarden/sdk-internal";
|
||||
|
||||
import { UserId } from "../../../types/guid";
|
||||
|
||||
export abstract class SdkService {
|
||||
client$: Observable<BitwardenClient>;
|
||||
/**
|
||||
* Check if the SDK is supported in the current environment.
|
||||
*/
|
||||
supported$: Observable<boolean>;
|
||||
|
||||
/**
|
||||
* Retrieve a client initialized without a user.
|
||||
* This client can only be used for operations that don't require a user context.
|
||||
*/
|
||||
client$: Observable<BitwardenClient | undefined>;
|
||||
|
||||
/**
|
||||
* Retrieve a client initialized for a specific user.
|
||||
* This client can be used for operations that require a user context, such as retrieving ciphers
|
||||
* and operations involving crypto. It can also be used for operations that don't require a user context.
|
||||
* @param userId
|
||||
*/
|
||||
abstract userClient$(userId: UserId): Observable<BitwardenClient>;
|
||||
|
||||
abstract failedToInitialize(): Promise<void>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user