@metacensus/api 0.3.0 → 0.5.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.
package/README.md CHANGED
@@ -29,6 +29,8 @@ client to reach for. Construct it with:
29
29
  (wrap the global to add retries, a 401 policy, or logging).
30
30
  - `signer?` — signs writes; see "Writes", below. Omit it for a read-only client.
31
31
  - `token?` — an initial bearer token, to resume a session without logging in.
32
+ - `credentials?` — the fetch credentials mode; set `"include"` in a browser so
33
+ the `HttpOnly` refresh cookie rides `refresh()` and `logout`. See "Auth", below.
32
34
 
33
35
  A non-2xx response throws `ApiError` (`method`, `url`, `status`, and the raw
34
36
  `body` — parse it defensively, since a 404 or 405 comes from the router, not a
@@ -55,38 +57,58 @@ The envelope isn't uniform, so the record isn't either:
55
57
  | a member — already flat | `Member`, unchanged / `Member[]` |
56
58
 
57
59
  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
+ against the signer's `time`, or re-checking the assertion — each signed-envelope
61
+ read has a **`getXSigned`** twin that returns the raw envelope:
60
62
 
61
63
  ```ts
62
- const signed = await client.getTopicSigned({ topicId }); // TopicSigned: { id, recorded, content, userSignature }
63
- await verify(pub, signed.content, signed.userSignature);
64
+ import { verifyUser, participantPolicy } from "@metacensus/api/signing";
65
+
66
+ const signed = await client.getTopicSigned({ topicId }); // { id, recorded, content, interpretation, userSignature }
67
+ const pub = await resolveEnrolledKey(signed.userSignature.keyId); // your key directory
68
+ await verifyUser(pub, signed.content, signed.interpretation, signed.userSignature, participantPolicy(origin));
64
69
  ```
65
70
 
66
71
  `getXSigned` exists only where there's a signature to see; `Member` has none.
67
72
 
68
73
  ## Writes and the signer
69
74
 
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:
75
+ A write takes **flat content** — never the envelope — and the `signer` returns
76
+ the record's `interpretation`, the `Signature` over it, and (sign-up only) the
77
+ enrolling `publicKey`; the client assembles the body. The signer is set once on
78
+ the constructor, because the key it signs with is identical for a session. The
79
+ signing mechanism is a **passkey (WebAuthn)**: the signer runs the ceremony and
80
+ packages its assertion — the private key never enters the client, and cannot,
81
+ because a passkey's key is non-extractable in the authenticator.
73
82
 
74
83
  ```ts
75
- import { SPEC, sign, keyId } from "@metacensus/api/signing";
84
+ import {
85
+ interpretation, userChallenge, keyId, participantPolicy,
86
+ } from "@metacensus/api/signing";
76
87
 
77
88
  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: "",
89
+ const interp = interpretation(contentType); // { spec, contentType } — the client names contentType
90
+ const kid = await keyId(publicKey);
91
+ const time = new Date().toISOString();
92
+
93
+ // The digest the assertion must commit to, carried as the WebAuthn challenge.
94
+ const challenge = await userChallenge(content, interp, kid, time);
95
+ const cred = await navigator.credentials.get({
96
+ publicKey: { challenge, allowCredentials: [/* this device's passkey */] },
97
+ }); // ui#55 owns provisioning and RP-ID scoping
98
+
99
+ const r = cred.response as AuthenticatorAssertionResponse;
100
+ return {
101
+ interpretation: interp,
102
+ signature: {
103
+ keyId: kid,
104
+ time,
105
+ assertion: {
106
+ authenticatorData: toBase64Url(r.authenticatorData),
107
+ clientDataJson: toBase64Url(r.clientDataJSON), // its challenge === base64url(challenge)
108
+ signature: toBase64Url(r.signature), // DER, verified as-is
109
+ },
110
+ },
87
111
  };
88
- s.value = await sign(privateKey, content, s);
89
- return s;
90
112
  };
91
113
 
92
114
  const client = new Client({ baseUrl, signer });
@@ -94,19 +116,40 @@ const created = await client.createTopic({ content: { name: "A review", descript
94
116
  // TopicRecord, flattened like a read
95
117
  ```
96
118
 
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.
119
+ The client supplies `content` and the exact `contentType` (the one thing left to
120
+ the caller, and the easiest to get wrong); the signer builds the interpretation
121
+ and the assertion. A headless signer (a server or a test) builds the same shape
122
+ with `assert()` instead of a browser ceremony — one format, both layers. A write
123
+ on a client built without a signer throws. **The browser ceremony above is
124
+ sketch, not shipped: provisioning a passkey to a device, RP-ID scoping across
125
+ environments, and recovery are [ui#55](https://github.com/metacensus/ui/issues/55).**
101
126
 
102
127
  ## Auth and the session token
103
128
 
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.
129
+ There are two tokens. The **access token** is short-lived: `login` and `signUp`
130
+ store the one they return, the client adds `Authorization: Bearer <token>` to
131
+ every later request, and `session.expiresIn` (seconds) says how long it lasts.
132
+ `token` (a getter) exposes the current one, to persist and restore a session via
133
+ the `token` option. `signUp` signs its `User` content through the same signer;
134
+ the signer returns the enrolling `publicKey`, which the client sends on the
135
+ request (not on the signature — no record carries its own verification key) and
136
+ the store binds under the signature's `keyId`. Keep the password out of
137
+ `content`, since content is what gets stored.
138
+
139
+ The **refresh token** is long-lived and never touches JavaScript. In a browser
140
+ the server keeps it in an `HttpOnly` cookie, so `refresh()` sends an empty body
141
+ and lets the cookie speak — construct the client with `credentials: "include"`
142
+ so the browser attaches that cookie (and the deployment must answer credentialed
143
+ CORS for your origin). `refresh()` returns a fresh `Session` and stores its new
144
+ access token, exactly as `login` does; the refresh token is rotated on each use
145
+ and `logout` revokes it. A non-browser caller with no cookie can instead pass the
146
+ token in `RefreshRequest.refreshToken` (and `LogoutRequest.refreshToken`) — the
147
+ contract is cookie-agnostic; the cookie is a transport the server adds.
148
+
149
+ The client keeps no refresh policy of its own: a 401 on an expired access token
150
+ is an ordinary `ApiError`, and the consumer decides when to call `refresh()` and
151
+ retry (react-query, say). Refresh at or before `expiresIn` to avoid the round
152
+ trip.
110
153
 
111
154
  ## The public surface
112
155
 
@@ -145,26 +188,32 @@ the enum's comment for why.
145
188
 
146
189
  ## Signing
147
190
 
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:
191
+ Every write on the authenticated surface carries a `content` message, an
192
+ `interpretation`, and a `userSignature` over both. A session token says who is
193
+ connected; the signature says who authored the record, and the API server does
194
+ not check it — it is verified by the persistence layer, behind the edge.
195
+ `@metacensus/api/signing` is what your `Signer` uses, and what a verifier calls:
153
196
 
154
197
  ```ts
155
- import { SPEC, sign, verify, keyId, generateKeyPair, encodePublicKey } from "@metacensus/api/signing";
198
+ import {
199
+ SPEC, interpretation, userChallenge, assert, verifyUser,
200
+ authenticatorData, participantPolicy, keyId, generateKeyPair, FLAG_UP, FLAG_UV,
201
+ } from "@metacensus/api/signing";
156
202
 
157
- const { privateKey, publicKey } = await generateKeyPair(); // ECDSA P-384
203
+ const { privateKey, publicKey } = await generateKeyPair(); // ECDSA P-256 (ES256)
158
204
  ```
159
205
 
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.
206
+ The mechanism is **WebAuthn/passkeys**, one format for both the participant and
207
+ the institution (ECDSA P-256 / ES256). This module is the toolkit: `interpretation`
208
+ and `userChallenge` build the digest, `assert` makes a headless assertion,
209
+ `verifyUser`/`verifyCountersign` check one under a `participantPolicy` or
210
+ `institutionPolicy`. `routes` carries a `signed` flag per route, so "which routes
211
+ need a key?" is a lookup rather than a guess.
212
+
213
+ The scheme, the digest, and the verify procedure are the repository README's
214
+ "The signing chain"; `go/signing` is the other half that computes the same digest
215
+ and whose DER assertions this module verifies. The browser passkey ceremony
216
+ itself is [ui#55](https://github.com/metacensus/ui/issues/55).
168
217
 
169
218
  ## Both surfaces
170
219
 
package/dist/signing.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { SPEC, canonicalize, signingInput, digest, sign, verify, generateKeyPair, encodePublicKey, decodePublicKey, keyId, } from "./src/signing.js";
1
+ export { SPEC, TYPE_GET, TYPE_COUNTERSIGN, FLAG_UP, FLAG_UV, FLAG_BE, FLAG_BS, canonicalize, interpretation, userSigningInput, countersignInput, userChallenge, countersignChallenge, authenticatorData, assert, verifyAssertion, verifyUser, verifyCountersign, participantPolicy, institutionPolicy, generateKeyPair, encodePublicKey, decodePublicKey, keyId, enrolledKey, } from "./src/signing.js";
2
+ export type { ClientData, Policy } from "./src/signing.js";
2
3
  //# sourceMappingURL=signing.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"signing.d.ts","sourceRoot":"","sources":["../signing.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAChB,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,MAAM,EACN,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,eAAe,EACf,KAAK,EACL,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/signing.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // The MetaCensus signing chain, producing the same digest as go/signing. A
2
2
  // third entry point splitting by concern, not surface. See ts/README.md,
3
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";
4
+ export { SPEC, TYPE_GET, TYPE_COUNTERSIGN, FLAG_UP, FLAG_UV, FLAG_BE, FLAG_BS, canonicalize, interpretation, userSigningInput, countersignInput, userChallenge, countersignChallenge, authenticatorData, assert, verifyAssertion, verifyUser, verifyCountersign, participantPolicy, institutionPolicy, generateKeyPair, encodePublicKey, decodePublicKey, keyId, enrolledKey, } from "./src/signing.js";
5
5
  //# sourceMappingURL=signing.js.map
@@ -1 +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"}
1
+ {"version":3,"file":"signing.js","sourceRoot":"","sources":["../signing.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,yEAAyE;AACzE,iDAAiD;AAEjD,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAChB,OAAO,EACP,OAAO,EACP,OAAO,EACP,OAAO,EACP,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,MAAM,EACN,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,eAAe,EACf,KAAK,EACL,WAAW,GACZ,MAAM,kBAAkB,CAAC"}
@@ -1,6 +1,6 @@
1
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";
2
+ import type { LoginRequest, LogoutRequest, LogoutResponse, RefreshRequest, Session, SignUpRequest } from "./metacensus/v1/auth.js";
3
+ import type { HealthcheckRequest, HealthcheckResponse, Interpretation, Signature, User } from "./metacensus/v1/common.js";
4
4
  import type { Prop, PropCreateRequest, PropGetRequest, PropListRequest, PropSigned, Vote, VoteListRequest, VoteSetRequest, VoteSigned } from "./metacensus/v1/prop.js";
5
5
  import type { Member, MemberGetRequest, MemberListRequest, Topic, TopicCreateRequest, TopicGetRequest, TopicListRequest, TopicSigned } from "./metacensus/v1/topic.js";
6
6
  import type { SelfGetRequest, UserGetRequest, UserListRequest, UserSigned } from "./metacensus/v1/user.js";
@@ -11,7 +11,12 @@ export declare class ApiError extends Error {
11
11
  readonly body: string;
12
12
  constructor(method: string, url: string, status: number, body: string);
13
13
  }
14
- export type Signer = (content: unknown, contentType: string) => Promise<UserSignature>;
14
+ export interface SignResult {
15
+ interpretation: Interpretation;
16
+ signature: Signature;
17
+ publicKey?: string;
18
+ }
19
+ export type Signer = (content: unknown, contentType: string) => Promise<SignResult>;
15
20
  export type PropRecord = Pick<PropSigned, "id" | "recorded"> & Prop;
16
21
  export type TopicRecord = Pick<TopicSigned, "id" | "recorded"> & Topic;
17
22
  export type UserRecord = Pick<UserSigned, "id" | "recorded"> & User;
@@ -22,28 +27,30 @@ export interface ClientOptions {
22
27
  readonly signer?: Signer;
23
28
  readonly token?: string;
24
29
  readonly prefix?: string;
30
+ readonly credentials?: RequestCredentials;
25
31
  }
26
32
  export declare class Client {
27
33
  #private;
28
34
  constructor(options: ClientOptions);
29
35
  get token(): string | undefined;
30
36
  login(req: LoginRequest): Promise<Session>;
31
- signUp(req: Omit<SignUpRequest, "userSignature">): Promise<Session>;
37
+ signUp(req: Omit<SignUpRequest, "userSignature" | "interpretation" | "publicKey">): Promise<Session>;
38
+ refresh(req: RefreshRequest): Promise<Session>;
32
39
  logout(req: LogoutRequest): Promise<LogoutResponse>;
33
40
  healthcheck(req: HealthcheckRequest): Promise<HealthcheckResponse>;
34
41
  listProps(req: PropListRequest): Promise<PropRecord[]>;
35
42
  listPropsSigned(req: PropListRequest): Promise<PropSigned[]>;
36
43
  getProp(req: PropGetRequest): Promise<PropRecord>;
37
44
  getPropSigned(req: PropGetRequest): Promise<PropSigned>;
38
- createProp(req: Omit<PropCreateRequest, "userSignature">): Promise<PropRecord>;
45
+ createProp(req: Omit<PropCreateRequest, "userSignature" | "interpretation" | "publicKey">): Promise<PropRecord>;
39
46
  listVotes(req: VoteListRequest): Promise<VoteRecord[]>;
40
47
  listVotesSigned(req: VoteListRequest): Promise<VoteSigned[]>;
41
- setVote(req: Omit<VoteSetRequest, "userSignature">): Promise<VoteRecord>;
48
+ setVote(req: Omit<VoteSetRequest, "userSignature" | "interpretation" | "publicKey">): Promise<VoteRecord>;
42
49
  listTopics(req: TopicListRequest): Promise<TopicRecord[]>;
43
50
  listTopicsSigned(req: TopicListRequest): Promise<TopicSigned[]>;
44
51
  getTopic(req: TopicGetRequest): Promise<TopicRecord>;
45
52
  getTopicSigned(req: TopicGetRequest): Promise<TopicSigned>;
46
- createTopic(req: Omit<TopicCreateRequest, "userSignature">): Promise<TopicRecord>;
53
+ createTopic(req: Omit<TopicCreateRequest, "userSignature" | "interpretation" | "publicKey">): Promise<TopicRecord>;
47
54
  listMembers(req: MemberListRequest): Promise<Member[]>;
48
55
  getMember(req: MemberGetRequest): Promise<Member>;
49
56
  listUsers(req: UserListRequest): Promise<UserRecord[]>;
@@ -1 +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,0BAA0B,CAAC;AAC9L,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAY,eAAe,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAKrH,qBAAa,QAAS,SAAQ,KAAK;IAE/B,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM;IAJvB,YACW,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAItB;CACF;AAID,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;AAwBvF,MAAM,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;IAGD,aAAa,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC,CAEtD;CACF;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAGD,qBAAa,YAAY;;IAKvB,YAAY,OAAO,EAAE,mBAAmB,EAIvC;IAOD,qBAAqB,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAErE;CACF"}
@@ -19,13 +19,13 @@ export class ApiError extends Error {
19
19
  function param(v) {
20
20
  return encodeURIComponent(String(v));
21
21
  }
22
- async function request(f, url, method, body, token) {
22
+ async function request(f, url, method, body, token, credentials) {
23
23
  const headers = {};
24
24
  if (body !== undefined)
25
25
  headers["Content-Type"] = "application/json";
26
26
  if (token !== undefined)
27
27
  headers["Authorization"] = `Bearer ${token}`;
28
- const res = await f(url, { method, headers, body });
28
+ const res = await f(url, { method, headers, body, credentials });
29
29
  if (res.status < 200 || res.status >= 300) {
30
30
  throw new ApiError(method, url, res.status, await res.text());
31
31
  }
@@ -50,12 +50,14 @@ export class Client {
50
50
  #fetch;
51
51
  #prefix;
52
52
  #signer;
53
+ #credentials;
53
54
  #token;
54
55
  constructor(options) {
55
56
  this.#baseUrl = options.baseUrl;
56
57
  this.#fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
57
58
  this.#prefix = options.prefix ?? apiPrefix;
58
59
  this.#signer = options.signer;
60
+ this.#credentials = options.credentials;
59
61
  this.#token = options.token;
60
62
  }
61
63
  // The session token from the last login/signUp, for persisting a session.
@@ -63,7 +65,7 @@ export class Client {
63
65
  return this.#token;
64
66
  }
65
67
  #request(method, path, body) {
66
- return request(this.#fetch, this.#baseUrl + this.#prefix + path, method, body, this.#token);
68
+ return request(this.#fetch, this.#baseUrl + this.#prefix + path, method, body, this.#token, this.#credentials);
67
69
  }
68
70
  #sign(content, contentType) {
69
71
  if (this.#signer === undefined) {
@@ -79,14 +81,20 @@ export class Client {
79
81
  }
80
82
  // AuthRoutes.SignUp: POST /signup
81
83
  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
+ const { interpretation, signature, publicKey } = await this.#sign(req.content, "metacensus.v1.User");
85
+ const session = await this.#request("POST", "/signup", JSON.stringify({ ...req, interpretation, publicKey, userSignature: signature }));
86
+ this.#token = session.token;
87
+ return session;
88
+ }
89
+ // AuthRoutes.Refresh: POST /refresh
90
+ async refresh(req) {
91
+ const session = await this.#request("POST", "/refresh", JSON.stringify(req));
84
92
  this.#token = session.token;
85
93
  return session;
86
94
  }
87
95
  // AuthRoutes.Logout: POST /logout
88
96
  async logout(req) {
89
- const res = await this.#request("POST", "/logout", undefined);
97
+ const res = await this.#request("POST", "/logout", JSON.stringify(req));
90
98
  this.#token = undefined;
91
99
  return res;
92
100
  }
@@ -113,8 +121,8 @@ export class Client {
113
121
  // PropRoutes.CreateProp: POST /topic/{topicId}/prop
114
122
  async createProp(req) {
115
123
  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 })));
124
+ const { interpretation, signature } = await this.#sign(rest.content, "metacensus.v1.Prop");
125
+ return flattenProp(await this.#request("POST", `/topic/${param(topicId)}/prop`, JSON.stringify({ ...rest, interpretation, userSignature: signature })));
118
126
  }
119
127
  // PropRoutes.ListVotes: GET /topic/{topicId}/prop/{propId}/vote
120
128
  listVotes(req) {
@@ -127,8 +135,8 @@ export class Client {
127
135
  // PropRoutes.SetVote: POST /topic/{topicId}/prop/{propId}/vote
128
136
  async setVote(req) {
129
137
  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 })));
138
+ const { interpretation, signature } = await this.#sign(rest.content, "metacensus.v1.Vote");
139
+ return flattenVote(await this.#request("POST", `/topic/${param(topicId)}/prop/${param(propId)}/vote`, JSON.stringify({ ...rest, interpretation, userSignature: signature })));
132
140
  }
133
141
  // TopicRoutes.ListTopics: GET /topic
134
142
  listTopics(req) {
@@ -148,8 +156,8 @@ export class Client {
148
156
  }
149
157
  // TopicRoutes.CreateTopic: POST /topic
150
158
  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 })));
159
+ const { interpretation, signature } = await this.#sign(req.content, "metacensus.v1.Topic");
160
+ return flattenTopic(await this.#request("POST", "/topic", JSON.stringify({ ...req, interpretation, userSignature: signature })));
153
161
  }
154
162
  // TopicRoutes.ListMembers: GET /topic/{topicId}/member
155
163
  listMembers(req) {
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAW3C,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE9D,+EAA+E;AAC/E,wEAAwE;AACxE,MAAM,OAAO,QAAS,SAAQ,KAAK;IAEtB,MAAM;IACN,GAAG;IACH,MAAM;IACN,IAAI;IAJf,YACW,MAAc,EACd,GAAW,EACX,MAAc,EACd,IAAY;QAErB,KAAK,CAAC,GAAG,MAAM,IAAI,GAAG,UAAU,MAAM,EAAE,CAAC,CAAC;sBALjC,MAAM;mBACN,GAAG;sBACH,MAAM;oBACN,IAAI;QAGb,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAMD,SAAS,KAAK,CAAC,CAA4B;IACzC,OAAO,kBAAkB,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,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACjE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,IAAI,YAAY,CAAC;IAChD,CAAC;IAED,QAAQ,CAAI,MAAc,EAAE,IAAY,EAAE,IAAa;QACrD,OAAO,OAAO,CAAI,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,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"}
@@ -1,4 +1,4 @@
1
- import type { User, UserSignature } from "./common.js";
1
+ import type { Interpretation, Signature, User } from "./common.js";
2
2
  export declare const protobufPackage = "metacensus.v1";
3
3
  /** Sign-up, login and logout. */
4
4
  export interface LoginRequest {
@@ -8,8 +8,9 @@ export interface LoginRequest {
8
8
  /**
9
9
  * Creates an account and enrolls the signing key every later write is
10
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.
11
+ * binds whatever it's handed, and the assertion proves possession of the
12
+ * matching private key at enrollment. This is the one write whose key is not
13
+ * resolved from persistence: no account, and so no key history, exists yet.
13
14
  */
14
15
  export interface SignUpRequest {
15
16
  content?: User | undefined;
@@ -18,17 +19,60 @@ export interface SignUpRequest {
18
19
  * signed, stored document.
19
20
  */
20
21
  password: string;
22
+ /** How the enrolling assertion is to be read; re-stamped onto the UserSigned. */
23
+ interpretation?: Interpretation | undefined;
21
24
  /**
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.
25
+ * The public half of the key being enrolled: base64url SPKI DER. Carried
26
+ * here, on the one enrollment write, rather than on every Signature — a
27
+ * usually-empty key field on every record is a footgun (forge content, key
28
+ * and signature and it "verifies"). The store checks `user_signature.key_id`
29
+ * thumbprints this key before binding it. For a passkey this is the public
30
+ * key the navigator.credentials.create() ceremony yielded.
24
31
  */
25
- userSignature?: UserSignature | undefined;
32
+ publicKey: string;
33
+ /**
34
+ * Over `content`, made with the key being enrolled; verified at sign-up
35
+ * against `public_key` (bound by key_id), not against a resolved key.
36
+ */
37
+ userSignature?: Signature | undefined;
26
38
  }
27
39
  export interface Session {
28
- /** Bearer token, sent back as `Authorization: Bearer <token>`. */
40
+ /**
41
+ * Short-lived access token, sent back as `Authorization: Bearer <token>`.
42
+ * Opaque; the client cannot read an expiry out of it, which is what
43
+ * `expires_in` is for.
44
+ */
29
45
  token: string;
46
+ /**
47
+ * Seconds until `token` expires, measured from when this response was
48
+ * issued. The client refreshes at or before that horizon (see `/refresh`);
49
+ * it is the only expiry signal, since the token is opaque.
50
+ */
51
+ expiresIn: number;
52
+ /**
53
+ * Long-lived credential that mints a fresh access token at `/refresh`,
54
+ * rotated on every use and revoked at logout. In the browser posture it
55
+ * never travels here: the server lifts it into an `HttpOnly` cookie and
56
+ * blanks this field, so JavaScript never holds it. A non-browser caller (a
57
+ * proxy or another server) reads it here instead. See ts/README.md, "Auth
58
+ * and the session token".
59
+ */
60
+ refreshToken: string;
61
+ }
62
+ /**
63
+ * Exchanges a refresh token for a fresh session. Cookie or body delivery is as
64
+ * on `Session.refresh_token`; a request that carries neither is rejected.
65
+ */
66
+ export interface RefreshRequest {
67
+ refreshToken: string;
30
68
  }
31
69
  export interface LogoutRequest {
70
+ /**
71
+ * The refresh token whose session to end — its rotation lineage and its
72
+ * access tokens with it. Cookie or body delivery is as on
73
+ * `Session.refresh_token`.
74
+ */
75
+ refreshToken: string;
32
76
  }
33
77
  export interface LogoutResponse {
34
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/metacensus/v1/auth.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEvD,eAAO,MAAM,eAAe,kBAAkB,CAAC;AAE/C,iCAAiC;AAEjC,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EACJ,IAAI,GACJ,SAAS,CAAC;IACd;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;CAC3C;AAED,MAAM,WAAW,OAAO;IACtB,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;CAC7B;AAED,MAAM,WAAW,cAAc;CAC9B"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/metacensus/v1/auth.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnE,eAAO,MAAM,eAAe,kBAAkB,CAAC;AAE/C,iCAAiC;AAEjC,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EACJ,IAAI,GACJ,SAAS,CAAC;IACd;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,cAAc,CAAC,EACX,cAAc,GACd,SAAS,CAAC;IACd;;;;;;;OAOG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CACvC;AAED,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