@a-tech.jo/auth-sdk 1.0.8 → 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 +24 -10
- package/dist/index.js +14 -7
- package/dist/index.mjs +14 -7
- package/dist/services/auth.d.ts +1 -1
- package/dist/services/auth.d.ts.map +1 -1
- package/dist/styles.css +2 -1
- package/package.json +1 -1
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
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
@@ -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://
|
|
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://
|
|
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."
|
package/dist/services/auth.d.ts
CHANGED
|
@@ -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,
|
|
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;
|