@vunexa/lixa 0.1.4 → 0.1.6-alpha.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.
- package/README.md +311 -11
- package/README.template.md +10 -10
- package/dist/export-types/index.d.ts +15 -11
- package/dist/index.d.cts +15 -11
- package/dist/models/session.d.ts +15 -11
- package/dist/models/session.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,7 +28,36 @@ A flexible, provider-agnostic OAuth 2.0 and OpenID Connect (OIDC) client library
|
|
|
28
28
|
|
|
29
29
|
## Architecture Overview
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
```mermaid
|
|
32
|
+
graph TD
|
|
33
|
+
User([User Client / Browser])
|
|
34
|
+
|
|
35
|
+
subgraph Lixa ["Lixa Core Engine"]
|
|
36
|
+
AuthNGuard["Primary AuthN Guard<br/>(Minimal Identity Scopes Only)"]
|
|
37
|
+
SessionMgr["Session Handler & Unified Session"]
|
|
38
|
+
AccountLinker["Account Linker<br/>(AUTO_LINK_BY_VERIFIED_EMAIL)"]
|
|
39
|
+
ResourceConn["Resource Connection API<br/>(Post-Login AuthZ)"]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
subgraph IdentityProviders ["Identity Providers (AuthN)"]
|
|
43
|
+
GoogleAuth["Google / OIDC"]
|
|
44
|
+
GitHubAuth["GitHub OAuth"]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
subgraph ResourceProviders ["Resource APIs (AuthZ)"]
|
|
48
|
+
GitHubAPI["GitHub API (repos, orgs)"]
|
|
49
|
+
GoogleDriveAPI["Google Drive API"]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
User -->|"1. Primary Login / Link Account"| AuthNGuard
|
|
53
|
+
AuthNGuard -->|"Request Identity"| IdentityProviders
|
|
54
|
+
IdentityProviders -->|"Tokens + UserInfo"| AccountLinker
|
|
55
|
+
AccountLinker -->|"Unified Session (session.accounts)"| SessionMgr
|
|
56
|
+
|
|
57
|
+
User -->|"2. Connect Resource API (Post-Login)"| ResourceConn
|
|
58
|
+
ResourceConn -->|"Request Permissions (repo, drive)"| ResourceProviders
|
|
59
|
+
ResourceProviders -->|"Resource Access Tokens"| SessionMgr
|
|
60
|
+
```
|
|
32
61
|
|
|
33
62
|
---
|
|
34
63
|
|
|
@@ -220,26 +249,26 @@ export interface Session<TRaw = OAuthTokenResponse> {
|
|
|
220
249
|
/** Unique session ID generated by Lixa */
|
|
221
250
|
id?: string;
|
|
222
251
|
|
|
223
|
-
/** Primary access token or session token */
|
|
224
|
-
token: string;
|
|
225
|
-
|
|
226
252
|
/** Unified user ID across linked accounts */
|
|
227
253
|
userId?: string;
|
|
228
254
|
|
|
229
255
|
/** Primary user email */
|
|
230
256
|
email?: string;
|
|
231
257
|
|
|
232
|
-
/**
|
|
233
|
-
provider?: string;
|
|
234
|
-
|
|
235
|
-
/** Linked SSO provider accounts (AuthN) */
|
|
258
|
+
/** Linked SSO provider accounts (AuthN) - Single Source of Truth */
|
|
236
259
|
accounts?: Record<string, LinkedAccount>;
|
|
237
260
|
|
|
238
|
-
/** Connected third-party resource provider tokens (AuthZ) */
|
|
261
|
+
/** Connected third-party resource provider tokens (AuthZ) - Single Source of Truth */
|
|
239
262
|
resources?: Record<string, ConnectedResource>;
|
|
240
263
|
|
|
241
|
-
/**
|
|
242
|
-
|
|
264
|
+
/** Optional primary access token or session token */
|
|
265
|
+
token?: string;
|
|
266
|
+
|
|
267
|
+
/** Optional current active auth provider */
|
|
268
|
+
provider?: string;
|
|
269
|
+
|
|
270
|
+
/** Optional raw token response from provider */
|
|
271
|
+
raw?: TRaw;
|
|
243
272
|
}
|
|
244
273
|
```
|
|
245
274
|
|
|
@@ -252,6 +281,277 @@ export interface Session<TRaw = OAuthTokenResponse> {
|
|
|
252
281
|
|
|
253
282
|
---
|
|
254
283
|
|
|
284
|
+
## Custom Session Storage Implementations
|
|
285
|
+
|
|
286
|
+
Lixa allows you to store sessions in any database or cache by implementing the `SessionStorage` interface.
|
|
287
|
+
|
|
288
|
+
### 1. SQLite Session Storage (`better-sqlite3`)
|
|
289
|
+
|
|
290
|
+
For relational persistence or single-node deployments using SQLite:
|
|
291
|
+
|
|
292
|
+
#### Table Schema (SQL DDL)
|
|
293
|
+
|
|
294
|
+
```sql
|
|
295
|
+
CREATE TABLE IF NOT EXISTS sessions (
|
|
296
|
+
id TEXT PRIMARY KEY,
|
|
297
|
+
user_email TEXT,
|
|
298
|
+
data TEXT NOT NULL,
|
|
299
|
+
expires_at INTEGER NOT NULL
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
CREATE INDEX IF NOT EXISTS idx_sessions_email ON sessions(user_email);
|
|
303
|
+
CREATE INDEX IF NOT EXISTS idx_sessions_expires ON sessions(expires_at);
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
#### TypeScript Implementation
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
import Database from "better-sqlite3";
|
|
310
|
+
import { Lixa, type SessionStorage, type Session } from "@vunexa/lixa";
|
|
311
|
+
|
|
312
|
+
export class SqliteSessionStorage implements SessionStorage {
|
|
313
|
+
private db = new Database("lixa_sessions.db");
|
|
314
|
+
|
|
315
|
+
constructor() {
|
|
316
|
+
this.db.exec(`
|
|
317
|
+
CREATE TABLE IF NOT EXISTS sessions (
|
|
318
|
+
id TEXT PRIMARY KEY,
|
|
319
|
+
user_email TEXT,
|
|
320
|
+
data TEXT NOT NULL,
|
|
321
|
+
expires_at INTEGER NOT NULL
|
|
322
|
+
);
|
|
323
|
+
CREATE INDEX IF NOT EXISTS idx_sessions_email ON sessions(user_email);
|
|
324
|
+
`);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
async saveSession<T extends Session>(sessionId: string, session: T, expiresInSeconds: number): Promise<void> {
|
|
328
|
+
const expiresAt = Math.floor(Date.now() / 1000) + expiresInSeconds;
|
|
329
|
+
const stmt = this.db.prepare(`
|
|
330
|
+
INSERT INTO sessions (id, user_email, data, expires_at)
|
|
331
|
+
VALUES (?, ?, ?, ?)
|
|
332
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
333
|
+
user_email = excluded.user_email,
|
|
334
|
+
data = excluded.data,
|
|
335
|
+
expires_at = excluded.expires_at
|
|
336
|
+
`);
|
|
337
|
+
stmt.run(sessionId, session.email || null, JSON.stringify(session), expiresAt);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
async getSession<T extends Session>(sessionId: string): Promise<T | null> {
|
|
341
|
+
const now = Math.floor(Date.now() / 1000);
|
|
342
|
+
const stmt = this.db.prepare(`SELECT data FROM sessions WHERE id = ? AND expires_at > ?`);
|
|
343
|
+
const row = stmt.get(sessionId, now) as { data: string } | undefined;
|
|
344
|
+
return row ? (JSON.parse(row.data) as T) : null;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
async deleteSession(sessionId: string): Promise<void> {
|
|
348
|
+
const stmt = this.db.prepare(`DELETE FROM sessions WHERE id = ?`);
|
|
349
|
+
stmt.run(sessionId);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
async getSessionByEmail<T extends Session>(email: string): Promise<{ sessionId: string; session: T } | null> {
|
|
353
|
+
const now = Math.floor(Date.now() / 1000);
|
|
354
|
+
const stmt = this.db.prepare(`SELECT id, data FROM sessions WHERE user_email = ? AND expires_at > ? LIMIT 1`);
|
|
355
|
+
const row = stmt.get(email, now) as { id: string; data: string } | undefined;
|
|
356
|
+
return row ? { sessionId: row.id, session: JSON.parse(row.data) as T } : null;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// Pass to Lixa instance
|
|
361
|
+
export const lixa = new Lixa({
|
|
362
|
+
sessionHandler: {
|
|
363
|
+
sessionStorage: new SqliteSessionStorage(),
|
|
364
|
+
},
|
|
365
|
+
providers: { /* ... */ },
|
|
366
|
+
});
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
#### Saved JSON Record Example in SQLite (`data` Column)
|
|
370
|
+
|
|
371
|
+
```json
|
|
372
|
+
{
|
|
373
|
+
"id": "e4a91f82c3b4a07f",
|
|
374
|
+
"token": "ya29.a0ARW5m7...",
|
|
375
|
+
"userId": "1049281048",
|
|
376
|
+
"email": "alex.developer@example.com",
|
|
377
|
+
"provider": "google",
|
|
378
|
+
"accounts": {
|
|
379
|
+
"google": {
|
|
380
|
+
"provider": "google",
|
|
381
|
+
"email": "alex.developer@example.com",
|
|
382
|
+
"providerUserId": "1049281048",
|
|
383
|
+
"accessToken": "ya29.a0ARW5m7...",
|
|
384
|
+
"linkedAt": 1771657200000
|
|
385
|
+
},
|
|
386
|
+
"github": {
|
|
387
|
+
"provider": "github",
|
|
388
|
+
"email": "alex.developer@example.com",
|
|
389
|
+
"providerUserId": "5829104",
|
|
390
|
+
"accessToken": "gho_8f7b2a9e1c3...",
|
|
391
|
+
"linkedAt": 1771657250000
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
"resources": {
|
|
395
|
+
"github": {
|
|
396
|
+
"provider": "github",
|
|
397
|
+
"accessToken": "gho_resource_repo_9a8b7c...",
|
|
398
|
+
"scopes": ["repo", "read:org"],
|
|
399
|
+
"connectedAt": 1771657300000
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
"raw": {
|
|
403
|
+
"access_token": "ya29.a0ARW5m7...",
|
|
404
|
+
"token_type": "Bearer",
|
|
405
|
+
"expires_in": 3599
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
---
|
|
411
|
+
|
|
412
|
+
### 2. AWS DynamoDB Session Storage (`@aws-sdk/lib-dynamodb`)
|
|
413
|
+
|
|
414
|
+
For serverless and distributed AWS deployments using DynamoDB:
|
|
415
|
+
|
|
416
|
+
#### Table Configuration
|
|
417
|
+
|
|
418
|
+
- **Table Name**: `LixaSessions`
|
|
419
|
+
- **Partition Key**: `sessionId` (String)
|
|
420
|
+
- **Global Secondary Index (GSI)**: `EmailIndex` (`email` as Partition Key)
|
|
421
|
+
- **TTL Attribute**: `ttl` (Unix timestamp in seconds for automatic AWS expiration)
|
|
422
|
+
|
|
423
|
+
#### TypeScript Implementation
|
|
424
|
+
|
|
425
|
+
```typescript
|
|
426
|
+
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
|
|
427
|
+
import { DynamoDBDocumentClient, PutCommand, GetCommand, DeleteCommand, QueryCommand } from "@aws-sdk/lib-dynamodb";
|
|
428
|
+
import { Lixa, type SessionStorage, type Session } from "@vunexa/lixa";
|
|
429
|
+
|
|
430
|
+
export class DynamoDbSessionStorage implements SessionStorage {
|
|
431
|
+
private docClient: DynamoDBDocumentClient;
|
|
432
|
+
private tableName = "LixaSessions";
|
|
433
|
+
|
|
434
|
+
constructor() {
|
|
435
|
+
const client = new DynamoDBClient({ region: process.env.AWS_REGION || "us-east-1" });
|
|
436
|
+
this.docClient = DynamoDBDocumentClient.from(client);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
async saveSession<T extends Session>(sessionId: string, session: T, expiresInSeconds: number): Promise<void> {
|
|
440
|
+
const ttl = Math.floor(Date.now() / 1000) + expiresInSeconds;
|
|
441
|
+
await this.docClient.send(
|
|
442
|
+
new PutCommand({
|
|
443
|
+
TableName: this.tableName,
|
|
444
|
+
Item: {
|
|
445
|
+
sessionId,
|
|
446
|
+
email: session.email || "N/A",
|
|
447
|
+
sessionData: session,
|
|
448
|
+
ttl,
|
|
449
|
+
},
|
|
450
|
+
})
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
async getSession<T extends Session>(sessionId: string): Promise<T | null> {
|
|
455
|
+
const res = await this.docClient.send(
|
|
456
|
+
new GetCommand({
|
|
457
|
+
TableName: this.tableName,
|
|
458
|
+
Key: { sessionId },
|
|
459
|
+
})
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
if (!res.Item) return null;
|
|
463
|
+
const now = Math.floor(Date.now() / 1000);
|
|
464
|
+
if (res.Item.ttl && res.Item.ttl < now) return null;
|
|
465
|
+
|
|
466
|
+
return res.Item.sessionData as T;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
async deleteSession(sessionId: string): Promise<void> {
|
|
470
|
+
await this.docClient.send(
|
|
471
|
+
new DeleteCommand({
|
|
472
|
+
TableName: this.tableName,
|
|
473
|
+
Key: { sessionId },
|
|
474
|
+
})
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
async getSessionByEmail<T extends Session>(email: string): Promise<{ sessionId: string; session: T } | null> {
|
|
479
|
+
const res = await this.docClient.send(
|
|
480
|
+
new QueryCommand({
|
|
481
|
+
TableName: this.tableName,
|
|
482
|
+
IndexName: "EmailIndex",
|
|
483
|
+
KeyConditionExpression: "email = :email",
|
|
484
|
+
ExpressionAttributeValues: { ":email": email },
|
|
485
|
+
Limit: 1,
|
|
486
|
+
})
|
|
487
|
+
);
|
|
488
|
+
|
|
489
|
+
if (!res.Items || res.Items.length === 0) return null;
|
|
490
|
+
const item = res.Items[0];
|
|
491
|
+
const now = Math.floor(Date.now() / 1000);
|
|
492
|
+
if (item.ttl && item.ttl < now) return null;
|
|
493
|
+
|
|
494
|
+
return { sessionId: item.sessionId, session: item.sessionData as T };
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// Pass to Lixa instance
|
|
499
|
+
export const lixa = new Lixa({
|
|
500
|
+
sessionHandler: {
|
|
501
|
+
sessionStorage: new DynamoDbSessionStorage(),
|
|
502
|
+
},
|
|
503
|
+
providers: { /* ... */ },
|
|
504
|
+
});
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
#### Saved DynamoDB Item JSON Example
|
|
508
|
+
|
|
509
|
+
```json
|
|
510
|
+
{
|
|
511
|
+
"sessionId": "e4a91f82c3b4a07f",
|
|
512
|
+
"email": "alex.developer@example.com",
|
|
513
|
+
"ttl": 1771743600,
|
|
514
|
+
"sessionData": {
|
|
515
|
+
"id": "e4a91f82c3b4a07f",
|
|
516
|
+
"token": "ya29.a0ARW5m7...",
|
|
517
|
+
"userId": "1049281048",
|
|
518
|
+
"email": "alex.developer@example.com",
|
|
519
|
+
"provider": "google",
|
|
520
|
+
"accounts": {
|
|
521
|
+
"google": {
|
|
522
|
+
"provider": "google",
|
|
523
|
+
"email": "alex.developer@example.com",
|
|
524
|
+
"providerUserId": "1049281048",
|
|
525
|
+
"accessToken": "ya29.a0ARW5m7...",
|
|
526
|
+
"linkedAt": 1771657200000
|
|
527
|
+
},
|
|
528
|
+
"github": {
|
|
529
|
+
"provider": "github",
|
|
530
|
+
"email": "alex.developer@example.com",
|
|
531
|
+
"providerUserId": "5829104",
|
|
532
|
+
"accessToken": "gho_8f7b2a9e1c3...",
|
|
533
|
+
"linkedAt": 1771657250000
|
|
534
|
+
}
|
|
535
|
+
},
|
|
536
|
+
"resources": {
|
|
537
|
+
"github": {
|
|
538
|
+
"provider": "github",
|
|
539
|
+
"accessToken": "gho_resource_repo_9a8b7c...",
|
|
540
|
+
"scopes": ["repo", "read:org"],
|
|
541
|
+
"connectedAt": 1771657300000
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
"raw": {
|
|
545
|
+
"access_token": "ya29.a0ARW5m7...",
|
|
546
|
+
"token_type": "Bearer",
|
|
547
|
+
"expires_in": 3599
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
---
|
|
554
|
+
|
|
255
555
|
## User Info Utilities
|
|
256
556
|
|
|
257
557
|
Lixa provides utilities to extract user information from OAuth tokens:
|
package/README.template.md
CHANGED
|
@@ -310,26 +310,26 @@ export interface Session<TRaw = OAuthTokenResponse> {
|
|
|
310
310
|
/** Unique session ID generated by Lixa */
|
|
311
311
|
id?: string;
|
|
312
312
|
|
|
313
|
-
/** Primary access token or session token */
|
|
314
|
-
token: string;
|
|
315
|
-
|
|
316
313
|
/** Unified user ID across linked accounts */
|
|
317
314
|
userId?: string;
|
|
318
315
|
|
|
319
316
|
/** Primary user email */
|
|
320
317
|
email?: string;
|
|
321
318
|
|
|
322
|
-
/**
|
|
323
|
-
provider?: string;
|
|
324
|
-
|
|
325
|
-
/** Linked SSO provider accounts (AuthN) */
|
|
319
|
+
/** Linked SSO provider accounts (AuthN) - Single Source of Truth */
|
|
326
320
|
accounts?: Record<string, LinkedAccount>;
|
|
327
321
|
|
|
328
|
-
/** Connected third-party resource provider tokens (AuthZ) */
|
|
322
|
+
/** Connected third-party resource provider tokens (AuthZ) - Single Source of Truth */
|
|
329
323
|
resources?: Record<string, ConnectedResource>;
|
|
330
324
|
|
|
331
|
-
/**
|
|
332
|
-
|
|
325
|
+
/** Optional primary access token or session token */
|
|
326
|
+
token?: string;
|
|
327
|
+
|
|
328
|
+
/** Optional current active auth provider */
|
|
329
|
+
provider?: string;
|
|
330
|
+
|
|
331
|
+
/** Optional raw token response from provider */
|
|
332
|
+
raw?: TRaw;
|
|
333
333
|
}
|
|
334
334
|
```
|
|
335
335
|
|
|
@@ -976,25 +976,29 @@ export declare interface Session<TRaw = OAuthTokenResponse> {
|
|
|
976
976
|
*/
|
|
977
977
|
id?: string;
|
|
978
978
|
/**
|
|
979
|
-
*
|
|
979
|
+
* Linked identity provider accounts (AuthN) keyed by provider name.
|
|
980
|
+
* Single source of truth for all authenticated user SSO identities.
|
|
980
981
|
*/
|
|
981
|
-
|
|
982
|
+
accounts?: Record<string, LinkedAccount>;
|
|
983
|
+
/**
|
|
984
|
+
* Connected third-party resource provider tokens (AuthZ) keyed by provider name.
|
|
985
|
+
* Single source of truth for all post-login third-party API permissions.
|
|
986
|
+
*/
|
|
987
|
+
resources?: Record<string, ConnectedResource>;
|
|
982
988
|
/** Unique unified user ID across linked accounts */
|
|
983
989
|
userId?: string;
|
|
984
990
|
/** Primary user email */
|
|
985
991
|
email?: string;
|
|
986
|
-
/**
|
|
992
|
+
/**
|
|
993
|
+
* Optional primary access token or custom session token identifier.
|
|
994
|
+
*/
|
|
995
|
+
token?: string;
|
|
996
|
+
/** Optional current active auth provider for this session turn */
|
|
987
997
|
provider?: string;
|
|
988
|
-
/** Linked SSO provider accounts keyed by provider name */
|
|
989
|
-
accounts?: Record<string, LinkedAccount>;
|
|
990
|
-
/** Connected third-party resource provider tokens keyed by provider name */
|
|
991
|
-
resources?: Record<string, ConnectedResource>;
|
|
992
998
|
/**
|
|
993
|
-
*
|
|
994
|
-
* Contains the complete OAuth token response and any additional data
|
|
995
|
-
* your SessionStrategy adds (user info, database IDs, etc.).
|
|
999
|
+
* Optional raw session token response data from provider.
|
|
996
1000
|
*/
|
|
997
|
-
raw
|
|
1001
|
+
raw?: TRaw;
|
|
998
1002
|
}
|
|
999
1003
|
|
|
1000
1004
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -103,25 +103,29 @@ interface Session<TRaw = OAuthTokenResponse> {
|
|
|
103
103
|
*/
|
|
104
104
|
id?: string;
|
|
105
105
|
/**
|
|
106
|
-
*
|
|
106
|
+
* Linked identity provider accounts (AuthN) keyed by provider name.
|
|
107
|
+
* Single source of truth for all authenticated user SSO identities.
|
|
107
108
|
*/
|
|
108
|
-
|
|
109
|
+
accounts?: Record<string, LinkedAccount>;
|
|
110
|
+
/**
|
|
111
|
+
* Connected third-party resource provider tokens (AuthZ) keyed by provider name.
|
|
112
|
+
* Single source of truth for all post-login third-party API permissions.
|
|
113
|
+
*/
|
|
114
|
+
resources?: Record<string, ConnectedResource>;
|
|
109
115
|
/** Unique unified user ID across linked accounts */
|
|
110
116
|
userId?: string;
|
|
111
117
|
/** Primary user email */
|
|
112
118
|
email?: string;
|
|
113
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* Optional primary access token or custom session token identifier.
|
|
121
|
+
*/
|
|
122
|
+
token?: string;
|
|
123
|
+
/** Optional current active auth provider for this session turn */
|
|
114
124
|
provider?: string;
|
|
115
|
-
/** Linked SSO provider accounts keyed by provider name */
|
|
116
|
-
accounts?: Record<string, LinkedAccount>;
|
|
117
|
-
/** Connected third-party resource provider tokens keyed by provider name */
|
|
118
|
-
resources?: Record<string, ConnectedResource>;
|
|
119
125
|
/**
|
|
120
|
-
*
|
|
121
|
-
* Contains the complete OAuth token response and any additional data
|
|
122
|
-
* your SessionStrategy adds (user info, database IDs, etc.).
|
|
126
|
+
* Optional raw session token response data from provider.
|
|
123
127
|
*/
|
|
124
|
-
raw
|
|
128
|
+
raw?: TRaw;
|
|
125
129
|
}
|
|
126
130
|
/**
|
|
127
131
|
* Provider metadata passed to session strategy.
|
package/dist/models/session.d.ts
CHANGED
|
@@ -103,25 +103,29 @@ export interface Session<TRaw = OAuthTokenResponse> {
|
|
|
103
103
|
*/
|
|
104
104
|
id?: string;
|
|
105
105
|
/**
|
|
106
|
-
*
|
|
106
|
+
* Linked identity provider accounts (AuthN) keyed by provider name.
|
|
107
|
+
* Single source of truth for all authenticated user SSO identities.
|
|
107
108
|
*/
|
|
108
|
-
|
|
109
|
+
accounts?: Record<string, LinkedAccount>;
|
|
110
|
+
/**
|
|
111
|
+
* Connected third-party resource provider tokens (AuthZ) keyed by provider name.
|
|
112
|
+
* Single source of truth for all post-login third-party API permissions.
|
|
113
|
+
*/
|
|
114
|
+
resources?: Record<string, ConnectedResource>;
|
|
109
115
|
/** Unique unified user ID across linked accounts */
|
|
110
116
|
userId?: string;
|
|
111
117
|
/** Primary user email */
|
|
112
118
|
email?: string;
|
|
113
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* Optional primary access token or custom session token identifier.
|
|
121
|
+
*/
|
|
122
|
+
token?: string;
|
|
123
|
+
/** Optional current active auth provider for this session turn */
|
|
114
124
|
provider?: string;
|
|
115
|
-
/** Linked SSO provider accounts keyed by provider name */
|
|
116
|
-
accounts?: Record<string, LinkedAccount>;
|
|
117
|
-
/** Connected third-party resource provider tokens keyed by provider name */
|
|
118
|
-
resources?: Record<string, ConnectedResource>;
|
|
119
125
|
/**
|
|
120
|
-
*
|
|
121
|
-
* Contains the complete OAuth token response and any additional data
|
|
122
|
-
* your SessionStrategy adds (user info, database IDs, etc.).
|
|
126
|
+
* Optional raw session token response data from provider.
|
|
123
127
|
*/
|
|
124
|
-
raw
|
|
128
|
+
raw?: TRaw;
|
|
125
129
|
}
|
|
126
130
|
/**
|
|
127
131
|
* Provider metadata passed to session strategy.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/models/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CACtD;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IAEjB,oCAAoC;IACpC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEpC,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE3B,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAC;IAEpB,4CAA4C;IAC5C,GAAG,EAAE,kBAAkB,CAAC;IAExB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAC;IAEjB,4BAA4B;IAC5B,WAAW,EAAE,MAAM,CAAC;IAEpB,yDAAyD;IACzD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,WAAW,eAAe;IAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgFG;IACH,aAAa,CAAC,SAAS,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACpG;AAED;;;;;GAKG;AACH,qBAAa,sBAAuB,YAAW,eAAe;IAC5D;;;;;;;OAOG;IACG,aAAa,CAAC,SAAS,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;CAUzG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vunexa/lixa",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6-alpha.2",
|
|
4
4
|
"description": "Lixa is a flexible, provider-agnostic OAuth and OpenID Connect (OIDC) client library that simplifies multi-provider authentication flows. It supports seamless integration with providers like Google and GitHub, offers extensible session management, and enables dynamic provider resolution based on callback URLs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"oauth",
|