@lucaapp/service-utils 1.40.2 → 1.40.4
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.
|
@@ -53,11 +53,11 @@ declare class ServiceIdentity {
|
|
|
53
53
|
error: import("../api/types/http").HTTPStatus.FORBIDDEN;
|
|
54
54
|
}>;
|
|
55
55
|
})[], undefined, undefined, undefined, z.ZodObject<{
|
|
56
|
-
'
|
|
56
|
+
'x-identity': z.ZodEffects<z.ZodString, string, string>;
|
|
57
57
|
}, "strip", z.ZodTypeAny, {
|
|
58
|
-
"
|
|
58
|
+
"x-identity": string;
|
|
59
59
|
}, {
|
|
60
|
-
"
|
|
60
|
+
"x-identity": string;
|
|
61
61
|
}>, z.ZodObject<{
|
|
62
62
|
payload: z.ZodAny;
|
|
63
63
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -35,8 +35,9 @@ const moment_1 = __importDefault(require("moment"));
|
|
|
35
35
|
const requestTracer_1 = require("../requestTracer");
|
|
36
36
|
const axios_1 = __importDefault(require("axios"));
|
|
37
37
|
const zod_1 = require("zod");
|
|
38
|
+
const validator_1 = __importDefault(require("validator"));
|
|
38
39
|
const JWT_ALGORITHM = 'ES256';
|
|
39
|
-
const JWT_HEADER_NAME = '
|
|
40
|
+
const JWT_HEADER_NAME = 'x-identity';
|
|
40
41
|
const JWT_ALLOWED_ALGORITHMS = [JWT_ALGORITHM];
|
|
41
42
|
const JWT_NBF = '0s';
|
|
42
43
|
const JWT_EXP = '1m';
|
|
@@ -128,7 +129,7 @@ class ServiceIdentity {
|
|
|
128
129
|
this.requireServiceIdentityV3 = (service) => (0, api_1.createMiddleware)({
|
|
129
130
|
schemas: {
|
|
130
131
|
headers: zod_1.z.object({
|
|
131
|
-
'
|
|
132
|
+
'x-identity': zod_1.z.string().refine(value => validator_1.default.isJWT(value)),
|
|
132
133
|
}),
|
|
133
134
|
context: zod_1.z.object({ payload: zod_1.z.any() }),
|
|
134
135
|
},
|
|
@@ -146,7 +147,7 @@ class ServiceIdentity {
|
|
|
146
147
|
if (method !== payload.method) {
|
|
147
148
|
return respond((0, api_1.forbidden)(`${method} !== ${payload.method}`));
|
|
148
149
|
}
|
|
149
|
-
next({ payload: payload.data });
|
|
150
|
+
return next({ payload: payload.data });
|
|
150
151
|
});
|
|
151
152
|
this.identityJWKSRoute = async (_, response) => {
|
|
152
153
|
response.send(await this.getIdentityJWKS());
|