增加index.d.ts文件
parent
0cd03ccde9
commit
f0058ae87b
|
@ -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
|
||||
}
|
2
index.js
2
index.js
|
@ -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.'
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue