@auxilium/datalynk-client 1.0.11 → 1.0.13

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 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;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,wDAAwD;IACxD,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;CACxB,CAAA;AAED;;GAE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;;;;;;;;;;;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, set?: boolean): Promise<null | User>;
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
@@ -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,CAAC;IACd,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;CACd,CAAA;AAED;;GAEG;AACH,qBAAa,IAAI;IAUJ,OAAO,CAAC,QAAQ,CAAC,GAAG;IAThC,oCAAoC;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 -1315,6 +1315,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1315
1315
  };
1316
1316
  return BehaviorSubject2;
1317
1317
  }(Subject);
1318
+ function filter(predicate, thisArg) {
1319
+ return operate(function(source, subscriber) {
1320
+ var index = 0;
1321
+ source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1322
+ return predicate.call(thisArg, value, index++) && subscriber.next(value);
1323
+ }));
1324
+ });
1325
+ }
1318
1326
  function distinctUntilChanged(comparator, keySelector) {
1319
1327
  if (keySelector === void 0) {
1320
1328
  keySelector = identity;
@@ -1357,19 +1365,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1357
1365
  background: "#ffffff",
1358
1366
  color: "#c83232",
1359
1367
  textColor: "#000000",
1360
- ...options
1368
+ ...clean(options, true)
1361
1369
  };
1362
1370
  this.close();
1363
1371
  document.head.innerHTML += _LoginPrompt.css(this.options);
1364
- document.body.innerHTML += _LoginPrompt.template(this.options);
1372
+ const div = document.createElement("div");
1373
+ div.innerHTML = _LoginPrompt.template(this.options);
1374
+ document.body.appendChild(div);
1365
1375
  this.alert = document.querySelector("#datalynk-login-alert");
1366
1376
  this.button = document.querySelector("#datalynk-login-form button");
1367
1377
  this.form = document.querySelector("#datalynk-login-form");
1368
1378
  this.password = document.querySelector('#datalynk-login-form input[name="password"]');
1369
1379
  this.persist = document.querySelector('#datalynk-login-form input[name="persist"]');
1370
1380
  this.username = document.querySelector('#datalynk-login-form input[name="username"]');
1381
+ if (options.persist === false) this.persist.parentElement.remove();
1371
1382
  this.form.onsubmit = (event) => this.login(event);
1372
- if (options.persist === false) this.persist.parentElement.style.display = "none";
1373
1383
  }
1374
1384
  /** Close the login prompt */
1375
1385
  close() {
@@ -1480,6 +1490,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1480
1490
  }
1481
1491
 
1482
1492
  #datalynk-login .login-header {
1493
+ display: flex;
1494
+ justify-content: center;
1495
+ align-items: center;
1483
1496
  color: var(--theme-text);
1484
1497
  text-align: center;
1485
1498
  font-size: 32px;
@@ -1534,6 +1547,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1534
1547
  }
1535
1548
 
1536
1549
  #datalynk-login .login-links{
1550
+ display: flex;
1537
1551
  padding: 0 0 1.5rem 0;
1538
1552
  }
1539
1553
 
@@ -1566,7 +1580,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1566
1580
  __publicField(_LoginPrompt, "template", (options) => `
1567
1581
  <div id="datalynk-login">
1568
1582
  <div class="added-links">
1569
- ${(options.addLinks || []).map((link) => `<a href="${link.url}" target="_blank">${link.text}</a>`).join(" | ")}
1583
+ ${(options.addLinks || []).map((link) => `<a href="${link.url || "#"}" target="_blank">${link.text}</a>`).join(" | ")}
1570
1584
  </div>
1571
1585
  <div class="login-container">
1572
1586
  <div class="login-header">
@@ -1575,7 +1589,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1575
1589
  <div class="login-content">
1576
1590
  <div class="login-body" style="max-width: 300px">
1577
1591
  <div id="datalynk-login-alert" class="hidden"></div>
1578
-
1579
1592
  <form id="datalynk-login-form">
1580
1593
  <div>
1581
1594
  <label for="username">Email or Username</label>
@@ -1590,7 +1603,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1590
1603
  <label style="display: block; margin-bottom: 0.75rem;">
1591
1604
  <input type="checkbox" name="persist" style="width: 20px"> Stay Logged In
1592
1605
  </label>
1593
- <button>Login</button>
1606
+ <button type="submit">Login</button>
1594
1607
  </form>
1595
1608
  </div>
1596
1609
  ${options.hideApps ? "" : `
@@ -1620,7 +1633,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1620
1633
  /** Current user as an observable */
1621
1634
  __publicField(this, "user$", new BehaviorSubject(void 0));
1622
1635
  this.api = api;
1623
- this.api.token$.subscribe((token) => this.current(token, true));
1636
+ this.api.token$.subscribe(async (token) => {
1637
+ if (token === void 0) return;
1638
+ this.user = await this.current(token);
1639
+ });
1624
1640
  }
1625
1641
  /** Current user */
1626
1642
  get user() {
@@ -1639,22 +1655,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1639
1655
  *
1640
1656
  * @return {Promise<User | null>}
1641
1657
  */
1642
- async current(token = this.api.token, set) {
1658
+ async current(token = this.api.token) {
1643
1659
  var _a;
1644
- if (!token) {
1645
- if (set && this.user != null) this.user = null;
1646
- return null;
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
- });
1660
+ if (!token) return null;
1661
+ else if (token == ((_a = this.user) == null ? void 0 : _a.token)) return this.user;
1662
+ return this.api.request({ "$/auth/current": {} }, { token }).then((resp) => (resp == null ? void 0 : resp.login) ? resp : null);
1658
1663
  }
1659
1664
  /**
1660
1665
  * Automatically handle sessions by checking localStorage & URL parameters for a token & prompting
@@ -1741,7 +1746,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1741
1746
  }).then(async (resp) => {
1742
1747
  const data = await resp.json().catch(() => ({}));
1743
1748
  if (!resp.ok || data["error"]) throw Object.assign(errorFromCode(resp.status, data.error) || {}, data);
1744
- return await this.current(data["token"], true);
1749
+ this.api.token = data["token"];
1750
+ return data;
1745
1751
  });
1746
1752
  }
1747
1753
  /**
@@ -1753,7 +1759,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1753
1759
  return fetch(`${this.api.url}guest`).then(async (resp) => {
1754
1760
  const data = await resp.json().catch(() => ({}));
1755
1761
  if (!resp.ok || data["error"]) throw Object.assign(errorFromCode(resp.status, data.error) || {}, data);
1756
- return await this.current(data["token"], true);
1762
+ this.api.token = data["token"];
1763
+ return data;
1757
1764
  });
1758
1765
  }
1759
1766
  /**
@@ -1773,7 +1780,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1773
1780
  */
1774
1781
  logout() {
1775
1782
  return this.api.request({ "$/auth/logout": {} }).then((resp) => {
1776
- this.api.token = resp.new;
1783
+ this.api.token = null;
1777
1784
  return resp;
1778
1785
  });
1779
1786
  }
@@ -2383,7 +2390,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2383
2390
  this.options.url = url.origin;
2384
2391
  }
2385
2392
  if (this.options.url !== false)
2386
- api.token$.pipe(distinctUntilChanged()).subscribe(() => this.connect());
2393
+ api.token$.pipe(filter((u) => u !== void 0), distinctUntilChanged()).subscribe(() => this.connect());
2387
2394
  }
2388
2395
  /**
2389
2396
  * Add listener for all socket events
@@ -2500,7 +2507,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2500
2507
  } });
2501
2508
  }
2502
2509
  }
2503
- const version = "1.0.11";
2510
+ const version = "1.0.13";
2504
2511
  class Api {
2505
2512
  /**
2506
2513
  * Connect to Datalynk & send requests
@@ -2527,7 +2534,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2527
2534
  /** Package version */
2528
2535
  __publicField(this, "version", version);
2529
2536
  /** API Session token */
2530
- __publicField(this, "token$", new BehaviorSubject(null));
2537
+ __publicField(this, "token$", new BehaviorSubject(void 0));
2531
2538
  /** Helpers */
2532
2539
  /** Authentication */
2533
2540
  __publicField(this, "auth", new Auth(this));
@@ -2548,10 +2555,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
2548
2555
  ...options
2549
2556
  };
2550
2557
  if (this.options.saveSession) {
2551
- const saved = localStorage == void 0 ? null : localStorage.getItem(this.localStorageKey);
2552
- if (saved) this.token = saved;
2558
+ if (localStorage == void 0) return;
2559
+ this.token = localStorage.getItem(this.localStorageKey) || null;
2553
2560
  this.token$.pipe(distinctUntilChanged()).subscribe((token) => {
2554
- if (localStorage == void 0) return;
2555
2561
  if (token) localStorage.setItem(this.localStorageKey, token);
2556
2562
  else localStorage.removeItem(this.localStorageKey);
2557
2563
  });
package/dist/index.mjs CHANGED
@@ -1311,6 +1311,14 @@ var BehaviorSubject = function(_super) {
1311
1311
  };
1312
1312
  return BehaviorSubject2;
1313
1313
  }(Subject);
1314
+ function filter(predicate, thisArg) {
1315
+ return operate(function(source, subscriber) {
1316
+ var index = 0;
1317
+ source.subscribe(createOperatorSubscriber(subscriber, function(value) {
1318
+ return predicate.call(thisArg, value, index++) && subscriber.next(value);
1319
+ }));
1320
+ });
1321
+ }
1314
1322
  function distinctUntilChanged(comparator, keySelector) {
1315
1323
  if (keySelector === void 0) {
1316
1324
  keySelector = identity;
@@ -1353,19 +1361,21 @@ const _LoginPrompt = class _LoginPrompt {
1353
1361
  background: "#ffffff",
1354
1362
  color: "#c83232",
1355
1363
  textColor: "#000000",
1356
- ...options
1364
+ ...clean(options, true)
1357
1365
  };
1358
1366
  this.close();
1359
1367
  document.head.innerHTML += _LoginPrompt.css(this.options);
1360
- document.body.innerHTML += _LoginPrompt.template(this.options);
1368
+ const div = document.createElement("div");
1369
+ div.innerHTML = _LoginPrompt.template(this.options);
1370
+ document.body.appendChild(div);
1361
1371
  this.alert = document.querySelector("#datalynk-login-alert");
1362
1372
  this.button = document.querySelector("#datalynk-login-form button");
1363
1373
  this.form = document.querySelector("#datalynk-login-form");
1364
1374
  this.password = document.querySelector('#datalynk-login-form input[name="password"]');
1365
1375
  this.persist = document.querySelector('#datalynk-login-form input[name="persist"]');
1366
1376
  this.username = document.querySelector('#datalynk-login-form input[name="username"]');
1377
+ if (options.persist === false) this.persist.parentElement.remove();
1367
1378
  this.form.onsubmit = (event) => this.login(event);
1368
- if (options.persist === false) this.persist.parentElement.style.display = "none";
1369
1379
  }
1370
1380
  /** Close the login prompt */
1371
1381
  close() {
@@ -1476,6 +1486,9 @@ __publicField(_LoginPrompt, "css", (options) => `
1476
1486
  }
1477
1487
 
1478
1488
  #datalynk-login .login-header {
1489
+ display: flex;
1490
+ justify-content: center;
1491
+ align-items: center;
1479
1492
  color: var(--theme-text);
1480
1493
  text-align: center;
1481
1494
  font-size: 32px;
@@ -1530,6 +1543,7 @@ __publicField(_LoginPrompt, "css", (options) => `
1530
1543
  }
1531
1544
 
1532
1545
  #datalynk-login .login-links{
1546
+ display: flex;
1533
1547
  padding: 0 0 1.5rem 0;
1534
1548
  }
1535
1549
 
@@ -1562,7 +1576,7 @@ __publicField(_LoginPrompt, "css", (options) => `
1562
1576
  __publicField(_LoginPrompt, "template", (options) => `
1563
1577
  <div id="datalynk-login">
1564
1578
  <div class="added-links">
1565
- ${(options.addLinks || []).map((link) => `<a href="${link.url}" target="_blank">${link.text}</a>`).join(" | ")}
1579
+ ${(options.addLinks || []).map((link) => `<a href="${link.url || "#"}" target="_blank">${link.text}</a>`).join(" | ")}
1566
1580
  </div>
1567
1581
  <div class="login-container">
1568
1582
  <div class="login-header">
@@ -1571,7 +1585,6 @@ __publicField(_LoginPrompt, "template", (options) => `
1571
1585
  <div class="login-content">
1572
1586
  <div class="login-body" style="max-width: 300px">
1573
1587
  <div id="datalynk-login-alert" class="hidden"></div>
1574
-
1575
1588
  <form id="datalynk-login-form">
1576
1589
  <div>
1577
1590
  <label for="username">Email or Username</label>
@@ -1586,7 +1599,7 @@ __publicField(_LoginPrompt, "template", (options) => `
1586
1599
  <label style="display: block; margin-bottom: 0.75rem;">
1587
1600
  <input type="checkbox" name="persist" style="width: 20px"> Stay Logged In
1588
1601
  </label>
1589
- <button>Login</button>
1602
+ <button type="submit">Login</button>
1590
1603
  </form>
1591
1604
  </div>
1592
1605
  ${options.hideApps ? "" : `
@@ -1616,7 +1629,10 @@ class Auth {
1616
1629
  /** Current user as an observable */
1617
1630
  __publicField(this, "user$", new BehaviorSubject(void 0));
1618
1631
  this.api = api;
1619
- this.api.token$.subscribe((token) => this.current(token, true));
1632
+ this.api.token$.subscribe(async (token) => {
1633
+ if (token === void 0) return;
1634
+ this.user = await this.current(token);
1635
+ });
1620
1636
  }
1621
1637
  /** Current user */
1622
1638
  get user() {
@@ -1635,22 +1651,11 @@ class Auth {
1635
1651
  *
1636
1652
  * @return {Promise<User | null>}
1637
1653
  */
1638
- async current(token = this.api.token, set) {
1654
+ async current(token = this.api.token) {
1639
1655
  var _a;
1640
- if (!token) {
1641
- if (set && this.user != null) this.user = null;
1642
- return null;
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
- });
1656
+ if (!token) return null;
1657
+ else if (token == ((_a = this.user) == null ? void 0 : _a.token)) return this.user;
1658
+ return this.api.request({ "$/auth/current": {} }, { token }).then((resp) => (resp == null ? void 0 : resp.login) ? resp : null);
1654
1659
  }
1655
1660
  /**
1656
1661
  * Automatically handle sessions by checking localStorage & URL parameters for a token & prompting
@@ -1737,7 +1742,8 @@ class Auth {
1737
1742
  }).then(async (resp) => {
1738
1743
  const data = await resp.json().catch(() => ({}));
1739
1744
  if (!resp.ok || data["error"]) throw Object.assign(errorFromCode(resp.status, data.error) || {}, data);
1740
- return await this.current(data["token"], true);
1745
+ this.api.token = data["token"];
1746
+ return data;
1741
1747
  });
1742
1748
  }
1743
1749
  /**
@@ -1749,7 +1755,8 @@ class Auth {
1749
1755
  return fetch(`${this.api.url}guest`).then(async (resp) => {
1750
1756
  const data = await resp.json().catch(() => ({}));
1751
1757
  if (!resp.ok || data["error"]) throw Object.assign(errorFromCode(resp.status, data.error) || {}, data);
1752
- return await this.current(data["token"], true);
1758
+ this.api.token = data["token"];
1759
+ return data;
1753
1760
  });
1754
1761
  }
1755
1762
  /**
@@ -1769,7 +1776,7 @@ class Auth {
1769
1776
  */
1770
1777
  logout() {
1771
1778
  return this.api.request({ "$/auth/logout": {} }).then((resp) => {
1772
- this.api.token = resp.new;
1779
+ this.api.token = null;
1773
1780
  return resp;
1774
1781
  });
1775
1782
  }
@@ -2379,7 +2386,7 @@ class Socket {
2379
2386
  this.options.url = url.origin;
2380
2387
  }
2381
2388
  if (this.options.url !== false)
2382
- api.token$.pipe(distinctUntilChanged()).subscribe(() => this.connect());
2389
+ api.token$.pipe(filter((u) => u !== void 0), distinctUntilChanged()).subscribe(() => this.connect());
2383
2390
  }
2384
2391
  /**
2385
2392
  * Add listener for all socket events
@@ -2496,7 +2503,7 @@ class Superuser {
2496
2503
  } });
2497
2504
  }
2498
2505
  }
2499
- const version = "1.0.11";
2506
+ const version = "1.0.13";
2500
2507
  class Api {
2501
2508
  /**
2502
2509
  * Connect to Datalynk & send requests
@@ -2523,7 +2530,7 @@ class Api {
2523
2530
  /** Package version */
2524
2531
  __publicField(this, "version", version);
2525
2532
  /** API Session token */
2526
- __publicField(this, "token$", new BehaviorSubject(null));
2533
+ __publicField(this, "token$", new BehaviorSubject(void 0));
2527
2534
  /** Helpers */
2528
2535
  /** Authentication */
2529
2536
  __publicField(this, "auth", new Auth(this));
@@ -2544,10 +2551,9 @@ class Api {
2544
2551
  ...options
2545
2552
  };
2546
2553
  if (this.options.saveSession) {
2547
- const saved = localStorage == void 0 ? null : localStorage.getItem(this.localStorageKey);
2548
- if (saved) this.token = saved;
2554
+ if (localStorage == void 0) return;
2555
+ this.token = localStorage.getItem(this.localStorageKey) || null;
2549
2556
  this.token$.pipe(distinctUntilChanged()).subscribe((token) => {
2550
- if (localStorage == void 0) return;
2551
2557
  if (token) localStorage.setItem(this.localStorageKey, token);
2552
2558
  else localStorage.removeItem(this.localStorageKey);
2553
2559
  });
@@ -1 +1 @@
1
- {"version":3,"file":"login-prompt.d.ts","sourceRoot":"","sources":["../src/login-prompt.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAAC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,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.11",
5
+ "version": "1.0.13",
6
6
  "author": "Zak Timson <zaktimson@gmail.com>",
7
7
  "private": false,
8
8
  "main": "./dist/index.cjs",