增加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) {
|
if (!conf.secret) {
|
||||||
console.warn(
|
console.warn(
|
||||||
new Error(
|
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",
|
"name": "@gm5/jwt",
|
||||||
"version": "2.0.2",
|
"version": "2.0.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "json web token",
|
"description": "json web token",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
|
"types": "index.d.ts",
|
||||||
"author": "yutent",
|
"author": "yutent",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"fivejs",
|
"fivejs",
|
||||||
|
|
Loading…
Reference in New Issue