Package breakdown - initial commit 1.0.0

This commit is contained in:
2023-05-23 14:28:43 -04:00
commit 929ebd96d6
33 changed files with 995 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
import { ExtractJwt, Strategy as JwtStrategy } from 'passport-jwt';
import { readOneByRecord } from '@mifi/services-common/lib/db/dao/readOneByRecord';
import { JWT_SECRET } from '../../constants/env';
const opts = {
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
secretOrKey: JWT_SECRET,
issuer: process.env.JWT_ISSUER,
audience: process.env.JWT_AUDIENCE,
};
export default new JwtStrategy(opts, async ({ sub }, done) => {
const auth = await readOneByRecord(sub);
return done(null, auth || false);
});

View File

@@ -0,0 +1,9 @@
// eslint-disable-next-line import/named
import { Strategy as LocalStrategy } from 'passport-local';
import { authenticate } from '@mifi/services-common/lib/db/api/authenticate';
export default new LocalStrategy(async (username: string, password: string, done: any) => {
const user = await authenticate(username, password);
done(null, user);
});