@@ -25,16 +25,17 @@ export type SignUpRuleAction = {
2525/**
2626 * A sign-up rule from the config.
2727 * Type definition for the signUpRules field in auth config.
28+ * Note: All fields except metadata are required after config defaults are applied.
2829 */
2930type SignUpRuleConfig = {
30- enabled ? : boolean ,
31- displayName ? : string ,
32- priority ? : number ,
33- condition ? : string ,
34- action ? : {
35- type ? : 'allow' | 'reject' | 'restrict' | 'log' | 'add_metadata' ,
36- message ? : string ,
37- metadata ? : Record < string , SignUpRuleMetadataEntry > ,
31+ enabled : boolean ,
32+ displayName : string | undefined ,
33+ priority : number ,
34+ condition : string | undefined ,
35+ action : {
36+ type : 'allow' | 'reject' | 'restrict' | 'log' | 'add_metadata' ,
37+ message : string | undefined ,
38+ metadata : Record < string , SignUpRuleMetadataEntry > | undefined ,
3839 } ,
3940} ;
4041
@@ -123,21 +124,21 @@ export async function evaluateSignUpRules(
123124 const sortedRuleEntries = Object . entries ( rules )
124125 . filter ( ( [ , rule ] ) => rule . enabled )
125126 . sort ( ( a , b ) => {
126- const priorityA = a [ 1 ] . priority ?? 0 ;
127- const priorityB = b [ 1 ] . priority ?? 0 ;
127+ const priorityA = a [ 1 ] . priority ;
128+ const priorityB = b [ 1 ] . priority ;
128129 if ( priorityA !== priorityB ) return priorityA - priorityB ;
129130 return stringCompare ( a [ 0 ] , b [ 0 ] ) ;
130131 } ) ;
131132
132133 // Evaluate each rule in order
133134 for ( const [ ruleId , rule ] of sortedRuleEntries ) {
134- if ( ! rule . condition || ! rule . action ) continue ;
135+ if ( ! rule . condition ) continue ;
135136
136137 try {
137138 const matches = evaluateCelExpression ( rule . condition , context ) ;
138139 if ( matches ) {
139140 const action : SignUpRuleAction = {
140- type : rule . action . type ?? 'allow' ,
141+ type : rule . action . type ,
141142 metadata : rule . action . metadata ,
142143 message : rule . action . message ,
143144 } ;
@@ -178,7 +179,8 @@ export function applySignUpRuleAction(result: SignUpRuleResult): {
178179 switch ( result . action . type ) {
179180 case 'reject' : {
180181 // Throw an error to reject the signup
181- // Don't include the custom rule message to avoid helping users evade rules
182+ // Note: We intentionally don't pass the custom message to avoid helping users evade rules
183+ // The custom message is only for internal logging/analytics purposes
182184 throw new KnownErrors . SignUpRejected ( ) ;
183185 }
184186 case 'restrict' : {
0 commit comments