diff --git a/ee/packages/license/src/token.ts b/ee/packages/license/src/token.ts index 1855d880d1ee..9a77adbc4418 100644 --- a/ee/packages/license/src/token.ts +++ b/ee/packages/license/src/token.ts @@ -3,14 +3,14 @@ import crypto from 'crypto'; import type { ILicenseV3 } from '@rocket.chat/core-typings'; import { verify, sign, getPairs } from '@rocket.chat/jwt'; -const convertV2KeyToV3 = (key: string): string => Buffer.from(key, 'base64').toString('utf-8'); +const base64Decode = (key: string): string => Buffer.from(key, 'base64').toString('utf-8'); const PUBLIC_LICENSE_KEY_V2 = 'LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQ0lqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FnOEFNSUlDQ2dLQ0FnRUFxV1Nza2Q5LzZ6Ung4a3lQY2ljcwpiMzJ3Mnd4VnV3N3lCVDk2clEvOEQreU1lQ01POXdTU3BIYS85bkZ5d293RXRpZ3B0L3dyb1BOK1ZHU3didHdQCkZYQmVxRWxCbmRHRkFsODZlNStFbGlIOEt6L2hHbkNtSk5tWHB4RUsyUkUwM1g0SXhzWVg3RERCN010eC9pcXMKY2pCL091dlNCa2ppU2xlUzdibE5JVC9kQTdLNC9DSjNvaXUwMmJMNEV4Y2xDSGVwenFOTWVQM3dVWmdweE9uZgpOT3VkOElYWUs3M3pTY3VFOEUxNTdZd3B6Q0twVmFIWDdaSmY4UXVOc09PNVcvYUlqS2wzTDYyNjkrZUlPRXJHCndPTm1hSG56Zmc5RkxwSmh6Z3BPMzhhVm43NnZENUtLakJhaldza1krNGEyZ1NRbUtOZUZxYXFPb3p5RUZNMGUKY0ZXWlZWWjNMZWg0dkVNb1lWUHlJeng5Nng4ZjIveW1QbmhJdXZRdjV3TjRmeWVwYTdFWTVVQ2NwNzF6OGtmUAo0RmNVelBBMElEV3lNaWhYUi9HNlhnUVFaNEdiL3FCQmh2cnZpSkNGemZZRGNKZ0w3RmVnRllIUDNQR0wwN1FnCnZMZXZNSytpUVpQcnhyYnh5U3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KEYS: [string, string] | undefined = undefined; @@ -28,7 +28,7 @@ export async function decryptStatsToken(encrypted: string): Promise { return JSON.stringify(payload); } - const [payload] = await verify(encrypted, convertV2KeyToV3(PUBLIC_STATS_KEY_V2)); + const [payload] = await verify(encrypted, base64Decode(PUBLIC_STATS_KEY_V2)); return JSON.stringify(payload); }