@a-tech.jo/auth-sdk 1.0.7 → 1.0.9

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,4 +1,4 @@
1
- # `@a-tech/auth-sdk`
1
+ # `@a-tech.jo/auth-sdk`
2
2
 
3
3
  A full-stack, customizable authentication SDK providing seamless login, registration, and session management for A-Tech applications.
4
4
 
@@ -15,7 +15,7 @@ Website: https://a-tech.dev
15
15
  Import the pre-compiled CSS file in your root `layout.tsx` or `_app.tsx`:
16
16
 
17
17
  ```tsx
18
- import "@a-tech/auth-sdk/styles.css";
18
+ import "@a-tech.jo/auth-sdk/styles.css";
19
19
 
20
20
  ```
21
21
 
@@ -55,19 +55,33 @@ 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
- import { SDKAuthContainer } from "@a-tech/auth-sdk";
58
+ "use client";
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";
63
+
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
+ );
81
+ }
59
82
 
60
- export default function AuthPage() {
61
- const handleSuccess = (data: { user: any; token: string }) => {
62
- console.log("Authenticated successfully:", data);
63
- };
64
83
 
65
- return (
66
- <div className="flex min-h-screen items-center justify-center">
67
- <SDKAuthContainer initialMode="login" onSuccess="{handleSuccess}"/>
68
- </div>
69
- );
70
- }
84
+ export default AuthWrapper;
71
85
 
72
86
  ```
73
87
 
@@ -78,7 +92,7 @@ export default function AuthPage() {
78
92
  Access the current user profile, JWT token, and session utilities anywhere within the `AuthProvider` scope:
79
93
 
80
94
  ```tsx
81
- import { useAuth } from "@a-tech/auth-sdk";
95
+ import { useAuth } from "@a-tech.jo/auth-sdk";
82
96
 
83
97
  export default function Dashboard() {
84
98
  const { user, token, logout, isExpired } = useAuth();
@@ -140,7 +154,7 @@ echo "//registry.npmjs.org/:_authToken=YOUR_NPM_TOKEN" > .npmrc && npm publish -
140
154
  Verify any JWT token and retrieve the active user profile using the SDK helper function:
141
155
 
142
156
  ```typescript
143
- import { verifyToken } from "@a-tech/auth-sdk";
157
+ import { verifyToken } from "@a-tech.jo/auth-sdk";
144
158
 
145
159
  async function validateSession(authToken: string) {
146
160
  // Verifies token and returns session status & user details
package/dist/index.js CHANGED
@@ -755,24 +755,30 @@ var SDKAuthContainer = ({
755
755
  };
756
756
 
757
757
  // src/services/auth.ts
758
- async function verifyToken(token, environment = "production") {
758
+ async function verifyToken(token, environment = "production", showLog = false) {
759
759
  const baseUrlMap = {
760
760
  local: "http://localhost:3000",
761
- stage: "https://auth.atech-workspace.com",
762
- production: "https://sso.a-tech.dev"
761
+ stage: "https://stage.auth.atech-workspace.com",
762
+ production: "https://auth.atech-workspace.com"
763
763
  // Replace with your production URL
764
764
  };
765
765
  const baseUrl = baseUrlMap[environment] || baseUrlMap.production;
766
+ if (showLog) console.log(" AUTH URL: ", baseUrl);
766
767
  try {
768
+ const headers = {
769
+ "Content-Type": "application/json",
770
+ Authorization: `Bearer ${token}`
771
+ };
772
+ const body = JSON.stringify({ token });
767
773
  const response = await fetch(`${baseUrl}/api/auth/verify`, {
768
774
  method: "POST",
769
- headers: {
770
- "Content-Type": "application/json",
771
- Authorization: `Bearer ${token}`
772
- },
775
+ headers,
773
776
  body: JSON.stringify({ token })
774
777
  });
778
+ if (showLog) console.log(" AUTH Headers: ", baseUrl);
779
+ if (showLog) console.log(" AUTH body: ", body);
775
780
  const data = await response.json();
781
+ if (showLog) console.log(" AUTH response: ", data);
776
782
  if (!response.ok) {
777
783
  return {
778
784
  valid: false,
@@ -781,6 +787,7 @@ async function verifyToken(token, environment = "production") {
781
787
  }
782
788
  return data;
783
789
  } catch (error) {
790
+ if (showLog) console.log(" AUTH catch error: ", error);
784
791
  return {
785
792
  valid: false,
786
793
  error: error.message || "Network error while verifying token."
package/dist/index.mjs CHANGED
@@ -719,24 +719,30 @@ var SDKAuthContainer = ({
719
719
  };
720
720
 
721
721
  // src/services/auth.ts
722
- async function verifyToken(token, environment = "production") {
722
+ async function verifyToken(token, environment = "production", showLog = false) {
723
723
  const baseUrlMap = {
724
724
  local: "http://localhost:3000",
725
- stage: "https://auth.atech-workspace.com",
726
- production: "https://sso.a-tech.dev"
725
+ stage: "https://stage.auth.atech-workspace.com",
726
+ production: "https://auth.atech-workspace.com"
727
727
  // Replace with your production URL
728
728
  };
729
729
  const baseUrl = baseUrlMap[environment] || baseUrlMap.production;
730
+ if (showLog) console.log(" AUTH URL: ", baseUrl);
730
731
  try {
732
+ const headers = {
733
+ "Content-Type": "application/json",
734
+ Authorization: `Bearer ${token}`
735
+ };
736
+ const body = JSON.stringify({ token });
731
737
  const response = await fetch(`${baseUrl}/api/auth/verify`, {
732
738
  method: "POST",
733
- headers: {
734
- "Content-Type": "application/json",
735
- Authorization: `Bearer ${token}`
736
- },
739
+ headers,
737
740
  body: JSON.stringify({ token })
738
741
  });
742
+ if (showLog) console.log(" AUTH Headers: ", baseUrl);
743
+ if (showLog) console.log(" AUTH body: ", body);
739
744
  const data = await response.json();
745
+ if (showLog) console.log(" AUTH response: ", data);
740
746
  if (!response.ok) {
741
747
  return {
742
748
  valid: false,
@@ -745,6 +751,7 @@ async function verifyToken(token, environment = "production") {
745
751
  }
746
752
  return data;
747
753
  } catch (error) {
754
+ if (showLog) console.log(" AUTH catch error: ", error);
748
755
  return {
749
756
  valid: false,
750
757
  error: error.message || "Network error while verifying token."
@@ -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":"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,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.7",
3
+ "version": "1.0.9",
4
4
  "description": "A-Tech Authentication SDK for React and Next.js",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",