Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(user-auth): use ms library and update docs

carlosmonastyrskic99440ba81f4
diff --git a/backend/src/lib/fn/time.ts b/backend/src/lib/fn/time.ts
index a7fca66e8d..27bd8f8a6d 100644
--- a/backend/src/lib/fn/time.ts
+++ b/backend/src/lib/fn/time.ts
@@ -1,29 +1,16 @@
+import ms, { StringValue } from "ms";
+
const convertToMilliseconds = (exp: string | number): number => {
if (typeof exp === "number") {
return exp * 1000;
}
- const match = exp.match(/^(\d+)\s*([a-z]*)$/i);
- if (!match) {
+ const result = ms(exp as StringValue);
+ if (typeof result !== "number") {
throw new Error(`Invalid expiration format: ${exp}`);
}
- const value = parseInt(match[1], 10);
- const unit = match[2].toLowerCase();
-
- switch (unit) {
- case "":
- case "s":
- return value * 1000; // seconds
- case "m":
- return value * 60 * 1000; // minutes
- case "h":
- return value * 60 * 60 * 1000; // hours
- case "d":
- return value * 24 * 60 * 60 * 1000; // days
- default:
- throw new Error(`Unsupported time unit: ${unit}`);
- }
+ return result;
};
export const getMinExpiresIn = (exp1: string | number, exp2: string | number): string | number => {
diff --git a/docs/documentation/platform/organization.mdx b/docs/documentation/platform/organization.mdx
index f1c62ff37f..3a53484fb8 100644
--- a/docs/documentation/platform/organization.mdx
+++ b/docs/documentation/platform/organization.mdx
@@ -27,6 +27,10 @@ The **Settings** page lets you manage information about your organization includ
![organization settings auth](../../images/platform/organization/organization-settings-auth.png)
+<Tip>
+ You can adjust the maximum time a user token will remain valid for your organization. After this period, users will be required to re-authenticate. This helps improve security by enforcing regular sign-ins.
+</Tip>
+
## Access Control
The **Access Control** page is where you can manage identities (both people and machines) that are part of your organization.
diff --git a/docs/images/platform/organization/organization-settings-auth.png b/docs/images/platform/organization/organization-settings-auth.png
index ca2340e9f2..fd7a946e02 100644
Binary files a/docs/images/platform/organization/organization-settings-auth.png and b/docs/images/platform/organization/organization-settings-auth.png differ