@forge/manifest 0.0.0-experimental-64caa5a → 0.0.0-experimental-490cfcf

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +355 -6
  2. package/out/index.d.ts +1 -1
  3. package/out/index.d.ts.map +1 -1
  4. package/out/mapping/product-event-to-scope-mapping.json +334 -110
  5. package/out/processor/full-validation-processor.d.ts.map +1 -1
  6. package/out/processor/full-validation-processor.js +3 -0
  7. package/out/schema/basic-manifest-schema.json +32 -0
  8. package/out/schema/basic-manifest.d.ts +13 -0
  9. package/out/schema/manifest-schema.json +2345 -1035
  10. package/out/schema/manifest.d.ts +1853 -1019
  11. package/out/scopes/deprecated-shipyard-scopes.json +24 -0
  12. package/out/scopes/shipyard-scopes.json +49 -69
  13. package/out/text/errors.d.ts +6 -0
  14. package/out/text/errors.d.ts.map +1 -1
  15. package/out/text/errors.js +8 -2
  16. package/out/types/egress-types.d.ts +1 -1
  17. package/out/types/egress-types.d.ts.map +1 -1
  18. package/out/types/egress-types.js +3 -1
  19. package/out/types/module-types.d.ts +9 -0
  20. package/out/types/module-types.d.ts.map +1 -1
  21. package/out/types/module-types.js +9 -0
  22. package/out/validators/connect-authentication-validator.d.ts +7 -0
  23. package/out/validators/connect-authentication-validator.d.ts.map +1 -0
  24. package/out/validators/connect-authentication-validator.js +27 -0
  25. package/out/validators/deprecated-permissions-validator.d.ts +7 -0
  26. package/out/validators/deprecated-permissions-validator.d.ts.map +1 -0
  27. package/out/validators/deprecated-permissions-validator.js +31 -0
  28. package/out/validators/index.d.ts +1 -0
  29. package/out/validators/index.d.ts.map +1 -1
  30. package/out/validators/index.js +1 -0
  31. package/out/validators/modules-validator.d.ts.map +1 -1
  32. package/out/validators/modules-validator.js +12 -3
  33. package/out/validators/permissions-validator.d.ts +6 -0
  34. package/out/validators/permissions-validator.d.ts.map +1 -1
  35. package/out/validators/permissions-validator.js +78 -69
  36. package/out/validators/product-trigger-scopes-validator.d.ts +4 -1
  37. package/out/validators/product-trigger-scopes-validator.d.ts.map +1 -1
  38. package/out/validators/product-trigger-scopes-validator.js +23 -7
  39. package/package.json +3 -3
@@ -92,9 +92,18 @@ class ModulesValidator {
92
92
  types_1.AllModuleTypes.JiraProjectSettingsPage,
93
93
  types_1.AllModuleTypes.JiraGlobalPage
94
94
  ].forEach((moduleType) => {
95
- const module = modules[moduleType];
96
- if (module && module.length > 1) {
97
- validationErrors.push(Object.assign({ message: text_1.errors.modules.fullPage.children(moduleType), reference: text_1.References.Modules, level: 'error' }, utils_1.findPosition(module[1].key, yamlContentByLine)));
95
+ const moduleArray = modules[moduleType];
96
+ if (moduleArray && moduleArray.length > 1) {
97
+ validationErrors.push(Object.assign({ message: text_1.errors.modules.fullPage.children(moduleType), reference: text_1.References.Modules, level: 'error' }, utils_1.findPosition(moduleArray[1].key, yamlContentByLine)));
98
+ }
99
+ if (moduleArray && moduleArray.length === 1) {
100
+ const module = moduleArray[0];
101
+ if (module && (module.pages || module.sections) && module.function) {
102
+ validationErrors.push(Object.assign({ message: text_1.errors.modules.subPages.subPagesWithUIKit(module.key), reference: text_1.References.Modules, level: 'error' }, utils_1.findPosition(module.key, yamlContentByLine)));
103
+ }
104
+ if (module && module.pages && module.sections) {
105
+ validationErrors.push(Object.assign({ message: text_1.errors.modules.subPages.invalidPagesAndSections(module.key), reference: text_1.References.Modules, level: 'error' }, utils_1.findPosition(module.key, yamlContentByLine)));
106
+ }
98
107
  }
99
108
  });
100
109
  [types_1.AllModuleTypes.JiraCustomField, types_1.AllModuleTypes.JiraCustomFieldType].forEach((moduleType) => {
@@ -2,6 +2,12 @@ import { ManifestObject, ManifestValidationResult } from '../types';
2
2
  import { ManifestSchema } from '../schema/manifest';
3
3
  import { ValidatorInterface } from './validator-interface';
4
4
  export declare class PermissionsValidator implements ValidatorInterface<ManifestObject<ManifestSchema> | undefined, ManifestSchema> {
5
+ private validationErrors;
6
+ constructor();
7
+ private isValidURL;
8
+ private isValidHash;
9
+ private addValidationErrors;
10
+ private validateExternalPermissionURLs;
5
11
  validate(manifest: ManifestObject<ManifestSchema> | undefined): ManifestValidationResult<ManifestSchema>;
6
12
  }
7
13
  //# sourceMappingURL=permissions-validator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"permissions-validator.d.ts","sourceRoot":"","sources":["../../src/validators/permissions-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAmB,MAAM,UAAU,CAAC;AAGrF,OAAO,EAAE,cAAc,EAAU,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAK3D,qBAAa,oBACX,YAAW,kBAAkB,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,SAAS,EAAE,cAAc,CAAC;IACzF,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,SAAS,GAAG,wBAAwB,CAAC,cAAc,CAAC;CAwHzG"}
1
+ {"version":3,"file":"permissions-validator.d.ts","sourceRoot":"","sources":["../../src/validators/permissions-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAmB,MAAM,UAAU,CAAC;AAGrF,OAAO,EAAE,cAAc,EAAU,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAM3D,qBAAa,oBACX,YAAW,kBAAkB,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,SAAS,EAAE,cAAc,CAAC;IACzF,OAAO,CAAC,gBAAgB,CAAoB;;IAM5C,OAAO,CAAC,UAAU;IA+BlB,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,8BAA8B;IAWtC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,SAAS,GAAG,wBAAwB,CAAC,cAAc,CAAC;CA8FzG"}
@@ -7,93 +7,102 @@ const text_1 = require("../text");
7
7
  const egress_types_1 = require("../types/egress-types");
8
8
  const url_1 = require("url");
9
9
  const shipyard_scopes_json_1 = tslib_1.__importDefault(require("../scopes/shipyard-scopes.json"));
10
+ const deprecated_shipyard_scopes_json_1 = tslib_1.__importDefault(require("../scopes/deprecated-shipyard-scopes.json"));
10
11
  class PermissionsValidator {
11
- validate(manifest) {
12
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
13
- if (!manifest || !manifest.typedContent || !manifest.typedContent.permissions) {
14
- return {
15
- success: false,
16
- manifestObject: manifest
17
- };
12
+ constructor() {
13
+ this.validationErrors = [];
14
+ }
15
+ isValidURL(inputURL) {
16
+ const protocolRegex = /^(.*?:\/\/)/;
17
+ const validURI = /^(\*\.)?[.a-zA-Z0-9_\-\/:~#%?=&]+$/;
18
+ const allowedProtocols = ['https:', 'wss:'];
19
+ const MAX_URL_LENGTH = 1000;
20
+ if (inputURL.length > MAX_URL_LENGTH) {
21
+ return false;
18
22
  }
19
- const validationErrors = [];
20
- function addValidationError(element, value, manifest) {
21
- validationErrors.push(Object.assign({ message: text_1.errors.permissions.invalidPermission(element, value), reference: text_1.References.Permissions, level: 'error' }, utils_1.findPosition(value, manifest.yamlContentByLine)));
23
+ if (inputURL === '*') {
24
+ return true;
22
25
  }
26
+ if (!inputURL.includes('.') || inputURL.includes(' ')) {
27
+ return false;
28
+ }
29
+ try {
30
+ const domainOrUrlWithProtocol = protocolRegex.test(inputURL) ? inputURL : `https://${inputURL}`;
31
+ const parsedUrl = new url_1.URL(domainOrUrlWithProtocol);
32
+ if (!allowedProtocols.includes(parsedUrl.protocol)) {
33
+ return false;
34
+ }
35
+ return validURI.test(parsedUrl.hostname);
36
+ }
37
+ catch (_) {
38
+ return false;
39
+ }
40
+ }
41
+ isValidHash(cspString) {
23
42
  const BASE_64_HASH_PATTERNS = [
24
43
  /^sha256-[a-zA-Z0-9=+/]{44}$/,
25
44
  /^sha384-[a-zA-Z0-9=+/]{64}$/,
26
45
  /^sha512-[a-zA-Z0-9=+/]{88}$/
27
46
  ];
28
- function isValidHash(cspString) {
29
- return BASE_64_HASH_PATTERNS.some((pattern) => pattern.test(cspString));
47
+ return BASE_64_HASH_PATTERNS.some((pattern) => pattern.test(cspString));
48
+ }
49
+ addValidationErrors(element, values, manifest) {
50
+ values.forEach((value) => {
51
+ this.validationErrors.push(Object.assign({ message: text_1.errors.permissions.invalidPermission(element, value), reference: text_1.References.Permissions, level: 'error' }, utils_1.findPosition(value, manifest.yamlContentByLine)));
52
+ });
53
+ }
54
+ validateExternalPermissionURLs(extPermType, perms, manifest) {
55
+ const invalidPerms = perms === null || perms === void 0 ? void 0 : perms.filter((key) => !this.isValidURL(key));
56
+ if (invalidPerms === null || invalidPerms === void 0 ? void 0 : invalidPerms.length) {
57
+ this.addValidationErrors(extPermType, invalidPerms, manifest);
30
58
  }
31
- const validURI = /^(\*\.)?[.a-zA-Z0-9_\-\/:~#%?=&]+$/;
32
- const protocolRegex = /^(.*?:\/\/)/;
33
- const allowedProtocols = ['https:', 'wss:'];
34
- const MAX_URL_LENGTH = 1000;
35
- function isValidURL(inputURL) {
36
- if (inputURL.length > MAX_URL_LENGTH) {
37
- return false;
38
- }
39
- if (inputURL === '*') {
40
- return true;
41
- }
42
- if (!inputURL.includes('.') || inputURL.includes(' ')) {
43
- return false;
44
- }
45
- try {
46
- const domainOrUrlWithProtocol = protocolRegex.test(inputURL) ? inputURL : `https://${inputURL}`;
47
- const parsedUrl = new url_1.URL(domainOrUrlWithProtocol);
48
- if (!allowedProtocols.includes(parsedUrl.protocol)) {
49
- return false;
50
- }
51
- return validURI.test(parsedUrl.hostname);
52
- }
53
- catch (_) {
54
- return false;
55
- }
59
+ }
60
+ validate(manifest) {
61
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
62
+ if (!manifest || !manifest.typedContent || !manifest.typedContent.permissions) {
63
+ return {
64
+ success: false,
65
+ manifestObject: manifest
66
+ };
56
67
  }
57
- const invalidScope = (_a = manifest.typedContent.permissions.scopes) === null || _a === void 0 ? void 0 : _a.find((key) => !shipyard_scopes_json_1.default.includes(key));
58
- if (invalidScope) {
59
- addValidationError('scopes', invalidScope, manifest);
68
+ const ALL_SCOPES = shipyard_scopes_json_1.default.concat(deprecated_shipyard_scopes_json_1.default);
69
+ const invalidScopes = (_a = manifest.typedContent.permissions.scopes) === null || _a === void 0 ? void 0 : _a.filter((key) => !ALL_SCOPES.includes(key));
70
+ if (invalidScopes === null || invalidScopes === void 0 ? void 0 : invalidScopes.length) {
71
+ this.addValidationErrors('scopes', invalidScopes, manifest);
60
72
  }
61
- const invalidScripts = (_c = (_b = manifest.typedContent.permissions.content) === null || _b === void 0 ? void 0 : _b.scripts) === null || _c === void 0 ? void 0 : _c.find((key) => !egress_types_1.EGRESS_TYPES.EGRESS_SCRIPTS.includes(key) && !isValidHash(key));
62
- if (invalidScripts) {
63
- addValidationError('content.scripts', invalidScripts, manifest);
73
+ const invalidScripts = (_c = (_b = manifest.typedContent.permissions.content) === null || _b === void 0 ? void 0 : _b.scripts) === null || _c === void 0 ? void 0 : _c.filter((key) => !egress_types_1.EGRESS_TYPES.ALLOWED_CSP_TYPES.includes(key) && !this.isValidHash(key));
74
+ if (invalidScripts === null || invalidScripts === void 0 ? void 0 : invalidScripts.length) {
75
+ this.addValidationErrors('content.scripts', invalidScripts, manifest);
64
76
  }
65
- const invalidBackendString = (_f = (_e = (_d = manifest.typedContent.permissions.external) === null || _d === void 0 ? void 0 : _d.fetch) === null || _e === void 0 ? void 0 : _e.backend) === null || _f === void 0 ? void 0 : _f.filter((item) => typeof item === 'string').find((key) => !isValidURL(key));
66
- if (invalidBackendString) {
67
- addValidationError('external.fetch.backend', invalidBackendString, manifest);
77
+ const invalidBackendStrings = (_f = (_e = (_d = manifest.typedContent.permissions.external) === null || _d === void 0 ? void 0 : _d.fetch) === null || _e === void 0 ? void 0 : _e.backend) === null || _f === void 0 ? void 0 : _f.filter((item) => typeof item === 'string' && !this.isValidURL(item));
78
+ if (invalidBackendStrings === null || invalidBackendStrings === void 0 ? void 0 : invalidBackendStrings.length) {
79
+ this.addValidationErrors('external.fetch.backend', invalidBackendStrings, manifest);
68
80
  }
69
81
  const remoteMap = (_g = manifest.typedContent.remotes) === null || _g === void 0 ? void 0 : _g.reduce((prev, item) => prev.set(item.key, item.baseUrl), new Map());
70
- const invalidBackendRemote = (_k = (_j = (_h = manifest.typedContent.permissions.external) === null || _h === void 0 ? void 0 : _h.fetch) === null || _j === void 0 ? void 0 : _j.backend) === null || _k === void 0 ? void 0 : _k.filter((item) => typeof item === 'object').find((item) => !remoteMap || !remoteMap.has(item.remote) || !isValidURL(remoteMap.get(item.remote)));
71
- if (invalidBackendRemote) {
72
- addValidationError('external.fetch.backend', invalidBackendRemote.remote, manifest);
73
- }
74
- const invalidClient = (_o = (_m = (_l = manifest.typedContent.permissions.external) === null || _l === void 0 ? void 0 : _l.fetch) === null || _m === void 0 ? void 0 : _m.client) === null || _o === void 0 ? void 0 : _o.find((key) => !isValidURL(key));
75
- if (invalidClient) {
76
- addValidationError('external.fetch.client', invalidClient, manifest);
77
- }
78
- const invalidNavigation = (_q = (_p = manifest.typedContent.permissions.external) === null || _p === void 0 ? void 0 : _p.navigation) === null || _q === void 0 ? void 0 : _q.find((key) => !isValidURL(key));
79
- if (invalidNavigation) {
80
- addValidationError('external.navigation', invalidNavigation, manifest);
81
- }
82
- const invalidImages = (_s = (_r = manifest.typedContent.permissions.external) === null || _r === void 0 ? void 0 : _r.images) === null || _s === void 0 ? void 0 : _s.find((key) => !isValidURL(key));
83
- if (invalidImages) {
84
- addValidationError('external.images', invalidImages, manifest);
82
+ const invalidBackendRemotes = (_k = (_j = (_h = manifest.typedContent.permissions.external) === null || _h === void 0 ? void 0 : _h.fetch) === null || _j === void 0 ? void 0 : _j.backend) === null || _k === void 0 ? void 0 : _k.filter((item) => typeof item === 'object' &&
83
+ (!remoteMap || !remoteMap.has(item.remote) || !this.isValidURL(remoteMap.get(item.remote)))).map((item) => item.remote);
84
+ if (invalidBackendRemotes === null || invalidBackendRemotes === void 0 ? void 0 : invalidBackendRemotes.length) {
85
+ this.addValidationErrors('external.fetch.backend', invalidBackendRemotes, manifest);
85
86
  }
86
- const invalidMedia = (_u = (_t = manifest.typedContent.permissions.external) === null || _t === void 0 ? void 0 : _t.media) === null || _u === void 0 ? void 0 : _u.find((key) => !isValidURL(key));
87
- if (invalidMedia) {
88
- addValidationError('external.media', invalidMedia, manifest);
87
+ const invalidClientStrings = (_o = (_m = (_l = manifest.typedContent.permissions.external) === null || _l === void 0 ? void 0 : _l.fetch) === null || _m === void 0 ? void 0 : _m.client) === null || _o === void 0 ? void 0 : _o.filter((item) => typeof item === 'string' && !this.isValidURL(item));
88
+ if (invalidClientStrings) {
89
+ this.addValidationErrors('external.fetch.client', invalidClientStrings, manifest);
89
90
  }
90
- const invalidExternalScripts = (_w = (_v = manifest.typedContent.permissions.external) === null || _v === void 0 ? void 0 : _v.scripts) === null || _w === void 0 ? void 0 : _w.find((key) => !isValidURL(key));
91
- if (invalidExternalScripts) {
92
- addValidationError('external.scripts', invalidExternalScripts, manifest);
91
+ const invalidClients = (_r = (_q = (_p = manifest.typedContent.permissions.external) === null || _p === void 0 ? void 0 : _p.fetch) === null || _q === void 0 ? void 0 : _q.client) === null || _r === void 0 ? void 0 : _r.filter((item) => typeof item === 'object' &&
92
+ (!remoteMap || !remoteMap.has(item.remote) || !this.isValidURL(remoteMap.get(item.remote)))).map((item) => item.remote);
93
+ if (invalidClients) {
94
+ this.addValidationErrors('external.fetch.client', invalidClients, manifest);
93
95
  }
96
+ this.validateExternalPermissionURLs('external.navigation', (_s = manifest.typedContent.permissions.external) === null || _s === void 0 ? void 0 : _s.navigation, manifest);
97
+ this.validateExternalPermissionURLs('external.images', (_t = manifest.typedContent.permissions.external) === null || _t === void 0 ? void 0 : _t.images, manifest);
98
+ this.validateExternalPermissionURLs('external.frames', (_u = manifest.typedContent.permissions.external) === null || _u === void 0 ? void 0 : _u.frames, manifest);
99
+ this.validateExternalPermissionURLs('external.scripts', (_v = manifest.typedContent.permissions.external) === null || _v === void 0 ? void 0 : _v.scripts, manifest);
100
+ this.validateExternalPermissionURLs('external.styles', (_w = manifest.typedContent.permissions.external) === null || _w === void 0 ? void 0 : _w.styles, manifest);
101
+ this.validateExternalPermissionURLs('external.media', (_x = manifest.typedContent.permissions.external) === null || _x === void 0 ? void 0 : _x.media, manifest);
102
+ this.validateExternalPermissionURLs('external.fonts', (_y = manifest.typedContent.permissions.external) === null || _y === void 0 ? void 0 : _y.fonts, manifest);
94
103
  return {
95
- success: validationErrors.length === 0,
96
- errors: validationErrors
104
+ success: this.validationErrors.length === 0,
105
+ errors: this.validationErrors
97
106
  };
98
107
  }
99
108
  }
@@ -3,7 +3,10 @@ import { ValidatorInterface } from './validator-interface';
3
3
  import { ManifestSchema } from '../schema/manifest';
4
4
  export interface MappingEntry {
5
5
  productEvent: string;
6
- oAuthScopes: string[];
6
+ oAuthScopes: {
7
+ current: string[];
8
+ deprecated?: string[];
9
+ };
7
10
  }
8
11
  export interface MappingConfig {
9
12
  mapping: MappingEntry[];
@@ -1 +1 @@
1
- {"version":3,"file":"product-trigger-scopes-validator.d.ts","sourceRoot":"","sources":["../../src/validators/product-trigger-scopes-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAmB,MAAM,UAAU,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIpD,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,qBAAa,6BAA6B,CAAC,CAAC,CAC1C,YAAW,kBAAkB,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,SAAS,EAAE,cAAc,CAAC;IAC7E,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,SAAS,GAAG,wBAAwB,CAAC,cAAc,CAAC;CAgDzG"}
1
+ {"version":3,"file":"product-trigger-scopes-validator.d.ts","sourceRoot":"","sources":["../../src/validators/product-trigger-scopes-validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAmB,MAAM,UAAU,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIpD,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE;QACX,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;KACvB,CAAC;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,qBAAa,6BAA6B,CAAC,CAAC,CAC1C,YAAW,kBAAkB,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,SAAS,EAAE,cAAc,CAAC;IAC7E,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAElD,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,cAAc,CAAC,GAAG,SAAS,GAAG,wBAAwB,CAAC,cAAc,CAAC;CAsEzG"}
@@ -16,9 +16,9 @@ class ProductTriggerScopesValidator {
16
16
  };
17
17
  }
18
18
  const validationErrors = [];
19
- const getRequiredScopesForProductEvent = (productEvent) => {
19
+ const getRequiredScopes = (productEvent, status) => {
20
20
  var _a;
21
- return ((_a = this.config.mapping.find((value) => value.productEvent == productEvent)) === null || _a === void 0 ? void 0 : _a.oAuthScopes) || [];
21
+ return (_a = this.config.mapping.find((value) => value.productEvent == productEvent)) === null || _a === void 0 ? void 0 : _a.oAuthScopes[status];
22
22
  };
23
23
  const addValidationError = (scope, event) => {
24
24
  validationErrors.push(Object.assign({ message: text_1.errors.permissions.missingPermissionFromScope(scope, event), reference: text_1.References.MissingScopes, level: 'error', metadata: {
@@ -33,11 +33,27 @@ class ProductTriggerScopesValidator {
33
33
  }
34
34
  const manifestScopes = ((_a = manifest.typedContent.permissions) === null || _a === void 0 ? void 0 : _a.scopes) || [];
35
35
  manifest.typedContent.modules.trigger.forEach((element) => {
36
- element.events.forEach((event) => {
37
- const requiredScopes = getRequiredScopesForProductEvent(event);
38
- const missingScopes = requiredScopes.filter((requiredScope) => !manifestScopes.includes(requiredScope));
39
- missingScopes.forEach((missingScope) => addValidationError(missingScope, event));
40
- });
36
+ for (const event of element.events) {
37
+ const currentScopes = getRequiredScopes(event, 'current');
38
+ if (!currentScopes)
39
+ continue;
40
+ const missingCurrentScopes = currentScopes.filter((scope) => !manifestScopes.includes(scope));
41
+ if (missingCurrentScopes.length === 0)
42
+ continue;
43
+ const deprecatedScopes = getRequiredScopes(event, 'deprecated');
44
+ const missingDeprecatedScopes = deprecatedScopes === null || deprecatedScopes === void 0 ? void 0 : deprecatedScopes.filter((scope) => !manifestScopes.includes(scope));
45
+ if ((missingDeprecatedScopes === null || missingDeprecatedScopes === void 0 ? void 0 : missingDeprecatedScopes.length) === 0)
46
+ continue;
47
+ if (missingCurrentScopes.length < currentScopes.length) {
48
+ missingCurrentScopes.forEach((scope) => addValidationError(scope, event));
49
+ continue;
50
+ }
51
+ if (missingDeprecatedScopes && deprecatedScopes && missingDeprecatedScopes.length < deprecatedScopes.length) {
52
+ missingDeprecatedScopes.forEach((scope) => addValidationError(scope, event));
53
+ continue;
54
+ }
55
+ missingCurrentScopes.forEach((scope) => addValidationError(scope, event));
56
+ }
41
57
  });
42
58
  return {
43
59
  success: validationErrors.length === 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/manifest",
3
- "version": "0.0.0-experimental-64caa5a",
3
+ "version": "0.0.0-experimental-490cfcf",
4
4
  "description": "Definitions and validations of the Forge manifest",
5
5
  "main": "out/index.js",
6
6
  "scripts": {
@@ -23,12 +23,12 @@
23
23
  "author": "Atlassian",
24
24
  "license": "UNLICENSED",
25
25
  "dependencies": {
26
- "@forge/util": "1.0.1",
26
+ "@forge/util": "1.2.0",
27
27
  "ajv": "^6.12.5",
28
28
  "cheerio": "^0.22.0",
29
29
  "js-yaml": "^3.13.1",
30
30
  "json-schema-to-typescript": "^9.1.1",
31
- "node-fetch": "^2.6.1",
31
+ "node-fetch": "2.6.1",
32
32
  "typescript-json-schema": "^0.45.1"
33
33
  }
34
34
  }