@vunexa/lixa 0.0.1-alpha.8 → 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.
Files changed (52) hide show
  1. package/README.md +263 -143
  2. package/dist/dao/session-cache.d.ts +11 -0
  3. package/dist/dao/session-cache.d.ts.map +1 -0
  4. package/dist/dao/state-cache.d.ts +8 -6
  5. package/dist/dao/state-cache.d.ts.map +1 -1
  6. package/dist/dao/types.d.ts +376 -3
  7. package/dist/dao/types.d.ts.map +1 -1
  8. package/dist/export-types/index.d.ts +1397 -0
  9. package/dist/export-types/tsdoc-metadata.json +11 -0
  10. package/dist/index.cjs +1035 -0
  11. package/dist/index.cjs.map +1 -0
  12. package/dist/index.d.cts +1361 -0
  13. package/dist/index.d.ts +11 -2
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +992 -9
  16. package/dist/index.js.map +1 -1
  17. package/dist/lixa.d.ts +286 -19
  18. package/dist/lixa.d.ts.map +1 -1
  19. package/dist/models/session.d.ts +316 -0
  20. package/dist/models/session.d.ts.map +1 -0
  21. package/dist/providers/IProvider.d.ts +127 -4
  22. package/dist/providers/IProvider.d.ts.map +1 -1
  23. package/dist/providers/index.d.ts +0 -2
  24. package/dist/providers/index.d.ts.map +1 -1
  25. package/dist/types.d.ts +195 -24
  26. package/dist/types.d.ts.map +1 -1
  27. package/dist/utils/user-info.d.ts +82 -0
  28. package/dist/utils/user-info.d.ts.map +1 -0
  29. package/package.json +15 -10
  30. package/dist/dao/state-cache.js +0 -18
  31. package/dist/dao/state-cache.js.map +0 -1
  32. package/dist/dao/types.js +0 -2
  33. package/dist/dao/types.js.map +0 -1
  34. package/dist/lixa.js +0 -248
  35. package/dist/lixa.js.map +0 -1
  36. package/dist/providers/IProvider.js +0 -2
  37. package/dist/providers/IProvider.js.map +0 -1
  38. package/dist/providers/github.d.ts +0 -9
  39. package/dist/providers/github.d.ts.map +0 -1
  40. package/dist/providers/github.js +0 -8
  41. package/dist/providers/github.js.map +0 -1
  42. package/dist/providers/google.d.ts +0 -9
  43. package/dist/providers/google.d.ts.map +0 -1
  44. package/dist/providers/google.js +0 -8
  45. package/dist/providers/google.js.map +0 -1
  46. package/dist/providers/index.js +0 -3
  47. package/dist/providers/index.js.map +0 -1
  48. package/dist/types.js +0 -2
  49. package/dist/types.js.map +0 -1
  50. package/dist/utils/constants.js +0 -4
  51. package/dist/utils/constants.js.map +0 -1
  52. package/index.d.ts +0 -227
package/dist/types.d.ts CHANGED
@@ -1,10 +1,52 @@
1
- import { StateDao } from "./dao/types";
1
+ import { SessionHandler, SessionStorage, StateHandler, StateStorage, StateData } from "./dao/types";
2
+ import { ProviderMetadata } from "./models/session";
3
+ import { IProvider } from "./providers/IProvider";
4
+ export { Session, ConnectedResource } from "./models/session";
5
+ export { ProviderMetadata };
6
+ export { OAuthTokenResponse } from "./models/session";
7
+ export { IProvider };
8
+ export { StateHandler };
9
+ export { StateStorage };
10
+ export { SessionHandler };
11
+ export { SessionStorage };
12
+ export { StateData };
2
13
  /**
3
- * Configuration for an OAuth provider.
14
+ * Configuration for an OAuth provider instance.
15
+ *
16
+ * @remarks
17
+ * For built-in providers (google, github), just provide credentials.
18
+ * For custom providers, include the provider implementation.
19
+ *
20
+ * The provider field uses a discriminated union to ensure type safety:
21
+ * - When omitted or undefined: assumes a built-in provider
22
+ * - When provided: must be a valid IProvider implementation
23
+ *
24
+ * @example
25
+ * Built-in provider configuration:
26
+ * ```typescript
27
+ * {
28
+ * clientId: 'your-client-id',
29
+ * clientSecret: 'your-client-secret',
30
+ * redirectUri: 'https://app.com/callback',
31
+ * scopes: ['openid', 'email']
32
+ * }
33
+ * ```
34
+ *
35
+ * @example
36
+ * Custom provider configuration:
37
+ * ```typescript
38
+ * {
39
+ * provider: new CustomProvider(),
40
+ * clientId: 'your-client-id',
41
+ * clientSecret: 'your-client-secret',
42
+ * redirectUri: 'https://app.com/callback',
43
+ * scopes: ['read:user']
44
+ * }
45
+ * ```
4
46
  *
5
47
  * @public
6
48
  */
7
- export interface ProviderConfig {
49
+ export type ProviderConfig = {
8
50
  /** The OAuth client ID provided by the provider */
9
51
  clientId: string;
10
52
  /** The OAuth client secret provided by the provider */
@@ -14,44 +56,173 @@ export interface ProviderConfig {
14
56
  /** Array of OAuth scopes to request */
15
57
  scopes: string[];
16
58
  /** Additional provider-specific configuration parameters */
17
- extraConfig?: Record<string, any>;
18
- }
59
+ extraConfig?: Record<string, string>;
60
+ } & ({
61
+ provider?: never;
62
+ } | {
63
+ provider: IProvider;
64
+ });
19
65
  /**
20
66
  * Main configuration object for Lixa.
67
+ * Provides type-safe provider name inference.
68
+ *
69
+ * @remarks
70
+ * The generic type parameter TProviders enables TypeScript to infer provider names
71
+ * from the configuration object, providing autocomplete and type checking for
72
+ * provider names in methods like getAuthUrl() and handleCallback().
73
+ *
74
+ * @typeParam TProviders - The provider configuration map type, defaults to a generic record
75
+ *
76
+ * @example
77
+ * Basic configuration with built-in providers:
78
+ * ```typescript
79
+ * import { Lixa } from '@vunexa/lixa';
80
+ * import { GoogleProvider } from '@vunexa/lixa-providers';
81
+ *
82
+ * const lixa = new Lixa({
83
+ * providers: {
84
+ * google: {
85
+ * provider: new GoogleProvider(),
86
+ * clientId: process.env.GOOGLE_CLIENT_ID!,
87
+ * clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
88
+ * redirectUri: 'https://app.com/auth/google/callback',
89
+ * scopes: ['openid', 'email', 'profile']
90
+ * }
91
+ * }
92
+ * });
93
+ * ```
94
+ *
95
+ * @example
96
+ * Configuration with custom session and state handlers:
97
+ * ```typescript
98
+ * const lixa = new Lixa({
99
+ * providers: {
100
+ * google: {
101
+ * provider: new GoogleProvider(),
102
+ * clientId: process.env.GOOGLE_CLIENT_ID!,
103
+ * clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
104
+ * redirectUri: 'https://app.com/auth/google/callback',
105
+ * scopes: ['openid', 'email', 'profile']
106
+ * }
107
+ * },
108
+ * stateHandler: {
109
+ * storage: {
110
+ * saveState: async (state, data, ttl) => await redis.setex(state, ttl, JSON.stringify(data)),
111
+ * getState: async (state) => JSON.parse(await redis.get(state) || 'null'),
112
+ * deleteState: async (state) => await redis.del(state)
113
+ * }
114
+ * },
115
+ * sessionHandler: {
116
+ * GenerateSession: async (tokenData, providerMetadata) => {
117
+ * const { userInfo } = await extractUserInfo(tokenData, providerMetadata);
118
+ * const user = await db.users.upsert({ email: userInfo.email });
119
+ * return { token: tokenData.access_token, raw: { ...tokenData, userId: user.id } };
120
+ * },
121
+ * storage: {
122
+ * saveSession: async (id, session, ttl) => await db.sessions.create({ id, session, ttl }),
123
+ * getSession: async (id) => await db.sessions.findOne({ id }),
124
+ * deleteSession: async (id) => await db.sessions.delete({ id })
125
+ * }
126
+ * },
127
+ * debug: true
128
+ * });
129
+ * ```
130
+ *
131
+ /**
132
+ * Strategy mode for multi-SSO identity account linking.
21
133
  *
22
134
  * @public
23
135
  */
24
- export interface LixaConfig {
25
- /** Map of provider names to their configurations */
26
- providers: Record<string, ProviderConfig>;
27
- /** Optional custom session creation strategy */
28
- sessionStrategy?: SessionStrategy;
29
- /** Optional custom state storage implementation */
30
- stateDao?: StateDao;
136
+ export declare enum AccountLinkingStrategy {
137
+ /** Automatically merge identities matching the same verified primary email address */
138
+ AUTO_LINK_BY_VERIFIED_EMAIL = "AUTO_LINK_BY_VERIFIED_EMAIL",
139
+ /** Keep identity profiles isolated per provider (no automatic account merging) */
140
+ ISOLATED = "ISOLATED"
31
141
  }
32
142
  /**
33
- * Strategy interface for custom session creation.
143
+ * Supported mode values for account linking configuration.
144
+ *
145
+ * @public
146
+ */
147
+ export type AccountLinkingMode = AccountLinkingStrategy | "AUTO_LINK_BY_VERIFIED_EMAIL" | "ISOLATED" | "linkByEmail" | "separate";
148
+ /**
149
+ * Account linking settings for Lixa.
34
150
  *
35
151
  * @public
36
152
  */
37
- export interface SessionStrategy {
153
+ export interface AccountLinkingConfig {
38
154
  /**
39
- * Creates a session from OAuth token data.
155
+ * Account linking mode strategy:
156
+ * - AccountLinkingStrategy.AUTO_LINK_BY_VERIFIED_EMAIL ("AUTO_LINK_BY_VERIFIED_EMAIL" / "linkByEmail"): Auto-link accounts sharing same verified email.
157
+ * - AccountLinkingStrategy.ISOLATED ("ISOLATED" / "separate"): Keep provider accounts isolated (default).
40
158
  *
41
- * @param userInfo - The token data received from the OAuth provider
42
- * @returns A Promise that resolves to a Session object
159
+ * @default AccountLinkingStrategy.ISOLATED
43
160
  */
44
- createSession(userInfo: any): Promise<Session>;
161
+ mode?: AccountLinkingMode;
162
+ /**
163
+ * Whether to require that the email address is verified by the provider before linking.
164
+ *
165
+ * @default true
166
+ */
167
+ requireVerifiedEmail?: boolean;
45
168
  }
46
169
  /**
47
- * Represents a user session after successful OAuth authentication.
170
+ * Main configuration object for Lixa.
171
+ * Provides type-safe provider name inference.
48
172
  *
49
173
  * @public
50
174
  */
51
- export interface Session {
52
- /** The session token (typically the access token) */
53
- token: string;
54
- /** Raw token data from the OAuth provider */
55
- raw: any;
175
+ export interface LixaConfig<TProviders extends Record<string, ProviderConfig> = Record<string, ProviderConfig>> {
176
+ /**
177
+ * Map of provider names to their configurations.
178
+ * Provider names will be available for autocomplete in getAuthUrl() and handleCallback().
179
+ */
180
+ providers: TProviders;
181
+ /**
182
+ * Account linking configuration for multi-SSO user linking.
183
+ */
184
+ accountLinking?: AccountLinkingConfig;
185
+ /**
186
+ * Optional custom state handler.
187
+ * Handles state generation and storage during OAuth authorization flow.
188
+ *
189
+ * - GenerateState: Customizes how state parameters and PKCE verifiers are generated
190
+ * - storage: Provides persistent state storage (save/get/delete operations)
191
+ *
192
+ * Defaults to in-memory cache if not provided (not suitable for production).
193
+ *
194
+ * @see {@link StateHandler}
195
+ */
196
+ stateHandler?: StateHandler;
197
+ /**
198
+ * Optional custom session handler.
199
+ * Handles session generation and storage after authentication.
200
+ *
201
+ * - GenerateSession: Customizes how OAuth tokens are converted into session data
202
+ * - storage: Provides persistent session storage (save/get/delete operations)
203
+ *
204
+ * Defaults to in-memory cache if not provided (not suitable for production).
205
+ *
206
+ * @see {@link SessionHandler}
207
+ */
208
+ sessionHandler?: SessionHandler;
209
+ /**
210
+ * Enable debug logging.
211
+ * When enabled, outputs structured logs for initialization, auth flow, and errors.
212
+ * Format: [Lixa] [timestamp] [level] [context] message
213
+ */
214
+ debug?: boolean;
56
215
  }
216
+ /**
217
+ * Helper type to create a configuration with only registered providers.
218
+ * Use this with Lixa.createConfig() for type safety.
219
+ *
220
+ * @deprecated This type is maintained for backward compatibility.
221
+ * The new inline provider configuration pattern makes this unnecessary.
222
+ *
223
+ * @public
224
+ */
225
+ export type SafeLixaConfig<TProviders extends Record<string, ProviderConfig>> = LixaConfig<TProviders> & {
226
+ providers: TProviders;
227
+ };
57
228
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC1C,gDAAgD;IAChD,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,mDAAmD;IACnD,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,aAAa,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAChD;AAED;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACtB,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,GAAG,EAAE,GAAG,CAAC;CACV"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACpG,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,cAAc,EAAE,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IAEjB,uDAAuD;IACvD,YAAY,EAAE,MAAM,CAAC;IAErB,oDAAoD;IACpD,WAAW,EAAE,MAAM,CAAC;IAEpB,uCAAuC;IACvC,MAAM,EAAE,MAAM,EAAE,CAAC;IAEjB,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC,GAAG,CACA;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,GACpB;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,CAC1B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AACH,oBAAY,sBAAsB;IAChC,sFAAsF;IACtF,2BAA2B,gCAAgC;IAE3D,kFAAkF;IAClF,QAAQ,aAAa;CACtB;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAC1B,sBAAsB,GACtB,6BAA6B,GAC7B,UAAU,GACV,aAAa,GACb,UAAU,CAAC;AAEf;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAE1B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU,CAAC,UAAU,SAAS,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC;IAC5G;;;OAGG;IACH,SAAS,EAAE,UAAU,CAAC;IAEtB;;OAEG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC;;;;;;;;;;OAUG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B;;;;;;;;;;OAUG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;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,82 @@
1
+ import type { OAuthTokenResponse, ProviderMetadata } from "../models/session";
2
+ /**
3
+ * User information extracted from OAuth provider
4
+ *
5
+ * @public
6
+ */
7
+ export interface UserInfo {
8
+ email: string;
9
+ id?: string | undefined;
10
+ sub?: string | undefined;
11
+ given_name?: string | undefined;
12
+ family_name?: string | undefined;
13
+ name?: string | undefined;
14
+ picture?: string | undefined;
15
+ email_verified?: boolean | undefined;
16
+ iss?: string | undefined;
17
+ }
18
+ /**
19
+ * Decode JWT ID token to extract user information
20
+ *
21
+ * @public
22
+ */
23
+ export declare function decodeIdToken(idToken: string): UserInfo;
24
+ /**
25
+ * Determine OAuth provider from ID token issuer
26
+ *
27
+ * @public
28
+ */
29
+ export declare function determineProviderFromIssuer(userInfo: UserInfo): string | null;
30
+ /**
31
+ * Fetch user info from OAuth provider's userinfo endpoint
32
+ *
33
+ * @param accessToken - OAuth access token
34
+ * @param userInfoEndpoint - The provider's userinfo endpoint URL
35
+ * @param providerName - Provider name for error messages (optional)
36
+ * @returns User information from the provider
37
+ *
38
+ * @throws Error if the request fails or response is invalid
39
+ *
40
+ * @public
41
+ */
42
+ export declare function fetchUserInfo(accessToken: string, userInfoEndpoint: string): Promise<UserInfo>;
43
+ /**
44
+ * Extract user info from OAuth token data
45
+ *
46
+ * @param tokenData - OAuth token response from provider
47
+ * @param providerMetadata - Provider metadata containing endpoints configuration
48
+ * @returns User info extracted from token or fetched from provider
49
+ *
50
+ * @remarks
51
+ * This function attempts to extract user information in the following order:
52
+ * 1. Decode ID token if present (preferred method for OIDC providers)
53
+ * 2. Fetch from userinfo endpoint using access token (uses providerMetadata.endpoints.userInfo)
54
+ *
55
+ * The function automatically determines the best method based on available token data.
56
+ * For OIDC providers (like Google), it decodes the JWT ID token.
57
+ * For OAuth-only providers (like GitHub), it fetches from the userinfo endpoint.
58
+ *
59
+ * @throws Error if no ID token or access token is available
60
+ * @throws Error if userinfo endpoint is required but not provided in providerMetadata
61
+ *
62
+ * @example
63
+ * With ID token (OIDC provider like Google):
64
+ * ```typescript
65
+ * const { userInfo } = await extractUserInfo(tokenData, providerMetadata);
66
+ * console.log(`User ${userInfo.email} authenticated`);
67
+ * ```
68
+ *
69
+ * @example
70
+ * Without ID token (OAuth provider like GitHub):
71
+ * ```typescript
72
+ * const { userInfo } = await extractUserInfo(tokenData, providerMetadata);
73
+ * // Automatically fetches from providerMetadata.endpoints.userInfo
74
+ * console.log(`User ${userInfo.email} authenticated`);
75
+ * ```
76
+ *
77
+ * @public
78
+ */
79
+ export declare function extractUserInfo(tokenData: OAuthTokenResponse, providerMetadata: ProviderMetadata): Promise<{
80
+ userInfo: UserInfo;
81
+ }>;
82
+ //# sourceMappingURL=user-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-info.d.ts","sourceRoot":"","sources":["../../src/utils/user-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE9E;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACrC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAiBvD;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAiB7E;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,QAAQ,CAAC,CA4BnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,kBAAkB,EAC7B,gBAAgB,EAAE,gBAAgB,GACjC,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC,CAejC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vunexa/lixa",
3
- "version": "0.0.1-alpha.8",
3
+ "version": "0.1.0",
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",
@@ -9,16 +9,19 @@
9
9
  "license": "MIT",
10
10
  "author": "vamsi",
11
11
  "type": "module",
12
- "main": "dist/index.js",
13
- "types": "index.d.ts",
12
+ "main": "./dist/index.cjs",
13
+ "module": "./dist/index.js",
14
+ "types": "./dist/export-types/index.d.ts",
14
15
  "exports": {
15
16
  ".": {
16
- "types": "./index.d.ts",
17
- "import": "./dist/index.js"
17
+ "types": "./dist/export-types/index.d.ts",
18
+ "import": "./dist/index.js",
19
+ "require": "./dist/index.cjs"
18
20
  }
19
21
  },
20
22
  "scripts": {
21
- "build": "tsc && npm run test && api-extractor run --local",
23
+ "build": "tsup && npm run test && npm run build:api-docs",
24
+ "build:api-docs": "tsc --emitDeclarationOnly && api-extractor run --local",
22
25
  "clean": "rm -rf dist",
23
26
  "prepublishOnly": "npm run clean && npm run build",
24
27
  "lint": "eslint src/**/*.ts",
@@ -28,13 +31,14 @@
28
31
  "test:coverage": "jest --coverage",
29
32
  "api-extractor": "api-extractor run --local --verbose",
30
33
  "docs:api": "npm run build && api-documenter markdown --input temp --output ./docs/api",
31
- "publish:alpha": "npm run build && npm version prerelease --preid=alpha && npm publish --tag alpha",
32
- "publish:beta": "npm run build && npm version prerelease --preid=beta && npm publish --tag beta",
33
- "publish:stable": "npm run build && npm version patch && npm publish --tag latest"
34
+ "pub:alpha": "npm version prerelease --preid=alpha && npm publish --tag alpha",
35
+ "pub:beta": "npm version prerelease --preid=beta && npm publish --tag beta",
36
+ "pub:patch": "npm version patch && npm publish --tag latest",
37
+ "pub:minor": "npm version minor && npm publish --tag latest",
38
+ "pub:major": "npm version major && npm publish --tag latest"
34
39
  },
35
40
  "files": [
36
41
  "dist",
37
- "index.d.ts",
38
42
  "README.md",
39
43
  "LICENSE"
40
44
  ],
@@ -50,6 +54,7 @@
50
54
  "globals": "^16.3.0",
51
55
  "jest": "^29.7.0",
52
56
  "ts-jest": "^29.1.2",
57
+ "tsup": "^8.5.0",
53
58
  "typescript": "^5.9.2"
54
59
  },
55
60
  "dependencies": {
@@ -1,18 +0,0 @@
1
- import NodeCache from 'node-cache';
2
- class LocalStateCache {
3
- cache;
4
- constructor(defaultTtlSeconds = 600) {
5
- this.cache = new NodeCache({ stdTTL: defaultTtlSeconds });
6
- }
7
- async saveState(state, data, expiresInSeconds) {
8
- this.cache.set(state, data, expiresInSeconds);
9
- }
10
- async getState(state) {
11
- return this.cache.get(state) || null;
12
- }
13
- async deleteState(state) {
14
- this.cache.del(state);
15
- }
16
- }
17
- export { LocalStateCache };
18
- //# sourceMappingURL=state-cache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"state-cache.js","sourceRoot":"","sources":["../../src/dao/state-cache.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAGnC,MAAM,eAAe;IACX,KAAK,CAAY;IAEzB,YAAY,oBAA4B,GAAG;QACzC,IAAI,CAAC,KAAK,GAAG,IAAI,SAAS,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,KAAa,EAAE,IAAS,EAAE,gBAAwB;QAChE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAa;QAC7B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;CACF;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
package/dist/dao/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/dao/types.ts"],"names":[],"mappings":""}