@mspkapps/auth-client 0.1.16 → 0.1.18
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/package.json +4 -4
- package/src/AuthClient.js +28 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mspkapps/auth-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Lightweight client for Your Auth Service",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
},
|
|
26
26
|
"repository": {
|
|
27
27
|
"type": "git",
|
|
28
|
-
"url": "https://github.com/
|
|
28
|
+
"url": "https://github.com/MSPK-APPS/authServiceNpm.git"
|
|
29
29
|
},
|
|
30
30
|
"bugs": {
|
|
31
|
-
"url": "https://github.com/
|
|
31
|
+
"url": "https://github.com/MSPK-APPS/authServiceNpm.git/issues"
|
|
32
32
|
},
|
|
33
|
-
"homepage": "https://github.com/
|
|
33
|
+
"homepage": "https://github.com/MSPK-APPS/authServiceNpm.git#readme",
|
|
34
34
|
"engines": {
|
|
35
35
|
"node": ">=18"
|
|
36
36
|
}
|
package/src/AuthClient.js
CHANGED
|
@@ -129,10 +129,10 @@ export class AuthClient {
|
|
|
129
129
|
|
|
130
130
|
const json = await safeJson(resp);
|
|
131
131
|
if (!resp.ok || json?.success === false) throw toError(resp, json, 'Google authentication failed');
|
|
132
|
-
|
|
132
|
+
|
|
133
133
|
const token = json?.data?.user_token;
|
|
134
134
|
if (token) this.setToken(token);
|
|
135
|
-
|
|
135
|
+
|
|
136
136
|
return json;
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -179,7 +179,32 @@ export class AuthClient {
|
|
|
179
179
|
if (!resp.ok || json?.success === false) throw toError(resp, json, 'Delete account failed');
|
|
180
180
|
return json;
|
|
181
181
|
}
|
|
182
|
-
|
|
182
|
+
|
|
183
|
+
async getEditableProfileFields() {
|
|
184
|
+
// either call profile (which contains editable flags) or a dedicated endpoint
|
|
185
|
+
const resp = await this.fetch(this._buildUrl('user/profile'), {
|
|
186
|
+
method: 'GET',
|
|
187
|
+
headers: this._headers()
|
|
188
|
+
});
|
|
189
|
+
const json = await safeJson(resp);
|
|
190
|
+
if (!resp.ok || json?.success === false) throw toError(resp, json, 'Get profile failed');
|
|
191
|
+
// return both profile and editable metadata
|
|
192
|
+
return json;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
async updateProfile(updates = {}) {
|
|
196
|
+
// updates can contain { name, username, email, extra: { fieldName: value } }
|
|
197
|
+
const resp = await this.fetch(this._buildUrl('user/profile'), {
|
|
198
|
+
method: 'PATCH',
|
|
199
|
+
headers: this._headers(),
|
|
200
|
+
body: JSON.stringify(updates)
|
|
201
|
+
});
|
|
202
|
+
const json = await safeJson(resp);
|
|
203
|
+
if (!resp.ok || json?.success === false) throw toError(resp, json, 'Update profile failed');
|
|
204
|
+
// If server indicates verification required, return that info to UI
|
|
205
|
+
return json;
|
|
206
|
+
}
|
|
207
|
+
|
|
183
208
|
async sendGoogleUserSetPasswordEmail({ email }) {
|
|
184
209
|
const resp = await this.fetch(this._buildUrl('auth/set-password-google-user'), {
|
|
185
210
|
method: 'POST',
|