@elysiajs/jwt 1.3.3 → 1.4.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/bun.lock +119 -171
- package/dist/cjs/index.d.ts +14 -10
- package/dist/cjs/index.js +18 -2640
- package/dist/index.d.ts +14 -10
- package/dist/index.mjs +19 -2651
- package/package.json +55 -54
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { Elysia
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import type { AnySchema, UnwrapSchema } from 'elysia/types';
|
|
2
3
|
import { type CryptoKey, type JWK, type KeyObject, type JoseHeaderParameters, type JWTVerifyOptions } from 'jose';
|
|
3
|
-
type
|
|
4
|
+
type Prettify<T> = {
|
|
5
|
+
[K in keyof T]: T[K];
|
|
6
|
+
} & {};
|
|
4
7
|
type NormalizedClaim = 'nbf' | 'exp' | 'iat';
|
|
5
8
|
type AllowClaimValue = string | number | boolean | null | undefined | AllowClaimValue[] | {
|
|
6
9
|
[key: string]: AllowClaimValue;
|
|
7
10
|
};
|
|
8
11
|
type ClaimType = Record<string, AllowClaimValue>;
|
|
12
|
+
type UnwrapSchemaWithFallback<Schema extends AnySchema | undefined, Fallback = unknown> = Schema extends AnySchema ? UnwrapSchema<NonNullable<Schema>> : Fallback;
|
|
9
13
|
/**
|
|
10
14
|
* This interface is a specific, strongly-typed representation of the
|
|
11
15
|
* standard claims found in a JWT payload.
|
|
@@ -115,7 +119,7 @@ export interface JWTHeaderParameters extends JoseHeaderParameters {
|
|
|
115
119
|
/** JWS "crit" (Critical) Header Parameter */
|
|
116
120
|
crit?: string[];
|
|
117
121
|
}
|
|
118
|
-
export interface JWTOption<Name extends string | undefined = 'jwt', Schema extends
|
|
122
|
+
export interface JWTOption<Name extends string | undefined = 'jwt', Schema extends AnySchema | undefined = undefined> extends JWTHeaderParameters, JWTPayloadInput {
|
|
119
123
|
/**
|
|
120
124
|
* Name to decorate method as
|
|
121
125
|
*
|
|
@@ -144,14 +148,11 @@ export interface JWTOption<Name extends string | undefined = 'jwt', Schema exten
|
|
|
144
148
|
*/
|
|
145
149
|
schema?: Schema;
|
|
146
150
|
}
|
|
147
|
-
export declare const jwt: <const Name extends string = "jwt", const Schema extends
|
|
151
|
+
export declare const jwt: <const Name extends string = "jwt", const Schema extends AnySchema | undefined = undefined>({ name, secret, schema, ...defaultValues }: JWTOption<Name, Schema>) => Elysia<"", {
|
|
148
152
|
decorator: { [name in Name extends string ? Name : "jwt"]: {
|
|
149
|
-
sign(signValue: Omit<
|
|
150
|
-
verify(jwt?: string, options?: JWTVerifyOptions): Promise<(
|
|
151
|
-
}; }
|
|
152
|
-
sign(signValue: Omit<UnwrapSchema<Schema, ClaimType>, NormalizedClaim> & JWTPayloadInput): Promise<string>;
|
|
153
|
-
verify(jwt?: string, options?: JWTVerifyOptions): Promise<(UnwrapSchema<Schema, ClaimType> & Omit<JWTPayloadSpec, keyof UnwrapSchema<Schema, {}>>) | false>;
|
|
154
|
-
}; }[K]; } : never;
|
|
153
|
+
sign(signValue: Prettify<Omit<UnwrapSchemaWithFallback<Schema, ClaimType>, NormalizedClaim> & JWTPayloadInput>): Promise<string>;
|
|
154
|
+
verify(jwt?: string, options?: JWTVerifyOptions): Promise<(UnwrapSchemaWithFallback<Schema, ClaimType> & Omit<JWTPayloadSpec, keyof UnwrapSchema<Schema, {}>>) | false>;
|
|
155
|
+
}; };
|
|
155
156
|
store: {};
|
|
156
157
|
derive: {};
|
|
157
158
|
resolve: {};
|
|
@@ -164,15 +165,18 @@ export declare const jwt: <const Name extends string = "jwt", const Schema exten
|
|
|
164
165
|
macro: {};
|
|
165
166
|
macroFn: {};
|
|
166
167
|
parser: {};
|
|
168
|
+
response: {};
|
|
167
169
|
}, {}, {
|
|
168
170
|
derive: {};
|
|
169
171
|
resolve: {};
|
|
170
172
|
schema: {};
|
|
171
173
|
standaloneSchema: {};
|
|
174
|
+
response: {};
|
|
172
175
|
}, {
|
|
173
176
|
derive: {};
|
|
174
177
|
resolve: {};
|
|
175
178
|
schema: {};
|
|
176
179
|
standaloneSchema: {};
|
|
180
|
+
response: {};
|
|
177
181
|
}>;
|
|
178
182
|
export default jwt;
|