Verify Reddit identity before Matrix capture

This commit is contained in:
jjbrunton committed 2026-08-08 16:03:54 +01:00
1 parent 2fd92bf82c
commit 2c533fa52a
3 files changed
+48 -14

No files matched your search

+20
View File
@@ -33,6 +33,26 @@ export interface AccountAuthContextOptions {
now?: () => number;
}
export interface CurrentAccountAuthentication {
getRedditUsername(): Promise<string | null>;
refreshMatrixCredentials(): Promise<{ userId: string } | null>;
}
export async function authenticateCurrentAccount(
authentication: CurrentAccountAuthentication,
): Promise<AuthenticatedAccount | null> {
const redditUsername = await authentication.getRedditUsername();
if (!redditUsername) return null;
const credentials = await authentication.refreshMatrixCredentials();
if (!credentials?.userId) return null;
return {
accountId: credentials.userId,
redditUsername,
matrixUserId: credentials.userId,
};
}
export const denyAccountAuth: AccountAuthGate = {
isFullyAuthenticated: () => false,
invalidate: () => undefined,