diff --git a/package.json b/package.json index 496c46f..5afabbf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@authsignal/node", - "version": "1.1.2", + "version": "1.1.3", "main": "./dist/index.js", "module": "./dist/index.mjs", "types": "dist/index.d.ts", @@ -21,6 +21,7 @@ "axios": "^1.7.2" }, "devDependencies": { + "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-typescript": "^8.3.2", "@types/node": "^17.0.35", "@typescript-eslint/eslint-plugin": "^5.25.0", diff --git a/rollup.config.js b/rollup.config.js index e7f035b..c6fb053 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,4 +1,5 @@ import typescript from "@rollup/plugin-typescript"; +import json from "@rollup/plugin-json"; export default { input: "src/index.ts", @@ -12,6 +13,6 @@ export default { format: "esm", }, ], - plugins: [typescript()], + plugins: [typescript(), json()], external: ["axios"], }; diff --git a/src/authsignal.ts b/src/authsignal.ts index 99c3953..d4dbc3b 100644 --- a/src/authsignal.ts +++ b/src/authsignal.ts @@ -1,4 +1,5 @@ -import axios from "axios"; +import axios, {AxiosRequestConfig} from "axios"; +import {version} from "../package.json"; import { AuthsignalConstructor, @@ -134,8 +135,11 @@ export class Authsignal { return {action, ...rest}; } - private getBasicAuthConfig() { + private getBasicAuthConfig(): AxiosRequestConfig { return { + headers: { + "X-Authsignal-Node-Version": version, + }, auth: { username: this.secret, password: "", diff --git a/tsconfig.json b/tsconfig.json index 17ee655..43d789a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,8 @@ "strict": true, "esModuleInterop": true, "declaration": true, - "declarationDir": "dist" + "declarationDir": "dist", + "resolveJsonModule": true, }, "include": ["./src/**/*.ts"] } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index d8ecf9f..16b44cf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -52,6 +52,13 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@rollup/plugin-json@^6.1.0": + version "6.1.0" + resolved "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-6.1.0.tgz#fbe784e29682e9bb6dee28ea75a1a83702e7b805" + integrity sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA== + dependencies: + "@rollup/pluginutils" "^5.1.0" + "@rollup/plugin-typescript@^8.3.2": version "8.3.2" resolved "https://registry.yarnpkg.com/@rollup/plugin-typescript/-/plugin-typescript-8.3.2.tgz#e1b719e2ed3e752bbc092001656c48378f2d15f0" @@ -69,11 +76,25 @@ estree-walker "^1.0.1" picomatch "^2.2.2" +"@rollup/pluginutils@^5.1.0": + version "5.1.0" + resolved "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz#7e53eddc8c7f483a4ad0b94afb1f7f5fd3c771e0" + integrity sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g== + dependencies: + "@types/estree" "^1.0.0" + estree-walker "^2.0.2" + picomatch "^2.3.1" + "@types/estree@0.0.39": version "0.0.39" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== +"@types/estree@^1.0.0": + version "1.0.5" + resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" + integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== + "@types/json-schema@^7.0.9": version "7.0.11" resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" @@ -446,6 +467,11 @@ estree-walker@^1.0.1: resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700" integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg== +estree-walker@^2.0.2: + version "2.0.2" + resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac" + integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w== + esutils@^2.0.2: version "2.0.3" resolved "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"