@spica-devkit/identity 0.18.10 → 0.18.11-pre1
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 +123 -1
- package/dist/index.js +2 -543
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -542
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/src/identity.d.ts +0 -38
- package/dist/src/index.d.ts +0 -2
- package/dist/src/interface.d.ts +0 -52
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,123 @@
|
|
|
1
|
-
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
|
|
3
|
+
interface SuccessResponse<P, R = P> {
|
|
4
|
+
request: P;
|
|
5
|
+
response: R;
|
|
6
|
+
}
|
|
7
|
+
interface FailureResponse<P> {
|
|
8
|
+
request: P;
|
|
9
|
+
response: {
|
|
10
|
+
message: string;
|
|
11
|
+
error: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
interface ManyResponse<P, R> {
|
|
15
|
+
successes: SuccessResponse<P, R>[];
|
|
16
|
+
failures: FailureResponse<P>[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface Identity {
|
|
20
|
+
_id: string;
|
|
21
|
+
identifier: string;
|
|
22
|
+
password: string;
|
|
23
|
+
policies: string[];
|
|
24
|
+
attributes?: object;
|
|
25
|
+
lastLogin?: Date;
|
|
26
|
+
failedAttempts?: Date[];
|
|
27
|
+
}
|
|
28
|
+
type IdentityUpdate = Partial<Identity>;
|
|
29
|
+
type IdentityCreate = Omit<Identity, "_id">;
|
|
30
|
+
type IdentityGet = Omit<Identity, "password">;
|
|
31
|
+
interface Strategy {
|
|
32
|
+
_id: string;
|
|
33
|
+
type: string;
|
|
34
|
+
name: string;
|
|
35
|
+
title: string;
|
|
36
|
+
}
|
|
37
|
+
interface Challenge {
|
|
38
|
+
show(): string;
|
|
39
|
+
answer(answer: string): Promise<string>;
|
|
40
|
+
}
|
|
41
|
+
type TokenScheme = {
|
|
42
|
+
token: string;
|
|
43
|
+
};
|
|
44
|
+
type ChallengeRes = {
|
|
45
|
+
challenge: string;
|
|
46
|
+
answerUrl: string;
|
|
47
|
+
};
|
|
48
|
+
interface LoginWithStrategyResponse {
|
|
49
|
+
url: string;
|
|
50
|
+
token: Observable<string | Challenge>;
|
|
51
|
+
}
|
|
52
|
+
interface FactorSchema {
|
|
53
|
+
type: string;
|
|
54
|
+
title: string;
|
|
55
|
+
description: string;
|
|
56
|
+
config: {
|
|
57
|
+
[key: string]: {
|
|
58
|
+
type: string;
|
|
59
|
+
enum?: any[];
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
interface FactorMeta {
|
|
64
|
+
type: string;
|
|
65
|
+
config: {
|
|
66
|
+
[key: string]: any;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface PublicInitialization {
|
|
71
|
+
publicUrl?: string;
|
|
72
|
+
}
|
|
73
|
+
interface ApikeyInitialization extends PublicInitialization {
|
|
74
|
+
apikey: string;
|
|
75
|
+
}
|
|
76
|
+
interface IdentityInitialization extends PublicInitialization {
|
|
77
|
+
identity: string;
|
|
78
|
+
}
|
|
79
|
+
interface IndexResult<T> {
|
|
80
|
+
meta: {
|
|
81
|
+
total: number;
|
|
82
|
+
};
|
|
83
|
+
data: T[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
declare function initialize(options: ApikeyInitialization | IdentityInitialization): void;
|
|
87
|
+
declare function verifyToken(token: string, baseUrl?: string, headers?: object): Promise<unknown>;
|
|
88
|
+
declare function login<TFA extends false>(identifier: string, password: string, tokenLifeSpan?: number, headers?: object): Promise<string>;
|
|
89
|
+
declare function login<TFA extends true>(identifier: string, password: string, tokenLifeSpan?: number, headers?: object): Promise<Challenge>;
|
|
90
|
+
declare function isChallenge(tokenOrChallenge: any): tokenOrChallenge is Challenge;
|
|
91
|
+
declare function loginWithStrategy(id: string): Promise<LoginWithStrategyResponse>;
|
|
92
|
+
declare namespace authfactor {
|
|
93
|
+
function list(headers?: object): Promise<FactorSchema[]>;
|
|
94
|
+
function register(identityId: string, factor: FactorMeta, headers?: object): Promise<Challenge>;
|
|
95
|
+
function unregister(identityId: string, headers?: object): any;
|
|
96
|
+
}
|
|
97
|
+
declare function getStrategies(headers?: object): Promise<Strategy[]>;
|
|
98
|
+
declare function get(id: string, headers?: object): Promise<IdentityGet>;
|
|
99
|
+
declare function getAll(queryParams?: {
|
|
100
|
+
paginate?: false;
|
|
101
|
+
limit?: number;
|
|
102
|
+
skip?: number;
|
|
103
|
+
filter?: object;
|
|
104
|
+
sort?: object;
|
|
105
|
+
}, headers?: object): Promise<IdentityGet[]>;
|
|
106
|
+
declare function getAll(queryParams?: {
|
|
107
|
+
paginate?: true;
|
|
108
|
+
limit?: number;
|
|
109
|
+
skip?: number;
|
|
110
|
+
filter?: object;
|
|
111
|
+
sort?: object;
|
|
112
|
+
}, headers?: object): Promise<IndexResult<IdentityGet>>;
|
|
113
|
+
declare function insert(identity: IdentityCreate, headers?: object): Promise<IdentityGet>;
|
|
114
|
+
declare function update(id: string, identity: IdentityUpdate, headers?: object): Promise<IdentityGet>;
|
|
115
|
+
declare function remove(id: string, headers?: object): Promise<any>;
|
|
116
|
+
declare function removeMany(ids: string[], headers?: object): Promise<ManyResponse<string, string>>;
|
|
117
|
+
declare namespace policy {
|
|
118
|
+
function attach(identityId: string, policyIds?: string[], headers?: object): Promise<string[]>;
|
|
119
|
+
function detach(identityId: string, policyIds?: string[], headers?: object): Promise<string[]>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export { authfactor, get, getAll, getStrategies, initialize, insert, isChallenge, login, loginWithStrategy, policy, remove, removeMany, update, verifyToken };
|
|
123
|
+
export type { Challenge, ChallengeRes, FactorMeta, FactorSchema, IdentityCreate, IdentityGet, IdentityUpdate, LoginWithStrategyResponse, Strategy, TokenScheme };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var axios = require('axios');
|
|
4
|
+
var rxjs = require('rxjs');
|
|
4
5
|
|
|
5
6
|
function logWarning(response) {
|
|
6
7
|
const warning = response.headers["warning"];
|
|
@@ -254,548 +255,6 @@ function addAuthHeader(headers, auth) {
|
|
|
254
255
|
return headers;
|
|
255
256
|
}
|
|
256
257
|
|
|
257
|
-
/******************************************************************************
|
|
258
|
-
Copyright (c) Microsoft Corporation.
|
|
259
|
-
|
|
260
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
261
|
-
purpose with or without fee is hereby granted.
|
|
262
|
-
|
|
263
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
264
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
265
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
266
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
267
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
268
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
269
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
270
|
-
***************************************************************************** */
|
|
271
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
272
|
-
|
|
273
|
-
var extendStatics = function(d, b) {
|
|
274
|
-
extendStatics = Object.setPrototypeOf ||
|
|
275
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
276
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
277
|
-
return extendStatics(d, b);
|
|
278
|
-
};
|
|
279
|
-
|
|
280
|
-
function __extends(d, b) {
|
|
281
|
-
if (typeof b !== "function" && b !== null)
|
|
282
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
283
|
-
extendStatics(d, b);
|
|
284
|
-
function __() { this.constructor = d; }
|
|
285
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
function __values(o) {
|
|
289
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
290
|
-
if (m) return m.call(o);
|
|
291
|
-
if (o && typeof o.length === "number") return {
|
|
292
|
-
next: function () {
|
|
293
|
-
if (o && i >= o.length) o = undefined;
|
|
294
|
-
return { value: o && o[i++], done: !o };
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
function __read(o, n) {
|
|
301
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
302
|
-
if (!m) return o;
|
|
303
|
-
var i = m.call(o), r, ar = [], e;
|
|
304
|
-
try {
|
|
305
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
306
|
-
}
|
|
307
|
-
catch (error) { e = { error: error }; }
|
|
308
|
-
finally {
|
|
309
|
-
try {
|
|
310
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
311
|
-
}
|
|
312
|
-
finally { if (e) throw e.error; }
|
|
313
|
-
}
|
|
314
|
-
return ar;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
function __spreadArray(to, from, pack) {
|
|
318
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
319
|
-
if (ar || !(i in from)) {
|
|
320
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
321
|
-
ar[i] = from[i];
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
328
|
-
var e = new Error(message);
|
|
329
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
function isFunction(value) {
|
|
333
|
-
return typeof value === 'function';
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
function createErrorClass(createImpl) {
|
|
337
|
-
var _super = function (instance) {
|
|
338
|
-
Error.call(instance);
|
|
339
|
-
instance.stack = new Error().stack;
|
|
340
|
-
};
|
|
341
|
-
var ctorFunc = createImpl(_super);
|
|
342
|
-
ctorFunc.prototype = Object.create(Error.prototype);
|
|
343
|
-
ctorFunc.prototype.constructor = ctorFunc;
|
|
344
|
-
return ctorFunc;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
var UnsubscriptionError = createErrorClass(function (_super) {
|
|
348
|
-
return function UnsubscriptionErrorImpl(errors) {
|
|
349
|
-
_super(this);
|
|
350
|
-
this.message = errors
|
|
351
|
-
? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ')
|
|
352
|
-
: '';
|
|
353
|
-
this.name = 'UnsubscriptionError';
|
|
354
|
-
this.errors = errors;
|
|
355
|
-
};
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
function arrRemove(arr, item) {
|
|
359
|
-
if (arr) {
|
|
360
|
-
var index = arr.indexOf(item);
|
|
361
|
-
0 <= index && arr.splice(index, 1);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
var Subscription = (function () {
|
|
366
|
-
function Subscription(initialTeardown) {
|
|
367
|
-
this.initialTeardown = initialTeardown;
|
|
368
|
-
this.closed = false;
|
|
369
|
-
this._parentage = null;
|
|
370
|
-
this._finalizers = null;
|
|
371
|
-
}
|
|
372
|
-
Subscription.prototype.unsubscribe = function () {
|
|
373
|
-
var e_1, _a, e_2, _b;
|
|
374
|
-
var errors;
|
|
375
|
-
if (!this.closed) {
|
|
376
|
-
this.closed = true;
|
|
377
|
-
var _parentage = this._parentage;
|
|
378
|
-
if (_parentage) {
|
|
379
|
-
this._parentage = null;
|
|
380
|
-
if (Array.isArray(_parentage)) {
|
|
381
|
-
try {
|
|
382
|
-
for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
|
|
383
|
-
var parent_1 = _parentage_1_1.value;
|
|
384
|
-
parent_1.remove(this);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
388
|
-
finally {
|
|
389
|
-
try {
|
|
390
|
-
if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
|
|
391
|
-
}
|
|
392
|
-
finally { if (e_1) throw e_1.error; }
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
else {
|
|
396
|
-
_parentage.remove(this);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
var initialFinalizer = this.initialTeardown;
|
|
400
|
-
if (isFunction(initialFinalizer)) {
|
|
401
|
-
try {
|
|
402
|
-
initialFinalizer();
|
|
403
|
-
}
|
|
404
|
-
catch (e) {
|
|
405
|
-
errors = e instanceof UnsubscriptionError ? e.errors : [e];
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
var _finalizers = this._finalizers;
|
|
409
|
-
if (_finalizers) {
|
|
410
|
-
this._finalizers = null;
|
|
411
|
-
try {
|
|
412
|
-
for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
|
|
413
|
-
var finalizer = _finalizers_1_1.value;
|
|
414
|
-
try {
|
|
415
|
-
execFinalizer(finalizer);
|
|
416
|
-
}
|
|
417
|
-
catch (err) {
|
|
418
|
-
errors = errors !== null && errors !== void 0 ? errors : [];
|
|
419
|
-
if (err instanceof UnsubscriptionError) {
|
|
420
|
-
errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
|
|
421
|
-
}
|
|
422
|
-
else {
|
|
423
|
-
errors.push(err);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
429
|
-
finally {
|
|
430
|
-
try {
|
|
431
|
-
if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
|
|
432
|
-
}
|
|
433
|
-
finally { if (e_2) throw e_2.error; }
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
if (errors) {
|
|
437
|
-
throw new UnsubscriptionError(errors);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
Subscription.prototype.add = function (teardown) {
|
|
442
|
-
var _a;
|
|
443
|
-
if (teardown && teardown !== this) {
|
|
444
|
-
if (this.closed) {
|
|
445
|
-
execFinalizer(teardown);
|
|
446
|
-
}
|
|
447
|
-
else {
|
|
448
|
-
if (teardown instanceof Subscription) {
|
|
449
|
-
if (teardown.closed || teardown._hasParent(this)) {
|
|
450
|
-
return;
|
|
451
|
-
}
|
|
452
|
-
teardown._addParent(this);
|
|
453
|
-
}
|
|
454
|
-
(this._finalizers = (_a = this._finalizers) !== null && _a !== undefined ? _a : []).push(teardown);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
|
-
Subscription.prototype._hasParent = function (parent) {
|
|
459
|
-
var _parentage = this._parentage;
|
|
460
|
-
return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
|
|
461
|
-
};
|
|
462
|
-
Subscription.prototype._addParent = function (parent) {
|
|
463
|
-
var _parentage = this._parentage;
|
|
464
|
-
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
|
|
465
|
-
};
|
|
466
|
-
Subscription.prototype._removeParent = function (parent) {
|
|
467
|
-
var _parentage = this._parentage;
|
|
468
|
-
if (_parentage === parent) {
|
|
469
|
-
this._parentage = null;
|
|
470
|
-
}
|
|
471
|
-
else if (Array.isArray(_parentage)) {
|
|
472
|
-
arrRemove(_parentage, parent);
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
Subscription.prototype.remove = function (teardown) {
|
|
476
|
-
var _finalizers = this._finalizers;
|
|
477
|
-
_finalizers && arrRemove(_finalizers, teardown);
|
|
478
|
-
if (teardown instanceof Subscription) {
|
|
479
|
-
teardown._removeParent(this);
|
|
480
|
-
}
|
|
481
|
-
};
|
|
482
|
-
Subscription.EMPTY = (function () {
|
|
483
|
-
var empty = new Subscription();
|
|
484
|
-
empty.closed = true;
|
|
485
|
-
return empty;
|
|
486
|
-
})();
|
|
487
|
-
return Subscription;
|
|
488
|
-
}());
|
|
489
|
-
Subscription.EMPTY;
|
|
490
|
-
function isSubscription(value) {
|
|
491
|
-
return (value instanceof Subscription ||
|
|
492
|
-
(value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
|
|
493
|
-
}
|
|
494
|
-
function execFinalizer(finalizer) {
|
|
495
|
-
if (isFunction(finalizer)) {
|
|
496
|
-
finalizer();
|
|
497
|
-
}
|
|
498
|
-
else {
|
|
499
|
-
finalizer.unsubscribe();
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
var config = {
|
|
504
|
-
onUnhandledError: null,
|
|
505
|
-
onStoppedNotification: null,
|
|
506
|
-
Promise: undefined,
|
|
507
|
-
useDeprecatedSynchronousErrorHandling: false,
|
|
508
|
-
useDeprecatedNextContext: false,
|
|
509
|
-
};
|
|
510
|
-
|
|
511
|
-
var timeoutProvider = {
|
|
512
|
-
setTimeout: function (handler, timeout) {
|
|
513
|
-
var args = [];
|
|
514
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
515
|
-
args[_i - 2] = arguments[_i];
|
|
516
|
-
}
|
|
517
|
-
return setTimeout.apply(undefined, __spreadArray([handler, timeout], __read(args)));
|
|
518
|
-
},
|
|
519
|
-
clearTimeout: function (handle) {
|
|
520
|
-
return (clearTimeout)(handle);
|
|
521
|
-
},
|
|
522
|
-
delegate: undefined,
|
|
523
|
-
};
|
|
524
|
-
|
|
525
|
-
function reportUnhandledError(err) {
|
|
526
|
-
timeoutProvider.setTimeout(function () {
|
|
527
|
-
{
|
|
528
|
-
throw err;
|
|
529
|
-
}
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
function noop() { }
|
|
534
|
-
|
|
535
|
-
function errorContext(cb) {
|
|
536
|
-
{
|
|
537
|
-
cb();
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
var Subscriber = (function (_super) {
|
|
542
|
-
__extends(Subscriber, _super);
|
|
543
|
-
function Subscriber(destination) {
|
|
544
|
-
var _this = _super.call(this) || this;
|
|
545
|
-
_this.isStopped = false;
|
|
546
|
-
if (destination) {
|
|
547
|
-
_this.destination = destination;
|
|
548
|
-
if (isSubscription(destination)) {
|
|
549
|
-
destination.add(_this);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
else {
|
|
553
|
-
_this.destination = EMPTY_OBSERVER;
|
|
554
|
-
}
|
|
555
|
-
return _this;
|
|
556
|
-
}
|
|
557
|
-
Subscriber.create = function (next, error, complete) {
|
|
558
|
-
return new SafeSubscriber(next, error, complete);
|
|
559
|
-
};
|
|
560
|
-
Subscriber.prototype.next = function (value) {
|
|
561
|
-
if (this.isStopped) ;
|
|
562
|
-
else {
|
|
563
|
-
this._next(value);
|
|
564
|
-
}
|
|
565
|
-
};
|
|
566
|
-
Subscriber.prototype.error = function (err) {
|
|
567
|
-
if (this.isStopped) ;
|
|
568
|
-
else {
|
|
569
|
-
this.isStopped = true;
|
|
570
|
-
this._error(err);
|
|
571
|
-
}
|
|
572
|
-
};
|
|
573
|
-
Subscriber.prototype.complete = function () {
|
|
574
|
-
if (this.isStopped) ;
|
|
575
|
-
else {
|
|
576
|
-
this.isStopped = true;
|
|
577
|
-
this._complete();
|
|
578
|
-
}
|
|
579
|
-
};
|
|
580
|
-
Subscriber.prototype.unsubscribe = function () {
|
|
581
|
-
if (!this.closed) {
|
|
582
|
-
this.isStopped = true;
|
|
583
|
-
_super.prototype.unsubscribe.call(this);
|
|
584
|
-
this.destination = null;
|
|
585
|
-
}
|
|
586
|
-
};
|
|
587
|
-
Subscriber.prototype._next = function (value) {
|
|
588
|
-
this.destination.next(value);
|
|
589
|
-
};
|
|
590
|
-
Subscriber.prototype._error = function (err) {
|
|
591
|
-
try {
|
|
592
|
-
this.destination.error(err);
|
|
593
|
-
}
|
|
594
|
-
finally {
|
|
595
|
-
this.unsubscribe();
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
Subscriber.prototype._complete = function () {
|
|
599
|
-
try {
|
|
600
|
-
this.destination.complete();
|
|
601
|
-
}
|
|
602
|
-
finally {
|
|
603
|
-
this.unsubscribe();
|
|
604
|
-
}
|
|
605
|
-
};
|
|
606
|
-
return Subscriber;
|
|
607
|
-
}(Subscription));
|
|
608
|
-
var ConsumerObserver = (function () {
|
|
609
|
-
function ConsumerObserver(partialObserver) {
|
|
610
|
-
this.partialObserver = partialObserver;
|
|
611
|
-
}
|
|
612
|
-
ConsumerObserver.prototype.next = function (value) {
|
|
613
|
-
var partialObserver = this.partialObserver;
|
|
614
|
-
if (partialObserver.next) {
|
|
615
|
-
try {
|
|
616
|
-
partialObserver.next(value);
|
|
617
|
-
}
|
|
618
|
-
catch (error) {
|
|
619
|
-
handleUnhandledError(error);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
};
|
|
623
|
-
ConsumerObserver.prototype.error = function (err) {
|
|
624
|
-
var partialObserver = this.partialObserver;
|
|
625
|
-
if (partialObserver.error) {
|
|
626
|
-
try {
|
|
627
|
-
partialObserver.error(err);
|
|
628
|
-
}
|
|
629
|
-
catch (error) {
|
|
630
|
-
handleUnhandledError(error);
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
else {
|
|
634
|
-
handleUnhandledError(err);
|
|
635
|
-
}
|
|
636
|
-
};
|
|
637
|
-
ConsumerObserver.prototype.complete = function () {
|
|
638
|
-
var partialObserver = this.partialObserver;
|
|
639
|
-
if (partialObserver.complete) {
|
|
640
|
-
try {
|
|
641
|
-
partialObserver.complete();
|
|
642
|
-
}
|
|
643
|
-
catch (error) {
|
|
644
|
-
handleUnhandledError(error);
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
};
|
|
648
|
-
return ConsumerObserver;
|
|
649
|
-
}());
|
|
650
|
-
var SafeSubscriber = (function (_super) {
|
|
651
|
-
__extends(SafeSubscriber, _super);
|
|
652
|
-
function SafeSubscriber(observerOrNext, error, complete) {
|
|
653
|
-
var _this = _super.call(this) || this;
|
|
654
|
-
var partialObserver;
|
|
655
|
-
if (isFunction(observerOrNext) || !observerOrNext) {
|
|
656
|
-
partialObserver = {
|
|
657
|
-
next: (observerOrNext !== null && observerOrNext !== undefined ? observerOrNext : undefined),
|
|
658
|
-
error: error !== null && error !== undefined ? error : undefined,
|
|
659
|
-
complete: complete !== null && complete !== undefined ? complete : undefined,
|
|
660
|
-
};
|
|
661
|
-
}
|
|
662
|
-
else {
|
|
663
|
-
{
|
|
664
|
-
partialObserver = observerOrNext;
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
_this.destination = new ConsumerObserver(partialObserver);
|
|
668
|
-
return _this;
|
|
669
|
-
}
|
|
670
|
-
return SafeSubscriber;
|
|
671
|
-
}(Subscriber));
|
|
672
|
-
function handleUnhandledError(error) {
|
|
673
|
-
{
|
|
674
|
-
reportUnhandledError(error);
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
function defaultErrorHandler(err) {
|
|
678
|
-
throw err;
|
|
679
|
-
}
|
|
680
|
-
var EMPTY_OBSERVER = {
|
|
681
|
-
closed: true,
|
|
682
|
-
next: noop,
|
|
683
|
-
error: defaultErrorHandler,
|
|
684
|
-
complete: noop,
|
|
685
|
-
};
|
|
686
|
-
|
|
687
|
-
var observable = (function () { return (typeof Symbol === 'function' && Symbol.observable) || '@@observable'; })();
|
|
688
|
-
|
|
689
|
-
function identity(x) {
|
|
690
|
-
return x;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
function pipeFromArray(fns) {
|
|
694
|
-
if (fns.length === 0) {
|
|
695
|
-
return identity;
|
|
696
|
-
}
|
|
697
|
-
if (fns.length === 1) {
|
|
698
|
-
return fns[0];
|
|
699
|
-
}
|
|
700
|
-
return function piped(input) {
|
|
701
|
-
return fns.reduce(function (prev, fn) { return fn(prev); }, input);
|
|
702
|
-
};
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
var Observable = (function () {
|
|
706
|
-
function Observable(subscribe) {
|
|
707
|
-
if (subscribe) {
|
|
708
|
-
this._subscribe = subscribe;
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
Observable.prototype.lift = function (operator) {
|
|
712
|
-
var observable = new Observable();
|
|
713
|
-
observable.source = this;
|
|
714
|
-
observable.operator = operator;
|
|
715
|
-
return observable;
|
|
716
|
-
};
|
|
717
|
-
Observable.prototype.subscribe = function (observerOrNext, error, complete) {
|
|
718
|
-
var _this = this;
|
|
719
|
-
var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
|
|
720
|
-
errorContext(function () {
|
|
721
|
-
var _a = _this, operator = _a.operator, source = _a.source;
|
|
722
|
-
subscriber.add(operator
|
|
723
|
-
?
|
|
724
|
-
operator.call(subscriber, source)
|
|
725
|
-
: source
|
|
726
|
-
?
|
|
727
|
-
_this._subscribe(subscriber)
|
|
728
|
-
:
|
|
729
|
-
_this._trySubscribe(subscriber));
|
|
730
|
-
});
|
|
731
|
-
return subscriber;
|
|
732
|
-
};
|
|
733
|
-
Observable.prototype._trySubscribe = function (sink) {
|
|
734
|
-
try {
|
|
735
|
-
return this._subscribe(sink);
|
|
736
|
-
}
|
|
737
|
-
catch (err) {
|
|
738
|
-
sink.error(err);
|
|
739
|
-
}
|
|
740
|
-
};
|
|
741
|
-
Observable.prototype.forEach = function (next, promiseCtor) {
|
|
742
|
-
var _this = this;
|
|
743
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
744
|
-
return new promiseCtor(function (resolve, reject) {
|
|
745
|
-
var subscriber = new SafeSubscriber({
|
|
746
|
-
next: function (value) {
|
|
747
|
-
try {
|
|
748
|
-
next(value);
|
|
749
|
-
}
|
|
750
|
-
catch (err) {
|
|
751
|
-
reject(err);
|
|
752
|
-
subscriber.unsubscribe();
|
|
753
|
-
}
|
|
754
|
-
},
|
|
755
|
-
error: reject,
|
|
756
|
-
complete: resolve,
|
|
757
|
-
});
|
|
758
|
-
_this.subscribe(subscriber);
|
|
759
|
-
});
|
|
760
|
-
};
|
|
761
|
-
Observable.prototype._subscribe = function (subscriber) {
|
|
762
|
-
var _a;
|
|
763
|
-
return (_a = this.source) === null || _a === undefined ? undefined : _a.subscribe(subscriber);
|
|
764
|
-
};
|
|
765
|
-
Observable.prototype[observable] = function () {
|
|
766
|
-
return this;
|
|
767
|
-
};
|
|
768
|
-
Observable.prototype.pipe = function () {
|
|
769
|
-
var operations = [];
|
|
770
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
771
|
-
operations[_i] = arguments[_i];
|
|
772
|
-
}
|
|
773
|
-
return pipeFromArray(operations)(this);
|
|
774
|
-
};
|
|
775
|
-
Observable.prototype.toPromise = function (promiseCtor) {
|
|
776
|
-
var _this = this;
|
|
777
|
-
promiseCtor = getPromiseCtor(promiseCtor);
|
|
778
|
-
return new promiseCtor(function (resolve, reject) {
|
|
779
|
-
var value;
|
|
780
|
-
_this.subscribe(function (x) { return (value = x); }, function (err) { return reject(err); }, function () { return resolve(value); });
|
|
781
|
-
});
|
|
782
|
-
};
|
|
783
|
-
Observable.create = function (subscribe) {
|
|
784
|
-
return new Observable(subscribe);
|
|
785
|
-
};
|
|
786
|
-
return Observable;
|
|
787
|
-
}());
|
|
788
|
-
function getPromiseCtor(promiseCtor) {
|
|
789
|
-
var _a;
|
|
790
|
-
return (_a = promiseCtor !== null && promiseCtor !== undefined ? promiseCtor : config.Promise) !== null && _a !== undefined ? _a : Promise;
|
|
791
|
-
}
|
|
792
|
-
function isObserver(value) {
|
|
793
|
-
return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
|
|
794
|
-
}
|
|
795
|
-
function isSubscriber(value) {
|
|
796
|
-
return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
|
|
797
|
-
}
|
|
798
|
-
|
|
799
258
|
function deepCopyJSON(param) {
|
|
800
259
|
return JSON.parse(JSON.stringify(param));
|
|
801
260
|
}
|
|
@@ -858,7 +317,7 @@ function isChallenge(tokenOrChallenge) {
|
|
|
858
317
|
async function loginWithStrategy(id) {
|
|
859
318
|
checkInitialized(authorization, service);
|
|
860
319
|
const { url, state } = await service.get(`/passport/strategy/${id}/url`);
|
|
861
|
-
const token = new Observable(observer => {
|
|
320
|
+
const token = new rxjs.Observable(observer => {
|
|
862
321
|
service
|
|
863
322
|
.post("/passport/identify", {
|
|
864
323
|
state
|