@crowdin/app-project-module 0.20.6 → 0.20.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/README.md CHANGED
@@ -43,6 +43,7 @@ In both options you will need to provide Crowdin App configuration file. Please
43
43
  - [Custom MT](#custom-mt)
44
44
  - [Profile Resources Menu](#profile-resources-menu)
45
45
  - [Other modules](#other-modules)
46
+ - [Other options](#other-options)
46
47
  - [Contributing](#contributing)
47
48
  - [Seeking Assistance](#seeking-assistance)
48
49
  - [License](#license)
@@ -768,6 +769,16 @@ const configuration = {
768
769
  crowdinModule.createApp(configuration);
769
770
  ```
770
771
 
772
+ ## Other options
773
+
774
+ ### Options for Crowdin JWT token validation
775
+
776
+ ```js
777
+ configuration.jwtValidationOptions = {
778
+ jwtValidationOptions: false, //ignore check if jwt is expired or not
779
+ };
780
+ ```
781
+
771
782
  ## Contributing
772
783
 
773
784
  If you want to contribute please read the [Contributing](/CONTRIBUTING.md) guidelines.
@@ -28,7 +28,7 @@ function getToken(req) {
28
28
  function prepareCrowdinRequest(jwtToken, config, optional = false, checkSubscriptionExpiration = true) {
29
29
  return __awaiter(this, void 0, void 0, function* () {
30
30
  (0, util_1.log)('Validating jwt token from incoming request', config.logger);
31
- const jwtPayload = yield (0, crowdin_apps_functions_1.validateJwtToken)(jwtToken, config.clientSecret);
31
+ const jwtPayload = yield (0, crowdin_apps_functions_1.validateJwtToken)(jwtToken, config.clientSecret, config.jwtValidationOptions);
32
32
  const context = {
33
33
  jwtPayload,
34
34
  clientId: (0, crowdin_apps_functions_1.constructCrowdinIdFromJwtPayload)(jwtPayload),
@@ -20,7 +20,7 @@ function handle(config) {
20
20
  return res.status(403).send({ error: 'Access denied' });
21
21
  }
22
22
  (0, util_1.log)('Validating jwt token from incoming request', config.logger);
23
- const jwtPayload = yield (0, crowdin_apps_functions_1.validateJwtToken)(tokenJwt, config.clientSecret);
23
+ const jwtPayload = yield (0, crowdin_apps_functions_1.validateJwtToken)(tokenJwt, config.clientSecret, config.jwtValidationOptions);
24
24
  const id = `${jwtPayload.domain || jwtPayload.context.organization_id}`;
25
25
  (0, util_1.log)('Loading crowdin credentials', config.logger);
26
26
  const credentials = yield (0, storage_1.getStorage)().getCrowdinCredentials(id);
@@ -1,5 +1,5 @@
1
1
  import Crowdin, { LanguagesModel, SourceFilesModel, SourceStringsModel } from '@crowdin/crowdin-api-client';
2
- import { JwtPayload } from '@crowdin/crowdin-apps-functions';
2
+ import { JwtPayload, VerifyOptions } from '@crowdin/crowdin-apps-functions';
3
3
  import { Request } from 'express';
4
4
  import { MySQLStorageConfig } from '../storage/mysql';
5
5
  import { PostgreStorageConfig } from '../storage/postgre';
@@ -16,6 +16,10 @@ export interface Config extends ImagePath {
16
16
  * Secret to encrypt/decrypt credentials (by default @clientSecret will be used)
17
17
  */
18
18
  cryptoSecret?: string;
19
+ /**
20
+ * Options to validate Crowdin JWT token
21
+ */
22
+ jwtValidationOptions?: VerifyOptions;
19
23
  /**
20
24
  * https url where an app is reachable from the internet (e.g. the one that ngrok generates for us)
21
25
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.20.6",
3
+ "version": "0.20.7",
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",
@@ -12,7 +12,7 @@
12
12
  "test": "echo \"test not implemented\""
13
13
  },
14
14
  "dependencies": {
15
- "@crowdin/crowdin-apps-functions": "0.1.4",
15
+ "@crowdin/crowdin-apps-functions": "0.1.6",
16
16
  "@types/pg": "^8.6.5",
17
17
  "crypto-js": "^4.0.0",
18
18
  "express": "4.17.1",