@elysiajs/jwt 0.1.0-rc.3 → 0.1.0-rc.4

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.
@@ -10,7 +10,7 @@ export interface JWTPayloadSpec {
10
10
  exp?: number;
11
11
  iat?: number;
12
12
  }
13
- export interface JWTOption<Name extends string = string, Schema extends TSchema | undefined = undefined> extends JWSHeaderParameters, Omit<JWTPayload, 'nbf' | 'exp'> {
13
+ export interface JWTOption<Name extends string | undefined = 'jwt', Schema extends TSchema | undefined = undefined> extends JWSHeaderParameters, Omit<JWTPayload, 'nbf' | 'exp'> {
14
14
  /**
15
15
  * Name to decorate method as
16
16
  *
@@ -29,7 +29,7 @@ export interface JWTOption<Name extends string = string, Schema extends TSchema
29
29
  * })
30
30
  * ```
31
31
  */
32
- name: Name;
32
+ name?: Name;
33
33
  /**
34
34
  * JWT Secret
35
35
  */
@@ -51,9 +51,9 @@ export interface JWTOption<Name extends string = string, Schema extends TSchema
51
51
  */
52
52
  exp?: string | number;
53
53
  }
54
- export declare const jwt: <Name extends string = string, Schema extends TSchema | undefined = undefined>({ name, secret, alg, crit, schema, nbf, exp, ...payload }: JWTOption<Name, Schema>) => (app: Elysia) => Elysia<{
54
+ export declare const jwt: <Name extends string | undefined, Schema extends TSchema | undefined = undefined>({ name, secret, alg, crit, schema, nbf, exp, ...payload }: JWTOption<Name, Schema>) => (app: Elysia) => Elysia<{
55
55
  store: {};
56
- request: { [key in Name]: {
56
+ request: { [key in Name extends string ? Name : "jwt"]: {
57
57
  sign: (morePayload: UnwrapSchema<Schema, Record<string, string>> & JWTPayloadSpec) => Promise<string>;
58
58
  verify: (jwt?: string) => Promise<false | (UnwrapSchema<Schema, Record<string, string>> & JWTPayloadSpec)>;
59
59
  }; };
package/dist/cjs/index.js CHANGED
@@ -4,7 +4,7 @@ exports.jwt = void 0;
4
4
  const elysia_1 = require("elysia");
5
5
  const jose_1 = require("jose");
6
6
  const typebox_1 = require("@sinclair/typebox");
7
- const jwt = ({ name, secret,
7
+ const jwt = ({ name = 'jwt', secret,
8
8
  // Start JWT Header
9
9
  alg = 'HS256', crit, schema,
10
10
  // End JWT Header
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ export interface JWTPayloadSpec {
10
10
  exp?: number;
11
11
  iat?: number;
12
12
  }
13
- export interface JWTOption<Name extends string = string, Schema extends TSchema | undefined = undefined> extends JWSHeaderParameters, Omit<JWTPayload, 'nbf' | 'exp'> {
13
+ export interface JWTOption<Name extends string | undefined = 'jwt', Schema extends TSchema | undefined = undefined> extends JWSHeaderParameters, Omit<JWTPayload, 'nbf' | 'exp'> {
14
14
  /**
15
15
  * Name to decorate method as
16
16
  *
@@ -29,7 +29,7 @@ export interface JWTOption<Name extends string = string, Schema extends TSchema
29
29
  * })
30
30
  * ```
31
31
  */
32
- name: Name;
32
+ name?: Name;
33
33
  /**
34
34
  * JWT Secret
35
35
  */
@@ -51,9 +51,9 @@ export interface JWTOption<Name extends string = string, Schema extends TSchema
51
51
  */
52
52
  exp?: string | number;
53
53
  }
54
- export declare const jwt: <Name extends string = string, Schema extends TSchema | undefined = undefined>({ name, secret, alg, crit, schema, nbf, exp, ...payload }: JWTOption<Name, Schema>) => (app: Elysia) => Elysia<{
54
+ export declare const jwt: <Name extends string | undefined, Schema extends TSchema | undefined = undefined>({ name, secret, alg, crit, schema, nbf, exp, ...payload }: JWTOption<Name, Schema>) => (app: Elysia) => Elysia<{
55
55
  store: {};
56
- request: { [key in Name]: {
56
+ request: { [key in Name extends string ? Name : "jwt"]: {
57
57
  sign: (morePayload: UnwrapSchema<Schema, Record<string, string>> & JWTPayloadSpec) => Promise<string>;
58
58
  verify: (jwt?: string) => Promise<false | (UnwrapSchema<Schema, Record<string, string>> & JWTPayloadSpec)>;
59
59
  }; };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createValidationError, getSchemaValidator } from 'elysia';
2
2
  import { SignJWT, jwtVerify } from 'jose';
3
3
  import { Type as t } from '@sinclair/typebox';
4
- export const jwt = ({ name, secret,
4
+ export const jwt = ({ name = 'jwt', secret,
5
5
  // Start JWT Header
6
6
  alg = 'HS256', crit, schema,
7
7
  // End JWT Header
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elysiajs/jwt",
3
3
  "description": "Plugin for Elysia for using JWT Authentication",
4
- "version": "0.1.0-rc.3",
4
+ "version": "0.1.0-rc.4",
5
5
  "author": {
6
6
  "name": "saltyAom",
7
7
  "url": "https://github.com/SaltyAom",