@spfn/auth 0.1.0-alpha.0 → 0.1.0-alpha.86

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.
Files changed (144) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +320 -12
  3. package/dist/adapters/nextjs/api.d.ts +446 -0
  4. package/dist/adapters/nextjs/api.js +3279 -0
  5. package/dist/adapters/nextjs/api.js.map +1 -0
  6. package/dist/adapters/nextjs/server.d.ts +246 -0
  7. package/dist/adapters/nextjs/server.js +3645 -0
  8. package/dist/adapters/nextjs/server.js.map +1 -0
  9. package/dist/client.d.ts +2 -0
  10. package/dist/client.js +1 -0
  11. package/dist/client.js.map +1 -0
  12. package/dist/index.d.ts +14 -0
  13. package/dist/index.js +9098 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/lib/api/auth-codes-verify.d.ts +37 -0
  16. package/dist/lib/api/auth-codes-verify.js +2949 -0
  17. package/dist/lib/api/auth-codes-verify.js.map +1 -0
  18. package/dist/lib/api/auth-codes.d.ts +37 -0
  19. package/dist/lib/api/auth-codes.js +2949 -0
  20. package/dist/lib/api/auth-codes.js.map +1 -0
  21. package/dist/lib/api/auth-exists.d.ts +38 -0
  22. package/dist/lib/api/auth-exists.js +2949 -0
  23. package/dist/lib/api/auth-exists.js.map +1 -0
  24. package/dist/lib/api/auth-invitations-accept.d.ts +38 -0
  25. package/dist/lib/api/auth-invitations-accept.js +2883 -0
  26. package/dist/lib/api/auth-invitations-accept.js.map +1 -0
  27. package/dist/lib/api/auth-invitations-cancel.d.ts +37 -0
  28. package/dist/lib/api/auth-invitations-cancel.js +2883 -0
  29. package/dist/lib/api/auth-invitations-cancel.js.map +1 -0
  30. package/dist/lib/api/auth-invitations-delete.d.ts +36 -0
  31. package/dist/lib/api/auth-invitations-delete.js +2883 -0
  32. package/dist/lib/api/auth-invitations-delete.js.map +1 -0
  33. package/dist/lib/api/auth-invitations-resend.d.ts +37 -0
  34. package/dist/lib/api/auth-invitations-resend.js +2883 -0
  35. package/dist/lib/api/auth-invitations-resend.js.map +1 -0
  36. package/dist/lib/api/auth-invitations.d.ts +109 -0
  37. package/dist/lib/api/auth-invitations.js +2887 -0
  38. package/dist/lib/api/auth-invitations.js.map +1 -0
  39. package/dist/lib/api/auth-keys-rotate.d.ts +37 -0
  40. package/dist/lib/api/auth-keys-rotate.js +2949 -0
  41. package/dist/lib/api/auth-keys-rotate.js.map +1 -0
  42. package/dist/lib/api/auth-login.d.ts +39 -0
  43. package/dist/lib/api/auth-login.js +2949 -0
  44. package/dist/lib/api/auth-login.js.map +1 -0
  45. package/dist/lib/api/auth-logout.d.ts +36 -0
  46. package/dist/lib/api/auth-logout.js +2949 -0
  47. package/dist/lib/api/auth-logout.js.map +1 -0
  48. package/dist/lib/api/auth-me.d.ts +50 -0
  49. package/dist/lib/api/auth-me.js +2949 -0
  50. package/dist/lib/api/auth-me.js.map +1 -0
  51. package/dist/lib/api/auth-password.d.ts +36 -0
  52. package/dist/lib/api/auth-password.js +2949 -0
  53. package/dist/lib/api/auth-password.js.map +1 -0
  54. package/dist/lib/api/auth-register.d.ts +38 -0
  55. package/dist/lib/api/auth-register.js +2949 -0
  56. package/dist/lib/api/auth-register.js.map +1 -0
  57. package/dist/lib/api/index.d.ts +356 -0
  58. package/dist/lib/api/index.js +3261 -0
  59. package/dist/lib/api/index.js.map +1 -0
  60. package/dist/lib/config.d.ts +70 -0
  61. package/dist/lib/config.js +64 -0
  62. package/dist/lib/config.js.map +1 -0
  63. package/dist/lib/contracts/auth.d.ts +302 -0
  64. package/dist/lib/contracts/auth.js +2951 -0
  65. package/dist/lib/contracts/auth.js.map +1 -0
  66. package/dist/lib/contracts/index.d.ts +3 -0
  67. package/dist/lib/contracts/index.js +3190 -0
  68. package/dist/lib/contracts/index.js.map +1 -0
  69. package/dist/lib/contracts/invitation.d.ts +243 -0
  70. package/dist/lib/contracts/invitation.js +2883 -0
  71. package/dist/lib/contracts/invitation.js.map +1 -0
  72. package/dist/lib/crypto.d.ts +76 -0
  73. package/dist/lib/crypto.js +127 -0
  74. package/dist/lib/crypto.js.map +1 -0
  75. package/dist/lib/index.d.ts +4 -0
  76. package/dist/lib/index.js +313 -0
  77. package/dist/lib/index.js.map +1 -0
  78. package/dist/lib/session.d.ts +68 -0
  79. package/dist/lib/session.js +126 -0
  80. package/dist/lib/session.js.map +1 -0
  81. package/dist/lib/types/api.d.ts +45 -0
  82. package/dist/lib/types/api.js +1 -0
  83. package/dist/lib/types/api.js.map +1 -0
  84. package/dist/lib/types/index.d.ts +3 -0
  85. package/dist/lib/types/index.js +2647 -0
  86. package/dist/lib/types/index.js.map +1 -0
  87. package/dist/lib/types/schemas.d.ts +45 -0
  88. package/dist/lib/types/schemas.js +2647 -0
  89. package/dist/lib/types/schemas.js.map +1 -0
  90. package/dist/lib.d.ts +2 -0
  91. package/dist/lib.js +1 -0
  92. package/dist/lib.js.map +1 -0
  93. package/dist/plugin.d.ts +12 -0
  94. package/dist/plugin.js +9081 -0
  95. package/dist/plugin.js.map +1 -0
  96. package/dist/server/entities/index.d.ts +11 -0
  97. package/dist/server/entities/index.js +395 -0
  98. package/dist/server/entities/index.js.map +1 -0
  99. package/dist/server/entities/invitations.d.ts +241 -0
  100. package/dist/server/entities/invitations.js +184 -0
  101. package/dist/server/entities/invitations.js.map +1 -0
  102. package/dist/server/entities/permissions.d.ts +196 -0
  103. package/dist/server/entities/permissions.js +49 -0
  104. package/dist/server/entities/permissions.js.map +1 -0
  105. package/dist/server/entities/role-permissions.d.ts +107 -0
  106. package/dist/server/entities/role-permissions.js +115 -0
  107. package/dist/server/entities/role-permissions.js.map +1 -0
  108. package/dist/server/entities/roles.d.ts +196 -0
  109. package/dist/server/entities/roles.js +50 -0
  110. package/dist/server/entities/roles.js.map +1 -0
  111. package/dist/server/entities/schema.d.ts +14 -0
  112. package/dist/server/entities/schema.js +7 -0
  113. package/dist/server/entities/schema.js.map +1 -0
  114. package/dist/server/entities/user-permissions.d.ts +163 -0
  115. package/dist/server/entities/user-permissions.js +193 -0
  116. package/dist/server/entities/user-permissions.js.map +1 -0
  117. package/dist/server/entities/user-public-keys.d.ts +227 -0
  118. package/dist/server/entities/user-public-keys.js +156 -0
  119. package/dist/server/entities/user-public-keys.js.map +1 -0
  120. package/dist/server/entities/user-social-accounts.d.ts +189 -0
  121. package/dist/server/entities/user-social-accounts.js +149 -0
  122. package/dist/server/entities/user-social-accounts.js.map +1 -0
  123. package/dist/server/entities/users.d.ts +235 -0
  124. package/dist/server/entities/users.js +117 -0
  125. package/dist/server/entities/users.js.map +1 -0
  126. package/dist/server/entities/verification-codes.d.ts +191 -0
  127. package/dist/server/entities/verification-codes.js +49 -0
  128. package/dist/server/entities/verification-codes.js.map +1 -0
  129. package/dist/server/routes/auth/index.d.ts +10 -0
  130. package/dist/server/routes/auth/index.js +4458 -0
  131. package/dist/server/routes/auth/index.js.map +1 -0
  132. package/dist/server/routes/index.d.ts +6 -0
  133. package/dist/server/routes/index.js +6582 -0
  134. package/dist/server/routes/index.js.map +1 -0
  135. package/dist/server/routes/invitations/index.d.ts +10 -0
  136. package/dist/server/routes/invitations/index.js +4395 -0
  137. package/dist/server/routes/invitations/index.js.map +1 -0
  138. package/dist/server.d.ts +1272 -0
  139. package/dist/server.js +2274 -0
  140. package/dist/server.js.map +1 -0
  141. package/migrations/0000_complex_swordsman.sql +167 -0
  142. package/migrations/meta/0000_snapshot.json +1397 -0
  143. package/migrations/meta/_journal.json +13 -0
  144. package/package.json +59 -24
@@ -0,0 +1,446 @@
1
+ import { DeleteInvitationBody } from '../../lib/api/auth-invitations-delete.js';
2
+ export { DeleteInvitationResponse } from '../../lib/api/auth-invitations-delete.js';
3
+ import { ResendInvitationBody } from '../../lib/api/auth-invitations-resend.js';
4
+ export { ResendInvitationResponse } from '../../lib/api/auth-invitations-resend.js';
5
+ import { CancelInvitationBody } from '../../lib/api/auth-invitations-cancel.js';
6
+ export { CancelInvitationResponse } from '../../lib/api/auth-invitations-cancel.js';
7
+ import { AcceptInvitationBody } from '../../lib/api/auth-invitations-accept.js';
8
+ export { AcceptInvitationResponse } from '../../lib/api/auth-invitations-accept.js';
9
+ import { GetInvitationParams, CreateInvitationBody, ListInvitationsQuery } from '../../lib/api/auth-invitations.js';
10
+ export { CreateInvitationResponse, GetInvitationResponse, ListInvitationsResponse } from '../../lib/api/auth-invitations.js';
11
+ import { GetMeBody } from '../../lib/api/auth-me.js';
12
+ import { ChangePasswordBody } from '../../lib/api/auth-password.js';
13
+ export { ChangePasswordResponse } from '../../lib/api/auth-password.js';
14
+ export { RotateKeyResponse } from '../../lib/api/auth-keys-rotate.js';
15
+ export { LogoutResponse } from '../../lib/api/auth-logout.js';
16
+ export { LoginResponse } from '../../lib/api/auth-login.js';
17
+ export { RegisterResponse } from '../../lib/api/auth-register.js';
18
+ import { CheckAccountExistsBody } from '../../lib/api/auth-exists.js';
19
+ export { CheckAccountExistsResponse } from '../../lib/api/auth-exists.js';
20
+ import { VerifyCodeBody } from '../../lib/api/auth-codes-verify.js';
21
+ export { VerifyCodeResponse } from '../../lib/api/auth-codes-verify.js';
22
+ import { SendVerificationCodeBody } from '../../lib/api/auth-codes.js';
23
+ export { SendVerificationCodeResponse } from '../../lib/api/auth-codes.js';
24
+ export { client } from '@spfn/core/client';
25
+ import '@spfn/core';
26
+ import '../../lib/contracts/invitation.js';
27
+ import '@sinclair/typebox';
28
+ import '../../lib/contracts/auth.js';
29
+
30
+ /**
31
+ * Client-side login types (without key fields)
32
+ */
33
+ type ClientLoginParams = {
34
+ body: {
35
+ email?: string;
36
+ phone?: string;
37
+ password: string;
38
+ };
39
+ };
40
+ /**
41
+ * Client-side register types (without key fields)
42
+ */
43
+ type ClientRegisterParams = {
44
+ body: {
45
+ email?: string;
46
+ phone?: string;
47
+ password: string;
48
+ verificationToken: string;
49
+ };
50
+ };
51
+ /**
52
+ * Login with email/password
53
+ *
54
+ * Interceptor automatically generates and injects publicKey fields
55
+ */
56
+ declare const login: (params: ClientLoginParams) => Promise<{
57
+ message?: string | undefined;
58
+ success: true;
59
+ data: {
60
+ email?: string | undefined;
61
+ phone?: string | undefined;
62
+ userId: string;
63
+ passwordChangeRequired: boolean;
64
+ };
65
+ } | {
66
+ success: false;
67
+ error: {
68
+ details?: any;
69
+ message: string;
70
+ code: string;
71
+ };
72
+ }>;
73
+ /**
74
+ * Register new account
75
+ *
76
+ * Interceptor automatically generates and injects publicKey fields
77
+ */
78
+ declare const register: (params: ClientRegisterParams) => Promise<{
79
+ success: false;
80
+ error: {
81
+ details?: any;
82
+ message: string;
83
+ code: string;
84
+ };
85
+ } | {
86
+ message?: string | undefined;
87
+ success: true;
88
+ data: {
89
+ email?: string | undefined;
90
+ phone?: string | undefined;
91
+ userId: string;
92
+ };
93
+ }>;
94
+ /**
95
+ * Logout current session
96
+ *
97
+ * Interceptor automatically adds JWT authentication
98
+ */
99
+ declare const logout: () => Promise<{
100
+ success: false;
101
+ error: {
102
+ details?: any;
103
+ message: string;
104
+ code: string;
105
+ };
106
+ } | {
107
+ message?: string | undefined;
108
+ success: true;
109
+ data: {
110
+ success: boolean;
111
+ };
112
+ }>;
113
+ /**
114
+ * Rotate encryption keys
115
+ *
116
+ * Interceptor automatically generates new key pair and adds JWT authentication
117
+ */
118
+ declare const rotateKey: () => Promise<{
119
+ success: false;
120
+ error: {
121
+ details?: any;
122
+ message: string;
123
+ code: string;
124
+ };
125
+ } | {
126
+ message?: string | undefined;
127
+ success: true;
128
+ data: {
129
+ success: boolean;
130
+ keyId: string;
131
+ };
132
+ }>;
133
+ /**
134
+ * Auth API collection
135
+ */
136
+ declare const authApi: {
137
+ readonly login: (params: ClientLoginParams) => Promise<{
138
+ message?: string | undefined;
139
+ success: true;
140
+ data: {
141
+ email?: string | undefined;
142
+ phone?: string | undefined;
143
+ userId: string;
144
+ passwordChangeRequired: boolean;
145
+ };
146
+ } | {
147
+ success: false;
148
+ error: {
149
+ details?: any;
150
+ message: string;
151
+ code: string;
152
+ };
153
+ }>;
154
+ readonly register: (params: ClientRegisterParams) => Promise<{
155
+ success: false;
156
+ error: {
157
+ details?: any;
158
+ message: string;
159
+ code: string;
160
+ };
161
+ } | {
162
+ message?: string | undefined;
163
+ success: true;
164
+ data: {
165
+ email?: string | undefined;
166
+ phone?: string | undefined;
167
+ userId: string;
168
+ };
169
+ }>;
170
+ readonly logout: () => Promise<{
171
+ success: false;
172
+ error: {
173
+ details?: any;
174
+ message: string;
175
+ code: string;
176
+ };
177
+ } | {
178
+ message?: string | undefined;
179
+ success: true;
180
+ data: {
181
+ success: boolean;
182
+ };
183
+ }>;
184
+ readonly rotateKey: () => Promise<{
185
+ success: false;
186
+ error: {
187
+ details?: any;
188
+ message: string;
189
+ code: string;
190
+ };
191
+ } | {
192
+ message?: string | undefined;
193
+ success: true;
194
+ data: {
195
+ success: boolean;
196
+ keyId: string;
197
+ };
198
+ }>;
199
+ readonly sendVerificationCode: (options: {
200
+ body: SendVerificationCodeBody;
201
+ }) => Promise<{
202
+ success: false;
203
+ error: {
204
+ details?: any;
205
+ message: string;
206
+ code: string;
207
+ };
208
+ } | {
209
+ message?: string | undefined;
210
+ success: true;
211
+ data: {
212
+ success: boolean;
213
+ expiresAt: string;
214
+ };
215
+ }>;
216
+ readonly verifyCode: (options: {
217
+ body: VerifyCodeBody;
218
+ }) => Promise<{
219
+ success: false;
220
+ error: {
221
+ details?: any;
222
+ message: string;
223
+ code: string;
224
+ };
225
+ } | {
226
+ message?: string | undefined;
227
+ success: true;
228
+ data: {
229
+ verificationToken?: string | undefined;
230
+ valid: boolean;
231
+ };
232
+ }>;
233
+ readonly checkAccountExists: (options: {
234
+ body: CheckAccountExistsBody;
235
+ }) => Promise<{
236
+ success: false;
237
+ error: {
238
+ details?: any;
239
+ message: string;
240
+ code: string;
241
+ };
242
+ } | {
243
+ message?: string | undefined;
244
+ success: true;
245
+ data: {
246
+ exists: boolean;
247
+ identifier: string;
248
+ identifierType: "email" | "phone";
249
+ };
250
+ }>;
251
+ readonly changePassword: (options: {
252
+ body: ChangePasswordBody;
253
+ }) => Promise<{
254
+ success: false;
255
+ error: {
256
+ details?: any;
257
+ message: string;
258
+ code: string;
259
+ };
260
+ } | {
261
+ message?: string | undefined;
262
+ success: true;
263
+ data: {
264
+ success: boolean;
265
+ };
266
+ }>;
267
+ readonly getMe: (options: {
268
+ body: GetMeBody;
269
+ }) => Promise<{
270
+ success: false;
271
+ error: {
272
+ details?: any;
273
+ message: string;
274
+ code: string;
275
+ };
276
+ } | {
277
+ message?: string | undefined;
278
+ success: true;
279
+ data: {
280
+ email?: string | undefined;
281
+ phone?: string | undefined;
282
+ userId: string;
283
+ role: {
284
+ id: number;
285
+ name: string;
286
+ displayName: string;
287
+ priority: number;
288
+ };
289
+ permissions: {
290
+ category?: string | undefined;
291
+ id: number;
292
+ name: string;
293
+ displayName: string;
294
+ }[];
295
+ };
296
+ }>;
297
+ readonly getInvitation: (options: {
298
+ params: GetInvitationParams;
299
+ }) => Promise<{
300
+ success: false;
301
+ error: {
302
+ details?: any;
303
+ message: string;
304
+ code: string;
305
+ };
306
+ } | {
307
+ message?: string | undefined;
308
+ success: true;
309
+ data: {
310
+ metadata?: any;
311
+ email: string;
312
+ expiresAt: string;
313
+ role: string;
314
+ roleDisplayName: string;
315
+ invitedBy: string;
316
+ };
317
+ }>;
318
+ readonly createInvitation: (options: {
319
+ body: CreateInvitationBody;
320
+ }) => Promise<{
321
+ success: false;
322
+ error: {
323
+ details?: any;
324
+ message: string;
325
+ code: string;
326
+ };
327
+ } | {
328
+ message?: string | undefined;
329
+ success: true;
330
+ data: {
331
+ email: string;
332
+ expiresAt: string;
333
+ id: number;
334
+ token: string;
335
+ roleId: number;
336
+ invitationUrl: string;
337
+ };
338
+ }>;
339
+ readonly listInvitations: (options: {
340
+ query?: ListInvitationsQuery;
341
+ }) => Promise<{
342
+ success: false;
343
+ error: {
344
+ details?: any;
345
+ message: string;
346
+ code: string;
347
+ };
348
+ } | {
349
+ message?: string | undefined;
350
+ success: true;
351
+ data: {
352
+ page: number;
353
+ limit: number;
354
+ invitations: {
355
+ acceptedAt?: string | undefined;
356
+ cancelledAt?: string | undefined;
357
+ email: string;
358
+ expiresAt: string;
359
+ role: {
360
+ id: number;
361
+ name: string;
362
+ displayName: string;
363
+ };
364
+ id: number;
365
+ status: string;
366
+ inviter: {
367
+ email: string;
368
+ id: number;
369
+ };
370
+ createdAt: string;
371
+ }[];
372
+ total: number;
373
+ totalPages: number;
374
+ };
375
+ }>;
376
+ readonly acceptInvitation: (options: {
377
+ body: AcceptInvitationBody;
378
+ }) => Promise<{
379
+ success: false;
380
+ error: {
381
+ details?: any;
382
+ message: string;
383
+ code: string;
384
+ };
385
+ } | {
386
+ message?: string | undefined;
387
+ success: true;
388
+ data: {
389
+ email: string;
390
+ userId: number;
391
+ role: string;
392
+ };
393
+ }>;
394
+ readonly cancelInvitation: (options: {
395
+ body: CancelInvitationBody;
396
+ }) => Promise<{
397
+ success: false;
398
+ error: {
399
+ details?: any;
400
+ message: string;
401
+ code: string;
402
+ };
403
+ } | {
404
+ message?: string | undefined;
405
+ success: true;
406
+ data: {
407
+ success: boolean;
408
+ cancelledAt: string;
409
+ };
410
+ }>;
411
+ readonly resendInvitation: (options: {
412
+ body: ResendInvitationBody;
413
+ }) => Promise<{
414
+ success: false;
415
+ error: {
416
+ details?: any;
417
+ message: string;
418
+ code: string;
419
+ };
420
+ } | {
421
+ message?: string | undefined;
422
+ success: true;
423
+ data: {
424
+ success: boolean;
425
+ expiresAt: string;
426
+ };
427
+ }>;
428
+ readonly deleteInvitation: (options: {
429
+ body: DeleteInvitationBody;
430
+ }) => Promise<{
431
+ success: false;
432
+ error: {
433
+ details?: any;
434
+ message: string;
435
+ code: string;
436
+ };
437
+ } | {
438
+ message?: string | undefined;
439
+ success: true;
440
+ data: {
441
+ success: boolean;
442
+ };
443
+ }>;
444
+ };
445
+
446
+ export { AcceptInvitationBody, CancelInvitationBody, ChangePasswordBody, CheckAccountExistsBody, type ClientLoginParams, type ClientRegisterParams, CreateInvitationBody, DeleteInvitationBody, GetInvitationParams, ListInvitationsQuery, ResendInvitationBody, SendVerificationCodeBody, VerifyCodeBody, authApi, login, logout, register, rotateKey };