Skip to content
Open
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
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

54 changes: 0 additions & 54 deletions .eslintrc

This file was deleted.

8 changes: 5 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:

jobs:
lint:
name: Javascript standard lint
name: Javascript Biome lint/format
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -28,8 +28,10 @@ jobs:
with:
node-version: 24
cache: npm
- run: npm clean-install
- run: npm run lint
- run: |
npm clean-install
npm run lint
npm run format

unittest:
name: unit tests
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Complete, compliant and well tested module for implementing an OAuth2 server in

[![Tests](https://github.com/node-oauth/node-oauth2-server/actions/workflows/tests.yml/badge.svg)](https://github.com/node-oauth/node-oauth2-server/actions/workflows/tests.yml)
[![CodeQL Semantic Analysis](https://github.com/node-oauth/node-oauth2-server/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/node-oauth/node-oauth2-server/actions/workflows/codeql-analysis.yml)
[![Tests for Release](https://github.com/node-oauth/node-oauth2-server/actions/workflows/tests-release.yml/badge.svg)](https://github.com/node-oauth/node-oauth2-server/actions/workflows/tests-release.yml)
[![Documentation Status](https://readthedocs.org/projects/node-oauthoauth2-server/badge/?version=latest)](https://node-oauthoauth2-server.readthedocs.io/en/latest/?badge=latest)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![npm Version](https://img.shields.io/npm/v/@node-oauth/oauth2-server?label=version)](https://www.npmjs.com/package/@node-oauth/oauth2-server)
[![npm Downloads/Week](https://img.shields.io/npm/dw/@node-oauth/oauth2-server)](https://www.npmjs.com/package/@node-oauth/oauth2-server)
[![GitHub License](https://img.shields.io/github/license/node-oauth/node-oauth2-server)](https://github.com/node-oauth/node-oauth2-server/blob/master/LICENSE)
[![Formatted with Biome](https://img.shields.io/badge/Formatted_with-Biome-60a5fa?style=flat&logo=biome)](https://biomejs.dev/)

NOTE: This project has been forked from [oauthjs/node-oauth2-server](https://github.com/oauthjs/node-oauth2-server) and is a continuation due to the project appearing to be abandoned. Please see [our issue board](https://github.com/node-oauth/node-oauth2-server/issues) to talk about next steps and the future of this project.

Expand Down
59 changes: 59 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"$schema": "https://biomejs.dev/schemas/2.5.0/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": true,
"includes": ["index.js", "lib/**/*.js", "test/**/*.js"]
},
Comment thread
jankapunkt marked this conversation as resolved.
"formatter": {
"enabled": true,
"indentStyle": "tab"
},
"linter": {
"enabled": true,
"rules": {
"preset": "recommended",
"suspicious": {
"noRedundantUseStrict": "off",
"noPrototypeBuiltins": "off",
"useIsArray": "off",
"noGlobalAssign": "off"
},
"complexity": {
"useArrowFunction": "off",
"useDateNow": "off",
"useOptionalChain": "off",
"useLiteralKeys": "off",
"noUselessThisAlias": "off"
},
"correctness": {
"noUnusedFunctionParameters": "off",
"noUnusedVariables": "off"
},
"style": {
"useNodejsImportProtocol": "off",
"useTemplate": "off"
}
}
Comment thread
jankapunkt marked this conversation as resolved.
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"indentStyle": "space",
"trailingCommas": "none",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"trailingCommas": "none",
"trailingCommas": "all",

Trailing commas "all" is biome's default and also appears to be what we already have in place; I'm also a big fan because it keeps diffs less noisy when adding new items

"lineWidth": 120
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ exports.UnauthorizedClientError = require('./lib/errors/unauthorized-client-erro
exports.UnauthorizedRequestError = require('./lib/errors/unauthorized-request-error');
exports.UnsupportedGrantTypeError = require('./lib/errors/unsupported-grant-type-error');
exports.UnsupportedResponseTypeError = require('./lib/errors/unsupported-response-type-error');

8 changes: 4 additions & 4 deletions lib/errors/access-denied-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ const OAuthError = require('./oauth-error');
*/
class AccessDeniedError extends OAuthError {
/**
* @constructor
* @param message {string}
* @param properties {object=}
*/
* @constructor
* @param message {string}
* @param properties {object=}
*/
constructor(message, properties) {
properties = {
code: 400,
Expand Down
2 changes: 1 addition & 1 deletion lib/errors/insufficient-scope-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class InsufficientScopeError extends OAuthError {
* @constructor
* @param message {string}
* @param properties {object=}
*/
*/
constructor(message, properties) {
properties = {
code: 403,
Expand Down
2 changes: 1 addition & 1 deletion lib/errors/invalid-argument-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class InvalidArgumentError extends OAuthError {
* @constructor
* @param message {string}
* @param properties {object=}
*/
*/
constructor(message, properties) {
properties = {
code: 500,
Expand Down
8 changes: 4 additions & 4 deletions lib/errors/invalid-client-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ const OAuthError = require('./oauth-error');

class InvalidClientError extends OAuthError {
/**
* @constructor
* @param message {string}
* @param properties {object=}
*/
* @constructor
* @param message {string}
* @param properties {object=}
*/
constructor(message, properties) {
properties = {
code: 400,
Expand Down
8 changes: 4 additions & 4 deletions lib/errors/invalid-grant-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const OAuthError = require('./oauth-error');

class InvalidGrantError extends OAuthError {
/**
* @constructor
* @param message {string}
* @param properties {object=}
*/
* @constructor
* @param message {string}
* @param properties {object=}
*/
constructor(message, properties) {
properties = {
code: 400,
Expand Down
8 changes: 4 additions & 4 deletions lib/errors/oauth-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const http = require('http');
*/
class OAuthError extends Error {
/**
* @constructor
* @param messageOrError
* @param properties
*/
* @constructor
* @param messageOrError
* @param properties
*/
constructor(messageOrError, properties) {
super(messageOrError, properties);

Expand Down
60 changes: 29 additions & 31 deletions lib/grant-types/abstract-grant-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ const { parseScope } = require('../utils/scope-util');
*/
class AbstractGrantType {
/**
* @constructor
* @param options {object}
* @param options.accessTokenLifetime {number} access token lifetime in seconds
* @param options.model {Model} the model
* @param options.refreshTokenLifetime {number}
* @param [options.alwaysIssueNewRefreshToken=true] {boolean=} Always revoke the used refresh token and issue a new one for the `refresh_token` grant.
* @throws {InvalidArgumentError} if {options.accessTokenLifeTime} is missing
* @throws {InvalidArgumentError} if {options.model} is missing
*/
constructor (options) {
* @constructor
* @param options {object}
* @param options.accessTokenLifetime {number} access token lifetime in seconds
* @param options.model {Model} the model
* @param options.refreshTokenLifetime {number}
* @param [options.alwaysIssueNewRefreshToken=true] {boolean=} Always revoke the used refresh token and issue a new one for the `refresh_token` grant.
* @throws {InvalidArgumentError} if {options.accessTokenLifeTime} is missing
* @throws {InvalidArgumentError} if {options.model} is missing
*/
constructor(options) {
options = options || {};

if (!options.accessTokenLifetime) {
Expand All @@ -42,17 +42,17 @@ class AbstractGrantType {
}

/**
* Generate access token.
* If the model implements `generateAccessToken` then
* this implementation will be used.
* Otherwise, falls back to an internal implementation from `TokenUtil.generateRandomToken`.
*
* @param client
* @param user
* @param scope
* @return {Promise<string>}
*/
async generateAccessToken (client, user, scope) {
* Generate access token.
* If the model implements `generateAccessToken` then
* this implementation will be used.
* Otherwise, falls back to an internal implementation from `TokenUtil.generateRandomToken`.
*
* @param client
* @param user
* @param scope
* @return {Promise<string>}
*/
async generateAccessToken(client, user, scope) {
if (this.model.generateAccessToken) {
// We should not fall back to a random accessToken, if the model did not
// return a token, in order to prevent unintended token-issuing.
Expand All @@ -63,9 +63,9 @@ class AbstractGrantType {
}

/**
* Generate refresh token.
*/
async generateRefreshToken (client, user, scope) {
* Generate refresh token.
*/
async generateRefreshToken(client, user, scope) {
if (this.model.generateRefreshToken) {
// We should not fall back to a random refreshToken, if the model did not
// return a token, in order to prevent unintended token-issuing.
Expand All @@ -76,19 +76,17 @@ class AbstractGrantType {
}

/**
* Get access token expiration date.
*/
* Get access token expiration date.
*/
getAccessTokenExpiresAt() {
return new Date(Date.now() + this.accessTokenLifetime * 1000);
}



/**
* Get refresh token expiration date (now + refresh token lifetime)
* @returns {Date}
*/
getRefreshTokenExpiresAt () {
getRefreshTokenExpiresAt() {
return new Date(Date.now() + this.refreshTokenLifetime * 1000);
}

Expand All @@ -97,7 +95,7 @@ class AbstractGrantType {
* @param request {Request}
* @returns {string|undefined}
*/
getScope (request) {
getScope(request) {
return parseScope(request.body.scope);
}

Expand All @@ -112,7 +110,7 @@ class AbstractGrantType {
* @return {string} the validated scope
* @throws {InvalidScopeError} if the {Model#validateScope} method returned a falsy value
*/
async validateScope (user, client, scope) {
async validateScope(user, client, scope) {
if (this.model.validateScope) {
const validatedScope = await this.model.validateScope(user, client, scope);

Expand Down
Loading
Loading