flashauthbyjagwar 1.2.0 → 3.0.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.
@@ -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,CA4B5F;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"}
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
- export async function GetGoogleLoginURL(serverURL, clientId) {
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
- if (data.success == false) {
20
- throw new Error('Failed to get login URL, Contact Admin');
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
- export async function SignUpWithJWT(serverURL, clientId, name, email, password) {
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
- export async function SingInWithJWT(serverURL, clientId, email, password) {
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
- export async function FetchProfile(serverURL, clientId, token) {
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,CAAoD;IACrE,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"}
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"}
@@ -1,17 +1,22 @@
1
- import { FetchProfile } from "./APIs/API";
2
- import AuthManager from "./Managers/AuthManager";
3
- import Storage from "./utils/Storage";
4
- import { jwtDecode } from 'jwt-decode';
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 AuthManager(this.clientId, this.serverURL);
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 = Storage.Get();
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
- Storage.Remove();
50
+ Storage_js_1.default.Remove();
46
51
  window.location.reload();
47
52
  }
48
53
  catch (error) {
49
- throw error;
54
+ alert("Auth token doesnt exist");
50
55
  }
51
56
  }
52
57
  FetchUserToken() {
53
- return Storage.Get();
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
- Storage.Remove();
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
- export default FlashAuthClient;
76
+ exports.default = FlashAuthClient;
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
- interface IOAuthProvider {
1
+ export interface IOAuthProvider {
2
2
  GetLoginURL(CliendId: string, serverURL: string): Promise<string>;
3
3
  }
4
4
  //# sourceMappingURL=IOAuthProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"IOAuthProvider.d.ts","sourceRoot":"","sources":["../../src/Interfaces/IOAuthProvider.ts"],"names":[],"mappings":"AAAA,UAAU,cAAc;IACpB,WAAW,CAAC,QAAQ,EAAC,MAAM,EAAE,SAAS,EAAC,MAAM,GAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACpE"}
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 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,16 +1,21 @@
1
- import GoogleAuthProvider from "../providers/GoogleAuthProvider";
2
- import OAuthPopupManager from "../providers/OAuthPopupManager";
3
- import Storage from "../utils/Storage";
4
- import LocalAuthPopupManager from "../providers/LocalAuthPopupManager";
5
- export default class AuthManager {
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 OAuthPopupManager();
13
- this.LocalAuthPopupManager = new LocalAuthPopupManager();
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 GoogleAuthProvider();
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
- Storage.Set(token);
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
- import FlashAuthClient from "./FlashAuthClient";
2
- export default FlashAuthClient;
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,4 +1,2 @@
1
- declare class GithubAuthProvider implements IOAuthProvider {
2
- GetLoginURL(CliendId: string, serverURL: string): Promise<string>;
3
- }
1
+ export {};
4
2
  //# sourceMappingURL=GithubAuthProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GithubAuthProvider.d.ts","sourceRoot":"","sources":["../../src/providers/GithubAuthProvider.ts"],"names":[],"mappings":"AAEA,cAAM,kBAAmB,YAAW,cAAc;IACxC,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG1E"}
1
+ {"version":3,"file":"GithubAuthProvider.d.ts","sourceRoot":"","sources":["../../src/providers/GithubAuthProvider.ts"],"names":[],"mappings":""}
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
2
3
  class GithubAuthProvider {
3
4
  async GetLoginURL(CliendId, serverURL) {
4
5
  return "";
@@ -1,3 +1,4 @@
1
+ import { IOAuthProvider } from "../Interfaces/IOAuthProvider";
1
2
  export default class GoogleAuthProvider implements IOAuthProvider {
2
3
  GetLoginURL(CliendId: string, serverURL: string): Promise<string>;
3
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleAuthProvider.d.ts","sourceRoot":"","sources":["../../src/providers/GoogleAuthProvider.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,OAAO,kBAAmB,YAAW,cAAc;IACvD,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAQ1E"}
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
- import { GetGoogleLoginURL } from "../APIs/API";
2
- export default class GoogleAuthProvider {
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
- export default class LocalAuthPopupManager {
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,4 +1,6 @@
1
- export default class OAuthPopupManager {
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;
@@ -30,3 +32,4 @@ export default class OAuthPopupManager {
30
32
  });
31
33
  }
32
34
  }
35
+ exports.default = OAuthPopupManager;
@@ -1,3 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
1
3
  const Storage = {
2
4
  Set(token) {
3
5
  try {
@@ -28,4 +30,4 @@ const Storage = {
28
30
  }
29
31
  }
30
32
  };
31
- export default Storage;
33
+ exports.default = Storage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flashauthbyjagwar",
3
- "version": "1.2.0",
3
+ "version": "3.0.0",
4
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
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,9 +11,9 @@
11
11
  "LICENSE"
12
12
  ],
13
13
  "scripts": {
14
- "build": "tsc",
14
+ "build": "npm run clean && tsc",
15
15
  "watch": "tsc --watch",
16
- "clean": "rimraf dist",
16
+ "clean": "rimraf dist && rimraf .history",
17
17
  "prepublishOnly": "npm run build"
18
18
  },
19
19
  "repository": {