refactor: use sync bcrypt to avoid issues with worker perms
refactor: fix up includes
This commit is contained in:
parent
e397bc884b
commit
1a02dcfcc3
27 changed files with 104 additions and 178 deletions
|
@ -1,13 +1,13 @@
|
|||
import { PASSWORD_ENTRIES } from '../../../models/password_entry.ts';
|
||||
import { USER, USERS } from '../../../models/user.ts';
|
||||
import { encodeBase32 } from 'jsr:@std/encoding';
|
||||
import lurid from 'jsr:@andyburke/lurid';
|
||||
import { encodeBase32 } from '@std/encoding';
|
||||
import lurid from '@andyburke/lurid';
|
||||
import { SESSION, SESSIONS } from '../../../models/session.ts';
|
||||
import { TOTP_ENTRIES } from '../../../models/totp_entry.ts';
|
||||
import { encodeBase64 } from 'jsr:@std/encoding/base64';
|
||||
import { encodeBase64 } from '@std/encoding/base64';
|
||||
import parse_body from '../../../utils/bodyparser.ts';
|
||||
import { get_session, get_user, PRECHECK_TABLE, require_user, SESSION_ID_TOKEN, SESSION_SECRET_TOKEN } from '../../../utils/prechecks.ts';
|
||||
import * as bcrypt from 'jsr:@da/bcrypt';
|
||||
import * as bcrypt from '@da/bcrypt';
|
||||
import { verifyTotp } from '../../../utils/totp.ts';
|
||||
|
||||
const DEFAULT_SESSION_TIME: number = 28 * (24 * (60 * (60 * 1_000))); // 28 days
|
||||
|
@ -79,7 +79,7 @@ export async function POST(req: Request, meta: Record<string, any>): Promise<Res
|
|||
});
|
||||
}
|
||||
|
||||
const verified = await bcrypt.compare(password_hash, password_entry.hash);
|
||||
const verified = bcrypt.compareSync(password_hash, password_entry.hash);
|
||||
|
||||
if (!verified) {
|
||||
return Response.json({
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import lurid from 'jsr:@andyburke/lurid';
|
||||
import lurid from '@andyburke/lurid';
|
||||
import { get_session, get_user, PRECHECK_TABLE, require_user } from '../../../../../utils/prechecks.ts';
|
||||
import { ROOM, ROOMS } from '../../../../../models/room.ts';
|
||||
import * as CANNED_RESPONSES from '../../../../../utils/canned_responses.ts';
|
||||
import { EVENT, get_events_collection_for_room } from '../../../../../models/event.ts';
|
||||
import parse_body from '../../../../../utils/bodyparser.ts';
|
||||
import { FSDB_COLLECTION, FSDB_SEARCH_OPTIONS, WALK_ENTRY } from 'jsr:@andyburke/fsdb';
|
||||
import * as path from 'jsr:@std/path';
|
||||
import { FSDB_COLLECTION, FSDB_SEARCH_OPTIONS, WALK_ENTRY } from '@andyburke/fsdb';
|
||||
import * as path from '@std/path';
|
||||
|
||||
export const PRECHECKS: PRECHECK_TABLE = {};
|
||||
|
||||
|
@ -79,8 +79,8 @@ export async function GET(request: Request, meta: Record<string, any>): Promise<
|
|||
};
|
||||
|
||||
const results = (await events.all(options))
|
||||
.map((entry) => entry.load())
|
||||
.sort((lhs_item, rhs_item) => rhs_item.timestamps.created.localeCompare(lhs_item.timestamps.created));
|
||||
.map((entry: WALK_ENTRY<EVENT>) => entry.load())
|
||||
.sort((lhs_item: EVENT, rhs_item: EVENT) => rhs_item.timestamps.created.localeCompare(lhs_item.timestamps.created));
|
||||
|
||||
// long-polling support
|
||||
if (results.length === 0 && meta.query.wait) {
|
||||
|
@ -106,10 +106,12 @@ export async function GET(request: Request, meta: Record<string, any>): Promise<
|
|||
events.on('create', on_create);
|
||||
request.signal.addEventListener('abort', () => {
|
||||
events.off('create', on_create);
|
||||
clearTimeout(timeout);
|
||||
reject(new Error('request aborted'));
|
||||
});
|
||||
Deno.addSignalListener('SIGINT', () => {
|
||||
events.off('create', on_create);
|
||||
clearTimeout(timeout);
|
||||
return resolve(Response.json(results, {
|
||||
status: 200,
|
||||
headers
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import lurid from 'jsr:@andyburke/lurid';
|
||||
import lurid from '@andyburke/lurid';
|
||||
import parse_body from '../../../utils/bodyparser.ts';
|
||||
import { get_session, get_user, require_user } from '../../../utils/prechecks.ts';
|
||||
import * as CANNED_RESPONSES from '../../../utils/canned_responses.ts';
|
||||
import { PRECHECK_TABLE } from '../../../utils/prechecks.ts';
|
||||
import { ROOM, ROOMS } from '../../../models/room.ts';
|
||||
import { WALK_ENTRY } from 'jsr:@andyburke/fsdb';
|
||||
import { WALK_ENTRY } from '@andyburke/fsdb';
|
||||
|
||||
export const PRECHECKS: PRECHECK_TABLE = {};
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { PASSWORD_ENTRIES, PASSWORD_ENTRY } from '../../../models/password_entry.ts';
|
||||
import { USER, USERS } from '../../../models/user.ts';
|
||||
import lurid from 'jsr:@andyburke/lurid';
|
||||
import { encodeBase64 } from 'jsr:@std/encoding';
|
||||
import lurid from '@andyburke/lurid';
|
||||
import { encodeBase64 } from '@std/encoding';
|
||||
import parse_body from '../../../utils/bodyparser.ts';
|
||||
import { create_new_session, SESSION_RESULT } from '../auth/index.ts';
|
||||
import { get_session, get_user, PRECHECK_TABLE, require_user } from '../../../utils/prechecks.ts';
|
||||
import * as CANNED_RESPONSES from '../../../utils/canned_responses.ts';
|
||||
import * as bcrypt from 'jsr:@da/bcrypt';
|
||||
import * as bcrypt from '@da/bcrypt';
|
||||
|
||||
// TODO: figure out a better solution for doling out permissions
|
||||
const DEFAULT_USER_PERMISSIONS: string[] = [
|
||||
|
@ -107,7 +107,7 @@ export async function POST(req: Request, meta: Record<string, any>): Promise<Res
|
|||
await USERS.create(user);
|
||||
|
||||
// automatically salted
|
||||
const hashed_password_value = await bcrypt.hash(password_hash);
|
||||
const hashed_password_value = bcrypt.hashSync(password_hash);
|
||||
|
||||
const password_entry: PASSWORD_ENTRY = {
|
||||
user_id: user.id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue