@flipstream/sdk 0.11.0 → 0.13.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 (98) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +179 -424
  3. package/dist/api/backend.d.ts +21 -3
  4. package/dist/api/backend.js +50 -10
  5. package/dist/api/backend.js.map +1 -1
  6. package/dist/api/credentials.js +4 -4
  7. package/dist/api/credentials.js.map +1 -1
  8. package/dist/api/datasets.d.ts +82 -14
  9. package/dist/api/datasets.js +193 -57
  10. package/dist/api/datasets.js.map +1 -1
  11. package/dist/api/index.d.ts +1 -1
  12. package/dist/api/log.d.ts +25 -20
  13. package/dist/api/log.js +63 -48
  14. package/dist/api/log.js.map +1 -1
  15. package/dist/api/me.js +9 -5
  16. package/dist/api/me.js.map +1 -1
  17. package/dist/api/members.d.ts +34 -1
  18. package/dist/api/members.js +67 -27
  19. package/dist/api/members.js.map +1 -1
  20. package/dist/api/wallet.d.ts +8 -5
  21. package/dist/api/wallet.js +40 -25
  22. package/dist/api/wallet.js.map +1 -1
  23. package/dist/api/workspaces.d.ts +35 -14
  24. package/dist/api/workspaces.js +53 -23
  25. package/dist/api/workspaces.js.map +1 -1
  26. package/dist/auth/discovery.d.ts +19 -6
  27. package/dist/auth/discovery.js +30 -6
  28. package/dist/auth/discovery.js.map +1 -1
  29. package/dist/auth/signIn.d.ts +18 -14
  30. package/dist/auth/signIn.js +29 -22
  31. package/dist/auth/signIn.js.map +1 -1
  32. package/dist/core/call.d.ts +13 -1
  33. package/dist/core/call.js +34 -9
  34. package/dist/core/call.js.map +1 -1
  35. package/dist/core/deadline.d.ts +30 -0
  36. package/dist/core/deadline.js +51 -0
  37. package/dist/core/deadline.js.map +1 -0
  38. package/dist/core/identify.d.ts +59 -14
  39. package/dist/core/identify.js +54 -20
  40. package/dist/core/identify.js.map +1 -1
  41. package/dist/core/invalid.d.ts +10 -0
  42. package/dist/core/invalid.js +28 -0
  43. package/dist/core/invalid.js.map +1 -0
  44. package/dist/core/names.d.ts +13 -2
  45. package/dist/core/names.js +11 -2
  46. package/dist/core/names.js.map +1 -1
  47. package/dist/core/notFound.d.ts +8 -0
  48. package/dist/core/notFound.js +8 -0
  49. package/dist/core/notFound.js.map +1 -0
  50. package/dist/core/read.d.ts +9 -0
  51. package/dist/core/read.js +14 -5
  52. package/dist/core/read.js.map +1 -1
  53. package/dist/core/result.d.ts +22 -13
  54. package/dist/core/result.js +5 -5
  55. package/dist/core/result.js.map +1 -1
  56. package/dist/core/retry.d.ts +5 -2
  57. package/dist/core/retry.js +6 -3
  58. package/dist/core/retry.js.map +1 -1
  59. package/dist/core/scope.d.ts +20 -0
  60. package/dist/core/scope.js +54 -0
  61. package/dist/core/scope.js.map +1 -0
  62. package/dist/core/shared.d.ts +39 -0
  63. package/dist/core/shared.js +177 -0
  64. package/dist/core/shared.js.map +1 -0
  65. package/dist/core/signal.d.ts +12 -0
  66. package/dist/core/signal.js +25 -0
  67. package/dist/core/signal.js.map +1 -0
  68. package/dist/flipstream.d.ts +223 -72
  69. package/dist/flipstream.js +225 -88
  70. package/dist/flipstream.js.map +1 -1
  71. package/dist/index.d.ts +1 -1
  72. package/dist/node/clientSecret.js +7 -6
  73. package/dist/node/clientSecret.js.map +1 -1
  74. package/dist/node/headless.d.ts +14 -6
  75. package/dist/node/headless.js +8 -6
  76. package/dist/node/headless.js.map +1 -1
  77. package/dist/node/index.d.ts +1 -1
  78. package/dist/node/index.js +1 -1
  79. package/dist/node/index.js.map +1 -1
  80. package/dist/node/keychainChild.js +26 -14
  81. package/dist/node/keychainChild.js.map +1 -1
  82. package/dist/node/keychainError.d.ts +3 -3
  83. package/dist/node/keychainStore.d.ts +10 -7
  84. package/dist/node/keychainStore.js +44 -23
  85. package/dist/node/keychainStore.js.map +1 -1
  86. package/dist/node/loopback.d.ts +13 -3
  87. package/dist/node/loopback.js +47 -5
  88. package/dist/node/loopback.js.map +1 -1
  89. package/dist/node/session.d.ts +17 -9
  90. package/dist/node/session.js +68 -50
  91. package/dist/node/session.js.map +1 -1
  92. package/dist/node/store.d.ts +35 -2
  93. package/dist/node/store.js +56 -12
  94. package/dist/node/store.js.map +1 -1
  95. package/dist/version.gen.js +1 -1
  96. package/docs/admin.md +558 -0
  97. package/docs/node-sign-in.md +63 -39
  98. package/package.json +1 -1
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { invalidAnswer } from '../core/invalid.js';
2
3
  import { sameUuid } from './ids.js';
3
4
  import { instant } from './time.js';
4
5
  /*
@@ -30,8 +31,10 @@ const zTransaction = z
30
31
  created_on: instant,
31
32
  })
32
33
  .transform(({ dataset_id, ...row }) => ({ ...row, dataset_id: dataset_id === '' || dataset_id === null ? null : dataset_id }));
33
- const invalid = (issues) => ({ ok: false, error: { kind: 'invalid', issues } });
34
- /** Your organisation's id, read every time, with no cache: the wallet's id is the organisation's. */
34
+ /**
35
+ * Your organisation's id, read every time, with no cache, but once for a whole scope (#376): the
36
+ * wallet's id is the organisation's.
37
+ */
35
38
  async function organizationId(seam, read) {
36
39
  const organization = await read(seam.myOrganization(zOrganizationId));
37
40
  return organization.ok ? { ok: true, data: organization.data.id } : organization;
@@ -44,12 +47,26 @@ async function organizationId(seam, read) {
44
47
  */
45
48
  function ownWallet(rows, organization) {
46
49
  if (rows.some((row) => !sameUuid(row.wallet_id, organization)))
47
- return invalid("a balance row is another wallet's");
50
+ return invalidAnswer("a balance row is another wallet's");
48
51
  const [row, ...more] = rows;
49
52
  if (more.length > 0)
50
- return invalid('more than one wallet for the organisation');
53
+ return invalidAnswer('more than one wallet for the organisation');
51
54
  return { ok: true, data: row ?? null };
52
55
  }
56
+ const UNNAMED = "the organisation's id can't name its wallet";
57
+ /**
58
+ * Whether your organisation has a wallet, decided in this one place for both reads (#375's code
59
+ * review, 5): its balance rows, read and held to `organization` by `ownWallet`, so a row is your
60
+ * wallet and null is none. The first of: the balance's failure, the wallet's verdict. `organization`
61
+ * is your organisation's id, read by the caller, so the ledger can be read beside the balance.
62
+ */
63
+ async function readOwnWallet(seam, read, organization) {
64
+ const spec = seam.balanceOf(organization, zBalanceRow);
65
+ if (spec === null)
66
+ return invalidAnswer(UNNAMED);
67
+ const rows = await read(spec);
68
+ return rows.ok ? ownWallet(rows.data, organization) : rows;
69
+ }
53
70
  /**
54
71
  * `flipstream.wallet.balance()`: your organisation's balance, or null when it has no wallet. No
55
72
  * wallet is a real state, not a fault, so it isn't `invalid`, and it isn't €0.00 either: a zero
@@ -59,44 +76,42 @@ export async function readBalance(seam, read) {
59
76
  const organization = await organizationId(seam, read);
60
77
  if (!organization.ok)
61
78
  return organization;
62
- const spec = seam.balanceOf(organization.data, zBalanceRow);
63
- if (spec === null)
64
- return invalid("the organisation's id can't name its wallet");
65
- const rows = await read(spec);
66
- if (!rows.ok)
67
- return rows;
68
- const wallet = ownWallet(rows.data, organization.data);
79
+ const wallet = await readOwnWallet(seam, read, organization.data);
69
80
  if (!wallet.ok)
70
81
  return wallet;
71
82
  return { ok: true, data: wallet.data === null ? null : { balance_micro: wallet.data.balance_micro, micro_per_euro: MICRO_PER_EURO } };
72
83
  }
73
84
  /**
74
85
  * `flipstream.wallet.transactions()`: your organisation's whole ledger, in one answer, with no
75
- * paging. Its rows carry no wallet id, so the balance is read beside it, and the ledger is answered
76
- * only when that balance is your organisation's wallet (`ownWallet`). With no wallet, only an empty
77
- * ledger is; any row then is invalid. The answer is the first of: the balance's failure, the
78
- * wallet's verdict, the ledger's failure.
86
+ * paging, or null when it has no wallet, as `readBalance` answers (#374), so no wallet is said one
87
+ * way across the wallet's reads. Its rows carry no wallet id, so the balance is read beside it, and
88
+ * the ledger is answered only when that balance is your organisation's wallet (`readOwnWallet`). The
89
+ * answer is the first of: the balance's failure, the wallet's verdict, the ledger's failure. No
90
+ * wallet is a verdict: null, whatever the ledger read did (#375's code review, 1), unless it
91
+ * answered rows, or an answer it can't read, which may be rows: those are invalid (#375 round 2,
92
+ * O2.F1).
79
93
  */
80
94
  export async function readLedger(seam, read) {
81
95
  const organization = await organizationId(seam, read);
82
96
  if (!organization.ok)
83
97
  return organization;
84
- const balanceSpec = seam.balanceOf(organization.data, zBalanceRow);
98
+ // Checked before either read is sent. The balance's path takes the same id, so once the
99
+ // ledger's can name it, so can the balance's, and readOwnWallet never refuses after this.
85
100
  const ledgerSpec = seam.ledgerOf(organization.data, zTransaction);
86
- if (balanceSpec === null || ledgerSpec === null)
87
- return invalid("the organisation's id can't name its wallet");
88
- const [balance, ledger] = await Promise.all([read(balanceSpec), read(ledgerSpec)]);
89
- if (!balance.ok)
90
- return balance;
101
+ if (ledgerSpec === null)
102
+ return invalidAnswer(UNNAMED);
103
+ const [wallet, ledger] = await Promise.all([readOwnWallet(seam, read, organization.data), read(ledgerSpec)]);
91
104
  // The wallet's verdict comes from the balance, so it comes before the ledger's own failure: a
92
- // caller never retries a ledger of a wallet that isn't theirs.
93
- const wallet = ownWallet(balance.data, organization.data);
105
+ // caller never retries a ledger of a wallet that isn't theirs, nor of no wallet.
94
106
  if (!wallet.ok)
95
107
  return wallet;
108
+ if (wallet.data === null) {
109
+ if (!ledger.ok)
110
+ return ledger.error.kind === 'invalid' ? ledger : { ok: true, data: null };
111
+ return ledger.data.length > 0 ? invalidAnswer('ledger rows for an organisation with no wallet') : { ok: true, data: null };
112
+ }
96
113
  if (!ledger.ok)
97
114
  return ledger;
98
- if (wallet.data === null && ledger.data.length > 0)
99
- return invalid('ledger rows for an organisation with no wallet');
100
115
  return { ok: true, data: { items: ledger.data, micro_per_euro: MICRO_PER_EURO } };
101
116
  }
102
117
  //# sourceMappingURL=wallet.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,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AE,cAAc,EAAE,EAAE,CAAA;AACnF,CAAC"}
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  import type { ApiResult } from '../core/result.js';
3
3
  import type { Backend } from './backend.js';
4
4
  import { type WorkspaceHandOff } from './handoff.js';
5
- import type { Read } from './me.js';
5
+ import { type Read } from './me.js';
6
6
  import { type Page, type PageRequest } from './page.js';
7
7
  /**
8
8
  * Which services are on in a workspace (#291, os D94), as the console reads its `meta.cloud`:
@@ -34,13 +34,13 @@ declare const zRecord: z.ZodObject<{
34
34
  type WorkspaceRecord = z.output<typeof zRecord>;
35
35
  /**
36
36
  * `flipstream.workspaces.list()`: one page of your organisation's workspaces. Your organisation is
37
- * read first, every time, with no cache, for its id. A workspace of another organisation makes the
38
- * page invalid. A bad limit or offset throws before anything is sent. No sort is sent (D550, as
39
- * amended): an empty one gives pulse-admin's repository default, `name` for clients
40
- * (ClientRepository.order_by, pulse-admin 72ec7ef), a single-column order with no tiebreaker, and
41
- * names aren't unique. So pages read at different times can overlap or skip a workspace: when
42
- * workspaces are added, removed or renamed in between, or when two share a name, and a changed
43
- * `total` shows only some of it. A complete, stable list is one page, of up to 1,000.
37
+ * read first, every time, with no cache (once for a whole scope, #376), for its id. A workspace of
38
+ * another organisation makes the page invalid. A bad limit or offset throws before anything is
39
+ * sent. No sort is sent (D550, as amended): an empty one gives pulse-admin's repository default,
40
+ * `name` for clients (ClientRepository.order_by, pulse-admin 72ec7ef), a single-column order with
41
+ * no tiebreaker, and names aren't unique. So pages read at different times can overlap or skip a
42
+ * workspace: when workspaces are added, removed or renamed in between, or when two share a name,
43
+ * and a changed `total` shows only some of it. A complete, stable list is one page, of up to 1,000.
44
44
  */
45
45
  export declare function readWorkspaces(seam: Backend, read: Read, page: PageRequest): Promise<ApiResult<Page<Workspace>>>;
46
46
  /**
@@ -60,11 +60,8 @@ export declare function createWorkspace(seam: Backend, send: Read, request: {
60
60
  readonly name: string;
61
61
  }): Promise<ApiResult<Workspace>>;
62
62
  /**
63
- * One of your organisation's workspaces, read beside your organisation. A workspace of another
64
- * organisation is invalid, as a staff token could otherwise reach it, and so is an answer that isn't
65
- * the workspace asked for. The organisation's failure, then the workspace's, is the answer. A read
66
- * under a workspace uses it too, so the workspace itself is proved, never only its records (D556,
67
- * as amended): pulse-admin answers an empty list for any workspace id.
63
+ * One of your organisation's workspaces, as `readOwnWorkspaceWith` reads it, with nothing beside it:
64
+ * for a call that reads or writes only after its workspace is proved.
68
65
  */
69
66
  export declare function readOwnWorkspace<O extends {
70
67
  readonly id: string;
@@ -72,12 +69,36 @@ export declare function readOwnWorkspace<O extends {
72
69
  readonly organization: O;
73
70
  readonly workspace: WorkspaceRecord;
74
71
  }>>;
72
+ /**
73
+ * One of your organisation's workspaces, and `alongside`'s answer, read once you're known to open
74
+ * it. Every call under one workspace known up front uses it (D556, as amended; D571), so the
75
+ * workspace itself is proved, never only its records: pulse-admin answers an empty list for any
76
+ * workspace id, and doesn't hold a limited member to their workspaces on every route.
77
+ * - **First, your organisation and you** (`readUser`), side by side. A workspace you don't open
78
+ * (`opensWorkspace`, D560) is then `not_found`, exactly as one nobody has, before anything under
79
+ * it is sent: no workspace read and no `alongside`, so its records, a dataset's embedded sign-in
80
+ * among them, are never fetched, and a refusal of them can't tell it apart (#373's code review, 3
81
+ * and 4).
82
+ * - **Then the workspace and `alongside`** (a list under it), side by side. A workspace of another
83
+ * organisation is invalid, as a staff token could otherwise reach it, and so is an answer that
84
+ * isn't the workspace asked for.
85
+ * The organisation's failure, then yours, then the workspace's, is the answer; `alongside`'s answer
86
+ * comes back as it is, for the caller to read after.
87
+ */
88
+ export declare function readOwnWorkspaceWith<O extends {
89
+ readonly id: string;
90
+ }, A>(seam: Backend, read: Read, workspaceId: string, organizationSchema: z.ZodType<O>, alongside: () => Promise<A>): Promise<ApiResult<{
91
+ readonly organization: O;
92
+ readonly workspace: WorkspaceRecord;
93
+ readonly alongside: A;
94
+ }>>;
75
95
  /** `flipstream.workspaces.get()`: one workspace, by `readOwnWorkspace`'s rules. */
76
96
  export declare function readWorkspace(seam: Backend, read: Read, workspaceId: string): Promise<ApiResult<Workspace>>;
77
97
  /**
78
98
  * `flipstream.workspaces.rename()` and `delete()`: a person's to do in the console (D542), so they
79
99
  * answer `needs_person` and never write. The workspace is read first, by `readOwnWorkspace`'s
80
- * rules, so one that isn't yours is `not_found` or `invalid`, never handed off. The address names
100
+ * rules, so one that isn't yours, or that you don't open, is `not_found` or `invalid`, never
101
+ * handed off. The address names
81
102
  * the organisation's short name and the workspace's canonical id, as the backend answered it.
82
103
  */
83
104
  export declare function handOffWorkspace(seam: Backend, read: Read, workspaceId: string, action: WorkspaceHandOff): Promise<ApiResult<never>>;
@@ -1,7 +1,11 @@
1
1
  import { z } from 'zod';
2
2
  import { parseJson } from '../core/body.js';
3
+ import { invalidAnswer, invalidStatusUnknown } from '../core/invalid.js';
4
+ import { notFound } from '../core/notFound.js';
3
5
  import { needsPerson, zHandOffOrganization } from './handoff.js';
4
6
  import { sameUuid } from './ids.js';
7
+ import { readUser } from './me.js';
8
+ import { opensWorkspace } from './members.js';
5
9
  import { pageQuery } from './page.js';
6
10
  import { unsent } from './unsent.js';
7
11
  const id = z.string().min(1);
@@ -40,16 +44,15 @@ function servicesOf(meta = '') {
40
44
  const zRecord = z.object({ id, name: z.string(), slug: z.string(), organization_id: id, meta: z.unknown().optional() });
41
45
  const zOrganizationId = z.object({ id });
42
46
  const publicOf = ({ id: workspaceId, name, slug, meta }) => ({ id: workspaceId, name, slug, services: servicesOf(meta) });
43
- const invalid = (issues) => ({ ok: false, error: { kind: 'invalid', issues } });
44
47
  /**
45
48
  * `flipstream.workspaces.list()`: one page of your organisation's workspaces. Your organisation is
46
- * read first, every time, with no cache, for its id. A workspace of another organisation makes the
47
- * page invalid. A bad limit or offset throws before anything is sent. No sort is sent (D550, as
48
- * amended): an empty one gives pulse-admin's repository default, `name` for clients
49
- * (ClientRepository.order_by, pulse-admin 72ec7ef), a single-column order with no tiebreaker, and
50
- * names aren't unique. So pages read at different times can overlap or skip a workspace: when
51
- * workspaces are added, removed or renamed in between, or when two share a name, and a changed
52
- * `total` shows only some of it. A complete, stable list is one page, of up to 1,000.
49
+ * read first, every time, with no cache (once for a whole scope, #376), for its id. A workspace of
50
+ * another organisation makes the page invalid. A bad limit or offset throws before anything is
51
+ * sent. No sort is sent (D550, as amended): an empty one gives pulse-admin's repository default,
52
+ * `name` for clients (ClientRepository.order_by, pulse-admin 72ec7ef), a single-column order with
53
+ * no tiebreaker, and names aren't unique. So pages read at different times can overlap or skip a
54
+ * workspace: when workspaces are added, removed or renamed in between, or when two share a name,
55
+ * and a changed `total` shows only some of it. A complete, stable list is one page, of up to 1,000.
53
56
  */
54
57
  export async function readWorkspaces(seam, read, page) {
55
58
  const sent = pageQuery(page);
@@ -57,9 +60,9 @@ export async function readWorkspaces(seam, read, page) {
57
60
  if (!organization.ok)
58
61
  return organization;
59
62
  const ours = organization.data.id;
60
- const spec = seam.workspacesOf(ours, sent, zRecord, (workspace) => workspace.organization_id === ours);
63
+ const spec = seam.workspacesOf(ours, sent, zRecord, (workspace) => sameUuid(workspace.organization_id, ours));
61
64
  if (spec === null)
62
- return invalid("the organisation's id can't name its workspaces");
65
+ return invalidAnswer("the organisation's id can't name its workspaces");
63
66
  const listed = await read(spec);
64
67
  return listed.ok ? { ok: true, data: { ...listed.data, items: listed.data.items.map(publicOf) } } : listed;
65
68
  }
@@ -90,33 +93,59 @@ export async function createWorkspace(seam, send, request) {
90
93
  if (!made.ok)
91
94
  return made;
92
95
  if (!sameUuid(made.data.organization_id, organization.data.id))
93
- return invalid("the workspace made is another organisation's");
96
+ return invalidStatusUnknown("the workspace made is another organisation's");
94
97
  return { ok: true, data: publicOf(made.data) };
95
98
  }
99
+ // pulse-admin's own 404 for a workspace nobody has, as recorded (test/recorded/admin/error-404.json;
100
+ // dff6bf9b, domain/client/__init__.py:122-129): a workspace you don't open answers exactly this, so it
101
+ // says no more than one nobody has (D571, #372).
102
+ const noSuchWorkspace = () => notFound('CLIENT_NOT_FOUND', 'Client not found!');
96
103
  /**
97
- * One of your organisation's workspaces, read beside your organisation. A workspace of another
98
- * organisation is invalid, as a staff token could otherwise reach it, and so is an answer that isn't
99
- * the workspace asked for. The organisation's failure, then the workspace's, is the answer. A read
100
- * under a workspace uses it too, so the workspace itself is proved, never only its records (D556,
101
- * as amended): pulse-admin answers an empty list for any workspace id.
104
+ * One of your organisation's workspaces, as `readOwnWorkspaceWith` reads it, with nothing beside it:
105
+ * for a call that reads or writes only after its workspace is proved.
102
106
  */
103
107
  export async function readOwnWorkspace(seam, read, workspaceId, organizationSchema) {
108
+ const own = await readOwnWorkspaceWith(seam, read, workspaceId, organizationSchema, () => Promise.resolve(null));
109
+ return own.ok ? { ok: true, data: { organization: own.data.organization, workspace: own.data.workspace } } : own;
110
+ }
111
+ /**
112
+ * One of your organisation's workspaces, and `alongside`'s answer, read once you're known to open
113
+ * it. Every call under one workspace known up front uses it (D556, as amended; D571), so the
114
+ * workspace itself is proved, never only its records: pulse-admin answers an empty list for any
115
+ * workspace id, and doesn't hold a limited member to their workspaces on every route.
116
+ * - **First, your organisation and you** (`readUser`), side by side. A workspace you don't open
117
+ * (`opensWorkspace`, D560) is then `not_found`, exactly as one nobody has, before anything under
118
+ * it is sent: no workspace read and no `alongside`, so its records, a dataset's embedded sign-in
119
+ * among them, are never fetched, and a refusal of them can't tell it apart (#373's code review, 3
120
+ * and 4).
121
+ * - **Then the workspace and `alongside`** (a list under it), side by side. A workspace of another
122
+ * organisation is invalid, as a staff token could otherwise reach it, and so is an answer that
123
+ * isn't the workspace asked for.
124
+ * The organisation's failure, then yours, then the workspace's, is the answer; `alongside`'s answer
125
+ * comes back as it is, for the caller to read after.
126
+ */
127
+ export async function readOwnWorkspaceWith(seam, read, workspaceId, organizationSchema, alongside) {
104
128
  const spec = seam.workspace(workspaceId, zRecord);
105
129
  if (spec === null)
106
130
  return { ok: false, error: { kind: 'refused', reason: 'path' } };
107
- const [organization, workspace] = await Promise.all([read(seam.myOrganization(organizationSchema)), read(spec)]);
131
+ const [organization, you] = await Promise.all([read(seam.myOrganization(organizationSchema)), readUser(seam, read)]);
108
132
  if (!organization.ok)
109
133
  return organization;
134
+ if (!you.ok)
135
+ return you;
136
+ if (!opensWorkspace(you.data, workspaceId))
137
+ return noSuchWorkspace();
138
+ const [workspace, beside] = await Promise.all([read(spec), alongside()]);
110
139
  if (!workspace.ok)
111
140
  return workspace;
112
141
  // Another workspace than the one asked for is never answered as it, as me() holds its user to
113
142
  // userinfo's sub; neither id is echoed. The caller's id may be any form pulse-admin reads as the
114
- // same UUID (sameUuid).
143
+ // same UUID (sameUuid), and so may the organisation's id the workspace names (#363).
115
144
  if (!sameUuid(workspace.data.id, workspaceId))
116
- return invalid("the workspace read isn't the one asked for");
117
- if (workspace.data.organization_id !== organization.data.id)
118
- return invalid("the workspace read is another organisation's");
119
- return { ok: true, data: { organization: organization.data, workspace: workspace.data } };
145
+ return invalidAnswer("the workspace read isn't the one asked for");
146
+ if (!sameUuid(workspace.data.organization_id, organization.data.id))
147
+ return invalidAnswer("the workspace read is another organisation's");
148
+ return { ok: true, data: { organization: organization.data, workspace: workspace.data, alongside: beside } };
120
149
  }
121
150
  /** `flipstream.workspaces.get()`: one workspace, by `readOwnWorkspace`'s rules. */
122
151
  export async function readWorkspace(seam, read, workspaceId) {
@@ -126,7 +155,8 @@ export async function readWorkspace(seam, read, workspaceId) {
126
155
  /**
127
156
  * `flipstream.workspaces.rename()` and `delete()`: a person's to do in the console (D542), so they
128
157
  * answer `needs_person` and never write. The workspace is read first, by `readOwnWorkspace`'s
129
- * rules, so one that isn't yours is `not_found` or `invalid`, never handed off. The address names
158
+ * rules, so one that isn't yours, or that you don't open, is `not_found` or `invalid`, never
159
+ * handed off. The address names
130
160
  * the organisation's short name and the workspace's canonical id, as the backend answered it.
131
161
  */
132
162
  export async function handOffWorkspace(seam, read, workspaceId, action) {
@@ -1 +1 @@
1
- {"version":3,"file":"workspaces.js","sourceRoot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,aAAa,CAAC,IAAa,EAAE,IAAU,EAAE,WAAmB;IAChF,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,CAAC,CAAA;IAC5E,OAAO,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;AACxE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAa,EAAE,IAAU,EAAE,WAAmB,EAAE,MAAwB;IAC7G,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,oBAAoB,CAAC,CAAA;IACjF,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,OAAO,GAAG,CAAA;IACvB,OAAO,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAA;AACvG,CAAC"}
@@ -1,18 +1,31 @@
1
1
  import type { ApiResult } from '../core/result.js';
2
2
  import { type AuthCallOptions } from './transport.js';
3
- /** What sign-in needs from an authorization server's metadata (RFC 8414), and nothing more. */
3
+ /**
4
+ * What sign-in needs from an authorization server's metadata (RFC 8414), and nothing more, in the
5
+ * metadata's own names (#353, D569).
6
+ */
4
7
  export interface AuthServer {
5
8
  /** The issuer as its metadata names it: what a redirect's `iss` must equal (RFC 9207). */
6
9
  readonly issuer: string;
7
10
  /** Where the person is sent to sign in. */
8
- readonly authorizationEndpoint: string;
11
+ readonly authorization_endpoint: string;
9
12
  /** Where the code is exchanged for tokens. */
10
- readonly tokenEndpoint: string;
13
+ readonly token_endpoint: string;
11
14
  /** Where a session is ended (RFC 7009), when the server has one. */
12
- readonly revocationEndpoint?: string;
13
- /** The server puts `iss` on every redirect (RFC 9207), so a redirect without one is refused. */
14
- readonly issuerOnRedirect: boolean;
15
+ readonly revocation_endpoint?: string;
16
+ /**
17
+ * The server puts `iss` on every redirect (RFC 9207), so a redirect without one is refused. False
18
+ * when its metadata doesn't say so.
19
+ */
20
+ readonly authorization_response_iss_parameter_supported: boolean;
15
21
  }
22
+ /**
23
+ * What a `server` given in place of discovery lacks, as `server.<field>` with what it must be, or
24
+ * null when it's an AuthServer's shape (#355's code review, 3): a discover() answer an app kept
25
+ * from a release before the snake rename (D569) holds camelCase names, and would otherwise be used
26
+ * as a server with no endpoints. Its values are checked where they're used.
27
+ */
28
+ export declare function serverProblem(server: unknown): string | null;
16
29
  /**
17
30
  * The authorization server at `issuer`, from its RFC 8414 metadata. `refused`, with nothing sent,
18
31
  * when `issuer` isn't an https URL, or with `allowLocalhostHttp`, an http one on this machine.
@@ -1,6 +1,28 @@
1
1
  import { z } from 'zod';
2
2
  import { call } from '../core/call.js';
3
+ import { invalidWith } from '../core/invalid.js';
3
4
  import { authTransport, endpointProblem, isSignInUrl } from './transport.js';
5
+ /**
6
+ * What a `server` given in place of discovery lacks, as `server.<field>` with what it must be, or
7
+ * null when it's an AuthServer's shape (#355's code review, 3): a discover() answer an app kept
8
+ * from a release before the snake rename (D569) holds camelCase names, and would otherwise be used
9
+ * as a server with no endpoints. Its values are checked where they're used.
10
+ */
11
+ export function serverProblem(server) {
12
+ if (typeof server !== 'object' || server === null)
13
+ return 'server must be discover()\'s answer';
14
+ const field = (name) => (Object.hasOwn(server, name) ? Reflect.get(server, name) : undefined);
15
+ for (const name of ['issuer', 'authorization_endpoint', 'token_endpoint']) {
16
+ if (typeof field(name) !== 'string')
17
+ return `server.${name} must be a string`;
18
+ }
19
+ const revocation = field('revocation_endpoint');
20
+ if (revocation !== undefined && typeof revocation !== 'string')
21
+ return 'server.revocation_endpoint must be a string, or left out';
22
+ if (typeof field('authorization_response_iss_parameter_supported') !== 'boolean')
23
+ return 'server.authorization_response_iss_parameter_supported must be a boolean';
24
+ return null;
25
+ }
4
26
  // Unknown fields are kept and never read: `first_party_client_id` among them, which the SDK never
5
27
  // uses in place of the app's own client ID (D421).
6
28
  const zMetadata = z.looseObject({
@@ -22,6 +44,7 @@ const zMetadata = z.looseObject({
22
44
  export async function discover(issuer, options = {}) {
23
45
  if (typeof issuer !== 'string' || !isSignInUrl(issuer, options.allowLocalhostHttp))
24
46
  return { ok: false, error: { kind: 'refused', reason: 'destination' } };
47
+ let status;
25
48
  const read = await call(authTransport(options), {
26
49
  effect: 'read',
27
50
  service: 'auth',
@@ -30,21 +53,22 @@ export async function discover(issuer, options = {}) {
30
53
  schema: zMetadata,
31
54
  deadlineMs: 10_000,
32
55
  retry: 'read',
33
- }, options.signal);
56
+ }, options.signal, undefined, (answered) => (status = answered));
34
57
  if (!read.ok)
35
58
  return read;
36
59
  const doc = read.data;
37
60
  const problem = problemWith(doc, issuer);
61
+ // Any server the app names, so its success status is the one it answered with (invalid.ts).
38
62
  if (problem !== null)
39
- return { ok: false, error: { kind: 'invalid', issues: problem, status: 200 } };
63
+ return invalidWith(problem, status);
40
64
  return {
41
65
  ok: true,
42
66
  data: {
43
67
  issuer: doc.issuer,
44
- authorizationEndpoint: doc.authorization_endpoint,
45
- tokenEndpoint: doc.token_endpoint,
46
- ...(doc.revocation_endpoint === undefined ? {} : { revocationEndpoint: doc.revocation_endpoint }),
47
- issuerOnRedirect: doc.authorization_response_iss_parameter_supported === true,
68
+ authorization_endpoint: doc.authorization_endpoint,
69
+ token_endpoint: doc.token_endpoint,
70
+ ...(doc.revocation_endpoint === undefined ? {} : { revocation_endpoint: doc.revocation_endpoint }),
71
+ authorization_response_iss_parameter_supported: doc.authorization_response_iss_parameter_supported === true,
48
72
  },
49
73
  };
50
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../src/auth/discovery.ts"],"names":[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M,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAA;IAC3B,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IACzE,GAAG,CAAC,QAAQ,GAAG,0CAA0C,IAAI,EAAE,CAAA;IAC/D,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAA;AACvB,CAAC;AAED,SAAS,WAAW,CAAC,GAA8B,EAAE,MAAc;IACjE,4FAA4F;IAC5F,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,mCAAmC,CAAA;IACrE,MAAM,SAAS,GAAG,CAAC,GAAG,CAAC,sBAAsB,EAAE,GAAG,CAAC,cAAc,EAAE,GAAG,CAAC,GAAG,CAAC,mBAAmB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAA;IAC/I,MAAM,OAAO,GAAG,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAClD,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,OAAO,CAAA;IACpC,IAAI,GAAG,CAAC,gCAAgC,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,IAAI;QAAE,OAAO,oCAAoC,CAAA;IAChH,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { ApiError } from '../core/result.js';
2
- import type { AuthServer } from './discovery.js';
2
+ import { type AuthServer } from './discovery.js';
3
3
  import { type AuthCallOptions } from './transport.js';
4
4
  /** What `startSignIn` takes. */
5
5
  export interface SignInRequest {
@@ -14,30 +14,32 @@ export interface SignInRequest {
14
14
  }
15
15
  /**
16
16
  * What finishing needs, held by the app between the two halves: only strings and a flag, so it
17
- * survives a page load in the app's own storage. The verifier is a secret: never log it.
17
+ * survives a page load in the app's own storage. The verifier is a secret: never log it. Its
18
+ * fields are snake_case since the snake rename (#353, D569): a pending that a release before it
19
+ * made isn't one, so `finishSignIn` refuses it, and the person starts the sign-in again.
18
20
  */
19
21
  export interface PendingSignIn {
20
22
  /** What the redirect must carry back (CSRF). */
21
23
  readonly state: string;
22
24
  /** The PKCE code verifier: the secret the code is exchanged with. */
23
25
  readonly verifier: string;
24
- readonly clientId: string;
25
- readonly redirectUri: string;
26
+ readonly client_id: string;
27
+ readonly redirect_uri: string;
26
28
  /** The scopes asked for, space-separated (RFC 6749 §3.3). */
27
29
  readonly scope: string;
28
- /** The server's issuer, its token endpoint, and whether it puts `iss` on every redirect. */
30
+ /** The server's issuer, its token endpoint, and whether it puts `iss` on every redirect (RFC 9207). */
29
31
  readonly issuer: string;
30
- readonly tokenEndpoint: string;
31
- readonly issuerOnRedirect: boolean;
32
+ readonly token_endpoint: string;
33
+ readonly authorization_response_iss_parameter_supported: boolean;
32
34
  }
33
- /** What a sign-in gives. The app stores them; the SDK keeps no copy. */
35
+ /** What a sign-in gives, in snake_case (#353, D569). The app stores them; the SDK keeps no copy. */
34
36
  export interface Tokens {
35
37
  /** For the transport's token function: never log it. */
36
- readonly accessToken: string;
38
+ readonly access_token: string;
37
39
  /** Absent when the server issued none. */
38
- readonly refreshToken?: string;
40
+ readonly refresh_token?: string;
39
41
  /** When the access token expires, in ms since the epoch; absent when the server didn't say. */
40
- readonly expiresAt?: number;
42
+ readonly expires_at?: number;
41
43
  /** The scopes granted, space-separated. */
42
44
  readonly scope: string;
43
45
  }
@@ -73,8 +75,9 @@ export type SignInResult = {
73
75
  };
74
76
  /**
75
77
  * The URL to send the person to, and what finishing will need. Rejects with a TypeError, before
76
- * anything is made, when the client ID is missing or empty, the redirect URI isn't absolute, or
77
- * the scopes are empty or one holds a space: from TypeScript, none of these compiles. Always S256;
78
+ * anything is made, when the client ID is missing or empty, the redirect URI isn't absolute, the
79
+ * scopes are empty or one holds a space, or `server` isn't discover()'s answer in its snake_case
80
+ * names, naming the field it lacks: from TypeScript, none of these compiles. Always S256;
78
81
  * no `resource` is sent, since the hosts share one audience.
79
82
  */
80
83
  export declare function startSignIn(request: SignInRequest): Promise<{
@@ -94,7 +97,8 @@ export declare const isPendingSignIn: (value: unknown) => value is PendingSignIn
94
97
  /**
95
98
  * Finishes a sign-in: the redirect is read (`readCallback`), and only then is its code exchanged
96
99
  * for tokens, once (`tokenCall`). A `pending` that isn't one (from
97
- * storage the app couldn't read back) is `refused`, with nothing sent. A public client's: an app
100
+ * storage the app couldn't read back, or one an earlier version made, in camelCase) is `refused`,
101
+ * with nothing sent. A public client's: an app
98
102
  * with a server signs in as a confidential client with `@flipstream/sdk/node`'s `finishSignIn`.
99
103
  */
100
104
  export declare function finishSignIn(callbackUrl: string | URL, pending: PendingSignIn, options?: AuthCallOptions): Promise<SignInResult>;