response-standardizer 1.3.6 → 1.3.7
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/dist/index.js +8 -3
- package/package.json +1 -1
- package/src/index.ts +9 -3
package/dist/index.js
CHANGED
|
@@ -14,9 +14,14 @@ const initKeycloak = async (config) => {
|
|
|
14
14
|
const realmUrl = `http://${KEYCLOAK_SERVICE}/realms/${KEYCLOAK_REALM}`;
|
|
15
15
|
(0, exports.info)(`Keycloak PublicKey Url: ${realmUrl}`);
|
|
16
16
|
const resp = await axios_1.default.get(realmUrl);
|
|
17
|
-
(
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
if (resp.status === 200) {
|
|
18
|
+
(0, exports.info)(`Keycloak: ${resp.data}`);
|
|
19
|
+
const key = resp.data.public_key;
|
|
20
|
+
KEYCLOAK_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----\n${key.match(/.{1,64}/g)?.join("\n")}\n-----END PUBLIC KEY-----`;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
(0, exports.error)(`There is no any public key for keycloak`);
|
|
24
|
+
}
|
|
20
25
|
};
|
|
21
26
|
exports.initKeycloak = initKeycloak;
|
|
22
27
|
const protect = (allowedRoles) => {
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -24,9 +24,15 @@ export const initKeycloak = async (config: { service?: string; realm?: string })
|
|
|
24
24
|
const realmUrl = `http://${KEYCLOAK_SERVICE}/realms/${KEYCLOAK_REALM}`;
|
|
25
25
|
info(`Keycloak PublicKey Url: ${realmUrl}`);
|
|
26
26
|
const resp = await axios.get(realmUrl);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
if(resp.status === 200){
|
|
28
|
+
info(`Keycloak: ${resp.data}`);
|
|
29
|
+
const key = resp.data.public_key;
|
|
30
|
+
KEYCLOAK_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----\n${key.match(/.{1,64}/g)?.join("\n")}\n-----END PUBLIC KEY-----`;
|
|
31
|
+
}else{
|
|
32
|
+
error(`There is no any public key for keycloak`);
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
30
36
|
};
|
|
31
37
|
|
|
32
38
|
export const protect = (allowedRoles?: string[]) => {
|