@spfn/auth 0.1.0-alpha.0 → 0.1.0-alpha.1
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/LICENSE +21 -0
- package/README.md +70 -12
- package/dist/api-BcQM4WKb.d.ts +45 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.js +1 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +8966 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/contracts/auth.d.ts +262 -0
- package/dist/lib/contracts/auth.js +2923 -0
- package/dist/lib/contracts/auth.js.map +1 -0
- package/dist/lib/contracts/index.d.ts +3 -0
- package/dist/lib/contracts/index.js +3162 -0
- package/dist/lib/contracts/index.js.map +1 -0
- package/dist/lib/contracts/invitation.d.ts +243 -0
- package/dist/lib/contracts/invitation.js +2883 -0
- package/dist/lib/contracts/invitation.js.map +1 -0
- package/dist/plugin.d.ts +12 -0
- package/dist/plugin.js +8949 -0
- package/dist/plugin.js.map +1 -0
- package/dist/server/entities/index.d.ts +10 -0
- package/dist/server/entities/index.js +399 -0
- package/dist/server/entities/index.js.map +1 -0
- package/dist/server/entities/invitations.d.ts +241 -0
- package/dist/server/entities/invitations.js +181 -0
- package/dist/server/entities/invitations.js.map +1 -0
- package/dist/server/entities/permissions.d.ts +196 -0
- package/dist/server/entities/permissions.js +44 -0
- package/dist/server/entities/permissions.js.map +1 -0
- package/dist/server/entities/role-permissions.d.ts +107 -0
- package/dist/server/entities/role-permissions.js +112 -0
- package/dist/server/entities/role-permissions.js.map +1 -0
- package/dist/server/entities/roles.d.ts +196 -0
- package/dist/server/entities/roles.js +45 -0
- package/dist/server/entities/roles.js.map +1 -0
- package/dist/server/entities/user-permissions.d.ts +163 -0
- package/dist/server/entities/user-permissions.js +191 -0
- package/dist/server/entities/user-permissions.js.map +1 -0
- package/dist/server/entities/user-public-keys.d.ts +227 -0
- package/dist/server/entities/user-public-keys.js +153 -0
- package/dist/server/entities/user-public-keys.js.map +1 -0
- package/dist/server/entities/user-social-accounts.d.ts +189 -0
- package/dist/server/entities/user-social-accounts.js +146 -0
- package/dist/server/entities/user-social-accounts.js.map +1 -0
- package/dist/server/entities/users.d.ts +235 -0
- package/dist/server/entities/users.js +113 -0
- package/dist/server/entities/users.js.map +1 -0
- package/dist/server/entities/verification-codes.d.ts +191 -0
- package/dist/server/entities/verification-codes.js +44 -0
- package/dist/server/entities/verification-codes.js.map +1 -0
- package/dist/server/routes/auth/index.d.ts +10 -0
- package/dist/server/routes/auth/index.js +4475 -0
- package/dist/server/routes/auth/index.js.map +1 -0
- package/dist/server/routes/index.d.ts +6 -0
- package/dist/server/routes/index.js +6352 -0
- package/dist/server/routes/index.js.map +1 -0
- package/dist/server/routes/invitations/index.d.ts +10 -0
- package/dist/server/routes/invitations/index.js +4209 -0
- package/dist/server/routes/invitations/index.js.map +1 -0
- package/dist/server.d.ts +1243 -0
- package/dist/server.js +2281 -0
- package/dist/server.js.map +1 -0
- package/migrations/0000_tired_gambit.sql +165 -0
- package/migrations/meta/0000_snapshot.json +1395 -0
- package/migrations/meta/_journal.json +13 -0
- package/package.json +32 -24
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @spfn/auth - Auth API Contracts
|
|
5
|
+
*
|
|
6
|
+
* Type-safe API contracts for authentication operations
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* POST /codes - Send verification code
|
|
10
|
+
*
|
|
11
|
+
* Sends a 6-digit verification code to email or phone
|
|
12
|
+
* Final path: /_auth/codes
|
|
13
|
+
*/
|
|
14
|
+
declare const sendVerificationCodeContract: {
|
|
15
|
+
readonly method: "POST";
|
|
16
|
+
readonly path: "/_auth/codes";
|
|
17
|
+
readonly body: _sinclair_typebox.TObject<{
|
|
18
|
+
target: _sinclair_typebox.TString;
|
|
19
|
+
targetType: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"email">, _sinclair_typebox.TLiteral<"phone">]>;
|
|
20
|
+
purpose: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"registration">, _sinclair_typebox.TLiteral<"login">, _sinclair_typebox.TLiteral<"password_reset">]>;
|
|
21
|
+
}>;
|
|
22
|
+
readonly response: _sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
|
|
23
|
+
success: _sinclair_typebox.TLiteral<true>;
|
|
24
|
+
data: _sinclair_typebox.TObject<{
|
|
25
|
+
success: _sinclair_typebox.TBoolean;
|
|
26
|
+
expiresAt: _sinclair_typebox.TString;
|
|
27
|
+
}>;
|
|
28
|
+
message: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
29
|
+
}>, _sinclair_typebox.TObject<{
|
|
30
|
+
success: _sinclair_typebox.TLiteral<false>;
|
|
31
|
+
error: _sinclair_typebox.TObject<{
|
|
32
|
+
code: _sinclair_typebox.TString;
|
|
33
|
+
message: _sinclair_typebox.TString;
|
|
34
|
+
details: _sinclair_typebox.TOptional<_sinclair_typebox.TAny>;
|
|
35
|
+
}>;
|
|
36
|
+
}>]>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* POST /codes/verify - Verify code (without creating account)
|
|
40
|
+
*
|
|
41
|
+
* Validates verification code, returns a temporary token
|
|
42
|
+
* Final path: /_auth/codes/verify
|
|
43
|
+
*/
|
|
44
|
+
declare const verifyCodeContract: {
|
|
45
|
+
readonly method: "POST";
|
|
46
|
+
readonly path: "/_auth/codes/verify";
|
|
47
|
+
readonly body: _sinclair_typebox.TObject<{
|
|
48
|
+
target: _sinclair_typebox.TString;
|
|
49
|
+
targetType: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"email">, _sinclair_typebox.TLiteral<"phone">]>;
|
|
50
|
+
code: _sinclair_typebox.TString;
|
|
51
|
+
purpose: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"registration">, _sinclair_typebox.TLiteral<"login">, _sinclair_typebox.TLiteral<"password_reset">]>;
|
|
52
|
+
}>;
|
|
53
|
+
readonly response: _sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
|
|
54
|
+
success: _sinclair_typebox.TLiteral<true>;
|
|
55
|
+
data: _sinclair_typebox.TObject<{
|
|
56
|
+
valid: _sinclair_typebox.TBoolean;
|
|
57
|
+
verificationToken: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
58
|
+
}>;
|
|
59
|
+
message: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
60
|
+
}>, _sinclair_typebox.TObject<{
|
|
61
|
+
success: _sinclair_typebox.TLiteral<false>;
|
|
62
|
+
error: _sinclair_typebox.TObject<{
|
|
63
|
+
code: _sinclair_typebox.TString;
|
|
64
|
+
message: _sinclair_typebox.TString;
|
|
65
|
+
details: _sinclair_typebox.TOptional<_sinclair_typebox.TAny>;
|
|
66
|
+
}>;
|
|
67
|
+
}>]>;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* POST /exists - Check if account exists
|
|
71
|
+
*
|
|
72
|
+
* Checks if an email or phone number is already registered
|
|
73
|
+
* Final path: /_auth/exists (prefix added from package.json)
|
|
74
|
+
*/
|
|
75
|
+
declare const checkAccountExistsContract: {
|
|
76
|
+
readonly method: "POST";
|
|
77
|
+
readonly path: "/_auth/exists";
|
|
78
|
+
readonly body: _sinclair_typebox.TObject<{
|
|
79
|
+
email: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
80
|
+
phone: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
81
|
+
}>;
|
|
82
|
+
readonly response: _sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
|
|
83
|
+
success: _sinclair_typebox.TLiteral<true>;
|
|
84
|
+
data: _sinclair_typebox.TObject<{
|
|
85
|
+
exists: _sinclair_typebox.TBoolean;
|
|
86
|
+
identifier: _sinclair_typebox.TString;
|
|
87
|
+
identifierType: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"email">, _sinclair_typebox.TLiteral<"phone">]>;
|
|
88
|
+
}>;
|
|
89
|
+
message: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
90
|
+
}>, _sinclair_typebox.TObject<{
|
|
91
|
+
success: _sinclair_typebox.TLiteral<false>;
|
|
92
|
+
error: _sinclair_typebox.TObject<{
|
|
93
|
+
code: _sinclair_typebox.TString;
|
|
94
|
+
message: _sinclair_typebox.TString;
|
|
95
|
+
details: _sinclair_typebox.TOptional<_sinclair_typebox.TAny>;
|
|
96
|
+
}>;
|
|
97
|
+
}>]>;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* POST /register - Register new user
|
|
101
|
+
*
|
|
102
|
+
* Register with email/phone and password, includes public key
|
|
103
|
+
* Final path: /_auth/register (prefix added from package.json)
|
|
104
|
+
*/
|
|
105
|
+
declare const registerContract: {
|
|
106
|
+
readonly method: "POST";
|
|
107
|
+
readonly path: "/_auth/register";
|
|
108
|
+
readonly body: _sinclair_typebox.TObject<{
|
|
109
|
+
email: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
110
|
+
phone: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
111
|
+
verificationToken: _sinclair_typebox.TString;
|
|
112
|
+
password: _sinclair_typebox.TString;
|
|
113
|
+
publicKey: _sinclair_typebox.TString;
|
|
114
|
+
keyId: _sinclair_typebox.TString;
|
|
115
|
+
fingerprint: _sinclair_typebox.TString;
|
|
116
|
+
algorithm: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"ES256">, _sinclair_typebox.TLiteral<"RS256">]>;
|
|
117
|
+
keySize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
118
|
+
}>;
|
|
119
|
+
readonly response: _sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
|
|
120
|
+
success: _sinclair_typebox.TLiteral<true>;
|
|
121
|
+
data: _sinclair_typebox.TObject<{
|
|
122
|
+
userId: _sinclair_typebox.TString;
|
|
123
|
+
email: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
124
|
+
phone: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
125
|
+
}>;
|
|
126
|
+
message: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
127
|
+
}>, _sinclair_typebox.TObject<{
|
|
128
|
+
success: _sinclair_typebox.TLiteral<false>;
|
|
129
|
+
error: _sinclair_typebox.TObject<{
|
|
130
|
+
code: _sinclair_typebox.TString;
|
|
131
|
+
message: _sinclair_typebox.TString;
|
|
132
|
+
details: _sinclair_typebox.TOptional<_sinclair_typebox.TAny>;
|
|
133
|
+
}>;
|
|
134
|
+
}>]>;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* POST /login - User login
|
|
138
|
+
*
|
|
139
|
+
* Authenticate user with email/phone and password
|
|
140
|
+
* Replaces existing key with new one
|
|
141
|
+
* Final path: /_auth/login (prefix added from package.json)
|
|
142
|
+
*/
|
|
143
|
+
declare const loginContract: {
|
|
144
|
+
readonly method: "POST";
|
|
145
|
+
readonly path: "/_auth/login";
|
|
146
|
+
readonly body: _sinclair_typebox.TObject<{
|
|
147
|
+
email: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
148
|
+
phone: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
149
|
+
password: _sinclair_typebox.TString;
|
|
150
|
+
publicKey: _sinclair_typebox.TString;
|
|
151
|
+
keyId: _sinclair_typebox.TString;
|
|
152
|
+
fingerprint: _sinclair_typebox.TString;
|
|
153
|
+
oldKeyId: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
154
|
+
algorithm: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"ES256">, _sinclair_typebox.TLiteral<"RS256">]>;
|
|
155
|
+
keySize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
156
|
+
}>;
|
|
157
|
+
readonly response: _sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
|
|
158
|
+
success: _sinclair_typebox.TLiteral<true>;
|
|
159
|
+
data: _sinclair_typebox.TObject<{
|
|
160
|
+
userId: _sinclair_typebox.TString;
|
|
161
|
+
email: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
162
|
+
phone: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
163
|
+
passwordChangeRequired: _sinclair_typebox.TBoolean;
|
|
164
|
+
}>;
|
|
165
|
+
message: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
166
|
+
}>, _sinclair_typebox.TObject<{
|
|
167
|
+
success: _sinclair_typebox.TLiteral<false>;
|
|
168
|
+
error: _sinclair_typebox.TObject<{
|
|
169
|
+
code: _sinclair_typebox.TString;
|
|
170
|
+
message: _sinclair_typebox.TString;
|
|
171
|
+
details: _sinclair_typebox.TOptional<_sinclair_typebox.TAny>;
|
|
172
|
+
}>;
|
|
173
|
+
}>]>;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* POST /logout - Logout user
|
|
177
|
+
*
|
|
178
|
+
* Revokes current key (requires authentication)
|
|
179
|
+
* Final path: /_auth/logout (prefix added from package.json)
|
|
180
|
+
*/
|
|
181
|
+
declare const logoutContract: {
|
|
182
|
+
readonly method: "POST";
|
|
183
|
+
readonly path: "/_auth/logout";
|
|
184
|
+
readonly body: _sinclair_typebox.TObject<{}>;
|
|
185
|
+
readonly response: _sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
|
|
186
|
+
success: _sinclair_typebox.TLiteral<true>;
|
|
187
|
+
data: _sinclair_typebox.TObject<{
|
|
188
|
+
success: _sinclair_typebox.TBoolean;
|
|
189
|
+
}>;
|
|
190
|
+
message: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
191
|
+
}>, _sinclair_typebox.TObject<{
|
|
192
|
+
success: _sinclair_typebox.TLiteral<false>;
|
|
193
|
+
error: _sinclair_typebox.TObject<{
|
|
194
|
+
code: _sinclair_typebox.TString;
|
|
195
|
+
message: _sinclair_typebox.TString;
|
|
196
|
+
details: _sinclair_typebox.TOptional<_sinclair_typebox.TAny>;
|
|
197
|
+
}>;
|
|
198
|
+
}>]>;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* POST /keys/rotate - Rotate key
|
|
202
|
+
*
|
|
203
|
+
* Replace current key with new one (requires authentication)
|
|
204
|
+
* Final path: /_auth/keys/rotate (prefix added from package.json)
|
|
205
|
+
*/
|
|
206
|
+
declare const rotateKeyContract: {
|
|
207
|
+
readonly method: "POST";
|
|
208
|
+
readonly path: "/_auth/keys/rotate";
|
|
209
|
+
readonly body: _sinclair_typebox.TObject<{
|
|
210
|
+
publicKey: _sinclair_typebox.TString;
|
|
211
|
+
keyId: _sinclair_typebox.TString;
|
|
212
|
+
fingerprint: _sinclair_typebox.TString;
|
|
213
|
+
algorithm: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"ES256">, _sinclair_typebox.TLiteral<"RS256">]>;
|
|
214
|
+
keySize: _sinclair_typebox.TOptional<_sinclair_typebox.TNumber>;
|
|
215
|
+
}>;
|
|
216
|
+
readonly response: _sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
|
|
217
|
+
success: _sinclair_typebox.TLiteral<true>;
|
|
218
|
+
data: _sinclair_typebox.TObject<{
|
|
219
|
+
success: _sinclair_typebox.TBoolean;
|
|
220
|
+
keyId: _sinclair_typebox.TString;
|
|
221
|
+
}>;
|
|
222
|
+
message: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
223
|
+
}>, _sinclair_typebox.TObject<{
|
|
224
|
+
success: _sinclair_typebox.TLiteral<false>;
|
|
225
|
+
error: _sinclair_typebox.TObject<{
|
|
226
|
+
code: _sinclair_typebox.TString;
|
|
227
|
+
message: _sinclair_typebox.TString;
|
|
228
|
+
details: _sinclair_typebox.TOptional<_sinclair_typebox.TAny>;
|
|
229
|
+
}>;
|
|
230
|
+
}>]>;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* PUT /password - Change user password
|
|
234
|
+
*
|
|
235
|
+
* Allows authenticated users to change their password
|
|
236
|
+
* Requires current password for verification
|
|
237
|
+
* Final path: /_auth/password (prefix added from package.json)
|
|
238
|
+
*/
|
|
239
|
+
declare const changePasswordContract: {
|
|
240
|
+
readonly method: "PUT";
|
|
241
|
+
readonly path: "/_auth/password";
|
|
242
|
+
readonly body: _sinclair_typebox.TObject<{
|
|
243
|
+
currentPassword: _sinclair_typebox.TString;
|
|
244
|
+
newPassword: _sinclair_typebox.TString;
|
|
245
|
+
}>;
|
|
246
|
+
readonly response: _sinclair_typebox.TUnion<[_sinclair_typebox.TObject<{
|
|
247
|
+
success: _sinclair_typebox.TLiteral<true>;
|
|
248
|
+
data: _sinclair_typebox.TObject<{
|
|
249
|
+
success: _sinclair_typebox.TBoolean;
|
|
250
|
+
}>;
|
|
251
|
+
message: _sinclair_typebox.TOptional<_sinclair_typebox.TString>;
|
|
252
|
+
}>, _sinclair_typebox.TObject<{
|
|
253
|
+
success: _sinclair_typebox.TLiteral<false>;
|
|
254
|
+
error: _sinclair_typebox.TObject<{
|
|
255
|
+
code: _sinclair_typebox.TString;
|
|
256
|
+
message: _sinclair_typebox.TString;
|
|
257
|
+
details: _sinclair_typebox.TOptional<_sinclair_typebox.TAny>;
|
|
258
|
+
}>;
|
|
259
|
+
}>]>;
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
export { changePasswordContract, checkAccountExistsContract, loginContract, logoutContract, registerContract, rotateKeyContract, sendVerificationCodeContract, verifyCodeContract };
|