@nestjs/jwt
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -9,5 +9,5 @@ /// <reference types="node" /> | ||
verify<T extends object = any>(token: string, options?: jwt.VerifyOptions): T; | ||
decode(token: string, options: jwt.DecodeOptions): null | { | ||
decode(token: string, options?: jwt.DecodeOptions): null | { | ||
[key: string]: any; | ||
} | string; | ||
} |
{ | ||
"name": "@nestjs/jwt", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@jwt)", | ||
@@ -5,0 +5,0 @@ "author": "Kamil Mysliwiec", |
@@ -63,9 +63,11 @@ <p align="center"> | ||
**1. Use factory** | ||
```typescript | ||
JwtModule.registerAsync({ | ||
useFactory: () => ({ | ||
secretOrPrivateKey: 'key', | ||
}), | ||
}) | ||
secretOrPrivateKey: 'key' | ||
}) | ||
}); | ||
``` | ||
Obviously, our factory behaves like every other one (might be `async` and is able to inject dependencies through `inject`). | ||
@@ -84,8 +86,11 @@ | ||
**2. Use class** | ||
```typescript | ||
JwtModule.registerAsync({ | ||
useClass: JwtConfigService, | ||
}) | ||
useClass: JwtConfigService | ||
}); | ||
``` | ||
Above construction will instantiate `JwtConfigService` inside `JwtModule` and will leverage it to create options object. | ||
```typescript | ||
@@ -95,3 +100,3 @@ class JwtConfigService implements JwtOptionsFactory { | ||
return { | ||
secretOrPrivateKey: 'key', | ||
secretOrPrivateKey: 'key' | ||
}; | ||
@@ -103,2 +108,3 @@ } | ||
**3. Use existing** | ||
```typescript | ||
@@ -110,2 +116,3 @@ JwtModule.registerAsync({ | ||
``` | ||
It works the same as `useClass` with one critical difference - `JwtModule` will lookup imported modules to reuse already created `ConfigService`, instead of instantiating it on its own. | ||
@@ -118,11 +125,15 @@ | ||
#### jwtService.sign(payload: string | Object | Buffer, options?: SignOptions): string | ||
The sign method is an implementation of jsonwebtoken `.sign()`. | ||
#### jwtService.verify\<T extends object = any>(token: string, options?: VerifyOptions): T | ||
The sign method is an implementation of jsonwebtoken `.verify()`. | ||
The verify method is an implementation of jsonwebtoken `.verify()`. | ||
#### jwtService.decode(token: string, options: DecodeOptions): object | string | ||
The sign method is an implementation of jsonwebtoken `.decode()`. | ||
The decode method is an implementation of jsonwebtoken `.decode()`. | ||
The `JwtModule` takes an `options` object: | ||
- `secretOrPrivateKey` [read more](https://github.com/auth0/node-jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback) | ||
@@ -139,5 +150,5 @@ - `signOptions` [read more](https://github.com/auth0/node-jsonwebtoken#jwtsignpayload-secretorprivatekey-options-callback) | ||
* Author - [Kamil Myśliwiec](https://kamilmysliwiec.com) | ||
* Website - [https://nestjs.com](https://nestjs.com/) | ||
* Twitter - [@nestframework](https://twitter.com/nestframework) | ||
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com) | ||
- Website - [https://nestjs.com](https://nestjs.com/) | ||
- Twitter - [@nestframework](https://twitter.com/nestframework) | ||
@@ -144,0 +155,0 @@ ## License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28866
151