Skip to content

Commit 20ce1e9

Browse files
sea-snakeclaude
andcommitted
feat: let AuthClient take identity and session storage
AuthClient now takes identityStorage and sessionStorage instead of one combined store, which is what lets an application share sign-in state across sibling subdomains by handing it CookieSessionStorage. The client is key-type agnostic as a result: the keyType option, the pending-key machinery, key (de)serialization, StoredKey and the localStorage migration are all gone, because the choice of algorithm now belongs to the identity store. The window flow persists the key only once a delegation is obtained, so a cancelled or failed ceremony can no longer overwrite the key of a session that is still valid. The redirect flow has to persist on the outbound load, since the key must survive the navigation, so #hydrate and #reconcile verify that the stored key matches the delegation's leaf public key and discard the session on a mismatch rather than assembling an identity that signs with an unauthorized key. subscribe() and dispose() expose the stores' change events and re-derive the identity on an external sign-in or sign-out. isAuthenticated() is synchronous, reading the session's expiry directly. Each concrete store owns its own storage slot, so no slot-key constants are exported. BREAKING CHANGE: removes the keyType option and the AuthClientStorage and StoredKey interfaces, along with the IdbStorage, LocalStorage and KEY_STORAGE_* exports; renames the storage option to identityStorage and adds sessionStorage. Existing sessions are not migrated and users re-authenticate. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 6656c45 commit 20ce1e9

7 files changed

Lines changed: 607 additions & 803 deletions

File tree

.claude/rules/team-general

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/thomas.gladdines/.identity-team-skills/rules/general

src/client/auth-client.ts

Lines changed: 282 additions & 420 deletions
Large diffs are not rendered by default.

src/client/index.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,3 @@ export * from './idle-manager.js';
1515
export { LocalIdentityStorage } from './local-identity-storage.js';
1616
export { LocalSessionStorage } from './local-session-storage.js';
1717
export type { Session, SessionStorage } from './session-storage.js';
18-
export {
19-
type AuthClientStorage,
20-
IdbStorage,
21-
KEY_STORAGE_DELEGATION,
22-
KEY_STORAGE_KEY,
23-
LocalStorage,
24-
} from './storage.js';

src/client/storage.ts

Lines changed: 0 additions & 112 deletions
This file was deleted.

0 commit comments

Comments
 (0)