flashauthbyjagwar 1.0.0 → 1.2.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/README.md CHANGED
@@ -1,6 +1,69 @@
1
- ---------------------------------------------------------------- FLASH AUTH SDK ------------------------------------------------------------------
2
- INTRODUCTION:
3
-
4
-
5
-
6
-
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
+ ```
@@ -1,11 +1,5 @@
1
- interface UserData {
2
- success: boolean;
3
- message: string;
4
- data: any;
5
- }
6
1
  export declare function GetGoogleLoginURL(serverURL: string, clientId: string): Promise<string>;
7
2
  export declare function SignUpWithJWT(serverURL: string, clientId: string, name: string, email: string, password: string): Promise<string>;
8
3
  export declare function SingInWithJWT(serverURL: string, clientId: string, email: string, password: string): Promise<any>;
9
- export declare function FetchProfile(serverURL: string, clientId: string, token: string): Promise<string | UserData>;
10
- export {};
4
+ export declare function FetchProfile(serverURL: string, clientId: string, token: string): Promise<any>;
11
5
  //# sourceMappingURL=API.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"API.d.ts","sourceRoot":"","sources":["../../src/APIs/API.ts"],"names":[],"mappings":"AAEA,UAAU,QAAQ;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,GAAG,CAAC;CACX;AAQD,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,CAoBvI;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,8BAsBpF"}
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"}
package/dist/APIs/API.js CHANGED
@@ -1,4 +1,3 @@
1
- import axios from "axios";
2
1
  export async function GetGoogleLoginURL(serverURL, clientId) {
3
2
  if (!clientId || !serverURL) {
4
3
  throw new Error("Missing client ID or server url");
@@ -32,15 +31,19 @@ export async function SignUpWithJWT(serverURL, clientId, name, email, password)
32
31
  }
33
32
  try {
34
33
  const payload = {
35
- name, email, password
34
+ name, email, password, authType: 'local'
36
35
  };
37
- const res = await axios.post(`${serverURL}/api/flashauth/local/signup`, payload, {
36
+ const url = `${serverURL}/api/flashauth/local/signup`;
37
+ const res = await fetch(url, {
38
+ method: 'POST',
38
39
  headers: {
39
40
  'Content-Type': 'application/json',
40
41
  'X-Client-Id': clientId
41
- }
42
+ },
43
+ body: JSON.stringify(payload)
42
44
  });
43
- return res.data;
45
+ const data = await res.json();
46
+ return data;
44
47
  }
45
48
  catch (error) {
46
49
  throw new Error("There is an error with sign up");
@@ -76,17 +79,17 @@ export async function FetchProfile(serverURL, clientId, token) {
76
79
  throw new Error("All the fields are required");
77
80
  }
78
81
  try {
79
- const userResponse = await axios.get(`${serverURL}/api/flashauth/fetch/profile`, {
82
+ const url = `${serverURL}/api/flashauth/fetch/profile`;
83
+ const res = await fetch(url, {
84
+ method: 'GET',
80
85
  headers: {
81
86
  'Content-Type': 'application/json',
82
87
  'X-Client-Id': clientId,
83
- Authorization: `Bearer:${token}`
88
+ 'Authorization': `Bearer:${token}`
84
89
  }
85
90
  });
86
- if (userResponse.data.success == false) {
87
- return userResponse.data.message;
88
- }
89
- return userResponse.data;
91
+ const data = await res.json();
92
+ return data.data;
90
93
  }
91
94
  catch (error) {
92
95
  throw new Error("There is an error with Fetching user profile");
@@ -1 +1 @@
1
- {"version":3,"file":"AuthManager.d.ts","sourceRoot":"","sources":["../../src/Managers/AuthManager.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,OAAO,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,iBAAiB,CAAsB;IAC/C,OAAO,CAAC,qBAAqB,CAAsB;gBAEvC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAC,MAAM;IAcxC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;CAwB5C"}
1
+ {"version":3,"file":"AuthManager.d.ts","sourceRoot":"","sources":["../../src/Managers/AuthManager.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,OAAO,OAAO,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,iBAAiB,CAAsB;IAC/C,OAAO,CAAC,qBAAqB,CAAsB;gBAEvC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAC,MAAM;IAcxC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;CAuB5C"}
@@ -21,7 +21,6 @@ export default class AuthManager {
21
21
  try {
22
22
  const googleProvider = new GoogleAuthProvider();
23
23
  const url = await googleProvider.GetLoginURL(this.ClientId, this.ServerURL);
24
- console.log("O AUTH URL", url);
25
24
  const popup = this.OAuthPopupManager.openPopupURL(url, "GoogleAuth", 500, 600);
26
25
  if (!popup)
27
26
  throw new Error("FlashAuth: Popup blocked by browser");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flashauthbyjagwar",
3
- "version": "1.0.0",
3
+ "version": "1.2.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",
@@ -39,7 +39,6 @@
39
39
  },
40
40
  "homepage": "https://github.com/jagwar7/flashauth-sdk#readme",
41
41
  "dependencies": {
42
- "axios": "^1.12.2",
43
42
  "firebase": "^12.1.0",
44
43
  "jwt-decode": "^4.0.0"
45
44
  },