@maxzima/wa-communicator 1.0.39 → 1.0.41
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/AccountTracker/Enums/AccountTrackerEnum.d.ts +4 -4
- package/dist/engine/AccountTracker/Enums/AccountTrackerEnum.js +22 -1
- package/dist/engine/AccountTracker/Public/AccountTracker.d.ts +1 -0
- package/dist/engine/AccountTracker/Public/AccountTracker.js +5 -4
- package/dist/engine/AccountTracker/Types/TAccountTracker.d.ts +8 -7
- package/dist/engine/AccountTracker/Types/TAccountTracker.js +1 -1
- package/dist/engine/Communicator/Enums/CommunicatorEnum.d.ts +2 -2
- package/dist/engine/Communicator/Enums/CommunicatorEnum.js +19 -1
- package/dist/engine/Communicator/Public/Communicator.d.ts +1 -1
- package/dist/engine/Communicator/Public/Communicator.js +15 -14
- package/dist/engine/Communicator/Types/TCommunicator.d.ts +2 -2
- package/dist/enums/CommunicatorErrorEnum.d.ts +3 -3
- package/dist/enums/CommunicatorErrorEnum.js +18 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -0
- package/dist/types/TCommunicator.d.ts +40 -40
- package/package.json +2 -2
- package/src/engine/AccountTracker/Enums/AccountTrackerEnum.ts +4 -4
- package/src/engine/AccountTracker/Public/AccountTracker.ts +7 -0
- package/src/engine/AccountTracker/Types/TAccountTracker.ts +13 -7
- package/src/engine/Communicator/Enums/CommunicatorEnum.ts +2 -2
- package/src/engine/Communicator/Public/Communicator.ts +5 -1
- package/src/enums/CommunicatorErrorEnum.ts +3 -3
- package/src/index.ts +7 -7
- package/src/types/TCommunicator.ts +1 -1
- package/tsconfig.json +1 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
declare
|
|
1
|
+
export declare enum GTMEventEnum {
|
|
2
2
|
SIGN_UP = "sign_up",
|
|
3
3
|
SIGN_UP_ONLINE = "sign_up_online"
|
|
4
4
|
}
|
|
5
|
-
declare
|
|
5
|
+
export declare enum GTMEventParamsEnum {
|
|
6
6
|
GCLID = "gclid",
|
|
7
7
|
PHONE = "phone",
|
|
8
8
|
EMAIL = "email",
|
|
@@ -10,9 +10,9 @@ declare const enum GTMEventParamsEnum {
|
|
|
10
10
|
SEND_TO = "send_to",
|
|
11
11
|
GCL_ID = "gcl_id"
|
|
12
12
|
}
|
|
13
|
-
declare
|
|
13
|
+
export declare enum LintrkActionTypeEnum {
|
|
14
14
|
TRACK = "track"
|
|
15
15
|
}
|
|
16
|
-
declare
|
|
16
|
+
export declare enum LintrkEventIdEnum {
|
|
17
17
|
REGISTRATION = 8612308
|
|
18
18
|
}
|
|
@@ -1 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
export var GTMEventEnum;
|
|
2
|
+
(function (GTMEventEnum) {
|
|
3
|
+
GTMEventEnum["SIGN_UP"] = "sign_up";
|
|
4
|
+
GTMEventEnum["SIGN_UP_ONLINE"] = "sign_up_online";
|
|
5
|
+
})(GTMEventEnum || (GTMEventEnum = {}));
|
|
6
|
+
export var GTMEventParamsEnum;
|
|
7
|
+
(function (GTMEventParamsEnum) {
|
|
8
|
+
GTMEventParamsEnum["GCLID"] = "gclid";
|
|
9
|
+
GTMEventParamsEnum["PHONE"] = "phone";
|
|
10
|
+
GTMEventParamsEnum["EMAIL"] = "email";
|
|
11
|
+
GTMEventParamsEnum["ORIGIN"] = "origin";
|
|
12
|
+
GTMEventParamsEnum["SEND_TO"] = "send_to";
|
|
13
|
+
GTMEventParamsEnum["GCL_ID"] = "gcl_id";
|
|
14
|
+
})(GTMEventParamsEnum || (GTMEventParamsEnum = {}));
|
|
15
|
+
export var LintrkActionTypeEnum;
|
|
16
|
+
(function (LintrkActionTypeEnum) {
|
|
17
|
+
LintrkActionTypeEnum["TRACK"] = "track";
|
|
18
|
+
})(LintrkActionTypeEnum || (LintrkActionTypeEnum = {}));
|
|
19
|
+
export var LintrkEventIdEnum;
|
|
20
|
+
(function (LintrkEventIdEnum) {
|
|
21
|
+
LintrkEventIdEnum[LintrkEventIdEnum["REGISTRATION"] = 8612308] = "REGISTRATION";
|
|
22
|
+
})(LintrkEventIdEnum || (LintrkEventIdEnum = {}));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GTMEventEnum, LintrkActionTypeEnum, LintrkEventIdEnum } from "./../Enums/AccountTrackerEnum";
|
|
1
2
|
export class AccountTracker {
|
|
2
3
|
constructor(props) {
|
|
3
4
|
this.sendGtmEvent = (event, eventParams) => {
|
|
@@ -15,15 +16,15 @@ export class AccountTracker {
|
|
|
15
16
|
if (typeof this.props.lintrk === 'undefined') {
|
|
16
17
|
return;
|
|
17
18
|
}
|
|
18
|
-
this.props.lintrk(
|
|
19
|
+
this.props.lintrk(LintrkActionTypeEnum.TRACK, {
|
|
19
20
|
conversation_id: id,
|
|
20
21
|
});
|
|
21
22
|
};
|
|
22
23
|
this.props = props;
|
|
23
24
|
}
|
|
24
25
|
sendRegistrationSuccessEvent(eventParams) {
|
|
25
|
-
this.sendGtmEvent(
|
|
26
|
-
this.sendGtmEvent(
|
|
27
|
-
this.sendLinkedInEvent(
|
|
26
|
+
this.sendGtmEvent(GTMEventEnum.SIGN_UP, eventParams.gtm);
|
|
27
|
+
this.sendGtmEvent(GTMEventEnum.SIGN_UP_ONLINE, eventParams.gtm);
|
|
28
|
+
this.sendLinkedInEvent(LintrkEventIdEnum.REGISTRATION);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
import { GTMEventEnum, GTMEventParamsEnum, LintrkActionTypeEnum, LintrkEventIdEnum } from "./../Enums/AccountTrackerEnum";
|
|
2
|
+
export type TLintrkOptions = {
|
|
2
3
|
conversation_id: LintrkEventIdEnum;
|
|
3
4
|
};
|
|
4
|
-
|
|
5
|
+
export type TAccountTrackerProps = {
|
|
5
6
|
gtmDataLayer?: object[];
|
|
6
7
|
lintrk?: (action: LintrkActionTypeEnum, options: TLintrkOptions) => void;
|
|
7
8
|
};
|
|
8
|
-
|
|
9
|
+
export type TAccountTrackerEventParams = {
|
|
9
10
|
'gtm'?: TAccountTrackerGtmEventParamsMapping;
|
|
10
11
|
};
|
|
11
|
-
|
|
12
|
+
export type TAccountTrackerGtmEventParamsMapping = {
|
|
12
13
|
[event in GTMEventEnum]: TAccountTrackerGtmEventParams;
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
export type TAccountTrackerGtmEventParams = TAccountTrackerGtmSignUpEventParams | TAccountTrackerGtmSignUpOnlineEventParams;
|
|
16
|
+
export type TAccountTrackerGtmSignUpEventParams = {
|
|
16
17
|
[GTMEventParamsEnum.GCLID]: string;
|
|
17
18
|
[GTMEventParamsEnum.EMAIL]: string;
|
|
18
19
|
[GTMEventParamsEnum.PHONE]: string;
|
|
19
20
|
};
|
|
20
|
-
|
|
21
|
+
export type TAccountTrackerGtmSignUpOnlineEventParams = {
|
|
21
22
|
[GTMEventParamsEnum.ORIGIN]: string;
|
|
22
23
|
[GTMEventParamsEnum.SEND_TO]: string;
|
|
23
24
|
[GTMEventParamsEnum.GCL_ID]: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import { GTMEventParamsEnum } from "./../Enums/AccountTrackerEnum";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare
|
|
1
|
+
export declare enum CommunicatorFAPIEndpointEnum {
|
|
2
2
|
GEO_BY_IP = "geo-by-ip",
|
|
3
3
|
USER = "user",
|
|
4
4
|
REGISTRATION = "clients/registration",
|
|
@@ -7,7 +7,7 @@ declare const enum CommunicatorFAPIEndpointEnum {
|
|
|
7
7
|
ASSIGNED_PRODUCTS = "assigned-products",
|
|
8
8
|
PROFILE_ASSIGN = "users/profiles"
|
|
9
9
|
}
|
|
10
|
-
declare
|
|
10
|
+
export declare enum CommunicatorAuthAPIEndpointEnum {
|
|
11
11
|
SIGN_IN = "sign-in",
|
|
12
12
|
CHALLENGE = "sign-in/challenge",
|
|
13
13
|
EMAIL = "sign-in/email",
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
export var CommunicatorFAPIEndpointEnum;
|
|
2
|
+
(function (CommunicatorFAPIEndpointEnum) {
|
|
3
|
+
CommunicatorFAPIEndpointEnum["GEO_BY_IP"] = "geo-by-ip";
|
|
4
|
+
CommunicatorFAPIEndpointEnum["USER"] = "user";
|
|
5
|
+
CommunicatorFAPIEndpointEnum["REGISTRATION"] = "clients/registration";
|
|
6
|
+
CommunicatorFAPIEndpointEnum["STORAGE"] = "storage";
|
|
7
|
+
CommunicatorFAPIEndpointEnum["RESTRICTED_COUNTRIES"] = "access-control/restricted-countries";
|
|
8
|
+
CommunicatorFAPIEndpointEnum["ASSIGNED_PRODUCTS"] = "assigned-products";
|
|
9
|
+
CommunicatorFAPIEndpointEnum["PROFILE_ASSIGN"] = "users/profiles";
|
|
10
|
+
})(CommunicatorFAPIEndpointEnum || (CommunicatorFAPIEndpointEnum = {}));
|
|
11
|
+
export var CommunicatorAuthAPIEndpointEnum;
|
|
12
|
+
(function (CommunicatorAuthAPIEndpointEnum) {
|
|
13
|
+
CommunicatorAuthAPIEndpointEnum["SIGN_IN"] = "sign-in";
|
|
14
|
+
CommunicatorAuthAPIEndpointEnum["CHALLENGE"] = "sign-in/challenge";
|
|
15
|
+
CommunicatorAuthAPIEndpointEnum["EMAIL"] = "sign-in/email";
|
|
16
|
+
CommunicatorAuthAPIEndpointEnum["SSE_AUTH"] = "sse/app-auth";
|
|
17
|
+
CommunicatorAuthAPIEndpointEnum["SIGN_UP"] = "sign-up";
|
|
18
|
+
CommunicatorAuthAPIEndpointEnum["SESSION"] = "sign-in/session";
|
|
19
|
+
})(CommunicatorAuthAPIEndpointEnum || (CommunicatorAuthAPIEndpointEnum = {}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TCreateSessionRequestData, TEmailUpdateRequestData, TGetCurrentUserProfileRequestData, TRegistrationRequestData, TResponse, TSetupChallengeRequestData, TSignInByMobileRequestData, TSignUpByMobileRequestData, TVerifyChallengeRequestData, TStorageRequestData, TGetRestrictedCountriesData, TSetupSSERequestData, TSignInByAppRequestData, TGetAssignedProductsRequestData, TProfileAssignRequestData } from "@root/types";
|
|
1
|
+
import type { TCreateSessionRequestData, TEmailUpdateRequestData, TGetCurrentUserProfileRequestData, TRegistrationRequestData, TResponse, TSetupChallengeRequestData, TSignInByMobileRequestData, TSignUpByMobileRequestData, TVerifyChallengeRequestData, TStorageRequestData, TGetRestrictedCountriesData, TSetupSSERequestData, TSignInByAppRequestData, TGetAssignedProductsRequestData, TProfileAssignRequestData } from "@root/types";
|
|
2
2
|
export declare class Communicator {
|
|
3
3
|
private props;
|
|
4
4
|
private sseAuth;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { CommunicatorDefaultRequestData } from "./../Constants/Communicator";
|
|
3
3
|
import { jsonParse } from "./../Utils/jsonParseSafe";
|
|
4
|
+
import { CommunicatorAuthAPIEndpointEnum, CommunicatorFAPIEndpointEnum } from "./../Enums/CommunicatorEnum";
|
|
4
5
|
export class Communicator {
|
|
5
6
|
constructor(props) {
|
|
6
7
|
this.getHeaders = (token) => {
|
|
@@ -53,7 +54,7 @@ export class Communicator {
|
|
|
53
54
|
}
|
|
54
55
|
return yield this.send({
|
|
55
56
|
method: 'POST',
|
|
56
|
-
url: `${this.props.clientAuthApiBaseUrl}${
|
|
57
|
+
url: `${this.props.clientAuthApiBaseUrl}${CommunicatorAuthAPIEndpointEnum.SIGN_IN}`,
|
|
57
58
|
body,
|
|
58
59
|
headers,
|
|
59
60
|
queryParams,
|
|
@@ -70,7 +71,7 @@ export class Communicator {
|
|
|
70
71
|
});
|
|
71
72
|
return yield this.send({
|
|
72
73
|
method: 'POST',
|
|
73
|
-
url: `${this.props.clientAuthApiBaseUrl}${
|
|
74
|
+
url: `${this.props.clientAuthApiBaseUrl}${CommunicatorAuthAPIEndpointEnum.CHALLENGE}`,
|
|
74
75
|
headers,
|
|
75
76
|
body,
|
|
76
77
|
});
|
|
@@ -86,7 +87,7 @@ export class Communicator {
|
|
|
86
87
|
});
|
|
87
88
|
return yield this.send({
|
|
88
89
|
method: 'POST',
|
|
89
|
-
url: `${this.props.clientAuthApiBaseUrl}${
|
|
90
|
+
url: `${this.props.clientAuthApiBaseUrl}${CommunicatorAuthAPIEndpointEnum.SIGN_UP}`,
|
|
90
91
|
body,
|
|
91
92
|
headers,
|
|
92
93
|
});
|
|
@@ -97,7 +98,7 @@ export class Communicator {
|
|
|
97
98
|
const headers = this.getHeaders(data.authToken);
|
|
98
99
|
return yield this.send({
|
|
99
100
|
method: 'GET',
|
|
100
|
-
url: `${this.props.clientAuthApiBaseUrl}${
|
|
101
|
+
url: `${this.props.clientAuthApiBaseUrl}${CommunicatorAuthAPIEndpointEnum.CHALLENGE}`,
|
|
101
102
|
headers,
|
|
102
103
|
queryParams: {
|
|
103
104
|
type: data.type,
|
|
@@ -113,7 +114,7 @@ export class Communicator {
|
|
|
113
114
|
request_id: data.requestId,
|
|
114
115
|
mobile: data.phoneNumber,
|
|
115
116
|
};
|
|
116
|
-
const url = `${this.props.clientAuthSSEBaseUrl}${
|
|
117
|
+
const url = `${this.props.clientAuthSSEBaseUrl}${CommunicatorAuthAPIEndpointEnum.SSE_AUTH}`;
|
|
117
118
|
this.sseAuth = new EventSource(new URL(`${url}?${this.processingQueryParams(params)}`));
|
|
118
119
|
if (this.sseAuth) {
|
|
119
120
|
this.sseAuth.addEventListener('open', (event) => {
|
|
@@ -160,7 +161,7 @@ export class Communicator {
|
|
|
160
161
|
});
|
|
161
162
|
return yield this.send({
|
|
162
163
|
method: 'POST',
|
|
163
|
-
url: `${this.props.clientAuthApiBaseUrl}${
|
|
164
|
+
url: `${this.props.clientAuthApiBaseUrl}${CommunicatorAuthAPIEndpointEnum.CHALLENGE}`,
|
|
164
165
|
headers,
|
|
165
166
|
body,
|
|
166
167
|
});
|
|
@@ -174,7 +175,7 @@ export class Communicator {
|
|
|
174
175
|
});
|
|
175
176
|
return yield this.send({
|
|
176
177
|
method: 'PATCH',
|
|
177
|
-
url: `${this.props.clientAuthApiBaseUrl}${
|
|
178
|
+
url: `${this.props.clientAuthApiBaseUrl}${CommunicatorAuthAPIEndpointEnum.EMAIL}`,
|
|
178
179
|
headers,
|
|
179
180
|
body,
|
|
180
181
|
});
|
|
@@ -185,7 +186,7 @@ export class Communicator {
|
|
|
185
186
|
const headers = this.getHeaders(data.authToken);
|
|
186
187
|
return yield this.send({
|
|
187
188
|
method: 'POST',
|
|
188
|
-
url: `${this.props.clientAuthApiBaseUrl}${
|
|
189
|
+
url: `${this.props.clientAuthApiBaseUrl}${CommunicatorAuthAPIEndpointEnum.SESSION}`,
|
|
189
190
|
headers,
|
|
190
191
|
});
|
|
191
192
|
});
|
|
@@ -195,7 +196,7 @@ export class Communicator {
|
|
|
195
196
|
const headers = this.getHeaders(data.accessToken);
|
|
196
197
|
return yield this.send({
|
|
197
198
|
method: 'GET',
|
|
198
|
-
url: `${this.props.clientFAPIBaseUrl}${
|
|
199
|
+
url: `${this.props.clientFAPIBaseUrl}${CommunicatorFAPIEndpointEnum.USER}`,
|
|
199
200
|
headers,
|
|
200
201
|
});
|
|
201
202
|
});
|
|
@@ -216,7 +217,7 @@ export class Communicator {
|
|
|
216
217
|
} }));
|
|
217
218
|
return yield this.send({
|
|
218
219
|
method: 'POST',
|
|
219
|
-
url: `${this.props.clientFAPIBaseUrl}${
|
|
220
|
+
url: `${this.props.clientFAPIBaseUrl}${CommunicatorFAPIEndpointEnum.REGISTRATION}`,
|
|
220
221
|
headers,
|
|
221
222
|
body,
|
|
222
223
|
});
|
|
@@ -230,7 +231,7 @@ export class Communicator {
|
|
|
230
231
|
});
|
|
231
232
|
return yield this.send({
|
|
232
233
|
method: 'POST',
|
|
233
|
-
url: `${this.props.clientFAPIBaseUrl}${
|
|
234
|
+
url: `${this.props.clientFAPIBaseUrl}${CommunicatorFAPIEndpointEnum.STORAGE}`,
|
|
234
235
|
headers,
|
|
235
236
|
body,
|
|
236
237
|
});
|
|
@@ -239,7 +240,7 @@ export class Communicator {
|
|
|
239
240
|
getRestrictedCountries(data) {
|
|
240
241
|
return __awaiter(this, void 0, void 0, function* () {
|
|
241
242
|
const headers = this.getHeaders();
|
|
242
|
-
return yield this.send(Object.assign({ method: 'GET', url: `${this.props.clientFAPIBaseUrl}${
|
|
243
|
+
return yield this.send(Object.assign({ method: 'GET', url: `${this.props.clientFAPIBaseUrl}${CommunicatorFAPIEndpointEnum.RESTRICTED_COUNTRIES}`, headers }, ((data === null || data === void 0 ? void 0 : data.entityType) && { queryParams: { entity_type: data.entityType } })));
|
|
243
244
|
});
|
|
244
245
|
}
|
|
245
246
|
getAssignedProducts(data) {
|
|
@@ -247,7 +248,7 @@ export class Communicator {
|
|
|
247
248
|
const headers = this.getHeaders(data.accessToken);
|
|
248
249
|
return yield this.send({
|
|
249
250
|
method: 'GET',
|
|
250
|
-
url: `${this.props.clientFAPIBaseUrl}${
|
|
251
|
+
url: `${this.props.clientFAPIBaseUrl}${CommunicatorFAPIEndpointEnum.ASSIGNED_PRODUCTS}`,
|
|
251
252
|
headers,
|
|
252
253
|
});
|
|
253
254
|
});
|
|
@@ -257,7 +258,7 @@ export class Communicator {
|
|
|
257
258
|
const headers = this.getHeaders(data.accessToken);
|
|
258
259
|
return yield this.send({
|
|
259
260
|
method: 'POST',
|
|
260
|
-
url: `${this.props.clientFAPIBaseUrl}${
|
|
261
|
+
url: `${this.props.clientFAPIBaseUrl}${CommunicatorFAPIEndpointEnum.PROFILE_ASSIGN}/${data.profileId}/assign`,
|
|
261
262
|
headers,
|
|
262
263
|
});
|
|
263
264
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
type TDefaultRequestData = {
|
|
2
2
|
IP: string;
|
|
3
3
|
LANG: string;
|
|
4
4
|
FETCH_HEADERS_INIT: HeadersInit;
|
|
5
5
|
AUDIT_SOURCE_TYPE: import('@root/types').TAuditSource;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
type TCommunicatorProps = {
|
|
8
8
|
env?: 'local' | 'dev' | 'prod';
|
|
9
9
|
clientAuthApiBaseUrl: string;
|
|
10
10
|
clientAuthSSEBaseUrl: string;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare enum CommunicatorUpdateChallengeCustomErrorCodeEnum {
|
|
2
2
|
INVALID_AUTH_HEADER = 90793,
|
|
3
3
|
FREQUENT_REQUESTS = 90449,
|
|
4
4
|
REQUESTS_EXCEEDED = 90696,
|
|
5
5
|
MISSING_EMAIL = 90174,
|
|
6
6
|
UNEXPECTED_CHALLENGE_TYPE = 90767
|
|
7
7
|
}
|
|
8
|
-
declare
|
|
8
|
+
declare enum CommunicatorVerifyChallengeCustomErrorCodeEnum {
|
|
9
9
|
SESSION_EXPIRED = 90302
|
|
10
10
|
}
|
|
11
|
-
declare
|
|
11
|
+
declare enum CommunicatorEmailCustomErrorCodeEnum {
|
|
12
12
|
UNKNOWN_ERROR = 91044,
|
|
13
13
|
UNPROCESSABLE_ENTITY = 90768
|
|
14
14
|
}
|
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
var CommunicatorUpdateChallengeCustomErrorCodeEnum;
|
|
2
|
+
(function (CommunicatorUpdateChallengeCustomErrorCodeEnum) {
|
|
3
|
+
CommunicatorUpdateChallengeCustomErrorCodeEnum[CommunicatorUpdateChallengeCustomErrorCodeEnum["INVALID_AUTH_HEADER"] = 90793] = "INVALID_AUTH_HEADER";
|
|
4
|
+
CommunicatorUpdateChallengeCustomErrorCodeEnum[CommunicatorUpdateChallengeCustomErrorCodeEnum["FREQUENT_REQUESTS"] = 90449] = "FREQUENT_REQUESTS";
|
|
5
|
+
CommunicatorUpdateChallengeCustomErrorCodeEnum[CommunicatorUpdateChallengeCustomErrorCodeEnum["REQUESTS_EXCEEDED"] = 90696] = "REQUESTS_EXCEEDED";
|
|
6
|
+
CommunicatorUpdateChallengeCustomErrorCodeEnum[CommunicatorUpdateChallengeCustomErrorCodeEnum["MISSING_EMAIL"] = 90174] = "MISSING_EMAIL";
|
|
7
|
+
CommunicatorUpdateChallengeCustomErrorCodeEnum[CommunicatorUpdateChallengeCustomErrorCodeEnum["UNEXPECTED_CHALLENGE_TYPE"] = 90767] = "UNEXPECTED_CHALLENGE_TYPE";
|
|
8
|
+
})(CommunicatorUpdateChallengeCustomErrorCodeEnum || (CommunicatorUpdateChallengeCustomErrorCodeEnum = {}));
|
|
9
|
+
var CommunicatorVerifyChallengeCustomErrorCodeEnum;
|
|
10
|
+
(function (CommunicatorVerifyChallengeCustomErrorCodeEnum) {
|
|
11
|
+
CommunicatorVerifyChallengeCustomErrorCodeEnum[CommunicatorVerifyChallengeCustomErrorCodeEnum["SESSION_EXPIRED"] = 90302] = "SESSION_EXPIRED";
|
|
12
|
+
})(CommunicatorVerifyChallengeCustomErrorCodeEnum || (CommunicatorVerifyChallengeCustomErrorCodeEnum = {}));
|
|
13
|
+
var CommunicatorEmailCustomErrorCodeEnum;
|
|
14
|
+
(function (CommunicatorEmailCustomErrorCodeEnum) {
|
|
15
|
+
CommunicatorEmailCustomErrorCodeEnum[CommunicatorEmailCustomErrorCodeEnum["UNKNOWN_ERROR"] = 91044] = "UNKNOWN_ERROR";
|
|
16
|
+
CommunicatorEmailCustomErrorCodeEnum[CommunicatorEmailCustomErrorCodeEnum["UNPROCESSABLE_ENTITY"] = 90768] = "UNPROCESSABLE_ENTITY";
|
|
17
|
+
})(CommunicatorEmailCustomErrorCodeEnum || (CommunicatorEmailCustomErrorCodeEnum = {}));
|
|
18
|
+
export { CommunicatorUpdateChallengeCustomErrorCodeEnum, CommunicatorVerifyChallengeCustomErrorCodeEnum, CommunicatorEmailCustomErrorCodeEnum, };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Communicator, AccountTracker } from "./engine";
|
|
2
2
|
export { CommunicatorUpdateChallengeCustomErrorCodeEnum, CommunicatorVerifyChallengeCustomErrorCodeEnum, CommunicatorEmailCustomErrorCodeEnum, } from "./enums";
|
|
3
|
-
export { TChallenge, TResponse, TSignInByMobileResponse, TSetupChallengeResponse, TVerifyChallengeResponse, TCreateSessionResponse, TGetCurrentUserProfileResponseUser, } from "./types";
|
|
3
|
+
export { type TChallenge, type TResponse, type TSignInByMobileResponse, type TSetupChallengeResponse, type TVerifyChallengeResponse, type TCreateSessionResponse, type TGetCurrentUserProfileResponseUser, } from "./types";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
type TChallenge = 'email_otp' | 'mobile_otp' | 'pin' | 'out_of_band';
|
|
2
|
+
type TAuditSource = 'Backend' | 'SelfService';
|
|
3
|
+
type TRegistrationRequestBodySourceDeviceType = 'mobile' | 'regular';
|
|
4
|
+
type TRequestProps = {
|
|
5
5
|
url?: string;
|
|
6
6
|
method?: RequestInit['method'];
|
|
7
7
|
body?: any;
|
|
@@ -9,25 +9,25 @@ declare type TRequestProps = {
|
|
|
9
9
|
mode?: RequestMode;
|
|
10
10
|
queryParams?: TRequestQueryParams;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
type TRequestQueryParams = {
|
|
13
13
|
[key: string]: string;
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
type TResponse = {
|
|
16
16
|
json: any;
|
|
17
17
|
status: number;
|
|
18
18
|
ok: boolean;
|
|
19
19
|
};
|
|
20
|
-
|
|
20
|
+
type TSignInStartRequestBody = {
|
|
21
21
|
device_id: string;
|
|
22
22
|
meta: TAccountMeta;
|
|
23
23
|
mobile?: string;
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
type TSignInAppRequestBody = {
|
|
26
26
|
type: 'out_of_band';
|
|
27
27
|
value: string;
|
|
28
28
|
request_id: string;
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
type TAccountMeta = {
|
|
31
31
|
audit_source_type: TAuditSource;
|
|
32
32
|
browser_page_resolution: string;
|
|
33
33
|
cookies_enabled: boolean;
|
|
@@ -36,54 +36,54 @@ declare type TAccountMeta = {
|
|
|
36
36
|
language: string;
|
|
37
37
|
user_agent: string;
|
|
38
38
|
};
|
|
39
|
-
|
|
39
|
+
type TAccountBrowserData = {
|
|
40
40
|
innerWidth: number;
|
|
41
41
|
innerHeight: number;
|
|
42
42
|
isCookieEnabled: boolean;
|
|
43
43
|
userAgent: NavigatorID['userAgent'];
|
|
44
44
|
};
|
|
45
|
-
|
|
45
|
+
type TSignInByMobileRequestData = {
|
|
46
46
|
phoneNumber: string;
|
|
47
47
|
deviceId: string;
|
|
48
48
|
browserData: TAccountBrowserData;
|
|
49
49
|
outOfBandAllowed?: boolean;
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
type TSignInByAppRequestData = {
|
|
52
52
|
authToken: string;
|
|
53
53
|
type: 'out_of_band';
|
|
54
54
|
value: string;
|
|
55
55
|
requestId: string;
|
|
56
56
|
};
|
|
57
|
-
|
|
57
|
+
type TSignInByMobileResponse = {
|
|
58
58
|
auth_token: string;
|
|
59
59
|
challenges: TChallenge[];
|
|
60
60
|
};
|
|
61
|
-
|
|
61
|
+
type TSignInBySSEResponse = {
|
|
62
62
|
request_id: string;
|
|
63
63
|
mobile: string;
|
|
64
64
|
};
|
|
65
|
-
|
|
65
|
+
type TSignUpStartRequestBody = {
|
|
66
66
|
locale: string;
|
|
67
67
|
mobile: string;
|
|
68
68
|
timezone_name: string;
|
|
69
69
|
};
|
|
70
|
-
|
|
70
|
+
type TSignUpByMobileRequestData = {
|
|
71
71
|
locale: string;
|
|
72
72
|
phoneNumber: string;
|
|
73
73
|
timezoneName: string;
|
|
74
74
|
};
|
|
75
|
-
|
|
75
|
+
type TSetupChallengeRequestData = {
|
|
76
76
|
type: TChallenge;
|
|
77
77
|
authToken: string;
|
|
78
78
|
};
|
|
79
|
-
|
|
79
|
+
type TSetupSSERequestData = {
|
|
80
80
|
requestId: string;
|
|
81
81
|
phoneNumber: string;
|
|
82
82
|
onOpen: () => void;
|
|
83
83
|
onError: () => void;
|
|
84
84
|
onMessage: (responseData: TSSEResponseData) => void;
|
|
85
85
|
};
|
|
86
|
-
|
|
86
|
+
type TSSEResponseData = {
|
|
87
87
|
success: boolean;
|
|
88
88
|
payload: {
|
|
89
89
|
otp?: string;
|
|
@@ -93,44 +93,44 @@ declare type TSSEResponseData = {
|
|
|
93
93
|
message: string;
|
|
94
94
|
};
|
|
95
95
|
};
|
|
96
|
-
|
|
96
|
+
type TSetupChallengeResponse = {
|
|
97
97
|
attempts_left: number;
|
|
98
98
|
masked_email: string;
|
|
99
99
|
masked_mobile: string;
|
|
100
100
|
next_attempt_after: number;
|
|
101
101
|
};
|
|
102
|
-
|
|
102
|
+
type TVerifyChallengeRequestBody = {
|
|
103
103
|
type: TChallenge;
|
|
104
104
|
value: string;
|
|
105
105
|
};
|
|
106
|
-
|
|
106
|
+
type TVerifyChallengeRequestData = {
|
|
107
107
|
authToken: string;
|
|
108
108
|
type: TChallenge;
|
|
109
109
|
code: string;
|
|
110
110
|
};
|
|
111
|
-
|
|
111
|
+
type TVerifyChallengeResponse = {
|
|
112
112
|
auth_token: string;
|
|
113
113
|
challenges: TChallenge[];
|
|
114
114
|
};
|
|
115
|
-
|
|
115
|
+
type TEmailUpdateRequestData = {
|
|
116
116
|
authToken: string;
|
|
117
117
|
email: string;
|
|
118
118
|
};
|
|
119
|
-
|
|
119
|
+
type TCreateSessionRequestData = {
|
|
120
120
|
authToken: string;
|
|
121
121
|
};
|
|
122
|
-
|
|
122
|
+
type TCreateSessionResponse = {
|
|
123
123
|
access_token: string;
|
|
124
124
|
refresh_token: string;
|
|
125
125
|
};
|
|
126
|
-
|
|
126
|
+
type TGetCurrentUserProfileResponseUser = {
|
|
127
127
|
profiles: (TGetCurrentUserProfileResponseUserProfiles & Record<string, unknown>)[];
|
|
128
128
|
};
|
|
129
|
-
|
|
129
|
+
type TGetCurrentUserProfileResponseUserProfiles = {
|
|
130
130
|
target_entity_name: string;
|
|
131
131
|
target_entity_id: string;
|
|
132
132
|
};
|
|
133
|
-
|
|
133
|
+
type TRegistrationRequestBodySource = {
|
|
134
134
|
hash: string;
|
|
135
135
|
device_type: TRegistrationRequestBodySourceDeviceType;
|
|
136
136
|
ga_id: string;
|
|
@@ -141,15 +141,15 @@ declare type TRegistrationRequestBodySource = {
|
|
|
141
141
|
utm_campaign: string;
|
|
142
142
|
utm_term: string;
|
|
143
143
|
};
|
|
144
|
-
|
|
144
|
+
type TRegistrationRequestBody = {
|
|
145
145
|
name: string;
|
|
146
146
|
country_code: string;
|
|
147
147
|
source: TRegistrationRequestBodySource;
|
|
148
148
|
};
|
|
149
|
-
|
|
149
|
+
type TGetCurrentUserProfileRequestData = {
|
|
150
150
|
accessToken: string;
|
|
151
151
|
};
|
|
152
|
-
|
|
152
|
+
type TRegistrationRequestData = {
|
|
153
153
|
accessToken: string;
|
|
154
154
|
name: TRegistrationRequestBody['name'];
|
|
155
155
|
countryCode: TRegistrationRequestBody['name'];
|
|
@@ -163,17 +163,17 @@ declare type TRegistrationRequestData = {
|
|
|
163
163
|
utmCampaign: TRegistrationRequestBodySource['utm_campaign'];
|
|
164
164
|
utmTerm: TRegistrationRequestBodySource['utm_term'];
|
|
165
165
|
};
|
|
166
|
-
|
|
166
|
+
type TStorageRequestData = {
|
|
167
167
|
accessToken: string;
|
|
168
168
|
origin: string;
|
|
169
169
|
};
|
|
170
|
-
|
|
170
|
+
type TGetRestrictedCountriesData = {
|
|
171
171
|
entityType?: import('@root/enums').CountryTypeEnum;
|
|
172
172
|
};
|
|
173
|
-
|
|
173
|
+
type TGetAssignedProductsRequestData = {
|
|
174
174
|
accessToken: string;
|
|
175
175
|
};
|
|
176
|
-
|
|
176
|
+
type TAssignedProduct = {
|
|
177
177
|
id: string;
|
|
178
178
|
client_id: string;
|
|
179
179
|
name: string;
|
|
@@ -194,14 +194,14 @@ declare type TAssignedProduct = {
|
|
|
194
194
|
product_additional_info?: any;
|
|
195
195
|
updated_at?: string;
|
|
196
196
|
};
|
|
197
|
-
|
|
197
|
+
type TGetAssignedProductsResponse = {
|
|
198
198
|
products: TAssignedProduct[];
|
|
199
199
|
};
|
|
200
|
-
|
|
200
|
+
type TProfileAssignRequestData = {
|
|
201
201
|
accessToken: string;
|
|
202
202
|
profileId: string;
|
|
203
203
|
};
|
|
204
|
-
|
|
204
|
+
type TProfileAssignResponse = {
|
|
205
205
|
profile_permission_ids: string[];
|
|
206
206
|
};
|
|
207
|
-
export { TRegistrationRequestBodySourceDeviceType, TChallenge, TAuditSource, TRequestProps, TRequestQueryParams, TResponse, TSignInStartRequestBody, TSignInAppRequestBody, TAccountMeta, TAccountBrowserData, TSignInByMobileRequestData, TSignInByAppRequestData, TSignInByMobileResponse, TSignInBySSEResponse, TSignUpStartRequestBody, TSignUpByMobileRequestData, TSetupChallengeRequestData, TSetupSSERequestData, TSSEResponseData, TSetupChallengeResponse, TVerifyChallengeRequestBody, TVerifyChallengeRequestData, TVerifyChallengeResponse, TEmailUpdateRequestData, TCreateSessionRequestData, TCreateSessionResponse, TGetCurrentUserProfileResponseUser, TGetCurrentUserProfileRequestData, TRegistrationRequestData, TStorageRequestData, TGetRestrictedCountriesData, TGetAssignedProductsRequestData, TAssignedProduct, TGetAssignedProductsResponse, TProfileAssignRequestData, TProfileAssignResponse, };
|
|
207
|
+
export type { TRegistrationRequestBodySourceDeviceType, TChallenge, TAuditSource, TRequestProps, TRequestQueryParams, TResponse, TSignInStartRequestBody, TSignInAppRequestBody, TAccountMeta, TAccountBrowserData, TSignInByMobileRequestData, TSignInByAppRequestData, TSignInByMobileResponse, TSignInBySSEResponse, TSignUpStartRequestBody, TSignUpByMobileRequestData, TSetupChallengeRequestData, TSetupSSERequestData, TSSEResponseData, TSetupChallengeResponse, TVerifyChallengeRequestBody, TVerifyChallengeRequestData, TVerifyChallengeResponse, TEmailUpdateRequestData, TCreateSessionRequestData, TCreateSessionResponse, TGetCurrentUserProfileResponseUser, TGetCurrentUserProfileRequestData, TRegistrationRequestData, TStorageRequestData, TGetRestrictedCountriesData, TGetAssignedProductsRequestData, TAssignedProduct, TGetAssignedProductsResponse, TProfileAssignRequestData, TProfileAssignResponse, };
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.41",
|
|
3
3
|
"name": "@maxzima/wa-communicator",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Noname",
|
|
@@ -53,6 +53,6 @@
|
|
|
53
53
|
"prettier": "2.8.8",
|
|
54
54
|
"size-limit": "8.2.4",
|
|
55
55
|
"ts-jest": "28.0.8",
|
|
56
|
-
"typescript": "
|
|
56
|
+
"typescript": "5.8.3"
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
export enum GTMEventEnum {
|
|
2
2
|
SIGN_UP = 'sign_up',
|
|
3
3
|
SIGN_UP_ONLINE = 'sign_up_online',
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export enum GTMEventParamsEnum {
|
|
7
7
|
GCLID = 'gclid',
|
|
8
8
|
PHONE = 'phone',
|
|
9
9
|
EMAIL = 'email',
|
|
@@ -12,10 +12,10 @@ const enum GTMEventParamsEnum {
|
|
|
12
12
|
GCL_ID = 'gcl_id',
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
export enum LintrkActionTypeEnum {
|
|
16
16
|
TRACK= 'track',
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
export enum LintrkEventIdEnum {
|
|
20
20
|
REGISTRATION = 8612308,
|
|
21
21
|
}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import {GTMEventEnum, LintrkActionTypeEnum, LintrkEventIdEnum} from "./../Enums/AccountTrackerEnum";
|
|
2
|
+
import type {
|
|
3
|
+
TAccountTrackerEventParams,
|
|
4
|
+
TAccountTrackerGtmEventParamsMapping,
|
|
5
|
+
TAccountTrackerProps
|
|
6
|
+
} from "./../Types/TAccountTracker";
|
|
7
|
+
|
|
1
8
|
export class AccountTracker {
|
|
2
9
|
private props: TAccountTrackerProps;
|
|
3
10
|
|
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
GTMEventEnum, GTMEventParamsEnum,
|
|
3
|
+
LintrkActionTypeEnum,
|
|
4
|
+
LintrkEventIdEnum
|
|
5
|
+
} from "./../Enums/AccountTrackerEnum";
|
|
6
|
+
|
|
7
|
+
export type TLintrkOptions = {
|
|
2
8
|
conversation_id: LintrkEventIdEnum;
|
|
3
9
|
}
|
|
4
10
|
|
|
5
|
-
type TAccountTrackerProps = {
|
|
11
|
+
export type TAccountTrackerProps = {
|
|
6
12
|
gtmDataLayer?: object[];
|
|
7
13
|
lintrk?: (action: LintrkActionTypeEnum, options: TLintrkOptions) => void;
|
|
8
14
|
}
|
|
9
15
|
|
|
10
|
-
type TAccountTrackerEventParams = {
|
|
16
|
+
export type TAccountTrackerEventParams = {
|
|
11
17
|
'gtm'?: TAccountTrackerGtmEventParamsMapping;
|
|
12
18
|
}
|
|
13
19
|
|
|
14
|
-
type TAccountTrackerGtmEventParamsMapping = {
|
|
20
|
+
export type TAccountTrackerGtmEventParamsMapping = {
|
|
15
21
|
[event in GTMEventEnum]: TAccountTrackerGtmEventParams;
|
|
16
22
|
};
|
|
17
23
|
|
|
18
|
-
type TAccountTrackerGtmEventParams = TAccountTrackerGtmSignUpEventParams | TAccountTrackerGtmSignUpOnlineEventParams;
|
|
24
|
+
export type TAccountTrackerGtmEventParams = TAccountTrackerGtmSignUpEventParams | TAccountTrackerGtmSignUpOnlineEventParams;
|
|
19
25
|
|
|
20
|
-
type TAccountTrackerGtmSignUpEventParams = {
|
|
26
|
+
export type TAccountTrackerGtmSignUpEventParams = {
|
|
21
27
|
[GTMEventParamsEnum.GCLID]: string;
|
|
22
28
|
[GTMEventParamsEnum.EMAIL]: string;
|
|
23
29
|
[GTMEventParamsEnum.PHONE]: string;
|
|
24
30
|
}
|
|
25
31
|
|
|
26
|
-
type TAccountTrackerGtmSignUpOnlineEventParams = {
|
|
32
|
+
export type TAccountTrackerGtmSignUpOnlineEventParams = {
|
|
27
33
|
[GTMEventParamsEnum.ORIGIN]: string;
|
|
28
34
|
[GTMEventParamsEnum.SEND_TO]: string;
|
|
29
35
|
[GTMEventParamsEnum.GCL_ID]: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export enum CommunicatorFAPIEndpointEnum {
|
|
2
2
|
GEO_BY_IP = 'geo-by-ip',
|
|
3
3
|
USER = 'user',
|
|
4
4
|
REGISTRATION = 'clients/registration',
|
|
@@ -8,7 +8,7 @@ const enum CommunicatorFAPIEndpointEnum {
|
|
|
8
8
|
PROFILE_ASSIGN = 'users/profiles',
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
export enum CommunicatorAuthAPIEndpointEnum {
|
|
12
12
|
SIGN_IN = 'sign-in',
|
|
13
13
|
CHALLENGE = 'sign-in/challenge',
|
|
14
14
|
EMAIL = 'sign-in/email',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
TAccountBrowserData,
|
|
3
3
|
TAccountMeta,
|
|
4
4
|
TCreateSessionRequestData,
|
|
@@ -27,6 +27,10 @@ import {
|
|
|
27
27
|
} from "@root/types";
|
|
28
28
|
import {CommunicatorDefaultRequestData} from "./../Constants/Communicator";
|
|
29
29
|
import {jsonParse} from "./../Utils/jsonParseSafe";
|
|
30
|
+
import {
|
|
31
|
+
CommunicatorAuthAPIEndpointEnum,
|
|
32
|
+
CommunicatorFAPIEndpointEnum
|
|
33
|
+
} from "./../Enums/CommunicatorEnum";
|
|
30
34
|
|
|
31
35
|
export class Communicator {
|
|
32
36
|
private props: TCommunicatorProps;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
enum CommunicatorUpdateChallengeCustomErrorCodeEnum {
|
|
2
2
|
INVALID_AUTH_HEADER = 90793,
|
|
3
3
|
FREQUENT_REQUESTS = 90449,
|
|
4
4
|
REQUESTS_EXCEEDED = 90696,
|
|
@@ -6,11 +6,11 @@ const enum CommunicatorUpdateChallengeCustomErrorCodeEnum {
|
|
|
6
6
|
UNEXPECTED_CHALLENGE_TYPE = 90767,
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
enum CommunicatorVerifyChallengeCustomErrorCodeEnum {
|
|
10
10
|
SESSION_EXPIRED = 90302,
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
enum CommunicatorEmailCustomErrorCodeEnum {
|
|
14
14
|
UNKNOWN_ERROR = 91044,
|
|
15
15
|
UNPROCESSABLE_ENTITY = 90768,
|
|
16
16
|
}
|
package/src/index.ts
CHANGED
|
@@ -10,11 +10,11 @@ export {
|
|
|
10
10
|
} from "./enums";
|
|
11
11
|
|
|
12
12
|
export {
|
|
13
|
-
TChallenge,
|
|
14
|
-
TResponse,
|
|
15
|
-
TSignInByMobileResponse,
|
|
16
|
-
TSetupChallengeResponse,
|
|
17
|
-
TVerifyChallengeResponse,
|
|
18
|
-
TCreateSessionResponse,
|
|
19
|
-
TGetCurrentUserProfileResponseUser,
|
|
13
|
+
type TChallenge,
|
|
14
|
+
type TResponse,
|
|
15
|
+
type TSignInByMobileResponse,
|
|
16
|
+
type TSetupChallengeResponse,
|
|
17
|
+
type TVerifyChallengeResponse,
|
|
18
|
+
type TCreateSessionResponse,
|
|
19
|
+
type TGetCurrentUserProfileResponseUser,
|
|
20
20
|
} from "./types";
|