local-tokens
Version:
Bundled oauth-mock-server with pre-configured token clients (sinple-oauth2) for testing services and middleware
72 lines • 1.91 kB
TypeScript
import { ClientCredentials, ResourceOwnerPassword } from 'simple-oauth2';
import type { ModuleOptions as SimpleOAuth2ModuleOptions } from 'simple-oauth2';
import { LocalTokenHooks } from './hooks';
interface LocalTokensConfig {
/**
* Audience, aka the Client ID
* - Used to generate tokens
* - Used to validate tokens
* - Used to build simple-oauth2 clients
* - Set as payload.aud
*/
audience: string;
/**
* Secret, aka the Client Secret
*/
secret: string;
}
interface LocalTokensLive {
/**
* JSON Web Key Store URL
*/
jwksUri: string;
/**
* Well-known OpenID Configuration URL
*/
openidUri: string;
/**
* Issuer URL, aka Server URL
*/
issuerUri: string;
/**
* Audience, aka the Client ID
*/
audience: string;
}
type Audience = string;
/**
* LocalTokenServer
* - An In-memory oauth-mock-server for generating and validating tokens
* - Includes JSON Web Key Stores (jwks) support
*/
export declare class LocalTokenServer {
hooks: LocalTokenHooks;
private _instance;
private _config;
constructor(config: LocalTokensConfig | Audience);
/**
* Get the issuer URL
* - Requires server started
*
* @returns {string} The issuer URL
*/
get issuer(): string;
/**
* Build new simple-oauth2 clients, configured to this server
*/
buildClients(): {
ClientCredentials: ClientCredentials<"client_id">;
ResourceOwnerPassword: ResourceOwnerPassword<"client_id">;
config: SimpleOAuth2ModuleOptions<"client_id">;
};
/**
* Start oauth mock server
*
* @param port {number}
* @param hostname {string}
*/
start(port?: number, hostname?: string): Promise<LocalTokensLive>;
stop(): Promise<this>;
}
export default LocalTokenServer;
//# sourceMappingURL=server.d.ts.map