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