@udibo/oauth2 0.14.0 → 0.14.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.
|
@@ -374,10 +374,20 @@ export interface HonoBffOptions {
|
|
|
374
374
|
* Who owns the BFF's session record. Defaults to `"own"`.
|
|
375
375
|
*
|
|
376
376
|
* - `"own"` (default): the BFF creates and owns its session at
|
|
377
|
-
* `/auth/callback` — it always mints a fresh id (`sessionStore.create`)
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
*
|
|
377
|
+
* `/auth/callback` — it always mints a fresh id (`sessionStore.create`).
|
|
378
|
+
* A session the inbound cookie names is replaced: once the code exchange
|
|
379
|
+
* and `resolveUser` succeed, the BFF destroys it (`sessionStore.destroy`)
|
|
380
|
+
* before creating the new one, so signing in again in the same browser —
|
|
381
|
+
* switching organization, a step-up — never leaves the earlier session
|
|
382
|
+
* readable beside the new one. Its refresh token is not revoked: an
|
|
383
|
+
* authorization server may extend a revocation to other tokens of the
|
|
384
|
+
* same grant or sign-in (RFC 7009 §2.1), the new ones included.
|
|
385
|
+
* A callback the authorization server refuses, or whose state check,
|
|
386
|
+
* code exchange or `resolveUser` fails, leaves the existing session as
|
|
387
|
+
* it was; a store failure while creating the replacement leaves the
|
|
388
|
+
* browser signed out. Use when the app has no session here until the
|
|
389
|
+
* OAuth flow completes: standalone BFFs, or apps whose login lives on a
|
|
390
|
+
* separate / external IDP.
|
|
381
391
|
* - `"shared"`: the app already created the session at its own login step,
|
|
382
392
|
* and the BFF **attaches** tokens to that existing session at
|
|
383
393
|
* `/auth/callback` (via `sessionStore.update`) instead of creating its
|
|
@@ -670,9 +670,10 @@ export class HonoBff {
|
|
|
670
670
|
createdAt: now,
|
|
671
671
|
updatedAt: now,
|
|
672
672
|
};
|
|
673
|
-
const
|
|
674
|
-
|
|
675
|
-
|
|
673
|
+
const inbound = getCookie(c, this.#cookieName);
|
|
674
|
+
const existing = this.#sessionMode === "shared" ? inbound : undefined;
|
|
675
|
+
if (inbound && !existing)
|
|
676
|
+
await this.#store.destroy(inbound);
|
|
676
677
|
const cookieValue = existing
|
|
677
678
|
? await this.#store.update(existing, data)
|
|
678
679
|
: await this.#store.create(data);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@udibo/oauth2",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.1",
|
|
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",
|