brand the persisted account did as DidString

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Samuel Newman
2026-08-04 10:50:12 +03:00
parent d191224474
commit 6d23db4e3b
+7 -1
View File
@@ -1,3 +1,4 @@
import {type DidString} from '@atproto/syntax'
import {z} from 'zod'
import {deviceLanguageCodes, deviceLocales} from '#/locale/deviceLocales'
@@ -13,7 +14,12 @@ const externalEmbedOptions = ['show', 'hide'] as const
*/
const accountSchema = z.object({
service: z.string(),
did: z.string(),
/*
* Branded at the type level only. The runtime check stays a bare `z.string()`
* so already-persisted accounts can never fail validation over the brand,
* which would log the user out on upgrade.
*/
did: z.string() as unknown as z.ZodType<DidString>,
handle: z.string(),
email: z.string().optional(),
emailConfirmed: z.boolean().optional(),