mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 06:28:12 +00:00
feat(fayda): add fayda verification endpoints and login-with-fayda
This commit is contained in:
@@ -15,6 +15,8 @@ export interface FaydaJwk {
|
||||
qi?: string;
|
||||
}
|
||||
|
||||
export type FaydaPlatform = 'WEB' | 'MOBILE';
|
||||
|
||||
export interface FaydaConfig {
|
||||
enabled: boolean;
|
||||
clientId: string;
|
||||
@@ -23,8 +25,6 @@ export interface FaydaConfig {
|
||||
userInfoEndpoint: string;
|
||||
redirectUri: string;
|
||||
privateJwk: FaydaJwk;
|
||||
successRedirectUrl: string;
|
||||
failureRedirectUrl: string;
|
||||
scope: string;
|
||||
acrValues: string;
|
||||
claimsLocales: string;
|
||||
@@ -36,10 +36,7 @@ const REQUIRED_VARS = [
|
||||
'FAYDA_AUTHORIZATION_ENDPOINT',
|
||||
'FAYDA_TOKEN_ENDPOINT',
|
||||
'FAYDA_USERINFO_ENDPOINT',
|
||||
'FAYDA_REDIRECT_URI',
|
||||
'FAYDA_PRIVATE_KEY_BASE64',
|
||||
'FAYDA_SUCCESS_REDIRECT_URL',
|
||||
'FAYDA_FAILURE_REDIRECT_URL',
|
||||
] as const;
|
||||
|
||||
function decodePrivateJwk(base64: string): FaydaJwk {
|
||||
@@ -73,7 +70,7 @@ export default registerAs('fayda', (): FaydaConfig => {
|
||||
const acrValues = process.env.FAYDA_ACR_VALUES ?? 'mosip:idp:acr:generated-code';
|
||||
const claimsLocales = process.env.FAYDA_CLAIMS_LOCALES ?? 'en am';
|
||||
const sessionTtl = Number.parseInt(process.env.FAYDA_SESSION_TTL_MINUTES ?? '10', 10);
|
||||
|
||||
const redirectUri = process.env.FAYDA_REDIRECT_URI ?? '';
|
||||
if (!enabled) {
|
||||
return {
|
||||
enabled: false,
|
||||
@@ -81,10 +78,8 @@ export default registerAs('fayda', (): FaydaConfig => {
|
||||
authorizationEndpoint: process.env.FAYDA_AUTHORIZATION_ENDPOINT ?? '',
|
||||
tokenEndpoint: process.env.FAYDA_TOKEN_ENDPOINT ?? '',
|
||||
userInfoEndpoint: process.env.FAYDA_USERINFO_ENDPOINT ?? '',
|
||||
redirectUri: process.env.FAYDA_REDIRECT_URI ?? '',
|
||||
redirectUri,
|
||||
privateJwk: { kty: 'RSA', n: '', e: '', d: '' },
|
||||
successRedirectUrl: process.env.FAYDA_SUCCESS_REDIRECT_URL ?? '',
|
||||
failureRedirectUrl: process.env.FAYDA_FAILURE_REDIRECT_URL ?? '',
|
||||
scope,
|
||||
acrValues,
|
||||
claimsLocales,
|
||||
@@ -98,6 +93,11 @@ export default registerAs('fayda', (): FaydaConfig => {
|
||||
`Fayda integration is enabled (FAYDA_ENABLED=true) but the following env vars are missing: ${missing.join(', ')}`,
|
||||
);
|
||||
}
|
||||
if (!redirectUri) {
|
||||
throw new Error(
|
||||
'Fayda integration is enabled but the redirect URI is missing: set FAYDA_REDIRECT_URI',
|
||||
);
|
||||
}
|
||||
if (Number.isNaN(sessionTtl) || sessionTtl <= 0) {
|
||||
throw new Error('FAYDA_SESSION_TTL_MINUTES must be a positive integer');
|
||||
}
|
||||
@@ -108,10 +108,8 @@ export default registerAs('fayda', (): FaydaConfig => {
|
||||
authorizationEndpoint: process.env.FAYDA_AUTHORIZATION_ENDPOINT!,
|
||||
tokenEndpoint: process.env.FAYDA_TOKEN_ENDPOINT!,
|
||||
userInfoEndpoint: process.env.FAYDA_USERINFO_ENDPOINT!,
|
||||
redirectUri: process.env.FAYDA_REDIRECT_URI!,
|
||||
redirectUri,
|
||||
privateJwk: decodePrivateJwk(process.env.FAYDA_PRIVATE_KEY_BASE64!),
|
||||
successRedirectUrl: process.env.FAYDA_SUCCESS_REDIRECT_URL!,
|
||||
failureRedirectUrl: process.env.FAYDA_FAILURE_REDIRECT_URL!,
|
||||
scope,
|
||||
acrValues,
|
||||
claimsLocales,
|
||||
|
||||
Reference in New Issue
Block a user