@auxilium/datalynk-client 1.0.11 → 1.0.12
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/api.d.ts.map +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/index.cjs +28 -30
- package/dist/index.mjs +28 -30
- package/dist/login-prompt.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAuB,MAAM,MAAM,CAAC;AAC3D,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAGtC,MAAM,MAAM,UAAU,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,GAAG,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACZ,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACxB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iCAAiC;I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EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,CAAC,CAAC;IAU7E;;;;;;;;;;;OAWG;IACI,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,CAAC,CAAC;IAqC/E;;;;;;;;;;;;OAYG;IACI,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;CAG5C"}
|
package/dist/auth.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export declare class Auth {
|
|
|
44
44
|
*
|
|
45
45
|
* @return {Promise<User | null>}
|
|
46
46
|
*/
|
|
47
|
-
current(token?: string | null
|
|
47
|
+
current(token?: string | null): Promise<null | User>;
|
|
48
48
|
/**
|
|
49
49
|
* Automatically handle sessions by checking localStorage & URL parameters for a token & prompting
|
|
50
50
|
* user with a login screen if required
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAyB,MAAM,MAAM,CAAC;AAC7D,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,WAAW,EAAE,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAE/D,mBAAmB;AACnB,MAAM,MAAM,IAAI,GAAG;IAClB,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,KAAK,EAAE,OAAO,CAAC;IACf,kCAAkC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,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OAMG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,WAAW;IAIrE;;;;OAIG;IACH,MAAM;gBAC6B,MAAM;aAAO,MAAM;;IAMtD;;;;;;;OAOG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAWvD;;;;;;OAMG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,KAAK,GAAG,OAAO;CAI3D"}
|
package/dist/index.cjs
CHANGED
|
@@ -1357,19 +1357,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1357
1357
|
background: "#ffffff",
|
|
1358
1358
|
color: "#c83232",
|
|
1359
1359
|
textColor: "#000000",
|
|
1360
|
-
...options
|
|
1360
|
+
...clean(options, true)
|
|
1361
1361
|
};
|
|
1362
1362
|
this.close();
|
|
1363
1363
|
document.head.innerHTML += _LoginPrompt.css(this.options);
|
|
1364
|
-
|
|
1364
|
+
const div = document.createElement("div");
|
|
1365
|
+
div.innerHTML = _LoginPrompt.template(this.options);
|
|
1366
|
+
document.body.appendChild(div);
|
|
1365
1367
|
this.alert = document.querySelector("#datalynk-login-alert");
|
|
1366
1368
|
this.button = document.querySelector("#datalynk-login-form button");
|
|
1367
1369
|
this.form = document.querySelector("#datalynk-login-form");
|
|
1368
1370
|
this.password = document.querySelector('#datalynk-login-form input[name="password"]');
|
|
1369
1371
|
this.persist = document.querySelector('#datalynk-login-form input[name="persist"]');
|
|
1370
1372
|
this.username = document.querySelector('#datalynk-login-form input[name="username"]');
|
|
1373
|
+
if (options.persist === false) this.persist.parentElement.remove();
|
|
1371
1374
|
this.form.onsubmit = (event) => this.login(event);
|
|
1372
|
-
if (options.persist === false) this.persist.parentElement.style.display = "none";
|
|
1373
1375
|
}
|
|
1374
1376
|
/** Close the login prompt */
|
|
1375
1377
|
close() {
|
|
@@ -1480,6 +1482,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1480
1482
|
}
|
|
1481
1483
|
|
|
1482
1484
|
#datalynk-login .login-header {
|
|
1485
|
+
display: flex;
|
|
1486
|
+
justify-content: center;
|
|
1487
|
+
align-items: center;
|
|
1483
1488
|
color: var(--theme-text);
|
|
1484
1489
|
text-align: center;
|
|
1485
1490
|
font-size: 32px;
|
|
@@ -1534,6 +1539,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1534
1539
|
}
|
|
1535
1540
|
|
|
1536
1541
|
#datalynk-login .login-links{
|
|
1542
|
+
display: flex;
|
|
1537
1543
|
padding: 0 0 1.5rem 0;
|
|
1538
1544
|
}
|
|
1539
1545
|
|
|
@@ -1566,7 +1572,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1566
1572
|
__publicField(_LoginPrompt, "template", (options) => `
|
|
1567
1573
|
<div id="datalynk-login">
|
|
1568
1574
|
<div class="added-links">
|
|
1569
|
-
${(options.addLinks || []).map((link) => `<a href="${link.url}" target="_blank">${link.text}</a>`).join(" | ")}
|
|
1575
|
+
${(options.addLinks || []).map((link) => `<a href="${link.url || "#"}" target="_blank">${link.text}</a>`).join(" | ")}
|
|
1570
1576
|
</div>
|
|
1571
1577
|
<div class="login-container">
|
|
1572
1578
|
<div class="login-header">
|
|
@@ -1575,7 +1581,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1575
1581
|
<div class="login-content">
|
|
1576
1582
|
<div class="login-body" style="max-width: 300px">
|
|
1577
1583
|
<div id="datalynk-login-alert" class="hidden"></div>
|
|
1578
|
-
|
|
1579
1584
|
<form id="datalynk-login-form">
|
|
1580
1585
|
<div>
|
|
1581
1586
|
<label for="username">Email or Username</label>
|
|
@@ -1590,7 +1595,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1590
1595
|
<label style="display: block; margin-bottom: 0.75rem;">
|
|
1591
1596
|
<input type="checkbox" name="persist" style="width: 20px"> Stay Logged In
|
|
1592
1597
|
</label>
|
|
1593
|
-
<button>Login</button>
|
|
1598
|
+
<button type="submit">Login</button>
|
|
1594
1599
|
</form>
|
|
1595
1600
|
</div>
|
|
1596
1601
|
${options.hideApps ? "" : `
|
|
@@ -1620,7 +1625,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1620
1625
|
/** Current user as an observable */
|
|
1621
1626
|
__publicField(this, "user$", new BehaviorSubject(void 0));
|
|
1622
1627
|
this.api = api;
|
|
1623
|
-
this.api.token$.subscribe((token) =>
|
|
1628
|
+
this.api.token$.subscribe(async (token) => {
|
|
1629
|
+
if (token === void 0) return;
|
|
1630
|
+
this.user = await this.current(token);
|
|
1631
|
+
});
|
|
1624
1632
|
}
|
|
1625
1633
|
/** Current user */
|
|
1626
1634
|
get user() {
|
|
@@ -1639,22 +1647,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1639
1647
|
*
|
|
1640
1648
|
* @return {Promise<User | null>}
|
|
1641
1649
|
*/
|
|
1642
|
-
async current(token = this.api.token
|
|
1650
|
+
async current(token = this.api.token) {
|
|
1643
1651
|
var _a;
|
|
1644
|
-
if (!token)
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
} else if (token == ((_a = this.user) == null ? void 0 : _a.token)) {
|
|
1648
|
-
return this.user;
|
|
1649
|
-
}
|
|
1650
|
-
return this.api.request({ "$/auth/current": {} }, { token }).then((resp) => {
|
|
1651
|
-
const u = (resp == null ? void 0 : resp.login) ? resp : null;
|
|
1652
|
-
if (set) {
|
|
1653
|
-
this.api.token = token;
|
|
1654
|
-
this.user = u;
|
|
1655
|
-
}
|
|
1656
|
-
return u;
|
|
1657
|
-
});
|
|
1652
|
+
if (!token) return null;
|
|
1653
|
+
else if (token == ((_a = this.user) == null ? void 0 : _a.token)) return this.user;
|
|
1654
|
+
return this.api.request({ "$/auth/current": {} }, { token }).then((resp) => (resp == null ? void 0 : resp.login) ? resp : null);
|
|
1658
1655
|
}
|
|
1659
1656
|
/**
|
|
1660
1657
|
* Automatically handle sessions by checking localStorage & URL parameters for a token & prompting
|
|
@@ -1741,7 +1738,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1741
1738
|
}).then(async (resp) => {
|
|
1742
1739
|
const data = await resp.json().catch(() => ({}));
|
|
1743
1740
|
if (!resp.ok || data["error"]) throw Object.assign(errorFromCode(resp.status, data.error) || {}, data);
|
|
1744
|
-
|
|
1741
|
+
this.api.token = data["token"];
|
|
1742
|
+
return data;
|
|
1745
1743
|
});
|
|
1746
1744
|
}
|
|
1747
1745
|
/**
|
|
@@ -1753,7 +1751,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1753
1751
|
return fetch(`${this.api.url}guest`).then(async (resp) => {
|
|
1754
1752
|
const data = await resp.json().catch(() => ({}));
|
|
1755
1753
|
if (!resp.ok || data["error"]) throw Object.assign(errorFromCode(resp.status, data.error) || {}, data);
|
|
1756
|
-
|
|
1754
|
+
this.api.token = data["token"];
|
|
1755
|
+
return data;
|
|
1757
1756
|
});
|
|
1758
1757
|
}
|
|
1759
1758
|
/**
|
|
@@ -1773,7 +1772,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1773
1772
|
*/
|
|
1774
1773
|
logout() {
|
|
1775
1774
|
return this.api.request({ "$/auth/logout": {} }).then((resp) => {
|
|
1776
|
-
this.api.token =
|
|
1775
|
+
this.api.token = null;
|
|
1777
1776
|
return resp;
|
|
1778
1777
|
});
|
|
1779
1778
|
}
|
|
@@ -2500,7 +2499,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2500
2499
|
} });
|
|
2501
2500
|
}
|
|
2502
2501
|
}
|
|
2503
|
-
const version = "1.0.
|
|
2502
|
+
const version = "1.0.12";
|
|
2504
2503
|
class Api {
|
|
2505
2504
|
/**
|
|
2506
2505
|
* Connect to Datalynk & send requests
|
|
@@ -2527,7 +2526,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2527
2526
|
/** Package version */
|
|
2528
2527
|
__publicField(this, "version", version);
|
|
2529
2528
|
/** API Session token */
|
|
2530
|
-
__publicField(this, "token$", new BehaviorSubject(
|
|
2529
|
+
__publicField(this, "token$", new BehaviorSubject(void 0));
|
|
2531
2530
|
/** Helpers */
|
|
2532
2531
|
/** Authentication */
|
|
2533
2532
|
__publicField(this, "auth", new Auth(this));
|
|
@@ -2548,10 +2547,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2548
2547
|
...options
|
|
2549
2548
|
};
|
|
2550
2549
|
if (this.options.saveSession) {
|
|
2551
|
-
|
|
2552
|
-
|
|
2550
|
+
if (localStorage == void 0) return;
|
|
2551
|
+
this.token = localStorage.getItem(this.localStorageKey) || null;
|
|
2553
2552
|
this.token$.pipe(distinctUntilChanged()).subscribe((token) => {
|
|
2554
|
-
if (localStorage == void 0) return;
|
|
2555
2553
|
if (token) localStorage.setItem(this.localStorageKey, token);
|
|
2556
2554
|
else localStorage.removeItem(this.localStorageKey);
|
|
2557
2555
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1353,19 +1353,21 @@ const _LoginPrompt = class _LoginPrompt {
|
|
|
1353
1353
|
background: "#ffffff",
|
|
1354
1354
|
color: "#c83232",
|
|
1355
1355
|
textColor: "#000000",
|
|
1356
|
-
...options
|
|
1356
|
+
...clean(options, true)
|
|
1357
1357
|
};
|
|
1358
1358
|
this.close();
|
|
1359
1359
|
document.head.innerHTML += _LoginPrompt.css(this.options);
|
|
1360
|
-
|
|
1360
|
+
const div = document.createElement("div");
|
|
1361
|
+
div.innerHTML = _LoginPrompt.template(this.options);
|
|
1362
|
+
document.body.appendChild(div);
|
|
1361
1363
|
this.alert = document.querySelector("#datalynk-login-alert");
|
|
1362
1364
|
this.button = document.querySelector("#datalynk-login-form button");
|
|
1363
1365
|
this.form = document.querySelector("#datalynk-login-form");
|
|
1364
1366
|
this.password = document.querySelector('#datalynk-login-form input[name="password"]');
|
|
1365
1367
|
this.persist = document.querySelector('#datalynk-login-form input[name="persist"]');
|
|
1366
1368
|
this.username = document.querySelector('#datalynk-login-form input[name="username"]');
|
|
1369
|
+
if (options.persist === false) this.persist.parentElement.remove();
|
|
1367
1370
|
this.form.onsubmit = (event) => this.login(event);
|
|
1368
|
-
if (options.persist === false) this.persist.parentElement.style.display = "none";
|
|
1369
1371
|
}
|
|
1370
1372
|
/** Close the login prompt */
|
|
1371
1373
|
close() {
|
|
@@ -1476,6 +1478,9 @@ __publicField(_LoginPrompt, "css", (options) => `
|
|
|
1476
1478
|
}
|
|
1477
1479
|
|
|
1478
1480
|
#datalynk-login .login-header {
|
|
1481
|
+
display: flex;
|
|
1482
|
+
justify-content: center;
|
|
1483
|
+
align-items: center;
|
|
1479
1484
|
color: var(--theme-text);
|
|
1480
1485
|
text-align: center;
|
|
1481
1486
|
font-size: 32px;
|
|
@@ -1530,6 +1535,7 @@ __publicField(_LoginPrompt, "css", (options) => `
|
|
|
1530
1535
|
}
|
|
1531
1536
|
|
|
1532
1537
|
#datalynk-login .login-links{
|
|
1538
|
+
display: flex;
|
|
1533
1539
|
padding: 0 0 1.5rem 0;
|
|
1534
1540
|
}
|
|
1535
1541
|
|
|
@@ -1562,7 +1568,7 @@ __publicField(_LoginPrompt, "css", (options) => `
|
|
|
1562
1568
|
__publicField(_LoginPrompt, "template", (options) => `
|
|
1563
1569
|
<div id="datalynk-login">
|
|
1564
1570
|
<div class="added-links">
|
|
1565
|
-
${(options.addLinks || []).map((link) => `<a href="${link.url}" target="_blank">${link.text}</a>`).join(" | ")}
|
|
1571
|
+
${(options.addLinks || []).map((link) => `<a href="${link.url || "#"}" target="_blank">${link.text}</a>`).join(" | ")}
|
|
1566
1572
|
</div>
|
|
1567
1573
|
<div class="login-container">
|
|
1568
1574
|
<div class="login-header">
|
|
@@ -1571,7 +1577,6 @@ __publicField(_LoginPrompt, "template", (options) => `
|
|
|
1571
1577
|
<div class="login-content">
|
|
1572
1578
|
<div class="login-body" style="max-width: 300px">
|
|
1573
1579
|
<div id="datalynk-login-alert" class="hidden"></div>
|
|
1574
|
-
|
|
1575
1580
|
<form id="datalynk-login-form">
|
|
1576
1581
|
<div>
|
|
1577
1582
|
<label for="username">Email or Username</label>
|
|
@@ -1586,7 +1591,7 @@ __publicField(_LoginPrompt, "template", (options) => `
|
|
|
1586
1591
|
<label style="display: block; margin-bottom: 0.75rem;">
|
|
1587
1592
|
<input type="checkbox" name="persist" style="width: 20px"> Stay Logged In
|
|
1588
1593
|
</label>
|
|
1589
|
-
<button>Login</button>
|
|
1594
|
+
<button type="submit">Login</button>
|
|
1590
1595
|
</form>
|
|
1591
1596
|
</div>
|
|
1592
1597
|
${options.hideApps ? "" : `
|
|
@@ -1616,7 +1621,10 @@ class Auth {
|
|
|
1616
1621
|
/** Current user as an observable */
|
|
1617
1622
|
__publicField(this, "user$", new BehaviorSubject(void 0));
|
|
1618
1623
|
this.api = api;
|
|
1619
|
-
this.api.token$.subscribe((token) =>
|
|
1624
|
+
this.api.token$.subscribe(async (token) => {
|
|
1625
|
+
if (token === void 0) return;
|
|
1626
|
+
this.user = await this.current(token);
|
|
1627
|
+
});
|
|
1620
1628
|
}
|
|
1621
1629
|
/** Current user */
|
|
1622
1630
|
get user() {
|
|
@@ -1635,22 +1643,11 @@ class Auth {
|
|
|
1635
1643
|
*
|
|
1636
1644
|
* @return {Promise<User | null>}
|
|
1637
1645
|
*/
|
|
1638
|
-
async current(token = this.api.token
|
|
1646
|
+
async current(token = this.api.token) {
|
|
1639
1647
|
var _a;
|
|
1640
|
-
if (!token)
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
} else if (token == ((_a = this.user) == null ? void 0 : _a.token)) {
|
|
1644
|
-
return this.user;
|
|
1645
|
-
}
|
|
1646
|
-
return this.api.request({ "$/auth/current": {} }, { token }).then((resp) => {
|
|
1647
|
-
const u = (resp == null ? void 0 : resp.login) ? resp : null;
|
|
1648
|
-
if (set) {
|
|
1649
|
-
this.api.token = token;
|
|
1650
|
-
this.user = u;
|
|
1651
|
-
}
|
|
1652
|
-
return u;
|
|
1653
|
-
});
|
|
1648
|
+
if (!token) return null;
|
|
1649
|
+
else if (token == ((_a = this.user) == null ? void 0 : _a.token)) return this.user;
|
|
1650
|
+
return this.api.request({ "$/auth/current": {} }, { token }).then((resp) => (resp == null ? void 0 : resp.login) ? resp : null);
|
|
1654
1651
|
}
|
|
1655
1652
|
/**
|
|
1656
1653
|
* Automatically handle sessions by checking localStorage & URL parameters for a token & prompting
|
|
@@ -1737,7 +1734,8 @@ class Auth {
|
|
|
1737
1734
|
}).then(async (resp) => {
|
|
1738
1735
|
const data = await resp.json().catch(() => ({}));
|
|
1739
1736
|
if (!resp.ok || data["error"]) throw Object.assign(errorFromCode(resp.status, data.error) || {}, data);
|
|
1740
|
-
|
|
1737
|
+
this.api.token = data["token"];
|
|
1738
|
+
return data;
|
|
1741
1739
|
});
|
|
1742
1740
|
}
|
|
1743
1741
|
/**
|
|
@@ -1749,7 +1747,8 @@ class Auth {
|
|
|
1749
1747
|
return fetch(`${this.api.url}guest`).then(async (resp) => {
|
|
1750
1748
|
const data = await resp.json().catch(() => ({}));
|
|
1751
1749
|
if (!resp.ok || data["error"]) throw Object.assign(errorFromCode(resp.status, data.error) || {}, data);
|
|
1752
|
-
|
|
1750
|
+
this.api.token = data["token"];
|
|
1751
|
+
return data;
|
|
1753
1752
|
});
|
|
1754
1753
|
}
|
|
1755
1754
|
/**
|
|
@@ -1769,7 +1768,7 @@ class Auth {
|
|
|
1769
1768
|
*/
|
|
1770
1769
|
logout() {
|
|
1771
1770
|
return this.api.request({ "$/auth/logout": {} }).then((resp) => {
|
|
1772
|
-
this.api.token =
|
|
1771
|
+
this.api.token = null;
|
|
1773
1772
|
return resp;
|
|
1774
1773
|
});
|
|
1775
1774
|
}
|
|
@@ -2496,7 +2495,7 @@ class Superuser {
|
|
|
2496
2495
|
} });
|
|
2497
2496
|
}
|
|
2498
2497
|
}
|
|
2499
|
-
const version = "1.0.
|
|
2498
|
+
const version = "1.0.12";
|
|
2500
2499
|
class Api {
|
|
2501
2500
|
/**
|
|
2502
2501
|
* Connect to Datalynk & send requests
|
|
@@ -2523,7 +2522,7 @@ class Api {
|
|
|
2523
2522
|
/** Package version */
|
|
2524
2523
|
__publicField(this, "version", version);
|
|
2525
2524
|
/** API Session token */
|
|
2526
|
-
__publicField(this, "token$", new BehaviorSubject(
|
|
2525
|
+
__publicField(this, "token$", new BehaviorSubject(void 0));
|
|
2527
2526
|
/** Helpers */
|
|
2528
2527
|
/** Authentication */
|
|
2529
2528
|
__publicField(this, "auth", new Auth(this));
|
|
@@ -2544,10 +2543,9 @@ class Api {
|
|
|
2544
2543
|
...options
|
|
2545
2544
|
};
|
|
2546
2545
|
if (this.options.saveSession) {
|
|
2547
|
-
|
|
2548
|
-
|
|
2546
|
+
if (localStorage == void 0) return;
|
|
2547
|
+
this.token = localStorage.getItem(this.localStorageKey) || null;
|
|
2549
2548
|
this.token$.pipe(distinctUntilChanged()).subscribe((token) => {
|
|
2550
|
-
if (localStorage == void 0) return;
|
|
2551
2549
|
if (token) localStorage.setItem(this.localStorageKey, token);
|
|
2552
2550
|
else localStorage.removeItem(this.localStorageKey);
|
|
2553
2551
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-prompt.d.ts","sourceRoot":"","sources":["../src/login-prompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC,MAAM,OAAO,CAAC;AAE1B,uCAAuC;AACvC,MAAM,MAAM,kBAAkB,GAAG;IAChC,+BAA+B;IAC/B,QAAQ,CAAC,EAAE;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC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CAAC,MAAM,CAAC,GAAG,CA0JR;IAEV,8BAA8B;IAC9B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAiDrB;IAEF,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAO;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAO;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAO;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAO;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAO;IAC/B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAO;IAEhC,SAAgB,OAAO,EAAG,kBAAkB,CAAC;IAE7C,OAAO,CAAC,KAAK,CAAY;IACzB,oDAAoD;IACpD,IAAI,gBAAmD;gBAE1B,GAAG,EAAE,GAAG,EAAkB,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB;IA0BtG,6BAA6B;IAC7B,KAAK;IAKL,0CAA0C;IAC1C,MAAM;IAIN,8BAA8B;IAC9B,KAAK,CAAC,KAAK,EAAE,GAAG;CA4BhB"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@auxilium/datalynk-client",
|
|
3
3
|
"description": "Datalynk client library",
|
|
4
4
|
"repository": "https://gitlab.auxiliumgroup.com/auxilium/datalynk/datalynk-client",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.12",
|
|
6
6
|
"author": "Zak Timson <zaktimson@gmail.com>",
|
|
7
7
|
"private": false,
|
|
8
8
|
"main": "./dist/index.cjs",
|