@longvansoftware/storefront-js-client 3.0.3 → 3.0.5
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Service } from "../serviceSDK";
|
|
2
|
-
import { LoginRequest, LoginResponse, RegisterRequest, SendOTPResponse, ValidateOTPResponse, CreateUserLoginResponse, GetAccessTokenByOTPResponse, CreateOrgResponse, CreateUserDetailResponse } from "../../types/auth";
|
|
2
|
+
import { LoginRequest, LoginResponse, RegisterRequest, SendOTPResponse, ValidateOTPResponse, CreateUserLoginResponse, GetAccessTokenByOTPResponse, CreateOrgResponse, CreateUserDetailResponse, UpdateInfoRequest, UpdateInfoResponse } from "../../types/auth";
|
|
3
3
|
/**
|
|
4
4
|
* Represents the authentication service.
|
|
5
5
|
*/
|
|
@@ -122,4 +122,25 @@ export declare class AuthService extends Service {
|
|
|
122
122
|
* @throws Will throw an error if the GraphQL mutation fails.
|
|
123
123
|
*/
|
|
124
124
|
getAccessTokenByOTP(otpCode: string, phone: string, type?: "SMS" | "ZALO"): Promise<GetAccessTokenByOTPResponse>;
|
|
125
|
+
/**
|
|
126
|
+
* Updates user information.
|
|
127
|
+
* Uses the SDK's configured orgId and access token automatically.
|
|
128
|
+
*
|
|
129
|
+
* @param updateUserRequest - The user information to update.
|
|
130
|
+
* @param type - Optional type parameter.
|
|
131
|
+
* @param password - Optional password for verification.
|
|
132
|
+
* @returns A promise that resolves to the updated user information.
|
|
133
|
+
* @throws Will throw an error if the GraphQL mutation fails.
|
|
134
|
+
*/
|
|
135
|
+
updateInfo(updateUserRequest: UpdateInfoRequest, type?: string, password?: string): Promise<UpdateInfoResponse>;
|
|
136
|
+
/**
|
|
137
|
+
* Creates/updates user password.
|
|
138
|
+
* Uses the SDK's configured orgId and access token automatically.
|
|
139
|
+
* This is a simplified version of updateInfo specifically for password creation.
|
|
140
|
+
*
|
|
141
|
+
* @param password - The new password to set.
|
|
142
|
+
* @returns A promise that resolves to the updated user information.
|
|
143
|
+
* @throws Will throw an error if the GraphQL mutation fails.
|
|
144
|
+
*/
|
|
145
|
+
createPassword(password: string): Promise<UpdateInfoResponse>;
|
|
125
146
|
}
|
|
@@ -473,7 +473,7 @@ class AuthService extends serviceSDK_1.Service {
|
|
|
473
473
|
};
|
|
474
474
|
try {
|
|
475
475
|
const response = yield this.graphqlQuery(queries_1.GET_ACCESS_TOKEN_BY_OTP, variables);
|
|
476
|
-
return response;
|
|
476
|
+
return { accessToken: response.getAccessTokenByOTP };
|
|
477
477
|
}
|
|
478
478
|
catch (error) {
|
|
479
479
|
console.log(`Error in getAccessTokenByOTP: ${error}`);
|
|
@@ -481,5 +481,60 @@ class AuthService extends serviceSDK_1.Service {
|
|
|
481
481
|
}
|
|
482
482
|
});
|
|
483
483
|
}
|
|
484
|
+
/**
|
|
485
|
+
* Updates user information.
|
|
486
|
+
* Uses the SDK's configured orgId and access token automatically.
|
|
487
|
+
*
|
|
488
|
+
* @param updateUserRequest - The user information to update.
|
|
489
|
+
* @param type - Optional type parameter.
|
|
490
|
+
* @param password - Optional password for verification.
|
|
491
|
+
* @returns A promise that resolves to the updated user information.
|
|
492
|
+
* @throws Will throw an error if the GraphQL mutation fails.
|
|
493
|
+
*/
|
|
494
|
+
updateInfo(updateUserRequest, type, password) {
|
|
495
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
496
|
+
const variables = {
|
|
497
|
+
orgId: this.orgId,
|
|
498
|
+
accessToken: this.token,
|
|
499
|
+
updateUserRequest,
|
|
500
|
+
type,
|
|
501
|
+
password,
|
|
502
|
+
};
|
|
503
|
+
try {
|
|
504
|
+
const response = yield this.graphqlMutation(mutations_1.UPDATE_INFO_MUTATION, variables);
|
|
505
|
+
return response.updateInfo;
|
|
506
|
+
}
|
|
507
|
+
catch (error) {
|
|
508
|
+
console.log(`Error in updateInfo: ${error}`);
|
|
509
|
+
throw error;
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* Creates/updates user password.
|
|
515
|
+
* Uses the SDK's configured orgId and access token automatically.
|
|
516
|
+
* This is a simplified version of updateInfo specifically for password creation.
|
|
517
|
+
*
|
|
518
|
+
* @param password - The new password to set.
|
|
519
|
+
* @returns A promise that resolves to the updated user information.
|
|
520
|
+
* @throws Will throw an error if the GraphQL mutation fails.
|
|
521
|
+
*/
|
|
522
|
+
createPassword(password) {
|
|
523
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
524
|
+
const variables = {
|
|
525
|
+
orgId: this.orgId,
|
|
526
|
+
accessToken: this.token,
|
|
527
|
+
password,
|
|
528
|
+
};
|
|
529
|
+
try {
|
|
530
|
+
const response = yield this.graphqlMutation(mutations_1.UPDATE_INFO_MUTATION, variables);
|
|
531
|
+
return response.updateInfo;
|
|
532
|
+
}
|
|
533
|
+
catch (error) {
|
|
534
|
+
console.log(`Error in createPassword: ${error}`);
|
|
535
|
+
throw error;
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
}
|
|
484
539
|
}
|
|
485
540
|
exports.AuthService = AuthService;
|
package/dist/src/types/auth.d.ts
CHANGED
|
@@ -235,3 +235,48 @@ export interface CreateUserDetailResponse {
|
|
|
235
235
|
/** Organization roles map */
|
|
236
236
|
orgRolesMap: Record<string, any>;
|
|
237
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Request interface for updating user information
|
|
240
|
+
*/
|
|
241
|
+
export interface UpdateInfoRequest {
|
|
242
|
+
/** Full name */
|
|
243
|
+
fullName?: string;
|
|
244
|
+
/** Email address */
|
|
245
|
+
email?: string;
|
|
246
|
+
/** Phone number */
|
|
247
|
+
phone?: string;
|
|
248
|
+
/** Address */
|
|
249
|
+
address?: string;
|
|
250
|
+
/** Identity number */
|
|
251
|
+
identityNumber?: string;
|
|
252
|
+
/** Gender */
|
|
253
|
+
gender?: string;
|
|
254
|
+
/** Birth date */
|
|
255
|
+
birthDate?: string;
|
|
256
|
+
/** Avatar URL */
|
|
257
|
+
avatarUrl?: string;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Response interface for updating user information
|
|
261
|
+
* Returns the updated user profile with full information
|
|
262
|
+
*/
|
|
263
|
+
export interface UpdateInfoResponse {
|
|
264
|
+
/** Party ID */
|
|
265
|
+
partyId: string;
|
|
266
|
+
/** Full name */
|
|
267
|
+
fullName: string;
|
|
268
|
+
/** Email address */
|
|
269
|
+
email: string;
|
|
270
|
+
/** Phone number */
|
|
271
|
+
phone: string;
|
|
272
|
+
/** Address */
|
|
273
|
+
address: string;
|
|
274
|
+
/** Identity number */
|
|
275
|
+
identityNumber: string;
|
|
276
|
+
/** Gender */
|
|
277
|
+
gender: string;
|
|
278
|
+
/** Birth date */
|
|
279
|
+
birthDate: string;
|
|
280
|
+
/** Avatar URL */
|
|
281
|
+
avatarUrl: string;
|
|
282
|
+
}
|