@hanzo/rooms 0.1.71 → 0.1.72

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.
@@ -123,11 +123,20 @@ export declare function own(sub: string | undefined): void;
123
123
  */
124
124
  export declare function follow(was: string | undefined, moved: () => void): () => void;
125
125
  /**
126
- * The organizations the token says this person belongs to, home first.
127
- * Empty for an account that has not made one: the SDK's own list falls back to
128
- * the `owner` claim, which is the application's org and nobody's to work in.
126
+ * The brands' directories (hanzoai/authz `IsDirectory`): the org a customer's
127
+ * account lives in, its home, and nobody's to work in. IAM lists the home first
128
+ * in the token's `orgs`; cloud opens a directory to no one.
129
+ */
130
+ export declare const DIRECTORIES: readonly string[];
131
+ /**
132
+ * The organizations this person works in, as the token names them: every org of
133
+ * its `orgs` but a directory, which is a home and nobody's tenant. Empty for an
134
+ * account that has not made one: the SDK's own list falls back to the `owner`
135
+ * claim, which is the application's org and nobody's to work in.
129
136
  */
130
137
  export declare function orgs(): string[];
138
+ /** The org of the person's own row: the first entry of the token's `orgs`, a directory or not. */
139
+ export declare function home(): string | null;
131
140
  /**
132
141
  * The reader's role in one organization as IAM signed it into the token's `orgs`
133
142
  * claim — owner, admin or member — or null where the token names no such org.
@@ -305,12 +305,14 @@ function claims() {
305
305
  return claimsOf(bearer());
306
306
  }
307
307
  /**
308
- * The organizations the token says this person belongs to, home first.
309
- * Empty for an account that has not made one: the SDK's own list falls back to
310
- * the `owner` claim, which is the application's org and nobody's to work in.
308
+ * The brands' directories (hanzoai/authz `IsDirectory`): the org a customer's
309
+ * account lives in, its home, and nobody's to work in. IAM lists the home first
310
+ * in the token's `orgs`; cloud opens a directory to no one.
311
311
  */
312
- export function orgs() {
313
- const set = claims()?.orgs;
312
+ export const DIRECTORIES = ['hanzo-id', 'lux-id', 'zoo-id', 'pars-id'];
313
+ /** Every org the token's `orgs` names, home first, each once. */
314
+ function listed(token) {
315
+ const set = claimsOf(token)?.orgs;
314
316
  const out = [];
315
317
  for (const ref of Array.isArray(set) ? set : []) {
316
318
  const o = ref?.org;
@@ -319,6 +321,19 @@ export function orgs() {
319
321
  }
320
322
  return out;
321
323
  }
324
+ /**
325
+ * The organizations this person works in, as the token names them: every org of
326
+ * its `orgs` but a directory, which is a home and nobody's tenant. Empty for an
327
+ * account that has not made one: the SDK's own list falls back to the `owner`
328
+ * claim, which is the application's org and nobody's to work in.
329
+ */
330
+ export function orgs() {
331
+ return listed(bearer()).filter((o) => !DIRECTORIES.includes(o));
332
+ }
333
+ /** The org of the person's own row: the first entry of the token's `orgs`, a directory or not. */
334
+ export function home() {
335
+ return listed(bearer())[0] ?? null;
336
+ }
322
337
  /**
323
338
  * The reader's role in one organization as IAM signed it into the token's `orgs`
324
339
  * claim — owner, admin or member — or null where the token names no such org.
@@ -354,8 +369,8 @@ export function named() {
354
369
  */
355
370
  export function me() {
356
371
  const name = claims()?.name;
357
- const home = orgs()[0];
358
- return typeof name === 'string' && name && home ? `${home}/${name}` : null;
372
+ const at = home();
373
+ return typeof name === 'string' && name && at ? `${at}/${name}` : null;
359
374
  }
360
375
  /** The organization this browser works in: the SDK's selection, when it is one of the token's. */
361
376
  export function org() {
@@ -435,7 +450,7 @@ export const ADMIN_ORG = 'admin';
435
450
  * organization and the step into one.
436
451
  */
437
452
  export function superAdmin() {
438
- return orgs()[0] === ADMIN_ORG;
453
+ return home() === ADMIN_ORG;
439
454
  }
440
455
  /** The organization a SuperAdmin stepped into through IAM, from the token's `assumed` claim, or null. */
441
456
  export function assumed() {
@@ -471,15 +486,9 @@ export async function support(org) {
471
486
  throw new Error(body?.msg || `IAM answered ${res.status}.`);
472
487
  tokens().setItem(ACCESS, next);
473
488
  tokens().setItem(EXPIRES, String(exp * 1000));
474
- pick(org ?? homeOf(next));
489
+ pick(org ?? listed(next).find((o) => !DIRECTORIES.includes(o)) ?? '');
475
490
  window.location.reload();
476
491
  }
477
- /** The org of the person's own row: the first entry of a token's `orgs`. */
478
- function homeOf(token) {
479
- const set = claimsOf(token)?.orgs;
480
- const first = Array.isArray(set) ? set[0]?.org : undefined;
481
- return typeof first === 'string' ? first : '';
482
- }
483
492
  /**
484
493
  * Leave support mode when IAM cannot answer the step out: the stored token is
485
494
  * marked spent, so the SDK's refresh — which mints from the person's own grant
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/rooms",
3
- "version": "0.1.71",
3
+ "version": "0.1.72",
4
4
  "description": "The workspace rooms — Home, Chat, Inbox, Contacts, Meet, Cal, Drive, Board, Work, Bots — and the frame that holds them, once, for every Hanzo surface.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",