oidc-provider
Version:
OAuth 2.0 Authorization Server implementation for Node.js with OpenID Connect
48 lines (42 loc) • 1.23 kB
JavaScript
import epochTime from '../helpers/epoch_time.js';
import apply from './mixins/apply.js';
import consumable from './mixins/consumable.js';
import hasFormat from './mixins/has_format.js';
import hasGrantId from './mixins/has_grant_id.js';
import hasGrantType from './mixins/has_grant_type.js';
import isSenderConstrained from './mixins/is_sender_constrained.js';
import isAttestationConstrained from './mixins/is_attestation_constrained.js';
import isSessionBound from './mixins/is_session_bound.js';
import storesAuth from './mixins/stores_auth.js';
export default (provider) => class RefreshToken extends apply([
consumable,
hasGrantType,
hasGrantId,
isSenderConstrained,
isAttestationConstrained,
isSessionBound(provider),
storesAuth,
hasFormat(provider, 'RefreshToken', provider.BaseToken),
]) {
constructor(...args) {
super(...args);
if (!this.iiat) {
this.iiat = this.iat || epochTime();
}
}
static get IN_PAYLOAD() {
return [
...super.IN_PAYLOAD,
'rar',
'rotations',
'iiat',
];
}
/*
* totalLifetime()
* number of seconds since the very first refresh token chain iat
*/
totalLifetime() {
return epochTime() - this.iiat;
}
};