authhero 4.90.0 → 4.92.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.
@@ -42053,6 +42053,33 @@ export declare const hookInsertSchema: z.ZodUnion<[
42053
42053
  synchronous?: boolean | undefined;
42054
42054
  priority?: number | undefined;
42055
42055
  hook_id?: string | undefined;
42056
+ }>,
42057
+ z.ZodObject<{
42058
+ trigger_id: z.ZodEnum<[
42059
+ "post-user-login",
42060
+ "credentials-exchange",
42061
+ "pre-user-registration",
42062
+ "post-user-registration"
42063
+ ]>;
42064
+ code_id: z.ZodString;
42065
+ enabled: z.ZodDefault<z.ZodBoolean>;
42066
+ synchronous: z.ZodDefault<z.ZodBoolean>;
42067
+ priority: z.ZodOptional<z.ZodNumber>;
42068
+ hook_id: z.ZodOptional<z.ZodString>;
42069
+ }, "strip", z.ZodTypeAny, {
42070
+ code_id: string;
42071
+ enabled: boolean;
42072
+ trigger_id: "pre-user-registration" | "post-user-registration" | "post-user-login" | "credentials-exchange";
42073
+ synchronous: boolean;
42074
+ priority?: number | undefined;
42075
+ hook_id?: string | undefined;
42076
+ }, {
42077
+ code_id: string;
42078
+ trigger_id: "pre-user-registration" | "post-user-registration" | "post-user-login" | "credentials-exchange";
42079
+ enabled?: boolean | undefined;
42080
+ synchronous?: boolean | undefined;
42081
+ priority?: number | undefined;
42082
+ hook_id?: string | undefined;
42056
42083
  }>
42057
42084
  ]>;
42058
42085
  export type HookInsert = z.infer<typeof hookInsertSchema>;
@@ -42160,9 +42187,77 @@ export declare const hookSchema: z.ZodUnion<[
42160
42187
  enabled?: boolean | undefined;
42161
42188
  synchronous?: boolean | undefined;
42162
42189
  priority?: number | undefined;
42190
+ }>,
42191
+ z.ZodObject<{
42192
+ hook_id: z.ZodString;
42193
+ code_id: z.ZodString;
42194
+ created_at: z.ZodString;
42195
+ updated_at: z.ZodString;
42196
+ trigger_id: z.ZodEnum<[
42197
+ "post-user-login",
42198
+ "credentials-exchange",
42199
+ "pre-user-registration",
42200
+ "post-user-registration"
42201
+ ]>;
42202
+ enabled: z.ZodDefault<z.ZodBoolean>;
42203
+ synchronous: z.ZodDefault<z.ZodBoolean>;
42204
+ priority: z.ZodOptional<z.ZodNumber>;
42205
+ }, "strip", z.ZodTypeAny, {
42206
+ created_at: string;
42207
+ updated_at: string;
42208
+ code_id: string;
42209
+ enabled: boolean;
42210
+ trigger_id: "pre-user-registration" | "post-user-registration" | "post-user-login" | "credentials-exchange";
42211
+ synchronous: boolean;
42212
+ hook_id: string;
42213
+ priority?: number | undefined;
42214
+ }, {
42215
+ created_at: string;
42216
+ updated_at: string;
42217
+ code_id: string;
42218
+ trigger_id: "pre-user-registration" | "post-user-registration" | "post-user-login" | "credentials-exchange";
42219
+ hook_id: string;
42220
+ enabled?: boolean | undefined;
42221
+ synchronous?: boolean | undefined;
42222
+ priority?: number | undefined;
42163
42223
  }>
42164
42224
  ]>;
42165
42225
  export type Hook = z.infer<typeof hookSchema>;
42226
+ export declare const hookCodeInsertSchema: z.ZodObject<{
42227
+ code: z.ZodString;
42228
+ secrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
42229
+ }, "strip", z.ZodTypeAny, {
42230
+ code: string;
42231
+ secrets?: Record<string, string> | undefined;
42232
+ }, {
42233
+ code: string;
42234
+ secrets?: Record<string, string> | undefined;
42235
+ }>;
42236
+ export type HookCodeInsert = z.infer<typeof hookCodeInsertSchema>;
42237
+ export declare const hookCodeSchema: z.ZodObject<{
42238
+ code: z.ZodString;
42239
+ secrets: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
42240
+ } & {
42241
+ created_at: z.ZodString;
42242
+ updated_at: z.ZodString;
42243
+ id: z.ZodString;
42244
+ tenant_id: z.ZodString;
42245
+ }, "strip", z.ZodTypeAny, {
42246
+ code: string;
42247
+ id: string;
42248
+ tenant_id: string;
42249
+ created_at: string;
42250
+ updated_at: string;
42251
+ secrets?: Record<string, string> | undefined;
42252
+ }, {
42253
+ code: string;
42254
+ id: string;
42255
+ tenant_id: string;
42256
+ created_at: string;
42257
+ updated_at: string;
42258
+ secrets?: Record<string, string> | undefined;
42259
+ }>;
42260
+ export type HookCode = z.infer<typeof hookCodeSchema>;
42166
42261
  export declare const profileDataSchema: z.ZodObject<{
42167
42262
  email: z.ZodOptional<z.ZodString>;
42168
42263
  email_verified: z.ZodOptional<z.ZodBoolean>;
@@ -48521,6 +48616,12 @@ export interface HooksAdapter {
48521
48616
  update: (tenant_id: string, hook_id: string, hook: Partial<HookInsert>) => Promise<boolean>;
48522
48617
  list: (tenant_id: string, params?: ListParams) => Promise<ListHooksResponse>;
48523
48618
  }
48619
+ export interface HookCodeAdapter {
48620
+ create: (tenant_id: string, hookCode: HookCodeInsert) => Promise<HookCode>;
48621
+ get: (tenant_id: string, id: string) => Promise<HookCode | null>;
48622
+ update: (tenant_id: string, id: string, hookCode: Partial<HookCodeInsert>) => Promise<boolean>;
48623
+ remove: (tenant_id: string, id: string) => Promise<boolean>;
48624
+ }
48524
48625
  export interface ThemesAdapter {
48525
48626
  create: (tenant_id: string, theme: ThemeInsert, themeId?: string) => Promise<Theme>;
48526
48627
  remove: (tenant_id: string, themeId: string) => Promise<boolean>;
@@ -48766,6 +48867,43 @@ export interface OutboxAdapter {
48766
48867
  /** Delete processed events older than the given ISO date. Returns count deleted. */
48767
48868
  cleanup(olderThan: string): Promise<number>;
48768
48869
  }
48870
+ export interface CodeExecutionResult {
48871
+ success: boolean;
48872
+ error?: string;
48873
+ durationMs: number;
48874
+ apiCalls: Array<{
48875
+ method: string;
48876
+ args: unknown[];
48877
+ }>;
48878
+ }
48879
+ export interface CodeExecutor {
48880
+ execute(params: {
48881
+ code: string;
48882
+ hookCodeId?: string;
48883
+ triggerId: string;
48884
+ event: Record<string, unknown>;
48885
+ /** Wall-clock timeout for the entire execution (ms). */
48886
+ timeoutMs?: number;
48887
+ /**
48888
+ * CPU-time limit (ms) for runtimes that distinguish CPU time from
48889
+ * wall-clock time (e.g. Cloudflare Workers for Platforms).
48890
+ * Ignored by executors that do not support CPU-time limits.
48891
+ */
48892
+ cpuLimitMs?: number;
48893
+ }): Promise<CodeExecutionResult>;
48894
+ /**
48895
+ * Deploy user code to the execution environment.
48896
+ * Called when hook code is created or updated.
48897
+ * Optional — LocalCodeExecutor does not need this.
48898
+ */
48899
+ deploy?(hookCodeId: string, code: string): Promise<void>;
48900
+ /**
48901
+ * Remove user code from the execution environment.
48902
+ * Called when hook code is deleted.
48903
+ * Optional — LocalCodeExecutor does not need this.
48904
+ */
48905
+ remove?(hookCodeId: string): Promise<void>;
48906
+ }
48769
48907
  /**
48770
48908
  * Parameters for cleaning up expired sessions
48771
48909
  */
@@ -48788,6 +48926,7 @@ export interface DataAdapters {
48788
48926
  flows: FlowsAdapter;
48789
48927
  forms: FormsAdapter;
48790
48928
  geo?: GeoAdapter;
48929
+ hookCode: HookCodeAdapter;
48791
48930
  hooks: HooksAdapter;
48792
48931
  invites: InvitesAdapter;
48793
48932
  keys: KeysAdapter;
@@ -51542,6 +51681,19 @@ export interface AuthHeroConfig {
51542
51681
  /** Optional height in pixels (default: 20) */
51543
51682
  height?: number;
51544
51683
  };
51684
+ /**
51685
+ * Code executor for user-authored code hooks.
51686
+ *
51687
+ * When provided, code hooks stored in the database will be executed
51688
+ * using this executor at auth flow trigger points.
51689
+ *
51690
+ * Available implementations:
51691
+ * - `LocalCodeExecutor` — uses `new Function()`, suitable for local dev only
51692
+ * - Custom implementations for isolated-vm, Cloudflare Workers for Platforms, etc.
51693
+ *
51694
+ * If not provided, code hooks are silently skipped.
51695
+ */
51696
+ codeExecutor?: CodeExecutor;
51545
51697
  /**
51546
51698
  * Custom webhook invoker function.
51547
51699
  *
@@ -51648,6 +51800,7 @@ export type Bindings = {
51648
51800
  href?: string;
51649
51801
  height?: number;
51650
51802
  };
51803
+ codeExecutor?: CodeExecutor;
51651
51804
  webhookInvoker?: WebhookInvoker;
51652
51805
  outbox?: OutboxConfig;
51653
51806
  };
@@ -52223,6 +52376,18 @@ export interface EnsureUsernameOptions {
52223
52376
  }
52224
52377
  declare function ensureUsername(options?: EnsureUsernameOptions): OnExecutePostLogin;
52225
52378
  declare function setPreferredUsername(): OnExecuteCredentialsExchange;
52379
+ /**
52380
+ * Local code executor using `new Function()`.
52381
+ * Suitable for local development only — no isolation or sandboxing.
52382
+ */
52383
+ export declare class LocalCodeExecutor implements CodeExecutor {
52384
+ execute(params: {
52385
+ code: string;
52386
+ triggerId: string;
52387
+ event: Record<string, unknown>;
52388
+ timeoutMs?: number;
52389
+ }): Promise<CodeExecutionResult>;
52390
+ }
52226
52391
  export declare function init(config: AuthHeroConfig): {
52227
52392
  app: OpenAPIHono<{
52228
52393
  Bindings: Bindings;
@@ -59590,6 +59755,142 @@ export declare function init(config: AuthHeroConfig): {
59590
59755
  };
59591
59756
  };
59592
59757
  }, "/connections"> & import("hono/types").MergeSchemaPath<{
59758
+ "/": {
59759
+ $post: {
59760
+ input: {
59761
+ header: {
59762
+ "tenant-id"?: string | undefined;
59763
+ };
59764
+ } & {
59765
+ json: {
59766
+ code: string;
59767
+ secrets?: Record<string, string> | undefined;
59768
+ };
59769
+ };
59770
+ output: {
59771
+ code: string;
59772
+ created_at: string;
59773
+ updated_at: string;
59774
+ tenant_id: string;
59775
+ id: string;
59776
+ deploymentStatus: "deployed" | "failed" | "not_required";
59777
+ deploymentError?: string | undefined;
59778
+ secrets?: {
59779
+ [x: string]: string;
59780
+ } | undefined;
59781
+ };
59782
+ outputFormat: "json";
59783
+ status: 201;
59784
+ };
59785
+ };
59786
+ } & {
59787
+ "/:id": {
59788
+ $get: {
59789
+ input: {
59790
+ param: {
59791
+ id: string;
59792
+ };
59793
+ } & {
59794
+ header: {
59795
+ "tenant-id"?: string | undefined;
59796
+ };
59797
+ };
59798
+ output: {};
59799
+ outputFormat: string;
59800
+ status: 404;
59801
+ } | {
59802
+ input: {
59803
+ param: {
59804
+ id: string;
59805
+ };
59806
+ } & {
59807
+ header: {
59808
+ "tenant-id"?: string | undefined;
59809
+ };
59810
+ };
59811
+ output: {
59812
+ code: string;
59813
+ id: string;
59814
+ tenant_id: string;
59815
+ created_at: string;
59816
+ updated_at: string;
59817
+ secrets?: {
59818
+ [x: string]: string;
59819
+ } | undefined;
59820
+ };
59821
+ outputFormat: "json";
59822
+ status: 200;
59823
+ };
59824
+ };
59825
+ } & {
59826
+ "/:id": {
59827
+ $put: {
59828
+ input: {
59829
+ param: {
59830
+ id: string;
59831
+ };
59832
+ } & {
59833
+ header: {
59834
+ "tenant-id"?: string | undefined;
59835
+ };
59836
+ } & {
59837
+ json: {
59838
+ code: string;
59839
+ secrets?: Record<string, string> | undefined;
59840
+ };
59841
+ };
59842
+ output: {};
59843
+ outputFormat: string;
59844
+ status: 404;
59845
+ } | {
59846
+ input: {
59847
+ param: {
59848
+ id: string;
59849
+ };
59850
+ } & {
59851
+ header: {
59852
+ "tenant-id"?: string | undefined;
59853
+ };
59854
+ } & {
59855
+ json: {
59856
+ code: string;
59857
+ secrets?: Record<string, string> | undefined;
59858
+ };
59859
+ };
59860
+ output: {
59861
+ code: string;
59862
+ created_at: string;
59863
+ updated_at: string;
59864
+ tenant_id: string;
59865
+ id: string;
59866
+ deploymentStatus: "deployed" | "failed" | "not_required";
59867
+ deploymentError?: string | undefined;
59868
+ secrets?: {
59869
+ [x: string]: string;
59870
+ } | undefined;
59871
+ };
59872
+ outputFormat: "json";
59873
+ status: 200;
59874
+ };
59875
+ };
59876
+ } & {
59877
+ "/:id": {
59878
+ $delete: {
59879
+ input: {
59880
+ param: {
59881
+ id: string;
59882
+ };
59883
+ } & {
59884
+ header: {
59885
+ "tenant-id"?: string | undefined;
59886
+ };
59887
+ };
59888
+ output: {};
59889
+ outputFormat: string;
59890
+ status: 200;
59891
+ };
59892
+ };
59893
+ }, "/hook-code"> & import("hono/types").MergeSchemaPath<{
59593
59894
  "/": {
59594
59895
  $get: {
59595
59896
  input: {
@@ -59634,6 +59935,15 @@ export declare function init(config: AuthHeroConfig): {
59634
59935
  hook_id: string;
59635
59936
  template_id: "ensure-username" | "set-preferred-username";
59636
59937
  priority?: number | undefined | undefined;
59938
+ } | {
59939
+ created_at: string;
59940
+ updated_at: string;
59941
+ code_id: string;
59942
+ enabled: boolean;
59943
+ trigger_id: "pre-user-registration" | "post-user-registration" | "post-user-login" | "credentials-exchange";
59944
+ synchronous: boolean;
59945
+ hook_id: string;
59946
+ priority?: number | undefined | undefined;
59637
59947
  })[] | {
59638
59948
  length: number;
59639
59949
  start: number;
@@ -59665,6 +59975,15 @@ export declare function init(config: AuthHeroConfig): {
59665
59975
  hook_id: string;
59666
59976
  template_id: "ensure-username" | "set-preferred-username";
59667
59977
  priority?: number | undefined | undefined;
59978
+ } | {
59979
+ created_at: string;
59980
+ updated_at: string;
59981
+ code_id: string;
59982
+ enabled: boolean;
59983
+ trigger_id: "pre-user-registration" | "post-user-registration" | "post-user-login" | "credentials-exchange";
59984
+ synchronous: boolean;
59985
+ hook_id: string;
59986
+ priority?: number | undefined | undefined;
59668
59987
  })[];
59669
59988
  total?: number | undefined;
59670
59989
  };
@@ -59701,6 +60020,13 @@ export declare function init(config: AuthHeroConfig): {
59701
60020
  synchronous?: boolean | undefined;
59702
60021
  priority?: number | undefined;
59703
60022
  hook_id?: string | undefined;
60023
+ } | {
60024
+ code_id: string;
60025
+ trigger_id: "pre-user-registration" | "post-user-registration" | "post-user-login" | "credentials-exchange";
60026
+ enabled?: boolean | undefined;
60027
+ synchronous?: boolean | undefined;
60028
+ priority?: number | undefined;
60029
+ hook_id?: string | undefined;
59704
60030
  };
59705
60031
  };
59706
60032
  output: {
@@ -59730,6 +60056,15 @@ export declare function init(config: AuthHeroConfig): {
59730
60056
  hook_id: string;
59731
60057
  template_id: "ensure-username" | "set-preferred-username";
59732
60058
  priority?: number | undefined | undefined;
60059
+ } | {
60060
+ created_at: string;
60061
+ updated_at: string;
60062
+ code_id: string;
60063
+ enabled: boolean;
60064
+ trigger_id: "pre-user-registration" | "post-user-registration" | "post-user-login" | "credentials-exchange";
60065
+ synchronous: boolean;
60066
+ hook_id: string;
60067
+ priority?: number | undefined | undefined;
59733
60068
  };
59734
60069
  outputFormat: "json";
59735
60070
  status: 201;
@@ -59791,6 +60126,15 @@ export declare function init(config: AuthHeroConfig): {
59791
60126
  hook_id: string;
59792
60127
  template_id: "ensure-username" | "set-preferred-username";
59793
60128
  priority?: number | undefined | undefined;
60129
+ } | {
60130
+ created_at: string;
60131
+ updated_at: string;
60132
+ code_id: string;
60133
+ enabled: boolean;
60134
+ trigger_id: "pre-user-registration" | "post-user-registration" | "post-user-login" | "credentials-exchange";
60135
+ synchronous: boolean;
60136
+ hook_id: string;
60137
+ priority?: number | undefined | undefined;
59794
60138
  };
59795
60139
  outputFormat: "json";
59796
60140
  status: 200;
@@ -59848,6 +60192,15 @@ export declare function init(config: AuthHeroConfig): {
59848
60192
  hook_id: string;
59849
60193
  template_id: "ensure-username" | "set-preferred-username";
59850
60194
  priority?: number | undefined | undefined;
60195
+ } | {
60196
+ created_at: string;
60197
+ updated_at: string;
60198
+ code_id: string;
60199
+ enabled: boolean;
60200
+ trigger_id: "pre-user-registration" | "post-user-registration" | "post-user-login" | "credentials-exchange";
60201
+ synchronous: boolean;
60202
+ hook_id: string;
60203
+ priority?: number | undefined | undefined;
59851
60204
  };
59852
60205
  outputFormat: "json";
59853
60206
  status: 200;
@@ -62876,8 +63229,8 @@ export declare function init(config: AuthHeroConfig): {
62876
63229
  scope?: string | undefined;
62877
63230
  error?: string | undefined;
62878
63231
  error_description?: string | undefined;
62879
- hd?: string | undefined;
62880
63232
  error_code?: string | undefined;
63233
+ hd?: string | undefined;
62881
63234
  error_reason?: string | undefined;
62882
63235
  };
62883
63236
  };
@@ -62892,8 +63245,8 @@ export declare function init(config: AuthHeroConfig): {
62892
63245
  scope?: string | undefined;
62893
63246
  error?: string | undefined;
62894
63247
  error_description?: string | undefined;
62895
- hd?: string | undefined;
62896
63248
  error_code?: string | undefined;
63249
+ hd?: string | undefined;
62897
63250
  error_reason?: string | undefined;
62898
63251
  };
62899
63252
  };
@@ -62910,8 +63263,8 @@ export declare function init(config: AuthHeroConfig): {
62910
63263
  scope?: string | undefined;
62911
63264
  error?: string | undefined;
62912
63265
  error_description?: string | undefined;
62913
- hd?: string | undefined;
62914
63266
  error_code?: string | undefined;
63267
+ hd?: string | undefined;
62915
63268
  error_reason?: string | undefined;
62916
63269
  };
62917
63270
  };
@@ -62932,8 +63285,8 @@ export declare function init(config: AuthHeroConfig): {
62932
63285
  scope?: string | undefined;
62933
63286
  error?: string | undefined;
62934
63287
  error_description?: string | undefined;
62935
- hd?: string | undefined;
62936
63288
  error_code?: string | undefined;
63289
+ hd?: string | undefined;
62937
63290
  error_reason?: string | undefined;
62938
63291
  };
62939
63292
  };
@@ -62948,8 +63301,8 @@ export declare function init(config: AuthHeroConfig): {
62948
63301
  scope?: string | undefined;
62949
63302
  error?: string | undefined;
62950
63303
  error_description?: string | undefined;
62951
- hd?: string | undefined;
62952
63304
  error_code?: string | undefined;
63305
+ hd?: string | undefined;
62953
63306
  error_reason?: string | undefined;
62954
63307
  };
62955
63308
  };
@@ -62966,8 +63319,8 @@ export declare function init(config: AuthHeroConfig): {
62966
63319
  scope?: string | undefined;
62967
63320
  error?: string | undefined;
62968
63321
  error_description?: string | undefined;
62969
- hd?: string | undefined;
62970
63322
  error_code?: string | undefined;
63323
+ hd?: string | undefined;
62971
63324
  error_reason?: string | undefined;
62972
63325
  };
62973
63326
  };