@metacensus/api 0.0.0 → 0.2.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 +121 -6
  2. package/dist/index.d.ts +1 -3
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +9 -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 +54 -0
  15. package/dist/src/client.d.ts.map +1 -0
  16. package/dist/src/client.js +146 -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 +54 -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 +56 -27
  35. package/dist/src/metacensus/v1/prop.d.ts.map +1 -1
  36. package/dist/src/metacensus/v1/prop.js +19 -20
  37. package/dist/src/metacensus/v1/prop.js.map +1 -1
  38. package/dist/src/metacensus/v1/topic.d.ts +20 -10
  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 +14 -5
  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 +193 -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,12 +1,14 @@
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`,
8
+ a typed client per surface — over a transport you supply — and the signing
9
+ chain. It reaches for nothing at runtime; `scripts/check-no-runtime.mjs` is
10
+ what says so, and what fails the build. The signing module is inside that
11
+ guard rather than an exception to it.
10
12
 
11
13
  ```bash
12
14
  npm install @metacensus/api
@@ -14,9 +16,122 @@ npm install @metacensus/api
14
16
 
15
17
  ```ts
16
18
  import type { Topic, PropCreateRequest } from "@metacensus/api";
17
- import { routes } from "@metacensus/api";
19
+ import { routes, Client, ApiError, type Transport } from "@metacensus/api";
20
+
21
+ const transport: Transport = async ({ method, path, body }) => {
22
+ const r = await fetch(baseUrl + path, { method, body });
23
+ return { status: r.status, body: await r.text() };
24
+ };
25
+ const api = new Client(transport);
26
+ const topic = await api.getTopic({ topicId });
27
+ ```
28
+
29
+ `path` is absolute and already carries `/metacensus/api/v1`, every segment
30
+ percent-encoded; prepend only an origin. `body`, when present, is the exact
31
+ string to send: the client serialises once, so what you log or hash is what
32
+ went out.
33
+
34
+ **The transport is where your own concerns go**: auth headers, a 401 policy,
35
+ retries. The client calls no `fetch`, keeps no cache, and throws `ApiError` for
36
+ any non-2xx the transport did not handle itself. `ApiError.body` is raw text —
37
+ a 404 or 405 comes from the server's router rather than a handler, so parse it
38
+ defensively rather than assuming JSON.
39
+
40
+ Signing is *not* a transport concern. A participant's signature is part of the
41
+ request message and is made before the client is called; see "Signing", below.
42
+
43
+ Every scalar is required, which is what makes Go's `EmitDefaultValues` and
44
+ these types describe the same document: `api.createTopic({ name })` does not
45
+ type-check, `{ name, description: "" }` does. Message-typed fields are
46
+ optional.
47
+
48
+ ## The public surface
49
+
50
+ The public, unauthenticated surface is an entry point of its own in the same
51
+ package, with a client to match:
52
+
53
+ ```ts
54
+ import type { PartnerSubmission } from "@metacensus/api/public";
55
+ import {
56
+ PartnerSubmission_Interest,
57
+ PublicClient,
58
+ publicPrefix,
59
+ } from "@metacensus/api/public";
60
+
61
+ const pub = new PublicClient(transport);
62
+ await pub.submitPartnerInterest({ name, email, interests, message, website: "" });
18
63
  ```
19
64
 
65
+ One package because the SPA calls both surfaces from one build; an entry point
66
+ per surface because a consumer of only the public surface should not acquire the
67
+ authenticated types. `@metacensus/api/signing` is a third, splitting by concern
68
+ rather than by surface — nothing on the public surface is ever signed.
69
+ `PublicClient` sends no credentials of its own; pass it a separate transport
70
+ from the one you pass `Client`.
71
+
72
+ `ApiError` is the same class from either entry point, so `instanceof ApiError`
73
+ holds for a failure from either surface. Importing it twice is harmless.
74
+
75
+ `PartnerSubmission_Interest` is a string enum, so the checkbox list is generated
76
+ from the contract rather than mirrored by hand — which is the coupling this
77
+ package exists to make mechanical. `Unspecified` is the proto3 zero value, not
78
+ an offered choice, so filter it out:
79
+
80
+ ```ts
81
+ const choices = Object.values(PartnerSubmission_Interest).filter(
82
+ (i) => i !== PartnerSubmission_Interest.Unspecified,
83
+ );
84
+ ```
85
+
86
+ The display labels are not in the contract; they stay in the SPA as copy. See
87
+ the enum's comment for why.
88
+
89
+ ## Signing
90
+
91
+ Every write on the authenticated surface carries a `content` message and a
92
+ `userSignature` over it. A session token says who is connected; the signature
93
+ says who authored the record, and the API server does not check it — it is
94
+ verified by the persistence layer, behind the edge.
95
+
96
+ ```ts
97
+ import { SPEC, sign, keyId, generateKeyPair, encodePublicKey } from "@metacensus/api/signing";
98
+
99
+ const { privateKey, publicKey } = await generateKeyPair(); // ECDSA P-384
100
+
101
+ const content = { name: "A review", description: "" };
102
+ const userSignature = {
103
+ signerId,
104
+ keyId: await keyId(publicKey),
105
+ alg: "Es384",
106
+ publicKey: "", // inline only on sign-up, which is what enrols the key
107
+ signingTime: new Date().toISOString(),
108
+ spec: SPEC,
109
+ contentType: "metacensus.v1.TopicContent",
110
+ value: "",
111
+ };
112
+ userSignature.value = await sign(privateKey, content, userSignature);
113
+
114
+ await api.createTopic({ content, userSignature });
115
+ ```
116
+
117
+ The digest is SHA-384 over RFC 8785 canonical JSON of
118
+ `{content, signature}`, with `value` emptied. Every field but `value` is inside
119
+ it, so a signature cannot be re-attributed or re-dated — which also means
120
+ `contentType` has to name the content you actually signed, and `signingTime`
121
+ has to be set.
122
+
123
+ Sign-up is the one request whose signature carries its own public key: there is
124
+ no id yet to look one up by. Set `publicKey` there, leave `signerId` empty, and
125
+ keep the password out of `content` — content is what gets stored.
126
+
127
+ `routes` carries a `signed` flag per route, so "which routes need a key?" is a
128
+ lookup rather than a guess.
129
+
130
+ The full account of the chain, and `go/signing`, the other half that has to
131
+ compute the same digest, are in the repository README.
132
+
133
+ ## Both surfaces
134
+
20
135
  The wire format is JSON, not protobuf binary. Field names are `lowerCamelCase`
21
136
  on the wire, enum values are PascalCase, and all ids are strings.
22
137
 
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 ClientRequest, type ClientResponse, type Transport, } 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;AAIhE,OAAO,EACL,MAAM,EACN,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,SAAS,GACf,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -1,16 +1,18 @@
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.
17
+ export { Client, ApiError, } from "./src/client.js";
16
18
  //# 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,gDAAgD;AAChD,OAAO,EACL,MAAM,EACN,QAAQ,GAIT,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 ClientRequest, type ClientResponse, type Transport, } 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,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,SAAS,GACf,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
11
+ // the 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,4EAA4E;AAC5E,0EAA0E;AAC1E,uDAAuD;AACvD,OAAO,EACL,YAAY,EACZ,QAAQ,GAIT,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,54 @@
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 } from "./metacensus/v1/common.js";
4
+ import type { Prop, PropCreateRequest, PropGetRequest, PropList, PropListRequest, Vote, VoteList, VoteListRequest, VoteSetRequest } from "./metacensus/v1/prop.js";
5
+ import type { Member, MemberGetRequest, MemberList, MemberListRequest, Topic, TopicCreateRequest, TopicGetRequest, TopicList, TopicListRequest } from "./metacensus/v1/topic.js";
6
+ import type { SelfGetRequest, User, UserGetRequest, UserList, UserListRequest } from "./metacensus/v1/user.js";
7
+ export interface ClientRequest {
8
+ readonly method: string;
9
+ readonly path: string;
10
+ readonly body?: string;
11
+ }
12
+ export interface ClientResponse {
13
+ readonly status: number;
14
+ readonly body: string;
15
+ }
16
+ export type Transport = (req: ClientRequest) => Promise<ClientResponse>;
17
+ export declare class ApiError extends Error {
18
+ readonly method: string;
19
+ readonly path: string;
20
+ readonly status: number;
21
+ readonly body: string;
22
+ constructor(method: string, path: string, status: number, body: string);
23
+ }
24
+ export declare class Client {
25
+ private readonly transport;
26
+ private readonly prefix;
27
+ constructor(transport: Transport, prefix?: string);
28
+ private call;
29
+ login(req: LoginRequest): Promise<Session>;
30
+ signUp(req: SignUpRequest): Promise<Session>;
31
+ logout(req: LogoutRequest): Promise<LogoutResponse>;
32
+ healthcheck(req: HealthcheckRequest): Promise<HealthcheckResponse>;
33
+ listProps(req: PropListRequest): Promise<PropList>;
34
+ getProp(req: PropGetRequest): Promise<Prop>;
35
+ createProp(req: PropCreateRequest): Promise<Prop>;
36
+ listVotes(req: VoteListRequest): Promise<VoteList>;
37
+ setVote(req: VoteSetRequest): Promise<Vote>;
38
+ listTopics(req: TopicListRequest): Promise<TopicList>;
39
+ getTopic(req: TopicGetRequest): Promise<Topic>;
40
+ createTopic(req: TopicCreateRequest): Promise<Topic>;
41
+ listMembers(req: MemberListRequest): Promise<MemberList>;
42
+ getMember(req: MemberGetRequest): Promise<Member>;
43
+ listUsers(req: UserListRequest): Promise<UserList>;
44
+ getUser(req: UserGetRequest): Promise<User>;
45
+ getSelf(req: SelfGetRequest): Promise<User>;
46
+ }
47
+ export declare class PublicClient {
48
+ private readonly transport;
49
+ private readonly prefix;
50
+ constructor(transport: Transport, prefix?: string);
51
+ private call;
52
+ submitPartnerInterest(req: PartnerSubmission): Promise<PartnerReceipt>;
53
+ }
54
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version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,CAGnD;IAGD,WAAW,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAEvD;IAGD,SAAS,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAEhD;IAGD,SAAS,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEjD;IAGD,OAAO,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1C;IAGD,OAAO,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1C;CACF;AAGD,qBAAa,YAAY;IAIrB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFzB,YACmB,SAAS,EAAE,SAAS,EACpB,MAAM,GAAE,MAA4B,EACnD;YAEU,IAAI;IAWlB,qBAAqB,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAGrE;CACF"}
@@ -0,0 +1,146 @@
1
+ // Code generated by routegen. DO NOT EDIT.
2
+ // The same literal as route-manifest.ts's apiPrefix, re-emitted rather than
3
+ // imported, since a value import under src/ is forbidden (check-no-runtime.mjs).
4
+ const apiPrefixDefault = "/metacensus/api/v1";
5
+ // The same literal as route-manifest.ts's publicPrefix, re-emitted rather than
6
+ // imported, since a value import under src/ is forbidden (check-no-runtime.mjs).
7
+ const publicPrefixDefault = "/metacensus/public";
8
+ function param(v) {
9
+ return encodeURIComponent(String(v));
10
+ }
11
+ // ApiError is any non-2xx the transport did not act on itself. body is the
12
+ // response text, unparsed: a 404 or 405 comes from the router, not a handler, so
13
+ // parse it defensively rather than assuming JSON.
14
+ export class ApiError extends Error {
15
+ method;
16
+ path;
17
+ status;
18
+ body;
19
+ constructor(method, path, status, body) {
20
+ super(`${method} ${path}: HTTP ${status}`);
21
+ this.method = method;
22
+ this.path = path;
23
+ this.status = status;
24
+ this.body = body;
25
+ this.name = "ApiError";
26
+ }
27
+ }
28
+ // Client calls the authenticated API: every route under /metacensus/api/v1.
29
+ export class Client {
30
+ transport;
31
+ prefix;
32
+ // Defaults to this surface's own apiPrefix, but can be overridden so a
33
+ // test harness can mount the same routes elsewhere.
34
+ constructor(transport, prefix = apiPrefixDefault) {
35
+ this.transport = transport;
36
+ this.prefix = prefix;
37
+ }
38
+ async call(method, path, body) {
39
+ const full = this.prefix + path;
40
+ const res = await this.transport({ method, path: full, body });
41
+ if (res.status < 200 || res.status >= 300) {
42
+ throw new ApiError(method, full, res.status, res.body);
43
+ }
44
+ // A cast: no runtime schema to validate against.
45
+ return (res.body === "" ? {} : JSON.parse(res.body));
46
+ }
47
+ // AuthRoutes.Login: POST /login
48
+ login(req) {
49
+ const body = req;
50
+ return this.call("POST", "/login", JSON.stringify(body));
51
+ }
52
+ // AuthRoutes.SignUp: POST /signup
53
+ signUp(req) {
54
+ const body = req;
55
+ return this.call("POST", "/signup", JSON.stringify(body));
56
+ }
57
+ // AuthRoutes.Logout: POST /logout
58
+ logout(req) {
59
+ return this.call("POST", "/logout", undefined);
60
+ }
61
+ // HealthRoutes.Healthcheck: GET /healthcheck
62
+ healthcheck(req) {
63
+ return this.call("GET", "/healthcheck", undefined);
64
+ }
65
+ // PropRoutes.ListProps: GET /topic/{topicId}/prop
66
+ listProps(req) {
67
+ return this.call("GET", `/topic/${param(req.topicId)}/prop`, undefined);
68
+ }
69
+ // PropRoutes.GetProp: GET /topic/{topicId}/prop/{propId}
70
+ getProp(req) {
71
+ return this.call("GET", `/topic/${param(req.topicId)}/prop/${param(req.propId)}`, undefined);
72
+ }
73
+ // PropRoutes.CreateProp: POST /topic/{topicId}/prop
74
+ createProp(req) {
75
+ const { topicId, ...body } = req;
76
+ return this.call("POST", `/topic/${param(topicId)}/prop`, JSON.stringify(body));
77
+ }
78
+ // PropRoutes.ListVotes: GET /topic/{topicId}/prop/{propId}/vote
79
+ listVotes(req) {
80
+ return this.call("GET", `/topic/${param(req.topicId)}/prop/${param(req.propId)}/vote`, undefined);
81
+ }
82
+ // PropRoutes.SetVote: POST /topic/{topicId}/prop/{propId}/vote
83
+ setVote(req) {
84
+ const { topicId, propId, ...body } = req;
85
+ return this.call("POST", `/topic/${param(topicId)}/prop/${param(propId)}/vote`, JSON.stringify(body));
86
+ }
87
+ // TopicRoutes.ListTopics: GET /topic
88
+ listTopics(req) {
89
+ return this.call("GET", "/topic", undefined);
90
+ }
91
+ // TopicRoutes.GetTopic: GET /topic/{topicId}
92
+ getTopic(req) {
93
+ return this.call("GET", `/topic/${param(req.topicId)}`, undefined);
94
+ }
95
+ // TopicRoutes.CreateTopic: POST /topic
96
+ createTopic(req) {
97
+ const body = req;
98
+ return this.call("POST", "/topic", JSON.stringify(body));
99
+ }
100
+ // TopicRoutes.ListMembers: GET /topic/{topicId}/member
101
+ listMembers(req) {
102
+ return this.call("GET", `/topic/${param(req.topicId)}/member`, undefined);
103
+ }
104
+ // TopicRoutes.GetMember: GET /topic/{topicId}/member/{userId}
105
+ getMember(req) {
106
+ return this.call("GET", `/topic/${param(req.topicId)}/member/${param(req.userId)}`, undefined);
107
+ }
108
+ // UserRoutes.ListUsers: GET /user
109
+ listUsers(req) {
110
+ return this.call("GET", "/user", undefined);
111
+ }
112
+ // UserRoutes.GetUser: GET /user/{userId}
113
+ getUser(req) {
114
+ return this.call("GET", `/user/${param(req.userId)}`, undefined);
115
+ }
116
+ // UserRoutes.GetSelf: GET /self
117
+ getSelf(req) {
118
+ return this.call("GET", "/self", undefined);
119
+ }
120
+ }
121
+ // PublicClient calls the public, unauthenticated surface: every route under /metacensus/public.
122
+ export class PublicClient {
123
+ transport;
124
+ prefix;
125
+ // Defaults to this surface's own publicPrefix, but can be overridden so a
126
+ // test harness can mount the same routes elsewhere.
127
+ constructor(transport, prefix = publicPrefixDefault) {
128
+ this.transport = transport;
129
+ this.prefix = prefix;
130
+ }
131
+ async call(method, path, body) {
132
+ const full = this.prefix + path;
133
+ const res = await this.transport({ method, path: full, body });
134
+ if (res.status < 200 || res.status >= 300) {
135
+ throw new ApiError(method, full, res.status, res.body);
136
+ }
137
+ // A cast: no runtime schema to validate against.
138
+ return (res.body === "" ? {} : JSON.parse(res.body));
139
+ }
140
+ // PartnerRoutes.SubmitPartnerInterest: POST /partner
141
+ submitPartnerInterest(req) {
142
+ const body = req;
143
+ return this.call("POST", "/partner", JSON.stringify(body));
144
+ }
145
+ }
146
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAY3C,4EAA4E;AAC5E,iFAAiF;AACjF,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AAE9C,+EAA+E;AAC/E,iFAAiF;AACjF,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AACjD,SAAS,KAAK,CAAC,CAA4B;IACzC,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC;AAuBD,2EAA2E;AAC3E,iFAAiF;AACjF,kDAAkD;AAClD,MAAM,OAAO,QAAS,SAAQ,KAAK;IAEtB,MAAM;IACN,IAAI;IACJ,MAAM;IACN,IAAI;IAJf,YACW,MAAc,EACd,IAAY,EACZ,MAAc,EACd,IAAY;QAErB,KAAK,CAAC,GAAG,MAAM,IAAI,IAAI,UAAU,MAAM,EAAE,CAAC,CAAC;sBALlC,MAAM;oBACN,IAAI;sBACJ,MAAM;oBACN,IAAI;QAGb,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAED,4EAA4E;AAC5E,MAAM,OAAO,MAAM;IAIE,SAAS;IACT,MAAM;IAJzB,uEAAuE;IACvE,oDAAoD;IACpD,YACmB,SAAoB,EACpB,MAAM,GAAW,gBAAgB;yBADjC,SAAS;sBACT,MAAM;IACtB,CAAC;IAEI,KAAK,CAAC,IAAI,CAAI,MAAc,EAAE,IAAY,EAAE,IAAa;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C,CAAC;CACF;AAED,gGAAgG;AAChG,MAAM,OAAO,YAAY;IAIJ,SAAS;IACT,MAAM;IAJzB,0EAA0E;IAC1E,oDAAoD;IACpD,YACmB,SAAoB,EACpB,MAAM,GAAW,mBAAmB;yBADpC,SAAS;sBACT,MAAM;IACtB,CAAC;IAEI,KAAK,CAAC,IAAI,CAAI,MAAc,EAAE,IAAY,EAAE,IAAa;QAC/D,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QAChC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/D,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;YAC1C,MAAM,IAAI,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QACzD,CAAC;QACD,iDAAiD;QACjD,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAM,CAAC;IAC5D,CAAC;IAED,qDAAqD;IACrD,qBAAqB,CAAC,GAAsB;QAC1C,MAAM,IAAI,GAAG,GAAG,CAAC;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7D,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"}
@@ -0,0 +1,55 @@
1
+ export declare const protobufPackage = "metacensus.public.v1";
2
+ /** The partner / express-interest form the marketing site posts to. */
3
+ /**
4
+ * One express-interest form post. The length caps below are enforced but not
5
+ * machine-readable — ts-proto drops field options, so protovalidate can't
6
+ * reach the client; see README.md.
7
+ */
8
+ export interface PartnerSubmission {
9
+ /** Required. Whitespace-collapsed, then capped at 120 characters. */
10
+ name: string;
11
+ /**
12
+ * Required. Trimmed, capped at 254 characters, and must contain an `@`
13
+ * with a dotted host after it. Deliberately a shape check, not RFC 5322.
14
+ */
15
+ email: string;
16
+ /**
17
+ * May be empty. Duplicates are collapsed rather than rejected; an
18
+ * unrecognised value rejects the whole submission.
19
+ */
20
+ interests: PartnerSubmission_Interest[];
21
+ /** Optional. Trimmed, capped at 2000 characters. */
22
+ message: string;
23
+ /**
24
+ * Honeypot. Must be empty; a filled one receives an ordinary receipt and
25
+ * is never delivered.
26
+ */
27
+ website: string;
28
+ }
29
+ /**
30
+ * The set of checkboxes is a contract; display wording lives in the SPA
31
+ * (see README.md). Unspecified is the proto3 zero value, not an offered
32
+ * choice — filter it out when building a form.
33
+ */
34
+ export declare enum PartnerSubmission_Interest {
35
+ Unspecified = "Unspecified",
36
+ PartnerOrPilot = "PartnerOrPilot",
37
+ FundTheWork = "FundTheWork",
38
+ ContributeExpertise = "ContributeExpertise",
39
+ BringToMyField = "BringToMyField",
40
+ RequestEarlyAccess = "RequestEarlyAccess"
41
+ }
42
+ /**
43
+ * The 200 answer. `submission_id` correlates with the service's logs; it
44
+ * isn't a fetchable handle.
45
+ */
46
+ export interface PartnerReceipt {
47
+ /**
48
+ * Always true; the one place this surface's shape still differs from
49
+ * metacensus.v1 (bare resources) — required because
50
+ * contract.UnmarshalOptions rejects unknown fields.
51
+ */
52
+ ok: boolean;
53
+ submissionId: string;
54
+ }
55
+ //# sourceMappingURL=partner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partner.d.ts","sourceRoot":"","sources":["../../../../../src/metacensus/public/v1/partner.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,eAAe,yBAAyB,CAAC;AAEtD,uEAAuE;AAEvE;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,SAAS,EAAE,0BAA0B,EAAE,CAAC;IACxC,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,oBAAY,0BAA0B;IACpC,WAAW,gBAAgB;IAC3B,cAAc,mBAAmB;IACjC,WAAW,gBAAgB;IAC3B,mBAAmB,wBAAwB;IAC3C,cAAc,mBAAmB;IACjC,kBAAkB,uBAAuB;CAC1C;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,EAAE,EAAE,OAAO,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1,22 @@
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/partner.proto
6
+ /* eslint-disable */
7
+ export const protobufPackage = "metacensus.public.v1";
8
+ /**
9
+ * The set of checkboxes is a contract; display wording lives in the SPA
10
+ * (see README.md). Unspecified is the proto3 zero value, not an offered
11
+ * choice — filter it out when building a form.
12
+ */
13
+ export var PartnerSubmission_Interest;
14
+ (function (PartnerSubmission_Interest) {
15
+ PartnerSubmission_Interest["Unspecified"] = "Unspecified";
16
+ PartnerSubmission_Interest["PartnerOrPilot"] = "PartnerOrPilot";
17
+ PartnerSubmission_Interest["FundTheWork"] = "FundTheWork";
18
+ PartnerSubmission_Interest["ContributeExpertise"] = "ContributeExpertise";
19
+ PartnerSubmission_Interest["BringToMyField"] = "BringToMyField";
20
+ PartnerSubmission_Interest["RequestEarlyAccess"] = "RequestEarlyAccess";
21
+ })(PartnerSubmission_Interest || (PartnerSubmission_Interest = {}));
22
+ //# sourceMappingURL=partner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partner.js","sourceRoot":"","sources":["../../../../../src/metacensus/public/v1/partner.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,YAAY;AACZ,gCAAgC;AAChC,iCAAiC;AACjC,6CAA6C;AAE7C,oBAAoB;AAEpB,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC;AA+BtD;;;;GAIG;AACH,MAAM,CAAN,IAAY,0BAOX;AAPD,WAAY,0BAA0B;IACpC,yDAA2B,CAAA;IAC3B,+DAAiC,CAAA;IACjC,yDAA2B,CAAA;IAC3B,yEAA2C,CAAA;IAC3C,+DAAiC,CAAA;IACjC,uEAAyC,CAAA;AAC3C,CAAC,EAPW,0BAA0B,KAA1B,0BAA0B,QAOrC"}
@@ -1,14 +1,28 @@
1
+ import type { UserContent, UserSignature } from "./common.js";
1
2
  export declare const protobufPackage = "metacensus.v1";
2
3
  /** Sign-up, login and logout. */
3
4
  export interface LoginRequest {
4
5
  email: string;
5
6
  password: string;
6
7
  }
8
+ /**
9
+ * Creates an account and enrolls the signing key every later write is
10
+ * signed with: trust on first use — nobody vouches for the key, the service
11
+ * binds whatever it's handed, and the signature proves possession of the
12
+ * matching private key at enrollment.
13
+ */
7
14
  export interface SignUpRequest {
8
- name: string;
9
- email: string;
10
- country: string;
15
+ content?: UserContent | undefined;
16
+ /**
17
+ * Deliberately outside `content`: a password must never be inside a
18
+ * signed, stored document.
19
+ */
11
20
  password: string;
21
+ /**
22
+ * Over `content`, made with the key being enrolled. `signer_id` is empty
23
+ * (no id exists yet) and `public_key` carries the key inline.
24
+ */
25
+ userSignature?: UserSignature | undefined;
12
26
  }
13
27
  export interface Session {
14
28
  /** Bearer token, sent back as `Authorization: Bearer <token>`. */