@classic-homes/auth 0.1.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,197 @@
1
+ /**
2
+ * Auth Types
3
+ *
4
+ * Type definitions for authentication-related data structures.
5
+ */
6
+ interface User {
7
+ id: string;
8
+ username: string;
9
+ email: string;
10
+ firstName?: string;
11
+ lastName?: string;
12
+ phone?: string;
13
+ role: string;
14
+ roles?: string[];
15
+ permissions: string[];
16
+ isActive: boolean;
17
+ emailVerified: boolean;
18
+ authMethod?: 'password' | 'oauth' | 'both';
19
+ ssoProfileUrl?: string;
20
+ createdAt: string;
21
+ lastLoginAt?: string;
22
+ }
23
+ interface AuthState {
24
+ accessToken: string | null;
25
+ refreshToken: string | null;
26
+ user: User | null;
27
+ isAuthenticated: boolean;
28
+ }
29
+ interface LoginCredentials {
30
+ username: string;
31
+ password: string;
32
+ }
33
+ interface LoginResponse {
34
+ accessToken: string;
35
+ refreshToken: string;
36
+ sessionToken?: string;
37
+ user: User;
38
+ expiresIn: number;
39
+ requiresMFA?: boolean;
40
+ mfaToken?: string;
41
+ /** @deprecated Use requiresMFA */
42
+ mfaRequired?: boolean;
43
+ /** @deprecated Use mfaToken */
44
+ mfaChallengeToken?: string;
45
+ availableMethods?: string[];
46
+ }
47
+ interface RegisterData {
48
+ username: string;
49
+ email: string;
50
+ password: string;
51
+ }
52
+ interface RegisterResponse {
53
+ message: string;
54
+ user: User;
55
+ requiresEmailVerification?: boolean;
56
+ }
57
+ interface Session {
58
+ id: string;
59
+ deviceName: string;
60
+ browser: string;
61
+ location: string;
62
+ ipAddress: string;
63
+ lastActivity: string;
64
+ isCurrent: boolean;
65
+ isTrusted: boolean;
66
+ deviceFingerprint: string;
67
+ trustedDeviceId?: string;
68
+ createdAt: string;
69
+ expiresAt: string;
70
+ }
71
+ interface ApiKey {
72
+ id: string;
73
+ name: string;
74
+ description?: string;
75
+ keyPreview: string;
76
+ permissions: string[];
77
+ role: string | null;
78
+ isActive: boolean;
79
+ expiresAt: string | null;
80
+ lastUsedAt: string | null;
81
+ createdAt: string;
82
+ usageCount?: number;
83
+ }
84
+ interface CreateApiKeyRequest {
85
+ name: string;
86
+ description?: string;
87
+ permissions?: string[];
88
+ role?: string;
89
+ expiresAt?: string | null;
90
+ }
91
+ interface CreateApiKeyResponse extends ApiKey {
92
+ /** The full API key - only returned once on creation */
93
+ key: string;
94
+ }
95
+ interface MFASetupResponse {
96
+ qrCodeUrl: string;
97
+ manualEntryKey: string;
98
+ backupCodes: string[];
99
+ instructions: {
100
+ step1: string;
101
+ step2: string;
102
+ step3: string;
103
+ step4: string;
104
+ };
105
+ }
106
+ interface MFAStatus {
107
+ enabled: boolean;
108
+ methods: string[];
109
+ }
110
+ interface MFAChallengeData {
111
+ mfaToken: string;
112
+ code: string;
113
+ method?: 'totp' | 'email' | 'backup';
114
+ trustDevice?: boolean;
115
+ }
116
+ interface Device {
117
+ id: string;
118
+ deviceFingerprint: string;
119
+ deviceName: string;
120
+ userAgent?: string | null;
121
+ ipAddress?: string | null;
122
+ trusted: boolean;
123
+ status: 'active' | 'revoked';
124
+ lastSeen?: string | null;
125
+ createdAt: string;
126
+ }
127
+ interface UserPreferences {
128
+ emailNotifications: boolean;
129
+ securityAlerts: boolean;
130
+ loginNotifications: boolean;
131
+ suspiciousActivityAlerts: boolean;
132
+ passwordChangeNotifications: boolean;
133
+ mfaChangeNotifications: boolean;
134
+ accountUpdates: boolean;
135
+ systemMaintenance: boolean;
136
+ featureAnnouncements: boolean;
137
+ newsAndUpdates: boolean;
138
+ apiKeyExpiration: boolean;
139
+ apiUsageAlerts: boolean;
140
+ rateLimit: boolean;
141
+ dataExportReady: boolean;
142
+ reportGeneration: boolean;
143
+ theme: 'light' | 'dark' | 'system';
144
+ language: string;
145
+ timezone: string;
146
+ dateFormat: string;
147
+ timeFormat: '12h' | '24h';
148
+ advancedSettings?: Record<string, unknown>;
149
+ lastUpdated?: string;
150
+ }
151
+ interface LinkedAccount {
152
+ id: string;
153
+ provider: string;
154
+ providerAccountId: string;
155
+ providerEmail?: string | null;
156
+ providerUsername?: string | null;
157
+ providerAvatarUrl?: string | null;
158
+ isPrimary: boolean;
159
+ isVerified: boolean;
160
+ createdAt: string;
161
+ lastUsedAt?: string | null;
162
+ }
163
+ interface SecurityEvent {
164
+ id: string;
165
+ eventType: string;
166
+ /** @deprecated Use eventType */
167
+ type?: string;
168
+ description: string;
169
+ severity: 'low' | 'medium' | 'high';
170
+ ipAddress?: string;
171
+ userAgent?: string;
172
+ location?: string;
173
+ metadata?: Record<string, unknown>;
174
+ createdAt: string;
175
+ }
176
+ interface Pagination {
177
+ page: number;
178
+ limit: number;
179
+ total: number;
180
+ totalPages: number;
181
+ }
182
+ interface ProfileUpdateData {
183
+ firstName?: string;
184
+ lastName?: string;
185
+ email?: string;
186
+ phone?: string;
187
+ }
188
+ interface ChangePasswordData {
189
+ currentPassword: string;
190
+ newPassword: string;
191
+ }
192
+ interface ResetPasswordData {
193
+ token: string;
194
+ newPassword: string;
195
+ }
196
+
197
+ export type { AuthState as A, CreateApiKeyRequest as C, Device as D, LoginCredentials as L, MFASetupResponse as M, Pagination as P, RegisterData as R, Session as S, User as U, LoginResponse as a, RegisterResponse as b, ApiKey as c, CreateApiKeyResponse as d, MFAStatus as e, MFAChallengeData as f, UserPreferences as g, LinkedAccount as h, SecurityEvent as i, ProfileUpdateData as j, ChangePasswordData as k, ResetPasswordData as l };
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@classic-homes/auth",
3
+ "version": "0.1.0",
4
+ "description": "Authentication services and Svelte bindings for Classic Theme apps",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./core": {
15
+ "types": "./dist/core/index.d.ts",
16
+ "import": "./dist/core/index.js"
17
+ },
18
+ "./svelte": {
19
+ "types": "./dist/svelte/index.d.ts",
20
+ "import": "./dist/svelte/index.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsup",
28
+ "dev": "tsup --watch",
29
+ "clean": "rm -rf dist",
30
+ "typecheck": "tsc --noEmit"
31
+ },
32
+ "keywords": [
33
+ "authentication",
34
+ "auth",
35
+ "svelte",
36
+ "classic-theme"
37
+ ],
38
+ "license": "MIT",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/Classic-Homes/classic-theme.git",
42
+ "directory": "packages/auth"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "peerDependencies": {
48
+ "svelte": "^5.0.0"
49
+ },
50
+ "peerDependenciesMeta": {
51
+ "svelte": {
52
+ "optional": true
53
+ }
54
+ },
55
+ "devDependencies": {
56
+ "svelte": "^5.0.0",
57
+ "tsup": "^8.0.0",
58
+ "typescript": "^5.3.0"
59
+ }
60
+ }