@longvansoftware/storefront-js-client 2.7.3 → 2.7.4
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/src/graphql/auth/mutations.d.ts +3 -0
- package/dist/src/graphql/auth/mutations.js +46 -1
- package/dist/src/graphql/auth/queries.d.ts +6 -0
- package/dist/src/graphql/auth/queries.js +51 -1
- package/dist/src/lib/auth/index.d.ts +26 -0
- package/dist/src/lib/auth/index.js +233 -0
- package/package.json +1 -1
|
@@ -5,3 +5,6 @@ export declare const VERIFY_CODE_MUTATION: import("graphql").DocumentNode;
|
|
|
5
5
|
export declare const RESET_PASSWORD_MUTATION: import("graphql").DocumentNode;
|
|
6
6
|
export declare const UPDATE_INFO_MUTATION: import("graphql").DocumentNode;
|
|
7
7
|
export declare const UPDATE_PASSWORD_MUTATION = "\n mutation UpdatePassword($orgId: String!, $accessToken: String!, $currentPassword: String!, $newPassword: String!) {\n updatePassword(orgId: $orgId, accessToken: $accessToken, currentPassword: $currentPassword, newPassword: $newPassword)\n }\n";
|
|
8
|
+
export declare const UPDATE_PROFILE_MUTATION: import("graphql").DocumentNode;
|
|
9
|
+
export declare const LINKING_USER_LOGIN_AND_USER_DETAIL_MUTATION: import("graphql").DocumentNode;
|
|
10
|
+
export declare const CREATE_USER_DETAIL_MUTATION: import("graphql").DocumentNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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.CREATE_USER_DETAIL_MUTATION = exports.LINKING_USER_LOGIN_AND_USER_DETAIL_MUTATION = exports.UPDATE_PROFILE_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!) {
|
|
@@ -97,3 +97,48 @@ exports.UPDATE_PASSWORD_MUTATION = `
|
|
|
97
97
|
updatePassword(orgId: $orgId, accessToken: $accessToken, currentPassword: $currentPassword, newPassword: $newPassword)
|
|
98
98
|
}
|
|
99
99
|
`;
|
|
100
|
+
exports.UPDATE_PROFILE_MUTATION = (0, graphql_tag_1.gql) `
|
|
101
|
+
mutation UpdateProfile(
|
|
102
|
+
$userLoginId: String!
|
|
103
|
+
$name: String!
|
|
104
|
+
$phone: String!
|
|
105
|
+
$email: String
|
|
106
|
+
) {
|
|
107
|
+
updateProfile(
|
|
108
|
+
userLoginId: $userLoginId
|
|
109
|
+
name: $name
|
|
110
|
+
phone: $phone
|
|
111
|
+
email: $email
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
`;
|
|
115
|
+
exports.LINKING_USER_LOGIN_AND_USER_DETAIL_MUTATION = (0, graphql_tag_1.gql) `
|
|
116
|
+
mutation LinkingUserLoginAndUserDetail(
|
|
117
|
+
$userLoginId: String!
|
|
118
|
+
$partyId: String!
|
|
119
|
+
) {
|
|
120
|
+
linkingUserLoginAndUserDetail(userLoginId: $userLoginId, partyId: $partyId)
|
|
121
|
+
}
|
|
122
|
+
`;
|
|
123
|
+
exports.CREATE_USER_DETAIL_MUTATION = (0, graphql_tag_1.gql) `
|
|
124
|
+
mutation CreateUserDetail($userLoginId: String!, $partnerId: String!) {
|
|
125
|
+
createUserDetail(userLoginId: $userLoginId, partnerId: $partnerId) {
|
|
126
|
+
partyId
|
|
127
|
+
orgId
|
|
128
|
+
fullName
|
|
129
|
+
email
|
|
130
|
+
phone
|
|
131
|
+
address
|
|
132
|
+
identityNumber
|
|
133
|
+
gender
|
|
134
|
+
birthDate
|
|
135
|
+
avatarUrl
|
|
136
|
+
accessToken
|
|
137
|
+
username
|
|
138
|
+
readyV2
|
|
139
|
+
orgPermissionsMap
|
|
140
|
+
orgPositionsMap
|
|
141
|
+
orgRolesMap
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
`;
|
|
@@ -1 +1,7 @@
|
|
|
1
1
|
export declare const GET_USER_DETAIL: import("graphql").DocumentNode;
|
|
2
|
+
export declare const GET_USER_LOGIN_BY_TOKEN: import("graphql").DocumentNode;
|
|
3
|
+
export declare const GET_USER_LOGIN_BY_USER_LOGIN_ID: import("graphql").DocumentNode;
|
|
4
|
+
export declare const CHECK_USERNAME_EXISTED: import("graphql").DocumentNode;
|
|
5
|
+
export declare const LOGIN_GOOGLE: import("graphql").DocumentNode;
|
|
6
|
+
export declare const LOGIN_FACEBOOK: import("graphql").DocumentNode;
|
|
7
|
+
export declare const LOGIN_ZALO: import("graphql").DocumentNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GET_USER_DETAIL = void 0;
|
|
3
|
+
exports.LOGIN_ZALO = exports.LOGIN_FACEBOOK = exports.LOGIN_GOOGLE = exports.CHECK_USERNAME_EXISTED = exports.GET_USER_LOGIN_BY_USER_LOGIN_ID = exports.GET_USER_LOGIN_BY_TOKEN = exports.GET_USER_DETAIL = void 0;
|
|
4
4
|
const graphql_tag_1 = require("graphql-tag");
|
|
5
5
|
exports.GET_USER_DETAIL = (0, graphql_tag_1.gql) `
|
|
6
6
|
query GetUserDetail($orgId: String!, $accessToken: String!) {
|
|
@@ -23,3 +23,53 @@ exports.GET_USER_DETAIL = (0, graphql_tag_1.gql) `
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
`;
|
|
26
|
+
exports.GET_USER_LOGIN_BY_TOKEN = (0, graphql_tag_1.gql) `
|
|
27
|
+
query GetUserLoginByToken($accessToken: String!) {
|
|
28
|
+
getUserLoginByToken(accessToken: $accessToken) {
|
|
29
|
+
id
|
|
30
|
+
status
|
|
31
|
+
partyId
|
|
32
|
+
userLoginId
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
// query GetUserLoginByUserLoginId {
|
|
37
|
+
// getUserLoginByUserLoginId(userLoginId: "0971879660") {
|
|
38
|
+
// id
|
|
39
|
+
// userLoginId
|
|
40
|
+
// accessToken
|
|
41
|
+
// status
|
|
42
|
+
// partyId
|
|
43
|
+
// }
|
|
44
|
+
// }
|
|
45
|
+
exports.GET_USER_LOGIN_BY_USER_LOGIN_ID = (0, graphql_tag_1.gql) `
|
|
46
|
+
query GetUserLoginByUserLoginId($userLoginId: String!) {
|
|
47
|
+
getUserLoginByUserLoginId(userLoginId: $userLoginId) {
|
|
48
|
+
id
|
|
49
|
+
userLoginId
|
|
50
|
+
accessToken
|
|
51
|
+
status
|
|
52
|
+
partyId
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
`;
|
|
56
|
+
exports.CHECK_USERNAME_EXISTED = (0, graphql_tag_1.gql) `
|
|
57
|
+
query CheckUsernameExisted($username: String!, $orgId: String!) {
|
|
58
|
+
checkUsernameExisted(username: $username, orgId: $orgId)
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
exports.LOGIN_GOOGLE = (0, graphql_tag_1.gql) `
|
|
62
|
+
query LoginGoogle($orgId: String!, $type: String!, $redirectUrl: String!) {
|
|
63
|
+
loginGoogle(orgId: $orgId, type: $type, redirectUrl: $redirectUrl)
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
exports.LOGIN_FACEBOOK = (0, graphql_tag_1.gql) `
|
|
67
|
+
query LoginFacebook($orgId: String!, $type: String!, $redirectUrl: String!) {
|
|
68
|
+
loginFacebook(orgId: $orgId, type: $type, redirectUrl: $redirectUrl)
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
exports.LOGIN_ZALO = (0, graphql_tag_1.gql) `
|
|
72
|
+
query LoginZalo($orgId: String!, $type: String!, $redirectUrl: String!) {
|
|
73
|
+
loginZalo(orgId: $orgId, type: $type, redirectUrl: $redirectUrl)
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
@@ -24,4 +24,30 @@ export declare class AuthService extends Service {
|
|
|
24
24
|
*/
|
|
25
25
|
register(registerRequest: RegisterRequest): Promise<void>;
|
|
26
26
|
getUserDetail(accessToken: string): Promise<any>;
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves user login information using the provided access token.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} accessToken - The access token used to authenticate the request.
|
|
31
|
+
* @returns {Promise<any>} A promise that resolves to the user login information.
|
|
32
|
+
* @throws Will throw an error if the GraphQL query fails.
|
|
33
|
+
*/
|
|
34
|
+
getUserLoginByToken(accessToken: string): Promise<any>;
|
|
35
|
+
updateProfile(userLoginId: string, name: string, phone: string, email: string): Promise<any>;
|
|
36
|
+
getUserLoginByUserLoginId(userLoginId: string): Promise<any>;
|
|
37
|
+
checkUsernameExisted(username: string): Promise<any>;
|
|
38
|
+
linkingUserLoginAndUserDetail(userLoginId: string, partyId: string): Promise<any>;
|
|
39
|
+
createUserDetail(userLoginId: string): Promise<any>;
|
|
40
|
+
sendSmsVerifyCode(username: string): Promise<any>;
|
|
41
|
+
verifyCode(username: string, code: string): Promise<any>;
|
|
42
|
+
resetPassword(username: string, newPassword: string, accessToken: string): Promise<any>;
|
|
43
|
+
loginGoogle(redirectUrl: string): Promise<any>;
|
|
44
|
+
loginFacebook(redirectUrl: string): Promise<any>;
|
|
45
|
+
/**
|
|
46
|
+
* Logs in a user via Zalo by executing a GraphQL query.
|
|
47
|
+
*
|
|
48
|
+
* @param redirectUrl - The URL to redirect the user to after login.
|
|
49
|
+
* @returns A promise that resolves to the result of the `loginZalo` GraphQL query.
|
|
50
|
+
* @throws Will throw an error if the GraphQL query fails.
|
|
51
|
+
*/
|
|
52
|
+
loginZalo(redirectUrl: string): Promise<any>;
|
|
27
53
|
}
|
|
@@ -68,5 +68,238 @@ class AuthService extends serviceSDK_1.Service {
|
|
|
68
68
|
}
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Retrieves user login information using the provided access token.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} accessToken - The access token used to authenticate the request.
|
|
75
|
+
* @returns {Promise<any>} A promise that resolves to the user login information.
|
|
76
|
+
* @throws Will throw an error if the GraphQL query fails.
|
|
77
|
+
*/
|
|
78
|
+
getUserLoginByToken(accessToken) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const query = queries_1.GET_USER_LOGIN_BY_TOKEN;
|
|
81
|
+
const variables = {
|
|
82
|
+
accessToken,
|
|
83
|
+
};
|
|
84
|
+
try {
|
|
85
|
+
const response = yield this.graphqlQuery(query, variables);
|
|
86
|
+
return response.getUserLoginByToken;
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
console.log(`Error in getUserLoginByToken: ${error}`);
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
updateProfile(userLoginId, name, phone, email) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
const variables = {
|
|
97
|
+
userLoginId,
|
|
98
|
+
name,
|
|
99
|
+
phone,
|
|
100
|
+
email,
|
|
101
|
+
};
|
|
102
|
+
try {
|
|
103
|
+
const response = yield this.graphqlMutation(mutations_1.UPDATE_PROFILE_MUTATION, variables);
|
|
104
|
+
return response.updateProfile;
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
console.log(`Error in updateProfile: ${error}`);
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
getUserLoginByUserLoginId(userLoginId) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
const query = queries_1.GET_USER_LOGIN_BY_USER_LOGIN_ID;
|
|
115
|
+
const variables = {
|
|
116
|
+
userLoginId,
|
|
117
|
+
};
|
|
118
|
+
try {
|
|
119
|
+
const response = yield this.graphqlQuery(query, variables);
|
|
120
|
+
return response.getUserLoginByUserLoginId;
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
console.log(`Error in getUserLoginByUserLoginId: ${error}`);
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
checkUsernameExisted(username) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
const variables = {
|
|
131
|
+
username,
|
|
132
|
+
orgId: this.orgId,
|
|
133
|
+
};
|
|
134
|
+
try {
|
|
135
|
+
const response = yield this.graphqlQuery(queries_1.CHECK_USERNAME_EXISTED, variables);
|
|
136
|
+
return response.checkUsernameExisted;
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
console.log(`Error in checkUsernameExisted: ${error}`);
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
linkingUserLoginAndUserDetail(userLoginId, partyId) {
|
|
145
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
const variables = {
|
|
147
|
+
userLoginId,
|
|
148
|
+
partyId,
|
|
149
|
+
};
|
|
150
|
+
try {
|
|
151
|
+
const response = yield this.graphqlMutation(mutations_1.LINKING_USER_LOGIN_AND_USER_DETAIL_MUTATION, variables);
|
|
152
|
+
return response.linkingUserLoginAndUserDetail;
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
console.log(`Error in linkingUserLoginAndUserDetail: ${error}`);
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
createUserDetail(userLoginId) {
|
|
161
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
+
const variables = {
|
|
163
|
+
userLoginId,
|
|
164
|
+
partnerId: this.orgId,
|
|
165
|
+
};
|
|
166
|
+
try {
|
|
167
|
+
const response = yield this.graphqlMutation(mutations_1.CREATE_USER_DETAIL_MUTATION, variables);
|
|
168
|
+
return response.createUserDetail;
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
console.log(`Error in createUserDetail: ${error}`);
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
// mutation VerifyCode {
|
|
177
|
+
// sendSmsVerifyCode(orgId: "FYP", username: "0971879660") {
|
|
178
|
+
// id
|
|
179
|
+
// code
|
|
180
|
+
// username
|
|
181
|
+
// timeExpired
|
|
182
|
+
// }
|
|
183
|
+
// }
|
|
184
|
+
sendSmsVerifyCode(username) {
|
|
185
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
186
|
+
const query = mutations_1.SEND_SMS_VERIFY_CODE_MUTATION;
|
|
187
|
+
const variables = {
|
|
188
|
+
orgId: this.orgId,
|
|
189
|
+
username,
|
|
190
|
+
};
|
|
191
|
+
try {
|
|
192
|
+
const response = yield this.graphqlMutation(query, variables);
|
|
193
|
+
return response.sendSmsVerifyCode;
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
console.log(`Error in sendSmsVerifyCode: ${error}`);
|
|
197
|
+
throw error;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
// mutation VerifyCode {
|
|
202
|
+
// verifyCode(
|
|
203
|
+
// orgId: "FYP"
|
|
204
|
+
// verifyCodeRequest: { username: "0971879660", code: "999999" }
|
|
205
|
+
// )
|
|
206
|
+
// }
|
|
207
|
+
verifyCode(username, code) {
|
|
208
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
209
|
+
const query = mutations_1.VERIFY_CODE_MUTATION;
|
|
210
|
+
const variables = {
|
|
211
|
+
orgId: this.orgId,
|
|
212
|
+
verifyCodeRequest: { username, code },
|
|
213
|
+
};
|
|
214
|
+
try {
|
|
215
|
+
const response = yield this.graphqlMutation(query, variables);
|
|
216
|
+
return response.verifyCode;
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
console.log(`Error in verifyCode: ${error}`);
|
|
220
|
+
throw error;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
resetPassword(username, newPassword, accessToken) {
|
|
225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
226
|
+
const query = mutations_1.RESET_PASSWORD_MUTATION;
|
|
227
|
+
const variables = {
|
|
228
|
+
orgId: this.orgId,
|
|
229
|
+
username,
|
|
230
|
+
newPassword,
|
|
231
|
+
accessToken,
|
|
232
|
+
};
|
|
233
|
+
try {
|
|
234
|
+
const response = yield this.graphqlMutation(query, variables);
|
|
235
|
+
return response.resetPassword;
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
console.log(`Error in resetPassword: ${error}`);
|
|
239
|
+
throw error;
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
loginGoogle(redirectUrl) {
|
|
244
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
245
|
+
const query = queries_1.LOGIN_GOOGLE;
|
|
246
|
+
const variables = {
|
|
247
|
+
orgId: this.orgId,
|
|
248
|
+
type: "login",
|
|
249
|
+
redirectUrl,
|
|
250
|
+
};
|
|
251
|
+
try {
|
|
252
|
+
const response = yield this.graphqlQuery(query, variables);
|
|
253
|
+
return response.loginGoogle;
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
console.log(`Error in loginGoogle: ${error}`);
|
|
257
|
+
throw error;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
loginFacebook(redirectUrl) {
|
|
262
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
263
|
+
const query = queries_1.LOGIN_FACEBOOK;
|
|
264
|
+
const variables = {
|
|
265
|
+
orgId: this.orgId,
|
|
266
|
+
type: "login",
|
|
267
|
+
redirectUrl,
|
|
268
|
+
};
|
|
269
|
+
try {
|
|
270
|
+
const response = yield this.graphqlQuery(query, variables);
|
|
271
|
+
return response.loginFacebook;
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
console.log(`Error in loginFacebook: ${error}`);
|
|
275
|
+
throw error;
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Logs in a user via Zalo by executing a GraphQL query.
|
|
281
|
+
*
|
|
282
|
+
* @param redirectUrl - The URL to redirect the user to after login.
|
|
283
|
+
* @returns A promise that resolves to the result of the `loginZalo` GraphQL query.
|
|
284
|
+
* @throws Will throw an error if the GraphQL query fails.
|
|
285
|
+
*/
|
|
286
|
+
loginZalo(redirectUrl) {
|
|
287
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
288
|
+
const query = queries_1.LOGIN_ZALO;
|
|
289
|
+
const variables = {
|
|
290
|
+
orgId: this.orgId,
|
|
291
|
+
type: "login",
|
|
292
|
+
redirectUrl,
|
|
293
|
+
};
|
|
294
|
+
try {
|
|
295
|
+
const response = yield this.graphqlQuery(query, variables);
|
|
296
|
+
return response.loginZalo;
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
console.log(`Error in loginZalo: ${error}`);
|
|
300
|
+
throw error;
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
71
304
|
}
|
|
72
305
|
exports.AuthService = AuthService;
|