@@ -4,45 +4,50 @@ type ClerkError<T> = {
4
4
clerk_error : T ;
5
5
} ;
6
6
7
- type ReverificationMismatchError < M extends { metadata ?: any } = { metadata : unknown } > = ClerkError <
7
+ const REVERIFICATION_REASON = 'reverification-error' ;
8
+
9
+ type ReverificationError < M extends { metadata ?: any } = { metadata : unknown } > = ClerkError <
8
10
{
9
11
type : 'forbidden' ;
10
- reason : 'reverification-mismatch' ;
12
+ reason : typeof REVERIFICATION_REASON ;
11
13
} & M
12
14
> ;
13
15
14
- const __experimental_reverificationMismatch = < MC extends __experimental_ReverificationConfig > ( missingConfig ?: MC ) =>
15
- ( {
16
- clerk_error : {
17
- type : 'forbidden' ,
18
- reason : 'reverification-mismatch' ,
19
- metadata : {
20
- reverification : missingConfig ,
21
- } ,
16
+ const __experimental_reverificationError = < MC extends __experimental_ReverificationConfig > (
17
+ missingConfig ?: MC ,
18
+ ) : ReverificationError < {
19
+ metadata : {
20
+ reverification ?: MC ;
21
+ } ;
22
+ } > => ( {
23
+ clerk_error : {
24
+ type : 'forbidden' ,
25
+ reason : REVERIFICATION_REASON ,
26
+ metadata : {
27
+ reverification : missingConfig ,
22
28
} ,
23
- } ) satisfies ReverificationMismatchError ;
29
+ } ,
30
+ } ) ;
24
31
25
- const __experimental_reverificationMismatchResponse = (
26
- ...args : Parameters < typeof __experimental_reverificationMismatch >
27
- ) =>
28
- new Response ( JSON . stringify ( __experimental_reverificationMismatch ( ...args ) ) , {
32
+ const __experimental_reverificationErrorResponse = ( ...args : Parameters < typeof __experimental_reverificationError > ) =>
33
+ new Response ( JSON . stringify ( __experimental_reverificationError ( ...args ) ) , {
29
34
status : 403 ,
30
35
} ) ;
31
36
32
37
const __experimental_isReverificationHint = (
33
38
result : any ,
34
- ) : result is ReturnType < typeof __experimental_reverificationMismatch > => {
39
+ ) : result is ReturnType < typeof __experimental_reverificationError > => {
35
40
return (
36
41
result &&
37
42
typeof result === 'object' &&
38
43
'clerk_error' in result &&
39
44
result . clerk_error ?. type === 'forbidden' &&
40
- result . clerk_error ?. reason === 'reverification-mismatch'
45
+ result . clerk_error ?. reason === REVERIFICATION_REASON
41
46
) ;
42
47
} ;
43
48
44
49
export {
45
- __experimental_reverificationMismatch ,
46
- __experimental_reverificationMismatchResponse ,
50
+ __experimental_reverificationError ,
51
+ __experimental_reverificationErrorResponse ,
47
52
__experimental_isReverificationHint ,
48
53
} ;
0 commit comments