brand the persisted account did as DidString
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import {type DidString} from '@atproto/syntax'
|
||||||
import {z} from 'zod'
|
import {z} from 'zod'
|
||||||
|
|
||||||
import {deviceLanguageCodes, deviceLocales} from '#/locale/deviceLocales'
|
import {deviceLanguageCodes, deviceLocales} from '#/locale/deviceLocales'
|
||||||
@@ -13,7 +14,12 @@ const externalEmbedOptions = ['show', 'hide'] as const
|
|||||||
*/
|
*/
|
||||||
const accountSchema = z.object({
|
const accountSchema = z.object({
|
||||||
service: z.string(),
|
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(),
|
handle: z.string(),
|
||||||
email: z.string().optional(),
|
email: z.string().optional(),
|
||||||
emailConfirmed: z.boolean().optional(),
|
emailConfirmed: z.boolean().optional(),
|
||||||
|
|||||||
Reference in New Issue
Block a user