@rocket.chat/api-client 0.1.0-rc.0 → 0.1.0-rc.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,20 @@
1
1
  # @rocket.chat/api-client
2
2
 
3
+ ## 0.1.0-rc.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [f76d514341]
8
+ - @rocket.chat/rest-typings@6.3.0-rc.2
9
+ - @rocket.chat/core-typings@6.3.0-rc.2
10
+
11
+ ## 0.1.0-rc.1
12
+
13
+ ### Patch Changes
14
+
15
+ - @rocket.chat/core-typings@6.3.0-rc.1
16
+ - @rocket.chat/rest-typings@6.3.0-rc.1
17
+
3
18
  ## 0.1.0-rc.0
4
19
 
5
20
  ### Minor Changes
@@ -0,0 +1,37 @@
1
+ import type { Serialized } from '@rocket.chat/core-typings';
2
+ import type { MatchPathPattern, OperationParams, OperationResult, PathFor, PathWithParamsFor, PathWithoutParamsFor } from '@rocket.chat/rest-typings';
3
+ type Next<T extends (...args: any[]) => any> = (...args: Parameters<T>) => ReturnType<T>;
4
+ export type Middleware<T extends (...args: any[]) => any> = (context: Parameters<T>, next: Next<T>) => ReturnType<T>;
5
+ export interface RestClientInterface {
6
+ get<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathWithParamsFor<'GET'> = PathWithParamsFor<'GET'>>(endpoint: TPath, params: OperationParams<'GET', TPathPattern>, options?: Omit<RequestInit, 'method'>): Promise<Serialized<OperationResult<'GET', TPathPattern>>>;
7
+ get<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathWithoutParamsFor<'GET'> = PathWithoutParamsFor<'GET'>>(endpoint: TPath, params?: undefined, options?: Omit<RequestInit, 'method'>): Promise<Serialized<OperationResult<'GET', TPathPattern>>>;
8
+ post<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathWithParamsFor<'POST'> = PathWithParamsFor<'POST'>>(endpoint: TPath, params: OperationParams<'POST', TPathPattern>, options?: Omit<RequestInit, 'method'>): Promise<Serialized<OperationResult<'POST', TPathPattern>>>;
9
+ post<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathWithoutParamsFor<'POST'> = PathWithoutParamsFor<'POST'>>(endpoint: TPath, params?: undefined, options?: Omit<RequestInit, 'method'>): Promise<Serialized<OperationResult<'POST', TPathPattern>>>;
10
+ put<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathWithParamsFor<'PUT'> = PathWithParamsFor<'PUT'>>(endpoint: TPath, params: OperationParams<'PUT', TPathPattern>, options?: Omit<RequestInit, 'method'>): Promise<Serialized<OperationResult<'PUT', TPathPattern>>>;
11
+ put<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathWithoutParamsFor<'PUT'> = PathWithoutParamsFor<'PUT'>>(endpoint: TPath, params?: undefined, options?: Omit<RequestInit, 'method'>): Promise<Serialized<OperationResult<'PUT', TPathPattern>>>;
12
+ delete<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathWithParamsFor<'DELETE'> = PathWithParamsFor<'DELETE'>>(endpoint: TPath, params: OperationParams<'DELETE', TPathPattern>, options?: Omit<RequestInit, 'method'>): Promise<Serialized<OperationResult<'DELETE', TPathPattern>>>;
13
+ delete<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathWithoutParamsFor<'DELETE'> = PathWithoutParamsFor<'DELETE'>>(endpoint: TPath, params?: undefined, options?: Omit<RequestInit, 'method'>): Promise<Serialized<OperationResult<'DELETE', TPathPattern>>>;
14
+ upload<TPath extends PathFor<'POST'>>(endpoint: TPath, params: void extends OperationParams<'POST', MatchPathPattern<TPath>> ? void : OperationParams<'POST', MatchPathPattern<TPath>>, events?: {
15
+ load?: (event: ProgressEvent<XMLHttpRequestEventTarget>) => void;
16
+ progress?: (event: ProgressEvent<XMLHttpRequestEventTarget>) => void;
17
+ abort?: (event: ProgressEvent<XMLHttpRequestEventTarget>) => void;
18
+ error?: (event: ProgressEvent<XMLHttpRequestEventTarget>) => void;
19
+ }, options?: Omit<RequestInit, 'method'>): XMLHttpRequest;
20
+ getCredentials(): {
21
+ 'X-User-Id': string;
22
+ 'X-Auth-Token': string;
23
+ } | undefined;
24
+ setCredentials(credentials: undefined | {
25
+ 'X-User-Id': string;
26
+ 'X-Auth-Token': string;
27
+ }): void;
28
+ use(middleware: Middleware<RestClientInterface['send']>): void;
29
+ send(endpoint: string, method: string, options?: Omit<RequestInit, 'method'>): Promise<Response>;
30
+ handleTwoFactorChallenge(cb: (args: {
31
+ method: 'totp' | 'email' | 'password';
32
+ emailOrUsername?: string;
33
+ invalidAttempt?: boolean;
34
+ }) => Promise<string>): void;
35
+ }
36
+ export {};
37
+ //# sourceMappingURL=RestClientInterface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RestClientInterface.d.ts","sourceRoot":"","sources":["../src/RestClientInterface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EACX,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,OAAO,EACP,iBAAiB,EACjB,oBAAoB,EACpB,MAAM,2BAA2B,CAAC;AAEnC,KAAK,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC;AAEzF,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC;AAGrH,MAAM,WAAW,mBAAmB;IACnC,GAAG,CAAC,YAAY,SAAS,gBAAgB,CAAC,KAAK,CAAC,EAAE,KAAK,SAAS,iBAAiB,CAAC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AAG,IAAI,CAAC;IAE/D,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEjG,wBAAwB,CACvB,EAAE,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,MAAM,CAAC,GAC1H,IAAI,CAAC;CACR"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=RestClientInterface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RestClientInterface.js","sourceRoot":"","sources":["../src/RestClientInterface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ declare const twoFactorMethods: readonly ["totp", "email", "password"];
2
+ type TwoFactorMethod = (typeof twoFactorMethods)[number];
3
+ export declare const isTotpRequiredError: (error: unknown) => error is {
4
+ error: 'totp-required';
5
+ } | {
6
+ errorType: 'totp-required';
7
+ };
8
+ export declare const isTotpInvalidError: (error: unknown) => error is {
9
+ error: 'totp-invalid';
10
+ } | {
11
+ errorType: 'totp-invalid';
12
+ };
13
+ export declare const isTwoFactorMethod: (method: string) => method is "totp" | "email" | "password";
14
+ export declare const hasRequiredTwoFactorMethod: (error: unknown) => error is {
15
+ details: {
16
+ method: TwoFactorMethod;
17
+ emailOrUsername?: string;
18
+ };
19
+ };
20
+ export {};
21
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,gBAAgB,wCAAyC,CAAC;AAEhE,KAAK,eAAe,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,eAAO,MAAM,mBAAmB,UAAW,OAAO;WAAqB,eAAe;;eAAkB,eAAe;CAGvC,CAAC;AAEjF,eAAO,MAAM,kBAAkB,UAAW,OAAO;WAAqB,cAAc;;eAAkB,cAAc;CAEvC,CAAC;AAE9E,eAAO,MAAM,iBAAiB,WAAY,MAAM,4CAAoF,CAAC;AAErI,eAAO,MAAM,0BAA0B,UAAW,OAAO;aAAuB;QAAE,MAAM,EAAE,eAAe,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAA;KAAE;CAQpI,CAAC"}
package/dist/errors.js ADDED
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasRequiredTwoFactorMethod = exports.isTwoFactorMethod = exports.isTotpInvalidError = exports.isTotpRequiredError = void 0;
4
+ const twoFactorMethods = ['totp', 'email', 'password'];
5
+ const isTotpRequiredError = (error) => typeof error === 'object' &&
6
+ ((error === null || error === void 0 ? void 0 : error.error) === 'totp-required' ||
7
+ (error === null || error === void 0 ? void 0 : error.errorType) === 'totp-required');
8
+ exports.isTotpRequiredError = isTotpRequiredError;
9
+ const isTotpInvalidError = (error) => (error === null || error === void 0 ? void 0 : error.error) === 'totp-invalid' ||
10
+ (error === null || error === void 0 ? void 0 : error.errorType) === 'totp-invalid';
11
+ exports.isTotpInvalidError = isTotpInvalidError;
12
+ const isTwoFactorMethod = (method) => twoFactorMethods.includes(method);
13
+ exports.isTwoFactorMethod = isTwoFactorMethod;
14
+ const hasRequiredTwoFactorMethod = (error) => {
15
+ const details = error && typeof error === 'object' && 'details' in error && error.details;
16
+ return (typeof details === 'object' &&
17
+ details !== null &&
18
+ typeof details.method === 'string' &&
19
+ (0, exports.isTwoFactorMethod)(details.method));
20
+ };
21
+ exports.hasRequiredTwoFactorMethod = hasRequiredTwoFactorMethod;
22
+ //# sourceMappingURL=errors.js.map
@@ -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chat/core-typings';
2
+ import type { MatchPathPattern, ParamsFor, OperationResult, PathWithoutParamsFor, PathWithParamsFor } from '@rocket.chat/rest-typings';
3
+ import type { Middleware, RestClientInterface } from './RestClientInterface';
4
+ export { RestClientInterface };
5
+ export declare class RestClient implements RestClientInterface {
6
+ private twoFactorHandler?;
7
+ private readonly baseUrl;
8
+ private headers;
9
+ private credentials;
10
+ constructor({ baseUrl, credentials, headers, }: {
11
+ baseUrl: string;
12
+ credentials?: {
13
+ 'X-User-Id': string;
14
+ 'X-Auth-Token': string;
15
+ };
16
+ headers?: Record<string, string>;
17
+ });
18
+ getCredentials(): ReturnType<RestClientInterface['getCredentials']>;
19
+ setCredentials: RestClientInterface['setCredentials'];
20
+ get<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathWithParamsFor<'GET'> = PathWithParamsFor<'GET'>>(endpoint: TPath, params: ParamsFor<'GET', TPathPattern>, options?: Omit<RequestInit, 'method'>): Promise<Serialized<OperationResult<'GET', TPathPattern>>>;
21
+ get<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathWithoutParamsFor<'GET'> = PathWithoutParamsFor<'GET'>>(endpoint: TPath, params?: undefined, options?: Omit<RequestInit, 'method'>): Promise<Serialized<OperationResult<'GET', TPathPattern>>>;
22
+ post<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathWithParamsFor<'POST'> = PathWithParamsFor<'POST'>>(endpoint: TPath, params: ParamsFor<'POST', TPathPattern>, options?: Omit<RequestInit, 'method'>): Promise<Serialized<OperationResult<'POST', TPathPattern>>>;
23
+ post<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathWithoutParamsFor<'POST'> = PathWithoutParamsFor<'POST'>>(endpoint: TPath, params?: undefined, options?: Omit<RequestInit, 'method'>): Promise<Serialized<OperationResult<'POST', TPathPattern>>>;
24
+ put<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathWithParamsFor<'PUT'> = PathWithParamsFor<'PUT'>>(endpoint: TPath, params: ParamsFor<'PUT', TPathPattern>, options?: Omit<RequestInit, 'method'>): Promise<Serialized<OperationResult<'PUT', TPathPattern>>>;
25
+ put<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathWithoutParamsFor<'PUT'> = PathWithoutParamsFor<'PUT'>>(endpoint: TPath, params?: undefined, options?: Omit<RequestInit, 'method'>): Promise<Serialized<OperationResult<'PUT', TPathPattern>>>;
26
+ delete<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathWithParamsFor<'DELETE'> = PathWithParamsFor<'DELETE'>>(endpoint: TPath, params: ParamsFor<'DELETE', TPathPattern>, options?: Omit<RequestInit, 'method'>): Promise<Serialized<OperationResult<'DELETE', TPathPattern>>>;
27
+ delete<TPathPattern extends MatchPathPattern<TPath>, TPath extends PathWithoutParamsFor<'DELETE'> = PathWithoutParamsFor<'DELETE'>>(endpoint: TPath, params?: undefined, options?: Omit<RequestInit, 'method'>): Promise<Serialized<OperationResult<'DELETE', TPathPattern>>>;
28
+ protected getCredentialsAsHeaders(): Record<string, string>;
29
+ send(endpoint: string, method: string, { headers, ...options }?: Omit<RequestInit, 'method'>): Promise<Response>;
30
+ protected getParams(data: Record<string, object | number | string | boolean> | void): string;
31
+ upload: RestClientInterface['upload'];
32
+ use(middleware: Middleware<RestClientInterface['send']>): void;
33
+ handleTwoFactorChallenge(cb: (args: {
34
+ method: 'totp' | 'email' | 'password';
35
+ emailOrUsername?: string;
36
+ invalidAttempt?: boolean;
37
+ }) => Promise<string>): void;
38
+ }
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EACX,gBAAgB,EAChB,SAAS,EACT,eAAe,EAEf,oBAAoB,EACpB,iBAAiB,EACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,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M,GAAG,OAAO,CAAC,GAAG,IAAI,GAAG,MAAM;IAI5F,MAAM,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAoCnC;IAEF,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI;IAO9D,wBAAwB,CACvB,EAAE,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;QAAC,eAAe,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,OAAO,CAAC,MAAM,CAAC,GAC1H,IAAI;CAGP"}
package/dist/index.js ADDED
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.RestClient = void 0;
24
+ const query_string_1 = require("query-string");
25
+ const errors_1 = require("./errors");
26
+ const pipe = (fn) => (...args) => fn(...args);
27
+ function buildFormData(data, formData = new FormData(), parentKey) {
28
+ if (data instanceof FormData) {
29
+ return data;
30
+ }
31
+ if (!data) {
32
+ return formData;
33
+ }
34
+ if (typeof data === 'object' && !(data instanceof File)) {
35
+ Object.keys(data).forEach((key) => {
36
+ buildFormData(formData, data[key], parentKey ? `${parentKey}[${key}]` : key);
37
+ });
38
+ }
39
+ else {
40
+ data && parentKey && formData.append(parentKey, data);
41
+ }
42
+ return formData;
43
+ }
44
+ const checkIfIsFormData = (data = {}) => {
45
+ if (data instanceof FormData) {
46
+ return true;
47
+ }
48
+ return Object.values(data).some((value) => {
49
+ if (value && typeof value === 'object' && !(value instanceof File)) {
50
+ return checkIfIsFormData(value);
51
+ }
52
+ return value instanceof File;
53
+ });
54
+ };
55
+ class RestClient {
56
+ constructor({ baseUrl, credentials, headers = {}, }) {
57
+ this.headers = {};
58
+ this.setCredentials = (credentials) => {
59
+ this.credentials = credentials;
60
+ };
61
+ this.upload = (endpoint, params, events, options = {}) => {
62
+ if (!params) {
63
+ throw new Error('Missing params');
64
+ }
65
+ const xhr = new XMLHttpRequest();
66
+ const data = new FormData();
67
+ Object.entries(params).forEach(([key, value]) => {
68
+ if (value instanceof File) {
69
+ data.append(key, value, value.name);
70
+ return;
71
+ }
72
+ value && data.append(key, value);
73
+ });
74
+ xhr.open('POST', `${this.baseUrl}${`/${endpoint}`.replace(/\/+/, '/')}`, true);
75
+ Object.entries(Object.assign(Object.assign({}, this.getCredentialsAsHeaders()), options.headers)).forEach(([key, value]) => {
76
+ xhr.setRequestHeader(key, value);
77
+ });
78
+ if (events === null || events === void 0 ? void 0 : events.load) {
79
+ xhr.upload.addEventListener('load', events.load);
80
+ }
81
+ if (events === null || events === void 0 ? void 0 : events.progress) {
82
+ xhr.upload.addEventListener('progress', events.progress);
83
+ }
84
+ if (events === null || events === void 0 ? void 0 : events.error) {
85
+ xhr.addEventListener('error', events.error);
86
+ }
87
+ if (events === null || events === void 0 ? void 0 : events.abort) {
88
+ xhr.addEventListener('abort', events.abort);
89
+ }
90
+ xhr.send(data);
91
+ return xhr;
92
+ };
93
+ this.baseUrl = `${baseUrl}/api`;
94
+ this.setCredentials(credentials);
95
+ this.headers = headers;
96
+ }
97
+ getCredentials() {
98
+ return this.credentials;
99
+ }
100
+ get(endpoint, params, options) {
101
+ return __awaiter(this, void 0, void 0, function* () {
102
+ if (/\?/.test(endpoint)) {
103
+ // throw new Error('Endpoint cannot contain query string');
104
+ console.warn('Endpoint cannot contain query string', endpoint);
105
+ }
106
+ const queryParams = this.getParams(params);
107
+ const response = yield this.send(`${endpoint}${queryParams ? `?${queryParams}` : ''}`, 'GET', options !== null && options !== void 0 ? options : {});
108
+ return response.json();
109
+ });
110
+ }
111
+ post(endpoint, params, _a = {}) {
112
+ var { headers } = _a, options = __rest(_a, ["headers"]);
113
+ return __awaiter(this, void 0, void 0, function* () {
114
+ const isFormData = checkIfIsFormData(params);
115
+ const response = yield this.send(endpoint, 'POST', Object.assign({ body: isFormData ? buildFormData(params) : JSON.stringify(params), headers: Object.assign(Object.assign({ Accept: 'application/json' }, (!isFormData && { 'Content-Type': 'application/json' })), headers) }, options));
116
+ // If the server sent no data, return an empty record as we're only expecting objects.
117
+ if (response.status === 204) {
118
+ return {};
119
+ }
120
+ return response.json();
121
+ });
122
+ }
123
+ put(endpoint, params, _a = {}) {
124
+ var { headers } = _a, options = __rest(_a, ["headers"]);
125
+ return __awaiter(this, void 0, void 0, function* () {
126
+ const isFormData = checkIfIsFormData(params);
127
+ const response = yield this.send(endpoint, 'PUT', Object.assign({ body: isFormData ? buildFormData(params) : JSON.stringify(params), headers: Object.assign(Object.assign({ Accept: 'application/json' }, (!isFormData && { 'Content-Type': 'application/json' })), headers) }, options));
128
+ return response.json();
129
+ });
130
+ }
131
+ delete(endpoint, _params, options = {}) {
132
+ return __awaiter(this, void 0, void 0, function* () {
133
+ const response = yield this.send(endpoint, 'DELETE', options !== null && options !== void 0 ? options : {});
134
+ return response.json();
135
+ });
136
+ }
137
+ getCredentialsAsHeaders() {
138
+ const credentials = this.getCredentials();
139
+ return credentials
140
+ ? {
141
+ 'X-User-Id': credentials['X-User-Id'],
142
+ 'X-Auth-Token': credentials['X-Auth-Token'],
143
+ }
144
+ : {};
145
+ }
146
+ send(endpoint, method, _a = {}) {
147
+ var { headers } = _a, options = __rest(_a, ["headers"]);
148
+ return fetch(`${this.baseUrl}${`/${endpoint}`.replace(/\/+/, '/')}`, Object.assign(Object.assign({}, options), { headers: Object.assign(Object.assign(Object.assign({}, this.getCredentialsAsHeaders()), this.headers), headers), method })).then((response) => __awaiter(this, void 0, void 0, function* () {
149
+ if (response.ok) {
150
+ return response;
151
+ }
152
+ if (response.status !== 400) {
153
+ return Promise.reject(response);
154
+ }
155
+ const clone = response.clone();
156
+ const error = yield clone.json();
157
+ if (((0, errors_1.isTotpRequiredError)(error) || (0, errors_1.isTotpInvalidError)(error)) && (0, errors_1.hasRequiredTwoFactorMethod)(error) && this.twoFactorHandler) {
158
+ const method2fa = 'details' in error ? error.details.method : 'password';
159
+ const code = yield this.twoFactorHandler({
160
+ method: method2fa,
161
+ emailOrUsername: error.details.emailOrUsername,
162
+ invalidAttempt: (0, errors_1.isTotpInvalidError)(error),
163
+ });
164
+ return this.send(endpoint, method, Object.assign(Object.assign({}, options), { headers: Object.assign(Object.assign(Object.assign(Object.assign({}, this.getCredentialsAsHeaders()), this.headers), headers), { 'x-2fa-code': code, 'x-2fa-method': method2fa }) }));
165
+ }
166
+ return Promise.reject(response);
167
+ }));
168
+ }
169
+ getParams(data) {
170
+ return data ? (0, query_string_1.stringify)(data, { arrayFormat: 'bracket' }) : '';
171
+ }
172
+ use(middleware) {
173
+ const fn = this.send.bind(this);
174
+ this.send = function (...context) {
175
+ return middleware(context, pipe(fn));
176
+ };
177
+ }
178
+ handleTwoFactorChallenge(cb) {
179
+ this.twoFactorHandler = cb;
180
+ }
181
+ }
182
+ exports.RestClient = RestClient;
183
+ //# sourceMapp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S,EAAC,IAAI,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,CAAC;IAwCD,GAAG,CAAC,UAAmD;QACtD,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,UAA4B,GAAG,OAAgD;YAC1F,OAAO,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QACtC,CAAgC,CAAC;IAClC,CAAC;IAED,wBAAwB,CACvB,EAA4H;QAE5H,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAC5B,CAAC;CACD;AA5QD,gCA4QC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rocket.chat/api-client",
3
- "version": "0.1.0-rc.0",
3
+ "version": "0.1.0-rc.2",
4
4
  "devDependencies": {
5
5
  "@swc/core": "^1.3.66",
6
6
  "@swc/jest": "^0.2.26",
@@ -25,8 +25,8 @@
25
25
  "/dist"
26
26
  ],
27
27
  "dependencies": {
28
- "@rocket.chat/core-typings": "^6.3.0-rc.0",
29
- "@rocket.chat/rest-typings": "^6.3.0-rc.0",
28
+ "@rocket.chat/core-typings": "^6.3.0-rc.2",
29
+ "@rocket.chat/rest-typings": "^6.3.0-rc.2",
30
30
  "filter-obj": "^3.0.0",
31
31
  "query-string": "^7.1.3",
32
32
  "split-on-first": "^3.0.0",