@nathapp/nestjs-microservices 1.0.0-rc.9 → 1.0.0
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/README.md +1 -1
- package/dist/adapter/adapter.interface.d.ts +179 -0
- package/dist/adapter/adapter.interface.js +3 -0
- package/dist/adapter/adapter.interface.js.map +1 -0
- package/dist/adapter/http-fetch-service.adapter.d.ts +17 -0
- package/dist/adapter/http-fetch-service.adapter.js +147 -0
- package/dist/adapter/http-fetch-service.adapter.js.map +1 -0
- package/dist/adapter/http-service.adapter.d.ts +9 -1
- package/dist/adapter/http-service.adapter.js +53 -12
- package/dist/adapter/http-service.adapter.js.map +1 -0
- package/dist/adapter/index.d.ts +4 -1
- package/dist/adapter/index.js +6 -1
- package/dist/adapter/index.js.map +1 -0
- package/dist/adapter/micro-service-adapter-factory.d.ts +4 -2
- package/dist/adapter/micro-service-adapter-factory.js +44 -1
- package/dist/adapter/micro-service-adapter-factory.js.map +1 -0
- package/dist/adapter/micro-service.adapter.d.ts +13 -12
- package/dist/adapter/micro-service.adapter.js +1 -0
- package/dist/adapter/micro-service.adapter.js.map +1 -0
- package/dist/adapter/nestjs-micro-service.adapter.d.ts +13 -0
- package/dist/adapter/nestjs-micro-service.adapter.js +32 -0
- package/dist/adapter/nestjs-micro-service.adapter.js.map +1 -0
- package/dist/client/base-grpc.service.d.ts +9 -0
- package/dist/client/base-grpc.service.js +14 -0
- package/dist/client/base-grpc.service.js.map +1 -0
- package/dist/client/closeable.interface.js +1 -0
- package/dist/client/closeable.interface.js.map +1 -0
- package/dist/client/constants.d.ts +2 -0
- package/dist/client/constants.js +6 -0
- package/dist/client/constants.js.map +1 -0
- package/dist/client/custom-client-rmq.d.ts +41 -0
- package/dist/client/custom-client-rmq.js +198 -0
- package/dist/client/custom-client-rmq.js.map +1 -0
- package/dist/client/index.d.ts +4 -1
- package/dist/client/index.js +8 -1
- package/dist/client/index.js.map +1 -0
- package/dist/client/jwt-client-grpc.proxy.d.ts +10 -0
- package/dist/client/jwt-client-grpc.proxy.js +132 -0
- package/dist/client/jwt-client-grpc.proxy.js.map +1 -0
- package/dist/client/service-client-factory.js +1 -0
- package/dist/client/service-client-factory.js.map +1 -0
- package/dist/client/service-client.d.ts +9 -3
- package/dist/client/service-client.js +8 -0
- package/dist/client/service-client.js.map +1 -0
- package/dist/constant/index.js +1 -0
- package/dist/constant/index.js.map +1 -0
- package/dist/constant/jwt-constant.js +1 -0
- package/dist/constant/jwt-constant.js.map +1 -0
- package/dist/constant/module-constant.js +1 -0
- package/dist/constant/module-constant.js.map +1 -0
- package/dist/decorator/index.d.ts +3 -2
- package/dist/decorator/index.js +8 -2
- package/dist/decorator/index.js.map +1 -0
- package/dist/decorator/micro-service.decorator.d.ts +2 -1
- package/dist/decorator/micro-service.decorator.js +22 -6
- package/dist/decorator/micro-service.decorator.js.map +1 -0
- package/dist/decorator/protobuf.decorator.d.ts +3 -0
- package/dist/decorator/protobuf.decorator.js +16 -0
- package/dist/decorator/protobuf.decorator.js.map +1 -0
- package/dist/enum/index.js +1 -0
- package/dist/enum/index.js.map +1 -0
- package/dist/enum/transport.enum.d.ts +8 -1
- package/dist/enum/transport.enum.js +10 -2
- package/dist/enum/transport.enum.js.map +1 -0
- package/dist/exception/app-rpc-exception.d.ts +5 -0
- package/dist/exception/app-rpc-exception.js +12 -0
- package/dist/exception/app-rpc-exception.js.map +1 -0
- package/dist/exception/index.d.ts +3 -0
- package/dist/exception/index.js +10 -0
- package/dist/exception/index.js.map +1 -0
- package/dist/exception/utils.d.ts +10 -0
- package/dist/exception/utils.js +41 -0
- package/dist/exception/utils.js.map +1 -0
- package/dist/external/grpc-options.interface.d.ts +16 -0
- package/dist/external/grpc-options.interface.js +3 -0
- package/dist/external/grpc-options.interface.js.map +1 -0
- package/dist/external/kafka.interface.d.ts +1119 -0
- package/dist/external/kafka.interface.js +78 -0
- package/dist/external/kafka.interface.js.map +1 -0
- package/dist/external/mqtt-client.interface.d.ts +30 -0
- package/dist/external/mqtt-client.interface.js +3 -0
- package/dist/external/mqtt-client.interface.js.map +1 -0
- package/dist/external/mqtt-options.interface.d.ts +54 -0
- package/dist/external/mqtt-options.interface.js +3 -0
- package/dist/external/mqtt-options.interface.js.map +1 -0
- package/dist/external/redis.interface.d.ts +52 -0
- package/dist/external/redis.interface.js +3 -0
- package/dist/external/redis.interface.js.map +1 -0
- package/dist/external/rmq-url.interface.d.ts +28 -0
- package/dist/external/rmq-url.interface.js +3 -0
- package/dist/external/rmq-url.interface.js.map +1 -0
- package/dist/filter/gprc-server.exception.filter.d.ts +6 -0
- package/dist/filter/gprc-server.exception.filter.js +22 -0
- package/dist/filter/gprc-server.exception.filter.js.map +1 -0
- package/dist/filter/index.d.ts +3 -0
- package/dist/filter/index.js +8 -0
- package/dist/filter/index.js.map +1 -0
- package/dist/filter/ms-global.exception.filter.d.ts +9 -0
- package/dist/filter/ms-global.exception.filter.js +40 -0
- package/dist/filter/ms-global.exception.filter.js.map +1 -0
- package/dist/guard/index.js +1 -0
- package/dist/guard/index.js.map +1 -0
- package/dist/guard/jwt-ms-auth.guard.js +3 -2
- package/dist/guard/jwt-ms-auth.guard.js.map +1 -0
- package/dist/guard/micro-service.guard.d.ts +4 -1
- package/dist/guard/micro-service.guard.js +33 -4
- package/dist/guard/micro-service.guard.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptor/grpc-to-http.interceptor.d.ts +6 -0
- package/dist/interceptor/grpc-to-http.interceptor.js +32 -0
- package/dist/interceptor/grpc-to-http.interceptor.js.map +1 -0
- package/dist/interceptor/http-to-grpc.interceptor.d.ts +5 -0
- package/dist/interceptor/http-to-grpc.interceptor.js +35 -0
- package/dist/interceptor/http-to-grpc.interceptor.js.map +1 -0
- package/dist/interceptor/index.d.ts +3 -0
- package/dist/interceptor/index.js +8 -0
- package/dist/interceptor/index.js.map +1 -0
- package/dist/module/index.d.ts +2 -2
- package/dist/module/index.js +3 -1
- package/dist/module/index.js.map +1 -0
- package/dist/module/micro-service-clients-module-factory.d.ts +9 -0
- package/dist/module/micro-service-clients-module-factory.js +16 -1
- package/dist/module/micro-service-clients-module-factory.js.map +1 -0
- package/dist/module/micro-service-clients-module.interface.js +1 -0
- package/dist/module/micro-service-clients-module.interface.js.map +1 -0
- package/dist/module/micro-service-clients.module.js +3 -2
- package/dist/module/micro-service-clients.module.js.map +1 -0
- package/dist/module/micro-service.module.d.ts +2 -0
- package/dist/module/micro-service.module.js +7 -4
- package/dist/module/micro-service.module.js.map +1 -0
- package/dist/server/custom-server-rmq.d.ts +27 -0
- package/dist/server/custom-server-rmq.js +160 -0
- package/dist/server/custom-server-rmq.js.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +8 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/server-keepalive.d.ts +7 -0
- package/dist/server/server-keepalive.js +22 -0
- package/dist/server/server-keepalive.js.map +1 -0
- package/dist/strategy/index.js +1 -0
- package/dist/strategy/index.js.map +1 -0
- package/dist/strategy/microservice-jwt-strategy-provider.d.ts +4 -2
- package/dist/strategy/microservice-jwt-strategy-provider.js +2 -1
- package/dist/strategy/microservice-jwt-strategy-provider.js.map +1 -0
- package/dist/strategy/microservice-jwt.strategy.d.ts +1 -0
- package/dist/strategy/microservice-jwt.strategy.js +10 -4
- package/dist/strategy/microservice-jwt.strategy.js.map +1 -0
- package/package.json +65 -25
- package/.eslintrc.js +0 -24
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompressionCodecs = exports.CompressionTypes = exports.logLevel = exports.AssignerProtocol = exports.PartitionAssigners = exports.ResourcePatternTypes = exports.AclOperationTypes = exports.AclPermissionTypes = exports.ConfigSource = exports.ConfigResourceTypes = exports.AclResourceTypes = exports.Partitioners = void 0;
|
|
4
|
+
var AclResourceTypes;
|
|
5
|
+
(function (AclResourceTypes) {
|
|
6
|
+
AclResourceTypes[AclResourceTypes["UNKNOWN"] = 0] = "UNKNOWN";
|
|
7
|
+
AclResourceTypes[AclResourceTypes["ANY"] = 1] = "ANY";
|
|
8
|
+
AclResourceTypes[AclResourceTypes["TOPIC"] = 2] = "TOPIC";
|
|
9
|
+
AclResourceTypes[AclResourceTypes["GROUP"] = 3] = "GROUP";
|
|
10
|
+
AclResourceTypes[AclResourceTypes["CLUSTER"] = 4] = "CLUSTER";
|
|
11
|
+
AclResourceTypes[AclResourceTypes["TRANSACTIONAL_ID"] = 5] = "TRANSACTIONAL_ID";
|
|
12
|
+
AclResourceTypes[AclResourceTypes["DELEGATION_TOKEN"] = 6] = "DELEGATION_TOKEN";
|
|
13
|
+
})(AclResourceTypes || (exports.AclResourceTypes = AclResourceTypes = {}));
|
|
14
|
+
var ConfigResourceTypes;
|
|
15
|
+
(function (ConfigResourceTypes) {
|
|
16
|
+
ConfigResourceTypes[ConfigResourceTypes["UNKNOWN"] = 0] = "UNKNOWN";
|
|
17
|
+
ConfigResourceTypes[ConfigResourceTypes["TOPIC"] = 2] = "TOPIC";
|
|
18
|
+
ConfigResourceTypes[ConfigResourceTypes["BROKER"] = 4] = "BROKER";
|
|
19
|
+
ConfigResourceTypes[ConfigResourceTypes["BROKER_LOGGER"] = 8] = "BROKER_LOGGER";
|
|
20
|
+
})(ConfigResourceTypes || (exports.ConfigResourceTypes = ConfigResourceTypes = {}));
|
|
21
|
+
var ConfigSource;
|
|
22
|
+
(function (ConfigSource) {
|
|
23
|
+
ConfigSource[ConfigSource["UNKNOWN"] = 0] = "UNKNOWN";
|
|
24
|
+
ConfigSource[ConfigSource["TOPIC_CONFIG"] = 1] = "TOPIC_CONFIG";
|
|
25
|
+
ConfigSource[ConfigSource["DYNAMIC_BROKER_CONFIG"] = 2] = "DYNAMIC_BROKER_CONFIG";
|
|
26
|
+
ConfigSource[ConfigSource["DYNAMIC_DEFAULT_BROKER_CONFIG"] = 3] = "DYNAMIC_DEFAULT_BROKER_CONFIG";
|
|
27
|
+
ConfigSource[ConfigSource["STATIC_BROKER_CONFIG"] = 4] = "STATIC_BROKER_CONFIG";
|
|
28
|
+
ConfigSource[ConfigSource["DEFAULT_CONFIG"] = 5] = "DEFAULT_CONFIG";
|
|
29
|
+
ConfigSource[ConfigSource["DYNAMIC_BROKER_LOGGER_CONFIG"] = 6] = "DYNAMIC_BROKER_LOGGER_CONFIG";
|
|
30
|
+
})(ConfigSource || (exports.ConfigSource = ConfigSource = {}));
|
|
31
|
+
var AclPermissionTypes;
|
|
32
|
+
(function (AclPermissionTypes) {
|
|
33
|
+
AclPermissionTypes[AclPermissionTypes["UNKNOWN"] = 0] = "UNKNOWN";
|
|
34
|
+
AclPermissionTypes[AclPermissionTypes["ANY"] = 1] = "ANY";
|
|
35
|
+
AclPermissionTypes[AclPermissionTypes["DENY"] = 2] = "DENY";
|
|
36
|
+
AclPermissionTypes[AclPermissionTypes["ALLOW"] = 3] = "ALLOW";
|
|
37
|
+
})(AclPermissionTypes || (exports.AclPermissionTypes = AclPermissionTypes = {}));
|
|
38
|
+
var AclOperationTypes;
|
|
39
|
+
(function (AclOperationTypes) {
|
|
40
|
+
AclOperationTypes[AclOperationTypes["UNKNOWN"] = 0] = "UNKNOWN";
|
|
41
|
+
AclOperationTypes[AclOperationTypes["ANY"] = 1] = "ANY";
|
|
42
|
+
AclOperationTypes[AclOperationTypes["ALL"] = 2] = "ALL";
|
|
43
|
+
AclOperationTypes[AclOperationTypes["READ"] = 3] = "READ";
|
|
44
|
+
AclOperationTypes[AclOperationTypes["WRITE"] = 4] = "WRITE";
|
|
45
|
+
AclOperationTypes[AclOperationTypes["CREATE"] = 5] = "CREATE";
|
|
46
|
+
AclOperationTypes[AclOperationTypes["DELETE"] = 6] = "DELETE";
|
|
47
|
+
AclOperationTypes[AclOperationTypes["ALTER"] = 7] = "ALTER";
|
|
48
|
+
AclOperationTypes[AclOperationTypes["DESCRIBE"] = 8] = "DESCRIBE";
|
|
49
|
+
AclOperationTypes[AclOperationTypes["CLUSTER_ACTION"] = 9] = "CLUSTER_ACTION";
|
|
50
|
+
AclOperationTypes[AclOperationTypes["DESCRIBE_CONFIGS"] = 10] = "DESCRIBE_CONFIGS";
|
|
51
|
+
AclOperationTypes[AclOperationTypes["ALTER_CONFIGS"] = 11] = "ALTER_CONFIGS";
|
|
52
|
+
AclOperationTypes[AclOperationTypes["IDEMPOTENT_WRITE"] = 12] = "IDEMPOTENT_WRITE";
|
|
53
|
+
})(AclOperationTypes || (exports.AclOperationTypes = AclOperationTypes = {}));
|
|
54
|
+
var ResourcePatternTypes;
|
|
55
|
+
(function (ResourcePatternTypes) {
|
|
56
|
+
ResourcePatternTypes[ResourcePatternTypes["UNKNOWN"] = 0] = "UNKNOWN";
|
|
57
|
+
ResourcePatternTypes[ResourcePatternTypes["ANY"] = 1] = "ANY";
|
|
58
|
+
ResourcePatternTypes[ResourcePatternTypes["MATCH"] = 2] = "MATCH";
|
|
59
|
+
ResourcePatternTypes[ResourcePatternTypes["LITERAL"] = 3] = "LITERAL";
|
|
60
|
+
ResourcePatternTypes[ResourcePatternTypes["PREFIXED"] = 4] = "PREFIXED";
|
|
61
|
+
})(ResourcePatternTypes || (exports.ResourcePatternTypes = ResourcePatternTypes = {}));
|
|
62
|
+
var logLevel;
|
|
63
|
+
(function (logLevel) {
|
|
64
|
+
logLevel[logLevel["NOTHING"] = 0] = "NOTHING";
|
|
65
|
+
logLevel[logLevel["ERROR"] = 1] = "ERROR";
|
|
66
|
+
logLevel[logLevel["WARN"] = 2] = "WARN";
|
|
67
|
+
logLevel[logLevel["INFO"] = 4] = "INFO";
|
|
68
|
+
logLevel[logLevel["DEBUG"] = 5] = "DEBUG";
|
|
69
|
+
})(logLevel || (exports.logLevel = logLevel = {}));
|
|
70
|
+
var CompressionTypes;
|
|
71
|
+
(function (CompressionTypes) {
|
|
72
|
+
CompressionTypes[CompressionTypes["None"] = 0] = "None";
|
|
73
|
+
CompressionTypes[CompressionTypes["GZIP"] = 1] = "GZIP";
|
|
74
|
+
CompressionTypes[CompressionTypes["Snappy"] = 2] = "Snappy";
|
|
75
|
+
CompressionTypes[CompressionTypes["LZ4"] = 3] = "LZ4";
|
|
76
|
+
CompressionTypes[CompressionTypes["ZSTD"] = 4] = "ZSTD";
|
|
77
|
+
})(CompressionTypes || (exports.CompressionTypes = CompressionTypes = {}));
|
|
78
|
+
//# sourceMappingURL=kafka.interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kafka.interface.js","sourceRoot":"","sources":["../../lib/external/kafka.interface.ts"],"names":[],"mappings":";;;AA4RA,IAAY,gBAQX;AARD,WAAY,gBAAgB;IAC1B,6DAAW,CAAA;IACX,qDAAO,CAAA;IACP,yDAAS,CAAA;IACT,yDAAS,CAAA;IACT,6DAAW,CAAA;IACX,+EAAoB,CAAA;IACpB,+EAAoB,CAAA;AACtB,CAAC,EARW,gBAAgB,gCAAhB,gBAAgB,QAQ3B;AAED,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAC7B,mEAAW,CAAA;IACX,+DAAS,CAAA;IACT,iEAAU,CAAA;IACV,+EAAiB,CAAA;AACnB,CAAC,EALW,mBAAmB,mCAAnB,mBAAmB,QAK9B;AAED,IAAY,YAQX;AARD,WAAY,YAAY;IACtB,qDAAW,CAAA;IACX,+DAAgB,CAAA;IAChB,iFAAyB,CAAA;IACzB,iGAAiC,CAAA;IACjC,+EAAwB,CAAA;IACxB,mEAAkB,CAAA;IAClB,+FAAgC,CAAA;AAClC,CAAC,EARW,YAAY,4BAAZ,YAAY,QAQvB;AAED,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,iEAAW,CAAA;IACX,yDAAO,CAAA;IACP,2DAAQ,CAAA;IACR,6DAAS,CAAA;AACX,CAAC,EALW,kBAAkB,kCAAlB,kBAAkB,QAK7B;AAED,IAAY,iBAcX;AAdD,WAAY,iBAAiB;IAC3B,+DAAW,CAAA;IACX,uDAAO,CAAA;IACP,uDAAO,CAAA;IACP,yDAAQ,CAAA;IACR,2DAAS,CAAA;IACT,6DAAU,CAAA;IACV,6DAAU,CAAA;IACV,2DAAS,CAAA;IACT,iEAAY,CAAA;IACZ,6EAAkB,CAAA;IAClB,kFAAqB,CAAA;IACrB,4EAAkB,CAAA;IAClB,kFAAqB,CAAA;AACvB,CAAC,EAdW,iBAAiB,iCAAjB,iBAAiB,QAc5B;AAED,IAAY,oBAMX;AAND,WAAY,oBAAoB;IAC9B,qEAAW,CAAA;IACX,6DAAO,CAAA;IACP,iEAAS,CAAA;IACT,qEAAW,CAAA;IACX,uEAAY,CAAA;AACd,CAAC,EANW,oBAAoB,oCAApB,oBAAoB,QAM/B;AAqRD,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,6CAAW,CAAA;IACX,yCAAS,CAAA;IACT,uCAAQ,CAAA;IACR,uCAAQ,CAAA;IACR,yCAAS,CAAA;AACX,CAAC,EANW,QAAQ,wBAAR,QAAQ,QAMnB;AAkgBD,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,uDAAQ,CAAA;IACR,uDAAQ,CAAA;IACR,2DAAU,CAAA;IACV,qDAAO,CAAA;IACP,uDAAQ,CAAA;AACV,CAAC,EANW,gBAAgB,gCAAhB,gBAAgB,QAM3B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
export declare class MqttClient extends EventEmitter {
|
|
3
|
+
connected: boolean;
|
|
4
|
+
disconnecting: boolean;
|
|
5
|
+
disconnected: boolean;
|
|
6
|
+
reconnecting: boolean;
|
|
7
|
+
incomingStore: any;
|
|
8
|
+
outgoingStore: any;
|
|
9
|
+
options: any;
|
|
10
|
+
queueQoSZero: boolean;
|
|
11
|
+
constructor(streamBuilder: (client: MqttClient) => any, options: any);
|
|
12
|
+
on(event: 'message', cb: any): this;
|
|
13
|
+
on(event: 'packetsend' | 'packetreceive', cb: any): this;
|
|
14
|
+
on(event: 'error', cb: any): this;
|
|
15
|
+
on(event: string, cb: Function): this;
|
|
16
|
+
once(event: 'message', cb: any): this;
|
|
17
|
+
once(event: 'packetsend' | 'packetreceive', cb: any): this;
|
|
18
|
+
once(event: 'error', cb: any): this;
|
|
19
|
+
once(event: string, cb: Function): this;
|
|
20
|
+
publish(topic: string, message: string | Buffer, opts: any, callback?: any): this;
|
|
21
|
+
publish(topic: string, message: string | Buffer, callback?: any): this;
|
|
22
|
+
subscribe(topic: string | string[], opts: any, callback?: any): this;
|
|
23
|
+
subscribe(topic: string | string[] | any, callback?: any): this;
|
|
24
|
+
unsubscribe(topic: string | string[], callback?: any): this;
|
|
25
|
+
end(force?: boolean, cb?: any): this;
|
|
26
|
+
removeOutgoingMessage(mid: number): this;
|
|
27
|
+
reconnect(opts?: any): this;
|
|
28
|
+
handleMessage(packet: any, callback: any): void;
|
|
29
|
+
getLastMessageId(): number;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mqtt-client.interface.js","sourceRoot":"","sources":["../../lib/external/mqtt-client.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export declare type QoS = 0 | 1 | 2;
|
|
2
|
+
export interface MqttClientOptions extends ISecureClientOptions {
|
|
3
|
+
port?: number;
|
|
4
|
+
host?: string;
|
|
5
|
+
hostname?: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
protocol?: 'wss' | 'ws' | 'mqtt' | 'mqtts' | 'tcp' | 'ssl' | 'wx' | 'wxs';
|
|
8
|
+
wsOptions?: {
|
|
9
|
+
[x: string]: any;
|
|
10
|
+
};
|
|
11
|
+
keepalive?: number;
|
|
12
|
+
clientId?: string;
|
|
13
|
+
protocolId?: string;
|
|
14
|
+
protocolVersion?: number;
|
|
15
|
+
clean?: boolean;
|
|
16
|
+
reconnectPeriod?: number;
|
|
17
|
+
connectTimeout?: number;
|
|
18
|
+
username?: string;
|
|
19
|
+
password?: string;
|
|
20
|
+
incomingStore?: any;
|
|
21
|
+
outgoingStore?: any;
|
|
22
|
+
queueQoSZero?: boolean;
|
|
23
|
+
reschedulePings?: boolean;
|
|
24
|
+
servers?: Array<{
|
|
25
|
+
host: string;
|
|
26
|
+
port: number;
|
|
27
|
+
}>;
|
|
28
|
+
resubscribe?: boolean;
|
|
29
|
+
will?: {
|
|
30
|
+
topic: string;
|
|
31
|
+
payload: string;
|
|
32
|
+
qos: QoS;
|
|
33
|
+
retain: boolean;
|
|
34
|
+
};
|
|
35
|
+
transformWsUrl?: (url: string, options: any, client: any) => string;
|
|
36
|
+
}
|
|
37
|
+
export interface ISecureClientOptions {
|
|
38
|
+
key?: string | string[] | Buffer | Buffer[] | Record<string, any>[];
|
|
39
|
+
cert?: string | string[] | Buffer | Buffer[];
|
|
40
|
+
ca?: string | string[] | Buffer | Buffer[];
|
|
41
|
+
rejectUnauthorized?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface IClientPublishOptions {
|
|
44
|
+
qos: QoS;
|
|
45
|
+
retain?: boolean;
|
|
46
|
+
dup?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface IClientSubscribeOptions {
|
|
49
|
+
qos: QoS;
|
|
50
|
+
}
|
|
51
|
+
export interface IClientReconnectOptions {
|
|
52
|
+
incomingStore?: any;
|
|
53
|
+
outgoingStore?: any;
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mqtt-options.interface.js","sourceRoot":"","sources":["../../lib/external/mqtt-options.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ConnectionOptions } from 'tls';
|
|
2
|
+
export interface IORedisOptions {
|
|
3
|
+
Connector?: any;
|
|
4
|
+
retryStrategy?: (times: number) => number | void | null;
|
|
5
|
+
commandTimeout?: number;
|
|
6
|
+
keepAlive?: number;
|
|
7
|
+
noDelay?: boolean;
|
|
8
|
+
connectionName?: string;
|
|
9
|
+
username?: string;
|
|
10
|
+
password?: string;
|
|
11
|
+
db?: number;
|
|
12
|
+
autoResubscribe?: boolean;
|
|
13
|
+
autoResendUnfulfilledCommands?: boolean;
|
|
14
|
+
reconnectOnError?: ((err: Error) => boolean | 1 | 2) | null;
|
|
15
|
+
readOnly?: boolean;
|
|
16
|
+
stringNumbers?: boolean;
|
|
17
|
+
connectTimeout?: number;
|
|
18
|
+
monitor?: boolean;
|
|
19
|
+
maxRetriesPerRequest?: number | null;
|
|
20
|
+
maxLoadingRetryTime?: number;
|
|
21
|
+
enableAutoPipelining?: boolean;
|
|
22
|
+
autoPipeliningIgnoredCommands?: string[];
|
|
23
|
+
offlineQueue?: boolean;
|
|
24
|
+
commandQueue?: boolean;
|
|
25
|
+
enableOfflineQueue?: boolean;
|
|
26
|
+
enableReadyCheck?: boolean;
|
|
27
|
+
lazyConnect?: boolean;
|
|
28
|
+
scripts?: Record<string, {
|
|
29
|
+
lua: string;
|
|
30
|
+
numberOfKeys?: number;
|
|
31
|
+
readOnly?: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
keyPrefix?: string;
|
|
34
|
+
showFriendlyErrorStack?: boolean;
|
|
35
|
+
disconnectTimeout?: number;
|
|
36
|
+
tls?: ConnectionOptions;
|
|
37
|
+
name?: string;
|
|
38
|
+
role?: 'master' | 'slave';
|
|
39
|
+
sentinelUsername?: string;
|
|
40
|
+
sentinelPassword?: string;
|
|
41
|
+
sentinels?: Array<Partial<any>>;
|
|
42
|
+
sentinelRetryStrategy?: (retryAttempts: number) => number | void | null;
|
|
43
|
+
sentinelReconnectStrategy?: (retryAttempts: number) => number | void | null;
|
|
44
|
+
preferredSlaves?: any;
|
|
45
|
+
sentinelCommandTimeout?: number;
|
|
46
|
+
enableTLSForSentinelMode?: boolean;
|
|
47
|
+
sentinelTLS?: ConnectionOptions;
|
|
48
|
+
natMap?: any;
|
|
49
|
+
updateSentinels?: boolean;
|
|
50
|
+
sentinelMaxConnections?: number;
|
|
51
|
+
failoverDetector?: boolean;
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.interface.js","sourceRoot":"","sources":["../../lib/external/redis.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface RmqUrl {
|
|
2
|
+
protocol?: string;
|
|
3
|
+
hostname?: string;
|
|
4
|
+
port?: number;
|
|
5
|
+
username?: string;
|
|
6
|
+
password?: string;
|
|
7
|
+
locale?: string;
|
|
8
|
+
frameMax?: number;
|
|
9
|
+
heartbeat?: number;
|
|
10
|
+
vhost?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface AmqpConnectionManagerSocketOptions {
|
|
13
|
+
reconnectTimeInSeconds?: number;
|
|
14
|
+
heartbeatIntervalInSeconds?: number;
|
|
15
|
+
findServers?: () => string | string[];
|
|
16
|
+
connectionOptions?: any;
|
|
17
|
+
}
|
|
18
|
+
export interface AmqplibQueueOptions {
|
|
19
|
+
durable?: boolean;
|
|
20
|
+
autoDelete?: boolean;
|
|
21
|
+
arguments?: any;
|
|
22
|
+
messageTtl?: number;
|
|
23
|
+
expires?: number;
|
|
24
|
+
deadLetterExchange?: string;
|
|
25
|
+
deadLetterRoutingKey?: string;
|
|
26
|
+
maxLength?: number;
|
|
27
|
+
maxPriority?: number;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rmq-url.interface.js","sourceRoot":"","sources":["../../lib/external/rmq-url.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RpcExceptionFilter } from "@nestjs/common";
|
|
2
|
+
import { RpcException } from "@nestjs/microservices";
|
|
3
|
+
import { Observable } from "rxjs";
|
|
4
|
+
export declare class GrpcServerExceptionFilter implements RpcExceptionFilter<RpcException> {
|
|
5
|
+
catch(exception: RpcException): Observable<any>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __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
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.GrpcServerExceptionFilter = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const microservices_1 = require("@nestjs/microservices");
|
|
12
|
+
const rxjs_1 = require("rxjs");
|
|
13
|
+
let GrpcServerExceptionFilter = class GrpcServerExceptionFilter {
|
|
14
|
+
catch(exception) {
|
|
15
|
+
return (0, rxjs_1.throwError)(() => exception.getError());
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.GrpcServerExceptionFilter = GrpcServerExceptionFilter;
|
|
19
|
+
exports.GrpcServerExceptionFilter = GrpcServerExceptionFilter = __decorate([
|
|
20
|
+
(0, common_1.Catch)(microservices_1.RpcException)
|
|
21
|
+
], GrpcServerExceptionFilter);
|
|
22
|
+
//# sourceMappingURL=gprc-server.exception.filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gprc-server.exception.filter.js","sourceRoot":"","sources":["../../lib/filter/gprc-server.exception.filter.ts"],"names":[],"mappings":";;;;;;;;;AAIA,2CAA2D;AAC3D,yDAAqD;AACrD,+BAA8C;AAGvC,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAGpC,KAAK,CAAC,SAAuB;QAC3B,OAAO,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;IAChD,CAAC;CACF,CAAA;AANY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,cAAK,EAAC,4BAAY,CAAC;GACP,yBAAyB,CAMrC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MicroServiceGlobalExceptionFilter = exports.GrpcServerExceptionFilter = void 0;
|
|
4
|
+
const gprc_server_exception_filter_1 = require("./gprc-server.exception.filter");
|
|
5
|
+
Object.defineProperty(exports, "GrpcServerExceptionFilter", { enumerable: true, get: function () { return gprc_server_exception_filter_1.GrpcServerExceptionFilter; } });
|
|
6
|
+
const ms_global_exception_filter_1 = require("./ms-global.exception.filter");
|
|
7
|
+
Object.defineProperty(exports, "MicroServiceGlobalExceptionFilter", { enumerable: true, get: function () { return ms_global_exception_filter_1.MicroServiceGlobalExceptionFilter; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/filter/index.ts"],"names":[],"mappings":";;;AAAA,iFAA2E;AAIzE,0GAJO,wDAAyB,OAIP;AAH3B,6EAAiF;AAI/E,kHAJO,8DAAiC,OAIP"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GlobalExceptionsFilter } from '@nathapp/nestjs-common';
|
|
2
|
+
import { ArgumentsHost } from '@nestjs/common';
|
|
3
|
+
import { HttpAdapterHost } from '@nestjs/core';
|
|
4
|
+
import { I18nService } from 'nestjs-i18n';
|
|
5
|
+
export declare class MicroServiceGlobalExceptionFilter extends GlobalExceptionsFilter {
|
|
6
|
+
private mlogger;
|
|
7
|
+
constructor(httpAdapterHost: HttpAdapterHost, i18nService: I18nService);
|
|
8
|
+
catch(exception: any, host: ArgumentsHost): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __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
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var MicroServiceGlobalExceptionFilter_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.MicroServiceGlobalExceptionFilter = void 0;
|
|
14
|
+
const nestjs_common_1 = require("@nathapp/nestjs-common");
|
|
15
|
+
const common_1 = require("@nestjs/common");
|
|
16
|
+
const core_1 = require("@nestjs/core");
|
|
17
|
+
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
18
|
+
const exception_1 = require("../exception");
|
|
19
|
+
let MicroServiceGlobalExceptionFilter = MicroServiceGlobalExceptionFilter_1 = class MicroServiceGlobalExceptionFilter extends nestjs_common_1.GlobalExceptionsFilter {
|
|
20
|
+
constructor(httpAdapterHost, i18nService) {
|
|
21
|
+
super(httpAdapterHost, i18nService);
|
|
22
|
+
this.mlogger = new common_1.Logger(MicroServiceGlobalExceptionFilter_1.name);
|
|
23
|
+
}
|
|
24
|
+
async catch(exception, host) {
|
|
25
|
+
if ((exception === null || exception === void 0 ? void 0 : exception.name) == 'Error') {
|
|
26
|
+
if ((0, exception_1.isGrpcError)(exception)) {
|
|
27
|
+
const newException = (0, exception_1.resolveGrpcErrorToException)(exception, this.mlogger);
|
|
28
|
+
super.catch(newException, host);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
super.catch(exception, host);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.MicroServiceGlobalExceptionFilter = MicroServiceGlobalExceptionFilter;
|
|
36
|
+
exports.MicroServiceGlobalExceptionFilter = MicroServiceGlobalExceptionFilter = MicroServiceGlobalExceptionFilter_1 = __decorate([
|
|
37
|
+
(0, common_1.Catch)(),
|
|
38
|
+
__metadata("design:paramtypes", [core_1.HttpAdapterHost, nestjs_i18n_1.I18nService])
|
|
39
|
+
], MicroServiceGlobalExceptionFilter);
|
|
40
|
+
//# sourceMappingURL=ms-global.exception.filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ms-global.exception.filter.js","sourceRoot":"","sources":["../../lib/filter/ms-global.exception.filter.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,0DAA8E;AAC9E,2CAA8D;AAC9D,uCAA+C;AAE/C,6CAA0C;AAC1C,4CAAwE;AAMjE,IAAM,iCAAiC,yCAAvC,MAAM,iCAAkC,SAAQ,sCAAsB;IAG3E,YAAY,eAAgC,EAAE,WAAwB;QACpE,KAAK,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;QAH9B,YAAO,GAAG,IAAI,eAAM,CAAC,mCAAiC,CAAC,IAAI,CAAC,CAAC;IAIrE,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,SAAc,EAAE,IAAmB;QAE7C,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,KAAI,OAAO,EAAE,CAAC;YAC/B,IAAI,IAAA,uBAAW,EAAC,SAAS,CAAC,EAAE,CAAC;gBAC3B,MAAM,YAAY,GAAG,IAAA,uCAA2B,EAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;gBAC1E,KAAK,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;gBAChC,OAAO;YACT,CAAC;QACH,CAAC;QAED,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF,CAAA;AAnBY,8EAAiC;4CAAjC,iCAAiC;IAD7C,IAAA,cAAK,GAAE;qCAIuB,sBAAe,EAAe,yBAAW;GAH3D,iCAAiC,CAmB7C"}
|
package/dist/guard/index.js
CHANGED
|
@@ -5,3 +5,4 @@ const jwt_ms_auth_guard_1 = require("./jwt-ms-auth.guard");
|
|
|
5
5
|
Object.defineProperty(exports, "JwtMsAuthGuard", { enumerable: true, get: function () { return jwt_ms_auth_guard_1.JwtMsAuthGuard; } });
|
|
6
6
|
const micro_service_guard_1 = require("./micro-service.guard");
|
|
7
7
|
Object.defineProperty(exports, "MicroServiceJwtAuthGuard", { enumerable: true, get: function () { return micro_service_guard_1.MicroServiceJwtAuthGuard; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/guard/index.ts"],"names":[],"mappings":";;;AAAA,2DAAqD;AAInD,+FAJO,kCAAc,OAIP;AAHhB,+DAAiE;AAI/D,yGAJO,8CAAwB,OAIP"}
|
|
@@ -59,8 +59,9 @@ let JwtMsAuthGuard = JwtMsAuthGuard_1 = class JwtMsAuthGuard extends (0, passpor
|
|
|
59
59
|
return user;
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
JwtMsAuthGuard =
|
|
62
|
+
exports.JwtMsAuthGuard = JwtMsAuthGuard;
|
|
63
|
+
exports.JwtMsAuthGuard = JwtMsAuthGuard = JwtMsAuthGuard_1 = __decorate([
|
|
63
64
|
(0, common_1.Injectable)(),
|
|
64
65
|
__metadata("design:paramtypes", [core_1.Reflector])
|
|
65
66
|
], JwtMsAuthGuard);
|
|
66
|
-
|
|
67
|
+
//# sourceMappingURL=jwt-ms-auth.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-ms-auth.guard.js","sourceRoot":"","sources":["../../lib/guard/jwt-ms-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,sDAAuF;AACvF,0DAA2E;AAC3E,2CAAsE;AACtE,uCAAyC;AACzC,+CAA6C;AAC7C,4CAAkD;AAO3C,IAAM,cAAc,sBAApB,MAAM,cAAe,SAAQ,IAAA,oBAAS,EAAC,+BAAiB,CAAC;IAI9D,YAAoB,SAAoB;QACtC,KAAK,EAAE,CAAC;QADU,cAAS,GAAT,SAAS,CAAW;QAFvB,WAAM,GAAG,IAAI,eAAM,CAAC,gBAAc,CAAC,IAAI,CAAC,CAAC;IAI1D,CAAC;IAED,WAAW,CAAC,OAAyB;QACnC,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QAEjC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAU,2BAAa,EAAE;YACxE,OAAO;YACP,KAAK;SACN,CAAC,CAAC;QAEH,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAU,2BAAa,EAAE;YAC5E,OAAO;YACP,KAAK;SACN,CAAC,CAAC;QAEH,MAAM,uBAAuB,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAU,8BAAkB,EAAE;YAC5F,OAAO;YACP,KAAK;SACN,CAAC,CAAC;QACH,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,kCAAkC,KAAK,CAAC,IAAI,aAAa,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAC7F,OAAO,IAAI,CAAC;QACd,CAAC;QACD,IAAI,YAAY,EAAE,CAAC;YACjB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,sCAAsC,KAAK,CAAC,IAAI,aAAa,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YACjG,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,uBAAuB,EAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,qCAAqC,KAAK,CAAC,IAAI,aAAa,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YAChG,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI;QAE3B,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,GAAG,IAAI,IAAI,4BAAY,CAAC,mCAAmB,CAAC,YAAY,CAAC,CAAC;QAClE,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAnDY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;qCAKoB,gBAAS;GAJ7B,cAAc,CAmD1B"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { ExecutionContext } from "@nestjs/common";
|
|
2
2
|
import { Reflector } from "@nestjs/core";
|
|
3
|
+
import { MicroServiceStrategyProvider } from "../strategy";
|
|
3
4
|
declare const MicroServiceJwtAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
|
4
5
|
export declare class MicroServiceJwtAuthGuard extends MicroServiceJwtAuthGuard_base {
|
|
5
6
|
private reflector;
|
|
7
|
+
private readonly strategyProvider;
|
|
6
8
|
private readonly logger;
|
|
7
|
-
constructor(reflector: Reflector);
|
|
9
|
+
constructor(reflector: Reflector, strategyProvider: MicroServiceStrategyProvider);
|
|
8
10
|
canActivate(context: ExecutionContext): boolean | Promise<boolean> | import("rxjs").Observable<boolean>;
|
|
9
11
|
handleRequest(err: any, user: any, info: any): any;
|
|
12
|
+
canActivateGrpc(context: ExecutionContext): Promise<boolean>;
|
|
10
13
|
}
|
|
11
14
|
export {};
|
|
@@ -17,10 +17,12 @@ const core_1 = require("@nestjs/core");
|
|
|
17
17
|
const passport_1 = require("@nestjs/passport");
|
|
18
18
|
const constant_1 = require("../constant");
|
|
19
19
|
const decorator_1 = require("../decorator");
|
|
20
|
+
const strategy_1 = require("../strategy");
|
|
20
21
|
let MicroServiceJwtAuthGuard = MicroServiceJwtAuthGuard_1 = class MicroServiceJwtAuthGuard extends (0, passport_1.AuthGuard)(constant_1.MICROSERVICE_STRATEGY_NAME) {
|
|
21
|
-
constructor(reflector) {
|
|
22
|
+
constructor(reflector, strategyProvider) {
|
|
22
23
|
super();
|
|
23
24
|
this.reflector = reflector;
|
|
25
|
+
this.strategyProvider = strategyProvider;
|
|
24
26
|
this.logger = new common_1.Logger(MicroServiceJwtAuthGuard_1.name);
|
|
25
27
|
}
|
|
26
28
|
canActivate(context) {
|
|
@@ -34,6 +36,10 @@ let MicroServiceJwtAuthGuard = MicroServiceJwtAuthGuard_1 = class MicroServiceJw
|
|
|
34
36
|
this.logger.verbose(`is not isMicroServices decorator, class: ${clazz.name}, method: ${handler.name}`);
|
|
35
37
|
return true;
|
|
36
38
|
}
|
|
39
|
+
const type = context.getType();
|
|
40
|
+
if (type === 'rpc') {
|
|
41
|
+
return this.canActivateGrpc(context);
|
|
42
|
+
}
|
|
37
43
|
return super.canActivate(context);
|
|
38
44
|
}
|
|
39
45
|
handleRequest(err, user, info) {
|
|
@@ -42,9 +48,32 @@ let MicroServiceJwtAuthGuard = MicroServiceJwtAuthGuard_1 = class MicroServiceJw
|
|
|
42
48
|
}
|
|
43
49
|
return user;
|
|
44
50
|
}
|
|
51
|
+
async canActivateGrpc(context) {
|
|
52
|
+
let header;
|
|
53
|
+
const rpcContext = context.switchToRpc();
|
|
54
|
+
const request = rpcContext.getContext();
|
|
55
|
+
const data = rpcContext.getData();
|
|
56
|
+
const prefix = 'Bearer ';
|
|
57
|
+
const metadata = context.getArgByIndex(1);
|
|
58
|
+
if (!metadata) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
header = metadata.get('Authorization')[0];
|
|
62
|
+
if (!header || !header.includes(prefix)) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
const token = header.slice(header.indexOf(' ') + 1);
|
|
66
|
+
const payload = this.strategyProvider.verify(token);
|
|
67
|
+
if (payload === undefined) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
request.user = payload;
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
45
73
|
};
|
|
46
|
-
MicroServiceJwtAuthGuard =
|
|
74
|
+
exports.MicroServiceJwtAuthGuard = MicroServiceJwtAuthGuard;
|
|
75
|
+
exports.MicroServiceJwtAuthGuard = MicroServiceJwtAuthGuard = MicroServiceJwtAuthGuard_1 = __decorate([
|
|
47
76
|
(0, common_1.Injectable)(),
|
|
48
|
-
__metadata("design:paramtypes", [core_1.Reflector])
|
|
77
|
+
__metadata("design:paramtypes", [core_1.Reflector, strategy_1.MicroServiceStrategyProvider])
|
|
49
78
|
], MicroServiceJwtAuthGuard);
|
|
50
|
-
|
|
79
|
+
//# sourceMappingURL=micro-service.guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"micro-service.guard.js","sourceRoot":"","sources":["../../lib/guard/micro-service.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,0DAA2E;AAC3E,2CAAsE;AACtE,uCAAyC;AACzC,+CAA6C;AAC7C,0CAAyD;AACzD,4CAAkD;AAClD,0CAA2D;AAMpD,IAAM,wBAAwB,gCAA9B,MAAM,wBAAyB,SAAQ,IAAA,oBAAS,EAAC,qCAA0B,CAAC;IAIjF,YAAoB,SAAoB,EAAmB,gBAA8C;QACvG,KAAK,EAAE,CAAC;QADU,cAAS,GAAT,SAAS,CAAW;QAAmB,qBAAgB,GAAhB,gBAAgB,CAA8B;QAFxF,WAAM,GAAG,IAAI,eAAM,CAAC,0BAAwB,CAAC,IAAI,CAAC,CAAC;IAIpE,CAAC;IAED,WAAW,CAAC,OAAyB;QACnC,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QAEjC,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAU,8BAAkB,EAAE;YACpF,OAAO;YACP,KAAK;SACN,CAAC,CAAC;QAGH,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,4CAA4C,KAAK,CAAC,IAAI,aAAa,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YACvG,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QAE/B,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;YACnB,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,aAAa,CAAC,GAAQ,EAAE,IAAS,EAAE,IAAS;QAE1C,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YACjB,MAAM,GAAG,IAAI,IAAI,4BAAY,CAAC,mCAAmB,CAAC,YAAY,CAAC,CAAC;QAClE,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,OAAyB;QAC7C,IAAI,MAAW,CAAC;QAChB,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC;QACxC,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,EAAE,CAAC;QAElC,MAAM,MAAM,GAAG,SAAS,CAAC;QACzB,MAAM,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1C,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACxC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAEpD,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACnD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC;QAMvB,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAxEY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;qCAKoB,gBAAS,EAAqC,uCAA4B;GAJ9F,wBAAwB,CAwEpC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -21,4 +21,9 @@ __exportStar(require("./decorator"), exports);
|
|
|
21
21
|
__exportStar(require("./enum"), exports);
|
|
22
22
|
__exportStar(require("./guard"), exports);
|
|
23
23
|
__exportStar(require("./module"), exports);
|
|
24
|
+
__exportStar(require("./server"), exports);
|
|
24
25
|
__exportStar(require("./strategy"), exports);
|
|
26
|
+
__exportStar(require("./exception"), exports);
|
|
27
|
+
__exportStar(require("./filter"), exports);
|
|
28
|
+
__exportStar(require("./interceptor"), exports);
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,2CAAyB;AACzB,6CAA2B;AAC3B,8CAA4B;AAC5B,yCAAuB;AACvB,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,6CAA2B;AAC3B,8CAA4B;AAC5B,2CAAyB;AACzB,gDAA8B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CallHandler, ExecutionContext, NestInterceptor } from "@nestjs/common";
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
export declare class GrpcToHttpInterceptor implements NestInterceptor {
|
|
4
|
+
private readonly logger;
|
|
5
|
+
intercept(_context: ExecutionContext, next: CallHandler<any>): Observable<any> | Promise<Observable<any>>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __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
|
+
};
|
|
8
|
+
var GrpcToHttpInterceptor_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.GrpcToHttpInterceptor = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const rxjs_1 = require("rxjs");
|
|
13
|
+
const operators_1 = require("rxjs/operators");
|
|
14
|
+
const exception_1 = require("../exception");
|
|
15
|
+
let GrpcToHttpInterceptor = GrpcToHttpInterceptor_1 = class GrpcToHttpInterceptor {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.logger = new common_1.Logger(GrpcToHttpInterceptor_1.name);
|
|
18
|
+
}
|
|
19
|
+
intercept(_context, next) {
|
|
20
|
+
return next.handle().pipe((0, operators_1.catchError)((err) => {
|
|
21
|
+
if (!(0, exception_1.isGrpcError)(err))
|
|
22
|
+
return (0, rxjs_1.throwError)(() => err);
|
|
23
|
+
const resolvedError = (0, exception_1.resolveGrpcErrorToException)(err, this.logger);
|
|
24
|
+
return (0, rxjs_1.throwError)(() => resolvedError);
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.GrpcToHttpInterceptor = GrpcToHttpInterceptor;
|
|
29
|
+
exports.GrpcToHttpInterceptor = GrpcToHttpInterceptor = GrpcToHttpInterceptor_1 = __decorate([
|
|
30
|
+
(0, common_1.Injectable)()
|
|
31
|
+
], GrpcToHttpInterceptor);
|
|
32
|
+
//# sourceMappingURL=grpc-to-http.interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grpc-to-http.interceptor.js","sourceRoot":"","sources":["../../lib/interceptor/grpc-to-http.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;AAKA,2CAMwB;AACxB,+BAA8C;AAC9C,8CAA4C;AAC5C,4CAAwE;AAGjE,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAA3B;QACY,WAAM,GAAG,IAAI,eAAM,CAAC,uBAAqB,CAAC,IAAI,CAAC,CAAC;IAsBnE,CAAC;IArBC,SAAS,CACP,QAA0B,EAC1B,IAAsB;QAEtB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACvB,IAAA,sBAAU,EAAC,CAAC,GAAG,EAAE,EAAE;YACjB,IACE,CAAC,IAAA,uBAAW,EAAC,GAAG,CAAC;gBAEjB,OAAO,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;YAE/B,MAAM,aAAa,GAAG,IAAA,uCAA2B,EAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YAGpE,OAAO,IAAA,iBAAU,EACf,GAAG,EAAE,CACH,aAAa,CAChB,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAA;AAvBY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;GACA,qBAAqB,CAuBjC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CallHandler, ExecutionContext, NestInterceptor } from "@nestjs/common";
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
export declare class HttpToGrpcInterceptor implements NestInterceptor {
|
|
4
|
+
intercept(_context: ExecutionContext, next: CallHandler<any>): Observable<any> | Promise<Observable<any>>;
|
|
5
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __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
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.HttpToGrpcInterceptor = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const rxjs_1 = require("rxjs");
|
|
12
|
+
const operators_1 = require("rxjs/operators");
|
|
13
|
+
const microservices_1 = require("@nestjs/microservices");
|
|
14
|
+
let HttpToGrpcInterceptor = class HttpToGrpcInterceptor {
|
|
15
|
+
intercept(_context, next) {
|
|
16
|
+
return next.handle().pipe((0, operators_1.catchError)((err) => {
|
|
17
|
+
if (!(typeof err === "object" &&
|
|
18
|
+
"response" in err &&
|
|
19
|
+
err.response &&
|
|
20
|
+
"status" in err))
|
|
21
|
+
return (0, rxjs_1.throwError)(() => err);
|
|
22
|
+
const exception = err.response;
|
|
23
|
+
const statusCode = 13;
|
|
24
|
+
return (0, rxjs_1.throwError)(() => new microservices_1.RpcException({
|
|
25
|
+
message: exception.message,
|
|
26
|
+
code: statusCode,
|
|
27
|
+
}));
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.HttpToGrpcInterceptor = HttpToGrpcInterceptor;
|
|
32
|
+
exports.HttpToGrpcInterceptor = HttpToGrpcInterceptor = __decorate([
|
|
33
|
+
(0, common_1.Injectable)()
|
|
34
|
+
], HttpToGrpcInterceptor);
|
|
35
|
+
//# sourceMappingURL=http-to-grpc.interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-to-grpc.interceptor.js","sourceRoot":"","sources":["../../lib/interceptor/http-to-grpc.interceptor.ts"],"names":[],"mappings":";;;;;;;;;AAGA,2CAKwB;AACxB,+BAA8C;AAC9C,8CAA4C;AAC5C,yDAAqD;AAG9C,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,SAAS,CACP,QAA0B,EAC1B,IAAsB;QAEtB,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CACvB,IAAA,sBAAU,EAAC,CAAC,GAAG,EAAE,EAAE;YACjB,IACE,CAAC,CACC,OAAO,GAAG,KAAK,QAAQ;gBACvB,UAAU,IAAI,GAAG;gBACjB,GAAG,CAAC,QAAQ;gBACZ,QAAQ,IAAI,GAAG,CAChB;gBAED,OAAO,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;YAE/B,MAAM,SAAS,GAAG,GAAG,CAAC,QAIrB,CAAC;YAGF,MAAM,UAAU,GAAG,EAAE,CAAC;YAEtB,OAAO,IAAA,iBAAU,EACf,GAAG,EAAE,CACH,IAAI,4BAAY,CAAC;gBACf,OAAO,EAAE,SAAS,CAAC,OAAO;gBAC1B,IAAI,EAAE,UAAU;aACjB,CAAC,CACL,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF,CAAA;AApCY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;GACA,qBAAqB,CAoCjC"}
|