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