@elysiajs/jwt 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.d.ts +43 -8
- package/dist/cjs/index.js +2466 -68
- package/dist/index.d.ts +43 -8
- package/dist/index.mjs +2452 -0
- package/package.json +54 -54
- package/dist/index.js +0 -66
package/dist/cjs/index.d.ts
CHANGED
|
@@ -12,20 +12,54 @@ export interface JWTPayloadSpec {
|
|
|
12
12
|
iat?: number;
|
|
13
13
|
}
|
|
14
14
|
export interface JWTOption<Name extends string | undefined = 'jwt', Schema extends TSchema | undefined = undefined> extends JWSHeaderParameters, Omit<JWTPayload, 'nbf' | 'exp'> {
|
|
15
|
+
/**
|
|
16
|
+
* Name to decorate method as
|
|
17
|
+
*
|
|
18
|
+
* ---
|
|
19
|
+
* @example
|
|
20
|
+
* For example, `jwt` will decorate Context with `Context.jwt`
|
|
21
|
+
*
|
|
22
|
+
* ```typescript
|
|
23
|
+
* app
|
|
24
|
+
* .decorate({
|
|
25
|
+
* name: 'myJWTNamespace',
|
|
26
|
+
* secret: process.env.JWT_SECRETS
|
|
27
|
+
* })
|
|
28
|
+
* .get('/sign/:name', ({ myJWTNamespace, params }) => {
|
|
29
|
+
* return myJWTNamespace.sign(params)
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
15
33
|
name?: Name;
|
|
34
|
+
/**
|
|
35
|
+
* JWT Secret
|
|
36
|
+
*/
|
|
16
37
|
secret: string | Uint8Array | KeyLike;
|
|
38
|
+
/**
|
|
39
|
+
* Type strict validation for JWT payload
|
|
40
|
+
*/
|
|
17
41
|
schema?: Schema;
|
|
42
|
+
/**
|
|
43
|
+
* JWT Not Before
|
|
44
|
+
*
|
|
45
|
+
* @see [RFC7519#section-4.1.5](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.5)
|
|
46
|
+
*/
|
|
18
47
|
nbf?: string | number;
|
|
48
|
+
/**
|
|
49
|
+
* JWT Expiration Time
|
|
50
|
+
*
|
|
51
|
+
* @see [RFC7519#section-4.1.4](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.4)
|
|
52
|
+
*/
|
|
19
53
|
exp?: string | number;
|
|
20
54
|
}
|
|
21
55
|
export declare const jwt: <const Name extends string = "jwt", const Schema extends TSchema | undefined = undefined>({ name, secret, alg, crit, schema, nbf, exp, ...payload }: JWTOption<Name, Schema>) => Elysia<"", false, {
|
|
22
|
-
decorator: { [name in Name extends string ? Name : "jwt"]: {
|
|
56
|
+
decorator: ({ [name in Name extends string ? Name : "jwt"]: {
|
|
23
57
|
readonly sign: (morePayload: UnwrapSchema<Schema, Record<string, string | number>> & JWTPayloadSpec) => Promise<string>;
|
|
24
|
-
readonly verify: (jwt?: string) => Promise<
|
|
25
|
-
}; } extends infer T ? { [
|
|
58
|
+
readonly verify: (jwt?: string) => Promise<(UnwrapSchema<Schema, Record<string, string | number>> & JWTPayloadSpec) | false>;
|
|
59
|
+
}; } extends infer T extends Object ? { [key in keyof T as key extends never ? never : key]: { [name in Name extends string ? Name : "jwt"]: {
|
|
26
60
|
readonly sign: (morePayload: UnwrapSchema<Schema, Record<string, string | number>> & JWTPayloadSpec) => Promise<string>;
|
|
27
|
-
readonly verify: (jwt?: string) => Promise<
|
|
28
|
-
}; }[K]; } : never;
|
|
61
|
+
readonly verify: (jwt?: string) => Promise<(UnwrapSchema<Schema, Record<string, string | number>> & JWTPayloadSpec) | false>;
|
|
62
|
+
}; }[key]; } : never) extends infer Collision ? {} extends Collision ? {} : { [K in keyof ({} & Collision)]: ({} & Collision)[K]; } : never;
|
|
29
63
|
store: {};
|
|
30
64
|
derive: {};
|
|
31
65
|
resolve: {};
|
|
@@ -35,13 +69,14 @@ export declare const jwt: <const Name extends string = "jwt", const Schema exten
|
|
|
35
69
|
}, {
|
|
36
70
|
schema: {};
|
|
37
71
|
macro: {};
|
|
72
|
+
macroFn: {};
|
|
38
73
|
}, {}, {
|
|
39
|
-
decorator: {};
|
|
40
|
-
store: {};
|
|
41
74
|
derive: {};
|
|
42
75
|
resolve: {};
|
|
76
|
+
schema: {};
|
|
43
77
|
}, {
|
|
78
|
+
derive: {};
|
|
79
|
+
resolve: {};
|
|
44
80
|
schema: {};
|
|
45
|
-
macro: {};
|
|
46
81
|
}>;
|
|
47
82
|
export default jwt;
|