Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat: resolved renew token not renewing
=87ac723fcb01
diff --git a/backend/src/services/identity-access-token/identity-access-token-service.ts b/backend/src/services/identity-access-token/identity-access-token-service.tsindex 47d1791d23..a51d80e41e 100644--- a/backend/src/services/identity-access-token/identity-access-token-service.ts+++ b/backend/src/services/identity-access-token/identity-access-token-service.ts@@ -78,9 +78,7 @@ export const identityAccessTokenServiceFactory = ({const renewAccessToken = async ({ accessToken }: TRenewAccessTokenDTO) => {const appCfg = getConfig();- const decodedToken = jwt.verify(accessToken, appCfg.AUTH_SECRET) as JwtPayload & {- identityAccessTokenId: string;- };+ const decodedToken = jwt.verify(accessToken, appCfg.AUTH_SECRET) as TIdentityAccessTokenJwtPayload;if (decodedToken.authTokenType !== AuthTokenType.IDENTITY_ACCESS_TOKEN) {throw new BadRequestError({ message: "Only identity access tokens can be renewed" });}@@ -127,7 +125,23 @@ export const identityAccessTokenServiceFactory = ({accessTokenLastRenewedAt: new Date()});- return { accessToken, identityAccessToken: updatedIdentityAccessToken };+ const renewedToken = jwt.sign(+ {+ identityId: decodedToken.identityId,+ clientSecretId: decodedToken.clientSecretId,+ identityAccessTokenId: decodedToken.identityAccessTokenId,+ authTokenType: AuthTokenType.IDENTITY_ACCESS_TOKEN+ } as TIdentityAccessTokenJwtPayload,+ appCfg.AUTH_SECRET,+ // akhilmhdh: for non-expiry tokens you should not even set the value, including undefined. Even for undefined jsonwebtoken throws error+ Number(identityAccessToken.accessTokenTTL) === 0+ ? undefined+ : {+ expiresIn: Number(identityAccessToken.accessTokenTTL)+ }+ );++ return { accessToken: renewedToken, identityAccessToken: updatedIdentityAccessToken };};const revokeAccessToken = async (accessToken: string) => {