Skip to content

Commit 0826099

Browse files
authored
Merge pull request #333 from axa-group/ntk/bump
Bump dependencies
2 parents 017ddb1 + f96daab commit 0826099

19 files changed

+904
-690
lines changed

.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 60 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import eslint from '@eslint/js';
2+
import jsdoc from 'eslint-plugin-jsdoc';
3+
import tseslint from 'typescript-eslint';
4+
import prettierConfig from 'eslint-config-prettier';
5+
import eslintPluginPrettierRecommendedConfig from 'eslint-plugin-prettier/recommended';
6+
import importPlugin from 'eslint-plugin-import';
7+
import vitest from '@vitest/eslint-plugin';
8+
9+
export default tseslint.config(
10+
eslint.configs.recommended,
11+
tseslint.configs.strictTypeChecked,
12+
tseslint.configs.stylisticTypeChecked,
13+
prettierConfig,
14+
eslintPluginPrettierRecommendedConfig,
15+
importPlugin.flatConfigs.recommended,
16+
importPlugin.flatConfigs.typescript,
17+
jsdoc.configs['flat/recommended-typescript'],
18+
{
19+
languageOptions: {
20+
parserOptions: {
21+
projectService: true,
22+
tsconfigRootDir: import.meta.dirname,
23+
},
24+
},
25+
},
26+
{
27+
ignores: ['node_modules/*', 'dist/*', 'coverage/*', '.vscode/*'],
28+
},
29+
{
30+
rules: {
31+
curly: 'warn',
32+
eqeqeq: 'warn',
33+
semi: 'warn',
34+
'@typescript-eslint/consistent-type-imports': 'warn',
35+
'jsdoc/require-jsdoc': [
36+
'warn',
37+
{
38+
publicOnly: true,
39+
},
40+
],
41+
"import/order": [
42+
"error",
43+
{
44+
"groups": [
45+
"builtin",
46+
"external",
47+
"internal",
48+
"parent",
49+
"sibling",
50+
"index"
51+
],
52+
"newlines-between": "always"
53+
}
54+
],
55+
},
56+
},
57+
{
58+
files: ['test/**/*.test.ts'],
59+
plugins: {
60+
vitest,
61+
},
62+
rules: {
63+
...vitest.configs.recommended.rules,
64+
},
65+
settings: {
66+
vitest: {
67+
typecheck: true,
68+
},
69+
},
70+
languageOptions: {
71+
globals: {
72+
...vitest.environments.env.globals,
73+
},
74+
},
75+
},
76+
{
77+
files: ['test/**/*.ts'],
78+
rules: {
79+
'@typescript-eslint/no-non-null-assertion': 'off',
80+
'@typescript-eslint/no-unsafe-assignment': 'off',
81+
'@typescript-eslint/no-unsafe-member-access': 'off',
82+
'jsdoc/require-jsdoc': 'off',
83+
},
84+
},
85+
);

package.json

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,30 +55,33 @@
5555
"dependencies": {
5656
"basic-auth": "^2.0.1",
5757
"cors": "^2.8.5",
58-
"express": "^4.21.2",
58+
"express": "^5.1.0",
5959
"is-plain-object": "^5.0.0",
6060
"jose": "^5.10.0"
6161
},
6262
"devDependencies": {
63+
"@eslint/js": "^9.26.0",
6364
"@types/basic-auth": "^1.1.6",
6465
"@types/cors": "^2.8.17",
65-
"@types/express": "^4.17.21",
66-
"@types/node": "^18.19.87",
66+
"@types/express": "^5.0.1",
67+
"@types/node": "^18.19.97",
6768
"@types/supertest": "^6.0.3",
68-
"@typescript-eslint/eslint-plugin": "^8.31.1",
69-
"@typescript-eslint/parser": "^8.31.1",
70-
"@vitest/coverage-v8": "^3.1.2",
71-
"@vitest/eslint-plugin": "^1.1.43",
72-
"eslint": "^8.57.1",
73-
"eslint-config-prettier": "^9.1.0",
74-
"eslint-plugin-import": "^2.29.1",
69+
"@typescript-eslint/eslint-plugin": "^8.32.0",
70+
"@typescript-eslint/parser": "^8.32.0",
71+
"@vitest/coverage-v8": "^3.1.3",
72+
"@vitest/eslint-plugin": "^1.1.44",
73+
"eslint": "^9.26.0",
74+
"eslint-config-prettier": "^10.1.3",
75+
"eslint-import-resolver-typescript": "^4.3.4",
76+
"eslint-plugin-import": "^2.31.0",
7577
"eslint-plugin-jsdoc": "^50.6.11",
76-
"eslint-plugin-prettier": "^5.2.6",
78+
"eslint-plugin-prettier": "^5.4.0",
7779
"prettier": "^3.5.3",
7880
"rimraf": "^5.0.10",
7981
"supertest": "^7.1.0",
8082
"typescript": "^5.8.3",
81-
"vitest": "^3.1.2"
83+
"typescript-eslint": "^8.32.0",
84+
"vitest": "^3.1.3"
8285
},
8386
"resolutions": {
8487
"@types/node": "^18"

src/lib/helpers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ export function assertIsValidTokenRequest(
9090
if ('aud' in body) {
9191
const aud = body['aud'];
9292
if (Array.isArray(aud)) {
93-
aud.forEach((a) => assertIsString(a, "Invalid 'aud' type"));
93+
aud.forEach((a) => {
94+
assertIsString(a, "Invalid 'aud' type");
95+
});
9496
} else {
9597
assertIsString(aud, "Invalid 'aud' type");
9698
}

src/lib/http-server.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ export class HttpServer {
3737

3838
/**
3939
* Creates a new instance of HttpServer.
40-
* @param {RequestListener} requestListener The function that will handle the server's requests.
41-
* @param {HttpServerOptions} options Optional HttpServerOptions to start the server with https.
40+
* @param requestListener The function that will handle the server's requests.
41+
* @param options Optional HttpServerOptions to start the server with https.
4242
*/
4343
constructor(requestListener: RequestListener, options?: HttpServerOptions) {
4444
this.#isSecured = false;
4545

46-
if (options?.key && options?.cert) {
46+
if (options?.key && options.cert) {
4747
this.#server = createHttpsServer(options, requestListener);
4848
this.#isSecured = true;
4949
} else {
@@ -53,7 +53,7 @@ export class HttpServer {
5353

5454
/**
5555
* Returns a value indicating whether or not the server is listening for connections.
56-
* @type {boolean}
56+
* @returns A boolean value indicating whether the server is listening.
5757
*/
5858
get listening(): boolean {
5959
return this.#server.listening;
@@ -62,7 +62,7 @@ export class HttpServer {
6262
/**
6363
* Returns the bound address, family name and port where the server is listening,
6464
* or null if the server has not been started.
65-
* @returns {AddressInfo} The server bound address information.
65+
* @returns The server bound address information.
6666
*/
6767
address(): AddressInfo {
6868
if (!this.listening) {
@@ -78,9 +78,9 @@ export class HttpServer {
7878

7979
/**
8080
* Starts the server.
81-
* @param {number} [port] Port number. If omitted, it will be assigned by the operating system.
82-
* @param {string} [host] Host name.
83-
* @returns {Promise<void>} A promise that resolves when the server has been started.
81+
* @param port Port number. If omitted, it will be assigned by the operating system.
82+
* @param host Host name.
83+
* @returns A promise that resolves when the server has been started.
8484
*/
8585
async start(port?: number, host?: string): Promise<Server> {
8686
if (this.listening) {
@@ -97,7 +97,7 @@ export class HttpServer {
9797

9898
/**
9999
* Stops the server.
100-
* @returns {Promise} Resolves when the server has been stopped.
100+
* @returns Resolves when the server has been stopped.
101101
*/
102102
async stop(): Promise<void> {
103103
if (!this.listening) {
@@ -107,17 +107,18 @@ export class HttpServer {
107107
return new Promise((resolve, reject) => {
108108
this.#server.close((err) => {
109109
if (err) {
110-
return reject(err);
110+
reject(err);
111+
return;
111112
}
112113

113-
return resolve();
114+
resolve();
114115
});
115116
});
116117
}
117118

118119
protected buildIssuerUrl(host: string | undefined, port: number): string {
119120
const url = new URL(
120-
`${this.#isSecured ? 'https' : 'http'}://localhost:${port}`,
121+
`${this.#isSecured ? 'https' : 'http'}://localhost:${port.toString()}`,
121122
);
122123

123124
if (host && !coversLocalhost(host)) {

src/lib/jwk-store.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function normalizeKeyKid(
9696
return;
9797
}
9898

99-
if (opts !== undefined && opts.kid !== undefined) {
99+
if (opts?.kid !== undefined) {
100100
jwk['kid'] = opts.kid;
101101
} else {
102102
jwk['kid'] = generateRandomKid();
@@ -118,18 +118,18 @@ export class JWKStore {
118118

119119
/**
120120
* Generates a new random key and adds it into this keystore.
121-
* @param {string} alg The selected algorithm.
122-
* @param {object} [opts] The options.
123-
* @param {string} [opts.kid] The key identifier to use.
124-
* @param {string} [opts.crv] The OKP "crv" to be used for "EdDSA" algorithm.
125-
* @returns {Promise<JWK>} The promise for the generated key.
121+
* @param alg The selected algorithm.
122+
* @param opts The options.
123+
* @param opts.kid The key identifier to use.
124+
* @param opts.crv The OKP "crv" to be used for "EdDSA" algorithm.
125+
* @returns The promise for the generated key.
126126
*/
127127
async generate(
128128
alg: string,
129129
opts?: { kid?: string; crv?: string },
130130
): Promise<JWK> {
131131
const generateOpts: GenerateKeyPairOptions =
132-
opts !== undefined && opts.crv !== undefined ? { crv: opts.crv } : {};
132+
opts?.crv !== undefined ? { crv: opts.crv } : {};
133133

134134
const pair = await generateKeyPair(alg, generateOpts);
135135
const joseJwk = await exportJWK(pair.privateKey);
@@ -144,15 +144,15 @@ export class JWKStore {
144144

145145
/**
146146
* Adds a JWK key to this keystore.
147-
* @param {object} maybeJwk The JWK key to add.
148-
* @returns {Promise<JWK>} The promise for the added key.
147+
* @param maybeJwk The JWK key to add.
148+
* @returns The promise for the added key.
149149
*/
150150
async add(maybeJwk: Record<string, unknown>): Promise<JWK> {
151151
const tempJwk = { ...maybeJwk };
152152

153153
normalizeKeyKid(tempJwk);
154154

155-
if (tempJwk.alg === undefined) {
155+
if (!('alg' in tempJwk)) {
156156
throw new Error('Unspecified JWK "alg" property');
157157
}
158158

@@ -178,8 +178,8 @@ export class JWKStore {
178178
/**
179179
* Gets a key from the keystore in a round-robin fashion.
180180
* If a 'kid' is provided, only keys that match will be taken into account.
181-
* @param {string} [kid] The optional key identifier to match keys against.
182-
* @returns {JWK.Key | null} The retrieved key.
181+
* @param kid The optional key identifier to match keys against.
182+
* @returns The retrieved key.
183183
*/
184184
get(kid?: string): JWK | undefined {
185185
return this.#keyRotator.next(kid);
@@ -188,9 +188,9 @@ export class JWKStore {
188188
/**
189189
* Generates a JSON representation of this keystore, which conforms
190190
* to a JWK Set from {I-D.ietf-jose-json-web-key}.
191-
* @param {boolean} [includePrivateFields] `true` if the private fields
191+
* @param [includePrivateFields] `true` if the private fields
192192
* of stored keys are to be included.
193-
* @returns {JWK[]} The JSON representation of this keystore.
193+
* @returns The JSON representation of this keystore.
194194
*/
195195
toJSON(includePrivateFields = false): JWK[] {
196196
return this.#keyRotator.toJSON(includePrivateFields);

src/lib/oauth2-issuer.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import { InternalEvents } from './types-internals';
3333
export class OAuth2Issuer extends EventEmitter {
3434
/**
3535
* Sets or returns the issuer URL.
36-
* @type {string}
3736
*/
3837
url: string | undefined;
3938

@@ -51,16 +50,16 @@ export class OAuth2Issuer extends EventEmitter {
5150

5251
/**
5352
* Returns the key store.
54-
* @type {JWKStore}
53+
* @returns The key store.
5554
*/
5655
get keys(): JWKStore {
5756
return this.#keys;
5857
}
5958

6059
/**
6160
* Builds a JWT.
62-
* @param {TokenBuildOptions} [opts] JWT token building overrides
63-
* @returns {Promise<string>} The produced JWT.
61+
* @param opts JWT token building overrides
62+
* @returns The produced JWT.
6463
* @fires OAuth2Issuer#beforeSigning
6564
*/
6665
async buildToken(opts?: TokenBuildOptions): Promise<string> {

0 commit comments

Comments
 (0)