32 lines
720 B
TypeScript
32 lines
720 B
TypeScript
/**
|
|
* OIDC/OAuth2 helpers
|
|
*/
|
|
|
|
export interface OIDCConfig {
|
|
issuer: string;
|
|
clientId: string;
|
|
clientSecret: string;
|
|
redirectUri: string;
|
|
}
|
|
|
|
export class OIDCProvider {
|
|
constructor(private config: OIDCConfig) {}
|
|
|
|
async getAuthorizationUrl(state: string): Promise<string> {
|
|
const params = new URLSearchParams({
|
|
client_id: this.config.clientId,
|
|
redirect_uri: this.config.redirectUri,
|
|
response_type: 'code',
|
|
scope: 'openid profile email',
|
|
state,
|
|
});
|
|
return `${this.config.issuer}/authorize?${params.toString()}`;
|
|
}
|
|
|
|
async exchangeCodeForToken(code: string): Promise<string> {
|
|
// Implementation for token exchange
|
|
throw new Error('Not implemented');
|
|
}
|
|
}
|
|
|