Skip to content

Commit 9441d08

Browse files
authored
Merge pull request #335 from axa-group/ntk/esm
Work prior to release version 8.0
2 parents 0826099 + a6b0bae commit 9441d08

17 files changed

+6218
-3837
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ubuntu-latest, macos-latest, windows-latest]
15-
node-version: [^18.12, ^20, ^22]
15+
node-version: [^20.19, ^22.12, ^24]
1616
runs-on: ${{ matrix.os }}
1717
steps:
1818
- uses: actions/checkout@v4
1919

2020
- uses: actions/setup-node@v4
2121
with:
2222
node-version: ${{ matrix.node-version }}
23-
cache: yarn
24-
cache-dependency-path: yarn.lock
23+
cache: npm
24+
cache-dependency-path: package-lock.json
2525

2626
- name: Yarn install
2727
run: yarn install --frozen-lockfile
@@ -34,3 +34,9 @@ jobs:
3434

3535
- name: Pack
3636
run: npm pack
37+
38+
- name: Check package exports
39+
run: npx publint
40+
41+
- name: Check dependencies exports
42+
run: npx publint deps --prod

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
/coverage/
33
/.vscode/
44
/.cache/
5+
/.rollup.cache/
56
/dist/

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ Generally we like to see pull requests that
2525
To run tests locally, first install all dependencies.
2626

2727
```shell
28-
yarn install
28+
npm install
2929
```
3030

3131
From the root directory, run the tests.
3232

3333
```shell
34-
yarn test
34+
npm run test
3535
```

README.md

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,14 @@ The purpose of this package is to provide an easily configurable OAuth 2 server,
1313
1414
## Development prerequisites
1515

16-
- [Node.js 18+](https://nodejs.org/)
17-
- [Yarn 1.15.2+](https://classic.yarnpkg.com/lang/en/)
16+
- [Node.js 20.19+](https://nodejs.org/)
1817

1918
## How to use
2019

2120
### Installation
2221

2322
Add it to your Node.js project as a development dependency:
2423

25-
With yarn...
26-
27-
```shell
28-
yarn add -D oauth2-mock-server
29-
```
30-
31-
...or with npm
32-
3324
```shell
3425
npm install --save-dev oauth2-mock-server
3526
```
@@ -39,7 +30,9 @@ npm install --save-dev oauth2-mock-server
3930
Here is an example for creating and running a server instance with a single random RSA key:
4031

4132
```js
42-
const { OAuth2Server } = require('oauth2-mock-server');
33+
import { OAuth2Server } from 'oauth2-mock-server';
34+
// ...or in CommonJS style:
35+
// const { OAuth2Server } = require('oauth2-mock-server');
4336

4437
let server = new OAuth2Server();
4538

@@ -72,19 +65,24 @@ await server.issuer.keys.add({
7265
JSON Web Tokens (JWT) can be built programmatically:
7366

7467
```js
75-
const request = require('request');
68+
import axios from 'axios';
7669

7770
// Build a new token
7871
let token = await server.issuer.buildToken();
7972

8073
// Call a remote API with the token
81-
request.get(
82-
'https://server.example.com/api/endpoint',
83-
{ auth: { bearer: token } },
84-
function callback(err, res, body) {
74+
axios
75+
.get('https://server.example.com/api/endpoint', {
76+
headers: {
77+
authorization: `Bearer ${token}`,
78+
},
79+
})
80+
.then((response) => {
8581
/* ... */
86-
}
87-
);
82+
})
83+
.catch((error) => {
84+
/* ... */
85+
});
8886
```
8987

9088
### Supported grant types
@@ -97,12 +95,12 @@ request.get(
9795

9896
### Supported JWK formats
9997

100-
| Algorithm | kty | alg |
101-
| ----------------- | --- | --------------------------- |
102-
| RSASSA-PKCS1-v1_5 | RSA | RS256, RS384, RS512 |
103-
| RSASSA-PSS | RSA | PS256, PS384, PS512 |
104-
| ECDSA | EC | ES256, ES256K, ES384, ES512 |
105-
| Edwards-curve DSA | OKP | EdDSA (Ed25519 / Ed448) |
98+
| Algorithm | kty | alg |
99+
| ----------------- | --- | ------------------- |
100+
| RSASSA-PKCS1-v1_5 | RSA | RS256, RS384, RS512 |
101+
| RSASSA-PSS | RSA | PS256, PS384, PS512 |
102+
| ECDSA | EC | ES256, ES384, ES512 |
103+
| EdDSA | OKP | Ed25519 |
106104

107105
### Customization hooks
108106

@@ -119,8 +117,9 @@ It also provides a convenient way, through event emitters, to programmatically c
119117
```
120118

121119
```js
122-
// Add the client ID to a token
123120
const basicAuth = require('basic-auth');
121+
122+
// Add the client ID to a token
124123
service.once('beforeTokenSigning', (token, req) => {
125124
const credentials = basicAuth(req);
126125
const clientId = credentials ? credentials.name : req.body.client_id;
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import jsdoc from 'eslint-plugin-jsdoc';
33
import tseslint from 'typescript-eslint';
44
import prettierConfig from 'eslint-config-prettier';
55
import eslintPluginPrettierRecommendedConfig from 'eslint-plugin-prettier/recommended';
6-
import importPlugin from 'eslint-plugin-import';
6+
import importPlugin from 'eslint-plugin-import-x';
77
import vitest from '@vitest/eslint-plugin';
88

99
export default tseslint.config(
@@ -18,8 +18,7 @@ export default tseslint.config(
1818
{
1919
languageOptions: {
2020
parserOptions: {
21-
projectService: true,
22-
tsconfigRootDir: import.meta.dirname,
21+
project: './tsconfig.eslint.json',
2322
},
2423
},
2524
},
@@ -38,19 +37,19 @@ export default tseslint.config(
3837
publicOnly: true,
3938
},
4039
],
41-
"import/order": [
42-
"error",
40+
'import-x/order': [
41+
'error',
4342
{
44-
"groups": [
45-
"builtin",
46-
"external",
47-
"internal",
48-
"parent",
49-
"sibling",
50-
"index"
43+
groups: [
44+
'builtin',
45+
'external',
46+
'internal',
47+
'parent',
48+
'sibling',
49+
'index',
5150
],
52-
"newlines-between": "always"
53-
}
51+
'newlines-between': 'always',
52+
},
5453
],
5554
},
5655
},

0 commit comments

Comments
 (0)