@arikajs/auth 0.1.0
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.
Potentially problematic release.
This version of @arikajs/auth might be problematic. Click here for more details.
- package/LICENSE +21 -0
- package/README.md +260 -0
- package/dist/AuthManager.d.ts +27 -0
- package/dist/AuthManager.d.ts.map +1 -0
- package/dist/AuthManager.js +112 -0
- package/dist/AuthManager.js.map +1 -0
- package/dist/Contracts/UserProvider.d.ts +6 -0
- package/dist/Contracts/UserProvider.d.ts.map +1 -0
- package/dist/Contracts/UserProvider.js +3 -0
- package/dist/Contracts/UserProvider.js.map +1 -0
- package/dist/Guard.d.ts +10 -0
- package/dist/Guard.d.ts.map +1 -0
- package/dist/Guard.js +3 -0
- package/dist/Guard.js.map +1 -0
- package/dist/Guards/SessionGuard.d.ts +19 -0
- package/dist/Guards/SessionGuard.d.ts.map +1 -0
- package/dist/Guards/SessionGuard.js +68 -0
- package/dist/Guards/SessionGuard.js.map +1 -0
- package/dist/Guards/TokenGuard.d.ts +17 -0
- package/dist/Guards/TokenGuard.d.ts.map +1 -0
- package/dist/Guards/TokenGuard.js +60 -0
- package/dist/Guards/TokenGuard.js.map +1 -0
- package/dist/Hasher.d.ts +11 -0
- package/dist/Hasher.d.ts.map +1 -0
- package/dist/Hasher.js +53 -0
- package/dist/Hasher.js.map +1 -0
- package/dist/Middleware/Authenticate.d.ts +15 -0
- package/dist/Middleware/Authenticate.d.ts.map +1 -0
- package/dist/Middleware/Authenticate.js +38 -0
- package/dist/Middleware/Authenticate.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ArikaJs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
## Arika Auth
|
|
2
|
+
|
|
3
|
+
`@arikajs/auth` provides a flexible authentication system for the ArikaJS framework.
|
|
4
|
+
|
|
5
|
+
It enables applications to authenticate users using session-based (web) or token-based (API) guards, while remaining lightweight, extensible, and framework-agnostic.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { AuthManager } from '@arikajs/auth';
|
|
9
|
+
|
|
10
|
+
if (await auth.attempt({ email, password })) {
|
|
11
|
+
const user = auth.user();
|
|
12
|
+
}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
### Status
|
|
18
|
+
|
|
19
|
+
- **Stage**: Experimental / v0.x
|
|
20
|
+
- **Scope (v0.x)**:
|
|
21
|
+
- Multi-guard authentication (Session & Token)
|
|
22
|
+
- User Provider interface
|
|
23
|
+
- Password hashing
|
|
24
|
+
- Middleware integration
|
|
25
|
+
- JS & TS friendly API
|
|
26
|
+
- **Out of scope (for this package)**:
|
|
27
|
+
- OAuth logic
|
|
28
|
+
- Database ORM implementation
|
|
29
|
+
- Authorization (Policies/Gates)
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 🎯 Purpose
|
|
34
|
+
|
|
35
|
+
Authentication answers one core question: **“Who is the current user?”**
|
|
36
|
+
|
|
37
|
+
This package is responsible for:
|
|
38
|
+
- Authenticating users
|
|
39
|
+
- Managing login & logout
|
|
40
|
+
- Maintaining authentication state
|
|
41
|
+
- Providing guards for different auth strategies
|
|
42
|
+
- Integrating with HTTP middleware and controllers
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 🧠 Responsibilities
|
|
47
|
+
|
|
48
|
+
### ✅ What Arika Auth Does
|
|
49
|
+
- Authenticate users via multiple guards
|
|
50
|
+
- Support session and token authentication
|
|
51
|
+
- Hash and verify passwords securely
|
|
52
|
+
- Attach authenticated user to the request
|
|
53
|
+
- Provide authentication middleware
|
|
54
|
+
- Offer a clean API for controllers and routes
|
|
55
|
+
|
|
56
|
+
### ❌ What Arika Auth Does NOT Do
|
|
57
|
+
- Authorization (policies / gates)
|
|
58
|
+
- User database or ORM management
|
|
59
|
+
- OAuth / social login (future scope)
|
|
60
|
+
- Session storage implementation (uses HTTP layer)
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Features
|
|
65
|
+
|
|
66
|
+
- **Multiple authentication guards**
|
|
67
|
+
- Configure different strategies for API vs Web.
|
|
68
|
+
- **Session-based authentication**
|
|
69
|
+
- Secure defaults for browser-based apps.
|
|
70
|
+
- **Token-based authentication**
|
|
71
|
+
- Simple API token validation.
|
|
72
|
+
- **Pluggable user providers**
|
|
73
|
+
- Connect to any database or ORM.
|
|
74
|
+
- **Secure password hashing**
|
|
75
|
+
- Industry-standard hashing algorithms (Bcrypt/Argon2).
|
|
76
|
+
- **Middleware-based protection**
|
|
77
|
+
- Easily secure routes.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Installation
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npm install @arikajs/auth
|
|
85
|
+
# or
|
|
86
|
+
yarn add @arikajs/auth
|
|
87
|
+
# or
|
|
88
|
+
pnpm add @arikajs/auth
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 🧬 Authentication Flow
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
Request
|
|
97
|
+
↓
|
|
98
|
+
Authenticate Middleware
|
|
99
|
+
↓
|
|
100
|
+
Auth Guard
|
|
101
|
+
↓
|
|
102
|
+
User Provider
|
|
103
|
+
↓
|
|
104
|
+
Authenticated User (or null)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 🧩 Guards
|
|
110
|
+
|
|
111
|
+
Guards define how users are authenticated.
|
|
112
|
+
|
|
113
|
+
### Built-in Guards (v0.x)
|
|
114
|
+
|
|
115
|
+
| Guard | Description |
|
|
116
|
+
| :--- | :--- |
|
|
117
|
+
| `session` | Cookie/session-based authentication |
|
|
118
|
+
| `token` | Header-based token authentication |
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## 🧱 User Providers
|
|
123
|
+
|
|
124
|
+
User providers define how users are retrieved.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
export interface UserProvider {
|
|
128
|
+
retrieveById(id: string | number): Promise<any>;
|
|
129
|
+
retrieveByCredentials(credentials: object): Promise<any>;
|
|
130
|
+
validateCredentials(user: any, credentials: object): boolean;
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Providers allow you to integrate any database or user store.
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 🔌 Basic Usage
|
|
139
|
+
|
|
140
|
+
### Checking Authentication State
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import { auth } from '@arikajs/auth';
|
|
144
|
+
|
|
145
|
+
if (auth.check()) {
|
|
146
|
+
const user = auth.user();
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Attempting Login
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
const success = await auth.attempt({
|
|
154
|
+
email: 'test@example.com',
|
|
155
|
+
password: 'secret',
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
if (!success) {
|
|
159
|
+
throw new Error('Invalid credentials');
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Logging Out
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
auth.logout();
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 🔒 Middleware Protection
|
|
172
|
+
|
|
173
|
+
### Protecting Routes
|
|
174
|
+
|
|
175
|
+
```ts
|
|
176
|
+
Route.get('/dashboard', handler)
|
|
177
|
+
.middleware(['auth']);
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### API Authentication
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
Route.get('/api/user', handler)
|
|
184
|
+
.middleware(['auth:token']);
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## ⚙️ Configuration
|
|
190
|
+
|
|
191
|
+
Example configuration:
|
|
192
|
+
|
|
193
|
+
```json
|
|
194
|
+
{
|
|
195
|
+
"default": "session",
|
|
196
|
+
"guards": {
|
|
197
|
+
"session": {
|
|
198
|
+
"driver": "session",
|
|
199
|
+
"provider": "users"
|
|
200
|
+
},
|
|
201
|
+
"token": {
|
|
202
|
+
"driver": "token",
|
|
203
|
+
"provider": "users"
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## 🔐 Password Hashing
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
import { Hasher } from '@arikajs/auth';
|
|
215
|
+
|
|
216
|
+
const hash = await Hasher.make('password');
|
|
217
|
+
const valid = await Hasher.check('password', hash);
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Uses industry-standard hashing algorithms.
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## 🧱 Project Structure
|
|
225
|
+
|
|
226
|
+
- `src/`
|
|
227
|
+
- `AuthManager.ts` – Main entry point
|
|
228
|
+
- `Guard.ts` – Guard interface
|
|
229
|
+
- `Guards/` – Implementations
|
|
230
|
+
- `SessionGuard.ts`, `TokenGuard.ts`
|
|
231
|
+
- `Hasher.ts` – Password hashing utility
|
|
232
|
+
- `Middleware/` – Auth middleware
|
|
233
|
+
- `Authenticate.ts`
|
|
234
|
+
- `Contracts/` – Interfaces
|
|
235
|
+
- `UserProvider.ts`
|
|
236
|
+
- `index.ts` – Public exports
|
|
237
|
+
- `package.json`
|
|
238
|
+
- `tsconfig.json`
|
|
239
|
+
- `README.md`
|
|
240
|
+
- `LICENSE`
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Versioning & Stability
|
|
245
|
+
|
|
246
|
+
- Current version: **v0.x** (experimental)
|
|
247
|
+
- API may change before **v1.0**
|
|
248
|
+
- Will follow semantic versioning after stabilization
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## 📜 License
|
|
253
|
+
|
|
254
|
+
`@arikajs/auth` is open-sourced software licensed under the **MIT License**.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## 🧠 Philosophy
|
|
259
|
+
|
|
260
|
+
> “Authentication identifies the user. Authorization defines their power.”
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Guard } from './Guard';
|
|
2
|
+
import { UserProvider } from './Contracts/UserProvider';
|
|
3
|
+
export declare class AuthManager {
|
|
4
|
+
private guards;
|
|
5
|
+
private providers;
|
|
6
|
+
private config;
|
|
7
|
+
constructor(config: any);
|
|
8
|
+
registerProvider(name: string, provider: UserProvider): void;
|
|
9
|
+
extend(name: string, callback: (app: any) => Guard): void;
|
|
10
|
+
guard(name?: string): Guard;
|
|
11
|
+
private resolveGuard;
|
|
12
|
+
private currentRequest;
|
|
13
|
+
setRequest(request: any): void;
|
|
14
|
+
private createSessionDriver;
|
|
15
|
+
private createTokenDriver;
|
|
16
|
+
shouldUse(name: string): void;
|
|
17
|
+
check(): Promise<boolean>;
|
|
18
|
+
guest(): Promise<boolean>;
|
|
19
|
+
user(): Promise<any>;
|
|
20
|
+
id(): Promise<string | number | null>;
|
|
21
|
+
validate(credentials: Record<string, any>): Promise<boolean>;
|
|
22
|
+
setUser(user: any): void;
|
|
23
|
+
attempt(credentials: Record<string, any>): Promise<boolean>;
|
|
24
|
+
login(user: any): void;
|
|
25
|
+
logout(): void;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=AuthManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthManager.d.ts","sourceRoot":"","sources":["../src/AuthManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIxD,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAiC;IAC/C,OAAO,CAAC,SAAS,CAAwC;IACzD,OAAO,CAAC,MAAM,CAAM;gBAER,MAAM,EAAE,GAAG;IAIhB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI;IAI5D,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,KAAK,GAAG,IAAI;IAIzD,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK;IAelC,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,cAAc,CAAW;IAE1B,UAAU,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;IASrC,OAAO,CAAC,mBAAmB;IAQ3B,OAAO,CAAC,iBAAiB;IAQlB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKvB,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IAIzB,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IAIzB,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC;IAIpB,EAAE,IAAI,OAAO,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAIrC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlE,OAAO,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAIlB,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAQjE,KAAK,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAStB,MAAM,IAAI,IAAI;CAQxB"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthManager = void 0;
|
|
4
|
+
const SessionGuard_1 = require("./Guards/SessionGuard");
|
|
5
|
+
const TokenGuard_1 = require("./Guards/TokenGuard");
|
|
6
|
+
class AuthManager {
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.guards = new Map();
|
|
9
|
+
this.providers = new Map();
|
|
10
|
+
this.currentRequest = {};
|
|
11
|
+
this.config = config;
|
|
12
|
+
}
|
|
13
|
+
registerProvider(name, provider) {
|
|
14
|
+
this.providers.set(name, provider);
|
|
15
|
+
}
|
|
16
|
+
extend(name, callback) {
|
|
17
|
+
// Implementation for custom guards
|
|
18
|
+
}
|
|
19
|
+
guard(name) {
|
|
20
|
+
name = name || this.config.default;
|
|
21
|
+
// Handle undefined name from config explicitly
|
|
22
|
+
if (!name) {
|
|
23
|
+
throw new Error('No auth guard defined.');
|
|
24
|
+
}
|
|
25
|
+
if (!this.guards.has(name)) {
|
|
26
|
+
this.guards.set(name, this.resolveGuard(name));
|
|
27
|
+
}
|
|
28
|
+
return this.guards.get(name);
|
|
29
|
+
}
|
|
30
|
+
resolveGuard(name) {
|
|
31
|
+
const config = this.config.guards[name];
|
|
32
|
+
if (!config) {
|
|
33
|
+
throw new Error(`Auth guard [${name}] is not defined.`);
|
|
34
|
+
}
|
|
35
|
+
if (config.driver === 'session') {
|
|
36
|
+
return this.createSessionDriver(name, config);
|
|
37
|
+
}
|
|
38
|
+
if (config.driver === 'token') {
|
|
39
|
+
return this.createTokenDriver(name, config);
|
|
40
|
+
}
|
|
41
|
+
throw new Error(`Auth driver [${config.driver}] for guard [${name}] is not supported.`);
|
|
42
|
+
}
|
|
43
|
+
setRequest(request) {
|
|
44
|
+
this.currentRequest = request;
|
|
45
|
+
this.guards.forEach(guard => {
|
|
46
|
+
if (guard.setRequest) {
|
|
47
|
+
guard.setRequest(request);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
createSessionDriver(name, config) {
|
|
52
|
+
const provider = this.providers.get(config.provider);
|
|
53
|
+
if (!provider) {
|
|
54
|
+
throw new Error(`User provider [${config.provider}] is not defined.`);
|
|
55
|
+
}
|
|
56
|
+
return new SessionGuard_1.SessionGuard(provider, this.currentRequest);
|
|
57
|
+
}
|
|
58
|
+
createTokenDriver(name, config) {
|
|
59
|
+
const provider = this.providers.get(config.provider);
|
|
60
|
+
if (!provider) {
|
|
61
|
+
throw new Error(`User provider [${config.provider}] is not defined.`);
|
|
62
|
+
}
|
|
63
|
+
return new TokenGuard_1.TokenGuard(provider, this.currentRequest);
|
|
64
|
+
}
|
|
65
|
+
shouldUse(name) {
|
|
66
|
+
this.config.default = name;
|
|
67
|
+
}
|
|
68
|
+
// Proxy methods to the default guard
|
|
69
|
+
async check() {
|
|
70
|
+
return await this.guard().check();
|
|
71
|
+
}
|
|
72
|
+
async guest() {
|
|
73
|
+
return await this.guard().guest();
|
|
74
|
+
}
|
|
75
|
+
async user() {
|
|
76
|
+
return await this.guard().user();
|
|
77
|
+
}
|
|
78
|
+
async id() {
|
|
79
|
+
return await this.guard().id();
|
|
80
|
+
}
|
|
81
|
+
async validate(credentials) {
|
|
82
|
+
return await this.guard().validate(credentials);
|
|
83
|
+
}
|
|
84
|
+
setUser(user) {
|
|
85
|
+
this.guard().setUser(user);
|
|
86
|
+
}
|
|
87
|
+
async attempt(credentials) {
|
|
88
|
+
const guard = this.guard();
|
|
89
|
+
if (typeof guard.attempt === 'function') {
|
|
90
|
+
return await guard.attempt(credentials);
|
|
91
|
+
}
|
|
92
|
+
throw new Error(`Guard [${this.config.default}] does not support login attempts.`);
|
|
93
|
+
}
|
|
94
|
+
login(user) {
|
|
95
|
+
const guard = this.guard();
|
|
96
|
+
if (typeof guard.login === 'function') {
|
|
97
|
+
guard.login(user);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
throw new Error(`Guard [${this.config.default}] does not support login.`);
|
|
101
|
+
}
|
|
102
|
+
logout() {
|
|
103
|
+
const guard = this.guard();
|
|
104
|
+
if (typeof guard.logout === 'function') {
|
|
105
|
+
guard.logout();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
throw new Error(`Guard [${this.config.default}] does not support logout.`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.AuthManager = AuthManager;
|
|
112
|
+
//# sourceMappingURL=AuthManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthManager.js","sourceRoot":"","sources":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C,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAClB,OAAO;QACX,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,OAAO,2BAA2B,CAAC,CAAC;IAC9E,CAAC;IAEM,MAAM;QACT,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAS,CAAC;QAClC,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YACrC,KAAK,CAAC,MAAM,EAAE,CAAC;YACf,OAAO;QACX,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,OAAO,4BAA4B,CAAC,CAAC;IAC/E,CAAC;CACJ;AAnID,kCAmIC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface UserProvider {
|
|
2
|
+
retrieveById(id: string | number): Promise<any>;
|
|
3
|
+
retrieveByCredentials(credentials: Record<string, any>): Promise<any>;
|
|
4
|
+
validateCredentials(user: any, credentials: Record<string, any>): boolean | Promise<boolean>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=UserProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserProvider.d.ts","sourceRoot":"","sources":["../../src/Contracts/UserProvider.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IACzB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAChD,qBAAqB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACtE,mBAAmB,CAAC,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAChG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UserProvider.js","sourceRoot":"","sources":["../../src/Contracts/UserProvider.ts"],"names":[],"mappings":""}
|
package/dist/Guard.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface Guard {
|
|
2
|
+
check(): boolean | Promise<boolean>;
|
|
3
|
+
guest(): boolean | Promise<boolean>;
|
|
4
|
+
user(): any | Promise<any>;
|
|
5
|
+
id(): string | number | null | Promise<string | number | null>;
|
|
6
|
+
validate(credentials: Record<string, any>): boolean | Promise<boolean>;
|
|
7
|
+
setUser(user: any): void;
|
|
8
|
+
setRequest?(request: any): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=Guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Guard.d.ts","sourceRoot":"","sources":["../src/Guard.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IAClB,KAAK,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,KAAK,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3B,EAAE,IAAI,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC;IAC/D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvE,OAAO,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;IACzB,UAAU,CAAC,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC;CACnC"}
|
package/dist/Guard.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Guard.js","sourceRoot":"","sources":["../src/Guard.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Guard } from '../Guard';
|
|
2
|
+
import { UserProvider } from '../Contracts/UserProvider';
|
|
3
|
+
export declare class SessionGuard implements Guard {
|
|
4
|
+
private provider;
|
|
5
|
+
private session;
|
|
6
|
+
private loggedUser;
|
|
7
|
+
constructor(provider: UserProvider, session: any);
|
|
8
|
+
check(): Promise<boolean>;
|
|
9
|
+
guest(): Promise<boolean>;
|
|
10
|
+
user(): Promise<any>;
|
|
11
|
+
id(): Promise<string | number | null>;
|
|
12
|
+
validate(credentials: Record<string, any>): Promise<boolean>;
|
|
13
|
+
attempt(credentials: Record<string, any>): Promise<boolean>;
|
|
14
|
+
login(user: any): void;
|
|
15
|
+
logout(): void;
|
|
16
|
+
setUser(user: any): void;
|
|
17
|
+
setRequest(request: any): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=SessionGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionGuard.d.ts","sourceRoot":"","sources":["../../src/Guards/SessionGuard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,qBAAa,YAAa,YAAW,KAAK;IACtC,OAAO,CAAC,QAAQ,CAAe;IAC/B,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,UAAU,CAAa;gBAEnB,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG;IAKnC,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IAIzB,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IAIzB,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC;IAcpB,EAAE,IAAI,OAAO,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAKrC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAS5D,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IASjE,KAAK,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAOtB,MAAM,IAAI,IAAI;IAOd,OAAO,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAIxB,UAAU,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;CAMxC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SessionGuard = void 0;
|
|
4
|
+
class SessionGuard {
|
|
5
|
+
constructor(provider, session) {
|
|
6
|
+
this.loggedUser = null;
|
|
7
|
+
this.provider = provider;
|
|
8
|
+
this.session = session;
|
|
9
|
+
}
|
|
10
|
+
async check() {
|
|
11
|
+
return !!(await this.user());
|
|
12
|
+
}
|
|
13
|
+
async guest() {
|
|
14
|
+
return !(await this.check());
|
|
15
|
+
}
|
|
16
|
+
async user() {
|
|
17
|
+
if (this.loggedUser) {
|
|
18
|
+
return this.loggedUser;
|
|
19
|
+
}
|
|
20
|
+
const id = this.session.get ? this.session.get('auth_user_id') : null;
|
|
21
|
+
if (id) {
|
|
22
|
+
this.loggedUser = await this.provider.retrieveById(id);
|
|
23
|
+
}
|
|
24
|
+
return this.loggedUser;
|
|
25
|
+
}
|
|
26
|
+
async id() {
|
|
27
|
+
const user = await this.user();
|
|
28
|
+
return user ? user.id : null;
|
|
29
|
+
}
|
|
30
|
+
async validate(credentials) {
|
|
31
|
+
const user = await this.provider.retrieveByCredentials(credentials);
|
|
32
|
+
if (!user) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return await this.provider.validateCredentials(user, credentials);
|
|
36
|
+
}
|
|
37
|
+
async attempt(credentials) {
|
|
38
|
+
if (await this.validate(credentials)) {
|
|
39
|
+
const user = await this.provider.retrieveByCredentials(credentials);
|
|
40
|
+
this.login(user);
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
login(user) {
|
|
46
|
+
this.loggedUser = user;
|
|
47
|
+
if (this.session.put) {
|
|
48
|
+
this.session.put('auth_user_id', user.id);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
logout() {
|
|
52
|
+
this.loggedUser = null;
|
|
53
|
+
if (this.session.forget) {
|
|
54
|
+
this.session.forget('auth_user_id');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
setUser(user) {
|
|
58
|
+
this.loggedUser = user;
|
|
59
|
+
}
|
|
60
|
+
setRequest(request) {
|
|
61
|
+
// In a real framework, this would bind the session from the request
|
|
62
|
+
if (request.session) {
|
|
63
|
+
this.session = request.session;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.SessionGuard = SessionGuard;
|
|
68
|
+
//# sourceMappingURL=SessionGuard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionGuard.js","sourceRoot":"","sources":["../../src/Guards/SessionGuard.ts"],"names":[],"mappings":";;;AAIA,MAAa,YAAY;IAKrB,YAAY,QAAsB,EAAE,OAAY;QAFxC,eAAU,GAAQ,IAAI,CAAC;QAG3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,KAAK;QACd,OAAO,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,KAAK;QACd,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,IAAI;QACb,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC,UAAU,CAAC;QAC3B,CAAC;QAED,MAAM,EA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,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9C,CAAC;IACL,CAAC;IAEM,MAAM;QACT,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACtB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QACxC,CAAC;IACL,CAAC;IAEM,OAAO,CAAC,IAAS;QACpB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IAC3B,CAAC;IAEM,UAAU,CAAC,OAAY;QAC1B,oEAAoE;QACpE,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QACnC,CAAC;IACL,CAAC;CACJ;AA/ED,oCA+EC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Guard } from '../Guard';
|
|
2
|
+
export declare class TokenGuard implements Guard {
|
|
3
|
+
private provider;
|
|
4
|
+
private storageKey;
|
|
5
|
+
private inputKey;
|
|
6
|
+
private request;
|
|
7
|
+
constructor(provider: any, request: any, inputKey?: string, storageKey?: string);
|
|
8
|
+
user(): Promise<any>;
|
|
9
|
+
check(): Promise<boolean>;
|
|
10
|
+
guest(): Promise<boolean>;
|
|
11
|
+
id(): Promise<string | number | null>;
|
|
12
|
+
validate(credentials: Record<string, any>): Promise<boolean>;
|
|
13
|
+
setUser(user: any): void;
|
|
14
|
+
setRequest(request: any): void;
|
|
15
|
+
protected getTokenForRequest(): string | null;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=TokenGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenGuard.d.ts","sourceRoot":"","sources":["../../src/Guards/TokenGuard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,qBAAa,UAAW,YAAW,KAAK;IACpC,OAAO,CAAC,QAAQ,CAAM;IACtB,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,OAAO,CAAM;gBAET,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,GAAE,MAAoB,EAAE,UAAU,GAAE,MAAoB;IAO5F,IAAI;IASJ,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IAIzB,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC;IAIzB,EAAE,IAAI,OAAO,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAKrC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlE,OAAO,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAMxB,UAAU,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;IAIrC,SAAS,CAAC,kBAAkB,IAAI,MAAM,GAAG,IAAI;CAmBhD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TokenGuard = void 0;
|
|
4
|
+
class TokenGuard {
|
|
5
|
+
constructor(provider, request, inputKey = 'api_token', storageKey = 'api_token') {
|
|
6
|
+
this.storageKey = 'api_token';
|
|
7
|
+
this.inputKey = 'api_token';
|
|
8
|
+
this.provider = provider;
|
|
9
|
+
this.request = request;
|
|
10
|
+
this.inputKey = inputKey;
|
|
11
|
+
this.storageKey = storageKey;
|
|
12
|
+
}
|
|
13
|
+
async user() {
|
|
14
|
+
if (!this.request)
|
|
15
|
+
return null;
|
|
16
|
+
let token = this.getTokenForRequest();
|
|
17
|
+
if (!token)
|
|
18
|
+
return null;
|
|
19
|
+
return await this.provider.retrieveByCredentials({ [this.storageKey]: token });
|
|
20
|
+
}
|
|
21
|
+
async check() {
|
|
22
|
+
return !!(await this.user());
|
|
23
|
+
}
|
|
24
|
+
async guest() {
|
|
25
|
+
return !(await this.check());
|
|
26
|
+
}
|
|
27
|
+
async id() {
|
|
28
|
+
const user = await this.user();
|
|
29
|
+
return user ? user.id : null;
|
|
30
|
+
}
|
|
31
|
+
async validate(credentials) {
|
|
32
|
+
return !!(await this.provider.retrieveByCredentials(credentials));
|
|
33
|
+
}
|
|
34
|
+
setUser(user) {
|
|
35
|
+
if (this.request) {
|
|
36
|
+
this.request.user = user;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
setRequest(request) {
|
|
40
|
+
this.request = request;
|
|
41
|
+
}
|
|
42
|
+
getTokenForRequest() {
|
|
43
|
+
// Simple implementation: check query param, input body, or Bearer token
|
|
44
|
+
if (this.request.query && this.request.query[this.inputKey]) {
|
|
45
|
+
return this.request.query[this.inputKey];
|
|
46
|
+
}
|
|
47
|
+
if (this.request.body && this.request.body[this.inputKey]) {
|
|
48
|
+
return this.request.body[this.inputKey];
|
|
49
|
+
}
|
|
50
|
+
if (this.request.headers && this.request.headers['authorization']) {
|
|
51
|
+
const authHeader = this.request.headers['authorization'];
|
|
52
|
+
if (authHeader.startsWith('Bearer ')) {
|
|
53
|
+
return authHeader.substring(7);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.TokenGuard = TokenGuard;
|
|
60
|
+
//# sourceMappingURL=TokenGuard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenGuard.js","sourceRoot":"","sources":["../../src/Guards/TokenGuard.ts"],"names":[],"mappings":";;;AAEA,MAAa,UAAU;IAMnB,YAAY,QAAa,EAAE,OAAY,EAAE,WAAmB,WAAW,EAAE,aAAqB,WAAW;QAJjG,eAAU,GAAW,WAAW,CAAC;QACjC,aAAQ,GAAW,WAAW,CAAC;QAInC,IAAI,CAAC,QAAQ,GAA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AC3B,CAAC;IAES,kBAAkB;QACxB,wEAAwE;QACxE,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1D,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7C,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACxD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC;YAChE,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;YACzD,IAAI,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;gBACnC,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACnC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AApED,gCAoEC"}
|
package/dist/Hasher.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class Hasher {
|
|
2
|
+
/**
|
|
3
|
+
* Create a hash from a plain text value.
|
|
4
|
+
*/
|
|
5
|
+
static make(value: string, rounds?: number): Promise<string>;
|
|
6
|
+
/**
|
|
7
|
+
* Check if a plain text value matches a hash.
|
|
8
|
+
*/
|
|
9
|
+
static check(value: string, hash: string): Promise<boolean>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=Hasher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Hasher.d.ts","sourceRoot":"","sources":["../src/Hasher.ts"],"names":[],"mappings":"AAEA,qBAAa,MAAM;IACf;;OAEG;WACiB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,MAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAI7E;;OAEG;WACiB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAG3E"}
|
package/dist/Hasher.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Hasher = void 0;
|
|
37
|
+
const bcrypt = __importStar(require("bcryptjs"));
|
|
38
|
+
class Hasher {
|
|
39
|
+
/**
|
|
40
|
+
* Create a hash from a plain text value.
|
|
41
|
+
*/
|
|
42
|
+
static async make(value, rounds = 10) {
|
|
43
|
+
return await bcrypt.hash(value, rounds);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Check if a plain text value matches a hash.
|
|
47
|
+
*/
|
|
48
|
+
static async check(value, hash) {
|
|
49
|
+
return await bcrypt.compare(value, hash);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.Hasher = Hasher;
|
|
53
|
+
//# sourceMappingURL=Hasher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Hasher.js","sourceRoot":"","sources":["../src/Hasher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AAEnC,MAAa,MAAM;IACf;;OAEG;IACI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAa,EAAE,SAAiB,EAAE;QACvD,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,KAAa,EAAE,IAAY;QACjD,OAAO,MAAM,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC;CACJ;AAdD,wBAcC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AuthManager } from '../AuthManager';
|
|
2
|
+
export declare class Authenticate {
|
|
3
|
+
private auth;
|
|
4
|
+
protected guards: string[];
|
|
5
|
+
constructor(auth: AuthManager);
|
|
6
|
+
/**
|
|
7
|
+
* Set the guards that should be checked.
|
|
8
|
+
*/
|
|
9
|
+
using(...guards: string[]): this;
|
|
10
|
+
/**
|
|
11
|
+
* Handle the incoming request.
|
|
12
|
+
*/
|
|
13
|
+
handle(request: any, next: (request: any) => Promise<any> | any): Promise<any>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=Authenticate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Authenticate.d.ts","sourceRoot":"","sources":["../../src/Middleware/Authenticate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBAAa,YAAY;IAGT,OAAO,CAAC,IAAI;IAFxB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,CAAM;gBAEZ,IAAI,EAAE,WAAW;IAErC;;OAEG;IACI,KAAK,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI;IAKvC;;OAEG;IACU,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;CAoB9F"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Authenticate = void 0;
|
|
4
|
+
class Authenticate {
|
|
5
|
+
constructor(auth) {
|
|
6
|
+
this.auth = auth;
|
|
7
|
+
this.guards = [];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Set the guards that should be checked.
|
|
11
|
+
*/
|
|
12
|
+
using(...guards) {
|
|
13
|
+
this.guards = guards;
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Handle the incoming request.
|
|
18
|
+
*/
|
|
19
|
+
async handle(request, next) {
|
|
20
|
+
// 1. Bind the current request to the AuthManager/Guards
|
|
21
|
+
this.auth.setRequest(request);
|
|
22
|
+
// 2. Determine guards to check
|
|
23
|
+
const guardsToCheck = this.guards.length === 0
|
|
24
|
+
? [undefined]
|
|
25
|
+
: this.guards;
|
|
26
|
+
// 3. Check each guard
|
|
27
|
+
for (const guard of guardsToCheck) {
|
|
28
|
+
if (await this.auth.guard(guard).check()) {
|
|
29
|
+
this.auth.shouldUse(guard);
|
|
30
|
+
return next(request);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// 4. Fail if no guard authenticated
|
|
34
|
+
throw new Error('Unauthenticated.');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.Authenticate = Authenticate;
|
|
38
|
+
//# sourceMappingURL=Authenticate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Authenticate.js","sourceRoot":"","sources":["../../src/Middleware/Authenticate.ts"],"names":[],"mappings":";;;AAEA,MAAa,YAAY;IAGrB,YAAoB,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;QAF3B,WAAM,GAAa,EAAE,CAAC;IAES,CAAC;IAE1C;;OAEG;IACI,KAAK,CAAC,GAAG,MAAgB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAAC,OAAY,EAAE,IAA0C;QACxE,wDAAwD;QACxD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAE9B,+BAA+B;QAC/B,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;YAC1C,CAAC,CAAC,CAAC,SAA8B,CAAC;YAClC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QAElB,sBAAsB;QACtB,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;YAChC,IAAI,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;gBACvC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;gBAC3B,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACzB,CAAC;QACL,CAAC;QAED,oCAAoC;QACpC,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACxC,CAAC;CACJ;AApCD,oCAoCC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './Guard';
|
|
2
|
+
export * from './AuthManager';
|
|
3
|
+
export * from './Hasher';
|
|
4
|
+
export * from './Contracts/UserProvider';
|
|
5
|
+
export * from './Guards/SessionGuard';
|
|
6
|
+
export * from './Guards/TokenGuard';
|
|
7
|
+
export * from './Middleware/Authenticate';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Guard"), exports);
|
|
18
|
+
__exportStar(require("./AuthManager"), exports);
|
|
19
|
+
__exportStar(require("./Hasher"), exports);
|
|
20
|
+
__exportStar(require("./Contracts/UserProvider"), exports);
|
|
21
|
+
__exportStar(require("./Guards/SessionGuard"), exports);
|
|
22
|
+
__exportStar(require("./Guards/TokenGuard"), exports);
|
|
23
|
+
__exportStar(require("./Middleware/Authenticate"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,gDAA8B;AAC9B,2CAAyB;AACzB,2DAAyC;AACzC,wDAAsC;AACtC,sDAAoC;AACpC,4DAA0C"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@arikajs/auth",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Flexible, multi-guard authentication system for the ArikaJS framework.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc -p tsconfig.json",
|
|
10
|
+
"build:tests": "tsc -p tsconfig.test.json",
|
|
11
|
+
"clean": "rm -rf dist",
|
|
12
|
+
"prepare": "echo skip",
|
|
13
|
+
"test": "npm run build && npm run build:tests && node scripts/fix-test-imports.js && node --test 'dist/tests/**/*.test.js'",
|
|
14
|
+
"test:watch": "npm run build && npm run build:tests && node --test --watch 'dist/tests/**/*.test.js'"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"keywords": [
|
|
20
|
+
"arika",
|
|
21
|
+
"arika-js",
|
|
22
|
+
"framework",
|
|
23
|
+
"auth",
|
|
24
|
+
"authentication",
|
|
25
|
+
"guard",
|
|
26
|
+
"session",
|
|
27
|
+
"jwt"
|
|
28
|
+
],
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=20.0.0"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/arikajs/auth.git"
|
|
35
|
+
},
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/arikajs/auth/issues"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/arikajs/auth#readme",
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"bcryptjs": "^2.4.3"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^20.11.24",
|
|
45
|
+
"@types/bcryptjs": "^2.4.6",
|
|
46
|
+
"typescript": "^5.3.3"
|
|
47
|
+
},
|
|
48
|
+
"author": "Prakash Tank"
|
|
49
|
+
}
|