@spica-devkit/identity 0.9.29 → 0.10.2
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/index.d.ts +123 -0
- package/index.js +467 -0
- package/index.js.map +1 -0
- package/index.mjs +454 -0
- package/index.mjs.map +1 -0
- package/package.json +11 -8
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1040
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -1025
- package/dist/index.mjs.map +0 -1
- package/dist/src/identity.d.ts +0 -36
- package/dist/src/index.d.ts +0 -2
- package/dist/src/interface.d.ts +0 -75
package/dist/index.mjs
DELETED
|
@@ -1,1025 +0,0 @@
|
|
|
1
|
-
import axios_1 from 'axios';
|
|
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;
|
|
22
|
-
|
|
23
|
-
function logWarning(response) {
|
|
24
|
-
const warning = response.headers["warning"];
|
|
25
|
-
if (warning) {
|
|
26
|
-
console.warn(warning);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.logWarning = logWarning;
|
|
30
|
-
class Axios {
|
|
31
|
-
constructor(config) {
|
|
32
|
-
this.interceptors = {
|
|
33
|
-
request: {
|
|
34
|
-
onFulfilled: (request) => {
|
|
35
|
-
request.maxBodyLength = Number.MAX_SAFE_INTEGER;
|
|
36
|
-
request.maxContentLength = Number.MAX_SAFE_INTEGER;
|
|
37
|
-
if (!request.headers["Authorization"]) {
|
|
38
|
-
throw new Error("You should call initialize method with a valid apikey or identity token.");
|
|
39
|
-
}
|
|
40
|
-
return request;
|
|
41
|
-
},
|
|
42
|
-
onRejected: (error) => {
|
|
43
|
-
return Promise.reject(error);
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
response: {
|
|
47
|
-
onFulfilled: (response) => {
|
|
48
|
-
logWarning(response);
|
|
49
|
-
return response.data;
|
|
50
|
-
},
|
|
51
|
-
onRejected: (error) => {
|
|
52
|
-
return Promise.reject(error.response ? error.response.data : error);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
this.instance = axios_1.default.create(config);
|
|
57
|
-
this.instance.interceptors.request.use(this.interceptors.request.onFulfilled, this.interceptors.request.onRejected);
|
|
58
|
-
this.instance.interceptors.response.use(this.interceptors.response.onFulfilled, this.interceptors.response.onRejected);
|
|
59
|
-
this.baseUrl = this.instance.defaults.baseURL;
|
|
60
|
-
}
|
|
61
|
-
setBaseUrl(url) {
|
|
62
|
-
this.instance.defaults.baseURL = url;
|
|
63
|
-
}
|
|
64
|
-
setWriteDefaults(writeDefaults) {
|
|
65
|
-
for (const [header, value] of Object.entries(writeDefaults.headers)) {
|
|
66
|
-
this.instance.defaults.headers.post[header] = value;
|
|
67
|
-
this.instance.defaults.headers.put[header] = value;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
setAuthorization(authorization) {
|
|
71
|
-
this.instance.defaults.headers["Authorization"] = authorization;
|
|
72
|
-
}
|
|
73
|
-
get(url, config) {
|
|
74
|
-
return this.instance.get(url, config);
|
|
75
|
-
}
|
|
76
|
-
post(url, body, config) {
|
|
77
|
-
return this.instance.post(url, body, config);
|
|
78
|
-
}
|
|
79
|
-
put(url, body, config) {
|
|
80
|
-
return this.instance.put(url, body, config);
|
|
81
|
-
}
|
|
82
|
-
patch(url, body, config) {
|
|
83
|
-
return this.instance.patch(url, body, config);
|
|
84
|
-
}
|
|
85
|
-
delete(url, config) {
|
|
86
|
-
return this.instance.delete(url, config);
|
|
87
|
-
}
|
|
88
|
-
request(config) {
|
|
89
|
-
return this.instance.request(config);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.Axios = Axios;
|
|
93
|
-
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
var initialize_1 = createCommonjsModule(function (module, exports) {
|
|
97
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
98
|
-
exports.isPlatformBrowser = exports.checkInitialized = exports.initialize = void 0;
|
|
99
|
-
|
|
100
|
-
let service;
|
|
101
|
-
function initialize(options) {
|
|
102
|
-
let authorization;
|
|
103
|
-
if ("apikey" in options) {
|
|
104
|
-
authorization = `APIKEY ${options.apikey}`;
|
|
105
|
-
}
|
|
106
|
-
else if ("identity" in options) {
|
|
107
|
-
authorization = `IDENTITY ${options.identity}`;
|
|
108
|
-
}
|
|
109
|
-
checkInitialized(authorization);
|
|
110
|
-
const publicUrl = options.publicUrl || getPublicUrl();
|
|
111
|
-
if (!publicUrl) {
|
|
112
|
-
throw new Error("Public url must be provided.");
|
|
113
|
-
}
|
|
114
|
-
if (!service) {
|
|
115
|
-
service = new request.Axios({ baseURL: publicUrl, headers: { Authorization: authorization } });
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
service.setBaseUrl(publicUrl);
|
|
119
|
-
service.setAuthorization(authorization);
|
|
120
|
-
}
|
|
121
|
-
return { authorization, publicUrl, service };
|
|
122
|
-
}
|
|
123
|
-
exports.initialize = initialize;
|
|
124
|
-
function checkInitialized(authorization) {
|
|
125
|
-
if (!authorization) {
|
|
126
|
-
throw new Error("You should call initialize method with a valid apikey or identity token.");
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
exports.checkInitialized = checkInitialized;
|
|
130
|
-
function getPublicUrl() {
|
|
131
|
-
return isPlatformBrowser() ? undefined : process.env.__INTERNAL__SPICA__PUBLIC_URL__;
|
|
132
|
-
}
|
|
133
|
-
function isPlatformBrowser() {
|
|
134
|
-
return typeof window !== "undefined";
|
|
135
|
-
}
|
|
136
|
-
exports.isPlatformBrowser = isPlatformBrowser;
|
|
137
|
-
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
var _interface = createCommonjsModule(function (module, exports) {
|
|
141
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
142
|
-
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
var url = createCommonjsModule(function (module, exports) {
|
|
146
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
147
|
-
exports.buildUrl = void 0;
|
|
148
|
-
function buildUrl(baseUrl, queryParams = {}) {
|
|
149
|
-
const url = new URL(baseUrl);
|
|
150
|
-
for (let [key, value] of Object.entries(queryParams)) {
|
|
151
|
-
if (typeof value != "string") {
|
|
152
|
-
value = JSON.stringify(value);
|
|
153
|
-
}
|
|
154
|
-
url.searchParams.set(key, value);
|
|
155
|
-
}
|
|
156
|
-
return url;
|
|
157
|
-
}
|
|
158
|
-
exports.buildUrl = buildUrl;
|
|
159
|
-
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
var src = createCommonjsModule(function (module, exports) {
|
|
163
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
164
|
-
if (k2 === undefined) k2 = k;
|
|
165
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
166
|
-
}) : (function(o, m, k, k2) {
|
|
167
|
-
if (k2 === undefined) k2 = k;
|
|
168
|
-
o[k2] = m[k];
|
|
169
|
-
}));
|
|
170
|
-
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
171
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
172
|
-
};
|
|
173
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
174
|
-
__exportStar(initialize_1, exports);
|
|
175
|
-
__exportStar(_interface, exports);
|
|
176
|
-
__exportStar(request, exports);
|
|
177
|
-
__exportStar(url, exports);
|
|
178
|
-
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
var internal_common = createCommonjsModule(function (module, exports) {
|
|
182
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
183
|
-
if (k2 === undefined) k2 = k;
|
|
184
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
185
|
-
}) : (function(o, m, k, k2) {
|
|
186
|
-
if (k2 === undefined) k2 = k;
|
|
187
|
-
o[k2] = m[k];
|
|
188
|
-
}));
|
|
189
|
-
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
190
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
191
|
-
};
|
|
192
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
193
|
-
__exportStar(src, exports);
|
|
194
|
-
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
/*! *****************************************************************************
|
|
198
|
-
Copyright (c) Microsoft Corporation.
|
|
199
|
-
|
|
200
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
201
|
-
purpose with or without fee is hereby granted.
|
|
202
|
-
|
|
203
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
204
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
205
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
206
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
207
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
208
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
209
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
210
|
-
***************************************************************************** */
|
|
211
|
-
/* global Reflect, Promise */
|
|
212
|
-
|
|
213
|
-
var extendStatics = function(d, b) {
|
|
214
|
-
extendStatics = Object.setPrototypeOf ||
|
|
215
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
216
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
217
|
-
return extendStatics(d, b);
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
function __extends(d, b) {
|
|
221
|
-
extendStatics(d, b);
|
|
222
|
-
function __() { this.constructor = d; }
|
|
223
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/** PURE_IMPORTS_START PURE_IMPORTS_END */
|
|
227
|
-
function isFunction(x) {
|
|
228
|
-
return typeof x === 'function';
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/** PURE_IMPORTS_START PURE_IMPORTS_END */
|
|
232
|
-
var _enable_super_gross_mode_that_will_cause_bad_things = false;
|
|
233
|
-
var config = {
|
|
234
|
-
Promise: undefined,
|
|
235
|
-
set useDeprecatedSynchronousErrorHandling(value) {
|
|
236
|
-
if (value) {
|
|
237
|
-
var error = /*@__PURE__*/ new Error();
|
|
238
|
-
/*@__PURE__*/ console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
|
|
239
|
-
}
|
|
240
|
-
_enable_super_gross_mode_that_will_cause_bad_things = value;
|
|
241
|
-
},
|
|
242
|
-
get useDeprecatedSynchronousErrorHandling() {
|
|
243
|
-
return _enable_super_gross_mode_that_will_cause_bad_things;
|
|
244
|
-
},
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
/** PURE_IMPORTS_START PURE_IMPORTS_END */
|
|
248
|
-
function hostReportError(err) {
|
|
249
|
-
setTimeout(function () { throw err; }, 0);
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/** PURE_IMPORTS_START _config,_util_hostReportError PURE_IMPORTS_END */
|
|
253
|
-
var empty = {
|
|
254
|
-
closed: true,
|
|
255
|
-
next: function (value) { },
|
|
256
|
-
error: function (err) {
|
|
257
|
-
if (config.useDeprecatedSynchronousErrorHandling) {
|
|
258
|
-
throw err;
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
hostReportError(err);
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
complete: function () { }
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
/** PURE_IMPORTS_START PURE_IMPORTS_END */
|
|
268
|
-
var isArray = /*@__PURE__*/ (function () { return Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); })();
|
|
269
|
-
|
|
270
|
-
/** PURE_IMPORTS_START PURE_IMPORTS_END */
|
|
271
|
-
function isObject(x) {
|
|
272
|
-
return x !== null && typeof x === 'object';
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/** PURE_IMPORTS_START PURE_IMPORTS_END */
|
|
276
|
-
var UnsubscriptionErrorImpl = /*@__PURE__*/ (function () {
|
|
277
|
-
function UnsubscriptionErrorImpl(errors) {
|
|
278
|
-
Error.call(this);
|
|
279
|
-
this.message = errors ?
|
|
280
|
-
errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ') : '';
|
|
281
|
-
this.name = 'UnsubscriptionError';
|
|
282
|
-
this.errors = errors;
|
|
283
|
-
return this;
|
|
284
|
-
}
|
|
285
|
-
UnsubscriptionErrorImpl.prototype = /*@__PURE__*/ Object.create(Error.prototype);
|
|
286
|
-
return UnsubscriptionErrorImpl;
|
|
287
|
-
})();
|
|
288
|
-
var UnsubscriptionError = UnsubscriptionErrorImpl;
|
|
289
|
-
|
|
290
|
-
/** PURE_IMPORTS_START _util_isArray,_util_isObject,_util_isFunction,_util_UnsubscriptionError PURE_IMPORTS_END */
|
|
291
|
-
var Subscription = /*@__PURE__*/ (function () {
|
|
292
|
-
function Subscription(unsubscribe) {
|
|
293
|
-
this.closed = false;
|
|
294
|
-
this._parentOrParents = null;
|
|
295
|
-
this._subscriptions = null;
|
|
296
|
-
if (unsubscribe) {
|
|
297
|
-
this._ctorUnsubscribe = true;
|
|
298
|
-
this._unsubscribe = unsubscribe;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
Subscription.prototype.unsubscribe = function () {
|
|
302
|
-
var errors;
|
|
303
|
-
if (this.closed) {
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
var _a = this, _parentOrParents = _a._parentOrParents, _ctorUnsubscribe = _a._ctorUnsubscribe, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
|
|
307
|
-
this.closed = true;
|
|
308
|
-
this._parentOrParents = null;
|
|
309
|
-
this._subscriptions = null;
|
|
310
|
-
if (_parentOrParents instanceof Subscription) {
|
|
311
|
-
_parentOrParents.remove(this);
|
|
312
|
-
}
|
|
313
|
-
else if (_parentOrParents !== null) {
|
|
314
|
-
for (var index = 0; index < _parentOrParents.length; ++index) {
|
|
315
|
-
var parent_1 = _parentOrParents[index];
|
|
316
|
-
parent_1.remove(this);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
if (isFunction(_unsubscribe)) {
|
|
320
|
-
if (_ctorUnsubscribe) {
|
|
321
|
-
this._unsubscribe = undefined;
|
|
322
|
-
}
|
|
323
|
-
try {
|
|
324
|
-
_unsubscribe.call(this);
|
|
325
|
-
}
|
|
326
|
-
catch (e) {
|
|
327
|
-
errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
if (isArray(_subscriptions)) {
|
|
331
|
-
var index = -1;
|
|
332
|
-
var len = _subscriptions.length;
|
|
333
|
-
while (++index < len) {
|
|
334
|
-
var sub = _subscriptions[index];
|
|
335
|
-
if (isObject(sub)) {
|
|
336
|
-
try {
|
|
337
|
-
sub.unsubscribe();
|
|
338
|
-
}
|
|
339
|
-
catch (e) {
|
|
340
|
-
errors = errors || [];
|
|
341
|
-
if (e instanceof UnsubscriptionError) {
|
|
342
|
-
errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
|
|
343
|
-
}
|
|
344
|
-
else {
|
|
345
|
-
errors.push(e);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
if (errors) {
|
|
352
|
-
throw new UnsubscriptionError(errors);
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
Subscription.prototype.add = function (teardown) {
|
|
356
|
-
var subscription = teardown;
|
|
357
|
-
if (!teardown) {
|
|
358
|
-
return Subscription.EMPTY;
|
|
359
|
-
}
|
|
360
|
-
switch (typeof teardown) {
|
|
361
|
-
case 'function':
|
|
362
|
-
subscription = new Subscription(teardown);
|
|
363
|
-
case 'object':
|
|
364
|
-
if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
|
|
365
|
-
return subscription;
|
|
366
|
-
}
|
|
367
|
-
else if (this.closed) {
|
|
368
|
-
subscription.unsubscribe();
|
|
369
|
-
return subscription;
|
|
370
|
-
}
|
|
371
|
-
else if (!(subscription instanceof Subscription)) {
|
|
372
|
-
var tmp = subscription;
|
|
373
|
-
subscription = new Subscription();
|
|
374
|
-
subscription._subscriptions = [tmp];
|
|
375
|
-
}
|
|
376
|
-
break;
|
|
377
|
-
default: {
|
|
378
|
-
throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
var _parentOrParents = subscription._parentOrParents;
|
|
382
|
-
if (_parentOrParents === null) {
|
|
383
|
-
subscription._parentOrParents = this;
|
|
384
|
-
}
|
|
385
|
-
else if (_parentOrParents instanceof Subscription) {
|
|
386
|
-
if (_parentOrParents === this) {
|
|
387
|
-
return subscription;
|
|
388
|
-
}
|
|
389
|
-
subscription._parentOrParents = [_parentOrParents, this];
|
|
390
|
-
}
|
|
391
|
-
else if (_parentOrParents.indexOf(this) === -1) {
|
|
392
|
-
_parentOrParents.push(this);
|
|
393
|
-
}
|
|
394
|
-
else {
|
|
395
|
-
return subscription;
|
|
396
|
-
}
|
|
397
|
-
var subscriptions = this._subscriptions;
|
|
398
|
-
if (subscriptions === null) {
|
|
399
|
-
this._subscriptions = [subscription];
|
|
400
|
-
}
|
|
401
|
-
else {
|
|
402
|
-
subscriptions.push(subscription);
|
|
403
|
-
}
|
|
404
|
-
return subscription;
|
|
405
|
-
};
|
|
406
|
-
Subscription.prototype.remove = function (subscription) {
|
|
407
|
-
var subscriptions = this._subscriptions;
|
|
408
|
-
if (subscriptions) {
|
|
409
|
-
var subscriptionIndex = subscriptions.indexOf(subscription);
|
|
410
|
-
if (subscriptionIndex !== -1) {
|
|
411
|
-
subscriptions.splice(subscriptionIndex, 1);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
};
|
|
415
|
-
Subscription.EMPTY = (function (empty) {
|
|
416
|
-
empty.closed = true;
|
|
417
|
-
return empty;
|
|
418
|
-
}(new Subscription()));
|
|
419
|
-
return Subscription;
|
|
420
|
-
}());
|
|
421
|
-
function flattenUnsubscriptionErrors(errors) {
|
|
422
|
-
return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError) ? err.errors : err); }, []);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
/** PURE_IMPORTS_START PURE_IMPORTS_END */
|
|
426
|
-
var rxSubscriber = /*@__PURE__*/ (function () {
|
|
427
|
-
return typeof Symbol === 'function'
|
|
428
|
-
? /*@__PURE__*/ Symbol('rxSubscriber')
|
|
429
|
-
: '@@rxSubscriber_' + /*@__PURE__*/ Math.random();
|
|
430
|
-
})();
|
|
431
|
-
|
|
432
|
-
/** PURE_IMPORTS_START tslib,_util_isFunction,_Observer,_Subscription,_internal_symbol_rxSubscriber,_config,_util_hostReportError PURE_IMPORTS_END */
|
|
433
|
-
var Subscriber = /*@__PURE__*/ (function (_super) {
|
|
434
|
-
__extends(Subscriber, _super);
|
|
435
|
-
function Subscriber(destinationOrNext, error, complete) {
|
|
436
|
-
var _this = _super.call(this) || this;
|
|
437
|
-
_this.syncErrorValue = null;
|
|
438
|
-
_this.syncErrorThrown = false;
|
|
439
|
-
_this.syncErrorThrowable = false;
|
|
440
|
-
_this.isStopped = false;
|
|
441
|
-
switch (arguments.length) {
|
|
442
|
-
case 0:
|
|
443
|
-
_this.destination = empty;
|
|
444
|
-
break;
|
|
445
|
-
case 1:
|
|
446
|
-
if (!destinationOrNext) {
|
|
447
|
-
_this.destination = empty;
|
|
448
|
-
break;
|
|
449
|
-
}
|
|
450
|
-
if (typeof destinationOrNext === 'object') {
|
|
451
|
-
if (destinationOrNext instanceof Subscriber) {
|
|
452
|
-
_this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
|
|
453
|
-
_this.destination = destinationOrNext;
|
|
454
|
-
destinationOrNext.add(_this);
|
|
455
|
-
}
|
|
456
|
-
else {
|
|
457
|
-
_this.syncErrorThrowable = true;
|
|
458
|
-
_this.destination = new SafeSubscriber(_this, destinationOrNext);
|
|
459
|
-
}
|
|
460
|
-
break;
|
|
461
|
-
}
|
|
462
|
-
default:
|
|
463
|
-
_this.syncErrorThrowable = true;
|
|
464
|
-
_this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
|
|
465
|
-
break;
|
|
466
|
-
}
|
|
467
|
-
return _this;
|
|
468
|
-
}
|
|
469
|
-
Subscriber.prototype[rxSubscriber] = function () { return this; };
|
|
470
|
-
Subscriber.create = function (next, error, complete) {
|
|
471
|
-
var subscriber = new Subscriber(next, error, complete);
|
|
472
|
-
subscriber.syncErrorThrowable = false;
|
|
473
|
-
return subscriber;
|
|
474
|
-
};
|
|
475
|
-
Subscriber.prototype.next = function (value) {
|
|
476
|
-
if (!this.isStopped) {
|
|
477
|
-
this._next(value);
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
Subscriber.prototype.error = function (err) {
|
|
481
|
-
if (!this.isStopped) {
|
|
482
|
-
this.isStopped = true;
|
|
483
|
-
this._error(err);
|
|
484
|
-
}
|
|
485
|
-
};
|
|
486
|
-
Subscriber.prototype.complete = function () {
|
|
487
|
-
if (!this.isStopped) {
|
|
488
|
-
this.isStopped = true;
|
|
489
|
-
this._complete();
|
|
490
|
-
}
|
|
491
|
-
};
|
|
492
|
-
Subscriber.prototype.unsubscribe = function () {
|
|
493
|
-
if (this.closed) {
|
|
494
|
-
return;
|
|
495
|
-
}
|
|
496
|
-
this.isStopped = true;
|
|
497
|
-
_super.prototype.unsubscribe.call(this);
|
|
498
|
-
};
|
|
499
|
-
Subscriber.prototype._next = function (value) {
|
|
500
|
-
this.destination.next(value);
|
|
501
|
-
};
|
|
502
|
-
Subscriber.prototype._error = function (err) {
|
|
503
|
-
this.destination.error(err);
|
|
504
|
-
this.unsubscribe();
|
|
505
|
-
};
|
|
506
|
-
Subscriber.prototype._complete = function () {
|
|
507
|
-
this.destination.complete();
|
|
508
|
-
this.unsubscribe();
|
|
509
|
-
};
|
|
510
|
-
Subscriber.prototype._unsubscribeAndRecycle = function () {
|
|
511
|
-
var _parentOrParents = this._parentOrParents;
|
|
512
|
-
this._parentOrParents = null;
|
|
513
|
-
this.unsubscribe();
|
|
514
|
-
this.closed = false;
|
|
515
|
-
this.isStopped = false;
|
|
516
|
-
this._parentOrParents = _parentOrParents;
|
|
517
|
-
return this;
|
|
518
|
-
};
|
|
519
|
-
return Subscriber;
|
|
520
|
-
}(Subscription));
|
|
521
|
-
var SafeSubscriber = /*@__PURE__*/ (function (_super) {
|
|
522
|
-
__extends(SafeSubscriber, _super);
|
|
523
|
-
function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
|
|
524
|
-
var _this = _super.call(this) || this;
|
|
525
|
-
_this._parentSubscriber = _parentSubscriber;
|
|
526
|
-
var next;
|
|
527
|
-
var context = _this;
|
|
528
|
-
if (isFunction(observerOrNext)) {
|
|
529
|
-
next = observerOrNext;
|
|
530
|
-
}
|
|
531
|
-
else if (observerOrNext) {
|
|
532
|
-
next = observerOrNext.next;
|
|
533
|
-
error = observerOrNext.error;
|
|
534
|
-
complete = observerOrNext.complete;
|
|
535
|
-
if (observerOrNext !== empty) {
|
|
536
|
-
context = Object.create(observerOrNext);
|
|
537
|
-
if (isFunction(context.unsubscribe)) {
|
|
538
|
-
_this.add(context.unsubscribe.bind(context));
|
|
539
|
-
}
|
|
540
|
-
context.unsubscribe = _this.unsubscribe.bind(_this);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
_this._context = context;
|
|
544
|
-
_this._next = next;
|
|
545
|
-
_this._error = error;
|
|
546
|
-
_this._complete = complete;
|
|
547
|
-
return _this;
|
|
548
|
-
}
|
|
549
|
-
SafeSubscriber.prototype.next = function (value) {
|
|
550
|
-
if (!this.isStopped && this._next) {
|
|
551
|
-
var _parentSubscriber = this._parentSubscriber;
|
|
552
|
-
if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
|
|
553
|
-
this.__tryOrUnsub(this._next, value);
|
|
554
|
-
}
|
|
555
|
-
else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
|
|
556
|
-
this.unsubscribe();
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
};
|
|
560
|
-
SafeSubscriber.prototype.error = function (err) {
|
|
561
|
-
if (!this.isStopped) {
|
|
562
|
-
var _parentSubscriber = this._parentSubscriber;
|
|
563
|
-
var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
|
|
564
|
-
if (this._error) {
|
|
565
|
-
if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
|
|
566
|
-
this.__tryOrUnsub(this._error, err);
|
|
567
|
-
this.unsubscribe();
|
|
568
|
-
}
|
|
569
|
-
else {
|
|
570
|
-
this.__tryOrSetError(_parentSubscriber, this._error, err);
|
|
571
|
-
this.unsubscribe();
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
else if (!_parentSubscriber.syncErrorThrowable) {
|
|
575
|
-
this.unsubscribe();
|
|
576
|
-
if (useDeprecatedSynchronousErrorHandling) {
|
|
577
|
-
throw err;
|
|
578
|
-
}
|
|
579
|
-
hostReportError(err);
|
|
580
|
-
}
|
|
581
|
-
else {
|
|
582
|
-
if (useDeprecatedSynchronousErrorHandling) {
|
|
583
|
-
_parentSubscriber.syncErrorValue = err;
|
|
584
|
-
_parentSubscriber.syncErrorThrown = true;
|
|
585
|
-
}
|
|
586
|
-
else {
|
|
587
|
-
hostReportError(err);
|
|
588
|
-
}
|
|
589
|
-
this.unsubscribe();
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
};
|
|
593
|
-
SafeSubscriber.prototype.complete = function () {
|
|
594
|
-
var _this = this;
|
|
595
|
-
if (!this.isStopped) {
|
|
596
|
-
var _parentSubscriber = this._parentSubscriber;
|
|
597
|
-
if (this._complete) {
|
|
598
|
-
var wrappedComplete = function () { return _this._complete.call(_this._context); };
|
|
599
|
-
if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
|
|
600
|
-
this.__tryOrUnsub(wrappedComplete);
|
|
601
|
-
this.unsubscribe();
|
|
602
|
-
}
|
|
603
|
-
else {
|
|
604
|
-
this.__tryOrSetError(_parentSubscriber, wrappedComplete);
|
|
605
|
-
this.unsubscribe();
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
else {
|
|
609
|
-
this.unsubscribe();
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
};
|
|
613
|
-
SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
|
|
614
|
-
try {
|
|
615
|
-
fn.call(this._context, value);
|
|
616
|
-
}
|
|
617
|
-
catch (err) {
|
|
618
|
-
this.unsubscribe();
|
|
619
|
-
if (config.useDeprecatedSynchronousErrorHandling) {
|
|
620
|
-
throw err;
|
|
621
|
-
}
|
|
622
|
-
else {
|
|
623
|
-
hostReportError(err);
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
};
|
|
627
|
-
SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
|
|
628
|
-
if (!config.useDeprecatedSynchronousErrorHandling) {
|
|
629
|
-
throw new Error('bad call');
|
|
630
|
-
}
|
|
631
|
-
try {
|
|
632
|
-
fn.call(this._context, value);
|
|
633
|
-
}
|
|
634
|
-
catch (err) {
|
|
635
|
-
if (config.useDeprecatedSynchronousErrorHandling) {
|
|
636
|
-
parent.syncErrorValue = err;
|
|
637
|
-
parent.syncErrorThrown = true;
|
|
638
|
-
return true;
|
|
639
|
-
}
|
|
640
|
-
else {
|
|
641
|
-
hostReportError(err);
|
|
642
|
-
return true;
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
return false;
|
|
646
|
-
};
|
|
647
|
-
SafeSubscriber.prototype._unsubscribe = function () {
|
|
648
|
-
var _parentSubscriber = this._parentSubscriber;
|
|
649
|
-
this._context = null;
|
|
650
|
-
this._parentSubscriber = null;
|
|
651
|
-
_parentSubscriber.unsubscribe();
|
|
652
|
-
};
|
|
653
|
-
return SafeSubscriber;
|
|
654
|
-
}(Subscriber));
|
|
655
|
-
|
|
656
|
-
/** PURE_IMPORTS_START _Subscriber PURE_IMPORTS_END */
|
|
657
|
-
function canReportError(observer) {
|
|
658
|
-
while (observer) {
|
|
659
|
-
var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
|
|
660
|
-
if (closed_1 || isStopped) {
|
|
661
|
-
return false;
|
|
662
|
-
}
|
|
663
|
-
else if (destination && destination instanceof Subscriber) {
|
|
664
|
-
observer = destination;
|
|
665
|
-
}
|
|
666
|
-
else {
|
|
667
|
-
observer = null;
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
return true;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
/** PURE_IMPORTS_START _Subscriber,_symbol_rxSubscriber,_Observer PURE_IMPORTS_END */
|
|
674
|
-
function toSubscriber(nextOrObserver, error, complete) {
|
|
675
|
-
if (nextOrObserver) {
|
|
676
|
-
if (nextOrObserver instanceof Subscriber) {
|
|
677
|
-
return nextOrObserver;
|
|
678
|
-
}
|
|
679
|
-
if (nextOrObserver[rxSubscriber]) {
|
|
680
|
-
return nextOrObserver[rxSubscriber]();
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
if (!nextOrObserver && !error && !complete) {
|
|
684
|
-
return new Subscriber(empty);
|
|
685
|
-
}
|
|
686
|
-
return new Subscriber(nextOrObserver, error, complete);
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
/** PURE_IMPORTS_START PURE_IMPORTS_END */
|
|
690
|
-
var observable = /*@__PURE__*/ (function () { return typeof Symbol === 'function' && Symbol.observable || '@@observable'; })();
|
|
691
|
-
|
|
692
|
-
/** PURE_IMPORTS_START PURE_IMPORTS_END */
|
|
693
|
-
function identity(x) {
|
|
694
|
-
return x;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
/** PURE_IMPORTS_START _identity PURE_IMPORTS_END */
|
|
698
|
-
function pipeFromArray(fns) {
|
|
699
|
-
if (fns.length === 0) {
|
|
700
|
-
return identity;
|
|
701
|
-
}
|
|
702
|
-
if (fns.length === 1) {
|
|
703
|
-
return fns[0];
|
|
704
|
-
}
|
|
705
|
-
return function piped(input) {
|
|
706
|
-
return fns.reduce(function (prev, fn) { return fn(prev); }, input);
|
|
707
|
-
};
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
/** PURE_IMPORTS_START _util_canReportError,_util_toSubscriber,_symbol_observable,_util_pipe,_config PURE_IMPORTS_END */
|
|
711
|
-
var Observable = /*@__PURE__*/ (function () {
|
|
712
|
-
function Observable(subscribe) {
|
|
713
|
-
this._isScalar = false;
|
|
714
|
-
if (subscribe) {
|
|
715
|
-
this._subscribe = subscribe;
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
Observable.prototype.lift = function (operator) {
|
|
719
|
-
var observable = new Observable();
|
|
720
|
-
observable.source = this;
|
|
721
|
-
observable.operator = operator;
|
|
722
|
-
return observable;
|
|
723
|
-
};
|
|
724
|
-
Observable.prototype.subscribe = function (observerOrNext, error, complete) {
|
|
725
|
-
var operator = this.operator;
|
|
726
|
-
var sink = toSubscriber(observerOrNext, error, complete);
|
|
727
|
-
if (operator) {
|
|
728
|
-
sink.add(operator.call(sink, this.source));
|
|
729
|
-
}
|
|
730
|
-
else {
|
|
731
|
-
sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
|
|
732
|
-
this._subscribe(sink) :
|
|
733
|
-
this._trySubscribe(sink));
|
|
734
|
-
}
|
|
735
|
-
if (config.useDeprecatedSynchronousErrorHandling) {
|
|
736
|
-
if (sink.syncErrorThrowable) {
|
|
737
|
-
sink.syncErrorThrowable = false;
|
|
738
|
-
if (sink.syncErrorThrown) {
|
|
739
|
-
throw sink.syncErrorValue;
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
return sink;
|
|
744
|
-
};
|
|
745
|
-
Observable.prototype._trySubscribe = function (sink) {
|
|
746
|
-
try {
|
|
747
|
-
return this._subscribe(sink);
|
|
748
|
-
}
|
|
749
|
-
catch (err) {
|
|
750
|
-
if (config.useDeprecatedSynchronousErrorHandling) {
|
|
751
|
-
sink.syncErrorThrown = true;
|
|
752
|
-
sink.syncErrorValue = err;
|
|
753
|
-
}
|
|
754
|
-
if (canReportError(sink)) {
|
|
755
|
-
sink.error(err);
|
|
756
|
-
}
|
|
757
|
-
else {
|
|
758
|
-
console.warn(err);
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
};
|
|
762
|
-
Observable.prototype.forEach = function (next, promiseCtor) {
|
|
763
|
-
var _this = this;
|
|
764
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
765
|
-
return new promiseCtor(function (resolve, reject) {
|
|
766
|
-
var subscription;
|
|
767
|
-
subscription = _this.subscribe(function (value) {
|
|
768
|
-
try {
|
|
769
|
-
next(value);
|
|
770
|
-
}
|
|
771
|
-
catch (err) {
|
|
772
|
-
reject(err);
|
|
773
|
-
if (subscription) {
|
|
774
|
-
subscription.unsubscribe();
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
}, reject, resolve);
|
|
778
|
-
});
|
|
779
|
-
};
|
|
780
|
-
Observable.prototype._subscribe = function (subscriber) {
|
|
781
|
-
var source = this.source;
|
|
782
|
-
return source && source.subscribe(subscriber);
|
|
783
|
-
};
|
|
784
|
-
Observable.prototype[observable] = function () {
|
|
785
|
-
return this;
|
|
786
|
-
};
|
|
787
|
-
Observable.prototype.pipe = function () {
|
|
788
|
-
var operations = [];
|
|
789
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
790
|
-
operations[_i] = arguments[_i];
|
|
791
|
-
}
|
|
792
|
-
if (operations.length === 0) {
|
|
793
|
-
return this;
|
|
794
|
-
}
|
|
795
|
-
return pipeFromArray(operations)(this);
|
|
796
|
-
};
|
|
797
|
-
Observable.prototype.toPromise = function (promiseCtor) {
|
|
798
|
-
var _this = this;
|
|
799
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
800
|
-
return new promiseCtor(function (resolve, reject) {
|
|
801
|
-
var value;
|
|
802
|
-
_this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
|
|
803
|
-
});
|
|
804
|
-
};
|
|
805
|
-
Observable.create = function (subscribe) {
|
|
806
|
-
return new Observable(subscribe);
|
|
807
|
-
};
|
|
808
|
-
return Observable;
|
|
809
|
-
}());
|
|
810
|
-
function getPromiseCtor(promiseCtor) {
|
|
811
|
-
if (!promiseCtor) {
|
|
812
|
-
promiseCtor = Promise;
|
|
813
|
-
}
|
|
814
|
-
if (!promiseCtor) {
|
|
815
|
-
throw new Error('no Promise impl found');
|
|
816
|
-
}
|
|
817
|
-
return promiseCtor;
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
var copy = createCommonjsModule(function (module, exports) {
|
|
821
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
822
|
-
exports.deepCopyJSON = void 0;
|
|
823
|
-
function deepCopyJSON(param) {
|
|
824
|
-
return JSON.parse(JSON.stringify(param));
|
|
825
|
-
}
|
|
826
|
-
exports.deepCopyJSON = deepCopyJSON;
|
|
827
|
-
|
|
828
|
-
});
|
|
829
|
-
|
|
830
|
-
var copy$1 = createCommonjsModule(function (module, exports) {
|
|
831
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
832
|
-
if (k2 === undefined) k2 = k;
|
|
833
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
834
|
-
}) : (function(o, m, k, k2) {
|
|
835
|
-
if (k2 === undefined) k2 = k;
|
|
836
|
-
o[k2] = m[k];
|
|
837
|
-
}));
|
|
838
|
-
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
839
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
840
|
-
};
|
|
841
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
842
|
-
__exportStar(copy, exports);
|
|
843
|
-
|
|
844
|
-
});
|
|
845
|
-
|
|
846
|
-
let authorization;
|
|
847
|
-
let service;
|
|
848
|
-
const identitySegment = "passport/identity";
|
|
849
|
-
class _Challenge {
|
|
850
|
-
constructor(res, answerResponseMapper = r => r) {
|
|
851
|
-
this.res = res;
|
|
852
|
-
this.answerResponseMapper = answerResponseMapper;
|
|
853
|
-
}
|
|
854
|
-
show() {
|
|
855
|
-
return this.res.challenge;
|
|
856
|
-
}
|
|
857
|
-
answer(answer) {
|
|
858
|
-
return service.post(this.res.answerUrl, { answer }).then(r => this.answerResponseMapper(r));
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
function initialize(options) {
|
|
862
|
-
const { authorization: _authorization, service: _service } = internal_common.initialize(options);
|
|
863
|
-
authorization = _authorization;
|
|
864
|
-
service = _service;
|
|
865
|
-
service.setWriteDefaults({
|
|
866
|
-
headers: {
|
|
867
|
-
"Content-Type": "application/json"
|
|
868
|
-
}
|
|
869
|
-
});
|
|
870
|
-
}
|
|
871
|
-
function verifyToken(token, baseUrl) {
|
|
872
|
-
const _baseUrl = baseUrl ? baseUrl : service ? service.baseUrl : undefined;
|
|
873
|
-
if (!_baseUrl) {
|
|
874
|
-
throw new Error("You should pass the base url of the server or call the initialize method.");
|
|
875
|
-
}
|
|
876
|
-
const req = new internal_common.Axios({ baseURL: _baseUrl });
|
|
877
|
-
return req.get(`${identitySegment}/verify`, { headers: { Authorization: token } });
|
|
878
|
-
}
|
|
879
|
-
async function login(identifier, password, tokenLifeSpan) {
|
|
880
|
-
internal_common.checkInitialized(authorization);
|
|
881
|
-
return service
|
|
882
|
-
.post("/passport/identify", {
|
|
883
|
-
identifier,
|
|
884
|
-
password,
|
|
885
|
-
expires: tokenLifeSpan
|
|
886
|
-
})
|
|
887
|
-
.then(r => {
|
|
888
|
-
if (isTokenScheme(r)) {
|
|
889
|
-
return r.token;
|
|
890
|
-
}
|
|
891
|
-
const challenge = new _Challenge(r, r => r.token);
|
|
892
|
-
return challenge;
|
|
893
|
-
});
|
|
894
|
-
}
|
|
895
|
-
// we don't want to export this function because it's for internal usages
|
|
896
|
-
function isTokenScheme(response) {
|
|
897
|
-
return typeof response.token == "string";
|
|
898
|
-
}
|
|
899
|
-
function isChallenge(tokenOrChallenge) {
|
|
900
|
-
return typeof tokenOrChallenge.show == "function" && typeof tokenOrChallenge.answer == "function";
|
|
901
|
-
}
|
|
902
|
-
async function loginWithStrategy(id) {
|
|
903
|
-
internal_common.checkInitialized(authorization);
|
|
904
|
-
const { url, state } = await service.get(`/passport/strategy/${id}/url`);
|
|
905
|
-
const token = new Observable(observer => {
|
|
906
|
-
service
|
|
907
|
-
.post("/passport/identify", {
|
|
908
|
-
state
|
|
909
|
-
})
|
|
910
|
-
.then(r => {
|
|
911
|
-
if (isTokenScheme(r)) {
|
|
912
|
-
observer.next(r.token);
|
|
913
|
-
}
|
|
914
|
-
else {
|
|
915
|
-
const challenge = new _Challenge(r, r => r.token);
|
|
916
|
-
observer.next(challenge);
|
|
917
|
-
}
|
|
918
|
-
observer.complete();
|
|
919
|
-
})
|
|
920
|
-
.catch(e => observer.error(e));
|
|
921
|
-
});
|
|
922
|
-
return {
|
|
923
|
-
url,
|
|
924
|
-
token
|
|
925
|
-
};
|
|
926
|
-
}
|
|
927
|
-
var authfactor;
|
|
928
|
-
(function (authfactor) {
|
|
929
|
-
function list() {
|
|
930
|
-
return service.get("passport/identity/factors");
|
|
931
|
-
}
|
|
932
|
-
authfactor.list = list;
|
|
933
|
-
async function register(identityId, factor) {
|
|
934
|
-
const response = await service.post(`passport/identity/${identityId}/start-factor-verification`, factor);
|
|
935
|
-
const challenge = new _Challenge(response, response => response.message);
|
|
936
|
-
return challenge;
|
|
937
|
-
}
|
|
938
|
-
authfactor.register = register;
|
|
939
|
-
function unregister(identityId) {
|
|
940
|
-
return service.delete(`passport/identity/${identityId}/factors`);
|
|
941
|
-
}
|
|
942
|
-
authfactor.unregister = unregister;
|
|
943
|
-
})(authfactor || (authfactor = {}));
|
|
944
|
-
function getStrategies() {
|
|
945
|
-
return service.get("/passport/strategies");
|
|
946
|
-
}
|
|
947
|
-
function get(id) {
|
|
948
|
-
internal_common.checkInitialized(authorization);
|
|
949
|
-
return service.get(`${identitySegment}/${id}`);
|
|
950
|
-
}
|
|
951
|
-
function getAll(queryParams = {}) {
|
|
952
|
-
internal_common.checkInitialized(authorization);
|
|
953
|
-
return service.get(identitySegment, {
|
|
954
|
-
params: queryParams
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
|
-
async function insert(identity) {
|
|
958
|
-
internal_common.checkInitialized(authorization);
|
|
959
|
-
identity = copy$1.deepCopyJSON(identity);
|
|
960
|
-
const desiredPolicies = identity.policies;
|
|
961
|
-
delete identity.policies;
|
|
962
|
-
const insertedIdentity = await service.post(identitySegment, identity);
|
|
963
|
-
return policy.attach(insertedIdentity._id, desiredPolicies).then(policies => {
|
|
964
|
-
insertedIdentity.policies = policies;
|
|
965
|
-
return insertedIdentity;
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
|
-
async function update(id, identity) {
|
|
969
|
-
internal_common.checkInitialized(authorization);
|
|
970
|
-
const existingIdentity = await service.get(`${identitySegment}/${id}`);
|
|
971
|
-
await policy.detach(id, existingIdentity.policies || []);
|
|
972
|
-
identity = copy$1.deepCopyJSON(identity);
|
|
973
|
-
const desiredPolicies = identity.policies;
|
|
974
|
-
delete identity.policies;
|
|
975
|
-
const updatedIdentity = await service.put(`${identitySegment}/${id}`, identity);
|
|
976
|
-
return policy.attach(id, desiredPolicies || []).then(policies => {
|
|
977
|
-
updatedIdentity.policies = policies;
|
|
978
|
-
return updatedIdentity;
|
|
979
|
-
});
|
|
980
|
-
}
|
|
981
|
-
function remove(id) {
|
|
982
|
-
internal_common.checkInitialized(authorization);
|
|
983
|
-
return service.delete(`${identitySegment}/${id}`);
|
|
984
|
-
}
|
|
985
|
-
// policy attach detach
|
|
986
|
-
var policy;
|
|
987
|
-
(function (policy) {
|
|
988
|
-
function attach(identityId, policyIds = []) {
|
|
989
|
-
internal_common.checkInitialized(authorization);
|
|
990
|
-
const promises = [];
|
|
991
|
-
const attachedPolicies = new Set();
|
|
992
|
-
for (const policyId of policyIds) {
|
|
993
|
-
const promise = service
|
|
994
|
-
.put(`${identitySegment}/${identityId}/policy/${policyId}`, {})
|
|
995
|
-
.then(() => attachedPolicies.add(policyId))
|
|
996
|
-
.catch(e => {
|
|
997
|
-
console.error(`Failed to attach policy with id ${policyId}: `, e);
|
|
998
|
-
return e;
|
|
999
|
-
});
|
|
1000
|
-
promises.push(promise);
|
|
1001
|
-
}
|
|
1002
|
-
return Promise.all(promises).then(() => Array.from(attachedPolicies));
|
|
1003
|
-
}
|
|
1004
|
-
policy.attach = attach;
|
|
1005
|
-
function detach(identityId, policyIds = []) {
|
|
1006
|
-
internal_common.checkInitialized(authorization);
|
|
1007
|
-
const promises = [];
|
|
1008
|
-
const detachedPolicies = new Set();
|
|
1009
|
-
for (const policyId of policyIds) {
|
|
1010
|
-
const promise = service
|
|
1011
|
-
.delete(`${identitySegment}/${identityId}/policy/${policyId}`)
|
|
1012
|
-
.then(() => detachedPolicies.add(policyId))
|
|
1013
|
-
.catch(e => {
|
|
1014
|
-
console.error(`Failed to detach policy with id ${policyId}: `, e);
|
|
1015
|
-
return e;
|
|
1016
|
-
});
|
|
1017
|
-
promises.push(promise);
|
|
1018
|
-
}
|
|
1019
|
-
return Promise.all(promises).then(() => Array.from(detachedPolicies));
|
|
1020
|
-
}
|
|
1021
|
-
policy.detach = detach;
|
|
1022
|
-
})(policy || (policy = {}));
|
|
1023
|
-
|
|
1024
|
-
export { authfactor, get, getAll, getStrategies, initialize, insert, isChallenge, login, loginWithStrategy, policy, remove, update, verifyToken };
|
|
1025
|
-
//# sourceMappingURL=index.mjs.map
|