1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

Check all requirements while duck typing

This commit is contained in:
Matt Gibson
2022-11-17 14:12:38 -05:00
parent 05353b63d4
commit f6dbf5294c

View File

@@ -24,7 +24,11 @@ export function browserSession<TCtor extends Constructor<any>>(constructor: TCto
// Require state service to be injected
const stateService: BrowserStateService = [this as any]
.concat(args)
.find((arg) => typeof arg.setInSessionMemory === "function");
.find(
(arg) =>
typeof arg.setInSessionMemory === "function" &&
typeof arg.getFromSessionMemory === "function"
);
if (!stateService) {
throw new Error(
`Cannot decorate ${constructor.name} with browserSession, Browser's StateService must be injected`