authhero 9.9.0 → 9.9.1
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.
- package/dist/assets/u/widget/index.esm.js +1 -1
- package/dist/authhero.cjs +543 -344
- package/dist/authhero.d.ts +135 -135
- package/dist/authhero.mjs +12205 -11732
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/authentication-flows/grant-tokens.d.ts +16 -0
- package/dist/types/helpers/refresh-token-lifetime.d.ts +103 -0
- package/dist/types/hooks/addDataHooks.d.ts +4 -3
- package/dist/types/index.d.ts +135 -135
- package/dist/types/routes/auth-api/index.d.ts +32 -32
- package/dist/types/routes/auth-api/passwordless.d.ts +2 -2
- package/dist/types/routes/auth-api/token.d.ts +24 -24
- package/dist/types/routes/management-api/custom-domains.d.ts +6 -6
- package/dist/types/routes/management-api/failed-events.d.ts +1 -1
- package/dist/types/routes/management-api/forms.d.ts +126 -126
- package/dist/types/routes/management-api/guardian.d.ts +5 -5
- package/dist/types/routes/management-api/helpers.d.ts +1 -1
- package/dist/types/routes/management-api/index.d.ts +80 -80
- package/dist/types/routes/management-api/keys.d.ts +8 -8
- package/dist/types/routes/management-api/organizations.d.ts +5 -5
- package/dist/types/routes/management-api/prompts.d.ts +4 -4
- package/dist/types/routes/management-api/roles.d.ts +1 -1
- package/dist/types/routes/management-api/tenant-export-import.d.ts +5 -5
- package/dist/types/routes/management-api/tenants.d.ts +1 -1
- package/dist/types/routes/management-api/users.d.ts +20 -20
- package/dist/types/routes/universal-login/identifier.d.ts +2 -2
- package/dist/types/routes/universal-login/index.d.ts +2 -2
- package/dist/types/routes/universal-login/info-code-exchange.d.ts +27 -0
- package/dist/types/routes/universal-login/token-info-page.d.ts +26 -0
- package/dist/types/routes/universal-login/u2-index.d.ts +5 -5
- package/dist/types/routes/universal-login/u2-routes.d.ts +5 -5
- package/dist/types/utils/email.d.ts +21 -9
- package/package.json +8 -8
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Context } from "hono";
|
|
2
|
+
import { GrantType, TokenResponse } from "@authhero/adapter-interfaces";
|
|
3
|
+
import { Bindings, Variables } from "../types";
|
|
4
|
+
import { GrantFlowResult } from "../types/GrantFlowResult";
|
|
5
|
+
/**
|
|
6
|
+
* Turn a resolved grant into wire tokens: narrow the requested scopes to what
|
|
7
|
+
* the user/client is actually granted for the audience, pick the token
|
|
8
|
+
* lifetime from the resource server, then mint the tokens.
|
|
9
|
+
*
|
|
10
|
+
* Shared by the /oauth/token endpoint and the server-side code exchange on the
|
|
11
|
+
* /u2/info test page so both mint identical tokens for the same grant.
|
|
12
|
+
*/
|
|
13
|
+
export declare function issueTokensForGrant(ctx: Context<{
|
|
14
|
+
Bindings: Bindings;
|
|
15
|
+
Variables: Variables;
|
|
16
|
+
}>, grantResult: GrantFlowResult, grantType: GrantType): Promise<TokenResponse>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Refresh-token lifetimes (issue #1260).
|
|
3
|
+
*
|
|
4
|
+
* Auth0 keeps refresh-token expiry and session expiry as two separate
|
|
5
|
+
* concepts: the former is configured per *client* (`client.refresh_token.*`,
|
|
6
|
+
* in seconds), the latter per *tenant* (`session_lifetime` /
|
|
7
|
+
* `idle_session_lifetime`, in hours). AuthHero historically derived
|
|
8
|
+
* refresh-token expiry from the tenant session lifetimes only, which made
|
|
9
|
+
* `infinite_token_lifetime` — the setting native/mobile clients rely on —
|
|
10
|
+
* unrepresentable.
|
|
11
|
+
*
|
|
12
|
+
* These helpers resolve the effective lifetime: per-client config wins when
|
|
13
|
+
* set, otherwise we fall back to the tenant-derived behaviour so existing
|
|
14
|
+
* tenants see no change.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* A resolved refresh-token lifetime.
|
|
18
|
+
*
|
|
19
|
+
* - `seconds` — expires this many seconds after the anchor point.
|
|
20
|
+
* - `infinite` — explicitly configured never to expire.
|
|
21
|
+
* - `unset` — nothing configured at either level. Distinct from `infinite`
|
|
22
|
+
* so callers can tell "the operator asked for no expiry" from "no opinion":
|
|
23
|
+
* at mint both mean no expiry, but on rotation only `infinite` clears an
|
|
24
|
+
* expiry the parent row already carried.
|
|
25
|
+
*/
|
|
26
|
+
export type RefreshTokenLifetime = {
|
|
27
|
+
kind: "seconds";
|
|
28
|
+
seconds: number;
|
|
29
|
+
} | {
|
|
30
|
+
kind: "infinite";
|
|
31
|
+
} | {
|
|
32
|
+
kind: "unset";
|
|
33
|
+
};
|
|
34
|
+
/** The subset of a client this module reads. */
|
|
35
|
+
export interface RefreshTokenLifetimeClient {
|
|
36
|
+
refresh_token?: {
|
|
37
|
+
expiration_type?: "expiring" | "non-expiring";
|
|
38
|
+
token_lifetime?: number;
|
|
39
|
+
infinite_token_lifetime?: boolean;
|
|
40
|
+
idle_token_lifetime?: number;
|
|
41
|
+
infinite_idle_token_lifetime?: boolean;
|
|
42
|
+
};
|
|
43
|
+
tenant: {
|
|
44
|
+
session_lifetime?: number;
|
|
45
|
+
idle_session_lifetime?: number;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Absolute ("hard") refresh-token lifetime: how long the token is valid for,
|
|
50
|
+
* regardless of use.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveAbsoluteRefreshTokenLifetime(client: RefreshTokenLifetimeClient): RefreshTokenLifetime;
|
|
53
|
+
/**
|
|
54
|
+
* Idle ("sliding") refresh-token lifetime: how long the token survives without
|
|
55
|
+
* being exchanged. Refreshed on every successful exchange.
|
|
56
|
+
*/
|
|
57
|
+
export declare function resolveIdleRefreshTokenLifetime(client: RefreshTokenLifetimeClient): RefreshTokenLifetime;
|
|
58
|
+
/**
|
|
59
|
+
* Turn a lifetime into an ISO expiry timestamp measured from `from`.
|
|
60
|
+
* `infinite` and `unset` both yield `undefined` — no expiry column is written.
|
|
61
|
+
*/
|
|
62
|
+
export declare function lifetimeToExpiresAt(lifetime: RefreshTokenLifetime, from?: number): string | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Both expiry timestamps for a freshly minted refresh token.
|
|
65
|
+
*/
|
|
66
|
+
export declare function resolveRefreshTokenExpiry(client: RefreshTokenLifetimeClient, from?: number): {
|
|
67
|
+
expires_at?: string;
|
|
68
|
+
idle_expires_at?: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* The idle expiry a token should carry after a successful exchange.
|
|
72
|
+
*
|
|
73
|
+
* Sliding only applies to a token that already had an idle window: a row minted
|
|
74
|
+
* without one is not retro-fitted with an expiry mid-life. The exception is an
|
|
75
|
+
* explicit `infinite` config, which clears an existing window so a client
|
|
76
|
+
* switched to non-expiring stops being cut off by expiries stamped earlier.
|
|
77
|
+
*/
|
|
78
|
+
export declare function slideIdleExpiry(client: RefreshTokenLifetimeClient, currentIdleExpiresAt: string | undefined, from?: number): string | undefined;
|
|
79
|
+
/**
|
|
80
|
+
* The expiry columns an in-place (non-rotating) exchange should write.
|
|
81
|
+
*
|
|
82
|
+
* Three-valued per column, matching the adapter's update contract:
|
|
83
|
+
* `undefined` leaves the stored value alone, a string overwrites it, `null`
|
|
84
|
+
* clears it.
|
|
85
|
+
*
|
|
86
|
+
* Rotation reconciles a changed client config for free — the child row is
|
|
87
|
+
* minted from the current lifetimes — but the non-rotating path keeps handing
|
|
88
|
+
* back the row it was given, so it has to say so explicitly:
|
|
89
|
+
*
|
|
90
|
+
* - Idle window: slides by the resolved lifetime, and is cleared when the
|
|
91
|
+
* client is configured never to idle-expire. A row minted without an idle
|
|
92
|
+
* window is not retro-fitted with one mid-life.
|
|
93
|
+
* - Absolute window: never extended — refreshing must not let a bounded token
|
|
94
|
+
* outlive the expiry stamped at mint — and only cleared when the client is
|
|
95
|
+
* configured never to expire.
|
|
96
|
+
*/
|
|
97
|
+
export declare function resolveExchangeExpiryUpdate(client: RefreshTokenLifetimeClient, current: {
|
|
98
|
+
expires_at?: string;
|
|
99
|
+
idle_expires_at?: string;
|
|
100
|
+
}, from?: number): {
|
|
101
|
+
expires_at?: null;
|
|
102
|
+
idle_expires_at?: string | null;
|
|
103
|
+
};
|
|
@@ -10,9 +10,10 @@ import { Bindings, Variables } from "../types";
|
|
|
10
10
|
* dispatch post-event outbox messages. `users.rawCreate` is NOT decorated —
|
|
11
11
|
* commit paths call it directly to bypass the hook layer by design.
|
|
12
12
|
*
|
|
13
|
-
* `email` is lowercased on the way in so the
|
|
14
|
-
* (`preUserSignupHook`, the email→primary linking
|
|
15
|
-
* normalized value that will be stored. Hooks can assign
|
|
13
|
+
* `email` is normalized (trimmed and lowercased) on the way in so the
|
|
14
|
+
* pre-commit hooks and lookups (`preUserSignupHook`, the email→primary linking
|
|
15
|
+
* query) see the same normalized value that will be stored. Hooks can assign
|
|
16
|
+
* `email` themselves
|
|
16
17
|
* after this point, so the decorators normalize again just before their
|
|
17
18
|
* commit — see `createUserHooks` / `createUserUpdateHooks`.
|
|
18
19
|
*/
|