flashauthbyjagwar 1.2.0 → 3.5.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.
- package/LICENSE +7 -7
- package/README.md +68 -68
- package/dist/APIs/API.d.ts.map +1 -1
- package/dist/APIs/API.js +12 -8
- package/dist/FlashAuthClient.d.ts.map +1 -1
- package/dist/FlashAuthClient.js +20 -15
- package/dist/Interfaces/ILocalPopupManager.js +2 -1
- package/dist/Interfaces/IOAuthPopupManager.js +2 -1
- package/dist/Interfaces/IOAuthProvider.d.ts +1 -1
- package/dist/Interfaces/IOAuthProvider.d.ts.map +1 -1
- package/dist/Interfaces/IOAuthProvider.js +1 -0
- package/dist/Interfaces/ProviderIN.js +2 -1
- package/dist/Managers/AuthManager.js +15 -9
- package/dist/index.js +7 -2
- package/dist/providers/GithubAuthProvider.d.ts +1 -3
- package/dist/providers/GithubAuthProvider.d.ts.map +1 -1
- package/dist/providers/GithubAuthProvider.js +1 -0
- package/dist/providers/GoogleAuthProvider.d.ts +1 -0
- package/dist/providers/GoogleAuthProvider.d.ts.map +1 -1
- package/dist/providers/GoogleAuthProvider.js +6 -3
- package/dist/providers/LocalAuthPopupManager.js +4 -1
- package/dist/providers/OAuthPopupManager.d.ts.map +1 -1
- package/dist/providers/OAuthPopupManager.js +14 -7
- package/dist/utils/Storage.js +3 -1
- package/package.json +50 -50
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Copyright (c) 2025 Jagwar. All rights reserved.
|
|
2
|
-
|
|
3
|
-
This software and associated documentation files (the "Software") are the exclusive property of Jagwar.
|
|
4
|
-
|
|
5
|
-
Unauthorized copying, modification, distribution, or use of this Software, in whole or in part, is strictly prohibited without the express written permission of the copyright holder.
|
|
6
|
-
|
|
7
|
-
For licensing inquiries, please contact: https://github.com/jagwar7
|
|
1
|
+
Copyright (c) 2025 Jagwar. All rights reserved.
|
|
2
|
+
|
|
3
|
+
This software and associated documentation files (the "Software") are the exclusive property of Jagwar.
|
|
4
|
+
|
|
5
|
+
Unauthorized copying, modification, distribution, or use of this Software, in whole or in part, is strictly prohibited without the express written permission of the copyright holder.
|
|
6
|
+
|
|
7
|
+
For licensing inquiries, please contact: https://github.com/jagwar7
|
package/README.md
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
```text
|
|
2
|
-
+----------------------+ +-----------------------------------+
|
|
3
|
-
| User Triggers Auth | | FlashAuth SDK Captures |
|
|
4
|
-
| in React App |---->| Credentials |
|
|
5
|
-
| (Login Button) | | (Email/Password or OAuth Token) |
|
|
6
|
-
+----------------------+ +-------------------+---------------+
|
|
7
|
-
|
|
|
8
|
-
|
|
|
9
|
-
|
|
|
10
|
-
v
|
|
11
|
-
+-----------------------------------------------------------------------------------------------+
|
|
12
|
-
| SDK Sends Encrypted Request to FlashAuth Backend with FlashAuth Client Public Key |
|
|
13
|
-
+-----------------------------------------------------------------------------------------------+
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
+------------------------------------------------------------------------+
|
|
19
|
-
| Backend Finds and Connect to Client' Database by Client Pubilc Key |
|
|
20
|
-
+------------------------------------------------------------------------+
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
24
|
-
+----------------------+ +----------------------------------+
|
|
25
|
-
| If Failed ? |<-------------| If Successfully connected ? |
|
|
26
|
-
+----------------------+ +--------+-------------------------+
|
|
27
|
-
| |
|
|
28
|
-
| |
|
|
29
|
-
| v
|
|
30
|
-
| +----------------------------------------------------------------------+
|
|
31
|
-
| | Backend Attempt for Creating / Updating user in client's database |
|
|
32
|
-
| | (Custom Logic + Security Checks) |
|
|
33
|
-
| +----------------------------------------------------------------------+
|
|
34
|
-
| |
|
|
35
|
-
| v
|
|
36
|
-
+----------------------+ +-----------------------------------------+
|
|
37
|
-
| If Failed ? |<-----------| If Successfuly Created / Updated ? |
|
|
38
|
-
+----------------------+ +---------------+-------------------------+
|
|
39
|
-
| |
|
|
40
|
-
+ +---------------+
|
|
41
|
-
| |
|
|
42
|
-
| |
|
|
43
|
-
| |
|
|
44
|
-
v v
|
|
45
|
-
+---------------------------------+ +---------------------------------+
|
|
46
|
-
| Error: Reject Auth | | Create/Update User in client's |
|
|
47
|
-
| (Invalid Credentials) | | Database |
|
|
48
|
-
+-----------------+---------------+ +-----------------+---------------+
|
|
49
|
-
| |
|
|
50
|
-
| +-----------------------+
|
|
51
|
-
| |
|
|
52
|
-
| |
|
|
53
|
-
| |
|
|
54
|
-
| v
|
|
55
|
-
| +-----------------------------------------------------+
|
|
56
|
-
| | Backend Sends Callback to App |
|
|
57
|
-
| | (Update Auth State) |
|
|
58
|
-
| +-----------------------------------------------------+
|
|
59
|
-
| |
|
|
60
|
-
| v
|
|
61
|
-
| +------------------+
|
|
62
|
-
+------->| User Logged In!|<-------+
|
|
63
|
-
| (Redirect/Unlock | |
|
|
64
|
-
| Features) | |
|
|
65
|
-
+------------------+ |
|
|
66
|
-
| |
|
|
67
|
-
+------------------+
|
|
68
|
-
Optional: Retry Flow
|
|
1
|
+
```text
|
|
2
|
+
+----------------------+ +-----------------------------------+
|
|
3
|
+
| User Triggers Auth | | FlashAuth SDK Captures |
|
|
4
|
+
| in React App |---->| Credentials |
|
|
5
|
+
| (Login Button) | | (Email/Password or OAuth Token) |
|
|
6
|
+
+----------------------+ +-------------------+---------------+
|
|
7
|
+
|
|
|
8
|
+
|
|
|
9
|
+
|
|
|
10
|
+
v
|
|
11
|
+
+-----------------------------------------------------------------------------------------------+
|
|
12
|
+
| SDK Sends Encrypted Request to FlashAuth Backend with FlashAuth Client Public Key |
|
|
13
|
+
+-----------------------------------------------------------------------------------------------+
|
|
14
|
+
|
|
|
15
|
+
|
|
|
16
|
+
|
|
|
17
|
+
|
|
|
18
|
+
+------------------------------------------------------------------------+
|
|
19
|
+
| Backend Finds and Connect to Client' Database by Client Pubilc Key |
|
|
20
|
+
+------------------------------------------------------------------------+
|
|
21
|
+
|
|
|
22
|
+
|
|
|
23
|
+
|
|
|
24
|
+
+----------------------+ +----------------------------------+
|
|
25
|
+
| If Failed ? |<-------------| If Successfully connected ? |
|
|
26
|
+
+----------------------+ +--------+-------------------------+
|
|
27
|
+
| |
|
|
28
|
+
| |
|
|
29
|
+
| v
|
|
30
|
+
| +----------------------------------------------------------------------+
|
|
31
|
+
| | Backend Attempt for Creating / Updating user in client's database |
|
|
32
|
+
| | (Custom Logic + Security Checks) |
|
|
33
|
+
| +----------------------------------------------------------------------+
|
|
34
|
+
| |
|
|
35
|
+
| v
|
|
36
|
+
+----------------------+ +-----------------------------------------+
|
|
37
|
+
| If Failed ? |<-----------| If Successfuly Created / Updated ? |
|
|
38
|
+
+----------------------+ +---------------+-------------------------+
|
|
39
|
+
| |
|
|
40
|
+
+ +---------------+
|
|
41
|
+
| |
|
|
42
|
+
| |
|
|
43
|
+
| |
|
|
44
|
+
v v
|
|
45
|
+
+---------------------------------+ +---------------------------------+
|
|
46
|
+
| Error: Reject Auth | | Create/Update User in client's |
|
|
47
|
+
| (Invalid Credentials) | | Database |
|
|
48
|
+
+-----------------+---------------+ +-----------------+---------------+
|
|
49
|
+
| |
|
|
50
|
+
| +-----------------------+
|
|
51
|
+
| |
|
|
52
|
+
| |
|
|
53
|
+
| |
|
|
54
|
+
| v
|
|
55
|
+
| +-----------------------------------------------------+
|
|
56
|
+
| | Backend Sends Callback to App |
|
|
57
|
+
| | (Update Auth State) |
|
|
58
|
+
| +-----------------------------------------------------+
|
|
59
|
+
| |
|
|
60
|
+
| v
|
|
61
|
+
| +------------------+
|
|
62
|
+
+------->| User Logged In!|<-------+
|
|
63
|
+
| (Redirect/Unlock | |
|
|
64
|
+
| Features) | |
|
|
65
|
+
+------------------+ |
|
|
66
|
+
| |
|
|
67
|
+
+------------------+
|
|
68
|
+
Optional: Retry Flow
|
|
69
69
|
```
|
package/dist/APIs/API.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"API.d.ts","sourceRoot":"","sources":["../../src/APIs/API.ts"],"names":[],"mappings":"AAQA,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"API.d.ts","sourceRoot":"","sources":["../../src/APIs/API.ts"],"names":[],"mappings":"AAQA,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA0B5F;AAgBD,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAwBvI;AAKD,wBAAsB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAC,MAAM,EAAE,QAAQ,EAAC,MAAM,gBAyBrG;AAWD,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAoBpF"}
|
package/dist/APIs/API.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetGoogleLoginURL = GetGoogleLoginURL;
|
|
4
|
+
exports.SignUpWithJWT = SignUpWithJWT;
|
|
5
|
+
exports.SingInWithJWT = SingInWithJWT;
|
|
6
|
+
exports.FetchProfile = FetchProfile;
|
|
7
|
+
async function GetGoogleLoginURL(serverURL, clientId) {
|
|
2
8
|
if (!clientId || !serverURL) {
|
|
3
9
|
throw new Error("Missing client ID or server url");
|
|
4
10
|
}
|
|
@@ -16,16 +22,14 @@ export async function GetGoogleLoginURL(serverURL, clientId) {
|
|
|
16
22
|
throw new Error(`Failed to get provider login URL: ${errorData.error || res.statusText}`);
|
|
17
23
|
}
|
|
18
24
|
const data = await res.json();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
return data.url;
|
|
25
|
+
console.log(data.data.url);
|
|
26
|
+
return data.data.url;
|
|
23
27
|
}
|
|
24
28
|
catch (err) {
|
|
25
29
|
throw err;
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
|
-
|
|
32
|
+
async function SignUpWithJWT(serverURL, clientId, name, email, password) {
|
|
29
33
|
if (!serverURL || !clientId || !name || !email || !password) {
|
|
30
34
|
throw new Error("All the fields are required");
|
|
31
35
|
}
|
|
@@ -49,7 +53,7 @@ export async function SignUpWithJWT(serverURL, clientId, name, email, password)
|
|
|
49
53
|
throw new Error("There is an error with sign up");
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
|
-
|
|
56
|
+
async function SingInWithJWT(serverURL, clientId, email, password) {
|
|
53
57
|
const proivder = 'local';
|
|
54
58
|
if (!serverURL || !clientId || !email || !password) {
|
|
55
59
|
throw new Error("All the fields are required");
|
|
@@ -74,7 +78,7 @@ export async function SingInWithJWT(serverURL, clientId, email, password) {
|
|
|
74
78
|
throw new Error("There is a problem while signing in");
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
|
-
|
|
81
|
+
async function FetchProfile(serverURL, clientId, token) {
|
|
78
82
|
if (!serverURL || !clientId || !token) {
|
|
79
83
|
throw new Error("All the fields are required");
|
|
80
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlashAuthClient.d.ts","sourceRoot":"","sources":["../src/FlashAuthClient.ts"],"names":[],"mappings":"AAMA,cAAM,eAAe;IACnB,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"FlashAuthClient.d.ts","sourceRoot":"","sources":["../src/FlashAuthClient.ts"],"names":[],"mappings":"AAMA,cAAM,eAAe;IACnB,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,SAAS,CAAuD;IACxE,OAAO,CAAC,WAAW,CAAc;gBAIrB,QAAQ,EAAC,MAAM;IAsBrB,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;IAyBnC,gBAAgB,IAAK,OAAO,CAAC,GAAG,CAAC;IAkBjC,OAAO,IAAK,OAAO,CAAC,GAAG,CAAC;IAe9B,cAAc,IAAI,GAAG;IAQrB,gBAAgB;CAcjB;AAGD,eAAe,eAAe,CAAC"}
|
package/dist/FlashAuthClient.js
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const API_js_1 = require("./APIs/API.js");
|
|
7
|
+
const AuthManager_js_1 = __importDefault(require("./Managers/AuthManager.js"));
|
|
8
|
+
const Storage_js_1 = __importDefault(require("./utils/Storage.js"));
|
|
9
|
+
const jwt_decode_1 = require("jwt-decode");
|
|
5
10
|
class FlashAuthClient {
|
|
6
11
|
constructor(clientId) {
|
|
7
|
-
this.serverURL = "https://jagwar-flash-auth.onrender.com";
|
|
12
|
+
this.serverURL = "https://jagwar-flash-auth-v2.onrender.com";
|
|
8
13
|
try {
|
|
9
14
|
if (!clientId) {
|
|
10
15
|
throw new Error("Flash Auth: Client public key is required");
|
|
11
16
|
}
|
|
12
17
|
this.clientId = clientId;
|
|
13
|
-
this.authManager = new
|
|
14
|
-
this.serverURL = "https://jagwar-flash-auth.onrender.com";
|
|
18
|
+
this.authManager = new AuthManager_js_1.default(this.clientId, this.serverURL);
|
|
19
|
+
this.serverURL = "https://jagwar-flash-auth-v2.onrender.com";
|
|
15
20
|
this.checkTokenExpiry();
|
|
16
21
|
}
|
|
17
22
|
catch (error) {
|
|
@@ -30,10 +35,10 @@ class FlashAuthClient {
|
|
|
30
35
|
}
|
|
31
36
|
async FetchUserProfile() {
|
|
32
37
|
try {
|
|
33
|
-
const token =
|
|
38
|
+
const token = Storage_js_1.default.Get();
|
|
34
39
|
if (!token)
|
|
35
40
|
return "Authentication token does not exist. Please sign in.";
|
|
36
|
-
const res = await FetchProfile(this.serverURL, this.clientId, token);
|
|
41
|
+
const res = await (0, API_js_1.FetchProfile)(this.serverURL, this.clientId, token);
|
|
37
42
|
return res;
|
|
38
43
|
}
|
|
39
44
|
catch (error) {
|
|
@@ -42,25 +47,25 @@ class FlashAuthClient {
|
|
|
42
47
|
}
|
|
43
48
|
async SignOut() {
|
|
44
49
|
try {
|
|
45
|
-
|
|
50
|
+
Storage_js_1.default.Remove();
|
|
46
51
|
window.location.reload();
|
|
47
52
|
}
|
|
48
53
|
catch (error) {
|
|
49
|
-
|
|
54
|
+
alert("Auth token doesnt exist");
|
|
50
55
|
}
|
|
51
56
|
}
|
|
52
57
|
FetchUserToken() {
|
|
53
|
-
return
|
|
58
|
+
return Storage_js_1.default.Get();
|
|
54
59
|
}
|
|
55
60
|
checkTokenExpiry() {
|
|
56
61
|
const token = this.FetchUserToken();
|
|
57
62
|
if (!token)
|
|
58
63
|
return;
|
|
59
64
|
try {
|
|
60
|
-
const decoded = jwtDecode(token);
|
|
65
|
+
const decoded = (0, jwt_decode_1.jwtDecode)(token);
|
|
61
66
|
const currentTime = Date.now() / 1000;
|
|
62
67
|
if (decoded.exp && decoded.exp < currentTime) {
|
|
63
|
-
|
|
68
|
+
Storage_js_1.default.Remove();
|
|
64
69
|
}
|
|
65
70
|
}
|
|
66
71
|
catch (error) {
|
|
@@ -68,4 +73,4 @@ class FlashAuthClient {
|
|
|
68
73
|
}
|
|
69
74
|
}
|
|
70
75
|
}
|
|
71
|
-
|
|
76
|
+
exports.default = FlashAuthClient;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IOAuthProvider.d.ts","sourceRoot":"","sources":["../../src/Interfaces/IOAuthProvider.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"IOAuthProvider.d.ts","sourceRoot":"","sources":["../../src/Interfaces/IOAuthProvider.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC3B,WAAW,CAAC,QAAQ,EAAC,MAAM,EAAE,SAAS,EAAC,MAAM,GAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACpE"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const GoogleAuthProvider_1 = __importDefault(require("../providers/GoogleAuthProvider"));
|
|
7
|
+
const OAuthPopupManager_1 = __importDefault(require("../providers/OAuthPopupManager"));
|
|
8
|
+
const Storage_1 = __importDefault(require("../utils/Storage"));
|
|
9
|
+
const LocalAuthPopupManager_1 = __importDefault(require("../providers/LocalAuthPopupManager"));
|
|
10
|
+
class AuthManager {
|
|
6
11
|
constructor(clientId, serverURL) {
|
|
7
12
|
try {
|
|
8
13
|
if (!clientId)
|
|
9
14
|
throw new Error("Missing client public key");
|
|
10
15
|
this.ClientId = clientId;
|
|
11
16
|
this.ServerURL = serverURL;
|
|
12
|
-
this.OAuthPopupManager = new
|
|
13
|
-
this.LocalAuthPopupManager = new
|
|
17
|
+
this.OAuthPopupManager = new OAuthPopupManager_1.default();
|
|
18
|
+
this.LocalAuthPopupManager = new LocalAuthPopupManager_1.default();
|
|
14
19
|
}
|
|
15
20
|
catch (error) {
|
|
16
21
|
console.log("AuthManager intialization error", error);
|
|
@@ -19,13 +24,13 @@ export default class AuthManager {
|
|
|
19
24
|
}
|
|
20
25
|
async SignInWithGoogle() {
|
|
21
26
|
try {
|
|
22
|
-
const googleProvider = new
|
|
27
|
+
const googleProvider = new GoogleAuthProvider_1.default();
|
|
23
28
|
const url = await googleProvider.GetLoginURL(this.ClientId, this.ServerURL);
|
|
24
29
|
const popup = this.OAuthPopupManager.openPopupURL(url, "GoogleAuth", 500, 600);
|
|
25
30
|
if (!popup)
|
|
26
31
|
throw new Error("FlashAuth: Popup blocked by browser");
|
|
27
32
|
const token = await this.OAuthPopupManager.handleAuthResponse(popup, this.ServerURL);
|
|
28
|
-
|
|
33
|
+
Storage_1.default.Set(token);
|
|
29
34
|
return token;
|
|
30
35
|
}
|
|
31
36
|
catch (error) {
|
|
@@ -34,3 +39,4 @@ export default class AuthManager {
|
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
}
|
|
42
|
+
exports.default = AuthManager;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const FlashAuthClient_1 = __importDefault(require("./FlashAuthClient"));
|
|
7
|
+
exports.default = FlashAuthClient_1.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GithubAuthProvider.d.ts","sourceRoot":"","sources":["../../src/providers/GithubAuthProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GithubAuthProvider.d.ts","sourceRoot":"","sources":["../../src/providers/GithubAuthProvider.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoogleAuthProvider.d.ts","sourceRoot":"","sources":["../../src/providers/GoogleAuthProvider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GoogleAuthProvider.d.ts","sourceRoot":"","sources":["../../src/providers/GoogleAuthProvider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,MAAM,CAAC,OAAO,OAAO,kBAAmB,YAAW,cAAc;IACvD,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAQ1E"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const API_1 = require("../APIs/API");
|
|
4
|
+
class GoogleAuthProvider {
|
|
3
5
|
async GetLoginURL(CliendId, serverURL) {
|
|
4
6
|
try {
|
|
5
|
-
return await GetGoogleLoginURL(serverURL, CliendId);
|
|
7
|
+
return await (0, API_1.GetGoogleLoginURL)(serverURL, CliendId);
|
|
6
8
|
}
|
|
7
9
|
catch (error) {
|
|
8
10
|
console.log("failed to get google login url", error);
|
|
@@ -10,3 +12,4 @@ export default class GoogleAuthProvider {
|
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
}
|
|
15
|
+
exports.default = GoogleAuthProvider;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class LocalAuthPopupManager {
|
|
2
4
|
openLocalPopupWindow(page, name, width, height) {
|
|
3
5
|
const left = window.screenX + (window.outerWidth - width) / 2;
|
|
4
6
|
const top = window.screenY + (window.outerHeight - height) / 2;
|
|
5
7
|
return window.open(page, name, `width=${width},height=${height},left=${left},top=${top}`);
|
|
6
8
|
}
|
|
7
9
|
}
|
|
10
|
+
exports.default = LocalAuthPopupManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OAuthPopupManager.d.ts","sourceRoot":"","sources":["../../src/providers/OAuthPopupManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAI,MAAM,kCAAkC,CAAC;AAExE,MAAM,CAAC,OAAO,OAAO,iBAAkB,YAAW,kBAAkB;IAEhE,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"OAuthPopupManager.d.ts","sourceRoot":"","sources":["../../src/providers/OAuthPopupManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAI,MAAM,kCAAkC,CAAC;AAExE,MAAM,CAAC,OAAO,OAAO,iBAAkB,YAAW,kBAAkB;IAEhE,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,GAAG,MAAM,GAAG,IAAI;IAS/E,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAuC9E"}
|
|
@@ -1,32 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class OAuthPopupManager {
|
|
2
4
|
openPopupURL(url, name, width, height) {
|
|
3
5
|
const left = window.screenX + (window.outerWidth - width) / 2;
|
|
4
6
|
const top = window.screenY + (window.outerHeight - height) / 2;
|
|
5
7
|
return window.open(url, name, `width=${width},height=${height},left=${left},top=${top}`);
|
|
6
8
|
}
|
|
7
9
|
async handleAuthResponse(popup, serverURL) {
|
|
8
|
-
return
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
let checkPopup;
|
|
12
|
+
const cleanup = () => {
|
|
13
|
+
clearInterval(checkPopup);
|
|
14
|
+
window.removeEventListener("message", popupEventResponse);
|
|
15
|
+
};
|
|
9
16
|
const popupEventResponse = (event) => {
|
|
10
17
|
if (event.origin !== serverURL.replace(/\/$/, ""))
|
|
11
18
|
return;
|
|
12
19
|
const data = event.data;
|
|
13
20
|
if (data.type === "FLASHAUTH_TOKEN" && data.token) {
|
|
14
|
-
|
|
21
|
+
cleanup();
|
|
15
22
|
resolve(data.token);
|
|
16
23
|
}
|
|
17
24
|
else if (data.type === "FLASHAUTH_ERROR") {
|
|
18
|
-
|
|
25
|
+
cleanup();
|
|
19
26
|
reject(new Error(data.error || "Authentication Failed"));
|
|
20
27
|
}
|
|
21
28
|
};
|
|
22
29
|
window.addEventListener("message", popupEventResponse);
|
|
23
|
-
|
|
30
|
+
checkPopup = setInterval(() => {
|
|
24
31
|
if (popup.closed) {
|
|
25
|
-
|
|
26
|
-
window.removeEventListener("message", popupEventResponse);
|
|
32
|
+
cleanup();
|
|
27
33
|
reject(new Error("FlashAuth: Popup closed by user"));
|
|
28
34
|
}
|
|
29
35
|
}, 500);
|
|
30
36
|
});
|
|
31
37
|
}
|
|
32
38
|
}
|
|
39
|
+
exports.default = OAuthPopupManager;
|
package/dist/utils/Storage.js
CHANGED
package/package.json
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "flashauthbyjagwar",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "An authentication SDK for your React site. No need to write auth logic — just create an account at flashauth.connectjagwar.com to get started.",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"module": "dist/index.js",
|
|
8
|
-
"files": [
|
|
9
|
-
"dist",
|
|
10
|
-
"README.md",
|
|
11
|
-
"LICENSE"
|
|
12
|
-
],
|
|
13
|
-
"scripts": {
|
|
14
|
-
"build": "tsc",
|
|
15
|
-
"watch": "tsc --watch",
|
|
16
|
-
"clean": "rimraf dist",
|
|
17
|
-
"prepublishOnly": "npm run build"
|
|
18
|
-
},
|
|
19
|
-
"repository": {
|
|
20
|
-
"type": "git",
|
|
21
|
-
"url": "https://github.com/jagwar7/flashauth-sdk.git"
|
|
22
|
-
},
|
|
23
|
-
"keywords": [
|
|
24
|
-
"flashauth",
|
|
25
|
-
"authentication",
|
|
26
|
-
"sdk",
|
|
27
|
-
"firebase",
|
|
28
|
-
"google-signin",
|
|
29
|
-
"typescript",
|
|
30
|
-
"javascript"
|
|
31
|
-
],
|
|
32
|
-
"author": {
|
|
33
|
-
"name": "Jagwar",
|
|
34
|
-
"url": "https://github.com/jagwar7"
|
|
35
|
-
},
|
|
36
|
-
"license": "MIT",
|
|
37
|
-
"bugs": {
|
|
38
|
-
"url": "https://github.com/jagwar7/flashauth-sdk/issues"
|
|
39
|
-
},
|
|
40
|
-
"homepage": "https://github.com/jagwar7/flashauth-sdk#readme",
|
|
41
|
-
"dependencies": {
|
|
42
|
-
"firebase": "^12.1.0",
|
|
43
|
-
"jwt-decode": "^4.0.0"
|
|
44
|
-
},
|
|
45
|
-
"devDependencies": {
|
|
46
|
-
"rimraf": "^6.
|
|
47
|
-
"typescript": "^5.9.2"
|
|
48
|
-
},
|
|
49
|
-
"private": false
|
|
50
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "flashauthbyjagwar",
|
|
3
|
+
"version": "3.5.0",
|
|
4
|
+
"description": "An authentication SDK for your React site. No need to write auth logic — just create an account at flashauth.connectjagwar.com to get started.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "npm run clean && tsc",
|
|
15
|
+
"watch": "tsc --watch",
|
|
16
|
+
"clean": "rimraf dist && rimraf .history",
|
|
17
|
+
"prepublishOnly": "npm run build"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/jagwar7/flashauth-sdk.git"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"flashauth",
|
|
25
|
+
"authentication",
|
|
26
|
+
"sdk",
|
|
27
|
+
"firebase",
|
|
28
|
+
"google-signin",
|
|
29
|
+
"typescript",
|
|
30
|
+
"javascript"
|
|
31
|
+
],
|
|
32
|
+
"author": {
|
|
33
|
+
"name": "Jagwar",
|
|
34
|
+
"url": "https://github.com/jagwar7"
|
|
35
|
+
},
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/jagwar7/flashauth-sdk/issues"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/jagwar7/flashauth-sdk#readme",
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"firebase": "^12.1.0",
|
|
43
|
+
"jwt-decode": "^4.0.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"rimraf": "^6.1.3",
|
|
47
|
+
"typescript": "^5.9.2"
|
|
48
|
+
},
|
|
49
|
+
"private": false
|
|
50
|
+
}
|