1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-23 03:33:54 +00:00

[PM-16790] introduce extension service (#13590)

This commit is contained in:
✨ Audrey ✨
2025-03-06 11:32:42 -05:00
committed by GitHub
parent 6f4a1ea37f
commit 9761588a2a
19 changed files with 461 additions and 39 deletions

View File

@@ -0,0 +1,27 @@
import { isClassifiedFormat } from "./classified-format";
describe("isClassifiedFormat", () => {
it("returns `false` when the argument is `null`", () => {
expect(isClassifiedFormat(null)).toEqual(false);
});
it.each([
[{ id: true, secret: "" }],
[{ secret: "", disclosed: {} }],
[{ id: true, disclosed: {} }],
])("returns `false` when the argument is missing a required member (=%p).", (value) => {
expect(isClassifiedFormat(value)).toEqual(false);
});
it("returns `false` when 'secret' is not a string", () => {
expect(isClassifiedFormat({ id: true, secret: false, disclosed: {} })).toEqual(false);
});
it("returns `false` when 'disclosed' is not an object", () => {
expect(isClassifiedFormat({ id: true, secret: "", disclosed: false })).toEqual(false);
});
it("returns `true` when the argument has a `secret`, `disclosed`, and `id`.", () => {
expect(isClassifiedFormat({ id: true, secret: "", disclosed: {} })).toEqual(true);
});
});

View File

@@ -21,5 +21,12 @@ export type ClassifiedFormat<Id, Disclosed> = {
export function isClassifiedFormat<Id, Disclosed>(
value: any,
): value is ClassifiedFormat<Id, Disclosed> {
return "id" in value && "secret" in value && "disclosed" in value;
return (
!!value &&
"id" in value &&
"secret" in value &&
"disclosed" in value &&
typeof value.secret === "string" &&
typeof value.disclosed === "object"
);
}

View File

@@ -523,6 +523,7 @@ export class UserStateSubject<
private onError(value: any) {
if (!this.isDisposed) {
this.log.debug(value, "forwarding error to subscribers");
this.output.error(value);
}