@atlaskit/teams-client 4.32.0 → 4.32.1
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 +10 -0
- package/dist/cjs/services/base-client/index.js +3 -2
- package/dist/cjs/services/graphql-client/main.js +33 -1
- package/dist/es2019/services/base-client/index.js +3 -2
- package/dist/es2019/services/graphql-client/main.js +34 -1
- package/dist/esm/services/base-client/index.js +3 -2
- package/dist/esm/services/graphql-client/main.js +34 -1
- package/dist/types/services/graphql-client/main.d.ts +4 -1
- package/dist/types-ts4.5/services/graphql-client/main.d.ts +4 -1
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/teams-client
|
|
2
2
|
|
|
3
|
+
## 4.32.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a45dd5a6666e8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a45dd5a6666e8) -
|
|
8
|
+
Fix invalid ARI being sent in X-Query-Context header when cloudId is unavailable. Previously, an
|
|
9
|
+
uninitialised cloudId defaulted to the string 'None', causing requests to include a malformed
|
|
10
|
+
header value of `ari:cloud:platform::site/None`. The client now defaults to an empty string so no
|
|
11
|
+
header is sent until a valid cloudId is set.
|
|
12
|
+
|
|
3
13
|
## 4.32.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -8,6 +8,7 @@ exports.BaseClient = void 0;
|
|
|
8
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
12
|
var _sentry = require("../sentry");
|
|
12
13
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
14
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -22,14 +23,14 @@ var BaseClient = exports.BaseClient = /*#__PURE__*/function () {
|
|
|
22
23
|
});
|
|
23
24
|
this.config = config;
|
|
24
25
|
this.context = {
|
|
25
|
-
cloudId: 'None'
|
|
26
|
+
cloudId: (0, _platformFeatureFlags.fg)('teams-app_client_fix-invalid-ari') ? '' : 'None'
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
29
|
return (0, _createClass2.default)(BaseClient, [{
|
|
29
30
|
key: "setContext",
|
|
30
31
|
value: function setContext(context) {
|
|
31
32
|
this.context = _objectSpread(_objectSpread({}, context), {}, {
|
|
32
|
-
cloudId: context.cloudId || 'None'
|
|
33
|
+
cloudId: (0, _platformFeatureFlags.fg)('teams-app_client_fix-invalid-ari') ? context.cloudId || '' : context.cloudId || 'None'
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
}, {
|
|
@@ -13,6 +13,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
13
13
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
15
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
16
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
17
|
var _error = require("../../common/utils/error");
|
|
17
18
|
var _baseClient = require("../base-client");
|
|
18
19
|
var _utils = require("./utils");
|
|
@@ -20,6 +21,24 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
20
21
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
22
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
22
23
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
24
|
+
/**
|
|
25
|
+
* Validates that a siteId (cloudId) conforms to the format expected by
|
|
26
|
+
* PlatformSiteAri from `@atlassian/ari/platform`.
|
|
27
|
+
*
|
|
28
|
+
* We inline this instead of importing `@atlassian/ari` because that package
|
|
29
|
+
* is private and `teams-client` is a public package - public packages cannot
|
|
30
|
+
* depend on private packages.
|
|
31
|
+
*
|
|
32
|
+
* The regex matches the `resourceIdSegmentFormats.siteId` rule from the
|
|
33
|
+
* PlatformSiteAri manifest: `/[a-zA-Z0-9_\-.]{1,255}/`
|
|
34
|
+
*/
|
|
35
|
+
var SITE_ID_PATTERN = /^[a-zA-Z0-9_\-.]{1,255}$/;
|
|
36
|
+
function createPlatformSiteAri(siteId) {
|
|
37
|
+
if (!SITE_ID_PATTERN.test(siteId)) {
|
|
38
|
+
throw new Error("Invalid siteId: ".concat(siteId));
|
|
39
|
+
}
|
|
40
|
+
return "ari:cloud:platform::site/".concat(siteId);
|
|
41
|
+
}
|
|
23
42
|
var BaseGraphQlClient = exports.BaseGraphQlClient = /*#__PURE__*/function (_BaseClient) {
|
|
24
43
|
function BaseGraphQlClient(serviceUrl, config) {
|
|
25
44
|
var _this;
|
|
@@ -36,7 +55,10 @@ var BaseGraphQlClient = exports.BaseGraphQlClient = /*#__PURE__*/function (_Base
|
|
|
36
55
|
}
|
|
37
56
|
|
|
38
57
|
/**
|
|
39
|
-
* Creates query context headers if cloudId is available.
|
|
58
|
+
* Creates query context headers if cloudId is available and valid.
|
|
59
|
+
* When the fix-invalid-ari flag is enabled, validates the cloudId before
|
|
60
|
+
* constructing the ARI, preventing invalid ARIs like
|
|
61
|
+
* `ari:cloud:platform::site/None` from being sent.
|
|
40
62
|
*/
|
|
41
63
|
}, {
|
|
42
64
|
key: "createQueryContextHeaders",
|
|
@@ -44,6 +66,16 @@ var BaseGraphQlClient = exports.BaseGraphQlClient = /*#__PURE__*/function (_Base
|
|
|
44
66
|
if (!cloudId) {
|
|
45
67
|
return undefined;
|
|
46
68
|
}
|
|
69
|
+
if ((0, _platformFeatureFlags.fg)('teams-app_client_fix-invalid-ari')) {
|
|
70
|
+
try {
|
|
71
|
+
var ari = createPlatformSiteAri(cloudId);
|
|
72
|
+
return {
|
|
73
|
+
'X-Query-Context': ari
|
|
74
|
+
};
|
|
75
|
+
} catch (_unused) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
47
79
|
return {
|
|
48
80
|
'X-Query-Context': "ari:cloud:platform::site/".concat(cloudId)
|
|
49
81
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { logException } from '../sentry';
|
|
3
4
|
export class BaseClient {
|
|
4
5
|
constructor(config) {
|
|
@@ -9,13 +10,13 @@ export class BaseClient {
|
|
|
9
10
|
});
|
|
10
11
|
this.config = config;
|
|
11
12
|
this.context = {
|
|
12
|
-
cloudId: 'None'
|
|
13
|
+
cloudId: fg('teams-app_client_fix-invalid-ari') ? '' : 'None'
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
setContext(context) {
|
|
16
17
|
this.context = {
|
|
17
18
|
...context,
|
|
18
|
-
cloudId: context.cloudId || 'None'
|
|
19
|
+
cloudId: fg('teams-app_client_fix-invalid-ari') ? context.cloudId || '' : context.cloudId || 'None'
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
getContext() {
|
|
@@ -1,6 +1,26 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
1
2
|
import { DefaultError, GraphQLError } from '../../common/utils/error';
|
|
2
3
|
import { BaseClient } from '../base-client';
|
|
3
4
|
import { handleGraphQLRequest } from './utils';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Validates that a siteId (cloudId) conforms to the format expected by
|
|
8
|
+
* PlatformSiteAri from `@atlassian/ari/platform`.
|
|
9
|
+
*
|
|
10
|
+
* We inline this instead of importing `@atlassian/ari` because that package
|
|
11
|
+
* is private and `teams-client` is a public package - public packages cannot
|
|
12
|
+
* depend on private packages.
|
|
13
|
+
*
|
|
14
|
+
* The regex matches the `resourceIdSegmentFormats.siteId` rule from the
|
|
15
|
+
* PlatformSiteAri manifest: `/[a-zA-Z0-9_\-.]{1,255}/`
|
|
16
|
+
*/
|
|
17
|
+
const SITE_ID_PATTERN = /^[a-zA-Z0-9_\-.]{1,255}$/;
|
|
18
|
+
function createPlatformSiteAri(siteId) {
|
|
19
|
+
if (!SITE_ID_PATTERN.test(siteId)) {
|
|
20
|
+
throw new Error(`Invalid siteId: ${siteId}`);
|
|
21
|
+
}
|
|
22
|
+
return `ari:cloud:platform::site/${siteId}`;
|
|
23
|
+
}
|
|
4
24
|
export class BaseGraphQlClient extends BaseClient {
|
|
5
25
|
constructor(serviceUrl, config) {
|
|
6
26
|
super(config);
|
|
@@ -11,12 +31,25 @@ export class BaseGraphQlClient extends BaseClient {
|
|
|
11
31
|
}
|
|
12
32
|
|
|
13
33
|
/**
|
|
14
|
-
* Creates query context headers if cloudId is available.
|
|
34
|
+
* Creates query context headers if cloudId is available and valid.
|
|
35
|
+
* When the fix-invalid-ari flag is enabled, validates the cloudId before
|
|
36
|
+
* constructing the ARI, preventing invalid ARIs like
|
|
37
|
+
* `ari:cloud:platform::site/None` from being sent.
|
|
15
38
|
*/
|
|
16
39
|
createQueryContextHeaders(cloudId) {
|
|
17
40
|
if (!cloudId) {
|
|
18
41
|
return undefined;
|
|
19
42
|
}
|
|
43
|
+
if (fg('teams-app_client_fix-invalid-ari')) {
|
|
44
|
+
try {
|
|
45
|
+
const ari = createPlatformSiteAri(cloudId);
|
|
46
|
+
return {
|
|
47
|
+
'X-Query-Context': ari
|
|
48
|
+
};
|
|
49
|
+
} catch {
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
20
53
|
return {
|
|
21
54
|
'X-Query-Context': `ari:cloud:platform::site/${cloudId}`
|
|
22
55
|
};
|
|
@@ -3,6 +3,7 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { logException } from '../sentry';
|
|
7
8
|
export var BaseClient = /*#__PURE__*/function () {
|
|
8
9
|
function BaseClient(config) {
|
|
@@ -15,14 +16,14 @@ export var BaseClient = /*#__PURE__*/function () {
|
|
|
15
16
|
});
|
|
16
17
|
this.config = config;
|
|
17
18
|
this.context = {
|
|
18
|
-
cloudId: 'None'
|
|
19
|
+
cloudId: fg('teams-app_client_fix-invalid-ari') ? '' : 'None'
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
return _createClass(BaseClient, [{
|
|
22
23
|
key: "setContext",
|
|
23
24
|
value: function setContext(context) {
|
|
24
25
|
this.context = _objectSpread(_objectSpread({}, context), {}, {
|
|
25
|
-
cloudId: context.cloudId || 'None'
|
|
26
|
+
cloudId: fg('teams-app_client_fix-invalid-ari') ? context.cloudId || '' : context.cloudId || 'None'
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
}, {
|
|
@@ -10,9 +10,29 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
10
10
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
11
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
12
12
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
14
|
import { DefaultError, GraphQLError } from '../../common/utils/error';
|
|
14
15
|
import { BaseClient } from '../base-client';
|
|
15
16
|
import { handleGraphQLRequest } from './utils';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Validates that a siteId (cloudId) conforms to the format expected by
|
|
20
|
+
* PlatformSiteAri from `@atlassian/ari/platform`.
|
|
21
|
+
*
|
|
22
|
+
* We inline this instead of importing `@atlassian/ari` because that package
|
|
23
|
+
* is private and `teams-client` is a public package - public packages cannot
|
|
24
|
+
* depend on private packages.
|
|
25
|
+
*
|
|
26
|
+
* The regex matches the `resourceIdSegmentFormats.siteId` rule from the
|
|
27
|
+
* PlatformSiteAri manifest: `/[a-zA-Z0-9_\-.]{1,255}/`
|
|
28
|
+
*/
|
|
29
|
+
var SITE_ID_PATTERN = /^[a-zA-Z0-9_\-.]{1,255}$/;
|
|
30
|
+
function createPlatformSiteAri(siteId) {
|
|
31
|
+
if (!SITE_ID_PATTERN.test(siteId)) {
|
|
32
|
+
throw new Error("Invalid siteId: ".concat(siteId));
|
|
33
|
+
}
|
|
34
|
+
return "ari:cloud:platform::site/".concat(siteId);
|
|
35
|
+
}
|
|
16
36
|
export var BaseGraphQlClient = /*#__PURE__*/function (_BaseClient) {
|
|
17
37
|
function BaseGraphQlClient(serviceUrl, config) {
|
|
18
38
|
var _this;
|
|
@@ -29,7 +49,10 @@ export var BaseGraphQlClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
29
49
|
}
|
|
30
50
|
|
|
31
51
|
/**
|
|
32
|
-
* Creates query context headers if cloudId is available.
|
|
52
|
+
* Creates query context headers if cloudId is available and valid.
|
|
53
|
+
* When the fix-invalid-ari flag is enabled, validates the cloudId before
|
|
54
|
+
* constructing the ARI, preventing invalid ARIs like
|
|
55
|
+
* `ari:cloud:platform::site/None` from being sent.
|
|
33
56
|
*/
|
|
34
57
|
}, {
|
|
35
58
|
key: "createQueryContextHeaders",
|
|
@@ -37,6 +60,16 @@ export var BaseGraphQlClient = /*#__PURE__*/function (_BaseClient) {
|
|
|
37
60
|
if (!cloudId) {
|
|
38
61
|
return undefined;
|
|
39
62
|
}
|
|
63
|
+
if (fg('teams-app_client_fix-invalid-ari')) {
|
|
64
|
+
try {
|
|
65
|
+
var ari = createPlatformSiteAri(cloudId);
|
|
66
|
+
return {
|
|
67
|
+
'X-Query-Context': ari
|
|
68
|
+
};
|
|
69
|
+
} catch (_unused) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
40
73
|
return {
|
|
41
74
|
'X-Query-Context': "ari:cloud:platform::site/".concat(cloudId)
|
|
42
75
|
};
|
|
@@ -5,7 +5,10 @@ export declare class BaseGraphQlClient extends BaseClient {
|
|
|
5
5
|
constructor(serviceUrl: string, config: ClientConfig);
|
|
6
6
|
setServiceUrl(serviceUrl: string): void;
|
|
7
7
|
/**
|
|
8
|
-
* Creates query context headers if cloudId is available.
|
|
8
|
+
* Creates query context headers if cloudId is available and valid.
|
|
9
|
+
* When the fix-invalid-ari flag is enabled, validates the cloudId before
|
|
10
|
+
* constructing the ARI, preventing invalid ARIs like
|
|
11
|
+
* `ari:cloud:platform::site/None` from being sent.
|
|
9
12
|
*/
|
|
10
13
|
private createQueryContextHeaders;
|
|
11
14
|
makeGraphQLRequest<Key extends string, Data = unknown, Variables = unknown>(body: Body<Variables>, options?: Options): Promise<ResultResponse<Key, Data>>;
|
|
@@ -5,7 +5,10 @@ export declare class BaseGraphQlClient extends BaseClient {
|
|
|
5
5
|
constructor(serviceUrl: string, config: ClientConfig);
|
|
6
6
|
setServiceUrl(serviceUrl: string): void;
|
|
7
7
|
/**
|
|
8
|
-
* Creates query context headers if cloudId is available.
|
|
8
|
+
* Creates query context headers if cloudId is available and valid.
|
|
9
|
+
* When the fix-invalid-ari flag is enabled, validates the cloudId before
|
|
10
|
+
* constructing the ARI, preventing invalid ARIs like
|
|
11
|
+
* `ari:cloud:platform::site/None` from being sent.
|
|
9
12
|
*/
|
|
10
13
|
private createQueryContextHeaders;
|
|
11
14
|
makeGraphQLRequest<Key extends string, Data = unknown, Variables = unknown>(body: Body<Variables>, options?: Options): Promise<ResultResponse<Key, Data>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/teams-client",
|
|
3
|
-
"version": "4.32.
|
|
3
|
+
"version": "4.32.1",
|
|
4
4
|
"description": "A client to retrieve team related data",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -93,6 +93,9 @@
|
|
|
93
93
|
"platform-feature-flags": {
|
|
94
94
|
"enable_edit_team_name_external_type_teams": {
|
|
95
95
|
"type": "boolean"
|
|
96
|
+
},
|
|
97
|
+
"teams-app_client_fix-invalid-ari": {
|
|
98
|
+
"type": "boolean"
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
}
|