2024-10-13 15:25:30 -07:00
|
|
|
import * as v from 'valibot';
|
2024-08-28 04:43:23 -07:00
|
|
|
|
2024-10-16 08:03:27 -07:00
|
|
|
import { datetimeSchema } from './utils';
|
|
|
|
|
2024-10-29 14:44:28 -07:00
|
|
|
/**
|
|
|
|
* @category Schemas
|
|
|
|
* @see {@link https://docs.pleroma.social/backend/development/API/pleroma_api/#get-apioauth_tokens}
|
|
|
|
*/
|
2024-10-15 16:08:56 -07:00
|
|
|
const oauthTokenSchema = v.pipe(
|
|
|
|
v.any(),
|
|
|
|
v.transform((token: any) => ({
|
|
|
|
...token,
|
|
|
|
valid_until: token?.valid_until?.padEnd(27, 'Z'),
|
|
|
|
})),
|
|
|
|
v.object({
|
|
|
|
app_name: v.string(),
|
|
|
|
id: v.number(),
|
2024-10-16 08:03:27 -07:00
|
|
|
valid_until: datetimeSchema,
|
2024-10-15 16:08:56 -07:00
|
|
|
}),
|
|
|
|
);
|
2024-08-28 04:43:23 -07:00
|
|
|
|
2024-10-13 15:25:30 -07:00
|
|
|
type OauthToken = v.InferOutput<typeof oauthTokenSchema>;
|
2024-08-28 04:43:23 -07:00
|
|
|
|
|
|
|
export { oauthTokenSchema, type OauthToken };
|