@@ -3,10 +3,6 @@ import { metaDeviceLogin, type MetaOAuthTokens } from "@corbits/meta-provider";
33import type { AuthProfile } from "../store.js" ;
44import { saveMetaProfile } from "../../config/oauth-stores.js" ;
55
6- // Meta's device flow is a direct RFC 8628 exchange: there is no PKCE loopback
7- // server and no authorization-code round trip. `startMetaLogin` adapts the
8- // self-contained `metaDeviceLogin` into the TUI's `OAuthLoginHandle` shape so
9- // the sign-in step can wait on a single promise.
106export type MetaLoginHandle = {
117 authorizeUrl : string ;
128 completed : Promise < {
@@ -20,34 +16,22 @@ export type StartMetaLoginOptions = {
2016 profile : string ;
2117 signal : AbortSignal ;
2218 home ?: string ;
23- /** Injectable fetch for tests (device authorize / token poll / mint). */
2419 fetchImpl ?: typeof fetch ;
25- /** Injectable sleep so tests skip real wall-clock waits. */
2620 sleep ?: ( ms : number , signal : AbortSignal ) => Promise < void > ;
27- /** Injectable clock for expiry math. */
2821 now ?: ( ) => number ;
29- /** Called with the device-code event so the TUI can surface verificationUri + userCode. */
3022 notify ?: ( event : {
3123 type : "device_code" ;
3224 verificationUri : string ;
3325 userCode : string ;
3426 } ) => void ;
3527} ;
3628
37- /**
38- * Runs Meta's device login. `metaDeviceLogin` owns the authorize → poll →
39- * mint sequence; `notify` surfaces the verification URI + user code so the
40- * caller can print them for the operator (Meta has no loopback callback).
41- * The returned handle resolves with the minted tokens once the flow
42- * completes, and `cancel` aborts the in-flight request.
43- */
4429export function startMetaLogin ( opts : StartMetaLoginOptions ) : MetaLoginHandle {
4530 const controller = new AbortController ( ) ;
4631 const abort = ( ) : void => {
4732 controller . abort ( ) ;
4833 } ;
49- // The TUI's cancel is a soft abandon: it lets the underlying login reject
50- // with the cancel message (the same shape the caller matches on).
34+ // Abort only; the login promise rejects with the message the TUI matches.
5135 opts . signal . addEventListener ( "abort" , abort , { once : true } ) ;
5236
5337 let committed : Promise < void > | undefined ;
@@ -92,10 +76,7 @@ export function startMetaLogin(opts: StartMetaLoginOptions): MetaLoginHandle {
9276 } ) ( ) ;
9377
9478 return {
95- // The verification URI is surfaced via `notify` (device flow); the
96- // authorizeUrl slot is unused for Meta, but the TUI reads it for the
97- // "open this url" login box. Keep it empty — the device code box shows
98- // the real instructions instead.
79+ // Empty: notify carries the device URI; this slot is the open-url box.
9980 authorizeUrl : "" ,
10081 completed,
10182 cancel : abort ,
0 commit comments