Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
A development and test oriented OAuth2 mock server
| Date | Stars |
|---|---|
| 2026-07-30 | 254 |
| 2026-08-09 | 255 |
| 2026-08-17 | 257 |
| 2026-08-20 | 258 |
| 2026-09-03 | 258 |
| 2026-09-23 | 259 |
| 2026-09-30 | 259 |
| 2026-10-02 | 260 |
| 2026-10-07 | 260 |
| 2026-10-24 | 259 |
| 2026-10-28 | 260 |
| 2026-11-04 | 260 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
35.0
growth rate 0.00%/day
# `oauth2-mock-server`
[](https://www.npmjs.com/package/oauth2-mock-server)
[](https://nodejs.org/)
> _OAuth 2 mock server. Intended to be used for development or testing purposes._
When developing an application that exposes or consumes APIs that are secured with an [OAuth 2](https://oauth.net/2/) authorization scheme, a mechanism for issuing access tokens is needed. Frequently, a developer needs to create custom code that fakes the creation of tokens for testing purposes, and these tokens cannot be properly verified, since there is no actual entity issuing those tokens.
The purpose of this package is to provide an easily configurable OAuth 2 server, that can be set up and torn down at will, and can be programmatically run while performing automated tests.
- **Real cryptography.** Tokens are signed with actual JWK key pairs. Consuming applications can verify them using the `/jwks` endpoint, without mocking the verification layer.
- **OIDC-conformant.** Exposes all the endpoints a real provider would: discovery, JWKS, authorization code flow with PKCE, userinfo, token introspection, revocation, and end session.
- **Programmatic and CLI.** Embed it in a JavaScript or TypeScript test suite (`beforeAll`/`afterAll`) or run it as a standalone process for Java, .NET, Python, and other non-JS projects.
- **Per-test customization via event hooks.** Use `server.service.once(Events.xxx, ...)` to alter token claims, simulate errors, or modify responses for a single test — without reconfiguring the server.
- **TypeScript-first.** Full type definitions ship with the package. The entire codebase is written in strict TypeScript.
> **Warning:** This tool is _not_ intended to be used as an actual production grade OAuth 2 server. It lacks many features that would be required in a proper implementation.
## Requirements
- [Node.js 22.12+](https://nodejs.org/)
## Installation
Add it to your Node.js project as a development dependency:
```sh
npm install --save-dev oauth2-mock-server
```
## CLI Usage
The server can be run from the command line.
```sh
npx oauth2-mock-server --help
```
## Library Usage
The server and its components can also be leveraged as a library, allowing finer control and configuration.
Here is an example for creating and running a server instance with a single random RSA key:
```js
import { OAuth2Server } from 'oauth2-mock-server';
// ...or in CommonJS style:
// const { OAuth2Server } = require('oauth2-mock-server');
let server = new OAuth2Server();
// Generate a new RSA key and add it to the keystore
await server.issuer.keys.generate('RS256');
// Start the server
await server.start(8080, 'localhost');
console.log('Issuer URL:', server.issuer.url); // -> http://localhost:8080
// Do some work with the server
// ...
// Stop the server
await server.stop();
```
Any number of existing JSON-formatted keys can be added to the keystore.
```js
// Add an existing JWK key to the keystore
await server.issuer.keys.add({
kid: 'some-key',
alg: 'RS256',
kty: 'RSA',
// ...
});
```
JSON Web Tokens (JWT) can also be built programmatically:
```js
import axios from 'axios';
// Build a new token
let token = await server.issuer.buildToken();
// Call a remote API with the token
const response = await axios.get('https://server.example.com/api/endpoint', {
headers: {
authorization: `Bearer ${token}`,
},
});
```
## HTTPS
To support HTTPS, an optional cert and key can be supplied to start the server with SSL/TLS using the in-built NodeJS [HTTPS](https://nodejs.org/api/https.html) module.
We recommend using a package to create a locally trusted certificate, like [mkcert](https://github.com/FiloSottile/mkcert).
```js
let server = new OAuth2Server(
'test-assets/mock-auth/key.pem', // Path to private key file
'test-assets/mock-auth/cert.pem', // Path to public SExcerpt of 13,604 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:20a978c72eaae534, topic:testing