@forge/lint 1.6.1-next.6 → 1.6.1-next.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @forge/lint
2
2
 
3
+ ## 1.6.1-next.7
4
+
5
+ ### Patch Changes
6
+
7
+ - 69e25c2: Required permissions scope linter should read from the x-atlassian-oauth2-scopes. If it is not present then read from the security OAuth2 field. Combining Product DACIs https://hello.atlassian.net/wiki/spaces/redfox/pages/1046875420/RFC+OAuth+scopes+deprecation+in+Jira+-+DAC and https://hello.atlassian.net/wiki/spaces/redfox/pages/1304762888/OpenAPI+-+DAC+contract.
8
+
3
9
  ## 1.6.1-next.6
4
10
 
5
11
  ### Patch Changes
@@ -2,6 +2,8 @@ import { LintResultRule, LintClass } from '../../../linter-interface';
2
2
  import { ApiCall, ProductApiCall } from '../api-call-interface';
3
3
  import { LintIssueVerifier, BaseLintIssueVerifier } from '../../verifier-interface';
4
4
  import { ManifestSchema as Manifest } from '@forge/manifest';
5
+ import { Swagger } from 'atlassian-openapi';
6
+ import OAuth2ScopesWithState = Swagger.OAuth2ScopesWithState;
5
7
  export interface ProductMethod {
6
8
  originalPath: string;
7
9
  methods: PathMethods;
@@ -9,6 +11,7 @@ export interface ProductMethod {
9
11
  export interface PathMethods {
10
12
  [method: string]: {
11
13
  security: SecurityEntry[];
14
+ 'x-atlassian-oauth2-scopes'?: OAuth2ScopesWithState[];
12
15
  };
13
16
  }
14
17
  interface SecurityEntry {
@@ -1 +1 @@
1
- {"version":3,"file":"product-verifier.d.ts","sourceRoot":"","sources":["../../../../../src/lint/linters/permission-linter/verifiers/product-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAGpF,OAAO,EAAE,cAAc,IAAI,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG7D,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,QAAQ,EAAE,aAAa,EAAE,CAAC;KAC3B,CAAC;CACH;AAED,UAAU,aAAa;IACrB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC9B;AAED,oBAAY,uBAAuB,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAEjE,qBAAa,eAAgB,SAAQ,qBAAsB,YAAW,iBAAiB,CAAC,OAAO,EAAE,CAAC;IAI9F,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAHxB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,QAAQ,EACD,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,MAAM;IAKlC,SAAS,CAAC,YAAY,IAAI,SAAS;IAItB,OAAO,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAoC3E,OAAO,CAAC,aAAa;IAerB,OAAO,CAAC,0BAA0B;IAQlC,OAAO,CAAC,iBAAiB;CAY1B"}
1
+ {"version":3,"file":"product-verifier.d.ts","sourceRoot":"","sources":["../../../../../src/lint/linters/permission-linter/verifiers/product-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAGpF,OAAO,EAAE,cAAc,IAAI,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC;AAE7D,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,MAAM,EAAE,MAAM,GAAG;QAChB,QAAQ,EAAE,aAAa,EAAE,CAAC;QAC1B,2BAA2B,CAAC,EAAE,qBAAqB,EAAE,CAAC;KACvD,CAAC;CACH;AAED,UAAU,aAAa;IACrB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC9B;AAED,oBAAY,uBAAuB,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAEjE,qBAAa,eAAgB,SAAQ,qBAAsB,YAAW,iBAAiB,CAAC,OAAO,EAAE,CAAC;IAI9F,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAHxB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,QAAQ,EACD,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,MAAM;IAKlC,SAAS,CAAC,YAAY,IAAI,SAAS;IAItB,OAAO,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAoC3E,OAAO,CAAC,aAAa;IAerB,OAAO,CAAC,0BAA0B;IAQlC,OAAO,CAAC,iBAAiB;CAoB1B"}
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProductVerifier = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  const linter_interface_1 = require("../../../linter-interface");
5
6
  const verifier_interface_1 = require("../../verifier-interface");
6
7
  const cli_shared_1 = require("@forge/cli-shared");
7
8
  const text_1 = require("../../../text");
9
+ const array_prototype_flatmap_1 = tslib_1.__importDefault(require("array.prototype.flatmap"));
8
10
  class ProductVerifier extends verifier_interface_1.BaseLintIssueVerifier {
9
11
  constructor(environment, manifest, pathMap, product) {
10
12
  super(environment, manifest);
@@ -58,10 +60,14 @@ class ProductVerifier extends verifier_interface_1.BaseLintIssueVerifier {
58
60
  return requiredScopes.filter((scope) => { var _a, _b; return !((_b = (_a = this.manifest.permissions) === null || _a === void 0 ? void 0 : _a.scopes) === null || _b === void 0 ? void 0 : _b.includes(scope)); });
59
61
  }
60
62
  getRequiredScopes({ regex, method }) {
61
- var _a, _b;
63
+ var _a, _b, _c;
62
64
  if (!regex)
63
65
  return [];
64
- const swaggerEntries = (_b = (_a = this.pathMap.get(regex)) === null || _a === void 0 ? void 0 : _a.methods[method]) === null || _b === void 0 ? void 0 : _b.security;
66
+ const oAuth2Scopes = (_a = this.pathMap.get(regex)) === null || _a === void 0 ? void 0 : _a.methods[method]['x-atlassian-oauth2-scopes'];
67
+ if (oAuth2Scopes) {
68
+ return array_prototype_flatmap_1.default(oAuth2Scopes.filter((scope) => scope.state === 'Current').map((scope) => scope.scopes), (x) => x);
69
+ }
70
+ const swaggerEntries = (_c = (_b = this.pathMap.get(regex)) === null || _b === void 0 ? void 0 : _b.methods[method]) === null || _c === void 0 ? void 0 : _c.security;
65
71
  if (!swaggerEntries)
66
72
  return [];
67
73
  return swaggerEntries === null || swaggerEntries === void 0 ? void 0 : swaggerEntries.reduce((prev, curr) => [...prev, ...(curr['OAuth2'] || []), ...(curr['oAuthDefinitions'] || [])], []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/lint",
3
- "version": "1.6.1-next.6",
3
+ "version": "1.6.1-next.7",
4
4
  "description": "Linting for forge apps",
5
5
  "main": "out/index.js",
6
6
  "license": "UNLICENSED",
@@ -20,6 +20,7 @@
20
20
  "@forge/manifest": "2.5.1-next.4",
21
21
  "@typescript-eslint/typescript-estree": "^3.5.0",
22
22
  "cross-spawn": "^7.0.1",
23
- "node-fetch": "^2.6.1"
23
+ "node-fetch": "^2.6.1",
24
+ "atlassian-openapi": "^1.0.13"
24
25
  }
25
26
  }