@maxzima/wa-communicator 1.0.14 → 1.0.16
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/dist/engine/Communicator/Enums/CommunicatorEnum.d.ts +2 -1
- package/dist/engine/Communicator/Public/Communicator.d.ts +2 -1
- package/dist/engine/Communicator/Public/Communicator.js +7 -1
- package/dist/enums/CommunicatorCountriesTypes.d.ts +10 -0
- package/dist/enums/CommunicatorCountriesTypes.js +11 -0
- package/dist/enums/index.d.ts +1 -0
- package/dist/enums/index.js +1 -0
- package/dist/types/TCommunicator.d.ts +5 -2
- package/package.json +1 -1
- package/src/engine/Communicator/Enums/CommunicatorEnum.ts +1 -0
- package/src/engine/Communicator/Public/Communicator.ts +15 -3
- package/src/enums/CommunicatorCountriesTypes.ts +11 -0
- package/src/enums/index.ts +1 -0
- package/src/types/TCommunicator.ts +8 -1
- package/test/__snapshots__/communicator.spec.ts.snap +15 -1
- package/test/communicator.spec.ts +6 -0
- package/test/testunits/communicator/requests.ts +13 -4
|
@@ -2,7 +2,8 @@ declare const enum CommunicatorFAPIEndpointEnum {
|
|
|
2
2
|
GEO_BY_IP = "geo-by-ip",
|
|
3
3
|
USER = "user",
|
|
4
4
|
REGISTRATION = "clients/registration",
|
|
5
|
-
STORAGE = "storage"
|
|
5
|
+
STORAGE = "storage",
|
|
6
|
+
RESTRICTED_COUNTRIES = "access-control/restricted-countries"
|
|
6
7
|
}
|
|
7
8
|
declare const enum CommunicatorAuthAPIEndpointEnum {
|
|
8
9
|
SIGN_IN = "sign-in",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TCreateSessionRequestData, TEmailUpdateRequestData, TGetCurrentUserProfileRequestData, TRegistrationRequestData, TResponse, TSetupChallengeRequestData, TSignInByMobileRequestData, TSignUpByMobileRequestData, TVerifyChallengeRequestData, TStorageRequestData } from "@root/types";
|
|
1
|
+
import type { TCreateSessionRequestData, TEmailUpdateRequestData, TGetCurrentUserProfileRequestData, TRegistrationRequestData, TResponse, TSetupChallengeRequestData, TSignInByMobileRequestData, TSignUpByMobileRequestData, TVerifyChallengeRequestData, TStorageRequestData, TGetRestrictedCountriesData } from "@root/types";
|
|
2
2
|
export declare class Communicator {
|
|
3
3
|
private props;
|
|
4
4
|
constructor(props: TCommunicatorProps);
|
|
@@ -11,6 +11,7 @@ export declare class Communicator {
|
|
|
11
11
|
getCurrentUserProfile(data: TGetCurrentUserProfileRequestData): Promise<TResponse>;
|
|
12
12
|
registration(data: TRegistrationRequestData): Promise<TResponse>;
|
|
13
13
|
setStorageValues(data: TStorageRequestData): Promise<TResponse>;
|
|
14
|
+
getRestrictedCountries(data?: TGetRestrictedCountriesData): Promise<TResponse>;
|
|
14
15
|
private send;
|
|
15
16
|
private getHeaders;
|
|
16
17
|
private getMeta;
|
|
@@ -151,7 +151,7 @@ export class Communicator {
|
|
|
151
151
|
}
|
|
152
152
|
setStorageValues(data) {
|
|
153
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
-
const headers = this.getHeaders(data.
|
|
154
|
+
const headers = this.getHeaders(data.accessToken);
|
|
155
155
|
const body = JSON.stringify({
|
|
156
156
|
seo_source: data.origin,
|
|
157
157
|
});
|
|
@@ -163,6 +163,12 @@ export class Communicator {
|
|
|
163
163
|
});
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
|
+
getRestrictedCountries(data) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
const headers = this.getHeaders();
|
|
169
|
+
return yield this.send(Object.assign({ method: 'GET', url: `${this.props.clientFAPIBaseUrl}${"access-control/restricted-countries"}`, headers }, ((data === null || data === void 0 ? void 0 : data.entityType) && { queryParams: { entity_type: data.entityType } })));
|
|
170
|
+
});
|
|
171
|
+
}
|
|
166
172
|
send(requestInitProps) {
|
|
167
173
|
return __awaiter(this, void 0, void 0, function* () {
|
|
168
174
|
let url = requestInitProps.url;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare enum CountryTypeEnum {
|
|
2
|
+
COUNTRIES = "countries",
|
|
3
|
+
EMPLOYEE = "employee",
|
|
4
|
+
CARD_USER = "carduser",
|
|
5
|
+
CLIENT_INFORMATION = "client_information",
|
|
6
|
+
CLIENT_PERSON = "client_person",
|
|
7
|
+
CLIENT_COMPANY = "client_company",
|
|
8
|
+
USER = "user",
|
|
9
|
+
GLOBAL = "global"
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var CountryTypeEnum;
|
|
2
|
+
(function (CountryTypeEnum) {
|
|
3
|
+
CountryTypeEnum["COUNTRIES"] = "countries";
|
|
4
|
+
CountryTypeEnum["EMPLOYEE"] = "employee";
|
|
5
|
+
CountryTypeEnum["CARD_USER"] = "carduser";
|
|
6
|
+
CountryTypeEnum["CLIENT_INFORMATION"] = "client_information";
|
|
7
|
+
CountryTypeEnum["CLIENT_PERSON"] = "client_person";
|
|
8
|
+
CountryTypeEnum["CLIENT_COMPANY"] = "client_company";
|
|
9
|
+
CountryTypeEnum["USER"] = "user";
|
|
10
|
+
CountryTypeEnum["GLOBAL"] = "global";
|
|
11
|
+
})(CountryTypeEnum || (CountryTypeEnum = {}));
|
package/dist/enums/index.d.ts
CHANGED
package/dist/enums/index.js
CHANGED
|
@@ -120,7 +120,10 @@ declare type TRegistrationRequestData = {
|
|
|
120
120
|
origin: TRegistrationRequestBodySource['origin'];
|
|
121
121
|
};
|
|
122
122
|
declare type TStorageRequestData = {
|
|
123
|
-
|
|
123
|
+
accessToken: string;
|
|
124
124
|
origin: string;
|
|
125
125
|
};
|
|
126
|
-
|
|
126
|
+
declare type TGetRestrictedCountriesData = {
|
|
127
|
+
entityType?: import('@root/enums').CountryTypeEnum;
|
|
128
|
+
};
|
|
129
|
+
export { TRegistrationRequestBodySourceDeviceType, TChallenge, TAuditSource, TRequestProps, TRequestQueryParams, TResponse, TSignInStartRequestBody, TAccountMeta, TAccountBrowserData, TSignInByMobileRequestData, TSignInByMobileResponse, TSignUpStartRequestBody, TSignUpByMobileRequestData, TSetupChallengeRequestData, TSetupChallengeResponse, TVerifyChallengeRequestBody, TVerifyChallengeRequestData, TVerifyChallengeResponse, TEmailUpdateRequestData, TCreateSessionRequestData, TCreateSessionResponse, TGetCurrentUserProfileResponseUser, TGetCurrentUserProfileRequestData, TRegistrationRequestData, TStorageRequestData, TGetRestrictedCountriesData, };
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
TAccountBrowserData,
|
|
3
3
|
TAccountMeta,
|
|
4
4
|
TCreateSessionRequestData,
|
|
@@ -15,7 +15,8 @@ import {
|
|
|
15
15
|
TSignUpStartRequestBody,
|
|
16
16
|
TVerifyChallengeRequestBody,
|
|
17
17
|
TVerifyChallengeRequestData,
|
|
18
|
-
TStorageRequestData
|
|
18
|
+
TStorageRequestData,
|
|
19
|
+
TGetRestrictedCountriesData
|
|
19
20
|
} from "@root/types";
|
|
20
21
|
import {CommunicatorDefaultRequestData} from "./../Constants/Communicator";
|
|
21
22
|
|
|
@@ -147,7 +148,7 @@ export class Communicator {
|
|
|
147
148
|
}
|
|
148
149
|
|
|
149
150
|
public async setStorageValues(data: TStorageRequestData) {
|
|
150
|
-
const headers = this.getHeaders(data.
|
|
151
|
+
const headers = this.getHeaders(data.accessToken);
|
|
151
152
|
const body = JSON.stringify({
|
|
152
153
|
seo_source: data.origin,
|
|
153
154
|
});
|
|
@@ -160,6 +161,17 @@ export class Communicator {
|
|
|
160
161
|
});
|
|
161
162
|
}
|
|
162
163
|
|
|
164
|
+
public async getRestrictedCountries(data?: TGetRestrictedCountriesData) {
|
|
165
|
+
const headers = this.getHeaders();
|
|
166
|
+
|
|
167
|
+
return await this.send({
|
|
168
|
+
method: 'GET',
|
|
169
|
+
url: `${this.props.clientFAPIBaseUrl}${CommunicatorFAPIEndpointEnum.RESTRICTED_COUNTRIES}`,
|
|
170
|
+
headers,
|
|
171
|
+
...(data?.entityType && {queryParams: {entity_type: data.entityType}}),
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
163
175
|
private async send(requestInitProps: TRequestProps): Promise<TResponse> {
|
|
164
176
|
let url = requestInitProps.url;
|
|
165
177
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* Categories can change during some times, check FAPI for validating this list. */
|
|
2
|
+
export enum CountryTypeEnum {
|
|
3
|
+
COUNTRIES = 'countries',
|
|
4
|
+
EMPLOYEE = 'employee',
|
|
5
|
+
CARD_USER = 'carduser',
|
|
6
|
+
CLIENT_INFORMATION = 'client_information',
|
|
7
|
+
CLIENT_PERSON = 'client_person',
|
|
8
|
+
CLIENT_COMPANY = 'client_company',
|
|
9
|
+
USER = 'user',
|
|
10
|
+
GLOBAL = 'global',
|
|
11
|
+
}
|
package/src/enums/index.ts
CHANGED
|
@@ -170,11 +170,17 @@ type TRegistrationRequestData = {
|
|
|
170
170
|
|
|
171
171
|
/* region registration */
|
|
172
172
|
type TStorageRequestData = {
|
|
173
|
-
|
|
173
|
+
accessToken: string,
|
|
174
174
|
origin: string,
|
|
175
175
|
}
|
|
176
176
|
/* endregion registration */
|
|
177
177
|
|
|
178
|
+
/* region getRestrictedCountries */
|
|
179
|
+
type TGetRestrictedCountriesData = {
|
|
180
|
+
entityType?: import('@root/enums').CountryTypeEnum;
|
|
181
|
+
}
|
|
182
|
+
/* endregion getRestrictedCountries */
|
|
183
|
+
|
|
178
184
|
export {
|
|
179
185
|
TRegistrationRequestBodySourceDeviceType,
|
|
180
186
|
TChallenge,
|
|
@@ -201,4 +207,5 @@ export {
|
|
|
201
207
|
TGetCurrentUserProfileRequestData,
|
|
202
208
|
TRegistrationRequestData,
|
|
203
209
|
TStorageRequestData,
|
|
210
|
+
TGetRestrictedCountriesData,
|
|
204
211
|
};
|
|
@@ -68,6 +68,20 @@ Object {
|
|
|
68
68
|
}
|
|
69
69
|
`;
|
|
70
70
|
|
|
71
|
+
exports[`Communicator requests getRestrictedCountries 1`] = `
|
|
72
|
+
Object {
|
|
73
|
+
"headers": Object {
|
|
74
|
+
"Accept": "application/json, text/plain, */*",
|
|
75
|
+
"Content-Type": "application/json",
|
|
76
|
+
},
|
|
77
|
+
"method": "GET",
|
|
78
|
+
"queryParams": Object {
|
|
79
|
+
"entity_type": "global",
|
|
80
|
+
},
|
|
81
|
+
"url": "https://google.com/access-control/restricted-countries",
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
|
|
71
85
|
exports[`Communicator requests registration 1`] = `
|
|
72
86
|
Object {
|
|
73
87
|
"body": "{\\"name\\":\\"_companyName_\\",\\"country_code\\":\\"CAN\\",\\"source\\":{\\"hash\\":\\"_hash_\\",\\"device_type\\":\\"mobile\\",\\"ga_id\\":\\"_gaId_\\",\\"origin\\":\\"_origin_\\"}}",
|
|
@@ -86,7 +100,7 @@ Object {
|
|
|
86
100
|
"body": "{\\"seo_source\\":\\"_origin_\\"}",
|
|
87
101
|
"headers": Object {
|
|
88
102
|
"Accept": "application/json, text/plain, */*",
|
|
89
|
-
"Authorization": "Bearer
|
|
103
|
+
"Authorization": "Bearer _accessToken_",
|
|
90
104
|
"Content-Type": "application/json",
|
|
91
105
|
},
|
|
92
106
|
"method": "POST",
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
signUpData,
|
|
15
15
|
verifyChallengeData,
|
|
16
16
|
setStorageValuesData,
|
|
17
|
+
getRestrictedCountriesData,
|
|
17
18
|
} from "./testunits/communicator/requests";
|
|
18
19
|
import {communicatorTestData} from "./testunits/communicator/general";
|
|
19
20
|
|
|
@@ -102,4 +103,9 @@ describe('Communicator requests', () => {
|
|
|
102
103
|
const setStorageValuesRequestData = await communicator.setStorageValues(setStorageValuesData);
|
|
103
104
|
expect(setStorageValuesRequestData).toMatchSnapshot();
|
|
104
105
|
});
|
|
106
|
+
|
|
107
|
+
test('getRestrictedCountries', async () => {
|
|
108
|
+
const getRestrictedCountriesRequestData = await communicator.getRestrictedCountries(getRestrictedCountriesData);
|
|
109
|
+
expect(getRestrictedCountriesRequestData).toMatchSnapshot();
|
|
110
|
+
});
|
|
105
111
|
});
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
TCreateSessionRequestData,
|
|
3
|
-
TEmailUpdateRequestData,
|
|
3
|
+
TEmailUpdateRequestData,
|
|
4
|
+
TGetCurrentUserProfileRequestData,
|
|
5
|
+
TGetRestrictedCountriesData,
|
|
6
|
+
TRegistrationRequestData,
|
|
4
7
|
TSetupChallengeRequestData,
|
|
5
8
|
TSignInByMobileRequestData,
|
|
6
9
|
TSignUpByMobileRequestData,
|
|
7
|
-
TVerifyChallengeRequestData,
|
|
8
10
|
TStorageRequestData,
|
|
11
|
+
TVerifyChallengeRequestData,
|
|
9
12
|
} from "../../../src/types";
|
|
10
13
|
import {communicatorTestData} from "./general";
|
|
14
|
+
import {CountryTypeEnum} from "../../../src/enums";
|
|
11
15
|
|
|
12
16
|
const signInData: TSignInByMobileRequestData = {
|
|
13
17
|
phoneNumber: communicatorTestData.phoneNumber,
|
|
@@ -55,10 +59,14 @@ const registrationData: TRegistrationRequestData = {
|
|
|
55
59
|
};
|
|
56
60
|
|
|
57
61
|
const setStorageValuesData: TStorageRequestData = {
|
|
58
|
-
|
|
62
|
+
accessToken: communicatorTestData.accessToken,
|
|
59
63
|
origin: communicatorTestData.origin,
|
|
60
64
|
};
|
|
61
65
|
|
|
66
|
+
const getRestrictedCountriesData: TGetRestrictedCountriesData = {
|
|
67
|
+
entityType: CountryTypeEnum.GLOBAL
|
|
68
|
+
};
|
|
69
|
+
|
|
62
70
|
export {
|
|
63
71
|
signInData,
|
|
64
72
|
signUpData,
|
|
@@ -69,4 +77,5 @@ export {
|
|
|
69
77
|
getCurrentUserProfileData,
|
|
70
78
|
registrationData,
|
|
71
79
|
setStorageValuesData,
|
|
80
|
+
getRestrictedCountriesData,
|
|
72
81
|
};
|