forked from andyburke/autonomous.contact
feature/refactor: smartfeeds to reduce the client complexity
This commit is contained in:
parent
46090d944a
commit
f6cd05beac
19 changed files with 782 additions and 800 deletions
|
|
@ -64,8 +64,8 @@ export function api(api_config?: Record<string, any>): API_CLIENT {
|
|||
cookies.push({
|
||||
name: options.totp_token ?? 'totp',
|
||||
value: await generateTotp(options.session.secret),
|
||||
maxAge: 30,
|
||||
expires: Date.now() + 30_000,
|
||||
maxAge: 29,
|
||||
expires: Date.now() + 29_000,
|
||||
path: '/'
|
||||
});
|
||||
|
||||
|
|
@ -80,7 +80,8 @@ export function api(api_config?: Record<string, any>): API_CLIENT {
|
|||
method: options?.method ?? 'GET',
|
||||
credentials: options?.credentials ?? 'include',
|
||||
redirect: options?.redirect ?? 'follow',
|
||||
headers
|
||||
headers,
|
||||
signal: options?.signal
|
||||
};
|
||||
|
||||
const response_transform = transform ?? DEFAULT_TRANSFORM;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ export function require_user(
|
|||
meta: Record<string, any>
|
||||
): undefined | Response {
|
||||
if (!meta.user) {
|
||||
console.dir({
|
||||
require_user: true,
|
||||
meta
|
||||
});
|
||||
return CANNED_RESPONSES.permission_denied();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,5 +110,10 @@ export async function verifyTotp(
|
|||
t0: number = 0,
|
||||
t: number = Date.now()
|
||||
): Promise<boolean> {
|
||||
return otp === await generateTotp(key, t0, t);
|
||||
const valid_otps = [
|
||||
await generateTotp(key, t0, t - 30_000),
|
||||
await generateTotp(key, t0, t),
|
||||
await generateTotp(key, t0, t + 30_000)
|
||||
];
|
||||
return valid_otps.includes(otp);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue