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