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