@@ -217,4 +217,35 @@ describe('verifyWebhook', () => {
217217 // All should be treated as missing
218218 await expect ( verifyWebhook ( mockRequest ) ) . rejects . toThrow ( 'svix-id, svix-timestamp, svix-signature' ) ;
219219 } ) ;
220+
221+ it ( 'should parse event_attributes' , async ( ) => {
222+ const clerkPayload = JSON . stringify ( {
223+ type : 'user.created' ,
224+ data : { id : 'user_123' , email : 'test@example.com' } ,
225+ event_attributes : {
226+ http_request : {
227+ client_ip : '127.0.0.1' ,
228+ user_agent : 'Mozilla/5.0 (Test)' ,
229+ } ,
230+ } ,
231+ } ) ;
232+ const svixId = 'msg_123' ;
233+ const svixTimestamp = ( Date . now ( ) / 1000 ) . toString ( ) ;
234+ const validSignature = createValidSignature ( svixId , svixTimestamp , clerkPayload ) ;
235+
236+ const mockRequest = new Request ( 'https://clerk.com/webhooks' , {
237+ method : 'POST' ,
238+ body : clerkPayload ,
239+ headers : new Headers ( {
240+ 'svix-id' : svixId ,
241+ 'svix-timestamp' : svixTimestamp ,
242+ 'svix-signature' : validSignature ,
243+ } ) ,
244+ } ) ;
245+
246+ const result = await verifyWebhook ( mockRequest , { signingSecret : mockSecret } ) ;
247+ expect ( result ) . toHaveProperty ( 'type' , 'user.created' ) ;
248+ expect ( result ) . toHaveProperty ( 'event_attributes.http_request.client_ip' , '127.0.0.1' ) ;
249+ expect ( result ) . toHaveProperty ( 'event_attributes.http_request.user_agent' , 'Mozilla/5.0 (Test)' ) ;
250+ } ) ;
220251} ) ;
0 commit comments