@oxy.so/core 1.11.0 → 1.12.1
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/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/mixins/OxyServices.user.js +15 -6
- package/dist/cjs/session/accountDialogController.js +41 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/mixins/OxyServices.user.js +15 -6
- package/dist/esm/session/accountDialogController.js +41 -0
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/mixins/OxyServices.user.d.ts +11 -2
- package/dist/types/session/accountDialogController.d.ts +45 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/mixins/OxyServices.user.ts +23 -6
- package/src/mixins/__tests__/getUsersByIds.test.ts +27 -0
- package/src/session/__tests__/accountDialogController.test.ts +173 -0
- package/src/session/__tests__/accountDialogShape.test.ts +1 -0
- package/src/session/accountDialogController.ts +65 -0
|
@@ -278,8 +278,10 @@ export function OxyServicesUserMixin(Base) {
|
|
|
278
278
|
* caller, and returns the SAME public `{ data: PublicUserProfile[] }`
|
|
279
279
|
* payload (canonical `name.displayName` + `_count`) in every case — no
|
|
280
280
|
* viewer-specific fields. This method picks the path automatically:
|
|
281
|
-
* - **Service
|
|
282
|
-
* apiSecret)` has been called, the
|
|
281
|
+
* - **Service host (backend):** when `configureServiceAuth(apiKey,
|
|
282
|
+
* apiSecret)` has been called, OR the process can attest its workload
|
|
283
|
+
* identity (ADR 0026 — an ECS task with no key pair), the chunk is fetched
|
|
284
|
+
* via `makeServiceRequest`
|
|
283
285
|
* (attaches `Authorization: Bearer <serviceToken>`). This is the
|
|
284
286
|
* server-to-server feed/notification hydration path (e.g. Mention's
|
|
285
287
|
* `PostHydrationService`) and is unchanged.
|
|
@@ -310,10 +312,17 @@ export function OxyServicesUserMixin(Base) {
|
|
|
310
312
|
for (let i = 0; i < uniqueIds.length; i += USERS_BY_IDS_CHUNK_SIZE) {
|
|
311
313
|
chunks.push(uniqueIds.slice(i, i + USERS_BY_IDS_CHUNK_SIZE));
|
|
312
314
|
}
|
|
313
|
-
// A backend
|
|
314
|
-
//
|
|
315
|
-
//
|
|
316
|
-
|
|
315
|
+
// A backend uses the bearer-service path; any other caller (browser / RN
|
|
316
|
+
// with a user session) uses the user-bearer path. "A backend" means one
|
|
317
|
+
// that can get a service token at all — a key pair, OR a task role it can
|
|
318
|
+
// attest. Asking only about the key pair sent every attested backend down
|
|
319
|
+
// the user path with no bearer: an anonymous request, charged to the
|
|
320
|
+
// shared NAT address's per-IP budget and slowed by its 500ms penalty.
|
|
321
|
+
// Measured from Mention's task (2026-09-25): 520ms per anonymous chunk
|
|
322
|
+
// against 20ms with the service token, enough to put its 1.5s hydration
|
|
323
|
+
// deadline out of reach on every cache miss.
|
|
324
|
+
const useServiceAuth = Boolean(this._serviceApiKey && this._serviceApiSecret)
|
|
325
|
+
|| await this._canUseWorkloadIdentity();
|
|
317
326
|
// Run chunks concurrently; a single chunk failure must not sink the rest.
|
|
318
327
|
const settled = await Promise.all(chunks.map(async (chunk) => {
|
|
319
328
|
try {
|
|
@@ -488,6 +488,46 @@ export class AccountDialogController {
|
|
|
488
488
|
this.activatingContextId = null;
|
|
489
489
|
}, () => this.sessionClient.activateContext(contextId));
|
|
490
490
|
}
|
|
491
|
+
/**
|
|
492
|
+
* A device account row was chosen — the one entry point for "use this
|
|
493
|
+
* account", whether or not anybody is signed in here.
|
|
494
|
+
*
|
|
495
|
+
* Signed in, it is a switch: the active row is already the answer
|
|
496
|
+
* (`'current'`), any other row is {@link activateContext}.
|
|
497
|
+
*
|
|
498
|
+
* Signed out, it is NOT a switch. The row is on the list because the DEVICE
|
|
499
|
+
* still holds that identity (Commons' shared identity, or a sibling app's
|
|
500
|
+
* session), not because this app does, so there is no bearer to activate a
|
|
501
|
+
* context with — and the active-row short-circuit used to read that stale
|
|
502
|
+
* "active" as "already signed in" and close the sheet on a signed-out app
|
|
503
|
+
* (OxyHQ/oxy#1375 item 20). Choosing the row is "Continue as @handle": the
|
|
504
|
+
* same {@link signInWithOxy} path as the "Continue with Oxy" button, which
|
|
505
|
+
* mints silently from the shared identity and otherwise falls back to the
|
|
506
|
+
* request. When that silent mint lands on a different pair from the one
|
|
507
|
+
* chosen (a device holding more than one person, or an organization row), the
|
|
508
|
+
* chosen row is then activated under the new bearer, so the press ends where
|
|
509
|
+
* it pointed.
|
|
510
|
+
*/
|
|
511
|
+
async chooseContext(contextId) {
|
|
512
|
+
if (this.isDeviceMutationInFlight())
|
|
513
|
+
return 'busy';
|
|
514
|
+
if (this.hasSession()) {
|
|
515
|
+
if (contextId === this.snapshot.activeContext?.contextId)
|
|
516
|
+
return 'current';
|
|
517
|
+
return (await this.activateContext(contextId)) ? 'switched' : 'failed';
|
|
518
|
+
}
|
|
519
|
+
await this.signInWithOxy();
|
|
520
|
+
// Only a sign-in that finished here (the silent shared-identity mint) can be
|
|
521
|
+
// steered to the chosen row; a request still waiting on approval belongs to
|
|
522
|
+
// whoever approves it.
|
|
523
|
+
if (this.signIn.phase !== 'completed' || !this.hasSession())
|
|
524
|
+
return 'signing-in';
|
|
525
|
+
const directory = this.sessionClient.getDirectory();
|
|
526
|
+
const offered = directory?.principals.some((principal) => principal.contexts.some((context) => context.id === contextId));
|
|
527
|
+
if (!offered || resolveActiveContext(directory)?.contextId === contextId)
|
|
528
|
+
return 'signing-in';
|
|
529
|
+
return (await this.activateContext(contextId)) ? 'switched' : 'signing-in';
|
|
530
|
+
}
|
|
491
531
|
/**
|
|
492
532
|
* Remove ONE `principal → account` pair, and only that pair.
|
|
493
533
|
*
|
|
@@ -1332,6 +1372,7 @@ export class AccountDialogController {
|
|
|
1332
1372
|
return {
|
|
1333
1373
|
view,
|
|
1334
1374
|
backView: backViewOf(view, hasSession),
|
|
1375
|
+
hasSession,
|
|
1335
1376
|
directory,
|
|
1336
1377
|
activeContext: resolveActiveContext(directory),
|
|
1337
1378
|
loading: this.loading,
|