From 3bd10469471d32b42d9632f2efa327766f7ee56b Mon Sep 17 00:00:00 2001 From: Lukas Hroch <lukashroch@gmail.com> Date: Sat, 18 Jan 2025 18:03:05 +0000 Subject: [PATCH] fix: read version from package file - tsup and extracts version as constant from the json file --- package.json | 1 - src/constants.ts | 9 ++------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 6bb29f0..eb754b3 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,6 @@ "node": ">=18.12.0" }, "files": [ - "package.json", "dist" ], "scripts": { diff --git a/src/constants.ts b/src/constants.ts index 8342525..0c24aca 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -3,12 +3,7 @@ // // SPDX-License-Identifier: MIT -import fs from 'fs'; -import path from 'path'; - -const pkg = JSON.parse( - fs.readFileSync(path.join(__dirname, '../package.json'), { encoding: 'utf-8' }), -); +import { version } from '../package.json'; export const CLIENT_ID_LENGTH = 20; export const CLIENT_SECRET_LENGTH = 40; @@ -19,7 +14,7 @@ export const JTI_LENGTH = 36; export const JWT_EXPIRATION = 300; export const JWT_LEEWAY = 60; -export const USER_AGENT = `duo_universal_node/${pkg.version}`; +export const USER_AGENT = `duo_universal_node/${version}`; export const SIG_ALGORITHM = 'HS512'; export const GRANT_TYPE = 'authorization_code'; export const CLIENT_ASSERTION_TYPE = 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer';