@udibo/oauth2 0.12.1 → 0.12.2

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.
@@ -13,7 +13,9 @@ import "../_dnt.polyfills.js";
13
13
  * that some browsers resolve as a host, and any value containing a C0 control
14
14
  * character or `DEL` — browsers strip TAB/CR/LF before parsing a URL, so
15
15
  * `/<TAB>/evil.com` would otherwise navigate to `evil.com`. Anything else
16
- * collapses to `fallback` (default `/`).
16
+ * collapses to `fallback` (default `/`), which is returned verbatim. The
17
+ * fallback is trusted caller configuration; do not pass user-controlled input
18
+ * there.
17
19
  *
18
20
  * Percent-encoded control characters (`/%09/x`) are safe and pass through: a
19
21
  * browser does not decode them before parsing, so they stay on the origin.
@@ -34,17 +36,17 @@ import "../_dnt.polyfills.js";
34
36
  * ```
35
37
  */
36
38
  export declare function safeReturnTo(value: string | null | undefined, fallback?: string): string;
37
- /** Options for {@link loginContinuation}. */
39
+ /** Trusted application configuration for {@link loginContinuation}. */
38
40
  export interface LoginContinuationOptions {
39
41
  /**
40
- * The authorization endpoint (absolute URL or path). When `returnTo` points at
41
- * it, the flow is **resumed** (the in-flight authorize request already carries
42
+ * Trusted authorization endpoint (absolute URL or path). When `returnTo` points
43
+ * at it, the flow is **resumed** (the in-flight authorize request already carries
42
44
  * its `state`). Omit it and every `returnTo` starts a fresh login.
43
45
  */
44
46
  authorizeEndpoint?: string;
45
- /** The login path to start a fresh login. Defaults to `"/auth/login"`. */
47
+ /** Trusted login path for a fresh login. Defaults to `"/auth/login"`. */
46
48
  loginPath?: string;
47
- /** Fallback when `returnTo` is missing/unsafe. Defaults to `"/"`. */
49
+ /** Trusted fallback for missing/unsafe `returnTo`. Defaults to `"/"`. */
48
50
  defaultReturnTo?: string;
49
51
  }
50
52
  /**
@@ -61,6 +63,7 @@ export interface LoginContinuationOptions {
61
63
  *
62
64
  * Pure and client-safe — the same logic behind `HonoBff.loginContinuation`
63
65
  * (server) and `BffClient.loginContinuation` (browser). `returnTo` is
64
- * open-redirect-guarded via {@link safeReturnTo}.
66
+ * open-redirect-guarded via {@link safeReturnTo}. The fallback, authorization
67
+ * endpoint and login path are trusted application configuration.
65
68
  */
66
69
  export declare function loginContinuation(returnTo: string | null | undefined, options?: LoginContinuationOptions): string;
package/esm/utils/url.js CHANGED
@@ -22,7 +22,9 @@ function hasControlCharacter(value) {
22
22
  * that some browsers resolve as a host, and any value containing a C0 control
23
23
  * character or `DEL` — browsers strip TAB/CR/LF before parsing a URL, so
24
24
  * `/<TAB>/evil.com` would otherwise navigate to `evil.com`. Anything else
25
- * collapses to `fallback` (default `/`).
25
+ * collapses to `fallback` (default `/`), which is returned verbatim. The
26
+ * fallback is trusted caller configuration; do not pass user-controlled input
27
+ * there.
26
28
  *
27
29
  * Percent-encoded control characters (`/%09/x`) are safe and pass through: a
28
30
  * browser does not decode them before parsing, so they stay on the origin.
@@ -74,7 +76,8 @@ export function safeReturnTo(value, fallback = "/") {
74
76
  *
75
77
  * Pure and client-safe — the same logic behind `HonoBff.loginContinuation`
76
78
  * (server) and `BffClient.loginContinuation` (browser). `returnTo` is
77
- * open-redirect-guarded via {@link safeReturnTo}.
79
+ * open-redirect-guarded via {@link safeReturnTo}. The fallback, authorization
80
+ * endpoint and login path are trusted application configuration.
78
81
  */
79
82
  export function loginContinuation(returnTo, options = {}) {
80
83
  const safe = safeReturnTo(returnTo, options.defaultReturnTo ?? "/");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@udibo/oauth2",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "description": "A flexible OAuth2 toolkit: framework-agnostic authorization & resource servers, a typed client, Hono adapters (including a backend-for-frontend), and React bindings.",
5
5
  "repository": {
6
6
  "type": "git",