@wnodex/passport 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
 
2
- > @wnodex/passport@0.2.1 build /home/runner/work/wnodex/wnodex/packages/passport
2
+ > @wnodex/passport@0.2.2 build /home/runner/work/wnodex/wnodex/packages/passport
3
3
  > rolldown -c && tsc
4
4
 
5
5
  [log] <DIR>/index.js chunk │ size: 1.06 kB
6
6
  [log]
7
- [success] rolldown v1.0.0-rc.1 Finished in 12.37 ms
7
+ [success] rolldown v1.0.0-rc.1 Finished in 18.75 ms
package/README.md CHANGED
@@ -1,14 +1,91 @@
1
1
  # @wnodex/passport
2
2
 
3
- wnodex passport middleware
3
+ > wnodex passport middleware
4
4
 
5
- ---
5
+ Part of the [wnodex](https://github.com/wnodex/wnodex) ecosystem, this package integrates the Passport.js authentication middleware.
6
6
 
7
- ## Table of Content
7
+ ## About
8
8
 
9
- - [License](#license)
9
+ `@wnodex/passport` provides a seamless way to integrate Passport.js, the popular authentication middleware for Node.js, into your `wnodex` application. It handles the initialization and session management of Passport.
10
10
 
11
- ---
11
+ ## Features
12
+
13
+ - Integrates Passport.js for robust authentication strategies.
14
+ - Simple configuration within the `wnodex` server.
15
+ - Supports using a custom Passport instance.
16
+ - Automatically initializes Passport and its session handling.
17
+
18
+ ## Why use it?
19
+
20
+ Authentication is a complex part of many applications. This package abstracts the setup process for Passport.js, allowing you to focus on implementing authentication strategies (e.g., local, JWT, OAuth) while keeping the configuration centralized and consistent with the rest of your `wnodex` application.
21
+
22
+ ## Installation
23
+
24
+ You can install the package using your favorite package manager:
25
+
26
+ **pnpm**
27
+
28
+ ```bash
29
+ pnpm add @wnodex/passport passport
30
+ ```
31
+
32
+ **npm**
33
+
34
+ ```bash
35
+ npm install @wnodex/passport passport
36
+ ```
37
+
38
+ **yarn**
39
+
40
+ ```bash
41
+ yarn add @wnodex/passport passport
42
+ ```
43
+
44
+ **bun**
45
+
46
+ ```bash
47
+ bun add @wnodex/passport passport
48
+ ```
49
+
50
+ You will also need to install the specific Passport strategy you intend to use (e.g., `passport-local`, `passport-jwt`).
51
+
52
+ ## Usage
53
+
54
+ `@wnodex/passport` is disabled by default. To enable it, set `passport: true` in the `Wnodex` constructor. You can also provide your own pre-configured Passport instance.
55
+
56
+ ```typescript
57
+ import { Wnodex } from 'wnodex';
58
+ import passport from 'passport';
59
+ import { Strategy as LocalStrategy } from 'passport-local';
60
+
61
+ // 1. Configure a Passport strategy
62
+ passport.use(
63
+ new LocalStrategy((username, password, done) => {
64
+ // Your user authentication logic here
65
+ if (username === 'admin' && password === 'password') {
66
+ return done(null, { id: 1, username: 'admin' });
67
+ }
68
+ return done(null, false);
69
+ })
70
+ );
71
+
72
+ // 2. Initialize Wnodex with Passport enabled
73
+ const server = new Wnodex({
74
+ // You need to enable session and cookie-parser for passport sessions
75
+ cookieParser: { secret: 'your-secret' },
76
+ session: { secret: 'your-session-secret' },
77
+ passport: true, // or pass your custom instance: `passport: passport`
78
+ });
79
+
80
+ const app = server.getApp();
81
+
82
+ // 3. Use passport routes
83
+ app.post('/login', passport.authenticate('local'), (req, res) => {
84
+ res.send('Logged in successfully');
85
+ });
86
+
87
+ server.start();
88
+ ```
12
89
 
13
90
  ## License
14
91
 
package/package.json CHANGED
@@ -1,10 +1,16 @@
1
1
  {
2
2
  "name": "@wnodex/passport",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "private": false,
5
- "description": "wnodex passport middleware",
5
+ "description": "A wnodex middleware that integrates Passport.js for authentication.",
6
6
  "keywords": [
7
- "wnodex"
7
+ "wnodex",
8
+ "middleware",
9
+ "passport",
10
+ "express",
11
+ "authentication",
12
+ "auth",
13
+ "security"
8
14
  ],
9
15
  "homepage": "https://github.com/wnodex/wnodex#readme",
10
16
  "bugs": {
@@ -39,7 +45,7 @@
39
45
  "@types/passport": "^1.0.17",
40
46
  "rolldown": "1.0.0-rc.1",
41
47
  "typescript": "5.9.2",
42
- "@wnodex/typescript-config": "0.2.1"
48
+ "@wnodex/typescript-config": "0.2.2"
43
49
  },
44
50
  "publishConfig": {
45
51
  "access": "public"