@nacre.work/api 0.18.0 → 0.20.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/dist/login.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { KeyObject } from 'node:crypto';
2
2
  import type { Pool } from 'pg';
3
+ import type { WebAuthnAssertionOptions } from './second-factor.js';
3
4
  export interface LoginRequest {
4
5
  readonly email: string;
5
6
  readonly password: string;
@@ -62,7 +63,33 @@ export interface LoginDeps {
62
63
  export interface SecondFactorGate {
63
64
  required(orgId: string, userId: string): Promise<boolean>;
64
65
  verify(orgId: string, userId: string, code: string): Promise<boolean>;
66
+ beginWebAuthnAssertion(orgId: string, userId: string): Promise<WebAuthnAssertionOptions | undefined>;
67
+ verifyWebAuthnAssertion(orgId: string, userId: string, response: WebAuthnProof): Promise<boolean>;
65
68
  }
69
+ /** What a browser hands back from `navigator.credentials.get`. */
70
+ export interface WebAuthnProof {
71
+ readonly credentialId: string;
72
+ readonly authenticatorData: Uint8Array;
73
+ readonly clientDataJSON: Uint8Array;
74
+ readonly signature: Uint8Array;
75
+ readonly challenge: string;
76
+ }
77
+ /**
78
+ * The proof the second half of a sign-in takes, and it is a union on purpose.
79
+ *
80
+ * A six-digit code and an assertion are not two spellings of one argument: the
81
+ * first is a string a person read off a screen and the second is a signature
82
+ * over an origin. Making the parameter a union means a caller has to say which
83
+ * it holds, and a handler that forgot the new kind is a compile error rather
84
+ * than a route that silently only ever accepts the old one.
85
+ */
86
+ export type SecondFactorProof = {
87
+ readonly kind: 'code';
88
+ readonly code: string;
89
+ } | {
90
+ readonly kind: 'webauthn';
91
+ readonly response: WebAuthnProof;
92
+ };
66
93
  /**
67
94
  * Sign-in has three outcomes now, and a union rather than a nullable pair.
68
95
  *
@@ -71,10 +98,44 @@ export interface SecondFactorGate {
71
98
  * a caller can ignore, and ignoring it here means issuing a session to somebody
72
99
  * who has not produced their second factor.
73
100
  */
74
- export type LoginOutcome = {
101
+ export type SessionOutcome = {
75
102
  readonly kind: 'tokens';
76
103
  readonly tokens: Tokens;
77
104
  } | {
105
+ /**
106
+ * A gate admitted this person only as far as enrolling a second factor.
107
+ *
108
+ * The challenge reaches the enrolment routes and nothing else, and
109
+ * confirming a factor is what turns it into a session. Without this
110
+ * outcome a policy requiring a factor would lock out everybody who had
111
+ * not already enrolled on the day it was turned on, and the route back
112
+ * would be the database.
113
+ */
114
+ readonly kind: 'enrol-second-factor';
115
+ readonly challenge: string;
116
+ readonly expiresIn: number;
117
+ /** The gate's own words, shown to the person. Never an internal detail. */
118
+ readonly reason: string;
119
+ } | {
120
+ /** A gate refused, and no action by this person changes that. */
121
+ readonly kind: 'refused';
122
+ readonly reason: string;
123
+ };
124
+ /**
125
+ * Sign-in's outcomes, which are the ones above plus the second-factor
126
+ * challenge.
127
+ *
128
+ * Split so that every path minting a session shares the first three: the union
129
+ * came from `issue`, which is the one place a session is made, and a caller
130
+ * that can reach `issue` can reach all of its answers. Only `login` can ask for
131
+ * a factor that already exists, so only `login` carries that member.
132
+ *
133
+ * A union rather than a nullable pair for the reason it always was: it turns
134
+ * every call site into a compile error until it says which outcome it means,
135
+ * and the alternative is an optional field a caller can ignore — where ignoring
136
+ * it means issuing a session to somebody a policy says may not have one.
137
+ */
138
+ export type LoginOutcome = SessionOutcome | {
78
139
  readonly kind: 'second-factor';
79
140
  /** Short-lived, single-purpose, and useless as an access token. */
80
141
  readonly challenge: string;
@@ -92,7 +153,15 @@ export type ChangePasswordOutcome = {
92
153
  readonly kind: 'changed';
93
154
  readonly tokens: Tokens;
94
155
  readonly email: string;
95
- } | 'wrong-password' | 'no-user';
156
+ }
157
+ /**
158
+ * A shared account: a credential more than one person holds, so none of them
159
+ * may change it for the rest. Distinct from `wrong-password` because the two
160
+ * are different facts and only one of them is fixed by retyping.
161
+ */
162
+ | 'shared' | Exclude<SessionOutcome, {
163
+ readonly kind: 'tokens';
164
+ }> | 'wrong-password' | 'no-user';
96
165
  export declare class Login {
97
166
  private readonly deps;
98
167
  constructor(deps: LoginDeps);
@@ -126,7 +195,53 @@ export declare class Login {
126
195
  * all of them into one refusal. Which of the four it was is not something a
127
196
  * client needs and is something an attacker would use.
128
197
  */
129
- completeSecondFactor(challenge: string, code: string): Promise<Tokens | undefined>;
198
+ completeSecondFactor(challenge: string, proof: SecondFactorProof): Promise<SessionOutcome | undefined>;
199
+ /**
200
+ * The options a browser needs for the assertion half of a sign-in.
201
+ *
202
+ * It takes the same challenge `login` handed back, and that is the whole
203
+ * reason this method is here rather than on the store: the JWT is what says
204
+ * who is signing in, and it is signed by a key the store does not have. An
205
+ * endpoint that took a user id instead would answer "which authenticators
206
+ * does this person hold" to anybody who asked.
207
+ *
208
+ * `undefined` where the challenge is not one of ours, where it has expired,
209
+ * and where the person has no key enrolled — one refusal, for the reason
210
+ * every refusal on this path is one.
211
+ */
212
+ beginSecondFactorWebAuthn(challenge: string): Promise<WebAuthnAssertionOptions | undefined>;
213
+ /**
214
+ * Who a sign-in challenge names, or nothing.
215
+ *
216
+ * One reader for the two halves that consult it, because a challenge whose
217
+ * audience is checked on one path and not the other is an access token
218
+ * accepted as a challenge — which is exactly what `challengeAudience` exists
219
+ * to stop.
220
+ */
221
+ private readChallenge;
222
+ /**
223
+ * Read an enrolment challenge, for the routes that accept one.
224
+ *
225
+ * Public because the enrolment surface is in `server.ts` and this is the only
226
+ * thing that may turn that token into a person. It answers the org and the
227
+ * user and nothing else — no role, no permissions — because the only thing
228
+ * such a token is allowed to do is add a factor to the account it names.
229
+ */
230
+ readEnrolmentChallenge(challenge: string): Promise<{
231
+ readonly orgId: string;
232
+ readonly userId: string;
233
+ } | undefined>;
234
+ /**
235
+ * A confirmed factor turns an enrolment challenge into a session.
236
+ *
237
+ * Called by the enrolment route once a factor is confirmed, so the person who
238
+ * was sent to enrol is not then asked to sign in again — which is the moment
239
+ * they would give up. It re-reads the account and runs the gates again rather
240
+ * than trusting that enrolling was enough: a gate that wanted a *particular*
241
+ * kind is entitled to refuse the one that was just added, and assuming
242
+ * otherwise would be this file deciding what a policy means.
243
+ */
244
+ sessionAfterEnrolment(orgId: string, userId: string): Promise<SessionOutcome | undefined>;
130
245
  /**
131
246
  * A person changes their own password, having proved the current one.
132
247
  *
@@ -193,7 +308,7 @@ export declare class Login {
193
308
  * took it. Which one is unknowable from here, so the whole family is revoked
194
309
  * and both sign in again.
195
310
  */
196
- refresh(token: string): Promise<Tokens | undefined>;
311
+ refresh(token: string): Promise<SessionOutcome | undefined>;
197
312
  /** Sign out. Ends the family, not just this token. */
198
313
  logout(token: string): Promise<boolean>;
199
314
  /**
@@ -216,6 +331,27 @@ export declare class Login {
216
331
  * revoked together; a fresh login starts a new one, so signing out of one
217
332
  * device does not sign out of the others.
218
333
  */
334
+ /**
335
+ * Mint a session, unless a gate says this authentication is not enough.
336
+ *
337
+ * **The gates are consulted here rather than beside each caller, and that is
338
+ * the whole of why this returns a union.** There are four paths from a
339
+ * verified credential to a session — a password with no factor asked for, a
340
+ * completed second factor, a spent refresh token, and a password change — and
341
+ * a check placed beside them is a check the fifth one forgets. That is this
342
+ * repository's most repeated defect, so the gate goes at the single point all
343
+ * four already reach, and every caller becomes a compile error until it says
344
+ * what it does with a refusal.
345
+ *
346
+ * A **refresh** is gated too, deliberately. A policy turned on while people
347
+ * are signed in would otherwise do nothing for any of them for as long as
348
+ * they kept renewing — authority renewed without the person present is the
349
+ * same case a delegation's `disabled` check exists for.
350
+ *
351
+ * `path` is what the caller is doing, passed rather than inferred: a gate
352
+ * that wants to demand a factor on sign-in and not interrupt a password
353
+ * change can only tell those apart if it is told.
354
+ */
219
355
  private issue;
220
356
  }
221
357
  //# sourceMappingURL=login.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAG5C,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,IAAI,CAAA;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IAED;;;;;;;;OAQG;YACW,IAAI;YAuBJ,YAAY;YAaZ,SAAS;YAYT,MAAM;IAgBpB;;;;;;;;OAQG;IACG,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IA+FjE,sDAAsD;IAChD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAkB7C;;;;;;;;;;;OAWG;YACW,YAAY;IAe1B;;;;;;OAMG;IACH;;;;;;;;;;;;;;;;;;;;OAoBG;YACW,KAAK;CAiFpB"}
package/dist/login.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createHash, createPublicKey, randomBytes, timingSafeEqual } from 'node:crypto';
2
- import { hashPassword, needsRehash, spendVerificationTime, verifyPassword, whileAuthenticating, withOrg, } from '@nacre.work/core';
2
+ import { admitSignIn, hashPassword, needsRehash, spendVerificationTime, verifyPassword, whileAuthenticating, withOrg, } from '@nacre.work/core';
3
3
  import { jwtVerify, SignJWT } from 'jose';
4
4
  /**
5
5
  * Email and password sign-in.
@@ -40,6 +40,16 @@ import { jwtVerify, SignJWT } from 'jose';
40
40
  const ACCESS_MIN_SECONDS = 60;
41
41
  /** Long enough to read a phone, short enough not to survive walking away. */
42
42
  const CHALLENGE_SECONDS = 300;
43
+ /**
44
+ * The enrolment challenge's lifetime, and deliberately longer than the one
45
+ * above.
46
+ *
47
+ * That one is "read six digits off a screen you are already holding". This one
48
+ * is "install an authenticator, scan a code, and write down ten recovery codes"
49
+ * — or find a security key in a drawer. Five minutes is a person being told to
50
+ * start over halfway through the one flow they were sent to complete.
51
+ */
52
+ const ENROL_SECONDS = 900;
43
53
  /**
44
54
  * The challenge's audience, which is deliberately not the API's.
45
55
  *
@@ -99,9 +109,13 @@ export class Login {
99
109
  * for this.
100
110
  */
101
111
  if (this.deps.secondFactors !== undefined && (await this.deps.secondFactors.required(candidate.org_id, candidate.id))) {
102
- return { kind: 'second-factor', challenge: await this.challenge(candidate), expiresIn: CHALLENGE_SECONDS };
112
+ return {
113
+ kind: 'second-factor',
114
+ challenge: await this.challenge(candidate, 'second-factor', CHALLENGE_SECONDS),
115
+ expiresIn: CHALLENGE_SECONDS,
116
+ };
103
117
  }
104
- return { kind: 'tokens', tokens: await this.issue(candidate, undefined) };
118
+ return this.issue(candidate, undefined, 'password');
105
119
  }
106
120
  /**
107
121
  * The token that says "this password was correct", and nothing else.
@@ -115,9 +129,9 @@ export class Login {
115
129
  * well, the code is single-use through `last_step`, and a person holding both
116
130
  * has finished signing in anyway.
117
131
  */
118
- async challenge(user) {
132
+ async challenge(user, purpose, seconds) {
119
133
  const now = this.clock;
120
- return new SignJWT({ org: user.org_id, purpose: 'second-factor' })
134
+ return new SignJWT({ org: user.org_id, purpose })
121
135
  .setProtectedHeader({
122
136
  alg: this.deps.algorithm ?? 'HS256',
123
137
  ...(this.deps.keyId === undefined ? {} : { kid: this.deps.keyId }),
@@ -126,7 +140,7 @@ export class Login {
126
140
  .setIssuer(this.deps.issuer)
127
141
  .setAudience(challengeAudience(this.deps.audience))
128
142
  .setIssuedAt(Math.floor(now.getTime() / 1000))
129
- .setExpirationTime(Math.floor(now.getTime() / 1000) + CHALLENGE_SECONDS)
143
+ .setExpirationTime(Math.floor(now.getTime() / 1000) + seconds)
130
144
  .sign(this.deps.key);
131
145
  }
132
146
  /**
@@ -137,12 +151,61 @@ export class Login {
137
151
  * all of them into one refusal. Which of the four it was is not something a
138
152
  * client needs and is something an attacker would use.
139
153
  */
140
- async completeSecondFactor(challenge, code) {
154
+ async completeSecondFactor(challenge, proof) {
155
+ const gate = this.deps.secondFactors;
156
+ if (gate === undefined)
157
+ return undefined;
158
+ const who = await this.readChallenge(challenge, 'second-factor');
159
+ if (who === undefined)
160
+ return undefined;
161
+ const { orgId, userId } = who;
162
+ const proved = proof.kind === 'code'
163
+ ? await gate.verify(orgId, userId, proof.code)
164
+ : await gate.verifyWebAuthnAssertion(orgId, userId, proof.response);
165
+ if (!proved)
166
+ return undefined;
167
+ // Re-read the row rather than trusting the challenge for anything but
168
+ // identity: five minutes is long enough to be disabled, and the role in the
169
+ // token has to be the one the database holds now.
170
+ const user = await this.userById(orgId, userId);
171
+ if (user === undefined || user.disabled_at !== null)
172
+ return undefined;
173
+ // The kind that was proved goes to the gates, because "a second factor" and
174
+ // "a factor whose signature covers the origin" are not the same claim and a
175
+ // policy may want the second.
176
+ return this.issue(user, undefined, 'second-factor', undefined, proof.kind === 'code' ? 'totp' : 'webauthn');
177
+ }
178
+ /**
179
+ * The options a browser needs for the assertion half of a sign-in.
180
+ *
181
+ * It takes the same challenge `login` handed back, and that is the whole
182
+ * reason this method is here rather than on the store: the JWT is what says
183
+ * who is signing in, and it is signed by a key the store does not have. An
184
+ * endpoint that took a user id instead would answer "which authenticators
185
+ * does this person hold" to anybody who asked.
186
+ *
187
+ * `undefined` where the challenge is not one of ours, where it has expired,
188
+ * and where the person has no key enrolled — one refusal, for the reason
189
+ * every refusal on this path is one.
190
+ */
191
+ async beginSecondFactorWebAuthn(challenge) {
141
192
  const gate = this.deps.secondFactors;
142
193
  if (gate === undefined)
143
194
  return undefined;
144
- let userId;
145
- let orgId;
195
+ const who = await this.readChallenge(challenge, 'second-factor');
196
+ if (who === undefined)
197
+ return undefined;
198
+ return gate.beginWebAuthnAssertion(who.orgId, who.userId);
199
+ }
200
+ /**
201
+ * Who a sign-in challenge names, or nothing.
202
+ *
203
+ * One reader for the two halves that consult it, because a challenge whose
204
+ * audience is checked on one path and not the other is an access token
205
+ * accepted as a challenge — which is exactly what `challengeAudience` exists
206
+ * to stop.
207
+ */
208
+ async readChallenge(challenge, purpose) {
146
209
  try {
147
210
  const { payload } = await jwtVerify(challenge, this.verificationKey, {
148
211
  issuer: this.deps.issuer,
@@ -150,24 +213,43 @@ export class Login {
150
213
  algorithms: [this.deps.algorithm ?? 'HS256'],
151
214
  currentDate: this.clock,
152
215
  });
153
- if (payload.purpose !== 'second-factor' || typeof payload.sub !== 'string' || typeof payload.org !== 'string') {
216
+ // The purpose is a required argument rather than a default, so a second
217
+ // reader written later has to say which kind of challenge it takes.
218
+ if (payload.purpose !== purpose || typeof payload.sub !== 'string' || typeof payload.org !== 'string') {
154
219
  return undefined;
155
220
  }
156
- userId = payload.sub;
157
- orgId = payload.org;
221
+ return { orgId: payload.org, userId: payload.sub };
158
222
  }
159
223
  catch {
160
224
  return undefined;
161
225
  }
162
- if (!(await gate.verify(orgId, userId, code)))
163
- return undefined;
164
- // Re-read the row rather than trusting the challenge for anything but
165
- // identity: five minutes is long enough to be disabled, and the role in the
166
- // token has to be the one the database holds now.
226
+ }
227
+ /**
228
+ * Read an enrolment challenge, for the routes that accept one.
229
+ *
230
+ * Public because the enrolment surface is in `server.ts` and this is the only
231
+ * thing that may turn that token into a person. It answers the org and the
232
+ * user and nothing else — no role, no permissions — because the only thing
233
+ * such a token is allowed to do is add a factor to the account it names.
234
+ */
235
+ async readEnrolmentChallenge(challenge) {
236
+ return this.readChallenge(challenge, 'enrol');
237
+ }
238
+ /**
239
+ * A confirmed factor turns an enrolment challenge into a session.
240
+ *
241
+ * Called by the enrolment route once a factor is confirmed, so the person who
242
+ * was sent to enrol is not then asked to sign in again — which is the moment
243
+ * they would give up. It re-reads the account and runs the gates again rather
244
+ * than trusting that enrolling was enough: a gate that wanted a *particular*
245
+ * kind is entitled to refuse the one that was just added, and assuming
246
+ * otherwise would be this file deciding what a policy means.
247
+ */
248
+ async sessionAfterEnrolment(orgId, userId) {
167
249
  const user = await this.userById(orgId, userId);
168
250
  if (user === undefined || user.disabled_at !== null)
169
251
  return undefined;
170
- return this.issue(user, undefined);
252
+ return this.issue(user, undefined, 'second-factor');
171
253
  }
172
254
  /**
173
255
  * A person changes their own password, having proved the current one.
@@ -205,7 +287,7 @@ export class Login {
205
287
  */
206
288
  async changePassword(orgId, userId, current, next) {
207
289
  const row = await withOrg(this.deps.pool, orgId, async (client) => {
208
- const { rows } = await client.query(`SELECT id, org_id, role, email, password_hash, disabled_at
290
+ const { rows } = await client.query(`SELECT id, org_id, role, email, password_hash, disabled_at, shared
209
291
  FROM users WHERE org_id = $1 AND id = $2`, [orgId, userId]);
210
292
  return rows[0];
211
293
  }, this.scope);
@@ -215,6 +297,22 @@ export class Login {
215
297
  // branch anybody sees.
216
298
  if (row === undefined || row.disabled_at !== null || row.password_hash === null)
217
299
  return 'no-user';
300
+ /*
301
+ * A credential more than one person holds is not one of them may change.
302
+ *
303
+ * Refused **before** the current password is verified, which is the one
304
+ * ordering decision here: checking it first would make this endpoint say
305
+ * whether the published password is still current, and the whole point is
306
+ * that the password is public. It costs nothing either, since a shared
307
+ * account can never pass.
308
+ *
309
+ * Here as well as at the route, and that is not a second copy of one check.
310
+ * The route is what answers `404` to a caller; this is what holds when a
311
+ * second route is written — the same argument the trigger on
312
+ * `user_second_factors` makes for the other half of this surface.
313
+ */
314
+ if (row.shared)
315
+ return 'shared';
218
316
  // Outside the transaction on purpose: scrypt at OWASP's minimum takes long
219
317
  // enough that holding a row lock across it is a lock held on arithmetic.
220
318
  if (!(await verifyPassword(current, row.password_hash)))
@@ -229,9 +327,15 @@ export class Login {
229
327
  // A new family. Carrying the old one would put the session that
230
328
  // replaces every other one in the same chain as the tokens just
231
329
  // revoked.
232
- return this.issue(row, undefined, client);
330
+ return this.issue(row, undefined, 'password-change', client);
233
331
  }, this.scope);
234
- return { kind: 'changed', tokens, email: row.email };
332
+ // A gate may interrupt a password change as readily as a sign-in, and the
333
+ // outcome is carried out rather than flattened: a person who has just
334
+ // proved their current password and is being told to enrol needs the
335
+ // challenge, not a failure with no next step.
336
+ if (tokens.kind !== 'tokens')
337
+ return tokens;
338
+ return { kind: 'changed', tokens: tokens.tokens, email: row.email };
235
339
  }
236
340
  async userById(orgId, userId) {
237
341
  return withOrg(this.deps.pool, orgId, async (client) => {
@@ -366,7 +470,7 @@ export class Login {
366
470
  const user = rows[0];
367
471
  if (user === undefined || user.disabled_at !== null)
368
472
  return 'gone';
369
- return this.issue(user, row.family_id, client);
473
+ return this.issue(user, row.family_id, 'refresh', client);
370
474
  }, this.scope);
371
475
  if (outcome === 'lost') {
372
476
  // Someone already spent this one. Two parties hold the same token and
@@ -419,7 +523,52 @@ export class Login {
419
523
  * revoked together; a fresh login starts a new one, so signing out of one
420
524
  * device does not sign out of the others.
421
525
  */
422
- async issue(user, family, client) {
526
+ /**
527
+ * Mint a session, unless a gate says this authentication is not enough.
528
+ *
529
+ * **The gates are consulted here rather than beside each caller, and that is
530
+ * the whole of why this returns a union.** There are four paths from a
531
+ * verified credential to a session — a password with no factor asked for, a
532
+ * completed second factor, a spent refresh token, and a password change — and
533
+ * a check placed beside them is a check the fifth one forgets. That is this
534
+ * repository's most repeated defect, so the gate goes at the single point all
535
+ * four already reach, and every caller becomes a compile error until it says
536
+ * what it does with a refusal.
537
+ *
538
+ * A **refresh** is gated too, deliberately. A policy turned on while people
539
+ * are signed in would otherwise do nothing for any of them for as long as
540
+ * they kept renewing — authority renewed without the person present is the
541
+ * same case a delegation's `disabled` check exists for.
542
+ *
543
+ * `path` is what the caller is doing, passed rather than inferred: a gate
544
+ * that wants to demand a factor on sign-in and not interrupt a password
545
+ * change can only tell those apart if it is told.
546
+ */
547
+ async issue(user, family, path, client, proved) {
548
+ const refusal = await admitSignIn({
549
+ orgId: user.org_id,
550
+ userId: user.id,
551
+ role: user.role,
552
+ path,
553
+ secondFactor: proved,
554
+ // Asked rather than assumed. `required` answers whether the account holds
555
+ // a confirmed factor, which is a different question from whether one was
556
+ // proved on this request — a refresh proves none and the account may
557
+ // still have one.
558
+ enrolled: this.deps.secondFactors === undefined
559
+ ? false
560
+ : await this.deps.secondFactors.required(user.org_id, user.id),
561
+ });
562
+ if (refusal !== undefined) {
563
+ if (refusal.kind === 'refuse')
564
+ return { kind: 'refused', reason: refusal.reason };
565
+ return {
566
+ kind: 'enrol-second-factor',
567
+ challenge: await this.challenge(user, 'enrol', ENROL_SECONDS),
568
+ expiresIn: ENROL_SECONDS,
569
+ reason: refusal.reason,
570
+ };
571
+ }
423
572
  const ttl = Math.max(ACCESS_MIN_SECONDS, this.deps.accessTokenTtl);
424
573
  const now = this.clock;
425
574
  const accessToken = await new SignJWT({
@@ -453,7 +602,10 @@ export class Login {
453
602
  await insert(client);
454
603
  else
455
604
  await withOrg(this.deps.pool, user.org_id, insert, this.scope);
456
- return { accessToken, refreshToken, expiresIn: ttl, orgId: user.org_id, userId: user.id };
605
+ return {
606
+ kind: 'tokens',
607
+ tokens: { accessToken, refreshToken, expiresIn: ttl, orgId: user.org_id, userId: user.id },
608
+ };
457
609
  }
458
610
  }
459
611
  //# sourceMappingURL=login.js.map
package/dist/login.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"login.js","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAEvF,OAAO,EACL,YAAY,EACZ,WAAW,EACX,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,OAAO,GACR,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAGzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,MAAM,kBAAkB,GAAG,EAAE,CAAA;AAE7B,6EAA6E;AAC7E,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAE7B;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAU,EAAE,CAAC,GAAG,QAAQ,gBAAgB,CAAA;AA2GnF,MAAM,MAAM,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAE1F,wEAAwE;AACxE,MAAM,IAAI,GAAG,GAAW,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC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0E;QAC1E,0EAA0E;QAC1E,qEAAqE;QACrE,sEAAsE;QACtE,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,MAAM,CAAC,MAAM,CAAC,CAAA;;YACzC,MAAM,OAAO,CAChB,IAAI,CAAC,IAAI,CAAC,IAAI,EACd,IAAI,CAAC,MAAM,EACX,MAAM,EACN,IAAI,CAAC,KAAK,CACX,CAAA;QAED,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;SAC3F,CAAA;IACH,CAAC;CACF"}
package/dist/main.js CHANGED
@@ -95,24 +95,50 @@ async function main() {
95
95
  },
96
96
  });
97
97
  /*
98
- * The second factor, when a key was configured.
98
+ * The second factor, and the two kinds are configured differently.
99
99
  *
100
- * `undefined` otherwise, and that is a supported deployment: the surface
101
- * answers 404 and sign-in issues tokens exactly as it always did. There is no
102
- * mode where a secret is stored unsealed.
100
+ * TOTP needs `NACRE_2FA_KEY` — its secret is shared, so it has to be kept and
101
+ * therefore sealed, and there is no mode where one is stored unsealed.
102
+ * WebAuthn needs no key at all: what is stored is a public key and a counter,
103
+ * and a dump of those produces no assertion. So this is constructed on every
104
+ * deployment, and `SecondFactors.kinds` is what decides which of the two a
105
+ * screen may offer.
106
+ *
107
+ * The relying party comes from `NACRE_CANONICAL_URL`, which every deployment
108
+ * already sets, rather than from a variable of its own. A `NACRE_WEBAUTHN_*`
109
+ * would be a second answer to "what is this installation's address", and a
110
+ * second answer to that is how a deployment ends up with credentials bound to
111
+ * a name it no longer serves.
103
112
  */
104
113
  const secondFactorKey = loadSecondFactorKey();
105
- const secondFactors = secondFactorKey === undefined
106
- ? undefined
107
- : new SecondFactors({
108
- pool,
109
- key: secondFactorKey,
110
- // What an authenticator prints above the account. The issuer of the
111
- // tokens is what this installation already calls itself, so a person
112
- // with two Nacre deployments sees two distinguishable entries.
113
- issuer: config.jwtIssuer,
114
- role: APP_ROLE,
115
- });
114
+ const canonical = new URL(config.canonicalUrl);
115
+ const secondFactors = new SecondFactors({
116
+ pool,
117
+ key: secondFactorKey,
118
+ // What an authenticator prints above the account. The issuer of the
119
+ // tokens is what this installation already calls itself, so a person
120
+ // with two Nacre deployments sees two distinguishable entries.
121
+ issuer: config.jwtIssuer,
122
+ relyingParty: {
123
+ // The **host** and never the origin: a relying party id is a registrable
124
+ // domain, so a scheme or a port in it is a credential no authenticator
125
+ // will make.
126
+ id: canonical.hostname,
127
+ name: canonical.hostname,
128
+ /*
129
+ * Where a page may run the ceremony from. The canonical origin, plus the
130
+ * browser origins this API already admits — the console is served from
131
+ * the API's own origin unless a deployment has said otherwise, and if it
132
+ * has, it has said so in `NACRE_API_ALLOWED_ORIGINS`.
133
+ *
134
+ * Compared for equality by the verifier. A suffix match would admit
135
+ * `evil-nacre.work`, which is the hole a phishing-resistant factor exists
136
+ * to close.
137
+ */
138
+ origins: [canonical.origin, ...config.apiAllowedOrigins],
139
+ },
140
+ role: APP_ROLE,
141
+ });
116
142
  /*
117
143
  * The sender, when the deployment configured one.
118
144
  *