@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.
@@ -29,11 +29,11 @@
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:3e335130ac54b76fcfe7, chunkhash:21bfda8bbd411c86f2b3, name:bundle.browser, version:v3.3.1
32
+ * hash:8b22b71ca40fe449370a, chunkhash:e848be995b687a9adf32, name:bundle.browser, version:v3.3.4
33
33
  */
34
34
  /*!
35
35
  * This bundle contains the following packages:
36
- * └─ @mapcreator/api (3.3.1) ── BSD 3-clause "New" or "Revised" License (http://www.opensource.org/licenses/BSD-3-Clause) ── package.json
36
+ * └─ @mapcreator/api (3.3.4) ── BSD 3-clause "New" or "Revised" License (http://www.opensource.org/licenses/BSD-3-Clause) ── package.json
37
37
  * ├─ @babel/runtime (7.10.2) ── MIT License (http://www.opensource.org/licenses/MIT) ── node_modules/@babel/runtime/package.json
38
38
  * │ └─ regenerator-runtime (0.13.5) ── MIT License (http://www.opensource.org/licenses/MIT) ── node_modules/@babel/runtime ~ regenerator-runtime/package.json
39
39
  * ├─ case (1.6.3) ── mit or gpl 3.0 or later ── node_modules/case/package.json
@@ -665,9 +665,9 @@ __webpack_require__.r(__webpack_exports__);
665
665
  /* harmony export */ });
666
666
  /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
667
667
  /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(case__WEBPACK_IMPORTED_MODULE_0__);
668
- /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(21);
669
- /* harmony import */ var _Mapcreator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(17);
670
- /* harmony import */ var _proxy_SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(15);
668
+ /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(22);
669
+ /* harmony import */ var _Mapcreator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(18);
670
+ /* harmony import */ var _proxy_SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(16);
671
671
  /* harmony import */ var _traits_Injectable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(65);
672
672
  /* harmony import */ var _utils_hash__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(33);
673
673
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(0);
@@ -1421,7 +1421,7 @@ __webpack_require__.r(__webpack_exports__);
1421
1421
  /* harmony export */ "encodeQueryString": () => (/* binding */ encodeQueryString),
1422
1422
  /* harmony export */ "wrapKyPrefixUrl": () => (/* binding */ wrapKyPrefixUrl)
1423
1423
  /* harmony export */ });
1424
- /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9);
1424
+ /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
1425
1425
  /*
1426
1426
  * BSD 3-Clause License
1427
1427
  *
@@ -1556,7 +1556,7 @@ __webpack_require__.d(__webpack_exports__, {
1556
1556
  });
1557
1557
 
1558
1558
  // EXTERNAL MODULE: ./src/enums/Enum.js + 1 modules
1559
- var Enum = __webpack_require__(11);
1559
+ var Enum = __webpack_require__(12);
1560
1560
  ;// CONCATENATED MODULE: ./src/enums/DeletedState.js
1561
1561
  /*
1562
1562
  * BSD 3-Clause License
@@ -1735,6 +1735,72 @@ const JobShareVisibility = new Enum["default"](['private', 'organisation', 'publ
1735
1735
  /* 8 */
1736
1736
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1737
1737
 
1738
+ "use strict";
1739
+ __webpack_require__.r(__webpack_exports__);
1740
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1741
+ /* harmony export */ "isNode": () => (/* binding */ isNode),
1742
+ /* harmony export */ "windowTest": () => (/* binding */ windowTest)
1743
+ /* harmony export */ });
1744
+ /*
1745
+ * BSD 3-Clause License
1746
+ *
1747
+ * Copyright (c) 2020, Mapcreator
1748
+ * All rights reserved.
1749
+ *
1750
+ * Redistribution and use in source and binary forms, with or without
1751
+ * modification, are permitted provided that the following conditions are met:
1752
+ *
1753
+ * Redistributions of source code must retain the above copyright notice, this
1754
+ * list of conditions and the following disclaimer.
1755
+ *
1756
+ * Redistributions in binary form must reproduce the above copyright notice,
1757
+ * this list of conditions and the following disclaimer in the documentation
1758
+ * and/or other materials provided with the distribution.
1759
+ *
1760
+ * Neither the name of the copyright holder nor the names of its
1761
+ * contributors may be used to endorse or promote products derived from
1762
+ * this software without specific prior written permission.
1763
+ *
1764
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1765
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1766
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1767
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1768
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1769
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1770
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1771
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1772
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1773
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1774
+ */
1775
+
1776
+ /**
1777
+ * Test if the application is running under nodejs
1778
+ * @returns {boolean} - Is the application running under node?
1779
+ * @see https://nodejs.org
1780
+ * @private
1781
+ */
1782
+ function isNode() {
1783
+ try {
1784
+ return Object.prototype.toString.call(typeof process === 'undefined' ? 0 : process) === '[object process]';
1785
+ } catch (_) {
1786
+ return false;
1787
+ }
1788
+ }
1789
+ /**
1790
+ * Quickly check if the window contains a variable
1791
+ * @param {string} str - target variable
1792
+ * @returns {boolean} - If the window contains the variable
1793
+ * @private
1794
+ */
1795
+
1796
+ function windowTest(str) {
1797
+ return typeof window !== 'undefined' && typeof window[str] !== 'undefined';
1798
+ }
1799
+
1800
+ /***/ }),
1801
+ /* 9 */
1802
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1803
+
1738
1804
  "use strict";
1739
1805
  __webpack_require__.r(__webpack_exports__);
1740
1806
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
@@ -2471,15 +2537,16 @@ class RequestParameters extends events__WEBPACK_IMPORTED_MODULE_1__.EventEmitter
2471
2537
  }
2472
2538
 
2473
2539
  /***/ }),
2474
- /* 9 */
2540
+ /* 10 */
2475
2541
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2476
2542
 
2477
2543
  "use strict";
2478
2544
  __webpack_require__.r(__webpack_exports__);
2479
2545
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2480
- /* harmony export */ "isNode": () => (/* binding */ isNode),
2481
- /* harmony export */ "windowTest": () => (/* binding */ windowTest)
2546
+ /* harmony export */ "default": () => (/* binding */ OAuthToken)
2482
2547
  /* harmony export */ });
2548
+ /* harmony import */ var _storage_StorageManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20);
2549
+ /* harmony import */ var _utils_requests__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6);
2483
2550
  /*
2484
2551
  * BSD 3-Clause License
2485
2552
  *
@@ -2512,32 +2579,153 @@ __webpack_require__.r(__webpack_exports__);
2512
2579
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2513
2580
  */
2514
2581
 
2582
+
2515
2583
  /**
2516
- * Test if the application is running under nodejs
2517
- * @returns {boolean} - Is the application running under node?
2518
- * @see https://nodejs.org
2519
- * @private
2584
+ * Oauth token container
2520
2585
  */
2521
- function isNode() {
2522
- try {
2523
- return Object.prototype.toString.call(typeof process === 'undefined' ? 0 : process) === '[object process]';
2524
- } catch (_) {
2525
- return false;
2586
+
2587
+ class OAuthToken {
2588
+ /**
2589
+ * @param {String} token - OAuth token
2590
+ * @param {String} [type=Bearer] - token type
2591
+ * @param {Date|Number} [expires=5 days] - expire time in seconds or Date
2592
+ * @param {Array<string>} [scopes=[]] - Any scopes
2593
+ */
2594
+ constructor(token, type = 'Bearer', expires = 432000, scopes = []) {
2595
+ this.scopes = scopes;
2596
+ this.token = token;
2597
+ this.type = type.toLowerCase().replace(/(\s|^)\w/g, x => x.toUpperCase());
2598
+
2599
+ if (typeof expires === 'number') {
2600
+ const ms = expires * 1000; // Expires is in seconds
2601
+
2602
+ this.expires = new Date(Date.now() + ms);
2603
+ } else if (expires instanceof Date) {
2604
+ this.expires = expires;
2605
+ } else {
2606
+ throw new TypeError('Expires not of type Date or Number');
2607
+ }
2608
+ }
2609
+ /**
2610
+ * String representation of the token, usable in the Authorization header
2611
+ * @returns {string} - String representation
2612
+ */
2613
+
2614
+
2615
+ toString() {
2616
+ return `${this.type} ${this.token}`;
2617
+ }
2618
+ /**
2619
+ * Get equivalent OAuth response object
2620
+ * @returns {{access_token: (String|*), token_type: String, expires_in: Number, scope: (Array.<String>|Array|*)}} - Raw response object
2621
+ */
2622
+
2623
+
2624
+ toResponseObject() {
2625
+ return {
2626
+ 'access_token': this.token,
2627
+ 'token_type': this.type.toLowerCase(),
2628
+ 'expires_in': this.expires - Date.now(),
2629
+ 'scope': this.scopes
2630
+ };
2631
+ }
2632
+ /**
2633
+ * Export oauth response query string
2634
+ * @returns {string} - OAuth response query
2635
+ */
2636
+
2637
+
2638
+ toQueryString() {
2639
+ return (0,_utils_requests__WEBPACK_IMPORTED_MODULE_1__.encodeQueryString)(this.toResponseObject());
2640
+ }
2641
+ /**
2642
+ * If the token has expired
2643
+ * @returns {Boolean} - expired
2644
+ */
2645
+
2646
+
2647
+ get expired() {
2648
+ return new Date() > this.expires;
2649
+ }
2650
+ /**
2651
+ * Internal storage key name
2652
+ * @returns {String} - storage name
2653
+ * @constant
2654
+ */
2655
+
2656
+
2657
+ static get storageName() {
2658
+ return 'api_token';
2659
+ }
2660
+ /**
2661
+ * Build instance from response object
2662
+ * @param {String|Object} data - object or JSON string
2663
+ * @returns {OAuthToken} - New OAuthToken instance
2664
+ */
2665
+
2666
+
2667
+ static fromResponseObject(data) {
2668
+ if (typeof data === 'string') {
2669
+ data = JSON.parse(data);
2670
+ } // Default expires = 5 days
2671
+
2672
+
2673
+ let expires = 432000;
2674
+
2675
+ if (typeof data['exipires_in'] !== 'undefined') {
2676
+ expires = Number(data['expires_in']);
2677
+ } else if (typeof data.expires === 'string') {
2678
+ expires = new Date(data.expires);
2679
+ }
2680
+
2681
+ return new OAuthToken(data['access_token'], data['token_type'], expires, data.scope || []);
2682
+ }
2683
+ /**
2684
+ * Store the token for later recovery. Token will be stored in HTTPS cookie if possible.
2685
+ * @param {String} name - db key name
2686
+ * @throws {OAuthToken#recover}
2687
+ */
2688
+
2689
+
2690
+ save(name = OAuthToken.storageName) {
2691
+ const data = {
2692
+ token: this.token,
2693
+ type: this.type,
2694
+ expires: this.expires.toUTCString(),
2695
+ scopes: this.scopes
2696
+ }; // Third parameter is only used when we're using cookies
2697
+
2698
+ _storage_StorageManager__WEBPACK_IMPORTED_MODULE_0__["default"].secure.set(name, JSON.stringify(data), this.expires);
2699
+ }
2700
+ /**
2701
+ * Recover a token by looking through the HTTPS cookies and localStorage
2702
+ * @param {String} name - Storage key name
2703
+ * @returns {OAuthToken|null} - null if none could be recovered
2704
+ * @throws {OAuthToken#save}
2705
+ */
2706
+
2707
+
2708
+ static recover(name = OAuthToken.storageName) {
2709
+ const data = _storage_StorageManager__WEBPACK_IMPORTED_MODULE_0__["default"].secure.get(name);
2710
+
2711
+ if (!data) {
2712
+ return null;
2713
+ }
2714
+
2715
+ const obj = JSON.parse(data);
2716
+ const instance = new OAuthToken(obj.token, obj.type, new Date(obj.expires), obj.scopes || []);
2717
+
2718
+ if (instance.expired) {
2719
+ return null;
2720
+ }
2721
+
2722
+ return instance;
2526
2723
  }
2527
- }
2528
- /**
2529
- * Quickly check if the window contains a variable
2530
- * @param {string} str - target variable
2531
- * @returns {boolean} - If the window contains the variable
2532
- * @private
2533
- */
2534
2724
 
2535
- function windowTest(str) {
2536
- return typeof window !== 'undefined' && typeof window[str] !== 'undefined';
2537
2725
  }
2538
2726
 
2539
2727
  /***/ }),
2540
- /* 10 */
2728
+ /* 11 */
2541
2729
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2542
2730
 
2543
2731
  "use strict";
@@ -2545,7 +2733,7 @@ __webpack_require__.r(__webpack_exports__);
2545
2733
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2546
2734
  /* harmony export */ "default": () => (/* binding */ CrudSetItemBase)
2547
2735
  /* harmony export */ });
2548
- /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(21);
2736
+ /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(22);
2549
2737
  /* harmony import */ var _CrudBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
2550
2738
  /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5);
2551
2739
  /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(case__WEBPACK_IMPORTED_MODULE_2__);
@@ -2633,7 +2821,7 @@ class CrudSetItemBase extends _CrudBase__WEBPACK_IMPORTED_MODULE_1__["default"]
2633
2821
  }
2634
2822
 
2635
2823
  /***/ }),
2636
- /* 11 */
2824
+ /* 12 */
2637
2825
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2638
2826
 
2639
2827
  "use strict";
@@ -2830,7 +3018,7 @@ class Enum extends Unobservable {
2830
3018
  }
2831
3019
 
2832
3020
  /***/ }),
2833
- /* 12 */
3021
+ /* 13 */
2834
3022
  /***/ ((module) => {
2835
3023
 
2836
3024
  function _defineProperty(obj, key, value) {
@@ -2851,16 +3039,24 @@ function _defineProperty(obj, key, value) {
2851
3039
  module.exports = _defineProperty;
2852
3040
 
2853
3041
  /***/ }),
2854
- /* 13 */
3042
+ /* 14 */
2855
3043
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2856
3044
 
2857
3045
  "use strict";
2858
3046
  __webpack_require__.r(__webpack_exports__);
2859
3047
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2860
- /* harmony export */ "default": () => (/* binding */ OAuthToken)
3048
+ /* harmony export */ "default": () => (/* binding */ OAuth)
2861
3049
  /* harmony export */ });
2862
- /* harmony import */ var _storage_StorageManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(22);
2863
- /* harmony import */ var _utils_requests__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6);
3050
+ /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(13);
3051
+ /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
3052
+ /* harmony import */ var ky_universal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(31);
3053
+ /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(22);
3054
+ /* harmony import */ var _storage_StorageManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(20);
3055
+ /* harmony import */ var _OAuthToken__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(10);
3056
+ /* harmony import */ var _StateContainer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(42);
3057
+ /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1);
3058
+
3059
+
2864
3060
  /*
2865
3061
  * BSD 3-Clause License
2866
3062
  *
@@ -2894,152 +3090,111 @@ __webpack_require__.r(__webpack_exports__);
2894
3090
  */
2895
3091
 
2896
3092
 
3093
+
3094
+
3095
+
3096
+
2897
3097
  /**
2898
- * Oauth token container
3098
+ * OAuth base class
3099
+ * @abstract
2899
3100
  */
2900
3101
 
2901
- class OAuthToken {
3102
+ class OAuth {
2902
3103
  /**
2903
- * @param {String} token - OAuth token
2904
- * @param {String} [type=Bearer] - token type
2905
- * @param {Date|Number} [expires=5 days] - expire time in seconds or Date
2906
- * @param {Array<string>} [scopes=[]] - Any scopes
3104
+ * @param {String} clientId - OAuth client id
3105
+ * @param {Array<String>} scopes - A list of required scopes
2907
3106
  */
2908
- constructor(token, type = 'Bearer', expires = 432000, scopes = []) {
2909
- this.scopes = scopes;
2910
- this.token = token;
2911
- this.type = type.toLowerCase().replace(/(\s|^)\w/g, x => x.toUpperCase());
2912
-
2913
- if (typeof expires === 'number') {
2914
- const ms = expires * 1000; // Expires is in seconds
3107
+ constructor(clientId, scopes = ['*']) {
3108
+ _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(this, "token", null);
2915
3109
 
2916
- this.expires = new Date(Date.now() + ms);
2917
- } else if (expires instanceof Date) {
2918
- this.expires = expires;
2919
- } else {
2920
- throw new TypeError('Expires not of type Date or Number');
2921
- }
2922
- }
2923
- /**
2924
- * String representation of the token, usable in the Authorization header
2925
- * @returns {string} - String representation
2926
- */
3110
+ _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(this, "path", '/');
2927
3111
 
3112
+ _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(this, "host", "https://api.beta.mapcreator.io");
2928
3113
 
2929
- toString() {
2930
- return `${this.type} ${this.token}`;
2931
- }
2932
- /**
2933
- * Get equivalent OAuth response object
2934
- * @returns {{access_token: (String|*), token_type: String, expires_in: Number, scope: (Array.<String>|Array|*)}} - Raw response object
2935
- */
3114
+ if (this.constructor === OAuth) {
3115
+ throw new _errors_AbstractError__WEBPACK_IMPORTED_MODULE_2__.AbstractClassError();
3116
+ }
2936
3117
 
3118
+ this.clientId = String(clientId);
3119
+ this.scopes = scopes;
2937
3120
 
2938
- toResponseObject() {
2939
- return {
2940
- 'access_token': this.token,
2941
- 'token_type': this.type.toLowerCase(),
2942
- 'expires_in': this.expires - Date.now(),
2943
- 'scope': this.scopes
2944
- };
3121
+ if (this.clientId) {
3122
+ this.token = _OAuthToken__WEBPACK_IMPORTED_MODULE_4__["default"].recover();
3123
+ }
2945
3124
  }
2946
3125
  /**
2947
- * Export oauth response query string
2948
- * @returns {string} - OAuth response query
3126
+ * If the current instance has a valid token
3127
+ * @returns {Boolean} - If a valid token is available
2949
3128
  */
2950
3129
 
2951
3130
 
2952
- toQueryString() {
2953
- return (0,_utils_requests__WEBPACK_IMPORTED_MODULE_1__.encodeQueryString)(this.toResponseObject());
3131
+ get authenticated() {
3132
+ return this.token !== null && !this.token.expired;
2954
3133
  }
2955
3134
  /**
2956
- * If the token has expired
2957
- * @returns {Boolean} - expired
3135
+ * Authenticate
3136
+ * @returns {Promise<OAuthToken>} - Authentication token
3137
+ * @throws {OAuthError}
3138
+ * @abstract
2958
3139
  */
2959
3140
 
2960
3141
 
2961
- get expired() {
2962
- return new Date() > this.expires;
3142
+ authenticate() {
3143
+ throw new _errors_AbstractError__WEBPACK_IMPORTED_MODULE_2__.AbstractMethodError();
2963
3144
  }
2964
3145
  /**
2965
- * Internal storage key name
2966
- * @returns {String} - storage name
2967
- * @constant
3146
+ * Forget the current session
3147
+ * Empty the session token store and forget the api token
2968
3148
  */
2969
3149
 
2970
3150
 
2971
- static get storageName() {
2972
- return 'api_token';
3151
+ forget() {
3152
+ _StateContainer__WEBPACK_IMPORTED_MODULE_5__["default"].clean();
3153
+ _storage_StorageManager__WEBPACK_IMPORTED_MODULE_3__["default"].secure.remove(_OAuthToken__WEBPACK_IMPORTED_MODULE_4__["default"].storageName);
3154
+ this.token = null;
2973
3155
  }
2974
3156
  /**
2975
- * Build instance from response object
2976
- * @param {String|Object} data - object or JSON string
2977
- * @returns {OAuthToken} - New OAuthToken instance
3157
+ * Invalidates the session token
3158
+ * @throws {OAuthError} - If de-authentication fails
3159
+ * @throws {ApiError} - If the api returns errors
3160
+ * @returns {CancelablePromise}
2978
3161
  */
2979
3162
 
2980
3163
 
2981
- static fromResponseObject(data) {
2982
- if (typeof data === 'string') {
2983
- data = JSON.parse(data);
2984
- } // Default expires = 5 days
2985
-
2986
-
2987
- let expires = 432000;
2988
-
2989
- if (typeof data['exipires_in'] !== 'undefined') {
2990
- expires = Number(data['expires_in']);
2991
- } else if (typeof data.expires === 'string') {
2992
- expires = new Date(data.expires);
3164
+ logout() {
3165
+ if (!this.token) {
3166
+ return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_6__.makeCancelable)(() => {});
2993
3167
  }
2994
3168
 
2995
- return new OAuthToken(data['access_token'], data['token_type'], expires, data.scope || []);
2996
- }
2997
- /**
2998
- * Store the token for later recovery. Token will be stored in HTTPS cookie if possible.
2999
- * @param {String} name - db key name
3000
- * @throws {OAuthToken#recover}
3001
- */
3002
-
3003
-
3004
- save(name = OAuthToken.storageName) {
3005
- const data = {
3006
- token: this.token,
3007
- type: this.type,
3008
- expires: this.expires.toUTCString(),
3009
- scopes: this.scopes
3010
- }; // Third parameter is only used when we're using cookies
3011
-
3012
- _storage_StorageManager__WEBPACK_IMPORTED_MODULE_0__["default"].secure.set(name, JSON.stringify(data), this.expires);
3169
+ const url = `${this.host}/oauth/logout`;
3170
+ return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_6__.makeCancelable)(async signal => {
3171
+ await ky_universal__WEBPACK_IMPORTED_MODULE_1__["default"].post(url, {
3172
+ headers: {
3173
+ Accept: 'application/json',
3174
+ Authorization: this.token.toString()
3175
+ },
3176
+ signal
3177
+ });
3178
+ this.forget();
3179
+ });
3013
3180
  }
3014
3181
  /**
3015
- * Recover a token by looking through the HTTPS cookies and localStorage
3016
- * @param {String} name - Storage key name
3017
- * @returns {OAuthToken|null} - null if none could be recovered
3018
- * @throws {OAuthToken#save}
3182
+ * Manually import OAuthToken, usefull for debugging
3183
+ * @param {String} token - OAuth token
3184
+ * @param {String} [type=Bearer] - token type
3185
+ * @param {Date|Number} [expires=5 days] - expire time in seconds or Date
3186
+ * @param {Array<string>} [scopes=[]] - Any scopes
3019
3187
  */
3020
3188
 
3021
3189
 
3022
- static recover(name = OAuthToken.storageName) {
3023
- const data = _storage_StorageManager__WEBPACK_IMPORTED_MODULE_0__["default"].secure.get(name);
3024
-
3025
- if (!data) {
3026
- return null;
3027
- }
3028
-
3029
- const obj = JSON.parse(data);
3030
- const instance = new OAuthToken(obj.token, obj.type, new Date(obj.expires), obj.scopes || []);
3031
-
3032
- if (instance.expired) {
3033
- return null;
3034
- }
3035
-
3036
- return instance;
3190
+ importToken(token, type = 'Bearer', expires = 432000, scopes = []) {
3191
+ this.token = new _OAuthToken__WEBPACK_IMPORTED_MODULE_4__["default"](token, type, expires, scopes);
3037
3192
  }
3038
3193
 
3039
3194
  }
3040
3195
 
3041
3196
  /***/ }),
3042
- /* 14 */
3197
+ /* 15 */
3043
3198
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3044
3199
 
3045
3200
  "use strict";
@@ -3048,7 +3203,7 @@ __webpack_require__.r(__webpack_exports__);
3048
3203
  /* harmony export */ "default": () => (/* binding */ ResourceProxy)
3049
3204
  /* harmony export */ });
3050
3205
  /* harmony import */ var _utils_requests__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6);
3051
- /* harmony import */ var _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(15);
3206
+ /* harmony import */ var _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16);
3052
3207
  /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
3053
3208
  /*
3054
3209
  * BSD 3-Clause License
@@ -3166,7 +3321,7 @@ class ResourceProxy extends _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_1__["d
3166
3321
  }
3167
3322
 
3168
3323
  /***/ }),
3169
- /* 15 */
3324
+ /* 16 */
3170
3325
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3171
3326
 
3172
3327
  "use strict";
@@ -3179,9 +3334,9 @@ __webpack_require__.d(__webpack_exports__, {
3179
3334
  });
3180
3335
 
3181
3336
  // EXTERNAL MODULE: ./src/Mapcreator.js + 1 modules
3182
- var Mapcreator = __webpack_require__(17);
3337
+ var Mapcreator = __webpack_require__(18);
3183
3338
  // EXTERNAL MODULE: ./src/RequestParameters.js
3184
- var RequestParameters = __webpack_require__(8);
3339
+ var RequestParameters = __webpack_require__(9);
3185
3340
  // EXTERNAL MODULE: ./src/utils/reflection.js
3186
3341
  var reflection = __webpack_require__(0);
3187
3342
  // EXTERNAL MODULE: ./src/utils/helpers.js
@@ -3706,7 +3861,7 @@ class SimpleResourceProxy {
3706
3861
  }
3707
3862
 
3708
3863
  /***/ }),
3709
- /* 16 */
3864
+ /* 17 */
3710
3865
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3711
3866
 
3712
3867
  "use strict";
@@ -3714,7 +3869,7 @@ __webpack_require__.r(__webpack_exports__);
3714
3869
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3715
3870
  /* harmony export */ "default": () => (/* binding */ CrudSetBase)
3716
3871
  /* harmony export */ });
3717
- /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(21);
3872
+ /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(22);
3718
3873
  /* harmony import */ var _CrudBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
3719
3874
  /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5);
3720
3875
  /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(case__WEBPACK_IMPORTED_MODULE_2__);
@@ -3802,7 +3957,7 @@ class CrudSetBase extends _CrudBase__WEBPACK_IMPORTED_MODULE_1__["default"] {
3802
3957
  }
3803
3958
 
3804
3959
  /***/ }),
3805
- /* 17 */
3960
+ /* 18 */
3806
3961
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3807
3962
 
3808
3963
  "use strict";
@@ -3821,15 +3976,15 @@ var enums = __webpack_require__(7);
3821
3976
  // EXTERNAL MODULE: ./src/oauth/DummyFlow.js
3822
3977
  var DummyFlow = __webpack_require__(76);
3823
3978
  // EXTERNAL MODULE: ./src/oauth/OAuth.js
3824
- var OAuth = __webpack_require__(19);
3979
+ var OAuth = __webpack_require__(14);
3825
3980
  // EXTERNAL MODULE: ./src/oauth/OAuthToken.js
3826
- var OAuthToken = __webpack_require__(13);
3981
+ var OAuthToken = __webpack_require__(10);
3827
3982
  // EXTERNAL MODULE: ./src/proxy/GeoResourceProxy.js
3828
3983
  var GeoResourceProxy = __webpack_require__(43);
3829
3984
  // EXTERNAL MODULE: ./src/proxy/ResourceProxy.js
3830
- var ResourceProxy = __webpack_require__(14);
3985
+ var ResourceProxy = __webpack_require__(15);
3831
3986
  // EXTERNAL MODULE: ./src/proxy/SimpleResourceProxy.js + 1 modules
3832
- var SimpleResourceProxy = __webpack_require__(15);
3987
+ var SimpleResourceProxy = __webpack_require__(16);
3833
3988
  // EXTERNAL MODULE: ./src/resources/index.js + 11 modules
3834
3989
  var resources = __webpack_require__(30);
3835
3990
  // EXTERNAL MODULE: ./src/resources/base/ResourceBase.js
@@ -4055,7 +4210,7 @@ class Mapcreator extends (0,reflection.mix)((events_default()), Injectable["defa
4055
4210
  * @param {OAuth|string} auth - Authentication flow
4056
4211
  * @param {string} host - Remote API host
4057
4212
  */
4058
- constructor(auth = new DummyFlow["default"](), host = "https://api.mapcreator.io") {
4213
+ constructor(auth = new DummyFlow["default"](), host = "https://api.beta.mapcreator.io") {
4059
4214
  super();
4060
4215
 
4061
4216
  if (typeof auth === 'string') {
@@ -4239,6 +4394,8 @@ class Mapcreator extends (0,reflection.mix)((events_default()), Injectable["defa
4239
4394
  // throwHttpErrors: false, // This is done through a custom hook
4240
4395
  // redirect: 'error',
4241
4396
  retry: 0,
4397
+ credentials: 'include',
4398
+ // Include cookies in requests
4242
4399
  headers: {
4243
4400
  'Accept': 'application/json',
4244
4401
  'X-No-CDN-Redirect': 'true'
@@ -4707,7 +4864,7 @@ class Mapcreator extends (0,reflection.mix)((events_default()), Injectable["defa
4707
4864
  }
4708
4865
 
4709
4866
  /***/ }),
4710
- /* 18 */
4867
+ /* 19 */
4711
4868
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4712
4869
 
4713
4870
  "use strict";
@@ -4715,7 +4872,7 @@ __webpack_require__.r(__webpack_exports__);
4715
4872
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4716
4873
  /* harmony export */ "default": () => (/* binding */ OAuthError)
4717
4874
  /* harmony export */ });
4718
- /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(12);
4875
+ /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(13);
4719
4876
  /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
4720
4877
 
4721
4878
 
@@ -4795,24 +4952,25 @@ class OAuthError extends Error {
4795
4952
  }
4796
4953
 
4797
4954
  /***/ }),
4798
- /* 19 */
4955
+ /* 20 */
4799
4956
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4800
4957
 
4801
4958
  "use strict";
4959
+ // ESM COMPAT FLAG
4802
4960
  __webpack_require__.r(__webpack_exports__);
4803
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4804
- /* harmony export */ "default": () => (/* binding */ OAuth)
4805
- /* harmony export */ });
4806
- /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(12);
4807
- /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
4808
- /* harmony import */ var ky_universal__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(31);
4809
- /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(21);
4810
- /* harmony import */ var _storage_StorageManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(22);
4811
- /* harmony import */ var _OAuthToken__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(13);
4812
- /* harmony import */ var _StateContainer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(42);
4813
- /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1);
4814
4961
 
4962
+ // EXPORTS
4963
+ __webpack_require__.d(__webpack_exports__, {
4964
+ "default": () => (/* binding */ StorageManager)
4965
+ });
4815
4966
 
4967
+ // EXTERNAL MODULE: ./src/utils/StaticClass.js
4968
+ var StaticClass = __webpack_require__(34);
4969
+ // EXTERNAL MODULE: ./src/utils/node.js
4970
+ var node = __webpack_require__(8);
4971
+ // EXTERNAL MODULE: ./src/storage/DataStoreContract.js
4972
+ var DataStoreContract = __webpack_require__(23);
4973
+ ;// CONCATENATED MODULE: ./src/storage/CookiesDriver.js
4816
4974
  /*
4817
4975
  * BSD 3-Clause License
4818
4976
  *
@@ -4846,455 +5004,47 @@ __webpack_require__.r(__webpack_exports__);
4846
5004
  */
4847
5005
 
4848
5006
 
4849
-
4850
-
4851
-
4852
-
4853
5007
  /**
4854
- * OAuth base class
4855
- * @abstract
5008
+ * @private
5009
+ * @todo fix
4856
5010
  */
4857
5011
 
4858
- class OAuth {
4859
- /**
4860
- * @param {String} clientId - OAuth client id
4861
- * @param {Array<String>} scopes - A list of required scopes
4862
- */
4863
- constructor(clientId, scopes = ['*']) {
4864
- _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(this, "token", null);
4865
-
4866
- _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(this, "path", '/');
4867
-
4868
- _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(this, "host", "https://api.mapcreator.io");
4869
-
4870
- if (this.constructor === OAuth) {
4871
- throw new _errors_AbstractError__WEBPACK_IMPORTED_MODULE_2__.AbstractClassError();
4872
- }
4873
-
4874
- this.clientId = String(clientId);
4875
- this.scopes = scopes;
4876
-
4877
- if (this.clientId) {
4878
- this.token = _OAuthToken__WEBPACK_IMPORTED_MODULE_4__["default"].recover();
4879
- }
5012
+ class CookiesDriver extends DataStoreContract["default"] {
5013
+ constructor(prefix = '_m4n_') {
5014
+ super();
5015
+ this.__prefix = prefix;
4880
5016
  }
4881
5017
  /**
4882
- * If the current instance has a valid token
4883
- * @returns {Boolean} - If a valid token is available
5018
+ * Cookie name prefix
5019
+ * @returns {String} - Prefix
5020
+ * @private
4884
5021
  */
4885
5022
 
4886
5023
 
4887
- get authenticated() {
4888
- return this.token !== null && !this.token.expired;
5024
+ get _prefix() {
5025
+ return this.__prefix;
4889
5026
  }
4890
5027
  /**
4891
- * Authenticate
4892
- * @returns {Promise<OAuthToken>} - Authentication token
4893
- * @throws {OAuthError}
4894
- * @abstract
5028
+ * @inheritDoc
4895
5029
  */
4896
5030
 
4897
5031
 
4898
- authenticate() {
4899
- throw new _errors_AbstractError__WEBPACK_IMPORTED_MODULE_2__.AbstractMethodError();
5032
+ static get secure() {
5033
+ return window.location.protocol === 'https:';
4900
5034
  }
4901
5035
  /**
4902
- * Forget the current session
4903
- * Empty the session token store and forget the api token
5036
+ * @inheritDoc
4904
5037
  */
4905
5038
 
4906
5039
 
4907
- forget() {
4908
- _StateContainer__WEBPACK_IMPORTED_MODULE_5__["default"].clean();
4909
- _storage_StorageManager__WEBPACK_IMPORTED_MODULE_3__["default"].secure.remove(_OAuthToken__WEBPACK_IMPORTED_MODULE_4__["default"].storageName);
4910
- this.token = null;
5040
+ static get available() {
5041
+ return !(0,node.isNode)();
4911
5042
  }
4912
5043
  /**
4913
- * Invalidates the session token
4914
- * @throws {OAuthError} - If de-authentication fails
4915
- * @throws {ApiError} - If the api returns errors
4916
- * @returns {CancelablePromise}
4917
- */
4918
-
4919
-
4920
- logout() {
4921
- if (!this.token) {
4922
- return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_6__.makeCancelable)(() => {});
4923
- }
4924
-
4925
- const url = `${this.host}/oauth/logout`;
4926
- return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_6__.makeCancelable)(async signal => {
4927
- await ky_universal__WEBPACK_IMPORTED_MODULE_1__["default"].post(url, {
4928
- headers: {
4929
- Accept: 'application/json',
4930
- Authorization: this.token.toString()
4931
- },
4932
- signal
4933
- });
4934
- this.forget();
4935
- });
4936
- }
4937
- /**
4938
- * Manually import OAuthToken, usefull for debugging
4939
- * @param {String} token - OAuth token
4940
- * @param {String} [type=Bearer] - token type
4941
- * @param {Date|Number} [expires=5 days] - expire time in seconds or Date
4942
- * @param {Array<string>} [scopes=[]] - Any scopes
4943
- */
4944
-
4945
-
4946
- importToken(token, type = 'Bearer', expires = 432000, scopes = []) {
4947
- this.token = new _OAuthToken__WEBPACK_IMPORTED_MODULE_4__["default"](token, type, expires, scopes);
4948
- }
4949
-
4950
- }
4951
-
4952
- /***/ }),
4953
- /* 20 */
4954
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4955
-
4956
- "use strict";
4957
- __webpack_require__.r(__webpack_exports__);
4958
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4959
- /* harmony export */ "default": () => (/* binding */ OwnedResourceProxy)
4960
- /* harmony export */ });
4961
- /* harmony import */ var _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15);
4962
- /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
4963
- /*
4964
- * BSD 3-Clause License
4965
- *
4966
- * Copyright (c) 2020, Mapcreator
4967
- * All rights reserved.
4968
- *
4969
- * Redistribution and use in source and binary forms, with or without
4970
- * modification, are permitted provided that the following conditions are met:
4971
- *
4972
- * Redistributions of source code must retain the above copyright notice, this
4973
- * list of conditions and the following disclaimer.
4974
- *
4975
- * Redistributions in binary form must reproduce the above copyright notice,
4976
- * this list of conditions and the following disclaimer in the documentation
4977
- * and/or other materials provided with the distribution.
4978
- *
4979
- * Neither the name of the copyright holder nor the names of its
4980
- * contributors may be used to endorse or promote products derived from
4981
- * this software without specific prior written permission.
4982
- *
4983
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
4984
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4985
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
4986
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
4987
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4988
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
4989
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
4990
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
4991
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
4992
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4993
- */
4994
-
4995
-
4996
- /**
4997
- * Used for proxying resource => organisation
4998
- */
4999
-
5000
- class OwnedResourceProxy extends _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_0__["default"] {
5001
- /**
5002
- * OwnedResourceProxy Constructor
5003
- * @param {Mapcreator} api - Api instance
5004
- * @param {ResourceBase} parent - Parent instance
5005
- * @param {Class<ResourceBase>} Target - Target constructor
5006
- */
5007
- constructor(api, parent, Target) {
5008
- const resource = Target.resourceName.replace(/s+$/, '');
5009
- const url = `${parent.url}/${resource}s`;
5010
- super(api, Target, url);
5011
- }
5012
- /**
5013
- * Sync items to the organisation
5014
- * @param {Array<ResourceBase>|Array<number>|ResourceBase|number} items - List of items to sync
5015
- * @throws {TypeError}
5016
- * @throws {ApiError} - If the api returns errors
5017
- * @returns {CancelablePromise}
5018
- */
5019
-
5020
-
5021
- sync(items) {
5022
- return this._modifyResourceLink(items, 'PATCH');
5023
- }
5024
- /**
5025
- * Attach items to the organisation
5026
- * @param {Array<ResourceBase>|Array<number>|ResourceBase|number} items - List of items to attach
5027
- * @throws {TypeError}
5028
- * @throws {ApiError} - If the api returns errors
5029
- * @returns {CancelablePromise}
5030
- */
5031
-
5032
-
5033
- attach(items) {
5034
- return this._modifyResourceLink(items, 'POST');
5035
- }
5036
- /**
5037
- * Detach items from the organisation
5038
- * @param {Array<ResourceBase>|Array<number>|ResourceBase|number} items - List of items to unlink
5039
- * @throws {TypeError}
5040
- * @throws {ApiError} - If the api returns errors
5041
- * @returns {CancelablePromise}
5042
- */
5043
-
5044
-
5045
- detach(items) {
5046
- return this._modifyResourceLink(items, 'DELETE');
5047
- }
5048
- /**
5049
- * Attach parent resource to all organisations
5050
- * @throws {ApiError} - If the api returns errors
5051
- * @returns {CancelablePromise}
5052
- */
5053
-
5054
-
5055
- attachAll() {
5056
- return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_1__.makeCancelable)(async signal => {
5057
- await this.api.ky.post(`${this.baseUrl}/all`, {
5058
- signal
5059
- });
5060
- });
5061
- }
5062
- /**
5063
- * Detach parent resource to all organisations
5064
- * @throws {ApiError} - If the api returns errors
5065
- * @returns {CancelablePromise}
5066
- */
5067
-
5068
-
5069
- detachAll() {
5070
- return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_1__.makeCancelable)(async signal => {
5071
- await this.api.ky.delete(`${this.baseUrl}/all`, {
5072
- signal
5073
- });
5074
- });
5075
- }
5076
- /**
5077
- * @param {Array<ResourceBase>|Array<number>|ResourceBase|number} items - List of items to sync, attach or detach
5078
- * @param {string} method - http method
5079
- * @throws {ApiError} - If the api returns errors
5080
- * @throws {TypeError}
5081
- * @returns {CancelablePromise}
5082
- * @private
5083
- */
5084
-
5085
-
5086
- _modifyResourceLink(items, method) {
5087
- if (!Array.isArray(items)) {
5088
- items = [items];
5089
- }
5090
-
5091
- const keys = items.map(x => OwnedResourceProxy._getKeyValue(x)).map(Number).filter(x => !Number.isNaN(x));
5092
- return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_1__.makeCancelable)(async signal => {
5093
- await this.api.ky(this.baseUrl, {
5094
- method,
5095
- signal,
5096
- json: {
5097
- keys
5098
- }
5099
- });
5100
- });
5101
- }
5102
-
5103
- static _getKeyValue(item) {
5104
- if (['number', 'string'].includes(typeof item)) {
5105
- return item;
5106
- }
5107
-
5108
- const key = item.constructor.resourceUrlKey || 'id';
5109
-
5110
- if (typeof item[key] !== 'undefined') {
5111
- return item[key];
5112
- }
5113
-
5114
- throw new TypeError('Expected items to be of type Array<ResourceBase>, Array<number>, ResourceBase or number}');
5115
- }
5116
-
5117
- }
5118
-
5119
- /***/ }),
5120
- /* 21 */
5121
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
5122
-
5123
- "use strict";
5124
- __webpack_require__.r(__webpack_exports__);
5125
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5126
- /* harmony export */ "AbstractError": () => (/* binding */ AbstractError),
5127
- /* harmony export */ "AbstractClassError": () => (/* binding */ AbstractClassError),
5128
- /* harmony export */ "AbstractMethodError": () => (/* binding */ AbstractMethodError)
5129
- /* harmony export */ });
5130
- /*
5131
- * BSD 3-Clause License
5132
- *
5133
- * Copyright (c) 2020, Mapcreator
5134
- * All rights reserved.
5135
- *
5136
- * Redistribution and use in source and binary forms, with or without
5137
- * modification, are permitted provided that the following conditions are met:
5138
- *
5139
- * Redistributions of source code must retain the above copyright notice, this
5140
- * list of conditions and the following disclaimer.
5141
- *
5142
- * Redistributions in binary form must reproduce the above copyright notice,
5143
- * this list of conditions and the following disclaimer in the documentation
5144
- * and/or other materials provided with the distribution.
5145
- *
5146
- * Neither the name of the copyright holder nor the names of its
5147
- * contributors may be used to endorse or promote products derived from
5148
- * this software without specific prior written permission.
5149
- *
5150
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5151
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5152
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5153
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5154
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5155
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5156
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5157
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5158
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5159
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5160
- */
5161
-
5162
- /**
5163
- * Thrown by abstract methods and classes
5164
- */
5165
- class AbstractError extends Error {
5166
- /**
5167
- * AbstractError constructor
5168
- * @param {?String} message - Error message
5169
- */
5170
- constructor(message = 'Unimplemented') {
5171
- super(message);
5172
- }
5173
-
5174
- }
5175
- /**
5176
- * Thrown upon invocation of an abstract class
5177
- * @example
5178
- * class FooBar {
5179
- * constructor() {
5180
- * if (this.constructor === FooBar) {
5181
- * throw new AbstractClassError();
5182
- * }
5183
- * }
5184
- * }
5185
- */
5186
-
5187
- class AbstractClassError extends AbstractError {
5188
- constructor() {
5189
- super('Can not make an instance of an abstract class');
5190
- }
5191
-
5192
- }
5193
- /**
5194
- * Thrown upon invocation of an abstract method
5195
- */
5196
-
5197
- class AbstractMethodError extends AbstractError {
5198
- constructor() {
5199
- super('Can not call an abstract method');
5200
- }
5201
-
5202
- }
5203
-
5204
- /***/ }),
5205
- /* 22 */
5206
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
5207
-
5208
- "use strict";
5209
- // ESM COMPAT FLAG
5210
- __webpack_require__.r(__webpack_exports__);
5211
-
5212
- // EXPORTS
5213
- __webpack_require__.d(__webpack_exports__, {
5214
- "default": () => (/* binding */ StorageManager)
5215
- });
5216
-
5217
- // EXTERNAL MODULE: ./src/utils/StaticClass.js
5218
- var StaticClass = __webpack_require__(34);
5219
- // EXTERNAL MODULE: ./src/utils/node.js
5220
- var node = __webpack_require__(9);
5221
- // EXTERNAL MODULE: ./src/storage/DataStoreContract.js
5222
- var DataStoreContract = __webpack_require__(23);
5223
- ;// CONCATENATED MODULE: ./src/storage/CookiesDriver.js
5224
- /*
5225
- * BSD 3-Clause License
5226
- *
5227
- * Copyright (c) 2020, Mapcreator
5228
- * All rights reserved.
5229
- *
5230
- * Redistribution and use in source and binary forms, with or without
5231
- * modification, are permitted provided that the following conditions are met:
5232
- *
5233
- * Redistributions of source code must retain the above copyright notice, this
5234
- * list of conditions and the following disclaimer.
5235
- *
5236
- * Redistributions in binary form must reproduce the above copyright notice,
5237
- * this list of conditions and the following disclaimer in the documentation
5238
- * and/or other materials provided with the distribution.
5239
- *
5240
- * Neither the name of the copyright holder nor the names of its
5241
- * contributors may be used to endorse or promote products derived from
5242
- * this software without specific prior written permission.
5243
- *
5244
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5245
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5246
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5247
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5248
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5249
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5250
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5251
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5252
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5253
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5254
- */
5255
-
5256
-
5257
- /**
5258
- * @private
5259
- * @todo fix
5260
- */
5261
-
5262
- class CookiesDriver extends DataStoreContract["default"] {
5263
- constructor(prefix = '_m4n_') {
5264
- super();
5265
- this.__prefix = prefix;
5266
- }
5267
- /**
5268
- * Cookie name prefix
5269
- * @returns {String} - Prefix
5270
- * @private
5271
- */
5272
-
5273
-
5274
- get _prefix() {
5275
- return this.__prefix;
5276
- }
5277
- /**
5278
- * @inheritDoc
5279
- */
5280
-
5281
-
5282
- static get secure() {
5283
- return window.location.protocol === 'https:';
5284
- }
5285
- /**
5286
- * @inheritDoc
5287
- */
5288
-
5289
-
5290
- static get available() {
5291
- return !(0,node.isNode)();
5292
- }
5293
- /**
5294
- * Store a value in the storage
5295
- * @param {String} name - value name
5296
- * @param {*} value - value
5297
- * @param {Date|String} [expires=2050-01-01] - Expiration date
5044
+ * Store a value in the storage
5045
+ * @param {String} name - value name
5046
+ * @param {*} value - value
5047
+ * @param {Date|String} [expires=2050-01-01] - Expiration date
5298
5048
  */
5299
5049
 
5300
5050
 
@@ -5357,7 +5107,7 @@ class CookiesDriver extends DataStoreContract["default"] {
5357
5107
 
5358
5108
  }
5359
5109
  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/defineProperty.js
5360
- var defineProperty = __webpack_require__(12);
5110
+ var defineProperty = __webpack_require__(13);
5361
5111
  var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);
5362
5112
  ;// CONCATENATED MODULE: ./src/storage/DummyDriver.js
5363
5113
 
@@ -5537,40 +5287,330 @@ class LocalStorageDriver extends DataStoreContract["default"] {
5537
5287
  return window.localStorage.getItem(name);
5538
5288
  }
5539
5289
  /**
5540
- * Remove a value from the store
5541
- * @param {String} name - value name
5290
+ * Remove a value from the store
5291
+ * @param {String} name - value name
5292
+ */
5293
+
5294
+
5295
+ remove(name) {
5296
+ name = LocalStorageDriver._prefix + name;
5297
+ window.localStorage.removeItem(name);
5298
+ }
5299
+ /**
5300
+ * Storage keys
5301
+ * @returns {Array<String>} - Stored keys
5302
+ */
5303
+
5304
+
5305
+ keys() {
5306
+ const keys = [];
5307
+ const storage = window.localStorage;
5308
+ const prefix = LocalStorageDriver._prefix;
5309
+
5310
+ for (let i = 0; i < storage.length; i++) {
5311
+ let key = storage.key(i);
5312
+
5313
+ if (key.startsWith(prefix)) {
5314
+ key = key.replace(new RegExp(`^${prefix}`), '');
5315
+ keys.push(key);
5316
+ }
5317
+ }
5318
+
5319
+ return keys;
5320
+ }
5321
+
5322
+ }
5323
+ ;// CONCATENATED MODULE: ./src/storage/StorageManager.js
5324
+ /*
5325
+ * BSD 3-Clause License
5326
+ *
5327
+ * Copyright (c) 2020, Mapcreator
5328
+ * All rights reserved.
5329
+ *
5330
+ * Redistribution and use in source and binary forms, with or without
5331
+ * modification, are permitted provided that the following conditions are met:
5332
+ *
5333
+ * Redistributions of source code must retain the above copyright notice, this
5334
+ * list of conditions and the following disclaimer.
5335
+ *
5336
+ * Redistributions in binary form must reproduce the above copyright notice,
5337
+ * this list of conditions and the following disclaimer in the documentation
5338
+ * and/or other materials provided with the distribution.
5339
+ *
5340
+ * Neither the name of the copyright holder nor the names of its
5341
+ * contributors may be used to endorse or promote products derived from
5342
+ * this software without specific prior written permission.
5343
+ *
5344
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5345
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5346
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5347
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5348
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5349
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5350
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5351
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5352
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5353
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5354
+ */
5355
+
5356
+
5357
+
5358
+
5359
+
5360
+ /**
5361
+ * @private
5362
+ */
5363
+
5364
+ class StorageManager extends StaticClass["default"] {
5365
+ /**
5366
+ * Available storage drivers
5367
+ * @returns {Array.<function>} - Available storage drivers
5368
+ */
5369
+ static get available() {
5370
+ return [DummyDriver, LocalStorageDriver, // CookiesDriver,
5371
+ FileDriver["default"]].filter(x => x.available);
5372
+ }
5373
+ /**
5374
+ * Get LocalStorageDriver instance
5375
+ * @returns {LocalStorageDriver} - Instance
5376
+ */
5377
+
5378
+
5379
+ static get localStorage() {
5380
+ return new LocalStorageDriver();
5381
+ }
5382
+ /**
5383
+ * Get CookiesDriver instance
5384
+ * @returns {CookiesDriver} - Instance
5385
+ */
5386
+
5387
+
5388
+ static get cookies() {
5389
+ return new CookiesDriver();
5390
+ }
5391
+ /**
5392
+ * Get FileDriver instance
5393
+ * @returns {FileDriver} - Instance
5394
+ */
5395
+
5396
+
5397
+ static get file() {
5398
+ return new FileDriver["default"]();
5399
+ }
5400
+ /**
5401
+ * Get DummyDriver instance
5402
+ * @returns {DummyDriver} - Instance
5403
+ */
5404
+
5405
+
5406
+ static get dummy() {
5407
+ return new DummyDriver();
5408
+ }
5409
+ /**
5410
+ * Returns the best available storage driver. For a secure driver use {@link StorageManager#secure}
5411
+ * @returns {DataStoreContract} - Best available storage driver
5412
+ */
5413
+
5414
+
5415
+ static get best() {
5416
+ return new this.available[0]();
5417
+ }
5418
+ /**
5419
+ * Returns the a secure storage driver
5420
+ * @returns {DataStoreContract} - Secure storage driver
5421
+ */
5422
+
5423
+
5424
+ static get secure() {
5425
+ const C = this.available.filter(x => x.secure)[0];
5426
+
5427
+ if (typeof C === 'undefined') {
5428
+ return StorageManager.best;
5429
+ }
5430
+
5431
+ return new C();
5432
+ }
5433
+
5434
+ }
5435
+
5436
+ /***/ }),
5437
+ /* 21 */
5438
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
5439
+
5440
+ "use strict";
5441
+ __webpack_require__.r(__webpack_exports__);
5442
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5443
+ /* harmony export */ "default": () => (/* binding */ OwnedResourceProxy)
5444
+ /* harmony export */ });
5445
+ /* harmony import */ var _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16);
5446
+ /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
5447
+ /*
5448
+ * BSD 3-Clause License
5449
+ *
5450
+ * Copyright (c) 2020, Mapcreator
5451
+ * All rights reserved.
5452
+ *
5453
+ * Redistribution and use in source and binary forms, with or without
5454
+ * modification, are permitted provided that the following conditions are met:
5455
+ *
5456
+ * Redistributions of source code must retain the above copyright notice, this
5457
+ * list of conditions and the following disclaimer.
5458
+ *
5459
+ * Redistributions in binary form must reproduce the above copyright notice,
5460
+ * this list of conditions and the following disclaimer in the documentation
5461
+ * and/or other materials provided with the distribution.
5462
+ *
5463
+ * Neither the name of the copyright holder nor the names of its
5464
+ * contributors may be used to endorse or promote products derived from
5465
+ * this software without specific prior written permission.
5466
+ *
5467
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5468
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5469
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5470
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5471
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5472
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5473
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5474
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5475
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5476
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5477
+ */
5478
+
5479
+
5480
+ /**
5481
+ * Used for proxying resource => organisation
5482
+ */
5483
+
5484
+ class OwnedResourceProxy extends _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_0__["default"] {
5485
+ /**
5486
+ * OwnedResourceProxy Constructor
5487
+ * @param {Mapcreator} api - Api instance
5488
+ * @param {ResourceBase} parent - Parent instance
5489
+ * @param {Class<ResourceBase>} Target - Target constructor
5490
+ */
5491
+ constructor(api, parent, Target) {
5492
+ const resource = Target.resourceName.replace(/s+$/, '');
5493
+ const url = `${parent.url}/${resource}s`;
5494
+ super(api, Target, url);
5495
+ }
5496
+ /**
5497
+ * Sync items to the organisation
5498
+ * @param {Array<ResourceBase>|Array<number>|ResourceBase|number} items - List of items to sync
5499
+ * @throws {TypeError}
5500
+ * @throws {ApiError} - If the api returns errors
5501
+ * @returns {CancelablePromise}
5502
+ */
5503
+
5504
+
5505
+ sync(items) {
5506
+ return this._modifyResourceLink(items, 'PATCH');
5507
+ }
5508
+ /**
5509
+ * Attach items to the organisation
5510
+ * @param {Array<ResourceBase>|Array<number>|ResourceBase|number} items - List of items to attach
5511
+ * @throws {TypeError}
5512
+ * @throws {ApiError} - If the api returns errors
5513
+ * @returns {CancelablePromise}
5514
+ */
5515
+
5516
+
5517
+ attach(items) {
5518
+ return this._modifyResourceLink(items, 'POST');
5519
+ }
5520
+ /**
5521
+ * Detach items from the organisation
5522
+ * @param {Array<ResourceBase>|Array<number>|ResourceBase|number} items - List of items to unlink
5523
+ * @throws {TypeError}
5524
+ * @throws {ApiError} - If the api returns errors
5525
+ * @returns {CancelablePromise}
5526
+ */
5527
+
5528
+
5529
+ detach(items) {
5530
+ return this._modifyResourceLink(items, 'DELETE');
5531
+ }
5532
+ /**
5533
+ * Attach parent resource to all organisations
5534
+ * @throws {ApiError} - If the api returns errors
5535
+ * @returns {CancelablePromise}
5536
+ */
5537
+
5538
+
5539
+ attachAll() {
5540
+ return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_1__.makeCancelable)(async signal => {
5541
+ await this.api.ky.post(`${this.baseUrl}/all`, {
5542
+ signal
5543
+ });
5544
+ });
5545
+ }
5546
+ /**
5547
+ * Detach parent resource to all organisations
5548
+ * @throws {ApiError} - If the api returns errors
5549
+ * @returns {CancelablePromise}
5542
5550
  */
5543
5551
 
5544
5552
 
5545
- remove(name) {
5546
- name = LocalStorageDriver._prefix + name;
5547
- window.localStorage.removeItem(name);
5553
+ detachAll() {
5554
+ return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_1__.makeCancelable)(async signal => {
5555
+ await this.api.ky.delete(`${this.baseUrl}/all`, {
5556
+ signal
5557
+ });
5558
+ });
5548
5559
  }
5549
5560
  /**
5550
- * Storage keys
5551
- * @returns {Array<String>} - Stored keys
5561
+ * @param {Array<ResourceBase>|Array<number>|ResourceBase|number} items - List of items to sync, attach or detach
5562
+ * @param {string} method - http method
5563
+ * @throws {ApiError} - If the api returns errors
5564
+ * @throws {TypeError}
5565
+ * @returns {CancelablePromise}
5566
+ * @private
5552
5567
  */
5553
5568
 
5554
5569
 
5555
- keys() {
5556
- const keys = [];
5557
- const storage = window.localStorage;
5558
- const prefix = LocalStorageDriver._prefix;
5570
+ _modifyResourceLink(items, method) {
5571
+ if (!Array.isArray(items)) {
5572
+ items = [items];
5573
+ }
5559
5574
 
5560
- for (let i = 0; i < storage.length; i++) {
5561
- let key = storage.key(i);
5575
+ const keys = items.map(x => OwnedResourceProxy._getKeyValue(x)).map(Number).filter(x => !Number.isNaN(x));
5576
+ return (0,_utils_helpers__WEBPACK_IMPORTED_MODULE_1__.makeCancelable)(async signal => {
5577
+ await this.api.ky(this.baseUrl, {
5578
+ method,
5579
+ signal,
5580
+ json: {
5581
+ keys
5582
+ }
5583
+ });
5584
+ });
5585
+ }
5562
5586
 
5563
- if (key.startsWith(prefix)) {
5564
- key = key.replace(new RegExp(`^${prefix}`), '');
5565
- keys.push(key);
5566
- }
5587
+ static _getKeyValue(item) {
5588
+ if (['number', 'string'].includes(typeof item)) {
5589
+ return item;
5567
5590
  }
5568
5591
 
5569
- return keys;
5592
+ const key = item.constructor.resourceUrlKey || 'id';
5593
+
5594
+ if (typeof item[key] !== 'undefined') {
5595
+ return item[key];
5596
+ }
5597
+
5598
+ throw new TypeError('Expected items to be of type Array<ResourceBase>, Array<number>, ResourceBase or number}');
5570
5599
  }
5571
5600
 
5572
5601
  }
5573
- ;// CONCATENATED MODULE: ./src/storage/StorageManager.js
5602
+
5603
+ /***/ }),
5604
+ /* 22 */
5605
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
5606
+
5607
+ "use strict";
5608
+ __webpack_require__.r(__webpack_exports__);
5609
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5610
+ /* harmony export */ "AbstractError": () => (/* binding */ AbstractError),
5611
+ /* harmony export */ "AbstractClassError": () => (/* binding */ AbstractClassError),
5612
+ /* harmony export */ "AbstractMethodError": () => (/* binding */ AbstractMethodError)
5613
+ /* harmony export */ });
5574
5614
  /*
5575
5615
  * BSD 3-Clause License
5576
5616
  *
@@ -5603,82 +5643,44 @@ class LocalStorageDriver extends DataStoreContract["default"] {
5603
5643
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5604
5644
  */
5605
5645
 
5606
-
5607
-
5608
-
5609
-
5610
5646
  /**
5611
- * @private
5647
+ * Thrown by abstract methods and classes
5612
5648
  */
5613
-
5614
- class StorageManager extends StaticClass["default"] {
5615
- /**
5616
- * Available storage drivers
5617
- * @returns {Array.<function>} - Available storage drivers
5618
- */
5619
- static get available() {
5620
- return [DummyDriver, LocalStorageDriver, // CookiesDriver,
5621
- FileDriver["default"]].filter(x => x.available);
5622
- }
5623
- /**
5624
- * Get LocalStorageDriver instance
5625
- * @returns {LocalStorageDriver} - Instance
5626
- */
5627
-
5628
-
5629
- static get localStorage() {
5630
- return new LocalStorageDriver();
5631
- }
5632
- /**
5633
- * Get CookiesDriver instance
5634
- * @returns {CookiesDriver} - Instance
5635
- */
5636
-
5637
-
5638
- static get cookies() {
5639
- return new CookiesDriver();
5640
- }
5641
- /**
5642
- * Get FileDriver instance
5643
- * @returns {FileDriver} - Instance
5644
- */
5645
-
5646
-
5647
- static get file() {
5648
- return new FileDriver["default"]();
5649
- }
5649
+ class AbstractError extends Error {
5650
5650
  /**
5651
- * Get DummyDriver instance
5652
- * @returns {DummyDriver} - Instance
5651
+ * AbstractError constructor
5652
+ * @param {?String} message - Error message
5653
5653
  */
5654
-
5655
-
5656
- static get dummy() {
5657
- return new DummyDriver();
5654
+ constructor(message = 'Unimplemented') {
5655
+ super(message);
5658
5656
  }
5659
- /**
5660
- * Returns the best available storage driver. For a secure driver use {@link StorageManager#secure}
5661
- * @returns {DataStoreContract} - Best available storage driver
5662
- */
5663
5657
 
5658
+ }
5659
+ /**
5660
+ * Thrown upon invocation of an abstract class
5661
+ * @example
5662
+ * class FooBar {
5663
+ * constructor() {
5664
+ * if (this.constructor === FooBar) {
5665
+ * throw new AbstractClassError();
5666
+ * }
5667
+ * }
5668
+ * }
5669
+ */
5664
5670
 
5665
- static get best() {
5666
- return new this.available[0]();
5671
+ class AbstractClassError extends AbstractError {
5672
+ constructor() {
5673
+ super('Can not make an instance of an abstract class');
5667
5674
  }
5668
- /**
5669
- * Returns the a secure storage driver
5670
- * @returns {DataStoreContract} - Secure storage driver
5671
- */
5672
-
5673
-
5674
- static get secure() {
5675
- const C = this.available.filter(x => x.secure)[0];
5676
5675
 
5677
- if (typeof C === 'undefined') {
5678
- return StorageManager.best;
5679
- }
5676
+ }
5677
+ /**
5678
+ * Thrown upon invocation of an abstract method
5679
+ */
5680
5680
 
5681
- return new C();
5681
+ class AbstractMethodError extends AbstractError {
5682
+ constructor() {
5683
+ super('Can not call an abstract method');
5682
5684
  }
5683
5685
 
5684
5686
  }
@@ -5692,7 +5694,7 @@ __webpack_require__.r(__webpack_exports__);
5692
5694
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5693
5695
  /* harmony export */ "default": () => (/* binding */ DataStoreContract)
5694
5696
  /* harmony export */ });
5695
- /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(21);
5697
+ /* harmony import */ var _errors_AbstractError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(22);
5696
5698
  /*
5697
5699
  * BSD 3-Clause License
5698
5700
  *
@@ -6422,7 +6424,7 @@ function base64Encode(buffer) {
6422
6424
  return base64;
6423
6425
  }
6424
6426
  // EXTERNAL MODULE: ./src/utils/node.js
6425
- var node = __webpack_require__(9);
6427
+ var node = __webpack_require__(8);
6426
6428
  ;// CONCATENATED MODULE: ./src/resources/base/DownloadedResource.js
6427
6429
  /*
6428
6430
  * BSD 3-Clause License
@@ -6754,13 +6756,13 @@ var OwnableResource = __webpack_require__(4);
6754
6756
  // EXTERNAL MODULE: ./src/utils/reflection.js
6755
6757
  var reflection = __webpack_require__(0);
6756
6758
  // EXTERNAL MODULE: ./src/resources/base/CrudSetBase.js
6757
- var CrudSetBase = __webpack_require__(16);
6759
+ var CrudSetBase = __webpack_require__(17);
6758
6760
  // EXTERNAL MODULE: ./src/resources/Mapstyle.js
6759
6761
  var Mapstyle = __webpack_require__(70);
6760
6762
  // EXTERNAL MODULE: ./src/proxy/ResourceProxy.js
6761
- var ResourceProxy = __webpack_require__(14);
6763
+ var ResourceProxy = __webpack_require__(15);
6762
6764
  // EXTERNAL MODULE: ./src/resources/base/CrudSetItemBase.js
6763
- var CrudSetItemBase = __webpack_require__(10);
6765
+ var CrudSetItemBase = __webpack_require__(11);
6764
6766
  ;// CONCATENATED MODULE: ./src/resources/MapstyleSetColor.js
6765
6767
  /*
6766
6768
  * BSD 3-Clause License
@@ -6890,7 +6892,7 @@ __webpack_require__.r(__webpack_exports__);
6890
6892
  /* harmony export */ });
6891
6893
  /* harmony import */ var _traits_OwnableResource__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
6892
6894
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
6893
- /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(10);
6895
+ /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
6894
6896
  /*
6895
6897
  * BSD 3-Clause License
6896
6898
  *
@@ -7238,7 +7240,7 @@ var Language = __webpack_require__(71);
7238
7240
  // EXTERNAL MODULE: ./src/resources/Layer.js
7239
7241
  var Layer = __webpack_require__(27);
7240
7242
  // EXTERNAL MODULE: ./src/resources/base/CrudSetItemBase.js
7241
- var CrudSetItemBase = __webpack_require__(10);
7243
+ var CrudSetItemBase = __webpack_require__(11);
7242
7244
  ;// CONCATENATED MODULE: ./src/resources/LayerFaq.js
7243
7245
  /*
7244
7246
  * BSD 3-Clause License
@@ -7364,7 +7366,7 @@ class OrganisationNote extends (0,reflection.mix)(CrudBase["default"], OwnableRe
7364
7366
  // EXTERNAL MODULE: ./src/resources/Permission.js
7365
7367
  var Permission = __webpack_require__(59);
7366
7368
  // EXTERNAL MODULE: ./src/resources/base/CrudSetBase.js
7367
- var CrudSetBase = __webpack_require__(16);
7369
+ var CrudSetBase = __webpack_require__(17);
7368
7370
  ;// CONCATENATED MODULE: ./src/resources/ProductTourStep.js
7369
7371
  /*
7370
7372
  * BSD 3-Clause License
@@ -8414,7 +8416,7 @@ __webpack_require__.r(__webpack_exports__);
8414
8416
  /* harmony export */ "default": () => (/* binding */ OrganisationProxy)
8415
8417
  /* harmony export */ });
8416
8418
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
8417
- /* harmony import */ var _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(15);
8419
+ /* harmony import */ var _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16);
8418
8420
  /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
8419
8421
  /*
8420
8422
  * BSD 3-Clause License
@@ -8603,7 +8605,7 @@ __webpack_require__.d(__webpack_exports__, {
8603
8605
  });
8604
8606
 
8605
8607
  // EXTERNAL MODULE: ./src/errors/AbstractError.js
8606
- var AbstractError = __webpack_require__(21);
8608
+ var AbstractError = __webpack_require__(22);
8607
8609
  // EXTERNAL MODULE: ./src/errors/ApiError.js
8608
8610
  var ApiError = __webpack_require__(66);
8609
8611
  // EXTERNAL MODULE: ./src/errors/ValidationError.js
@@ -8646,7 +8648,7 @@ var ValidationError = __webpack_require__(78);
8646
8648
  */
8647
8649
  class NodeError extends Error {}
8648
8650
  // EXTERNAL MODULE: ./src/errors/OAuthError.js
8649
- var OAuthError = __webpack_require__(18);
8651
+ var OAuthError = __webpack_require__(19);
8650
8652
  // EXTERNAL MODULE: ./src/errors/StaticClassError.js
8651
8653
  var StaticClassError = __webpack_require__(62);
8652
8654
  // EXTERNAL MODULE: ./src/errors/GeoError.js
@@ -9391,7 +9393,7 @@ __webpack_require__.d(__webpack_exports__, {
9391
9393
  });
9392
9394
 
9393
9395
  // EXTERNAL MODULE: ./src/storage/StorageManager.js + 3 modules
9394
- var StorageManager = __webpack_require__(22);
9396
+ var StorageManager = __webpack_require__(20);
9395
9397
  // EXTERNAL MODULE: ./src/utils/StaticClass.js
9396
9398
  var StaticClass = __webpack_require__(34);
9397
9399
  ;// CONCATENATED MODULE: ./src/utils/uuid.js
@@ -9581,9 +9583,9 @@ __webpack_require__.r(__webpack_exports__);
9581
9583
  /* harmony export */ "default": () => (/* binding */ GeoResourceProxy)
9582
9584
  /* harmony export */ });
9583
9585
  /* harmony import */ var _errors_GeoError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(44);
9584
- /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8);
9586
+ /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9);
9585
9587
  /* harmony import */ var _utils_geo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(64);
9586
- /* harmony import */ var _ResourceProxy__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(14);
9588
+ /* harmony import */ var _ResourceProxy__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(15);
9587
9589
  /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(1);
9588
9590
  /*
9589
9591
  * BSD 3-Clause License
@@ -9801,7 +9803,7 @@ __webpack_require__.r(__webpack_exports__);
9801
9803
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9802
9804
  /* harmony export */ "default": () => (/* binding */ Organisation)
9803
9805
  /* harmony export */ });
9804
- /* harmony import */ var _proxy_OwnedResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20);
9806
+ /* harmony import */ var _proxy_OwnedResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(21);
9805
9807
  /* harmony import */ var _base_CrudBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
9806
9808
  /* harmony import */ var _Color__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(46);
9807
9809
  /* harmony import */ var _Contract__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(67);
@@ -9821,7 +9823,7 @@ __webpack_require__.r(__webpack_exports__);
9821
9823
  /* harmony import */ var _utils_requests__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(6);
9822
9824
  /* harmony import */ var _LayerGroup__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(74);
9823
9825
  /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(30);
9824
- /* harmony import */ var _proxy_ResourceProxy__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(14);
9826
+ /* harmony import */ var _proxy_ResourceProxy__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(15);
9825
9827
  /*
9826
9828
  * BSD 3-Clause License
9827
9829
  *
@@ -10134,7 +10136,7 @@ __webpack_require__.r(__webpack_exports__);
10134
10136
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10135
10137
  /* harmony export */ "default": () => (/* binding */ DimensionSet)
10136
10138
  /* harmony export */ });
10137
- /* harmony import */ var _base_CrudSetBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16);
10139
+ /* harmony import */ var _base_CrudSetBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(17);
10138
10140
  /* harmony import */ var _Dimension__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(48);
10139
10141
  /* harmony import */ var _traits_OwnableResource__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
10140
10142
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(0);
@@ -10203,7 +10205,7 @@ __webpack_require__.r(__webpack_exports__);
10203
10205
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10204
10206
  /* harmony export */ "default": () => (/* binding */ Dimension)
10205
10207
  /* harmony export */ });
10206
- /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
10208
+ /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11);
10207
10209
  /*
10208
10210
  * BSD 3-Clause License
10209
10211
  *
@@ -10317,7 +10319,7 @@ __webpack_require__.r(__webpack_exports__);
10317
10319
  /* harmony export */ });
10318
10320
  /* harmony import */ var _traits_OwnableResource__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
10319
10321
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
10320
- /* harmony import */ var _base_CrudSetBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(16);
10322
+ /* harmony import */ var _base_CrudSetBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(17);
10321
10323
  /* harmony import */ var _Font__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(51);
10322
10324
  /*
10323
10325
  * BSD 3-Clause License
@@ -10384,7 +10386,7 @@ __webpack_require__.r(__webpack_exports__);
10384
10386
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10385
10387
  /* harmony export */ "default": () => (/* binding */ Font)
10386
10388
  /* harmony export */ });
10387
- /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
10389
+ /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11);
10388
10390
  /*
10389
10391
  * BSD 3-Clause License
10390
10392
  *
@@ -10437,12 +10439,12 @@ __webpack_require__.r(__webpack_exports__);
10437
10439
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10438
10440
  /* harmony export */ "default": () => (/* binding */ Job)
10439
10441
  /* harmony export */ });
10440
- /* harmony import */ var _proxy_ResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14);
10442
+ /* harmony import */ var _proxy_ResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15);
10441
10443
  /* harmony import */ var _base_DownloadedResource__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(25);
10442
10444
  /* harmony import */ var _base_CrudBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
10443
10445
  /* harmony import */ var _JobResult__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(53);
10444
10446
  /* harmony import */ var _JobRevision__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(69);
10445
- /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8);
10447
+ /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(9);
10446
10448
  /* harmony import */ var _utils_requests__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(6);
10447
10449
  /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(7);
10448
10450
  /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1);
@@ -10640,7 +10642,7 @@ __webpack_require__.r(__webpack_exports__);
10640
10642
  /* harmony export */ });
10641
10643
  /* harmony import */ var _base_DownloadedResource__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25);
10642
10644
  /* harmony import */ var _base_ResourceBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
10643
- /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8);
10645
+ /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9);
10644
10646
  /* harmony import */ var _utils_requests__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6);
10645
10647
  /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7);
10646
10648
  /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1);
@@ -10867,7 +10869,7 @@ __webpack_require__.d(__webpack_exports__, {
10867
10869
  // EXTERNAL MODULE: ./src/traits/Trait.js
10868
10870
  var Trait = __webpack_require__(32);
10869
10871
  // EXTERNAL MODULE: ./src/Mapcreator.js + 1 modules
10870
- var Mapcreator = __webpack_require__(17);
10872
+ var Mapcreator = __webpack_require__(18);
10871
10873
  // EXTERNAL MODULE: ./src/resources/base/DownloadedResource.js + 1 modules
10872
10874
  var DownloadedResource = __webpack_require__(25);
10873
10875
  // EXTERNAL MODULE: ./src/resources/base/ResourceBase.js
@@ -11147,7 +11149,7 @@ __webpack_require__.r(__webpack_exports__);
11147
11149
  /* harmony export */ "default": () => (/* binding */ SvgSet)
11148
11150
  /* harmony export */ });
11149
11151
  /* harmony import */ var _traits_OwnableResource__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
11150
- /* harmony import */ var _base_CrudSetBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16);
11152
+ /* harmony import */ var _base_CrudSetBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(17);
11151
11153
  /* harmony import */ var _Svg__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(57);
11152
11154
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(0);
11153
11155
  /*
@@ -11215,7 +11217,7 @@ __webpack_require__.r(__webpack_exports__);
11215
11217
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11216
11218
  /* harmony export */ "default": () => (/* binding */ Svg)
11217
11219
  /* harmony export */ });
11218
- /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
11220
+ /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11);
11219
11221
  /*
11220
11222
  * BSD 3-Clause License
11221
11223
  *
@@ -11264,8 +11266,8 @@ __webpack_require__.r(__webpack_exports__);
11264
11266
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11265
11267
  /* harmony export */ "default": () => (/* binding */ User)
11266
11268
  /* harmony export */ });
11267
- /* harmony import */ var _proxy_OwnedResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20);
11268
- /* harmony import */ var _proxy_ResourceProxy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(14);
11269
+ /* harmony import */ var _proxy_OwnedResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(21);
11270
+ /* harmony import */ var _proxy_ResourceProxy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(15);
11269
11271
  /* harmony import */ var _base_CrudBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
11270
11272
  /* harmony import */ var _Color__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(46);
11271
11273
  /* harmony import */ var _Dimension__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(48);
@@ -11677,7 +11679,7 @@ __webpack_require__.r(__webpack_exports__);
11677
11679
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11678
11680
  /* harmony export */ "default": () => (/* binding */ FileDriver)
11679
11681
  /* harmony export */ });
11680
- /* harmony import */ var _utils_node__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9);
11682
+ /* harmony import */ var _utils_node__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
11681
11683
  /* harmony import */ var _DataStoreContract__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(23);
11682
11684
  /*
11683
11685
  * BSD 3-Clause License
@@ -11877,7 +11879,7 @@ __webpack_require__.r(__webpack_exports__);
11877
11879
  /* harmony export */ "GeoPoint": () => (/* binding */ GeoPoint),
11878
11880
  /* harmony export */ "GeoBoundary": () => (/* binding */ GeoBoundary)
11879
11881
  /* harmony export */ });
11880
- /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(12);
11882
+ /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(13);
11881
11883
  /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
11882
11884
  /* harmony import */ var _errors_GeoError__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(44);
11883
11885
 
@@ -12241,7 +12243,7 @@ class Injectable extends _Trait__WEBPACK_IMPORTED_MODULE_2__["default"] {
12241
12243
  const OwnableResource = (__webpack_require__(4)["default"]);
12242
12244
 
12243
12245
  if ((0,_utils_reflection__WEBPACK_IMPORTED_MODULE_1__.hasTrait)(value, OwnableResource)) {
12244
- const OwnedResourceProxy = (__webpack_require__(20)["default"]);
12246
+ const OwnedResourceProxy = (__webpack_require__(21)["default"]);
12245
12247
 
12246
12248
  this._inject(name, function () {
12247
12249
  return new OwnedResourceProxy(this.api, this, value);
@@ -12252,7 +12254,7 @@ class Injectable extends _Trait__WEBPACK_IMPORTED_MODULE_2__["default"] {
12252
12254
  return this._proxyResourceList(value);
12253
12255
  });
12254
12256
  } else {
12255
- const ResourceProxy = (__webpack_require__(14)["default"]);
12257
+ const ResourceProxy = (__webpack_require__(15)["default"]);
12256
12258
 
12257
12259
  this._inject(name, function () {
12258
12260
  return new ResourceProxy(this, value);
@@ -12288,7 +12290,7 @@ __webpack_require__.r(__webpack_exports__);
12288
12290
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12289
12291
  /* harmony export */ "default": () => (/* binding */ ApiError)
12290
12292
  /* harmony export */ });
12291
- /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(12);
12293
+ /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(13);
12292
12294
  /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
12293
12295
 
12294
12296
 
@@ -12564,7 +12566,7 @@ __webpack_require__.r(__webpack_exports__);
12564
12566
  /* harmony import */ var _JobResult__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(53);
12565
12567
  /* harmony import */ var _JobShare__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(26);
12566
12568
  /* harmony import */ var _Layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(27);
12567
- /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8);
12569
+ /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(9);
12568
12570
  /* harmony import */ var _utils_requests__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(6);
12569
12571
  /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(7);
12570
12572
  /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1);
@@ -12816,7 +12818,7 @@ __webpack_require__.r(__webpack_exports__);
12816
12818
  /* harmony export */ });
12817
12819
  /* harmony import */ var _traits_HandlesImages__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(54);
12818
12820
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
12819
- /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(10);
12821
+ /* harmony import */ var _base_CrudSetItemBase__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(11);
12820
12822
  /*
12821
12823
  * BSD 3-Clause License
12822
12824
  *
@@ -12982,7 +12984,7 @@ __webpack_require__.r(__webpack_exports__);
12982
12984
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12983
12985
  /* harmony export */ "default": () => (/* binding */ Role)
12984
12986
  /* harmony export */ });
12985
- /* harmony import */ var _proxy_OwnedResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20);
12987
+ /* harmony import */ var _proxy_OwnedResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(21);
12986
12988
  /* harmony import */ var _base_CrudBase__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
12987
12989
  /* harmony import */ var _Permission__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(59);
12988
12990
  /* harmony import */ var _User__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(58);
@@ -13057,7 +13059,7 @@ __webpack_require__.r(__webpack_exports__);
13057
13059
  /* harmony import */ var _traits_OwnableResource__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
13058
13060
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
13059
13061
  /* harmony import */ var _Layer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(27);
13060
- /* harmony import */ var _base_CrudSetBase__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(16);
13062
+ /* harmony import */ var _base_CrudSetBase__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(17);
13061
13063
  /* harmony import */ var _proxy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(75);
13062
13064
  /*
13063
13065
  * BSD 3-Clause License
@@ -13132,9 +13134,9 @@ __webpack_require__.r(__webpack_exports__);
13132
13134
  /* harmony export */ });
13133
13135
  /* harmony import */ var _GeoResourceProxy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(43);
13134
13136
  /* harmony import */ var _OrganisationProxy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(35);
13135
- /* harmony import */ var _OwnedResourceProxy__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(20);
13136
- /* harmony import */ var _ResourceProxy__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(14);
13137
- /* harmony import */ var _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(15);
13137
+ /* harmony import */ var _OwnedResourceProxy__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(21);
13138
+ /* harmony import */ var _ResourceProxy__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(15);
13139
+ /* harmony import */ var _SimpleResourceProxy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(16);
13138
13140
  /*
13139
13141
  * BSD 3-Clause License
13140
13142
  *
@@ -13181,8 +13183,8 @@ __webpack_require__.r(__webpack_exports__);
13181
13183
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13182
13184
  /* harmony export */ "default": () => (/* binding */ DummyFlow)
13183
13185
  /* harmony export */ });
13184
- /* harmony import */ var _errors_OAuthError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(18);
13185
- /* harmony import */ var _OAuth__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(19);
13186
+ /* harmony import */ var _errors_OAuthError__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19);
13187
+ /* harmony import */ var _OAuth__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(14);
13186
13188
  /*
13187
13189
  * BSD 3-Clause License
13188
13190
  *
@@ -13261,8 +13263,8 @@ __webpack_require__.r(__webpack_exports__);
13261
13263
  /* harmony import */ var case__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(case__WEBPACK_IMPORTED_MODULE_0__);
13262
13264
  /* harmony import */ var events__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(24);
13263
13265
  /* harmony import */ var events__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(events__WEBPACK_IMPORTED_MODULE_1__);
13264
- /* harmony import */ var _Mapcreator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(17);
13265
- /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8);
13266
+ /* harmony import */ var _Mapcreator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(18);
13267
+ /* harmony import */ var _RequestParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9);
13266
13268
  /* harmony import */ var _resources_base_ResourceBase__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3);
13267
13269
  /* harmony import */ var _utils_reflection__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(0);
13268
13270
  /* harmony import */ var _utils_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(1);
@@ -13660,7 +13662,7 @@ __webpack_require__.r(__webpack_exports__);
13660
13662
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13661
13663
  /* harmony export */ "default": () => (/* binding */ ValidationError)
13662
13664
  /* harmony export */ });
13663
- /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(12);
13665
+ /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(13);
13664
13666
  /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
13665
13667
  /* harmony import */ var _ApiError__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(66);
13666
13668
 
@@ -13925,6 +13927,7 @@ __webpack_require__.d(__webpack_exports__, {
13925
13927
  "AbstractError": () => (/* reexport */ AbstractError.AbstractError),
13926
13928
  "AbstractMethodError": () => (/* reexport */ AbstractError.AbstractMethodError),
13927
13929
  "ApiError": () => (/* reexport */ ApiError["default"]),
13930
+ "CookieFlow": () => (/* reexport */ CookieFlow),
13928
13931
  "DeletedState": () => (/* reexport */ enums.DeletedState),
13929
13932
  "DummyFlow": () => (/* reexport */ DummyFlow["default"]),
13930
13933
  "Enum": () => (/* reexport */ Enum["default"]),
@@ -13949,27 +13952,27 @@ __webpack_require__.d(__webpack_exports__, {
13949
13952
  });
13950
13953
 
13951
13954
  // EXTERNAL MODULE: ./src/Mapcreator.js + 1 modules
13952
- var Mapcreator = __webpack_require__(17);
13955
+ var Mapcreator = __webpack_require__(18);
13953
13956
  // EXTERNAL MODULE: ./src/RequestParameters.js
13954
- var RequestParameters = __webpack_require__(8);
13957
+ var RequestParameters = __webpack_require__(9);
13955
13958
  // EXTERNAL MODULE: ./src/storage/StorageManager.js + 3 modules
13956
- var StorageManager = __webpack_require__(22);
13959
+ var StorageManager = __webpack_require__(20);
13957
13960
  // EXTERNAL MODULE: ./src/enums/Enum.js + 1 modules
13958
- var Enum = __webpack_require__(11);
13961
+ var Enum = __webpack_require__(12);
13959
13962
  // EXTERNAL MODULE: ./src/enums/index.js + 3 modules
13960
13963
  var enums = __webpack_require__(7);
13961
13964
  // EXTERNAL MODULE: ./src/oauth/OAuth.js
13962
- var OAuth = __webpack_require__(19);
13965
+ var OAuth = __webpack_require__(14);
13963
13966
  // EXTERNAL MODULE: ./src/oauth/OAuthToken.js
13964
- var OAuthToken = __webpack_require__(13);
13967
+ var OAuthToken = __webpack_require__(10);
13965
13968
  // EXTERNAL MODULE: ./src/oauth/StateContainer.js + 1 modules
13966
13969
  var StateContainer = __webpack_require__(42);
13967
13970
  // EXTERNAL MODULE: ./src/utils/requests.js
13968
13971
  var requests = __webpack_require__(6);
13969
13972
  // EXTERNAL MODULE: ./src/errors/OAuthError.js
13970
- var OAuthError = __webpack_require__(18);
13973
+ var OAuthError = __webpack_require__(19);
13971
13974
  // EXTERNAL MODULE: ./src/utils/node.js
13972
- var node = __webpack_require__(9);
13975
+ var node = __webpack_require__(8);
13973
13976
  // EXTERNAL MODULE: ./node_modules/case/dist/Case.js
13974
13977
  var Case = __webpack_require__(5);
13975
13978
  ;// CONCATENATED MODULE: ./src/oauth/ImplicitFlow.js
@@ -14232,6 +14235,7 @@ class ImplicitFlow extends OAuth["default"] {
14232
14235
 
14233
14236
 
14234
14237
 
14238
+
14235
14239
  /**
14236
14240
  * Implicit OAuth flow using a pop-up.
14237
14241
  */
@@ -14283,25 +14287,24 @@ class ImplicitFlowPopup extends ImplicitFlow {
14283
14287
  }
14284
14288
 
14285
14289
  return new Promise((resolve, reject) => {
14290
+ const localStorage = StorageManager["default"].localStorage;
14291
+ const storageName = 'api_auth';
14292
+ localStorage.remove(storageName);
14286
14293
  const popup = window.open(this._buildRedirectUrl(), ImplicitFlowPopup.popupWindowName, this.windowOptions);
14287
14294
  const ticker = setInterval(() => {
14288
- if (popup.closed) {
14289
- reject(new OAuthError["default"]('window_closed', 'Pop-up window was closed before data could be extracted'));
14290
- }
14291
-
14292
- let done = false;
14295
+ const locationHash = localStorage.get(storageName);
14293
14296
 
14294
- try {
14295
- done = !['', 'about:blank'].includes(popup.location.href);
14296
- } catch (e) {// Nothing
14297
- }
14298
-
14299
- if (done) {
14297
+ if (locationHash) {
14300
14298
  clearInterval(ticker);
14301
14299
 
14302
- const data = this._getAnchorParams(popup.location.hash);
14300
+ const data = this._getAnchorParams(locationHash);
14301
+
14302
+ localStorage.remove(storageName);
14303
14303
 
14304
- popup.close();
14304
+ try {
14305
+ popup.close();
14306
+ } catch (e) {// cloudflare intercepted or closed manually
14307
+ }
14305
14308
 
14306
14309
  if (data.error) {
14307
14310
  reject(new OAuthError["default"](data.error, data.message));
@@ -14491,10 +14494,114 @@ class PasswordFlow extends OAuth["default"] {
14491
14494
  }
14492
14495
  // EXTERNAL MODULE: ./src/oauth/DummyFlow.js
14493
14496
  var DummyFlow = __webpack_require__(76);
14497
+ ;// CONCATENATED MODULE: ./src/oauth/CookieFlow.js
14498
+ /*
14499
+ * BSD 3-Clause License
14500
+ *
14501
+ * Copyright (c) 2020, Mapcreator
14502
+ * All rights reserved.
14503
+ *
14504
+ * Redistribution and use in source and binary forms, with or without
14505
+ * modification, are permitted provided that the following conditions are met:
14506
+ *
14507
+ * Redistributions of source code must retain the above copyright notice, this
14508
+ * list of conditions and the following disclaimer.
14509
+ *
14510
+ * Redistributions in binary form must reproduce the above copyright notice,
14511
+ * this list of conditions and the following disclaimer in the documentation
14512
+ * and/or other materials provided with the distribution.
14513
+ *
14514
+ * Neither the name of the copyright holder nor the names of its
14515
+ * contributors may be used to endorse or promote products derived from
14516
+ * this software without specific prior written permission.
14517
+ *
14518
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14519
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14520
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
14521
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
14522
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
14523
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
14524
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
14525
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
14526
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
14527
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14528
+ */
14529
+
14530
+
14531
+
14532
+
14533
+ /**
14534
+ * Cookie-based authentication flow using redirection
14535
+ */
14536
+
14537
+ class CookieFlow extends OAuth["default"] {
14538
+ /**
14539
+ * Cookie-based authentication flow
14540
+ * @param {String} clientId - OAuth client id
14541
+ * @param {String} callbackUrl - callbackUrl to redirect to after successful login
14542
+ * @param {Array<String>} scopes - A list of required scopes
14543
+ */
14544
+ constructor(clientId, callbackUrl = '', scopes = ['*']) {
14545
+ super(clientId, scopes);
14546
+
14547
+ if ((0,node.isNode)()) {
14548
+ throw new Error(`${this.constructor.name} can't be used under nodejs`);
14549
+ }
14550
+
14551
+ this.path = '/login';
14552
+ this.callbackUrl = callbackUrl;
14553
+
14554
+ if (!this.callbackUrl) {
14555
+ // Drop the anchor (if any)
14556
+ this.callbackUrl = window.location.toString().split('#')[0];
14557
+ }
14558
+ }
14559
+ /**
14560
+ * @inheritDoc
14561
+ */
14562
+
14563
+
14564
+ authenticate() {
14565
+ return new Promise((resolve, reject) => {
14566
+ // Check authentication status by making a request to the user resources endpoint
14567
+ fetch(`${this.host}/v1/users/me/resources`, {
14568
+ method: 'GET',
14569
+ credentials: 'include' // Important: include cookies in the request
14570
+
14571
+ }).then(response => {
14572
+ if (response.ok) {
14573
+ // We're authenticated, create a token object to maintain compatibility
14574
+ this.token = new OAuthToken["default"]('cookie_auth', 'cookie', 86400);
14575
+ resolve(this.token);
14576
+ } else {
14577
+ // Not authenticated, redirect to login
14578
+ window.location = this._buildRedirectUrl();
14579
+ }
14580
+ }).catch(error => {
14581
+ // Network error or other issues, redirect to login
14582
+ window.location = this._buildRedirectUrl();
14583
+ });
14584
+ });
14585
+ }
14586
+ /**
14587
+ * Builds the url for redirection
14588
+ * @returns {String} - Redirect url
14589
+ * @protected
14590
+ */
14591
+
14592
+
14593
+ _buildRedirectUrl() {
14594
+ const queryParams = {
14595
+ 'redirect_uri': this.callbackUrl
14596
+ };
14597
+ return `${this.host + this.path}?${(0,requests.encodeQueryString)(queryParams)}`;
14598
+ }
14599
+
14600
+ }
14494
14601
  // EXTERNAL MODULE: ./src/errors/ApiError.js
14495
14602
  var ApiError = __webpack_require__(66);
14496
14603
  // EXTERNAL MODULE: ./src/errors/AbstractError.js
14497
- var AbstractError = __webpack_require__(21);
14604
+ var AbstractError = __webpack_require__(22);
14498
14605
  // EXTERNAL MODULE: ./src/errors/ValidationError.js
14499
14606
  var ValidationError = __webpack_require__(78);
14500
14607
  // EXTERNAL MODULE: ./src/errors/StaticClassError.js
@@ -14554,6 +14661,7 @@ var proxy = __webpack_require__(75);
14554
14661
 
14555
14662
 
14556
14663
 
14664
+
14557
14665
  // Exceptions
14558
14666
 
14559
14667
 
@@ -14580,7 +14688,7 @@ var proxy = __webpack_require__(75);
14580
14688
  * @private
14581
14689
  */
14582
14690
 
14583
- const version = "v3.3.1";
14691
+ const version = "v3.3.4";
14584
14692
  })();
14585
14693
 
14586
14694
  /******/ return __webpack_exports__;