@appforgeapps/shieldforge-types 0.0.5

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 ADDED
@@ -0,0 +1,59 @@
1
+ # @shieldforge/types
2
+
3
+ Shared TypeScript types and interfaces for the ShieldForge authentication library.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @shieldforge/types
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import type {
15
+ User,
16
+ AuthUser,
17
+ AuthPayload,
18
+ LoginInput,
19
+ RegisterInput,
20
+ UserAccountStatus,
21
+ PasswordStrength,
22
+ ShieldForgeConfig,
23
+ } from '@shieldforge/types';
24
+ ```
25
+
26
+ ## Exported Types
27
+
28
+ ### User Types
29
+
30
+ - `User` - Complete user interface with all fields including sensitive data
31
+ - `AuthUser` - Sanitized user interface for client-side use (no passwordHash)
32
+ - `UserAccountStatus` - Enum for user account status (ACTIVE, INACTIVE, SUSPENDED, PENDING)
33
+
34
+ ### Authentication Types
35
+
36
+ - `LoginInput` - Input type for login operations
37
+ - `RegisterInput` - Input type for registration
38
+ - `UpdateProfileInput` - Input type for profile updates
39
+ - `UpdatePasswordInput` - Input type for password changes
40
+ - `AuthPayload` - Response type for auth operations (user + token)
41
+ - `JwtPayload` - JWT token payload structure
42
+
43
+ ### Configuration Types
44
+
45
+ - `ShieldForgeConfig` - Configuration for @shieldforge/core
46
+ - `AuthProviderConfig` - Configuration for @shieldforge/react
47
+ - `PasskeyConfig` - Configuration for @shieldforge/passkey
48
+ - `SmtpConfig` - SMTP configuration for email sending
49
+
50
+ ### Other Types
51
+
52
+ - `Session` - Session interface
53
+ - `PasswordStrength` - Password strength result (score + feedback)
54
+ - `PasskeyCredential` - Passkey credential interface
55
+ - `Challenge` - WebAuthn challenge interface
56
+
57
+ ## License
58
+
59
+ MIT
@@ -0,0 +1,160 @@
1
+ /**
2
+ * User account status enum
3
+ */
4
+ export declare enum UserAccountStatus {
5
+ ACTIVE = "ACTIVE",
6
+ INACTIVE = "INACTIVE",
7
+ SUSPENDED = "SUSPENDED",
8
+ PENDING = "PENDING"
9
+ }
10
+ /**
11
+ * Core User interface
12
+ */
13
+ export interface User {
14
+ id: string;
15
+ email: string;
16
+ username?: string;
17
+ name?: string;
18
+ passwordHash?: string;
19
+ accountStatus?: UserAccountStatus;
20
+ emailVerified?: boolean;
21
+ createdAt?: Date;
22
+ updatedAt?: Date;
23
+ }
24
+ /**
25
+ * Sanitized user for client-side (no sensitive fields)
26
+ */
27
+ export interface AuthUser {
28
+ id: string;
29
+ email: string;
30
+ username?: string;
31
+ name?: string;
32
+ accountStatus?: UserAccountStatus;
33
+ emailVerified?: boolean;
34
+ createdAt?: Date;
35
+ updatedAt?: Date;
36
+ }
37
+ /**
38
+ * Session interface
39
+ */
40
+ export interface Session {
41
+ userId: string;
42
+ token: string;
43
+ expiresAt: Date;
44
+ createdAt: Date;
45
+ }
46
+ /**
47
+ * Login input
48
+ */
49
+ export interface LoginInput {
50
+ email: string;
51
+ password: string;
52
+ }
53
+ /**
54
+ * Register input
55
+ */
56
+ export interface RegisterInput {
57
+ email: string;
58
+ password: string;
59
+ username?: string;
60
+ name?: string;
61
+ }
62
+ /**
63
+ * Update profile input
64
+ */
65
+ export interface UpdateProfileInput {
66
+ username?: string;
67
+ name?: string;
68
+ email?: string;
69
+ }
70
+ /**
71
+ * Update password input
72
+ */
73
+ export interface UpdatePasswordInput {
74
+ currentPassword: string;
75
+ newPassword: string;
76
+ }
77
+ /**
78
+ * Auth payload returned from authentication operations
79
+ */
80
+ export interface AuthPayload {
81
+ user: AuthUser;
82
+ token: string;
83
+ }
84
+ /**
85
+ * JWT payload structure
86
+ */
87
+ export interface JwtPayload {
88
+ userId: string;
89
+ email: string;
90
+ iat?: number;
91
+ exp?: number;
92
+ }
93
+ /**
94
+ * Password strength result
95
+ */
96
+ export interface PasswordStrength {
97
+ score: 0 | 1 | 2 | 3 | 4;
98
+ feedback: string[];
99
+ }
100
+ /**
101
+ * SMTP configuration
102
+ */
103
+ export interface SmtpConfig {
104
+ host: string;
105
+ port: number;
106
+ user: string;
107
+ pass: string;
108
+ from: string;
109
+ secure?: boolean;
110
+ }
111
+ /**
112
+ * ShieldForge core configuration
113
+ */
114
+ export interface ShieldForgeConfig {
115
+ jwtSecret: string;
116
+ jwtExpiresIn?: string;
117
+ saltRounds?: number;
118
+ smtp?: SmtpConfig;
119
+ }
120
+ /**
121
+ * Passkey service configuration
122
+ */
123
+ export interface PasskeyConfig {
124
+ rpName: string;
125
+ rpId: string;
126
+ origin: string;
127
+ challengeTTL?: number;
128
+ }
129
+ /**
130
+ * Auth provider configuration for React
131
+ */
132
+ export interface AuthProviderConfig {
133
+ storageKey?: string;
134
+ pollInterval?: number;
135
+ enableCrossTabSync?: boolean;
136
+ initialToken?: string | null;
137
+ initialUser?: AuthUser | null;
138
+ }
139
+ /**
140
+ * Passkey credential
141
+ */
142
+ export interface PasskeyCredential {
143
+ id: string;
144
+ userId: string;
145
+ credentialId: string;
146
+ publicKey: string;
147
+ counter: number;
148
+ transports?: string[];
149
+ createdAt?: Date;
150
+ }
151
+ /**
152
+ * Challenge for WebAuthn
153
+ */
154
+ export interface Challenge {
155
+ challenge: string;
156
+ userId?: string;
157
+ createdAt: Date;
158
+ expiresAt: Date;
159
+ }
160
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,iBAAiB;IAC3B,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,OAAO,YAAY;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,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AiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * User account status enum
3
+ */
4
+ export var UserAccountStatus;
5
+ (function (UserAccountStatus) {
6
+ UserAccountStatus["ACTIVE"] = "ACTIVE";
7
+ UserAccountStatus["INACTIVE"] = "INACTIVE";
8
+ UserAccountStatus["SUSPENDED"] = "SUSPENDED";
9
+ UserAccountStatus["PENDING"] = "PENDING";
10
+ })(UserAccountStatus || (UserAccountStatus = {}));
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,0CAAqB,CAAA;IACrB,4CAAuB,CAAA;IACvB,wCAAmB,CAAA;AACrB,CAAC,EALW,iBAAiB,KAAjB,iBAAiB,QAK5B"}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@appforgeapps/shieldforge-types",
3
+ "version": "0.0.5",
4
+ "description": "Shared TypeScript types for ShieldForge authentication library",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/chriscase/ShieldForge.git",
8
+ "directory": "packages/types"
9
+ },
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "main": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "files": [
16
+ "dist",
17
+ "src",
18
+ "README.md"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc",
22
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
23
+ "prepublishOnly": "npm run build"
24
+ },
25
+ "keywords": [
26
+ "typescript",
27
+ "types",
28
+ "authentication",
29
+ "shieldforge"
30
+ ],
31
+ "author": "chriscase",
32
+ "license": "MIT",
33
+ "devDependencies": {
34
+ "typescript": "^5.3.3"
35
+ }
36
+ }
package/src/index.ts ADDED
@@ -0,0 +1,175 @@
1
+ /**
2
+ * User account status enum
3
+ */
4
+ export enum UserAccountStatus {
5
+ ACTIVE = 'ACTIVE',
6
+ INACTIVE = 'INACTIVE',
7
+ SUSPENDED = 'SUSPENDED',
8
+ PENDING = 'PENDING'
9
+ }
10
+
11
+ /**
12
+ * Core User interface
13
+ */
14
+ export interface User {
15
+ id: string;
16
+ email: string;
17
+ username?: string;
18
+ name?: string;
19
+ passwordHash?: string;
20
+ accountStatus?: UserAccountStatus;
21
+ emailVerified?: boolean;
22
+ createdAt?: Date;
23
+ updatedAt?: Date;
24
+ }
25
+
26
+ /**
27
+ * Sanitized user for client-side (no sensitive fields)
28
+ */
29
+ export interface AuthUser {
30
+ id: string;
31
+ email: string;
32
+ username?: string;
33
+ name?: string;
34
+ accountStatus?: UserAccountStatus;
35
+ emailVerified?: boolean;
36
+ createdAt?: Date;
37
+ updatedAt?: Date;
38
+ }
39
+
40
+ /**
41
+ * Session interface
42
+ */
43
+ export interface Session {
44
+ userId: string;
45
+ token: string;
46
+ expiresAt: Date;
47
+ createdAt: Date;
48
+ }
49
+
50
+ /**
51
+ * Login input
52
+ */
53
+ export interface LoginInput {
54
+ email: string;
55
+ password: string;
56
+ }
57
+
58
+ /**
59
+ * Register input
60
+ */
61
+ export interface RegisterInput {
62
+ email: string;
63
+ password: string;
64
+ username?: string;
65
+ name?: string;
66
+ }
67
+
68
+ /**
69
+ * Update profile input
70
+ */
71
+ export interface UpdateProfileInput {
72
+ username?: string;
73
+ name?: string;
74
+ email?: string;
75
+ }
76
+
77
+ /**
78
+ * Update password input
79
+ */
80
+ export interface UpdatePasswordInput {
81
+ currentPassword: string;
82
+ newPassword: string;
83
+ }
84
+
85
+ /**
86
+ * Auth payload returned from authentication operations
87
+ */
88
+ export interface AuthPayload {
89
+ user: AuthUser;
90
+ token: string;
91
+ }
92
+
93
+ /**
94
+ * JWT payload structure
95
+ */
96
+ export interface JwtPayload {
97
+ userId: string;
98
+ email: string;
99
+ iat?: number;
100
+ exp?: number;
101
+ }
102
+
103
+ /**
104
+ * Password strength result
105
+ */
106
+ export interface PasswordStrength {
107
+ score: 0 | 1 | 2 | 3 | 4;
108
+ feedback: string[];
109
+ }
110
+
111
+ /**
112
+ * SMTP configuration
113
+ */
114
+ export interface SmtpConfig {
115
+ host: string;
116
+ port: number;
117
+ user: string;
118
+ pass: string;
119
+ from: string;
120
+ secure?: boolean;
121
+ }
122
+
123
+ /**
124
+ * ShieldForge core configuration
125
+ */
126
+ export interface ShieldForgeConfig {
127
+ jwtSecret: string;
128
+ jwtExpiresIn?: string;
129
+ saltRounds?: number;
130
+ smtp?: SmtpConfig;
131
+ }
132
+
133
+ /**
134
+ * Passkey service configuration
135
+ */
136
+ export interface PasskeyConfig {
137
+ rpName: string;
138
+ rpId: string;
139
+ origin: string;
140
+ challengeTTL?: number;
141
+ }
142
+
143
+ /**
144
+ * Auth provider configuration for React
145
+ */
146
+ export interface AuthProviderConfig {
147
+ storageKey?: string;
148
+ pollInterval?: number;
149
+ enableCrossTabSync?: boolean;
150
+ initialToken?: string | null;
151
+ initialUser?: AuthUser | null;
152
+ }
153
+
154
+ /**
155
+ * Passkey credential
156
+ */
157
+ export interface PasskeyCredential {
158
+ id: string;
159
+ userId: string;
160
+ credentialId: string;
161
+ publicKey: string;
162
+ counter: number;
163
+ transports?: string[];
164
+ createdAt?: Date;
165
+ }
166
+
167
+ /**
168
+ * Challenge for WebAuthn
169
+ */
170
+ export interface Challenge {
171
+ challenge: string;
172
+ userId?: string;
173
+ createdAt: Date;
174
+ expiresAt: Date;
175
+ }