@forge/api 6.4.0-next.0 → 6.4.0-next.2

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,19 @@
1
1
  # @forge/api
2
2
 
3
+ ## 6.4.0-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [29741cf]
8
+ - Updated dependencies [354f5d1]
9
+ - @forge/manifest@11.1.1-next.0
10
+
11
+ ## 6.4.0-next.1
12
+
13
+ ### Minor Changes
14
+
15
+ - 9989c3d: hasPermissions SDK throws an error upon invalid keys
16
+
3
17
  ## 6.4.0-next.0
4
18
 
5
19
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/api/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,sBAAsB,EAAE,kBAAkB,EAAgB,MAAM,WAAW,CAAC;AAGpG,OAAO,EAAU,QAAQ,EAAS,MAAM,iBAAiB,CAAC;AAM1D,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAQ/F;AA8BD,YAAY,EAAE,sBAAsB,EAAE,CAAC;AAKvC,YAAY,EAAE,kBAAkB,EAAE,CAAC;AAOnC,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC9B;AAqID,eAAO,MAAM,aAAa,iBAAkB,QAAQ,sBAAsB,CAAC,KAAG,gBAE7E,CAAC;AA8DF,eAAO,MAAM,QAAQ,UAAW,MAAM,KAAG,OAKxC,CAAC;AAyBF,eAAO,MAAM,YAAY,SAAU,SAAS,GAAG,QAAQ,OAAO,MAAM,KAAG,OAKtE,CAAC;AAyBF,eAAO,MAAM,eAAe,SAAU,QAA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AAM,KAAG,OAAO;yBA8Bb,SAAS,GAAG,QAAQ,OAAO,MAAM,KAAG,OAAO;4BA8BxC,QAAQ,MAAM,QAAQ,EAAE,OAAO,CAAC,OAAO,MAAM,KAAG,OAAO;CAe5F,CAAC"}
@@ -48,6 +48,35 @@ const getMissingUrls = (requiredUrls, currentlyGrantedUrls) => {
48
48
  });
49
49
  return missingUrls;
50
50
  };
51
+ const VALID_REQUIREMENT_KEYS = ['scopes', 'external'];
52
+ const VALID_EXTERNAL_TYPES = [
53
+ 'fetch',
54
+ 'fonts',
55
+ 'frames',
56
+ 'images',
57
+ 'media',
58
+ 'scripts',
59
+ 'styles'
60
+ ];
61
+ const VALID_FETCH_TYPES = ['backend', 'client'];
62
+ const validateKeys = (obj, validKeys) => {
63
+ const validKeysSet = new Set(validKeys);
64
+ const providedKeys = Object.keys(obj);
65
+ const invalidKeys = providedKeys.filter((key) => !validKeysSet.has(key));
66
+ if (invalidKeys.length > 0) {
67
+ throw new Error(`Invalid permission key(s): ${invalidKeys.join(', ')}. ` +
68
+ `Visit https://go.atlassian.com/forge-permissions for more information.`);
69
+ }
70
+ };
71
+ const validatePermissionRequirements = (requirements) => {
72
+ validateKeys(requirements, VALID_REQUIREMENT_KEYS);
73
+ if (requirements.external) {
74
+ validateKeys(requirements.external, VALID_EXTERNAL_TYPES);
75
+ if (requirements.external.fetch) {
76
+ validateKeys(requirements.external.fetch, VALID_FETCH_TYPES);
77
+ }
78
+ }
79
+ };
51
80
  const getMissingFetchPermissions = (requiredFetch, currentlyGrantedFetch) => {
52
81
  if (!requiredFetch) {
53
82
  return undefined;
@@ -102,6 +131,7 @@ const hasPermissionWithoutMetrics = (requirements) => {
102
131
  if (!arePermissionsAvailable) {
103
132
  throw new errors_1.ApiNotReadyError('This feature is not available yet');
104
133
  }
134
+ validatePermissionRequirements(requirements);
105
135
  const missingPermissions = {};
106
136
  let hasMissingPermissions = false;
107
137
  const missingScopes = getMissingScopes(requirements.scopes, currentlyGrantedPermissions.scopes);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forge/api",
3
- "version": "6.4.0-next.0",
3
+ "version": "6.4.0-next.2",
4
4
  "description": "Forge API methods",
5
5
  "author": "Atlassian",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",
@@ -28,7 +28,7 @@
28
28
  "@forge/auth": "0.0.9",
29
29
  "@forge/egress": "2.3.0-next.0",
30
30
  "@forge/i18n": "0.0.7",
31
- "@forge/manifest": "^11.1.0",
31
+ "@forge/manifest": "^11.1.1-next.0",
32
32
  "@forge/storage": "2.0.3",
33
33
  "headers-utils": "^3.0.2",
34
34
  "minimatch": "^9.0.5"