@oxy.so/core 1.8.1 → 1.9.0

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.
@@ -1850,6 +1850,7 @@
1850
1850
  "switch": {
1851
1851
  "title": "Switch account",
1852
1852
  "count": "{{count}} accounts",
1853
+ "countOne": "{{count}} account",
1853
1854
  "empty": "Accounts you own or share"
1854
1855
  }
1855
1856
  },
@@ -1970,7 +1971,8 @@
1970
1971
  "loading": "Loading sessions…",
1971
1972
  "empty": "No active sessions",
1972
1973
  "signOutAllOnThisDevice": "Sign out of all other devices",
1973
- "signOutAllSubtitle": "End {{count}} other device session(s)"
1974
+ "signOutAllSubtitle": "End {{count}} other device session(s)",
1975
+ "otherSession": "Another session"
1974
1976
  },
1975
1977
  "confirms": {
1976
1978
  "removeDeviceTitle": "Remove device",
@@ -1850,6 +1850,7 @@
1850
1850
  "switch": {
1851
1851
  "title": "Cambiar de cuenta",
1852
1852
  "count": "{{count}} cuentas",
1853
+ "countOne": "{{count}} cuenta",
1853
1854
  "empty": "Cuentas que posees o compartes"
1854
1855
  }
1855
1856
  },
@@ -1970,7 +1971,8 @@
1970
1971
  "loading": "Cargando sesiones…",
1971
1972
  "empty": "No hay sesiones activas",
1972
1973
  "signOutAllOnThisDevice": "Cerrar sesión en los demás dispositivos",
1973
- "signOutAllSubtitle": "Finalizar {{count}} sesión(es) de otros dispositivos"
1974
+ "signOutAllSubtitle": "Finalizar {{count}} sesión(es) de otros dispositivos",
1975
+ "otherSession": "Otra sesión"
1974
1976
  },
1975
1977
  "confirms": {
1976
1978
  "removeDeviceTitle": "Eliminar dispositivo",
@@ -1850,6 +1850,7 @@
1850
1850
  "switch": {
1851
1851
  "title": "Switch account",
1852
1852
  "count": "{{count}} accounts",
1853
+ "countOne": "{{count}} account",
1853
1854
  "empty": "Accounts you own or share"
1854
1855
  }
1855
1856
  },
@@ -1970,7 +1971,8 @@
1970
1971
  "loading": "Loading sessions…",
1971
1972
  "empty": "No active sessions",
1972
1973
  "signOutAllOnThisDevice": "Sign out of all other devices",
1973
- "signOutAllSubtitle": "End {{count}} other device session(s)"
1974
+ "signOutAllSubtitle": "End {{count}} other device session(s)",
1975
+ "otherSession": "Another session"
1974
1976
  },
1975
1977
  "confirms": {
1976
1978
  "removeDeviceTitle": "Remove device",
@@ -1850,6 +1850,7 @@
1850
1850
  "switch": {
1851
1851
  "title": "Cambiar de cuenta",
1852
1852
  "count": "{{count}} cuentas",
1853
+ "countOne": "{{count}} cuenta",
1853
1854
  "empty": "Cuentas que posees o compartes"
1854
1855
  }
1855
1856
  },
@@ -1970,7 +1971,8 @@
1970
1971
  "loading": "Cargando sesiones…",
1971
1972
  "empty": "No hay sesiones activas",
1972
1973
  "signOutAllOnThisDevice": "Cerrar sesión en los demás dispositivos",
1973
- "signOutAllSubtitle": "Finalizar {{count}} sesión(es) de otros dispositivos"
1974
+ "signOutAllSubtitle": "Finalizar {{count}} sesión(es) de otros dispositivos",
1975
+ "otherSession": "Otra sesión"
1974
1976
  },
1975
1977
  "confirms": {
1976
1978
  "removeDeviceTitle": "Eliminar dispositivo",
@@ -58,6 +58,7 @@
58
58
  */
59
59
  Object.defineProperty(exports, "__esModule", { value: true });
60
60
  exports.AccountDialogController = void 0;
61
+ exports.backViewOf = backViewOf;
61
62
  exports.createAccountDialogController = createAccountDialogController;
62
63
  const logger_1 = require("../logger");
63
64
  const errorUtils_1 = require("../utils/errorUtils");
@@ -333,16 +334,25 @@ class AccountDialogController {
333
334
  }
334
335
  // Signed out. The directory is bearer-read and `SessionClient` drops the one
335
336
  // it holds when the device empties, so there is nothing to clear here — only
336
- // the in-flight bookkeeping, which no longer describes anything.
337
+ // the in-flight bookkeeping, which no longer describes anything. The account
338
+ // menu described the account that just left, so it gives way to the entry.
337
339
  this.error = null;
338
340
  this.loading = false;
341
+ this.view = this.resolveView(this.view);
339
342
  this.emit();
340
343
  }
341
344
  // =========================================================================
342
345
  // View actions
343
346
  // =========================================================================
344
- /** Set the dialog view directly. */
345
- setView(view) {
347
+ /**
348
+ * Set the dialog view directly.
349
+ *
350
+ * `'accounts'` is only honoured with a session. Signed out it lands on the
351
+ * sign-in entry instead — the menu it would open holds "Switch account",
352
+ * storage and "Sign out" for an account that does not exist.
353
+ */
354
+ setView(requested) {
355
+ const view = this.resolveView(requested);
346
356
  if (this.view === view)
347
357
  return;
348
358
  this.view = view;
@@ -355,6 +365,37 @@ class AccountDialogController {
355
365
  }
356
366
  this.emit();
357
367
  }
368
+ /**
369
+ * Go back one step: `signup` and `qr` return to the sign-in entry, and the
370
+ * entry returns to the account menu when somebody is signed in.
371
+ *
372
+ * Returns `false` — changing nothing — when the current view is the dialog's
373
+ * first one, so the host closes the dialog instead. Leaving an active
374
+ * request withdraws it; otherwise its authorize code stays approvable until
375
+ * it expires.
376
+ */
377
+ back() {
378
+ const target = backViewOf(this.view, this.hasSession());
379
+ if (target === null)
380
+ return false;
381
+ if (this.signIn.phase === 'starting' || this.signIn.phase === 'waiting') {
382
+ this.cancelSignIn();
383
+ }
384
+ this.setView(target);
385
+ return true;
386
+ }
387
+ /** `'accounts'` needs a session; without one the sign-in entry stands in for it. */
388
+ resolveView(view) {
389
+ return view === 'accounts' && !this.hasSession() ? 'signin' : view;
390
+ }
391
+ /**
392
+ * Whether an account is signed in here — the precondition of the account
393
+ * menu. The bearer, not the directory: the directory is bearer-read, and the
394
+ * menu's content (hero, storage, sign-out) is all about the bearer's account.
395
+ */
396
+ hasSession() {
397
+ return this.isAuthenticated();
398
+ }
358
399
  /** Switch to the "add account" view (the sign-in entry chooser). */
359
400
  add() {
360
401
  this.setView('add');
@@ -1289,8 +1330,13 @@ class AccountDialogController {
1289
1330
  }
1290
1331
  computeSnapshot() {
1291
1332
  const directory = this.sessionClient.getDirectory();
1333
+ const hasSession = this.hasSession();
1334
+ // Resolved here as well as in `setView`: the controller is constructed on
1335
+ // `'accounts'` before anyone knows whether a bearer exists.
1336
+ const view = this.resolveView(this.view);
1292
1337
  return {
1293
- view: this.view,
1338
+ view,
1339
+ backView: backViewOf(view, hasSession),
1294
1340
  directory,
1295
1341
  activeContext: (0, deviceDirectory_1.resolveActiveContext)(directory),
1296
1342
  loading: this.loading,
@@ -1316,6 +1362,29 @@ class AccountDialogController {
1316
1362
  }
1317
1363
  }
1318
1364
  exports.AccountDialogController = AccountDialogController;
1365
+ /**
1366
+ * The view one step back from `view`, or `null` when `view` is the dialog's
1367
+ * first view.
1368
+ *
1369
+ * The sign-in entry is `'add'` ("add another account") when somebody is signed
1370
+ * in and `'signin'` when nobody is; `signup` and `qr` are reached FROM that
1371
+ * entry, so they return to it. The entry itself returns to the account menu —
1372
+ * which exists only with a session. This used to be a host-side
1373
+ * "back = accounts" that assumed a signed-in origin, so a signed-out Back from
1374
+ * "Create your account" opened a menu holding "Sign out" for nobody.
1375
+ */
1376
+ function backViewOf(view, hasSession) {
1377
+ switch (view) {
1378
+ case 'signup':
1379
+ case 'qr':
1380
+ return hasSession ? 'add' : 'signin';
1381
+ case 'add':
1382
+ return hasSession ? 'accounts' : null;
1383
+ case 'signin':
1384
+ case 'accounts':
1385
+ return null;
1386
+ }
1387
+ }
1319
1388
  /** Factory mirroring `createSessionClient`, for ergonomic wiring by consumers. */
1320
1389
  function createAccountDialogController(options) {
1321
1390
  return new AccountDialogController(options);