Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions apps/api-gateway/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ import helmet from 'helmet';

dotenv.config();

/**
* Initializes and starts the API Gateway application with OpenTelemetry, microservices, Swagger documentation, security, middleware, and static file serving.
*
* Configures the NestJS application with custom logging, NATS microservice connection, request validation, global exception handling, CORS, API versioning, and global interceptors. Serves static files from multiple directories and sets up Swagger documentation at the `/api` endpoint. Starts the application on the host and port specified by environment variables.
*/
async function bootstrap(): Promise<void> {
try {
if (otelSDK) {
Expand Down
18 changes: 17 additions & 1 deletion apps/api-gateway/src/user/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ export const getDefaultClient = async (): Promise<IClientDetailsSSO> => ({
clientSecret: await encryptClientCredential(process.env.KEYCLOAK_MANAGEMENT_CLIENT_SECRET)
});

// Now getting from env, but can get from DB
/**
* Retrieves SSO client details for a given alias from environment variables.
*
* Constructs environment variable keys using the provided alias to obtain the client ID, client secret, domain, and alias name. If the alias name is not set in the environment, it defaults to the input alias.
*
* @param alias - The identifier used to construct environment variable keys for client credentials
* @returns An object containing the client ID, client secret, domain, and alias name
*/
function getClientDetails(alias: string): IClientDetailsSSO {
const clientIdKey = `${alias}_KEYCLOAK_MANAGEMENT_CLIENT_ID`;
const clientSecretKey = `${alias}_KEYCLOAK_MANAGEMENT_CLIENT_SECRET`;
Expand All @@ -30,6 +37,15 @@ function getClientDetails(alias: string): IClientDetailsSSO {
return clientDetails;
}

/**
* Retrieves SSO client credentials for the specified alias.
*
* If the alias matches the default client alias (case-insensitive), returns the default client details. Otherwise, fetches client details for the given alias from environment variables. Throws an error if required configuration is missing.
*
* @param alias - The client alias to retrieve credentials for
* @returns The SSO client details associated with the alias
* @throws Error if client ID, client secret, or domain are missing for the specified alias
*/
export async function getCredentialsByAlias(alias: string): Promise<IClientDetailsSSO> {
const defaultClient = await getDefaultClient();
if (alias.toUpperCase() === defaultClient.alias) {
Expand Down
16 changes: 16 additions & 0 deletions libs/common/src/cast.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,12 @@ export function checkDidLedgerAndNetwork(schemaType: string, did: string): boole
return false;
}

/**
* Updates the issuance date of each credential in the array to the current date if it differs from today.
*
* @param data - Array of credential data objects to check and update
* @returns The updated array of credential data objects
*/
export function validateAndUpdateIssuanceDates(data: ICredentialData[]): ICredentialData[] {
// Get current date in 'YYYY-MM-DD' format
// eslint-disable-next-line prefer-destructuring
Expand Down Expand Up @@ -456,6 +462,16 @@ export const encryptClientCredential = async (clientCredential: string): Promise
}
};

/**
* Decorator that validates the structure of nested schema fields based on the `schemaDataType` property.
*
* Ensures that:
* - For `object` types, only `properties` is defined and `items` is not.
* - For `array` types, only `items` is defined and `properties` is not.
* - For other types, neither `properties` nor `items` are present.
*
* Provides detailed error messages when the structure does not match the expected format for the given `schemaDataType`.
*/
export function ValidateNestedStructureFields(validationOptions?: ValidationOptions) {
return function (object: object, propertyName: string): void {
registerDecorator({
Expand Down
5 changes: 5 additions & 0 deletions libs/prisma-service/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@ const updateClientCredential = async (): Promise<void> => {
}
};

/**
* Executes the full database seeding and initialization process.
*
* Runs all seeding and setup functions in sequence to populate configuration, master data, and perform required migrations and updates.
*/
async function main(): Promise<void> {
await createPlatformConfig();
await createOrgRoles();
Expand Down