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 13aaeac8769426caa701d74f6ab76bd47cca7eab Mon Sep 17 00:00:00 2001 From: Mark Bishop Date: Mon, 22 Jan 2024 17:19:40 -0500 Subject: [PATCH 2/5] Add --resolveJsonModule to build flags --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bc3a06c..5a0f8d2 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,8 @@ "dist" ], "scripts": { - "build_for_example": "rimraf example/node_modules/@duosecurity/duo_universal && tsc --project tsconfig.build.json --outDir example/node_modules/@duosecurity/duo_universal", - "build": "rimraf dist && tsc --project tsconfig.build.json", + "build_for_example": "rimraf example/node_modules/@duosecurity/duo_universal && tsc --project tsconfig.build.json --outDir example/node_modules/@duosecurity/duo_universal --resolveJsonModule", + "build": "rimraf dist && tsc --project tsconfig.build.json --resolveJsonModule", "prepublishOnly": "npm run build", "lint": "eslint --ext .ts src/", "lint:fix": "npm run lint -- --fix", From 5ca89448af0915c628275b4700fbcbe5299eef15 Mon Sep 17 00:00:00 2001 From: Mark Bishop Date: Wed, 24 Jan 2024 11:05:49 -0500 Subject: [PATCH 3/5] Try adding current directory to rootDirs --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 504e139..3e80816 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ "declaration": true, "strict": true, "esModuleInterop": true, - "rootDir": "src", + "rootDirs": ["src", "."], "types": [ "node", "jest", From 57a6923dfc2a5103bc3ccef6b587c4239e68c159 Mon Sep 17 00:00:00 2001 From: Mark Bishop Date: Wed, 24 Jan 2024 11:14:40 -0500 Subject: [PATCH 4/5] Add JSON module flag to test --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5a0f8d2..e1d2228 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ "lint": "eslint --ext .ts src/", "lint:fix": "npm run lint -- --fix", "test": "jest", - "test:coverage": "npm run test -- --coverage", - "test:watch": "npm run test -- --watch" + "test:coverage": "npm run test -- --coverage --resolveJsonModule", + "test:watch": "npm run test -- --watch --resolveJsonModule" }, "dependencies": { "axios": "^1.2.2", From 2eb74d962c13218b2028b9f37f5d4d1825dcc6df Mon Sep 17 00:00:00 2001 From: Mark Bishop Date: Wed, 24 Jan 2024 11:26:21 -0500 Subject: [PATCH 5/5] Update tsconfig.json --- package.json | 8 ++++---- tsconfig.json | 17 ++++------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index e1d2228..bc3a06c 100644 --- a/package.json +++ b/package.json @@ -25,14 +25,14 @@ "dist" ], "scripts": { - "build_for_example": "rimraf example/node_modules/@duosecurity/duo_universal && tsc --project tsconfig.build.json --outDir example/node_modules/@duosecurity/duo_universal --resolveJsonModule", - "build": "rimraf dist && tsc --project tsconfig.build.json --resolveJsonModule", + "build_for_example": "rimraf example/node_modules/@duosecurity/duo_universal && tsc --project tsconfig.build.json --outDir example/node_modules/@duosecurity/duo_universal", + "build": "rimraf dist && tsc --project tsconfig.build.json", "prepublishOnly": "npm run build", "lint": "eslint --ext .ts src/", "lint:fix": "npm run lint -- --fix", "test": "jest", - "test:coverage": "npm run test -- --coverage --resolveJsonModule", - "test:watch": "npm run test -- --watch --resolveJsonModule" + "test:coverage": "npm run test -- --coverage", + "test:watch": "npm run test -- --watch" }, "dependencies": { "axios": "^1.2.2", diff --git a/tsconfig.json b/tsconfig.json index 3e80816..738556a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,19 +11,10 @@ "declaration": true, "strict": true, "esModuleInterop": true, + "resolveJsonModule": true, "rootDirs": ["src", "."], - "types": [ - "node", - "jest", - "jest-extended" - ] + "types": ["node", "jest", "jest-extended"] }, - "include": [ - "src/**/*.ts", - "test/**/*.ts" - ], - "exclude": [ - "node_modules", - "dist" - ] + "include": ["src/**/*.ts", "test/**/*.ts"], + "exclude": ["node_modules", "dist"] }