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

ESM/CSJ build & dependency reduction #42

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
21 changes: 0 additions & 21 deletions .eslintrc.js

This file was deleted.

24 changes: 16 additions & 8 deletions .github/workflows/nodejs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,32 @@ jobs:

strategy:
matrix:
node-version: [18.x, 20.x]
node-version: [18.x, 20.x, 22.x]

steps:
- name: Repository checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.8.1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install latest npm
run: npm install -g npm
cache: pnpm

- name: Install dependencies
run: npm ci
run: pnpm install

- name: Run lint
run: npm run lint
run: pnpm lint

- name: Run build
run: npm run build
run: pnpm build

- name: Run tests
run: npm run test:coverage
run: pnpm test:coverage

- name: Code coverage
uses: codecov/codecov-action@v1
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-manager-strict=false
4 changes: 0 additions & 4 deletions .prettierrc.js

This file was deleted.

16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ Duo especially thanks [Lukas Hroch](https://github.com/lukashroch) for creating

## Getting Started

This library requires Node.js v14 or later.
This library requires Node.js LTS (v18 or later).

To use this client in your existing developing environment, install it from NPM
To use this client in your existing developing environment, install it with your package manager of choice.

```sh
npm install @duosecurity/duo_universal

pnpm add @duosecurity/duo_universal

yarn add @duosecurity/duo_universal
```

Once it's installed, see our developer documentation at https://duo.com/docs/duoweb and the `example` folder in this repo for guidance on integrating Duo 2FA into your web application.
Expand Down Expand Up @@ -68,7 +72,7 @@ const state = client.generateState();
Creates authentication URL to redirect user to Duo Security Universal prompt. Provide user identifier and state generated in previous step.

```ts
const authUrl = client.createAuthUrl('username', 'state');
const authUrl = await client.createAuthUrl('username', 'state');
```

### 6. Token & code exchange
Expand All @@ -92,19 +96,19 @@ Fork the repository
Install dependencies

```sh
npm install
pnpm install
```

Make your proposed changes. Add tests if applicable, lint the code. Submit a pull request.

## Tests

```sh
npm run test
pnpm run test
```

## Lint

```sh
npm run lint
pnpm run lint
```
15 changes: 15 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
eslintPluginPrettierRecommended,
{
rules: {
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': ['warn', { ignoreRestSiblings: true }],
},
},
);
4 changes: 2 additions & 2 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cd duo_universal_nodejs/example

Install dependencies
```
npm install
pnpm install
```

## Run the application
Expand All @@ -25,7 +25,7 @@ npm install

2. Start the application
```
npm run start
pnpm run start
```

3. Navigate to http://localhost:3000
Expand Down
Loading
Loading