@vunexa/lixa 0.0.1-alpha.9 → 0.1.1

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 (84) hide show
  1. package/README.md +173 -143
  2. package/README.template.md +360 -0
  3. package/dist/dao/session-cache.d.ts +11 -0
  4. package/dist/dao/session-cache.d.ts.map +1 -0
  5. package/dist/dao/state-cache.d.ts +8 -6
  6. package/dist/dao/state-cache.d.ts.map +1 -1
  7. package/dist/dao/types.d.ts +376 -3
  8. package/dist/dao/types.d.ts.map +1 -1
  9. package/dist/export-types/index.d.ts +1397 -0
  10. package/dist/export-types/tsdoc-metadata.json +11 -0
  11. package/dist/index.cjs +1035 -0
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.d.cts +1361 -0
  14. package/dist/index.d.ts +11 -2
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +992 -9
  17. package/dist/index.js.map +1 -1
  18. package/dist/lixa.d.ts +280 -15
  19. package/dist/lixa.d.ts.map +1 -1
  20. package/dist/models/session.d.ts +316 -0
  21. package/dist/models/session.d.ts.map +1 -0
  22. package/dist/providers/IProvider.d.ts +127 -4
  23. package/dist/providers/IProvider.d.ts.map +1 -1
  24. package/dist/providers/index.d.ts +0 -2
  25. package/dist/providers/index.d.ts.map +1 -1
  26. package/dist/types.d.ts +195 -24
  27. package/dist/types.d.ts.map +1 -1
  28. package/dist/utils/user-info.d.ts +82 -0
  29. package/dist/utils/user-info.d.ts.map +1 -0
  30. package/docs/api/index.md +32 -0
  31. package/docs/api/lixa.iprovider.authorizationendpoint.md +13 -0
  32. package/docs/api/lixa.iprovider.md +100 -0
  33. package/docs/api/lixa.iprovider.tokenendpoint.md +13 -0
  34. package/docs/api/lixa.iprovider.userinfoendpoint.md +13 -0
  35. package/docs/api/lixa.lixa._constructor_.md +50 -0
  36. package/docs/api/lixa.lixa.generaterandomstate.md +23 -0
  37. package/docs/api/lixa.lixa.getauthurl.md +85 -0
  38. package/docs/api/lixa.lixa.handlecallback.md +73 -0
  39. package/docs/api/lixa.lixa.isproviderregistered.md +65 -0
  40. package/docs/api/lixa.lixa.md +164 -0
  41. package/docs/api/lixa.lixa.registerprovider.md +69 -0
  42. package/docs/api/lixa.lixaconfig.md +96 -0
  43. package/docs/api/lixa.lixaconfig.providers.md +13 -0
  44. package/docs/api/lixa.lixaconfig.sessionstrategy.md +13 -0
  45. package/docs/api/lixa.lixaconfig.statedao.md +13 -0
  46. package/docs/api/lixa.md +108 -0
  47. package/docs/api/lixa.providerconfig.clientid.md +13 -0
  48. package/docs/api/lixa.providerconfig.clientsecret.md +13 -0
  49. package/docs/api/lixa.providerconfig.extraconfig.md +13 -0
  50. package/docs/api/lixa.providerconfig.md +134 -0
  51. package/docs/api/lixa.providerconfig.redirecturi.md +13 -0
  52. package/docs/api/lixa.providerconfig.scopes.md +13 -0
  53. package/docs/api/lixa.session.md +77 -0
  54. package/docs/api/lixa.session.raw.md +13 -0
  55. package/docs/api/lixa.session.token.md +13 -0
  56. package/docs/api/lixa.sessionstrategy.createsession.md +56 -0
  57. package/docs/api/lixa.sessionstrategy.md +40 -0
  58. package/docs/images/account-linking.svg +1 -0
  59. package/docs/images/architecture.svg +1 -0
  60. package/docs/images/resource-connection.svg +1 -0
  61. package/package.json +18 -10
  62. package/dist/dao/state-cache.js +0 -18
  63. package/dist/dao/state-cache.js.map +0 -1
  64. package/dist/dao/types.js +0 -2
  65. package/dist/dao/types.js.map +0 -1
  66. package/dist/lixa.js +0 -244
  67. package/dist/lixa.js.map +0 -1
  68. package/dist/providers/IProvider.js +0 -2
  69. package/dist/providers/IProvider.js.map +0 -1
  70. package/dist/providers/github.d.ts +0 -9
  71. package/dist/providers/github.d.ts.map +0 -1
  72. package/dist/providers/github.js +0 -8
  73. package/dist/providers/github.js.map +0 -1
  74. package/dist/providers/google.d.ts +0 -9
  75. package/dist/providers/google.d.ts.map +0 -1
  76. package/dist/providers/google.js +0 -8
  77. package/dist/providers/google.js.map +0 -1
  78. package/dist/providers/index.js +0 -3
  79. package/dist/providers/index.js.map +0 -1
  80. package/dist/types.js +0 -2
  81. package/dist/types.js.map +0 -1
  82. package/dist/utils/constants.js +0 -4
  83. package/dist/utils/constants.js.map +0 -1
  84. package/index.d.ts +0 -229
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"}
@@ -0,0 +1,32 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md)
4
+
5
+ ## API Reference
6
+
7
+ ## Packages
8
+
9
+ <table><thead><tr><th>
10
+
11
+ Package
12
+
13
+
14
+ </th><th>
15
+
16
+ Description
17
+
18
+
19
+ </th></tr></thead>
20
+ <tbody><tr><td>
21
+
22
+ [@vunexa/lixa](./lixa.md)
23
+
24
+
25
+ </td><td>
26
+
27
+ A flexible, provider-agnostic OAuth 2.0 and OpenID Connect (OIDC) client library for backend applications.
28
+
29
+
30
+ </td></tr>
31
+ </tbody></table>
32
+
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@vunexa/lixa](./lixa.md) &gt; [IProvider](./lixa.iprovider.md) &gt; [authorizationEndpoint](./lixa.iprovider.authorizationendpoint.md)
4
+
5
+ ## IProvider.authorizationEndpoint property
6
+
7
+ The OAuth authorization endpoint URL
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ authorizationEndpoint: string;
13
+ ```
@@ -0,0 +1,100 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@vunexa/lixa](./lixa.md) &gt; [IProvider](./lixa.iprovider.md)
4
+
5
+ ## IProvider interface
6
+
7
+ Interface for OAuth provider implementations.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ interface IProvider
13
+ ```
14
+
15
+ ## Remarks
16
+
17
+ Implement this interface to add support for custom OAuth providers.
18
+
19
+ ## Properties
20
+
21
+ <table><thead><tr><th>
22
+
23
+ Property
24
+
25
+
26
+ </th><th>
27
+
28
+ Modifiers
29
+
30
+
31
+ </th><th>
32
+
33
+ Type
34
+
35
+
36
+ </th><th>
37
+
38
+ Description
39
+
40
+
41
+ </th></tr></thead>
42
+ <tbody><tr><td>
43
+
44
+ [authorizationEndpoint](./lixa.iprovider.authorizationendpoint.md)
45
+
46
+
47
+ </td><td>
48
+
49
+
50
+ </td><td>
51
+
52
+ string
53
+
54
+
55
+ </td><td>
56
+
57
+ The OAuth authorization endpoint URL
58
+
59
+
60
+ </td></tr>
61
+ <tr><td>
62
+
63
+ [tokenEndpoint](./lixa.iprovider.tokenendpoint.md)
64
+
65
+
66
+ </td><td>
67
+
68
+
69
+ </td><td>
70
+
71
+ string
72
+
73
+
74
+ </td><td>
75
+
76
+ The OAuth token exchange endpoint URL
77
+
78
+
79
+ </td></tr>
80
+ <tr><td>
81
+
82
+ [userInfoEndpoint](./lixa.iprovider.userinfoendpoint.md)
83
+
84
+
85
+ </td><td>
86
+
87
+
88
+ </td><td>
89
+
90
+ string
91
+
92
+
93
+ </td><td>
94
+
95
+ The user information endpoint URL
96
+
97
+
98
+ </td></tr>
99
+ </tbody></table>
100
+
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@vunexa/lixa](./lixa.md) &gt; [IProvider](./lixa.iprovider.md) &gt; [tokenEndpoint](./lixa.iprovider.tokenendpoint.md)
4
+
5
+ ## IProvider.tokenEndpoint property
6
+
7
+ The OAuth token exchange endpoint URL
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ tokenEndpoint: string;
13
+ ```
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@vunexa/lixa](./lixa.md) &gt; [IProvider](./lixa.iprovider.md) &gt; [userInfoEndpoint](./lixa.iprovider.userinfoendpoint.md)
4
+
5
+ ## IProvider.userInfoEndpoint property
6
+
7
+ The user information endpoint URL
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ userInfoEndpoint: string;
13
+ ```
@@ -0,0 +1,50 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@vunexa/lixa](./lixa.md) &gt; [Lixa](./lixa.lixa.md) &gt; [(constructor)](./lixa.lixa._constructor_.md)
4
+
5
+ ## Lixa.(constructor)
6
+
7
+ Creates a new Lixa instance with the provided configuration.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ constructor(config: LixaConfig);
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Parameter
20
+
21
+
22
+ </th><th>
23
+
24
+ Type
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ config
36
+
37
+
38
+ </td><td>
39
+
40
+ [LixaConfig](./lixa.lixaconfig.md)
41
+
42
+
43
+ </td><td>
44
+
45
+ The configuration object containing provider settings and optional session strategy
46
+
47
+
48
+ </td></tr>
49
+ </tbody></table>
50
+
@@ -0,0 +1,23 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@vunexa/lixa](./lixa.md) &gt; [Lixa](./lixa.lixa.md) &gt; [generateRandomState](./lixa.lixa.generaterandomstate.md)
4
+
5
+ ## Lixa.generateRandomState() method
6
+
7
+ Generates a cryptographically secure random state parameter for OAuth flows.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ static generateRandomState(): string;
13
+ ```
14
+ **Returns:**
15
+
16
+ string
17
+
18
+ A 32-character hexadecimal string
19
+
20
+ ## Remarks
21
+
22
+ The state parameter is used to prevent CSRF attacks in OAuth flows.
23
+
@@ -0,0 +1,85 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@vunexa/lixa](./lixa.md) &gt; [Lixa](./lixa.lixa.md) &gt; [getAuthUrl](./lixa.lixa.getauthurl.md)
4
+
5
+ ## Lixa.getAuthUrl() method
6
+
7
+ Generates the authorization URL for the specified provider.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ getAuthUrl(provider: string, state: string): string;
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Parameter
20
+
21
+
22
+ </th><th>
23
+
24
+ Type
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ provider
36
+
37
+
38
+ </td><td>
39
+
40
+ string
41
+
42
+
43
+ </td><td>
44
+
45
+ The provider name (case-insensitive)
46
+
47
+
48
+ </td></tr>
49
+ <tr><td>
50
+
51
+ state
52
+
53
+
54
+ </td><td>
55
+
56
+ string
57
+
58
+
59
+ </td><td>
60
+
61
+ The state parameter for CSRF protection
62
+
63
+
64
+ </td></tr>
65
+ </tbody></table>
66
+
67
+ **Returns:**
68
+
69
+ string
70
+
71
+ The complete authorization URL to redirect users to
72
+
73
+ ## Exceptions
74
+
75
+ Error when the provider is not configured
76
+
77
+ ## Example
78
+
79
+
80
+ ```typescript
81
+ const state = Lixa.generateRandomState();
82
+ const authUrl = lixa.getAuthUrl('google', state);
83
+ res.redirect(authUrl);
84
+ ```
85
+