clhq-auth-module 1.1.0-alpha.101 → 1.1.0-alpha.103
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.
|
@@ -24,6 +24,12 @@ export interface UserPayload {
|
|
|
24
24
|
email: string;
|
|
25
25
|
role: string;
|
|
26
26
|
}
|
|
27
|
-
export
|
|
28
|
-
resolveUserId(auth0UserId: string): Promise<string | null>;
|
|
27
|
+
export declare abstract class UserResolver {
|
|
28
|
+
abstract resolveUserId(auth0UserId: string): Promise<string | null>;
|
|
29
29
|
}
|
|
30
|
+
export interface AuthenticatedUser {
|
|
31
|
+
id: string;
|
|
32
|
+
email: string;
|
|
33
|
+
auth0Id?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare function maskSensitiveId(id: string | undefined): string;
|
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserResolver = void 0;
|
|
4
|
+
exports.maskSensitiveId = maskSensitiveId;
|
|
5
|
+
class UserResolver {
|
|
6
|
+
}
|
|
7
|
+
exports.UserResolver = UserResolver;
|
|
8
|
+
function maskSensitiveId(id) {
|
|
9
|
+
if (!id)
|
|
10
|
+
return '[none]';
|
|
11
|
+
if (id.length <= 10)
|
|
12
|
+
return '***';
|
|
13
|
+
return `${id.substring(0, 10)}***`;
|
|
14
|
+
}
|
|
@@ -8,12 +8,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
11
14
|
var AuthMiddleware_1;
|
|
12
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
16
|
exports.AuthMiddleware = void 0;
|
|
14
17
|
const common_1 = require("@nestjs/common");
|
|
15
18
|
const lodash_1 = require("lodash");
|
|
16
19
|
const auth0_service_1 = require("../auth/services/auth0.service");
|
|
20
|
+
const auth_interface_1 = require("../auth/interfaces/auth.interface");
|
|
17
21
|
let AuthMiddleware = AuthMiddleware_1 = class AuthMiddleware {
|
|
18
22
|
auth0Service;
|
|
19
23
|
userResolver;
|
|
@@ -37,7 +41,10 @@ let AuthMiddleware = AuthMiddleware_1 = class AuthMiddleware {
|
|
|
37
41
|
const userEmail = (0, lodash_1.get)(decodedToken, 'https://clippyhq.com/email', '');
|
|
38
42
|
const auth0UserId = decodedToken?.sub;
|
|
39
43
|
this.logger.debug('token');
|
|
40
|
-
this.logger.debug({
|
|
44
|
+
this.logger.debug({
|
|
45
|
+
sub: (0, auth_interface_1.maskSensitiveId)(auth0UserId),
|
|
46
|
+
email: userEmail,
|
|
47
|
+
});
|
|
41
48
|
let userId = auth0UserId;
|
|
42
49
|
if (this.userResolver && auth0UserId) {
|
|
43
50
|
try {
|
|
@@ -51,7 +58,7 @@ let AuthMiddleware = AuthMiddleware_1 = class AuthMiddleware {
|
|
|
51
58
|
}
|
|
52
59
|
}
|
|
53
60
|
catch (resolveError) {
|
|
54
|
-
this.logger.error(`Error resolving user ID for ${auth0UserId}:`, resolveError);
|
|
61
|
+
this.logger.error(`Error resolving user ID for ${(0, auth_interface_1.maskSensitiveId)(auth0UserId)}:`, resolveError);
|
|
55
62
|
}
|
|
56
63
|
}
|
|
57
64
|
const user = {
|
|
@@ -78,5 +85,8 @@ let AuthMiddleware = AuthMiddleware_1 = class AuthMiddleware {
|
|
|
78
85
|
exports.AuthMiddleware = AuthMiddleware;
|
|
79
86
|
exports.AuthMiddleware = AuthMiddleware = AuthMiddleware_1 = __decorate([
|
|
80
87
|
(0, common_1.Injectable)(),
|
|
81
|
-
|
|
88
|
+
__param(1, (0, common_1.Optional)()),
|
|
89
|
+
__param(1, (0, common_1.Inject)(auth_interface_1.UserResolver)),
|
|
90
|
+
__metadata("design:paramtypes", [auth0_service_1.Auth0Service,
|
|
91
|
+
auth_interface_1.UserResolver])
|
|
82
92
|
], AuthMiddleware);
|