@spica-devkit/identity 0.9.29 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,32 +1,6 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var axios_1 = require('axios');
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var axios_1__default = /*#__PURE__*/_interopDefaultLegacy(axios_1);
10
-
11
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
12
-
13
- function createCommonjsModule(fn, basedir, module) {
14
- return module = {
15
- path: basedir,
16
- exports: {},
17
- require: function (path, base) {
18
- return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
19
- }
20
- }, fn(module, module.exports), module.exports;
21
- }
22
-
23
- function commonjsRequire () {
24
- throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
25
- }
26
-
27
- var request = createCommonjsModule(function (module, exports) {
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.Axios = exports.logWarning = void 0;
3
+ var axios = require('axios');
30
4
 
31
5
  function logWarning(response) {
32
6
  const warning = response.headers["warning"];
@@ -34,7 +8,6 @@ function logWarning(response) {
34
8
  console.warn(warning);
35
9
  }
36
10
  }
37
- exports.logWarning = logWarning;
38
11
  class Axios {
39
12
  constructor(config) {
40
13
  this.interceptors = {
@@ -61,10 +34,11 @@ class Axios {
61
34
  }
62
35
  }
63
36
  };
64
- this.instance = axios_1__default['default'].default.create(config);
37
+ this.instance = axios.create(config);
65
38
  this.instance.interceptors.request.use(this.interceptors.request.onFulfilled, this.interceptors.request.onRejected);
66
39
  this.instance.interceptors.response.use(this.interceptors.response.onFulfilled, this.interceptors.response.onRejected);
67
40
  this.baseUrl = this.instance.defaults.baseURL;
41
+ this.instance.defaults.paramsSerializer = paramsSerializer;
68
42
  }
69
43
  setBaseUrl(url) {
70
44
  this.instance.defaults.baseURL = url;
@@ -97,16 +71,77 @@ class Axios {
97
71
  return this.instance.request(config);
98
72
  }
99
73
  }
100
- exports.Axios = Axios;
101
-
102
- });
103
-
104
- var initialize_1 = createCommonjsModule(function (module, exports) {
105
- Object.defineProperty(exports, "__esModule", { value: true });
106
- exports.isPlatformBrowser = exports.checkInitialized = exports.initialize = void 0;
74
+ function encode(val) {
75
+ return encodeURIComponent(val)
76
+ .replace(/%3A/gi, ":")
77
+ .replace(/%24/g, "$")
78
+ .replace(/%2C/gi, ",")
79
+ .replace(/%20/g, "+")
80
+ .replace(/%5B/gi, "[")
81
+ .replace(/%5D/gi, "]");
82
+ }
83
+ function utilsIsURLSearchParams(val) {
84
+ return typeof URLSearchParams !== "undefined" && val instanceof URLSearchParams;
85
+ }
86
+ function utilsIsArray(val) {
87
+ return toString.call(val) === "[object Array]";
88
+ }
89
+ function utilsIsDate(val) {
90
+ return toString.call(val) === "[object Date]";
91
+ }
92
+ function utilsIsObject(val) {
93
+ return val !== null && typeof val === "object";
94
+ }
95
+ function utilsForEach(obj, fn) {
96
+ if (obj === null || typeof obj === "undefined") {
97
+ return;
98
+ }
99
+ if (typeof obj !== "object") {
100
+ obj = [obj];
101
+ }
102
+ if (utilsIsArray(obj)) {
103
+ for (var i = 0, l = obj.length; i < l; i++) {
104
+ fn.call(null, obj[i], i, obj);
105
+ }
106
+ }
107
+ else {
108
+ for (var key in obj) {
109
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
110
+ fn.call(null, obj[key], key, obj);
111
+ }
112
+ }
113
+ }
114
+ }
115
+ function paramsSerializer(params) {
116
+ if (utilsIsURLSearchParams(params)) {
117
+ return params.toString();
118
+ }
119
+ var parts = [];
120
+ utilsForEach(params, function serialize(val, key) {
121
+ if (val === null || typeof val === "undefined") {
122
+ return;
123
+ }
124
+ if (utilsIsArray(val)) {
125
+ key = key + "[]";
126
+ }
127
+ else {
128
+ val = [val];
129
+ }
130
+ utilsForEach(val, function parseValue(v) {
131
+ if (utilsIsDate(v)) {
132
+ v = v.toISOString();
133
+ }
134
+ else if (utilsIsObject(v)) {
135
+ v = JSON.stringify(v);
136
+ }
137
+ parts.push(encode(key) + "=" + encode(v));
138
+ });
139
+ });
140
+ return parts.join("&");
141
+ }
107
142
 
108
- let service;
109
- function initialize(options) {
143
+ let service$1;
144
+ function initialize$1(options) {
110
145
  let authorization;
111
146
  if ("apikey" in options) {
112
147
  authorization = `APIKEY ${options.apikey}`;
@@ -119,90 +154,28 @@ function initialize(options) {
119
154
  if (!publicUrl) {
120
155
  throw new Error("Public url must be provided.");
121
156
  }
122
- if (!service) {
123
- service = new request.Axios({ baseURL: publicUrl, headers: { Authorization: authorization } });
157
+ if (!service$1) {
158
+ service$1 = new Axios({ baseURL: publicUrl, headers: { Authorization: authorization } });
124
159
  }
125
160
  else {
126
- service.setBaseUrl(publicUrl);
127
- service.setAuthorization(authorization);
161
+ service$1.setBaseUrl(publicUrl);
162
+ service$1.setAuthorization(authorization);
128
163
  }
129
- return { authorization, publicUrl, service };
164
+ return { authorization, publicUrl, service: service$1 };
130
165
  }
131
- exports.initialize = initialize;
132
166
  function checkInitialized(authorization) {
133
167
  if (!authorization) {
134
168
  throw new Error("You should call initialize method with a valid apikey or identity token.");
135
169
  }
136
170
  }
137
- exports.checkInitialized = checkInitialized;
138
171
  function getPublicUrl() {
139
172
  return isPlatformBrowser() ? undefined : process.env.__INTERNAL__SPICA__PUBLIC_URL__;
140
173
  }
141
174
  function isPlatformBrowser() {
142
175
  return typeof window !== "undefined";
143
176
  }
144
- exports.isPlatformBrowser = isPlatformBrowser;
145
-
146
- });
147
-
148
- var _interface = createCommonjsModule(function (module, exports) {
149
- Object.defineProperty(exports, "__esModule", { value: true });
150
-
151
- });
152
-
153
- var url = createCommonjsModule(function (module, exports) {
154
- Object.defineProperty(exports, "__esModule", { value: true });
155
- exports.buildUrl = void 0;
156
- function buildUrl(baseUrl, queryParams = {}) {
157
- const url = new URL(baseUrl);
158
- for (let [key, value] of Object.entries(queryParams)) {
159
- if (typeof value != "string") {
160
- value = JSON.stringify(value);
161
- }
162
- url.searchParams.set(key, value);
163
- }
164
- return url;
165
- }
166
- exports.buildUrl = buildUrl;
167
-
168
- });
169
-
170
- var src = createCommonjsModule(function (module, exports) {
171
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
172
- if (k2 === undefined) k2 = k;
173
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
174
- }) : (function(o, m, k, k2) {
175
- if (k2 === undefined) k2 = k;
176
- o[k2] = m[k];
177
- }));
178
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
179
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
180
- };
181
- Object.defineProperty(exports, "__esModule", { value: true });
182
- __exportStar(initialize_1, exports);
183
- __exportStar(_interface, exports);
184
- __exportStar(request, exports);
185
- __exportStar(url, exports);
186
177
 
187
- });
188
-
189
- var internal_common = createCommonjsModule(function (module, exports) {
190
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
191
- if (k2 === undefined) k2 = k;
192
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
193
- }) : (function(o, m, k, k2) {
194
- if (k2 === undefined) k2 = k;
195
- o[k2] = m[k];
196
- }));
197
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
198
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
199
- };
200
- Object.defineProperty(exports, "__esModule", { value: true });
201
- __exportStar(src, exports);
202
-
203
- });
204
-
205
- /*! *****************************************************************************
178
+ /******************************************************************************
206
179
  Copyright (c) Microsoft Corporation.
207
180
 
208
181
  Permission to use, copy, modify, and/or distribute this software for any
@@ -216,493 +189,428 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
216
189
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
217
190
  PERFORMANCE OF THIS SOFTWARE.
218
191
  ***************************************************************************** */
219
- /* global Reflect, Promise */
192
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
220
193
 
221
194
  var extendStatics = function(d, b) {
222
195
  extendStatics = Object.setPrototypeOf ||
223
196
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
224
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
197
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
225
198
  return extendStatics(d, b);
226
199
  };
227
200
 
228
201
  function __extends(d, b) {
202
+ if (typeof b !== "function" && b !== null)
203
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
229
204
  extendStatics(d, b);
230
205
  function __() { this.constructor = d; }
231
206
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
232
- }
233
-
234
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
235
- function isFunction(x) {
236
- return typeof x === 'function';
237
- }
238
-
239
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
240
- var _enable_super_gross_mode_that_will_cause_bad_things = false;
241
- var config = {
242
- Promise: undefined,
243
- set useDeprecatedSynchronousErrorHandling(value) {
244
- if (value) {
245
- var error = /*@__PURE__*/ new Error();
246
- /*@__PURE__*/ console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
247
- }
248
- _enable_super_gross_mode_that_will_cause_bad_things = value;
249
- },
250
- get useDeprecatedSynchronousErrorHandling() {
251
- return _enable_super_gross_mode_that_will_cause_bad_things;
252
- },
253
- };
254
-
255
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
256
- function hostReportError(err) {
257
- setTimeout(function () { throw err; }, 0);
258
- }
259
-
260
- /** PURE_IMPORTS_START _config,_util_hostReportError PURE_IMPORTS_END */
261
- var empty = {
262
- closed: true,
263
- next: function (value) { },
264
- error: function (err) {
265
- if (config.useDeprecatedSynchronousErrorHandling) {
266
- throw err;
267
- }
268
- else {
269
- hostReportError(err);
270
- }
271
- },
272
- complete: function () { }
207
+ }
208
+
209
+ function __values(o) {
210
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
211
+ if (m) return m.call(o);
212
+ if (o && typeof o.length === "number") return {
213
+ next: function () {
214
+ if (o && i >= o.length) o = undefined;
215
+ return { value: o && o[i++], done: !o };
216
+ }
217
+ };
218
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
219
+ }
220
+
221
+ function __read(o, n) {
222
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
223
+ if (!m) return o;
224
+ var i = m.call(o), r, ar = [], e;
225
+ try {
226
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
227
+ }
228
+ catch (error) { e = { error: error }; }
229
+ finally {
230
+ try {
231
+ if (r && !r.done && (m = i["return"])) m.call(i);
232
+ }
233
+ finally { if (e) throw e.error; }
234
+ }
235
+ return ar;
236
+ }
237
+
238
+ function __spreadArray(to, from, pack) {
239
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
240
+ if (ar || !(i in from)) {
241
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
242
+ ar[i] = from[i];
243
+ }
244
+ }
245
+ return to.concat(ar || Array.prototype.slice.call(from));
246
+ }
247
+
248
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
249
+ var e = new Error(message);
250
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
273
251
  };
274
252
 
275
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
276
- var isArray = /*@__PURE__*/ (function () { return Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); })();
277
-
278
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
279
- function isObject(x) {
280
- return x !== null && typeof x === 'object';
253
+ function isFunction(value) {
254
+ return typeof value === 'function';
281
255
  }
282
256
 
283
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
284
- var UnsubscriptionErrorImpl = /*@__PURE__*/ (function () {
285
- function UnsubscriptionErrorImpl(errors) {
286
- Error.call(this);
287
- this.message = errors ?
288
- errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ') : '';
257
+ function createErrorClass(createImpl) {
258
+ var _super = function (instance) {
259
+ Error.call(instance);
260
+ instance.stack = new Error().stack;
261
+ };
262
+ var ctorFunc = createImpl(_super);
263
+ ctorFunc.prototype = Object.create(Error.prototype);
264
+ ctorFunc.prototype.constructor = ctorFunc;
265
+ return ctorFunc;
266
+ }
267
+
268
+ var UnsubscriptionError = createErrorClass(function (_super) {
269
+ return function UnsubscriptionErrorImpl(errors) {
270
+ _super(this);
271
+ this.message = errors
272
+ ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ')
273
+ : '';
289
274
  this.name = 'UnsubscriptionError';
290
275
  this.errors = errors;
291
- return this;
276
+ };
277
+ });
278
+
279
+ function arrRemove(arr, item) {
280
+ if (arr) {
281
+ var index = arr.indexOf(item);
282
+ 0 <= index && arr.splice(index, 1);
292
283
  }
293
- UnsubscriptionErrorImpl.prototype = /*@__PURE__*/ Object.create(Error.prototype);
294
- return UnsubscriptionErrorImpl;
295
- })();
296
- var UnsubscriptionError = UnsubscriptionErrorImpl;
284
+ }
297
285
 
298
- /** PURE_IMPORTS_START _util_isArray,_util_isObject,_util_isFunction,_util_UnsubscriptionError PURE_IMPORTS_END */
299
- var Subscription = /*@__PURE__*/ (function () {
300
- function Subscription(unsubscribe) {
286
+ var Subscription = (function () {
287
+ function Subscription(initialTeardown) {
288
+ this.initialTeardown = initialTeardown;
301
289
  this.closed = false;
302
- this._parentOrParents = null;
303
- this._subscriptions = null;
304
- if (unsubscribe) {
305
- this._ctorUnsubscribe = true;
306
- this._unsubscribe = unsubscribe;
307
- }
290
+ this._parentage = null;
291
+ this._finalizers = null;
308
292
  }
309
293
  Subscription.prototype.unsubscribe = function () {
294
+ var e_1, _a, e_2, _b;
310
295
  var errors;
311
- if (this.closed) {
312
- return;
313
- }
314
- var _a = this, _parentOrParents = _a._parentOrParents, _ctorUnsubscribe = _a._ctorUnsubscribe, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
315
- this.closed = true;
316
- this._parentOrParents = null;
317
- this._subscriptions = null;
318
- if (_parentOrParents instanceof Subscription) {
319
- _parentOrParents.remove(this);
320
- }
321
- else if (_parentOrParents !== null) {
322
- for (var index = 0; index < _parentOrParents.length; ++index) {
323
- var parent_1 = _parentOrParents[index];
324
- parent_1.remove(this);
325
- }
326
- }
327
- if (isFunction(_unsubscribe)) {
328
- if (_ctorUnsubscribe) {
329
- this._unsubscribe = undefined;
330
- }
331
- try {
332
- _unsubscribe.call(this);
333
- }
334
- catch (e) {
335
- errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
336
- }
337
- }
338
- if (isArray(_subscriptions)) {
339
- var index = -1;
340
- var len = _subscriptions.length;
341
- while (++index < len) {
342
- var sub = _subscriptions[index];
343
- if (isObject(sub)) {
296
+ if (!this.closed) {
297
+ this.closed = true;
298
+ var _parentage = this._parentage;
299
+ if (_parentage) {
300
+ this._parentage = null;
301
+ if (Array.isArray(_parentage)) {
344
302
  try {
345
- sub.unsubscribe();
346
- }
347
- catch (e) {
348
- errors = errors || [];
349
- if (e instanceof UnsubscriptionError) {
350
- errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
303
+ for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
304
+ var parent_1 = _parentage_1_1.value;
305
+ parent_1.remove(this);
351
306
  }
352
- else {
353
- errors.push(e);
307
+ }
308
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
309
+ finally {
310
+ try {
311
+ if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
354
312
  }
313
+ finally { if (e_1) throw e_1.error; }
355
314
  }
356
315
  }
316
+ else {
317
+ _parentage.remove(this);
318
+ }
357
319
  }
358
- }
359
- if (errors) {
360
- throw new UnsubscriptionError(errors);
361
- }
362
- };
363
- Subscription.prototype.add = function (teardown) {
364
- var subscription = teardown;
365
- if (!teardown) {
366
- return Subscription.EMPTY;
367
- }
368
- switch (typeof teardown) {
369
- case 'function':
370
- subscription = new Subscription(teardown);
371
- case 'object':
372
- if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
373
- return subscription;
320
+ var initialFinalizer = this.initialTeardown;
321
+ if (isFunction(initialFinalizer)) {
322
+ try {
323
+ initialFinalizer();
374
324
  }
375
- else if (this.closed) {
376
- subscription.unsubscribe();
377
- return subscription;
325
+ catch (e) {
326
+ errors = e instanceof UnsubscriptionError ? e.errors : [e];
378
327
  }
379
- else if (!(subscription instanceof Subscription)) {
380
- var tmp = subscription;
381
- subscription = new Subscription();
382
- subscription._subscriptions = [tmp];
328
+ }
329
+ var _finalizers = this._finalizers;
330
+ if (_finalizers) {
331
+ this._finalizers = null;
332
+ try {
333
+ for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
334
+ var finalizer = _finalizers_1_1.value;
335
+ try {
336
+ execFinalizer(finalizer);
337
+ }
338
+ catch (err) {
339
+ errors = errors !== null && errors !== void 0 ? errors : [];
340
+ if (err instanceof UnsubscriptionError) {
341
+ errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
342
+ }
343
+ else {
344
+ errors.push(err);
345
+ }
346
+ }
347
+ }
348
+ }
349
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
350
+ finally {
351
+ try {
352
+ if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
353
+ }
354
+ finally { if (e_2) throw e_2.error; }
383
355
  }
384
- break;
385
- default: {
386
- throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
387
356
  }
388
- }
389
- var _parentOrParents = subscription._parentOrParents;
390
- if (_parentOrParents === null) {
391
- subscription._parentOrParents = this;
392
- }
393
- else if (_parentOrParents instanceof Subscription) {
394
- if (_parentOrParents === this) {
395
- return subscription;
357
+ if (errors) {
358
+ throw new UnsubscriptionError(errors);
396
359
  }
397
- subscription._parentOrParents = [_parentOrParents, this];
398
360
  }
399
- else if (_parentOrParents.indexOf(this) === -1) {
400
- _parentOrParents.push(this);
401
- }
402
- else {
403
- return subscription;
361
+ };
362
+ Subscription.prototype.add = function (teardown) {
363
+ var _a;
364
+ if (teardown && teardown !== this) {
365
+ if (this.closed) {
366
+ execFinalizer(teardown);
367
+ }
368
+ else {
369
+ if (teardown instanceof Subscription) {
370
+ if (teardown.closed || teardown._hasParent(this)) {
371
+ return;
372
+ }
373
+ teardown._addParent(this);
374
+ }
375
+ (this._finalizers = (_a = this._finalizers) !== null && _a !== undefined ? _a : []).push(teardown);
376
+ }
404
377
  }
405
- var subscriptions = this._subscriptions;
406
- if (subscriptions === null) {
407
- this._subscriptions = [subscription];
378
+ };
379
+ Subscription.prototype._hasParent = function (parent) {
380
+ var _parentage = this._parentage;
381
+ return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
382
+ };
383
+ Subscription.prototype._addParent = function (parent) {
384
+ var _parentage = this._parentage;
385
+ this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
386
+ };
387
+ Subscription.prototype._removeParent = function (parent) {
388
+ var _parentage = this._parentage;
389
+ if (_parentage === parent) {
390
+ this._parentage = null;
408
391
  }
409
- else {
410
- subscriptions.push(subscription);
392
+ else if (Array.isArray(_parentage)) {
393
+ arrRemove(_parentage, parent);
411
394
  }
412
- return subscription;
413
395
  };
414
- Subscription.prototype.remove = function (subscription) {
415
- var subscriptions = this._subscriptions;
416
- if (subscriptions) {
417
- var subscriptionIndex = subscriptions.indexOf(subscription);
418
- if (subscriptionIndex !== -1) {
419
- subscriptions.splice(subscriptionIndex, 1);
420
- }
396
+ Subscription.prototype.remove = function (teardown) {
397
+ var _finalizers = this._finalizers;
398
+ _finalizers && arrRemove(_finalizers, teardown);
399
+ if (teardown instanceof Subscription) {
400
+ teardown._removeParent(this);
421
401
  }
422
402
  };
423
- Subscription.EMPTY = (function (empty) {
403
+ Subscription.EMPTY = (function () {
404
+ var empty = new Subscription();
424
405
  empty.closed = true;
425
406
  return empty;
426
- }(new Subscription()));
407
+ })();
427
408
  return Subscription;
428
409
  }());
429
- function flattenUnsubscriptionErrors(errors) {
430
- return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError) ? err.errors : err); }, []);
410
+ Subscription.EMPTY;
411
+ function isSubscription(value) {
412
+ return (value instanceof Subscription ||
413
+ (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
414
+ }
415
+ function execFinalizer(finalizer) {
416
+ if (isFunction(finalizer)) {
417
+ finalizer();
418
+ }
419
+ else {
420
+ finalizer.unsubscribe();
421
+ }
431
422
  }
432
423
 
433
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
434
- var rxSubscriber = /*@__PURE__*/ (function () {
435
- return typeof Symbol === 'function'
436
- ? /*@__PURE__*/ Symbol('rxSubscriber')
437
- : '@@rxSubscriber_' + /*@__PURE__*/ Math.random();
438
- })();
424
+ var config = {
425
+ onUnhandledError: null,
426
+ onStoppedNotification: null,
427
+ Promise: undefined,
428
+ useDeprecatedSynchronousErrorHandling: false,
429
+ useDeprecatedNextContext: false,
430
+ };
431
+
432
+ var timeoutProvider = {
433
+ setTimeout: function (handler, timeout) {
434
+ var args = [];
435
+ for (var _i = 2; _i < arguments.length; _i++) {
436
+ args[_i - 2] = arguments[_i];
437
+ }
438
+ return setTimeout.apply(undefined, __spreadArray([handler, timeout], __read(args)));
439
+ },
440
+ clearTimeout: function (handle) {
441
+ return (clearTimeout)(handle);
442
+ },
443
+ delegate: undefined,
444
+ };
445
+
446
+ function reportUnhandledError(err) {
447
+ timeoutProvider.setTimeout(function () {
448
+ {
449
+ throw err;
450
+ }
451
+ });
452
+ }
439
453
 
440
- /** PURE_IMPORTS_START tslib,_util_isFunction,_Observer,_Subscription,_internal_symbol_rxSubscriber,_config,_util_hostReportError PURE_IMPORTS_END */
441
- var Subscriber = /*@__PURE__*/ (function (_super) {
454
+ function noop() { }
455
+
456
+ function errorContext(cb) {
457
+ {
458
+ cb();
459
+ }
460
+ }
461
+
462
+ var Subscriber = (function (_super) {
442
463
  __extends(Subscriber, _super);
443
- function Subscriber(destinationOrNext, error, complete) {
464
+ function Subscriber(destination) {
444
465
  var _this = _super.call(this) || this;
445
- _this.syncErrorValue = null;
446
- _this.syncErrorThrown = false;
447
- _this.syncErrorThrowable = false;
448
466
  _this.isStopped = false;
449
- switch (arguments.length) {
450
- case 0:
451
- _this.destination = empty;
452
- break;
453
- case 1:
454
- if (!destinationOrNext) {
455
- _this.destination = empty;
456
- break;
457
- }
458
- if (typeof destinationOrNext === 'object') {
459
- if (destinationOrNext instanceof Subscriber) {
460
- _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
461
- _this.destination = destinationOrNext;
462
- destinationOrNext.add(_this);
463
- }
464
- else {
465
- _this.syncErrorThrowable = true;
466
- _this.destination = new SafeSubscriber(_this, destinationOrNext);
467
- }
468
- break;
469
- }
470
- default:
471
- _this.syncErrorThrowable = true;
472
- _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
473
- break;
467
+ if (destination) {
468
+ _this.destination = destination;
469
+ if (isSubscription(destination)) {
470
+ destination.add(_this);
471
+ }
472
+ }
473
+ else {
474
+ _this.destination = EMPTY_OBSERVER;
474
475
  }
475
476
  return _this;
476
477
  }
477
- Subscriber.prototype[rxSubscriber] = function () { return this; };
478
478
  Subscriber.create = function (next, error, complete) {
479
- var subscriber = new Subscriber(next, error, complete);
480
- subscriber.syncErrorThrowable = false;
481
- return subscriber;
479
+ return new SafeSubscriber(next, error, complete);
482
480
  };
483
481
  Subscriber.prototype.next = function (value) {
484
- if (!this.isStopped) {
482
+ if (this.isStopped) ;
483
+ else {
485
484
  this._next(value);
486
485
  }
487
486
  };
488
487
  Subscriber.prototype.error = function (err) {
489
- if (!this.isStopped) {
488
+ if (this.isStopped) ;
489
+ else {
490
490
  this.isStopped = true;
491
491
  this._error(err);
492
492
  }
493
493
  };
494
494
  Subscriber.prototype.complete = function () {
495
- if (!this.isStopped) {
495
+ if (this.isStopped) ;
496
+ else {
496
497
  this.isStopped = true;
497
498
  this._complete();
498
499
  }
499
500
  };
500
501
  Subscriber.prototype.unsubscribe = function () {
501
- if (this.closed) {
502
- return;
502
+ if (!this.closed) {
503
+ this.isStopped = true;
504
+ _super.prototype.unsubscribe.call(this);
505
+ this.destination = null;
503
506
  }
504
- this.isStopped = true;
505
- _super.prototype.unsubscribe.call(this);
506
507
  };
507
508
  Subscriber.prototype._next = function (value) {
508
509
  this.destination.next(value);
509
510
  };
510
511
  Subscriber.prototype._error = function (err) {
511
- this.destination.error(err);
512
- this.unsubscribe();
512
+ try {
513
+ this.destination.error(err);
514
+ }
515
+ finally {
516
+ this.unsubscribe();
517
+ }
513
518
  };
514
519
  Subscriber.prototype._complete = function () {
515
- this.destination.complete();
516
- this.unsubscribe();
517
- };
518
- Subscriber.prototype._unsubscribeAndRecycle = function () {
519
- var _parentOrParents = this._parentOrParents;
520
- this._parentOrParents = null;
521
- this.unsubscribe();
522
- this.closed = false;
523
- this.isStopped = false;
524
- this._parentOrParents = _parentOrParents;
525
- return this;
520
+ try {
521
+ this.destination.complete();
522
+ }
523
+ finally {
524
+ this.unsubscribe();
525
+ }
526
526
  };
527
527
  return Subscriber;
528
528
  }(Subscription));
529
- var SafeSubscriber = /*@__PURE__*/ (function (_super) {
530
- __extends(SafeSubscriber, _super);
531
- function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
532
- var _this = _super.call(this) || this;
533
- _this._parentSubscriber = _parentSubscriber;
534
- var next;
535
- var context = _this;
536
- if (isFunction(observerOrNext)) {
537
- next = observerOrNext;
538
- }
539
- else if (observerOrNext) {
540
- next = observerOrNext.next;
541
- error = observerOrNext.error;
542
- complete = observerOrNext.complete;
543
- if (observerOrNext !== empty) {
544
- context = Object.create(observerOrNext);
545
- if (isFunction(context.unsubscribe)) {
546
- _this.add(context.unsubscribe.bind(context));
547
- }
548
- context.unsubscribe = _this.unsubscribe.bind(_this);
549
- }
550
- }
551
- _this._context = context;
552
- _this._next = next;
553
- _this._error = error;
554
- _this._complete = complete;
555
- return _this;
529
+ var ConsumerObserver = (function () {
530
+ function ConsumerObserver(partialObserver) {
531
+ this.partialObserver = partialObserver;
556
532
  }
557
- SafeSubscriber.prototype.next = function (value) {
558
- if (!this.isStopped && this._next) {
559
- var _parentSubscriber = this._parentSubscriber;
560
- if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
561
- this.__tryOrUnsub(this._next, value);
533
+ ConsumerObserver.prototype.next = function (value) {
534
+ var partialObserver = this.partialObserver;
535
+ if (partialObserver.next) {
536
+ try {
537
+ partialObserver.next(value);
562
538
  }
563
- else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
564
- this.unsubscribe();
539
+ catch (error) {
540
+ handleUnhandledError(error);
565
541
  }
566
542
  }
567
543
  };
568
- SafeSubscriber.prototype.error = function (err) {
569
- if (!this.isStopped) {
570
- var _parentSubscriber = this._parentSubscriber;
571
- var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
572
- if (this._error) {
573
- if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
574
- this.__tryOrUnsub(this._error, err);
575
- this.unsubscribe();
576
- }
577
- else {
578
- this.__tryOrSetError(_parentSubscriber, this._error, err);
579
- this.unsubscribe();
580
- }
581
- }
582
- else if (!_parentSubscriber.syncErrorThrowable) {
583
- this.unsubscribe();
584
- if (useDeprecatedSynchronousErrorHandling) {
585
- throw err;
586
- }
587
- hostReportError(err);
544
+ ConsumerObserver.prototype.error = function (err) {
545
+ var partialObserver = this.partialObserver;
546
+ if (partialObserver.error) {
547
+ try {
548
+ partialObserver.error(err);
588
549
  }
589
- else {
590
- if (useDeprecatedSynchronousErrorHandling) {
591
- _parentSubscriber.syncErrorValue = err;
592
- _parentSubscriber.syncErrorThrown = true;
593
- }
594
- else {
595
- hostReportError(err);
596
- }
597
- this.unsubscribe();
550
+ catch (error) {
551
+ handleUnhandledError(error);
598
552
  }
599
553
  }
600
- };
601
- SafeSubscriber.prototype.complete = function () {
602
- var _this = this;
603
- if (!this.isStopped) {
604
- var _parentSubscriber = this._parentSubscriber;
605
- if (this._complete) {
606
- var wrappedComplete = function () { return _this._complete.call(_this._context); };
607
- if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
608
- this.__tryOrUnsub(wrappedComplete);
609
- this.unsubscribe();
610
- }
611
- else {
612
- this.__tryOrSetError(_parentSubscriber, wrappedComplete);
613
- this.unsubscribe();
614
- }
615
- }
616
- else {
617
- this.unsubscribe();
618
- }
554
+ else {
555
+ handleUnhandledError(err);
619
556
  }
620
557
  };
621
- SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
622
- try {
623
- fn.call(this._context, value);
624
- }
625
- catch (err) {
626
- this.unsubscribe();
627
- if (config.useDeprecatedSynchronousErrorHandling) {
628
- throw err;
558
+ ConsumerObserver.prototype.complete = function () {
559
+ var partialObserver = this.partialObserver;
560
+ if (partialObserver.complete) {
561
+ try {
562
+ partialObserver.complete();
629
563
  }
630
- else {
631
- hostReportError(err);
564
+ catch (error) {
565
+ handleUnhandledError(error);
632
566
  }
633
567
  }
634
568
  };
635
- SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
636
- if (!config.useDeprecatedSynchronousErrorHandling) {
637
- throw new Error('bad call');
638
- }
639
- try {
640
- fn.call(this._context, value);
569
+ return ConsumerObserver;
570
+ }());
571
+ var SafeSubscriber = (function (_super) {
572
+ __extends(SafeSubscriber, _super);
573
+ function SafeSubscriber(observerOrNext, error, complete) {
574
+ var _this = _super.call(this) || this;
575
+ var partialObserver;
576
+ if (isFunction(observerOrNext) || !observerOrNext) {
577
+ partialObserver = {
578
+ next: (observerOrNext !== null && observerOrNext !== undefined ? observerOrNext : undefined),
579
+ error: error !== null && error !== undefined ? error : undefined,
580
+ complete: complete !== null && complete !== undefined ? complete : undefined,
581
+ };
641
582
  }
642
- catch (err) {
643
- if (config.useDeprecatedSynchronousErrorHandling) {
644
- parent.syncErrorValue = err;
645
- parent.syncErrorThrown = true;
646
- return true;
647
- }
648
- else {
649
- hostReportError(err);
650
- return true;
583
+ else {
584
+ {
585
+ partialObserver = observerOrNext;
651
586
  }
652
587
  }
653
- return false;
654
- };
655
- SafeSubscriber.prototype._unsubscribe = function () {
656
- var _parentSubscriber = this._parentSubscriber;
657
- this._context = null;
658
- this._parentSubscriber = null;
659
- _parentSubscriber.unsubscribe();
660
- };
588
+ _this.destination = new ConsumerObserver(partialObserver);
589
+ return _this;
590
+ }
661
591
  return SafeSubscriber;
662
592
  }(Subscriber));
663
-
664
- /** PURE_IMPORTS_START _Subscriber PURE_IMPORTS_END */
665
- function canReportError(observer) {
666
- while (observer) {
667
- var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
668
- if (closed_1 || isStopped) {
669
- return false;
670
- }
671
- else if (destination && destination instanceof Subscriber) {
672
- observer = destination;
673
- }
674
- else {
675
- observer = null;
676
- }
593
+ function handleUnhandledError(error) {
594
+ {
595
+ reportUnhandledError(error);
677
596
  }
678
- return true;
679
597
  }
680
-
681
- /** PURE_IMPORTS_START _Subscriber,_symbol_rxSubscriber,_Observer PURE_IMPORTS_END */
682
- function toSubscriber(nextOrObserver, error, complete) {
683
- if (nextOrObserver) {
684
- if (nextOrObserver instanceof Subscriber) {
685
- return nextOrObserver;
686
- }
687
- if (nextOrObserver[rxSubscriber]) {
688
- return nextOrObserver[rxSubscriber]();
689
- }
690
- }
691
- if (!nextOrObserver && !error && !complete) {
692
- return new Subscriber(empty);
693
- }
694
- return new Subscriber(nextOrObserver, error, complete);
598
+ function defaultErrorHandler(err) {
599
+ throw err;
695
600
  }
601
+ var EMPTY_OBSERVER = {
602
+ closed: true,
603
+ next: noop,
604
+ error: defaultErrorHandler,
605
+ complete: noop,
606
+ };
696
607
 
697
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
698
- var observable = /*@__PURE__*/ (function () { return typeof Symbol === 'function' && Symbol.observable || '@@observable'; })();
608
+ var observable = (function () { return (typeof Symbol === 'function' && Symbol.observable) || '@@observable'; })();
699
609
 
700
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
701
610
  function identity(x) {
702
611
  return x;
703
612
  }
704
613
 
705
- /** PURE_IMPORTS_START _identity PURE_IMPORTS_END */
706
614
  function pipeFromArray(fns) {
707
615
  if (fns.length === 0) {
708
616
  return identity;
@@ -715,10 +623,8 @@ function pipeFromArray(fns) {
715
623
  };
716
624
  }
717
625
 
718
- /** PURE_IMPORTS_START _util_canReportError,_util_toSubscriber,_symbol_observable,_util_pipe,_config PURE_IMPORTS_END */
719
- var Observable = /*@__PURE__*/ (function () {
626
+ var Observable = (function () {
720
627
  function Observable(subscribe) {
721
- this._isScalar = false;
722
628
  if (subscribe) {
723
629
  this._subscribe = subscribe;
724
630
  }
@@ -730,64 +636,52 @@ var Observable = /*@__PURE__*/ (function () {
730
636
  return observable;
731
637
  };
732
638
  Observable.prototype.subscribe = function (observerOrNext, error, complete) {
733
- var operator = this.operator;
734
- var sink = toSubscriber(observerOrNext, error, complete);
735
- if (operator) {
736
- sink.add(operator.call(sink, this.source));
737
- }
738
- else {
739
- sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
740
- this._subscribe(sink) :
741
- this._trySubscribe(sink));
742
- }
743
- if (config.useDeprecatedSynchronousErrorHandling) {
744
- if (sink.syncErrorThrowable) {
745
- sink.syncErrorThrowable = false;
746
- if (sink.syncErrorThrown) {
747
- throw sink.syncErrorValue;
748
- }
749
- }
750
- }
751
- return sink;
639
+ var _this = this;
640
+ var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
641
+ errorContext(function () {
642
+ var _a = _this, operator = _a.operator, source = _a.source;
643
+ subscriber.add(operator
644
+ ?
645
+ operator.call(subscriber, source)
646
+ : source
647
+ ?
648
+ _this._subscribe(subscriber)
649
+ :
650
+ _this._trySubscribe(subscriber));
651
+ });
652
+ return subscriber;
752
653
  };
753
654
  Observable.prototype._trySubscribe = function (sink) {
754
655
  try {
755
656
  return this._subscribe(sink);
756
657
  }
757
658
  catch (err) {
758
- if (config.useDeprecatedSynchronousErrorHandling) {
759
- sink.syncErrorThrown = true;
760
- sink.syncErrorValue = err;
761
- }
762
- if (canReportError(sink)) {
763
- sink.error(err);
764
- }
765
- else {
766
- console.warn(err);
767
- }
659
+ sink.error(err);
768
660
  }
769
661
  };
770
662
  Observable.prototype.forEach = function (next, promiseCtor) {
771
663
  var _this = this;
772
664
  promiseCtor = getPromiseCtor(promiseCtor);
773
665
  return new promiseCtor(function (resolve, reject) {
774
- var subscription;
775
- subscription = _this.subscribe(function (value) {
776
- try {
777
- next(value);
778
- }
779
- catch (err) {
780
- reject(err);
781
- if (subscription) {
782
- subscription.unsubscribe();
666
+ var subscriber = new SafeSubscriber({
667
+ next: function (value) {
668
+ try {
669
+ next(value);
783
670
  }
784
- }
785
- }, reject, resolve);
671
+ catch (err) {
672
+ reject(err);
673
+ subscriber.unsubscribe();
674
+ }
675
+ },
676
+ error: reject,
677
+ complete: resolve,
678
+ });
679
+ _this.subscribe(subscriber);
786
680
  });
787
681
  };
788
682
  Observable.prototype._subscribe = function (subscriber) {
789
- var source = this.source;
790
- return source && source.subscribe(subscriber);
683
+ var _a;
684
+ return (_a = this.source) === null || _a === undefined ? undefined : _a.subscribe(subscriber);
791
685
  };
792
686
  Observable.prototype[observable] = function () {
793
687
  return this;
@@ -797,9 +691,6 @@ var Observable = /*@__PURE__*/ (function () {
797
691
  for (var _i = 0; _i < arguments.length; _i++) {
798
692
  operations[_i] = arguments[_i];
799
693
  }
800
- if (operations.length === 0) {
801
- return this;
802
- }
803
694
  return pipeFromArray(operations)(this);
804
695
  };
805
696
  Observable.prototype.toPromise = function (promiseCtor) {
@@ -807,7 +698,7 @@ var Observable = /*@__PURE__*/ (function () {
807
698
  promiseCtor = getPromiseCtor(promiseCtor);
808
699
  return new promiseCtor(function (resolve, reject) {
809
700
  var value;
810
- _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
701
+ _this.subscribe(function (x) { return (value = x); }, function (err) { return reject(err); }, function () { return resolve(value); });
811
702
  });
812
703
  };
813
704
  Observable.create = function (subscribe) {
@@ -816,40 +707,19 @@ var Observable = /*@__PURE__*/ (function () {
816
707
  return Observable;
817
708
  }());
818
709
  function getPromiseCtor(promiseCtor) {
819
- if (!promiseCtor) {
820
- promiseCtor = Promise;
821
- }
822
- if (!promiseCtor) {
823
- throw new Error('no Promise impl found');
824
- }
825
- return promiseCtor;
710
+ var _a;
711
+ return (_a = promiseCtor !== null && promiseCtor !== undefined ? promiseCtor : config.Promise) !== null && _a !== undefined ? _a : Promise;
712
+ }
713
+ function isObserver(value) {
714
+ return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
715
+ }
716
+ function isSubscriber(value) {
717
+ return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
826
718
  }
827
719
 
828
- var copy = createCommonjsModule(function (module, exports) {
829
- Object.defineProperty(exports, "__esModule", { value: true });
830
- exports.deepCopyJSON = void 0;
831
720
  function deepCopyJSON(param) {
832
721
  return JSON.parse(JSON.stringify(param));
833
722
  }
834
- exports.deepCopyJSON = deepCopyJSON;
835
-
836
- });
837
-
838
- var copy$1 = createCommonjsModule(function (module, exports) {
839
- var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
840
- if (k2 === undefined) k2 = k;
841
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
842
- }) : (function(o, m, k, k2) {
843
- if (k2 === undefined) k2 = k;
844
- o[k2] = m[k];
845
- }));
846
- var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
847
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
848
- };
849
- Object.defineProperty(exports, "__esModule", { value: true });
850
- __exportStar(copy, exports);
851
-
852
- });
853
723
 
854
724
  let authorization;
855
725
  let service;
@@ -867,7 +737,7 @@ class _Challenge {
867
737
  }
868
738
  }
869
739
  function initialize(options) {
870
- const { authorization: _authorization, service: _service } = internal_common.initialize(options);
740
+ const { authorization: _authorization, service: _service } = initialize$1(options);
871
741
  authorization = _authorization;
872
742
  service = _service;
873
743
  service.setWriteDefaults({
@@ -881,11 +751,11 @@ function verifyToken(token, baseUrl) {
881
751
  if (!_baseUrl) {
882
752
  throw new Error("You should pass the base url of the server or call the initialize method.");
883
753
  }
884
- const req = new internal_common.Axios({ baseURL: _baseUrl });
754
+ const req = new Axios({ baseURL: _baseUrl });
885
755
  return req.get(`${identitySegment}/verify`, { headers: { Authorization: token } });
886
756
  }
887
757
  async function login(identifier, password, tokenLifeSpan) {
888
- internal_common.checkInitialized(authorization);
758
+ checkInitialized(authorization);
889
759
  return service
890
760
  .post("/passport/identify", {
891
761
  identifier,
@@ -900,7 +770,6 @@ async function login(identifier, password, tokenLifeSpan) {
900
770
  return challenge;
901
771
  });
902
772
  }
903
- // we don't want to export this function because it's for internal usages
904
773
  function isTokenScheme(response) {
905
774
  return typeof response.token == "string";
906
775
  }
@@ -908,7 +777,7 @@ function isChallenge(tokenOrChallenge) {
908
777
  return typeof tokenOrChallenge.show == "function" && typeof tokenOrChallenge.answer == "function";
909
778
  }
910
779
  async function loginWithStrategy(id) {
911
- internal_common.checkInitialized(authorization);
780
+ checkInitialized(authorization);
912
781
  const { url, state } = await service.get(`/passport/strategy/${id}/url`);
913
782
  const token = new Observable(observer => {
914
783
  service
@@ -932,6 +801,7 @@ async function loginWithStrategy(id) {
932
801
  token
933
802
  };
934
803
  }
804
+ exports.authfactor = void 0;
935
805
  (function (authfactor) {
936
806
  function list() {
937
807
  return service.get("passport/identity/factors");
@@ -952,18 +822,18 @@ function getStrategies() {
952
822
  return service.get("/passport/strategies");
953
823
  }
954
824
  function get(id) {
955
- internal_common.checkInitialized(authorization);
825
+ checkInitialized(authorization);
956
826
  return service.get(`${identitySegment}/${id}`);
957
827
  }
958
828
  function getAll(queryParams = {}) {
959
- internal_common.checkInitialized(authorization);
829
+ checkInitialized(authorization);
960
830
  return service.get(identitySegment, {
961
831
  params: queryParams
962
832
  });
963
833
  }
964
834
  async function insert(identity) {
965
- internal_common.checkInitialized(authorization);
966
- identity = copy$1.deepCopyJSON(identity);
835
+ checkInitialized(authorization);
836
+ identity = deepCopyJSON(identity);
967
837
  const desiredPolicies = identity.policies;
968
838
  delete identity.policies;
969
839
  const insertedIdentity = await service.post(identitySegment, identity);
@@ -973,25 +843,26 @@ async function insert(identity) {
973
843
  });
974
844
  }
975
845
  async function update(id, identity) {
976
- internal_common.checkInitialized(authorization);
846
+ checkInitialized(authorization);
977
847
  const existingIdentity = await service.get(`${identitySegment}/${id}`);
978
- await exports.policy.detach(id, existingIdentity.policies || []);
979
- identity = copy$1.deepCopyJSON(identity);
848
+ identity = deepCopyJSON(identity);
980
849
  const desiredPolicies = identity.policies;
981
850
  delete identity.policies;
851
+ const { onlyInFirst: policiesForDetach, onlyInSecond: policiesForAttach } = getArrayDifferences(existingIdentity.policies, desiredPolicies);
982
852
  const updatedIdentity = await service.put(`${identitySegment}/${id}`, identity);
983
- return exports.policy.attach(id, desiredPolicies || []).then(policies => {
984
- updatedIdentity.policies = policies;
985
- return updatedIdentity;
986
- });
853
+ updatedIdentity.policies = desiredPolicies;
854
+ await exports.policy.attach(id, policiesForAttach);
855
+ await exports.policy.detach(id, policiesForDetach);
856
+ return updatedIdentity;
987
857
  }
988
858
  function remove(id) {
989
- internal_common.checkInitialized(authorization);
859
+ checkInitialized(authorization);
990
860
  return service.delete(`${identitySegment}/${id}`);
991
861
  }
862
+ exports.policy = void 0;
992
863
  (function (policy) {
993
864
  function attach(identityId, policyIds = []) {
994
- internal_common.checkInitialized(authorization);
865
+ checkInitialized(authorization);
995
866
  const promises = [];
996
867
  const attachedPolicies = new Set();
997
868
  for (const policyId of policyIds) {
@@ -1008,7 +879,7 @@ function remove(id) {
1008
879
  }
1009
880
  policy.attach = attach;
1010
881
  function detach(identityId, policyIds = []) {
1011
- internal_common.checkInitialized(authorization);
882
+ checkInitialized(authorization);
1012
883
  const promises = [];
1013
884
  const detachedPolicies = new Set();
1014
885
  for (const policyId of policyIds) {
@@ -1025,6 +896,13 @@ function remove(id) {
1025
896
  }
1026
897
  policy.detach = detach;
1027
898
  })(exports.policy || (exports.policy = {}));
899
+ function getArrayDifferences(arr1, arr2) {
900
+ const set1 = new Set(arr1);
901
+ const set2 = new Set(arr2);
902
+ const onlyInFirst = arr1.filter(item => !set2.has(item));
903
+ const onlyInSecond = arr2.filter(item => !set1.has(item));
904
+ return { onlyInFirst, onlyInSecond };
905
+ }
1028
906
 
1029
907
  exports.get = get;
1030
908
  exports.getAll = getAll;