1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-14 07:23:45 +00:00

introduce DefaultSendAccessService.authenticate$

This commit is contained in:
✨ Audrey ✨
2025-07-21 18:32:29 -04:00
parent d8ddf13e23
commit dfef036cb6
6 changed files with 402 additions and 4 deletions

View File

@@ -48,6 +48,19 @@ export class DefaultSemanticLogger<Context extends object> implements SemanticLo
throw new Error(panicMessage);
}
panicWhen<T>(
when: boolean,
content: Jsonify<T> | string,
message?: string,
): when is false | never {
if (when) {
// type conversion safe because Jsonify<string> === string
this.panic(content as Jsonify<T | string>, message);
}
return !when;
}
private log<T>(content: Jsonify<T>, level: LogLevelType, message?: string) {
const log = {
...this.context,

View File

@@ -92,4 +92,24 @@ export interface SemanticLogger {
/** combined signature for overloaded methods */
panic<T>(content: Jsonify<T> | string, message?: string): never;
/** Conditionally panics.
* @param when - when this condition is true, the logger panics.
* @param message - a message to record in the log's `message` field.
*/
panicWhen(when: boolean, message: string): when is false | never;
/** Conditionally panics.
* @param when - when this condition is true, the logger panics.
* @param content - JSON content included in the log's `content` field.
* @param message - a message to record in the log's `message` field.
*/
panicWhen<T>(when: boolean, content: Jsonify<T>, message?: string): when is false | never;
/** combined signature for overloaded methods */
panicWhen<T>(
when: boolean,
content: Jsonify<T> | string,
message?: string,
): when is false | never;
}