authhero 9.8.0 → 9.9.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.
Files changed (28) hide show
  1. package/dist/authhero.cjs +139 -139
  2. package/dist/authhero.d.ts +84 -64
  3. package/dist/authhero.mjs +8107 -8052
  4. package/dist/tsconfig.types.tsbuildinfo +1 -1
  5. package/dist/types/authentication-flows/passwordless.d.ts +26 -3
  6. package/dist/types/helpers/revoke-session-refresh-tokens.d.ts +33 -0
  7. package/dist/types/index.d.ts +84 -64
  8. package/dist/types/routes/auth-api/index.d.ts +33 -13
  9. package/dist/types/routes/auth-api/passwordless.d.ts +6 -6
  10. package/dist/types/routes/auth-api/revoke.d.ts +6 -6
  11. package/dist/types/routes/auth-api/token.d.ts +20 -0
  12. package/dist/types/routes/auth-api/well-known.d.ts +1 -1
  13. package/dist/types/routes/management-api/guardian.d.ts +5 -5
  14. package/dist/types/routes/management-api/helpers.d.ts +1 -1
  15. package/dist/types/routes/management-api/index.d.ts +44 -44
  16. package/dist/types/routes/management-api/keys.d.ts +12 -12
  17. package/dist/types/routes/management-api/logs.d.ts +4 -4
  18. package/dist/types/routes/management-api/organizations.d.ts +5 -5
  19. package/dist/types/routes/management-api/prompts.d.ts +4 -4
  20. package/dist/types/routes/management-api/tenants.d.ts +1 -1
  21. package/dist/types/routes/management-api/users.d.ts +14 -14
  22. package/dist/types/routes/universal-login/identifier.d.ts +2 -2
  23. package/dist/types/routes/universal-login/index.d.ts +2 -2
  24. package/dist/types/routes/universal-login/u2-index.d.ts +5 -5
  25. package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
  26. package/dist/types/state-machines/login-session.d.ts +1 -1
  27. package/dist/types/utils/jwks.d.ts +2 -2
  28. package/package.json +6 -6
@@ -1,10 +1,13 @@
1
1
  import { Context } from "hono";
2
2
  import { z } from "@hono/zod-openapi";
3
3
  import { Bindings, Variables } from "../types";
4
+ import { GrantFlowUserResult } from "../types/GrantFlowResult";
4
5
  export declare const passwordlessGrantParamsSchema: z.ZodObject<{
5
6
  client_id: z.ZodString;
6
7
  username: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
7
8
  otp: z.ZodString;
9
+ scope: z.ZodOptional<z.ZodString>;
10
+ audience: z.ZodOptional<z.ZodString>;
8
11
  authParams: z.ZodOptional<z.ZodObject<{
9
12
  client_id: z.ZodString;
10
13
  act_as: z.ZodOptional<z.ZodString>;
@@ -42,7 +45,7 @@ export declare const passwordlessGrantParamsSchema: z.ZodObject<{
42
45
  export declare function passwordlessGrantUser(ctx: Context<{
43
46
  Bindings: Bindings;
44
47
  Variables: Variables;
45
- }>, { client_id, username, otp, authParams, enforceIpCheck, }: z.input<typeof passwordlessGrantParamsSchema>): Promise<{
48
+ }>, { client_id, username, otp, scope, audience, authParams, enforceIpCheck, }: z.input<typeof passwordlessGrantParamsSchema>): Promise<{
46
49
  user: {
47
50
  connection: string;
48
51
  email_verified: boolean;
@@ -558,16 +561,16 @@ export declare function passwordlessGrantUser(ctx: Context<{
558
561
  authConnection: "username" | "email" | "sms";
559
562
  session_id: string | undefined;
560
563
  authParams: {
564
+ audience?: string | undefined;
565
+ scope?: string | undefined;
561
566
  client_id: string;
562
567
  act_as?: string | undefined;
563
568
  response_type?: import("@authhero/adapter-interfaces").AuthorizationResponseType | undefined;
564
569
  response_mode?: import("@authhero/adapter-interfaces").AuthorizationResponseMode | undefined;
565
570
  redirect_uri?: string | undefined;
566
- audience?: string | undefined;
567
571
  organization?: string | undefined;
568
572
  state?: string | undefined;
569
573
  nonce?: string | undefined;
570
- scope?: string | undefined;
571
574
  prompt?: string | undefined;
572
575
  code_challenge_method?: import("@authhero/adapter-interfaces").CodeChallengeMethod | undefined;
573
576
  code_challenge?: string | undefined;
@@ -590,6 +593,26 @@ export declare function passwordlessGrantUser(ctx: Context<{
590
593
  vendor_id?: string | undefined;
591
594
  };
592
595
  }>;
596
+ /**
597
+ * The `http://auth0.com/oauth/grant-type/passwordless/otp` grant at
598
+ * /oauth/token.
599
+ *
600
+ * Unlike the authorization-code exchange — where /authorize has already
601
+ * authenticated the login session and created a session — nothing has run for
602
+ * this login yet: /passwordless/start only stores a PENDING login session and
603
+ * an OTP. So authenticate it here, which creates the session the auth cookie
604
+ * and the refresh token below both hang off, then mint a refresh token when
605
+ * `offline_access` was requested (issue #1273).
606
+ *
607
+ * The sibling front-channel path (`passwordlessGrant`, used by
608
+ * /co/authenticate) does not go through here: createFrontChannelAuthResponse
609
+ * does both steps itself, and skips the refresh token for code flows so the
610
+ * exchange issues it instead.
611
+ */
612
+ export declare function passwordlessOtpGrant(ctx: Context<{
613
+ Bindings: Bindings;
614
+ Variables: Variables;
615
+ }>, params: z.input<typeof passwordlessGrantParamsSchema>): Promise<GrantFlowUserResult>;
593
616
  export declare function passwordlessGrant(ctx: Context<{
594
617
  Bindings: Bindings;
595
618
  Variables: Variables;
@@ -0,0 +1,33 @@
1
+ import { DataAdapters } from "@authhero/adapter-interfaces";
2
+ /**
3
+ * The parts of a session this cascade needs: its own id, which refresh tokens
4
+ * point at through `session_id`, and the login session it originated from,
5
+ * which is the only link rows minted before that column existed carry.
6
+ */
7
+ export interface RevocableSession {
8
+ id: string;
9
+ login_session_id?: string;
10
+ }
11
+ /**
12
+ * Revoke every refresh token issued under a session.
13
+ *
14
+ * Call this only where a session is *deliberately* ended — an admin revoking
15
+ * or deleting it, or a user being blocked. Natural expiry and cleanup must not
16
+ * cascade: a refresh token is designed to outlive its session, and killing
17
+ * tokens on an SSO timeout would log out every long-lived native client on
18
+ * each timeout. Revocation couples; lifetime does not.
19
+ *
20
+ * Two sweeps, run in sequence:
21
+ *
22
+ * 1. `session_id` — the ownership edge, and the one that is actually complete.
23
+ * 2. `login_id` — legacy fallback for rows minted before `session_id` existed.
24
+ * `sessions.login_session_id` records only the session's *originating*
25
+ * authorization transaction and is never repointed on SSO reuse, so on its
26
+ * own it misses every token minted during a later re-authorization. It is
27
+ * retained until pre-Stage-2 rows have aged out (#1259) and then dropped.
28
+ *
29
+ * Sequential rather than parallel because a row can match both predicates, and
30
+ * both adapters guard on `revoked_at IS NULL` — so the second sweep skips what
31
+ * the first already revoked instead of double-counting it.
32
+ */
33
+ export declare function revokeSessionRefreshTokens(data: DataAdapters, tenant_id: string, session: RevocableSession, revoked_at: string): Promise<number>;