feat(oidc): persist hashed OIDC tokens, authorization codes, and user consent in smartdata storage
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import * as plugins from '../plugins.js';
|
||||
import type { OidcManager } from './classes.oidcmanager.js';
|
||||
|
||||
@plugins.smartdata.Manager()
|
||||
export class OidcUserConsent extends plugins.smartdata.SmartDataDbDoc<
|
||||
OidcUserConsent,
|
||||
plugins.idpInterfaces.data.IUserConsent,
|
||||
OidcManager
|
||||
> {
|
||||
@plugins.smartdata.unI()
|
||||
public id: string;
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
public data: plugins.idpInterfaces.data.IUserConsent['data'] = {
|
||||
userId: '',
|
||||
clientId: '',
|
||||
scopes: [],
|
||||
grantedAt: 0,
|
||||
updatedAt: 0,
|
||||
};
|
||||
|
||||
public async grantScopes(scopesArg: plugins.idpInterfaces.data.TOidcScope[]) {
|
||||
this.data.scopes = [...new Set([...this.data.scopes, ...scopesArg])];
|
||||
if (!this.data.grantedAt) {
|
||||
this.data.grantedAt = Date.now();
|
||||
}
|
||||
this.data.updatedAt = Date.now();
|
||||
await this.save();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user