work-in-progress atproto PDS
typescript atproto pds atcute

refactor: normalize TOTP/security key name whitespace

mary.my.id 08123f8c 1d3a8a01

verified
+5 -6
+2 -1
packages/danaus/src/web/controllers/account/security/totp/lib/forms.ts
··· 5 5 import * as v from 'valibot'; 6 6 7 7 import { decodeSecret, verifyTotpCode } from '#app/accounts/totp.ts'; 8 + import { normalizeWhitespace } from '#app/utils/schema.ts'; 8 9 import { requireSudo } from '#app/web/lib/forms.ts'; 9 10 10 11 import { getAppContext } from '#web/middlewares/app-context.ts'; ··· 16 17 */ 17 18 export const setupTotpForm = form( 18 19 v.object({ 19 - name: v.optional(v.pipe(v.string(), v.maxLength(32, `Name is too long`))), 20 + name: v.optional(v.pipe(v.string(), normalizeWhitespace, v.maxLength(32, `Name is too long`))), 20 21 secret: v.pipe(v.string(), v.minLength(1)), 21 22 _code: v.pipe(v.string(), v.length(6, `Enter the 6-digit code`)), 22 23 }),
+3 -5
packages/danaus/src/web/controllers/account/security/webauthn/lib/forms.ts
··· 6 6 import * as v from 'valibot'; 7 7 8 8 import { WebAuthnCredentialType } from '#app/accounts/db/schema.ts'; 9 - import { 10 - generateWebAuthnRegistrationOptions, 11 - verifyWebAuthnRegistration, 12 - } from '#app/accounts/webauthn.ts'; 9 + import { generateWebAuthnRegistrationOptions, verifyWebAuthnRegistration } from '#app/accounts/webauthn.ts'; 10 + import { normalizeWhitespace } from '#app/utils/schema.ts'; 13 11 import { requireSudo } from '#app/web/lib/forms.ts'; 14 12 15 13 import { getAppContext } from '#web/middlewares/app-context.ts'; ··· 81 79 export const completeWebAuthnForm = form( 82 80 v.object({ 83 81 token: v.pipe(v.string(), v.minLength(1)), 84 - name: v.optional(v.pipe(v.string(), v.maxLength(32, `Name is too long`))), 82 + name: v.optional(v.pipe(v.string(), normalizeWhitespace, v.maxLength(32, `Name is too long`))), 85 83 response: v.pipe(v.string(), v.minLength(1), v.parseJson(), registrationResponseSchema), 86 84 }), 87 85 async (data, issue) => {