@shohaghinfo/aerojs 0.1.2 → 0.3.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.
- package/README.md +291 -7
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +1 -0
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/oauth/github-driver.d.ts +16 -0
- package/dist/auth/oauth/github-driver.d.ts.map +1 -0
- package/dist/auth/oauth/github-driver.js +79 -0
- package/dist/auth/oauth/github-driver.js.map +1 -0
- package/dist/auth/oauth/google-driver.d.ts +16 -0
- package/dist/auth/oauth/google-driver.d.ts.map +1 -0
- package/dist/auth/oauth/google-driver.js +63 -0
- package/dist/auth/oauth/google-driver.js.map +1 -0
- package/dist/auth/oauth/index.d.ts +9 -0
- package/dist/auth/oauth/index.d.ts.map +1 -0
- package/dist/auth/oauth/index.js +9 -0
- package/dist/auth/oauth/index.js.map +1 -0
- package/dist/auth/oauth/oauth-driver.d.ts +35 -0
- package/dist/auth/oauth/oauth-driver.d.ts.map +1 -0
- package/dist/auth/oauth/oauth-driver.js +6 -0
- package/dist/auth/oauth/oauth-driver.js.map +1 -0
- package/dist/auth/oauth/oauth-manager.d.ts +26 -0
- package/dist/auth/oauth/oauth-manager.d.ts.map +1 -0
- package/dist/auth/oauth/oauth-manager.js +86 -0
- package/dist/auth/oauth/oauth-manager.js.map +1 -0
- package/dist/cli/commands/make.d.ts +5 -0
- package/dist/cli/commands/make.d.ts.map +1 -1
- package/dist/cli/commands/make.js +119 -0
- package/dist/cli/commands/make.js.map +1 -1
- package/dist/cli/runner.d.ts.map +1 -1
- package/dist/cli/runner.js +72 -3
- package/dist/cli/runner.js.map +1 -1
- package/dist/core/application.d.ts +5 -0
- package/dist/core/application.d.ts.map +1 -1
- package/dist/core/application.js +12 -0
- package/dist/core/application.js.map +1 -1
- package/dist/core/context.d.ts +4 -0
- package/dist/core/context.d.ts.map +1 -1
- package/dist/core/context.js +8 -0
- package/dist/core/context.js.map +1 -1
- package/dist/http/http.d.ts +44 -0
- package/dist/http/http.d.ts.map +1 -0
- package/dist/http/http.js +132 -0
- package/dist/http/http.js.map +1 -0
- package/dist/http/index.d.ts +8 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +8 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/request-builder.d.ts +48 -0
- package/dist/http/request-builder.d.ts.map +1 -0
- package/dist/http/request-builder.js +186 -0
- package/dist/http/request-builder.js.map +1 -0
- package/dist/http/response.d.ts +34 -0
- package/dist/http/response.d.ts.map +1 -0
- package/dist/http/response.js +77 -0
- package/dist/http/response.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/mail/drivers/smtp-mail-driver.d.ts +39 -0
- package/dist/mail/drivers/smtp-mail-driver.d.ts.map +1 -0
- package/dist/mail/drivers/smtp-mail-driver.js +318 -0
- package/dist/mail/drivers/smtp-mail-driver.js.map +1 -0
- package/dist/mail/index.d.ts +1 -0
- package/dist/mail/index.d.ts.map +1 -1
- package/dist/mail/index.js +1 -0
- package/dist/mail/index.js.map +1 -1
- package/dist/mail/mailer.d.ts +20 -3
- package/dist/mail/mailer.d.ts.map +1 -1
- package/dist/mail/mailer.js +28 -1
- package/dist/mail/mailer.js.map +1 -1
- package/dist/notifications/index.d.ts +7 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +7 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/notification-manager.d.ts +39 -0
- package/dist/notifications/notification-manager.d.ts.map +1 -0
- package/dist/notifications/notification-manager.js +130 -0
- package/dist/notifications/notification-manager.js.map +1 -0
- package/dist/notifications/notification.d.ts +48 -0
- package/dist/notifications/notification.d.ts.map +1 -0
- package/dist/notifications/notification.js +9 -0
- package/dist/notifications/notification.js.map +1 -0
- package/dist/queue/drivers/redis-queue-driver.d.ts +20 -0
- package/dist/queue/drivers/redis-queue-driver.d.ts.map +1 -1
- package/dist/queue/drivers/redis-queue-driver.js +92 -33
- package/dist/queue/drivers/redis-queue-driver.js.map +1 -1
- package/dist/queue/queue-manager.d.ts +4 -1
- package/dist/queue/queue-manager.d.ts.map +1 -1
- package/dist/queue/queue-manager.js +8 -1
- package/dist/queue/queue-manager.js.map +1 -1
- package/dist/security/index.d.ts +2 -1
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +2 -1
- package/dist/security/index.js.map +1 -1
- package/dist/security/rate-limiter.d.ts +20 -0
- package/dist/security/rate-limiter.d.ts.map +1 -1
- package/dist/security/rate-limiter.js +85 -0
- package/dist/security/rate-limiter.js.map +1 -1
- package/dist/security/signed-url.d.ts +29 -0
- package/dist/security/signed-url.d.ts.map +1 -0
- package/dist/security/signed-url.js +86 -0
- package/dist/security/signed-url.js.map +1 -0
- package/dist/storage/drivers/local-driver.d.ts +1 -0
- package/dist/storage/drivers/local-driver.d.ts.map +1 -1
- package/dist/storage/drivers/local-driver.js +5 -0
- package/dist/storage/drivers/local-driver.js.map +1 -1
- package/dist/storage/drivers/memory-driver.d.ts +1 -0
- package/dist/storage/drivers/memory-driver.d.ts.map +1 -1
- package/dist/storage/drivers/memory-driver.js +5 -0
- package/dist/storage/drivers/memory-driver.js.map +1 -1
- package/package.json +14 -2
package/README.md
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
### The Blazing-Fast, Zero-Dependency Full-Stack Web Framework for Node.js
|
|
6
6
|
|
|
7
7
|
[](https://github.com/atifsoftware/AeroJS/actions/workflows/ci.yml)
|
|
8
|
-
[](https://www.npmjs.com/package/@shohaghinfo/aerojs)
|
|
9
|
+
[](https://www.npmjs.com/package/@shohaghinfo/aerojs)
|
|
9
10
|
[](package.json)
|
|
10
11
|
[](package.json)
|
|
11
12
|
[](package.json)
|
|
@@ -57,6 +58,13 @@
|
|
|
57
58
|
28. [Background Queue & Mail System (`Queue`, `Mail`)](#28-background-queue--mail-system-queue-mail)
|
|
58
59
|
29. [OpenAPI 3.0 & Interactive Swagger UI (`useSwagger`)](#29-openapi-30--interactive-swagger-ui-useswagger)
|
|
59
60
|
30. [Aero Command-Line Interface (`aero` CLI)](#30-aero-command-line-interface-aero-cli)
|
|
61
|
+
31. [SMTP Mail Driver (`SmtpMailDriver`, `Mail`)](#31-smtp-mail-driver-smtpmaildriver-mail)
|
|
62
|
+
32. [Distributed Redis Rate Limiter (`RedisRateLimitStore`)](#32-distributed-redis-rate-limiter-redisratelimitstore)
|
|
63
|
+
33. [Redis Queue Driver with DLQ (`RedisQueueDriver`)](#33-redis-queue-driver-with-dlq-redisqueuedriver)
|
|
64
|
+
34. [Fluent HTTP Client (`Http`, `HttpResponse`)](#34-fluent-http-client-http-httpresponse)
|
|
65
|
+
35. [OAuth 2.0 & Social Login (`OAuth`, Google, GitHub)](#35-oauth-20--social-login-oauth-google-github)
|
|
66
|
+
36. [Multi-Channel Notifications (`Notification`, `Notifications`)](#36-multi-channel-notifications-notification-notifications)
|
|
67
|
+
37. [Tamper-Proof Signed URLs (`UrlSigner`, `validateSignedUrl`)](#37-tamper-proof-signed-urls-urlsigner-validatesignedurl)
|
|
60
68
|
- [Performance, Size & Advantages](#-performance-size--advantages)
|
|
61
69
|
- [Comparison Matrix](#-comparison-matrix)
|
|
62
70
|
- [License](#-license)
|
|
@@ -146,13 +154,50 @@ Aero is engineered from first principles to combine the best architectural conce
|
|
|
146
154
|
|
|
147
155
|
## 📦 Installation
|
|
148
156
|
|
|
157
|
+
### Option 1: Create a New Project (Recommended)
|
|
158
|
+
|
|
159
|
+
Scaffold a complete production-ready application in seconds using `npx`:
|
|
160
|
+
|
|
149
161
|
```bash
|
|
150
|
-
|
|
162
|
+
# Interactive project creation
|
|
163
|
+
npx @shohaghinfo/aerojs new my-app
|
|
164
|
+
|
|
165
|
+
# Or scaffold in current directory
|
|
166
|
+
npx @shohaghinfo/aerojs init
|
|
151
167
|
```
|
|
152
168
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
169
|
+
### Option 2: Install into an Existing Project
|
|
170
|
+
|
|
171
|
+
Add AeroJS to your project with your favorite package manager:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
# npm
|
|
175
|
+
npm install @shohaghinfo/aerojs
|
|
176
|
+
|
|
177
|
+
# pnpm
|
|
178
|
+
pnpm add @shohaghinfo/aerojs
|
|
179
|
+
|
|
180
|
+
# yarn
|
|
181
|
+
yarn add @shohaghinfo/aerojs
|
|
182
|
+
|
|
183
|
+
# bun
|
|
184
|
+
bun add @shohaghinfo/aerojs
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Option 3: Global CLI Installation
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
npm install -g @shohaghinfo/aerojs
|
|
191
|
+
|
|
192
|
+
# Now you can use the 'aero' command anywhere:
|
|
193
|
+
aero new my-app
|
|
194
|
+
# or
|
|
195
|
+
aerojs new my-app
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
#### Requirements:
|
|
199
|
+
- **Node.js**: `>= 20.0.0`
|
|
200
|
+
- **Module System**: ESM (`"type": "module"` in `package.json`)
|
|
156
201
|
|
|
157
202
|
---
|
|
158
203
|
|
|
@@ -1145,7 +1190,7 @@ Unlike legacy Node.js frameworks that ship with bloated dependency trees, AeroJS
|
|
|
1145
1190
|
- Ideal for **Serverless environments** (AWS Lambda, Cloudflare Containers, Vercel Serverless, Google Cloud Run) and autoscaling Docker microservices.
|
|
1146
1191
|
|
|
1147
1192
|
#### 🏎️ Lightning-Fast CI/CD Deployments
|
|
1148
|
-
- `npm install
|
|
1193
|
+
- `npm install @shohaghinfo/aerojs` downloads only a few kilobytes and completes in **1–2 seconds**, drastically cutting down pipeline build times and bandwidth costs.
|
|
1149
1194
|
|
|
1150
1195
|
#### 🌐 Unified Full-Stack Architecture
|
|
1151
1196
|
- Eliminates context switching and multi-repository overhead: build **REST APIs**, **React/Vue 3 SPAs (Inertia.js)**, and traditional **SSR Views (Edge.js/EJS)** in a single cohesive codebase.
|
|
@@ -1155,9 +1200,248 @@ Unlike legacy Node.js frameworks that ship with bloated dependency trees, AeroJS
|
|
|
1155
1200
|
|
|
1156
1201
|
---
|
|
1157
1202
|
|
|
1203
|
+
### 31. SMTP Mail Driver (`SmtpMailDriver`, `Mail`)
|
|
1204
|
+
|
|
1205
|
+
AeroJS includes a **zero-dependency native SMTP transport** directly built on Node.js `net` and `tls` sockets. Supports SSL (port 465), STARTTLS (port 587/25), AUTH LOGIN, multipart HTML & plain text, and base64 attachments.
|
|
1206
|
+
|
|
1207
|
+
```typescript
|
|
1208
|
+
import { Mail, MailMessage, SmtpMailDriver } from '@shohaghinfo/aerojs';
|
|
1209
|
+
|
|
1210
|
+
// 1. Configure in MailManager
|
|
1211
|
+
Mail.configure({
|
|
1212
|
+
default: 'smtp',
|
|
1213
|
+
mailers: {
|
|
1214
|
+
smtp: {
|
|
1215
|
+
driver: 'smtp',
|
|
1216
|
+
host: 'smtp.mailtrap.io',
|
|
1217
|
+
port: 587,
|
|
1218
|
+
auth: {
|
|
1219
|
+
user: process.env.SMTP_USER!,
|
|
1220
|
+
pass: process.env.SMTP_PASS!,
|
|
1221
|
+
},
|
|
1222
|
+
},
|
|
1223
|
+
},
|
|
1224
|
+
});
|
|
1225
|
+
|
|
1226
|
+
// 2. Dispatch with attachments & HTML
|
|
1227
|
+
await Mail.send((msg) => {
|
|
1228
|
+
msg.to('patient@example.com')
|
|
1229
|
+
.from('billing@hospital.org', 'Hospital Billing')
|
|
1230
|
+
.subject('Monthly Statement & Invoice')
|
|
1231
|
+
.html('<h1>Hello!</h1><p>Please find your medical invoice attached.</p>')
|
|
1232
|
+
.attach('invoice.pdf', pdfBuffer, 'application/pdf');
|
|
1233
|
+
});
|
|
1234
|
+
```
|
|
1235
|
+
|
|
1236
|
+
---
|
|
1237
|
+
|
|
1238
|
+
### 32. Distributed Redis Rate Limiter (`RedisRateLimitStore`)
|
|
1239
|
+
|
|
1240
|
+
For distributed production deployments running behind reverse proxies or multiple server nodes, `RedisRateLimitStore` synchronizes rate limit counters across all instances via atomic Redis commands.
|
|
1241
|
+
|
|
1242
|
+
```typescript
|
|
1243
|
+
import { Aero, rateLimit, RedisRateLimitStore, RedisClient } from '@shohaghinfo/aerojs';
|
|
1244
|
+
|
|
1245
|
+
const app = new Aero();
|
|
1246
|
+
const redis = new RedisClient({ host: '127.0.0.1', port: 6379 });
|
|
1247
|
+
|
|
1248
|
+
app.use(
|
|
1249
|
+
rateLimit({
|
|
1250
|
+
windowMs: 60_000, // 1 minute
|
|
1251
|
+
max: 100, // 100 requests per minute
|
|
1252
|
+
store: new RedisRateLimitStore({
|
|
1253
|
+
client: redis,
|
|
1254
|
+
prefix: 'rl:api:',
|
|
1255
|
+
fallbackToMemory: true, // Gracefully handles Redis disconnection
|
|
1256
|
+
}),
|
|
1257
|
+
})
|
|
1258
|
+
);
|
|
1259
|
+
```
|
|
1260
|
+
|
|
1261
|
+
---
|
|
1262
|
+
|
|
1263
|
+
### 33. Redis Queue Driver with DLQ (`RedisQueueDriver`)
|
|
1264
|
+
|
|
1265
|
+
AeroJS provides a production-grade background job queue backed by Redis with FIFO execution (`LPUSH`/`RPOP`), delayed scheduling (`ZADD`), worker reservation tracking, retry backoff, and a Dead Letter Queue (DLQ).
|
|
1266
|
+
|
|
1267
|
+
```typescript
|
|
1268
|
+
import { Queue, Job, RedisQueueDriver, RedisClient } from '@shohaghinfo/aerojs';
|
|
1269
|
+
|
|
1270
|
+
// 1. Configure Redis Queue Connection
|
|
1271
|
+
Queue.configure({
|
|
1272
|
+
default: 'redis',
|
|
1273
|
+
connections: {
|
|
1274
|
+
redis: {
|
|
1275
|
+
driver: 'redis',
|
|
1276
|
+
redis: new RedisClient({ host: '127.0.0.1', port: 6379 }),
|
|
1277
|
+
},
|
|
1278
|
+
},
|
|
1279
|
+
});
|
|
1280
|
+
|
|
1281
|
+
// 2. Define Background Job
|
|
1282
|
+
class ProcessPayrollJob extends Job {
|
|
1283
|
+
public async handle(): Promise<void> {
|
|
1284
|
+
console.log(`Processing payroll batch #${this.data.batchId}...`);
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
Queue.registerJob('ProcessPayrollJob', ProcessPayrollJob);
|
|
1288
|
+
|
|
1289
|
+
// 3. Dispatch Job (Immediate or Delayed)
|
|
1290
|
+
await Queue.dispatch(new ProcessPayrollJob({ batchId: 402 }), {
|
|
1291
|
+
delay: 10, // Wait 10 seconds before execution
|
|
1292
|
+
});
|
|
1293
|
+
|
|
1294
|
+
// 4. Start Worker
|
|
1295
|
+
const worker = Queue.createWorker({ concurrency: 5 });
|
|
1296
|
+
await worker.start();
|
|
1297
|
+
```
|
|
1298
|
+
|
|
1299
|
+
---
|
|
1300
|
+
|
|
1301
|
+
### 34. Fluent HTTP Client (`Http`, `HttpResponse`)
|
|
1302
|
+
|
|
1303
|
+
AeroJS ships with a powerful, zero-dependency fluent HTTP client built on native `fetch`. It supports automatic JSON serialization, query string formatting, Bearer/Basic authentication, timeouts, retries, and comprehensive testing fakes.
|
|
1304
|
+
|
|
1305
|
+
```typescript
|
|
1306
|
+
import { Http } from '@shohaghinfo/aerojs';
|
|
1307
|
+
|
|
1308
|
+
// 1. Fluent API calls
|
|
1309
|
+
const response = await Http.baseUrl('https://api.hospital-network.com/v1')
|
|
1310
|
+
.withToken(process.env.API_KEY!)
|
|
1311
|
+
.withQuery({ status: 'active', limit: 50 })
|
|
1312
|
+
.timeout(5000)
|
|
1313
|
+
.retry(3, 200)
|
|
1314
|
+
.get('/patients');
|
|
1315
|
+
|
|
1316
|
+
if (response.successful) {
|
|
1317
|
+
const patients = response.json();
|
|
1318
|
+
console.log('Patients fetched:', patients);
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
// 2. Testing Fakes (Mocking external services)
|
|
1322
|
+
Http.fake({
|
|
1323
|
+
'/patients': [{ id: 1, name: 'Alice Smith' }],
|
|
1324
|
+
'/billing': Http.response({ invoiceId: 'INV-101' }, 201),
|
|
1325
|
+
});
|
|
1326
|
+
|
|
1327
|
+
const res = await Http.post('https://api.hospital-network.com/v1/billing', { amount: 500 });
|
|
1328
|
+
expect(res.status).toBe(201);
|
|
1329
|
+
|
|
1330
|
+
Http.assertSent((req) => req.url.includes('/billing') && req.method === 'POST');
|
|
1331
|
+
```
|
|
1332
|
+
|
|
1333
|
+
---
|
|
1334
|
+
|
|
1335
|
+
### 35. OAuth 2.0 & Social Login (`OAuth`, Google, GitHub)
|
|
1336
|
+
|
|
1337
|
+
Authenticate users with Google, GitHub, or custom OAuth 2.0 identity providers without external libraries.
|
|
1338
|
+
|
|
1339
|
+
```typescript
|
|
1340
|
+
import { OAuth, router } from '@shohaghinfo/aerojs';
|
|
1341
|
+
|
|
1342
|
+
// 1. Configure Providers
|
|
1343
|
+
OAuth.configure({
|
|
1344
|
+
providers: {
|
|
1345
|
+
google: {
|
|
1346
|
+
clientId: process.env.GOOGLE_CLIENT_ID!,
|
|
1347
|
+
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
|
|
1348
|
+
redirectUri: 'https://myapp.com/auth/google/callback',
|
|
1349
|
+
},
|
|
1350
|
+
github: {
|
|
1351
|
+
clientId: process.env.GITHUB_CLIENT_ID!,
|
|
1352
|
+
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
|
|
1353
|
+
redirectUri: 'https://myapp.com/auth/github/callback',
|
|
1354
|
+
},
|
|
1355
|
+
},
|
|
1356
|
+
});
|
|
1357
|
+
|
|
1358
|
+
// 2. Redirect to Provider
|
|
1359
|
+
router.get('/auth/google', (ctx) => {
|
|
1360
|
+
ctx.redirect(OAuth.driver('google').getRedirectUrl());
|
|
1361
|
+
});
|
|
1362
|
+
|
|
1363
|
+
// 3. Handle Callback
|
|
1364
|
+
router.get('/auth/google/callback', async (ctx) => {
|
|
1365
|
+
const code = ctx.query.code as string;
|
|
1366
|
+
const { user, accessToken } = await OAuth.driver('google').handleCallback(code);
|
|
1367
|
+
|
|
1368
|
+
console.log('Logged in user:', user.name, user.email, user.avatarUrl);
|
|
1369
|
+
ctx.json({ success: true, user });
|
|
1370
|
+
});
|
|
1371
|
+
```
|
|
1372
|
+
|
|
1373
|
+
---
|
|
1374
|
+
|
|
1375
|
+
### 36. Multi-Channel Notifications (`Notification`, `Notifications`)
|
|
1376
|
+
|
|
1377
|
+
Deliver notifications simultaneously across multiple delivery channels (Email, Database, Realtime Broadcast, SMS) with unified syntax.
|
|
1378
|
+
|
|
1379
|
+
```typescript
|
|
1380
|
+
import { Notification, Notifications, MailMessage } from '@shohaghinfo/aerojs';
|
|
1381
|
+
|
|
1382
|
+
class OrderShippedNotification extends Notification {
|
|
1383
|
+
constructor(public order: any) {
|
|
1384
|
+
super();
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
// Choose delivery channels
|
|
1388
|
+
public via(user: any): string[] {
|
|
1389
|
+
return ['mail', 'database', 'broadcast'];
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
public toMail(user: any): MailMessage {
|
|
1393
|
+
const msg = new MailMessage();
|
|
1394
|
+
return msg.subject(`Order #${this.order.id} Shipped`)
|
|
1395
|
+
.html(`<h1>Your package is on its way!</h1>`);
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
public toDatabase(user: any) {
|
|
1399
|
+
return { orderId: this.order.id, trackingNumber: 'TRK-98124' };
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
public toBroadcast(user: any) {
|
|
1403
|
+
return {
|
|
1404
|
+
channel: `user.${user.id}`,
|
|
1405
|
+
event: 'OrderShipped',
|
|
1406
|
+
data: { orderId: this.order.id },
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
// Dispatch to single user or array of users
|
|
1412
|
+
await Notifications.send(customer, new OrderShippedNotification(order));
|
|
1413
|
+
```
|
|
1414
|
+
|
|
1415
|
+
---
|
|
1416
|
+
|
|
1417
|
+
### 37. Tamper-Proof Signed URLs (`UrlSigner`, `validateSignedUrl`)
|
|
1418
|
+
|
|
1419
|
+
Generate time-limited, cryptographically verified URLs for private downloads, password resets, or webhooks.
|
|
1420
|
+
|
|
1421
|
+
```typescript
|
|
1422
|
+
import { UrlSigner, validateSignedUrl, Storage, router } from '@shohaghinfo/aerojs';
|
|
1423
|
+
|
|
1424
|
+
// 1. Generate 15-minute temporary download link
|
|
1425
|
+
const downloadUrl = await Storage.temporaryUrl('invoices/inv-2026.pdf', 900);
|
|
1426
|
+
// Returns: /storage/invoices/inv-2026.pdf?expires=1790924000&signature=8f9a2...
|
|
1427
|
+
|
|
1428
|
+
// 2. Protect route with middleware
|
|
1429
|
+
router.get('/secure/download', validateSignedUrl(), async (ctx) => {
|
|
1430
|
+
ctx.json({ data: 'Confidential file contents' });
|
|
1431
|
+
});
|
|
1432
|
+
|
|
1433
|
+
// 3. Or verify inline inside controller:
|
|
1434
|
+
if (!ctx.hasValidSignature()) {
|
|
1435
|
+
ctx.status(403).json({ error: 'Signature invalid or expired' });
|
|
1436
|
+
return;
|
|
1437
|
+
}
|
|
1438
|
+
```
|
|
1439
|
+
|
|
1440
|
+
---
|
|
1441
|
+
|
|
1158
1442
|
## 📊 Comparison Matrix
|
|
1159
1443
|
|
|
1160
|
-
| Feature | Express | Koa | Fastify | AdonisJS | **
|
|
1444
|
+
| Feature | Express | Koa | Fastify | AdonisJS | **AeroJS** |
|
|
1161
1445
|
|---|:---:|:---:|:---:|:---:|:---:|
|
|
1162
1446
|
| **Zero Runtime Dependencies** | ❌ (30+) | ❌ (20+) | ❌ (15+) | ❌ (50+) | **✅ ZERO** |
|
|
1163
1447
|
| **Radix Tree Routing** | ❌ | ❌ | ✅ | ❌ | **✅ O(k)** |
|
package/dist/auth/index.d.ts
CHANGED
package/dist/auth/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC"}
|
package/dist/auth/index.js
CHANGED
package/dist/auth/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file github-driver.ts
|
|
3
|
+
* @description GitHub OAuth 2.0 social login provider for AeroJS.
|
|
4
|
+
*/
|
|
5
|
+
import type { OAuthDriver, OAuthDriverConfig, OAuthUser, OAuthCallbackResult } from './oauth-driver.js';
|
|
6
|
+
export declare class GitHubOAuthDriver implements OAuthDriver {
|
|
7
|
+
private config;
|
|
8
|
+
constructor(config: OAuthDriverConfig);
|
|
9
|
+
getRedirectUrl(options?: {
|
|
10
|
+
state?: string;
|
|
11
|
+
scopes?: string[];
|
|
12
|
+
}): string;
|
|
13
|
+
getUserFromToken(accessToken: string): Promise<OAuthUser>;
|
|
14
|
+
handleCallback(code: string): Promise<OAuthCallbackResult>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=github-driver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-driver.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth/github-driver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxG,qBAAa,iBAAkB,YAAW,WAAW;IACnD,OAAO,CAAC,MAAM,CAAoB;gBAEtB,MAAM,EAAE,iBAAiB;IAO9B,cAAc,CAAC,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;KAAO,GAAG,MAAM;IAerE,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAkCzD,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAsBxE"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file github-driver.ts
|
|
3
|
+
* @description GitHub OAuth 2.0 social login provider for AeroJS.
|
|
4
|
+
*/
|
|
5
|
+
import { Http } from '../../http/http.js';
|
|
6
|
+
export class GitHubOAuthDriver {
|
|
7
|
+
config;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.config = {
|
|
10
|
+
scopes: ['read:user', 'user:email'],
|
|
11
|
+
...config,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
getRedirectUrl(options = {}) {
|
|
15
|
+
const scopes = options.scopes || this.config.scopes || ['read:user', 'user:email'];
|
|
16
|
+
const params = new URLSearchParams({
|
|
17
|
+
client_id: this.config.clientId,
|
|
18
|
+
redirect_uri: this.config.redirectUri,
|
|
19
|
+
scope: scopes.join(' '),
|
|
20
|
+
});
|
|
21
|
+
if (options.state) {
|
|
22
|
+
params.set('state', options.state);
|
|
23
|
+
}
|
|
24
|
+
return `https://github.com/login/oauth/authorize?${params.toString()}`;
|
|
25
|
+
}
|
|
26
|
+
async getUserFromToken(accessToken) {
|
|
27
|
+
const res = await Http.withToken(accessToken)
|
|
28
|
+
.withHeaders({ 'User-Agent': 'AeroJS-OAuth' })
|
|
29
|
+
.get('https://api.github.com/user');
|
|
30
|
+
res.throw();
|
|
31
|
+
const data = res.json();
|
|
32
|
+
// If primary email is private in GitHub, fetch from /user/emails
|
|
33
|
+
let email = data.email || null;
|
|
34
|
+
if (!email) {
|
|
35
|
+
try {
|
|
36
|
+
const emailsRes = await Http.withToken(accessToken)
|
|
37
|
+
.withHeaders({ 'User-Agent': 'AeroJS-OAuth' })
|
|
38
|
+
.get('https://api.github.com/user/emails');
|
|
39
|
+
if (emailsRes.successful) {
|
|
40
|
+
const emails = emailsRes.json();
|
|
41
|
+
const primary = emails.find((e) => e.primary && e.verified) || emails[0];
|
|
42
|
+
if (primary)
|
|
43
|
+
email = primary.email;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Ignored
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
id: String(data.id),
|
|
52
|
+
email,
|
|
53
|
+
name: data.name || data.login || null,
|
|
54
|
+
avatarUrl: data.avatar_url || null,
|
|
55
|
+
raw: data,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async handleCallback(code) {
|
|
59
|
+
const res = await Http.acceptJson()
|
|
60
|
+
.withHeaders({ 'User-Agent': 'AeroJS-OAuth' })
|
|
61
|
+
.post('https://github.com/login/oauth/access_token', {
|
|
62
|
+
client_id: this.config.clientId,
|
|
63
|
+
client_secret: this.config.clientSecret,
|
|
64
|
+
code,
|
|
65
|
+
redirect_uri: this.config.redirectUri,
|
|
66
|
+
});
|
|
67
|
+
res.throw();
|
|
68
|
+
const tokenData = res.json();
|
|
69
|
+
const accessToken = tokenData.access_token;
|
|
70
|
+
const user = await this.getUserFromToken(accessToken);
|
|
71
|
+
return {
|
|
72
|
+
accessToken,
|
|
73
|
+
tokenType: tokenData.token_type,
|
|
74
|
+
scope: tokenData.scope,
|
|
75
|
+
user,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=github-driver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-driver.js","sourceR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KAAK,EAAE,CAAC;QAEZ,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QAC7B,MAAM,WAAW,GAAG,SAAS,CAAC,YAAY,CAAC;QAC3C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAEtD,OAAO;YACL,WAAW;YACX,SAAS,EAAE,SAAS,CAAC,UAAU;YAC/B,KAAK,EAAE,SAAS,CAAC,KAAK;YACtB,IAAI;SACL,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file google-driver.ts
|
|
3
|
+
* @description Google OAuth 2.0 social login provider for AeroJS.
|
|
4
|
+
*/
|
|
5
|
+
import type { OAuthDriver, OAuthDriverConfig, OAuthUser, OAuthCallbackResult } from './oauth-driver.js';
|
|
6
|
+
export declare class GoogleOAuthDriver implements OAuthDriver {
|
|
7
|
+
private config;
|
|
8
|
+
constructor(config: OAuthDriverConfig);
|
|
9
|
+
getRedirectUrl(options?: {
|
|
10
|
+
state?: string;
|
|
11
|
+
scopes?: string[];
|
|
12
|
+
}): string;
|
|
13
|
+
getUserFromToken(accessToken: string): Promise<OAuthUser>;
|
|
14
|
+
handleCallback(code: string): Promise<OAuthCallbackResult>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=google-driver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-driver.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth/google-driver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxG,qBAAa,iBAAkB,YAAW,WAAW;IACnD,OAAO,CAAC,MAAM,CAAoB;gBAEtB,MAAM,EAAE,iBAAiB;IAO9B,cAAc,CAAC,OAAO,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;KAAO,GAAG,MAAM;IAkBrE,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAczD,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAuBxE"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file google-driver.ts
|
|
3
|
+
* @description Google OAuth 2.0 social login provider for AeroJS.
|
|
4
|
+
*/
|
|
5
|
+
import { Http } from '../../http/http.js';
|
|
6
|
+
export class GoogleOAuthDriver {
|
|
7
|
+
config;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.config = {
|
|
10
|
+
scopes: ['openid', 'email', 'profile'],
|
|
11
|
+
...config,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
getRedirectUrl(options = {}) {
|
|
15
|
+
const scopes = options.scopes || this.config.scopes || ['openid', 'email', 'profile'];
|
|
16
|
+
const params = new URLSearchParams({
|
|
17
|
+
client_id: this.config.clientId,
|
|
18
|
+
redirect_uri: this.config.redirectUri,
|
|
19
|
+
response_type: 'code',
|
|
20
|
+
scope: scopes.join(' '),
|
|
21
|
+
access_type: 'offline',
|
|
22
|
+
prompt: 'consent',
|
|
23
|
+
});
|
|
24
|
+
if (options.state) {
|
|
25
|
+
params.set('state', options.state);
|
|
26
|
+
}
|
|
27
|
+
return `https://accounts.google.com/o/oauth2/v2/auth?${params.toString()}`;
|
|
28
|
+
}
|
|
29
|
+
async getUserFromToken(accessToken) {
|
|
30
|
+
const res = await Http.withToken(accessToken).get('https://www.googleapis.com/oauth2/v3/userinfo');
|
|
31
|
+
res.throw();
|
|
32
|
+
const data = res.json();
|
|
33
|
+
return {
|
|
34
|
+
id: String(data.sub || data.id),
|
|
35
|
+
email: data.email || null,
|
|
36
|
+
name: data.name || null,
|
|
37
|
+
avatarUrl: data.picture || null,
|
|
38
|
+
raw: data,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async handleCallback(code) {
|
|
42
|
+
const res = await Http.asForm().post('https://oauth2.googleapis.com/token', {
|
|
43
|
+
client_id: this.config.clientId,
|
|
44
|
+
client_secret: this.config.clientSecret,
|
|
45
|
+
code,
|
|
46
|
+
grant_type: 'authorization_code',
|
|
47
|
+
redirect_uri: this.config.redirectUri,
|
|
48
|
+
});
|
|
49
|
+
res.throw();
|
|
50
|
+
const tokenData = res.json();
|
|
51
|
+
const accessToken = tokenData.access_token;
|
|
52
|
+
const user = await this.getUserFromToken(accessToken);
|
|
53
|
+
return {
|
|
54
|
+
accessToken,
|
|
55
|
+
tokenType: tokenData.token_type,
|
|
56
|
+
expiresIn: tokenData.expires_in,
|
|
57
|
+
refreshToken: tokenData.refresh_token,
|
|
58
|
+
scope: tokenData.scope,
|
|
59
|
+
user,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=google-driver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-driver.js","sourceRoot":"","sources":["../../../src/auth/oauth/google-driver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,MAAM,OAAO,iBAAiB;IACpB,MAAM,CAAoB;IAElC,YAAY,MAAyB;QACnC,IAAI,CAAC,MAAM,GAAG;YACZ,MAAM,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC;YACtC,GAAG,MAAM;SACV,CAAC;IACJ,CAAC;IAEM,cAAc,CAAC,UAAiD,EAAE;QACvE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QACtF,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC;YACjC,SAAS,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CAAC,MAAM,CAAC,WAAW;SACtC,CAAC,CAAC;QACH,GAAG,CAAC,KAAK,EAAE,CAAC;QAEZ,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QAC7B,MAAM,WAAW,GAAG,SAAS,CAAC,YAAY,CAAC;QAC3C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAEtD,OAAO;YACL,WAAW;YACX,SAAS,EAAE,SAAS,CAAC,UAAU;YAC/B,SAAS,EAAE,SAAS,CAAC,UAAU;YAC/B,YAAY,EAAE,SAAS,CAAC,aAAa;YACrC,KAAK,EAAE,SAAS,CAAC,KAAK;YACtB,IAAI;SACL,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file index.ts
|
|
3
|
+
* @description AeroJS Social Authentication & OAuth 2.0 Module.
|
|
4
|
+
*/
|
|
5
|
+
export * from './oauth-driver.js';
|
|
6
|
+
export * from './google-driver.js';
|
|
7
|
+
export * from './github-driver.js';
|
|
8
|
+
export * from './oauth-manager.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file index.ts
|
|
3
|
+
* @description AeroJS Social Authentication & OAuth 2.0 Module.
|
|
4
|
+
*/
|
|
5
|
+
export * from './oauth-driver.js';
|
|
6
|
+
export * from './google-driver.js';
|
|
7
|
+
export * from './github-driver.js';
|
|
8
|
+
export * from './oauth-manager.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/auth/oauth/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file oauth-driver.ts
|
|
3
|
+
* @description Standard contracts and models for OAuth 2.0 social login in AeroJS.
|
|
4
|
+
*/
|
|
5
|
+
export interface OAuthUser {
|
|
6
|
+
id: string;
|
|
7
|
+
email: string | null;
|
|
8
|
+
name: string | null;
|
|
9
|
+
avatarUrl: string | null;
|
|
10
|
+
raw: any;
|
|
11
|
+
}
|
|
12
|
+
export interface OAuthCallbackResult {
|
|
13
|
+
accessToken: string;
|
|
14
|
+
tokenType?: string;
|
|
15
|
+
expiresIn?: number;
|
|
16
|
+
refreshToken?: string;
|
|
17
|
+
scope?: string;
|
|
18
|
+
user: OAuthUser;
|
|
19
|
+
}
|
|
20
|
+
export interface OAuthDriverConfig {
|
|
21
|
+
clientId: string;
|
|
22
|
+
clientSecret: string;
|
|
23
|
+
redirectUri: string;
|
|
24
|
+
scopes?: string[];
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
}
|
|
27
|
+
export interface OAuthDriver {
|
|
28
|
+
getRedirectUrl(options?: {
|
|
29
|
+
state?: string;
|
|
30
|
+
scopes?: string[];
|
|
31
|
+
}): string;
|
|
32
|
+
getUserFromToken(accessToken: string): Promise<OAuthUser>;
|
|
33
|
+
handleCallback(code: string, state?: string): Promise<OAuthCallbackResult>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=oauth-driver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-driver.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth/oauth-driver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,GAAG,EAAE,GAAG,CAAC;CACV;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,cAAc,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,MAAM,CAAC;IACxE,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1D,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC5E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-driver.js","sourceRoot":"","sources":["../../../src/auth/oauth/oauth-driver.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file oauth-manager.ts
|
|
3
|
+
* @description Central OAuth 2.0 social login manager for AeroJS.
|
|
4
|
+
* Manages OAuth providers (Google, GitHub, custom) with easy redirection and callback handling.
|
|
5
|
+
*/
|
|
6
|
+
import type { OAuthDriver, OAuthDriverConfig, OAuthUser } from './oauth-driver.js';
|
|
7
|
+
export interface OAuthConfig {
|
|
8
|
+
providers?: Record<string, OAuthDriverConfig>;
|
|
9
|
+
}
|
|
10
|
+
export declare class OAuthManager {
|
|
11
|
+
private configs;
|
|
12
|
+
private drivers;
|
|
13
|
+
private customFactories;
|
|
14
|
+
private fakedUser?;
|
|
15
|
+
constructor(config?: OAuthConfig);
|
|
16
|
+
configure(config: OAuthConfig): this;
|
|
17
|
+
extend(providerName: string, factory: (config: OAuthDriverConfig) => OAuthDriver): this;
|
|
18
|
+
driver(provider: 'google' | 'github' | string): OAuthDriver;
|
|
19
|
+
/**
|
|
20
|
+
* Fakes OAuth authentication for test environments.
|
|
21
|
+
*/
|
|
22
|
+
fake(user?: Partial<OAuthUser>): OAuthUser;
|
|
23
|
+
restore(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare const OAuth: OAuthManager;
|
|
26
|
+
//# sourceMappingURL=oauth-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth-manager.d.ts","sourceRoot":"","sources":["../../../src/auth/oauth/oauth-manager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,SAAS,EAAuB,MAAM,mBAAmB,CAAC;AAIxG,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAC/C;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,eAAe,CAAiE;IACxF,OAAO,CAAC,SAAS,CAAC,CAAY;gBAElB,MAAM,GAAE,WAAgB;IAI7B,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IASpC,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,WAAW,GAAG,IAAI;IAKvF,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW;IA8ClE;;OAEG;IACI,IAAI,CAAC,IAAI,GAAE,OAAO,CAAC,SAAS,CAAM,GAAG,SAAS;IAW9C,OAAO,IAAI,IAAI;CAGvB;AAED,eAAO,MAAM,KAAK,cAAqB,CAAC"}
|