@crowdin/app-project-module 0.53.1 → 0.54.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/out/modules/integration/handlers/crowdin-webhook.js +5 -1
- package/out/modules/integration/handlers/integration-login.js +9 -2
- package/out/modules/integration/types.d.ts +17 -0
- package/out/modules/integration/util/cron.js +25 -6
- package/out/modules/integration/util/defaults.js +42 -36
- package/out/modules/integration/util/types.d.ts +2 -2
- package/out/static/js/form.js +10 -10
- package/out/util/connection.js +19 -14
- package/out/util/handlebars.js +11 -2
- package/out/views/login.handlebars +1 -1
- package/out/views/main.handlebars +2 -2
- package/package.json +11 -11
package/out/util/connection.js
CHANGED
|
@@ -180,27 +180,29 @@ function prepareCrowdinClient({ config, credentials, autoRenew = false, context,
|
|
|
180
180
|
}
|
|
181
181
|
exports.prepareCrowdinClient = prepareCrowdinClient;
|
|
182
182
|
function prepareIntegrationCredentials(config, integration, integrationCredentials) {
|
|
183
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
183
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
184
184
|
return __awaiter(this, void 0, void 0, function* () {
|
|
185
185
|
const credentials = JSON.parse((0, _1.decryptData)(config, integrationCredentials.credentials));
|
|
186
|
-
|
|
186
|
+
const oauthLogin = integration.oauthLogin;
|
|
187
|
+
const integrationLogin = integration.loginForm;
|
|
188
|
+
if ((oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.refresh) || (integrationLogin === null || integrationLogin === void 0 ? void 0 : integrationLogin.refresh)) {
|
|
187
189
|
(0, logger_1.log)('Checking if integration credentials need to be refreshed');
|
|
188
|
-
const oauthLogin = integration.oauthLogin;
|
|
189
190
|
const { expireIn } = credentials;
|
|
190
191
|
//2 min as an extra buffer
|
|
191
|
-
const isExpired = expireIn - 120 < Date.now() / 1000;
|
|
192
|
+
const isExpired = !expireIn || expireIn - 120 < Date.now() / 1000;
|
|
193
|
+
const performRefreshTokenRequest = (oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.performRefreshTokenRequest) || (integrationLogin === null || integrationLogin === void 0 ? void 0 : integrationLogin.performRefreshTokenRequest);
|
|
192
194
|
if (isExpired) {
|
|
193
195
|
(0, logger_1.log)('Integration credentials have expired. Requesting a new credentials');
|
|
194
196
|
let newCredentials;
|
|
195
|
-
if (
|
|
196
|
-
newCredentials = yield
|
|
197
|
+
if (performRefreshTokenRequest) {
|
|
198
|
+
newCredentials = yield performRefreshTokenRequest(credentials);
|
|
197
199
|
}
|
|
198
|
-
else {
|
|
200
|
+
else if (oauthLogin) {
|
|
199
201
|
const url = oauthLogin.refreshTokenUrl || oauthLogin.accessTokenUrl;
|
|
200
202
|
const request = {};
|
|
201
|
-
request[((
|
|
202
|
-
request[((
|
|
203
|
-
request[((
|
|
203
|
+
request[((_a = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.fieldsMapping) === null || _a === void 0 ? void 0 : _a.clientId) || 'client_id'] = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.clientId;
|
|
204
|
+
request[((_b = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.fieldsMapping) === null || _b === void 0 ? void 0 : _b.clientSecret) || 'client_secret'] = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.clientSecret;
|
|
205
|
+
request[((_c = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.fieldsMapping) === null || _c === void 0 ? void 0 : _c.refreshToken) || 'refresh_token'] = credentials.refreshToken;
|
|
204
206
|
if (oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.extraRefreshTokenParameters) {
|
|
205
207
|
Object.entries(oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.extraRefreshTokenParameters).forEach(([key, value]) => (request[key] = value));
|
|
206
208
|
}
|
|
@@ -208,11 +210,14 @@ function prepareIntegrationCredentials(config, integration, integrationCredentia
|
|
|
208
210
|
headers: { Accept: 'application/json' },
|
|
209
211
|
})).data;
|
|
210
212
|
}
|
|
211
|
-
|
|
213
|
+
else {
|
|
214
|
+
return credentials;
|
|
215
|
+
}
|
|
216
|
+
credentials.accessToken = newCredentials[((_d = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.fieldsMapping) === null || _d === void 0 ? void 0 : _d.accessToken) || 'access_token'];
|
|
212
217
|
credentials.expireIn =
|
|
213
|
-
Number(newCredentials[((
|
|
214
|
-
if (newCredentials[((
|
|
215
|
-
credentials.refreshToken = newCredentials[((
|
|
218
|
+
Number(newCredentials[((_e = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.fieldsMapping) === null || _e === void 0 ? void 0 : _e.expiresIn) || 'expires_in']) + Date.now() / 1000;
|
|
219
|
+
if (newCredentials[((_f = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.fieldsMapping) === null || _f === void 0 ? void 0 : _f.refreshToken) || 'refresh_token']) {
|
|
220
|
+
credentials.refreshToken = newCredentials[((_g = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.fieldsMapping) === null || _g === void 0 ? void 0 : _g.refreshToken) || 'refresh_token'];
|
|
216
221
|
}
|
|
217
222
|
(0, logger_1.log)('Saving updated integration credentials in the database');
|
|
218
223
|
yield (0, storage_1.getStorage)().updateIntegrationCredentials(integrationCredentials.id, (0, _1.encryptData)(config, JSON.stringify(credentials)));
|
package/out/util/handlebars.js
CHANGED
|
@@ -22,8 +22,17 @@ exports.engine = (0, express_handlebars_1.default)({
|
|
|
22
22
|
return options.inverse(this);
|
|
23
23
|
},
|
|
24
24
|
in: function (a, b, options) {
|
|
25
|
-
if (a !== undefined && a !== null && b !== undefined && b !== null
|
|
26
|
-
|
|
25
|
+
if (a !== undefined && a !== null && b !== undefined && b !== null) {
|
|
26
|
+
let bArray;
|
|
27
|
+
if (Array.isArray(b)) {
|
|
28
|
+
bArray = b;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
bArray = b.split(' ');
|
|
32
|
+
}
|
|
33
|
+
if (bArray.includes(a === null || a === void 0 ? void 0 : a.toString())) {
|
|
34
|
+
return options.fn(this);
|
|
35
|
+
}
|
|
27
36
|
}
|
|
28
37
|
return options.inverse(this);
|
|
29
38
|
},
|
|
@@ -184,7 +184,7 @@
|
|
|
184
184
|
<option
|
|
185
185
|
{{#if ../defaultValue}}
|
|
186
186
|
{{#ifeq ../defaultValue value}} selected {{/ifeq}}
|
|
187
|
-
{{#in ../defaultValue
|
|
187
|
+
{{#in value ../defaultValue}} selected {{/in}}
|
|
188
188
|
{{/if}}
|
|
189
189
|
value="{{value}}">{{label}}
|
|
190
190
|
</option>
|
|
@@ -420,7 +420,7 @@
|
|
|
420
420
|
project = res;
|
|
421
421
|
const languagesSorted = project.targetLanguages.sort((a, b) => a.name.localeCompare(b.name));
|
|
422
422
|
|
|
423
|
-
if (project.inContext) {
|
|
423
|
+
if (project.inContext && config?.inContext) {
|
|
424
424
|
languagesSorted.push({...project.inContextPseudoLanguage, inContext: true});
|
|
425
425
|
}
|
|
426
426
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crowdin/app-project-module",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
4
4
|
"description": "Module that generates for you all common endpoints for serving standalone Crowdin App",
|
|
5
5
|
"main": "out/index.js",
|
|
6
6
|
"types": "out/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"express": "4.19.2",
|
|
29
29
|
"express-handlebars": "^5.3.5",
|
|
30
30
|
"lodash.uniqby": "^4.7.0",
|
|
31
|
-
"mysql2": "^3.9.
|
|
31
|
+
"mysql2": "^3.9.8",
|
|
32
32
|
"node-cron": "^3.0.3",
|
|
33
33
|
"pg": "^8.11.5",
|
|
34
34
|
"redoc-express": "^2.1.0",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@babel/preset-react": "^7.24.1",
|
|
41
41
|
"@emotion/react": "^11.11.4",
|
|
42
|
-
"@emotion/styled": "^11.11.
|
|
43
|
-
"@mui/icons-material": "^5.15.
|
|
44
|
-
"@mui/material": "^5.15.
|
|
45
|
-
"@rjsf/core": "^5.18.
|
|
46
|
-
"@rjsf/mui": "^5.18.
|
|
47
|
-
"@rjsf/utils": "^5.18.
|
|
48
|
-
"@rjsf/validator-ajv8": "^5.18.
|
|
42
|
+
"@emotion/styled": "^11.11.5",
|
|
43
|
+
"@mui/icons-material": "^5.15.19",
|
|
44
|
+
"@mui/material": "^5.15.19",
|
|
45
|
+
"@rjsf/core": "^5.18.4",
|
|
46
|
+
"@rjsf/mui": "^5.18.4",
|
|
47
|
+
"@rjsf/utils": "^5.18.4",
|
|
48
|
+
"@rjsf/validator-ajv8": "^5.18.4",
|
|
49
49
|
"@rollup/plugin-babel": "^6.0.4",
|
|
50
50
|
"@rollup/plugin-commonjs": "^24.1.0",
|
|
51
51
|
"@rollup/plugin-json": "^6.1.0",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@types/lodash.uniqby": "^4.7.9",
|
|
61
61
|
"@types/node": "^16.18.69",
|
|
62
62
|
"@types/node-cron": "^3.0.11",
|
|
63
|
-
"@types/pg": "^8.11.
|
|
63
|
+
"@types/pg": "^8.11.6",
|
|
64
64
|
"@types/swagger-jsdoc": "^6.0.4",
|
|
65
65
|
"@types/uuid": "^9.0.7",
|
|
66
66
|
"@typescript-eslint/eslint-plugin": "^2.3.1",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"jest-junit": "^15.0.0",
|
|
73
73
|
"prettier": "^2.8.8",
|
|
74
74
|
"react": "^18.3.1",
|
|
75
|
-
"react-dom": "^18.
|
|
75
|
+
"react-dom": "^18.3.1",
|
|
76
76
|
"rollup": "^3.29.4",
|
|
77
77
|
"ts-jest": "^29.1.1",
|
|
78
78
|
"typescript": "^4.9.5"
|