@vunexa/lixa 0.1.6-alpha.7 → 0.1.6-alpha.9
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 +1 -2
- package/README.template.md +1 -2
- package/dist/dao/session-cache.d.ts +2 -1
- package/dist/dao/session-cache.d.ts.map +1 -1
- package/dist/dao/state-cache.d.ts +4 -0
- package/dist/dao/state-cache.d.ts.map +1 -1
- package/dist/dao/types.d.ts +21 -75
- package/dist/dao/types.d.ts.map +1 -1
- package/dist/errors.d.ts +90 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/export-types/index.d.ts +439 -95
- package/dist/express.d.ts +103 -0
- package/dist/express.d.ts.map +1 -0
- package/dist/index.cjs +509 -129
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +408 -96
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +483 -128
- package/dist/index.js.map +1 -1
- package/dist/lixa.d.ts +25 -21
- package/dist/lixa.d.ts.map +1 -1
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/cookies.d.ts +142 -0
- package/dist/utils/cookies.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/lixa.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type LixaConfig, type ProviderConfig } from "./types";
|
|
2
2
|
import { IProvider } from "./providers";
|
|
3
|
-
import { ResourceHandler } from "./dao/types";
|
|
4
3
|
import { type Session, type ConnectedResource } from "./models/session";
|
|
5
4
|
/**
|
|
6
5
|
* Type representing the keys of configured providers
|
|
@@ -61,8 +60,11 @@ type ConfiguredProviderKey<T extends LixaConfig<Record<string, ProviderConfig>>>
|
|
|
61
60
|
declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConfig>> = LixaConfig> {
|
|
62
61
|
private static DEFAULT_PROVIDERS;
|
|
63
62
|
private static CONFIGURED_PROVIDERS;
|
|
64
|
-
private
|
|
65
|
-
private
|
|
63
|
+
private localStateHandler;
|
|
64
|
+
private localSessionHandler;
|
|
65
|
+
private localResourceHandler;
|
|
66
|
+
private userResourceStore;
|
|
67
|
+
private refreshMutexes;
|
|
66
68
|
private config;
|
|
67
69
|
private stateHandler;
|
|
68
70
|
private sessionHandler;
|
|
@@ -87,7 +89,7 @@ declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConfig>> =
|
|
|
87
89
|
*
|
|
88
90
|
* @param name - The provider name
|
|
89
91
|
* @param config - The provider configuration
|
|
90
|
-
* @throws
|
|
92
|
+
* @throws InvalidProviderConfigError when required fields are missing or invalid
|
|
91
93
|
*/
|
|
92
94
|
private validateProviderConfig;
|
|
93
95
|
/**
|
|
@@ -95,20 +97,16 @@ declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConfig>> =
|
|
|
95
97
|
*
|
|
96
98
|
* @param name - The provider name
|
|
97
99
|
* @param provider - The provider implementation
|
|
98
|
-
* @throws
|
|
100
|
+
* @throws InvalidProviderConfigError when required properties are missing
|
|
99
101
|
*/
|
|
100
102
|
private validateProviderImplementation;
|
|
101
103
|
/**
|
|
102
|
-
* Structured
|
|
104
|
+
* Structured logging with standardized format and custom logger support.
|
|
103
105
|
*
|
|
104
|
-
* @param level - Log level (INFO, WARN, ERROR)
|
|
105
|
-
* @param context - Context of the log (Init, Auth, Token, Session, State)
|
|
106
|
+
* @param level - Log level (INFO, WARN, ERROR, DEBUG)
|
|
107
|
+
* @param context - Context of the log (Init, Auth, Token, Session, State, AccountLinking, Resource)
|
|
106
108
|
* @param message - Log message
|
|
107
109
|
* @param data - Optional data to log
|
|
108
|
-
*
|
|
109
|
-
* @remarks
|
|
110
|
-
* Format: [Lixa] [timestamp] [level] [context] message
|
|
111
|
-
* Only logs when debug mode is enabled.
|
|
112
110
|
*/
|
|
113
111
|
private log;
|
|
114
112
|
/**
|
|
@@ -307,7 +305,7 @@ declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConfig>> =
|
|
|
307
305
|
*/
|
|
308
306
|
getAuthUrl(provider: ConfiguredProviderKey<TConfig> | string, state?: string): Promise<string>;
|
|
309
307
|
/**
|
|
310
|
-
* Restricts primary authentication scopes strictly to AuthN identity scopes.
|
|
308
|
+
* Restricts primary authentication scopes strictly to AuthN identity scopes unless allowNonAuthScopes is true.
|
|
311
309
|
*/
|
|
312
310
|
private resolveAuthNScopes;
|
|
313
311
|
/**
|
|
@@ -373,14 +371,6 @@ declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConfig>> =
|
|
|
373
371
|
prompt?: string;
|
|
374
372
|
extraConfig?: Record<string, string>;
|
|
375
373
|
}): Promise<string>;
|
|
376
|
-
/**
|
|
377
|
-
* Handles the OAuth callback for a connected resource provider and stores resource tokens on the session.
|
|
378
|
-
*
|
|
379
|
-
* @param params - Object containing sessionId, provider, code, state, and requested scopes
|
|
380
|
-
* @returns Updated Session containing stored resource tokens under session.resources[provider]
|
|
381
|
-
*/
|
|
382
|
-
private static userResourceStore;
|
|
383
|
-
static LOCAL_RESOURCE_HANDLER: ResourceHandler;
|
|
384
374
|
private getUserKeyFromSession;
|
|
385
375
|
/**
|
|
386
376
|
* Handles the OAuth callback for a connected resource provider and stores resource tokens bound to user account.
|
|
@@ -413,11 +403,16 @@ declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConfig>> =
|
|
|
413
403
|
getConnectedResource(sessionId: string, provider: string): Promise<ConnectedResource | null>;
|
|
414
404
|
/**
|
|
415
405
|
* Refreshes a user's resource access token using its refresh token.
|
|
406
|
+
* Deduplicates concurrent refresh requests via an in-flight promise mutex.
|
|
416
407
|
*
|
|
417
408
|
* @param userIdOrEmail - User identifier or email
|
|
418
409
|
* @param provider - Provider identifier (e.g. 'google', 'github')
|
|
419
410
|
*/
|
|
420
411
|
refreshUserResourceToken(userIdOrEmail: string, provider: string, existingResource?: ConnectedResource): Promise<ConnectedResource>;
|
|
412
|
+
/**
|
|
413
|
+
* Internal execution of refresh token exchange.
|
|
414
|
+
*/
|
|
415
|
+
private executeRefreshUserResourceToken;
|
|
421
416
|
/**
|
|
422
417
|
* Refreshes a connected resource access token for an active session.
|
|
423
418
|
*/
|
|
@@ -430,7 +425,16 @@ declare class Lixa<TConfig extends LixaConfig<Record<string, ProviderConfig>> =
|
|
|
430
425
|
* Disconnects a resource provider from an active session and user account.
|
|
431
426
|
*/
|
|
432
427
|
disconnectResource(sessionId: string, provider: string): Promise<boolean>;
|
|
428
|
+
/**
|
|
429
|
+
* Retrieves active session details from session storage.
|
|
430
|
+
*/
|
|
433
431
|
fetchSessionInfo(sessionId: string): Promise<Session | null>;
|
|
432
|
+
/**
|
|
433
|
+
* Deletes a session from session storage (e.g. on logout).
|
|
434
|
+
*
|
|
435
|
+
* @param sessionId - Active session identifier
|
|
436
|
+
*/
|
|
437
|
+
deleteSession(sessionId: string): Promise<void>;
|
|
434
438
|
private exchangeCodeForToken;
|
|
435
439
|
private findProviderByType;
|
|
436
440
|
}
|
package/dist/lixa.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lixa.d.ts","sourceRoot":"","sources":["../src/lixa.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"lixa.d.ts","sourceRoot":"","sources":["../src/lixa.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAKxC,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,iBAAiB,EAAkD,MAAM,kBAAkB,CAAC;AAexH;;GAEG;AACH,KAAK,qBAAqB,CAAC,CAAC,SAAS,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,IAAI,M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;IA+D7C;;OAEG;IACU,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAiBlG;;OAEG;IACU,sBAAsB,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAM9F;;OAEG;IACU,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAetF;;OAEG;IACU,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAKzE;;;;OAIG;IACU,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAK9C,oBAAoB;IAmDlC,OAAO,CAAC,kBAAkB;CAS3B;AAED,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -57,6 +57,12 @@ export type ProviderConfig = {
|
|
|
57
57
|
redirectUri: string;
|
|
58
58
|
/** Array of OAuth scopes to request */
|
|
59
59
|
scopes: string[];
|
|
60
|
+
/**
|
|
61
|
+
* Set to true to allow non-identity (resource) scopes during primary authentication flow.
|
|
62
|
+
* By default (false), Lixa restricts primary AuthN scopes to identity scopes to maintain
|
|
63
|
+
* clean AuthN vs AuthZ separation.
|
|
64
|
+
*/
|
|
65
|
+
allowNonAuthScopes?: boolean;
|
|
60
66
|
/** Additional provider-specific configuration parameters */
|
|
61
67
|
extraConfig?: Record<string, string>;
|
|
62
68
|
} & ({
|
|
@@ -222,6 +228,28 @@ export interface LixaConfig<TProviders extends Record<string, ProviderConfig> =
|
|
|
222
228
|
* Format: [Lixa] [timestamp] [level] [context] message
|
|
223
229
|
*/
|
|
224
230
|
debug?: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Optional custom structured logger implementation.
|
|
233
|
+
* If provided, all Lixa logs will be routed through this logger.
|
|
234
|
+
*/
|
|
235
|
+
logger?: LixaLogger;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Log level for Lixa structured logging.
|
|
239
|
+
* @public
|
|
240
|
+
*/
|
|
241
|
+
export type LogLevel = "INFO" | "WARN" | "ERROR" | "DEBUG";
|
|
242
|
+
/**
|
|
243
|
+
* Log context for Lixa structured logging.
|
|
244
|
+
* @public
|
|
245
|
+
*/
|
|
246
|
+
export type LogContext = "Init" | "Auth" | "Token" | "Session" | "State" | "AccountLinking" | "Resource";
|
|
247
|
+
/**
|
|
248
|
+
* Custom logger interface for Lixa.
|
|
249
|
+
* @public
|
|
250
|
+
*/
|
|
251
|
+
export interface LixaLogger {
|
|
252
|
+
log(level: LogLevel, context: LogContext, message: string, data?: Record<string, unknown>): void;
|
|
225
253
|
}
|
|
226
254
|
/**
|
|
227
255
|
* Helper type to create a configuration with only registered providers.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACtI,OAAO,EAAW,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,OAAO,EAAE,c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D;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAE3D;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,gBAAgB,GAAG,UAAU,CAAC;AAEzG;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAClG;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,CAAC,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,GAAG;IACvG,SAAS,EAAE,UAAU,CAAC;CACvB,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sensible default cookie configuration options.
|
|
3
|
+
* Follows RFC 6265bis and OAuth 2.0 security best practices.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface CookieOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Cookie name.
|
|
10
|
+
* @default 'lixa_session'
|
|
11
|
+
*/
|
|
12
|
+
name?: string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Cookie path.
|
|
15
|
+
* @default '/'
|
|
16
|
+
*/
|
|
17
|
+
path?: string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Maximum age of the cookie in seconds.
|
|
20
|
+
*/
|
|
21
|
+
maxAge?: number | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Prevents client-side scripts from accessing the cookie (XSS protection).
|
|
24
|
+
* @default true
|
|
25
|
+
*/
|
|
26
|
+
httpOnly?: boolean | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Ensures the cookie is only transmitted over secure HTTPS connections.
|
|
29
|
+
* @default false in development, true in production
|
|
30
|
+
*/
|
|
31
|
+
secure?: boolean | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Controls whether the cookie is sent with cross-site requests (CSRF protection).
|
|
34
|
+
* @default 'lax'
|
|
35
|
+
*/
|
|
36
|
+
sameSite?: "lax" | "strict" | "none" | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Cookie domain.
|
|
39
|
+
*/
|
|
40
|
+
domain?: string | undefined;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Cookie payload containing name, value, options, and formatted header.
|
|
44
|
+
*
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export interface CookiePayload {
|
|
48
|
+
name: string;
|
|
49
|
+
value: string;
|
|
50
|
+
options: CookieOptions;
|
|
51
|
+
/**
|
|
52
|
+
* Formatted `Set-Cookie` header value string.
|
|
53
|
+
*/
|
|
54
|
+
header: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Default session cookie name.
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare const DEFAULT_SESSION_COOKIE_NAME = "lixa_session";
|
|
61
|
+
/**
|
|
62
|
+
* Default OAuth state cookie name.
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export declare const DEFAULT_STATE_COOKIE_NAME = "lixa_oauth_state";
|
|
66
|
+
/**
|
|
67
|
+
* Default session max age in seconds (24 hours).
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export declare const DEFAULT_SESSION_MAX_AGE_SECONDS: number;
|
|
71
|
+
/**
|
|
72
|
+
* Default OAuth state max age in seconds (5 minutes / 300 seconds).
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
export declare const DEFAULT_STATE_MAX_AGE_SECONDS: number;
|
|
76
|
+
/**
|
|
77
|
+
* Checks if the runtime environment is production.
|
|
78
|
+
* @public
|
|
79
|
+
*/
|
|
80
|
+
export declare function isProductionEnvironment(): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Serializes a cookie name, value, and options into a standard `Set-Cookie` header string.
|
|
83
|
+
*
|
|
84
|
+
* @param name - Cookie name
|
|
85
|
+
* @param value - Cookie value
|
|
86
|
+
* @param options - Cookie attributes
|
|
87
|
+
* @returns Formatted `Set-Cookie` string
|
|
88
|
+
*
|
|
89
|
+
* @public
|
|
90
|
+
*/
|
|
91
|
+
export declare function serializeCookie(name: string, value: string, options?: CookieOptions): string;
|
|
92
|
+
/**
|
|
93
|
+
* Generates a session cookie payload with secure default options.
|
|
94
|
+
*
|
|
95
|
+
* @param sessionId - The session identifier string
|
|
96
|
+
* @param options - Optional overrides for cookie attributes
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const cookie = createSessionCookie(sessionId);
|
|
101
|
+
* res.setHeader("Set-Cookie", cookie.header);
|
|
102
|
+
* // or with Express:
|
|
103
|
+
* res.cookie(cookie.name, cookie.value, cookie.options);
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
108
|
+
export declare function createSessionCookie(sessionId: string, options?: CookieOptions): CookiePayload;
|
|
109
|
+
/**
|
|
110
|
+
* Generates an expired session cookie payload to clear the session on logout.
|
|
111
|
+
*
|
|
112
|
+
* @param options - Optional overrides for cookie name or attributes
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const cookie = clearSessionCookie();
|
|
117
|
+
* res.setHeader("Set-Cookie", cookie.header);
|
|
118
|
+
* // or with Express:
|
|
119
|
+
* res.clearCookie(cookie.name, cookie.options);
|
|
120
|
+
* ```
|
|
121
|
+
*
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
export declare function clearSessionCookie(options?: CookieOptions): CookiePayload;
|
|
125
|
+
/**
|
|
126
|
+
* Generates an OAuth CSRF state cookie payload for in-flight authorization flows.
|
|
127
|
+
*
|
|
128
|
+
* @param state - The random state string
|
|
129
|
+
* @param options - Optional overrides for cookie attributes
|
|
130
|
+
*
|
|
131
|
+
* @public
|
|
132
|
+
*/
|
|
133
|
+
export declare function createStateCookie(state: string, options?: CookieOptions): CookiePayload;
|
|
134
|
+
/**
|
|
135
|
+
* Generates an expired OAuth state cookie payload to clean up the state cookie after callback.
|
|
136
|
+
*
|
|
137
|
+
* @param options - Optional overrides for cookie attributes
|
|
138
|
+
*
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
export declare function clearStateCookie(options?: CookieOptions): CookiePayload;
|
|
142
|
+
//# sourceMappingURL=cookies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookies.d.ts","sourceRoot":"","sources":["../../src/utils/cookies.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE1B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE1B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE/B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;IAEjD;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,aAAa,CAAC;IACvB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B,iBAAiB,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,yBAAyB,qBAAqB,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,+BAA+B,QAAe,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,6BAA6B,QAAS,CAAC;AAEpD;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,OAAO,CAEjD;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAsC5F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,CAqB7F;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,CAqBzE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,CAqBvF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,CAqBvE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vunexa/lixa",
|
|
3
|
-
"version": "0.1.6-alpha.
|
|
3
|
+
"version": "0.1.6-alpha.9",
|
|
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",
|