@mapcreator/api 3.3.1 → 3.3.4

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/bundle.js CHANGED
@@ -29,7 +29,7 @@
29
29
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
30
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
31
  *
32
- * hash:af26823235a66e3e14db, chunkhash:99c5aae0fb9546866704, name:bundle, version:v3.3.1
32
+ * hash:46af3da39dc599039df3, chunkhash:2b47f360aaf02e10b2ca, name:bundle, version:v3.3.4
33
33
  */
34
34
  /******/ (() => { // webpackBootstrap
35
35
  /******/ "use strict";
@@ -626,11 +626,11 @@ __webpack_require__.r(__webpack_exports__);
626
626
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
627
627
  /* harmony export */ "default": () => (/* binding */ ResourceBase)
628
628
  /* harmony export */ });
629
- /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
629
+ /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9);
630
630
  /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(case__WEBPACK_IMPORTED_MODULE_0__);
631
- /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(21);
632
- /* harmony import */ var _Mapcreator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(16);
633
- /* harmony import */ var _proxy_SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(14);
631
+ /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(22);
632
+ /* harmony import */ var _Mapcreator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(17);
633
+ /* harmony import */ var _proxy_SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(15);
634
634
  /* harmony import */ var _traits_Injectable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(61);
635
635
  /* harmony import */ var _utils_hash__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(23);
636
636
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(0);
@@ -1205,7 +1205,7 @@ __webpack_require__.r(__webpack_exports__);
1205
1205
  /* harmony export */ "encodeQueryString": () => (/* binding */ encodeQueryString),
1206
1206
  /* harmony export */ "wrapKyPrefixUrl": () => (/* binding */ wrapKyPrefixUrl)
1207
1207
  /* harmony export */ });
1208
- /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9);
1208
+ /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7);
1209
1209
  /*
1210
1210
  * BSD 3-Clause License
1211
1211
  *
@@ -1339,7 +1339,7 @@ __webpack_require__.d(__webpack_exports__, {
1339
1339
  });
1340
1340
 
1341
1341
  // EXTERNAL MODULE: ./src/enums/Enum.js + 1 modules
1342
- var Enum = __webpack_require__(11);
1342
+ var Enum = __webpack_require__(12);
1343
1343
  ;// CONCATENATED MODULE: ./src/enums/DeletedState.js
1344
1344
  /*
1345
1345
  * BSD 3-Clause License
@@ -1518,11 +1518,76 @@ const JobShareVisibility = new Enum["default"](['private', 'organisation', 'publ
1518
1518
  /* 7 */
1519
1519
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1520
1520
 
1521
+ __webpack_require__.r(__webpack_exports__);
1522
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1523
+ /* harmony export */ "isNode": () => (/* binding */ isNode),
1524
+ /* harmony export */ "windowTest": () => (/* binding */ windowTest)
1525
+ /* harmony export */ });
1526
+ /*
1527
+ * BSD 3-Clause License
1528
+ *
1529
+ * Copyright (c) 2020, Mapcreator
1530
+ * All rights reserved.
1531
+ *
1532
+ * Redistribution and use in source and binary forms, with or without
1533
+ * modification, are permitted provided that the following conditions are met:
1534
+ *
1535
+ * Redistributions of source code must retain the above copyright notice, this
1536
+ * list of conditions and the following disclaimer.
1537
+ *
1538
+ * Redistributions in binary form must reproduce the above copyright notice,
1539
+ * this list of conditions and the following disclaimer in the documentation
1540
+ * and/or other materials provided with the distribution.
1541
+ *
1542
+ * Neither the name of the copyright holder nor the names of its
1543
+ * contributors may be used to endorse or promote products derived from
1544
+ * this software without specific prior written permission.
1545
+ *
1546
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1547
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1548
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1549
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1550
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1551
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1552
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1553
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1554
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1555
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1556
+ */
1557
+
1558
+ /**
1559
+ * Test if the application is running under nodejs
1560
+ * @returns {boolean} - Is the application running under node?
1561
+ * @see https://nodejs.org
1562
+ * @private
1563
+ */
1564
+ function isNode() {
1565
+ try {
1566
+ return Object.prototype.toString.call(typeof process === 'undefined' ? 0 : process) === '[object process]';
1567
+ } catch (_) {
1568
+ return false;
1569
+ }
1570
+ }
1571
+ /**
1572
+ * Quickly check if the window contains a variable
1573
+ * @param {string} str - target variable
1574
+ * @returns {boolean} - If the window contains the variable
1575
+ * @private
1576
+ */
1577
+
1578
+ function windowTest(str) {
1579
+ return typeof window !== 'undefined' && typeof window[str] !== 'undefined';
1580
+ }
1581
+
1582
+ /***/ }),
1583
+ /* 8 */
1584
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1585
+
1521
1586
  __webpack_require__.r(__webpack_exports__);
1522
1587
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1523
1588
  /* harmony export */ "default": () => (/* binding */ RequestParameters)
1524
1589
  /* harmony export */ });
1525
- /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
1590
+ /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9);
1526
1591
  /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(case__WEBPACK_IMPORTED_MODULE_0__);
1527
1592
  /* harmony import */ var events__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(40);
1528
1593
  /* harmony import */ var events__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(events__WEBPACK_IMPORTED_MODULE_1__);
@@ -2253,20 +2318,21 @@ class RequestParameters extends events__WEBPACK_IMPORTED_MODULE_1__.EventEmitter
2253
2318
  }
2254
2319
 
2255
2320
  /***/ }),
2256
- /* 8 */
2321
+ /* 9 */
2257
2322
  /***/ ((module) => {
2258
2323
 
2259
2324
  module.exports = require("case");
2260
2325
 
2261
2326
  /***/ }),
2262
- /* 9 */
2327
+ /* 10 */
2263
2328
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2264
2329
 
2265
2330
  __webpack_require__.r(__webpack_exports__);
2266
2331
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2267
- /* harmony export */ "isNode": () => (/* binding */ isNode),
2268
- /* harmony export */ "windowTest": () => (/* binding */ windowTest)
2332
+ /* harmony export */ "default": () => (/* binding */ OAuthToken)
2269
2333
  /* harmony export */ });
2334
+ /* harmony import */ var _storage_StorageManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20);
2335
+ /* harmony import */ var _utils_requests__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
2270
2336
  /*
2271
2337
  * BSD 3-Clause License
2272
2338
  *
@@ -2299,41 +2365,162 @@ __webpack_require__.r(__webpack_exports__);
2299
2365
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2300
2366
  */
2301
2367
 
2368
+
2302
2369
  /**
2303
- * Test if the application is running under nodejs
2304
- * @returns {boolean} - Is the application running under node?
2305
- * @see https://nodejs.org
2306
- * @private
2370
+ * Oauth token container
2307
2371
  */
2308
- function isNode() {
2309
- try {
2310
- return Object.prototype.toString.call(typeof process === 'undefined' ? 0 : process) === '[object process]';
2311
- } catch (_) {
2312
- return false;
2372
+
2373
+ class OAuthToken {
2374
+ /**
2375
+ * @param {String} token - OAuth token
2376
+ * @param {String} [type=Bearer] - token type
2377
+ * @param {Date|Number} [expires=5 days] - expire time in seconds or Date
2378
+ * @param {Array<string>} [scopes=[]] - Any scopes
2379
+ */
2380
+ constructor(token, type = 'Bearer', expires = 432000, scopes = []) {
2381
+ this.scopes = scopes;
2382
+ this.token = token;
2383
+ this.type = type.toLowerCase().replace(/(\s|^)\w/g, x => x.toUpperCase());
2384
+
2385
+ if (typeof expires === 'number') {
2386
+ const ms = expires * 1000; // Expires is in seconds
2387
+
2388
+ this.expires = new Date(Date.now() + ms);
2389
+ } else if (expires instanceof Date) {
2390
+ this.expires = expires;
2391
+ } else {
2392
+ throw new TypeError('Expires not of type Date or Number');
2393
+ }
2394
+ }
2395
+ /**
2396
+ * String representation of the token, usable in the Authorization header
2397
+ * @returns {string} - String representation
2398
+ */
2399
+
2400
+
2401
+ toString() {
2402
+ return `${this.type} ${this.token}`;
2403
+ }
2404
+ /**
2405
+ * Get equivalent OAuth response object
2406
+ * @returns {{access_token: (String|*), token_type: String, expires_in: Number, scope: (Array.<String>|Array|*)}} - Raw response object
2407
+ */
2408
+
2409
+
2410
+ toResponseObject() {
2411
+ return {
2412
+ 'access_token': this.token,
2413
+ 'token_type': this.type.toLowerCase(),
2414
+ 'expires_in': this.expires - Date.now(),
2415
+ 'scope': this.scopes
2416
+ };
2417
+ }
2418
+ /**
2419
+ * Export oauth response query string
2420
+ * @returns {string} - OAuth response query
2421
+ */
2422
+
2423
+
2424
+ toQueryString() {
2425
+ return (0,_utils_requests__WEBPACK_IMPORTED_MODULE_1__.encodeQueryString)(this.toResponseObject());
2426
+ }
2427
+ /**
2428
+ * If the token has expired
2429
+ * @returns {Boolean} - expired
2430
+ */
2431
+
2432
+
2433
+ get expired() {
2434
+ return new Date() > this.expires;
2435
+ }
2436
+ /**
2437
+ * Internal storage key name
2438
+ * @returns {String} - storage name
2439
+ * @constant
2440
+ */
2441
+
2442
+
2443
+ static get storageName() {
2444
+ return 'api_token';
2445
+ }
2446
+ /**
2447
+ * Build instance from response object
2448
+ * @param {String|Object} data - object or JSON string
2449
+ * @returns {OAuthToken} - New OAuthToken instance
2450
+ */
2451
+
2452
+
2453
+ static fromResponseObject(data) {
2454
+ if (typeof data === 'string') {
2455
+ data = JSON.parse(data);
2456
+ } // Default expires = 5 days
2457
+
2458
+
2459
+ let expires = 432000;
2460
+
2461
+ if (typeof data['exipires_in'] !== 'undefined') {
2462
+ expires = Number(data['expires_in']);
2463
+ } else if (typeof data.expires === 'string') {
2464
+ expires = new Date(data.expires);
2465
+ }
2466
+
2467
+ return new OAuthToken(data['access_token'], data['token_type'], expires, data.scope || []);
2468
+ }
2469
+ /**
2470
+ * Store the token for later recovery. Token will be stored in HTTPS cookie if possible.
2471
+ * @param {String} name - db key name
2472
+ * @throws {OAuthToken#recover}
2473
+ */
2474
+
2475
+
2476
+ save(name = OAuthToken.storageName) {
2477
+ const data = {
2478
+ token: this.token,
2479
+ type: this.type,
2480
+ expires: this.expires.toUTCString(),
2481
+ scopes: this.scopes
2482
+ }; // Third parameter is only used when we're using cookies
2483
+
2484
+ _storage_StorageManager__WEBPACK_IMPORTED_MODULE_0__["default"].secure.set(name, JSON.stringify(data), this.expires);
2485
+ }
2486
+ /**
2487
+ * Recover a token by looking through the HTTPS cookies and localStorage
2488
+ * @param {String} name - Storage key name
2489
+ * @returns {OAuthToken|null} - null if none could be recovered
2490
+ * @throws {OAuthToken#save}
2491
+ */
2492
+
2493
+
2494
+ static recover(name = OAuthToken.storageName) {
2495
+ const data = _storage_StorageManager__WEBPACK_IMPORTED_MODULE_0__["default"].secure.get(name);
2496
+
2497
+ if (!data) {
2498
+ return null;
2499
+ }
2500
+
2501
+ const obj = JSON.parse(data);
2502
+ const instance = new OAuthToken(obj.token, obj.type, new Date(obj.expires), obj.scopes || []);
2503
+
2504
+ if (instance.expired) {
2505
+ return null;
2506
+ }
2507
+
2508
+ return instance;
2313
2509
  }
2314
- }
2315
- /**
2316
- * Quickly check if the window contains a variable
2317
- * @param {string} str - target variable
2318
- * @returns {boolean} - If the window contains the variable
2319
- * @private
2320
- */
2321
2510
 
2322
- function windowTest(str) {
2323
- return typeof window !== 'undefined' && typeof window[str] !== 'undefined';
2324
2511
  }
2325
2512
 
2326
2513
  /***/ }),
2327
- /* 10 */
2514
+ /* 11 */
2328
2515
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2329
2516
 
2330
2517
  __webpack_require__.r(__webpack_exports__);
2331
2518
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2332
2519
  /* harmony export */ "default": () => (/* binding */ CrudSetItemBase)
2333
2520
  /* harmony export */ });
2334
- /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(21);
2521
+ /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(22);
2335
2522
  /* harmony import */ var _CrudBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
2336
- /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);
2523
+ /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9);
2337
2524
  /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(case__WEBPACK_IMPORTED_MODULE_2__);
2338
2525
  /*
2339
2526
  * BSD 3-Clause License
@@ -2419,7 +2606,7 @@ class CrudSetItemBase extends _CrudBase__WEBPACK_IMPORTED_MODULE_1__["default"]
2419
2606
  }
2420
2607
 
2421
2608
  /***/ }),
2422
- /* 11 */
2609
+ /* 12 */
2423
2610
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2424
2611
 
2425
2612
  // ESM COMPAT FLAG
@@ -2431,7 +2618,7 @@ __webpack_require__.d(__webpack_exports__, {
2431
2618
  });
2432
2619
 
2433
2620
  // EXTERNAL MODULE: external "case"
2434
- var external_case_ = __webpack_require__(8);
2621
+ var external_case_ = __webpack_require__(9);
2435
2622
  // EXTERNAL MODULE: ./src/utils/reflection.js
2436
2623
  var reflection = __webpack_require__(0);
2437
2624
  ;// CONCATENATED MODULE: ./src/utils/Unobservable.js
@@ -2615,15 +2802,24 @@ class Enum extends Unobservable {
2615
2802
  }
2616
2803
 
2617
2804
  /***/ }),
2618
- /* 12 */
2805
+ /* 13 */
2619
2806
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2620
2807
 
2621
2808
  __webpack_require__.r(__webpack_exports__);
2622
2809
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2623
- /* harmony export */ "default": () => (/* binding */ OAuthToken)
2810
+ /* harmony export */ "default": () => (/* binding */ OAuth)
2624
2811
  /* harmony export */ });
2625
- /* harmony import */ var _storage_StorageManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(22);
2626
- /* harmony import */ var _utils_requests__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
2812
+ /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19);
2813
+ /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
2814
+ /* harmony import */ var ky_universal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(31);
2815
+ /* harmony import */ var ky_universal__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ky_universal__WEBPACK_IMPORTED_MODULE_1__);
2816
+ /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(22);
2817
+ /* harmony import */ var _storage_StorageManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(20);
2818
+ /* harmony import */ var _OAuthToken__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(10);
2819
+ /* harmony import */ var _StateContainer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(37);
2820
+ /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1);
2821
+
2822
+
2627
2823
  /*
2628
2824
  * BSD 3-Clause License
2629
2825
  *
@@ -2657,152 +2853,111 @@ __webpack_require__.r(__webpack_exports__);
2657
2853
  */
2658
2854
 
2659
2855
 
2856
+
2857
+
2858
+
2859
+
2660
2860
  /**
2661
- * Oauth token container
2861
+ * OAuth base class
2862
+ * @abstract
2662
2863
  */
2663
2864
 
2664
- class OAuthToken {
2865
+ class OAuth {
2665
2866
  /**
2666
- * @param {String} token - OAuth token
2667
- * @param {String} [type=Bearer] - token type
2668
- * @param {Date|Number} [expires=5 days] - expire time in seconds or Date
2669
- * @param {Array<string>} [scopes=[]] - Any scopes
2867
+ * @param {String} clientId - OAuth client id
2868
+ * @param {Array<String>} scopes - A list of required scopes
2670
2869
  */
2671
- constructor(token, type = 'Bearer', expires = 432000, scopes = []) {
2672
- this.scopes = scopes;
2673
- this.token = token;
2674
- this.type = type.toLowerCase().replace(/(\s|^)\w/g, x => x.toUpperCase());
2675
-
2676
- if (typeof expires === 'number') {
2677
- const ms = expires * 1000; // Expires is in seconds
2870
+ constructor(clientId, scopes = ['*']) {
2871
+ _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(this, "token", null);
2678
2872
 
2679
- this.expires = new Date(Date.now() + ms);
2680
- } else if (expires instanceof Date) {
2681
- this.expires = expires;
2682
- } else {
2683
- throw new TypeError('Expires not of type Date or Number');
2684
- }
2685
- }
2686
- /**
2687
- * String representation of the token, usable in the Authorization header
2688
- * @returns {string} - String representation
2689
- */
2873
+ _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(this, "path", '/');
2690
2874
 
2875
+ _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(this, "host", "https://api.beta.mapcreator.io");
2691
2876
 
2692
- toString() {
2693
- return `${this.type} ${this.token}`;
2694
- }
2695
- /**
2696
- * Get equivalent OAuth response object
2697
- * @returns {{access_token: (String|*), token_type: String, expires_in: Number, scope: (Array.<String>|Array|*)}} - Raw response object
2698
- */
2877
+ if (this.constructor === OAuth) {
2878
+ throw new _errors_AbstractError__WEBPACK_IMPORTED_MODULE_2__.AbstractClassError();
2879
+ }
2699
2880
 
2881
+ this.clientId = String(clientId);
2882
+ this.scopes = scopes;
2700
2883
 
2701
- toResponseObject() {
2702
- return {
2703
- 'access_token': this.token,
2704
- 'token_type': this.type.toLowerCase(),
2705
- 'expires_in': this.expires - Date.now(),
2706
- 'scope': this.scopes
2707
- };
2884
+ if (this.clientId) {
2885
+ this.token = _OAuthToken__WEBPACK_IMPORTED_MODULE_4__["default"].recover();
2886
+ }
2708
2887
  }
2709
2888
  /**
2710
- * Export oauth response query string
2711
- * @returns {string} - OAuth response query
2889
+ * If the current instance has a valid token
2890
+ * @returns {Boolean} - If a valid token is available
2712
2891
  */
2713
2892
 
2714
2893
 
2715
- toQueryString() {
2716
- return (0,_utils_requests__WEBPACK_IMPORTED_MODULE_1__.encodeQueryString)(this.toResponseObject());
2894
+ get authenticated() {
2895
+ return this.token !== null && !this.token.expired;
2717
2896
  }
2718
2897
  /**
2719
- * If the token has expired
2720
- * @returns {Boolean} - expired
2898
+ * Authenticate
2899
+ * @returns {Promise<OAuthToken>} - Authentication token
2900
+ * @throws {OAuthError}
2901
+ * @abstract
2721
2902
  */
2722
2903
 
2723
2904
 
2724
- get expired() {
2725
- return new Date() > this.expires;
2905
+ authenticate() {
2906
+ throw new _errors_AbstractError__WEBPACK_IMPORTED_MODULE_2__.AbstractMethodError();
2726
2907
  }
2727
2908
  /**
2728
- * Internal storage key name
2729
- * @returns {String} - storage name
2730
- * @constant
2909
+ * Forget the current session
2910
+ * Empty the session token store and forget the api token
2731
2911
  */
2732
2912
 
2733
2913
 
2734
- static get storageName() {
2735
- return 'api_token';
2914
+ forget() {
2915
+ _StateContainer__WEBPACK_IMPORTED_MODULE_5__["default"].clean();
2916
+ _storage_StorageManager__WEBPACK_IMPORTED_MODULE_3__["default"].secure.remove(_OAuthToken__WEBPACK_IMPORTED_MODULE_4__["default"].storageName);
2917
+ this.token = null;
2736
2918
  }
2737
2919
  /**
2738
- * Build instance from response object
2739
- * @param {String|Object} data - object or JSON string
2740
- * @returns {OAuthToken} - New OAuthToken instance
2920
+ * Invalidates the session token
2921
+ * @throws {OAuthError} - If de-authentication fails
2922
+ * @throws {ApiError} - If the api returns errors
2923
+ * @returns {CancelablePromise}
2741
2924
  */
2742
2925
 
2743
2926
 
2744
- static fromResponseObject(data) {
2745
- if (typeof data === 'string') {
2746
- data = JSON.parse(data);
2747
- } // Default expires = 5 days
2748
-
2749
-
2750
- let expires = 432000;
2751
-
2752
- if (typeof data['exipires_in'] !== 'undefined') {
2753
- expires = Number(data['expires_in']);
2754
- } else if (typeof data.expires === 'string') {
2755
- expires = new Date(data.expires);
2927
+ logout() {
2928
+ if (!this.token) {
2929
+ return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_6__.makeCancelable)(() => {});
2756
2930
  }
2757
2931
 
2758
- return new OAuthToken(data['access_token'], data['token_type'], expires, data.scope || []);
2759
- }
2760
- /**
2761
- * Store the token for later recovery. Token will be stored in HTTPS cookie if possible.
2762
- * @param {String} name - db key name
2763
- * @throws {OAuthToken#recover}
2764
- */
2765
-
2766
-
2767
- save(name = OAuthToken.storageName) {
2768
- const data = {
2769
- token: this.token,
2770
- type: this.type,
2771
- expires: this.expires.toUTCString(),
2772
- scopes: this.scopes
2773
- }; // Third parameter is only used when we're using cookies
2774
-
2775
- _storage_StorageManager__WEBPACK_IMPORTED_MODULE_0__["default"].secure.set(name, JSON.stringify(data), this.expires);
2932
+ const url = `${this.host}/oauth/logout`;
2933
+ return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_6__.makeCancelable)(async signal => {
2934
+ await ky_universal__WEBPACK_IMPORTED_MODULE_1___default().post(url, {
2935
+ headers: {
2936
+ Accept: 'application/json',
2937
+ Authorization: this.token.toString()
2938
+ },
2939
+ signal
2940
+ });
2941
+ this.forget();
2942
+ });
2776
2943
  }
2777
2944
  /**
2778
- * Recover a token by looking through the HTTPS cookies and localStorage
2779
- * @param {String} name - Storage key name
2780
- * @returns {OAuthToken|null} - null if none could be recovered
2781
- * @throws {OAuthToken#save}
2945
+ * Manually import OAuthToken, usefull for debugging
2946
+ * @param {String} token - OAuth token
2947
+ * @param {String} [type=Bearer] - token type
2948
+ * @param {Date|Number} [expires=5 days] - expire time in seconds or Date
2949
+ * @param {Array<string>} [scopes=[]] - Any scopes
2782
2950
  */
2783
2951
 
2784
2952
 
2785
- static recover(name = OAuthToken.storageName) {
2786
- const data = _storage_StorageManager__WEBPACK_IMPORTED_MODULE_0__["default"].secure.get(name);
2787
-
2788
- if (!data) {
2789
- return null;
2790
- }
2791
-
2792
- const obj = JSON.parse(data);
2793
- const instance = new OAuthToken(obj.token, obj.type, new Date(obj.expires), obj.scopes || []);
2794
-
2795
- if (instance.expired) {
2796
- return null;
2797
- }
2798
-
2799
- return instance;
2953
+ importToken(token, type = 'Bearer', expires = 432000, scopes = []) {
2954
+ this.token = new _OAuthToken__WEBPACK_IMPORTED_MODULE_4__["default"](token, type, expires, scopes);
2800
2955
  }
2801
2956
 
2802
2957
  }
2803
2958
 
2804
2959
  /***/ }),
2805
- /* 13 */
2960
+ /* 14 */
2806
2961
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2807
2962
 
2808
2963
  __webpack_require__.r(__webpack_exports__);
@@ -2810,7 +2965,7 @@ __webpack_require__.r(__webpack_exports__);
2810
2965
  /* harmony export */ "default": () => (/* binding */ ResourceProxy)
2811
2966
  /* harmony export */ });
2812
2967
  /* harmony import */ var _utils_requests__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
2813
- /* harmony import */ var _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(14);
2968
+ /* harmony import */ var _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(15);
2814
2969
  /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
2815
2970
  /*
2816
2971
  * BSD 3-Clause License
@@ -2928,7 +3083,7 @@ class ResourceProxy extends _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_1__["d
2928
3083
  }
2929
3084
 
2930
3085
  /***/ }),
2931
- /* 14 */
3086
+ /* 15 */
2932
3087
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2933
3088
 
2934
3089
  // ESM COMPAT FLAG
@@ -2940,9 +3095,9 @@ __webpack_require__.d(__webpack_exports__, {
2940
3095
  });
2941
3096
 
2942
3097
  // EXTERNAL MODULE: ./src/Mapcreator.js + 1 modules
2943
- var Mapcreator = __webpack_require__(16);
3098
+ var Mapcreator = __webpack_require__(17);
2944
3099
  // EXTERNAL MODULE: ./src/RequestParameters.js
2945
- var RequestParameters = __webpack_require__(7);
3100
+ var RequestParameters = __webpack_require__(8);
2946
3101
  // EXTERNAL MODULE: ./src/utils/reflection.js
2947
3102
  var reflection = __webpack_require__(0);
2948
3103
  // EXTERNAL MODULE: ./src/utils/helpers.js
@@ -3467,16 +3622,16 @@ class SimpleResourceProxy {
3467
3622
  }
3468
3623
 
3469
3624
  /***/ }),
3470
- /* 15 */
3625
+ /* 16 */
3471
3626
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3472
3627
 
3473
3628
  __webpack_require__.r(__webpack_exports__);
3474
3629
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3475
3630
  /* harmony export */ "default": () => (/* binding */ CrudSetBase)
3476
3631
  /* harmony export */ });
3477
- /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(21);
3632
+ /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(22);
3478
3633
  /* harmony import */ var _CrudBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
3479
- /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);
3634
+ /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9);
3480
3635
  /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(case__WEBPACK_IMPORTED_MODULE_2__);
3481
3636
  /*
3482
3637
  * BSD 3-Clause License
@@ -3562,7 +3717,7 @@ class CrudSetBase extends _CrudBase__WEBPACK_IMPORTED_MODULE_1__["default"] {
3562
3717
  }
3563
3718
 
3564
3719
  /***/ }),
3565
- /* 16 */
3720
+ /* 17 */
3566
3721
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3567
3722
 
3568
3723
  // ESM COMPAT FLAG
@@ -3581,15 +3736,15 @@ var enums = __webpack_require__(6);
3581
3736
  // EXTERNAL MODULE: ./src/oauth/DummyFlow.js
3582
3737
  var DummyFlow = __webpack_require__(72);
3583
3738
  // EXTERNAL MODULE: ./src/oauth/OAuth.js
3584
- var OAuth = __webpack_require__(19);
3739
+ var OAuth = __webpack_require__(13);
3585
3740
  // EXTERNAL MODULE: ./src/oauth/OAuthToken.js
3586
- var OAuthToken = __webpack_require__(12);
3741
+ var OAuthToken = __webpack_require__(10);
3587
3742
  // EXTERNAL MODULE: ./src/proxy/GeoResourceProxy.js
3588
3743
  var GeoResourceProxy = __webpack_require__(38);
3589
3744
  // EXTERNAL MODULE: ./src/proxy/ResourceProxy.js
3590
- var ResourceProxy = __webpack_require__(13);
3745
+ var ResourceProxy = __webpack_require__(14);
3591
3746
  // EXTERNAL MODULE: ./src/proxy/SimpleResourceProxy.js + 1 modules
3592
- var SimpleResourceProxy = __webpack_require__(14);
3747
+ var SimpleResourceProxy = __webpack_require__(15);
3593
3748
  // EXTERNAL MODULE: ./src/resources/index.js + 11 modules
3594
3749
  var resources = __webpack_require__(30);
3595
3750
  // EXTERNAL MODULE: ./src/resources/base/ResourceBase.js
@@ -3815,7 +3970,7 @@ class Mapcreator extends (0,reflection.mix)((external_events_default()), Injecta
3815
3970
  * @param {OAuth|string} auth - Authentication flow
3816
3971
  * @param {string} host - Remote API host
3817
3972
  */
3818
- constructor(auth = new DummyFlow["default"](), host = "https://api.mapcreator.io") {
3973
+ constructor(auth = new DummyFlow["default"](), host = "https://api.beta.mapcreator.io") {
3819
3974
  super();
3820
3975
 
3821
3976
  if (typeof auth === 'string') {
@@ -3999,6 +4154,8 @@ class Mapcreator extends (0,reflection.mix)((external_events_default()), Injecta
3999
4154
  // throwHttpErrors: false, // This is done through a custom hook
4000
4155
  // redirect: 'error',
4001
4156
  retry: 0,
4157
+ credentials: 'include',
4158
+ // Include cookies in requests
4002
4159
  headers: {
4003
4160
  'Accept': 'application/json',
4004
4161
  'X-No-CDN-Redirect': 'true'
@@ -4467,14 +4624,14 @@ class Mapcreator extends (0,reflection.mix)((external_events_default()), Injecta
4467
4624
  }
4468
4625
 
4469
4626
  /***/ }),
4470
- /* 17 */
4627
+ /* 18 */
4471
4628
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4472
4629
 
4473
4630
  __webpack_require__.r(__webpack_exports__);
4474
4631
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4475
4632
  /* harmony export */ "default": () => (/* binding */ OAuthError)
4476
4633
  /* harmony export */ });
4477
- /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(18);
4634
+ /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19);
4478
4635
  /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
4479
4636
 
4480
4637
 
@@ -4554,30 +4711,30 @@ class OAuthError extends Error {
4554
4711
  }
4555
4712
 
4556
4713
  /***/ }),
4557
- /* 18 */
4714
+ /* 19 */
4558
4715
  /***/ ((module) => {
4559
4716
 
4560
4717
  module.exports = require("@babel/runtime/helpers/defineProperty");
4561
4718
 
4562
4719
  /***/ }),
4563
- /* 19 */
4720
+ /* 20 */
4564
4721
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4565
4722
 
4723
+ // ESM COMPAT FLAG
4566
4724
  __webpack_require__.r(__webpack_exports__);
4567
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4568
- /* harmony export */ "default": () => (/* binding */ OAuth)
4569
- /* harmony export */ });
4570
- /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(18);
4571
- /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
4572
- /* harmony import */ var ky_universal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(31);
4573
- /* harmony import */ var ky_universal__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(ky_universal__WEBPACK_IMPORTED_MODULE_1__);
4574
- /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(21);
4575
- /* harmony import */ var _storage_StorageManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(22);
4576
- /* harmony import */ var _OAuthToken__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(12);
4577
- /* harmony import */ var _StateContainer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(37);
4578
- /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1);
4579
4725
 
4726
+ // EXPORTS
4727
+ __webpack_require__.d(__webpack_exports__, {
4728
+ "default": () => (/* binding */ StorageManager)
4729
+ });
4580
4730
 
4731
+ // EXTERNAL MODULE: ./src/utils/StaticClass.js
4732
+ var StaticClass = __webpack_require__(33);
4733
+ // EXTERNAL MODULE: ./src/utils/node.js
4734
+ var node = __webpack_require__(7);
4735
+ // EXTERNAL MODULE: ./src/storage/DataStoreContract.js
4736
+ var DataStoreContract = __webpack_require__(24);
4737
+ ;// CONCATENATED MODULE: ./src/storage/CookiesDriver.js
4581
4738
  /*
4582
4739
  * BSD 3-Clause License
4583
4740
  *
@@ -4611,452 +4768,47 @@ __webpack_require__.r(__webpack_exports__);
4611
4768
  */
4612
4769
 
4613
4770
 
4614
-
4615
-
4616
-
4617
-
4618
4771
  /**
4619
- * OAuth base class
4620
- * @abstract
4772
+ * @private
4773
+ * @todo fix
4621
4774
  */
4622
4775
 
4623
- class OAuth {
4624
- /**
4625
- * @param {String} clientId - OAuth client id
4626
- * @param {Array<String>} scopes - A list of required scopes
4627
- */
4628
- constructor(clientId, scopes = ['*']) {
4629
- _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(this, "token", null);
4630
-
4631
- _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(this, "path", '/');
4632
-
4633
- _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(this, "host", "https://api.mapcreator.io");
4634
-
4635
- if (this.constructor === OAuth) {
4636
- throw new _errors_AbstractError__WEBPACK_IMPORTED_MODULE_2__.AbstractClassError();
4637
- }
4638
-
4639
- this.clientId = String(clientId);
4640
- this.scopes = scopes;
4641
-
4642
- if (this.clientId) {
4643
- this.token = _OAuthToken__WEBPACK_IMPORTED_MODULE_4__["default"].recover();
4644
- }
4776
+ class CookiesDriver extends DataStoreContract["default"] {
4777
+ constructor(prefix = '_m4n_') {
4778
+ super();
4779
+ this.__prefix = prefix;
4645
4780
  }
4646
4781
  /**
4647
- * If the current instance has a valid token
4648
- * @returns {Boolean} - If a valid token is available
4782
+ * Cookie name prefix
4783
+ * @returns {String} - Prefix
4784
+ * @private
4649
4785
  */
4650
4786
 
4651
4787
 
4652
- get authenticated() {
4653
- return this.token !== null && !this.token.expired;
4788
+ get _prefix() {
4789
+ return this.__prefix;
4654
4790
  }
4655
4791
  /**
4656
- * Authenticate
4657
- * @returns {Promise<OAuthToken>} - Authentication token
4658
- * @throws {OAuthError}
4659
- * @abstract
4792
+ * @inheritDoc
4660
4793
  */
4661
4794
 
4662
4795
 
4663
- authenticate() {
4664
- throw new _errors_AbstractError__WEBPACK_IMPORTED_MODULE_2__.AbstractMethodError();
4796
+ static get secure() {
4797
+ return window.location.protocol === 'https:';
4665
4798
  }
4666
4799
  /**
4667
- * Forget the current session
4668
- * Empty the session token store and forget the api token
4800
+ * @inheritDoc
4669
4801
  */
4670
4802
 
4671
4803
 
4672
- forget() {
4673
- _StateContainer__WEBPACK_IMPORTED_MODULE_5__["default"].clean();
4674
- _storage_StorageManager__WEBPACK_IMPORTED_MODULE_3__["default"].secure.remove(_OAuthToken__WEBPACK_IMPORTED_MODULE_4__["default"].storageName);
4675
- this.token = null;
4804
+ static get available() {
4805
+ return !(0,node.isNode)();
4676
4806
  }
4677
4807
  /**
4678
- * Invalidates the session token
4679
- * @throws {OAuthError} - If de-authentication fails
4680
- * @throws {ApiError} - If the api returns errors
4681
- * @returns {CancelablePromise}
4682
- */
4683
-
4684
-
4685
- logout() {
4686
- if (!this.token) {
4687
- return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_6__.makeCancelable)(() => {});
4688
- }
4689
-
4690
- const url = `${this.host}/oauth/logout`;
4691
- return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_6__.makeCancelable)(async signal => {
4692
- await ky_universal__WEBPACK_IMPORTED_MODULE_1___default().post(url, {
4693
- headers: {
4694
- Accept: 'application/json',
4695
- Authorization: this.token.toString()
4696
- },
4697
- signal
4698
- });
4699
- this.forget();
4700
- });
4701
- }
4702
- /**
4703
- * Manually import OAuthToken, usefull for debugging
4704
- * @param {String} token - OAuth token
4705
- * @param {String} [type=Bearer] - token type
4706
- * @param {Date|Number} [expires=5 days] - expire time in seconds or Date
4707
- * @param {Array<string>} [scopes=[]] - Any scopes
4708
- */
4709
-
4710
-
4711
- importToken(token, type = 'Bearer', expires = 432000, scopes = []) {
4712
- this.token = new _OAuthToken__WEBPACK_IMPORTED_MODULE_4__["default"](token, type, expires, scopes);
4713
- }
4714
-
4715
- }
4716
-
4717
- /***/ }),
4718
- /* 20 */
4719
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4720
-
4721
- __webpack_require__.r(__webpack_exports__);
4722
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4723
- /* harmony export */ "default": () => (/* binding */ OwnedResourceProxy)
4724
- /* harmony export */ });
4725
- /* harmony import */ var _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14);
4726
- /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
4727
- /*
4728
- * BSD 3-Clause License
4729
- *
4730
- * Copyright (c) 2020, Mapcreator
4731
- * All rights reserved.
4732
- *
4733
- * Redistribution and use in source and binary forms, with or without
4734
- * modification, are permitted provided that the following conditions are met:
4735
- *
4736
- * Redistributions of source code must retain the above copyright notice, this
4737
- * list of conditions and the following disclaimer.
4738
- *
4739
- * Redistributions in binary form must reproduce the above copyright notice,
4740
- * this list of conditions and the following disclaimer in the documentation
4741
- * and/or other materials provided with the distribution.
4742
- *
4743
- * Neither the name of the copyright holder nor the names of its
4744
- * contributors may be used to endorse or promote products derived from
4745
- * this software without specific prior written permission.
4746
- *
4747
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
4748
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4749
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
4750
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
4751
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4752
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
4753
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
4754
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
4755
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4756
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4757
- */
4758
-
4759
-
4760
- /**
4761
- * Used for proxying resource => organisation
4762
- */
4763
-
4764
- class OwnedResourceProxy extends _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_0__["default"] {
4765
- /**
4766
- * OwnedResourceProxy Constructor
4767
- * @param {Mapcreator} api - Api instance
4768
- * @param {ResourceBase} parent - Parent instance
4769
- * @param {Class<ResourceBase>} Target - Target constructor
4770
- */
4771
- constructor(api, parent, Target) {
4772
- const resource = Target.resourceName.replace(/s+$/, '');
4773
- const url = `${parent.url}/${resource}s`;
4774
- super(api, Target, url);
4775
- }
4776
- /**
4777
- * Sync items to the organisation
4778
- * @param {Array<ResourceBase>|Array<number>|ResourceBase|number} items - List of items to sync
4779
- * @throws {TypeError}
4780
- * @throws {ApiError} - If the api returns errors
4781
- * @returns {CancelablePromise}
4782
- */
4783
-
4784
-
4785
- sync(items) {
4786
- return this._modifyResourceLink(items, 'PATCH');
4787
- }
4788
- /**
4789
- * Attach items to the organisation
4790
- * @param {Array<ResourceBase>|Array<number>|ResourceBase|number} items - List of items to attach
4791
- * @throws {TypeError}
4792
- * @throws {ApiError} - If the api returns errors
4793
- * @returns {CancelablePromise}
4794
- */
4795
-
4796
-
4797
- attach(items) {
4798
- return this._modifyResourceLink(items, 'POST');
4799
- }
4800
- /**
4801
- * Detach items from the organisation
4802
- * @param {Array<ResourceBase>|Array<number>|ResourceBase|number} items - List of items to unlink
4803
- * @throws {TypeError}
4804
- * @throws {ApiError} - If the api returns errors
4805
- * @returns {CancelablePromise}
4806
- */
4807
-
4808
-
4809
- detach(items) {
4810
- return this._modifyResourceLink(items, 'DELETE');
4811
- }
4812
- /**
4813
- * Attach parent resource to all organisations
4814
- * @throws {ApiError} - If the api returns errors
4815
- * @returns {CancelablePromise}
4816
- */
4817
-
4818
-
4819
- attachAll() {
4820
- return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_1__.makeCancelable)(async signal => {
4821
- await this.api.ky.post(`${this.baseUrl}/all`, {
4822
- signal
4823
- });
4824
- });
4825
- }
4826
- /**
4827
- * Detach parent resource to all organisations
4828
- * @throws {ApiError} - If the api returns errors
4829
- * @returns {CancelablePromise}
4830
- */
4831
-
4832
-
4833
- detachAll() {
4834
- return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_1__.makeCancelable)(async signal => {
4835
- await this.api.ky.delete(`${this.baseUrl}/all`, {
4836
- signal
4837
- });
4838
- });
4839
- }
4840
- /**
4841
- * @param {Array<ResourceBase>|Array<number>|ResourceBase|number} items - List of items to sync, attach or detach
4842
- * @param {string} method - http method
4843
- * @throws {ApiError} - If the api returns errors
4844
- * @throws {TypeError}
4845
- * @returns {CancelablePromise}
4846
- * @private
4847
- */
4848
-
4849
-
4850
- _modifyResourceLink(items, method) {
4851
- if (!Array.isArray(items)) {
4852
- items = [items];
4853
- }
4854
-
4855
- const keys = items.map(x => OwnedResourceProxy._getKeyValue(x)).map(Number).filter(x => !Number.isNaN(x));
4856
- return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_1__.makeCancelable)(async signal => {
4857
- await this.api.ky(this.baseUrl, {
4858
- method,
4859
- signal,
4860
- json: {
4861
- keys
4862
- }
4863
- });
4864
- });
4865
- }
4866
-
4867
- static _getKeyValue(item) {
4868
- if (['number', 'string'].includes(typeof item)) {
4869
- return item;
4870
- }
4871
-
4872
- const key = item.constructor.resourceUrlKey || 'id';
4873
-
4874
- if (typeof item[key] !== 'undefined') {
4875
- return item[key];
4876
- }
4877
-
4878
- throw new TypeError('Expected items to be of type Array<ResourceBase>, Array<number>, ResourceBase or number}');
4879
- }
4880
-
4881
- }
4882
-
4883
- /***/ }),
4884
- /* 21 */
4885
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4886
-
4887
- __webpack_require__.r(__webpack_exports__);
4888
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4889
- /* harmony export */ "AbstractError": () => (/* binding */ AbstractError),
4890
- /* harmony export */ "AbstractClassError": () => (/* binding */ AbstractClassError),
4891
- /* harmony export */ "AbstractMethodError": () => (/* binding */ AbstractMethodError)
4892
- /* harmony export */ });
4893
- /*
4894
- * BSD 3-Clause License
4895
- *
4896
- * Copyright (c) 2020, Mapcreator
4897
- * All rights reserved.
4898
- *
4899
- * Redistribution and use in source and binary forms, with or without
4900
- * modification, are permitted provided that the following conditions are met:
4901
- *
4902
- * Redistributions of source code must retain the above copyright notice, this
4903
- * list of conditions and the following disclaimer.
4904
- *
4905
- * Redistributions in binary form must reproduce the above copyright notice,
4906
- * this list of conditions and the following disclaimer in the documentation
4907
- * and/or other materials provided with the distribution.
4908
- *
4909
- * Neither the name of the copyright holder nor the names of its
4910
- * contributors may be used to endorse or promote products derived from
4911
- * this software without specific prior written permission.
4912
- *
4913
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
4914
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4915
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
4916
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
4917
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4918
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
4919
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
4920
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
4921
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4922
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4923
- */
4924
-
4925
- /**
4926
- * Thrown by abstract methods and classes
4927
- */
4928
- class AbstractError extends Error {
4929
- /**
4930
- * AbstractError constructor
4931
- * @param {?String} message - Error message
4932
- */
4933
- constructor(message = 'Unimplemented') {
4934
- super(message);
4935
- }
4936
-
4937
- }
4938
- /**
4939
- * Thrown upon invocation of an abstract class
4940
- * @example
4941
- * class FooBar {
4942
- * constructor() {
4943
- * if (this.constructor === FooBar) {
4944
- * throw new AbstractClassError();
4945
- * }
4946
- * }
4947
- * }
4948
- */
4949
-
4950
- class AbstractClassError extends AbstractError {
4951
- constructor() {
4952
- super('Can not make an instance of an abstract class');
4953
- }
4954
-
4955
- }
4956
- /**
4957
- * Thrown upon invocation of an abstract method
4958
- */
4959
-
4960
- class AbstractMethodError extends AbstractError {
4961
- constructor() {
4962
- super('Can not call an abstract method');
4963
- }
4964
-
4965
- }
4966
-
4967
- /***/ }),
4968
- /* 22 */
4969
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4970
-
4971
- // ESM COMPAT FLAG
4972
- __webpack_require__.r(__webpack_exports__);
4973
-
4974
- // EXPORTS
4975
- __webpack_require__.d(__webpack_exports__, {
4976
- "default": () => (/* binding */ StorageManager)
4977
- });
4978
-
4979
- // EXTERNAL MODULE: ./src/utils/StaticClass.js
4980
- var StaticClass = __webpack_require__(33);
4981
- // EXTERNAL MODULE: ./src/utils/node.js
4982
- var node = __webpack_require__(9);
4983
- // EXTERNAL MODULE: ./src/storage/DataStoreContract.js
4984
- var DataStoreContract = __webpack_require__(24);
4985
- ;// CONCATENATED MODULE: ./src/storage/CookiesDriver.js
4986
- /*
4987
- * BSD 3-Clause License
4988
- *
4989
- * Copyright (c) 2020, Mapcreator
4990
- * All rights reserved.
4991
- *
4992
- * Redistribution and use in source and binary forms, with or without
4993
- * modification, are permitted provided that the following conditions are met:
4994
- *
4995
- * Redistributions of source code must retain the above copyright notice, this
4996
- * list of conditions and the following disclaimer.
4997
- *
4998
- * Redistributions in binary form must reproduce the above copyright notice,
4999
- * this list of conditions and the following disclaimer in the documentation
5000
- * and/or other materials provided with the distribution.
5001
- *
5002
- * Neither the name of the copyright holder nor the names of its
5003
- * contributors may be used to endorse or promote products derived from
5004
- * this software without specific prior written permission.
5005
- *
5006
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5007
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5008
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5009
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5010
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5011
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5012
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5013
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5014
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5015
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5016
- */
5017
-
5018
-
5019
- /**
5020
- * @private
5021
- * @todo fix
5022
- */
5023
-
5024
- class CookiesDriver extends DataStoreContract["default"] {
5025
- constructor(prefix = '_m4n_') {
5026
- super();
5027
- this.__prefix = prefix;
5028
- }
5029
- /**
5030
- * Cookie name prefix
5031
- * @returns {String} - Prefix
5032
- * @private
5033
- */
5034
-
5035
-
5036
- get _prefix() {
5037
- return this.__prefix;
5038
- }
5039
- /**
5040
- * @inheritDoc
5041
- */
5042
-
5043
-
5044
- static get secure() {
5045
- return window.location.protocol === 'https:';
5046
- }
5047
- /**
5048
- * @inheritDoc
5049
- */
5050
-
5051
-
5052
- static get available() {
5053
- return !(0,node.isNode)();
5054
- }
5055
- /**
5056
- * Store a value in the storage
5057
- * @param {String} name - value name
5058
- * @param {*} value - value
5059
- * @param {Date|String} [expires=2050-01-01] - Expiration date
4808
+ * Store a value in the storage
4809
+ * @param {String} name - value name
4810
+ * @param {*} value - value
4811
+ * @param {Date|String} [expires=2050-01-01] - Expiration date
5060
4812
  */
5061
4813
 
5062
4814
 
@@ -5119,7 +4871,7 @@ class CookiesDriver extends DataStoreContract["default"] {
5119
4871
 
5120
4872
  }
5121
4873
  // EXTERNAL MODULE: external "@babel/runtime/helpers/defineProperty"
5122
- var defineProperty_ = __webpack_require__(18);
4874
+ var defineProperty_ = __webpack_require__(19);
5123
4875
  var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty_);
5124
4876
  ;// CONCATENATED MODULE: ./src/storage/DummyDriver.js
5125
4877
 
@@ -5299,40 +5051,328 @@ class LocalStorageDriver extends DataStoreContract["default"] {
5299
5051
  return window.localStorage.getItem(name);
5300
5052
  }
5301
5053
  /**
5302
- * Remove a value from the store
5303
- * @param {String} name - value name
5054
+ * Remove a value from the store
5055
+ * @param {String} name - value name
5056
+ */
5057
+
5058
+
5059
+ remove(name) {
5060
+ name = LocalStorageDriver._prefix + name;
5061
+ window.localStorage.removeItem(name);
5062
+ }
5063
+ /**
5064
+ * Storage keys
5065
+ * @returns {Array<String>} - Stored keys
5066
+ */
5067
+
5068
+
5069
+ keys() {
5070
+ const keys = [];
5071
+ const storage = window.localStorage;
5072
+ const prefix = LocalStorageDriver._prefix;
5073
+
5074
+ for (let i = 0; i < storage.length; i++) {
5075
+ let key = storage.key(i);
5076
+
5077
+ if (key.startsWith(prefix)) {
5078
+ key = key.replace(new RegExp(`^${prefix}`), '');
5079
+ keys.push(key);
5080
+ }
5081
+ }
5082
+
5083
+ return keys;
5084
+ }
5085
+
5086
+ }
5087
+ ;// CONCATENATED MODULE: ./src/storage/StorageManager.js
5088
+ /*
5089
+ * BSD 3-Clause License
5090
+ *
5091
+ * Copyright (c) 2020, Mapcreator
5092
+ * All rights reserved.
5093
+ *
5094
+ * Redistribution and use in source and binary forms, with or without
5095
+ * modification, are permitted provided that the following conditions are met:
5096
+ *
5097
+ * Redistributions of source code must retain the above copyright notice, this
5098
+ * list of conditions and the following disclaimer.
5099
+ *
5100
+ * Redistributions in binary form must reproduce the above copyright notice,
5101
+ * this list of conditions and the following disclaimer in the documentation
5102
+ * and/or other materials provided with the distribution.
5103
+ *
5104
+ * Neither the name of the copyright holder nor the names of its
5105
+ * contributors may be used to endorse or promote products derived from
5106
+ * this software without specific prior written permission.
5107
+ *
5108
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5109
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5110
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5111
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5112
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5113
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5114
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5115
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5116
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5117
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5118
+ */
5119
+
5120
+
5121
+
5122
+
5123
+
5124
+ /**
5125
+ * @private
5126
+ */
5127
+
5128
+ class StorageManager extends StaticClass["default"] {
5129
+ /**
5130
+ * Available storage drivers
5131
+ * @returns {Array.<function>} - Available storage drivers
5132
+ */
5133
+ static get available() {
5134
+ return [DummyDriver, LocalStorageDriver, // CookiesDriver,
5135
+ FileDriver["default"]].filter(x => x.available);
5136
+ }
5137
+ /**
5138
+ * Get LocalStorageDriver instance
5139
+ * @returns {LocalStorageDriver} - Instance
5140
+ */
5141
+
5142
+
5143
+ static get localStorage() {
5144
+ return new LocalStorageDriver();
5145
+ }
5146
+ /**
5147
+ * Get CookiesDriver instance
5148
+ * @returns {CookiesDriver} - Instance
5149
+ */
5150
+
5151
+
5152
+ static get cookies() {
5153
+ return new CookiesDriver();
5154
+ }
5155
+ /**
5156
+ * Get FileDriver instance
5157
+ * @returns {FileDriver} - Instance
5158
+ */
5159
+
5160
+
5161
+ static get file() {
5162
+ return new FileDriver["default"]();
5163
+ }
5164
+ /**
5165
+ * Get DummyDriver instance
5166
+ * @returns {DummyDriver} - Instance
5167
+ */
5168
+
5169
+
5170
+ static get dummy() {
5171
+ return new DummyDriver();
5172
+ }
5173
+ /**
5174
+ * Returns the best available storage driver. For a secure driver use {@link StorageManager#secure}
5175
+ * @returns {DataStoreContract} - Best available storage driver
5176
+ */
5177
+
5178
+
5179
+ static get best() {
5180
+ return new this.available[0]();
5181
+ }
5182
+ /**
5183
+ * Returns the a secure storage driver
5184
+ * @returns {DataStoreContract} - Secure storage driver
5185
+ */
5186
+
5187
+
5188
+ static get secure() {
5189
+ const C = this.available.filter(x => x.secure)[0];
5190
+
5191
+ if (typeof C === 'undefined') {
5192
+ return StorageManager.best;
5193
+ }
5194
+
5195
+ return new C();
5196
+ }
5197
+
5198
+ }
5199
+
5200
+ /***/ }),
5201
+ /* 21 */
5202
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
5203
+
5204
+ __webpack_require__.r(__webpack_exports__);
5205
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5206
+ /* harmony export */ "default": () => (/* binding */ OwnedResourceProxy)
5207
+ /* harmony export */ });
5208
+ /* harmony import */ var _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15);
5209
+ /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
5210
+ /*
5211
+ * BSD 3-Clause License
5212
+ *
5213
+ * Copyright (c) 2020, Mapcreator
5214
+ * All rights reserved.
5215
+ *
5216
+ * Redistribution and use in source and binary forms, with or without
5217
+ * modification, are permitted provided that the following conditions are met:
5218
+ *
5219
+ * Redistributions of source code must retain the above copyright notice, this
5220
+ * list of conditions and the following disclaimer.
5221
+ *
5222
+ * Redistributions in binary form must reproduce the above copyright notice,
5223
+ * this list of conditions and the following disclaimer in the documentation
5224
+ * and/or other materials provided with the distribution.
5225
+ *
5226
+ * Neither the name of the copyright holder nor the names of its
5227
+ * contributors may be used to endorse or promote products derived from
5228
+ * this software without specific prior written permission.
5229
+ *
5230
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5231
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5232
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5233
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5234
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5235
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5236
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5237
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5238
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5239
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5240
+ */
5241
+
5242
+
5243
+ /**
5244
+ * Used for proxying resource => organisation
5245
+ */
5246
+
5247
+ class OwnedResourceProxy extends _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_0__["default"] {
5248
+ /**
5249
+ * OwnedResourceProxy Constructor
5250
+ * @param {Mapcreator} api - Api instance
5251
+ * @param {ResourceBase} parent - Parent instance
5252
+ * @param {Class<ResourceBase>} Target - Target constructor
5253
+ */
5254
+ constructor(api, parent, Target) {
5255
+ const resource = Target.resourceName.replace(/s+$/, '');
5256
+ const url = `${parent.url}/${resource}s`;
5257
+ super(api, Target, url);
5258
+ }
5259
+ /**
5260
+ * Sync items to the organisation
5261
+ * @param {Array<ResourceBase>|Array<number>|ResourceBase|number} items - List of items to sync
5262
+ * @throws {TypeError}
5263
+ * @throws {ApiError} - If the api returns errors
5264
+ * @returns {CancelablePromise}
5265
+ */
5266
+
5267
+
5268
+ sync(items) {
5269
+ return this._modifyResourceLink(items, 'PATCH');
5270
+ }
5271
+ /**
5272
+ * Attach items to the organisation
5273
+ * @param {Array<ResourceBase>|Array<number>|ResourceBase|number} items - List of items to attach
5274
+ * @throws {TypeError}
5275
+ * @throws {ApiError} - If the api returns errors
5276
+ * @returns {CancelablePromise}
5277
+ */
5278
+
5279
+
5280
+ attach(items) {
5281
+ return this._modifyResourceLink(items, 'POST');
5282
+ }
5283
+ /**
5284
+ * Detach items from the organisation
5285
+ * @param {Array<ResourceBase>|Array<number>|ResourceBase|number} items - List of items to unlink
5286
+ * @throws {TypeError}
5287
+ * @throws {ApiError} - If the api returns errors
5288
+ * @returns {CancelablePromise}
5289
+ */
5290
+
5291
+
5292
+ detach(items) {
5293
+ return this._modifyResourceLink(items, 'DELETE');
5294
+ }
5295
+ /**
5296
+ * Attach parent resource to all organisations
5297
+ * @throws {ApiError} - If the api returns errors
5298
+ * @returns {CancelablePromise}
5299
+ */
5300
+
5301
+
5302
+ attachAll() {
5303
+ return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_1__.makeCancelable)(async signal => {
5304
+ await this.api.ky.post(`${this.baseUrl}/all`, {
5305
+ signal
5306
+ });
5307
+ });
5308
+ }
5309
+ /**
5310
+ * Detach parent resource to all organisations
5311
+ * @throws {ApiError} - If the api returns errors
5312
+ * @returns {CancelablePromise}
5304
5313
  */
5305
5314
 
5306
5315
 
5307
- remove(name) {
5308
- name = LocalStorageDriver._prefix + name;
5309
- window.localStorage.removeItem(name);
5316
+ detachAll() {
5317
+ return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_1__.makeCancelable)(async signal => {
5318
+ await this.api.ky.delete(`${this.baseUrl}/all`, {
5319
+ signal
5320
+ });
5321
+ });
5310
5322
  }
5311
5323
  /**
5312
- * Storage keys
5313
- * @returns {Array<String>} - Stored keys
5324
+ * @param {Array<ResourceBase>|Array<number>|ResourceBase|number} items - List of items to sync, attach or detach
5325
+ * @param {string} method - http method
5326
+ * @throws {ApiError} - If the api returns errors
5327
+ * @throws {TypeError}
5328
+ * @returns {CancelablePromise}
5329
+ * @private
5314
5330
  */
5315
5331
 
5316
5332
 
5317
- keys() {
5318
- const keys = [];
5319
- const storage = window.localStorage;
5320
- const prefix = LocalStorageDriver._prefix;
5333
+ _modifyResourceLink(items, method) {
5334
+ if (!Array.isArray(items)) {
5335
+ items = [items];
5336
+ }
5321
5337
 
5322
- for (let i = 0; i < storage.length; i++) {
5323
- let key = storage.key(i);
5338
+ const keys = items.map(x => OwnedResourceProxy._getKeyValue(x)).map(Number).filter(x => !Number.isNaN(x));
5339
+ return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_1__.makeCancelable)(async signal => {
5340
+ await this.api.ky(this.baseUrl, {
5341
+ method,
5342
+ signal,
5343
+ json: {
5344
+ keys
5345
+ }
5346
+ });
5347
+ });
5348
+ }
5324
5349
 
5325
- if (key.startsWith(prefix)) {
5326
- key = key.replace(new RegExp(`^${prefix}`), '');
5327
- keys.push(key);
5328
- }
5350
+ static _getKeyValue(item) {
5351
+ if (['number', 'string'].includes(typeof item)) {
5352
+ return item;
5329
5353
  }
5330
5354
 
5331
- return keys;
5355
+ const key = item.constructor.resourceUrlKey || 'id';
5356
+
5357
+ if (typeof item[key] !== 'undefined') {
5358
+ return item[key];
5359
+ }
5360
+
5361
+ throw new TypeError('Expected items to be of type Array<ResourceBase>, Array<number>, ResourceBase or number}');
5332
5362
  }
5333
5363
 
5334
5364
  }
5335
- ;// CONCATENATED MODULE: ./src/storage/StorageManager.js
5365
+
5366
+ /***/ }),
5367
+ /* 22 */
5368
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
5369
+
5370
+ __webpack_require__.r(__webpack_exports__);
5371
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5372
+ /* harmony export */ "AbstractError": () => (/* binding */ AbstractError),
5373
+ /* harmony export */ "AbstractClassError": () => (/* binding */ AbstractClassError),
5374
+ /* harmony export */ "AbstractMethodError": () => (/* binding */ AbstractMethodError)
5375
+ /* harmony export */ });
5336
5376
  /*
5337
5377
  * BSD 3-Clause License
5338
5378
  *
@@ -5365,82 +5405,44 @@ class LocalStorageDriver extends DataStoreContract["default"] {
5365
5405
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5366
5406
  */
5367
5407
 
5368
-
5369
-
5370
-
5371
-
5372
5408
  /**
5373
- * @private
5409
+ * Thrown by abstract methods and classes
5374
5410
  */
5375
-
5376
- class StorageManager extends StaticClass["default"] {
5377
- /**
5378
- * Available storage drivers
5379
- * @returns {Array.<function>} - Available storage drivers
5380
- */
5381
- static get available() {
5382
- return [DummyDriver, LocalStorageDriver, // CookiesDriver,
5383
- FileDriver["default"]].filter(x => x.available);
5384
- }
5385
- /**
5386
- * Get LocalStorageDriver instance
5387
- * @returns {LocalStorageDriver} - Instance
5388
- */
5389
-
5390
-
5391
- static get localStorage() {
5392
- return new LocalStorageDriver();
5393
- }
5394
- /**
5395
- * Get CookiesDriver instance
5396
- * @returns {CookiesDriver} - Instance
5397
- */
5398
-
5399
-
5400
- static get cookies() {
5401
- return new CookiesDriver();
5402
- }
5403
- /**
5404
- * Get FileDriver instance
5405
- * @returns {FileDriver} - Instance
5406
- */
5407
-
5408
-
5409
- static get file() {
5410
- return new FileDriver["default"]();
5411
- }
5411
+ class AbstractError extends Error {
5412
5412
  /**
5413
- * Get DummyDriver instance
5414
- * @returns {DummyDriver} - Instance
5413
+ * AbstractError constructor
5414
+ * @param {?String} message - Error message
5415
5415
  */
5416
-
5417
-
5418
- static get dummy() {
5419
- return new DummyDriver();
5416
+ constructor(message = 'Unimplemented') {
5417
+ super(message);
5420
5418
  }
5421
- /**
5422
- * Returns the best available storage driver. For a secure driver use {@link StorageManager#secure}
5423
- * @returns {DataStoreContract} - Best available storage driver
5424
- */
5425
5419
 
5420
+ }
5421
+ /**
5422
+ * Thrown upon invocation of an abstract class
5423
+ * @example
5424
+ * class FooBar {
5425
+ * constructor() {
5426
+ * if (this.constructor === FooBar) {
5427
+ * throw new AbstractClassError();
5428
+ * }
5429
+ * }
5430
+ * }
5431
+ */
5426
5432
 
5427
- static get best() {
5428
- return new this.available[0]();
5433
+ class AbstractClassError extends AbstractError {
5434
+ constructor() {
5435
+ super('Can not make an instance of an abstract class');
5429
5436
  }
5430
- /**
5431
- * Returns the a secure storage driver
5432
- * @returns {DataStoreContract} - Secure storage driver
5433
- */
5434
-
5435
-
5436
- static get secure() {
5437
- const C = this.available.filter(x => x.secure)[0];
5438
5437
 
5439
- if (typeof C === 'undefined') {
5440
- return StorageManager.best;
5441
- }
5438
+ }
5439
+ /**
5440
+ * Thrown upon invocation of an abstract method
5441
+ */
5442
5442
 
5443
- return new C();
5443
+ class AbstractMethodError extends AbstractError {
5444
+ constructor() {
5445
+ super('Can not call an abstract method');
5444
5446
  }
5445
5447
 
5446
5448
  }
@@ -5535,7 +5537,7 @@ __webpack_require__.r(__webpack_exports__);
5535
5537
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5536
5538
  /* harmony export */ "default": () => (/* binding */ DataStoreContract)
5537
5539
  /* harmony export */ });
5538
- /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(21);
5540
+ /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(22);
5539
5541
  /*
5540
5542
  * BSD 3-Clause License
5541
5543
  *
@@ -5760,7 +5762,7 @@ function base64Encode(buffer) {
5760
5762
  return base64;
5761
5763
  }
5762
5764
  // EXTERNAL MODULE: ./src/utils/node.js
5763
- var node = __webpack_require__(9);
5765
+ var node = __webpack_require__(7);
5764
5766
  ;// CONCATENATED MODULE: ./src/resources/base/DownloadedResource.js
5765
5767
  /*
5766
5768
  * BSD 3-Clause License
@@ -6089,13 +6091,13 @@ var OwnableResource = __webpack_require__(4);
6089
6091
  // EXTERNAL MODULE: ./src/utils/reflection.js
6090
6092
  var reflection = __webpack_require__(0);
6091
6093
  // EXTERNAL MODULE: ./src/resources/base/CrudSetBase.js
6092
- var CrudSetBase = __webpack_require__(15);
6094
+ var CrudSetBase = __webpack_require__(16);
6093
6095
  // EXTERNAL MODULE: ./src/resources/Mapstyle.js
6094
6096
  var Mapstyle = __webpack_require__(66);
6095
6097
  // EXTERNAL MODULE: ./src/proxy/ResourceProxy.js
6096
- var ResourceProxy = __webpack_require__(13);
6098
+ var ResourceProxy = __webpack_require__(14);
6097
6099
  // EXTERNAL MODULE: ./src/resources/base/CrudSetItemBase.js
6098
- var CrudSetItemBase = __webpack_require__(10);
6100
+ var CrudSetItemBase = __webpack_require__(11);
6099
6101
  ;// CONCATENATED MODULE: ./src/resources/MapstyleSetColor.js
6100
6102
  /*
6101
6103
  * BSD 3-Clause License
@@ -6224,7 +6226,7 @@ __webpack_require__.r(__webpack_exports__);
6224
6226
  /* harmony export */ });
6225
6227
  /* harmony import */ var _traits_OwnableResource__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
6226
6228
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
6227
- /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(10);
6229
+ /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
6228
6230
  /*
6229
6231
  * BSD 3-Clause License
6230
6232
  *
@@ -6571,7 +6573,7 @@ var Language = __webpack_require__(67);
6571
6573
  // EXTERNAL MODULE: ./src/resources/Layer.js
6572
6574
  var Layer = __webpack_require__(27);
6573
6575
  // EXTERNAL MODULE: ./src/resources/base/CrudSetItemBase.js
6574
- var CrudSetItemBase = __webpack_require__(10);
6576
+ var CrudSetItemBase = __webpack_require__(11);
6575
6577
  ;// CONCATENATED MODULE: ./src/resources/LayerFaq.js
6576
6578
  /*
6577
6579
  * BSD 3-Clause License
@@ -6697,7 +6699,7 @@ class OrganisationNote extends (0,reflection.mix)(CrudBase["default"], OwnableRe
6697
6699
  // EXTERNAL MODULE: ./src/resources/Permission.js
6698
6700
  var Permission = __webpack_require__(55);
6699
6701
  // EXTERNAL MODULE: ./src/resources/base/CrudSetBase.js
6700
- var CrudSetBase = __webpack_require__(15);
6702
+ var CrudSetBase = __webpack_require__(16);
6701
6703
  ;// CONCATENATED MODULE: ./src/resources/ProductTourStep.js
6702
6704
  /*
6703
6705
  * BSD 3-Clause License
@@ -7150,7 +7152,7 @@ __webpack_require__.r(__webpack_exports__);
7150
7152
  /* harmony export */ "default": () => (/* binding */ OrganisationProxy)
7151
7153
  /* harmony export */ });
7152
7154
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
7153
- /* harmony import */ var _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(14);
7155
+ /* harmony import */ var _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(15);
7154
7156
  /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
7155
7157
  /*
7156
7158
  * BSD 3-Clause License
@@ -7338,7 +7340,7 @@ __webpack_require__.d(__webpack_exports__, {
7338
7340
  });
7339
7341
 
7340
7342
  // EXTERNAL MODULE: ./src/errors/AbstractError.js
7341
- var AbstractError = __webpack_require__(21);
7343
+ var AbstractError = __webpack_require__(22);
7342
7344
  // EXTERNAL MODULE: ./src/errors/ApiError.js
7343
7345
  var ApiError = __webpack_require__(62);
7344
7346
  // EXTERNAL MODULE: ./src/errors/ValidationError.js
@@ -7381,7 +7383,7 @@ var ValidationError = __webpack_require__(74);
7381
7383
  */
7382
7384
  class NodeError extends Error {}
7383
7385
  // EXTERNAL MODULE: ./src/errors/OAuthError.js
7384
- var OAuthError = __webpack_require__(17);
7386
+ var OAuthError = __webpack_require__(18);
7385
7387
  // EXTERNAL MODULE: ./src/errors/StaticClassError.js
7386
7388
  var StaticClassError = __webpack_require__(57);
7387
7389
  // EXTERNAL MODULE: ./src/errors/GeoError.js
@@ -7479,7 +7481,7 @@ class MessageVariant extends ResourceBase["default"] {}
7479
7481
  // EXTERNAL MODULE: ./src/utils/helpers.js
7480
7482
  var helpers = __webpack_require__(1);
7481
7483
  // EXTERNAL MODULE: external "case"
7482
- var external_case_ = __webpack_require__(8);
7484
+ var external_case_ = __webpack_require__(9);
7483
7485
  ;// CONCATENATED MODULE: ./src/resources/Message.js
7484
7486
  /*
7485
7487
  * BSD 3-Clause License
@@ -7587,7 +7589,7 @@ __webpack_require__.d(__webpack_exports__, {
7587
7589
  });
7588
7590
 
7589
7591
  // EXTERNAL MODULE: ./src/storage/StorageManager.js + 3 modules
7590
- var StorageManager = __webpack_require__(22);
7592
+ var StorageManager = __webpack_require__(20);
7591
7593
  // EXTERNAL MODULE: ./src/utils/StaticClass.js
7592
7594
  var StaticClass = __webpack_require__(33);
7593
7595
  ;// CONCATENATED MODULE: ./src/utils/uuid.js
@@ -7776,9 +7778,9 @@ __webpack_require__.r(__webpack_exports__);
7776
7778
  /* harmony export */ "default": () => (/* binding */ GeoResourceProxy)
7777
7779
  /* harmony export */ });
7778
7780
  /* harmony import */ var _errors_GeoError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(39);
7779
- /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
7781
+ /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8);
7780
7782
  /* harmony import */ var _utils_geo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(60);
7781
- /* harmony import */ var _ResourceProxy__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(13);
7783
+ /* harmony import */ var _ResourceProxy__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(14);
7782
7784
  /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1);
7783
7785
  /*
7784
7786
  * BSD 3-Clause License
@@ -8000,7 +8002,7 @@ __webpack_require__.r(__webpack_exports__);
8000
8002
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8001
8003
  /* harmony export */ "default": () => (/* binding */ Organisation)
8002
8004
  /* harmony export */ });
8003
- /* harmony import */ var _proxy_OwnedResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20);
8005
+ /* harmony import */ var _proxy_OwnedResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(21);
8004
8006
  /* harmony import */ var _base_CrudBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
8005
8007
  /* harmony import */ var _Color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(42);
8006
8008
  /* harmony import */ var _Contract__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(63);
@@ -8020,7 +8022,7 @@ __webpack_require__.r(__webpack_exports__);
8020
8022
  /* harmony import */ var _utils_requests__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(5);
8021
8023
  /* harmony import */ var _LayerGroup__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(70);
8022
8024
  /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(30);
8023
- /* harmony import */ var _proxy_ResourceProxy__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(13);
8025
+ /* harmony import */ var _proxy_ResourceProxy__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(14);
8024
8026
  /*
8025
8027
  * BSD 3-Clause License
8026
8028
  *
@@ -8331,7 +8333,7 @@ __webpack_require__.r(__webpack_exports__);
8331
8333
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8332
8334
  /* harmony export */ "default": () => (/* binding */ DimensionSet)
8333
8335
  /* harmony export */ });
8334
- /* harmony import */ var _base_CrudSetBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15);
8336
+ /* harmony import */ var _base_CrudSetBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16);
8335
8337
  /* harmony import */ var _Dimension__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(44);
8336
8338
  /* harmony import */ var _traits_OwnableResource__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
8337
8339
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(0);
@@ -8399,7 +8401,7 @@ __webpack_require__.r(__webpack_exports__);
8399
8401
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8400
8402
  /* harmony export */ "default": () => (/* binding */ Dimension)
8401
8403
  /* harmony export */ });
8402
- /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
8404
+ /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11);
8403
8405
  /*
8404
8406
  * BSD 3-Clause License
8405
8407
  *
@@ -8511,7 +8513,7 @@ __webpack_require__.r(__webpack_exports__);
8511
8513
  /* harmony export */ });
8512
8514
  /* harmony import */ var _traits_OwnableResource__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
8513
8515
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
8514
- /* harmony import */ var _base_CrudSetBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(15);
8516
+ /* harmony import */ var _base_CrudSetBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(16);
8515
8517
  /* harmony import */ var _Font__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(47);
8516
8518
  /*
8517
8519
  * BSD 3-Clause License
@@ -8577,7 +8579,7 @@ __webpack_require__.r(__webpack_exports__);
8577
8579
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8578
8580
  /* harmony export */ "default": () => (/* binding */ Font)
8579
8581
  /* harmony export */ });
8580
- /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
8582
+ /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11);
8581
8583
  /*
8582
8584
  * BSD 3-Clause License
8583
8585
  *
@@ -8629,12 +8631,12 @@ __webpack_require__.r(__webpack_exports__);
8629
8631
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8630
8632
  /* harmony export */ "default": () => (/* binding */ Job)
8631
8633
  /* harmony export */ });
8632
- /* harmony import */ var _proxy_ResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(13);
8634
+ /* harmony import */ var _proxy_ResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14);
8633
8635
  /* harmony import */ var _base_DownloadedResource__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(25);
8634
8636
  /* harmony import */ var _base_CrudBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
8635
8637
  /* harmony import */ var _JobResult__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(49);
8636
8638
  /* harmony import */ var _JobRevision__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(65);
8637
- /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7);
8639
+ /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8);
8638
8640
  /* harmony import */ var _utils_requests__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5);
8639
8641
  /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(6);
8640
8642
  /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1);
@@ -8831,7 +8833,7 @@ __webpack_require__.r(__webpack_exports__);
8831
8833
  /* harmony export */ });
8832
8834
  /* harmony import */ var _base_DownloadedResource__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25);
8833
8835
  /* harmony import */ var _base_ResourceBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
8834
- /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7);
8836
+ /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);
8835
8837
  /* harmony import */ var _utils_requests__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5);
8836
8838
  /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6);
8837
8839
  /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1);
@@ -9057,7 +9059,7 @@ __webpack_require__.d(__webpack_exports__, {
9057
9059
  // EXTERNAL MODULE: ./src/traits/Trait.js
9058
9060
  var Trait = __webpack_require__(32);
9059
9061
  // EXTERNAL MODULE: ./src/Mapcreator.js + 1 modules
9060
- var Mapcreator = __webpack_require__(16);
9062
+ var Mapcreator = __webpack_require__(17);
9061
9063
  // EXTERNAL MODULE: ./src/resources/base/DownloadedResource.js + 1 modules
9062
9064
  var DownloadedResource = __webpack_require__(25);
9063
9065
  // EXTERNAL MODULE: ./src/resources/base/ResourceBase.js
@@ -9335,7 +9337,7 @@ __webpack_require__.r(__webpack_exports__);
9335
9337
  /* harmony export */ "default": () => (/* binding */ SvgSet)
9336
9338
  /* harmony export */ });
9337
9339
  /* harmony import */ var _traits_OwnableResource__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
9338
- /* harmony import */ var _base_CrudSetBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(15);
9340
+ /* harmony import */ var _base_CrudSetBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16);
9339
9341
  /* harmony import */ var _Svg__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(53);
9340
9342
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(0);
9341
9343
  /*
@@ -9402,7 +9404,7 @@ __webpack_require__.r(__webpack_exports__);
9402
9404
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9403
9405
  /* harmony export */ "default": () => (/* binding */ Svg)
9404
9406
  /* harmony export */ });
9405
- /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
9407
+ /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11);
9406
9408
  /*
9407
9409
  * BSD 3-Clause License
9408
9410
  *
@@ -9450,8 +9452,8 @@ __webpack_require__.r(__webpack_exports__);
9450
9452
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9451
9453
  /* harmony export */ "default": () => (/* binding */ User)
9452
9454
  /* harmony export */ });
9453
- /* harmony import */ var _proxy_OwnedResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20);
9454
- /* harmony import */ var _proxy_ResourceProxy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(13);
9455
+ /* harmony import */ var _proxy_OwnedResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(21);
9456
+ /* harmony import */ var _proxy_ResourceProxy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(14);
9455
9457
  /* harmony import */ var _base_CrudBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
9456
9458
  /* harmony import */ var _Color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(42);
9457
9459
  /* harmony import */ var _Dimension__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(44);
@@ -9852,7 +9854,7 @@ __webpack_require__.r(__webpack_exports__);
9852
9854
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9853
9855
  /* harmony export */ "default": () => (/* binding */ FileDriver)
9854
9856
  /* harmony export */ });
9855
- /* harmony import */ var _utils_node__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9);
9857
+ /* harmony import */ var _utils_node__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7);
9856
9858
  /* harmony import */ var _DataStoreContract__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(24);
9857
9859
  /*
9858
9860
  * BSD 3-Clause License
@@ -10057,7 +10059,7 @@ __webpack_require__.r(__webpack_exports__);
10057
10059
  /* harmony export */ "GeoPoint": () => (/* binding */ GeoPoint),
10058
10060
  /* harmony export */ "GeoBoundary": () => (/* binding */ GeoBoundary)
10059
10061
  /* harmony export */ });
10060
- /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(18);
10062
+ /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19);
10061
10063
  /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
10062
10064
  /* harmony import */ var _errors_GeoError__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(39);
10063
10065
 
@@ -10420,7 +10422,7 @@ class Injectable extends _Trait__WEBPACK_IMPORTED_MODULE_2__["default"] {
10420
10422
  const OwnableResource = (__webpack_require__(4)["default"]);
10421
10423
 
10422
10424
  if ((0,_utils_reflection__WEBPACK_IMPORTED_MODULE_1__.hasTrait)(value, OwnableResource)) {
10423
- const OwnedResourceProxy = (__webpack_require__(20)["default"]);
10425
+ const OwnedResourceProxy = (__webpack_require__(21)["default"]);
10424
10426
 
10425
10427
  this._inject(name, function () {
10426
10428
  return new OwnedResourceProxy(this.api, this, value);
@@ -10431,7 +10433,7 @@ class Injectable extends _Trait__WEBPACK_IMPORTED_MODULE_2__["default"] {
10431
10433
  return this._proxyResourceList(value);
10432
10434
  });
10433
10435
  } else {
10434
- const ResourceProxy = (__webpack_require__(13)["default"]);
10436
+ const ResourceProxy = (__webpack_require__(14)["default"]);
10435
10437
 
10436
10438
  this._inject(name, function () {
10437
10439
  return new ResourceProxy(this, value);
@@ -10466,7 +10468,7 @@ __webpack_require__.r(__webpack_exports__);
10466
10468
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10467
10469
  /* harmony export */ "default": () => (/* binding */ ApiError)
10468
10470
  /* harmony export */ });
10469
- /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(18);
10471
+ /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19);
10470
10472
  /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
10471
10473
 
10472
10474
 
@@ -10739,7 +10741,7 @@ __webpack_require__.r(__webpack_exports__);
10739
10741
  /* harmony import */ var _JobResult__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(49);
10740
10742
  /* harmony import */ var _JobShare__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(26);
10741
10743
  /* harmony import */ var _Layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(27);
10742
- /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7);
10744
+ /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8);
10743
10745
  /* harmony import */ var _utils_requests__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5);
10744
10746
  /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(6);
10745
10747
  /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1);
@@ -10990,7 +10992,7 @@ __webpack_require__.r(__webpack_exports__);
10990
10992
  /* harmony export */ });
10991
10993
  /* harmony import */ var _traits_HandlesImages__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(50);
10992
10994
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
10993
- /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(10);
10995
+ /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
10994
10996
  /*
10995
10997
  * BSD 3-Clause License
10996
10998
  *
@@ -11153,7 +11155,7 @@ __webpack_require__.r(__webpack_exports__);
11153
11155
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11154
11156
  /* harmony export */ "default": () => (/* binding */ Role)
11155
11157
  /* harmony export */ });
11156
- /* harmony import */ var _proxy_OwnedResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20);
11158
+ /* harmony import */ var _proxy_OwnedResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(21);
11157
11159
  /* harmony import */ var _base_CrudBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
11158
11160
  /* harmony import */ var _Permission__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(55);
11159
11161
  /* harmony import */ var _User__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(54);
@@ -11227,7 +11229,7 @@ __webpack_require__.r(__webpack_exports__);
11227
11229
  /* harmony import */ var _traits_OwnableResource__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
11228
11230
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
11229
11231
  /* harmony import */ var _Layer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(27);
11230
- /* harmony import */ var _base_CrudSetBase__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(15);
11232
+ /* harmony import */ var _base_CrudSetBase__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(16);
11231
11233
  /* harmony import */ var _proxy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(71);
11232
11234
  /*
11233
11235
  * BSD 3-Clause License
@@ -11301,9 +11303,9 @@ __webpack_require__.r(__webpack_exports__);
11301
11303
  /* harmony export */ });
11302
11304
  /* harmony import */ var _GeoResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(38);
11303
11305
  /* harmony import */ var _OrganisationProxy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(34);
11304
- /* harmony import */ var _OwnedResourceProxy__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(20);
11305
- /* harmony import */ var _ResourceProxy__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(13);
11306
- /* harmony import */ var _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(14);
11306
+ /* harmony import */ var _OwnedResourceProxy__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(21);
11307
+ /* harmony import */ var _ResourceProxy__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(14);
11308
+ /* harmony import */ var _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(15);
11307
11309
  /*
11308
11310
  * BSD 3-Clause License
11309
11311
  *
@@ -11349,8 +11351,8 @@ __webpack_require__.r(__webpack_exports__);
11349
11351
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11350
11352
  /* harmony export */ "default": () => (/* binding */ DummyFlow)
11351
11353
  /* harmony export */ });
11352
- /* harmony import */ var _errors_OAuthError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(17);
11353
- /* harmony import */ var _OAuth__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(19);
11354
+ /* harmony import */ var _errors_OAuthError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(18);
11355
+ /* harmony import */ var _OAuth__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(13);
11354
11356
  /*
11355
11357
  * BSD 3-Clause License
11356
11358
  *
@@ -11424,12 +11426,12 @@ __webpack_require__.r(__webpack_exports__);
11424
11426
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11425
11427
  /* harmony export */ "default": () => (/* binding */ ResourceLister)
11426
11428
  /* harmony export */ });
11427
- /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
11429
+ /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9);
11428
11430
  /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(case__WEBPACK_IMPORTED_MODULE_0__);
11429
11431
  /* harmony import */ var events__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(40);
11430
11432
  /* harmony import */ var events__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(events__WEBPACK_IMPORTED_MODULE_1__);
11431
- /* harmony import */ var _Mapcreator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(16);
11432
- /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7);
11433
+ /* harmony import */ var _Mapcreator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(17);
11434
+ /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8);
11433
11435
  /* harmony import */ var _resources_base_ResourceBase__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3);
11434
11436
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(0);
11435
11437
  /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1);
@@ -11826,7 +11828,7 @@ __webpack_require__.r(__webpack_exports__);
11826
11828
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11827
11829
  /* harmony export */ "default": () => (/* binding */ ValidationError)
11828
11830
  /* harmony export */ });
11829
- /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(18);
11831
+ /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19);
11830
11832
  /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
11831
11833
  /* harmony import */ var _ApiError__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(62);
11832
11834
 
@@ -12090,6 +12092,7 @@ __webpack_require__.d(__webpack_exports__, {
12090
12092
  "AbstractError": () => (/* reexport */ AbstractError.AbstractError),
12091
12093
  "AbstractMethodError": () => (/* reexport */ AbstractError.AbstractMethodError),
12092
12094
  "ApiError": () => (/* reexport */ ApiError["default"]),
12095
+ "CookieFlow": () => (/* reexport */ CookieFlow),
12093
12096
  "DeletedState": () => (/* reexport */ enums.DeletedState),
12094
12097
  "DummyFlow": () => (/* reexport */ DummyFlow["default"]),
12095
12098
  "Enum": () => (/* reexport */ Enum["default"]),
@@ -12114,29 +12117,29 @@ __webpack_require__.d(__webpack_exports__, {
12114
12117
  });
12115
12118
 
12116
12119
  // EXTERNAL MODULE: ./src/Mapcreator.js + 1 modules
12117
- var Mapcreator = __webpack_require__(16);
12120
+ var Mapcreator = __webpack_require__(17);
12118
12121
  // EXTERNAL MODULE: ./src/RequestParameters.js
12119
- var RequestParameters = __webpack_require__(7);
12122
+ var RequestParameters = __webpack_require__(8);
12120
12123
  // EXTERNAL MODULE: ./src/storage/StorageManager.js + 3 modules
12121
- var StorageManager = __webpack_require__(22);
12124
+ var StorageManager = __webpack_require__(20);
12122
12125
  // EXTERNAL MODULE: ./src/enums/Enum.js + 1 modules
12123
- var Enum = __webpack_require__(11);
12126
+ var Enum = __webpack_require__(12);
12124
12127
  // EXTERNAL MODULE: ./src/enums/index.js + 3 modules
12125
12128
  var enums = __webpack_require__(6);
12126
12129
  // EXTERNAL MODULE: ./src/oauth/OAuth.js
12127
- var OAuth = __webpack_require__(19);
12130
+ var OAuth = __webpack_require__(13);
12128
12131
  // EXTERNAL MODULE: ./src/oauth/OAuthToken.js
12129
- var OAuthToken = __webpack_require__(12);
12132
+ var OAuthToken = __webpack_require__(10);
12130
12133
  // EXTERNAL MODULE: ./src/oauth/StateContainer.js + 1 modules
12131
12134
  var StateContainer = __webpack_require__(37);
12132
12135
  // EXTERNAL MODULE: ./src/utils/requests.js
12133
12136
  var requests = __webpack_require__(5);
12134
12137
  // EXTERNAL MODULE: ./src/errors/OAuthError.js
12135
- var OAuthError = __webpack_require__(17);
12138
+ var OAuthError = __webpack_require__(18);
12136
12139
  // EXTERNAL MODULE: ./src/utils/node.js
12137
- var node = __webpack_require__(9);
12140
+ var node = __webpack_require__(7);
12138
12141
  // EXTERNAL MODULE: external "case"
12139
- var external_case_ = __webpack_require__(8);
12142
+ var external_case_ = __webpack_require__(9);
12140
12143
  ;// CONCATENATED MODULE: ./src/oauth/ImplicitFlow.js
12141
12144
  /*
12142
12145
  * BSD 3-Clause License
@@ -12397,6 +12400,7 @@ class ImplicitFlow extends OAuth["default"] {
12397
12400
 
12398
12401
 
12399
12402
 
12403
+
12400
12404
  /**
12401
12405
  * Implicit OAuth flow using a pop-up.
12402
12406
  */
@@ -12448,25 +12452,24 @@ class ImplicitFlowPopup extends ImplicitFlow {
12448
12452
  }
12449
12453
 
12450
12454
  return new Promise((resolve, reject) => {
12455
+ const localStorage = StorageManager["default"].localStorage;
12456
+ const storageName = 'api_auth';
12457
+ localStorage.remove(storageName);
12451
12458
  const popup = window.open(this._buildRedirectUrl(), ImplicitFlowPopup.popupWindowName, this.windowOptions);
12452
12459
  const ticker = setInterval(() => {
12453
- if (popup.closed) {
12454
- reject(new OAuthError["default"]('window_closed', 'Pop-up window was closed before data could be extracted'));
12455
- }
12456
-
12457
- let done = false;
12460
+ const locationHash = localStorage.get(storageName);
12458
12461
 
12459
- try {
12460
- done = !['', 'about:blank'].includes(popup.location.href);
12461
- } catch (e) {// Nothing
12462
- }
12463
-
12464
- if (done) {
12462
+ if (locationHash) {
12465
12463
  clearInterval(ticker);
12466
12464
 
12467
- const data = this._getAnchorParams(popup.location.hash);
12465
+ const data = this._getAnchorParams(locationHash);
12466
+
12467
+ localStorage.remove(storageName);
12468
12468
 
12469
- popup.close();
12469
+ try {
12470
+ popup.close();
12471
+ } catch (e) {// cloudflare intercepted or closed manually
12472
+ }
12470
12473
 
12471
12474
  if (data.error) {
12472
12475
  reject(new OAuthError["default"](data.error, data.message));
@@ -12657,10 +12660,114 @@ class PasswordFlow extends OAuth["default"] {
12657
12660
  }
12658
12661
  // EXTERNAL MODULE: ./src/oauth/DummyFlow.js
12659
12662
  var DummyFlow = __webpack_require__(72);
12663
+ ;// CONCATENATED MODULE: ./src/oauth/CookieFlow.js
12664
+ /*
12665
+ * BSD 3-Clause License
12666
+ *
12667
+ * Copyright (c) 2020, Mapcreator
12668
+ * All rights reserved.
12669
+ *
12670
+ * Redistribution and use in source and binary forms, with or without
12671
+ * modification, are permitted provided that the following conditions are met:
12672
+ *
12673
+ * Redistributions of source code must retain the above copyright notice, this
12674
+ * list of conditions and the following disclaimer.
12675
+ *
12676
+ * Redistributions in binary form must reproduce the above copyright notice,
12677
+ * this list of conditions and the following disclaimer in the documentation
12678
+ * and/or other materials provided with the distribution.
12679
+ *
12680
+ * Neither the name of the copyright holder nor the names of its
12681
+ * contributors may be used to endorse or promote products derived from
12682
+ * this software without specific prior written permission.
12683
+ *
12684
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
12685
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
12686
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
12687
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
12688
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
12689
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
12690
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
12691
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
12692
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
12693
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12694
+ */
12695
+
12696
+
12697
+
12698
+
12699
+ /**
12700
+ * Cookie-based authentication flow using redirection
12701
+ */
12702
+
12703
+ class CookieFlow extends OAuth["default"] {
12704
+ /**
12705
+ * Cookie-based authentication flow
12706
+ * @param {String} clientId - OAuth client id
12707
+ * @param {String} callbackUrl - callbackUrl to redirect to after successful login
12708
+ * @param {Array<String>} scopes - A list of required scopes
12709
+ */
12710
+ constructor(clientId, callbackUrl = '', scopes = ['*']) {
12711
+ super(clientId, scopes);
12712
+
12713
+ if ((0,node.isNode)()) {
12714
+ throw new Error(`${this.constructor.name} can't be used under nodejs`);
12715
+ }
12716
+
12717
+ this.path = '/login';
12718
+ this.callbackUrl = callbackUrl;
12719
+
12720
+ if (!this.callbackUrl) {
12721
+ // Drop the anchor (if any)
12722
+ this.callbackUrl = window.location.toString().split('#')[0];
12723
+ }
12724
+ }
12725
+ /**
12726
+ * @inheritDoc
12727
+ */
12728
+
12729
+
12730
+ authenticate() {
12731
+ return new Promise((resolve, reject) => {
12732
+ // Check authentication status by making a request to the user resources endpoint
12733
+ fetch(`${this.host}/v1/users/me/resources`, {
12734
+ method: 'GET',
12735
+ credentials: 'include' // Important: include cookies in the request
12736
+
12737
+ }).then(response => {
12738
+ if (response.ok) {
12739
+ // We're authenticated, create a token object to maintain compatibility
12740
+ this.token = new OAuthToken["default"]('cookie_auth', 'cookie', 86400);
12741
+ resolve(this.token);
12742
+ } else {
12743
+ // Not authenticated, redirect to login
12744
+ window.location = this._buildRedirectUrl();
12745
+ }
12746
+ }).catch(error => {
12747
+ // Network error or other issues, redirect to login
12748
+ window.location = this._buildRedirectUrl();
12749
+ });
12750
+ });
12751
+ }
12752
+ /**
12753
+ * Builds the url for redirection
12754
+ * @returns {String} - Redirect url
12755
+ * @protected
12756
+ */
12757
+
12758
+
12759
+ _buildRedirectUrl() {
12760
+ const queryParams = {
12761
+ 'redirect_uri': this.callbackUrl
12762
+ };
12763
+ return `${this.host + this.path}?${(0,requests.encodeQueryString)(queryParams)}`;
12764
+ }
12765
+
12766
+ }
12660
12767
  // EXTERNAL MODULE: ./src/errors/ApiError.js
12661
12768
  var ApiError = __webpack_require__(62);
12662
12769
  // EXTERNAL MODULE: ./src/errors/AbstractError.js
12663
- var AbstractError = __webpack_require__(21);
12770
+ var AbstractError = __webpack_require__(22);
12664
12771
  // EXTERNAL MODULE: ./src/errors/ValidationError.js
12665
12772
  var ValidationError = __webpack_require__(74);
12666
12773
  // EXTERNAL MODULE: ./src/errors/StaticClassError.js
@@ -12720,6 +12827,7 @@ var proxy = __webpack_require__(71);
12720
12827
 
12721
12828
 
12722
12829
 
12830
+
12723
12831
  // Exceptions
12724
12832
 
12725
12833
 
@@ -12746,7 +12854,7 @@ var proxy = __webpack_require__(71);
12746
12854
  * @private
12747
12855
  */
12748
12856
 
12749
- const version = "v3.3.1";
12857
+ const version = "v3.3.4";
12750
12858
  })();
12751
12859
 
12752
12860
  module.exports = __webpack_exports__;