@spfn/auth 0.1.0-alpha.1 → 0.1.0-alpha.87

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 (124) hide show
  1. package/README.md +250 -0
  2. package/dist/adapters/nextjs/api.d.ts +446 -0
  3. package/dist/adapters/nextjs/api.js +3279 -0
  4. package/dist/adapters/nextjs/api.js.map +1 -0
  5. package/dist/adapters/nextjs/server.d.ts +246 -0
  6. package/dist/adapters/nextjs/server.js +3645 -0
  7. package/dist/adapters/nextjs/server.js.map +1 -0
  8. package/dist/index.d.ts +3 -46
  9. package/dist/index.js +7438 -7304
  10. package/dist/index.js.map +1 -1
  11. package/dist/lib/api/auth-codes-verify.d.ts +37 -0
  12. package/dist/lib/api/auth-codes-verify.js +2949 -0
  13. package/dist/lib/api/auth-codes-verify.js.map +1 -0
  14. package/dist/lib/api/auth-codes.d.ts +37 -0
  15. package/dist/lib/api/auth-codes.js +2949 -0
  16. package/dist/lib/api/auth-codes.js.map +1 -0
  17. package/dist/lib/api/auth-exists.d.ts +38 -0
  18. package/dist/lib/api/auth-exists.js +2949 -0
  19. package/dist/lib/api/auth-exists.js.map +1 -0
  20. package/dist/lib/api/auth-invitations-accept.d.ts +38 -0
  21. package/dist/lib/api/auth-invitations-accept.js +2883 -0
  22. package/dist/lib/api/auth-invitations-accept.js.map +1 -0
  23. package/dist/lib/api/auth-invitations-cancel.d.ts +37 -0
  24. package/dist/lib/api/auth-invitations-cancel.js +2883 -0
  25. package/dist/lib/api/auth-invitations-cancel.js.map +1 -0
  26. package/dist/lib/api/auth-invitations-delete.d.ts +36 -0
  27. package/dist/lib/api/auth-invitations-delete.js +2883 -0
  28. package/dist/lib/api/auth-invitations-delete.js.map +1 -0
  29. package/dist/lib/api/auth-invitations-resend.d.ts +37 -0
  30. package/dist/lib/api/auth-invitations-resend.js +2883 -0
  31. package/dist/lib/api/auth-invitations-resend.js.map +1 -0
  32. package/dist/lib/api/auth-invitations.d.ts +109 -0
  33. package/dist/lib/api/auth-invitations.js +2887 -0
  34. package/dist/lib/api/auth-invitations.js.map +1 -0
  35. package/dist/lib/api/auth-keys-rotate.d.ts +37 -0
  36. package/dist/lib/api/auth-keys-rotate.js +2949 -0
  37. package/dist/lib/api/auth-keys-rotate.js.map +1 -0
  38. package/dist/lib/api/auth-login.d.ts +39 -0
  39. package/dist/lib/api/auth-login.js +2949 -0
  40. package/dist/lib/api/auth-login.js.map +1 -0
  41. package/dist/lib/api/auth-logout.d.ts +36 -0
  42. package/dist/lib/api/auth-logout.js +2949 -0
  43. package/dist/lib/api/auth-logout.js.map +1 -0
  44. package/dist/lib/api/auth-me.d.ts +50 -0
  45. package/dist/lib/api/auth-me.js +2949 -0
  46. package/dist/lib/api/auth-me.js.map +1 -0
  47. package/dist/lib/api/auth-password.d.ts +36 -0
  48. package/dist/lib/api/auth-password.js +2949 -0
  49. package/dist/lib/api/auth-password.js.map +1 -0
  50. package/dist/lib/api/auth-register.d.ts +38 -0
  51. package/dist/lib/api/auth-register.js +2949 -0
  52. package/dist/lib/api/auth-register.js.map +1 -0
  53. package/dist/lib/api/index.d.ts +356 -0
  54. package/dist/lib/api/index.js +3261 -0
  55. package/dist/lib/api/index.js.map +1 -0
  56. package/dist/lib/config.d.ts +70 -0
  57. package/dist/lib/config.js +64 -0
  58. package/dist/lib/config.js.map +1 -0
  59. package/dist/lib/contracts/auth.d.ts +41 -1
  60. package/dist/lib/contracts/auth.js +28 -0
  61. package/dist/lib/contracts/auth.js.map +1 -1
  62. package/dist/lib/contracts/index.d.ts +1 -1
  63. package/dist/lib/contracts/index.js +28 -0
  64. package/dist/lib/contracts/index.js.map +1 -1
  65. package/dist/lib/crypto.d.ts +76 -0
  66. package/dist/lib/crypto.js +127 -0
  67. package/dist/lib/crypto.js.map +1 -0
  68. package/dist/lib/index.d.ts +4 -0
  69. package/dist/lib/index.js +313 -0
  70. package/dist/lib/index.js.map +1 -0
  71. package/dist/lib/session.d.ts +68 -0
  72. package/dist/lib/session.js +126 -0
  73. package/dist/lib/session.js.map +1 -0
  74. package/dist/{api-BcQM4WKb.d.ts → lib/types/api.d.ts} +2 -2
  75. package/dist/lib/types/api.js +1 -0
  76. package/dist/lib/types/api.js.map +1 -0
  77. package/dist/lib/types/index.d.ts +3 -0
  78. package/dist/lib/types/index.js +2647 -0
  79. package/dist/lib/types/index.js.map +1 -0
  80. package/dist/lib/types/schemas.d.ts +45 -0
  81. package/dist/lib/types/schemas.js +2647 -0
  82. package/dist/lib/types/schemas.js.map +1 -0
  83. package/dist/lib.d.ts +2 -0
  84. package/dist/lib.js +1 -0
  85. package/dist/lib.js.map +1 -0
  86. package/dist/plugin.js +7438 -7304
  87. package/dist/plugin.js.map +1 -1
  88. package/dist/server/entities/index.d.ts +1 -0
  89. package/dist/server/entities/index.js +23 -27
  90. package/dist/server/entities/index.js.map +1 -1
  91. package/dist/server/entities/invitations.js +12 -9
  92. package/dist/server/entities/invitations.js.map +1 -1
  93. package/dist/server/entities/permissions.js +8 -3
  94. package/dist/server/entities/permissions.js.map +1 -1
  95. package/dist/server/entities/role-permissions.js +12 -9
  96. package/dist/server/entities/role-permissions.js.map +1 -1
  97. package/dist/server/entities/roles.js +8 -3
  98. package/dist/server/entities/roles.js.map +1 -1
  99. package/dist/server/entities/schema.d.ts +14 -0
  100. package/dist/server/entities/schema.js +7 -0
  101. package/dist/server/entities/schema.js.map +1 -0
  102. package/dist/server/entities/user-permissions.js +14 -12
  103. package/dist/server/entities/user-permissions.js.map +1 -1
  104. package/dist/server/entities/user-public-keys.js +12 -9
  105. package/dist/server/entities/user-public-keys.js.map +1 -1
  106. package/dist/server/entities/user-social-accounts.js +12 -9
  107. package/dist/server/entities/user-social-accounts.js.map +1 -1
  108. package/dist/server/entities/users.js +10 -6
  109. package/dist/server/entities/users.js.map +1 -1
  110. package/dist/server/entities/verification-codes.js +8 -3
  111. package/dist/server/entities/verification-codes.js.map +1 -1
  112. package/dist/server/routes/auth/index.js +497 -512
  113. package/dist/server/routes/auth/index.js.map +1 -1
  114. package/dist/server/routes/index.js +777 -545
  115. package/dist/server/routes/index.js.map +1 -1
  116. package/dist/server/routes/invitations/index.js +416 -230
  117. package/dist/server/routes/invitations/index.js.map +1 -1
  118. package/dist/server.d.ts +91 -62
  119. package/dist/server.js +323 -327
  120. package/dist/server.js.map +1 -1
  121. package/migrations/{0000_tired_gambit.sql → 0000_familiar_firebrand.sql} +2 -0
  122. package/migrations/meta/0000_snapshot.json +4 -2
  123. package/migrations/meta/_journal.json +2 -2
  124. package/package.json +41 -7
@@ -0,0 +1,356 @@
1
+ import { DeleteInvitationBody } from './auth-invitations-delete.js';
2
+ export { DeleteInvitationResponse } from './auth-invitations-delete.js';
3
+ import { ResendInvitationBody } from './auth-invitations-resend.js';
4
+ export { ResendInvitationResponse } from './auth-invitations-resend.js';
5
+ import { CancelInvitationBody } from './auth-invitations-cancel.js';
6
+ export { CancelInvitationResponse } from './auth-invitations-cancel.js';
7
+ import { AcceptInvitationBody } from './auth-invitations-accept.js';
8
+ export { AcceptInvitationResponse } from './auth-invitations-accept.js';
9
+ import { GetInvitationParams, CreateInvitationBody, ListInvitationsQuery } from './auth-invitations.js';
10
+ export { CreateInvitationResponse, GetInvitationResponse, ListInvitationsResponse } from './auth-invitations.js';
11
+ import { GetMeBody } from './auth-me.js';
12
+ export { GetMeResponse } from './auth-me.js';
13
+ import { ChangePasswordBody } from './auth-password.js';
14
+ export { ChangePasswordResponse } from './auth-password.js';
15
+ import { RotateKeyBody } from './auth-keys-rotate.js';
16
+ export { RotateKeyResponse } from './auth-keys-rotate.js';
17
+ import { LogoutBody } from './auth-logout.js';
18
+ export { LogoutResponse } from './auth-logout.js';
19
+ import { LoginBody } from './auth-login.js';
20
+ export { LoginResponse } from './auth-login.js';
21
+ import { RegisterBody } from './auth-register.js';
22
+ export { RegisterResponse } from './auth-register.js';
23
+ import { CheckAccountExistsBody } from './auth-exists.js';
24
+ export { CheckAccountExistsResponse } from './auth-exists.js';
25
+ import { VerifyCodeBody } from './auth-codes-verify.js';
26
+ export { VerifyCodeResponse } from './auth-codes-verify.js';
27
+ import { SendVerificationCodeBody } from './auth-codes.js';
28
+ export { SendVerificationCodeResponse } from './auth-codes.js';
29
+ export { client } from '@spfn/core/client';
30
+ import '@spfn/core';
31
+ import '../contracts/invitation.js';
32
+ import '@sinclair/typebox';
33
+ import '../contracts/auth.js';
34
+
35
+ /**
36
+ * Type-safe API client
37
+ */
38
+ declare const authApi: {
39
+ readonly sendVerificationCode: (options: {
40
+ body: SendVerificationCodeBody;
41
+ }) => Promise<{
42
+ message?: string | undefined;
43
+ success: true;
44
+ data: {
45
+ success: boolean;
46
+ expiresAt: string;
47
+ };
48
+ } | {
49
+ success: false;
50
+ error: {
51
+ details?: any;
52
+ code: string;
53
+ message: string;
54
+ };
55
+ }>;
56
+ readonly verifyCode: (options: {
57
+ body: VerifyCodeBody;
58
+ }) => Promise<{
59
+ success: false;
60
+ error: {
61
+ details?: any;
62
+ code: string;
63
+ message: string;
64
+ };
65
+ } | {
66
+ message?: string | undefined;
67
+ success: true;
68
+ data: {
69
+ verificationToken?: string | undefined;
70
+ valid: boolean;
71
+ };
72
+ }>;
73
+ readonly checkAccountExists: (options: {
74
+ body: CheckAccountExistsBody;
75
+ }) => Promise<{
76
+ success: false;
77
+ error: {
78
+ details?: any;
79
+ code: string;
80
+ message: string;
81
+ };
82
+ } | {
83
+ message?: string | undefined;
84
+ success: true;
85
+ data: {
86
+ exists: boolean;
87
+ identifier: string;
88
+ identifierType: "email" | "phone";
89
+ };
90
+ }>;
91
+ readonly register: (options: {
92
+ body: RegisterBody;
93
+ }) => Promise<{
94
+ success: false;
95
+ error: {
96
+ details?: any;
97
+ code: string;
98
+ message: string;
99
+ };
100
+ } | {
101
+ message?: string | undefined;
102
+ success: true;
103
+ data: {
104
+ email?: string | undefined;
105
+ phone?: string | undefined;
106
+ userId: string;
107
+ };
108
+ }>;
109
+ readonly login: (options: {
110
+ body: LoginBody;
111
+ }) => Promise<{
112
+ success: false;
113
+ error: {
114
+ details?: any;
115
+ code: string;
116
+ message: string;
117
+ };
118
+ } | {
119
+ message?: string | undefined;
120
+ success: true;
121
+ data: {
122
+ email?: string | undefined;
123
+ phone?: string | undefined;
124
+ userId: string;
125
+ passwordChangeRequired: boolean;
126
+ };
127
+ }>;
128
+ readonly logout: (options: {
129
+ body: LogoutBody;
130
+ }) => Promise<{
131
+ success: false;
132
+ error: {
133
+ details?: any;
134
+ code: string;
135
+ message: string;
136
+ };
137
+ } | {
138
+ message?: string | undefined;
139
+ success: true;
140
+ data: {
141
+ success: boolean;
142
+ };
143
+ }>;
144
+ readonly rotateKey: (options: {
145
+ body: RotateKeyBody;
146
+ }) => Promise<{
147
+ success: false;
148
+ error: {
149
+ details?: any;
150
+ code: string;
151
+ message: string;
152
+ };
153
+ } | {
154
+ message?: string | undefined;
155
+ success: true;
156
+ data: {
157
+ success: boolean;
158
+ keyId: string;
159
+ };
160
+ }>;
161
+ readonly changePassword: (options: {
162
+ body: ChangePasswordBody;
163
+ }) => Promise<{
164
+ success: false;
165
+ error: {
166
+ details?: any;
167
+ code: string;
168
+ message: string;
169
+ };
170
+ } | {
171
+ message?: string | undefined;
172
+ success: true;
173
+ data: {
174
+ success: boolean;
175
+ };
176
+ }>;
177
+ readonly getMe: (options: {
178
+ body: GetMeBody;
179
+ }) => Promise<{
180
+ success: false;
181
+ error: {
182
+ details?: any;
183
+ code: string;
184
+ message: string;
185
+ };
186
+ } | {
187
+ message?: string | undefined;
188
+ success: true;
189
+ data: {
190
+ email?: string | undefined;
191
+ phone?: string | undefined;
192
+ userId: string;
193
+ role: {
194
+ id: number;
195
+ name: string;
196
+ displayName: string;
197
+ priority: number;
198
+ };
199
+ permissions: {
200
+ category?: string | undefined;
201
+ id: number;
202
+ name: string;
203
+ displayName: string;
204
+ }[];
205
+ };
206
+ }>;
207
+ readonly getInvitation: (options: {
208
+ params: GetInvitationParams;
209
+ }) => Promise<{
210
+ success: false;
211
+ error: {
212
+ details?: any;
213
+ code: string;
214
+ message: string;
215
+ };
216
+ } | {
217
+ message?: string | undefined;
218
+ success: true;
219
+ data: {
220
+ metadata?: any;
221
+ email: string;
222
+ expiresAt: string;
223
+ role: string;
224
+ roleDisplayName: string;
225
+ invitedBy: string;
226
+ };
227
+ }>;
228
+ readonly createInvitation: (options: {
229
+ body: CreateInvitationBody;
230
+ }) => Promise<{
231
+ success: false;
232
+ error: {
233
+ details?: any;
234
+ code: string;
235
+ message: string;
236
+ };
237
+ } | {
238
+ message?: string | undefined;
239
+ success: true;
240
+ data: {
241
+ email: string;
242
+ expiresAt: string;
243
+ id: number;
244
+ token: string;
245
+ roleId: number;
246
+ invitationUrl: string;
247
+ };
248
+ }>;
249
+ readonly listInvitations: (options: {
250
+ query?: ListInvitationsQuery;
251
+ }) => Promise<{
252
+ success: false;
253
+ error: {
254
+ details?: any;
255
+ code: string;
256
+ message: string;
257
+ };
258
+ } | {
259
+ message?: string | undefined;
260
+ success: true;
261
+ data: {
262
+ page: number;
263
+ limit: number;
264
+ invitations: {
265
+ acceptedAt?: string | undefined;
266
+ cancelledAt?: string | undefined;
267
+ email: string;
268
+ expiresAt: string;
269
+ role: {
270
+ id: number;
271
+ name: string;
272
+ displayName: string;
273
+ };
274
+ id: number;
275
+ status: string;
276
+ inviter: {
277
+ email: string;
278
+ id: number;
279
+ };
280
+ createdAt: string;
281
+ }[];
282
+ total: number;
283
+ totalPages: number;
284
+ };
285
+ }>;
286
+ readonly acceptInvitation: (options: {
287
+ body: AcceptInvitationBody;
288
+ }) => Promise<{
289
+ success: false;
290
+ error: {
291
+ details?: any;
292
+ code: string;
293
+ message: string;
294
+ };
295
+ } | {
296
+ message?: string | undefined;
297
+ success: true;
298
+ data: {
299
+ email: string;
300
+ userId: number;
301
+ role: string;
302
+ };
303
+ }>;
304
+ readonly cancelInvitation: (options: {
305
+ body: CancelInvitationBody;
306
+ }) => Promise<{
307
+ success: false;
308
+ error: {
309
+ details?: any;
310
+ code: string;
311
+ message: string;
312
+ };
313
+ } | {
314
+ message?: string | undefined;
315
+ success: true;
316
+ data: {
317
+ success: boolean;
318
+ cancelledAt: string;
319
+ };
320
+ }>;
321
+ readonly resendInvitation: (options: {
322
+ body: ResendInvitationBody;
323
+ }) => Promise<{
324
+ success: false;
325
+ error: {
326
+ details?: any;
327
+ code: string;
328
+ message: string;
329
+ };
330
+ } | {
331
+ message?: string | undefined;
332
+ success: true;
333
+ data: {
334
+ success: boolean;
335
+ expiresAt: string;
336
+ };
337
+ }>;
338
+ readonly deleteInvitation: (options: {
339
+ body: DeleteInvitationBody;
340
+ }) => Promise<{
341
+ success: false;
342
+ error: {
343
+ details?: any;
344
+ code: string;
345
+ message: string;
346
+ };
347
+ } | {
348
+ message?: string | undefined;
349
+ success: true;
350
+ data: {
351
+ success: boolean;
352
+ };
353
+ }>;
354
+ };
355
+
356
+ export { AcceptInvitationBody, CancelInvitationBody, ChangePasswordBody, CheckAccountExistsBody, CreateInvitationBody, DeleteInvitationBody, GetInvitationParams, GetMeBody, ListInvitationsQuery, LoginBody, LogoutBody, RegisterBody, ResendInvitationBody, RotateKeyBody, SendVerificationCodeBody, VerifyCodeBody, authApi };