@mspkapps/auth-client 0.1.28 → 0.1.29
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 +1 -1
- package/src/AuthClient.js +62 -1
package/package.json
CHANGED
package/src/AuthClient.js
CHANGED
|
@@ -232,6 +232,53 @@ export class AuthClient {
|
|
|
232
232
|
if (!resp.ok || json?.success === false) throw toError(resp, json, 'Request failed');
|
|
233
233
|
return json;
|
|
234
234
|
}
|
|
235
|
+
|
|
236
|
+
// ---------- Developer Data APIs ----------
|
|
237
|
+
async getDeveloperGroups() {
|
|
238
|
+
const resp = await this.fetch(this._buildUrl('developer/groups'), {
|
|
239
|
+
method: 'GET',
|
|
240
|
+
headers: this._headers()
|
|
241
|
+
});
|
|
242
|
+
const json = await safeJson(resp);
|
|
243
|
+
if (!resp.ok || json?.success === false) throw toError(resp, json, 'Get developer groups failed');
|
|
244
|
+
return json;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async getDeveloperApps(groupId = null) {
|
|
248
|
+
const url = groupId
|
|
249
|
+
? this._buildUrl(`developer/apps?group_id=${encodeURIComponent(groupId)}`)
|
|
250
|
+
: this._buildUrl('developer/apps');
|
|
251
|
+
const resp = await this.fetch(url, {
|
|
252
|
+
method: 'GET',
|
|
253
|
+
headers: this._headers()
|
|
254
|
+
});
|
|
255
|
+
const json = await safeJson(resp);
|
|
256
|
+
if (!resp.ok || json?.success === false) throw toError(resp, json, 'Get developer apps failed');
|
|
257
|
+
return json;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
async getAppUsers({ appId, page = 1, limit = 50 }) {
|
|
261
|
+
if (!appId) throw new AuthError('appId is required', 400, 'MISSING_APP_ID', null);
|
|
262
|
+
const url = this._buildUrl(`developer/users?app_id=${encodeURIComponent(appId)}&page=${page}&limit=${limit}`);
|
|
263
|
+
const resp = await this.fetch(url, {
|
|
264
|
+
method: 'GET',
|
|
265
|
+
headers: this._headers()
|
|
266
|
+
});
|
|
267
|
+
const json = await safeJson(resp);
|
|
268
|
+
if (!resp.ok || json?.success === false) throw toError(resp, json, 'Get app users failed');
|
|
269
|
+
return json;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
async getUserData(userId) {
|
|
273
|
+
if (!userId) throw new AuthError('userId is required', 400, 'MISSING_USER_ID', null);
|
|
274
|
+
const resp = await this.fetch(this._buildUrl(`developer/user/${encodeURIComponent(userId)}`), {
|
|
275
|
+
method: 'GET',
|
|
276
|
+
headers: this._headers()
|
|
277
|
+
});
|
|
278
|
+
const json = await safeJson(resp);
|
|
279
|
+
if (!resp.ok || json?.success === false) throw toError(resp, json, 'Get user data failed');
|
|
280
|
+
return json;
|
|
281
|
+
}
|
|
235
282
|
}
|
|
236
283
|
|
|
237
284
|
// ---------- helpers ----------
|
|
@@ -324,7 +371,21 @@ const authclient = {
|
|
|
324
371
|
verifyToken(accessToken) {
|
|
325
372
|
return ensureClient().verifyToken(accessToken);
|
|
326
373
|
},
|
|
374
|
+
|
|
375
|
+
// developer data APIs
|
|
376
|
+
getDeveloperGroups() {
|
|
377
|
+
return ensureClient().getDeveloperGroups();
|
|
378
|
+
},
|
|
379
|
+
getDeveloperApps(groupId = null) {
|
|
380
|
+
return ensureClient().getDeveloperApps(groupId);
|
|
381
|
+
},
|
|
382
|
+
getAppUsers({ appId, page, limit }) {
|
|
383
|
+
return ensureClient().getAppUsers({ appId, page, limit });
|
|
384
|
+
},
|
|
385
|
+
getUserData(userId) {
|
|
386
|
+
return ensureClient().getUserData(userId);
|
|
387
|
+
},
|
|
327
388
|
};
|
|
328
389
|
|
|
329
390
|
export { authclient, init }; // named exports if someone prefers them
|
|
330
|
-
export default authclient; // default export for your desired DX
|
|
391
|
+
export default authclient; // default export for your desired DX
|