Skip to content

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

Merge pull request #7833 from Infisical/fix/validate-signup-signin-emails

Victor Hugo dos Santosb9e1afabb836
diff --cc backend/src/keystore/keystore.ts
index 0ddc28ec66,ebeaac6dc5..598b0e6319
--- a/backend/src/keystore/keystore.ts
+++ b/backend/src/keystore/keystore.ts
@@@ -287,8 -288,8 +296,9 @@@ export type TKeyStoreFactory =
incrementBy: (key: string, value: number) => Promise<number>;
incrementByAndRefreshExpiryIfUnderLimit: (key: string, limit: number, expiryInSeconds: number) => Promise<number>;
decrementByOrDelete: (key: string) => Promise<number>;
+ claimLeastLoaded: (keys: string[], baseOccupancies: number[], expiryInSeconds: number) => Promise<number>;
incrementByWithExpiry: (key: string, value: number, expiryInSeconds: number) => Promise<number>;
+ probeDistinctMember: (key: string, member: string, expiryInSeconds: number) => Promise<boolean>;
incrementSeededWithExpiry: (key: string, seed: number, expiryInSeconds: number) => Promise<number>;
getKeysByPattern: (pattern: string, limit?: number) => Promise<string[]>;
// list operations
@@@ -788,8 -755,8 +812,9 @@@ export const keyStoreFactory =
incrementBy,
incrementByAndRefreshExpiryIfUnderLimit,
decrementByOrDelete,
+ claimLeastLoaded,
incrementByWithExpiry,
+ probeDistinctMember,
incrementSeededWithExpiry,
acquireLock(resources: string[], duration: number, settings?: Partial<Settings>) {
return redisLock.acquire(resources, duration, settings);
diff --cc backend/src/keystore/memory.ts
index b84e04d888,2543b44772..8daabe7d98
--- a/backend/src/keystore/memory.ts
+++ b/backend/src/keystore/memory.ts
@@@ -119,38 -121,17 +121,44 @@@ export const inMemoryKeyStore = (): TKe
store[key] = String(next);
return next;
},
- incrementByAndRefreshExpiryIfUnderLimit: async () => {
- return 1;
+ // Enforces the limit rather than always admitting. The stub used to return 1 unconditionally,
+ // which silently disabled any cap built on it for whoever wired this store in next.
+ incrementByAndRefreshExpiryIfUnderLimit: async (key, limit) => {
+ const current = typeof store[key] === "string" ? parseInt(store[key] as string, 10) : 0;
+ const next = current + 1;
+ if (next > limit) return -1;
+ store[key] = String(next);
+ return next;
},
- decrementByOrDelete: async () => {
- return 0;
+ claimLeastLoaded: async (keys, baseOccupancies) => {
+ if (keys.length === 0) return 0;
+ if (keys.length !== baseOccupancies.length) {
+ throw new Error("claimLeastLoaded: baseOccupancies must have one entry per key");
+ }
+ let bestIdx = 0;
+ let bestTotal: number | null = null;
+ keys.forEach((key, i) => {
+ const reserved = typeof store[key] === "string" ? parseInt(store[key] as string, 10) : 0;
+ const total = baseOccupancies[i] + reserved;
+ if (bestTotal === null || total < bestTotal) {
+ bestTotal = total;
+ bestIdx = i + 1;
+ }
+ });
+ const chosen = keys[bestIdx - 1];
+ const current = typeof store[chosen] === "string" ? parseInt(store[chosen] as string, 10) : 0;
+ store[chosen] = String(current + 1);
+ return bestIdx;
+ },
+ decrementByOrDelete: async (key) => {
+ const current = typeof store[key] === "string" ? parseInt(store[key] as string, 10) : 0;
+ const next = current - 1;
+ if (next <= 0) {
+ delete store[key];
+ return 0;
+ }
+ store[key] = String(next);
+ return next;
},
incrementByWithExpiry: async (key, value) => {
const current = typeof store[key] === "string" ? parseInt(store[key] as string, 10) : 0;