romandev
romandev10mo ago

Conflict with oslo package

I'm using convex with lucia-auth and lucia-auth recommends to use oslo/password to hash them. My code is:
'use node';

import { generateId } from 'lucia';
import { v } from 'convex/values';
import { mutation } from './_generated/server';
import { auth } from './auth';
import { Argon2id } from 'oslo/password';

export const insert = mutation({
args: { email: v.string(), password: v.string() },
handler: async (ctx, { email, password }) => {
const lucia = auth(ctx.db);
const userId = generateId(15);
console.log({ userId, email, password });
const hashedPassword = await new Argon2id().hash(password);
await ctx.db.insert('users', {
id: userId,
email,
password: hashedPassword,
});
const sessionId = await lucia.createSession(userId, {});
return sessionId;
},
});
'use node';

import { generateId } from 'lucia';
import { v } from 'convex/values';
import { mutation } from './_generated/server';
import { auth } from './auth';
import { Argon2id } from 'oslo/password';

export const insert = mutation({
args: { email: v.string(), password: v.string() },
handler: async (ctx, { email, password }) => {
const lucia = auth(ctx.db);
const userId = generateId(15);
console.log({ userId, email, password });
const hashedPassword = await new Argon2id().hash(password);
await ctx.db.insert('users', {
id: userId,
email,
password: hashedPassword,
});
const sessionId = await lucia.createSession(userId, {});
return sessionId;
},
});
But for some reason, the convex dev command returns this error:
✘ [ERROR] No loader is configured for ".node" files: node_modules/.pnpm/@node-rs+argon2-android-arm-eabi@1.7.0/node_modules/@node-rs/argon2-android-arm-eabi/argon2.android-arm-eabi.node

node_modules/.pnpm/@node-rs+argon2@1.7.0/node_modules/@node-rs/argon2/index.js:84:36:
84 │ nativeBinding = require('@node-rs/argon2-android-arm-eabi')
✘ [ERROR] No loader is configured for ".node" files: node_modules/.pnpm/@node-rs+argon2-android-arm-eabi@1.7.0/node_modules/@node-rs/argon2-android-arm-eabi/argon2.android-arm-eabi.node

node_modules/.pnpm/@node-rs+argon2@1.7.0/node_modules/@node-rs/argon2/index.js:84:36:
84 │ nativeBinding = require('@node-rs/argon2-android-arm-eabi')
3 Replies
Michal Srb
Michal Srb10mo ago
Use Scrypt from lucia instead:
import { Scrypt } from "lucia";

async function hashPassword(password: string) {
return await new Scrypt().hash(password);
}

async function verifyPassword(password: string, hash: string) {
return await new Scrypt().verify(hash, password);
}
import { Scrypt } from "lucia";

async function hashPassword(password: string) {
return await new Scrypt().hash(password);
}

async function verifyPassword(password: string, hash: string) {
return await new Scrypt().verify(hash, password);
}
Michal Srb
Michal Srb10mo ago
See https://lucia-auth.com/tutorials/username-and-password/nextjs-app for more details Argon2id is not support by Convex runtimes
Lucia
Username and password auth in Next.js App Router
Lucia is an open source auth library that abstracts away the complexity of handling sessions.
romandev
romandevOP10mo ago
Thanks!

Did you find this page helpful?