@elysiajs/jwt 0.1.0 → 0.2.1

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/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { type Elysia, type UnwrapSchema } from 'elysia';
1
+ import { type Elysia } from 'elysia';
2
2
  import { type JWTPayload, type JWSHeaderParameters } from 'jose';
3
- import type { TSchema } from '@sinclair/typebox';
3
+ import type { Static, TSchema } from '@sinclair/typebox';
4
+ type UnwrapSchema<Schema extends TSchema | undefined, Fallback = unknown> = Schema extends TSchema ? Static<NonNullable<Schema>> : Fallback;
4
5
  export interface JWTPayloadSpec {
5
6
  iss?: string;
6
7
  sub?: string;
@@ -17,8 +18,8 @@ export interface JWTOption<Name extends string | undefined = 'jwt', Schema exten
17
18
  nbf?: string | number;
18
19
  exp?: string | number;
19
20
  }
20
- 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<{
21
- store: {};
21
+ export declare const jwt: <Name extends string = "jwt", Schema extends TSchema | undefined = undefined>({ name, secret, alg, crit, schema, nbf, exp, ...payload }: JWTOption<Name, Schema>) => (app: Elysia) => Elysia<{
22
+ store: Record<any, any> & Record<typeof import("elysia").SCHEMA, {}> & Record<typeof import("elysia").DEFS, {}>;
22
23
  request: { [key in Name extends string ? Name : "jwt"]: {
23
24
  sign: (morePayload: UnwrapSchema<Schema, Record<string, string>> & JWTPayloadSpec) => Promise<string>;
24
25
  verify: (jwt?: string) => Promise<false | (UnwrapSchema<Schema, Record<string, string>> & JWTPayloadSpec)>;
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ export const jwt = ({ name = 'jwt', secret, alg = 'HS256', crit, schema, nbf, ex
17
17
  exp: t.Optional(t.Union([t.String(), t.Number()])),
18
18
  iat: t.Optional(t.String())
19
19
  })
20
- ]))
20
+ ]), {})
21
21
  : undefined;
22
22
  return app.decorate(name, {
23
23
  sign: (morePayload) => {
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",
4
+ "version": "0.2.1",
5
5
  "author": {
6
6
  "name": "saltyAom",
7
7
  "url": "https://github.com/SaltyAom",
@@ -35,18 +35,18 @@
35
35
  "release": "npm run build && npm run test && npm publish --access public"
36
36
  },
37
37
  "dependencies": {
38
- "jose": "^4.11.1"
38
+ "jose": "^4.12.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@elysiajs/cookie": "^0.1.0-rc.2",
42
- "@sinclair/typebox": "0.25.10",
41
+ "@elysiajs/cookie": "^0.1.1",
42
+ "@sinclair/typebox": "^0.25.21",
43
43
  "@types/node": "^18.11.7",
44
- "bun-types": "^0.2.2",
44
+ "bun-types": "^0.5.0",
45
45
  "eslint": "^8.26.0",
46
- "elysia": "^0.1.0-rc.5",
47
- "typescript": "^4.8.4"
46
+ "elysia": "^0.2.7",
47
+ "typescript": "^4.9.4"
48
48
  },
49
49
  "peerDependencies": {
50
- "elysia": ">= 0.1.0-rc.5"
50
+ "elysia": ">= 0.2.0"
51
51
  }
52
52
  }