@vunexa/lixa 0.0.1-alpha.3 → 0.0.1-alpha.33
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 +1081 -76
- package/dist/dao/session-cache.d.ts +10 -0
- package/dist/dao/session-cache.d.ts.map +1 -0
- package/dist/dao/state-cache.d.ts +12 -0
- package/dist/dao/state-cache.d.ts.map +1 -0
- package/dist/dao/types.d.ts +370 -0
- package/dist/dao/types.d.ts.map +1 -0
- package/dist/export-types/index.d.ts +1220 -0
- package/dist/export-types/tsdoc-metadata.json +11 -0
- package/dist/index.cjs +723 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1189 -0
- package/dist/index.d.ts +19 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +681 -1
- package/dist/index.js.map +1 -1
- package/dist/lixa.d.ts +322 -11
- package/dist/lixa.d.ts.map +1 -1
- package/dist/models/session.d.ts +273 -0
- package/dist/models/session.d.ts.map +1 -0
- package/dist/providers/IProvider.d.ts +128 -0
- package/dist/providers/IProvider.d.ts.map +1 -1
- package/dist/providers/index.d.ts +0 -2
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/types.d.ts +167 -16
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/user-info.d.ts +82 -0
- package/dist/utils/user-info.d.ts.map +1 -0
- package/package.json +20 -10
- package/dist/lixa.js +0 -107
- package/dist/lixa.js.map +0 -1
- package/dist/providers/IProvider.js +0 -3
- package/dist/providers/IProvider.js.map +0 -1
- package/dist/providers/github.d.ts +0 -9
- package/dist/providers/github.d.ts.map +0 -1
- package/dist/providers/github.js +0 -8
- package/dist/providers/github.js.map +0 -1
- package/dist/providers/google.d.ts +0 -9
- package/dist/providers/google.d.ts.map +0 -1
- package/dist/providers/google.js +0 -8
- package/dist/providers/google.js.map +0 -1
- package/dist/providers/index.js +0 -3
- package/dist/providers/index.js.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils/constants.js +0 -4
- package/dist/utils/constants.js.map +0 -1
- package/index.d.ts +0 -63
|
@@ -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":"A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th 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.
|
|
13
|
-
"
|
|
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": "
|
|
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",
|
|
@@ -27,13 +30,15 @@
|
|
|
27
30
|
"test:watch": "jest --watch",
|
|
28
31
|
"test:coverage": "jest --coverage",
|
|
29
32
|
"api-extractor": "api-extractor run --local --verbose",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
+
"docs:api": "npm run build && api-documenter markdown --input temp --output ./docs/api",
|
|
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"
|
|
33
39
|
},
|
|
34
40
|
"files": [
|
|
35
41
|
"dist",
|
|
36
|
-
"index.d.ts",
|
|
37
42
|
"README.md",
|
|
38
43
|
"LICENSE"
|
|
39
44
|
],
|
|
@@ -42,12 +47,17 @@
|
|
|
42
47
|
"@microsoft/api-extractor": "^7.52.11",
|
|
43
48
|
"@types/jest": "^29.5.12",
|
|
44
49
|
"@types/node": "^24.3.1",
|
|
50
|
+
"@types/node-cache": "^4.1.3",
|
|
45
51
|
"@typescript-eslint/eslint-plugin": "^8.42.0",
|
|
46
52
|
"@typescript-eslint/parser": "^8.42.0",
|
|
47
53
|
"eslint": "^9.35.0",
|
|
48
54
|
"globals": "^16.3.0",
|
|
49
55
|
"jest": "^29.7.0",
|
|
50
56
|
"ts-jest": "^29.1.2",
|
|
57
|
+
"tsup": "^8.5.0",
|
|
51
58
|
"typescript": "^5.9.2"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {
|
|
61
|
+
"node-cache": "^5.1.2"
|
|
52
62
|
}
|
|
53
63
|
}
|
package/dist/lixa.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from "crypto";
|
|
2
|
-
import { GithubProvider, GoogleProvider } from "./providers";
|
|
3
|
-
import { GITHUB, GOOGLE } from "./utils/constants";
|
|
4
|
-
/**
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
class Lixa {
|
|
8
|
-
static CONFIGURED_PROVIDERS = new Map();
|
|
9
|
-
config;
|
|
10
|
-
constructor(config) {
|
|
11
|
-
this.config = config;
|
|
12
|
-
if (!Lixa.CONFIGURED_PROVIDERS.has(GITHUB)) {
|
|
13
|
-
Lixa.CONFIGURED_PROVIDERS.set(GITHUB, new GithubProvider());
|
|
14
|
-
}
|
|
15
|
-
if (!Lixa.CONFIGURED_PROVIDERS.has(GOOGLE)) {
|
|
16
|
-
Lixa.CONFIGURED_PROVIDERS.set(GOOGLE, new GoogleProvider());
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
static isProviderRegistered(provider) {
|
|
20
|
-
return Lixa.CONFIGURED_PROVIDERS.has(provider.toLowerCase());
|
|
21
|
-
}
|
|
22
|
-
static registerProvider(providerMap) {
|
|
23
|
-
// This is a static method, so we can't access instance properties.
|
|
24
|
-
// Instead, we can modify the prototype to add the new provider.
|
|
25
|
-
Object.entries(providerMap).forEach(([key, providerImpl]) => {
|
|
26
|
-
Lixa.CONFIGURED_PROVIDERS.set(key, providerImpl);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
generateRandomState() {
|
|
30
|
-
return randomBytes(16).toString("hex");
|
|
31
|
-
}
|
|
32
|
-
getAuthUrl(provider, state) {
|
|
33
|
-
const providerType = provider.toLowerCase();
|
|
34
|
-
const providerConfig = this.findProviderByType(providerType);
|
|
35
|
-
const providerImpl = Lixa.CONFIGURED_PROVIDERS.get(providerType);
|
|
36
|
-
if (!providerConfig || !providerImpl) {
|
|
37
|
-
throw new Error(`Provider ${providerType} not configured`);
|
|
38
|
-
}
|
|
39
|
-
const params = new URLSearchParams({
|
|
40
|
-
client_id: providerConfig.clientId,
|
|
41
|
-
redirect_uri: providerConfig.redirectUri,
|
|
42
|
-
scope: providerConfig.scopes.join(" "),
|
|
43
|
-
state,
|
|
44
|
-
response_type: "code",
|
|
45
|
-
...providerConfig.extraConfig,
|
|
46
|
-
});
|
|
47
|
-
return `${providerImpl.authorizationEndpoint}?${params.toString()}`;
|
|
48
|
-
}
|
|
49
|
-
async handleCallback({ provider, code, state, }) {
|
|
50
|
-
if (!code || code.trim() === "") {
|
|
51
|
-
throw new Error("Invalid or missing code in callback");
|
|
52
|
-
}
|
|
53
|
-
if (!state || state.trim() === "") {
|
|
54
|
-
throw new Error("Invalid or missing state in callback");
|
|
55
|
-
}
|
|
56
|
-
//TODO: Validate state here
|
|
57
|
-
const providerConfig = this.findProviderByType(provider.toLowerCase());
|
|
58
|
-
const providerImpl = Lixa.CONFIGURED_PROVIDERS.get(provider);
|
|
59
|
-
if (!providerConfig || !providerImpl) {
|
|
60
|
-
throw new Error(`Provider ${provider} not configured`);
|
|
61
|
-
}
|
|
62
|
-
// Exchange code for tokens and fetch user info here.
|
|
63
|
-
const tokens = await this.exchangeCodeForToken(code, providerConfig, providerImpl);
|
|
64
|
-
// For simplicity, we'll just return the tokens as the session.
|
|
65
|
-
// In a real implementation, you'd fetch user info and create a session.
|
|
66
|
-
const session = {
|
|
67
|
-
token: tokens.access_token,
|
|
68
|
-
raw: tokens, // Replace with actual user info
|
|
69
|
-
};
|
|
70
|
-
// If a session strategy is provided, use it to create a session.
|
|
71
|
-
if (this.config.sessionStrategy) {
|
|
72
|
-
return this.config.sessionStrategy.createSession(session.raw);
|
|
73
|
-
}
|
|
74
|
-
return session;
|
|
75
|
-
}
|
|
76
|
-
async exchangeCodeForToken(code, providerConfig, providerImpl, codeVerifier) {
|
|
77
|
-
// Build the request body
|
|
78
|
-
const body = {
|
|
79
|
-
client_id: providerConfig.clientId,
|
|
80
|
-
client_secret: providerConfig.clientSecret,
|
|
81
|
-
code,
|
|
82
|
-
redirect_uri: providerConfig.redirectUri,
|
|
83
|
-
grant_type: "authorization_code",
|
|
84
|
-
};
|
|
85
|
-
if (codeVerifier) {
|
|
86
|
-
body.code_verifier = codeVerifier;
|
|
87
|
-
}
|
|
88
|
-
const params = new URLSearchParams(body);
|
|
89
|
-
const response = await fetch(providerImpl.tokenEndpoint, {
|
|
90
|
-
method: "POST",
|
|
91
|
-
headers: {
|
|
92
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
93
|
-
Accept: "application/json",
|
|
94
|
-
},
|
|
95
|
-
body: params.toString(),
|
|
96
|
-
});
|
|
97
|
-
if (!response.ok) {
|
|
98
|
-
throw new Error(`Token exchange failed: ${response.status} ${response.statusText}`);
|
|
99
|
-
}
|
|
100
|
-
return response.json();
|
|
101
|
-
}
|
|
102
|
-
findProviderByType(providerType) {
|
|
103
|
-
return this.config.providers[providerType];
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
export { Lixa };
|
|
107
|
-
//# 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;AAErC,OAAO,EAAa,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;GAEG;AACH,MAAM,IAAI;IACA,MAAM,CAAC,oBAAoB,GAA2B,IAAI,GAAG,EAAE,CAAC;IAChE,MAAM,CAAa;IAE3B,YAAY,MAAkB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,cAAc,EAAE,CAAC,CAAC;QAC9D,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,cAAc,EAAE,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAEM,MAAM,CAAC,oBAAoB,CAAC,QAAgB;QACjD,OAAO,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IAC/D,CAAC;IAEM,MAAM,CAAC,gBAAgB,CAAC,WAE9B;QACC,mEAAmE;QACnE,gEAAgE;QAChE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,YAAY,CAAC,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AM,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;QAEzC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,YAAY,CAAC,aAAa,EAAE;YACvD,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IProvider.js","sourceRoot":"","sources":["../../src/providers/IProvider.ts"],"names":[],"mappings":"AAAA,iEAAiE"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IProvider } from "./IProvider";
|
|
2
|
-
declare class GithubProvider implements IProvider {
|
|
3
|
-
providerType: string;
|
|
4
|
-
authorizationEndpoint: string;
|
|
5
|
-
tokenEndpoint: string;
|
|
6
|
-
userInfoEndpoint: string;
|
|
7
|
-
}
|
|
8
|
-
export { GithubProvider };
|
|
9
|
-
//# sourceMappingURL=github.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../src/providers/github.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,cAAM,cAAe,YAAW,SAAS;IACvC,YAAY,SAAY;IACxB,qBAAqB,SAA8C;IACnE,aAAa,SAAiD;IAC9D,gBAAgB,SAAiC;CAClD;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/providers/github.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
class GithubProvider {
|
|
2
|
-
providerType = "GITHUB";
|
|
3
|
-
authorizationEndpoint = "https://github.com/login/oauth/authorize";
|
|
4
|
-
tokenEndpoint = "https://github.com/login/oauth/access_token";
|
|
5
|
-
userInfoEndpoint = "https://api.github.com/user";
|
|
6
|
-
}
|
|
7
|
-
export { GithubProvider };
|
|
8
|
-
//# sourceMappingURL=github.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"github.js","sourceRoot":"","sources":["../../src/providers/github.ts"],"names":[],"mappings":"AAEA,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,9 +0,0 @@
|
|
|
1
|
-
import { IProvider } from "./IProvider";
|
|
2
|
-
declare class GoogleProvider implements IProvider {
|
|
3
|
-
providerType: string;
|
|
4
|
-
authorizationEndpoint: string;
|
|
5
|
-
tokenEndpoint: string;
|
|
6
|
-
userInfoEndpoint: string;
|
|
7
|
-
}
|
|
8
|
-
export { GoogleProvider };
|
|
9
|
-
//# sourceMappingURL=google.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../src/providers/google.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,cAAM,cAAe,YAAW,SAAS;IACvC,YAAY,SAAY;IACxB,qBAAqB,SAAkD;IACvE,aAAa,SAAyC;IACtD,gBAAgB,SAAmD;CACpE;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/providers/google.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
class GoogleProvider {
|
|
2
|
-
providerType = "GOOGLE";
|
|
3
|
-
authorizationEndpoint = "https://accounts.google.com/o/oauth2/v2/auth";
|
|
4
|
-
tokenEndpoint = "https://oauth2.googleapis.com/token";
|
|
5
|
-
userInfoEndpoint = "https://www.googleapis.com/oauth2/v2/userinfo";
|
|
6
|
-
}
|
|
7
|
-
export { GoogleProvider };
|
|
8
|
-
//# sourceMappingURL=google.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"google.js","sourceRoot":"","sources":["../../src/providers/google.ts"],"names":[],"mappings":"AAEA,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"}
|
package/dist/providers/index.js
DELETED
|
@@ -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.js
DELETED
package/dist/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/utils/constants.js
DELETED
|
@@ -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"}
|
package/index.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
declare interface IProvider {
|
|
2
|
-
authorizationEndpoint: string;
|
|
3
|
-
tokenEndpoint: string;
|
|
4
|
-
userInfoEndpoint: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export declare class Lixa {
|
|
11
|
-
private static CONFIGURED_PROVIDERS;
|
|
12
|
-
private config;
|
|
13
|
-
constructor(config: LixaConfig);
|
|
14
|
-
static isProviderRegistered(provider: string): boolean;
|
|
15
|
-
static registerProvider(providerMap: {
|
|
16
|
-
[key: string]: IProvider;
|
|
17
|
-
}): void;
|
|
18
|
-
generateRandomState(): string;
|
|
19
|
-
getAuthUrl(provider: string, state: string): string;
|
|
20
|
-
handleCallback({ provider, code, state, }: {
|
|
21
|
-
provider: string;
|
|
22
|
-
code: string;
|
|
23
|
-
state?: string;
|
|
24
|
-
}): Promise<Session>;
|
|
25
|
-
private exchangeCodeForToken;
|
|
26
|
-
private findProviderByType;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
export declare interface LixaConfig {
|
|
33
|
-
providers: Record<string, ProviderConfig>;
|
|
34
|
-
sessionStrategy?: SessionStrategy;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @public
|
|
39
|
-
*/
|
|
40
|
-
export declare interface ProviderConfig {
|
|
41
|
-
clientId: string;
|
|
42
|
-
clientSecret: string;
|
|
43
|
-
redirectUri: string;
|
|
44
|
-
scopes: string[];
|
|
45
|
-
extraConfig?: Record<string, any>;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @public
|
|
50
|
-
*/
|
|
51
|
-
export declare interface Session {
|
|
52
|
-
token: string;
|
|
53
|
-
raw: any;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @public
|
|
58
|
-
*/
|
|
59
|
-
export declare interface SessionStrategy {
|
|
60
|
-
createSession(userInfo: any): Promise<Session>;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export { }
|