fix: remove fastify-jwt

This commit is contained in:
Jannik Keye
2019-02-04 12:52:22 +01:00
parent 5196b2f647
commit d88fa777b3
6 changed files with 6 additions and 154 deletions

View File

@@ -564,6 +564,12 @@
"sourceRepoURL": "https://www.npmjs.com/package/fast-simplex-noise",
"asOfVersion": "3.0.0"
},
{
"libraryName": "Fastify-JWT",
"typingsPackageName": "fastify-jwt",
"sourceRepoURL": "https://github.com/fastify/fastify-jwt",
"asOfVersion": "0.8.1"
},
{
"libraryName": "fecha",
"typingsPackageName": "fecha",

View File

@@ -1,72 +0,0 @@
import fastify = require("fastify");
import fastifyJwt = require("fastify-jwt");
const app = fastify();
app.register<fastifyJwt.FastifyJwtOptions>(fastifyJwt, {
secret: "super-secret",
});
app.register<fastifyJwt.FastifyJwtOptions>(fastifyJwt, {
secret: (request, reply, callback) => {
return "";
},
});
app.get("/path", (request, reply) => {
request.jwtVerify();
request.jwtVerify({});
request.jwtVerify({}, () => "string");
request.jwtVerify(() => "string", () => "string");
reply.jwtSign("payload");
reply.jwtSign("payload", {});
reply.jwtSign("payload", {}, () => "string");
reply.jwtSign({ a: "b" }, {}, () => "string");
reply.jwtSign([], {}, () => "string");
reply.jwtSign(new Buffer("buffer"), {}, () => "string");
reply.jwtSign("payload", () => "string", () => "string");
});
app.jwt.sign({ a: "b" }, {}, (err, token) => {
if (err) {
throw err;
}
return token;
});
app.jwt.sign("string", { algorithm: "some-algorithm" }, (err, token) => {
if (err) {
throw err;
}
return token;
});
app.jwt.sign([], {}, (err, token) => {
if (err) {
throw err;
}
return token;
});
app.jwt.sign(new Buffer("buffer"), {}, (err, token) => {
if (err) {
throw err;
}
return token;
});
app.jwt.decode("some-token");
app.jwt.decode("some-token");
app.jwt.secret = "some-secret";
app.jwt.verify("some-token", {}, (err) => {
if (err) {
throw err;
}
return true;
});

View File

@@ -1,52 +0,0 @@
// Type definitions for fastify-jwt 0.4
// Project: https://github.com/fastify/fastify-jwt#readme
// Definitions by: Jannik Keye <https://github.com/jannikkeye>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
import fastify = require("fastify");
import { Secret, SignOptions, VerifyOptions, VerifyCallback, SignCallback, DecodeOptions } from 'jsonwebtoken';
import { IncomingMessage, ServerResponse } from 'http';
declare module "fastify" {
interface FastifyInstance<HttpServer, HttpRequest, HttpResponse> {
jwt: jwt;
}
interface SignFunction {
(payload: string | Buffer | object, options?: SignOptions): string;
(payload: string | Buffer | object, options?: SignOptions, callback?: SignCallback): void;
}
interface VerifyFunction {
(token: string, options?: VerifyOptions, callback?: VerifyCallback): void;
(token: string, options?: VerifyOptions): object | string;
}
interface jwt {
sign: SignFunction;
verify: VerifyFunction;
decode(token: string, options?: DecodeOptions): null | { [key: string]: any } | string;
secret: Secret;
}
interface FastifyRequest<HttpRequest> {
jwtVerify: (options?: VerifyOptions | VerifyCallback, next?: VerifyCallback) => Promise<null | { [key: string]: any } | string> | null | { [key: string]: any } | string;
}
interface FastifyReply<HttpResponse> {
jwtSign: (payload: string | Buffer | object, options?: SignOptions | SignCallback, next?: SignCallback) => void;
}
}
declare function fastifyJwt(): void;
declare namespace fastifyJwt {
type SecretCallback = (request: fastify.FastifyRequest<IncomingMessage>, reply: string | Buffer | object, callback?: VerifyCallback | SignCallback) => void;
interface FastifyJwtOptions {
secret: string | SecretCallback;
}
}
export = fastifyJwt;

View File

@@ -1,6 +0,0 @@
{
"private": true,
"dependencies": {
"fastify": ">=1.13.1 || 2.0.0-rc.1"
}
}

View File

@@ -1,23 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"fastify-jwt-tests.ts"
]
}

View File

@@ -1 +0,0 @@
{ "extends": "dtslint/dt.json" }