@oxyhq/core 17.0.0 → 17.0.3

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.
Files changed (36) hide show
  1. package/dist/cjs/.tsbuildinfo +1 -1
  2. package/dist/cjs/i18n/locales/en-US.json +6 -0
  3. package/dist/cjs/i18n/locales/es-ES.json +6 -0
  4. package/dist/cjs/i18n/locales/locales/en-US.json +6 -0
  5. package/dist/cjs/i18n/locales/locales/es-ES.json +6 -0
  6. package/dist/cjs/mixins/OxyServices.accounts.js +3 -1
  7. package/dist/cjs/server/userInvalidation.js +6 -0
  8. package/dist/cjs/session/accountDialogController.js +3 -1
  9. package/dist/cjs/session/accountProjection.js +19 -1
  10. package/dist/esm/.tsbuildinfo +1 -1
  11. package/dist/esm/i18n/locales/en-US.json +6 -0
  12. package/dist/esm/i18n/locales/es-ES.json +6 -0
  13. package/dist/esm/i18n/locales/locales/en-US.json +6 -0
  14. package/dist/esm/i18n/locales/locales/es-ES.json +6 -0
  15. package/dist/esm/mixins/OxyServices.accounts.js +1 -1
  16. package/dist/esm/server/userInvalidation.js +6 -0
  17. package/dist/esm/session/accountDialogController.js +3 -1
  18. package/dist/esm/session/accountProjection.js +19 -1
  19. package/dist/types/.tsbuildinfo +1 -1
  20. package/dist/types/crypto/keyManager.d.ts +2 -2
  21. package/dist/types/mixins/OxyServices.accounts.d.ts +8 -7
  22. package/dist/types/session/accountDialogController.d.ts +1 -1
  23. package/dist/types/session/accountProjection.d.ts +6 -0
  24. package/package.json +3 -3
  25. package/src/crypto/keyManager.ts +1 -2
  26. package/src/i18n/locales/en-US.json +6 -0
  27. package/src/i18n/locales/es-ES.json +6 -0
  28. package/src/mixins/OxyServices.accounts.ts +8 -8
  29. package/src/server/__tests__/userInvalidation.test.ts +14 -2
  30. package/src/server/userInvalidation.ts +6 -0
  31. package/src/session/__tests__/accountDialogController.test.ts +13 -1
  32. package/src/session/__tests__/accountProjection.test.ts +31 -0
  33. package/src/session/accountDialogController.ts +4 -2
  34. package/src/session/accountProjection.ts +19 -1
  35. package/src/types/color.d.ts +0 -20
  36. package/src/types/elliptic.d.ts +0 -70
@@ -54,6 +54,12 @@
54
54
  "status": {
55
55
  "accountSwitched": "Now using {{name}}",
56
56
  "signingIn": "Signing in…"
57
+ },
58
+ "errors": {
59
+ "notConfigured": "Sign-in isn't available",
60
+ "notConfiguredDescription": "{{app}} isn't set up for sign-in yet. Contact the app's developer.",
61
+ "failed": "Couldn't start sign-in",
62
+ "failedDescription": "Something went wrong. Please try again."
57
63
  }
58
64
  },
59
65
  "signup": {
@@ -54,6 +54,12 @@
54
54
  "status": {
55
55
  "accountSwitched": "Ahora usando {{name}}",
56
56
  "signingIn": "Iniciando sesión…"
57
+ },
58
+ "errors": {
59
+ "notConfigured": "El inicio de sesión no está disponible",
60
+ "notConfiguredDescription": "{{app}} todavía no está configurada para iniciar sesión. Contacta con quien desarrolla la app.",
61
+ "failed": "No se pudo iniciar sesión",
62
+ "failedDescription": "Algo ha ido mal. Inténtalo de nuevo."
57
63
  }
58
64
  },
59
65
  "signup": {
@@ -54,6 +54,12 @@
54
54
  "status": {
55
55
  "accountSwitched": "Now using {{name}}",
56
56
  "signingIn": "Signing in…"
57
+ },
58
+ "errors": {
59
+ "notConfigured": "Sign-in isn't available",
60
+ "notConfiguredDescription": "{{app}} isn't set up for sign-in yet. Contact the app's developer.",
61
+ "failed": "Couldn't start sign-in",
62
+ "failedDescription": "Something went wrong. Please try again."
57
63
  }
58
64
  },
59
65
  "signup": {
@@ -54,6 +54,12 @@
54
54
  "status": {
55
55
  "accountSwitched": "Ahora usando {{name}}",
56
56
  "signingIn": "Iniciando sesión…"
57
+ },
58
+ "errors": {
59
+ "notConfigured": "El inicio de sesión no está disponible",
60
+ "notConfiguredDescription": "{{app}} todavía no está configurada para iniciar sesión. Contacta con quien desarrolla la app.",
61
+ "failed": "No se pudo iniciar sesión",
62
+ "failedDescription": "Algo ha ido mal. Inténtalo de nuevo."
57
63
  }
58
64
  },
59
65
  "signup": {
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ORGANIZATION_CATEGORIES = void 0;
3
+ exports.isActAsEligibleKind = exports.ORGANIZATION_CATEGORIES = exports.ACCOUNT_KINDS = void 0;
4
4
  exports.OxyServicesAccountsMixin = OxyServicesAccountsMixin;
5
5
  const userIdentity_1 = require("../utils/userIdentity");
6
6
  const mixinHelpers_1 = require("./mixinHelpers");
7
7
  var contracts_1 = require("@oxyhq/contracts");
8
+ Object.defineProperty(exports, "ACCOUNT_KINDS", { enumerable: true, get: function () { return contracts_1.ACCOUNT_KINDS; } });
8
9
  Object.defineProperty(exports, "ORGANIZATION_CATEGORIES", { enumerable: true, get: function () { return contracts_1.ORGANIZATION_CATEGORIES; } });
10
+ Object.defineProperty(exports, "isActAsEligibleKind", { enumerable: true, get: function () { return contracts_1.isActAsEligibleKind; } });
9
11
  function OxyServicesAccountsMixin(Base) {
10
12
  return class extends Base {
11
13
  constructor(...args) {
@@ -166,6 +166,12 @@ function createOxyUserInvalidationHandler(options = {}) {
166
166
  * wrong data.
167
167
  */
168
168
  function evictOxyIdentityCache(oxy, userId) {
169
+ // Match the sweep the user mixin runs after a local profile write — session-
170
+ // bound and /users/me entries are keyed without the user id, so they must be
171
+ // prefix-swept on cross-service invalidation too.
172
+ oxy.clearCacheByPrefix('GET:/session/user/');
173
+ oxy.clearCacheByPrefix('GET:/users/me');
174
+ oxy.clearCacheByPrefix('GET:/auth/lookup/');
169
175
  oxy.clearCacheEntry(`GET:/users/${userId}`);
170
176
  oxy.clearCacheByPrefix('GET:/profiles/username/');
171
177
  oxy.clearCacheByPrefix('GET:/profiles/resolve');
@@ -459,7 +459,7 @@ class AccountDialogController {
459
459
  */
460
460
  async switchTo(accountId) {
461
461
  if (this.switchingAccountId)
462
- return;
462
+ return false;
463
463
  this.switchingAccountId = accountId;
464
464
  this.error = null;
465
465
  this.emit();
@@ -488,9 +488,11 @@ class AccountDialogController {
488
488
  }
489
489
  // Re-project + refetch immediately; the subscription also fires.
490
490
  await this.refresh();
491
+ return true;
491
492
  }
492
493
  catch (error) {
493
494
  this.error = errorMessage(error);
495
+ return false;
494
496
  }
495
497
  finally {
496
498
  this.switchingAccountId = null;
@@ -20,6 +20,7 @@
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.projectSwitchableAccounts = projectSwitchableAccounts;
22
22
  exports.switchableAccountIds = switchableAccountIds;
23
+ const contracts_1 = require("@oxyhq/contracts");
23
24
  const accountUtils_1 = require("../utils/accountUtils");
24
25
  const userHandle_1 = require("../utils/userHandle");
25
26
  /**
@@ -30,6 +31,9 @@ const userHandle_1 = require("../utils/userHandle");
30
31
  * graph-only rows (in graph order). An account present as BOTH a device session
31
32
  * and a graph node is deduped into ONE device row enriched with the graph
32
33
  * metadata (relationship / kind / parent / membership).
34
+ *
35
+ * Graph nodes of a kind nobody may act as (`channel`) are omitted — see the
36
+ * filter below.
33
37
  */
34
38
  function projectSwitchableAccounts(input) {
35
39
  const { state, graph, profilesById, activeUser, locale, resolveAvatarUrl } = input;
@@ -99,6 +103,17 @@ function projectSwitchableAccounts(input) {
99
103
  continue;
100
104
  }
101
105
  // Graph-only account (owned org / shared, not yet a device session).
106
+ //
107
+ // This lane is why a no-login account is NOT kept out of the switcher "by
108
+ // construction": the graph contributes accounts that have no device session
109
+ // and no credentials at all, which is exactly how an org first becomes
110
+ // switchable. So a kind that must never be switched into has to be filtered
111
+ // HERE, and `isActAsEligibleKind` is the same predicate the server enforces
112
+ // on `POST /accounts/:id/switch` — offering a row the server would 403 is a
113
+ // dead button.
114
+ if (!(0, contracts_1.isActAsEligibleKind)(node.kind)) {
115
+ continue;
116
+ }
102
117
  remember(toRow(node.account, {
103
118
  relationship: node.relationship,
104
119
  kind: node.kind,
@@ -117,6 +132,9 @@ function projectSwitchableAccounts(input) {
117
132
  * `oxyServices.getUsersByIds(...)`; graph nodes already embed their `account`
118
133
  * document, but including their ids lets the caller pass one id set and lets the
119
134
  * projection prefer freshly-fetched profiles uniformly.
135
+ *
136
+ * Applies the SAME act-as filter as {@link projectSwitchableAccounts} to graph
137
+ * nodes, so this never fetches a profile for a row the projection will drop.
120
138
  */
121
139
  function switchableAccountIds(state, graph) {
122
140
  const ids = new Set();
@@ -126,7 +144,7 @@ function switchableAccountIds(state, graph) {
126
144
  }
127
145
  }
128
146
  for (const node of graph) {
129
- if (node.accountId) {
147
+ if (node.accountId && (0, contracts_1.isActAsEligibleKind)(node.kind)) {
130
148
  ids.add(node.accountId);
131
149
  }
132
150
  }