@a-tech.jo/auth-sdk 1.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.
@@ -0,0 +1,246 @@
1
+ /* src/styles.css */
2
+ :root {
3
+ --atech-primary: #7c3aed;
4
+ --atech-navy: #0f172a;
5
+ --atech-pink: #ec4899;
6
+ --atech-bg: #ffffff;
7
+ }
8
+ .atech-card {
9
+ width: 100%;
10
+ max-width: 28rem;
11
+ margin-left: auto;
12
+ margin-right: auto;
13
+ padding: 2rem;
14
+ border-radius: 1rem;
15
+ background-color: var(--atech-bg);
16
+ border: 1px solid #f1f5f9;
17
+ box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
18
+ box-sizing: border-box;
19
+ font-family:
20
+ system-ui,
21
+ -apple-system,
22
+ BlinkMacSystemFont,
23
+ "Segoe UI",
24
+ Roboto,
25
+ sans-serif;
26
+ }
27
+ .atech-header {
28
+ display: flex;
29
+ justify-content: center;
30
+ margin-bottom: 1rem;
31
+ }
32
+ .atech-logo {
33
+ height: 3rem;
34
+ width: auto;
35
+ object-fit: contain;
36
+ }
37
+ .atech-title {
38
+ font-size: 1.5rem;
39
+ font-weight: 700;
40
+ text-align: center;
41
+ margin-bottom: 1.5rem;
42
+ margin-top: 0;
43
+ letter-spacing: -0.025em;
44
+ color: var(--atech-navy);
45
+ }
46
+ .atech-error {
47
+ margin-bottom: 1rem;
48
+ padding: 0.75rem;
49
+ font-size: 0.75rem;
50
+ font-weight: 500;
51
+ color: #b91c1c;
52
+ background-color: #fef2f2;
53
+ border: 1px solid #fee2e2;
54
+ border-radius: 0.75rem;
55
+ }
56
+ .atech-form {
57
+ display: flex;
58
+ flex-direction: column;
59
+ gap: 1rem;
60
+ }
61
+ .atech-field {
62
+ display: flex;
63
+ flex-direction: column;
64
+ }
65
+ .atech-label {
66
+ display: block;
67
+ font-size: 0.75rem;
68
+ font-weight: 600;
69
+ color: #334155;
70
+ margin-bottom: 0.375rem;
71
+ }
72
+ .atech-input {
73
+ width: 100%;
74
+ padding: 0.625rem 0.875rem;
75
+ font-size: 0.875rem;
76
+ background-color: #f8fafc;
77
+ border: 1px solid #e2e8f0;
78
+ border-radius: 0.75rem;
79
+ font-weight: 400;
80
+ color: #0f172a;
81
+ box-sizing: border-box;
82
+ outline: none;
83
+ transition: all 0.2s ease;
84
+ }
85
+ .atech-input::placeholder {
86
+ color: #94a3b8;
87
+ }
88
+ .atech-input:hover {
89
+ border-color: #cbd5e1;
90
+ }
91
+ .atech-input:focus {
92
+ background-color: #ffffff;
93
+ border-color: var(--atech-primary);
94
+ box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
95
+ }
96
+ .atech-button {
97
+ width: 100%;
98
+ padding: 0.625rem 1rem;
99
+ font-size: 0.875rem;
100
+ font-weight: 600;
101
+ color: #ffffff;
102
+ background-color: var(--atech-primary);
103
+ border: none;
104
+ border-radius: 0.75rem;
105
+ cursor: pointer;
106
+ display: flex;
107
+ align-items: center;
108
+ justify-content: center;
109
+ gap: 0.5rem;
110
+ transition: opacity 0.2s ease;
111
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
112
+ }
113
+ .atech-button:hover:not(:disabled) {
114
+ opacity: 0.9;
115
+ }
116
+ .atech-button:disabled {
117
+ opacity: 0.5;
118
+ cursor: not-allowed;
119
+ }
120
+ .atech-footer {
121
+ margin-top: 1.5rem;
122
+ display: flex;
123
+ align-items: center;
124
+ justify-content: space-between;
125
+ font-size: 0.75rem;
126
+ font-weight: 600;
127
+ }
128
+ .atech-link {
129
+ background: none;
130
+ border: none;
131
+ padding: 0;
132
+ font: inherit;
133
+ cursor: pointer;
134
+ color: var(--atech-pink);
135
+ transition: text-decoration 0.2s ease;
136
+ }
137
+ .atech-link:hover {
138
+ text-decoration: underline;
139
+ }
140
+ .atech-spinner {
141
+ animation: atech-spin 1s linear infinite;
142
+ height: 1rem;
143
+ width: 1rem;
144
+ }
145
+ @keyframes atech-spin {
146
+ from {
147
+ transform: rotate(0deg);
148
+ }
149
+ to {
150
+ transform: rotate(360deg);
151
+ }
152
+ }
153
+ .atech-auth-wrapper {
154
+ display: flex;
155
+ flex-direction: column;
156
+ align-items: center;
157
+ width: 100%;
158
+ }
159
+ .atech-sso-badge {
160
+ display: inline-flex;
161
+ align-items: center;
162
+ gap: 0.5rem;
163
+ margin-bottom: 1rem;
164
+ padding: 0.375rem 0.875rem;
165
+ background-color: #f8fafc;
166
+ border: 1px solid #e2e8f0;
167
+ border-radius: 9999px;
168
+ font-size: 0.75rem;
169
+ font-weight: 600;
170
+ color: var(--atech-navy, #0f172a);
171
+ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
172
+ }
173
+ .atech-sso-pulse {
174
+ width: 0.5rem;
175
+ height: 0.5rem;
176
+ border-radius: 9999px;
177
+ background-color: var(--atech-primary, #7c3aed);
178
+ box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.4);
179
+ animation: atech-pulse 2s infinite;
180
+ }
181
+ @keyframes atech-pulse {
182
+ 0% {
183
+ box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.4);
184
+ }
185
+ 70% {
186
+ box-shadow: 0 0 0 6px rgba(124, 58, 237, 0);
187
+ }
188
+ 100% {
189
+ box-shadow: 0 0 0 0 rgba(124, 58, 237, 0);
190
+ }
191
+ }
192
+ .atech-country-trigger {
193
+ padding: 0.5rem 0.75rem;
194
+ font-size: 0.875rem;
195
+ background-color: #f8fafc;
196
+ border: 1px solid #cbd5e1;
197
+ border-radius: 0.375rem;
198
+ color: var(--atech-navy, #0f172a);
199
+ display: flex;
200
+ align-items: center;
201
+ gap: 0.375rem;
202
+ cursor: pointer;
203
+ transition: all 0.2s ease;
204
+ white-space: nowrap;
205
+ }
206
+ .atech-country-trigger:hover {
207
+ background-color: #f1f5f9;
208
+ }
209
+ .atech-country-popover {
210
+ position: absolute;
211
+ top: 100%;
212
+ left: 0;
213
+ margin-top: 0.25rem;
214
+ width: 280px;
215
+ background-color: #ffffff;
216
+ border: 1px solid #e2e8f0;
217
+ border-radius: 0.5rem;
218
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
219
+ padding: 0.5rem;
220
+ z-index: 50;
221
+ }
222
+ .atech-country-list {
223
+ max-height: 180px;
224
+ overflow-y: auto;
225
+ display: flex;
226
+ flex-direction: column;
227
+ gap: 0.125rem;
228
+ }
229
+ .atech-country-option {
230
+ width: 100%;
231
+ display: flex;
232
+ align-items: center;
233
+ justify-content: space-between;
234
+ padding: 0.375rem 0.5rem;
235
+ font-size: 0.75rem;
236
+ color: #334155;
237
+ background: transparent;
238
+ border: none;
239
+ border-radius: 0.25rem;
240
+ cursor: pointer;
241
+ transition: background-color 0.15s ease;
242
+ }
243
+ .atech-country-option:hover {
244
+ background-color: #f1f5f9;
245
+ color: var(--atech-primary, #7c3aed);
246
+ }
@@ -0,0 +1,102 @@
1
+ export type AuthEnvironment = "production" | "stage" | "local";
2
+ export interface EndpointConfig {
3
+ login: string;
4
+ register: string;
5
+ forgotPassword: string;
6
+ resetPassword: string;
7
+ refreshToken: string;
8
+ me: string;
9
+ }
10
+ export interface StorageKeys {
11
+ accessToken: string;
12
+ refreshToken: string;
13
+ }
14
+ export interface BrandConfig {
15
+ logoUrl?: string;
16
+ companyName?: string;
17
+ }
18
+ export interface SDKOptions {
19
+ /**
20
+ * Target environment preset
21
+ * @default 'production'
22
+ */
23
+ environment?: AuthEnvironment;
24
+ /**
25
+ * Custom Base URL override. If provided, takes top precedence over environment defaults.
26
+ */
27
+ customBaseUrl?: string;
28
+ /**
29
+ * Override specific environment base URLs
30
+ */
31
+ environmentUrls?: Partial<Record<AuthEnvironment, string>>;
32
+ /**
33
+ * Customizable API endpoint routes
34
+ */
35
+ endpoints?: Partial<EndpointConfig>;
36
+ /**
37
+ * Custom localStorage key names for JWT tokens
38
+ */
39
+ storageKeys?: Partial<StorageKeys>;
40
+ /**
41
+ * Brand assets and company details for UI components
42
+ */
43
+ brand?: BrandConfig;
44
+ /**
45
+ * Global callbacks
46
+ */
47
+ onSuccess?: (data: any) => void;
48
+ onError?: (error: Error) => void;
49
+ }
50
+ export type AuthConfig = SDKOptions;
51
+ export interface LoginPayload {
52
+ email?: string;
53
+ password?: string;
54
+ }
55
+ export interface RegisterPayload {
56
+ firstName?: string;
57
+ lastName?: string;
58
+ email?: string;
59
+ phoneNumber?: string;
60
+ password?: string;
61
+ }
62
+ export interface ForgotPasswordPayload {
63
+ email: string;
64
+ }
65
+ export interface ResetPasswordPayload {
66
+ email: string;
67
+ resetCode: string;
68
+ newPassword?: string;
69
+ }
70
+ export interface AuthResponse {
71
+ success: boolean;
72
+ token?: string;
73
+ refreshToken?: string;
74
+ user?: any;
75
+ message?: string;
76
+ error?: string;
77
+ }
78
+ export interface ThemeConfig {
79
+ /** Primary button and focus highlight color */
80
+ primary?: string;
81
+ /** Text and heading color */
82
+ navy?: string;
83
+ /** Accent link color */
84
+ pink?: string;
85
+ /** Form card background color */
86
+ bg?: string;
87
+ }
88
+ export interface SDKOptions {
89
+ environment?: AuthEnvironment;
90
+ customBaseUrl?: string;
91
+ environmentUrls?: Partial<Record<AuthEnvironment, string>>;
92
+ endpoints?: Partial<EndpointConfig>;
93
+ storageKeys?: Partial<StorageKeys>;
94
+ brand?: BrandConfig;
95
+ /**
96
+ * Define default theme colors for all SDK UI components
97
+ */
98
+ theme?: ThemeConfig;
99
+ onSuccess?: (data: any) => void;
100
+ onError?: (error: Error) => void;
101
+ }
102
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,OAAO,GAAG,OAAO,CAAC;AAE/D,MAAM,WAAW,cAAc;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,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ech.jo/auth-sdk",
3
+ "version": "1.0.0",
4
+ "description": "A-Tech Authentication SDK for React and Next.js",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "style": "./dist/styles.css",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.mjs",
19
+ "require": "./dist/index.js"
20
+ },
21
+ "./styles.css": "./dist/styles.css",
22
+ "./dist/styles.css": "./dist/styles.css"
23
+ },
24
+ "sideEffects": [
25
+ "**/*.css"
26
+ ],
27
+ "scripts": {
28
+ "build": "tsup && tsc --emitDeclarationOnly",
29
+ "dev": "tsup --watch",
30
+ "example": "npm run dev --workspace=example",
31
+ "pack": "npm pack",
32
+ "clean": "rm -rf dist node_modules/.cache *.tgz example/.next",
33
+ "prepublishOnly": "npm run clean && npm run build"
34
+ },
35
+ "peerDependencies": {
36
+ "react": ">=18.0.0",
37
+ "react-dom": ">=18.0.0"
38
+ },
39
+ "devDependencies": {
40
+ "@types/react": "^19.0.0",
41
+ "@types/react-dom": "^19.0.0",
42
+ "react": "^19.0.0",
43
+ "react-dom": "^19.0.0",
44
+ "tsup": "^8.3.0",
45
+ "typescript": "^5.0.0"
46
+ }
47
+ }