backend-common: refactor away namespace usage in ServerTokenManager

Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
This commit is contained in:
MT Lewis
2021-11-26 13:38:32 +00:00
parent f5c43945eb
commit a8eeaa13b4
2 changed files with 11 additions and 34 deletions
+1 -13
View File
@@ -537,19 +537,7 @@ export class ServerTokenManager implements TokenManager {
token: string;
}>;
// (undocumented)
static noop(): ServerTokenManager.NoopTokenManager;
}
// @public (undocumented)
export namespace ServerTokenManager {
export class NoopTokenManager implements TokenManager {
// (undocumented)
authenticate(): Promise<void>;
// (undocumented)
getToken(): Promise<{
token: string;
}>;
}
static noop(): TokenManager;
}
// @public (undocumented)
@@ -19,6 +19,14 @@ import { Config } from '@backstage/config';
import { AuthenticationError } from '@backstage/errors';
import { TokenManager } from './types';
class NoopTokenManager implements TokenManager {
async getToken() {
return { token: '' };
}
async authenticate() {}
}
/**
* Creates and validates tokens for use during backend-to-backend
* authentication.
@@ -29,8 +37,8 @@ export class ServerTokenManager implements TokenManager {
private readonly verificationKeys: JWKS.KeyStore;
private readonly signingKey: JWK.Key;
static noop() {
return new ServerTokenManager.NoopTokenManager();
static noop(): TokenManager {
return new NoopTokenManager();
}
static fromConfig(config: Config) {
@@ -70,22 +78,3 @@ export class ServerTokenManager implements TokenManager {
}
}
}
/**
* @public
*/
export namespace ServerTokenManager {
/**
* Stub token manager which returns empty tokens and always
* authenticates successfully.
*
* @public
*/
export class NoopTokenManager implements TokenManager {
async getToken() {
return { token: '' };
}
async authenticate() {}
}
}