2024-10-13 15:25:30 -07:00
|
|
|
import * as v from 'valibot';
|
2024-08-28 04:43:23 -07:00
|
|
|
|
2024-10-29 14:44:28 -07:00
|
|
|
/**
|
|
|
|
* @category Schemas
|
|
|
|
* @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-10-14 11:54:44 -07:00
|
|
|
created_at: v.fallback(v.optional(v.number()), undefined),
|
2024-08-28 04:43:23 -07:00
|
|
|
|
2024-11-26 09:46:44 -08:00
|
|
|
id: v.fallback(v.optional(v.pipe(v.unknown(), v.transform(String))), undefined),
|
2024-10-13 15:25:30 -07:00
|
|
|
refresh_token: v.fallback(v.optional(v.string()), undefined),
|
2024-10-14 11:54:44 -07:00
|
|
|
expires_in: v.fallback(v.optional(v.number()), 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-11-29 07:01:54 -08:00
|
|
|
/**
|
|
|
|
* @category Entity types
|
|
|
|
*/
|
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 };
|