chore: remove passport package
This commit is contained in:
parent
31ad64cd95
commit
ae5f5a97d9
@ -546,12 +546,6 @@ importers:
|
||||
p-map:
|
||||
specifier: 4.0.0
|
||||
version: 4.0.0
|
||||
passport:
|
||||
specifier: ^0.7.0
|
||||
version: 0.7.0
|
||||
passport-jwt:
|
||||
specifier: ^4.0.1
|
||||
version: 4.0.1
|
||||
ping:
|
||||
specifier: ^0.4.4
|
||||
version: 0.4.4
|
||||
@ -637,12 +631,6 @@ importers:
|
||||
'@types/nodemailer':
|
||||
specifier: ^6.4.11
|
||||
version: 6.4.11
|
||||
'@types/passport':
|
||||
specifier: ^1.0.12
|
||||
version: 1.0.12
|
||||
'@types/passport-jwt':
|
||||
specifier: ^3.0.9
|
||||
version: 3.0.9
|
||||
'@types/ping':
|
||||
specifier: ^0.4.2
|
||||
version: 0.4.2
|
||||
@ -4274,15 +4262,6 @@ packages:
|
||||
'@types/parse5@6.0.3':
|
||||
resolution: {integrity: sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g==}
|
||||
|
||||
'@types/passport-jwt@3.0.9':
|
||||
resolution: {integrity: sha512-5XJt+79emfgpuBvBQusUPylFIVtW1QVAAkTRwCbRJAmxUjmLtIqUU6V1ovpnHPu6Qut3mR5Juc+s7kd06roNTg==}
|
||||
|
||||
'@types/passport-strategy@0.2.35':
|
||||
resolution: {integrity: sha512-o5D19Jy2XPFoX2rKApykY15et3Apgax00RRLf0RUotPDUsYrQa7x4howLYr9El2mlUApHmCMv5CZ1IXqKFQ2+g==}
|
||||
|
||||
'@types/passport@1.0.12':
|
||||
resolution: {integrity: sha512-QFdJ2TiAEoXfEQSNDISJR1Tm51I78CymqcBa8imbjo6dNNu+l2huDxxbDEIoFIwOSKMkOfHEikyDuZ38WwWsmw==}
|
||||
|
||||
'@types/pbf@3.0.5':
|
||||
resolution: {integrity: sha512-j3pOPiEcWZ34R6a6mN07mUkM4o4Lwf6hPNt8eilOeZhTFbxFXmKhvXl9Y28jotFPaI1bpPDJsbCprUoNke6OrA==}
|
||||
|
||||
@ -9312,17 +9291,6 @@ packages:
|
||||
pascal-case@3.1.2:
|
||||
resolution: {integrity: sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==}
|
||||
|
||||
passport-jwt@4.0.1:
|
||||
resolution: {integrity: sha512-UCKMDYhNuGOBE9/9Ycuoyh7vP6jpeTp/+sfMJl7nLff/t6dps+iaeE0hhNkKN8/HZHcJ7lCdOyDxHdDoxoSvdQ==}
|
||||
|
||||
passport-strategy@1.0.0:
|
||||
resolution: {integrity: sha512-CB97UUvDKJde2V0KDWWB3lyf6PC3FaZP7YxZ2G8OAtn9p4HI9j9JLP9qjOGZFvyl8uwNT8qM+hGnz/n16NI7oA==}
|
||||
engines: {node: '>= 0.4.0'}
|
||||
|
||||
passport@0.7.0:
|
||||
resolution: {integrity: sha512-cPLl+qZpSc+ireUvt+IzqbED1cHHkDoVYMo30jbJIdOOjQ1MQYZBPiNvmi8UM6lJuOpTPXJGZQk0DtC4y61MYQ==}
|
||||
engines: {node: '>= 0.4.0'}
|
||||
|
||||
path-browserify@1.0.1:
|
||||
resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==}
|
||||
|
||||
@ -9403,9 +9371,6 @@ packages:
|
||||
pathval@1.1.1:
|
||||
resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==}
|
||||
|
||||
pause@0.0.1:
|
||||
resolution: {integrity: sha512-KG8UEiEVkR3wGEb4m5yZkVCzigAD+cVEJck2CzYZO37ZGJfctvVptVO192MwrtPhzONn6go8ylnOdMhKqi4nfg==}
|
||||
|
||||
pbf@3.2.1:
|
||||
resolution: {integrity: sha512-ClrV7pNOn7rtmoQVF4TS1vyU0WhYRnP92fzbfF75jAIwpnzdJXf8iTd4CMEqO4yUenH6NDqLiwjqlh6QgZzgLQ==}
|
||||
hasBin: true
|
||||
@ -17946,21 +17911,6 @@ snapshots:
|
||||
|
||||
'@types/parse5@6.0.3': {}
|
||||
|
||||
'@types/passport-jwt@3.0.9':
|
||||
dependencies:
|
||||
'@types/express': 4.17.17
|
||||
'@types/jsonwebtoken': 9.0.5
|
||||
'@types/passport-strategy': 0.2.35
|
||||
|
||||
'@types/passport-strategy@0.2.35':
|
||||
dependencies:
|
||||
'@types/express': 4.17.17
|
||||
'@types/passport': 1.0.12
|
||||
|
||||
'@types/passport@1.0.12':
|
||||
dependencies:
|
||||
'@types/express': 4.17.17
|
||||
|
||||
'@types/pbf@3.0.5': {}
|
||||
|
||||
'@types/ping@0.4.2': {}
|
||||
@ -24334,19 +24284,6 @@ snapshots:
|
||||
no-case: 3.0.4
|
||||
tslib: 2.6.2
|
||||
|
||||
passport-jwt@4.0.1:
|
||||
dependencies:
|
||||
jsonwebtoken: 9.0.2
|
||||
passport-strategy: 1.0.0
|
||||
|
||||
passport-strategy@1.0.0: {}
|
||||
|
||||
passport@0.7.0:
|
||||
dependencies:
|
||||
passport-strategy: 1.0.0
|
||||
pause: 0.0.1
|
||||
utils-merge: 1.0.1
|
||||
|
||||
path-browserify@1.0.1: {}
|
||||
|
||||
path-dirname@1.0.2: {}
|
||||
@ -24408,8 +24345,6 @@ snapshots:
|
||||
|
||||
pathval@1.1.1: {}
|
||||
|
||||
pause@0.0.1: {}
|
||||
|
||||
pbf@3.2.1:
|
||||
dependencies:
|
||||
ieee754: 1.2.1
|
||||
|
@ -2,7 +2,6 @@ import express from 'express';
|
||||
import 'express-async-errors';
|
||||
import compression from 'compression';
|
||||
import swaggerUI from 'swagger-ui-express';
|
||||
import passport from 'passport';
|
||||
import morgan from 'morgan';
|
||||
import { websiteRouter } from './router/website.js';
|
||||
import { telemetryRouter } from './router/telemetry.js';
|
||||
@ -38,7 +37,6 @@ app.use(
|
||||
},
|
||||
})
|
||||
);
|
||||
app.use(passport.initialize());
|
||||
app.use(morgan('tiny'));
|
||||
app.use(cors());
|
||||
|
||||
|
@ -1,7 +1,3 @@
|
||||
import { findUser } from '../model/user.js';
|
||||
import passport from 'passport';
|
||||
import { Handler } from 'express';
|
||||
import { Strategy as JwtStrategy, ExtractJwt } from 'passport-jwt';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import { jwtSecret } from '../utils/common.js';
|
||||
|
||||
@ -14,38 +10,6 @@ export interface JWTPayload {
|
||||
role: string;
|
||||
}
|
||||
|
||||
passport.use(
|
||||
new JwtStrategy(
|
||||
{
|
||||
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
||||
secretOrKey: jwtSecret,
|
||||
issuer: jwtIssuer,
|
||||
audience: jwtAudience,
|
||||
},
|
||||
function (jwt_payload, done) {
|
||||
findUser(jwt_payload.id)
|
||||
.then((user) => {
|
||||
if (user) {
|
||||
done(null, user);
|
||||
} else {
|
||||
done(null, false);
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
done(err);
|
||||
});
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
passport.serializeUser(function (user: any, cb) {
|
||||
cb(null, { id: user.id, username: user.username });
|
||||
});
|
||||
|
||||
passport.deserializeUser(function (user: any, cb) {
|
||||
cb(null, user);
|
||||
});
|
||||
|
||||
export function jwtSign(payload: JWTPayload): string {
|
||||
const token = jwt.sign(
|
||||
{
|
||||
@ -72,9 +36,3 @@ export function jwtVerify(token: string): JWTPayload {
|
||||
|
||||
return payload as JWTPayload;
|
||||
}
|
||||
|
||||
export function auth(): Handler {
|
||||
return passport.authenticate('jwt', {
|
||||
session: false,
|
||||
});
|
||||
}
|
||||
|
@ -61,8 +61,6 @@
|
||||
"nanoid": "^5.0.4",
|
||||
"nodemailer": "^6.9.8",
|
||||
"p-map": "4.0.0",
|
||||
"passport": "^0.7.0",
|
||||
"passport-jwt": "^4.0.1",
|
||||
"ping": "^0.4.4",
|
||||
"prom-client": "^15.1.3",
|
||||
"puppeteer": "23.4.1",
|
||||
@ -93,8 +91,6 @@
|
||||
"@types/morgan": "^1.9.5",
|
||||
"@types/node": "^18.17.12",
|
||||
"@types/nodemailer": "^6.4.11",
|
||||
"@types/passport": "^1.0.12",
|
||||
"@types/passport-jwt": "^3.0.9",
|
||||
"@types/ping": "^0.4.2",
|
||||
"@types/request-ip": "^0.0.38",
|
||||
"@types/supertest": "^6.0.2",
|
||||
|
Loading…
Reference in New Issue
Block a user