@baasix/types 1.0.11 → 1.0.13
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/dist/index.d.mts +13 -1
- package/dist/index.d.ts +13 -1
- package/package.json +1 -1
- package/src/auth.ts +299 -289
- package/src/schema.ts +2 -0
package/dist/index.d.mts
CHANGED
|
@@ -64,6 +64,8 @@ interface Permission {
|
|
|
64
64
|
conditions?: Record<string, unknown>;
|
|
65
65
|
defaultValues?: Record<string, unknown>;
|
|
66
66
|
relConditions?: Record<string, unknown>;
|
|
67
|
+
/** WITH CHECK filter — see PermissionData.checkConditions */
|
|
68
|
+
checkConditions?: Record<string, unknown> | null;
|
|
67
69
|
}
|
|
68
70
|
/**
|
|
69
71
|
* Permission data structure (internal to PermissionService)
|
|
@@ -73,6 +75,12 @@ interface PermissionData {
|
|
|
73
75
|
conditions: Record<string, unknown>;
|
|
74
76
|
relConditions: Record<string, unknown>;
|
|
75
77
|
defaultValues: Record<string, unknown>;
|
|
78
|
+
/**
|
|
79
|
+
* WITH CHECK (RLS-style) filter: what a written row must satisfy, enforced
|
|
80
|
+
* post-write pre-commit on both create and update. null/absent = no check.
|
|
81
|
+
* `conditions` never applies to create grants.
|
|
82
|
+
*/
|
|
83
|
+
checkConditions?: Record<string, unknown> | null;
|
|
76
84
|
}
|
|
77
85
|
/**
|
|
78
86
|
* Data for creating a new permission
|
|
@@ -85,6 +93,8 @@ interface CreatePermissionData {
|
|
|
85
93
|
conditions?: Record<string, unknown>;
|
|
86
94
|
defaultValues?: Record<string, unknown>;
|
|
87
95
|
relConditions?: Record<string, unknown>;
|
|
96
|
+
/** WITH CHECK filter — see PermissionData.checkConditions */
|
|
97
|
+
checkConditions?: Record<string, unknown> | null;
|
|
88
98
|
}
|
|
89
99
|
/**
|
|
90
100
|
* Tenant interface
|
|
@@ -246,7 +256,9 @@ interface OAuth2UserInfo {
|
|
|
246
256
|
/**
|
|
247
257
|
* Supported field types in Baasix
|
|
248
258
|
*/
|
|
249
|
-
type FieldType = "String" | "Text" | "HTML" | "Integer" | "BigInt" | "Float" | "Real" | "Double" | "Decimal" | "Boolean" | "Date" | "DateTime" | "Time" | "UUID" | "SUID" | "JSON" | "JSONB" | "Array" | "Geometry" | "Point" | "LineString" | "Polygon" | "
|
|
259
|
+
type FieldType = "String" | "Text" | "HTML" | "Integer" | "BigInt" | "Float" | "Real" | "Double" | "Decimal" | "Boolean" | "Date" | "DateTime" | "Time" | "UUID" | "SUID" | "JSON" | "JSONB" | "Array" | "Geometry" | "Point" | "LineString" | "Polygon" | "ENUM"
|
|
260
|
+
/** @deprecated Use "ENUM" — the server normalizes casing, but "ENUM" is canonical */
|
|
261
|
+
| "Enum";
|
|
250
262
|
/**
|
|
251
263
|
* Default value types supported by Baasix
|
|
252
264
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -64,6 +64,8 @@ interface Permission {
|
|
|
64
64
|
conditions?: Record<string, unknown>;
|
|
65
65
|
defaultValues?: Record<string, unknown>;
|
|
66
66
|
relConditions?: Record<string, unknown>;
|
|
67
|
+
/** WITH CHECK filter — see PermissionData.checkConditions */
|
|
68
|
+
checkConditions?: Record<string, unknown> | null;
|
|
67
69
|
}
|
|
68
70
|
/**
|
|
69
71
|
* Permission data structure (internal to PermissionService)
|
|
@@ -73,6 +75,12 @@ interface PermissionData {
|
|
|
73
75
|
conditions: Record<string, unknown>;
|
|
74
76
|
relConditions: Record<string, unknown>;
|
|
75
77
|
defaultValues: Record<string, unknown>;
|
|
78
|
+
/**
|
|
79
|
+
* WITH CHECK (RLS-style) filter: what a written row must satisfy, enforced
|
|
80
|
+
* post-write pre-commit on both create and update. null/absent = no check.
|
|
81
|
+
* `conditions` never applies to create grants.
|
|
82
|
+
*/
|
|
83
|
+
checkConditions?: Record<string, unknown> | null;
|
|
76
84
|
}
|
|
77
85
|
/**
|
|
78
86
|
* Data for creating a new permission
|
|
@@ -85,6 +93,8 @@ interface CreatePermissionData {
|
|
|
85
93
|
conditions?: Record<string, unknown>;
|
|
86
94
|
defaultValues?: Record<string, unknown>;
|
|
87
95
|
relConditions?: Record<string, unknown>;
|
|
96
|
+
/** WITH CHECK filter — see PermissionData.checkConditions */
|
|
97
|
+
checkConditions?: Record<string, unknown> | null;
|
|
88
98
|
}
|
|
89
99
|
/**
|
|
90
100
|
* Tenant interface
|
|
@@ -246,7 +256,9 @@ interface OAuth2UserInfo {
|
|
|
246
256
|
/**
|
|
247
257
|
* Supported field types in Baasix
|
|
248
258
|
*/
|
|
249
|
-
type FieldType = "String" | "Text" | "HTML" | "Integer" | "BigInt" | "Float" | "Real" | "Double" | "Decimal" | "Boolean" | "Date" | "DateTime" | "Time" | "UUID" | "SUID" | "JSON" | "JSONB" | "Array" | "Geometry" | "Point" | "LineString" | "Polygon" | "
|
|
259
|
+
type FieldType = "String" | "Text" | "HTML" | "Integer" | "BigInt" | "Float" | "Real" | "Double" | "Decimal" | "Boolean" | "Date" | "DateTime" | "Time" | "UUID" | "SUID" | "JSON" | "JSONB" | "Array" | "Geometry" | "Point" | "LineString" | "Polygon" | "ENUM"
|
|
260
|
+
/** @deprecated Use "ENUM" — the server normalizes casing, but "ENUM" is canonical */
|
|
261
|
+
| "Enum";
|
|
250
262
|
/**
|
|
251
263
|
* Default value types supported by Baasix
|
|
252
264
|
*/
|
package/package.json
CHANGED
package/src/auth.ts
CHANGED
|
@@ -1,289 +1,299 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Authentication & Authorization Types
|
|
3
|
-
* Shared across core, sdk, cli, and app packages
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// ============================================================================
|
|
7
|
-
// User Types
|
|
8
|
-
// ============================================================================
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Base user interface
|
|
12
|
-
*/
|
|
13
|
-
export interface User {
|
|
14
|
-
id: string;
|
|
15
|
-
email: string;
|
|
16
|
-
firstName?: string;
|
|
17
|
-
lastName?: string;
|
|
18
|
-
avatar?: string;
|
|
19
|
-
role?: Role;
|
|
20
|
-
role_Id?: string;
|
|
21
|
-
tenant_Id?: string;
|
|
22
|
-
status?: string;
|
|
23
|
-
createdAt?: string;
|
|
24
|
-
updatedAt?: string;
|
|
25
|
-
[key: string]: unknown;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* User with password (internal use only)
|
|
30
|
-
*/
|
|
31
|
-
export interface UserWithPassword extends User {
|
|
32
|
-
password?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* User with expanded roles and permissions
|
|
37
|
-
*/
|
|
38
|
-
export interface UserWithRolesAndPermissions {
|
|
39
|
-
id: string | number;
|
|
40
|
-
email?: string;
|
|
41
|
-
roles: string[];
|
|
42
|
-
permissions: string[];
|
|
43
|
-
tenantId?: string | number;
|
|
44
|
-
[key: string]: unknown;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// ============================================================================
|
|
48
|
-
// Role & Permission Types
|
|
49
|
-
// ============================================================================
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Role interface
|
|
53
|
-
*/
|
|
54
|
-
export interface Role {
|
|
55
|
-
id: string;
|
|
56
|
-
name: string;
|
|
57
|
-
description?: string;
|
|
58
|
-
isTenantSpecific?: boolean;
|
|
59
|
-
[key: string]: unknown;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Permission action types
|
|
64
|
-
*/
|
|
65
|
-
export type PermissionAction = "create" | "read" | "update" | "delete";
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Permission interface
|
|
69
|
-
*/
|
|
70
|
-
export interface Permission {
|
|
71
|
-
id: string;
|
|
72
|
-
role_Id: string;
|
|
73
|
-
collection: string;
|
|
74
|
-
action: PermissionAction;
|
|
75
|
-
fields?: string[] | null;
|
|
76
|
-
conditions?: Record<string, unknown>;
|
|
77
|
-
defaultValues?: Record<string, unknown>;
|
|
78
|
-
relConditions?: Record<string, unknown>;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
*
|
|
147
|
-
*/
|
|
148
|
-
export interface
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Auth state
|
|
226
|
-
*/
|
|
227
|
-
export
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
*
|
|
236
|
-
*/
|
|
237
|
-
export interface
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
//
|
|
263
|
-
//
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
*
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Authentication & Authorization Types
|
|
3
|
+
* Shared across core, sdk, cli, and app packages
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// User Types
|
|
8
|
+
// ============================================================================
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Base user interface
|
|
12
|
+
*/
|
|
13
|
+
export interface User {
|
|
14
|
+
id: string;
|
|
15
|
+
email: string;
|
|
16
|
+
firstName?: string;
|
|
17
|
+
lastName?: string;
|
|
18
|
+
avatar?: string;
|
|
19
|
+
role?: Role;
|
|
20
|
+
role_Id?: string;
|
|
21
|
+
tenant_Id?: string;
|
|
22
|
+
status?: string;
|
|
23
|
+
createdAt?: string;
|
|
24
|
+
updatedAt?: string;
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* User with password (internal use only)
|
|
30
|
+
*/
|
|
31
|
+
export interface UserWithPassword extends User {
|
|
32
|
+
password?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* User with expanded roles and permissions
|
|
37
|
+
*/
|
|
38
|
+
export interface UserWithRolesAndPermissions {
|
|
39
|
+
id: string | number;
|
|
40
|
+
email?: string;
|
|
41
|
+
roles: string[];
|
|
42
|
+
permissions: string[];
|
|
43
|
+
tenantId?: string | number;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// Role & Permission Types
|
|
49
|
+
// ============================================================================
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Role interface
|
|
53
|
+
*/
|
|
54
|
+
export interface Role {
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
isTenantSpecific?: boolean;
|
|
59
|
+
[key: string]: unknown;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Permission action types
|
|
64
|
+
*/
|
|
65
|
+
export type PermissionAction = "create" | "read" | "update" | "delete";
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Permission interface
|
|
69
|
+
*/
|
|
70
|
+
export interface Permission {
|
|
71
|
+
id: string;
|
|
72
|
+
role_Id: string;
|
|
73
|
+
collection: string;
|
|
74
|
+
action: PermissionAction;
|
|
75
|
+
fields?: string[] | null;
|
|
76
|
+
conditions?: Record<string, unknown>;
|
|
77
|
+
defaultValues?: Record<string, unknown>;
|
|
78
|
+
relConditions?: Record<string, unknown>;
|
|
79
|
+
/** WITH CHECK filter — see PermissionData.checkConditions */
|
|
80
|
+
checkConditions?: Record<string, unknown> | null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Permission data structure (internal to PermissionService)
|
|
85
|
+
*/
|
|
86
|
+
export interface PermissionData {
|
|
87
|
+
fields: string[] | null;
|
|
88
|
+
conditions: Record<string, unknown>;
|
|
89
|
+
relConditions: Record<string, unknown>;
|
|
90
|
+
defaultValues: Record<string, unknown>;
|
|
91
|
+
/**
|
|
92
|
+
* WITH CHECK (RLS-style) filter: what a written row must satisfy, enforced
|
|
93
|
+
* post-write pre-commit on both create and update. null/absent = no check.
|
|
94
|
+
* `conditions` never applies to create grants.
|
|
95
|
+
*/
|
|
96
|
+
checkConditions?: Record<string, unknown> | null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Data for creating a new permission
|
|
101
|
+
*/
|
|
102
|
+
export interface CreatePermissionData {
|
|
103
|
+
role_Id: string;
|
|
104
|
+
collection: string;
|
|
105
|
+
action: PermissionAction;
|
|
106
|
+
fields?: string[];
|
|
107
|
+
conditions?: Record<string, unknown>;
|
|
108
|
+
defaultValues?: Record<string, unknown>;
|
|
109
|
+
relConditions?: Record<string, unknown>;
|
|
110
|
+
/** WITH CHECK filter — see PermissionData.checkConditions */
|
|
111
|
+
checkConditions?: Record<string, unknown> | null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ============================================================================
|
|
115
|
+
// Tenant Types
|
|
116
|
+
// ============================================================================
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Tenant interface
|
|
120
|
+
*/
|
|
121
|
+
export interface Tenant {
|
|
122
|
+
id: string;
|
|
123
|
+
name: string;
|
|
124
|
+
[key: string]: unknown;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// ============================================================================
|
|
128
|
+
// Session & Token Types
|
|
129
|
+
// ============================================================================
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Session interface
|
|
133
|
+
*/
|
|
134
|
+
export interface Session {
|
|
135
|
+
id: string;
|
|
136
|
+
token: string;
|
|
137
|
+
user_Id: string;
|
|
138
|
+
expiresAt: Date | string;
|
|
139
|
+
ipAddress?: string;
|
|
140
|
+
userAgent?: string;
|
|
141
|
+
createdAt?: string;
|
|
142
|
+
updatedAt?: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Auth tokens
|
|
147
|
+
*/
|
|
148
|
+
export interface AuthTokens {
|
|
149
|
+
accessToken: string;
|
|
150
|
+
refreshToken?: string;
|
|
151
|
+
expiresAt?: number;
|
|
152
|
+
expiresIn?: number;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* JWT payload interface
|
|
157
|
+
*/
|
|
158
|
+
export interface JWTPayload {
|
|
159
|
+
id: string;
|
|
160
|
+
email: string;
|
|
161
|
+
role: string;
|
|
162
|
+
sessionToken: string;
|
|
163
|
+
tenant_Id?: string | number | null;
|
|
164
|
+
/** Pinned baasix_UserRole row id (assignment switching). Absent on legacy tokens. */
|
|
165
|
+
userRole_Id?: string | null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// ============================================================================
|
|
169
|
+
// Accountability Types
|
|
170
|
+
// ============================================================================
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Accountability object interface - used for permission checking
|
|
174
|
+
*/
|
|
175
|
+
export interface Accountability {
|
|
176
|
+
user?: { id: string | number; email?: string; isAdmin?: boolean; [key: string]: any };
|
|
177
|
+
role?: { id: string | number; name?: string; isTenantSpecific?: boolean } | string | number;
|
|
178
|
+
/** Full active baasix_UserRole row (assignment) — custom columns included. */
|
|
179
|
+
userRole?: Record<string, any>;
|
|
180
|
+
permissions?: any[];
|
|
181
|
+
tenant?: string | number;
|
|
182
|
+
ipaddress?: string;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ============================================================================
|
|
186
|
+
// Auth Request/Response Types
|
|
187
|
+
// ============================================================================
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Login credentials
|
|
191
|
+
*/
|
|
192
|
+
export interface LoginCredentials {
|
|
193
|
+
email: string;
|
|
194
|
+
password: string;
|
|
195
|
+
tenantId?: string;
|
|
196
|
+
/** Authentication mode: 'jwt' for token-based or 'cookie' for cookie-based auth */
|
|
197
|
+
authMode?: "jwt" | "cookie";
|
|
198
|
+
/** Authentication type for session management (e.g., 'web', 'mobile', 'default') */
|
|
199
|
+
authType?: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Registration data
|
|
204
|
+
*/
|
|
205
|
+
export interface RegisterData {
|
|
206
|
+
email: string;
|
|
207
|
+
password: string;
|
|
208
|
+
firstName?: string;
|
|
209
|
+
lastName?: string;
|
|
210
|
+
[key: string]: unknown;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Auth response
|
|
215
|
+
*/
|
|
216
|
+
export interface AuthResponse {
|
|
217
|
+
token: string;
|
|
218
|
+
refreshToken?: string;
|
|
219
|
+
user: User;
|
|
220
|
+
role?: Role;
|
|
221
|
+
expiresIn?: number;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Auth state events
|
|
226
|
+
*/
|
|
227
|
+
export type AuthStateEvent =
|
|
228
|
+
| "SIGNED_IN"
|
|
229
|
+
| "SIGNED_OUT"
|
|
230
|
+
| "TOKEN_REFRESHED"
|
|
231
|
+
| "USER_UPDATED"
|
|
232
|
+
| "TENANT_SWITCHED";
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Auth state
|
|
236
|
+
*/
|
|
237
|
+
export interface AuthState {
|
|
238
|
+
user: User | null;
|
|
239
|
+
isAuthenticated: boolean;
|
|
240
|
+
isLoading: boolean;
|
|
241
|
+
error: Error | null;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Magic link options
|
|
246
|
+
*/
|
|
247
|
+
export interface MagicLinkOptions {
|
|
248
|
+
email: string;
|
|
249
|
+
redirectUrl?: string;
|
|
250
|
+
mode?: "link" | "code";
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Password reset options
|
|
255
|
+
*/
|
|
256
|
+
export interface PasswordResetOptions {
|
|
257
|
+
email: string;
|
|
258
|
+
redirectUrl?: string;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// ============================================================================
|
|
262
|
+
// Auth Mode Types
|
|
263
|
+
// ============================================================================
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Authentication mode for the SDK/app
|
|
267
|
+
* - 'jwt': Use JWT tokens stored in the configured storage adapter (default)
|
|
268
|
+
* - 'cookie': Use HTTP-only cookies (server handles token storage)
|
|
269
|
+
*/
|
|
270
|
+
export type AuthMode = "jwt" | "cookie";
|
|
271
|
+
|
|
272
|
+
// ============================================================================
|
|
273
|
+
// OAuth Types
|
|
274
|
+
// ============================================================================
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* OAuth2 tokens
|
|
278
|
+
*/
|
|
279
|
+
export interface OAuth2Tokens {
|
|
280
|
+
accessToken: string;
|
|
281
|
+
refreshToken?: string;
|
|
282
|
+
idToken?: string;
|
|
283
|
+
expiresAt?: Date;
|
|
284
|
+
tokenType?: string;
|
|
285
|
+
scope?: string;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* OAuth2 user info
|
|
290
|
+
*/
|
|
291
|
+
export interface OAuth2UserInfo {
|
|
292
|
+
id: string;
|
|
293
|
+
email: string;
|
|
294
|
+
name?: string;
|
|
295
|
+
firstName?: string;
|
|
296
|
+
lastName?: string;
|
|
297
|
+
picture?: string;
|
|
298
|
+
[key: string]: unknown;
|
|
299
|
+
}
|