@oxyhq/core 17.0.2 → 17.1.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.
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 +39 -1
  7. package/dist/cjs/session/accountDialogController.js +3 -1
  8. package/dist/cjs/session/accountProjection.js +19 -1
  9. package/dist/esm/.tsbuildinfo +1 -1
  10. package/dist/esm/i18n/locales/en-US.json +6 -0
  11. package/dist/esm/i18n/locales/es-ES.json +6 -0
  12. package/dist/esm/i18n/locales/locales/en-US.json +6 -0
  13. package/dist/esm/i18n/locales/locales/es-ES.json +6 -0
  14. package/dist/esm/mixins/OxyServices.accounts.js +37 -1
  15. package/dist/esm/session/accountDialogController.js +3 -1
  16. package/dist/esm/session/accountProjection.js +19 -1
  17. package/dist/types/.tsbuildinfo +1 -1
  18. package/dist/types/crypto/keyManager.d.ts +2 -2
  19. package/dist/types/index.d.ts +1 -1
  20. package/dist/types/mixins/OxyServices.accounts.d.ts +73 -9
  21. package/dist/types/models/interfaces.d.ts +17 -1
  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/index.ts +4 -0
  29. package/src/mixins/OxyServices.accounts.ts +115 -12
  30. package/src/models/interfaces.ts +17 -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
@@ -18,6 +18,7 @@
18
18
  */
19
19
 
20
20
  import type { DeviceSessionState } from '@oxyhq/contracts';
21
+ import { isActAsEligibleKind } from '@oxyhq/contracts';
21
22
  import type { User } from '../models/interfaces';
22
23
  import type {
23
24
  AccountNode,
@@ -142,6 +143,9 @@ export interface ProjectSwitchableAccountsInput {
142
143
  * graph-only rows (in graph order). An account present as BOTH a device session
143
144
  * and a graph node is deduped into ONE device row enriched with the graph
144
145
  * metadata (relationship / kind / parent / membership).
146
+ *
147
+ * Graph nodes of a kind nobody may act as (`channel`) are omitted — see the
148
+ * filter below.
145
149
  */
146
150
  export function projectSwitchableAccounts(input: ProjectSwitchableAccountsInput): SwitchableAccount[] {
147
151
  const { state, graph, profilesById, activeUser, locale, resolveAvatarUrl } = input;
@@ -227,6 +231,17 @@ export function projectSwitchableAccounts(input: ProjectSwitchableAccountsInput)
227
231
  continue;
228
232
  }
229
233
  // Graph-only account (owned org / shared, not yet a device session).
234
+ //
235
+ // This lane is why a no-login account is NOT kept out of the switcher "by
236
+ // construction": the graph contributes accounts that have no device session
237
+ // and no credentials at all, which is exactly how an org first becomes
238
+ // switchable. So a kind that must never be switched into has to be filtered
239
+ // HERE, and `isActAsEligibleKind` is the same predicate the server enforces
240
+ // on `POST /accounts/:id/switch` — offering a row the server would 403 is a
241
+ // dead button.
242
+ if (!isActAsEligibleKind(node.kind)) {
243
+ continue;
244
+ }
230
245
  remember(toRow(node.account, {
231
246
  relationship: node.relationship,
232
247
  kind: node.kind,
@@ -247,6 +262,9 @@ export function projectSwitchableAccounts(input: ProjectSwitchableAccountsInput)
247
262
  * `oxyServices.getUsersByIds(...)`; graph nodes already embed their `account`
248
263
  * document, but including their ids lets the caller pass one id set and lets the
249
264
  * projection prefer freshly-fetched profiles uniformly.
265
+ *
266
+ * Applies the SAME act-as filter as {@link projectSwitchableAccounts} to graph
267
+ * nodes, so this never fetches a profile for a row the projection will drop.
250
268
  */
251
269
  export function switchableAccountIds(
252
270
  state: DeviceSessionState | null,
@@ -259,7 +277,7 @@ export function switchableAccountIds(
259
277
  }
260
278
  }
261
279
  for (const node of graph) {
262
- if (node.accountId) {
280
+ if (node.accountId && isActAsEligibleKind(node.kind)) {
263
281
  ids.add(node.accountId);
264
282
  }
265
283
  }
@@ -1,20 +0,0 @@
1
- declare module 'color' {
2
- interface Color {
3
- (color: string | Color | undefined, model?: string): Color;
4
- rgb(): Color;
5
- rgba(): Color;
6
- alpha(): number;
7
- alpha(val: number): Color;
8
- fade(val: number): Color;
9
- lighten(val: number): Color;
10
- darken(val: number): Color;
11
- string(): string;
12
- hex(): string;
13
- toString(): string;
14
- }
15
-
16
- function color(color: string | Color | undefined, model?: string): Color;
17
- export default color;
18
- }
19
-
20
-
@@ -1,70 +0,0 @@
1
- declare module 'elliptic' {
2
- export interface BN {
3
- toArray(endian?: 'be' | 'le', length?: number): number[];
4
- toString(base?: number): string;
5
- }
6
-
7
- export interface KeyPair {
8
- getPrivate(enc?: 'hex' | 'array' | 'bn'): string | number[] | any;
9
- getPublic(): Point;
10
- getPublic(enc: 'hex'): string;
11
- getPublic(enc: 'array'): number[];
12
- getPublic(compressed: boolean, enc?: 'hex'): string;
13
- getPublic(compressed: boolean, enc?: 'array'): number[];
14
- sign(msg: string | number[]): Signature;
15
- verify(msg: string | number[], signature: Signature | string | { r: string | number[]; s: string | number[] }): boolean;
16
- /** ECDH: derive the shared point's x-coordinate against another party's public point. */
17
- derive(pub: Point): BN;
18
- }
19
-
20
- export interface Signature {
21
- r: any;
22
- s: any;
23
- recoveryParam: number | null;
24
- toDER(enc?: 'hex'): string;
25
- toCompact(enc?: 'hex', param?: number): string;
26
- }
27
-
28
- export interface Curve {
29
- n: any;
30
- red: any;
31
- g: Point;
32
- decodePoint(bytes: string | number[], enc?: string): Point;
33
- }
34
-
35
- export interface Point {
36
- x: any;
37
- y: any;
38
- inf: boolean;
39
- getX(): any;
40
- getY(): any;
41
- encode(enc?: string, compressed?: boolean): string | number[];
42
- add(p: Point): Point;
43
- mul(k: any): Point;
44
- eq(p: Point): boolean;
45
- }
46
-
47
- export class EC {
48
- constructor(curve: string | Curve);
49
- keyFromPrivate(priv: string | number[], enc?: string): KeyPair;
50
- keyFromPublic(pub: string | number[] | Point, enc?: string): KeyPair;
51
- genKeyPair(opts?: { entropy?: string | number[]; pers?: string | number[] }): KeyPair;
52
- keyPair(opts?: { priv?: string | number[]; pub?: string | number[] | Point; privEnc?: string; pubEnc?: string }): KeyPair;
53
- curve: Curve;
54
- n: any;
55
- nh: any;
56
- g: Point;
57
- }
58
-
59
- export type ECKeyPair = KeyPair;
60
-
61
- // ec can be called as a function or used as a constructor
62
- export interface ECConstructor {
63
- new (curve: string | Curve): EC;
64
- (curve: string | Curve): EC;
65
- }
66
-
67
- export const ec: ECConstructor;
68
- }
69
-
70
-