@wireapp/api-client 23.1.2 → 23.2.0

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.
@@ -12,6 +12,7 @@ import { GenericAPI } from './generic';
12
12
  import { GiphyAPI } from './giphy/';
13
13
  import { HttpClient } from './http/';
14
14
  import { NotificationAPI } from './notification/';
15
+ import { OAuthAPI } from './oauth/OAuthAPI';
15
16
  import { SelfAPI } from './self/';
16
17
  import { ServiceProviderAPI } from './serviceProvider';
17
18
  import { ServicesAPI } from './services';
@@ -41,6 +42,7 @@ type Apis = {
41
42
  conversation: ConversationAPI;
42
43
  giphy: GiphyAPI;
43
44
  notification: NotificationAPI;
45
+ oauth: OAuthAPI;
44
46
  self: SelfAPI;
45
47
  services: ServicesAPI;
46
48
  serviceProvider: ServiceProviderAPI;
@@ -105,15 +107,16 @@ export declare class APIClient extends EventEmitter {
105
107
  /**
106
108
  * Will set the APIClient to use a specific version of the API (by default uses version 0)
107
109
  * It will fetch the API Config and use the highest possible version
108
- * @param acceptedVersions Which version the consumer supports
109
- * @param useDevVersion allow the api-client to use development version of the api (if present). The dev version also need to be listed on the supportedVersions given as parameters
110
+ * @param min mininum version to use
111
+ * @param max maximum version to use
112
+ * @param allowDev allow the api-client to use development version of the api (if present). The dev version also need to be listed on the supportedVersions given as parameters
110
113
  * If we have version 2 that is a dev version, this is going to be the output of those calls
111
- * - useVersion([0, 1, 2], true) > version 2 is used
112
- * - useVersion([0, 1, 2], false) > version 1 is used
113
- * - useVersion([0, 1], true) > version 1 is used
114
+ * - useVersion(0, 2, true) > version 2 is used
115
+ * - useVersion(0, 2) > version 1 is used
116
+ * - useVersion(0, 1, true) > version 1 is used
114
117
  * @return The highest version that is both supported by client and backend
115
118
  */
116
- useVersion(acceptedVersions: number[], useDevVersion?: boolean): Promise<BackendFeatures>;
119
+ useVersion(min: number, max: number, allowDev?: boolean): Promise<BackendFeatures>;
117
120
  init(clientType?: ClientType, cookie?: Cookie): Promise<Context>;
118
121
  login(loginData: LoginData): Promise<Context>;
119
122
  loginWithToken(accessTokenString: string, clientType?: ClientType): Promise<Context>;
@@ -1 +1 @@
1
- {"version":3,"file":"APIClient.d.ts","sourceRoot":"","sources":["../src/APIClient.ts"],"names":[],"mappings":";AAqBA,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,QAAQ,EAAC,MAAM,UAAU,CAAC;AAClC,OAAO,EACL,eAAe,EAEf,OAAO,EACP,OAAO,EACP,MAAM,EACN,iBAAiB,EACjB,SAAS,EAET,YAAY,EACb,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAC,SAAS,EAAE,UAAU,EAAC,MAAM,WAAW,CAAC;AAChD,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAC,UAAU,EAAC,MAAM,WAAW,CAAC;AACrC,OAAO,EAAC,QAAQ,EAAC,MAAM,UAAU,CAAC;AAClC,OAAO,EAAe,UAAU,EAAC,MAAM,SAAS,CAAC;AACjD,OAAO,EAAC,eAAe,EAAC,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAChC,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAC,WAAW,EAAC,MAAM,YAAY,CAAC;AACvC,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,QAAQ,CAAC;AAClD,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,UAAU,EACV,UAAU,EACV,UAAU,EACV,OAAO,EACP,mBAAmB,EACnB,iB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AAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;IAiB7C,cAAc,CAAC,iBAAiB,EAAE,MAAM,EAAE,UAAU,GAAE,UAA4B,GAAG,OAAO,CAAC,OAAO,CAAC;IAerG,QAAQ,CAAC,WAAW,EAAE,YAAY,EAAE,UAAU,GAAE,UAAiC,GAAG,OAAO,CAAC,OAAO,CAAC;IAYpG,MAAM,CAAC,OAAO,GAAE;QAAC,iBAAiB,EAAE,OAAO,CAAA;KAA8B,GAAG,OAAO,CAAC,IAAI,CAAC;IAe/F,OAAO,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,eAAe;YAIxC,aAAa;IAgBpB,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAIxC,IAAW,QAAQ,IAAI,MAAM,GAAG,SAAS,CAExC;IAED,IAAW,MAAM,IAAI,MAAM,GAAG,SAAS,CAEtC;IAED,IAAW,MAAM,IAAI,MAAM,GAAG,SAAS,CAEtC;IAED,8DAA8D;IAC9D,IAAW,eAAe,IAAI,MAAM,CAKnC;IAED,gEAAgE;IAChE,IAAW,iBAAiB,IAAI,MAAM,CAKrC;CACF"}
package/lib/APIClient.js CHANGED
@@ -38,6 +38,7 @@ const generic_1 = require("./generic");
38
38
  const giphy_1 = require("./giphy/");
39
39
  const http_1 = require("./http/");
40
40
  const notification_1 = require("./notification/");
41
+ const OAuthAPI_1 = require("./oauth/OAuthAPI");
41
42
  const obfuscation_1 = require("./obfuscation/");
42
43
  const self_1 = require("./self/");
43
44
  const serviceProvider_1 = require("./serviceProvider");
@@ -103,6 +104,7 @@ class APIClient extends events_1.EventEmitter {
103
104
  conversation: new conversation_1.ConversationAPI(this.transport.http, backendFeatures),
104
105
  giphy: new giphy_1.GiphyAPI(this.transport.http),
105
106
  notification: new notification_1.NotificationAPI(this.transport.http),
107
+ oauth: new OAuthAPI_1.OAuthAPI(this.transport.http),
106
108
  self: new self_1.SelfAPI(this.transport.http),
107
109
  serviceProvider: new serviceProvider_1.ServiceProviderAPI(this.transport.http),
108
110
  teams: {
@@ -139,33 +141,31 @@ class APIClient extends events_1.EventEmitter {
139
141
  /**
140
142
  * Will set the APIClient to use a specific version of the API (by default uses version 0)
141
143
  * It will fetch the API Config and use the highest possible version
142
- * @param acceptedVersions Which version the consumer supports
143
- * @param useDevVersion allow the api-client to use development version of the api (if present). The dev version also need to be listed on the supportedVersions given as parameters
144
+ * @param min mininum version to use
145
+ * @param max maximum version to use
146
+ * @param allowDev allow the api-client to use development version of the api (if present). The dev version also need to be listed on the supportedVersions given as parameters
144
147
  * If we have version 2 that is a dev version, this is going to be the output of those calls
145
- * - useVersion([0, 1, 2], true) > version 2 is used
146
- * - useVersion([0, 1, 2], false) > version 1 is used
147
- * - useVersion([0, 1], true) > version 1 is used
148
+ * - useVersion(0, 2, true) > version 2 is used
149
+ * - useVersion(0, 2) > version 1 is used
150
+ * - useVersion(0, 1, true) > version 1 is used
148
151
  * @return The highest version that is both supported by client and backend
149
152
  */
150
- async useVersion(acceptedVersions, useDevVersion = false) {
153
+ async useVersion(min, max, allowDev) {
151
154
  var _a;
152
- if (acceptedVersions.length === 1 && acceptedVersions[0] === 0) {
153
- // Nothing to do since version 0 is the default one
154
- return this.computeBackendFeatures(0);
155
- }
156
155
  let backendVersions = { supported: [0] };
157
156
  try {
158
157
  backendVersions = (await this.transport.http.sendRequest({ url: '/api-version' })).data;
159
158
  }
160
159
  catch (error) { }
161
- const devVersions = useDevVersion ? (_a = backendVersions.development) !== null && _a !== void 0 ? _a : [] : [];
160
+ const devVersions = allowDev ? (_a = backendVersions.development) !== null && _a !== void 0 ? _a : [] : [];
162
161
  const highestCommonVersion = backendVersions.supported
163
162
  .concat(devVersions)
164
163
  .sort()
165
164
  .reverse()
166
- .find(version => acceptedVersions.includes(version));
165
+ .find(version => version >= min && version <= max);
167
166
  if (highestCommonVersion === undefined) {
168
- throw new Error(`Backend does not support requested versions [${acceptedVersions.join(', ')}] (supported versions ${backendVersions.supported.join(', ')})`);
167
+ const supportedStr = backendVersions.supported.join(', ');
168
+ throw new Error(`Backend does not support requested versions [${min}-${max}] (supported versions ${supportedStr})`);
169
169
  }
170
170
  this.backendFeatures = this.computeBackendFeatures(highestCommonVersion, backendVersions);
171
171
  this.transport.http.useVersion(this.backendFeatures.version);
@@ -0,0 +1,32 @@
1
+ import { OAuthApplication } from './OAuthApplication';
2
+ import { OAuthBody } from './OAuthBody';
3
+ import { OAuthClient } from './OAuthClient';
4
+ import { HttpClient } from '../http';
5
+ export declare class OAuthAPI {
6
+ private readonly client;
7
+ constructor(client: HttpClient);
8
+ static readonly URL: {
9
+ APPLICATIONS: string;
10
+ AUTHORIZATION: string;
11
+ CODES: string;
12
+ CLIENTS: string;
13
+ OAUTH: string;
14
+ };
15
+ /**
16
+ * Get all OAuth applications.
17
+ */
18
+ getApplications(): Promise<OAuthApplication[]>;
19
+ /**
20
+ * Remove an application by ID.
21
+ */
22
+ deleteApplication(applicationId: string): Promise<void>;
23
+ /**
24
+ * Create an OAuth authorization code.
25
+ */
26
+ postOAuthCode(oauthBody: OAuthBody): Promise<void>;
27
+ /**
28
+ * Get OAuth client information.
29
+ */
30
+ getClient(applicationId: string): Promise<OAuthClient>;
31
+ }
32
+ //# sourceMappingURL=OAuthAPI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OAuthAPI.d.ts","sourceRoot":"","sources":["../../src/oauth/OAuthAPI.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AAEnC,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAE/C,gBAAuB,GAAG;;;;;;MAMxB;IAEF;;OAEG;IACU,eAAe,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAU3D;;OAEG;IACU,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYpE;;OAEG;IACU,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAa/D;;OAEG;IACU,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CASpE"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2023 Wire Swiss GmbH
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program. If not, see http://www.gnu.org/licenses/.
18
+ *
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.OAuthAPI = void 0;
22
+ class OAuthAPI {
23
+ constructor(client) {
24
+ this.client = client;
25
+ }
26
+ /**
27
+ * Get all OAuth applications.
28
+ */
29
+ async getApplications() {
30
+ const config = {
31
+ method: 'get',
32
+ url: `${OAuthAPI.URL.OAUTH}/${OAuthAPI.URL.APPLICATIONS}`,
33
+ };
34
+ const response = await this.client.sendJSON(config);
35
+ return response.data;
36
+ }
37
+ /**
38
+ * Remove an application by ID.
39
+ */
40
+ async deleteApplication(applicationId) {
41
+ const config = {
42
+ method: 'delete',
43
+ url: `${OAuthAPI.URL.OAUTH}/${OAuthAPI.URL.APPLICATIONS}/${applicationId}`,
44
+ };
45
+ try {
46
+ await this.client.sendJSON(config);
47
+ }
48
+ catch (error) {
49
+ throw error;
50
+ }
51
+ }
52
+ /**
53
+ * Create an OAuth authorization code.
54
+ */
55
+ async postOAuthCode(oauthBody) {
56
+ const config = {
57
+ data: oauthBody,
58
+ method: 'post',
59
+ url: `${OAuthAPI.URL.OAUTH}/${OAuthAPI.URL.AUTHORIZATION}/${OAuthAPI.URL.CODES}`,
60
+ };
61
+ try {
62
+ await this.client.sendJSON(config);
63
+ }
64
+ catch (error) {
65
+ throw error;
66
+ }
67
+ }
68
+ /**
69
+ * Get OAuth client information.
70
+ */
71
+ async getClient(applicationId) {
72
+ const config = {
73
+ method: 'get',
74
+ url: `${OAuthAPI.URL.OAUTH}/${OAuthAPI.URL.CLIENTS}/${applicationId}`,
75
+ };
76
+ const response = await this.client.sendJSON(config);
77
+ return response.data;
78
+ }
79
+ }
80
+ exports.OAuthAPI = OAuthAPI;
81
+ OAuthAPI.URL = {
82
+ APPLICATIONS: 'applications',
83
+ AUTHORIZATION: 'authorization',
84
+ CODES: 'codes',
85
+ CLIENTS: 'clients',
86
+ OAUTH: '/oauth',
87
+ };
@@ -0,0 +1,5 @@
1
+ export interface OAuthApplication {
2
+ id: string;
3
+ name: string;
4
+ }
5
+ //# sourceMappingURL=OAuthApplication.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OAuthApplication.d.ts","sourceRoot":"","sources":["../../src/oauth/OAuthApplication.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2023 Wire Swiss GmbH
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program. If not, see http://www.gnu.org/licenses/.
18
+ *
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ export interface OAuthBody {
2
+ client_id: string;
3
+ redirect_uri: string;
4
+ response_type: string;
5
+ scope: string;
6
+ state: string;
7
+ }
8
+ //# sourceMappingURL=OAuthBody.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OAuthBody.d.ts","sourceRoot":"","sources":["../../src/oauth/OAuthBody.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2023 Wire Swiss GmbH
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program. If not, see http://www.gnu.org/licenses/.
18
+ *
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ export interface OAuthClient {
2
+ application_name: string;
3
+ client_id: string;
4
+ redirect_url: string;
5
+ }
6
+ //# sourceMappingURL=OAuthClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OAuthClient.d.ts","sourceRoot":"","sources":["../../src/oauth/OAuthClient.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,WAAW;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2023 Wire Swiss GmbH
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program. If not, see http://www.gnu.org/licenses/.
18
+ *
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -63,6 +63,6 @@
63
63
  "watch": "webpack serve --config webpack.browser.js",
64
64
  "prepare": "yarn dist"
65
65
  },
66
- "version": "23.1.2",
67
- "gitHead": "fa13f02bbb039d7019e719eadd156f8170952481"
66
+ "version": "23.2.0",
67
+ "gitHead": "1bef113fd111dd092ff64fb8d5f0e12abd42cf5c"
68
68
  }