@neuctra/authix 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,30 @@
1
+ interface LoginParams {
2
+ email: string;
3
+ password: string;
4
+ appId: string;
5
+ }
6
+ interface LoginOptions {
7
+ baseUrl: string;
8
+ apiKey: string;
9
+ }
10
+ export interface UserInfo {
11
+ id: string;
12
+ name: string;
13
+ email: string;
14
+ phone?: string;
15
+ address?: string;
16
+ avatarUrl?: string;
17
+ isActive?: boolean;
18
+ createdAt?: string;
19
+ token?: string;
20
+ [key: string]: any;
21
+ }
22
+ /**
23
+ * User login API (API Key required)
24
+ */
25
+ export declare const loginUser: (params: LoginParams, options: LoginOptions) => Promise<UserInfo>;
26
+ /**
27
+ * Helper to get stored user info
28
+ */
29
+ export declare const getStoredUserInfo: () => UserInfo | null;
30
+ export {};
@@ -0,0 +1,47 @@
1
+ interface SignupParams {
2
+ name: string;
3
+ email: string;
4
+ password: string;
5
+ appId: string;
6
+ phone?: string;
7
+ address?: string;
8
+ avatarUrl?: string;
9
+ isActive?: boolean;
10
+ role?: string;
11
+ }
12
+ interface SignupOptions {
13
+ baseUrl: string;
14
+ apiKey: string;
15
+ }
16
+ interface UserInfo {
17
+ id: string;
18
+ name: string;
19
+ email: string;
20
+ token: string;
21
+ appId: string;
22
+ phone?: string;
23
+ address?: string;
24
+ avatarUrl?: string;
25
+ isActive: boolean;
26
+ role: string;
27
+ adminId?: string;
28
+ createdAt: string;
29
+ [key: string]: any;
30
+ }
31
+ /**
32
+ * User signup API (API Key required)
33
+ */
34
+ export declare const signupUser: (params: SignupParams, options: SignupOptions) => Promise<UserInfo>;
35
+ /**
36
+ * Helper to get stored user info (same as login)
37
+ */
38
+ export declare const getStoredUserInfo: () => UserInfo | null;
39
+ /**
40
+ * Helper to clear stored user info
41
+ */
42
+ export declare const clearStoredUserInfo: () => void;
43
+ /**
44
+ * Helper to check if user is authenticated
45
+ */
46
+ export declare const isAuthenticated: () => boolean;
47
+ export {};
@@ -0,0 +1,5 @@
1
+ import "./index.css";
2
+ export * from "./sdk/index.js";
3
+ export * from "./react/index.js";
4
+ export * from "./vue/index.js";
5
+ export { setSdkConfig, getSdkConfig } from "./sdk/config.js";
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ interface UserButtonProps {
3
+ darkMode?: boolean;
4
+ primaryColor?: string;
5
+ onLogout: () => void;
6
+ profileUrl?: string;
7
+ }
8
+ export declare const ReactUserButton: React.FC<UserButtonProps>;
9
+ export {};
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ interface AuthFormProps {
3
+ logoUrl?: string;
4
+ title?: string;
5
+ subtitle?: string;
6
+ footerText?: string;
7
+ primaryColor?: string;
8
+ gradient?: string;
9
+ darkMode?: boolean;
10
+ signupUrl?: string;
11
+ onSuccess?: (user: any) => void;
12
+ onError?: (error: any) => void;
13
+ }
14
+ export declare const ReactUserLogin: React.FC<AuthFormProps>;
15
+ export {};
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { UserInfo } from "../api/login.js";
3
+ interface UserProfileProps {
4
+ token: string;
5
+ user?: UserInfo | null;
6
+ darkMode?: boolean;
7
+ primaryColor?: string;
8
+ }
9
+ export declare const ReactUserProfile: React.FC<UserProfileProps>;
10
+ export {};
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ interface SignupFormProps {
3
+ logoUrl?: string;
4
+ title?: string;
5
+ subtitle?: string;
6
+ footerText?: string;
7
+ primaryColor?: string;
8
+ gradient?: string;
9
+ darkMode?: boolean;
10
+ showPhone?: boolean;
11
+ showAddress?: boolean;
12
+ showAvatar?: boolean;
13
+ showRole?: boolean;
14
+ showStatus?: boolean;
15
+ loginUrl?: string;
16
+ onSuccess?: (user: any) => void;
17
+ onError?: (error: any) => void;
18
+ onClose?: () => void;
19
+ }
20
+ export declare const ReactUserSignUp: React.FC<SignupFormProps>;
21
+ export {};
@@ -0,0 +1,4 @@
1
+ export { ReactUserLogin } from "./UserLogin.js";
2
+ export { ReactUserSignUp } from "./UserSignUp.js";
3
+ export { ReactUserProfile } from "./UserProfile.js";
4
+ export { ReactUserButton } from "./UserButton.js";
@@ -0,0 +1,15 @@
1
+ interface SdkConfig {
2
+ baseUrl: string;
3
+ apiKey: string;
4
+ appId: string;
5
+ }
6
+ /**
7
+ * Set SDK configuration once
8
+ * @param config - { baseUrl, apiKey, appId }
9
+ */
10
+ export declare const setSdkConfig: (config: Partial<SdkConfig>) => void;
11
+ /**
12
+ * Get the global SDK config
13
+ */
14
+ export declare const getSdkConfig: () => SdkConfig;
15
+ export {};
@@ -0,0 +1,221 @@
1
+ /**
2
+ * SDK configuration options
3
+ */
4
+ interface NeuctraAuthixConfig {
5
+ /** Base URL of the Authix API (required) */
6
+ baseUrl: string;
7
+ /** API key for authentication */
8
+ apiKey: string;
9
+ /** App ID for scoping user operations */
10
+ appId: string;
11
+ }
12
+ /**
13
+ * Parameters for signing up a new user
14
+ */
15
+ interface SignupParams {
16
+ name: string;
17
+ email: string;
18
+ password: string;
19
+ phone?: string | null;
20
+ address?: string | null;
21
+ avatarUrl?: string | null;
22
+ isActive?: boolean;
23
+ role?: string;
24
+ adminId?: string | null;
25
+ }
26
+ /**
27
+ * Parameters for logging in a user
28
+ */
29
+ interface LoginParams {
30
+ email: string;
31
+ password: string;
32
+ appId: string;
33
+ }
34
+ /**
35
+ * Parameters for updating an existing user
36
+ */
37
+ interface UpdateUserParams {
38
+ userId: string;
39
+ name?: string;
40
+ email?: string;
41
+ password?: string;
42
+ phone?: string | null;
43
+ address?: string | null;
44
+ avatarUrl?: string | null;
45
+ isActive?: boolean;
46
+ role?: string;
47
+ appId?: string | null;
48
+ }
49
+ /**
50
+ * Parameters for changing a user password (Admin action)
51
+ */
52
+ interface ChangePasswordParams {
53
+ userId: string;
54
+ currentPassword: string;
55
+ newPassword: string;
56
+ appId?: string | null;
57
+ }
58
+ /**
59
+ * Parameters for deleting a user
60
+ */
61
+ interface DeleteUserParams {
62
+ userId: string;
63
+ appId?: string | null;
64
+ }
65
+ /**
66
+ * Parameters for fetching a user profile
67
+ */
68
+ interface GetProfileParams {
69
+ /** JWT access token */
70
+ token: string;
71
+ }
72
+ /**
73
+ * Fetch all extra data objects for a user
74
+ */
75
+ interface GetUserDataParams {
76
+ userId: string;
77
+ }
78
+ /**
79
+ * Fetch a single data object from a user's extra data
80
+ */
81
+ interface GetSingleUserDataParams {
82
+ userId: string;
83
+ dataId: string;
84
+ }
85
+ /**
86
+ * Add a new object to a user's extra data
87
+ */
88
+ interface AddUserDataParams {
89
+ userId: string;
90
+ /** The object to add */
91
+ data: Record<string, any>;
92
+ }
93
+ /**
94
+ * Update an existing object in a user's extra data
95
+ */
96
+ interface UpdateUserDataParams {
97
+ userId: string;
98
+ dataId: string;
99
+ /** Fields to update */
100
+ data: Record<string, any>;
101
+ }
102
+ /**
103
+ * Delete an object from a user's extra data
104
+ */
105
+ interface DeleteUserDataParams {
106
+ userId: string;
107
+ dataId: string;
108
+ }
109
+ /**
110
+ * Main SDK class for interacting with Neuctra Authix API
111
+ */
112
+ export declare class NeuctraAuthix {
113
+ private baseUrl;
114
+ private apiKey;
115
+ private appId;
116
+ private client;
117
+ /**
118
+ * Initialize the SDK client
119
+ * @param config configuration object with baseUrl, apiKey, and appId
120
+ */
121
+ constructor(config: NeuctraAuthixConfig);
122
+ /**
123
+ * Universal request helper with error handling
124
+ * @param method HTTP method (GET, POST, PUT, DELETE)
125
+ * @param path API endpoint path
126
+ * @param data optional request body
127
+ * @param extraHeaders optional headers
128
+ */
129
+ private request;
130
+ /**
131
+ * Register a new user
132
+ * @param params user details
133
+ */
134
+ signup(params: SignupParams): Promise<any>;
135
+ /**
136
+ * Login a user
137
+ * @param params login details
138
+ */
139
+ login(params: LoginParams): Promise<any>;
140
+ /**
141
+ * Update an existing user
142
+ * @param params fields to update
143
+ */
144
+ updateUser(params: UpdateUserParams): Promise<any>;
145
+ /**
146
+ * Change a user's password (Admin only)
147
+ * @param params requires userId, currentPassword, newPassword
148
+ */
149
+ changePassword(params: ChangePasswordParams): Promise<any>;
150
+ /**
151
+ * Delete a user
152
+ * @param params requires userId and optionally appId
153
+ */
154
+ deleteUser(params: DeleteUserParams): Promise<any>;
155
+ /**
156
+ * Get the profile of the authenticated user
157
+ * @param params requires JWT token
158
+ */
159
+ getProfile(params: GetProfileParams): Promise<any>;
160
+ /**
161
+ * Send verification OTP (requires logged-in user token)
162
+ * @param params requires token
163
+ */
164
+ sendVerifyOTP(params: {
165
+ token: string;
166
+ appId?: string;
167
+ }): Promise<any>;
168
+ /**
169
+ * Verify email with OTP (requires logged-in user token)
170
+ * @param params requires token + otp
171
+ */
172
+ verifyEmail(params: {
173
+ token: string;
174
+ otp: string;
175
+ appId?: string;
176
+ }): Promise<any>;
177
+ /**
178
+ * Forgot password (public route)
179
+ * @param params requires email
180
+ */
181
+ forgotPassword(params: {
182
+ email: string;
183
+ appId?: string;
184
+ }): Promise<any>;
185
+ /**
186
+ * Reset password (public route)
187
+ * @param params requires email, otp, newPassword
188
+ */
189
+ resetPassword(params: {
190
+ email: string;
191
+ otp: string;
192
+ newPassword: string;
193
+ appId?: string;
194
+ }): Promise<any>;
195
+ /**
196
+ * Get all data objects for a user
197
+ * @param params requires userId
198
+ */
199
+ getUserData(params: GetUserDataParams): Promise<any>;
200
+ /**
201
+ * Get a single data object for a user
202
+ * @param params requires userId and dataId
203
+ */
204
+ getSingleUserData(params: GetSingleUserDataParams): Promise<any>;
205
+ /**
206
+ * Add a new data object to a user
207
+ * @param params requires userId and data object
208
+ */
209
+ addUserData(params: AddUserDataParams): Promise<any>;
210
+ /**
211
+ * Update a data object by its id
212
+ * @param params requires userId, dataId, and updated fields
213
+ */
214
+ updateUserData(params: UpdateUserDataParams): Promise<any>;
215
+ /**
216
+ * Delete a data object by its id
217
+ * @param params requires userId and dataId
218
+ */
219
+ deleteUserData(params: DeleteUserDataParams): Promise<any>;
220
+ }
221
+ export {};
@@ -0,0 +1 @@
1
+ export { default as VueButton } from "./Button.vue";
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vite").UserConfig;
2
+ export default _default;
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@neuctra/authix",
3
+ "version": "1.0.0",
4
+ "description": "Authentication SDK and UI components library for React and Vue with TailwindCSS",
5
+ "author": "Taha Asif",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "dist/neuctra-authix.cjs.js",
9
+ "module": "dist/neuctra-authix.es.js",
10
+ "types": "dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/neuctra-authix.es.js",
14
+ "require": "./dist/neuctra-authix.cjs.js"
15
+ },
16
+ "./react": {
17
+ "import": "./dist/react/index.js",
18
+ "types": "./dist/react/index.d.ts"
19
+ },
20
+ "./vue": {
21
+ "import": "./dist/vue/index.js",
22
+ "types": "./dist/vue/index.d.ts"
23
+ },
24
+ "./sdk": {
25
+ "import": "./dist/sdk/index.js",
26
+ "types": "./dist/sdk/index.d.ts"
27
+ }
28
+ },
29
+ "files": [
30
+ "dist"
31
+ ],
32
+ "scripts": {
33
+ "dev": "vite",
34
+ "build": "vite build && tsc --emitDeclarationOnly",
35
+ "preview": "vite preview",
36
+ "clean": "rm -rf dist",
37
+ "release": "npm publish --access public"
38
+ },
39
+ "keywords": [
40
+ "ui-components",
41
+ "react",
42
+ "vue",
43
+ "tailwind",
44
+ "vite",
45
+ "library",
46
+ "authentication",
47
+ "sdk",
48
+ "jwt",
49
+ "otp"
50
+ ],
51
+ "devDependencies": {
52
+ "@tailwindcss/vite": "^4.1.13",
53
+ "@types/node": "^20.0.0",
54
+ "@types/react": "^18.2.48",
55
+ "@types/react-dom": "^18.2.18",
56
+ "@vitejs/plugin-react": "^5.0.3",
57
+ "@vitejs/plugin-vue": "^6.0.1",
58
+ "autoprefixer": "^10.4.21",
59
+ "axios": "^1.12.2",
60
+ "postcss": "^8.5.6",
61
+ "tailwindcss": "^4.1.13",
62
+ "typescript": "^5.9.2",
63
+ "vite": "^7.1.7",
64
+ "lucide-react": "^0.544.0"
65
+ },
66
+ "peerDependencies": {
67
+ "react": ">=16",
68
+ "react-dom": ">=16",
69
+ "vue": ">=3"
70
+ }
71
+ }