From 790c2c026a70942e66ffc5fa985013ac36a7d29f Mon Sep 17 00:00:00 2001 From: Mark Bishop Date: Mon, 22 Jan 2024 13:45:31 -0500 Subject: [PATCH 1/5] Change how version string is loaded from package.json --- src/constants.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 1272c6e..0c24aca 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -3,9 +3,7 @@ // // SPDX-License-Identifier: MIT -import fs from 'fs'; - -const pkg = JSON.parse(fs.readFileSync('package.json', { encoding: 'utf-8' })); +import { version } from '../package.json'; export const CLIENT_ID_LENGTH = 20; export const CLIENT_SECRET_LENGTH = 40; @@ -16,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'; From 9faf9115be623d1fffc7e7ff3abe2c9af6ac9454 Mon Sep 17 00:00:00 2001 From: Mark Bishop Date: Wed, 7 Feb 2024 14:51:59 -0500 Subject: [PATCH 2/5] Prepend the directory when loading package.json constants --- package.json | 1 + src/constants.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bc3a06c..ee16856 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" }, "files": [ + "package.json", "dist" ], "scripts": { diff --git a/src/constants.ts b/src/constants.ts index 0c24aca..73d191c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -3,7 +3,12 @@ // // SPDX-License-Identifier: MIT -import { version } from '../package.json'; +import fs from 'fs'; +import path from 'path'; + +const pkg = JSON.parse( + fs.readFileSync(path.join(__dirname, '../package.json'), { encoding: 'utf-8' }) +); export const CLIENT_ID_LENGTH = 20; export const CLIENT_SECRET_LENGTH = 40; @@ -14,7 +19,7 @@ export const JTI_LENGTH = 36; export const JWT_EXPIRATION = 300; export const JWT_LEEWAY = 60; -export const USER_AGENT = `duo_universal_node/${version}`; +export const USER_AGENT = `duo_universal_node/${pkg.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'; From 017413974d564428cf57c772fcd5e3ebd7383ae0 Mon Sep 17 00:00:00 2001 From: Mark Bishop Date: Mon, 18 Mar 2024 10:43:26 -0400 Subject: [PATCH 3/5] Remove stray newline --- src/constants.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/constants.ts b/src/constants.ts index f83f033..ef232c3 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -3,7 +3,6 @@ // // SPDX-License-Identifier: MIT - import fs from 'fs'; import path from 'path'; From 100859a1335b6176a0b7bcc500aaa62de4d189e9 Mon Sep 17 00:00:00 2001 From: Mark Bishop Date: Mon, 18 Mar 2024 10:48:36 -0400 Subject: [PATCH 4/5] Fixup version --- src/constants.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index ef232c3..8342525 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -7,7 +7,7 @@ import fs from 'fs'; import path from 'path'; const pkg = JSON.parse( - fs.readFileSync(path.join(__dirname, '../package.json'), { encoding: 'utf-8' }) + fs.readFileSync(path.join(__dirname, '../package.json'), { encoding: 'utf-8' }), ); export const CLIENT_ID_LENGTH = 20; @@ -19,7 +19,7 @@ export const JTI_LENGTH = 36; export const JWT_EXPIRATION = 300; export const JWT_LEEWAY = 60; -export const USER_AGENT = `duo_universal_node/${version}`; +export const USER_AGENT = `duo_universal_node/${pkg.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'; From 7d225b6fd1036781597d34cfb970b4e690007b21 Mon Sep 17 00:00:00 2001 From: Mark Bishop Date: Mon, 18 Mar 2024 10:52:47 -0400 Subject: [PATCH 5/5] Remove comma --- src/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants.ts b/src/constants.ts index 8342525..73d191c 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -7,7 +7,7 @@ import fs from 'fs'; import path from 'path'; const pkg = JSON.parse( - fs.readFileSync(path.join(__dirname, '../package.json'), { encoding: 'utf-8' }), + fs.readFileSync(path.join(__dirname, '../package.json'), { encoding: 'utf-8' }) ); export const CLIENT_ID_LENGTH = 20;