2024-10-13 15:25:30 -07:00
|
|
|
import * as v from 'valibot';
|
2024-08-28 04:43:23 -07:00
|
|
|
|
|
|
|
/** @see {@link https://docs.joinmastodon.org/entities/Token/} */
|
2024-10-13 15:25:30 -07:00
|
|
|
const tokenSchema = v.object({
|
|
|
|
access_token: v.string(),
|
|
|
|
token_type: v.string(),
|
|
|
|
scope: v.string(),
|
2024-08-28 04:43:23 -07:00
|
|
|
created_at: z.number().optional().catch(undefined),
|
|
|
|
|
|
|
|
id: z.number().optional().catch(undefined),
|
2024-10-13 15:25:30 -07:00
|
|
|
refresh_token: v.fallback(v.optional(v.string()), undefined),
|
2024-08-28 04:43:23 -07:00
|
|
|
expires_in: z.number().optional().catch(undefined),
|
2024-10-13 15:25:30 -07:00
|
|
|
me: v.fallback(v.optional(v.string()), undefined),
|
2024-08-28 04:43:23 -07:00
|
|
|
});
|
|
|
|
|
2024-10-13 15:25:30 -07:00
|
|
|
type Token = v.InferOutput<typeof tokenSchema>;
|
2024-08-28 04:43:23 -07:00
|
|
|
|
|
|
|
export { tokenSchema, type Token };
|