@vunexa/lixa 0.1.6-alpha.1 → 0.1.6-alpha.3

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 CHANGED
@@ -28,36 +28,7 @@ A flexible, provider-agnostic OAuth 2.0 and OpenID Connect (OIDC) client library
28
28
 
29
29
  ## Architecture Overview
30
30
 
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
- ```
31
+ ![Architecture Overview](https://cdn.jsdelivr.net/npm/@vunexa/lixa/docs/images/architecture.svg)
61
32
 
62
33
  ---
63
34
 
@@ -249,26 +220,26 @@ export interface Session<TRaw = OAuthTokenResponse> {
249
220
  /** Unique session ID generated by Lixa */
250
221
  id?: string;
251
222
 
252
- /** Primary access token or session token */
253
- token: string;
254
-
255
223
  /** Unified user ID across linked accounts */
256
224
  userId?: string;
257
225
 
258
226
  /** Primary user email */
259
227
  email?: string;
260
228
 
261
- /** Current active auth provider */
262
- provider?: string;
263
-
264
- /** Linked SSO provider accounts (AuthN) */
229
+ /** Linked SSO provider accounts (AuthN) - Single Source of Truth */
265
230
  accounts?: Record<string, LinkedAccount>;
266
231
 
267
- /** Connected third-party resource provider tokens (AuthZ) */
232
+ /** Connected third-party resource provider tokens (AuthZ) - Single Source of Truth */
268
233
  resources?: Record<string, ConnectedResource>;
269
234
 
270
- /** Full raw token response from provider */
271
- raw: TRaw;
235
+ /** Optional primary access token or session token */
236
+ token?: string;
237
+
238
+ /** Optional current active auth provider */
239
+ provider?: string;
240
+
241
+ /** Optional raw token response from provider */
242
+ raw?: TRaw;
272
243
  }
273
244
  ```
274
245
 
@@ -371,10 +342,8 @@ export const lixa = new Lixa({
371
342
  ```json
372
343
  {
373
344
  "id": "e4a91f82c3b4a07f",
374
- "token": "ya29.a0ARW5m7...",
375
345
  "userId": "1049281048",
376
346
  "email": "alex.developer@example.com",
377
- "provider": "google",
378
347
  "accounts": {
379
348
  "google": {
380
349
  "provider": "google",
@@ -398,11 +367,6 @@ export const lixa = new Lixa({
398
367
  "scopes": ["repo", "read:org"],
399
368
  "connectedAt": 1771657300000
400
369
  }
401
- },
402
- "raw": {
403
- "access_token": "ya29.a0ARW5m7...",
404
- "token_type": "Bearer",
405
- "expires_in": 3599
406
370
  }
407
371
  }
408
372
  ```
@@ -513,10 +477,8 @@ export const lixa = new Lixa({
513
477
  "ttl": 1771743600,
514
478
  "sessionData": {
515
479
  "id": "e4a91f82c3b4a07f",
516
- "token": "ya29.a0ARW5m7...",
517
480
  "userId": "1049281048",
518
481
  "email": "alex.developer@example.com",
519
- "provider": "google",
520
482
  "accounts": {
521
483
  "google": {
522
484
  "provider": "google",
@@ -540,11 +502,6 @@ export const lixa = new Lixa({
540
502
  "scopes": ["repo", "read:org"],
541
503
  "connectedAt": 1771657300000
542
504
  }
543
- },
544
- "raw": {
545
- "access_token": "ya29.a0ARW5m7...",
546
- "token_type": "Bearer",
547
- "expires_in": 3599
548
505
  }
549
506
  }
550
507
  }
@@ -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
- /** Current active auth provider */
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
- /** Full raw token response from provider */
332
- raw: TRaw;
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
 
@@ -432,10 +432,8 @@ export const lixa = new Lixa({
432
432
  ```json
433
433
  {
434
434
  "id": "e4a91f82c3b4a07f",
435
- "token": "ya29.a0ARW5m7...",
436
435
  "userId": "1049281048",
437
436
  "email": "alex.developer@example.com",
438
- "provider": "google",
439
437
  "accounts": {
440
438
  "google": {
441
439
  "provider": "google",
@@ -459,11 +457,6 @@ export const lixa = new Lixa({
459
457
  "scopes": ["repo", "read:org"],
460
458
  "connectedAt": 1771657300000
461
459
  }
462
- },
463
- "raw": {
464
- "access_token": "ya29.a0ARW5m7...",
465
- "token_type": "Bearer",
466
- "expires_in": 3599
467
460
  }
468
461
  }
469
462
  ```
@@ -574,10 +567,8 @@ export const lixa = new Lixa({
574
567
  "ttl": 1771743600,
575
568
  "sessionData": {
576
569
  "id": "e4a91f82c3b4a07f",
577
- "token": "ya29.a0ARW5m7...",
578
570
  "userId": "1049281048",
579
571
  "email": "alex.developer@example.com",
580
- "provider": "google",
581
572
  "accounts": {
582
573
  "google": {
583
574
  "provider": "google",
@@ -601,11 +592,6 @@ export const lixa = new Lixa({
601
592
  "scopes": ["repo", "read:org"],
602
593
  "connectedAt": 1771657300000
603
594
  }
604
- },
605
- "raw": {
606
- "access_token": "ya29.a0ARW5m7...",
607
- "token_type": "Bearer",
608
- "expires_in": 3599
609
595
  }
610
596
  }
611
597
  }
@@ -976,25 +976,29 @@ export declare interface Session<TRaw = OAuthTokenResponse> {
976
976
  */
977
977
  id?: string;
978
978
  /**
979
- * The primary access token or session token identifier.
979
+ * Linked identity provider accounts (AuthN) keyed by provider name.
980
+ * Single source of truth for all authenticated user SSO identities.
980
981
  */
981
- token: string;
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
- /** Current active auth provider for this session turn */
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
- * Raw session data.
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: TRaw;
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
- * The primary access token or session token identifier.
106
+ * Linked identity provider accounts (AuthN) keyed by provider name.
107
+ * Single source of truth for all authenticated user SSO identities.
107
108
  */
108
- token: string;
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
- /** Current active auth provider for this session turn */
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
- * Raw session data.
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: TRaw;
128
+ raw?: TRaw;
125
129
  }
126
130
  /**
127
131
  * Provider metadata passed to session strategy.
@@ -103,25 +103,29 @@ export interface Session<TRaw = OAuthTokenResponse> {
103
103
  */
104
104
  id?: string;
105
105
  /**
106
- * The primary access token or session token identifier.
106
+ * Linked identity provider accounts (AuthN) keyed by provider name.
107
+ * Single source of truth for all authenticated user SSO identities.
107
108
  */
108
- token: string;
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
- /** Current active auth provider for this session turn */
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
- * Raw session data.
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: TRaw;
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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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACH,MAAM,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.6-alpha.1",
3
+ "version": "0.1.6-alpha.3",
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",