@flipstream/sdk 0.12.0 → 0.14.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 (87) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +128 -30
  3. package/dist/api/backend.d.ts +18 -3
  4. package/dist/api/backend.js +33 -6
  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.js +30 -50
  9. package/dist/api/datasets.js.map +1 -1
  10. package/dist/api/handoff.d.ts +1 -1
  11. package/dist/api/handoff.js +7 -0
  12. package/dist/api/handoff.js.map +1 -1
  13. package/dist/api/log.d.ts +4 -4
  14. package/dist/api/log.js +23 -42
  15. package/dist/api/log.js.map +1 -1
  16. package/dist/api/me.d.ts +5 -3
  17. package/dist/api/me.js +5 -4
  18. package/dist/api/me.js.map +1 -1
  19. package/dist/api/members.d.ts +40 -17
  20. package/dist/api/members.js +66 -29
  21. package/dist/api/members.js.map +1 -1
  22. package/dist/api/ownRecord.d.ts +46 -0
  23. package/dist/api/ownRecord.js +57 -0
  24. package/dist/api/ownRecord.js.map +1 -0
  25. package/dist/api/refusal.d.ts +14 -0
  26. package/dist/api/refusal.js +23 -0
  27. package/dist/api/refusal.js.map +1 -0
  28. package/dist/api/wallet.d.ts +2 -1
  29. package/dist/api/wallet.js +18 -21
  30. package/dist/api/wallet.js.map +1 -1
  31. package/dist/api/workspaces.d.ts +14 -9
  32. package/dist/api/workspaces.js +21 -15
  33. package/dist/api/workspaces.js.map +1 -1
  34. package/dist/auth/discovery.js +3 -1
  35. package/dist/auth/discovery.js.map +1 -1
  36. package/dist/core/call.d.ts +12 -2
  37. package/dist/core/call.js +5 -2
  38. package/dist/core/call.js.map +1 -1
  39. package/dist/core/identify.d.ts +65 -14
  40. package/dist/core/identify.js +69 -27
  41. package/dist/core/identify.js.map +1 -1
  42. package/dist/core/inPlaceOf.d.ts +6 -0
  43. package/dist/core/inPlaceOf.js +17 -0
  44. package/dist/core/inPlaceOf.js.map +1 -0
  45. package/dist/core/invalid.d.ts +32 -6
  46. package/dist/core/invalid.js +36 -17
  47. package/dist/core/invalid.js.map +1 -1
  48. package/dist/core/notFound.d.ts +2 -2
  49. package/dist/core/notFound.js.map +1 -1
  50. package/dist/core/read.d.ts +6 -3
  51. package/dist/core/read.js +5 -6
  52. package/dist/core/read.js.map +1 -1
  53. package/dist/core/result.d.ts +16 -8
  54. package/dist/core/result.js +1 -0
  55. package/dist/core/result.js.map +1 -1
  56. package/dist/core/shared.d.ts +43 -0
  57. package/dist/core/shared.js +178 -0
  58. package/dist/core/shared.js.map +1 -0
  59. package/dist/core/signal.d.ts +12 -0
  60. package/dist/core/signal.js +25 -0
  61. package/dist/core/signal.js.map +1 -0
  62. package/dist/flipstream.d.ts +160 -22
  63. package/dist/flipstream.js +207 -81
  64. package/dist/flipstream.js.map +1 -1
  65. package/dist/index.d.ts +2 -2
  66. package/dist/index.js +3 -2
  67. package/dist/index.js.map +1 -1
  68. package/dist/node/clientSecret.js +2 -1
  69. package/dist/node/clientSecret.js.map +1 -1
  70. package/dist/node/keychainChild.js +60 -25
  71. package/dist/node/keychainChild.js.map +1 -1
  72. package/dist/node/keychainError.d.ts +4 -1
  73. package/dist/node/keychainError.js.map +1 -1
  74. package/dist/node/keychainStore.js +42 -8
  75. package/dist/node/keychainStore.js.map +1 -1
  76. package/dist/node/loopback.d.ts +5 -2
  77. package/dist/node/loopback.js +28 -3
  78. package/dist/node/loopback.js.map +1 -1
  79. package/dist/node/session.js +11 -5
  80. package/dist/node/session.js.map +1 -1
  81. package/dist/query/query.d.ts +52 -8
  82. package/dist/query/query.js +133 -19
  83. package/dist/query/query.js.map +1 -1
  84. package/dist/version.gen.js +1 -1
  85. package/docs/admin.md +108 -4
  86. package/docs/node-sign-in.md +11 -5
  87. package/package.json +1 -1
@@ -1,8 +1,9 @@
1
1
  import { z } from 'zod';
2
- import { invalidAnswer } from '../core/invalid.js';
2
+ import { invalidIn } from '../core/invalid.js';
3
3
  import { notFound } from '../core/notFound.js';
4
4
  import { RANKED, roleFromBackend } from '../core/names.js';
5
5
  import { createdById } from './created.js';
6
+ import { needsPerson, zHandOffOrganization } from './handoff.js';
6
7
  import { sameUuid } from './ids.js';
7
8
  import { instant } from './time.js';
8
9
  const id = z.string().min(1);
@@ -103,28 +104,38 @@ export async function listMembers(seam, read, page) {
103
104
  return organization;
104
105
  if (!listed.ok)
105
106
  return listed;
106
- const foreign = listed.data.items.findIndex((member) => !sameUuid(member.organization_id, organization.data.id));
107
- if (foreign !== -1)
108
- return invalidAnswer(`records[${String(foreign)}] is another organisation's member`);
107
+ const foreign = foreignRow(listed, organization.data.id, 'member');
108
+ if (foreign !== null)
109
+ return foreign;
109
110
  const key = listed.data.items.findIndex((member) => member.is_api_user);
110
111
  if (key !== -1)
111
- return invalidAnswer(`records[${String(key)}] is an API user, not a person`);
112
+ return invalidIn(listed, `records[${String(key)}] is an API user, not a person`);
112
113
  return { ok: true, data: { ...listed.data, items: listed.data.items.map(publicOf) } };
113
114
  }
114
115
  /**
115
- * `flipstream.members.get()`: one of your organisation's people, by their id. An answer that isn't
116
- * the person asked for, or is another organisation's, is invalid, echoing no id; an API user's is
117
- * `not_found`, as an id nobody has, whatever else its record holds. Only then is the person read.
118
- * Every invalid after the read keeps the response's status, 200.
119
- * The organisation's failure, then the person's, is the answer. A caller that is reading your
120
- * organisation already passes that read as `organization`, so it isn't read twice (#295); otherwise
121
- * it's read here, and only once the path is known to be one, so a refused call sends nothing.
116
+ * `flipstream.members.get()`: one of your organisation's people, by their id, by `readMember`'s
117
+ * rules. A caller that is reading your organisation already passes that read as `organization`, so
118
+ * it isn't read twice (#295).
122
119
  */
123
- export async function getMember(seam, read, request, organization) {
120
+ export async function getMember(seam, read, request, organization = () => read(seam.myOrganization(zOrganizationId))) {
121
+ const found = await readMember(seam, read, request, organization);
122
+ return found.ok ? { ok: true, data: found.data.member } : found;
123
+ }
124
+ /**
125
+ * One of your organisation's people, by their id, with your organisation as `organization` reads
126
+ * it. `organization` is a function, called only once the id is known to be one path segment, so a
127
+ * refused id asks no token, hands no transport a request and starts no shared read, whoever the
128
+ * caller is (#415's code review, 1 to 4). An answer that isn't the person asked for, or is another
129
+ * organisation's, is invalid, echoing no id; an API user's is `not_found`, as an id nobody has,
130
+ * whatever else its record holds. Only then is the person read. Every invalid after the read keeps
131
+ * the status the person's answer came with (#385). The organisation's failure, then the person's,
132
+ * is the answer.
133
+ */
134
+ async function readMember(seam, read, request, organization) {
124
135
  const spec = seam.user(request.member_id, zWho);
125
136
  if (spec === null)
126
137
  return { ok: false, error: { kind: 'refused', reason: 'path' } };
127
- const [ours, who] = await Promise.all([organization ?? read(seam.myOrganization(zOrganizationId)), read(spec)]);
138
+ const [ours, who] = await Promise.all([organization(), read(spec)]);
128
139
  if (!ours.ok)
129
140
  return ours;
130
141
  if (!who.ok)
@@ -132,15 +143,30 @@ export async function getMember(seam, read, request, organization) {
132
143
  const whose = zWhose.safeParse(who.data);
133
144
  // A key is not_found even when whose it is can't be read, as an id nobody has (#367's code review, 8).
134
145
  if (!whose.success)
135
- return who.data.is_api_user ? noSuchMember() : invalidAnswer(z.prettifyError(whose.error));
146
+ return who.data.is_api_user ? noSuchMember() : invalidIn(who, z.prettifyError(whose.error));
136
147
  if (!sameUuid(whose.data.id, request.member_id))
137
- return invalidAnswer("the member read isn't the one asked for");
148
+ return invalidIn(who, "the member read isn't the one asked for");
138
149
  if (!sameUuid(whose.data.organization_id, ours.data.id))
139
- return invalidAnswer("the member read is another organisation's");
150
+ return invalidIn(who, "the member read is another organisation's");
140
151
  if (who.data.is_api_user)
141
152
  return noSuchMember();
142
153
  const person = zRecord.safeParse(who.data);
143
- return person.success ? { ok: true, data: publicOf(person.data) } : invalidAnswer(z.prettifyError(person.error));
154
+ return person.success ? { ok: true, data: { member: publicOf(person.data), organization: ours.data } } : invalidIn(who, z.prettifyError(person.error));
155
+ }
156
+ /**
157
+ * `flipstream.members.remove()`: a D542 hand-off, as `datasets.delete` is. The person is read by
158
+ * `readMember`'s rules, with your organisation read for its short name too: your organisation's
159
+ * failure, then the person's, is the answer, so one nobody has, one your role can't read or an API
160
+ * key is `not_found`, a refused read is `forbidden`, and another organisation's person is
161
+ * `invalid`. A path that can't stay one segment is refused before anything is read. Only then
162
+ * `needs_person`, never a write (no call sends `DELETE /users/{id}`), with the person's page in the
163
+ * console where one can be named.
164
+ */
165
+ export async function handOffMemberRemove(seam, read, request) {
166
+ const member = await readMember(seam, read, request, () => read(seam.myOrganization(zHandOffOrganization)));
167
+ if (!member.ok)
168
+ return member;
169
+ return needsPerson('member.remove', seam.memberPage(member.data.organization.slug, member.data.member.id));
144
170
  }
145
171
  /**
146
172
  * The workspaces `member` opens, by D560's rule, read so it fails closed: a person whose account
@@ -162,19 +188,30 @@ export function opensWorkspace(you, workspaceId) {
162
188
  const opens = workspacesOpenedBy(you);
163
189
  return opens === 'every' || opens.some((id) => sameUuid(id, workspaceId));
164
190
  }
191
+ /**
192
+ * A page's first row of another organisation than `organizationId` (D556), as `invalid` naming its
193
+ * place, never an id, with `noun` naming what the row is, and the status the page's answer came with
194
+ * (#385); null when every row is your organisation's. None is dropped. The one check every page held
195
+ * to your organisation makes: your members, a workspace's datasets, their count and its logbook, and
196
+ * `heldToYou`'s first (#385's code review, 5).
197
+ */
198
+ export function foreignRow(page, organizationId, noun) {
199
+ const at = page.data.items.findIndex((row) => !sameUuid(row.organization_id, organizationId));
200
+ return at === -1 ? null : invalidIn(page, `records[${String(at)}] is another organisation's ${noun}`);
201
+ }
165
202
  /**
166
203
  * A page's `items` held to you (D556, D560): the first of another organisation than
167
- * `organizationId`, then the first in a workspace `you` don't open (`workspacesOpenedBy`), is
168
- * `invalid`, naming its place and never an id, with `noun` naming what the record is. Null when every
169
- * one is yours to see. None is dropped. The one check that log.list({ member_id }) (#295) and
170
- * datasets.list({ organization: true }) (#342) share, so the two can't drift apart (#342's code
171
- * review, 7).
204
+ * `organizationId` (`foreignRow`), then the first in a workspace `you` don't open
205
+ * (`workspacesOpenedBy`), is `invalid`, naming its place and never an id, with `noun` naming what the
206
+ * record is, and the status the page's answer came with (#385). Null when every one is yours to see.
207
+ * None is dropped. The one check that log.list({ member_id }) (#295) and datasets.list({
208
+ * organization: true }) (#342) share, so the two can't drift apart (#342's code review, 7).
172
209
  */
173
- export function heldToYou(items, organizationId, you, noun) {
174
- const foreign = items.findIndex((item) => !sameUuid(item.organization_id, organizationId));
175
- if (foreign !== -1)
176
- return invalidAnswer(`records[${String(foreign)}] is another organisation's ${noun}`);
177
- const closed = items.findIndex((item) => !opensWorkspace(you, item.workspace_id));
178
- return closed === -1 ? null : invalidAnswer(`records[${String(closed)}].workspace_id is a workspace you don't open`);
210
+ export function heldToYou(page, organizationId, you, noun) {
211
+ const foreign = foreignRow(page, organizationId, noun);
212
+ if (foreign !== null)
213
+ return foreign;
214
+ const closed = page.data.items.findIndex((item) => !opensWorkspace(you, item.workspace_id));
215
+ return closed === -1 ? null : invalidIn(page, `records[${String(closed)}].workspace_id is a workspace you don't open`);
179
216
  }
180
217
  //# sourceMappingURL=members.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"members.js","sourceRoot":"","sources":["../../src/api/members.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,eAAe,EAAa,MAAM,kBAAkB,CAAA;AAGrE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAGnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAkEnC,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAA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CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAA;IAC3F,OAAO,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,WAAW,MAAM,CAAC,MAAM,CAAC,8CAA8C,CAAC,CAAA;AACxH,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { z } from 'zod';
2
+ import type { CallSpec } from '../core/call.js';
3
+ import { type Failed, type Heard } from '../core/invalid.js';
4
+ import type { ApiResult } from '../core/result.js';
5
+ import type { Backend } from './backend.js';
6
+ import { type Read } from './me.js';
7
+ /** What a record read by its id names: itself, its organisation and its workspace. */
8
+ interface Placed {
9
+ readonly id: string;
10
+ readonly organization_id: string;
11
+ readonly workspace_id: string;
12
+ }
13
+ /**
14
+ * A record read by its id, a dataset or a log entry, held to you: the one rule both use (#404's
15
+ * code review, 1), as two copies of it drifted apart before (#404). The record names its workspace
16
+ * only once read, so it's read beside your organisation (D556) and you (`readUser`), all three
17
+ * started at once. A workspace named up front is `readOwnWorkspaceWith`'s rule instead.
18
+ * - **The order:** the answer is your organisation's failure, then yours, then the record's, then
19
+ * its checks: another organisation's record is `invalid`, and one in a workspace you don't open is
20
+ * `not_found`. So a sign-in whose read of you fails gets that failure whether the record exists or
21
+ * not (D571).
22
+ * - **No wait for the record once the answer is known:** when your organisation's read or yours has
23
+ * failed, the call answers once your organisation's read and yours have answered, without waiting
24
+ * for the record, and its end ends the record's read (the call scope, withReads, #349), whose
25
+ * rejection is still the call's.
26
+ * - **The record's own failure** is the backend's, passed on as it came, but pulse-admin's own
27
+ * refusal of it: that says it exists, so it answers `noSuch`, as one nobody has
28
+ * (`refusedAsNobodyHas`, D578), as one in a workspace you don't open does (D571). A role pulse-admin
29
+ * refuses every record gets `not_found` for every id, as accepted. A write's own 403, once the
30
+ * record is read, stays the caller's.
31
+ * - **An answer that isn't the record asked for** is `invalid`, and so is another organisation's,
32
+ * echoing no id: a staff token's reach is never shown as yours (D544). That `invalid` still says
33
+ * the record exists, to a token the backend answers other organisations' records for, as intended.
34
+ * - **One in a workspace you don't open** answers `noSuch`, the backend's own 404 for one nobody
35
+ * has, so a write after it sends nothing (D560, D571, #372).
36
+ * Both come back: the record as read, so a check after it keeps its status (#385), and your
37
+ * organisation, as `organizationSchema` reads it, so only a read that needs more than its id asks
38
+ * for more (#280). `what` names the record in an `invalid`'s words.
39
+ */
40
+ export declare function readOwnRecord<R extends Placed, O extends {
41
+ readonly id: string;
42
+ }>(seam: Backend, read: Read, spec: CallSpec<R>, id: string, organizationSchema: z.ZodType<O>, what: string, noSuch: () => Failed): Promise<ApiResult<{
43
+ readonly record: Heard<R>;
44
+ readonly organization: O;
45
+ }>>;
46
+ export {};
@@ -0,0 +1,57 @@
1
+ import { invalidIn } from '../core/invalid.js';
2
+ import { sameUuid } from './ids.js';
3
+ import { readUser } from './me.js';
4
+ import { opensWorkspace } from './members.js';
5
+ import { refusedAsNobodyHas } from './refusal.js';
6
+ /**
7
+ * A record read by its id, a dataset or a log entry, held to you: the one rule both use (#404's
8
+ * code review, 1), as two copies of it drifted apart before (#404). The record names its workspace
9
+ * only once read, so it's read beside your organisation (D556) and you (`readUser`), all three
10
+ * started at once. A workspace named up front is `readOwnWorkspaceWith`'s rule instead.
11
+ * - **The order:** the answer is your organisation's failure, then yours, then the record's, then
12
+ * its checks: another organisation's record is `invalid`, and one in a workspace you don't open is
13
+ * `not_found`. So a sign-in whose read of you fails gets that failure whether the record exists or
14
+ * not (D571).
15
+ * - **No wait for the record once the answer is known:** when your organisation's read or yours has
16
+ * failed, the call answers once your organisation's read and yours have answered, without waiting
17
+ * for the record, and its end ends the record's read (the call scope, withReads, #349), whose
18
+ * rejection is still the call's.
19
+ * - **The record's own failure** is the backend's, passed on as it came, but pulse-admin's own
20
+ * refusal of it: that says it exists, so it answers `noSuch`, as one nobody has
21
+ * (`refusedAsNobodyHas`, D578), as one in a workspace you don't open does (D571). A role pulse-admin
22
+ * refuses every record gets `not_found` for every id, as accepted. A write's own 403, once the
23
+ * record is read, stays the caller's.
24
+ * - **An answer that isn't the record asked for** is `invalid`, and so is another organisation's,
25
+ * echoing no id: a staff token's reach is never shown as yours (D544). That `invalid` still says
26
+ * the record exists, to a token the backend answers other organisations' records for, as intended.
27
+ * - **One in a workspace you don't open** answers `noSuch`, the backend's own 404 for one nobody
28
+ * has, so a write after it sends nothing (D560, D571, #372).
29
+ * Both come back: the record as read, so a check after it keeps its status (#385), and your
30
+ * organisation, as `organizationSchema` reads it, so only a read that needs more than its id asks
31
+ * for more (#280). `what` names the record in an `invalid`'s words.
32
+ */
33
+ export async function readOwnRecord(seam, read, spec, id, organizationSchema, what, noSuch) {
34
+ // Started in this order, as they always were, so a transport's rejection is still the first
35
+ // read's to reject in that order (withReads, #349).
36
+ const organization = read(seam.myOrganization(organizationSchema));
37
+ const record = read(spec);
38
+ const you = readUser(seam, read);
39
+ // Observed at once: once your organisation's read or yours has failed, it isn't waited for.
40
+ record.catch(() => undefined);
41
+ const [ours, yours] = await Promise.all([organization, you]);
42
+ if (!ours.ok)
43
+ return ours;
44
+ if (!yours.ok)
45
+ return yours;
46
+ const answer = await record;
47
+ if (!answer.ok)
48
+ return refusedAsNobodyHas(answer, noSuch);
49
+ if (!sameUuid(answer.data.id, id))
50
+ return invalidIn(answer, `the ${what} read isn't the one asked for`);
51
+ if (!sameUuid(answer.data.organization_id, ours.data.id))
52
+ return invalidIn(answer, `the ${what} read is another organisation's`);
53
+ if (!opensWorkspace(yours.data, answer.data.workspace_id))
54
+ return noSuch();
55
+ return { ok: true, data: { record: answer, organization: ours.data } };
56
+ }
57
+ //# sourceMappingURL=ownRecord.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ownRecord.js","sourceRoot":"","sources":["../../src/api/ownRecord.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SA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,CAAC,CAAA;IACvG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAAE,OAAO,SAAS,CAAC,MAAM,EAAE,OAAO,IAAI,iCAAiC,CAAC,CAAA;IAChI,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC;QAAE,OAAO,MAAM,EAAE,CAAA;IAC1E,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAA;AACxE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Failed } from '../core/invalid.js';
2
+ /**
3
+ * A record's or a workspace's own read's failure, as the call answers it: the one rule
4
+ * `readOwnRecord` and `readOwnWorkspaceWith` use (D578, #406; #410's code review, 2, 3 and 8).
5
+ * - **pulse-admin's own refusal of it** says it exists, so it answers `noSuch`, exactly as one
6
+ * nobody has, as one in a workspace you don't open does (D571). It's answered in place of the
7
+ * refusal (`inPlaceOf`), so the call still names the read it came from, as for the backend's own
8
+ * 404 (#410's code review, 1).
9
+ * - **Any other failure** passes as it came: a 403 that isn't pulse-admin's own, from a proxy, a
10
+ * gateway or a sign-in page in front of it, or pulse-admin's refusal of the token, says nothing
11
+ * about the record, and masking it would make a setup that refuses everything read as nothing
12
+ * existing.
13
+ */
14
+ export declare function refusedAsNobodyHas(failed: Failed, noSuch: () => Failed): Failed;
@@ -0,0 +1,23 @@
1
+ import { inPlaceOf } from '../core/inPlaceOf.js';
2
+ // pulse-admin's own refusal: its ForbiddenException, a 403 with its JSON error, code
3
+ // FORBIDDEN_EXCEPTION (dff6bf9b, adapters/ingress/fastapi/__init__.py:124-133: the code is the
4
+ // exception's class name, as `{ code, message }`). Its other 403, TOKEN_INVALID_EXCEPTION, refuses
5
+ // the token, not a record.
6
+ const REFUSED = 'FORBIDDEN_EXCEPTION';
7
+ /**
8
+ * A record's or a workspace's own read's failure, as the call answers it: the one rule
9
+ * `readOwnRecord` and `readOwnWorkspaceWith` use (D578, #406; #410's code review, 2, 3 and 8).
10
+ * - **pulse-admin's own refusal of it** says it exists, so it answers `noSuch`, exactly as one
11
+ * nobody has, as one in a workspace you don't open does (D571). It's answered in place of the
12
+ * refusal (`inPlaceOf`), so the call still names the read it came from, as for the backend's own
13
+ * 404 (#410's code review, 1).
14
+ * - **Any other failure** passes as it came: a 403 that isn't pulse-admin's own, from a proxy, a
15
+ * gateway or a sign-in page in front of it, or pulse-admin's refusal of the token, says nothing
16
+ * about the record, and masking it would make a setup that refuses everything read as nothing
17
+ * existing.
18
+ */
19
+ export function refusedAsNobodyHas(failed, noSuch) {
20
+ const { error } = failed;
21
+ return error.kind === 'forbidden' && error.code === REFUSED ? inPlaceOf(failed, noSuch()) : failed;
22
+ }
23
+ //# sourceMappingURL=refusal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refusal.js","sourceRoot":"","sources":["../../src/api/refusal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAGhD,qFAAqF;AACrF,+FAA+F;AAC/F,mGAAmG;AACnG,2BAA2B;AAC3B,MAAM,OAAO,GAAG,qBAAqB,CAAA;AAErC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc,EAAE,MAAoB;IACrE,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IACxB,OAAO,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAA;AACpG,CAAC"}
@@ -32,7 +32,8 @@ export interface Ledger {
32
32
  /**
33
33
  * `flipstream.wallet.balance()`: your organisation's balance, or null when it has no wallet. No
34
34
  * wallet is a real state, not a fault, so it isn't `invalid`, and it isn't €0.00 either: a zero
35
- * balance would claim a wallet that holds nothing.
35
+ * balance would claim a wallet that holds nothing. Your organisation is read first, every time, with
36
+ * no cache (once for a whole scope, #376), as `transactions()` reads it: the wallet's id is its id.
36
37
  */
37
38
  export declare function readBalance(seam: Backend, read: Read): Promise<ApiResult<Balance | null>>;
38
39
  /**
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { invalidAnswer } from '../core/invalid.js';
2
+ import { invalidIn } from '../core/invalid.js';
3
3
  import { sameUuid } from './ids.js';
4
4
  import { instant } from './time.js';
5
5
  /*
@@ -31,23 +31,19 @@ const zTransaction = z
31
31
  created_on: instant,
32
32
  })
33
33
  .transform(({ dataset_id, ...row }) => ({ ...row, dataset_id: dataset_id === '' || dataset_id === null ? null : dataset_id }));
34
- /** Your organisation's id, read every time, with no cache: the wallet's id is the organisation's. */
35
- async function organizationId(seam, read) {
36
- const organization = await read(seam.myOrganization(zOrganizationId));
37
- return organization.ok ? { ok: true, data: organization.data.id } : organization;
38
- }
39
34
  /**
40
35
  * The guard both reads share: the balance's rows held to the organisation read. pulse-wallet scopes
41
36
  * by the token, not the path, and answers the caller's own wallet for another organisation's id
42
37
  * (#244's recording), so a row of another wallet is invalid, never read as yours. Two wallets are
43
38
  * invalid too: an organisation has one. No rows is no wallet, null.
44
39
  */
45
- function ownWallet(rows, organization) {
40
+ function ownWallet(balance, organization) {
41
+ const rows = balance.data;
46
42
  if (rows.some((row) => !sameUuid(row.wallet_id, organization)))
47
- return invalidAnswer("a balance row is another wallet's");
43
+ return invalidIn(balance, "a balance row is another wallet's");
48
44
  const [row, ...more] = rows;
49
45
  if (more.length > 0)
50
- return invalidAnswer('more than one wallet for the organisation');
46
+ return invalidIn(balance, 'more than one wallet for the organisation');
51
47
  return { ok: true, data: row ?? null };
52
48
  }
53
49
  const UNNAMED = "the organisation's id can't name its wallet";
@@ -55,25 +51,26 @@ const UNNAMED = "the organisation's id can't name its wallet";
55
51
  * Whether your organisation has a wallet, decided in this one place for both reads (#375's code
56
52
  * review, 5): its balance rows, read and held to `organization` by `ownWallet`, so a row is your
57
53
  * wallet and null is none. The first of: the balance's failure, the wallet's verdict. `organization`
58
- * is your organisation's id, read by the caller, so the ledger can be read beside the balance.
54
+ * is your organisation, read by the caller, so the ledger can be read beside the balance.
59
55
  */
60
56
  async function readOwnWallet(seam, read, organization) {
61
- const spec = seam.balanceOf(organization, zBalanceRow);
57
+ const spec = seam.balanceOf(organization.data.id, zBalanceRow);
62
58
  if (spec === null)
63
- return invalidAnswer(UNNAMED);
59
+ return invalidIn(organization, UNNAMED);
64
60
  const rows = await read(spec);
65
- return rows.ok ? ownWallet(rows.data, organization) : rows;
61
+ return rows.ok ? ownWallet(rows, organization.data.id) : rows;
66
62
  }
67
63
  /**
68
64
  * `flipstream.wallet.balance()`: your organisation's balance, or null when it has no wallet. No
69
65
  * wallet is a real state, not a fault, so it isn't `invalid`, and it isn't €0.00 either: a zero
70
- * balance would claim a wallet that holds nothing.
66
+ * balance would claim a wallet that holds nothing. Your organisation is read first, every time, with
67
+ * no cache (once for a whole scope, #376), as `transactions()` reads it: the wallet's id is its id.
71
68
  */
72
69
  export async function readBalance(seam, read) {
73
- const organization = await organizationId(seam, read);
70
+ const organization = await read(seam.myOrganization(zOrganizationId));
74
71
  if (!organization.ok)
75
72
  return organization;
76
- const wallet = await readOwnWallet(seam, read, organization.data);
73
+ const wallet = await readOwnWallet(seam, read, organization);
77
74
  if (!wallet.ok)
78
75
  return wallet;
79
76
  return { ok: true, data: wallet.data === null ? null : { balance_micro: wallet.data.balance_micro, micro_per_euro: MICRO_PER_EURO } };
@@ -89,15 +86,15 @@ export async function readBalance(seam, read) {
89
86
  * O2.F1).
90
87
  */
91
88
  export async function readLedger(seam, read) {
92
- const organization = await organizationId(seam, read);
89
+ const organization = await read(seam.myOrganization(zOrganizationId));
93
90
  if (!organization.ok)
94
91
  return organization;
95
92
  // Checked before either read is sent. The balance's path takes the same id, so once the
96
93
  // ledger's can name it, so can the balance's, and readOwnWallet never refuses after this.
97
- const ledgerSpec = seam.ledgerOf(organization.data, zTransaction);
94
+ const ledgerSpec = seam.ledgerOf(organization.data.id, zTransaction);
98
95
  if (ledgerSpec === null)
99
- return invalidAnswer(UNNAMED);
100
- const [wallet, ledger] = await Promise.all([readOwnWallet(seam, read, organization.data), read(ledgerSpec)]);
96
+ return invalidIn(organization, UNNAMED);
97
+ const [wallet, ledger] = await Promise.all([readOwnWallet(seam, read, organization), read(ledgerSpec)]);
101
98
  // The wallet's verdict comes from the balance, so it comes before the ledger's own failure: a
102
99
  // caller never retries a ledger of a wallet that isn't theirs, nor of no wallet.
103
100
  if (!wallet.ok)
@@ -105,7 +102,7 @@ export async function readLedger(seam, read) {
105
102
  if (wallet.data === null) {
106
103
  if (!ledger.ok)
107
104
  return ledger.error.kind === 'invalid' ? ledger : { ok: true, data: null };
108
- return ledger.data.length > 0 ? invalidAnswer('ledger rows for an organisation with no wallet') : { ok: true, data: null };
105
+ return ledger.data.length > 0 ? invalidIn(ledger, 'ledger rows for an organisation with no wallet') : { ok: true, data: null };
109
106
  }
110
107
  if (!ledger.ok)
111
108
  return ledger;
@@ -1 +1 @@
1
- {"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGlD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC;;;GAGG;AAEH;;;;GAIG;AACH,MAAM,cAAc,GAAG,MAAM,CAAA;AAiC7B,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAC5B,MAAM,eAAe,GAAG,CAAC,CAAC,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,IAAI,CAAC,EAAE,EAAE,YAAY,CAAC,CAAA;IACpE,IAAI,UAAU,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IAChE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,YAAY,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;IACvG,8FAA8F;IAC9F,iFAAiF;IACjF,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,OAAO,MAAM,CAAA;IAC7B,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;QAC1F,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,gDAAgD,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;IAChI,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,OAAO,MAAM,CAAA;IAC7B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,cAAc,EAAE,cAAc,EAAE,EAAE,CAAA;AACnF,CAAC"}
@@ -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
  /**
@@ -81,9 +81,14 @@ export declare function readOwnWorkspace<O extends {
81
81
  * and 4).
82
82
  * - **Then the workspace and `alongside`** (a list under it), side by side. A workspace of another
83
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.
84
+ * isn't the workspace asked for. pulse-admin's own refusal of the workspace's read is `not_found`,
85
+ * exactly as one nobody has, since it says the workspace exists (`refusedAsNobodyHas`, D578), for
86
+ * every call under a named workspace. A 403 on `alongside`, or on a write after it, is the
87
+ * caller's, as it came.
85
88
  * 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.
89
+ * comes back as it is, for the caller to read after. This isn't `readOwnRecord`'s rule, which reads
90
+ * a record beside you because the record names its workspace only once read: a workspace named up
91
+ * front is read only once you're known to open it, so one you don't open is never fetched.
87
92
  */
88
93
  export declare function readOwnWorkspaceWith<O extends {
89
94
  readonly id: string;
@@ -1,11 +1,12 @@
1
1
  import { z } from 'zod';
2
2
  import { parseJson } from '../core/body.js';
3
- import { invalidAnswer, invalidStatusUnknown } from '../core/invalid.js';
3
+ import { invalidIn } from '../core/invalid.js';
4
4
  import { notFound } from '../core/notFound.js';
5
5
  import { needsPerson, zHandOffOrganization } from './handoff.js';
6
6
  import { sameUuid } from './ids.js';
7
7
  import { readUser } from './me.js';
8
8
  import { opensWorkspace } from './members.js';
9
+ import { refusedAsNobodyHas } from './refusal.js';
9
10
  import { pageQuery } from './page.js';
10
11
  import { unsent } from './unsent.js';
11
12
  const id = z.string().min(1);
@@ -46,13 +47,13 @@ const zOrganizationId = z.object({ id });
46
47
  const publicOf = ({ id: workspaceId, name, slug, meta }) => ({ id: workspaceId, name, slug, services: servicesOf(meta) });
47
48
  /**
48
49
  * `flipstream.workspaces.list()`: one page of your organisation's workspaces. Your organisation is
49
- * read first, every time, with no cache, for its id. A workspace of another organisation makes the
50
- * page invalid. A bad limit or offset throws before anything is sent. No sort is sent (D550, as
51
- * amended): an empty one gives pulse-admin's repository default, `name` for clients
52
- * (ClientRepository.order_by, pulse-admin 72ec7ef), a single-column order with no tiebreaker, and
53
- * names aren't unique. So pages read at different times can overlap or skip a workspace: when
54
- * workspaces are added, removed or renamed in between, or when two share a name, and a changed
55
- * `total` shows only some of it. A complete, stable list is one page, of up to 1,000.
50
+ * read first, every time, with no cache (once for a whole scope, #376), for its id. A workspace of
51
+ * another organisation makes the page invalid. A bad limit or offset throws before anything is
52
+ * sent. No sort is sent (D550, as amended): an empty one gives pulse-admin's repository default,
53
+ * `name` for clients (ClientRepository.order_by, pulse-admin 72ec7ef), a single-column order with
54
+ * no tiebreaker, and names aren't unique. So pages read at different times can overlap or skip a
55
+ * workspace: when workspaces are added, removed or renamed in between, or when two share a name,
56
+ * and a changed `total` shows only some of it. A complete, stable list is one page, of up to 1,000.
56
57
  */
57
58
  export async function readWorkspaces(seam, read, page) {
58
59
  const sent = pageQuery(page);
@@ -62,7 +63,7 @@ export async function readWorkspaces(seam, read, page) {
62
63
  const ours = organization.data.id;
63
64
  const spec = seam.workspacesOf(ours, sent, zRecord, (workspace) => sameUuid(workspace.organization_id, ours));
64
65
  if (spec === null)
65
- return invalidAnswer("the organisation's id can't name its workspaces");
66
+ return invalidIn(organization, "the organisation's id can't name its workspaces");
66
67
  const listed = await read(spec);
67
68
  return listed.ok ? { ok: true, data: { ...listed.data, items: listed.data.items.map(publicOf) } } : listed;
68
69
  }
@@ -93,7 +94,7 @@ export async function createWorkspace(seam, send, request) {
93
94
  if (!made.ok)
94
95
  return made;
95
96
  if (!sameUuid(made.data.organization_id, organization.data.id))
96
- return invalidStatusUnknown("the workspace made is another organisation's");
97
+ return invalidIn(made, "the workspace made is another organisation's");
97
98
  return { ok: true, data: publicOf(made.data) };
98
99
  }
99
100
  // pulse-admin's own 404 for a workspace nobody has, as recorded (test/recorded/admin/error-404.json;
@@ -120,9 +121,14 @@ export async function readOwnWorkspace(seam, read, workspaceId, organizationSche
120
121
  * and 4).
121
122
  * - **Then the workspace and `alongside`** (a list under it), side by side. A workspace of another
122
123
  * 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
+ * isn't the workspace asked for. pulse-admin's own refusal of the workspace's read is `not_found`,
125
+ * exactly as one nobody has, since it says the workspace exists (`refusedAsNobodyHas`, D578), for
126
+ * every call under a named workspace. A 403 on `alongside`, or on a write after it, is the
127
+ * caller's, as it came.
124
128
  * 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.
129
+ * comes back as it is, for the caller to read after. This isn't `readOwnRecord`'s rule, which reads
130
+ * a record beside you because the record names its workspace only once read: a workspace named up
131
+ * front is read only once you're known to open it, so one you don't open is never fetched.
126
132
  */
127
133
  export async function readOwnWorkspaceWith(seam, read, workspaceId, organizationSchema, alongside) {
128
134
  const spec = seam.workspace(workspaceId, zRecord);
@@ -137,14 +143,14 @@ export async function readOwnWorkspaceWith(seam, read, workspaceId, organization
137
143
  return noSuchWorkspace();
138
144
  const [workspace, beside] = await Promise.all([read(spec), alongside()]);
139
145
  if (!workspace.ok)
140
- return workspace;
146
+ return refusedAsNobodyHas(workspace, noSuchWorkspace);
141
147
  // Another workspace than the one asked for is never answered as it, as me() holds its user to
142
148
  // userinfo's sub; neither id is echoed. The caller's id may be any form pulse-admin reads as the
143
149
  // same UUID (sameUuid), and so may the organisation's id the workspace names (#363).
144
150
  if (!sameUuid(workspace.data.id, workspaceId))
145
- return invalidAnswer("the workspace read isn't the one asked for");
151
+ return invalidIn(workspace, "the workspace read isn't the one asked for");
146
152
  if (!sameUuid(workspace.data.organization_id, organization.data.id))
147
- return invalidAnswer("the workspace read is another organisation's");
153
+ return invalidIn(workspace, "the workspace read is another organisation's");
148
154
  return { ok: true, data: { organization: organization.data, workspace: workspace.data, alongside: beside } };
149
155
  }
150
156
  /** `flipstream.workspaces.get()`: one workspace, by `readOwnWorkspace`'s rules. */