simplify example

Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2024-11-22 10:43:25 +01:00
parent 062eaf3f75
commit aea3fcf034
+1 -18
View File
@@ -436,24 +436,7 @@ const decoratedPluginTokenHandler = createServiceFactory({
deps: {},
async factory() {
return (defaultImplementation: PluginTokenHandler) =>
new (class CustomHandler implements PluginTokenHandler {
verifyToken(
token: string,
): Promise<{ subject: string; limitedUserToken?: string } | undefined> {
// custom logic here
if (isMyCustomToken(token)) {
return { subject: 'custom-subject' };
}
return defaultImplementation.verifyToken(token);
}
issueToken(options: {
pluginId: string;
targetPluginId: string;
limitedUserToken?: { token: string; expiresAt: Date };
}): Promise<{ token: string }> {
return defaultImplementation.issueToken(options);
}
})();
new CustomTokenHandler(defaultImplementation);
},
});
```