@oneuptime/common 12.0.21 → 12.0.22

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 (40) hide show
  1. package/Models/DatabaseModels/Index.ts +2 -0
  2. package/Models/DatabaseModels/UserTwoFactorBackupCode.ts +262 -0
  3. package/Server/API/UserTwoFactorBackupCodeAPI.ts +258 -0
  4. package/Server/Infrastructure/Postgres/SchemaMigrations/1789100000000-AddUserTwoFactorBackupCode.ts +63 -0
  5. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
  6. package/Server/Services/Index.ts +2 -0
  7. package/Server/Services/UserService.ts +42 -0
  8. package/Server/Services/UserTwoFactorBackupCodeService.ts +355 -0
  9. package/Server/Utils/TwoFactorBackupCode.ts +266 -0
  10. package/Tests/Server/API/UserAuthenticationAPI.test.ts +16 -3
  11. package/Tests/Server/API/UserTwoFactorAuthAdminAPI.test.ts +18 -2
  12. package/Tests/Server/API/UserTwoFactorBackupCodeAPI.test.ts +1390 -0
  13. package/Tests/Server/Services/UserAuthenticationService.test.ts +23 -1
  14. package/Tests/Server/Services/UserTwoFactorAuthAdmin.test.ts +21 -0
  15. package/Tests/Server/Services/UserTwoFactorBackupCodeAdminSurface.test.ts +919 -0
  16. package/Tests/Server/Services/UserTwoFactorBackupCodeService.test.ts +862 -0
  17. package/Tests/Server/Utils/TwoFactorBackupCode.test.ts +475 -0
  18. package/Types/Email/EmailTemplateType.ts +2 -0
  19. package/Types/UserAuthenticationStatus.ts +16 -0
  20. package/build/dist/Models/DatabaseModels/Index.js +2 -0
  21. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  22. package/build/dist/Models/DatabaseModels/UserTwoFactorBackupCode.js +277 -0
  23. package/build/dist/Models/DatabaseModels/UserTwoFactorBackupCode.js.map +1 -0
  24. package/build/dist/Server/API/UserTwoFactorBackupCodeAPI.js +201 -0
  25. package/build/dist/Server/API/UserTwoFactorBackupCodeAPI.js.map +1 -0
  26. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1789100000000-AddUserTwoFactorBackupCode.js +46 -0
  27. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1789100000000-AddUserTwoFactorBackupCode.js.map +1 -0
  28. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
  29. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  30. package/build/dist/Server/Services/Index.js +2 -0
  31. package/build/dist/Server/Services/Index.js.map +1 -1
  32. package/build/dist/Server/Services/UserService.js +39 -0
  33. package/build/dist/Server/Services/UserService.js.map +1 -1
  34. package/build/dist/Server/Services/UserTwoFactorBackupCodeService.js +327 -0
  35. package/build/dist/Server/Services/UserTwoFactorBackupCodeService.js.map +1 -0
  36. package/build/dist/Server/Utils/TwoFactorBackupCode.js +269 -0
  37. package/build/dist/Server/Utils/TwoFactorBackupCode.js.map +1 -0
  38. package/build/dist/Types/Email/EmailTemplateType.js +2 -0
  39. package/build/dist/Types/Email/EmailTemplateType.js.map +1 -1
  40. package/package.json +1 -1
@@ -0,0 +1,327 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import DatabaseService from "./DatabaseService";
11
+ import Model from "../../Models/DatabaseModels/UserTwoFactorBackupCode";
12
+ import TwoFactorBackupCode, { BackupCodeSetSize, } from "../Utils/TwoFactorBackupCode";
13
+ import QueryHelper from "../Types/Database/QueryHelper";
14
+ import BadDataException from "../../Types/Exception/BadDataException";
15
+ import LIMIT_MAX from "../../Types/Database/LimitMax";
16
+ import SortOrder from "../../Types/BaseDatabase/SortOrder";
17
+ import OneUptimeDate from "../../Types/Date";
18
+ import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
19
+ import logger from "../Utils/Logger";
20
+ export class Service extends DatabaseService {
21
+ constructor() {
22
+ super(Model);
23
+ }
24
+ /*
25
+ * The model denies create to everyone, so the only way a row is written is
26
+ * `regenerateForUser` below, as root. This hook is the second lock on the
27
+ * same door: it refuses any create that did not come through there.
28
+ *
29
+ * Worth having both because the two guards fail differently. The table
30
+ * permission is enforced by the CRUD API layer and is bypassed wholesale by
31
+ * `isRoot`, which every internal caller uses -- so a future service that
32
+ * reaches for `UserTwoFactorBackupCodeService.create()` with a plaintext
33
+ * code, or with no owner, would sail past it. What lands in `codeHash` is
34
+ * the credential; there is no recovering from writing the wrong thing there.
35
+ */
36
+ async onBeforeCreate(createBy) {
37
+ if (!createBy.data.userId) {
38
+ throw new BadDataException("User id is required");
39
+ }
40
+ if (!createBy.data.codeHash) {
41
+ throw new BadDataException("Backup code hash is required");
42
+ }
43
+ /*
44
+ * A code that arrives already spent is a caller confusing itself about
45
+ * which end of the lifecycle it is at. Codes are minted usable and are
46
+ * spent only by `consumeCode`.
47
+ *
48
+ * Deleted rather than set to undefined: `exactOptionalPropertyTypes` is on,
49
+ * so the property being ABSENT and the property holding `undefined` are
50
+ * different things to the compiler, and only the first is allowed here.
51
+ */
52
+ delete createBy.data.usedAt;
53
+ return {
54
+ createBy: createBy,
55
+ carryForward: {},
56
+ };
57
+ }
58
+ /**
59
+ * Mint a fresh set of backup codes for one user, replacing whatever they
60
+ * had, and return the PLAINTEXT codes.
61
+ *
62
+ * This is the only moment the plaintext exists anywhere. The caller shows it
63
+ * to the user once and then it is gone -- only the keyed digests are stored,
64
+ * so nothing (not this service, not a master admin, not a database dump) can
65
+ * produce the codes again. That is the property the feature is worth having
66
+ * for, and it is why the API route wraps this in a response the UI is
67
+ * expected to make the user acknowledge.
68
+ *
69
+ * REPLACING rather than adding is deliberate. "Generate more codes" would
70
+ * leave the codes from a list the user printed, lost and then regenerated
71
+ * over still working, which defeats the point of regenerating after a
72
+ * suspected compromise.
73
+ *
74
+ * ALL OR NOTHING, and this is the part that needs care. The old set is
75
+ * deleted first, then the new rows are written one at a time -- so a failure
76
+ * partway through the loop would otherwise leave the account holding a few
77
+ * rows that WERE written and that the caller, having thrown, never showed to
78
+ * anybody. `getStatusForUser` would then report "4 backup codes" to a user
79
+ * who has never seen one of them: codes that are unusable in practice and
80
+ * that hide the fact that they have no recovery route left. That is the
81
+ * worst state this feature can produce, because it looks exactly like the
82
+ * good one.
83
+ *
84
+ * So a failure is compensated: everything written for this user is removed,
85
+ * and the account ends with NO codes and an error on screen. "You have no
86
+ * backup codes" is a state the profile page already tells the user to fix;
87
+ * "you have four codes you have never seen" is not.
88
+ *
89
+ * The compensating delete is itself best-effort -- if it also fails there is
90
+ * nothing further to try -- but it turns a silent, permanent trap into two
91
+ * consecutive infrastructure failures.
92
+ */
93
+ async regenerateForUser(data) {
94
+ const count = data.count || BackupCodeSetSize;
95
+ await this.deleteAllForUser({ userId: data.userId });
96
+ const codes = TwoFactorBackupCode.generateCodeSet(count);
97
+ try {
98
+ for (const code of codes) {
99
+ const backupCode = new Model();
100
+ backupCode.userId = data.userId;
101
+ backupCode.codeHash = TwoFactorBackupCode.hashCode({
102
+ code: code,
103
+ userId: data.userId,
104
+ });
105
+ await this.create({
106
+ data: backupCode,
107
+ props: {
108
+ isRoot: true,
109
+ },
110
+ });
111
+ }
112
+ }
113
+ catch (err) {
114
+ try {
115
+ await this.deleteAllForUser({ userId: data.userId });
116
+ }
117
+ catch (cleanupError) {
118
+ /*
119
+ * Swallowed so the ORIGINAL failure is what the caller sees. The
120
+ * cleanup error is the less useful of the two -- it explains why the
121
+ * rollback did not happen, not why the write did not.
122
+ */
123
+ logger.error(cleanupError);
124
+ }
125
+ throw err;
126
+ }
127
+ return codes;
128
+ }
129
+ /**
130
+ * Spend one of this user's backup codes, if the submitted code is one of
131
+ * them and has not been used already.
132
+ *
133
+ * ONE STATEMENT, ON PURPOSE
134
+ *
135
+ * The obvious shape -- find the row, check `usedAt`, then update it -- has a
136
+ * window between the read and the write, and "single use" is the entire
137
+ * guarantee a backup code offers. Two sign-in attempts carrying the same
138
+ * code that arrive together would both read a null `usedAt` and both be let
139
+ * in, which is precisely the property an attacker who has watched somebody
140
+ * type a code off a printed list would exploit.
141
+ *
142
+ * `usedAt IS NULL` in the WHERE clause moves the decision inside Postgres,
143
+ * where the row lock settles it: the first statement to reach the row
144
+ * updates it, the second matches nothing. `RETURNING "_id"` is what turns
145
+ * that into an answer for the caller -- an UPDATE that matched no rows and
146
+ * an UPDATE that matched one are otherwise indistinguishable from here.
147
+ *
148
+ * Written as raw parameterized SQL rather than through the ORM because no
149
+ * write path on DatabaseService both takes a non-primary-key predicate and
150
+ * reports what it matched. Column and table names are literals in this file,
151
+ * never caller input, and all three values are bound parameters.
152
+ *
153
+ * `deletedAt IS NULL` is included because soft-deleted rows are still
154
+ * physically present; without it, a code from a set that regeneration
155
+ * replaced would still sign somebody in.
156
+ *
157
+ * @returns true when a code was spent, false when the code was wrong,
158
+ * already used, or belongs to somebody else.
159
+ */
160
+ async consumeCode(data) {
161
+ const normalizedCode = TwoFactorBackupCode.normalizeCode(data.code);
162
+ /*
163
+ * Refused before the query rather than hashed and looked up. An empty
164
+ * submission cannot be anybody's code, and letting it through would mean
165
+ * one round trip per empty request on a route an attacker can call.
166
+ */
167
+ if (!normalizedCode) {
168
+ return false;
169
+ }
170
+ const codeHash = TwoFactorBackupCode.hashCode({
171
+ code: normalizedCode,
172
+ userId: data.userId,
173
+ });
174
+ const rows = await this.getRepository()
175
+ .manager.query(`UPDATE "UserTwoFactorBackupCode"
176
+ SET "usedAt" = $1, "updatedAt" = CURRENT_TIMESTAMP
177
+ WHERE "userId" = $2
178
+ AND "codeHash" = $3
179
+ AND "usedAt" IS NULL
180
+ AND "deletedAt" IS NULL
181
+ RETURNING "_id"`, [OneUptimeDate.getCurrentDate(), data.userId.toString(), codeHash])
182
+ /*
183
+ * For an UPDATE the postgres driver hands back `[rows, rowCount]` rather
184
+ * than a bare row array, so the rows have to be unwrapped. Written
185
+ * defensively: a driver that returns the bare array instead must read as
186
+ * "no code was spent", never as a silent success.
187
+ */
188
+ .then((result) => {
189
+ if (!Array.isArray(result)) {
190
+ return [];
191
+ }
192
+ const first = result[0];
193
+ return Array.isArray(first) ? first : [];
194
+ });
195
+ return rows.length > 0;
196
+ }
197
+ /**
198
+ * How many codes this user has, and how many are still spendable.
199
+ *
200
+ * Counted rather than fetched: the rows carry a credential digest and there
201
+ * is no caller that needs them, so nothing is loaded that a stray log line
202
+ * could then print.
203
+ */
204
+ async getStatusForUser(data) {
205
+ const total = await this.countBy({
206
+ query: {
207
+ userId: data.userId,
208
+ },
209
+ props: {
210
+ isRoot: true,
211
+ },
212
+ });
213
+ if (total.toNumber() === 0) {
214
+ return {
215
+ total: 0,
216
+ unused: 0,
217
+ generatedAt: null,
218
+ };
219
+ }
220
+ const unused = await this.countUnusedForUser({
221
+ userId: data.userId,
222
+ });
223
+ const newest = await this.findOneBy({
224
+ query: {
225
+ userId: data.userId,
226
+ },
227
+ select: {
228
+ createdAt: true,
229
+ },
230
+ sort: {
231
+ createdAt: SortOrder.Descending,
232
+ },
233
+ props: {
234
+ isRoot: true,
235
+ },
236
+ });
237
+ return {
238
+ total: total.toNumber(),
239
+ unused: unused,
240
+ generatedAt: (newest === null || newest === void 0 ? void 0 : newest.createdAt) || null,
241
+ };
242
+ }
243
+ /**
244
+ * How many unused codes this user has left.
245
+ *
246
+ * Split out from `getStatusForUser` because the login path needs exactly
247
+ * this number and nothing else: it decides whether the two factor challenge
248
+ * screen offers "use a backup code" at all, and it is answered on every
249
+ * two-factor sign-in.
250
+ *
251
+ * `usedAt: QueryHelper.isNull()` rather than `usedAt: null`. A bare null
252
+ * predicate is dropped by TypeORM rather than compiled to `IS NULL`, so the
253
+ * count would silently include spent codes and the login page would offer a
254
+ * recovery route to a user with nothing left to recover with.
255
+ */
256
+ async countUnusedForUser(data) {
257
+ const unused = await this.countBy({
258
+ query: {
259
+ userId: data.userId,
260
+ usedAt: QueryHelper.isNull(),
261
+ },
262
+ props: {
263
+ isRoot: true,
264
+ },
265
+ });
266
+ return unused.toNumber();
267
+ }
268
+ /**
269
+ * Drop every backup code this user has.
270
+ *
271
+ * Called by regeneration, and by UserService.resetTwoFactorAuth -- an
272
+ * operator resetting two factor auth for somebody who lost a device must
273
+ * take the recovery codes with it. Leaving them behind would mean the reset
274
+ * did not actually revoke the account's second-factor material, which is the
275
+ * one thing the operator pressed the button to do.
276
+ */
277
+ async deleteAllForUser(data) {
278
+ await this.deleteBy({
279
+ query: {
280
+ userId: data.userId,
281
+ },
282
+ limit: LIMIT_MAX,
283
+ skip: 0,
284
+ props: {
285
+ isRoot: true,
286
+ },
287
+ });
288
+ }
289
+ }
290
+ __decorate([
291
+ CaptureSpan(),
292
+ __metadata("design:type", Function),
293
+ __metadata("design:paramtypes", [Object]),
294
+ __metadata("design:returntype", Promise)
295
+ ], Service.prototype, "onBeforeCreate", null);
296
+ __decorate([
297
+ CaptureSpan(),
298
+ __metadata("design:type", Function),
299
+ __metadata("design:paramtypes", [Object]),
300
+ __metadata("design:returntype", Promise)
301
+ ], Service.prototype, "regenerateForUser", null);
302
+ __decorate([
303
+ CaptureSpan(),
304
+ __metadata("design:type", Function),
305
+ __metadata("design:paramtypes", [Object]),
306
+ __metadata("design:returntype", Promise)
307
+ ], Service.prototype, "consumeCode", null);
308
+ __decorate([
309
+ CaptureSpan(),
310
+ __metadata("design:type", Function),
311
+ __metadata("design:paramtypes", [Object]),
312
+ __metadata("design:returntype", Promise)
313
+ ], Service.prototype, "getStatusForUser", null);
314
+ __decorate([
315
+ CaptureSpan(),
316
+ __metadata("design:type", Function),
317
+ __metadata("design:paramtypes", [Object]),
318
+ __metadata("design:returntype", Promise)
319
+ ], Service.prototype, "countUnusedForUser", null);
320
+ __decorate([
321
+ CaptureSpan(),
322
+ __metadata("design:type", Function),
323
+ __metadata("design:paramtypes", [Object]),
324
+ __metadata("design:returntype", Promise)
325
+ ], Service.prototype, "deleteAllForUser", null);
326
+ export default new Service();
327
+ //# sourceMappingURL=UserTwoFactorBackupCodeService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserTwoFactorBackupCodeService.js","sourceRoot":"","sources":["../../../../Server/Services/UserTwoFactorBackupCodeService.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,MAAM,qDAAqD,CAAC;AACxE,OAAO,mBAAmB,EAAE,EAC1B,iBAAiB,GAClB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,WAAW,MAAM,+BAA+B,CAAC;AACxD,OAAO,gBAAgB,MAAM,wCAAwC,CAAC;AACtE,OAAO,SAAS,MAAM,+BAA+B,CAAC;AACtD,OAAO,SAAS,MAAM,oCAAoC,CAAC;AAG3D,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,WAAW,MAAM,gCAAgC,CAAC;AACzD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAyBrC,MAAM,OAAO,OAAQ,SAAQ,eAAsB;IACjD;QACE,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAED;;;;;;;;;;;OAWG;IAEsB,AAAN,KAAK,CAAC,cAAc,CACrC,QAAyB;QAEzB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YAC1B,MAAM,IAAI,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,IAAI,gBAAgB,CAAC,8BA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D,MAAM,IAAI,CAAC,QAAQ,CAAC;YAClB,KAAK,EAAE;gBACL,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB;YACD,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,CAAC;YACP,KAAK,EAAE;gBACL,MAAM,EAAE,IAAI;aACb;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAtS0B;IADxB,WAAW,EAAE;;;;6CA2Bb;AAsCY;IADZ,WAAW,EAAE;;;;gDA2Cb;AAkCY;IADZ,WAAW,EAAE;;;;0CAiDb;AAUY;IADZ,WAAW,EAAE;;;;+CA6Cb;AAgBY;IADZ,WAAW,EAAE;;;;iDAab;AAYY;IADZ,WAAW,EAAE;;;;+CAYb;AAGH,eAAe,IAAI,OAAO,EAAE,CAAC"}
@@ -0,0 +1,269 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { EncryptionSecret } from "../EnvironmentConfig";
11
+ import CaptureSpan from "./Telemetry/CaptureSpan";
12
+ import crypto from "crypto";
13
+ /*
14
+ * Single-use recovery codes for an account whose second factor is gone --
15
+ * the phone that held the authenticator app, or the security key that is now
16
+ * in a taxi somewhere.
17
+ *
18
+ * WHY THIS IS SERVER-ONLY
19
+ *
20
+ * Nothing in this file falls back to Math.random. Common/Utils/UUID does, on
21
+ * purpose, because it is bundled into the dashboard and has to keep producing
22
+ * well-formed ids in a browser with no Web Crypto -- which is exactly why
23
+ * ObjectID.generate() must never mint a code here. A backup code is a
24
+ * password-equivalent credential; if the platform cannot produce secure
25
+ * randomness, generation must throw rather than quietly emit something
26
+ * predictable. Common/Server/Utils/VerificationCode.ts makes the same call for
27
+ * the same reason.
28
+ *
29
+ * THE CODE SPACE
30
+ *
31
+ * Ten characters drawn uniformly from a 32 symbol alphabet is 2^50 codes, and
32
+ * a user holds ten of them at once -- so a blind guess lands with probability
33
+ * ~10/2^50, about one in 10^14. That is far beyond anything the rate limiter
34
+ * needs to defend, which matters because it settles the design question a TOTP
35
+ * code cannot settle: the six digit space is small enough that the limiter IS
36
+ * the control, whereas here the code itself is.
37
+ *
38
+ * THE HASH
39
+ *
40
+ * Codes are stored as HMAC-SHA256 keyed by the instance's EncryptionSecret,
41
+ * never in the clear, and the fast keyed-digest lane is the RIGHT one here
42
+ * rather than scrypt. scrypt exists to make guessing a low-entropy,
43
+ * human-chosen secret expensive; a code minted above has no low-entropy
44
+ * structure to guess, so the cost would buy nothing and would be paid on every
45
+ * verification. Keying with the EncryptionSecret is what a bare SHA-256 would
46
+ * miss: it lives in configuration rather than in Postgres, so a database dump
47
+ * on its own cannot be run through a dictionary of every possible code.
48
+ *
49
+ * The digest is deterministic given (userId, code), which is deliberate and is
50
+ * what makes single-use consumption a single conditional UPDATE rather than a
51
+ * read of every one of the user's rows followed by a comparison of each. A
52
+ * per-row salt would forfeit that for no gain -- see the note on domain
53
+ * separation below for the property it would have been bought for, which the
54
+ * userId already provides.
55
+ */
56
+ /**
57
+ * Crockford's Base32 alphabet: the digits and the uppercase letters, minus
58
+ * I, L, O and U.
59
+ *
60
+ * These codes get read off a screen and typed back in months later, possibly
61
+ * from a piece of paper in a drawer, so the alphabet is chosen for the eye
62
+ * rather than for density. I/1, L/1 and O/0 are the pairs people transcribe
63
+ * wrongly; U is dropped by Crockford so that no code can spell an obscenity
64
+ * at a user who did nothing to deserve one.
65
+ *
66
+ * Exactly 32 symbols, so each character carries a clean five bits and the
67
+ * entropy arithmetic in the header comment is exact rather than approximate.
68
+ */
69
+ export const BackupCodeAlphabet = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
70
+ /** Characters per code. Ten symbols over a 32 symbol alphabet is 2^50. */
71
+ export const BackupCodeLength = 10;
72
+ /**
73
+ * How many codes a user is issued at once.
74
+ *
75
+ * Ten is enough that losing a phone does not become an emergency after the
76
+ * second sign-in, and small enough that the printed list is one short block a
77
+ * person will actually keep.
78
+ */
79
+ export const BackupCodeSetSize = 10;
80
+ /** Characters per group in the displayed form, e.g. `AB3D5-9XZQ2`. */
81
+ const DISPLAY_GROUP_LENGTH = 5;
82
+ /*
83
+ * Prefixed into every digest so a stored hash is bound to the scheme that
84
+ * produced it. If the construction below ever has to change, old rows keep
85
+ * verifying under the version they were written with instead of silently
86
+ * failing to match and locking a user out of their own recovery codes.
87
+ */
88
+ const HASH_SCHEME_VERSION = "v1";
89
+ /*
90
+ * Characters a person plausibly types in place of a symbol that is not in the
91
+ * alphabet. Applied before the strip below, so `O` becomes `0` rather than
92
+ * being deleted -- deleting it would shorten the code and guarantee a
93
+ * mismatch, which is the confusing failure this map exists to avoid.
94
+ */
95
+ const AMBIGUOUS_CHARACTER_MAP = {
96
+ I: "1",
97
+ L: "1",
98
+ O: "0",
99
+ };
100
+ export default class TwoFactorBackupCode {
101
+ /**
102
+ * One code, drawn uniformly from the alphabet above.
103
+ *
104
+ * `crypto.randomInt` per character rather than `randomBytes(n) % 32`. The
105
+ * modulo version happens to be uniform for this alphabet only because 32
106
+ * divides 256, and it stops being uniform the moment somebody edits the
107
+ * alphabet -- silently, with no test that would notice. `randomInt` rejects
108
+ * out-of-range draws internally for whatever bound it is given, so the
109
+ * uniformity does not depend on a coincidence nobody wrote down.
110
+ */
111
+ static generateCode() {
112
+ let code = "";
113
+ for (let index = 0; index < BackupCodeLength; index++) {
114
+ code += BackupCodeAlphabet.charAt(crypto.randomInt(0, BackupCodeAlphabet.length));
115
+ }
116
+ return code;
117
+ }
118
+ /**
119
+ * A full set of distinct codes.
120
+ *
121
+ * Duplicates are not a security problem -- at 2^50 the birthday odds across
122
+ * ten draws are around 4e-14 -- but a duplicate WOULD be a correctness
123
+ * problem downstream: two rows sharing a digest means consuming one leaves a
124
+ * second, identical, still-valid code behind, so a "single-use" code would
125
+ * work twice. Cheaper to rule out here than to reason about there.
126
+ */
127
+ static generateCodeSet(count = BackupCodeSetSize) {
128
+ const codes = new Set();
129
+ while (codes.size < count) {
130
+ codes.add(TwoFactorBackupCode.generateCode());
131
+ }
132
+ return Array.from(codes);
133
+ }
134
+ /**
135
+ * The form shown to the user: one hyphen in the middle, for the same reason
136
+ * the alphabet drops ambiguous letters -- a ten character run is hard to
137
+ * read back without losing your place.
138
+ *
139
+ * Purely cosmetic. `normalizeCode` strips the hyphen straight back out, so
140
+ * a user may type the code with it, without it, or with the spaces their
141
+ * password manager pasted in.
142
+ */
143
+ static formatForDisplay(code) {
144
+ const groups = [];
145
+ for (let index = 0; index < code.length; index += DISPLAY_GROUP_LENGTH) {
146
+ groups.push(code.substring(index, index + DISPLAY_GROUP_LENGTH));
147
+ }
148
+ return groups.join("-");
149
+ }
150
+ /**
151
+ * Reduce whatever the user typed to the canonical form the digest is
152
+ * computed over.
153
+ *
154
+ * Everything here is about not rejecting somebody who supplied exactly the
155
+ * right secret material: the display hyphen, the spaces a clipboard adds,
156
+ * lowercase from a phone keyboard, and the three transcription confusions
157
+ * the alphabet was chosen to make survivable. Anything still outside the
158
+ * alphabet after that is dropped rather than rejected -- this is a
159
+ * canonicaliser, not a validator; the digest comparison is what decides
160
+ * whether a code is real.
161
+ *
162
+ * @param rawCode - The code exactly as submitted.
163
+ * @returns The code reduced to alphabet symbols, uppercase.
164
+ */
165
+ static normalizeCode(rawCode) {
166
+ /*
167
+ * The code arrives straight off a JSON body, so it is only a string
168
+ * because the client chose to send one. A number or an object here must
169
+ * fail verification, not throw out of `.toUpperCase` and surface as a 500.
170
+ */
171
+ if (typeof rawCode !== "string" || !rawCode) {
172
+ return "";
173
+ }
174
+ let normalized = "";
175
+ for (const character of rawCode.toUpperCase()) {
176
+ const mapped = AMBIGUOUS_CHARACTER_MAP[character] || character;
177
+ if (BackupCodeAlphabet.includes(mapped)) {
178
+ normalized += mapped;
179
+ }
180
+ }
181
+ return normalized;
182
+ }
183
+ /**
184
+ * The digest stored for one of `userId`'s codes.
185
+ *
186
+ * Domain separated by the owning user, which is what stops one precomputed
187
+ * table from inverting every account's codes at once and stops two users who
188
+ * happen to be issued the same code from being visibly linked by a matching
189
+ * row. The user id is known at verification time -- the password has already
190
+ * been accepted by then -- so binding to it costs nothing.
191
+ *
192
+ * Both parts are LENGTH-PREFIXED into the message rather than merely
193
+ * concatenated, so no pair of (userId, code) values can be rearranged into
194
+ * the same byte string as another pair. Concatenation alone is a real
195
+ * ambiguity, not a theoretical one: without prefixes, ("ab", "cd") and
196
+ * ("abc", "d") hash identically.
197
+ */
198
+ static hashCode(data) {
199
+ const message = [
200
+ HASH_SCHEME_VERSION,
201
+ data.userId.toString(),
202
+ TwoFactorBackupCode.normalizeCode(data.code),
203
+ ]
204
+ .map((part) => {
205
+ return `${part.length}:${part}`;
206
+ })
207
+ .join("");
208
+ return crypto
209
+ .createHmac("sha256", EncryptionSecret.toString())
210
+ .update(message)
211
+ .digest("hex");
212
+ }
213
+ /**
214
+ * Compare two digests without leaking, through timing, how many leading
215
+ * characters matched.
216
+ *
217
+ * The consume path compares digests in Postgres rather than here, so this is
218
+ * for callers that already hold both -- but it exists so that nobody writing
219
+ * one reaches for `===` and hands an attacker a way to recover a stored hash
220
+ * one character at a time.
221
+ *
222
+ * Lengths are compared first because `crypto.timingSafeEqual` THROWS on a
223
+ * length mismatch. Digests here are always 64 hex characters, so an early
224
+ * exit only happens on malformed input, where the length is not the secret.
225
+ */
226
+ static isHashEqual(a, b) {
227
+ if (!a || !b || a.length !== b.length) {
228
+ return false;
229
+ }
230
+ return crypto.timingSafeEqual(Buffer.from(a, "utf8"), Buffer.from(b, "utf8"));
231
+ }
232
+ }
233
+ __decorate([
234
+ CaptureSpan(),
235
+ __metadata("design:type", Function),
236
+ __metadata("design:paramtypes", []),
237
+ __metadata("design:returntype", String)
238
+ ], TwoFactorBackupCode, "generateCode", null);
239
+ __decorate([
240
+ CaptureSpan(),
241
+ __metadata("design:type", Function),
242
+ __metadata("design:paramtypes", [Number]),
243
+ __metadata("design:returntype", Array)
244
+ ], TwoFactorBackupCode, "generateCodeSet", null);
245
+ __decorate([
246
+ CaptureSpan(),
247
+ __metadata("design:type", Function),
248
+ __metadata("design:paramtypes", [String]),
249
+ __metadata("design:returntype", String)
250
+ ], TwoFactorBackupCode, "formatForDisplay", null);
251
+ __decorate([
252
+ CaptureSpan(),
253
+ __metadata("design:type", Function),
254
+ __metadata("design:paramtypes", [String]),
255
+ __metadata("design:returntype", String)
256
+ ], TwoFactorBackupCode, "normalizeCode", null);
257
+ __decorate([
258
+ CaptureSpan(),
259
+ __metadata("design:type", Function),
260
+ __metadata("design:paramtypes", [Object]),
261
+ __metadata("design:returntype", String)
262
+ ], TwoFactorBackupCode, "hashCode", null);
263
+ __decorate([
264
+ CaptureSpan(),
265
+ __metadata("design:type", Function),
266
+ __metadata("design:paramtypes", [String, String]),
267
+ __metadata("design:returntype", Boolean)
268
+ ], TwoFactorBackupCode, "isHashEqual", null);
269
+ //# sourceMappingURL=TwoFactorBackupCode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TwoFactorBackupCode.js","sourceRoot":"","sources":["../../../../Server/Utils/TwoFactorBackupCode.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,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EAAE,CAAC;aACjD,MAAM,CAAC,OAAO,CAAC;aACf,MAAM,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;IAED;;;;;;;;;;;;OAYG;IAEW,AAAP,MAAM,CAAC,WAAW,CAAC,CAAS,EAAE,CAAS;QAC5C,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;YACtC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,MAAM,CAAC,eAAe,CAC3B,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,EACtB,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CACvB,CAAC;IACJ,CAAC;CACF;AA1Je;IADb,WAAW,EAAE;;;;6CAWb;AAYa;IADb,WAAW,EAAE;;;oCAGX,KAAK;gDAQP;AAYa;IADb,WAAW,EAAE;;;;iDAab;AAkBa;IADb,WAAW,EAAE;;;;8CAsBb;AAkBa;IADb,WAAW,EAAE;;;;yCAgBb;AAgBa;IADb,WAAW,EAAE;;;;4CAUb"}
@@ -11,6 +11,8 @@ var EmailTemplateType;
11
11
  EmailTemplateType["ConfirmStatusPageSubscription"] = "ConfirmStatusPageSubscription.hbs";
12
12
  EmailTemplateType["EmailVerified"] = "EmailVerified.hbs";
13
13
  EmailTemplateType["PasswordChanged"] = "PasswordChanged.hbs";
14
+ EmailTemplateType["TwoFactorBackupCodeUsed"] = "TwoFactorBackupCodeUsed.hbs";
15
+ EmailTemplateType["TwoFactorBackupCodesRegenerated"] = "TwoFactorBackupCodesRegenerated.hbs";
14
16
  EmailTemplateType["ProbeOwnerAdded"] = "ProbeOwnerAdded.hbs";
15
17
  EmailTemplateType["InviteMember"] = "InviteMember.hbs";
16
18
  EmailTemplateType["EmailChanged"] = "EmailChanged.hbs";
@@ -1 +1 @@
1
- {"version":3,"file":"EmailTemplateType.js","sourceRoot":"","sources":["../../../../Types/Email/EmailTemplateType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AAA;IACzD,wFAAmE,CAAA;IACnE,sFAAiE,CAAA;IAEjE,oGAA+E,CAAA;IAC/E,0FAAqE,CAAA;IACrE,wGAAmF,CAAA;IACnF,8GAAyF,CAAA;IACzF,oHAA+F,CAAA;IAC/F,0FAAqE,CAAA;IACrE,sEAAiD,CAAA;IACjD,gGAA2E,CAAA;IAC3E,wDAAmC,CAAA;IACnC,8DAAyC,CAAA;IACzC,oEAA+C,CAAA;IAC/C,8DAAyC,CAAA;IACzC,4EAAuD,CAAA;IACvD,kFAA6D,CAAA;IAE7D,4EAAuD,CAAA;IACvD,oFAA+D,CAAA;IAC/D,oFAA+D,CAAA;IAC/D,0EAAqD,CAAA;IACrD,8FAAyE,CAAA;IAEzE,kFAA6D,CAAA;IAC7D,4CAAuB,CAAA;IAEvB,gFAA2D,CAAA;IAC3D,kEAA6C,CAAA;IAC7C,wEAAmD,CAAA;IAEnD,8FAAyE,CAAA;IACzE,4FAAuE,CAAA;AACzE,CAAC,EAhGI,iBAAiB,KAAjB,iBAAiB,QAgGrB;AAED,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"EmailTemplateType.js","sourceRoot":"","sources":["../../../../Types/Email/EmailTemplateType.ts"],"names":[],"mappings":"AAAA,IAAK,iBAkGJ;AAlGD,WAAK,iBAAiB;IACpB,wDAAmC,CAAA;IACnC,0DAAqC,CAAA;IACrC,sDAAiC,CAAA;IACjC,kEAA6C,CAAA;IAC7C,sEAAiD,CAAA;IACjD,oFAA+D,CAAA;IAC/D,wFAAmE,CAAA;IACnE,gEAA2C,CAAA;IAC3C,wFAAmE,CAAA;IACnE,wDAAmC,CAAA;IACnC,4DAAuC,CAAA;IACvC,4EAAuD,CAAA;IACvD,4FAAuE,CAAA;IACvE,4DAAuC,CAAA;IACvC,sDAAiC,CAAA;IACjC,sDAAiC,CAAA;IACjC,0EAAqD,CAAA;IACrD,wFAAmE,CAAA;IACnE,gFAA2D,CAAA;IAC3D,oGAA+E,CAAA;IAC/E,kFAA6D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,kFAA6D,CAAA;IAC7D,4CAAuB,CAAA;IAEvB,gFAA2D,CAAA;IAC3D,kEAA6C,CAAA;IAC7C,wEAAmD,CAAA;IAEnD,8FAAyE,CAAA;IACzE,4FAAuE,CAAA;AACzE,CAAC,EAlGI,iBAAiB,KAAjB,iBAAiB,QAkGrB;AAED,eAAe,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneuptime/common",
3
- "version": "12.0.21",
3
+ "version": "12.0.22",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",