UNPKG

1.97 kBJavaScriptView Raw
1"use strict";
2var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6 return c > 3 && r && Object.defineProperty(target, key, r), r;
7};
8var __metadata = (this && this.__metadata) || function (k, v) {
9 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10};
11var __param = (this && this.__param) || function (paramIndex, decorator) {
12 return function (target, key) { decorator(target, key, paramIndex); }
13};
14Object.defineProperty(exports, "__esModule", { value: true });
15const jwtTool = require("jsonwebtoken");
16const common_1 = require("@nestjs/common");
17const jwt_constants_1 = require("./jwt.constants");
18let JwtService = class JwtService {
19 constructor(jwtOption) {
20 this.jwtOption = jwtOption;
21 }
22 sign(payload, options = {}) {
23 const { secret, sign } = this.jwtOption;
24 return jwtTool.sign(payload, secret, Object.assign({}, sign, options));
25 }
26 verify(token, options = {}) {
27 const { secret, verify } = this.jwtOption;
28 return jwtTool.verify(token, secret, Object.assign({}, verify, options));
29 }
30 decode(token, options = {}) {
31 const { decode } = this.jwtOption;
32 return jwtTool.decode(token, Object.assign({}, decode, options));
33 }
34};
35JwtService = __decorate([
36 common_1.Injectable(),
37 __param(0, common_1.Inject(jwt_constants_1.JWT_OPTION)),
38 __metadata("design:paramtypes", [Object])
39], JwtService);
40exports.JwtService = JwtService;
41//# sourceMappingURL=jwt.service.js.map
\No newline at end of file