Repository navigation
refactor(account): delete the attachIdentity seam #17835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
186 commits
Select commit
Hold shift + click to select a range
c19c893
refactor(account): make hosts the single source of auth copy
MaanilVerma e211cd3
fix(locales): drop account-existence wording from email-already-in-use
MaanilVerma 64ece9e
test(auth): guard cloud auth copy against account enumeration
MaanilVerma 3aa6c3c
test(auth): address review nits on auth copy resolution
MaanilVerma 36c5790
test(website): assert the collapsed invalid-credential line on user-n…
MaanilVerma c66a653
fix(website): drop the unrenderable user-not-found/wrong-password copy
MaanilVerma 9348238
test(website): broaden the sign-in enumeration oracle to match the cl…
MaanilVerma b742c75
Merge branch 'main' into maanil/fe-2188-localization-sso
MaanilVerma 7184764
fix(locales): drop the unrenderable user-not-found/wrong-password copy
MaanilVerma d0e3c13
Merge branch 'main' into maanil/fe-2188-localization-sso
MaanilVerma 3633eb7
test(website): use the i18n generic-error copy after the main merge
MaanilVerma cea548a
Merge branch 'main' into maanil/fe-2188-localization-sso
MaanilVerma 61b4451
fix(workspace): type the session error key against the locale shape
MaanilVerma b7a3541
Merge branch 'main' into maanil/fe-2188-localization-sso
MaanilVerma 885faf4
Merge branch 'main' into maanil/fe-2188-localization-sso
MaanilVerma e68e3f0
Merge remote-tracking branch 'origin/main' into maanil/fe-2188-locali…
MaanilVerma 4db1dbe
Merge remote-tracking branch 'origin/main' into maanil/fe-2191-decomp…
MaanilVerma d69670b
refactor(account): add pure session state transition and mint arbitra…
MaanilVerma 7a16e1f
refactor(account): route every session commit through one transition
MaanilVerma 6c9c0a5
refactor(account): import AccountUser from sessionContracts in identity
MaanilVerma d5e9fc3
refactor(account): carry commit payloads in session events and effects
MaanilVerma 4878540
refactor(account): extract credential cache and mint coordinator from…
MaanilVerma 3ccca0d
refactor(account): keep credential freshness policy with the cache
MaanilVerma d18c716
Merge remote-tracking branch 'origin/main' into maanil/fe-2196-c2-con…
MaanilVerma ce6d000
feat(account): construct the session client with identity and add dis…
MaanilVerma c265fdb
fix(account): harden the construct-with-identity tests and neutralize…
MaanilVerma 4516673
refactor(cloud): construct the session client with identity in worksp…
MaanilVerma 75711dc
refactor(cloud): review fixes for construct-with-identity in workspac…
MaanilVerma e35ef22
feat(account): lazily activated identity port
MaanilVerma dcc57ab
refactor(website): construct the workshop session client with a lazy …
MaanilVerma 35d7eb4
fix(account): resolve lazy identity activation on the first delivery
MaanilVerma d043b0f
test(website): flag off then on never shows signed-out before Firebas…
MaanilVerma 78ed507
Merge remote-tracking branch 'origin/main' into maanil/fe-2196-c4-pac…
MaanilVerma c723b51
fix(account): drop a lazy identity loader rejection that lands after …
MaanilVerma 1e2216a
test(website): drive the workshop session host over the real session …
MaanilVerma f48b71c
feat(account): pass the popup resolver with host persistence, expose …
MaanilVerma 4695894
refactor(cloud): initialize Firebase through the account package, dro…
MaanilVerma 755e77e
Merge branch 'maanil/fe-2196-c3b-website-construct-with-identity' int…
MaanilVerma c6a9f83
refactor(cloud): route identity through the module, initialize explic…
MaanilVerma f1fd706
Merge remote-tracking branch 'origin/main' into maanil/fe-2196-c5-del…
MaanilVerma 8820c56
refactor(account): delete the attachIdentity seam
MaanilVerma eaec12f
docs(adr): record package-owned identity taken at construction
MaanilVerma 39dfbd8
test(auth): pin the non-initializing feature-flag read and the error-…
MaanilVerma 47b7a90
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma acabdcd
refactor(account): mint the Firebase identity brand through brandIden…
MaanilVerma fdacc24
docs(adr): state what AUTH-IDENTITY-0033 supersedes and who mints the…
MaanilVerma 79be5b3
test(account): share the session suites' fakes through one fixture mo…
MaanilVerma 821bdf6
refactor(account): route the expiry commit through the single commit …
MaanilVerma 20a8d0c
docs(auth): note observer-order independence and the pre-existing-app…
MaanilVerma c31f4ac
Merge branch 'maanil/fe-2191-decompose-session' into maanil/fe-2196-c…
MaanilVerma 75e3c28
Merge branch 'maanil/fe-2196-c2-construct-with-identity' into maanil/…
MaanilVerma 9dc4b31
fix(account): guard lazy identity delivery by generation and sign out…
MaanilVerma f5fc42b
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma 706de77
Merge branch 'maanil/fe-2196-c3b-website-construct-with-identity' int…
MaanilVerma 900ca23
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma f7e2e23
Merge remote-tracking branch 'origin/main' into maanil/fe-2191-decomp…
MaanilVerma e7153ec
Merge branch 'maanil/fe-2191-decompose-session' into maanil/fe-2196-c…
MaanilVerma 7459488
Merge branch 'maanil/fe-2196-c2-construct-with-identity' into maanil/…
MaanilVerma f2adf68
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma 370a871
Merge branch 'maanil/fe-2196-c3b-website-construct-with-identity' int…
MaanilVerma e4b82d4
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma 9874cfe
Merge branch 'main' into maanil/fe-2188-localization-sso
MaanilVerma 651e277
Merge branch 'maanil/fe-2188-localization-sso' into maanil/fe-2191-de…
MaanilVerma 59b7573
Merge branch 'maanil/fe-2191-decompose-session' into maanil/fe-2196-c…
MaanilVerma 1b84482
Merge branch 'maanil/fe-2196-c2-construct-with-identity' into maanil/…
MaanilVerma 8f17e4e
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma 3357db2
Merge branch 'maanil/fe-2196-c3b-website-construct-with-identity' int…
MaanilVerma 0244648
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma 71e38b3
refactor(account): split the session transition and mint arbitration …
MaanilVerma 0f96221
Merge branch 'maanil/fe-2191-decompose-session' into maanil/fe-2196-c…
MaanilVerma d48d1f1
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma 3edfb4c
Merge branch 'maanil/fe-2196-c3b-website-construct-with-identity' int…
MaanilVerma 5f7ad49
Merge branch 'maanil/fe-2196-c2-construct-with-identity' into maanil/…
MaanilVerma 008f5b5
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma 612a1bb
fix(account): tighten the popup mint to exactly one identity event
MaanilVerma 44bbc19
perf(account): read stored credentials only when the in-memory one is…
MaanilVerma d65981c
fix(account): let a failed lazy identity activation retry and settle …
MaanilVerma 84a1ca2
fix(account): detach an identity subscription disposed during its fir…
MaanilVerma 91acae0
fix(auth): read persisted Firebase sessions from IndexedDB at boot
MaanilVerma 7547ac9
test: type the Firebase Auth doubles
MaanilVerma 0a237d9
fix(account): apply the host's Auth dependencies to a pre-existing app
MaanilVerma 0122487
fix(auth): fail loudly when Firebase resolves before remote config
MaanilVerma aeb36fc
Merge branch 'maanil/fe-2191-decompose-session' into maanil/fe-2196-c…
MaanilVerma 6699d65
Merge branch 'maanil/fe-2196-c2-construct-with-identity' into maanil/…
MaanilVerma 709b4c8
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma 0fd63d5
Merge branch 'maanil/fe-2196-c3b-website-construct-with-identity' int…
MaanilVerma 23c5bb6
test(auth): share the enumeration oracle and cover the cancelled seco…
MaanilVerma df8ea1d
Merge branch 'main' into maanil/fe-2188-localization-sso
MaanilVerma d58fc50
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma 82e272e
Merge remote-tracking branch 'origin/maanil/fe-2188-localization-sso'…
MaanilVerma 65fa927
Merge branch 'maanil/fe-2191-decompose-session' into maanil/fe-2196-c…
MaanilVerma eb6dd94
Merge branch 'maanil/fe-2196-c2-construct-with-identity' into maanil/…
MaanilVerma 2e0858b
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma 3f4ad32
Merge branch 'maanil/fe-2196-c3b-website-construct-with-identity' int…
MaanilVerma 7f5094b
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma 448c4b9
Merge remote-tracking branch 'origin/main' into maanil/fe-2188-locali…
MaanilVerma 52054e1
Merge branch 'maanil/fe-2188-localization-sso' into maanil/fe-2191-de…
MaanilVerma 838ae89
Merge branch 'maanil/fe-2191-decompose-session' into maanil/fe-2196-c…
MaanilVerma d179a6c
Merge branch 'maanil/fe-2196-c2-construct-with-identity' into maanil/…
MaanilVerma eaa4428
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma 6e8dfcd
Merge branch 'maanil/fe-2196-c3b-website-construct-with-identity' int…
MaanilVerma 0c7766a
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma 386d96d
Merge remote-tracking branch 'origin/main' into maanil/fe-2188-locali…
MaanilVerma 1b89a09
Merge branch 'maanil/fe-2191-decompose-session' into maanil/fe-2196-c…
MaanilVerma ffbec33
Merge branch 'maanil/fe-2188-localization-sso' into maanil/fe-2191-de…
MaanilVerma ea2ac9a
Merge branch 'maanil/fe-2196-c2-construct-with-identity' into maanil/…
MaanilVerma bc0a230
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma 2889104
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma a846e1d
Merge branch 'maanil/fe-2196-c3b-website-construct-with-identity' int…
MaanilVerma 006f110
test(account): name the post-dispose explicit-user mint for what it does
MaanilVerma df6ffd7
refactor(account): name the mint guards by verdict and split the type…
MaanilVerma e87ba1f
fix(account): stop the auto-mint when the client is disposed during t…
MaanilVerma dc2ab4c
docs(account): state what lazy identity activation resolves on and th…
MaanilVerma b9b17fe
fix(cloud): record the Firebase init phase even when it throws
MaanilVerma 19ae957
test(account): take the identity suite's fakes from the shared fixture
MaanilVerma d48db49
test(account): share the session test fakes from one fixture module
MaanilVerma 086b0c1
test(account): keep the brand gate and the identity fakes honest
MaanilVerma 2edcccb
docs(cloud): describe the fail-closed Firebase resolution and the per…
MaanilVerma 88a3944
docs(account): record the compile-time brand and the persistence hier…
MaanilVerma c5801ad
test(cloud): model the Firebase first delivery one way and pin store …
MaanilVerma 016f718
docs(cloud): name the construction-order dependency behind the identi…
MaanilVerma 7306ed8
test(website): pin the lazy identity re-activation, the abandoned min…
MaanilVerma a68fe71
test(cloud): tighten the Firebase doubles and pin the port-first regi…
MaanilVerma 03bfdb7
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma 482ba49
Merge branch 'maanil/fe-2196-c2-construct-with-identity' into maanil/…
MaanilVerma 7d1d4c7
Merge branch 'maanil/fe-2191-decompose-session' into maanil/fe-2196-c…
MaanilVerma 37a84c2
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma 7af0afe
Merge branch 'maanil/fe-2196-c2-construct-with-identity' into maanil/…
MaanilVerma 1c7b2a4
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma 4bea63d
Merge branch 'maanil/fe-2196-c3b-website-construct-with-identity' int…
MaanilVerma 5e56bef
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma 9826d1b
Merge remote-tracking branch 'origin/main' into maanil/fe-2188-locali…
MaanilVerma f8e97d4
Merge branch 'maanil/fe-2188-localization-sso' into maanil/fe-2191-de…
MaanilVerma 4d98540
Merge branch 'maanil/fe-2191-decompose-session' into maanil/fe-2196-c…
MaanilVerma 53db9f3
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma ba5c637
Merge branch 'maanil/fe-2196-c2-construct-with-identity' into maanil/…
MaanilVerma bc716ee
Merge branch 'maanil/fe-2196-c3b-website-construct-with-identity' int…
MaanilVerma 69ae03c
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma 0ed3a4d
fix(account): construct the pack smoke client with identity after att…
MaanilVerma feaeccc
test(account): split the client builder out of the data fixture and d…
MaanilVerma 01a3b78
Merge branch 'maanil/fe-2191-decompose-session' into maanil/fe-2196-c…
MaanilVerma 112bec2
test(account): import the scheduler buffer default instead of copying it
MaanilVerma 83d8fb8
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma b321250
Merge branch 'maanil/fe-2196-c2-construct-with-identity' into maanil/…
MaanilVerma f32024e
Merge branch 'maanil/fe-2191-decompose-session' into maanil/fe-2196-c…
MaanilVerma 693f781
Merge branch 'maanil/fe-2196-c3b-website-construct-with-identity' int…
MaanilVerma 46c0778
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma e9a3ef0
test(account): pin the re-entrant identity delivery and tidy the bran…
MaanilVerma 4fbdc9b
fix(account): drop a session subscriber whose first replay throws
MaanilVerma 50580a6
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma 94b1495
Merge branch 'maanil/fe-2196-c2-construct-with-identity' into maanil/…
MaanilVerma 6b17307
Merge branch 'maanil/fe-2191-decompose-session' into maanil/fe-2196-c…
MaanilVerma da83189
test(website): pin the flag-off delivery, the cache hit, and trim the…
MaanilVerma 5b8b504
test(cloud): guard the replay port, export the settle ceiling, and ex…
MaanilVerma 1df3a2a
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma 9c1a388
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma 2ee9541
Merge branch 'maanil/fe-2196-c3b-website-construct-with-identity' int…
MaanilVerma 22fb0d7
test(account): drive the subscribe-guard test through construction id…
MaanilVerma 7614f52
Merge remote-tracking branch 'origin/main' into maanil/fe-2191-decomp…
MaanilVerma 4fa9efd
Merge branch 'maanil/fe-2191-decompose-session' into maanil/fe-2196-c…
MaanilVerma cb01c88
Merge branch 'maanil/fe-2196-c2-construct-with-identity' into maanil/…
MaanilVerma a8003b7
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma a4a0c77
Merge remote-tracking branch 'origin/maanil/fe-2196-c3b-website-const…
MaanilVerma 6eaa1b0
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma e8b0522
test(cloud): stub firebase and vuefire in the billing subscription-ra…
MaanilVerma e3ef8fd
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma 2949c2e
Merge remote-tracking branch 'origin/main' into maanil/fe-2196-c2-con…
MaanilVerma 4eea04e
Merge branch 'maanil/fe-2196-c2-construct-with-identity' into maanil/…
MaanilVerma c01fa5f
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma d145c57
Merge branch 'main' into maanil/fe-2196-c3-store-construct-with-identity
MaanilVerma 6e819ed
Merge branch 'maanil/fe-2196-c3-store-construct-with-identity' into m…
MaanilVerma a2187f8
Merge remote-tracking branch 'origin/maanil/fe-2196-c3b-website-const…
MaanilVerma 97866c9
Merge remote-tracking branch 'origin/maanil/fe-2196-c4-package-fireba…
MaanilVerma 5e57606
Merge remote-tracking branch 'origin/main' into maanil/fe-2196-c3-sto…
MaanilVerma 549b82b
fix(cloud): fail closed when a rollback catches a unified mint parked…
MaanilVerma c93e823
Merge remote-tracking branch 'origin/maanil/fe-2196-c3-store-construc…
MaanilVerma 0748a15
Merge remote-tracking branch 'origin/maanil/fe-2196-c3b-website-const…
MaanilVerma 0ff9345
Merge remote-tracking branch 'origin/maanil/fe-2196-c4-package-fireba…
MaanilVerma ba521c5
Merge remote-tracking branch 'origin/main' into maanil/fe-2196-c4-pac…
MaanilVerma 381c38f
fix: validate existing Firebase app project before reuse
MaanilVerma 5ec0021
test: load remote config before reusing an existing Firebase app
MaanilVerma 61235b3
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma cd67079
Merge branch 'main' into maanil/fe-2196-c4-package-firebase-init
MaanilVerma 53051ee
fix: narrow existing-app project check to the session-deciding fields
MaanilVerma d692d98
Merge branch 'maanil/fe-2196-c4-package-firebase-init' into maanil/fe…
MaanilVerma c63ac50
Merge remote-tracking branch 'origin/main' into maanil/fe-2196-c5-del…
MaanilVerma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
docs/adr/AUTH-IDENTITY-0033-account-package-owns-identity-taken-at-construction.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| # ADR-AUTH-IDENTITY-0033: The Account Package Owns Identity and the Session Client Takes It at Construction | ||
|
|
||
| Date: 2026-09-16 | ||
|
|
||
| ## Status | ||
|
|
||
| Accepted | ||
|
|
||
| Supersedes the original transitional text of | ||
| [AUTH-IDENTITY-0028](AUTH-IDENTITY-0028-account-package-firebase-entry-delivers-cloud-identity.md) | ||
| (the Pinia identity adapter and the `attachIdentity` seam); rules 1–5 of | ||
| 0028 as amended on 2026-09-16 stand. | ||
|
|
||
| ## Context | ||
|
|
||
| ADR-AUTH-IDENTITY-0028 first shipped a transitional shape: the cloud app | ||
| owned identity (vuefire plus the Pinia `authStore`) and pushed it into the | ||
| `@comfyorg/account` session client through `attachIdentity`, a | ||
| post-construction seam guarded at runtime by `isAccountIdentity`. The Workshop | ||
| site attached the same way. The account TDD needs the package to own Firebase | ||
| initialization and sign-in state so one account layer serves the cloud app, | ||
| the website, and platform.comfy.org, framework-agnostic and publishable, and | ||
| so SSO can land without a second source of identity truth. The seam was | ||
| marked `@deprecated` with this ADR as its tracked removal (FE-2196). | ||
|
|
||
| Before the migration, `createSessionClient` was a 744-line closure that | ||
| mutated session state from eleven sites; building the shared foundation on | ||
| that shape was rejected in review (FE-2191). | ||
|
|
||
| ## Decision | ||
|
|
||
| Identity ownership moves into the package, and the session client takes its | ||
| identity only at construction. Landed as one bottom-up stack, each slice | ||
| inert behind `unified_cloud_auth`: | ||
|
|
||
| 1. **Decomposition (FE-2191).** Every session commit runs through one pure | ||
| `transition(state, event)` in `sessionState.ts` that returns the next | ||
| state and an ordered effect list; mint arbitration is a pure function; | ||
| the credential cache and the in-flight mint coordinator are their own | ||
| modules. Behavior unchanged, proven by the untouched suites. | ||
| 2. **Constructor injection.** `createSessionClient(options, identity)` | ||
| subscribes the identity at construction; `dispose()` detaches it once and | ||
| is idempotent. `autoMint` is a client option. | ||
| 3. **The cloud store constructs with identity.** `workspaceAuthStore` passes | ||
| the package's Firebase entry to `createSessionClient`; the flag-watch | ||
| attach/detach and its re-sync helpers are gone. `authStore` is a | ||
| projection for app-wide side effects and pushes nothing into the client. | ||
| 4. **Lazy identity for the lazy-Firebase host.** The Workshop site loads | ||
| Firebase on first need, so the package ships `createLazyIdentity`: a | ||
| branded port that activates on its first delivery and drops loader | ||
| rejections that land after deactivation. Construct-with-identity holds | ||
| without eager Firebase. | ||
| 5. **Package-initialized Firebase.** The cloud app's identity module creates | ||
|
CodeJuggernaut marked this conversation as resolved.
Resolved
|
||
| the `[DEFAULT]` app from remote config through the package entry, with an | ||
| ordered persistence hierarchy (`browserLocalPersistence`, then | ||
| `indexedDBLocalPersistence`, the store vuefire persisted into, then | ||
| `browserSessionPersistence`) so an existing session is restored from any | ||
| of them and settles in localStorage, and with | ||
| `browserPopupRedirectResolver`, which `initializeAuth` does not wire on its | ||
| own and popup sign-in needs; vuefire no longer initializes Firebase, and | ||
| `main.ts` calls `initialize()` explicitly after remote config loads. | ||
| 6. **Seam deletion (this slice).** `attachIdentity`, `AttachIdentityOptions`, | ||
| and the `isAccountIdentity` runtime gate are removed. The `AccountIdentity` | ||
| brand is a compile-time gate only: the package's Firebase entry and | ||
| `createLazyIdentity` mint it, and the `testing` seam deliberately exposes | ||
| the minter as `createTestIdentity` for fakes. A hand-rolled port is a | ||
| compile error; no runtime check remains, so a JavaScript consumer is not | ||
| stopped. | ||
| Re-attaching or replacing an identity is no longer a behavior the client | ||
| has. | ||
|
|
||
| Hosts supply only adapters: storage, transport, clock, navigation, and the | ||
| active workspace. Mints stay host-driven in the cloud app (`autoMint: false`). | ||
|
|
||
| ### Invariants preserved (ADR-AUTH-CREDENTIALS-0011) | ||
|
|
||
| Live credential over storage; the popup mint before the first identity | ||
| delivery; refresh re-arm, cross-tab lease, and cookie rotation; the | ||
| `mintSequence` and target-mismatch fail-closed on a workspace switch; | ||
| sign-out through `invalidate()` keeps the identity; no personal-token | ||
| downgrade. Every mint, refresh, and arbitration assertion in the package | ||
| suites is unchanged across the stack. | ||
|
|
||
| ### Alternatives rejected | ||
|
|
||
| - **Keep the adapter permanently.** Blocks the framework-agnostic publish and | ||
| SSO, and calcifies a second identity authority. | ||
| - **Big-bang rewrite.** Unshippable without the flag as a safety net. | ||
| - **Package owns Firebase, host keeps identity authority.** Leaves the | ||
| dual source of truth the TDD exists to remove. | ||
| - **Keep `isAccountIdentity` as defense in depth.** It guarded unbranded ports | ||
| pushed in through `attachIdentity`, which no longer exists; the brand type is | ||
| the contract, and `./testing` is the one deliberate way to mint it. | ||
|
|
||
| ## Consequences | ||
|
|
||
| ### Positive | ||
|
|
||
| - The cloud app and the Workshop site bind identity the same way, through | ||
| the same package entry, so session behavior cannot drift between them. | ||
| - The Pinia stores are thin reactive views over `session.subscribe`. | ||
| - The package public surface is construction plus `dispose`, which is what | ||
| the core/ui split and the npm publish need; a non-Firebase identity later | ||
| is a second branded entry, not a host adapter. | ||
|
|
||
| ### Negative | ||
|
|
||
| - The package API is a breaking change for external consumers. Only Comfy | ||
| web surfaces consume it today. | ||
| - The Firebase-init switch was the highest-risk slice; its real-SDK | ||
| acceptance (popup sign-in, refresh re-arm, workspace switch, sign-out) is | ||
| proven only by the e2e gate in CI. | ||
| - The legacy workspace-token rail and the `unified_cloud_auth` flag remain | ||
| until FE-951 retires them. | ||
|
|
||
| ## Notes | ||
|
|
||
| Blast radius: the two auth stores, the sign-in composables and components, | ||
| the Workshop session host, and the package public API. No entity callback, | ||
| `node.*`, or `graph._version` surface is touched, so the ADR-CRDT-LAYOUT-0003 | ||
| and ADR-ECS-0008 extension-migration clause does not apply. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,53 +1,25 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
|
|
||
| import { brandIdentity, identityBrand, isAccountIdentity } from './identity.js' | ||
|
|
||
| describe('isAccountIdentity', () => { | ||
| it('accepts a port branded through the package entry', () => { | ||
| const identity = brandIdentity({ onUserChanged: () => () => undefined }) | ||
|
|
||
| expect( | ||
| isAccountIdentity(identity), | ||
| 'a port branded by the package must satisfy the full contract' | ||
| ).toBe(true) | ||
| }) | ||
|
|
||
| it('rejects a forged brand key whose value is not the literal true', () => { | ||
| const forged = { | ||
| onUserChanged: () => () => undefined, | ||
| [identityBrand]: false | ||
| } | ||
|
|
||
| expect( | ||
| isAccountIdentity(forged), | ||
| 'the brand must hold the literal true, not merely be present as a key' | ||
| ).toBe(false) | ||
| }) | ||
|
|
||
| it('rejects a branded object missing the onUserChanged method', () => { | ||
| const brandOnly = { [identityBrand]: true } | ||
|
|
||
| expect( | ||
| isAccountIdentity(brandOnly), | ||
| 'the guard promises onUserChanged, so a branded object without it must fail' | ||
| ).toBe(false) | ||
| }) | ||
|
|
||
| it('rejects a branded object whose onUserChanged is not callable', () => { | ||
| const wrongMethod = { | ||
| onUserChanged: 'not a function', | ||
| [identityBrand]: true | ||
| } | ||
|
|
||
| expect( | ||
| isAccountIdentity(wrongMethod), | ||
| 'onUserChanged must be a function for the guard to claim the contract' | ||
| ).toBe(false) | ||
| }) | ||
|
|
||
| it('rejects non-object values', () => { | ||
| expect(isAccountIdentity(null)).toBe(false) | ||
| expect(isAccountIdentity(undefined)).toBe(false) | ||
| expect(isAccountIdentity('branded')).toBe(false) | ||
| import { EXCHANGE_URL, memoryStorage } from './__fixtures__/sessionFakes.js' | ||
| import type { AccountIdentity } from './identity.js' | ||
| import { brandIdentity, identityBrand } from './identity.js' | ||
| import { createSessionClient } from './session.js' | ||
|
|
||
| describe('identity brand', () => { | ||
| it('an unbranded port is a compile error and brandIdentity stamps the brand without mutating its input', () => { | ||
|
CodeJuggernaut marked this conversation as resolved.
Resolved
|
||
| const port = { onUserChanged: () => () => undefined } | ||
| // @ts-expect-error an unbranded port is not an AccountIdentity | ||
| const unbranded: AccountIdentity = port | ||
| const branded: AccountIdentity = brandIdentity(port) | ||
| const client = createSessionClient( | ||
| { exchangeUrl: EXCHANGE_URL, storage: memoryStorage() }, | ||
| // @ts-expect-error createSessionClient takes only a branded identity | ||
| port | ||
| ) | ||
| client.dispose() | ||
|
|
||
| expect(branded[identityBrand]).toBe(true) | ||
| expect(branded.onUserChanged).toBe(port.onUserChanged) | ||
| expect(identityBrand in unbranded).toBe(false) | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.