Add auth schemas
This commit is contained in:
parent
943c5fddee
commit
02d599beab
|
@ -0,0 +1,20 @@
|
||||||
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
import { tokenSchema } from 'soapbox/schemas/token';
|
||||||
|
import { coerceObject, filteredArray } from 'soapbox/schemas/utils';
|
||||||
|
|
||||||
|
const authUserSchema = z.object({
|
||||||
|
access_token: z.string(),
|
||||||
|
id: z.string(),
|
||||||
|
url: z.string().url(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const soapboxAuthSchema = coerceObject({
|
||||||
|
tokens: filteredArray(tokenSchema),
|
||||||
|
users: filteredArray(authUserSchema),
|
||||||
|
me: z.string().url().nullable().catch(null),
|
||||||
|
});
|
||||||
|
|
||||||
|
type SoapboxAuth = z.infer<typeof soapboxAuthSchema>;
|
||||||
|
|
||||||
|
export { soapboxAuthSchema, SoapboxAuth };
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
const tokenSchema = z.object({
|
||||||
|
access_token: z.string(),
|
||||||
|
token_type: z.string(),
|
||||||
|
scope: z.string(),
|
||||||
|
created_at: z.number(),
|
||||||
|
});
|
||||||
|
|
||||||
|
type Token = z.infer<typeof tokenSchema>;
|
||||||
|
|
||||||
|
export { tokenSchema, Token };
|
Loading…
Reference in New Issue