@auxilium/datalynk-client 1.0.10 → 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/README.md +5 -4
- 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 +128 -88
- package/dist/index.mjs +128 -88
- package/dist/login-prompt.d.ts +16 -9
- package/dist/login-prompt.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -184,12 +184,13 @@ This library comes with some logic to automatically handle the login flow & shou
|
|
|
184
184
|
2. It will check the localStorage for a saved token
|
|
185
185
|
3. It will prompt the user to login via UI
|
|
186
186
|
4. Reload page if token changed
|
|
187
|
+
|
|
187
188
|
```js
|
|
188
189
|
await api.auth.handleLogin('spoke', {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
background: 'url("...")', // CSS URL or hex color
|
|
191
|
+
color: '#ff0000', // hex color
|
|
192
|
+
title: '<img alt="logo" src="..." />', // text or HTML
|
|
193
|
+
textColor: '#ffffff' // Color of title text
|
|
193
194
|
});
|
|
194
195
|
```
|
|
195
196
|
|
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,MA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AAG,MAAM,CAAC;IACzB,gBAAgB;IAChB,QAAQ,CAAC,SAAS,YAAuB;IAEzC;;;;;;;;;;OAUG;gBACS,GAAG,EAAE,MAAM,EAAkB,OAAO,GAAE,UAAe;IAyBjE,OAAO,CAAC,QAAQ;IAqBhB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAsB9B;;;;OAIG;IACI,KAAK,CAAC,GAAG,QAAQ,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE;IAe9C;;;;OAIG;IACI,QAAQ,CAAC,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC;IAiB7C;;;;;;OAMG;IACI,KAAK,CAAC,CAAC,GAAG,GAAG,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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OAIG;IACG,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAOpC;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC;IAOtC;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAOrC;;;;;;;;OAQG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;KAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBzH;;;;OAIG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAS3B;;;;;;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
|
@@ -31,6 +31,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
31
31
|
return value2;
|
|
32
32
|
}, space);
|
|
33
33
|
}
|
|
34
|
+
function blackOrWhite(background) {
|
|
35
|
+
const exploded = background == null ? void 0 : background.match(background.length >= 6 ? /\w\w/g : /\w/g);
|
|
36
|
+
if (!exploded) return "black";
|
|
37
|
+
const [r2, g, b2] = exploded.map((hex) => parseInt(hex, 16));
|
|
38
|
+
const luminance = (0.299 * r2 + 0.587 * g + 0.114 * b2) / 255;
|
|
39
|
+
return luminance > 0.5 ? "black" : "white";
|
|
40
|
+
}
|
|
34
41
|
class PromiseProgress extends Promise {
|
|
35
42
|
constructor(executor) {
|
|
36
43
|
super((resolve, reject) => executor(
|
|
@@ -1337,6 +1344,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1337
1344
|
__publicField(this, "password");
|
|
1338
1345
|
__publicField(this, "persist");
|
|
1339
1346
|
__publicField(this, "username");
|
|
1347
|
+
__publicField(this, "options");
|
|
1340
1348
|
__publicField(this, "_done");
|
|
1341
1349
|
/** Promise which resolves once login is complete */
|
|
1342
1350
|
__publicField(this, "done", new Promise((res) => {
|
|
@@ -1344,21 +1352,28 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1344
1352
|
}));
|
|
1345
1353
|
this.api = api;
|
|
1346
1354
|
this.spoke = spoke;
|
|
1347
|
-
this.options =
|
|
1348
|
-
|
|
1349
|
-
|
|
1355
|
+
this.options = {
|
|
1356
|
+
title: this.spoke,
|
|
1357
|
+
background: "#ffffff",
|
|
1358
|
+
color: "#c83232",
|
|
1359
|
+
textColor: "#000000",
|
|
1360
|
+
...clean(options, true)
|
|
1361
|
+
};
|
|
1362
|
+
this.close();
|
|
1363
|
+
document.head.innerHTML += _LoginPrompt.css(this.options);
|
|
1364
|
+
const div = document.createElement("div");
|
|
1365
|
+
div.innerHTML = _LoginPrompt.template(this.options);
|
|
1366
|
+
document.body.appendChild(div);
|
|
1350
1367
|
this.alert = document.querySelector("#datalynk-login-alert");
|
|
1351
1368
|
this.button = document.querySelector("#datalynk-login-form button");
|
|
1352
1369
|
this.form = document.querySelector("#datalynk-login-form");
|
|
1353
1370
|
this.password = document.querySelector('#datalynk-login-form input[name="password"]');
|
|
1354
1371
|
this.persist = document.querySelector('#datalynk-login-form input[name="persist"]');
|
|
1355
1372
|
this.username = document.querySelector('#datalynk-login-form input[name="username"]');
|
|
1373
|
+
if (options.persist === false) this.persist.parentElement.remove();
|
|
1356
1374
|
this.form.onsubmit = (event) => this.login(event);
|
|
1357
|
-
if (options.persist === false) this.persist.parentElement.style.display = "none";
|
|
1358
1375
|
}
|
|
1359
|
-
/**
|
|
1360
|
-
* Close the login prompt
|
|
1361
|
-
*/
|
|
1376
|
+
/** Close the login prompt */
|
|
1362
1377
|
close() {
|
|
1363
1378
|
var _a, _b;
|
|
1364
1379
|
(_a = document.querySelector("#datalynk-login-css")) == null ? void 0 : _a.remove();
|
|
@@ -1398,14 +1413,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1398
1413
|
}
|
|
1399
1414
|
};
|
|
1400
1415
|
/** Dynamically create CSS style */
|
|
1401
|
-
__publicField(_LoginPrompt, "css", (
|
|
1416
|
+
__publicField(_LoginPrompt, "css", (options) => `
|
|
1402
1417
|
<style id="datalynk-login-styles">
|
|
1403
1418
|
@import url('https://fonts.cdnfonts.com/css/ar-blanca');
|
|
1404
1419
|
|
|
1405
1420
|
#datalynk-login {
|
|
1406
|
-
--theme-background: ${background};
|
|
1407
|
-
--theme-
|
|
1408
|
-
--theme-
|
|
1421
|
+
--theme-background: ${options.background};
|
|
1422
|
+
--theme-container: #000000cc;
|
|
1423
|
+
--theme-glow: ${options.glow || options.color};
|
|
1424
|
+
--theme-primary: ${options.color};
|
|
1425
|
+
--theme-text: ${options.textColor};;
|
|
1409
1426
|
|
|
1410
1427
|
position: fixed;
|
|
1411
1428
|
left: 0;
|
|
@@ -1418,6 +1435,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1418
1435
|
font-family: sans-serif;
|
|
1419
1436
|
z-index: 1000;
|
|
1420
1437
|
}
|
|
1438
|
+
|
|
1439
|
+
#datalynk-login .added-links {
|
|
1440
|
+
color: var(--theme-text);
|
|
1441
|
+
position: fixed;
|
|
1442
|
+
bottom: 0;
|
|
1443
|
+
right: 0;
|
|
1444
|
+
padding: 0.25rem;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
#datalynk-login .added-links a, #datalynk-login .added-links a:hover, #datalynk-login .added-links a:visited {
|
|
1448
|
+
color: var(--theme-text);
|
|
1449
|
+
text-shadow: 0 0 10px black;
|
|
1450
|
+
}
|
|
1421
1451
|
|
|
1422
1452
|
#datalynk-login-alert {
|
|
1423
1453
|
padding: 0.75rem;
|
|
@@ -1425,6 +1455,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1425
1455
|
color: white;
|
|
1426
1456
|
border-radius: 5px;
|
|
1427
1457
|
margin-bottom: 1rem;
|
|
1458
|
+
border: grey 1px solid;
|
|
1428
1459
|
}
|
|
1429
1460
|
|
|
1430
1461
|
#datalynk-login label {
|
|
@@ -1442,30 +1473,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1442
1473
|
color: black;
|
|
1443
1474
|
}
|
|
1444
1475
|
|
|
1445
|
-
#datalynk-login input:disabled {
|
|
1446
|
-
color: #333;
|
|
1447
|
-
background-color: #ccc;
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
#datalynk-login button {
|
|
1451
|
-
background-color: #e03a3e;
|
|
1452
|
-
background-image: none;
|
|
1453
|
-
border: 0;
|
|
1454
|
-
color: #fff;
|
|
1455
|
-
padding: 8px 24px;
|
|
1456
|
-
border-radius: 5px;
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
#datalynk-login button:disabled {
|
|
1460
|
-
cursor: pointer;
|
|
1461
|
-
filter: brightness(90%);
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1464
|
-
#datalynk-login button:hover:not(:disabled) {
|
|
1465
|
-
cursor: pointer;
|
|
1466
|
-
filter: brightness(110%);
|
|
1467
|
-
}
|
|
1468
|
-
|
|
1469
1476
|
#datalynk-login .login-container {
|
|
1470
1477
|
position: fixed;
|
|
1471
1478
|
top: 50%;
|
|
@@ -1475,7 +1482,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1475
1482
|
}
|
|
1476
1483
|
|
|
1477
1484
|
#datalynk-login .login-header {
|
|
1478
|
-
|
|
1485
|
+
display: flex;
|
|
1486
|
+
justify-content: center;
|
|
1487
|
+
align-items: center;
|
|
1488
|
+
color: var(--theme-text);
|
|
1479
1489
|
text-align: center;
|
|
1480
1490
|
font-size: 32px;
|
|
1481
1491
|
margin-bottom: 2rem;
|
|
@@ -1485,23 +1495,59 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1485
1495
|
display: flex;
|
|
1486
1496
|
flex-direction: column;
|
|
1487
1497
|
align-items: center;
|
|
1488
|
-
background: var(--theme-
|
|
1498
|
+
background: var(--theme-container);
|
|
1499
|
+
border-top: var(--theme-glow) 1px solid;
|
|
1500
|
+
box-shadow: 0 -10px 20px -10px var(--theme-glow);
|
|
1489
1501
|
}
|
|
1490
1502
|
|
|
1491
1503
|
#datalynk-login .login-body {
|
|
1492
|
-
padding: 3.5rem 0 0 0;
|
|
1504
|
+
padding: ${options.hideApps ? "3.5rem 0" : "3.5rem 0 1.5rem 0"};
|
|
1505
|
+
width: 100%;
|
|
1506
|
+
max-width: 400px;;
|
|
1493
1507
|
color: white;
|
|
1494
1508
|
}
|
|
1509
|
+
|
|
1510
|
+
#datalynk-login input:disabled {
|
|
1511
|
+
color: #333;
|
|
1512
|
+
background-color: #ccc;
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
#datalynk-login input[type="checkbox"] {
|
|
1516
|
+
height: 15px;
|
|
1517
|
+
margin: 0;
|
|
1518
|
+
padding: 0;
|
|
1519
|
+
accent-color: var(--theme-primary);
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
#datalynk-login button {
|
|
1523
|
+
background-color: var(--theme-primary);
|
|
1524
|
+
background-image: none;
|
|
1525
|
+
border: 0;
|
|
1526
|
+
color: ${blackOrWhite(options.color)};
|
|
1527
|
+
padding: 8px 24px;
|
|
1528
|
+
border-radius: 5px;
|
|
1529
|
+
}
|
|
1495
1530
|
|
|
1496
|
-
#datalynk-login
|
|
1497
|
-
|
|
1531
|
+
#datalynk-login button:disabled {
|
|
1532
|
+
cursor: pointer;
|
|
1533
|
+
filter: brightness(90%);
|
|
1498
1534
|
}
|
|
1499
1535
|
|
|
1500
|
-
#datalynk-login
|
|
1536
|
+
#datalynk-login button:hover:not(:disabled) {
|
|
1537
|
+
cursor: pointer;
|
|
1538
|
+
filter: ${blackOrWhite(options.color) == "black" ? "brightness(105%)" : "brightness(80%)"};
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
#datalynk-login .login-links{
|
|
1542
|
+
display: flex;
|
|
1543
|
+
padding: 0 0 1.5rem 0;
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
#datalynk-login .login-links a {
|
|
1501
1547
|
text-decoration: none;
|
|
1502
1548
|
}
|
|
1503
1549
|
|
|
1504
|
-
#datalynk-login .login-
|
|
1550
|
+
#datalynk-login .login-links img {
|
|
1505
1551
|
width: 150px;
|
|
1506
1552
|
height: auto;
|
|
1507
1553
|
}
|
|
@@ -1510,31 +1556,31 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1510
1556
|
display: none;
|
|
1511
1557
|
}
|
|
1512
1558
|
|
|
1559
|
+
#datalynk-login .login-footer {
|
|
1560
|
+
transform: translateY(-18px);
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1513
1563
|
#datalynk-login .sloped-div {
|
|
1514
|
-
margin-left:auto;
|
|
1515
|
-
margin-right: auto;
|
|
1516
|
-
display: inline-flex;
|
|
1517
|
-
padding: 0 3rem 0.5rem 3rem;
|
|
1518
|
-
justify-content: center;
|
|
1519
|
-
align-items: center;
|
|
1520
|
-
background: var(--theme-primary);
|
|
1521
|
-
clip-path: polygon(0 0, 100% 0, 80% 100%, 20% 100%);
|
|
1522
1564
|
position: absolute;
|
|
1523
|
-
|
|
1524
|
-
|
|
1565
|
+
height: 45px;
|
|
1566
|
+
width: 200px;
|
|
1567
|
+
background: var(--theme-container);
|
|
1568
|
+
clip-path: polygon(0 20px, 100% 20px, 85% 60px, 15% 60px);
|
|
1525
1569
|
}
|
|
1526
1570
|
</style>`);
|
|
1527
1571
|
/** Dynamically create HTML */
|
|
1528
|
-
__publicField(_LoginPrompt, "template", (
|
|
1572
|
+
__publicField(_LoginPrompt, "template", (options) => `
|
|
1529
1573
|
<div id="datalynk-login">
|
|
1574
|
+
<div class="added-links">
|
|
1575
|
+
${(options.addLinks || []).map((link) => `<a href="${link.url || "#"}" target="_blank">${link.text}</a>`).join(" | ")}
|
|
1576
|
+
</div>
|
|
1530
1577
|
<div class="login-container">
|
|
1531
1578
|
<div class="login-header">
|
|
1532
|
-
${title}
|
|
1579
|
+
${options.title}
|
|
1533
1580
|
</div>
|
|
1534
1581
|
<div class="login-content">
|
|
1535
1582
|
<div class="login-body" style="max-width: 300px">
|
|
1536
1583
|
<div id="datalynk-login-alert" class="hidden"></div>
|
|
1537
|
-
|
|
1538
1584
|
<form id="datalynk-login-form">
|
|
1539
1585
|
<div>
|
|
1540
1586
|
<label for="username">Email or Username</label>
|
|
@@ -1549,10 +1595,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1549
1595
|
<label style="display: block; margin-bottom: 0.75rem;">
|
|
1550
1596
|
<input type="checkbox" name="persist" style="width: 20px"> Stay Logged In
|
|
1551
1597
|
</label>
|
|
1552
|
-
<button>Login</button>
|
|
1598
|
+
<button type="submit">Login</button>
|
|
1553
1599
|
</form>
|
|
1554
1600
|
</div>
|
|
1555
|
-
|
|
1601
|
+
${options.hideApps ? "" : `
|
|
1602
|
+
<div class="login-links" style="text-align: center">
|
|
1556
1603
|
<a href="https://itunes.apple.com/ca/app/auxilium-mobile/id1166379280?mt=8" target="_blank">
|
|
1557
1604
|
<img alt="App Store" src="https://datalynk.auxiliumgroup.com/api/js/auxilium/dijits/templates/login/_common/mobile_apple_transparent.png">
|
|
1558
1605
|
</a>
|
|
@@ -1560,14 +1607,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1560
1607
|
<img alt="Playstore" src="https://datalynk.auxiliumgroup.com/api/js/auxilium/dijits/templates/login/_common/mobile_google_transparent.png">
|
|
1561
1608
|
</a>
|
|
1562
1609
|
</div>
|
|
1610
|
+
`}
|
|
1563
1611
|
</div>
|
|
1564
|
-
<div class="
|
|
1565
|
-
<div
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
</div>
|
|
1612
|
+
<div class="login-footer" style="position: relative; display: flex; align-items: center; justify-content: center;">
|
|
1613
|
+
<div class="sloped-div"></div>
|
|
1614
|
+
<a href="https://auxiliumgroup.com" target="_blank" style="position: relative; height: 40px; display: flex; align-items: center; text-decoration: none; font-family: 'AR BLANCA', serif; font-size: 26px; color: white;">
|
|
1615
|
+
Au<span style="font-size: 52px; color: #c83232; margin-bottom: 5px">x</span>ilium
|
|
1616
|
+
<span style="position: absolute; font-size: 10px; color: #c83232; top: 2px; right: 2px">Group</span>
|
|
1617
|
+
</a>
|
|
1571
1618
|
</div>
|
|
1572
1619
|
</div>
|
|
1573
1620
|
</div>
|
|
@@ -1578,7 +1625,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1578
1625
|
/** Current user as an observable */
|
|
1579
1626
|
__publicField(this, "user$", new BehaviorSubject(void 0));
|
|
1580
1627
|
this.api = api;
|
|
1581
|
-
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
|
+
});
|
|
1582
1632
|
}
|
|
1583
1633
|
/** Current user */
|
|
1584
1634
|
get user() {
|
|
@@ -1597,22 +1647,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1597
1647
|
*
|
|
1598
1648
|
* @return {Promise<User | null>}
|
|
1599
1649
|
*/
|
|
1600
|
-
async current(token = this.api.token
|
|
1650
|
+
async current(token = this.api.token) {
|
|
1601
1651
|
var _a;
|
|
1602
|
-
if (!token)
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
} else if (token == ((_a = this.user) == null ? void 0 : _a.token)) {
|
|
1606
|
-
return this.user;
|
|
1607
|
-
}
|
|
1608
|
-
return this.api.request({ "$/auth/current": {} }, { token }).then((resp) => {
|
|
1609
|
-
const u = (resp == null ? void 0 : resp.login) ? resp : null;
|
|
1610
|
-
if (set) {
|
|
1611
|
-
this.api.token = token;
|
|
1612
|
-
this.user = u;
|
|
1613
|
-
}
|
|
1614
|
-
return u;
|
|
1615
|
-
});
|
|
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);
|
|
1616
1655
|
}
|
|
1617
1656
|
/**
|
|
1618
1657
|
* Automatically handle sessions by checking localStorage & URL parameters for a token & prompting
|
|
@@ -1699,7 +1738,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1699
1738
|
}).then(async (resp) => {
|
|
1700
1739
|
const data = await resp.json().catch(() => ({}));
|
|
1701
1740
|
if (!resp.ok || data["error"]) throw Object.assign(errorFromCode(resp.status, data.error) || {}, data);
|
|
1702
|
-
|
|
1741
|
+
this.api.token = data["token"];
|
|
1742
|
+
return data;
|
|
1703
1743
|
});
|
|
1704
1744
|
}
|
|
1705
1745
|
/**
|
|
@@ -1711,7 +1751,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1711
1751
|
return fetch(`${this.api.url}guest`).then(async (resp) => {
|
|
1712
1752
|
const data = await resp.json().catch(() => ({}));
|
|
1713
1753
|
if (!resp.ok || data["error"]) throw Object.assign(errorFromCode(resp.status, data.error) || {}, data);
|
|
1714
|
-
|
|
1754
|
+
this.api.token = data["token"];
|
|
1755
|
+
return data;
|
|
1715
1756
|
});
|
|
1716
1757
|
}
|
|
1717
1758
|
/**
|
|
@@ -1731,7 +1772,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
1731
1772
|
*/
|
|
1732
1773
|
logout() {
|
|
1733
1774
|
return this.api.request({ "$/auth/logout": {} }).then((resp) => {
|
|
1734
|
-
this.api.token =
|
|
1775
|
+
this.api.token = null;
|
|
1735
1776
|
return resp;
|
|
1736
1777
|
});
|
|
1737
1778
|
}
|
|
@@ -2458,7 +2499,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2458
2499
|
} });
|
|
2459
2500
|
}
|
|
2460
2501
|
}
|
|
2461
|
-
const version = "1.0.
|
|
2502
|
+
const version = "1.0.12";
|
|
2462
2503
|
class Api {
|
|
2463
2504
|
/**
|
|
2464
2505
|
* Connect to Datalynk & send requests
|
|
@@ -2485,7 +2526,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2485
2526
|
/** Package version */
|
|
2486
2527
|
__publicField(this, "version", version);
|
|
2487
2528
|
/** API Session token */
|
|
2488
|
-
__publicField(this, "token$", new BehaviorSubject(
|
|
2529
|
+
__publicField(this, "token$", new BehaviorSubject(void 0));
|
|
2489
2530
|
/** Helpers */
|
|
2490
2531
|
/** Authentication */
|
|
2491
2532
|
__publicField(this, "auth", new Auth(this));
|
|
@@ -2506,10 +2547,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
2506
2547
|
...options
|
|
2507
2548
|
};
|
|
2508
2549
|
if (this.options.saveSession) {
|
|
2509
|
-
|
|
2510
|
-
|
|
2550
|
+
if (localStorage == void 0) return;
|
|
2551
|
+
this.token = localStorage.getItem(this.localStorageKey) || null;
|
|
2511
2552
|
this.token$.pipe(distinctUntilChanged()).subscribe((token) => {
|
|
2512
|
-
if (localStorage == void 0) return;
|
|
2513
2553
|
if (token) localStorage.setItem(this.localStorageKey, token);
|
|
2514
2554
|
else localStorage.removeItem(this.localStorageKey);
|
|
2515
2555
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -27,6 +27,13 @@ function JSONSanitize(obj, space) {
|
|
|
27
27
|
return value2;
|
|
28
28
|
}, space);
|
|
29
29
|
}
|
|
30
|
+
function blackOrWhite(background) {
|
|
31
|
+
const exploded = background == null ? void 0 : background.match(background.length >= 6 ? /\w\w/g : /\w/g);
|
|
32
|
+
if (!exploded) return "black";
|
|
33
|
+
const [r2, g, b2] = exploded.map((hex) => parseInt(hex, 16));
|
|
34
|
+
const luminance = (0.299 * r2 + 0.587 * g + 0.114 * b2) / 255;
|
|
35
|
+
return luminance > 0.5 ? "black" : "white";
|
|
36
|
+
}
|
|
30
37
|
class PromiseProgress extends Promise {
|
|
31
38
|
constructor(executor) {
|
|
32
39
|
super((resolve, reject) => executor(
|
|
@@ -1333,6 +1340,7 @@ const _LoginPrompt = class _LoginPrompt {
|
|
|
1333
1340
|
__publicField(this, "password");
|
|
1334
1341
|
__publicField(this, "persist");
|
|
1335
1342
|
__publicField(this, "username");
|
|
1343
|
+
__publicField(this, "options");
|
|
1336
1344
|
__publicField(this, "_done");
|
|
1337
1345
|
/** Promise which resolves once login is complete */
|
|
1338
1346
|
__publicField(this, "done", new Promise((res) => {
|
|
@@ -1340,21 +1348,28 @@ const _LoginPrompt = class _LoginPrompt {
|
|
|
1340
1348
|
}));
|
|
1341
1349
|
this.api = api;
|
|
1342
1350
|
this.spoke = spoke;
|
|
1343
|
-
this.options =
|
|
1344
|
-
|
|
1345
|
-
|
|
1351
|
+
this.options = {
|
|
1352
|
+
title: this.spoke,
|
|
1353
|
+
background: "#ffffff",
|
|
1354
|
+
color: "#c83232",
|
|
1355
|
+
textColor: "#000000",
|
|
1356
|
+
...clean(options, true)
|
|
1357
|
+
};
|
|
1358
|
+
this.close();
|
|
1359
|
+
document.head.innerHTML += _LoginPrompt.css(this.options);
|
|
1360
|
+
const div = document.createElement("div");
|
|
1361
|
+
div.innerHTML = _LoginPrompt.template(this.options);
|
|
1362
|
+
document.body.appendChild(div);
|
|
1346
1363
|
this.alert = document.querySelector("#datalynk-login-alert");
|
|
1347
1364
|
this.button = document.querySelector("#datalynk-login-form button");
|
|
1348
1365
|
this.form = document.querySelector("#datalynk-login-form");
|
|
1349
1366
|
this.password = document.querySelector('#datalynk-login-form input[name="password"]');
|
|
1350
1367
|
this.persist = document.querySelector('#datalynk-login-form input[name="persist"]');
|
|
1351
1368
|
this.username = document.querySelector('#datalynk-login-form input[name="username"]');
|
|
1369
|
+
if (options.persist === false) this.persist.parentElement.remove();
|
|
1352
1370
|
this.form.onsubmit = (event) => this.login(event);
|
|
1353
|
-
if (options.persist === false) this.persist.parentElement.style.display = "none";
|
|
1354
1371
|
}
|
|
1355
|
-
/**
|
|
1356
|
-
* Close the login prompt
|
|
1357
|
-
*/
|
|
1372
|
+
/** Close the login prompt */
|
|
1358
1373
|
close() {
|
|
1359
1374
|
var _a, _b;
|
|
1360
1375
|
(_a = document.querySelector("#datalynk-login-css")) == null ? void 0 : _a.remove();
|
|
@@ -1394,14 +1409,16 @@ const _LoginPrompt = class _LoginPrompt {
|
|
|
1394
1409
|
}
|
|
1395
1410
|
};
|
|
1396
1411
|
/** Dynamically create CSS style */
|
|
1397
|
-
__publicField(_LoginPrompt, "css", (
|
|
1412
|
+
__publicField(_LoginPrompt, "css", (options) => `
|
|
1398
1413
|
<style id="datalynk-login-styles">
|
|
1399
1414
|
@import url('https://fonts.cdnfonts.com/css/ar-blanca');
|
|
1400
1415
|
|
|
1401
1416
|
#datalynk-login {
|
|
1402
|
-
--theme-background: ${background};
|
|
1403
|
-
--theme-
|
|
1404
|
-
--theme-
|
|
1417
|
+
--theme-background: ${options.background};
|
|
1418
|
+
--theme-container: #000000cc;
|
|
1419
|
+
--theme-glow: ${options.glow || options.color};
|
|
1420
|
+
--theme-primary: ${options.color};
|
|
1421
|
+
--theme-text: ${options.textColor};;
|
|
1405
1422
|
|
|
1406
1423
|
position: fixed;
|
|
1407
1424
|
left: 0;
|
|
@@ -1414,6 +1431,19 @@ __publicField(_LoginPrompt, "css", (background = "#ffffff", color = "#000000cc",
|
|
|
1414
1431
|
font-family: sans-serif;
|
|
1415
1432
|
z-index: 1000;
|
|
1416
1433
|
}
|
|
1434
|
+
|
|
1435
|
+
#datalynk-login .added-links {
|
|
1436
|
+
color: var(--theme-text);
|
|
1437
|
+
position: fixed;
|
|
1438
|
+
bottom: 0;
|
|
1439
|
+
right: 0;
|
|
1440
|
+
padding: 0.25rem;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
#datalynk-login .added-links a, #datalynk-login .added-links a:hover, #datalynk-login .added-links a:visited {
|
|
1444
|
+
color: var(--theme-text);
|
|
1445
|
+
text-shadow: 0 0 10px black;
|
|
1446
|
+
}
|
|
1417
1447
|
|
|
1418
1448
|
#datalynk-login-alert {
|
|
1419
1449
|
padding: 0.75rem;
|
|
@@ -1421,6 +1451,7 @@ __publicField(_LoginPrompt, "css", (background = "#ffffff", color = "#000000cc",
|
|
|
1421
1451
|
color: white;
|
|
1422
1452
|
border-radius: 5px;
|
|
1423
1453
|
margin-bottom: 1rem;
|
|
1454
|
+
border: grey 1px solid;
|
|
1424
1455
|
}
|
|
1425
1456
|
|
|
1426
1457
|
#datalynk-login label {
|
|
@@ -1438,30 +1469,6 @@ __publicField(_LoginPrompt, "css", (background = "#ffffff", color = "#000000cc",
|
|
|
1438
1469
|
color: black;
|
|
1439
1470
|
}
|
|
1440
1471
|
|
|
1441
|
-
#datalynk-login input:disabled {
|
|
1442
|
-
color: #333;
|
|
1443
|
-
background-color: #ccc;
|
|
1444
|
-
}
|
|
1445
|
-
|
|
1446
|
-
#datalynk-login button {
|
|
1447
|
-
background-color: #e03a3e;
|
|
1448
|
-
background-image: none;
|
|
1449
|
-
border: 0;
|
|
1450
|
-
color: #fff;
|
|
1451
|
-
padding: 8px 24px;
|
|
1452
|
-
border-radius: 5px;
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
#datalynk-login button:disabled {
|
|
1456
|
-
cursor: pointer;
|
|
1457
|
-
filter: brightness(90%);
|
|
1458
|
-
}
|
|
1459
|
-
|
|
1460
|
-
#datalynk-login button:hover:not(:disabled) {
|
|
1461
|
-
cursor: pointer;
|
|
1462
|
-
filter: brightness(110%);
|
|
1463
|
-
}
|
|
1464
|
-
|
|
1465
1472
|
#datalynk-login .login-container {
|
|
1466
1473
|
position: fixed;
|
|
1467
1474
|
top: 50%;
|
|
@@ -1471,7 +1478,10 @@ __publicField(_LoginPrompt, "css", (background = "#ffffff", color = "#000000cc",
|
|
|
1471
1478
|
}
|
|
1472
1479
|
|
|
1473
1480
|
#datalynk-login .login-header {
|
|
1474
|
-
|
|
1481
|
+
display: flex;
|
|
1482
|
+
justify-content: center;
|
|
1483
|
+
align-items: center;
|
|
1484
|
+
color: var(--theme-text);
|
|
1475
1485
|
text-align: center;
|
|
1476
1486
|
font-size: 32px;
|
|
1477
1487
|
margin-bottom: 2rem;
|
|
@@ -1481,23 +1491,59 @@ __publicField(_LoginPrompt, "css", (background = "#ffffff", color = "#000000cc",
|
|
|
1481
1491
|
display: flex;
|
|
1482
1492
|
flex-direction: column;
|
|
1483
1493
|
align-items: center;
|
|
1484
|
-
background: var(--theme-
|
|
1494
|
+
background: var(--theme-container);
|
|
1495
|
+
border-top: var(--theme-glow) 1px solid;
|
|
1496
|
+
box-shadow: 0 -10px 20px -10px var(--theme-glow);
|
|
1485
1497
|
}
|
|
1486
1498
|
|
|
1487
1499
|
#datalynk-login .login-body {
|
|
1488
|
-
padding: 3.5rem 0 0 0;
|
|
1500
|
+
padding: ${options.hideApps ? "3.5rem 0" : "3.5rem 0 1.5rem 0"};
|
|
1501
|
+
width: 100%;
|
|
1502
|
+
max-width: 400px;;
|
|
1489
1503
|
color: white;
|
|
1490
1504
|
}
|
|
1505
|
+
|
|
1506
|
+
#datalynk-login input:disabled {
|
|
1507
|
+
color: #333;
|
|
1508
|
+
background-color: #ccc;
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
#datalynk-login input[type="checkbox"] {
|
|
1512
|
+
height: 15px;
|
|
1513
|
+
margin: 0;
|
|
1514
|
+
padding: 0;
|
|
1515
|
+
accent-color: var(--theme-primary);
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
#datalynk-login button {
|
|
1519
|
+
background-color: var(--theme-primary);
|
|
1520
|
+
background-image: none;
|
|
1521
|
+
border: 0;
|
|
1522
|
+
color: ${blackOrWhite(options.color)};
|
|
1523
|
+
padding: 8px 24px;
|
|
1524
|
+
border-radius: 5px;
|
|
1525
|
+
}
|
|
1491
1526
|
|
|
1492
|
-
#datalynk-login
|
|
1493
|
-
|
|
1527
|
+
#datalynk-login button:disabled {
|
|
1528
|
+
cursor: pointer;
|
|
1529
|
+
filter: brightness(90%);
|
|
1494
1530
|
}
|
|
1495
1531
|
|
|
1496
|
-
#datalynk-login
|
|
1532
|
+
#datalynk-login button:hover:not(:disabled) {
|
|
1533
|
+
cursor: pointer;
|
|
1534
|
+
filter: ${blackOrWhite(options.color) == "black" ? "brightness(105%)" : "brightness(80%)"};
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
#datalynk-login .login-links{
|
|
1538
|
+
display: flex;
|
|
1539
|
+
padding: 0 0 1.5rem 0;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
#datalynk-login .login-links a {
|
|
1497
1543
|
text-decoration: none;
|
|
1498
1544
|
}
|
|
1499
1545
|
|
|
1500
|
-
#datalynk-login .login-
|
|
1546
|
+
#datalynk-login .login-links img {
|
|
1501
1547
|
width: 150px;
|
|
1502
1548
|
height: auto;
|
|
1503
1549
|
}
|
|
@@ -1506,31 +1552,31 @@ __publicField(_LoginPrompt, "css", (background = "#ffffff", color = "#000000cc",
|
|
|
1506
1552
|
display: none;
|
|
1507
1553
|
}
|
|
1508
1554
|
|
|
1555
|
+
#datalynk-login .login-footer {
|
|
1556
|
+
transform: translateY(-18px);
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1509
1559
|
#datalynk-login .sloped-div {
|
|
1510
|
-
margin-left:auto;
|
|
1511
|
-
margin-right: auto;
|
|
1512
|
-
display: inline-flex;
|
|
1513
|
-
padding: 0 3rem 0.5rem 3rem;
|
|
1514
|
-
justify-content: center;
|
|
1515
|
-
align-items: center;
|
|
1516
|
-
background: var(--theme-primary);
|
|
1517
|
-
clip-path: polygon(0 0, 100% 0, 80% 100%, 20% 100%);
|
|
1518
1560
|
position: absolute;
|
|
1519
|
-
|
|
1520
|
-
|
|
1561
|
+
height: 45px;
|
|
1562
|
+
width: 200px;
|
|
1563
|
+
background: var(--theme-container);
|
|
1564
|
+
clip-path: polygon(0 20px, 100% 20px, 85% 60px, 15% 60px);
|
|
1521
1565
|
}
|
|
1522
1566
|
</style>`);
|
|
1523
1567
|
/** Dynamically create HTML */
|
|
1524
|
-
__publicField(_LoginPrompt, "template", (
|
|
1568
|
+
__publicField(_LoginPrompt, "template", (options) => `
|
|
1525
1569
|
<div id="datalynk-login">
|
|
1570
|
+
<div class="added-links">
|
|
1571
|
+
${(options.addLinks || []).map((link) => `<a href="${link.url || "#"}" target="_blank">${link.text}</a>`).join(" | ")}
|
|
1572
|
+
</div>
|
|
1526
1573
|
<div class="login-container">
|
|
1527
1574
|
<div class="login-header">
|
|
1528
|
-
${title}
|
|
1575
|
+
${options.title}
|
|
1529
1576
|
</div>
|
|
1530
1577
|
<div class="login-content">
|
|
1531
1578
|
<div class="login-body" style="max-width: 300px">
|
|
1532
1579
|
<div id="datalynk-login-alert" class="hidden"></div>
|
|
1533
|
-
|
|
1534
1580
|
<form id="datalynk-login-form">
|
|
1535
1581
|
<div>
|
|
1536
1582
|
<label for="username">Email or Username</label>
|
|
@@ -1545,10 +1591,11 @@ __publicField(_LoginPrompt, "template", (title = "Datalynk") => `
|
|
|
1545
1591
|
<label style="display: block; margin-bottom: 0.75rem;">
|
|
1546
1592
|
<input type="checkbox" name="persist" style="width: 20px"> Stay Logged In
|
|
1547
1593
|
</label>
|
|
1548
|
-
<button>Login</button>
|
|
1594
|
+
<button type="submit">Login</button>
|
|
1549
1595
|
</form>
|
|
1550
1596
|
</div>
|
|
1551
|
-
|
|
1597
|
+
${options.hideApps ? "" : `
|
|
1598
|
+
<div class="login-links" style="text-align: center">
|
|
1552
1599
|
<a href="https://itunes.apple.com/ca/app/auxilium-mobile/id1166379280?mt=8" target="_blank">
|
|
1553
1600
|
<img alt="App Store" src="https://datalynk.auxiliumgroup.com/api/js/auxilium/dijits/templates/login/_common/mobile_apple_transparent.png">
|
|
1554
1601
|
</a>
|
|
@@ -1556,14 +1603,14 @@ __publicField(_LoginPrompt, "template", (title = "Datalynk") => `
|
|
|
1556
1603
|
<img alt="Playstore" src="https://datalynk.auxiliumgroup.com/api/js/auxilium/dijits/templates/login/_common/mobile_google_transparent.png">
|
|
1557
1604
|
</a>
|
|
1558
1605
|
</div>
|
|
1606
|
+
`}
|
|
1559
1607
|
</div>
|
|
1560
|
-
<div class="
|
|
1561
|
-
<div
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
</div>
|
|
1608
|
+
<div class="login-footer" style="position: relative; display: flex; align-items: center; justify-content: center;">
|
|
1609
|
+
<div class="sloped-div"></div>
|
|
1610
|
+
<a href="https://auxiliumgroup.com" target="_blank" style="position: relative; height: 40px; display: flex; align-items: center; text-decoration: none; font-family: 'AR BLANCA', serif; font-size: 26px; color: white;">
|
|
1611
|
+
Au<span style="font-size: 52px; color: #c83232; margin-bottom: 5px">x</span>ilium
|
|
1612
|
+
<span style="position: absolute; font-size: 10px; color: #c83232; top: 2px; right: 2px">Group</span>
|
|
1613
|
+
</a>
|
|
1567
1614
|
</div>
|
|
1568
1615
|
</div>
|
|
1569
1616
|
</div>
|
|
@@ -1574,7 +1621,10 @@ class Auth {
|
|
|
1574
1621
|
/** Current user as an observable */
|
|
1575
1622
|
__publicField(this, "user$", new BehaviorSubject(void 0));
|
|
1576
1623
|
this.api = api;
|
|
1577
|
-
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
|
+
});
|
|
1578
1628
|
}
|
|
1579
1629
|
/** Current user */
|
|
1580
1630
|
get user() {
|
|
@@ -1593,22 +1643,11 @@ class Auth {
|
|
|
1593
1643
|
*
|
|
1594
1644
|
* @return {Promise<User | null>}
|
|
1595
1645
|
*/
|
|
1596
|
-
async current(token = this.api.token
|
|
1646
|
+
async current(token = this.api.token) {
|
|
1597
1647
|
var _a;
|
|
1598
|
-
if (!token)
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
} else if (token == ((_a = this.user) == null ? void 0 : _a.token)) {
|
|
1602
|
-
return this.user;
|
|
1603
|
-
}
|
|
1604
|
-
return this.api.request({ "$/auth/current": {} }, { token }).then((resp) => {
|
|
1605
|
-
const u = (resp == null ? void 0 : resp.login) ? resp : null;
|
|
1606
|
-
if (set) {
|
|
1607
|
-
this.api.token = token;
|
|
1608
|
-
this.user = u;
|
|
1609
|
-
}
|
|
1610
|
-
return u;
|
|
1611
|
-
});
|
|
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);
|
|
1612
1651
|
}
|
|
1613
1652
|
/**
|
|
1614
1653
|
* Automatically handle sessions by checking localStorage & URL parameters for a token & prompting
|
|
@@ -1695,7 +1734,8 @@ class Auth {
|
|
|
1695
1734
|
}).then(async (resp) => {
|
|
1696
1735
|
const data = await resp.json().catch(() => ({}));
|
|
1697
1736
|
if (!resp.ok || data["error"]) throw Object.assign(errorFromCode(resp.status, data.error) || {}, data);
|
|
1698
|
-
|
|
1737
|
+
this.api.token = data["token"];
|
|
1738
|
+
return data;
|
|
1699
1739
|
});
|
|
1700
1740
|
}
|
|
1701
1741
|
/**
|
|
@@ -1707,7 +1747,8 @@ class Auth {
|
|
|
1707
1747
|
return fetch(`${this.api.url}guest`).then(async (resp) => {
|
|
1708
1748
|
const data = await resp.json().catch(() => ({}));
|
|
1709
1749
|
if (!resp.ok || data["error"]) throw Object.assign(errorFromCode(resp.status, data.error) || {}, data);
|
|
1710
|
-
|
|
1750
|
+
this.api.token = data["token"];
|
|
1751
|
+
return data;
|
|
1711
1752
|
});
|
|
1712
1753
|
}
|
|
1713
1754
|
/**
|
|
@@ -1727,7 +1768,7 @@ class Auth {
|
|
|
1727
1768
|
*/
|
|
1728
1769
|
logout() {
|
|
1729
1770
|
return this.api.request({ "$/auth/logout": {} }).then((resp) => {
|
|
1730
|
-
this.api.token =
|
|
1771
|
+
this.api.token = null;
|
|
1731
1772
|
return resp;
|
|
1732
1773
|
});
|
|
1733
1774
|
}
|
|
@@ -2454,7 +2495,7 @@ class Superuser {
|
|
|
2454
2495
|
} });
|
|
2455
2496
|
}
|
|
2456
2497
|
}
|
|
2457
|
-
const version = "1.0.
|
|
2498
|
+
const version = "1.0.12";
|
|
2458
2499
|
class Api {
|
|
2459
2500
|
/**
|
|
2460
2501
|
* Connect to Datalynk & send requests
|
|
@@ -2481,7 +2522,7 @@ class Api {
|
|
|
2481
2522
|
/** Package version */
|
|
2482
2523
|
__publicField(this, "version", version);
|
|
2483
2524
|
/** API Session token */
|
|
2484
|
-
__publicField(this, "token$", new BehaviorSubject(
|
|
2525
|
+
__publicField(this, "token$", new BehaviorSubject(void 0));
|
|
2485
2526
|
/** Helpers */
|
|
2486
2527
|
/** Authentication */
|
|
2487
2528
|
__publicField(this, "auth", new Auth(this));
|
|
@@ -2502,10 +2543,9 @@ class Api {
|
|
|
2502
2543
|
...options
|
|
2503
2544
|
};
|
|
2504
2545
|
if (this.options.saveSession) {
|
|
2505
|
-
|
|
2506
|
-
|
|
2546
|
+
if (localStorage == void 0) return;
|
|
2547
|
+
this.token = localStorage.getItem(this.localStorageKey) || null;
|
|
2507
2548
|
this.token$.pipe(distinctUntilChanged()).subscribe((token) => {
|
|
2508
|
-
if (localStorage == void 0) return;
|
|
2509
2549
|
if (token) localStorage.setItem(this.localStorageKey, token);
|
|
2510
2550
|
else localStorage.removeItem(this.localStorageKey);
|
|
2511
2551
|
});
|
package/dist/login-prompt.d.ts
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
import { Api } from './api';
|
|
2
2
|
/** Styling options for login prompt */
|
|
3
3
|
export type LoginPromptOptions = {
|
|
4
|
-
/**
|
|
4
|
+
/** Add links to top of page */
|
|
5
|
+
addLinks?: {
|
|
6
|
+
text: string;
|
|
7
|
+
url: string;
|
|
8
|
+
}[];
|
|
9
|
+
/** Background CSS property: url("...") #fff */
|
|
5
10
|
background?: string;
|
|
6
|
-
/**
|
|
11
|
+
/** Primary color as hex: `#000000` */
|
|
7
12
|
color?: string;
|
|
13
|
+
/** Change glow color, defaults to color or set to falsy to disable */
|
|
14
|
+
glow?: string;
|
|
15
|
+
/** Hide app links */
|
|
16
|
+
hideApps?: boolean;
|
|
8
17
|
/** Allow users to stay logged in */
|
|
9
18
|
persist?: boolean;
|
|
10
|
-
/** Header
|
|
19
|
+
/** Header string or HTML: <img alt="logo" src="...">*/
|
|
11
20
|
title?: string;
|
|
12
|
-
/**
|
|
13
|
-
|
|
21
|
+
/** Color of headers & links */
|
|
22
|
+
textColor?: string;
|
|
14
23
|
};
|
|
15
24
|
/** Create a login prompt */
|
|
16
25
|
export declare class LoginPrompt {
|
|
17
26
|
private readonly api;
|
|
18
27
|
readonly spoke: string;
|
|
19
|
-
options: LoginPromptOptions;
|
|
20
28
|
/** Dynamically create CSS style */
|
|
21
29
|
private static css;
|
|
22
30
|
/** Dynamically create HTML */
|
|
@@ -27,13 +35,12 @@ export declare class LoginPrompt {
|
|
|
27
35
|
private readonly password;
|
|
28
36
|
private readonly persist;
|
|
29
37
|
private readonly username;
|
|
38
|
+
readonly options: LoginPromptOptions;
|
|
30
39
|
private _done;
|
|
31
40
|
/** Promise which resolves once login is complete */
|
|
32
41
|
done: Promise<void>;
|
|
33
42
|
constructor(api: Api, spoke: string, options?: LoginPromptOptions);
|
|
34
|
-
/**
|
|
35
|
-
* Close the login prompt
|
|
36
|
-
*/
|
|
43
|
+
/** Close the login prompt */
|
|
37
44
|
close(): void;
|
|
38
45
|
/** Check if login prompt is still open */
|
|
39
46
|
isOpen(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-prompt.d.ts","sourceRoot":"","sources":["../src/login-prompt.ts"],"names":[],"mappings":"
|
|
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,GAAG,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;IACzC,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oCAAoC;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,CAAA;AAED,4BAA4B;AAC5B,qBAAa,WAAW;IA+NX,OAAO,CAAC,QAAQ,CAAC,GAAG;aAAuB,KAAK,EAAE,MAAM;IA9NpE,mCAAmC;IACnC,OAAO,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",
|