Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump dependencies #299

Merged
merged 4 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint", "import", "vitest", "jsdoc"],
"plugins": [
"@typescript-eslint",
"import",
"@vitest",
"jsdoc"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
Expand All @@ -15,19 +20,34 @@
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:jsdoc/recommended",
"plugin:vitest/recommended",
"plugin:@vitest/legacy-recommended",
"plugin:prettier/recommended"
],
"rules": {
"curly": "warn",
"eqeqeq": "warn",
"semi": "warn",
"@typescript-eslint/consistent-type-imports": "warn",
"jsdoc/require-jsdoc": [
"warn",
{
"publicOnly": true
}
],
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index"
],
"newlines-between": "always"
}
],
"import/no-unresolved": [
"error",
{
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll": true
"source.fixAll": "explicit"
poveden marked this conversation as resolved.
Show resolved Hide resolved
},
"editor.formatOnSave": true,
"typescript.tsdk": "./node_modules/typescript/lib"
Expand Down
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## Unreleased

### Added

- Include scope in token for authorization_code and refresh_token grants (by [PetrasJaug](https://github.com/PetrasJaug))

### Changed

- Update dependencies

## [7.1.2](https://github.com/axa-group/oauth2-mock-server/compare/v7.1.1...v7.1.2) — 2024-05-21

### Changed

- Add support for Node.js 22
- Add support for Node.js 22 (by [sheinbergon](https://github.com/sheinbergon))

## [7.1.1](https://github.com/axa-group/oauth2-mock-server/compare/v7.1.0...v7.1.1) — 2023-10-24

Expand Down
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,30 @@
"dependencies": {
"basic-auth": "^2.0.1",
"cors": "^2.8.5",
"express": "^4.18.2",
"express": "^4.21.1",
"is-plain-object": "^5.0.0",
"jose": "^5.3.0"
"jose": "^5.9.6"
},
"devDependencies": {
"@types/basic-auth": "^1.1.5",
"@types/cors": "^2.8.15",
"@types/express": "^4.17.20",
"@types/node": "^18.18.6",
"@types/supertest": "^2.0.15",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"@vitest/coverage-v8": "^0.34.6",
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jsdoc": "^46.8.2",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-vitest": "^0.3.8",
"prettier": "^3.0.3",
"rimraf": "^5.0.5",
"supertest": "^6.3.3",
"typescript": "^5.2.2",
"vitest": "^0.34.6"
"@types/basic-auth": "^1.1.6",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/node": "^18.19.64",
"@types/supertest": "^6.0.2",
"@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0",
"@vitest/coverage-v8": "^2.1.5",
"@vitest/eslint-plugin": "^1.1.10",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^50.5.0",
"eslint-plugin-prettier": "^5.2.1",
"prettier": "^3.1.1",
"rimraf": "^5.0.10",
"supertest": "^7.0.0",
"typescript": "^5.3.3",
"vitest": "^2.1.5"
},
"resolutions": {
"@types/node": "^18"
Expand Down
8 changes: 4 additions & 4 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

/* eslint-disable jsdoc/require-jsdoc */

import { AssertionError } from 'assert';
import type { AddressInfo } from 'net';
import { readFileSync } from 'fs';
import { AssertionError } from 'node:assert';
import type { AddressInfo } from 'node:net';
import { readFileSync } from 'node:fs';
import { webcrypto as crypto } from 'node:crypto';

import { isPlainObject } from 'is-plain-object';

import type { CodeChallenge, PKCEAlgorithm, TokenRequest } from './types';
import { webcrypto as crypto } from 'crypto';

export const defaultTokenTtl = 3600;

Expand Down
12 changes: 7 additions & 5 deletions src/lib/http-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
* @module lib/http-server
*/

import { Server, RequestListener, createServer } from 'http';
import { createServer as createHttpsServer } from 'https';
import { AddressInfo, isIP } from 'net';
import { URL } from 'url';
import type { Server, RequestListener } from 'node:http';
import { createServer } from 'node:http';
import { createServer as createHttpsServer } from 'node:https';
import type { AddressInfo } from 'node:net';
import { isIP } from 'node:net';
import { URL } from 'node:url';

import { assertIsAddressInfo } from './helpers';
import { HttpServerOptions } from './types';
import type { HttpServerOptions } from './types';

/**
* Provides a restartable wrapper for http.CreateServer().
Expand Down
21 changes: 10 additions & 11 deletions src/lib/jwk-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,15 @@
* @module lib/jwk-store
*/

import { KeyObject, randomBytes } from 'crypto';
import { KeyObject, randomBytes } from 'node:crypto';
import { AssertionError } from 'node:assert';

import {
exportJWK,
importJWK,
generateKeyPair,
GenerateKeyPairOptions,
} from 'jose';
import type { GenerateKeyPairOptions } from 'jose';
import { exportJWK, importJWK, generateKeyPair } from 'jose';

import { JWK } from './types';
import { JWKWithKid } from './types-internals';
import { AssertionError } from 'assert';
import type { JWK } from './types';
import type { JWKWithKid } from './types-internals';
import { assertIsPlainObject } from './helpers';

const generateRandomKid = () => {
return randomBytes(40).toString('hex');
Expand Down Expand Up @@ -90,9 +87,11 @@ const privateToPublicTransformerMap: Record<string, JwkTransformer> = {
const supportedAlgs = Object.keys(privateToPublicTransformerMap);

function normalizeKeyKid(
jwk: Record<string, unknown>,
jwk: unknown,
opts?: { kid?: string },
): asserts jwk is JWKWithKid {
assertIsPlainObject(jwk, 'Invalid jwk format');

if (jwk['kid'] !== undefined) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/oauth2-issuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
* @module lib/oauth2-issuer
*/

import { EventEmitter } from 'events';
import { EventEmitter } from 'node:events';

import { importJWK, SignJWT } from 'jose';

import { JWKStore } from './jwk-store';
import { assertIsString, defaultTokenTtl } from './helpers';
import { Header, MutableToken, Payload, TokenBuildOptions } from './types';
import type { Header, MutableToken, Payload, TokenBuildOptions } from './types';
import { InternalEvents } from './types-internals';

/**
Expand Down
12 changes: 7 additions & 5 deletions src/lib/oauth2-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
* @module lib/oauth2-server
*/

import { readFileSync } from 'fs';
import { AddressInfo } from 'net';
import { Server } from 'http';
import { readFileSync } from 'node:fs';
import type { AddressInfo } from 'node:net';
import type { Server } from 'node:http';

import { HttpServer } from './http-server';
import { OAuth2Issuer } from './oauth2-issuer';
import { OAuth2Service } from './oauth2-service';
import { assertIsAddressInfo } from './helpers';
import { HttpServerOptions, OAuth2Options } from './types';
import type { HttpServerOptions, OAuth2Options } from './types';

/**
* Represents an OAuth2 HTTP server.
Expand All @@ -43,7 +43,9 @@ export class OAuth2Server extends HttpServer {
*/
constructor(key?: string, cert?: string, oauth2Options?: OAuth2Options) {
if ((key && !cert) || (!key && cert)) {
throw 'Both key and cert need to be supplied to start the server with https';
throw new Error(
'Both key and cert need to be supplied to start the server with https',
);
}

const iss = new OAuth2Issuer();
Expand Down
13 changes: 7 additions & 6 deletions src/lib/oauth2-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
* @module lib/oauth2-service
*/

import { IncomingMessage, type RequestListener } from 'http';
import { URL } from 'url';
import type { IncomingMessage, RequestListener } from 'node:http';
import { URL } from 'node:url';
import { randomUUID } from 'node:crypto';
import { EventEmitter } from 'node:events';
import { AssertionError } from 'node:assert';

import express, { type RequestHandler } from 'express';
import cors from 'cors';
import basicAuth from 'basic-auth';
import { EventEmitter } from 'events';
import { randomUUID } from 'crypto';

import { OAuth2Issuer } from './oauth2-issuer';
import type { OAuth2Issuer } from './oauth2-issuer';
import {
assertIsString,
assertIsStringOrUndefined,
Expand All @@ -50,7 +52,6 @@ import type {
} from './types';
import { Events } from './types';
import { InternalEvents } from './types-internals';
import { AssertionError } from 'assert';

const DEFAULT_ENDPOINTS: OAuth2Endpoints = Object.freeze({
wellKnownDocument: '/.well-known/openid-configuration',
Expand Down
4 changes: 3 additions & 1 deletion src/lib/types-internals.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { JWK as JoseJWK } from 'jose';
import type { JWK as JoseJWK } from 'jose';

export interface JWKWithKid extends JoseJWK {
kid: string;
alg: string;
[propName: string]: unknown;
}

export enum InternalEvents {
Expand Down
7 changes: 4 additions & 3 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ServerOptions } from 'https';
import { JWKWithKid } from './types-internals';
import { supportedPkceAlgorithms } from './helpers';
import type { ServerOptions } from 'node:https';

import type { JWKWithKid } from './types-internals';
import type { supportedPkceAlgorithms } from './helpers';

export interface TokenRequest {
scope?: string;
Expand Down
7 changes: 4 additions & 3 deletions src/oauth2-mock-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
* limitations under the License.
*/

import { writeFile } from 'fs/promises';
import path from 'path';
import { writeFile } from 'node:fs/promises';
import path from 'node:path';

import { OAuth2Server } from './index';
import { assertIsString, readJsonFromFile, shift } from './lib/helpers';
import type { JWK, Options } from './lib/types';

import { OAuth2Server } from './index';

/* eslint no-console: off */

const defaultOptions: Options = {
Expand Down
3 changes: 2 additions & 1 deletion test/cli.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { afterEach, describe, it, expect, vi } from 'vitest';
import { writeFile } from 'fs/promises';

import { afterEach, describe, it, expect, vi } from 'vitest';

import { exec } from './lib/child-script';

vi.mock('fs/promises', () => ({
Expand Down
5 changes: 3 additions & 2 deletions test/helpers.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';
import type { AddressInfo } from 'net';

import { describe, expect, it } from 'vitest';

import {
assertIsAddressInfo,
assertIsPlainObject,
Expand All @@ -13,7 +14,7 @@ import {
pkceVerifierMatchesChallenge,
shift,
} from '../src/lib/helpers';
import { CodeChallenge, PKCEAlgorithm } from '../src';
import type { CodeChallenge, PKCEAlgorithm } from '../src';

describe('helpers', () => {
describe('assertIsString', () => {
Expand Down
5 changes: 3 additions & 2 deletions test/http-server.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, it, expect } from 'vitest';
import { readFileSync } from 'fs';
import { RequestListener } from 'http';
import type { RequestListener } from 'http';

import { describe, it, expect } from 'vitest';
import request from 'supertest';

import { HttpServer } from '../src/lib/http-server';
Expand Down
1 change: 1 addition & 0 deletions test/jwk-store.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, it, expect } from 'vitest';

import { JWKStore } from '../src/lib/jwk-store';

import * as testKeys from './keys';

describe('JWK Store', () => {
Expand Down
1 change: 1 addition & 0 deletions test/keys/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path';

import { readJsonFromFile } from '../../src/lib/helpers';

export function getParsed(filename: string): Record<string, unknown> {
Expand Down
3 changes: 2 additions & 1 deletion test/lib/child-script.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import util from 'util';
import { OAuth2Server } from '../../src';

import type { OAuth2Server } from '../../src';

interface Output {
result: OAuth2Server | null;
Expand Down
Loading
Loading