@formant/data-sdk 1.78.0 → 1.78.2
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/CHANGELOG.md +8 -0
- package/dist/data-sdk.cjs.js +1 -1
- package/dist/data-sdk.cjs.js.map +1 -1
- package/dist/data-sdk.es.js +15 -15
- package/dist/data-sdk.es.js.map +1 -1
- package/dist/data-sdk.es6.js +15 -15
- package/dist/data-sdk.umd.js +1 -1
- package/dist/types/data-sdk/src/stores/AuthenticationStore.d.ts +1 -1
- package/package.json +2 -2
package/dist/data-sdk.es.js
CHANGED
|
@@ -228,32 +228,32 @@ class AuthenticationStore {
|
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
async loginWithToken(t, n) {
|
|
232
|
-
var
|
|
233
|
-
const
|
|
231
|
+
async loginWithToken(t, n, r = !1) {
|
|
232
|
+
var s;
|
|
233
|
+
const o = JSON.parse(base64Exports.decode(t.split(".")[1]));
|
|
234
234
|
try {
|
|
235
|
-
let
|
|
236
|
-
if (this._isShareToken =
|
|
237
|
-
const
|
|
235
|
+
let g;
|
|
236
|
+
if (this._isShareToken = o["formant:claims"] && o["formant:claims"].type == "share", o["formant:claims"] && (this._currentOrganization = o["formant:claims"].organizationId), o["custom:organization_id"] && (this._currentOrganization = o["custom:organization_id"]), this._isShareToken || (g = o.sub), o["formant:claims"] && o["formant:claims"].userId && (g = o["formant:claims"].userId), g && ((s = this._currentUser) == null ? void 0 : s.id) !== g && !r) {
|
|
237
|
+
const l = await fetch(`${this._apiUrl}/v1/admin/users/${g}`, {
|
|
238
238
|
method: "GET",
|
|
239
239
|
headers: {
|
|
240
240
|
"Content-Type": "application/json",
|
|
241
241
|
Authorization: "Bearer " + t
|
|
242
242
|
}
|
|
243
|
-
}),
|
|
244
|
-
if (
|
|
245
|
-
throw new Error(
|
|
246
|
-
this._currentUser =
|
|
243
|
+
}), u = await l.json();
|
|
244
|
+
if (l.status !== 200)
|
|
245
|
+
throw new Error(u.message);
|
|
246
|
+
this._currentUser = u;
|
|
247
247
|
}
|
|
248
|
-
this._token = t, this._waitingForAuth.forEach((
|
|
249
|
-
} catch (
|
|
250
|
-
console.error("loginWithToken() failed", { err:
|
|
248
|
+
this._token = t, this._waitingForAuth.forEach((l) => l(!0));
|
|
249
|
+
} catch (g) {
|
|
250
|
+
console.error("loginWithToken() failed", { err: g }), this._waitingForAuth.forEach((l) => l(!1));
|
|
251
251
|
} finally {
|
|
252
252
|
this._waitingForAuth.clear();
|
|
253
253
|
}
|
|
254
254
|
n && (this._refreshToken = n, setInterval(async () => {
|
|
255
255
|
if (this._refreshToken) {
|
|
256
|
-
const
|
|
256
|
+
const l = await (await fetch(`${this._apiUrl}/v1/admin/auth/refresh`, {
|
|
257
257
|
method: "POST",
|
|
258
258
|
headers: {
|
|
259
259
|
"Content-Type": "application/json"
|
|
@@ -262,7 +262,7 @@ class AuthenticationStore {
|
|
|
262
262
|
refreshToken: this._refreshToken
|
|
263
263
|
})
|
|
264
264
|
})).json();
|
|
265
|
-
this._token =
|
|
265
|
+
this._token = l.authentication.accessToken;
|
|
266
266
|
}
|
|
267
267
|
}, 1e3 * 60 * 60));
|
|
268
268
|
}
|