@maxzima/wa-communicator 1.0.5 → 1.0.7
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/README.md +4 -2
- package/dist/engine/Communicator/Public/Communicator.d.ts +2 -2
- package/dist/engine/Communicator/Public/Communicator.js +10 -7
- package/dist/types/TCommunicator.d.ts +11 -1
- package/package.json +1 -1
- package/src/engine/Communicator/Public/Communicator.ts +16 -7
- package/src/types/TCommunicator.ts +14 -0
package/README.md
CHANGED
|
@@ -87,7 +87,7 @@ communicator.signUp({
|
|
|
87
87
|
.then((response) => callback(response));
|
|
88
88
|
|
|
89
89
|
communicator.registration({
|
|
90
|
-
accessToken: '
|
|
90
|
+
accessToken: 'some_access_token...',
|
|
91
91
|
name: 'companyName',
|
|
92
92
|
hash: 'some_tracking_hash...',
|
|
93
93
|
deviceType: 'mobile',
|
|
@@ -96,7 +96,9 @@ communicator.registration({
|
|
|
96
96
|
})
|
|
97
97
|
.then((response) => callback(response));
|
|
98
98
|
|
|
99
|
-
communicator.getCurrentUserProfile(
|
|
99
|
+
communicator.getCurrentUserProfile({
|
|
100
|
+
accessToken: 'some_access_token...',
|
|
101
|
+
})
|
|
100
102
|
.then((response) => callback(response))
|
|
101
103
|
```
|
|
102
104
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TCreateSessionRequestData, TEmailUpdateRequestData, TRegistrationRequestData, TResponse, TSetupChallengeRequestData, TSignInByMobileRequestData, TSignUpByMobileRequestData, TVerifyChallengeRequestData } from "@root/types";
|
|
1
|
+
import { TCreateSessionRequestData, TEmailUpdateRequestData, TGetCurrentUserProfileRequestData, TRegistrationRequestData, TResponse, TSetupChallengeRequestData, TSignInByMobileRequestData, TSignUpByMobileRequestData, TVerifyChallengeRequestData } from "@root/types";
|
|
2
2
|
export declare class Communicator {
|
|
3
3
|
private props;
|
|
4
4
|
constructor(props: TCommunicatorProps);
|
|
@@ -8,7 +8,7 @@ export declare class Communicator {
|
|
|
8
8
|
verifyChallenge(data: TVerifyChallengeRequestData): Promise<TResponse>;
|
|
9
9
|
emailUpdate(data: TEmailUpdateRequestData): Promise<TResponse>;
|
|
10
10
|
createSession(data: TCreateSessionRequestData): Promise<TResponse>;
|
|
11
|
-
getCurrentUserProfile(): Promise<TResponse>;
|
|
11
|
+
getCurrentUserProfile(data: TGetCurrentUserProfileRequestData): Promise<TResponse>;
|
|
12
12
|
registration(data: TRegistrationRequestData): Promise<TResponse>;
|
|
13
13
|
private send;
|
|
14
14
|
private getMeta;
|
|
@@ -2,15 +2,15 @@ import { __awaiter } from "tslib";
|
|
|
2
2
|
import { CommunicatorDefaultRequestData } from "./../Constants/Communicator";
|
|
3
3
|
export class Communicator {
|
|
4
4
|
constructor(props) {
|
|
5
|
-
this.getMeta = () => {
|
|
5
|
+
this.getMeta = (browserData) => {
|
|
6
6
|
return {
|
|
7
7
|
audit_source_type: CommunicatorDefaultRequestData.AUDIT_SOURCE_TYPE,
|
|
8
|
-
browser_page_resolution: `${
|
|
9
|
-
cookies_enabled:
|
|
8
|
+
browser_page_resolution: `${browserData.innerWidth}x${browserData.innerHeight}`,
|
|
9
|
+
cookies_enabled: browserData.isCookieEnabled,
|
|
10
10
|
ip: CommunicatorDefaultRequestData.IP,
|
|
11
11
|
js_enabled: true,
|
|
12
12
|
language: CommunicatorDefaultRequestData.LANG,
|
|
13
|
-
user_agent:
|
|
13
|
+
user_agent: browserData.userAgent,
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
this.processingQueryParams = (queryParams) => {
|
|
@@ -29,7 +29,10 @@ export class Communicator {
|
|
|
29
29
|
}
|
|
30
30
|
signIn(data) {
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
|
|
32
|
+
if (!data.browserData) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const meta = this.getMeta(data.browserData);
|
|
33
36
|
const body = JSON.stringify({
|
|
34
37
|
captcha_response: '_',
|
|
35
38
|
meta,
|
|
@@ -106,12 +109,12 @@ export class Communicator {
|
|
|
106
109
|
});
|
|
107
110
|
});
|
|
108
111
|
}
|
|
109
|
-
getCurrentUserProfile() {
|
|
112
|
+
getCurrentUserProfile(data) {
|
|
110
113
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
114
|
return yield this.send({
|
|
112
115
|
method: 'GET',
|
|
113
116
|
url: `${this.props.clientFAPIBaseUrl}${"user"}`,
|
|
114
|
-
headers: CommunicatorDefaultRequestData.FETCH_HEADERS_INIT,
|
|
117
|
+
headers: Object.assign({ 'Authorization': `Bearer ${data.accessToken}` }, CommunicatorDefaultRequestData.FETCH_HEADERS_INIT),
|
|
115
118
|
});
|
|
116
119
|
});
|
|
117
120
|
}
|
|
@@ -31,8 +31,15 @@ declare type TAccountMeta = {
|
|
|
31
31
|
language: string;
|
|
32
32
|
user_agent: string;
|
|
33
33
|
};
|
|
34
|
+
declare type TAccountBrowserData = {
|
|
35
|
+
innerWidth: number;
|
|
36
|
+
innerHeight: number;
|
|
37
|
+
isCookieEnabled: boolean;
|
|
38
|
+
userAgent: NavigatorID['userAgent'];
|
|
39
|
+
};
|
|
34
40
|
declare type TSignInByMobileRequestData = {
|
|
35
41
|
phoneNumber: string;
|
|
42
|
+
browserData: TAccountBrowserData;
|
|
36
43
|
};
|
|
37
44
|
declare type TSignInByMobileResponse = {
|
|
38
45
|
auth_token: string;
|
|
@@ -99,6 +106,9 @@ declare type TRegistrationRequestBody = {
|
|
|
99
106
|
name: string;
|
|
100
107
|
source: TRegistrationRequestBodySource;
|
|
101
108
|
};
|
|
109
|
+
declare type TGetCurrentUserProfileRequestData = {
|
|
110
|
+
accessToken: string;
|
|
111
|
+
};
|
|
102
112
|
declare type TRegistrationRequestData = {
|
|
103
113
|
accessToken: string;
|
|
104
114
|
name: TRegistrationRequestBody['name'];
|
|
@@ -107,4 +117,4 @@ declare type TRegistrationRequestData = {
|
|
|
107
117
|
gaId: TRegistrationRequestBodySource['ga_id'];
|
|
108
118
|
origin: TRegistrationRequestBodySource['origin'];
|
|
109
119
|
};
|
|
110
|
-
export { TChallenge, TAuditSource, TRequestProps, TRequestQueryParams, TResponse, TSignInStartRequestBody, TAccountMeta, TSignInByMobileRequestData, TSignInByMobileResponse, TSignUpStartRequestBody, TSignUpByMobileRequestData, TSetupChallengeRequestData, TSetupChallengeResponse, TVerifyChallengeRequestBody, TVerifyChallengeRequestData, TVerifyChallengeResponse, TEmailUpdateRequestData, TCreateSessionRequestData, TCreateSessionResponse, TGetCurrentUserProfileResponseUser, TRegistrationRequestData };
|
|
120
|
+
export { TChallenge, TAuditSource, TRequestProps, TRequestQueryParams, TResponse, TSignInStartRequestBody, TAccountMeta, TAccountBrowserData, TSignInByMobileRequestData, TSignInByMobileResponse, TSignUpStartRequestBody, TSignUpByMobileRequestData, TSetupChallengeRequestData, TSetupChallengeResponse, TVerifyChallengeRequestBody, TVerifyChallengeRequestData, TVerifyChallengeResponse, TEmailUpdateRequestData, TCreateSessionRequestData, TCreateSessionResponse, TGetCurrentUserProfileResponseUser, TGetCurrentUserProfileRequestData, TRegistrationRequestData };
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
TAccountBrowserData,
|
|
2
3
|
TAccountMeta,
|
|
3
4
|
TCreateSessionRequestData,
|
|
4
5
|
TEmailUpdateRequestData,
|
|
6
|
+
TGetCurrentUserProfileRequestData,
|
|
5
7
|
TRegistrationRequestData,
|
|
6
8
|
TRequestProps,
|
|
7
9
|
TRequestQueryParams,
|
|
@@ -24,7 +26,11 @@ export class Communicator {
|
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
public async signIn(data: TSignInByMobileRequestData) {
|
|
27
|
-
|
|
29
|
+
if (!data.browserData) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const meta = this.getMeta(data.browserData);
|
|
28
34
|
const body = JSON.stringify({
|
|
29
35
|
captcha_response: '_',
|
|
30
36
|
meta,
|
|
@@ -112,11 +118,14 @@ export class Communicator {
|
|
|
112
118
|
});
|
|
113
119
|
}
|
|
114
120
|
|
|
115
|
-
public async getCurrentUserProfile() {
|
|
121
|
+
public async getCurrentUserProfile(data: TGetCurrentUserProfileRequestData) {
|
|
116
122
|
return await this.send({
|
|
117
123
|
method: 'GET',
|
|
118
124
|
url: `${this.props.clientFAPIBaseUrl}${CommunicatorFAPIEndpointEnum.USER}`,
|
|
119
|
-
headers:
|
|
125
|
+
headers: {
|
|
126
|
+
'Authorization': `Bearer ${data.accessToken}`,
|
|
127
|
+
...CommunicatorDefaultRequestData.FETCH_HEADERS_INIT,
|
|
128
|
+
},
|
|
120
129
|
});
|
|
121
130
|
}
|
|
122
131
|
|
|
@@ -164,15 +173,15 @@ export class Communicator {
|
|
|
164
173
|
});
|
|
165
174
|
}
|
|
166
175
|
|
|
167
|
-
private getMeta = (): TAccountMeta => {
|
|
176
|
+
private getMeta = (browserData: TAccountBrowserData): TAccountMeta => {
|
|
168
177
|
return {
|
|
169
178
|
audit_source_type: CommunicatorDefaultRequestData.AUDIT_SOURCE_TYPE,
|
|
170
|
-
browser_page_resolution: `${
|
|
171
|
-
cookies_enabled:
|
|
179
|
+
browser_page_resolution: `${browserData.innerWidth}x${browserData.innerHeight}`,
|
|
180
|
+
cookies_enabled: browserData.isCookieEnabled,
|
|
172
181
|
ip: CommunicatorDefaultRequestData.IP,
|
|
173
182
|
js_enabled: true,
|
|
174
183
|
language: CommunicatorDefaultRequestData.LANG,
|
|
175
|
-
user_agent:
|
|
184
|
+
user_agent: browserData.userAgent,
|
|
176
185
|
};
|
|
177
186
|
};
|
|
178
187
|
|
|
@@ -38,8 +38,16 @@ type TAccountMeta = {
|
|
|
38
38
|
user_agent: string
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
type TAccountBrowserData = {
|
|
42
|
+
innerWidth: number,
|
|
43
|
+
innerHeight: number,
|
|
44
|
+
isCookieEnabled: boolean,
|
|
45
|
+
userAgent: NavigatorID['userAgent'],
|
|
46
|
+
}
|
|
47
|
+
|
|
41
48
|
type TSignInByMobileRequestData = {
|
|
42
49
|
phoneNumber: string,
|
|
50
|
+
browserData: TAccountBrowserData,
|
|
43
51
|
}
|
|
44
52
|
|
|
45
53
|
type TSignInByMobileResponse = {
|
|
@@ -144,6 +152,10 @@ type TRegistrationRequestBody = {
|
|
|
144
152
|
source: TRegistrationRequestBodySource,
|
|
145
153
|
}
|
|
146
154
|
|
|
155
|
+
type TGetCurrentUserProfileRequestData = {
|
|
156
|
+
accessToken: string,
|
|
157
|
+
}
|
|
158
|
+
|
|
147
159
|
type TRegistrationRequestData = {
|
|
148
160
|
accessToken: string,
|
|
149
161
|
name: TRegistrationRequestBody['name'],
|
|
@@ -162,6 +174,7 @@ export {
|
|
|
162
174
|
TResponse,
|
|
163
175
|
TSignInStartRequestBody,
|
|
164
176
|
TAccountMeta,
|
|
177
|
+
TAccountBrowserData,
|
|
165
178
|
TSignInByMobileRequestData,
|
|
166
179
|
TSignInByMobileResponse,
|
|
167
180
|
TSignUpStartRequestBody,
|
|
@@ -175,5 +188,6 @@ export {
|
|
|
175
188
|
TCreateSessionRequestData,
|
|
176
189
|
TCreateSessionResponse,
|
|
177
190
|
TGetCurrentUserProfileResponseUser,
|
|
191
|
+
TGetCurrentUserProfileRequestData,
|
|
178
192
|
TRegistrationRequestData
|
|
179
193
|
};
|