tangled
alpha
login
or
join now
mary.my.id
/
danaus
4
fork
atom
work-in-progress atproto PDS
typescript
atproto
pds
atcute
4
fork
atom
overview
issues
pulls
pipelines
refactor: normalize TOTP/security key name whitespace
mary.my.id
1 month ago
08123f8c
1d3a8a01
verified
This commit was signed with the committer's
known signature
.
mary.my.id
SSH Key Fingerprint:
SHA256:ZlTP/auFSGpGnaoDg4mCTG1g9OZvXp62jWR4c6H4O3c=
+5
-6
2 changed files
expand all
collapse all
unified
split
packages
danaus
src
web
controllers
account
security
totp
lib
forms.ts
webauthn
lib
forms.ts
+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
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
19
-
name: v.optional(v.pipe(v.string(), v.maxLength(32, `Name is too long`))),
20
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
9
-
import {
10
10
-
generateWebAuthnRegistrationOptions,
11
11
-
verifyWebAuthnRegistration,
12
12
-
} from '#app/accounts/webauthn.ts';
9
9
+
import { generateWebAuthnRegistrationOptions, verifyWebAuthnRegistration } from '#app/accounts/webauthn.ts';
10
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
84
-
name: v.optional(v.pipe(v.string(), v.maxLength(32, `Name is too long`))),
82
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) => {