@flusys/nestjs-notification 6.0.0-rc.1 → 6.0.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.
|
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "NotificationGateway", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _common = require("@nestjs/common");
|
|
12
|
+
const _jwt = require("@nestjs/jwt");
|
|
12
13
|
const _websockets = require("@nestjs/websockets");
|
|
13
|
-
const _jsonwebtoken = /*#__PURE__*/ _interop_require_wildcard(require("jsonwebtoken"));
|
|
14
14
|
const _socketio = require("socket.io");
|
|
15
15
|
const _notificationconfigservice = require("../services/notification-config.service");
|
|
16
16
|
function _define_property(obj, key, value) {
|
|
@@ -26,47 +26,6 @@ function _define_property(obj, key, value) {
|
|
|
26
26
|
}
|
|
27
27
|
return obj;
|
|
28
28
|
}
|
|
29
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
30
|
-
if (typeof WeakMap !== "function") return null;
|
|
31
|
-
var cacheBabelInterop = new WeakMap();
|
|
32
|
-
var cacheNodeInterop = new WeakMap();
|
|
33
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
34
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
35
|
-
})(nodeInterop);
|
|
36
|
-
}
|
|
37
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
38
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
39
|
-
return obj;
|
|
40
|
-
}
|
|
41
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
42
|
-
return {
|
|
43
|
-
default: obj
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
47
|
-
if (cache && cache.has(obj)) {
|
|
48
|
-
return cache.get(obj);
|
|
49
|
-
}
|
|
50
|
-
var newObj = {
|
|
51
|
-
__proto__: null
|
|
52
|
-
};
|
|
53
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
54
|
-
for(var key in obj){
|
|
55
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
56
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
57
|
-
if (desc && (desc.get || desc.set)) {
|
|
58
|
-
Object.defineProperty(newObj, key, desc);
|
|
59
|
-
} else {
|
|
60
|
-
newObj[key] = obj[key];
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
newObj.default = obj;
|
|
65
|
-
if (cache) {
|
|
66
|
-
cache.set(obj, newObj);
|
|
67
|
-
}
|
|
68
|
-
return newObj;
|
|
69
|
-
}
|
|
70
29
|
function _ts_decorate(decorators, target, key, desc) {
|
|
71
30
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
72
31
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -171,16 +130,23 @@ let NotificationGateway = class NotificationGateway {
|
|
|
171
130
|
if (!secret) {
|
|
172
131
|
return null;
|
|
173
132
|
}
|
|
174
|
-
return
|
|
133
|
+
return this.jwtService.verify(token, {
|
|
134
|
+
secret,
|
|
135
|
+
algorithms: [
|
|
136
|
+
'HS256'
|
|
137
|
+
]
|
|
138
|
+
});
|
|
175
139
|
} catch {
|
|
176
140
|
return null;
|
|
177
141
|
}
|
|
178
142
|
}
|
|
179
|
-
constructor(configService){
|
|
143
|
+
constructor(configService, jwtService){
|
|
180
144
|
_define_property(this, "configService", void 0);
|
|
145
|
+
_define_property(this, "jwtService", void 0);
|
|
181
146
|
_define_property(this, "connectedUsers", void 0);
|
|
182
147
|
_define_property(this, "server", void 0);
|
|
183
148
|
this.configService = configService;
|
|
149
|
+
this.jwtService = jwtService;
|
|
184
150
|
this.connectedUsers = new Map();
|
|
185
151
|
}
|
|
186
152
|
};
|
|
@@ -197,8 +163,10 @@ NotificationGateway = _ts_decorate([
|
|
|
197
163
|
}
|
|
198
164
|
}),
|
|
199
165
|
_ts_param(0, (0, _common.Inject)(_notificationconfigservice.NotificationConfigService)),
|
|
166
|
+
_ts_param(1, (0, _common.Inject)(_jwt.JwtService)),
|
|
200
167
|
_ts_metadata("design:type", Function),
|
|
201
168
|
_ts_metadata("design:paramtypes", [
|
|
202
|
-
typeof _notificationconfigservice.NotificationConfigService === "undefined" ? Object : _notificationconfigservice.NotificationConfigService
|
|
169
|
+
typeof _notificationconfigservice.NotificationConfigService === "undefined" ? Object : _notificationconfigservice.NotificationConfigService,
|
|
170
|
+
typeof _jwt.JwtService === "undefined" ? Object : _jwt.JwtService
|
|
203
171
|
])
|
|
204
172
|
], NotificationGateway);
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "NotificationModule", {
|
|
|
11
11
|
const _modules = require("@flusys/nestjs-shared/modules");
|
|
12
12
|
const _interfaces = require("@flusys/nestjs-shared/interfaces");
|
|
13
13
|
const _common = require("@nestjs/common");
|
|
14
|
+
const _jwt = require("@nestjs/jwt");
|
|
14
15
|
const _notificationconstants = require("../config/notification.constants");
|
|
15
16
|
const _controllers = require("../controllers");
|
|
16
17
|
const _adapters = require("../adapters");
|
|
@@ -47,6 +48,7 @@ let NotificationModule = class NotificationModule {
|
|
|
47
48
|
controllers: options.includeController !== false ? CONTROLLERS : [],
|
|
48
49
|
providers: [
|
|
49
50
|
...this.buildProviders(options),
|
|
51
|
+
_jwt.JwtService,
|
|
50
52
|
_gateways.NotificationGateway,
|
|
51
53
|
_adapters.NotificationAdapter,
|
|
52
54
|
ADAPTER_PROVIDER
|
|
@@ -71,6 +73,7 @@ let NotificationModule = class NotificationModule {
|
|
|
71
73
|
providers: [
|
|
72
74
|
...this.createAsyncProviders(options),
|
|
73
75
|
...this.buildProviders(),
|
|
76
|
+
_jwt.JwtService,
|
|
74
77
|
_gateways.NotificationGateway,
|
|
75
78
|
_adapters.NotificationAdapter,
|
|
76
79
|
ADAPTER_PROVIDER
|
|
@@ -26,8 +26,8 @@ function _ts_param(paramIndex, decorator) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
import { Inject } from '@nestjs/common';
|
|
29
|
+
import { JwtService } from '@nestjs/jwt';
|
|
29
30
|
import { WebSocketGateway, WebSocketServer } from '@nestjs/websockets';
|
|
30
|
-
import * as jwt from 'jsonwebtoken';
|
|
31
31
|
import { Server } from 'socket.io';
|
|
32
32
|
import { NotificationConfigService } from '../services/notification-config.service';
|
|
33
33
|
export class NotificationGateway {
|
|
@@ -120,16 +120,23 @@ export class NotificationGateway {
|
|
|
120
120
|
if (!secret) {
|
|
121
121
|
return null;
|
|
122
122
|
}
|
|
123
|
-
return
|
|
123
|
+
return this.jwtService.verify(token, {
|
|
124
|
+
secret,
|
|
125
|
+
algorithms: [
|
|
126
|
+
'HS256'
|
|
127
|
+
]
|
|
128
|
+
});
|
|
124
129
|
} catch {
|
|
125
130
|
return null;
|
|
126
131
|
}
|
|
127
132
|
}
|
|
128
|
-
constructor(configService){
|
|
133
|
+
constructor(configService, jwtService){
|
|
129
134
|
_define_property(this, "configService", void 0);
|
|
135
|
+
_define_property(this, "jwtService", void 0);
|
|
130
136
|
_define_property(this, "connectedUsers", void 0);
|
|
131
137
|
_define_property(this, "server", void 0);
|
|
132
138
|
this.configService = configService;
|
|
139
|
+
this.jwtService = jwtService;
|
|
133
140
|
this.connectedUsers = new Map();
|
|
134
141
|
}
|
|
135
142
|
}
|
|
@@ -146,8 +153,10 @@ NotificationGateway = _ts_decorate([
|
|
|
146
153
|
}
|
|
147
154
|
}),
|
|
148
155
|
_ts_param(0, Inject(NotificationConfigService)),
|
|
156
|
+
_ts_param(1, Inject(JwtService)),
|
|
149
157
|
_ts_metadata("design:type", Function),
|
|
150
158
|
_ts_metadata("design:paramtypes", [
|
|
151
|
-
typeof NotificationConfigService === "undefined" ? Object : NotificationConfigService
|
|
159
|
+
typeof NotificationConfigService === "undefined" ? Object : NotificationConfigService,
|
|
160
|
+
typeof JwtService === "undefined" ? Object : JwtService
|
|
152
161
|
])
|
|
153
162
|
], NotificationGateway);
|
|
@@ -7,6 +7,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
7
7
|
import { CacheModule, UtilsModule } from '@flusys/nestjs-shared/modules';
|
|
8
8
|
import { NOTIFICATION_ADAPTER } from '@flusys/nestjs-shared/interfaces';
|
|
9
9
|
import { Module } from '@nestjs/common';
|
|
10
|
+
import { JwtService } from '@nestjs/jwt';
|
|
10
11
|
import { NOTIFICATION_MODULE_OPTIONS } from '../config/notification.constants';
|
|
11
12
|
import { NotificationController } from '../controllers';
|
|
12
13
|
import { NotificationAdapter } from '../adapters';
|
|
@@ -37,6 +38,7 @@ export class NotificationModule {
|
|
|
37
38
|
controllers: options.includeController !== false ? CONTROLLERS : [],
|
|
38
39
|
providers: [
|
|
39
40
|
...this.buildProviders(options),
|
|
41
|
+
JwtService,
|
|
40
42
|
NotificationGateway,
|
|
41
43
|
NotificationAdapter,
|
|
42
44
|
ADAPTER_PROVIDER
|
|
@@ -61,6 +63,7 @@ export class NotificationModule {
|
|
|
61
63
|
providers: [
|
|
62
64
|
...this.createAsyncProviders(options),
|
|
63
65
|
...this.buildProviders(),
|
|
66
|
+
JwtService,
|
|
64
67
|
NotificationGateway,
|
|
65
68
|
NotificationAdapter,
|
|
66
69
|
ADAPTER_PROVIDER
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { JwtService } from '@nestjs/jwt';
|
|
1
2
|
import { OnGatewayConnection, OnGatewayDisconnect, OnGatewayInit } from '@nestjs/websockets';
|
|
2
3
|
import { Server, Socket } from 'socket.io';
|
|
3
4
|
import { NotificationConfigService } from '../services/notification-config.service';
|
|
4
5
|
export declare class NotificationGateway implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect {
|
|
5
6
|
private readonly configService;
|
|
7
|
+
private readonly jwtService;
|
|
6
8
|
private readonly connectedUsers;
|
|
7
9
|
server: Server;
|
|
8
|
-
constructor(configService: NotificationConfigService);
|
|
10
|
+
constructor(configService: NotificationConfigService, jwtService: JwtService);
|
|
9
11
|
afterInit(): void;
|
|
10
12
|
handleConnection(client: Socket): Promise<void>;
|
|
11
13
|
handleDisconnect(client: Socket): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/nestjs-notification",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "Notification module with real-time Socket.IO support",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "fesm/index.js",
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
"@nestjs/common": "^11.0.0",
|
|
81
81
|
"@nestjs/config": "^4.0.0",
|
|
82
82
|
"@nestjs/core": "^11.0.0",
|
|
83
|
+
"@nestjs/jwt": "^11.0.0",
|
|
83
84
|
"@nestjs/platform-express": "^11.0.0",
|
|
84
85
|
"@nestjs/swagger": "^11.0.0",
|
|
85
86
|
"@nestjs/typeorm": "^11.0.0",
|
|
@@ -92,8 +93,7 @@
|
|
|
92
93
|
"express": "^5.0.0"
|
|
93
94
|
},
|
|
94
95
|
"dependencies": {
|
|
95
|
-
"@flusys/nestjs-core": "6.0.
|
|
96
|
-
"@flusys/nestjs-shared": "6.0.
|
|
97
|
-
"jsonwebtoken": "^9.0.0"
|
|
96
|
+
"@flusys/nestjs-core": "6.0.1",
|
|
97
|
+
"@flusys/nestjs-shared": "6.0.1"
|
|
98
98
|
}
|
|
99
99
|
}
|