@metacensus/api 0.0.0 → 0.3.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 (66) hide show
  1. package/README.md +158 -7
  2. package/dist/index.d.ts +1 -3
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +11 -7
  5. package/dist/index.js.map +1 -1
  6. package/dist/public.d.ts +6 -0
  7. package/dist/public.d.ts.map +1 -0
  8. package/dist/public.js +14 -0
  9. package/dist/public.js.map +1 -0
  10. package/dist/signing.d.ts +2 -0
  11. package/dist/signing.d.ts.map +1 -0
  12. package/dist/signing.js +5 -0
  13. package/dist/signing.js.map +1 -0
  14. package/dist/src/client.d.ts +66 -0
  15. package/dist/src/client.d.ts.map +1 -0
  16. package/dist/src/client.js +205 -0
  17. package/dist/src/client.js.map +1 -0
  18. package/dist/src/metacensus/public/v1/common.d.ts +20 -0
  19. package/dist/src/metacensus/public/v1/common.d.ts.map +1 -0
  20. package/dist/src/metacensus/public/v1/common.js +26 -0
  21. package/dist/src/metacensus/public/v1/common.js.map +1 -0
  22. package/dist/src/metacensus/public/v1/partner.d.ts +55 -0
  23. package/dist/src/metacensus/public/v1/partner.d.ts.map +1 -0
  24. package/dist/src/metacensus/public/v1/partner.js +22 -0
  25. package/dist/src/metacensus/public/v1/partner.js.map +1 -0
  26. package/dist/src/metacensus/v1/auth.d.ts +17 -3
  27. package/dist/src/metacensus/v1/auth.d.ts.map +1 -1
  28. package/dist/src/metacensus/v1/auth.js +0 -1
  29. package/dist/src/metacensus/v1/auth.js.map +1 -1
  30. package/dist/src/metacensus/v1/common.d.ts +85 -6
  31. package/dist/src/metacensus/v1/common.d.ts.map +1 -1
  32. package/dist/src/metacensus/v1/common.js +10 -0
  33. package/dist/src/metacensus/v1/common.js.map +1 -1
  34. package/dist/src/metacensus/v1/prop.d.ts +65 -26
  35. package/dist/src/metacensus/v1/prop.d.ts.map +1 -1
  36. package/dist/src/metacensus/v1/prop.js +1 -2
  37. package/dist/src/metacensus/v1/prop.js.map +1 -1
  38. package/dist/src/metacensus/v1/topic.d.ts +27 -12
  39. package/dist/src/metacensus/v1/topic.d.ts.map +1 -1
  40. package/dist/src/metacensus/v1/topic.js +0 -1
  41. package/dist/src/metacensus/v1/topic.js.map +1 -1
  42. package/dist/src/metacensus/v1/user.d.ts +21 -7
  43. package/dist/src/metacensus/v1/user.d.ts.map +1 -1
  44. package/dist/src/metacensus/v1/user.js +0 -1
  45. package/dist/src/metacensus/v1/user.js.map +1 -1
  46. package/dist/src/route-manifest.d.ts +3 -0
  47. package/dist/src/route-manifest.d.ts.map +1 -1
  48. package/dist/src/route-manifest.js +32 -30
  49. package/dist/src/route-manifest.js.map +1 -1
  50. package/dist/src/signing.d.ts +37 -0
  51. package/dist/src/signing.d.ts.map +1 -0
  52. package/dist/src/signing.js +188 -0
  53. package/dist/src/signing.js.map +1 -0
  54. package/package.json +16 -4
  55. package/dist/src/metacensus/v1/extraction.d.ts +0 -48
  56. package/dist/src/metacensus/v1/extraction.d.ts.map +0 -1
  57. package/dist/src/metacensus/v1/extraction.js +0 -8
  58. package/dist/src/metacensus/v1/extraction.js.map +0 -1
  59. package/dist/src/metacensus/v1/paper.d.ts +0 -57
  60. package/dist/src/metacensus/v1/paper.d.ts.map +0 -1
  61. package/dist/src/metacensus/v1/paper.js +0 -8
  62. package/dist/src/metacensus/v1/paper.js.map +0 -1
  63. package/dist/src/metacensus/v1/protocol.d.ts +0 -42
  64. package/dist/src/metacensus/v1/protocol.d.ts.map +0 -1
  65. package/dist/src/metacensus/v1/protocol.js +0 -8
  66. package/dist/src/metacensus/v1/protocol.js.map +0 -1
package/README.md CHANGED
@@ -1,22 +1,173 @@
1
1
  # @metacensus/api
2
2
 
3
3
  TypeScript interfaces for the MetaCensus API contract — every request and
4
- response under `/metacensus/api/v1`, generated from the `.proto` sources that
5
- also generate the Go side.
4
+ response under `/metacensus/api/v1` and `/metacensus/public`, generated from the
5
+ `.proto` sources that also generate the Go side.
6
6
 
7
- **Types only.** There are no runtime dependencies and no value imports; a build
8
- step enforces both. What ships is the generated interfaces, the route manifest,
9
- and `protobufPackage`.
7
+ What ships is the generated interfaces, the route manifest, `protobufPackage`, a
8
+ batteries-included client per surface, and the signing chain. How dependencies
9
+ are weighed is in the repository's AGENTS.md, under "Dependencies".
10
10
 
11
11
  ```bash
12
12
  npm install @metacensus/api
13
13
  ```
14
14
 
15
15
  ```ts
16
- import type { Topic, PropCreateRequest } from "@metacensus/api";
17
- import { routes } from "@metacensus/api";
16
+ import { Client, ApiError, type Signer } from "@metacensus/api";
17
+
18
+ const client = new Client({ baseUrl: "https://api.example.com", signer });
19
+ await client.login({ email, password }); // token stored internally
20
+ const topic = await client.getTopic({ topicId }); // TopicRecord: { id, recorded, name, description }
21
+ ```
22
+
23
+ `Client` is batteries-included: it owns its `fetch`, holds the session token
24
+ across `login`/`logout`, and signs writes with the `signer` you inject. It is the
25
+ client to reach for. Construct it with:
26
+
27
+ - `baseUrl` — the origin; the client adds `/metacensus/api/v1` and the route.
28
+ - `fetch?` — a `fetch` to use instead of the global, for tests or instrumentation
29
+ (wrap the global to add retries, a 401 policy, or logging).
30
+ - `signer?` — signs writes; see "Writes", below. Omit it for a read-only client.
31
+ - `token?` — an initial bearer token, to resume a session without logging in.
32
+
33
+ A non-2xx response throws `ApiError` (`method`, `url`, `status`, and the raw
34
+ `body` — parse it defensively, since a 404 or 405 comes from the router, not a
35
+ handler). Every scalar is required, which is what makes Go's `EmitDefaultValues`
36
+ and these types describe the same document: `client.createTopic({ content: { name } })`
37
+ does not type-check, `{ content: { name, description: "" } }` does.
38
+
39
+ ## Reads: flat record or signed envelope
40
+
41
+ A read returns the **flat record** — the domain object with the server's `id`
42
+ and `recorded` folded in, and the `{content, userSignature}` envelope gone:
43
+
44
+ ```ts
45
+ const topic = await client.getTopic({ topicId }); // { id, recorded, name, description }
46
+ topic.name; // not topic.content.name
47
+ ```
48
+
49
+ The envelope isn't uniform, so the record isn't either:
50
+
51
+ | Response shape | `getX` / `listX` returns |
52
+ | --- | --- |
53
+ | id-bearing envelope (topic, prop, user) | `TopicRecord` — `{ id, recorded, ...content }` — / `TopicRecord[]` |
54
+ | a vote — envelope with **no `id`** | `VoteRecord` (no `id`) / `VoteRecord[]` |
55
+ | a member — already flat | `Member`, unchanged / `Member[]` |
56
+
57
+ When you need the signature itself — verifying authorship, comparing `recorded`
58
+ against the signer's `signingTime`, or re-hashing the document — each
59
+ signed-envelope read has a **`getXSigned`** twin that returns the raw envelope:
60
+
61
+ ```ts
62
+ const signed = await client.getTopicSigned({ topicId }); // TopicSigned: { id, recorded, content, userSignature }
63
+ await verify(pub, signed.content, signed.userSignature);
64
+ ```
65
+
66
+ `getXSigned` exists only where there's a signature to see; `Member` has none.
67
+
68
+ ## Writes and the signer
69
+
70
+ A write takes **flat content** — never the envelope — and the `signer` assembles
71
+ the rest. The signer is set once on the constructor, because the key it signs
72
+ with is identical for a session:
73
+
74
+ ```ts
75
+ import { SPEC, sign, keyId } from "@metacensus/api/signing";
76
+
77
+ const signer: Signer = async (content, contentType) => {
78
+ const s = {
79
+ signerId,
80
+ keyId: await keyId(publicKey),
81
+ alg: "Es384",
82
+ publicKey: "",
83
+ signingTime: new Date().toISOString(),
84
+ spec: SPEC,
85
+ contentType, // the client names it — you don't
86
+ value: "",
87
+ };
88
+ s.value = await sign(privateKey, content, s);
89
+ return s;
90
+ };
91
+
92
+ const client = new Client({ baseUrl, signer });
93
+ const created = await client.createTopic({ content: { name: "A review", description: "" } });
94
+ // TopicRecord, flattened like a read
95
+ ```
96
+
97
+ The client supplies `content` and the exact `contentType` (the one thing
98
+ `sign`/`verify` leave to the caller, and the easiest to get wrong); your closure
99
+ holds the key and does the crypto — the key never enters the client. A write on
100
+ a client built without a signer throws.
101
+
102
+ ## Auth and the session token
103
+
104
+ `login` and `signUp` store the returned token; the client adds
105
+ `Authorization: Bearer <token>` to every later request, and `logout` clears it.
106
+ `signUp` signs its `User` content through the same signer (that signature enrols
107
+ the key — inline `publicKey`, empty `signerId`; keep the password out of
108
+ `content`, since content is what gets stored). `token` (a getter) exposes the
109
+ current token, to persist and later restore a session via the `token` option.
110
+
111
+ ## The public surface
112
+
113
+ The public, unauthenticated surface is an entry point of its own in the same
114
+ package, with a client to match — no signer, no token:
115
+
116
+ ```ts
117
+ import type { PartnerSubmission } from "@metacensus/api/public";
118
+ import { PartnerSubmission_Interest, PublicClient } from "@metacensus/api/public";
119
+
120
+ const pub = new PublicClient({ baseUrl });
121
+ await pub.submitPartnerInterest({ name, email, interests, message, website: "" });
122
+ ```
123
+
124
+ One package because the SPA calls both surfaces from one build; an entry point
125
+ per surface because a consumer of only the public surface should not acquire the
126
+ authenticated types. `@metacensus/api/signing` is a third, splitting by concern
127
+ rather than by surface — nothing on the public surface is ever signed.
128
+
129
+ `ApiError` is the same class from either entry point, so `instanceof ApiError`
130
+ holds for a failure from either surface. Importing it twice is harmless.
131
+
132
+ `PartnerSubmission_Interest` is a string enum, so the checkbox list is generated
133
+ from the contract rather than mirrored by hand — which is the coupling this
134
+ package exists to make mechanical. `Unspecified` is the proto3 zero value, not
135
+ an offered choice, so filter it out:
136
+
137
+ ```ts
138
+ const choices = Object.values(PartnerSubmission_Interest).filter(
139
+ (i) => i !== PartnerSubmission_Interest.Unspecified,
140
+ );
141
+ ```
142
+
143
+ The display labels are not in the contract; they stay in the SPA as copy. See
144
+ the enum's comment for why.
145
+
146
+ ## Signing
147
+
148
+ Every write on the authenticated surface carries a `content` message and a
149
+ `userSignature` over it. A session token says who is connected; the signature
150
+ says who authored the record, and the API server does not check it — it is
151
+ verified by the persistence layer, behind the edge. `@metacensus/api/signing` is
152
+ what your `Signer` uses to make one:
153
+
154
+ ```ts
155
+ import { SPEC, sign, verify, keyId, generateKeyPair, encodePublicKey } from "@metacensus/api/signing";
156
+
157
+ const { privateKey, publicKey } = await generateKeyPair(); // ECDSA P-384
18
158
  ```
19
159
 
160
+ The digest is SHA-384 over RFC 8785 canonical JSON of `{content, signature}`,
161
+ with `value` emptied. Every field but `value` is inside it, so a signature cannot
162
+ be re-attributed or re-dated — which is why `contentType` has to name the content
163
+ you actually signed and `signingTime` has to be set. `routes` carries a `signed`
164
+ flag per route, so "which routes need a key?" is a lookup rather than a guess.
165
+
166
+ The full account of the chain, and `go/signing`, the other half that has to
167
+ compute the same digest, are in the repository README.
168
+
169
+ ## Both surfaces
170
+
20
171
  The wire format is JSON, not protobuf binary. Field names are `lowerCamelCase`
21
172
  on the wire, enum values are PascalCase, and all ids are strings.
22
173
 
package/dist/index.d.ts CHANGED
@@ -1,11 +1,9 @@
1
1
  export * from "./src/metacensus/v1/auth.js";
2
2
  export * from "./src/metacensus/v1/common.js";
3
- export * from "./src/metacensus/v1/extraction.js";
4
- export * from "./src/metacensus/v1/paper.js";
5
3
  export * from "./src/metacensus/v1/prop.js";
6
- export * from "./src/metacensus/v1/protocol.js";
7
4
  export * from "./src/metacensus/v1/topic.js";
8
5
  export * from "./src/metacensus/v1/user.js";
9
6
  export * from "./src/route-manifest.js";
10
7
  export { protobufPackage } from "./src/metacensus/v1/common.js";
8
+ export { Client, ApiError, type ClientOptions, type Signer, type TopicRecord, type PropRecord, type VoteRecord, type UserRecord, } from "./src/client.js";
11
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAIA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AAIxC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAOA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AAGxC,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAMhE,OAAO,EACL,MAAM,EACN,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,UAAU,GAChB,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -1,16 +1,20 @@
1
- // The MetaCensus API contract, as TypeScript. Types only, no runtime.
1
+ // The authenticated MetaCensus API contract (/metacensus/api/v1): generated
2
+ // types, route manifest, and typed Client. Everything under ./src is
3
+ // generated; a new .proto file needs a line here.
2
4
  //
3
- // Everything under ./src is generated; a new .proto file needs a line here.
5
+ // See ts/README.md for why the public surface (./public.ts) is a separate
6
+ // entry point rather than merged in here.
4
7
  export * from "./src/metacensus/v1/auth.js";
5
8
  export * from "./src/metacensus/v1/common.js";
6
- export * from "./src/metacensus/v1/extraction.js";
7
- export * from "./src/metacensus/v1/paper.js";
8
9
  export * from "./src/metacensus/v1/prop.js";
9
- export * from "./src/metacensus/v1/protocol.js";
10
10
  export * from "./src/metacensus/v1/topic.js";
11
11
  export * from "./src/metacensus/v1/user.js";
12
12
  export * from "./src/route-manifest.js";
13
- // Every generated file exports an identical `protobufPackage`, so `export *`
14
- // cannot pick one.
13
+ // `export *` can't pick one file's `protobufPackage` over another's.
15
14
  export { protobufPackage } from "./src/metacensus/v1/common.js";
15
+ // Named, not `export *`: src/client.ts has one class per surface, and this
16
+ // entry point wants only the authenticated one. `Client` is batteries-included;
17
+ // the `…Record` types are its flat reads and `Signer` its write seam. See
18
+ // ts/README.md, "The generated client".
19
+ export { Client, ApiError, } from "./src/client.js";
16
20
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,EAAE;AACF,4EAA4E;AAE5E,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AAExC,6EAA6E;AAC7E,mBAAmB;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,qEAAqE;AACrE,kDAAkD;AAClD,EAAE;AACF,0EAA0E;AAC1E,0CAA0C;AAE1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AAExC,qEAAqE;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,2EAA2E;AAC3E,gFAAgF;AAChF,0EAA0E;AAC1E,wCAAwC;AACxC,OAAO,EACL,MAAM,EACN,QAAQ,GAOT,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./src/metacensus/public/v1/common.js";
2
+ export * from "./src/metacensus/public/v1/partner.js";
3
+ export * from "./src/route-manifest.js";
4
+ export { protobufPackage } from "./src/metacensus/public/v1/common.js";
5
+ export { PublicClient, ApiError, type PublicClientOptions, } from "./src/client.js";
6
+ //# sourceMappingURL=public.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../public.ts"],"names":[],"mappings":"AAIA,cAAc,sCAAsC,CAAC;AACrD,cAAc,uCAAuC,CAAC;AACtD,cAAc,yBAAyB,CAAC;AAGxC,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAMvE,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,KAAK,mBAAmB,GACzB,MAAM,iBAAiB,CAAC"}
package/dist/public.js ADDED
@@ -0,0 +1,14 @@
1
+ // The public, unauthenticated MetaCensus surface (/metacensus/public):
2
+ // generated types, route manifest, and PublicClient. See ts/README.md for
3
+ // why this is a separate entry point from the authenticated one.
4
+ export * from "./src/metacensus/public/v1/common.js";
5
+ export * from "./src/metacensus/public/v1/partner.js";
6
+ export * from "./src/route-manifest.js";
7
+ // `export *` can't pick one file's `protobufPackage` over another's.
8
+ export { protobufPackage } from "./src/metacensus/public/v1/common.js";
9
+ // Named, not `export *`: src/client.ts has one class per surface, and this
10
+ // entry point wants only PublicClient. A public-only consumer still carries the
11
+ // authenticated Client as dead code (a bundler drops it), but not the
12
+ // authenticated types, which is what the split is for.
13
+ export { PublicClient, ApiError, } from "./src/client.js";
14
+ //# sourceMappingURL=public.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.js","sourceRoot":"","sources":["../public.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,0EAA0E;AAC1E,iEAAiE;AAEjE,cAAc,sCAAsC,CAAC;AACrD,cAAc,uCAAuC,CAAC;AACtD,cAAc,yBAAyB,CAAC;AAExC,qEAAqE;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAEvE,2EAA2E;AAC3E,gFAAgF;AAChF,sEAAsE;AACtE,uDAAuD;AACvD,OAAO,EACL,YAAY,EACZ,QAAQ,GAET,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { SPEC, canonicalize, signingInput, digest, sign, verify, generateKeyPair, encodePublicKey, decodePublicKey, keyId, } from "./src/signing.js";
2
+ //# sourceMappingURL=signing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signing.d.ts","sourceRoot":"","sources":["../signing.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,IAAI,EACJ,MAAM,EACN,eAAe,EACf,eAAe,EACf,eAAe,EACf,KAAK,GACN,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,5 @@
1
+ // The MetaCensus signing chain, producing the same digest as go/signing. A
2
+ // third entry point splitting by concern, not surface. See ts/README.md,
3
+ // "Signing". The runtime half is src/signing.ts.
4
+ export { SPEC, canonicalize, signingInput, digest, sign, verify, generateKeyPair, encodePublicKey, decodePublicKey, keyId, } from "./src/signing.js";
5
+ //# sourceMappingURL=signing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signing.js","sourceRoot":"","sources":["../signing.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,yEAAyE;AACzE,iDAAiD;AAEjD,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,IAAI,EACJ,MAAM,EACN,eAAe,EACf,eAAe,EACf,eAAe,EACf,KAAK,GACN,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,66 @@
1
+ import type { PartnerReceipt, PartnerSubmission } from "./metacensus/public/v1/partner.js";
2
+ import type { LoginRequest, LogoutRequest, LogoutResponse, Session, SignUpRequest } from "./metacensus/v1/auth.js";
3
+ import type { HealthcheckRequest, HealthcheckResponse, User, UserSignature } from "./metacensus/v1/common.js";
4
+ import type { Prop, PropCreateRequest, PropGetRequest, PropListRequest, PropSigned, Vote, VoteListRequest, VoteSetRequest, VoteSigned } from "./metacensus/v1/prop.js";
5
+ import type { Member, MemberGetRequest, MemberListRequest, Topic, TopicCreateRequest, TopicGetRequest, TopicListRequest, TopicSigned } from "./metacensus/v1/topic.js";
6
+ import type { SelfGetRequest, UserGetRequest, UserListRequest, UserSigned } from "./metacensus/v1/user.js";
7
+ export declare class ApiError extends Error {
8
+ readonly method: string;
9
+ readonly url: string;
10
+ readonly status: number;
11
+ readonly body: string;
12
+ constructor(method: string, url: string, status: number, body: string);
13
+ }
14
+ export type Signer = (content: unknown, contentType: string) => Promise<UserSignature>;
15
+ export type PropRecord = Pick<PropSigned, "id" | "recorded"> & Prop;
16
+ export type TopicRecord = Pick<TopicSigned, "id" | "recorded"> & Topic;
17
+ export type UserRecord = Pick<UserSigned, "id" | "recorded"> & User;
18
+ export type VoteRecord = Pick<VoteSigned, "recorded"> & Vote;
19
+ export interface ClientOptions {
20
+ readonly baseUrl: string;
21
+ readonly fetch?: typeof globalThis.fetch;
22
+ readonly signer?: Signer;
23
+ readonly token?: string;
24
+ readonly prefix?: string;
25
+ }
26
+ export declare class Client {
27
+ #private;
28
+ constructor(options: ClientOptions);
29
+ get token(): string | undefined;
30
+ login(req: LoginRequest): Promise<Session>;
31
+ signUp(req: Omit<SignUpRequest, "userSignature">): Promise<Session>;
32
+ logout(req: LogoutRequest): Promise<LogoutResponse>;
33
+ healthcheck(req: HealthcheckRequest): Promise<HealthcheckResponse>;
34
+ listProps(req: PropListRequest): Promise<PropRecord[]>;
35
+ listPropsSigned(req: PropListRequest): Promise<PropSigned[]>;
36
+ getProp(req: PropGetRequest): Promise<PropRecord>;
37
+ getPropSigned(req: PropGetRequest): Promise<PropSigned>;
38
+ createProp(req: Omit<PropCreateRequest, "userSignature">): Promise<PropRecord>;
39
+ listVotes(req: VoteListRequest): Promise<VoteRecord[]>;
40
+ listVotesSigned(req: VoteListRequest): Promise<VoteSigned[]>;
41
+ setVote(req: Omit<VoteSetRequest, "userSignature">): Promise<VoteRecord>;
42
+ listTopics(req: TopicListRequest): Promise<TopicRecord[]>;
43
+ listTopicsSigned(req: TopicListRequest): Promise<TopicSigned[]>;
44
+ getTopic(req: TopicGetRequest): Promise<TopicRecord>;
45
+ getTopicSigned(req: TopicGetRequest): Promise<TopicSigned>;
46
+ createTopic(req: Omit<TopicCreateRequest, "userSignature">): Promise<TopicRecord>;
47
+ listMembers(req: MemberListRequest): Promise<Member[]>;
48
+ getMember(req: MemberGetRequest): Promise<Member>;
49
+ listUsers(req: UserListRequest): Promise<UserRecord[]>;
50
+ listUsersSigned(req: UserListRequest): Promise<UserSigned[]>;
51
+ getUser(req: UserGetRequest): Promise<UserRecord>;
52
+ getUserSigned(req: UserGetRequest): Promise<UserSigned>;
53
+ getSelf(req: SelfGetRequest): Promise<UserRecord>;
54
+ getSelfSigned(req: SelfGetRequest): Promise<UserSigned>;
55
+ }
56
+ export interface PublicClientOptions {
57
+ readonly baseUrl: string;
58
+ readonly fetch?: typeof globalThis.fetch;
59
+ readonly prefix?: string;
60
+ }
61
+ export declare class PublicClient {
62
+ #private;
63
+ constructor(options: PublicClientOptions);
64
+ submitPartnerInterest(req: PartnerSubmission): Promise<PartnerReceipt>;
65
+ }
66
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAC3F,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACnH,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC9G,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,cAAc,EAAY,eAAe,EAAE,UAAU,EAAE,IAAI,EAAY,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC3L,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAc,iBAAiB,EAAE,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAa,gBAAgB,EAAE,WAAW,EAAE,MAAM,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DO NOT EDIT.
2
+ import { apiPrefix, publicPrefix } from "./route-manifest.js";
3
+ // ApiError is any non-2xx response. body is the response text, unparsed: a 404
4
+ // or 405 comes from the router, not a handler, so parse it defensively.
5
+ export class ApiError extends Error {
6
+ method;
7
+ url;
8
+ status;
9
+ body;
10
+ constructor(method, url, status, body) {
11
+ super(`${method} ${url}: HTTP ${status}`);
12
+ this.method = method;
13
+ this.url = url;
14
+ this.status = status;
15
+ this.body = body;
16
+ this.name = "ApiError";
17
+ }
18
+ }
19
+ function param(v) {
20
+ return encodeURIComponent(String(v));
21
+ }
22
+ async function request(f, url, method, body, token) {
23
+ const headers = {};
24
+ if (body !== undefined)
25
+ headers["Content-Type"] = "application/json";
26
+ if (token !== undefined)
27
+ headers["Authorization"] = `Bearer ${token}`;
28
+ const res = await f(url, { method, headers, body });
29
+ if (res.status < 200 || res.status >= 300) {
30
+ throw new ApiError(method, url, res.status, await res.text());
31
+ }
32
+ const text = await res.text();
33
+ return (text === "" ? {} : JSON.parse(text));
34
+ }
35
+ function flattenProp(r) {
36
+ return { id: r.id, recorded: r.recorded, ...r.content };
37
+ }
38
+ function flattenTopic(r) {
39
+ return { id: r.id, recorded: r.recorded, ...r.content };
40
+ }
41
+ function flattenUser(r) {
42
+ return { id: r.id, recorded: r.recorded, ...r.content };
43
+ }
44
+ function flattenVote(r) {
45
+ return { recorded: r.recorded, ...r.content };
46
+ }
47
+ // Client calls the authenticated API.
48
+ export class Client {
49
+ #baseUrl;
50
+ #fetch;
51
+ #prefix;
52
+ #signer;
53
+ #token;
54
+ constructor(options) {
55
+ this.#baseUrl = options.baseUrl;
56
+ this.#fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
57
+ this.#prefix = options.prefix ?? apiPrefix;
58
+ this.#signer = options.signer;
59
+ this.#token = options.token;
60
+ }
61
+ // The session token from the last login/signUp, for persisting a session.
62
+ get token() {
63
+ return this.#token;
64
+ }
65
+ #request(method, path, body) {
66
+ return request(this.#fetch, this.#baseUrl + this.#prefix + path, method, body, this.#token);
67
+ }
68
+ #sign(content, contentType) {
69
+ if (this.#signer === undefined) {
70
+ throw new Error("Client: a write needs a signer; construct new Client({ ..., signer })");
71
+ }
72
+ return this.#signer(content, contentType);
73
+ }
74
+ // AuthRoutes.Login: POST /login
75
+ async login(req) {
76
+ const session = await this.#request("POST", "/login", JSON.stringify(req));
77
+ this.#token = session.token;
78
+ return session;
79
+ }
80
+ // AuthRoutes.SignUp: POST /signup
81
+ async signUp(req) {
82
+ const userSignature = await this.#sign(req.content, "metacensus.v1.User");
83
+ const session = await this.#request("POST", "/signup", JSON.stringify({ ...req, userSignature }));
84
+ this.#token = session.token;
85
+ return session;
86
+ }
87
+ // AuthRoutes.Logout: POST /logout
88
+ async logout(req) {
89
+ const res = await this.#request("POST", "/logout", undefined);
90
+ this.#token = undefined;
91
+ return res;
92
+ }
93
+ // HealthRoutes.Healthcheck: GET /healthcheck
94
+ healthcheck(req) {
95
+ return this.#request("GET", "/healthcheck", undefined);
96
+ }
97
+ // PropRoutes.ListProps: GET /topic/{topicId}/prop
98
+ listProps(req) {
99
+ return this.#request("GET", `/topic/${param(req.topicId)}/prop`, undefined).then((r) => r.items.map(flattenProp));
100
+ }
101
+ // PropRoutes.ListProps: GET /topic/{topicId}/prop
102
+ listPropsSigned(req) {
103
+ return this.#request("GET", `/topic/${param(req.topicId)}/prop`, undefined).then((r) => r.items);
104
+ }
105
+ // PropRoutes.GetProp: GET /topic/{topicId}/prop/{propId}
106
+ getProp(req) {
107
+ return this.#request("GET", `/topic/${param(req.topicId)}/prop/${param(req.propId)}`, undefined).then(flattenProp);
108
+ }
109
+ // PropRoutes.GetProp: GET /topic/{topicId}/prop/{propId}
110
+ getPropSigned(req) {
111
+ return this.#request("GET", `/topic/${param(req.topicId)}/prop/${param(req.propId)}`, undefined);
112
+ }
113
+ // PropRoutes.CreateProp: POST /topic/{topicId}/prop
114
+ async createProp(req) {
115
+ const { topicId, ...rest } = req;
116
+ const userSignature = await this.#sign(rest.content, "metacensus.v1.Prop");
117
+ return flattenProp(await this.#request("POST", `/topic/${param(topicId)}/prop`, JSON.stringify({ ...rest, userSignature })));
118
+ }
119
+ // PropRoutes.ListVotes: GET /topic/{topicId}/prop/{propId}/vote
120
+ listVotes(req) {
121
+ return this.#request("GET", `/topic/${param(req.topicId)}/prop/${param(req.propId)}/vote`, undefined).then((r) => r.items.map(flattenVote));
122
+ }
123
+ // PropRoutes.ListVotes: GET /topic/{topicId}/prop/{propId}/vote
124
+ listVotesSigned(req) {
125
+ return this.#request("GET", `/topic/${param(req.topicId)}/prop/${param(req.propId)}/vote`, undefined).then((r) => r.items);
126
+ }
127
+ // PropRoutes.SetVote: POST /topic/{topicId}/prop/{propId}/vote
128
+ async setVote(req) {
129
+ const { topicId, propId, ...rest } = req;
130
+ const userSignature = await this.#sign(rest.content, "metacensus.v1.Vote");
131
+ return flattenVote(await this.#request("POST", `/topic/${param(topicId)}/prop/${param(propId)}/vote`, JSON.stringify({ ...rest, userSignature })));
132
+ }
133
+ // TopicRoutes.ListTopics: GET /topic
134
+ listTopics(req) {
135
+ return this.#request("GET", "/topic", undefined).then((r) => r.items.map(flattenTopic));
136
+ }
137
+ // TopicRoutes.ListTopics: GET /topic
138
+ listTopicsSigned(req) {
139
+ return this.#request("GET", "/topic", undefined).then((r) => r.items);
140
+ }
141
+ // TopicRoutes.GetTopic: GET /topic/{topicId}
142
+ getTopic(req) {
143
+ return this.#request("GET", `/topic/${param(req.topicId)}`, undefined).then(flattenTopic);
144
+ }
145
+ // TopicRoutes.GetTopic: GET /topic/{topicId}
146
+ getTopicSigned(req) {
147
+ return this.#request("GET", `/topic/${param(req.topicId)}`, undefined);
148
+ }
149
+ // TopicRoutes.CreateTopic: POST /topic
150
+ async createTopic(req) {
151
+ const userSignature = await this.#sign(req.content, "metacensus.v1.Topic");
152
+ return flattenTopic(await this.#request("POST", "/topic", JSON.stringify({ ...req, userSignature })));
153
+ }
154
+ // TopicRoutes.ListMembers: GET /topic/{topicId}/member
155
+ listMembers(req) {
156
+ return this.#request("GET", `/topic/${param(req.topicId)}/member`, undefined).then((r) => r.items);
157
+ }
158
+ // TopicRoutes.GetMember: GET /topic/{topicId}/member/{userId}
159
+ getMember(req) {
160
+ return this.#request("GET", `/topic/${param(req.topicId)}/member/${param(req.userId)}`, undefined);
161
+ }
162
+ // UserRoutes.ListUsers: GET /user
163
+ listUsers(req) {
164
+ return this.#request("GET", "/user", undefined).then((r) => r.items.map(flattenUser));
165
+ }
166
+ // UserRoutes.ListUsers: GET /user
167
+ listUsersSigned(req) {
168
+ return this.#request("GET", "/user", undefined).then((r) => r.items);
169
+ }
170
+ // UserRoutes.GetUser: GET /user/{userId}
171
+ getUser(req) {
172
+ return this.#request("GET", `/user/${param(req.userId)}`, undefined).then(flattenUser);
173
+ }
174
+ // UserRoutes.GetUser: GET /user/{userId}
175
+ getUserSigned(req) {
176
+ return this.#request("GET", `/user/${param(req.userId)}`, undefined);
177
+ }
178
+ // UserRoutes.GetSelf: GET /self
179
+ getSelf(req) {
180
+ return this.#request("GET", "/self", undefined).then(flattenUser);
181
+ }
182
+ // UserRoutes.GetSelf: GET /self
183
+ getSelfSigned(req) {
184
+ return this.#request("GET", "/self", undefined);
185
+ }
186
+ }
187
+ // PublicClient calls the public, unauthenticated surface.
188
+ export class PublicClient {
189
+ #baseUrl;
190
+ #fetch;
191
+ #prefix;
192
+ constructor(options) {
193
+ this.#baseUrl = options.baseUrl;
194
+ this.#fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
195
+ this.#prefix = options.prefix ?? publicPrefix;
196
+ }
197
+ #request(method, path, body) {
198
+ return request(this.#fetch, this.#baseUrl + this.#prefix + path, method, body, undefined);
199
+ }
200
+ // PartnerRoutes.SubmitPartnerInterest: POST /partner
201
+ submitPartnerInterest(req) {
202
+ return this.#request("POST", "/partner", JSON.stringify(req));
203
+ }
204
+ }
205
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot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S,CAAC,CAAC;IAC/F,CAAC;IAED,qDAAqD;IACrD,qBAAqB,CAAC,GAAsB;QAC1C,OAAO,IAAI,CAAC,QAAQ,CAAiB,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAChF,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ export declare const protobufPackage = "metacensus.public.v1";
2
+ /**
3
+ * Shared types for the public surface. See README.md, "The two surfaces" and
4
+ * "Errors on the two surfaces".
5
+ *
6
+ * The statuses this surface answers with, which `google.api.http` cannot
7
+ * express and so live nowhere else. 400 and 403 share a sentence on purpose:
8
+ * which applies is not a caller's business.
9
+ *
10
+ * 400 the submission was not valid, or the body was not JSON
11
+ * 403 the `Origin` was absent or not allowlisted
12
+ * 413 the body exceeded 16 KiB
13
+ * 429 the per-client rate limit was exceeded; `Retry-After` carries seconds
14
+ * 502 the submission could not be relayed upstream
15
+ * 500 something else went wrong
16
+ *
17
+ * No messages yet: this is the one file the cross-file typing rule exempts, so
18
+ * a type shared across the surface's resources would go here.
19
+ */
20
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/metacensus/public/v1/common.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,eAAe,yBAAyB,CAAC;AAEtD;;;;;;;;;;;;;;;;;GAiBG"}
@@ -0,0 +1,26 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.7.7
4
+ // protoc unknown
5
+ // source: metacensus/public/v1/common.proto
6
+ /* eslint-disable */
7
+ export const protobufPackage = "metacensus.public.v1";
8
+ /**
9
+ * Shared types for the public surface. See README.md, "The two surfaces" and
10
+ * "Errors on the two surfaces".
11
+ *
12
+ * The statuses this surface answers with, which `google.api.http` cannot
13
+ * express and so live nowhere else. 400 and 403 share a sentence on purpose:
14
+ * which applies is not a caller's business.
15
+ *
16
+ * 400 the submission was not valid, or the body was not JSON
17
+ * 403 the `Origin` was absent or not allowlisted
18
+ * 413 the body exceeded 16 KiB
19
+ * 429 the per-client rate limit was exceeded; `Retry-After` carries seconds
20
+ * 502 the submission could not be relayed upstream
21
+ * 500 something else went wrong
22
+ *
23
+ * No messages yet: this is the one file the cross-file typing rule exempts, so
24
+ * a type shared across the surface's resources would go here.
25
+ */
26
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../../../src/metacensus/public/v1/common.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,YAAY;AACZ,gCAAgC;AAChC,iCAAiC;AACjC,4CAA4C;AAE5C,oBAAoB;AAEpB,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC;AAEtD;;;;;;;;;;;;;;;;;GAiBG"}