clhq-auth-module 1.1.0-alpha.101 → 1.1.0-alpha.102
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
|
+
}
|
|
@@ -14,6 +14,7 @@ exports.AuthMiddleware = void 0;
|
|
|
14
14
|
const common_1 = require("@nestjs/common");
|
|
15
15
|
const lodash_1 = require("lodash");
|
|
16
16
|
const auth0_service_1 = require("../auth/services/auth0.service");
|
|
17
|
+
const auth_interface_1 = require("../auth/interfaces/auth.interface");
|
|
17
18
|
let AuthMiddleware = AuthMiddleware_1 = class AuthMiddleware {
|
|
18
19
|
auth0Service;
|
|
19
20
|
userResolver;
|
|
@@ -37,7 +38,10 @@ let AuthMiddleware = AuthMiddleware_1 = class AuthMiddleware {
|
|
|
37
38
|
const userEmail = (0, lodash_1.get)(decodedToken, 'https://clippyhq.com/email', '');
|
|
38
39
|
const auth0UserId = decodedToken?.sub;
|
|
39
40
|
this.logger.debug('token');
|
|
40
|
-
this.logger.debug({
|
|
41
|
+
this.logger.debug({
|
|
42
|
+
sub: (0, auth_interface_1.maskSensitiveId)(auth0UserId),
|
|
43
|
+
email: userEmail,
|
|
44
|
+
});
|
|
41
45
|
let userId = auth0UserId;
|
|
42
46
|
if (this.userResolver && auth0UserId) {
|
|
43
47
|
try {
|
|
@@ -51,7 +55,7 @@ let AuthMiddleware = AuthMiddleware_1 = class AuthMiddleware {
|
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
catch (resolveError) {
|
|
54
|
-
this.logger.error(`Error resolving user ID for ${auth0UserId}:`, resolveError);
|
|
58
|
+
this.logger.error(`Error resolving user ID for ${(0, auth_interface_1.maskSensitiveId)(auth0UserId)}:`, resolveError);
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
const user = {
|
|
@@ -78,5 +82,6 @@ let AuthMiddleware = AuthMiddleware_1 = class AuthMiddleware {
|
|
|
78
82
|
exports.AuthMiddleware = AuthMiddleware;
|
|
79
83
|
exports.AuthMiddleware = AuthMiddleware = AuthMiddleware_1 = __decorate([
|
|
80
84
|
(0, common_1.Injectable)(),
|
|
81
|
-
__metadata("design:paramtypes", [auth0_service_1.Auth0Service,
|
|
85
|
+
__metadata("design:paramtypes", [auth0_service_1.Auth0Service,
|
|
86
|
+
auth_interface_1.UserResolver])
|
|
82
87
|
], AuthMiddleware);
|