@maxzima/wa-communicator 1.0.12 → 1.0.14
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 +16 -6
- package/dist/types/TCommunicator.d.ts +5 -1
- package/package.json +1 -1
- package/src/engine/Communicator/Enums/CommunicatorEnum.ts +1 -0
- package/src/engine/Communicator/Public/Communicator.ts +17 -2
- package/src/types/TCommunicator.ts +9 -1
- package/test/__snapshots__/communicator.spec.ts.snap +13 -0
- package/test/communicator.spec.ts +7 -1
- package/test/testunits/communicator/requests.ts +8 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
declare const enum CommunicatorFAPIEndpointEnum {
|
|
2
2
|
GEO_BY_IP = "geo-by-ip",
|
|
3
3
|
USER = "user",
|
|
4
|
-
REGISTRATION = "clients/registration"
|
|
4
|
+
REGISTRATION = "clients/registration",
|
|
5
|
+
STORAGE = "storage"
|
|
5
6
|
}
|
|
6
7
|
declare const enum CommunicatorAuthAPIEndpointEnum {
|
|
7
8
|
SIGN_IN = "sign-in",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TCreateSessionRequestData, TEmailUpdateRequestData, TGetCurrentUserProfileRequestData, TRegistrationRequestData, TResponse, TSetupChallengeRequestData, TSignInByMobileRequestData, TSignUpByMobileRequestData, TVerifyChallengeRequestData } from "@root/types";
|
|
1
|
+
import { TCreateSessionRequestData, TEmailUpdateRequestData, TGetCurrentUserProfileRequestData, TRegistrationRequestData, TResponse, TSetupChallengeRequestData, TSignInByMobileRequestData, TSignUpByMobileRequestData, TVerifyChallengeRequestData, TStorageRequestData } from "@root/types";
|
|
2
2
|
export declare class Communicator {
|
|
3
3
|
private props;
|
|
4
4
|
constructor(props: TCommunicatorProps);
|
|
@@ -10,6 +10,7 @@ export declare class Communicator {
|
|
|
10
10
|
createSession(data: TCreateSessionRequestData): Promise<TResponse>;
|
|
11
11
|
getCurrentUserProfile(data: TGetCurrentUserProfileRequestData): Promise<TResponse>;
|
|
12
12
|
registration(data: TRegistrationRequestData): Promise<TResponse>;
|
|
13
|
+
setStorageValues(data: TStorageRequestData): Promise<TResponse>;
|
|
13
14
|
private send;
|
|
14
15
|
private getHeaders;
|
|
15
16
|
private getMeta;
|
|
@@ -135,16 +135,12 @@ export class Communicator {
|
|
|
135
135
|
registration(data) {
|
|
136
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
137
|
const headers = this.getHeaders(data.accessToken);
|
|
138
|
-
const body = JSON.stringify({
|
|
139
|
-
name: data.name,
|
|
140
|
-
country_code: data.countryCode,
|
|
141
|
-
source: {
|
|
138
|
+
const body = JSON.stringify(Object.assign(Object.assign({ name: data.name }, (data.countryCode && { country_code: data.countryCode })), { source: {
|
|
142
139
|
hash: data.hash,
|
|
143
140
|
device_type: data.deviceType,
|
|
144
141
|
ga_id: data.gaId,
|
|
145
142
|
origin: data.origin,
|
|
146
|
-
}
|
|
147
|
-
});
|
|
143
|
+
} }));
|
|
148
144
|
return yield this.send({
|
|
149
145
|
method: 'POST',
|
|
150
146
|
url: `${this.props.clientFAPIBaseUrl}${"clients/registration"}`,
|
|
@@ -153,6 +149,20 @@ export class Communicator {
|
|
|
153
149
|
});
|
|
154
150
|
});
|
|
155
151
|
}
|
|
152
|
+
setStorageValues(data) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
const headers = this.getHeaders(data.authToken);
|
|
155
|
+
const body = JSON.stringify({
|
|
156
|
+
seo_source: data.origin,
|
|
157
|
+
});
|
|
158
|
+
return yield this.send({
|
|
159
|
+
method: 'POST',
|
|
160
|
+
url: `${this.props.clientFAPIBaseUrl}${"storage"}`,
|
|
161
|
+
headers,
|
|
162
|
+
body,
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
}
|
|
156
166
|
send(requestInitProps) {
|
|
157
167
|
return __awaiter(this, void 0, void 0, function* () {
|
|
158
168
|
let url = requestInitProps.url;
|
|
@@ -119,4 +119,8 @@ declare type TRegistrationRequestData = {
|
|
|
119
119
|
gaId: TRegistrationRequestBodySource['ga_id'];
|
|
120
120
|
origin: TRegistrationRequestBodySource['origin'];
|
|
121
121
|
};
|
|
122
|
-
|
|
122
|
+
declare type TStorageRequestData = {
|
|
123
|
+
authToken: string;
|
|
124
|
+
origin: string;
|
|
125
|
+
};
|
|
126
|
+
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, };
|
package/package.json
CHANGED
|
@@ -14,7 +14,8 @@ import {
|
|
|
14
14
|
TSignUpByMobileRequestData,
|
|
15
15
|
TSignUpStartRequestBody,
|
|
16
16
|
TVerifyChallengeRequestBody,
|
|
17
|
-
TVerifyChallengeRequestData
|
|
17
|
+
TVerifyChallengeRequestData,
|
|
18
|
+
TStorageRequestData
|
|
18
19
|
} from "@root/types";
|
|
19
20
|
import {CommunicatorDefaultRequestData} from "./../Constants/Communicator";
|
|
20
21
|
|
|
@@ -128,7 +129,7 @@ export class Communicator {
|
|
|
128
129
|
const headers = this.getHeaders(data.accessToken);
|
|
129
130
|
const body = JSON.stringify({
|
|
130
131
|
name: data.name,
|
|
131
|
-
country_code: data.countryCode,
|
|
132
|
+
...(data.countryCode && { country_code: data.countryCode }),
|
|
132
133
|
source: {
|
|
133
134
|
hash: data.hash,
|
|
134
135
|
device_type: data.deviceType,
|
|
@@ -145,6 +146,20 @@ export class Communicator {
|
|
|
145
146
|
});
|
|
146
147
|
}
|
|
147
148
|
|
|
149
|
+
public async setStorageValues(data: TStorageRequestData) {
|
|
150
|
+
const headers = this.getHeaders(data.authToken);
|
|
151
|
+
const body = JSON.stringify({
|
|
152
|
+
seo_source: data.origin,
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
return await this.send({
|
|
156
|
+
method: 'POST',
|
|
157
|
+
url: `${this.props.clientFAPIBaseUrl}${CommunicatorFAPIEndpointEnum.STORAGE}`,
|
|
158
|
+
headers,
|
|
159
|
+
body,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
148
163
|
private async send(requestInitProps: TRequestProps): Promise<TResponse> {
|
|
149
164
|
let url = requestInitProps.url;
|
|
150
165
|
|
|
@@ -168,6 +168,13 @@ type TRegistrationRequestData = {
|
|
|
168
168
|
}
|
|
169
169
|
/* endregion registration */
|
|
170
170
|
|
|
171
|
+
/* region registration */
|
|
172
|
+
type TStorageRequestData = {
|
|
173
|
+
authToken: string,
|
|
174
|
+
origin: string,
|
|
175
|
+
}
|
|
176
|
+
/* endregion registration */
|
|
177
|
+
|
|
171
178
|
export {
|
|
172
179
|
TRegistrationRequestBodySourceDeviceType,
|
|
173
180
|
TChallenge,
|
|
@@ -192,5 +199,6 @@ export {
|
|
|
192
199
|
TCreateSessionResponse,
|
|
193
200
|
TGetCurrentUserProfileResponseUser,
|
|
194
201
|
TGetCurrentUserProfileRequestData,
|
|
195
|
-
TRegistrationRequestData
|
|
202
|
+
TRegistrationRequestData,
|
|
203
|
+
TStorageRequestData,
|
|
196
204
|
};
|
|
@@ -81,6 +81,19 @@ Object {
|
|
|
81
81
|
}
|
|
82
82
|
`;
|
|
83
83
|
|
|
84
|
+
exports[`Communicator requests setStorageValues 1`] = `
|
|
85
|
+
Object {
|
|
86
|
+
"body": "{\\"seo_source\\":\\"_origin_\\"}",
|
|
87
|
+
"headers": Object {
|
|
88
|
+
"Accept": "application/json, text/plain, */*",
|
|
89
|
+
"Authorization": "Bearer _authToken_",
|
|
90
|
+
"Content-Type": "application/json",
|
|
91
|
+
},
|
|
92
|
+
"method": "POST",
|
|
93
|
+
"url": "https://google.com/storage",
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
|
|
84
97
|
exports[`Communicator requests setupChallenge 1`] = `
|
|
85
98
|
Object {
|
|
86
99
|
"headers": Object {
|
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
setupChallengeData,
|
|
13
13
|
signInData,
|
|
14
14
|
signUpData,
|
|
15
|
-
verifyChallengeData
|
|
15
|
+
verifyChallengeData,
|
|
16
|
+
setStorageValuesData,
|
|
16
17
|
} from "./testunits/communicator/requests";
|
|
17
18
|
import {communicatorTestData} from "./testunits/communicator/general";
|
|
18
19
|
|
|
@@ -96,4 +97,9 @@ describe('Communicator requests', () => {
|
|
|
96
97
|
const registrationRequestData = await communicator.registration(registrationData);
|
|
97
98
|
expect(registrationRequestData).toMatchSnapshot();
|
|
98
99
|
});
|
|
100
|
+
|
|
101
|
+
test('setStorageValues', async () => {
|
|
102
|
+
const setStorageValuesRequestData = await communicator.setStorageValues(setStorageValuesData);
|
|
103
|
+
expect(setStorageValuesRequestData).toMatchSnapshot();
|
|
104
|
+
});
|
|
99
105
|
});
|
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
TSetupChallengeRequestData,
|
|
5
5
|
TSignInByMobileRequestData,
|
|
6
6
|
TSignUpByMobileRequestData,
|
|
7
|
-
TVerifyChallengeRequestData
|
|
7
|
+
TVerifyChallengeRequestData,
|
|
8
|
+
TStorageRequestData,
|
|
8
9
|
} from "../../../src/types";
|
|
9
10
|
import {communicatorTestData} from "./general";
|
|
10
11
|
|
|
@@ -53,6 +54,11 @@ const registrationData: TRegistrationRequestData = {
|
|
|
53
54
|
origin: communicatorTestData.origin,
|
|
54
55
|
};
|
|
55
56
|
|
|
57
|
+
const setStorageValuesData: TStorageRequestData = {
|
|
58
|
+
authToken: communicatorTestData.authToken,
|
|
59
|
+
origin: communicatorTestData.origin,
|
|
60
|
+
};
|
|
61
|
+
|
|
56
62
|
export {
|
|
57
63
|
signInData,
|
|
58
64
|
signUpData,
|
|
@@ -62,4 +68,5 @@ export {
|
|
|
62
68
|
createSessionData,
|
|
63
69
|
getCurrentUserProfileData,
|
|
64
70
|
registrationData,
|
|
71
|
+
setStorageValuesData,
|
|
65
72
|
};
|