@flytedesk/app-kit 1.0.0 → 3.0.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.
- package/README.md +50 -0
- package/dist/auth/client/index.d.ts +2 -1
- package/dist/auth/client/index.js +2 -1
- package/dist/auth/client/index.js.map +1 -1
- package/dist/auth/client/signInError.d.ts +15 -0
- package/dist/auth/client/signInError.js +48 -0
- package/dist/auth/client/signInError.js.map +1 -0
- package/dist/auth/index.d.ts +5 -4
- package/dist/auth/index.js +3 -2
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/oidc-client.d.ts +22 -11
- package/dist/auth/oidc-client.js +44 -39
- package/dist/auth/oidc-client.js.map +1 -1
- package/dist/auth/plugin.js +201 -51
- package/dist/auth/plugin.js.map +1 -1
- package/dist/auth/shared-types.d.ts +27 -0
- package/dist/auth/shared-types.js +26 -0
- package/dist/auth/shared-types.js.map +1 -1
- package/dist/auth/testing/fake-idp.d.ts +23 -0
- package/dist/auth/testing/fake-idp.js +58 -6
- package/dist/auth/testing/fake-idp.js.map +1 -1
- package/dist/auth/types.d.ts +83 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,56 @@ own domain work resumes.
|
|
|
25
25
|
pnpm add @flytedesk/app-kit
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
## Auth (`@flytedesk/app-kit/auth`)
|
|
29
|
+
|
|
30
|
+
`idpRequestTimeoutMs` (`FlytedeskAuthOptions`/`OidcClientOptions`, default 5s) bounds
|
|
31
|
+
**every** call this package makes to flytedesk-id — token, userinfo, the per-app
|
|
32
|
+
authorization check, `/me/apps`, discovery and revocation — not just `/token`. A hung
|
|
33
|
+
flytedesk-id endpoint fails loudly with the typed `IdpTimeoutError` instead of hanging
|
|
34
|
+
the request indefinitely; this matters most for the authorization check, which runs on
|
|
35
|
+
every authenticated request to every consumer of this package. Sign-out still completes
|
|
36
|
+
locally (cookies cleared, refresh-token family revoked) even when the IdP-side
|
|
37
|
+
revocation call itself times out.
|
|
38
|
+
|
|
39
|
+
**Residual risk in the refresh-token grace window (RFC 9700 §4.14.2).** `POST
|
|
40
|
+
{routePrefix}/refresh` rotates the presented refresh token on every call and treats a
|
|
41
|
+
second presentation of an already-rotated token as a legitimate concurrent-tab race
|
|
42
|
+
(401, nothing revoked) rather than reuse, as long as it arrives within
|
|
43
|
+
`refreshReuseGraceMs` (default 20s) of the rotation. This is deliberate — two browser
|
|
44
|
+
tabs sharing one cookie jar can otherwise trip false-positive reuse detection — but it
|
|
45
|
+
means that within that same window, an attacker who has obtained a copy of a
|
|
46
|
+
not-yet-presented refresh token and wins the race against the legitimate browser is
|
|
47
|
+
**indistinguishable from a same-device two-tab race**: both look like "a token was
|
|
48
|
+
rotated, then its predecessor was presented again shortly after." A presentation
|
|
49
|
+
**outside** the window, or of a token that was never rotated at all, is always treated
|
|
50
|
+
as reuse and revokes the whole family. Consumers who need a tighter bound can lower
|
|
51
|
+
`refreshReuseGraceMs`, trading some tolerance for slow concurrent-tab requests for a
|
|
52
|
+
narrower attack window; it cannot be set to zero without reintroducing the false-positive
|
|
53
|
+
two-tab problem this window exists to solve.
|
|
54
|
+
|
|
55
|
+
**Failed interactive sign-ins land back in the app, not on a raw JSON error page.**
|
|
56
|
+
`signInUrl` (`FlytedeskAuthOptions`, required) is where `GET {routePrefix}/callback`
|
|
57
|
+
redirects an INTERACTIVE (not `prompt=none`) sign-in failure — idp_error (including
|
|
58
|
+
`access_denied` and `login_required`), an invalid/expired login-attempt cookie, a state
|
|
59
|
+
mismatch, or a token exchange/verification failure — with `?signin_error=<code>`
|
|
60
|
+
appended, `<code>` being one of `"expired"`, `"cancelled"`, or `"other"` (never the raw
|
|
61
|
+
internal failure reason, which is logged server-side only). A **silent** (`prompt=none`)
|
|
62
|
+
callback failure is unaffected: it still answers through the existing postMessage
|
|
63
|
+
contract (`SilentAuthMessage`), consumed only inside `./client/silentAuth.js`'s hidden
|
|
64
|
+
iframe. When the login-attempt cookie is missing entirely (its 10-minute
|
|
65
|
+
`loginAttemptTtlSeconds` already elapsed), the `silent` flag can't be recovered — this is
|
|
66
|
+
deliberately always treated as interactive (`signin_error=expired`): a genuinely silent
|
|
67
|
+
attempt runs in a hidden iframe and resolves within seconds, so an expired cookie in
|
|
68
|
+
practice only ever means an interactive one, and a redirect delivered inside a hidden
|
|
69
|
+
iframe is harmless (invisible to the user; the parent page's own listener just times out
|
|
70
|
+
as it would have anyway).
|
|
71
|
+
|
|
72
|
+
`./client/signInError.js`'s `consumeSignInError()` reads and clears `signin_error` from
|
|
73
|
+
the current page's URL and returns the plain message to render (or `null` when there
|
|
74
|
+
isn't one) — e.g. `error={consumeSignInError()}` straight into
|
|
75
|
+
`@flytedan/flytebot-design-system`'s `SignInPage` (0.21.0+). `@flytedesk/app-kit` itself
|
|
76
|
+
never depends on the design system; this returns a plain string.
|
|
77
|
+
|
|
28
78
|
## Publishing
|
|
29
79
|
|
|
30
80
|
Published to the public npm registry under the `@flytedesk` org, access `restricted`.
|
|
@@ -7,5 +7,6 @@
|
|
|
7
7
|
export { ApiRequestError, RequestDeadlineError, DEFAULT_REQUEST_DEADLINE_MS, configureApiClient, setAccessToken, getAccessToken, getBaseUrl, setAuthRecovery, apiRequest, apiUpload, type AuthRecovery, type RequestOptions, } from "./httpClient.js";
|
|
8
8
|
export { useAuthSession, type AuthStatus, type AuthSessionState, type LoadingSessionState, type AuthenticatedSessionState, type UnauthenticatedSessionState, type ErrorSessionState, } from "./useAuthSession.js";
|
|
9
9
|
export { attemptSilentResume, type SilentResumeResult, type AttemptSilentResumeOptions, } from "./silentAuth.js";
|
|
10
|
+
export { consumeSignInError } from "./signInError.js";
|
|
10
11
|
export type { AppSwitcherEntry, AuthedUserDto, IdpRole, ApiErrorBody, SilentAuthMessage } from "../shared-types.js";
|
|
11
|
-
export { AUTH_ROUTE_PREFIX, AUTH_ROUTE_SEGMENTS, authRoutePath, type AuthRouteSegment } from "../shared-types.js";
|
|
12
|
+
export { AUTH_ROUTE_PREFIX, AUTH_ROUTE_SEGMENTS, authRoutePath, SIGNIN_ERROR_QUERY_PARAM, SIGNIN_ERROR_CODES, type AuthRouteSegment, type SignInErrorCode, } from "../shared-types.js";
|
|
@@ -7,5 +7,6 @@
|
|
|
7
7
|
export { ApiRequestError, RequestDeadlineError, DEFAULT_REQUEST_DEADLINE_MS, configureApiClient, setAccessToken, getAccessToken, getBaseUrl, setAuthRecovery, apiRequest, apiUpload, } from "./httpClient.js";
|
|
8
8
|
export { useAuthSession, } from "./useAuthSession.js";
|
|
9
9
|
export { attemptSilentResume, } from "./silentAuth.js";
|
|
10
|
-
export {
|
|
10
|
+
export { consumeSignInError } from "./signInError.js";
|
|
11
|
+
export { AUTH_ROUTE_PREFIX, AUTH_ROUTE_SEGMENTS, authRoutePath, SIGNIN_ERROR_QUERY_PARAM, SIGNIN_ERROR_CODES, } from "../shared-types.js";
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/auth/client/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,UAAU,EACV,eAAe,EACf,UAAU,EACV,SAAS,GAGV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,GAOf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,mBAAmB,GAGpB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/auth/client/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,UAAU,EACV,eAAe,EACf,UAAU,EACV,SAAS,GAGV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,GAOf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,mBAAmB,GAGpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGtD,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,wBAAwB,EACxB,kBAAkB,GAGnB,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads `?signin_error=<code>` off the current page's URL and returns the plain message
|
|
3
|
+
* to render, or `null` when the URL carries no `signin_error` at all (the ordinary case
|
|
4
|
+
* — a fresh visit to the sign-in page, or a successful sign-in that never came back
|
|
5
|
+
* through this failure path). An unrecognized code (a future server version this client
|
|
6
|
+
* hasn't caught up to yet, or anything else malformed) renders the same generic message
|
|
7
|
+
* as `"other"` rather than `null` — the app's callback DID fail, and that's still worth
|
|
8
|
+
* saying even if this particular code is unknown.
|
|
9
|
+
*
|
|
10
|
+
* Removes the param from the URL via `history.replaceState` (never a navigation) before
|
|
11
|
+
* returning, so a page refresh or a copied/shared link never re-shows a stale error and
|
|
12
|
+
* the code never lingers in browser history. A caller on the server, or a test with no
|
|
13
|
+
* `window` at all, gets `null` — there is nothing to read or clear.
|
|
14
|
+
*/
|
|
15
|
+
export declare function consumeSignInError(): string | null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AK-19: reads (and clears) the `signin_error` query param `../plugin.ts`'s callback
|
|
3
|
+
* redirects with on every INTERACTIVE sign-in failure, and maps it to a plain, specific
|
|
4
|
+
* message — so a consuming app's sign-in page can pass ONE string straight to
|
|
5
|
+
* `@flytedan/flytebot-design-system`'s `SignInPage` `error` prop (0.21.0+) instead of
|
|
6
|
+
* every app re-parsing the query and re-declaring the same three messages by hand. This
|
|
7
|
+
* package deliberately never depends on the design system (see package.json's
|
|
8
|
+
* dependencies — a browser-safe Node package has no business importing a React UI
|
|
9
|
+
* library), so this returns a plain string or `null`, nothing design-system-shaped; the
|
|
10
|
+
* consuming app is what wires the string into `SignInPage`.
|
|
11
|
+
*/
|
|
12
|
+
import { SIGNIN_ERROR_CODES, SIGNIN_ERROR_QUERY_PARAM } from "../shared-types.js";
|
|
13
|
+
/** The plain message every app's sign-in page renders for one `SignInErrorCode` —
|
|
14
|
+
* see that type's doc comment (`../shared-types.js`) for what collapses into "other". */
|
|
15
|
+
const SIGNIN_ERROR_MESSAGES = {
|
|
16
|
+
expired: "Your sign-in took too long. Please try again.",
|
|
17
|
+
cancelled: "Sign-in was cancelled.",
|
|
18
|
+
other: "Sign-in didn't complete. Please try again.",
|
|
19
|
+
};
|
|
20
|
+
function isSignInErrorCode(value) {
|
|
21
|
+
return SIGNIN_ERROR_CODES.includes(value);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Reads `?signin_error=<code>` off the current page's URL and returns the plain message
|
|
25
|
+
* to render, or `null` when the URL carries no `signin_error` at all (the ordinary case
|
|
26
|
+
* — a fresh visit to the sign-in page, or a successful sign-in that never came back
|
|
27
|
+
* through this failure path). An unrecognized code (a future server version this client
|
|
28
|
+
* hasn't caught up to yet, or anything else malformed) renders the same generic message
|
|
29
|
+
* as `"other"` rather than `null` — the app's callback DID fail, and that's still worth
|
|
30
|
+
* saying even if this particular code is unknown.
|
|
31
|
+
*
|
|
32
|
+
* Removes the param from the URL via `history.replaceState` (never a navigation) before
|
|
33
|
+
* returning, so a page refresh or a copied/shared link never re-shows a stale error and
|
|
34
|
+
* the code never lingers in browser history. A caller on the server, or a test with no
|
|
35
|
+
* `window` at all, gets `null` — there is nothing to read or clear.
|
|
36
|
+
*/
|
|
37
|
+
export function consumeSignInError() {
|
|
38
|
+
if (typeof window === "undefined")
|
|
39
|
+
return null;
|
|
40
|
+
const url = new URL(window.location.href);
|
|
41
|
+
const raw = url.searchParams.get(SIGNIN_ERROR_QUERY_PARAM);
|
|
42
|
+
if (raw === null)
|
|
43
|
+
return null;
|
|
44
|
+
url.searchParams.delete(SIGNIN_ERROR_QUERY_PARAM);
|
|
45
|
+
window.history.replaceState(null, "", url.toString());
|
|
46
|
+
return SIGNIN_ERROR_MESSAGES[isSignInErrorCode(raw) ? raw : "other"];
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=signInError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signInError.js","sourceRoot":"","sources":["../../../src/auth/client/signInError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAwB,MAAM,oBAAoB,CAAC;AAexG;0FAC0F;AAC1F,MAAM,qBAAqB,GAAoC;IAC7D,OAAO,EAAE,+CAA+C;IACxD,SAAS,EAAE,wBAAwB;IACnC,KAAK,EAAE,4CAA4C;CACpD,CAAC;AAEF,SAAS,iBAAiB,CAAC,KAAa;IACtC,OAAQ,kBAAwC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,kBAAkB;IAChC,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IAE/C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,GAAG,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAC3D,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAE9B,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC;IAClD,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IAEtD,OAAO,qBAAqB,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;AACvE,CAAC"}
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
* redirectUri: "https://my-app.flytedesk.com/api/v1/auth/callback",
|
|
35
35
|
* appId: "my-app",
|
|
36
36
|
* postLoginRedirect: "https://my-app.flytedesk.com/",
|
|
37
|
+
* signInUrl: "https://my-app.flytedesk.com/sign-in",
|
|
37
38
|
* cookieSecret: process.env.COOKIE_SECRET!,
|
|
38
39
|
* secureCookies: process.env.NODE_ENV === "production",
|
|
39
40
|
* accessTokenSecret: process.env.JWT_SECRET!,
|
|
@@ -43,11 +44,11 @@
|
|
|
43
44
|
* app.get("/me", { preHandler: requireAuth }, async (request) => request.authUser);
|
|
44
45
|
*/
|
|
45
46
|
export { requireAuth, requirePermission } from "./guards.js";
|
|
46
|
-
export type { AuthedUser, AuthStore, CreateIdpSessionInput, CreateRefreshTokenInput, FlytedeskAuthOptions, IdpRole, IdpSessionRow, RefreshTokenRow, UpdateIdpSessionInput, UserinfoClaims, } from "./types.js";
|
|
47
|
+
export type { AuthedUser, AuthStore, CreateIdpSessionInput, CreateRefreshTokenInput, FlytedeskAuthOptions, IdpRole, IdpSessionRow, RefreshTokenRow, RevokeFamilyReason, UpdateIdpSessionInput, UserinfoClaims, } from "./types.js";
|
|
47
48
|
export type { AppSwitcherEntry, IdpAuthorization, IdpTokenResponse, IdTokenClaims, OidcClient, OidcClientOptions, } from "./oidc-client.js";
|
|
48
|
-
export { createOidcClient, DEFAULT_OIDC_SCOPES,
|
|
49
|
-
export type { ApiErrorBody, SilentAuthMessage } from "./shared-types.js";
|
|
50
|
-
export { AUTH_REQUEST_DEADLINE_MS, AUTH_ROUTE_PREFIX, AUTH_ROUTE_SEGMENTS, authRoutePath, SILENT_AUTH_MESSAGE_SOURCE, type AuthRouteSegment, } from "./shared-types.js";
|
|
49
|
+
export { createOidcClient, DEFAULT_OIDC_SCOPES, DEFAULT_IDP_REQUEST_TIMEOUT_MS } from "./oidc-client.js";
|
|
50
|
+
export type { ApiErrorBody, SilentAuthMessage, SignInErrorCode } from "./shared-types.js";
|
|
51
|
+
export { AUTH_REQUEST_DEADLINE_MS, AUTH_ROUTE_PREFIX, AUTH_ROUTE_SEGMENTS, authRoutePath, SILENT_AUTH_MESSAGE_SOURCE, SIGNIN_ERROR_QUERY_PARAM, SIGNIN_ERROR_CODES, type AuthRouteSegment, } from "./shared-types.js";
|
|
51
52
|
export { IdpError, IdpUnavailableError, IdpTimeoutError, IdpAccessRevokedError, AuthStoreError, OidcHttpError, classifyIdpError, } from "./errors.js";
|
|
52
53
|
export { generatePkce, randomState, type PkcePair } from "./pkce.js";
|
|
53
54
|
export { generateRefreshToken, hashRefreshToken, signAccessToken, verifyAccessToken, type AccessTokenClaims, } from "./tokens.js";
|
package/dist/auth/index.js
CHANGED
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
* redirectUri: "https://my-app.flytedesk.com/api/v1/auth/callback",
|
|
35
35
|
* appId: "my-app",
|
|
36
36
|
* postLoginRedirect: "https://my-app.flytedesk.com/",
|
|
37
|
+
* signInUrl: "https://my-app.flytedesk.com/sign-in",
|
|
37
38
|
* cookieSecret: process.env.COOKIE_SECRET!,
|
|
38
39
|
* secureCookies: process.env.NODE_ENV === "production",
|
|
39
40
|
* accessTokenSecret: process.env.JWT_SECRET!,
|
|
@@ -43,8 +44,8 @@
|
|
|
43
44
|
* app.get("/me", { preHandler: requireAuth }, async (request) => request.authUser);
|
|
44
45
|
*/
|
|
45
46
|
export { requireAuth, requirePermission } from "./guards.js";
|
|
46
|
-
export { createOidcClient, DEFAULT_OIDC_SCOPES,
|
|
47
|
-
export { AUTH_REQUEST_DEADLINE_MS, AUTH_ROUTE_PREFIX, AUTH_ROUTE_SEGMENTS, authRoutePath, SILENT_AUTH_MESSAGE_SOURCE, } from "./shared-types.js";
|
|
47
|
+
export { createOidcClient, DEFAULT_OIDC_SCOPES, DEFAULT_IDP_REQUEST_TIMEOUT_MS } from "./oidc-client.js";
|
|
48
|
+
export { AUTH_REQUEST_DEADLINE_MS, AUTH_ROUTE_PREFIX, AUTH_ROUTE_SEGMENTS, authRoutePath, SILENT_AUTH_MESSAGE_SOURCE, SIGNIN_ERROR_QUERY_PARAM, SIGNIN_ERROR_CODES, } from "./shared-types.js";
|
|
48
49
|
export { IdpError, IdpUnavailableError, IdpTimeoutError, IdpAccessRevokedError, AuthStoreError, OidcHttpError, classifyIdpError, } from "./errors.js";
|
|
49
50
|
export { generatePkce, randomState } from "./pkce.js";
|
|
50
51
|
export { generateRefreshToken, hashRefreshToken, signAccessToken, verifyAccessToken, } from "./tokens.js";
|
package/dist/auth/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAwB7D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAC;AAGzG,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,0BAA0B,EAC1B,wBAAwB,EACxB,kBAAkB,GAEnB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAiB,MAAM,WAAW,CAAC;AAErE,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAElB,MAAM,aAAa,CAAC"}
|
|
@@ -10,12 +10,12 @@ import type { UserinfoClaims } from "./types.js";
|
|
|
10
10
|
* narrower grant can override via `FlytedeskAuthOptions.scopes`/`OidcClientOptions.scopes`.
|
|
11
11
|
*/
|
|
12
12
|
export declare const DEFAULT_OIDC_SCOPES: readonly ["openid", "email", "profile", "offline_access"];
|
|
13
|
-
/** Sane default for
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* `OidcClientOptions.
|
|
18
|
-
export declare const
|
|
13
|
+
/** Sane default for EVERY flytedesk-id call this client makes (AK-20, gap 1 —
|
|
14
|
+
* generalized from AK-14 gap 5's `/token`-only timeout) — matches media-planner's
|
|
15
|
+
* `IDP_TOKEN_TIMEOUT_MS`, which `services/idpSession.ts` there sizes a DB transaction +
|
|
16
|
+
* advisory lock around specifically so it can never be held open while a flytedesk-id
|
|
17
|
+
* call is still in flight. Configurable via `OidcClientOptions.idpRequestTimeoutMs`. */
|
|
18
|
+
export declare const DEFAULT_IDP_REQUEST_TIMEOUT_MS = 5000;
|
|
19
19
|
export interface OidcClientOptions {
|
|
20
20
|
issuer: string;
|
|
21
21
|
clientId: string;
|
|
@@ -24,11 +24,22 @@ export interface OidcClientOptions {
|
|
|
24
24
|
/** OAuth scopes requested by `buildAuthorizeUrl`. Default `DEFAULT_OIDC_SCOPES`
|
|
25
25
|
* (includes `offline_access` — see that constant's doc comment). */
|
|
26
26
|
scopes?: string[];
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Bounds EVERY flytedesk-id call this client makes — `/token` (`exchangeCodeForTokens`,
|
|
29
|
+
* `refreshIdpTokens`), `/me` (`fetchUserinfo`), `/apps/{id}/authorization`
|
|
30
|
+
* (`fetchAuthorization`), `/me/apps` (`fetchMyApps`), discovery and revocation
|
|
31
|
+
* (`revokeIdpToken`) — via `AbortSignal.timeout`, through the one bounded-request
|
|
32
|
+
* helper every one of those methods goes through (AK-20, gap 1; generalized from
|
|
33
|
+
* AK-14 gap 5, which only bounded `/token`). Default `DEFAULT_IDP_REQUEST_TIMEOUT_MS`.
|
|
34
|
+
* A hung flytedesk-id response rejects with the typed `IdpTimeoutError` instead of
|
|
35
|
+
* hanging the caller (and, transitively, whatever lock/transaction/request it's
|
|
36
|
+
* inside) indefinitely. `fetchAuthorization` runs on every authenticated request
|
|
37
|
+
* (see `../plugin.ts`'s `loadAuthedUser`), so a hang there previously hung every
|
|
38
|
+
* signed-in request to every consumer of this package — this option is what closes
|
|
39
|
+
* that gap. No alias or deprecated name is kept for the old, narrower
|
|
40
|
+
* `tokenRequestTimeoutMs`.
|
|
41
|
+
*/
|
|
42
|
+
idpRequestTimeoutMs?: number;
|
|
32
43
|
}
|
|
33
44
|
export interface IdpTokenResponse {
|
|
34
45
|
access_token: string;
|
package/dist/auth/oidc-client.js
CHANGED
|
@@ -10,12 +10,12 @@ import { IdpTimeoutError, IdpUnavailableError, OidcHttpError } from "./errors.js
|
|
|
10
10
|
* narrower grant can override via `FlytedeskAuthOptions.scopes`/`OidcClientOptions.scopes`.
|
|
11
11
|
*/
|
|
12
12
|
export const DEFAULT_OIDC_SCOPES = ["openid", "email", "profile", "offline_access"];
|
|
13
|
-
/** Sane default for
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* `OidcClientOptions.
|
|
18
|
-
export const
|
|
13
|
+
/** Sane default for EVERY flytedesk-id call this client makes (AK-20, gap 1 —
|
|
14
|
+
* generalized from AK-14 gap 5's `/token`-only timeout) — matches media-planner's
|
|
15
|
+
* `IDP_TOKEN_TIMEOUT_MS`, which `services/idpSession.ts` there sizes a DB transaction +
|
|
16
|
+
* advisory lock around specifically so it can never be held open while a flytedesk-id
|
|
17
|
+
* call is still in flight. Configurable via `OidcClientOptions.idpRequestTimeoutMs`. */
|
|
18
|
+
export const DEFAULT_IDP_REQUEST_TIMEOUT_MS = 5_000;
|
|
19
19
|
/**
|
|
20
20
|
* One instance per FlytedeskAuthOptions (i.e. per plugin registration), not a module
|
|
21
21
|
* singleton — keeps the JWKS/discovery caches below scoped to one issuer/client pair
|
|
@@ -39,35 +39,42 @@ export function createOidcClient(opts) {
|
|
|
39
39
|
const clientSecret = encodeURIComponent(opts.clientSecret);
|
|
40
40
|
return "Basic " + Buffer.from(`${clientId}:${clientSecret}`).toString("base64");
|
|
41
41
|
}
|
|
42
|
-
const
|
|
42
|
+
const idpRequestTimeoutMs = opts.idpRequestTimeoutMs ?? DEFAULT_IDP_REQUEST_TIMEOUT_MS;
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
44
|
+
* The ONE bounded-request helper every flytedesk-id call in this client goes through
|
|
45
|
+
* (AK-20, gap 1) — `tokenRequest` below, `fetchUserinfo`, `fetchAuthorization`,
|
|
46
|
+
* `fetchMyApps`, `getDiscovery` and `revokeIdpToken`'s own POST all call this instead
|
|
47
|
+
* of `fetch` directly. Bounded by `AbortSignal.timeout`: unbounded before this card, a
|
|
48
|
+
* hung flytedesk-id response on ANY of these — most importantly `fetchAuthorization`,
|
|
49
|
+
* which runs on every authenticated request via `../plugin.ts`'s `loadAuthedUser` —
|
|
50
|
+
* could hold open whatever the caller wraps it in (for a consumer following
|
|
51
|
+
* media-planner's model, a Postgres transaction + advisory lock). A timeout throws the
|
|
52
|
+
* more specific `IdpTimeoutError`; any other network failure (DNS, refused connection,
|
|
53
|
+
* ...) is classified as `IdpUnavailableError` rather than propagating an unclassified
|
|
54
|
+
* error — both are typed, neither is swallowed. Deliberately does NOT inspect
|
|
55
|
+
* `res.ok`: a non-2xx response is still a normal, successfully-received `Response`,
|
|
56
|
+
* and each call site classifies it into its own message/error shape.
|
|
51
57
|
*/
|
|
52
|
-
async function
|
|
53
|
-
let res;
|
|
58
|
+
async function idpFetch(url, init, label) {
|
|
54
59
|
try {
|
|
55
|
-
|
|
56
|
-
method: "POST",
|
|
57
|
-
headers: {
|
|
58
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
59
|
-
Authorization: basicAuthHeader(),
|
|
60
|
-
},
|
|
61
|
-
body: new URLSearchParams(body).toString(),
|
|
62
|
-
signal: AbortSignal.timeout(tokenRequestTimeoutMs),
|
|
63
|
-
});
|
|
60
|
+
return await fetch(url, { ...init, signal: AbortSignal.timeout(idpRequestTimeoutMs) });
|
|
64
61
|
}
|
|
65
62
|
catch (err) {
|
|
66
63
|
if (err instanceof Error && (err.name === "TimeoutError" || err.name === "AbortError")) {
|
|
67
|
-
throw new IdpTimeoutError(`flytedesk-id
|
|
64
|
+
throw new IdpTimeoutError(`flytedesk-id ${label} did not respond within ${idpRequestTimeoutMs}ms`, err);
|
|
68
65
|
}
|
|
69
|
-
throw new IdpUnavailableError(`flytedesk-id
|
|
66
|
+
throw new IdpUnavailableError(`flytedesk-id ${label} request failed: ${err instanceof Error ? err.message : String(err)}`, err);
|
|
70
67
|
}
|
|
68
|
+
}
|
|
69
|
+
async function tokenRequest(body) {
|
|
70
|
+
const res = await idpFetch(issuerUrl("/token"), {
|
|
71
|
+
method: "POST",
|
|
72
|
+
headers: {
|
|
73
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
74
|
+
Authorization: basicAuthHeader(),
|
|
75
|
+
},
|
|
76
|
+
body: new URLSearchParams(body).toString(),
|
|
77
|
+
}, "/token");
|
|
71
78
|
if (!res.ok) {
|
|
72
79
|
const text = await res.text().catch(() => "");
|
|
73
80
|
throw new OidcHttpError(`flytedesk-id /token returned ${res.status}: ${text}`, res.status);
|
|
@@ -81,7 +88,7 @@ export function createOidcClient(opts) {
|
|
|
81
88
|
}
|
|
82
89
|
let discoveryCache;
|
|
83
90
|
function getDiscovery() {
|
|
84
|
-
discoveryCache ??=
|
|
91
|
+
discoveryCache ??= idpFetch(issuerUrl("/.well-known/openid-configuration"), {}, "discovery").then((res) => {
|
|
85
92
|
if (!res.ok)
|
|
86
93
|
throw new Error(`flytedesk-id discovery returned ${res.status}`);
|
|
87
94
|
return res.json();
|
|
@@ -144,9 +151,7 @@ export function createOidcClient(opts) {
|
|
|
144
151
|
/** `GET {issuer}/me` — the profile claims (email/name/email_verified) the id_token
|
|
145
152
|
* deliberately doesn't carry for the Authorization Code flow. */
|
|
146
153
|
async fetchUserinfo(idpAccessToken) {
|
|
147
|
-
const res = await
|
|
148
|
-
headers: { Authorization: `Bearer ${idpAccessToken}` },
|
|
149
|
-
});
|
|
154
|
+
const res = await idpFetch(issuerUrl("/me"), { headers: { Authorization: `Bearer ${idpAccessToken}` } }, "/me");
|
|
150
155
|
if (!res.ok) {
|
|
151
156
|
throw new OidcHttpError(`flytedesk-id userinfo (/me) returned ${res.status}`, res.status);
|
|
152
157
|
}
|
|
@@ -166,9 +171,7 @@ export function createOidcClient(opts) {
|
|
|
166
171
|
* by calling this live rather than memoizing the result — see FlytedeskAuthOptions
|
|
167
172
|
* authorizationCacheTtlMs's doc comment for the one sanctioned exception. */
|
|
168
173
|
async fetchAuthorization(idpAccessToken, appId) {
|
|
169
|
-
const res = await
|
|
170
|
-
headers: { Authorization: `Bearer ${idpAccessToken}` },
|
|
171
|
-
});
|
|
174
|
+
const res = await idpFetch(issuerUrl(`/apps/${appId}/authorization`), { headers: { Authorization: `Bearer ${idpAccessToken}` } }, "authorization endpoint");
|
|
172
175
|
if (!res.ok) {
|
|
173
176
|
throw new OidcHttpError(`flytedesk-id authorization endpoint returned ${res.status}`, res.status);
|
|
174
177
|
}
|
|
@@ -176,9 +179,7 @@ export function createOidcClient(opts) {
|
|
|
176
179
|
},
|
|
177
180
|
/** `GET {issuer}/me/apps` — see fetchMyApps's doc comment on OidcClient above. */
|
|
178
181
|
async fetchMyApps(idpAccessToken) {
|
|
179
|
-
const res = await
|
|
180
|
-
headers: { Authorization: `Bearer ${idpAccessToken}` },
|
|
181
|
-
});
|
|
182
|
+
const res = await idpFetch(issuerUrl("/me/apps"), { headers: { Authorization: `Bearer ${idpAccessToken}` } }, "/me/apps");
|
|
182
183
|
if (!res.ok) {
|
|
183
184
|
throw new OidcHttpError(`flytedesk-id /me/apps returned ${res.status}`, res.status);
|
|
184
185
|
}
|
|
@@ -194,17 +195,21 @@ export function createOidcClient(opts) {
|
|
|
194
195
|
const discovery = await getDiscovery();
|
|
195
196
|
if (!discovery.revocation_endpoint)
|
|
196
197
|
return false;
|
|
197
|
-
const res = await
|
|
198
|
+
const res = await idpFetch(discovery.revocation_endpoint, {
|
|
198
199
|
method: "POST",
|
|
199
200
|
headers: {
|
|
200
201
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
201
202
|
Authorization: basicAuthHeader(),
|
|
202
203
|
},
|
|
203
204
|
body: new URLSearchParams({ token }).toString(),
|
|
204
|
-
});
|
|
205
|
+
}, "revocation");
|
|
205
206
|
return res.ok;
|
|
206
207
|
}
|
|
207
208
|
catch {
|
|
209
|
+
// Best-effort by design (see this method's doc comment above) — a timed-out or
|
|
210
|
+
// otherwise-failed revocation (AK-20, gap 1) must never block local logout, so
|
|
211
|
+
// an IdpTimeoutError/IdpUnavailableError from idpFetch is swallowed here exactly
|
|
212
|
+
// like any other failure, not treated specially.
|
|
208
213
|
return false;
|
|
209
214
|
}
|
|
210
215
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oidc-client.js","sourceRoot":"","sources":["../../src/auth/oidc-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAwB,MAAM,MAAM,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIlF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,CAAU,CAAC;AAE7F;;;;
|
|
1
|
+
{"version":3,"file":"oidc-client.js","sourceRoot":"","sources":["../../src/au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