@vunexa/lixa 0.0.1-alpha.16 → 0.0.1-alpha.18

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 (46) hide show
  1. package/dist/IProvider-2tDwRAnH.d.cts +18 -0
  2. package/dist/IProvider-2tDwRAnH.d.ts +18 -0
  3. package/dist/index.cjs +357 -15
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +261 -0
  6. package/dist/index.js +319 -10
  7. package/dist/index.js.map +1 -1
  8. package/dist/providers-entry.cjs +47 -26
  9. package/dist/providers-entry.cjs.map +1 -0
  10. package/dist/providers-entry.d.cts +25 -0
  11. package/dist/providers-entry.js +19 -21
  12. package/dist/providers-entry.js.map +1 -1
  13. package/package.json +20 -10
  14. package/dist/dao/session-cache.cjs +0 -24
  15. package/dist/dao/session-cache.js +0 -18
  16. package/dist/dao/session-cache.js.map +0 -1
  17. package/dist/dao/state-cache.cjs +0 -24
  18. package/dist/dao/state-cache.js +0 -18
  19. package/dist/dao/state-cache.js.map +0 -1
  20. package/dist/dao/types.cjs +0 -3
  21. package/dist/dao/types.js +0 -2
  22. package/dist/dao/types.js.map +0 -1
  23. package/dist/lixa.cjs +0 -295
  24. package/dist/lixa.js +0 -289
  25. package/dist/lixa.js.map +0 -1
  26. package/dist/models/session.cjs +0 -34
  27. package/dist/models/session.js +0 -30
  28. package/dist/models/session.js.map +0 -1
  29. package/dist/providers/IProvider.cjs +0 -3
  30. package/dist/providers/IProvider.js +0 -2
  31. package/dist/providers/IProvider.js.map +0 -1
  32. package/dist/providers/github.cjs +0 -15
  33. package/dist/providers/github.js +0 -12
  34. package/dist/providers/github.js.map +0 -1
  35. package/dist/providers/google.cjs +0 -15
  36. package/dist/providers/google.js +0 -12
  37. package/dist/providers/google.js.map +0 -1
  38. package/dist/providers/index.cjs +0 -8
  39. package/dist/providers/index.js +0 -3
  40. package/dist/providers/index.js.map +0 -1
  41. package/dist/types.cjs +0 -3
  42. package/dist/types.js +0 -2
  43. package/dist/types.js.map +0 -1
  44. package/dist/utils/constants.cjs +0 -8
  45. package/dist/utils/constants.js +0 -4
  46. package/dist/utils/constants.js.map +0 -1
package/dist/lixa.js DELETED
@@ -1,289 +0,0 @@
1
- import { randomBytes } from "crypto";
2
- import { LocalStateCache } from "./dao/state-cache";
3
- import crypto from "crypto";
4
- import { LocalSessionCache } from "./dao/session-cache";
5
- import { DefaultSessionStrategy } from "./models/session";
6
- /**
7
- * A flexible, provider-agnostic OAuth 2.0 and OpenID Connect (OIDC) client library.
8
- *
9
- * @remarks
10
- * Lixa simplifies multi-provider authentication flows and supports extensible session management.
11
- *
12
- * @example
13
- * ```typescript
14
- * import { Lixa } from '@vunexa/lixa';
15
- * import { GoogleProvider } from '@vunexa/lixa/providers';
16
- *
17
- * // Register providers before using them
18
- * Lixa.registerProvider({ google: new GoogleProvider() });
19
- *
20
- * const config = Lixa.createConfig({
21
- * providers: {
22
- * google: {
23
- * clientId: 'your-client-id',
24
- * clientSecret: 'your-client-secret',
25
- * redirectUri: 'https://yourapp.com/auth/google/callback',
26
- * scopes: ['openid', 'email', 'profile']
27
- * }
28
- * }
29
- * });
30
- *
31
- * const lixa = new Lixa(config);
32
- * ```
33
- *
34
- * @public
35
- */
36
- class Lixa {
37
- static CONFIGURED_PROVIDERS = new Map();
38
- static LOCAL_STATE_CACHE = new LocalStateCache();
39
- static LOCAL_SESSION_CACHE = new LocalSessionCache();
40
- static DEFAULT_SESSION_STRATEGY = new DefaultSessionStrategy();
41
- config;
42
- stateDao;
43
- sesionDao;
44
- sessionStrategy;
45
- /**
46
- * Creates a new Lixa instance with the provided configuration.
47
- *
48
- * @param config - The configuration object containing provider settings and optional session strategy
49
- */
50
- constructor(config) {
51
- // Validate that all providers in config are registered
52
- const configuredProviders = Object.keys(config.providers);
53
- const registeredProviders = Lixa.getRegisteredProviders();
54
- for (const provider of configuredProviders) {
55
- if (!registeredProviders.includes(provider.toLowerCase())) {
56
- throw new Error(`Provider '${provider}' is not registered. Please register it first using Lixa.registerProvider()`);
57
- }
58
- }
59
- this.config = config;
60
- this.stateDao = config.stateDao || Lixa.LOCAL_STATE_CACHE;
61
- this.sesionDao = config.sessionDao || Lixa.LOCAL_SESSION_CACHE;
62
- this.sessionStrategy = config.sessionStrategy || Lixa.DEFAULT_SESSION_STRATEGY;
63
- }
64
- /**
65
- * Checks if a provider is both registered and configured for this instance.
66
- * This is a type guard that narrows the provider type for use with getAuthUrl.
67
- *
68
- * @param provider - The provider name to check (case-insensitive)
69
- * @returns True if the provider is registered and configured, false otherwise
70
- *
71
- * @example
72
- * ```typescript
73
- * if (lixa.isProviderConfigured(provider)) {
74
- * // TypeScript now knows provider is a valid ConfiguredProviderKey
75
- * const authUrl = lixa.getAuthUrl(provider, state);
76
- * }
77
- * ```
78
- */
79
- isProviderConfigured(provider) {
80
- const providerType = provider.toLowerCase();
81
- return Lixa.CONFIGURED_PROVIDERS.has(providerType) &&
82
- this.config.providers.hasOwnProperty(providerType);
83
- }
84
- /**
85
- * Registers custom OAuth providers for use with Lixa.
86
- *
87
- * @param providerMap - A map of provider names to IProvider implementations
88
- *
89
- * @example
90
- * ```typescript
91
- * class CustomProvider implements IProvider {
92
- * authorizationEndpoint = 'https://custom.com/oauth/authorize';
93
- * tokenEndpoint = 'https://custom.com/oauth/token';
94
- * userInfoEndpoint = 'https://custom.com/api/user';
95
- * }
96
- *
97
- * Lixa.registerProvider({ custom: new CustomProvider() });
98
- * ```
99
- */
100
- static registerProvider(providerMap) {
101
- Object.entries(providerMap).forEach(([key, providerImpl]) => {
102
- Lixa.CONFIGURED_PROVIDERS.set(key.toLowerCase(), providerImpl);
103
- });
104
- }
105
- /**
106
- * Gets the list of registered provider names.
107
- *
108
- * @returns Array of registered provider names
109
- */
110
- static getRegisteredProviders() {
111
- return Array.from(Lixa.CONFIGURED_PROVIDERS.keys());
112
- }
113
- /**
114
- * Creates a type-safe configuration that only allows registered providers.
115
- *
116
- * @param config - Configuration object with providers that must be registered
117
- * @returns The same configuration object, but with type safety for registered providers
118
- */
119
- static createConfig(config) {
120
- // Validate that all providers in config are registered
121
- const configuredProviders = Object.keys(config.providers);
122
- const registeredProviders = Lixa.getRegisteredProviders();
123
- for (const provider of configuredProviders) {
124
- if (!registeredProviders.includes(provider.toLowerCase())) {
125
- throw new Error(`Provider '${provider}' is not registered. Please register it first using Lixa.registerProvider()`);
126
- }
127
- }
128
- return config;
129
- }
130
- /**
131
- * Generates a cryptographically secure random state parameter for OAuth flows.
132
- *
133
- * @returns A 32-character hexadecimal string
134
- *
135
- * @remarks
136
- * The state parameter is used to prevent CSRF attacks in OAuth flows.
137
- */
138
- static generateRandomState() {
139
- return randomBytes(16).toString("hex");
140
- }
141
- /**
142
- * Generates a cryptographically secure code verifier for PKCE flows.
143
- *
144
- * @returns A 64-character hexadecimal string
145
- *
146
- * @remarks
147
- * The code verifier is used in PKCE (Proof Key for Code Exchange) to enhance security.
148
- */
149
- static generateCodeVerifier() {
150
- return randomBytes(32).toString("hex");
151
- }
152
- static buildCodeChallenge(codeVerifier) {
153
- const hash = crypto
154
- .createHash("sha256")
155
- .update(codeVerifier)
156
- .digest("base64");
157
- // Convert to base64url
158
- return hash.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
159
- }
160
- /**
161
- * Generates the authorization URL for the specified provider.
162
- *
163
- * @param provider - The provider name (must be a configured provider key)
164
- * @param state - The state parameter for CSRF protection
165
- * @returns The complete authorization URL to redirect users to
166
- *
167
- * @throws Error when the provider is not configured
168
- *
169
- * @example
170
- * ```typescript
171
- * const state = Lixa.generateRandomState();
172
- * const authUrl = lixa.getAuthUrl('google', state);
173
- * res.redirect(authUrl);
174
- * ```
175
- */
176
- getAuthUrl(provider, state) {
177
- const providerType = String(provider).toLowerCase();
178
- const providerConfig = this.findProviderByType(providerType);
179
- const providerImpl = Lixa.CONFIGURED_PROVIDERS.get(providerType);
180
- if (!providerConfig || !providerImpl) {
181
- throw new Error(`Provider ${providerType} not configured`);
182
- }
183
- const codeVerifier = Lixa.generateCodeVerifier();
184
- const codeChallenge = Lixa.buildCodeChallenge(codeVerifier);
185
- // Cache the state paramaeter with TTL of 5 minutes (300 seconds)
186
- // We dont care about value. we are onl interested in key existence
187
- this.stateDao.saveState(state, {
188
- createdAt: Date.now(),
189
- provider: providerType,
190
- codeVerifier,
191
- }, 300 // 5 minutes in seconds
192
- );
193
- const params = new URLSearchParams({
194
- client_id: providerConfig.clientId,
195
- redirect_uri: providerConfig.redirectUri,
196
- scope: providerConfig.scopes.join(" "),
197
- state,
198
- response_type: "code",
199
- code_challenge: codeChallenge,
200
- code_challenge_method: "S256",
201
- ...providerConfig.extraConfig,
202
- });
203
- return `${providerImpl.authorizationEndpoint}?${params.toString()}`;
204
- }
205
- /**
206
- * Handles the OAuth callback and creates a user session.
207
- *
208
- * @param provider - The provider name (must be a configured provider key)
209
- * @param code - The authorization code from the provider
210
- * @param state - The state parameter for validation
211
- * @returns A Promise that resolves to the session ID
212
- *
213
- * @throws Error when code or state is missing/invalid, or provider is not configured
214
- *
215
- * @example
216
- * ```typescript
217
- * const sessionId = await lixa.handleCallback({
218
- * provider: 'google',
219
- * code: req.query.code,
220
- * state: req.query.state
221
- * });
222
- * ```
223
- */
224
- async handleCallback({ provider, code, state, }) {
225
- if (!code || code.trim() === "") {
226
- throw new Error("Invalid or missing code in callback");
227
- }
228
- if (!state || state.trim() === "") {
229
- throw new Error("Invalid or missing state in callback");
230
- }
231
- //Validate state here
232
- const cachedState = await this.stateDao.getState(state);
233
- if (!cachedState) {
234
- throw new Error("Invalid or expired state");
235
- }
236
- // State is valid, remove it from cache to prevent reuse
237
- await this.stateDao.deleteState(state);
238
- //Get code verifier from cached state
239
- const codeVerifier = cachedState.codeVerifier;
240
- const providerType = String(provider).toLowerCase();
241
- const providerConfig = this.findProviderByType(providerType);
242
- const providerImpl = Lixa.CONFIGURED_PROVIDERS.get(providerType);
243
- if (!providerConfig || !providerImpl) {
244
- throw new Error(`Provider ${String(provider)} not configured`);
245
- }
246
- // Exchange code for tokens and fetch user info here.
247
- const tokens = await this.exchangeCodeForToken(code, providerConfig, providerImpl, codeVerifier);
248
- const session = await this.sessionStrategy.createSession(tokens);
249
- // Generate unique session ID
250
- const sessionId = randomBytes(32).toString("hex");
251
- // Store session with 24 hour TTL (86400 seconds)
252
- await this.sesionDao.saveSession(sessionId, session, 86400);
253
- return sessionId;
254
- }
255
- fetchSessionInfo(sessionId) {
256
- return this.sesionDao.getSession(sessionId);
257
- }
258
- async exchangeCodeForToken(code, providerConfig, providerImpl, codeVerifier) {
259
- // Build the request body
260
- const body = {
261
- client_id: providerConfig.clientId,
262
- client_secret: providerConfig.clientSecret,
263
- code,
264
- redirect_uri: providerConfig.redirectUri,
265
- grant_type: "authorization_code",
266
- };
267
- if (codeVerifier) {
268
- body.code_verifier = codeVerifier;
269
- }
270
- const params = new URLSearchParams(body);
271
- const response = await fetch(providerImpl.tokenEndpoint, {
272
- method: "POST",
273
- headers: {
274
- "Content-Type": "application/x-www-form-urlencoded",
275
- Accept: "application/json",
276
- },
277
- body: params.toString(),
278
- });
279
- if (!response.ok) {
280
- throw new Error(`Token exchange failed: ${response.status} ${response.statusText}`);
281
- }
282
- return response.json();
283
- }
284
- findProviderByType(providerType) {
285
- return this.config.providers[providerType];
286
- }
287
- }
288
- export { Lixa };
289
- //# sourceMappingURL=lixa.js.map
package/dist/lixa.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"lixa.js","sourceRoot":"","sources":["../src/lixa.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGrC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAsC,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAY9F;;;;;;;;;;;;;;;;;;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ACvD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,mCAAmC;gBACnD,MAAM,EAAE,kBAAkB;aAC3B;YACD,IAAI,EAAE,MAAM,CAAC,QAAQ,EAAE;SACxB,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,0BAA0B,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CACnE,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IAEO,kBAAkB,CAAC,YAAoB;QAC7C,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IAC7C,CAAC;;AAGH,OAAO,EAAE,IAAI,EAAE,CAAC"}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultSessionStrategy = void 0;
4
- /**
5
- * Default session strategy that works with any OAuth provider.
6
- * Extracts common token information and creates a standardized session.
7
- *
8
- * @public
9
- */
10
- class DefaultSessionStrategy {
11
- /**
12
- * Creates a session from OAuth token data.
13
- * Handles common OAuth token formats and extracts the access token.
14
- *
15
- * @param tokenData - The token data received from the OAuth provider
16
- * @returns A Promise that resolves to a Session object
17
- */
18
- async createSession(tokenData) {
19
- // Extract access token from various possible formats
20
- const accessToken = tokenData.access_token ||
21
- tokenData.accessToken ||
22
- tokenData.token ||
23
- tokenData;
24
- if (!accessToken || typeof accessToken !== 'string') {
25
- throw new Error('No valid access token found in OAuth response');
26
- }
27
- return {
28
- token: accessToken,
29
- raw: tokenData,
30
- };
31
- }
32
- }
33
- exports.DefaultSessionStrategy = DefaultSessionStrategy;
34
- //# sourceMappingURL=session.js.map
@@ -1,30 +0,0 @@
1
- /**
2
- * Default session strategy that works with any OAuth provider.
3
- * Extracts common token information and creates a standardized session.
4
- *
5
- * @public
6
- */
7
- export class DefaultSessionStrategy {
8
- /**
9
- * Creates a session from OAuth token data.
10
- * Handles common OAuth token formats and extracts the access token.
11
- *
12
- * @param tokenData - The token data received from the OAuth provider
13
- * @returns A Promise that resolves to a Session object
14
- */
15
- async createSession(tokenData) {
16
- // Extract access token from various possible formats
17
- const accessToken = tokenData.access_token ||
18
- tokenData.accessToken ||
19
- tokenData.token ||
20
- tokenData;
21
- if (!accessToken || typeof accessToken !== 'string') {
22
- throw new Error('No valid access token found in OAuth response');
23
- }
24
- return {
25
- token: accessToken,
26
- raw: tokenData,
27
- };
28
- }
29
- }
30
- //# sourceMappingURL=session.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/models/session.ts"],"names":[],"mappings":"AA2BA;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IACjC;;;;;;OAMG;IACH,KAAK,CAAC,aAAa,CAAC,SAAc;QAChC,qDAAqD;QACrD,MAAM,WAAW,GAAG,SAAS,CAAC,YAAY;YACvB,SAAS,CAAC,WAAW;YACrB,SAAS,CAAC,KAAK;YACf,SAAS,CAAC;QAE7B,IAAI,CAAC,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACpD,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACnE,CAAC;QAED,OAAO;YACL,KAAK,EAAE,WAAW;YAClB,GAAG,EAAE,SAAS;SACf,CAAC;IACJ,CAAC;CACF"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=IProvider.js.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=IProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IProvider.js","sourceRoot":"","sources":["../../src/providers/IProvider.ts"],"names":[],"mappings":""}
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GithubProvider = void 0;
4
- /**
5
- * GitHub OAuth provider implementation
6
- * @public
7
- */
8
- class GithubProvider {
9
- providerType = "GITHUB";
10
- authorizationEndpoint = "https://github.com/login/oauth/authorize";
11
- tokenEndpoint = "https://github.com/login/oauth/access_token";
12
- userInfoEndpoint = "https://api.github.com/user";
13
- }
14
- exports.GithubProvider = GithubProvider;
15
- //# sourceMappingURL=github.js.map
@@ -1,12 +0,0 @@
1
- /**
2
- * GitHub OAuth provider implementation
3
- * @public
4
- */
5
- class GithubProvider {
6
- providerType = "GITHUB";
7
- authorizationEndpoint = "https://github.com/login/oauth/authorize";
8
- tokenEndpoint = "https://github.com/login/oauth/access_token";
9
- userInfoEndpoint = "https://api.github.com/user";
10
- }
11
- export { GithubProvider };
12
- //# sourceMappingURL=github.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"github.js","sourceRoot":"","sources":["../../src/providers/github.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,cAAc;IAClB,YAAY,GAAG,QAAQ,CAAC;IACxB,qBAAqB,GAAG,0CAA0C,CAAC;IACnE,aAAa,GAAG,6CAA6C,CAAC;IAC9D,gBAAgB,GAAG,6BAA6B,CAAC;CAClD;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GoogleProvider = void 0;
4
- /**
5
- * Google OAuth provider implementation
6
- * @public
7
- */
8
- class GoogleProvider {
9
- providerType = "GOOGLE";
10
- authorizationEndpoint = "https://accounts.google.com/o/oauth2/v2/auth";
11
- tokenEndpoint = "https://oauth2.googleapis.com/token";
12
- userInfoEndpoint = "https://www.googleapis.com/oauth2/v2/userinfo";
13
- }
14
- exports.GoogleProvider = GoogleProvider;
15
- //# sourceMappingURL=google.js.map
@@ -1,12 +0,0 @@
1
- /**
2
- * Google OAuth provider implementation
3
- * @public
4
- */
5
- class GoogleProvider {
6
- providerType = "GOOGLE";
7
- authorizationEndpoint = "https://accounts.google.com/o/oauth2/v2/auth";
8
- tokenEndpoint = "https://oauth2.googleapis.com/token";
9
- userInfoEndpoint = "https://www.googleapis.com/oauth2/v2/userinfo";
10
- }
11
- export { GoogleProvider };
12
- //# sourceMappingURL=google.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"google.js","sourceRoot":"","sources":["../../src/providers/google.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,cAAc;IAClB,YAAY,GAAG,QAAQ,CAAC;IACxB,qBAAqB,GAAG,8CAA8C,CAAC;IACvE,aAAa,GAAG,qCAAqC,CAAC;IACtD,gBAAgB,GAAG,+CAA+C,CAAC;CACpE;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GoogleProvider = exports.GithubProvider = void 0;
4
- var github_1 = require("./github.cjs");
5
- Object.defineProperty(exports, "GithubProvider", { enumerable: true, get: function () { return github_1.GithubProvider; } });
6
- var google_1 = require("./google.cjs");
7
- Object.defineProperty(exports, "GoogleProvider", { enumerable: true, get: function () { return google_1.GoogleProvider; } });
8
- //# sourceMappingURL=index.js.map
@@ -1,3 +0,0 @@
1
- export { GithubProvider } from "./github";
2
- export { GoogleProvider } from "./google";
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC"}
package/dist/types.cjs DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GITHUB = exports.GOOGLE = void 0;
4
- const GOOGLE = "google";
5
- exports.GOOGLE = GOOGLE;
6
- const GITHUB = "github";
7
- exports.GITHUB = GITHUB;
8
- //# sourceMappingURL=constants.js.map
@@ -1,4 +0,0 @@
1
- const GOOGLE = "google";
2
- const GITHUB = "github";
3
- export { GOOGLE, GITHUB };
4
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG,QAAQ,CAAC;AACxB,MAAM,MAAM,GAAG,QAAQ,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC"}