@authhero/cloudflare-adapter 2.8.0 → 2.10.0

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.
@@ -249,7 +249,7 @@ declare const logInsertSchema: z.ZodObject<{
249
249
  date: z.ZodString;
250
250
  description: z.ZodOptional<z.ZodString>;
251
251
  ip: z.ZodOptional<z.ZodString>;
252
- user_agent: z.ZodString;
252
+ user_agent: z.ZodOptional<z.ZodString>;
253
253
  details: z.ZodOptional<z.ZodAny>;
254
254
  isMobile: z.ZodBoolean;
255
255
  user_id: z.ZodOptional<z.ZodString>;
@@ -259,7 +259,7 @@ declare const logInsertSchema: z.ZodObject<{
259
259
  client_id: z.ZodOptional<z.ZodString>;
260
260
  client_name: z.ZodOptional<z.ZodString>;
261
261
  audience: z.ZodOptional<z.ZodString>;
262
- scope: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
262
+ scope: z.ZodOptional<z.ZodString>;
263
263
  strategy: z.ZodOptional<z.ZodString>;
264
264
  strategy_type: z.ZodOptional<z.ZodString>;
265
265
  hostname: z.ZodOptional<z.ZodString>;
@@ -287,20 +287,48 @@ declare const logInsertSchema: z.ZodObject<{
287
287
  } | undefined;
288
288
  }>>;
289
289
  log_id: z.ZodOptional<z.ZodString>;
290
+ location_info: z.ZodOptional<z.ZodObject<{
291
+ country_code: z.ZodString;
292
+ country_code3: z.ZodString;
293
+ country_name: z.ZodString;
294
+ city_name: z.ZodString;
295
+ latitude: z.ZodString;
296
+ longitude: z.ZodString;
297
+ time_zone: z.ZodString;
298
+ continent_code: z.ZodString;
299
+ }, "strip", z.ZodTypeAny, {
300
+ country_code: string;
301
+ country_code3: string;
302
+ country_name: string;
303
+ city_name: string;
304
+ latitude: string;
305
+ longitude: string;
306
+ time_zone: string;
307
+ continent_code: string;
308
+ }, {
309
+ country_code: string;
310
+ country_code3: string;
311
+ country_name: string;
312
+ city_name: string;
313
+ latitude: string;
314
+ longitude: string;
315
+ time_zone: string;
316
+ continent_code: string;
317
+ }>>;
290
318
  }, "strip", z.ZodTypeAny, {
291
319
  type: "acls_summary" | "actions_execution_failed" | "api_limit" | "api_limit_warning" | "appi" | "ciba_exchange_failed" | "ciba_exchange_succeeded" | "ciba_start_failed" | "ciba_start_succeeded" | "cls" | "cs" | "depnote" | "f" | "fc" | "fce" | "fco" | "fcoa" | "fcp" | "fcph" | "fcpn" | "fcpr" | "fcpro" | "fcu" | "fd" | "fdeac" | "fdeaz" | "fdecc" | "fdu" | "feacft" | "feccft" | "fecte" | "fede" | "federated_logout_failed" | "fens" | "feoobft" | "feotpft" | "fepft" | "fepotpft" | "fercft" | "ferrt" | "fertft" | "fh" | "fi" | "flo" | "flows_execution_completed" | "flows_execution_failed" | "fn" | "forms_submission_failed" | "forms_submission_succeeded" | "fp" | "fpar" | "fpurh" | "fs" | "fsa" | "fu" | "fui" | "fv" | "fvr" | "gd_auth_email_verification" | "gd_auth_fail_email_verification" | "gd_auth_failed" | "gd_auth_rejected" | "gd_auth_succeed" | "gd_enrollment_complete" | "gd_otp_rate_limit_exceed" | "gd_recovery_failed" | "gd_recovery_rate_limit_exceed" | "gd_recovery_succeed" | "gd_send_email" | "gd_send_email_verification" | "gd_send_email_verification_failure" | "gd_send_pn" | "gd_send_pn_failure" | "gd_send_sms" | "gd_send_sms_failure" | "gd_send_voice" | "gd_send_voice_failure" | "gd_start_auth" | "gd_start_enroll" | "gd_start_enroll_failed" | "gd_tenant_update" | "gd_unenroll" | "gd_update_device_account" | "gd_webauthn_challenge_failed" | "gd_webauthn_enrollment_failed" | "kms_key_management_failure" | "kms_key_management_success" | "kms_key_state_changed" | "limit_delegation" | "limit_mu" | "limit_sul" | "limit_wc" | "mfar" | "mgmt_api_read" | "my_account_authentication_method_failed" | "my_account_authentication_method_succeeded" | "oidc_backchannel_logout_failed" | "oidc_backchannel_logout_succeeded" | "organization_member_added" | "passkey_challenge_failed" | "passkey_challenge_started" | "pla" | "pwd_leak" | "reset_pwd_leak" | "resource_cleanup" | "rich_consents_access_error" | "s" | "sapi" | "sce" | "scoa" | "scp" | "scpn" | "scpr" | "scu" | "scv" | "sd" | "sdu" | "seacft" | "seccft" | "secte" | "sede" | "sens" | "seoobft" | "seotpft" | "sepft" | "sepkoobft" | "sepkotpft" | "sepkrcft" | "sercft" | "sertft" | "si" | "signup_pwd_leak" | "slo" | "srrt" | "ss" | "ss_sso_failure" | "ss_sso_info" | "ss_sso_success" | "ssa" | "sscim" | "sui" | "sv" | "svr" | "too_many_records" | "ublkdu" | "universal_logout_failed" | "universal_logout_succeeded" | "w" | "wn" | "wum";
292
320
  date: string;
293
- user_agent: string;
294
321
  isMobile: boolean;
295
322
  description?: string | undefined;
296
323
  connection?: string | undefined;
297
324
  user_id?: string | undefined;
298
325
  client_id?: string | undefined;
299
326
  audience?: string | undefined;
300
- scope?: string[] | undefined;
327
+ scope?: string | undefined;
301
328
  strategy?: string | undefined;
302
329
  connection_id?: string | undefined;
303
330
  ip?: string | undefined;
331
+ user_agent?: string | undefined;
304
332
  details?: any;
305
333
  user_name?: string | undefined;
306
334
  client_name?: string | undefined;
@@ -314,20 +342,30 @@ declare const logInsertSchema: z.ZodObject<{
314
342
  } | undefined;
315
343
  } | undefined;
316
344
  log_id?: string | undefined;
345
+ location_info?: {
346
+ country_code: string;
347
+ country_code3: string;
348
+ country_name: string;
349
+ city_name: string;
350
+ latitude: string;
351
+ longitude: string;
352
+ time_zone: string;
353
+ continent_code: string;
354
+ } | undefined;
317
355
  }, {
318
356
  type: string;
319
357
  date: string;
320
- user_agent: string;
321
358
  isMobile: boolean;
322
359
  description?: string | undefined;
323
360
  connection?: string | undefined;
324
361
  user_id?: string | undefined;
325
362
  client_id?: string | undefined;
326
363
  audience?: string | undefined;
327
- scope?: string[] | undefined;
364
+ scope?: string | undefined;
328
365
  strategy?: string | undefined;
329
366
  connection_id?: string | undefined;
330
367
  ip?: string | undefined;
368
+ user_agent?: string | undefined;
331
369
  details?: any;
332
370
  user_name?: string | undefined;
333
371
  client_name?: string | undefined;
@@ -341,6 +379,16 @@ declare const logInsertSchema: z.ZodObject<{
341
379
  } | undefined;
342
380
  } | undefined;
343
381
  log_id?: string | undefined;
382
+ location_info?: {
383
+ country_code: string;
384
+ country_code3: string;
385
+ country_name: string;
386
+ city_name: string;
387
+ latitude: string;
388
+ longitude: string;
389
+ time_zone: string;
390
+ continent_code: string;
391
+ } | undefined;
344
392
  }>;
345
393
  export type LogInsert = z.infer<typeof logInsertSchema>;
346
394
  declare const logSchema: z.ZodObject<{
@@ -349,7 +397,7 @@ declare const logSchema: z.ZodObject<{
349
397
  date: z.ZodString;
350
398
  description: z.ZodOptional<z.ZodString>;
351
399
  ip: z.ZodOptional<z.ZodString>;
352
- user_agent: z.ZodString;
400
+ user_agent: z.ZodOptional<z.ZodString>;
353
401
  details: z.ZodOptional<z.ZodAny>;
354
402
  isMobile: z.ZodBoolean;
355
403
  user_id: z.ZodOptional<z.ZodString>;
@@ -359,7 +407,7 @@ declare const logSchema: z.ZodObject<{
359
407
  client_id: z.ZodOptional<z.ZodString>;
360
408
  client_name: z.ZodOptional<z.ZodString>;
361
409
  audience: z.ZodOptional<z.ZodString>;
362
- scope: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
410
+ scope: z.ZodOptional<z.ZodString>;
363
411
  strategy: z.ZodOptional<z.ZodString>;
364
412
  strategy_type: z.ZodOptional<z.ZodString>;
365
413
  hostname: z.ZodOptional<z.ZodString>;
@@ -386,10 +434,37 @@ declare const logSchema: z.ZodObject<{
386
434
  node?: string | undefined;
387
435
  } | undefined;
388
436
  }>>;
437
+ location_info: z.ZodOptional<z.ZodObject<{
438
+ country_code: z.ZodString;
439
+ country_code3: z.ZodString;
440
+ country_name: z.ZodString;
441
+ city_name: z.ZodString;
442
+ latitude: z.ZodString;
443
+ longitude: z.ZodString;
444
+ time_zone: z.ZodString;
445
+ continent_code: z.ZodString;
446
+ }, "strip", z.ZodTypeAny, {
447
+ country_code: string;
448
+ country_code3: string;
449
+ country_name: string;
450
+ city_name: string;
451
+ latitude: string;
452
+ longitude: string;
453
+ time_zone: string;
454
+ continent_code: string;
455
+ }, {
456
+ country_code: string;
457
+ country_code3: string;
458
+ country_name: string;
459
+ city_name: string;
460
+ latitude: string;
461
+ longitude: string;
462
+ time_zone: string;
463
+ continent_code: string;
464
+ }>>;
389
465
  }, "strip", z.ZodTypeAny, {
390
466
  type: "acls_summary" | "actions_execution_failed" | "api_limit" | "api_limit_warning" | "appi" | "ciba_exchange_failed" | "ciba_exchange_succeeded" | "ciba_start_failed" | "ciba_start_succeeded" | "cls" | "cs" | "depnote" | "f" | "fc" | "fce" | "fco" | "fcoa" | "fcp" | "fcph" | "fcpn" | "fcpr" | "fcpro" | "fcu" | "fd" | "fdeac" | "fdeaz" | "fdecc" | "fdu" | "feacft" | "feccft" | "fecte" | "fede" | "federated_logout_failed" | "fens" | "feoobft" | "feotpft" | "fepft" | "fepotpft" | "fercft" | "ferrt" | "fertft" | "fh" | "fi" | "flo" | "flows_execution_completed" | "flows_execution_failed" | "fn" | "forms_submission_failed" | "forms_submission_succeeded" | "fp" | "fpar" | "fpurh" | "fs" | "fsa" | "fu" | "fui" | "fv" | "fvr" | "gd_auth_email_verification" | "gd_auth_fail_email_verification" | "gd_auth_failed" | "gd_auth_rejected" | "gd_auth_succeed" | "gd_enrollment_complete" | "gd_otp_rate_limit_exceed" | "gd_recovery_failed" | "gd_recovery_rate_limit_exceed" | "gd_recovery_succeed" | "gd_send_email" | "gd_send_email_verification" | "gd_send_email_verification_failure" | "gd_send_pn" | "gd_send_pn_failure" | "gd_send_sms" | "gd_send_sms_failure" | "gd_send_voice" | "gd_send_voice_failure" | "gd_start_auth" | "gd_start_enroll" | "gd_start_enroll_failed" | "gd_tenant_update" | "gd_unenroll" | "gd_update_device_account" | "gd_webauthn_challenge_failed" | "gd_webauthn_enrollment_failed" | "kms_key_management_failure" | "kms_key_management_success" | "kms_key_state_changed" | "limit_delegation" | "limit_mu" | "limit_sul" | "limit_wc" | "mfar" | "mgmt_api_read" | "my_account_authentication_method_failed" | "my_account_authentication_method_succeeded" | "oidc_backchannel_logout_failed" | "oidc_backchannel_logout_succeeded" | "organization_member_added" | "passkey_challenge_failed" | "passkey_challenge_started" | "pla" | "pwd_leak" | "reset_pwd_leak" | "resource_cleanup" | "rich_consents_access_error" | "s" | "sapi" | "sce" | "scoa" | "scp" | "scpn" | "scpr" | "scu" | "scv" | "sd" | "sdu" | "seacft" | "seccft" | "secte" | "sede" | "sens" | "seoobft" | "seotpft" | "sepft" | "sepkoobft" | "sepkotpft" | "sepkrcft" | "sercft" | "sertft" | "si" | "signup_pwd_leak" | "slo" | "srrt" | "ss" | "ss_sso_failure" | "ss_sso_info" | "ss_sso_success" | "ssa" | "sscim" | "sui" | "sv" | "svr" | "too_many_records" | "ublkdu" | "universal_logout_failed" | "universal_logout_succeeded" | "w" | "wn" | "wum";
391
467
  date: string;
392
- user_agent: string;
393
468
  isMobile: boolean;
394
469
  log_id: string;
395
470
  description?: string | undefined;
@@ -397,10 +472,11 @@ declare const logSchema: z.ZodObject<{
397
472
  user_id?: string | undefined;
398
473
  client_id?: string | undefined;
399
474
  audience?: string | undefined;
400
- scope?: string[] | undefined;
475
+ scope?: string | undefined;
401
476
  strategy?: string | undefined;
402
477
  connection_id?: string | undefined;
403
478
  ip?: string | undefined;
479
+ user_agent?: string | undefined;
404
480
  details?: any;
405
481
  user_name?: string | undefined;
406
482
  client_name?: string | undefined;
@@ -413,10 +489,19 @@ declare const logSchema: z.ZodObject<{
413
489
  node?: string | undefined;
414
490
  } | undefined;
415
491
  } | undefined;
492
+ location_info?: {
493
+ country_code: string;
494
+ country_code3: string;
495
+ country_name: string;
496
+ city_name: string;
497
+ latitude: string;
498
+ longitude: string;
499
+ time_zone: string;
500
+ continent_code: string;
501
+ } | undefined;
416
502
  }, {
417
503
  type: string;
418
504
  date: string;
419
- user_agent: string;
420
505
  isMobile: boolean;
421
506
  log_id: string;
422
507
  description?: string | undefined;
@@ -424,10 +509,11 @@ declare const logSchema: z.ZodObject<{
424
509
  user_id?: string | undefined;
425
510
  client_id?: string | undefined;
426
511
  audience?: string | undefined;
427
- scope?: string[] | undefined;
512
+ scope?: string | undefined;
428
513
  strategy?: string | undefined;
429
514
  connection_id?: string | undefined;
430
515
  ip?: string | undefined;
516
+ user_agent?: string | undefined;
431
517
  details?: any;
432
518
  user_name?: string | undefined;
433
519
  client_name?: string | undefined;
@@ -440,6 +526,16 @@ declare const logSchema: z.ZodObject<{
440
526
  node?: string | undefined;
441
527
  } | undefined;
442
528
  } | undefined;
529
+ location_info?: {
530
+ country_code: string;
531
+ country_code3: string;
532
+ country_name: string;
533
+ city_name: string;
534
+ latitude: string;
535
+ longitude: string;
536
+ time_zone: string;
537
+ continent_code: string;
538
+ } | undefined;
443
539
  }>;
444
540
  export type Log = z.infer<typeof logSchema>;
445
541
  export interface CacheAdapter {
@@ -483,6 +579,23 @@ export interface CustomDomainsAdapter {
483
579
  remove: (tenant_id: string, id: string) => Promise<boolean>;
484
580
  update: (tenant_id: string, id: string, custom_domain: Partial<CustomDomain>) => Promise<boolean>;
485
581
  }
582
+ export interface GeoInfo {
583
+ country_code: string;
584
+ country_code3: string;
585
+ country_name: string;
586
+ city_name: string;
587
+ latitude: string;
588
+ longitude: string;
589
+ time_zone: string;
590
+ continent_code: string;
591
+ }
592
+ export interface GeoAdapter {
593
+ /**
594
+ * Get geo information from the current request
595
+ * @returns Geo information or null if not available
596
+ */
597
+ getGeoInfo(): Promise<GeoInfo | null>;
598
+ }
486
599
  export interface R2SQLLogsAdapterConfig {
487
600
  /**
488
601
  * Cloudflare Pipeline HTTP endpoint URL for ingesting logs
@@ -493,7 +606,8 @@ export interface R2SQLLogsAdapterConfig {
493
606
  /**
494
607
  * Cloudflare service binding for Pipeline (for Workers)
495
608
  * Use this instead of pipelineEndpoint when running in a Worker
496
- * Must have a fetch() method
609
+ * Must have a fetch() method or can be the Pipeline directly
610
+ * Can be passed as env.AUTHHERO_LOGS_STREAM from wrangler.toml
497
611
  */
498
612
  pipelineBinding?: {
499
613
  fetch: typeof fetch;
@@ -558,11 +672,16 @@ export interface CloudflareConfig {
558
672
  * R2 SQL logs adapter configuration (optional)
559
673
  */
560
674
  r2SqlLogs?: R2SQLLogsAdapterConfig;
675
+ /**
676
+ * Function to get request headers for geo information (optional)
677
+ */
678
+ getHeaders?: () => Record<string, string>;
561
679
  }
562
680
  export interface CloudflareAdapters {
563
681
  customDomains: CustomDomainsAdapter;
564
682
  cache: CacheAdapter;
565
683
  logs?: LogsDataAdapter;
684
+ geo?: GeoAdapter;
566
685
  }
567
686
  declare function createAdapters(config: CloudflareConfig): CloudflareAdapters;
568
687