feat: replace browser login with imported Reddit sessions
This commit is contained in:
1 parent
2b0545afcf
commit
c483c7b8be
76 files changed
+2048
-2828
No files matched your search
@@ -6,18 +6,13 @@ export const RedditSessionStateSchema = z.union([
|
||||
z.literal('login-required'),
|
||||
z.literal('unreachable'),
|
||||
]);
|
||||
export const LoginInfoResponseSchema = z.strictObject({
|
||||
vncEnabled: z.boolean(),
|
||||
novncPort: z.number(),
|
||||
publicUrl: z.string().nullable(),
|
||||
passwordRequired: z.boolean(),
|
||||
});
|
||||
export const LoginStatusResponseSchema = z.union([
|
||||
z.strictObject({ ready: z.literal(false), error: z.string() }),
|
||||
z.strictObject({
|
||||
ready: z.literal(true),
|
||||
loggedIn: z.boolean(),
|
||||
status: RedditSessionStateSchema,
|
||||
username: z.string().min(1).nullable().optional(),
|
||||
}),
|
||||
z.strictObject({
|
||||
ready: z.literal(true),
|
||||
@@ -25,10 +20,29 @@ export const LoginStatusResponseSchema = z.union([
|
||||
error: z.string(),
|
||||
}),
|
||||
]);
|
||||
export const LoginStartResponseSchema = z.union([
|
||||
z.strictObject({ ok: z.literal(true) }),
|
||||
export const RedditCookieImportRequestSchema = z.strictObject({
|
||||
cookies: z.array(z.strictObject({
|
||||
name: z.string().min(1).max(256),
|
||||
value: z.string().max(16_384),
|
||||
domain: z.string().min(1).max(253),
|
||||
path: z.string().min(1).max(4_096).default('/'),
|
||||
expires: z.number().finite().optional(),
|
||||
httpOnly: z.boolean().optional(),
|
||||
secure: z.boolean().optional(),
|
||||
sameSite: z.enum(['strict', 'lax', 'none', 'no_restriction', 'unspecified']).optional(),
|
||||
})).min(1).max(100),
|
||||
matrix: z.strictObject({
|
||||
homeserver: z.string().url(),
|
||||
accessToken: z.string().min(1).max(16_384),
|
||||
userId: z.string().min(1).max(512),
|
||||
capturedAt: z.number().finite(),
|
||||
}),
|
||||
});
|
||||
export const RedditCookieImportResponseSchema = z.union([
|
||||
z.strictObject({ ok: z.literal(true), status: z.literal('authenticated') }),
|
||||
z.strictObject({ ok: z.literal(false), error: z.string() }),
|
||||
]);
|
||||
|
||||
export type RedditSessionState = z.infer<typeof RedditSessionStateSchema>;
|
||||
export type LoginStatusResponse = z.infer<typeof LoginStatusResponseSchema>;
|
||||
export type RedditCookieImportRequest = z.infer<typeof RedditCookieImportRequestSchema>;
|
||||
Reference in new issue
Block a user