@mspkapps/auth-client 0.1.23 → 0.1.24

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/AuthClient.js +16 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mspkapps/auth-client",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "description": "Lightweight client for Your Auth Service",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/AuthClient.js CHANGED
@@ -209,6 +209,19 @@ export class AuthClient {
209
209
  return json;
210
210
  }
211
211
 
212
+ async verifyToken(accessToken) {
213
+ const resp = await this.fetch(this._buildUrl('auth/verify-token'), {
214
+ method: 'POST',
215
+ headers: {
216
+ ...this._headers(),
217
+ Authorization: `Bearer ${accessToken}`
218
+ }
219
+ });
220
+ const json = await safeJson(resp);
221
+ if (!resp.ok || json?.success === false) throw toError(resp, json, 'Verify token failed');
222
+ return json?.data ?? json;
223
+ }
224
+
212
225
  async authed(path, { method = 'GET', body, headers } = {}) {
213
226
  const resp = await this.fetch(this._buildUrl(path), {
214
227
  method,
@@ -308,6 +321,9 @@ const authclient = {
308
321
  logout() {
309
322
  return ensureClient().logout();
310
323
  },
324
+ verifyToken(accessToken) {
325
+ return ensureClient().verifyToken(accessToken);
326
+ },
311
327
  };
312
328
 
313
329
  export { authclient, init }; // named exports if someone prefers them