agl 42.2.0 → 42.2.2
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.
- package/changelog.md +12 -0
- package/dist_serve/bundle.js +3 -3
- package/dist_serve/bundle.js.map +2 -2
- package/dist_serve/bundle.js.third-party-notices.json +31 -31
- package/dist_serve/bundle.js.third-party-notices.txt +31 -31
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/functions.monacoassets.js +3 -3
- package/dist_ts_authswitch/classes.authoritybroker.d.ts +6 -0
- package/dist_ts_authswitch/classes.authoritybroker.js +42 -19
- package/dist_ts_authswitch/classes.authorityusage.js +5 -3
- package/dist_ts_authswitch/classes.claudeauthority.js +2 -2
- package/docs/authswitch.md +3 -1
- package/package.json +2 -2
- package/readme.md +1 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/functions.monacoassets.ts +2 -2
- package/ts_authswitch/classes.authoritybroker.ts +38 -16
- package/ts_authswitch/classes.authorityusage.ts +5 -2
- package/ts_authswitch/classes.claudeauthority.ts +1 -1
- package/ts_web/00_commitinfo_data.ts +1 -1
|
@@ -315,21 +315,7 @@ export class AuthSwitchAuthorityBroker {
|
|
|
315
315
|
after = page.at(-1)!.id;
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
-
|
|
319
|
-
while (true) {
|
|
320
|
-
const page = await this.database.grantsByState('exchange_may_have_been_sent', after);
|
|
321
|
-
if (!page.length) break;
|
|
322
|
-
for (const grant of page) {
|
|
323
|
-
const updateId = plugins.crypto.randomUUID();
|
|
324
|
-
await this.database.changeGrant(updateId, grant.id, current => {
|
|
325
|
-
if (!current || current.state !== 'exchange_may_have_been_sent') throw new Error('Refresh recovery changed concurrently.');
|
|
326
|
-
return { ...current, state: 'needs_reauth', attemptId: null, problem: 'exchange_uncertain',
|
|
327
|
-
revision: current.revision + 1, statusObservedAt: new Date(this.now()).toISOString(), updateId };
|
|
328
|
-
});
|
|
329
|
-
this.publish();
|
|
330
|
-
}
|
|
331
|
-
after = page.at(-1)!.id;
|
|
332
|
-
}
|
|
318
|
+
await this.endUnheldRefreshes();
|
|
333
319
|
if (this.proactive) this.schedule();
|
|
334
320
|
}
|
|
335
321
|
|
|
@@ -363,6 +349,42 @@ export class AuthSwitchAuthorityBroker {
|
|
|
363
349
|
after = page.at(-1)!.id;
|
|
364
350
|
}
|
|
365
351
|
}
|
|
352
|
+
await this.endUnheldRefreshes();
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Ends every refresh marker no renewal of this daemon holds. Only this daemon renews, so such an attempt is over with
|
|
357
|
+
* its outcome unrecorded: it failed past its marker, or an earlier daemon died during it. Its exchange may have spent
|
|
358
|
+
* the token, so it is never replayed and only a sign-in repairs the login.
|
|
359
|
+
*/
|
|
360
|
+
private async endUnheldRefreshes(): Promise<void> {
|
|
361
|
+
let after: string | null = null;
|
|
362
|
+
while (!this.closed) {
|
|
363
|
+
const page = await this.database.grantsByState('exchange_may_have_been_sent', after);
|
|
364
|
+
if (!page.length) break;
|
|
365
|
+
for (const grant of page) {
|
|
366
|
+
if (this.refreshes.has(grant.accountId) || this.claudeGrants?.pendingRefresh(grant.id)) continue;
|
|
367
|
+
const updateId = plugins.crypto.randomUUID();
|
|
368
|
+
try {
|
|
369
|
+
await this.database.changeGrant(updateId, grant.id, current => {
|
|
370
|
+
if (current.state !== 'exchange_may_have_been_sent' || current.attemptId !== grant.attemptId) {
|
|
371
|
+
throw new Error('Refresh recovery changed concurrently.');
|
|
372
|
+
}
|
|
373
|
+
return { ...current, state: 'needs_reauth', attemptId: null, problem: 'exchange_uncertain',
|
|
374
|
+
revision: current.revision + 1, statusObservedAt: new Date(this.now()).toISOString(), updateId };
|
|
375
|
+
});
|
|
376
|
+
} catch (error) {
|
|
377
|
+
// A renewal that ended between the page and this write has settled its own marker.
|
|
378
|
+
const latest = await this.database.readGrant(grant.id);
|
|
379
|
+
if (latest?.state === 'exchange_may_have_been_sent' && latest.attemptId === grant.attemptId) throw error;
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
process.stderr.write(`Authswitch ended login ${grant.id}: its renewal stopped with no recorded outcome, `
|
|
383
|
+
+ 'so it needs a new sign-in.\n');
|
|
384
|
+
this.publish();
|
|
385
|
+
}
|
|
386
|
+
after = page.at(-1)!.id;
|
|
387
|
+
}
|
|
366
388
|
}
|
|
367
389
|
|
|
368
390
|
private isDue(grant: IStoredAuthorityGrant, minValidityMs: number): boolean {
|
|
@@ -1521,7 +1543,7 @@ export class AuthSwitchAuthorityBroker {
|
|
|
1521
1543
|
statusObservedAt: new Date(this.now()).toISOString(), updateId: uncertainId };
|
|
1522
1544
|
});
|
|
1523
1545
|
this.publish();
|
|
1524
|
-
} catch { /*
|
|
1546
|
+
} catch { /* The next scan ends the marker this left (`endUnheldRefreshes`). */ }
|
|
1525
1547
|
// The grant is now `needs_reauth`: an uncertain rotation is never replayed, so only a sign-in repairs it.
|
|
1526
1548
|
throw new AuthSwitchRefusal('login_needs_reauth', loginNeedsReauth);
|
|
1527
1549
|
}
|
|
@@ -405,6 +405,10 @@ const native = (context: IAuthSwitchUsageContext): boolean => context.providerId
|
|
|
405
405
|
const readable = (context: IAuthSwitchUsageContext): boolean => usable(context)
|
|
406
406
|
|| (native(context) && !context.removed && context.nativeSource === null);
|
|
407
407
|
|
|
408
|
+
/** What keeps a login of a readable kind from being read now, so its usage is missing for want of access. */
|
|
409
|
+
const accessStoppedStates = ['exchange_may_have_been_sent', 'needs_reauth', 'handoff_pending', 'handoff_quarantined',
|
|
410
|
+
'legacy_native_pending'];
|
|
411
|
+
|
|
408
412
|
/**
|
|
409
413
|
* Whether a reading or observation made under one context still describes the login of another: the same account,
|
|
410
414
|
* login, subject, workspace, owner and authorization, and the same Claude Code home where both name one. A renewed token
|
|
@@ -938,8 +942,7 @@ export class AuthSwitchAuthorityUsage {
|
|
|
938
942
|
if (!readable(context)) {
|
|
939
943
|
this.unschedule(accountId, loginId);
|
|
940
944
|
return this.unavailable(accountId, loginId,
|
|
941
|
-
context.removed ||
|
|
942
|
-
? 'access_unavailable' : 'unsupported');
|
|
945
|
+
context.removed || accessStoppedStates.includes(context.grantState) ? 'access_unavailable' : 'unsupported');
|
|
943
946
|
}
|
|
944
947
|
let stored: IAuthSwitchStoredUsage | null;
|
|
945
948
|
try { stored = await this.options.store.read(accountId, loginId); }
|
|
@@ -165,7 +165,7 @@ export class ClaudeNativeAuthority {
|
|
|
165
165
|
});
|
|
166
166
|
this.changed();
|
|
167
167
|
} catch {
|
|
168
|
-
// The pre-send marker is durable.
|
|
168
|
+
// The pre-send marker is durable. The broker's next scan makes an unresolved rotation needs_reauth.
|
|
169
169
|
throw new Error('Claude refresh commit is uncertain; the previous token will not be replayed.');
|
|
170
170
|
}
|
|
171
171
|
}
|