Cookies validation and Security Guidelines (#242)

* Add OTP and security guidelines documentation and additional checks on client-provided values

- Introduced additional checks on client-provided values such as cookies
- Introduced a new OTP API documentation outlining the creation and verification of OTP tokens for sensitive operations.
- Added comprehensive security guidelines for writing secure code in Next.js, covering client and server components, environment variables, authentication, and error handling.

These additions enhance the project's security posture and provide clear instructions for developers on implementing secure practices.

* Add OTP API documentation and enhance security guidelines

- Introduced comprehensive documentation for the OTP API, detailing the creation and verification of OTP tokens for sensitive operations.
- Enhanced security guidelines for Next.js, emphasizing the importance of input validation, environment variable management, and error handling.
- Implemented additional checks for client-provided values to improve overall security posture.

These updates provide clear instructions for developers and strengthen the project's security framework.
This commit is contained in:
Giancarlo Buomprisco
2025-04-22 05:44:55 +07:00
committed by GitHub
parent 1327a8efb7
commit e193c94f06
7 changed files with 325 additions and 34 deletions

View File

@@ -1,11 +1,31 @@
import { getLogger } from '@kit/shared/logger';
/**
* Resolves the translation file for a given language and namespace.
*
* @name i18nResolver
* @description Resolve the translation file for the given language and namespace in the current application.
* @param language
* @param namespace
*/
export async function i18nResolver(language: string, namespace: string) {
const data = await import(
`../../public/locales/${language}/${namespace}.json`
);
const logger = await getLogger();
return data as Record<string, string>;
try {
const data = await import(
`../../public/locales/${language}/${namespace}.json`
);
return data as Record<string, string>;
} catch (error) {
console.group(
`Error while loading translation file: ${language}/${namespace}`,
);
logger.error(error instanceof Error ? error.message : error);
logger.warn(
`Please create a translation file for this language at "public/locales/${language}/${namespace}.json"`,
);
console.groupEnd();
// return an empty object if the file could not be loaded to avoid loops
return {};
}
}