Remove cooldown parameter option
Signed-off-by: Andy Caruso <macaruso@gmail.com>
This commit is contained in:
@@ -185,7 +185,7 @@ describe('IdentityClient', () => {
|
||||
|
||||
it('should accept token from new key', async () => {
|
||||
const fixedTime = Date.now();
|
||||
const spy = jest
|
||||
jest
|
||||
.spyOn(Date, 'now')
|
||||
.mockImplementation(() => fixedTime - keyDurationSeconds * 1000 * 2);
|
||||
const token1 = await factory.issueToken({ claims: { sub: 'foo1' } });
|
||||
@@ -195,8 +195,13 @@ describe('IdentityClient', () => {
|
||||
} catch (_err) {
|
||||
// Ignore thrown error
|
||||
}
|
||||
// Move forward in time where the signing key has been rotated
|
||||
spy.mockRestore();
|
||||
// Move forward in time where the signing key has been rotated and the
|
||||
// cooldown period to look up a new public key has elapsed.
|
||||
jest
|
||||
.spyOn(Date, 'now')
|
||||
.mockImplementation(
|
||||
() => fixedTime + 30 * keyDurationSeconds * 1000 + 2,
|
||||
);
|
||||
const token = await factory.issueToken({ claims: { sub: 'foo' } });
|
||||
const response = await client.authenticate(token);
|
||||
expect(response).toEqual({
|
||||
|
||||
@@ -41,30 +41,22 @@ export class IdentityClient {
|
||||
/**
|
||||
* Create a new {@link IdentityClient} instance.
|
||||
*/
|
||||
static create(
|
||||
options: {
|
||||
discovery: PluginEndpointDiscovery;
|
||||
issuer: string;
|
||||
},
|
||||
cooldownMs = 30000,
|
||||
): IdentityClient {
|
||||
return new IdentityClient(options, cooldownMs);
|
||||
static create(options: {
|
||||
discovery: PluginEndpointDiscovery;
|
||||
issuer: string;
|
||||
}): IdentityClient {
|
||||
return new IdentityClient(options);
|
||||
}
|
||||
|
||||
private constructor(
|
||||
options: {
|
||||
discovery: PluginEndpointDiscovery;
|
||||
issuer: string;
|
||||
},
|
||||
cooldownMs: number,
|
||||
) {
|
||||
private constructor(options: {
|
||||
discovery: PluginEndpointDiscovery;
|
||||
issuer: string;
|
||||
}) {
|
||||
this.discovery = options.discovery;
|
||||
this.issuer = options.issuer;
|
||||
this.discovery.getBaseUrl('auth').then(url => {
|
||||
this.endpoint = new URL(`${url}/.well-known/jwks.json`);
|
||||
this.keyStore = createRemoteJWKSet(this.endpoint, {
|
||||
cooldownDuration: cooldownMs,
|
||||
});
|
||||
this.keyStore = createRemoteJWKSet(this.endpoint);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user