From ec4734b8ab42aee68ece3cb3d58ea8a21bc0e69a Mon Sep 17 00:00:00 2001 From: "lluis@protofy.xyz" Date: Thu, 7 Nov 2024 01:47:39 +0100 Subject: [PATCH] Increase expiry time for devices token --- packages/protonode/src/lib/crypt.ts | 4 ++-- packages/protonode/src/lib/serviceToken.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/protonode/src/lib/crypt.ts b/packages/protonode/src/lib/crypt.ts index c6e3693c4..b48d44c8f 100644 --- a/packages/protonode/src/lib/crypt.ts +++ b/packages/protonode/src/lib/crypt.ts @@ -4,8 +4,8 @@ import jwt from 'jsonwebtoken'; export const hash = async (password: string) => bcrypt.hash(password, 10) export const checkPassword = async (password: string, hash: string) => bcrypt.compare(password, hash) -export const genToken = (data:any) => { - return jwt.sign(data, process.env.TOKEN_SECRET ?? '', { expiresIn: '3600000s' }); +export const genToken = (data:any,options:any={ expiresIn: '3600000s' }) => { + return jwt.sign(data, process.env.TOKEN_SECRET ?? '', options); } export const verifyToken = (token: string) => { diff --git a/packages/protonode/src/lib/serviceToken.ts b/packages/protonode/src/lib/serviceToken.ts index b45f1c727..87946df35 100644 --- a/packages/protonode/src/lib/serviceToken.ts +++ b/packages/protonode/src/lib/serviceToken.ts @@ -9,5 +9,5 @@ export const getServiceToken = () => { } export const getDeviceToken = (deviceId,isAdmin:boolean=false) =>{ - return genToken({id: deviceId, type: 'device', admin: isAdmin===false?false:true}) + return genToken({id: deviceId, type: 'device', admin: isAdmin},{expiresIn: '100y'}) } \ No newline at end of file