@rebasepro/types 0.9.1-canary.26fe4b2 → 0.9.1-canary.29ed165
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.
|
@@ -201,6 +201,26 @@ export interface UserCreationPrepareResult {
|
|
|
201
201
|
/** Whether an invitation was sent (only relevant when hookHandledEmail is true). */
|
|
202
202
|
invitationSent: boolean;
|
|
203
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* What a create body for an auth collection may name beyond the collection's
|
|
206
|
+
* own declared fields — see `AuthAdapter.describeUserCreationContract()`.
|
|
207
|
+
*
|
|
208
|
+
* @group Auth
|
|
209
|
+
*/
|
|
210
|
+
export interface UserCreationWriteContract {
|
|
211
|
+
/**
|
|
212
|
+
* Whether to check the body for fields neither the collection nor
|
|
213
|
+
* {@link extraFields} declares. `false` skips the check entirely.
|
|
214
|
+
*/
|
|
215
|
+
validate: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Credential and provider keys the adapter consumes itself, which the
|
|
218
|
+
* collection therefore does not declare as columns. `password` is the
|
|
219
|
+
* canonical one: `prepareUserCreation` hashes it into `passwordHash` and
|
|
220
|
+
* deletes it before the row is ever built.
|
|
221
|
+
*/
|
|
222
|
+
extraFields: string[];
|
|
223
|
+
}
|
|
204
224
|
/**
|
|
205
225
|
* Result of `AuthAdapter.finalizeUserCreation()`.
|
|
206
226
|
*
|
|
@@ -371,6 +391,30 @@ export interface AuthAdapter {
|
|
|
371
391
|
* @returns Processed values ready for `driver.save()`, plus metadata for the post-save step.
|
|
372
392
|
*/
|
|
373
393
|
prepareUserCreation?(values: Record<string, unknown>, collectionAuth?: unknown): Promise<UserCreationPrepareResult>;
|
|
394
|
+
/**
|
|
395
|
+
* Describe what a create body for this auth collection is allowed to name,
|
|
396
|
+
* so unknown-field validation can run on it.
|
|
397
|
+
*
|
|
398
|
+
* A signup body is not the collection's shape: it carries credential fields
|
|
399
|
+
* like `password` that the users table never declares as columns, and
|
|
400
|
+
* `prepareUserCreation` maps them onto real ones. Validating the raw body
|
|
401
|
+
* against the collection alone would reject every legitimate signup — which
|
|
402
|
+
* is why the check used to be skipped outright for auth collections. That
|
|
403
|
+
* skip was total, so an undeclared field was silently dropped and the write
|
|
404
|
+
* still returned 201, while the same typo on a normal collection was a 400.
|
|
405
|
+
*
|
|
406
|
+
* This narrows the exemption to the fields the adapter actually consumes.
|
|
407
|
+
*
|
|
408
|
+
* `validate: false` disables the check for this collection, and is the right
|
|
409
|
+
* answer when a custom `onCreateUser` hook is configured: the body is then
|
|
410
|
+
* the hook's contract, not the collection's, and this layer cannot know what
|
|
411
|
+
* the hook accepts.
|
|
412
|
+
*
|
|
413
|
+
* If not implemented, validation is skipped — the pre-existing behaviour.
|
|
414
|
+
*
|
|
415
|
+
* @param collectionAuth - The parsed `AuthCollectionConfig` from the collection (if `auth` is an object).
|
|
416
|
+
*/
|
|
417
|
+
describeUserCreationContract?(collectionAuth?: unknown): UserCreationWriteContract;
|
|
374
418
|
/**
|
|
375
419
|
* Finalize a user creation after the entity has been persisted.
|
|
376
420
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebasepro/types",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.9.1-canary.
|
|
4
|
+
"version": "0.9.1-canary.29ed165",
|
|
5
5
|
"description": "Rebase type definitions — shared interfaces and controller types",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/rebaseco"
|
|
@@ -223,6 +223,27 @@ export interface UserCreationPrepareResult {
|
|
|
223
223
|
invitationSent: boolean;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
+
/**
|
|
227
|
+
* What a create body for an auth collection may name beyond the collection's
|
|
228
|
+
* own declared fields — see `AuthAdapter.describeUserCreationContract()`.
|
|
229
|
+
*
|
|
230
|
+
* @group Auth
|
|
231
|
+
*/
|
|
232
|
+
export interface UserCreationWriteContract {
|
|
233
|
+
/**
|
|
234
|
+
* Whether to check the body for fields neither the collection nor
|
|
235
|
+
* {@link extraFields} declares. `false` skips the check entirely.
|
|
236
|
+
*/
|
|
237
|
+
validate: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* Credential and provider keys the adapter consumes itself, which the
|
|
240
|
+
* collection therefore does not declare as columns. `password` is the
|
|
241
|
+
* canonical one: `prepareUserCreation` hashes it into `passwordHash` and
|
|
242
|
+
* deletes it before the row is ever built.
|
|
243
|
+
*/
|
|
244
|
+
extraFields: string[];
|
|
245
|
+
}
|
|
246
|
+
|
|
226
247
|
/**
|
|
227
248
|
* Result of `AuthAdapter.finalizeUserCreation()`.
|
|
228
249
|
*
|
|
@@ -425,6 +446,33 @@ export interface AuthAdapter {
|
|
|
425
446
|
collectionAuth?: unknown
|
|
426
447
|
): Promise<UserCreationPrepareResult>;
|
|
427
448
|
|
|
449
|
+
/**
|
|
450
|
+
* Describe what a create body for this auth collection is allowed to name,
|
|
451
|
+
* so unknown-field validation can run on it.
|
|
452
|
+
*
|
|
453
|
+
* A signup body is not the collection's shape: it carries credential fields
|
|
454
|
+
* like `password` that the users table never declares as columns, and
|
|
455
|
+
* `prepareUserCreation` maps them onto real ones. Validating the raw body
|
|
456
|
+
* against the collection alone would reject every legitimate signup — which
|
|
457
|
+
* is why the check used to be skipped outright for auth collections. That
|
|
458
|
+
* skip was total, so an undeclared field was silently dropped and the write
|
|
459
|
+
* still returned 201, while the same typo on a normal collection was a 400.
|
|
460
|
+
*
|
|
461
|
+
* This narrows the exemption to the fields the adapter actually consumes.
|
|
462
|
+
*
|
|
463
|
+
* `validate: false` disables the check for this collection, and is the right
|
|
464
|
+
* answer when a custom `onCreateUser` hook is configured: the body is then
|
|
465
|
+
* the hook's contract, not the collection's, and this layer cannot know what
|
|
466
|
+
* the hook accepts.
|
|
467
|
+
*
|
|
468
|
+
* If not implemented, validation is skipped — the pre-existing behaviour.
|
|
469
|
+
*
|
|
470
|
+
* @param collectionAuth - The parsed `AuthCollectionConfig` from the collection (if `auth` is an object).
|
|
471
|
+
*/
|
|
472
|
+
describeUserCreationContract?(
|
|
473
|
+
collectionAuth?: unknown
|
|
474
|
+
): UserCreationWriteContract;
|
|
475
|
+
|
|
428
476
|
/**
|
|
429
477
|
* Finalize a user creation after the entity has been persisted.
|
|
430
478
|
*
|