@longvansoftware/storefront-js-client 3.4.6 → 3.4.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.
|
@@ -14,3 +14,6 @@ export declare const ADD_ROLE_USER_MUTATION: import("graphql").DocumentNode;
|
|
|
14
14
|
export declare const CREATE_USER_LOGIN_MUTATION: import("graphql").DocumentNode;
|
|
15
15
|
export declare const SEND_OTP_MUTATION: import("graphql").DocumentNode;
|
|
16
16
|
export declare const VALIDATE_OTP_MUTATION: import("graphql").DocumentNode;
|
|
17
|
+
export declare const CREATE_RESET_KEY: import("graphql").DocumentNode;
|
|
18
|
+
export declare const CHECK_RESET_KEY: import("graphql").DocumentNode;
|
|
19
|
+
export declare const RESET_PASSWORD: import("graphql").DocumentNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VALIDATE_OTP_MUTATION = exports.SEND_OTP_MUTATION = exports.CREATE_USER_LOGIN_MUTATION = exports.ADD_ROLE_USER_MUTATION = exports.CREATE_ORG_MUTATION = exports.CREATE_USER_DETAIL_MUTATION = exports.LINKING_USER_LOGIN_AND_USER_DETAIL_MUTATION = exports.UPDATE_PROFILE_MUTATION = exports.CREATE_PASSWORD_MUTATION = exports.UPDATE_PASSWORD_MUTATION = exports.UPDATE_INFO_MUTATION = exports.RESET_PASSWORD_MUTATION = exports.VERIFY_CODE_MUTATION = exports.SEND_SMS_VERIFY_CODE_MUTATION = exports.REGISTER_MUTATION = exports.LOGIN_MUTATION = void 0;
|
|
3
|
+
exports.RESET_PASSWORD = exports.CHECK_RESET_KEY = exports.CREATE_RESET_KEY = exports.VALIDATE_OTP_MUTATION = exports.SEND_OTP_MUTATION = exports.CREATE_USER_LOGIN_MUTATION = exports.ADD_ROLE_USER_MUTATION = exports.CREATE_ORG_MUTATION = exports.CREATE_USER_DETAIL_MUTATION = exports.LINKING_USER_LOGIN_AND_USER_DETAIL_MUTATION = exports.UPDATE_PROFILE_MUTATION = exports.CREATE_PASSWORD_MUTATION = exports.UPDATE_PASSWORD_MUTATION = exports.UPDATE_INFO_MUTATION = exports.RESET_PASSWORD_MUTATION = exports.VERIFY_CODE_MUTATION = exports.SEND_SMS_VERIFY_CODE_MUTATION = exports.REGISTER_MUTATION = exports.LOGIN_MUTATION = void 0;
|
|
4
4
|
const graphql_tag_1 = require("graphql-tag");
|
|
5
5
|
exports.LOGIN_MUTATION = (0, graphql_tag_1.gql) `
|
|
6
6
|
mutation Login($loginRequest: LoginRequest!) {
|
|
@@ -98,7 +98,11 @@ exports.UPDATE_PASSWORD_MUTATION = `
|
|
|
98
98
|
}
|
|
99
99
|
`;
|
|
100
100
|
exports.CREATE_PASSWORD_MUTATION = (0, graphql_tag_1.gql) `
|
|
101
|
-
mutation CreatePassword(
|
|
101
|
+
mutation CreatePassword(
|
|
102
|
+
$orgId: String!
|
|
103
|
+
$accessToken: String!
|
|
104
|
+
$password: String!
|
|
105
|
+
) {
|
|
102
106
|
updateInfo(orgId: $orgId, accessToken: $accessToken, password: $password) {
|
|
103
107
|
partyId
|
|
104
108
|
fullName
|
|
@@ -218,7 +222,41 @@ exports.SEND_OTP_MUTATION = (0, graphql_tag_1.gql) `
|
|
|
218
222
|
}
|
|
219
223
|
`;
|
|
220
224
|
exports.VALIDATE_OTP_MUTATION = (0, graphql_tag_1.gql) `
|
|
221
|
-
mutation ValidateOTP(
|
|
225
|
+
mutation ValidateOTP(
|
|
226
|
+
$otpCode: String!
|
|
227
|
+
$phone: String!
|
|
228
|
+
$channelType: String
|
|
229
|
+
) {
|
|
222
230
|
validateOTP(otpCode: $otpCode, phone: $phone, channelType: $channelType)
|
|
223
231
|
}
|
|
224
232
|
`;
|
|
233
|
+
exports.CREATE_RESET_KEY = (0, graphql_tag_1.gql) `
|
|
234
|
+
mutation CreateResetKey($userLoginId: String!) {
|
|
235
|
+
createResetKey(userLoginId: $userLoginId)
|
|
236
|
+
}
|
|
237
|
+
`;
|
|
238
|
+
exports.CHECK_RESET_KEY = (0, graphql_tag_1.gql) `
|
|
239
|
+
mutation CheckResetKey($resetKey: String!) {
|
|
240
|
+
checkResetKey(resetKey: $resetKey) {
|
|
241
|
+
userLoginId
|
|
242
|
+
isVerified
|
|
243
|
+
accessToken
|
|
244
|
+
errorMessage
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
`;
|
|
248
|
+
exports.RESET_PASSWORD = (0, graphql_tag_1.gql) `
|
|
249
|
+
mutation ResetPassword(
|
|
250
|
+
$orgId: String!
|
|
251
|
+
$username: String!
|
|
252
|
+
$newPassword: String!
|
|
253
|
+
$accessToken: String!
|
|
254
|
+
) {
|
|
255
|
+
resetPassword(
|
|
256
|
+
orgId: $orgId
|
|
257
|
+
username: $username
|
|
258
|
+
newPassword: $newPassword
|
|
259
|
+
accessToken: $accessToken
|
|
260
|
+
)
|
|
261
|
+
}
|
|
262
|
+
`;
|
|
@@ -92,7 +92,8 @@ export declare class AuthService extends Service {
|
|
|
92
92
|
* @returns A promise that resolves to the result of the sendOTP mutation.
|
|
93
93
|
* @throws Will throw an error if the GraphQL mutation fails.
|
|
94
94
|
*/
|
|
95
|
-
sendOTP(phone: string, type?:
|
|
95
|
+
sendOTP(phone: string, type?: "SMS" | "ZALO"): Promise<SendOTPResponse>;
|
|
96
|
+
sendOTPV2(orgId: String, phone: string, type?: "SMS" | "ZALO"): Promise<SendOTPResponse>;
|
|
96
97
|
/**
|
|
97
98
|
* Validates OTP code for the specified phone number.
|
|
98
99
|
*
|
|
@@ -102,7 +103,7 @@ export declare class AuthService extends Service {
|
|
|
102
103
|
* @returns A promise that resolves to the result of the validateOTP mutation.
|
|
103
104
|
* @throws Will throw an error if the GraphQL mutation fails.
|
|
104
105
|
*/
|
|
105
|
-
validateOTP(otpCode: string, phone: string, type?:
|
|
106
|
+
validateOTP(otpCode: string, phone: string, type?: "SMS" | "ZALO"): Promise<ValidateOTPResponse>;
|
|
106
107
|
/**
|
|
107
108
|
* Gets access token by validating OTP code for the specified phone number.
|
|
108
109
|
* This function validates the OTP and returns an access token if successful.
|
|
@@ -113,7 +114,7 @@ export declare class AuthService extends Service {
|
|
|
113
114
|
* @returns A promise that resolves to an object containing the access token.
|
|
114
115
|
* @throws Will throw an error if the GraphQL query fails.
|
|
115
116
|
*/
|
|
116
|
-
getAccessTokenByOTP(otpCode: string, phone: string, type?:
|
|
117
|
+
getAccessTokenByOTP(otpCode: string, phone: string, type?: "SMS" | "ZALO"): Promise<GetAccessTokenByOTPResponse>;
|
|
117
118
|
/**
|
|
118
119
|
* Creates/sets a password for a user using the updateInfo mutation.
|
|
119
120
|
* Uses the SDK's internal orgId and token (accessToken).
|
|
@@ -134,4 +135,7 @@ export declare class AuthService extends Service {
|
|
|
134
135
|
* @throws Will throw an error if the GraphQL mutation fails.
|
|
135
136
|
*/
|
|
136
137
|
updateInfo(updateUserRequest?: any, type?: string, password?: string): Promise<UpdateInfoResponse>;
|
|
138
|
+
createResetKey(userLoginId: string): Promise<any>;
|
|
139
|
+
checkResetKey(resetKey: string): Promise<any>;
|
|
140
|
+
resetPasswordV2(orgId: string, username: string, newPassword: string, accessToken: string): Promise<any>;
|
|
137
141
|
}
|
|
@@ -408,7 +408,24 @@ class AuthService extends serviceSDK_1.Service {
|
|
|
408
408
|
const variables = {
|
|
409
409
|
orgId: this.orgId,
|
|
410
410
|
phone,
|
|
411
|
-
channelType: type ||
|
|
411
|
+
channelType: type || "SMS", // Default to SMS if not specified
|
|
412
|
+
};
|
|
413
|
+
try {
|
|
414
|
+
const response = yield this.graphqlMutation(mutations_1.SEND_OTP_MUTATION, variables);
|
|
415
|
+
return response.sendOTP;
|
|
416
|
+
}
|
|
417
|
+
catch (error) {
|
|
418
|
+
console.log(`Error in sendOTP: ${error}`);
|
|
419
|
+
throw error;
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
sendOTPV2(orgId, phone, type) {
|
|
424
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
425
|
+
const variables = {
|
|
426
|
+
orgId: orgId,
|
|
427
|
+
phone,
|
|
428
|
+
channelType: type || "SMS", // Default to SMS if not specified
|
|
412
429
|
};
|
|
413
430
|
try {
|
|
414
431
|
const response = yield this.graphqlMutation(mutations_1.SEND_OTP_MUTATION, variables);
|
|
@@ -434,7 +451,7 @@ class AuthService extends serviceSDK_1.Service {
|
|
|
434
451
|
const variables = {
|
|
435
452
|
otpCode,
|
|
436
453
|
phone,
|
|
437
|
-
channelType: type ||
|
|
454
|
+
channelType: type || "SMS",
|
|
438
455
|
};
|
|
439
456
|
try {
|
|
440
457
|
const response = yield this.graphqlMutation(mutations_1.VALIDATE_OTP_MUTATION, variables);
|
|
@@ -461,7 +478,7 @@ class AuthService extends serviceSDK_1.Service {
|
|
|
461
478
|
const variables = {
|
|
462
479
|
otpCode,
|
|
463
480
|
phone,
|
|
464
|
-
channelType: type ||
|
|
481
|
+
channelType: type || "SMS",
|
|
465
482
|
};
|
|
466
483
|
try {
|
|
467
484
|
const response = yield this.graphqlQuery(queries_1.GET_ACCESS_TOKEN_BY_OTP_QUERY, variables);
|
|
@@ -527,5 +544,53 @@ class AuthService extends serviceSDK_1.Service {
|
|
|
527
544
|
}
|
|
528
545
|
});
|
|
529
546
|
}
|
|
547
|
+
createResetKey(userLoginId) {
|
|
548
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
549
|
+
const mutation = mutations_1.CREATE_RESET_KEY;
|
|
550
|
+
const variables = {
|
|
551
|
+
userLoginId,
|
|
552
|
+
};
|
|
553
|
+
try {
|
|
554
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
|
555
|
+
return response.createResetKey;
|
|
556
|
+
}
|
|
557
|
+
catch (error) {
|
|
558
|
+
throw error;
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
checkResetKey(resetKey) {
|
|
563
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
564
|
+
const mutations = mutations_1.CHECK_RESET_KEY;
|
|
565
|
+
const variables = {
|
|
566
|
+
resetKey,
|
|
567
|
+
};
|
|
568
|
+
try {
|
|
569
|
+
const response = yield this.graphqlMutation(mutations, variables);
|
|
570
|
+
return response.checkResetKey;
|
|
571
|
+
}
|
|
572
|
+
catch (error) {
|
|
573
|
+
throw error;
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
resetPasswordV2(orgId, username, newPassword, accessToken) {
|
|
578
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
579
|
+
const mutation = mutations_1.RESET_PASSWORD;
|
|
580
|
+
const variables = {
|
|
581
|
+
orgId,
|
|
582
|
+
username,
|
|
583
|
+
newPassword,
|
|
584
|
+
accessToken
|
|
585
|
+
};
|
|
586
|
+
try {
|
|
587
|
+
const response = yield this.graphqlMutation(mutation, variables);
|
|
588
|
+
return response.resetPasswordV2;
|
|
589
|
+
}
|
|
590
|
+
catch (error) {
|
|
591
|
+
throw error;
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
}
|
|
530
595
|
}
|
|
531
596
|
exports.AuthService = AuthService;
|