增加index.d.ts文件

master
yutent 2025-01-02 12:13:27 +08:00
parent 0cd03ccde9
commit f0058ae87b
3 changed files with 30 additions and 2 deletions

27
index.d.ts vendored Normal file
View File

@ -0,0 +1,27 @@
import Request from '@gm5/request'
import Response from '@gm5/response'
declare module '@gm5/jwt' {
interface JwtConfig {
ttl?: number
level?: number
secret: string
}
interface JwtModule {
name: string
install(conf?: JwtConfig): {
ttl: number
sign(data: object, secret: string): string
verify(token: string, secret: string): object | false
}
}
export const JwtModule: JwtModule
export function createJwt(): (
req: Request,
res: Response,
next: () => void
) => void
}

View File

@ -24,7 +24,7 @@ export const JwtModule = {
if (!conf.secret) {
console.warn(
new Error(
'Please make sure to set the `secret` field, as the default value is not secure'
'You must set a `secret` key for jwt, or it will use the default key.'
)
)
}

View File

@ -1,9 +1,10 @@
{
"name": "@gm5/jwt",
"version": "2.0.2",
"version": "2.0.3",
"type": "module",
"description": "json web token",
"main": "index.js",
"types": "index.d.ts",
"author": "yutent",
"keywords": [
"fivejs",