@a-tech.jo/auth-sdk 1.0.8 → 1.0.10

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
@@ -55,20 +55,34 @@ export default function ClientLayout({ children }: { children: React.ReactNode }
55
55
  Render the pre-built, responsive authentication card supporting mode toggling (Login, Register, Forgot Password).
56
56
 
57
57
  ```tsx
58
+ "use client";
58
59
  import { SDKAuthContainer } from "@a-tech.jo/auth-sdk";
60
+ import { useRouter } from 'next/navigation'
61
+ // Styles
62
+ import "@a-tech.jo/auth-sdk/styles.css";
59
63
 
60
- export default function AuthPage() {
61
- const handleSuccess = (data: { user: any; token: string }) => {
62
- console.log("Authenticated successfully:", data);
63
- };
64
-
65
- return (
66
- <div className="flex min-h-screen items-center justify-center">
67
- <SDKAuthContainer initialMode="login" onSuccess="{handleSuccess}"/>
68
- </div>
69
- );
64
+ function AuthWrapper() {
65
+ const router = useRouter()
66
+
67
+ const handleSuccess = () => {
68
+ console.log("Authentication successful!");
69
+ // Example: Redirect user or refresh session state
70
+ router.push('/dashboard')
71
+ };
72
+
73
+ return (
74
+ <div className="flex min-h-screen items-center justify-center">
75
+ <SDKAuthContainer
76
+ initialMode="login"
77
+ onSuccess={handleSuccess}
78
+ />
79
+ </div>
80
+ );
70
81
  }
71
82
 
83
+
84
+ export default AuthWrapper;
85
+
72
86
  ```
73
87
 
74
88
  ---
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
@@ -755,35 +765,35 @@ var SDKAuthContainer = ({
755
765
  };
756
766
 
757
767
  // src/services/auth.ts
758
- async function verifyToken(token, environment = "production") {
768
+ var import_axios = __toESM(require("axios"));
769
+ async function verifyToken(token, environment = "production", showLog = false) {
759
770
  const baseUrlMap = {
760
771
  local: "http://localhost:3000",
761
- stage: "https://auth.atech-workspace.com",
762
- production: "https://sso.a-tech.dev"
772
+ stage: "https://stage.auth.atech-workspace.com",
773
+ production: "https://auth.atech-workspace.com"
763
774
  // Replace with your production URL
764
775
  };
765
776
  const baseUrl = baseUrlMap[environment] || baseUrlMap.production;
777
+ const fullUrl = `${baseUrl}/api/auth/verify`;
778
+ if (showLog) console.log(" AUTH BASE URL: ", baseUrl);
779
+ if (showLog) console.log(" AUTH FULL URL: ", fullUrl);
766
780
  try {
767
- const response = await fetch(`${baseUrl}/api/auth/verify`, {
768
- method: "POST",
769
- headers: {
770
- "Content-Type": "application/json",
771
- Authorization: `Bearer ${token}`
772
- },
773
- body: JSON.stringify({ token })
774
- });
775
- const data = await response.json();
776
- if (!response.ok) {
777
- return {
778
- valid: false,
779
- error: data.error || "Token verification failed."
780
- };
781
- }
782
- return data;
781
+ const headers = {
782
+ "Content-Type": "application/json",
783
+ Authorization: `Bearer ${token}`
784
+ };
785
+ const body = { token };
786
+ if (showLog) console.log(" AUTH Headers: ", headers);
787
+ if (showLog) console.log(" AUTH body: ", JSON.stringify(body));
788
+ const response = await import_axios.default.post(fullUrl, body, { headers });
789
+ if (showLog) console.log(" AUTH response: ", response.data);
790
+ return response.data;
783
791
  } catch (error) {
792
+ if (showLog) console.log(" AUTH catch error: ", error);
793
+ const errorMessage = error.response?.data?.error || error.message || "Network error while verifying token.";
784
794
  return {
785
795
  valid: false,
786
- error: error.message || "Network error while verifying token."
796
+ error: errorMessage
787
797
  };
788
798
  }
789
799
  }
package/dist/index.mjs CHANGED
@@ -719,35 +719,35 @@ var SDKAuthContainer = ({
719
719
  };
720
720
 
721
721
  // src/services/auth.ts
722
- async function verifyToken(token, environment = "production") {
722
+ import axios from "axios";
723
+ async function verifyToken(token, environment = "production", showLog = false) {
723
724
  const baseUrlMap = {
724
725
  local: "http://localhost:3000",
725
- stage: "https://auth.atech-workspace.com",
726
- production: "https://sso.a-tech.dev"
726
+ stage: "https://stage.auth.atech-workspace.com",
727
+ production: "https://auth.atech-workspace.com"
727
728
  // Replace with your production URL
728
729
  };
729
730
  const baseUrl = baseUrlMap[environment] || baseUrlMap.production;
731
+ const fullUrl = `${baseUrl}/api/auth/verify`;
732
+ if (showLog) console.log(" AUTH BASE URL: ", baseUrl);
733
+ if (showLog) console.log(" AUTH FULL URL: ", fullUrl);
730
734
  try {
731
- const response = await fetch(`${baseUrl}/api/auth/verify`, {
732
- method: "POST",
733
- headers: {
734
- "Content-Type": "application/json",
735
- Authorization: `Bearer ${token}`
736
- },
737
- body: JSON.stringify({ token })
738
- });
739
- const data = await response.json();
740
- if (!response.ok) {
741
- return {
742
- valid: false,
743
- error: data.error || "Token verification failed."
744
- };
745
- }
746
- return data;
735
+ const headers = {
736
+ "Content-Type": "application/json",
737
+ Authorization: `Bearer ${token}`
738
+ };
739
+ const body = { token };
740
+ if (showLog) console.log(" AUTH Headers: ", headers);
741
+ if (showLog) console.log(" AUTH body: ", JSON.stringify(body));
742
+ const response = await axios.post(fullUrl, body, { headers });
743
+ if (showLog) console.log(" AUTH response: ", response.data);
744
+ return response.data;
747
745
  } catch (error) {
746
+ if (showLog) console.log(" AUTH catch error: ", error);
747
+ const errorMessage = error.response?.data?.error || error.message || "Network error while verifying token.";
748
748
  return {
749
749
  valid: false,
750
- error: error.message || "Network error while verifying token."
750
+ error: errorMessage
751
751
  };
752
752
  }
753
753
  }
@@ -6,5 +6,5 @@ import { VerifyTokenResponse } from "../types";
6
6
  * @param environment - Optional environment override ('local' | 'stage' | 'production').
7
7
  * @returns Promise containing verification status and user details.
8
8
  */
9
- export declare function verifyToken(token: string, environment?: "local" | "stage" | "production"): Promise<VerifyTokenResponse>;
9
+ export declare function verifyToken(token: string, environment?: "local" | "stage" | "production", showLog?: boolean): Promise<VerifyTokenResponse>;
10
10
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/services/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC7B,KAAK,EAAE,MAAM,EACb,WAAW,GAAE,OAAO,GAAG,OAAO,GAAG,YAA2B,GAC7D,OAAO,CAAC,mBAAmB,CAAC,CAmC9B"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/services/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC7B,KAAK,EAAE,MAAM,EACb,WAAW,GAAE,OAAO,GAAG,OAAO,GAAG,YAA2B,EAC5D,OAAO,GAAE,OAAe,GACzB,OAAO,CAAC,mBAAmB,CAAC,CAyC9B"}
package/dist/styles.css CHANGED
@@ -6,13 +6,14 @@
6
6
  --atech-bg: #ffffff;
7
7
  }
8
8
  .atech-card {
9
+ --atech-bg: #ffffff !important;
10
+ background-color: #ffffff !important;
9
11
  width: 100%;
10
12
  max-width: 28rem;
11
13
  margin-left: auto;
12
14
  margin-right: auto;
13
15
  padding: 2rem;
14
16
  border-radius: 1rem;
15
- background-color: var(--atech-bg);
16
17
  border: 1px solid #f1f5f9;
17
18
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
18
19
  box-sizing: border-box;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a-tech.jo/auth-sdk",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "A-Tech Authentication SDK for React and Next.js",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -44,5 +44,8 @@
44
44
  "react-dom": "^19.0.0",
45
45
  "tsup": "^8.3.0",
46
46
  "typescript": "^5.0.0"
47
+ },
48
+ "dependencies": {
49
+ "axios": "^1.20.0"
47
50
  }
48
- }
51
+ }