@smplcty/auth 0.2.0 → 0.2.1

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
@@ -177,25 +177,71 @@ Twilio's Verify service doesn't deliver SMS to every carrier reliably (especiall
177
177
 
178
178
  `@smplcty/auth` ships per-developer TOTP enrollment for exactly this case. Each enrolled dev has their own time-based one-time password secret stored in `dev_otp_enrollments`, scanned into a standard authenticator app (1Password, Authy, Google Authenticator, etc.). The sign-in-verify handler tries the dev OTP first; if it doesn't match, it falls through to Twilio.
179
179
 
180
- ### Verifying a dev OTP
180
+ ### How the codes are distinguished from Twilio codes
181
+
182
+ **They aren't, by format.** A 6-digit TOTP code from an authenticator app is indistinguishable from a 6-digit SMS code from Twilio. Users type whatever they have into the same input field. The backend figures out which one was used by **trying dev OTP first, then falling through to Twilio**.
183
+
184
+ The 1-in-1,000,000 collision risk between a wrong Twilio code and the user's current TOTP is negligible, and the audit trail (`dev_otp_enrollments.last_used_at` + `used_count`) lets you tell after the fact which path succeeded for any given sign-in.
185
+
186
+ ### Send side: skip Twilio for dev-enrolled users
187
+
188
+ When a user is enrolled in dev OTP, you don't need to send them an SMS at all — they'll generate their code from their authenticator app. Use `isDevOtpEnrolled` to skip the Twilio call:
181
189
 
182
190
  ```ts
183
- import { verifyDevOtp } from '@smplcty/auth';
191
+ import { findUserByCommunicationMethod, isDevOtpEnrolled } from '@smplcty/auth';
192
+ import { createTwilioVerifyClient } from '@smplcty/twilio';
193
+
194
+ const twilio = createTwilioVerifyClient({ /* ... */ });
184
195
 
185
- // In your sign-in-verify handler, AFTER looking up the user:
186
- const ok = await verifyDevOtp(db, userCommunicationMethodId, submittedCode);
187
- if (ok) {
188
- // Log an audit event with phone, IP, timestamp.
189
- return createSession(db, { userCommunicationMethodId, ttl: '30 days', ip, geo });
196
+ // Sign-in send handler:
197
+ const lookup = await findUserByCommunicationMethod(db, { channel: 'phone', code: phone });
198
+ if (!lookup) {
199
+ // User not registered. Return success anyway to avoid the enumeration oracle.
200
+ return ok();
190
201
  }
191
202
 
192
- // Fall through to Twilio Verify
193
- const verified = await verifyVerificationCode(to, submittedCode);
194
- if (verified) {
195
- return createSession(db, { ... });
203
+ const enrolled = await isDevOtpEnrolled(db, lookup.userCommunicationMethodId);
204
+ if (!enrolled) {
205
+ // Normal user — send the SMS code.
206
+ await twilio.sendVerificationCode({ channel: 'sms', to: phone });
196
207
  }
208
+ // Dev-enrolled user gets the same response shape with no SMS — they
209
+ // already know to open their authenticator app.
197
210
 
198
- return { statusCode: 400, body: 'Invalid code' };
211
+ return ok();
212
+ ```
213
+
214
+ `isDevOtpEnrolled(db, userCommunicationMethodId)` returns `boolean`. Cheap one-row lookup. Throws `InvalidInputError` if the id is malformed.
215
+
216
+ ### Verify side: try dev OTP first, fall through to Twilio
217
+
218
+ ```ts
219
+ import { verifyDevOtp, createSession, findUserByCommunicationMethod } from '@smplcty/auth';
220
+ import { createTwilioVerifyClient } from '@smplcty/twilio';
221
+
222
+ const twilio = createTwilioVerifyClient({ /* ... */ });
223
+
224
+ // Sign-in verify handler:
225
+ const lookup = await findUserByCommunicationMethod(db, { channel: 'phone', code: phone });
226
+ if (!lookup) return badRequest('Invalid code');
227
+
228
+ // 1. Try dev OTP first.
229
+ const devOk = await verifyDevOtp(db, lookup.userCommunicationMethodId, submittedCode);
230
+ if (devOk) {
231
+ // dev_otp_enrollments.last_used_at and used_count have been updated
232
+ // — that's your built-in audit signal that the dev path was taken.
233
+ return await createSessionResponse(db, lookup, ip, geo);
234
+ }
235
+
236
+ // 2. Fall through to Twilio. For users without a dev enrollment this
237
+ // is the only path; for users with one whose code didn't match (e.g.
238
+ // they happened to type the SMS code), this is the fallback.
239
+ const twilioOk = await twilio.verifyVerificationCode({ to: phone, code: submittedCode });
240
+ if (twilioOk) {
241
+ return await createSessionResponse(db, lookup, ip, geo);
242
+ }
243
+
244
+ return badRequest('Invalid code');
199
245
  ```
200
246
 
201
247
  `verifyDevOtp` returns `false` (does not throw) when:
@@ -205,6 +251,8 @@ return { statusCode: 400, body: 'Invalid code' };
205
251
 
206
252
  On success it updates the enrollment row's `last_used_at` and `used_count`, giving you a built-in audit signal that the dev OTP path was taken.
207
253
 
254
+ Both `verifyDevOtp` and `isDevOtpEnrolled` return `false` regardless of whether the user is enrolled or not (just with different conditions), so neither leaks enrollment status to the caller.
255
+
208
256
  ### Enrolling a dev
209
257
 
210
258
  There's no shipped CLI — at the team sizes this library is designed for, manual enrollment via SQL is fine and explicit. Here's the recipe:
package/dist/dev-otp.d.ts CHANGED
@@ -29,6 +29,28 @@ import type { Queryable } from './types.js';
29
29
  * positive integer or `code` is not a non-empty string.
30
30
  */
31
31
  export declare function verifyDevOtp(db: Queryable, userCommunicationMethodId: number, code: string): Promise<boolean>;
32
+ /**
33
+ * Check whether a user_communication_method has a dev OTP enrollment.
34
+ *
35
+ * Use this on the **send** side of a sign-in flow to skip the Twilio
36
+ * SMS send for dev-enrolled users — they'll generate their code from
37
+ * an authenticator app instead, so the SMS would be wasted (and may
38
+ * not deliver anyway, which is the whole reason they're enrolled in
39
+ * dev OTP).
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const enrolled = await isDevOtpEnrolled(db, user.userCommunicationMethodId);
44
+ * if (!enrolled) {
45
+ * await twilio.sendVerificationCode({ channel: 'sms', to });
46
+ * }
47
+ * return ok(); // dev users get the same response shape; the verify
48
+ * // step will accept their TOTP code
49
+ * ```
50
+ *
51
+ * @throws {InvalidInputError} If `userCommunicationMethodId` is not a positive integer.
52
+ */
53
+ export declare function isDevOtpEnrolled(db: Queryable, userCommunicationMethodId: number): Promise<boolean>;
32
54
  /**
33
55
  * Generate a fresh base32-encoded TOTP secret suitable for storing in
34
56
  * the `dev_otp_enrollments.totp_secret` column.
@@ -1 +1 @@
1
- {"version":3,"file":"dev-otp.d.ts","sourceRoot":"","sources":["../src/dev-otp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAqC5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,YAAY,CAChC,EAAE,EAAE,SAAS,EACb,yBAAyB,EAAE,MAAM,EACjC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,CA2ClB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,MAAM,CAeT"}
1
+ {"version":3,"file":"dev-otp.d.ts","sourceRoot":"","sources":["../src/dev-otp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AA4C5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,YAAY,CAChC,EAAE,EAAE,SAAS,EACb,yBAAyB,EAAE,MAAM,EACjC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,CAwClB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,SAAS,EACb,yBAAyB,EAAE,MAAM,GAChC,OAAO,CAAC,OAAO,CAAC,CAalB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,MAAM,CAeT"}
package/dist/dev-otp.js CHANGED
@@ -17,6 +17,12 @@ const SELECT_ENROLLMENT = `
17
17
  FROM dev_otp_enrollments
18
18
  WHERE user_communication_method_id = $1
19
19
  `;
20
+ const SELECT_ENROLLMENT_EXISTS = `
21
+ SELECT 1
22
+ FROM dev_otp_enrollments
23
+ WHERE user_communication_method_id = $1
24
+ LIMIT 1
25
+ `;
20
26
  const RECORD_USE = `
21
27
  UPDATE dev_otp_enrollments
22
28
  SET last_used_at = now(),
@@ -67,14 +73,15 @@ export async function verifyDevOtp(db, userCommunicationMethodId, code) {
67
73
  if (!enrollment) {
68
74
  return false;
69
75
  }
70
- let valid = false;
71
76
  try {
72
77
  const result = verifySync({
73
78
  secret: enrollment.totpSecret,
74
79
  token: code,
75
80
  epochTolerance: EPOCH_TOLERANCE_SECONDS,
76
81
  });
77
- valid = result.valid;
82
+ if (!result.valid) {
83
+ return false;
84
+ }
78
85
  }
79
86
  catch {
80
87
  // otplib throws on malformed secrets or non-numeric tokens — treat
@@ -83,12 +90,40 @@ export async function verifyDevOtp(db, userCommunicationMethodId, code) {
83
90
  // the consumer's audit pipeline.
84
91
  return false;
85
92
  }
86
- if (!valid) {
87
- return false;
88
- }
89
93
  await db.query(RECORD_USE, [userCommunicationMethodId]);
90
94
  return true;
91
95
  }
96
+ /**
97
+ * Check whether a user_communication_method has a dev OTP enrollment.
98
+ *
99
+ * Use this on the **send** side of a sign-in flow to skip the Twilio
100
+ * SMS send for dev-enrolled users — they'll generate their code from
101
+ * an authenticator app instead, so the SMS would be wasted (and may
102
+ * not deliver anyway, which is the whole reason they're enrolled in
103
+ * dev OTP).
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * const enrolled = await isDevOtpEnrolled(db, user.userCommunicationMethodId);
108
+ * if (!enrolled) {
109
+ * await twilio.sendVerificationCode({ channel: 'sms', to });
110
+ * }
111
+ * return ok(); // dev users get the same response shape; the verify
112
+ * // step will accept their TOTP code
113
+ * ```
114
+ *
115
+ * @throws {InvalidInputError} If `userCommunicationMethodId` is not a positive integer.
116
+ */
117
+ export async function isDevOtpEnrolled(db, userCommunicationMethodId) {
118
+ if (!Number.isInteger(userCommunicationMethodId) ||
119
+ userCommunicationMethodId <= 0) {
120
+ throw new InvalidInputError('userCommunicationMethodId must be a positive integer');
121
+ }
122
+ const { rowCount } = await db.query(SELECT_ENROLLMENT_EXISTS, [
123
+ userCommunicationMethodId,
124
+ ]);
125
+ return (rowCount ?? 0) > 0;
126
+ }
92
127
  /**
93
128
  * Generate a fresh base32-encoded TOTP secret suitable for storing in
94
129
  * the `dev_otp_enrollments.totp_secret` column.
@@ -1 +1 @@
1
- {"version":3,"file":"dev-otp.js","sourceRoot":"","sources":["../src/dev-otp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,mEAAmE;AACnE,sEAAsE;AACtE,qEAAqE;AACrE,6DAA6D;AAC7D,oCAAoC;AACpC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,MAAM,iBAAiB,GAAG;;;;;;;;;;CAUzB,CAAC;AAEF,MAAM,UAAU,GAAG;;;;;CAKlB,CAAC;AAWF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,EAAa,EACb,yBAAiC,EACjC,IAAY;IAEZ,IACE,CAAC,MAAM,CAAC,SAAS,CAAC,yBAAyB,CAAC;QAC5C,yBAAyB,IAAI,CAAC,EAC9B,CAAC;QACD,MAAM,IAAI,iBAAiB,CACzB,sDAAsD,CACvD,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,iBAAiB,CAAC,iCAAiC,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC,KAAK,CAAgB,iBAAiB,EAAE;QAChE,yBAAyB;KAC1B,CAAC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AAC,KAItC;IACC,IAAI,OAAO,KAAK,EAAE,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnE,MAAM,IAAI,iBAAiB,CAAC,mCAAmC,CAAC,CAAC;IACnE,CAAC;IACD,IAAI,OAAO,KAAK,EAAE,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjE,MAAM,IAAI,iBAAiB,CAAC,kCAAkC,CAAC,CAAC;IAClE,CAAC;IACD,IAAI,OAAO,KAAK,EAAE,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnE,MAAM,IAAI,iBAAiB,CAAC,mCAAmC,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,WAAW,CAAC;QACjB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,MAAM,EAAE,KAAK,CAAC,MAAM;KACrB,CAAC,CAAC;AACL,CAAC"}
package/dist/index.d.ts CHANGED
@@ -7,5 +7,5 @@ export { findUserByCommunicationMethod } from './find-user-by-communication-meth
7
7
  export { withSession } from './with-session.js';
8
8
  export { withTransaction } from './with-transaction.js';
9
9
  export { setSessionId, setRoleName, setTenantIds, setAllTenants, setSessionContext, SESSION_VAR_NAMES, } from './set-helpers.js';
10
- export { verifyDevOtp, generateDevOtpSecret, getDevOtpEnrollmentUri, } from './dev-otp.js';
10
+ export { verifyDevOtp, isDevOtpEnrolled, generateDevOtpSecret, getDevOtpEnrollmentUri, } from './dev-otp.js';
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,GAClB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E,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,OAAO,EACL,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -11,5 +11,5 @@ export { withTransaction } from './with-transaction.js';
11
11
  // Low-level helpers — must be called inside an open transaction.
12
12
  export { setSessionId, setRoleName, setTenantIds, setAllTenants, setSessionContext, SESSION_VAR_NAMES, } from './set-helpers.js';
13
13
  // Developer OTP — for devs whose phones can't receive Twilio SMS.
14
- export { verifyDevOtp, generateDevOtpSecret, getDevOtpEnrollmentUri, } from './dev-otp.js';
14
+ export { verifyDevOtp, isDevOtpEnrolled, generateDevOtpSecret, getDevOtpEnrollmentUri, } from './dev-otp.js';
15
15
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAgBrB,oBAAoB;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF,wBAAwB;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,iEAAiE;AACjE,OAAO,EACL,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,kEAAkE;AAClE,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAgBrB,oBAAoB;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF,wBAAwB;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,iEAAiE;AACjE,OAAO,EACL,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,kEAAkE;AAClE,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smplcty/auth",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Robust, type-safe session and role-based authentication primitives for PostgreSQL apps using Row-Level Security.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -57,12 +57,14 @@
57
57
  "pg": ">=8.0.0"
58
58
  },
59
59
  "devDependencies": {
60
+ "@eslint/js": "^10.0.1",
60
61
  "@smplcty/schema-flow": "^0.3.7",
61
62
  "@types/node": "^25.5.2",
62
63
  "@types/pg": "^8.20.0",
63
64
  "eslint": "^10.2.0",
64
65
  "pg": "^8.20.0",
65
66
  "typescript": "^6.0.2",
67
+ "typescript-eslint": "^8.58.1",
66
68
  "vitest": "^4.1.4"
67
69
  },
68
70
  "dependencies": {