-
Notifications
You must be signed in to change notification settings - Fork 0
feat: extract the login orchestration into a host-agnostic package #1276
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
5 commits
Select commit
Hold shift + click to select a range
f6d14a3
feat: extract the login orchestration into a host-agnostic package
claude 864e665
docs: name the shared login package in the host login sections
claude db020f9
test: cover web email collection and the login hex decoder edges
claude 8b602d1
docs: correct the hex codec claim and the shared login orchestration
claude 3d1c419
fix(login): key the restore latch on session and facade
claude 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
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
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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { collectedMethods } from '@cipherbox/login'; | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { webCollector } from './webCollector'; | ||
|
|
||
| describe('web credential collection', () => { | ||
| it('offers every method a browser can collect', () => { | ||
| expect(collectedMethods(webCollector('google-client-id'))).toEqual([ | ||
| 'google', | ||
| 'email', | ||
| 'wallet', | ||
| ]); | ||
| }); | ||
|
|
||
| // The missing variable disables one method, never the session: a build | ||
| // without it still logs in by email and wallet (`engine/config`). | ||
| it('drops only google when the build carries no client ID', () => { | ||
| expect(collectedMethods(webCollector(undefined))).toEqual(['email', 'wallet']); | ||
| }); | ||
|
|
||
| it('passes the material the page already collected straight through', async () => { | ||
| const collector = webCollector('google-client-id'); | ||
| const proof = { message: 'siwe-message', signature: '0xabc' }; | ||
| const answer = { email: 'user@example.com', code: '123456' }; | ||
|
|
||
| await expect(collector.google?.('google.id.token')).resolves.toBe('google.id.token'); | ||
| await expect(collector.email?.(answer)).resolves.toBe(answer); | ||
| await expect(collector.wallet?.(proof)).resolves.toBe(proof); | ||
| }); | ||
| }); | ||
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,32 @@ | ||
| /** | ||
| * Web's credential collection (ADR 0008 D3). Collection happens in the DOM | ||
| * before the flow is called — Google Identity Services renders its own button | ||
| * and hands the page a token, and wagmi signs in the wallet — so what the flow | ||
| * asks for is already in hand. A host that drives its own flow, as desktop's | ||
| * loopback OAuth listener does, does that work inside these collectors instead. | ||
| */ | ||
|
|
||
| import type { CollectedMaterial, CredentialCollector, WalletProof } from '@cipherbox/login'; | ||
|
|
||
| /** What each of web's collectors is handed. */ | ||
| export interface WebCollected extends CollectedMaterial { | ||
| /** The ID token Google Identity Services delivered. */ | ||
| google: string; | ||
| email: { email: string; code: string }; | ||
| wallet: WalletProof; | ||
| } | ||
|
|
||
| /** | ||
| * A build carrying no Google client ID renders no Google button, so the method | ||
| * is absent here to match — that alone disables it, and no other method is | ||
| * affected (`engine/config`). | ||
| */ | ||
| export function webCollector( | ||
| googleClientId: string | undefined | ||
| ): CredentialCollector<WebCollected> { | ||
| return { | ||
| google: googleClientId ? (idToken) => Promise.resolve(idToken) : undefined, | ||
| email: (answer) => Promise.resolve(answer), | ||
| wallet: (proof) => Promise.resolve(proof), | ||
| }; | ||
| } |
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.