@niledatabase/server 3.0.0-alpha.28 → 3.0.0-alpha.29
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/Api.d.ts +2 -0
- package/dist/api/utils/auth.d.ts +8 -0
- package/dist/auth/index.d.ts +10 -1
- package/dist/server.cjs.development.js +230 -174
- package/dist/server.cjs.development.js.map +1 -1
- package/dist/server.cjs.production.min.js +1 -1
- package/dist/server.cjs.production.min.js.map +1 -1
- package/dist/server.esm.js +230 -174
- package/dist/server.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/Api.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Routes } from './api/types';
|
|
2
|
+
import Auth from './auth';
|
|
2
3
|
import Tenants from './tenants';
|
|
3
4
|
import Users from './users';
|
|
4
5
|
import { Config } from './utils/Config';
|
|
5
6
|
export declare class Api {
|
|
6
7
|
config: Config;
|
|
7
8
|
users: Users;
|
|
9
|
+
auth: Auth;
|
|
8
10
|
tenants: Tenants;
|
|
9
11
|
routes: Routes;
|
|
10
12
|
handlers: {
|
package/dist/api/utils/auth.d.ts
CHANGED
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { ActiveSession, JWT } from '../api/utils/auth';
|
|
1
2
|
import { Config } from '../utils/Config';
|
|
3
|
+
import { NileRequest } from '../utils/Requester';
|
|
2
4
|
/**
|
|
3
5
|
* a helper function to log in server side.
|
|
4
6
|
*/
|
|
5
|
-
export
|
|
7
|
+
export declare function serverLogin(config: Config, handlers: {
|
|
6
8
|
GET: (req: Request) => Promise<void | Response>;
|
|
7
9
|
POST: (req: Request) => Promise<void | Response>;
|
|
8
10
|
DELETE: (req: Request) => Promise<void | Response>;
|
|
@@ -11,3 +13,10 @@ export default function serverAuth(config: Config, handlers: {
|
|
|
11
13
|
email: string;
|
|
12
14
|
password: string;
|
|
13
15
|
}) => Promise<Headers>;
|
|
16
|
+
export default class Auth extends Config {
|
|
17
|
+
headers?: Headers;
|
|
18
|
+
constructor(config: Config, headers?: Headers);
|
|
19
|
+
handleHeaders(init?: RequestInit): RequestInit | undefined;
|
|
20
|
+
get sessionUrl(): string;
|
|
21
|
+
session: (req: NileRequest<void> | Headers, init?: RequestInit) => Promise<Response | JWT | ActiveSession>;
|
|
22
|
+
}
|
|
@@ -3307,179 +3307,6 @@ var appRoutes = function appRoutes(prefix) {
|
|
|
3307
3307
|
};
|
|
3308
3308
|
};
|
|
3309
3309
|
|
|
3310
|
-
// url host does not matter, we only match on the 1st leg by path
|
|
3311
|
-
var ORIGIN = 'https://us-west-2.api.dev.thenile.dev';
|
|
3312
|
-
/**
|
|
3313
|
-
* a helper function to log in server side.
|
|
3314
|
-
*/
|
|
3315
|
-
function serverAuth(config, handlers) {
|
|
3316
|
-
var _Logger = Logger(config, '[server side login]'),
|
|
3317
|
-
info = _Logger.info,
|
|
3318
|
-
error = _Logger.error,
|
|
3319
|
-
debug = _Logger.debug;
|
|
3320
|
-
var routes = appRoutes(config.routePrefix);
|
|
3321
|
-
return /*#__PURE__*/function () {
|
|
3322
|
-
var _login = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
3323
|
-
var _providers, _exec;
|
|
3324
|
-
var email, password, sessionUrl, baseHeaders, sessionReq, sessionRes, providers, csrf, csrfReq, csrfRes, csrfToken, _yield$csrfRes$json, json, _ref2, credentials, csrfCookie, signInUrl, body, postReq, loginRes, authCookie, _ref3, token, headers;
|
|
3325
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3326
|
-
while (1) switch (_context.prev = _context.next) {
|
|
3327
|
-
case 0:
|
|
3328
|
-
email = _ref.email, password = _ref.password;
|
|
3329
|
-
if (!(!email || !password)) {
|
|
3330
|
-
_context.next = 3;
|
|
3331
|
-
break;
|
|
3332
|
-
}
|
|
3333
|
-
throw new Error('Server side login requires a user email and password.');
|
|
3334
|
-
case 3:
|
|
3335
|
-
sessionUrl = new URL("" + ORIGIN + routes.PROVIDERS);
|
|
3336
|
-
baseHeaders = {
|
|
3337
|
-
host: sessionUrl.host,
|
|
3338
|
-
'niledb-origin': ORIGIN
|
|
3339
|
-
};
|
|
3340
|
-
info("Obtaining providers for " + email);
|
|
3341
|
-
sessionReq = new Request(sessionUrl, _extends({
|
|
3342
|
-
method: 'GET'
|
|
3343
|
-
}, baseHeaders));
|
|
3344
|
-
_context.next = 9;
|
|
3345
|
-
return handlers.POST(sessionReq);
|
|
3346
|
-
case 9:
|
|
3347
|
-
sessionRes = _context.sent;
|
|
3348
|
-
if (!((sessionRes == null ? void 0 : sessionRes.status) === 404)) {
|
|
3349
|
-
_context.next = 12;
|
|
3350
|
-
break;
|
|
3351
|
-
}
|
|
3352
|
-
throw new Error('Unable to login, cannot find region api.');
|
|
3353
|
-
case 12:
|
|
3354
|
-
_context.prev = 12;
|
|
3355
|
-
_context.next = 15;
|
|
3356
|
-
return sessionRes == null ? void 0 : sessionRes.json();
|
|
3357
|
-
case 15:
|
|
3358
|
-
providers = _context.sent;
|
|
3359
|
-
_context.next = 22;
|
|
3360
|
-
break;
|
|
3361
|
-
case 18:
|
|
3362
|
-
_context.prev = 18;
|
|
3363
|
-
_context.t0 = _context["catch"](12);
|
|
3364
|
-
info(sessionUrl, {
|
|
3365
|
-
sessionRes: sessionRes
|
|
3366
|
-
});
|
|
3367
|
-
error(_context.t0);
|
|
3368
|
-
case 22:
|
|
3369
|
-
info('Obtaining csrf');
|
|
3370
|
-
csrf = new URL("" + ORIGIN + routes.CSRF);
|
|
3371
|
-
csrfReq = new Request(csrf, {
|
|
3372
|
-
method: 'GET',
|
|
3373
|
-
headers: new Headers(_extends({}, baseHeaders))
|
|
3374
|
-
});
|
|
3375
|
-
_context.next = 27;
|
|
3376
|
-
return handlers.POST(csrfReq);
|
|
3377
|
-
case 27:
|
|
3378
|
-
csrfRes = _context.sent;
|
|
3379
|
-
_context.prev = 28;
|
|
3380
|
-
_context.next = 31;
|
|
3381
|
-
return csrfRes == null ? void 0 : csrfRes.json();
|
|
3382
|
-
case 31:
|
|
3383
|
-
_context.t1 = _yield$csrfRes$json = _context.sent;
|
|
3384
|
-
if (!(_context.t1 != null)) {
|
|
3385
|
-
_context.next = 36;
|
|
3386
|
-
break;
|
|
3387
|
-
}
|
|
3388
|
-
_context.t2 = _yield$csrfRes$json;
|
|
3389
|
-
_context.next = 37;
|
|
3390
|
-
break;
|
|
3391
|
-
case 36:
|
|
3392
|
-
_context.t2 = {};
|
|
3393
|
-
case 37:
|
|
3394
|
-
json = _context.t2;
|
|
3395
|
-
csrfToken = json == null ? void 0 : json.csrfToken;
|
|
3396
|
-
_context.next = 45;
|
|
3397
|
-
break;
|
|
3398
|
-
case 41:
|
|
3399
|
-
_context.prev = 41;
|
|
3400
|
-
_context.t3 = _context["catch"](28);
|
|
3401
|
-
info(sessionUrl, {
|
|
3402
|
-
csrfRes: csrfRes
|
|
3403
|
-
});
|
|
3404
|
-
error(_context.t3, {
|
|
3405
|
-
csrfRes: csrfRes
|
|
3406
|
-
});
|
|
3407
|
-
case 45:
|
|
3408
|
-
_ref2 = (_providers = providers) != null ? _providers : {}, credentials = _ref2.credentials;
|
|
3409
|
-
csrfCookie = csrfRes == null ? void 0 : csrfRes.headers.get('set-cookie');
|
|
3410
|
-
if (credentials) {
|
|
3411
|
-
_context.next = 49;
|
|
3412
|
-
break;
|
|
3413
|
-
}
|
|
3414
|
-
throw new Error('Unable to obtain credential provider. Aborting server side login.');
|
|
3415
|
-
case 49:
|
|
3416
|
-
signInUrl = new URL(credentials.callbackUrl);
|
|
3417
|
-
if (csrfCookie) {
|
|
3418
|
-
_context.next = 53;
|
|
3419
|
-
break;
|
|
3420
|
-
}
|
|
3421
|
-
debug('CSRF failed', {
|
|
3422
|
-
headers: csrfRes == null ? void 0 : csrfRes.headers
|
|
3423
|
-
});
|
|
3424
|
-
throw new Error('Unable to authenticate REST, CSRF missing.');
|
|
3425
|
-
case 53:
|
|
3426
|
-
info("Attempting sign in with email " + email + " " + signInUrl.href);
|
|
3427
|
-
body = JSON.stringify({
|
|
3428
|
-
email: email,
|
|
3429
|
-
password: password,
|
|
3430
|
-
csrfToken: csrfToken,
|
|
3431
|
-
callbackUrl: credentials.callbackUrl
|
|
3432
|
-
});
|
|
3433
|
-
postReq = new Request(signInUrl, {
|
|
3434
|
-
method: 'POST',
|
|
3435
|
-
headers: new Headers(_extends({}, baseHeaders, {
|
|
3436
|
-
'content-type': 'application/json',
|
|
3437
|
-
cookie: csrfCookie.split(',').join('; ')
|
|
3438
|
-
})),
|
|
3439
|
-
body: body
|
|
3440
|
-
});
|
|
3441
|
-
_context.next = 58;
|
|
3442
|
-
return handlers.POST(postReq);
|
|
3443
|
-
case 58:
|
|
3444
|
-
loginRes = _context.sent;
|
|
3445
|
-
authCookie = loginRes == null ? void 0 : loginRes.headers.get('set-cookie');
|
|
3446
|
-
if (authCookie) {
|
|
3447
|
-
_context.next = 62;
|
|
3448
|
-
break;
|
|
3449
|
-
}
|
|
3450
|
-
throw new Error('authentication failed');
|
|
3451
|
-
case 62:
|
|
3452
|
-
_ref3 = (_exec = /((__Secure-)?nile\.session-token=.+?);/.exec(authCookie)) != null ? _exec : [], token = _ref3[1];
|
|
3453
|
-
if (token) {
|
|
3454
|
-
_context.next = 66;
|
|
3455
|
-
break;
|
|
3456
|
-
}
|
|
3457
|
-
error('Unable to obtain auth token', {
|
|
3458
|
-
authCookie: authCookie
|
|
3459
|
-
});
|
|
3460
|
-
throw new Error('Server login failed');
|
|
3461
|
-
case 66:
|
|
3462
|
-
info('Server login successful', {
|
|
3463
|
-
authCookie: authCookie,
|
|
3464
|
-
csrfCookie: csrfCookie
|
|
3465
|
-
});
|
|
3466
|
-
headers = new Headers(_extends({}, baseHeaders, {
|
|
3467
|
-
cookie: [token, csrfCookie].join('; ')
|
|
3468
|
-
}));
|
|
3469
|
-
return _context.abrupt("return", headers);
|
|
3470
|
-
case 69:
|
|
3471
|
-
case "end":
|
|
3472
|
-
return _context.stop();
|
|
3473
|
-
}
|
|
3474
|
-
}, _callee, null, [[12, 18], [28, 41]]);
|
|
3475
|
-
}));
|
|
3476
|
-
function login(_x) {
|
|
3477
|
-
return _login.apply(this, arguments);
|
|
3478
|
-
}
|
|
3479
|
-
return login;
|
|
3480
|
-
}();
|
|
3481
|
-
}
|
|
3482
|
-
|
|
3483
3310
|
var Requester = /*#__PURE__*/function (_Config) {
|
|
3484
3311
|
function Requester(config) {
|
|
3485
3312
|
return _Config.call(this, config) || this;
|
|
@@ -3721,6 +3548,233 @@ var Requester = /*#__PURE__*/function (_Config) {
|
|
|
3721
3548
|
return Requester;
|
|
3722
3549
|
}(Config);
|
|
3723
3550
|
|
|
3551
|
+
// url host does not matter, we only match on the 1st leg by path
|
|
3552
|
+
var ORIGIN = 'https://us-west-2.api.dev.thenile.dev';
|
|
3553
|
+
/**
|
|
3554
|
+
* a helper function to log in server side.
|
|
3555
|
+
*/
|
|
3556
|
+
function serverLogin(config, handlers) {
|
|
3557
|
+
var _Logger = Logger(config, '[server side login]'),
|
|
3558
|
+
info = _Logger.info,
|
|
3559
|
+
error = _Logger.error,
|
|
3560
|
+
debug = _Logger.debug;
|
|
3561
|
+
var routes = appRoutes(config.routePrefix);
|
|
3562
|
+
return /*#__PURE__*/function () {
|
|
3563
|
+
var _login = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
3564
|
+
var _providers, _exec;
|
|
3565
|
+
var email, password, sessionUrl, baseHeaders, sessionReq, sessionRes, providers, csrf, csrfReq, csrfRes, csrfToken, _yield$csrfRes$json, json, _ref2, credentials, csrfCookie, signInUrl, body, postReq, loginRes, authCookie, _ref3, token, headers;
|
|
3566
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3567
|
+
while (1) switch (_context.prev = _context.next) {
|
|
3568
|
+
case 0:
|
|
3569
|
+
email = _ref.email, password = _ref.password;
|
|
3570
|
+
if (!(!email || !password)) {
|
|
3571
|
+
_context.next = 3;
|
|
3572
|
+
break;
|
|
3573
|
+
}
|
|
3574
|
+
throw new Error('Server side login requires a user email and password.');
|
|
3575
|
+
case 3:
|
|
3576
|
+
sessionUrl = new URL("" + ORIGIN + routes.PROVIDERS);
|
|
3577
|
+
baseHeaders = {
|
|
3578
|
+
host: sessionUrl.host,
|
|
3579
|
+
'niledb-origin': ORIGIN
|
|
3580
|
+
};
|
|
3581
|
+
info("Obtaining providers for " + email);
|
|
3582
|
+
sessionReq = new Request(sessionUrl, _extends({
|
|
3583
|
+
method: 'GET'
|
|
3584
|
+
}, baseHeaders));
|
|
3585
|
+
_context.next = 9;
|
|
3586
|
+
return handlers.POST(sessionReq);
|
|
3587
|
+
case 9:
|
|
3588
|
+
sessionRes = _context.sent;
|
|
3589
|
+
if (!((sessionRes == null ? void 0 : sessionRes.status) === 404)) {
|
|
3590
|
+
_context.next = 12;
|
|
3591
|
+
break;
|
|
3592
|
+
}
|
|
3593
|
+
throw new Error('Unable to login, cannot find region api.');
|
|
3594
|
+
case 12:
|
|
3595
|
+
_context.prev = 12;
|
|
3596
|
+
_context.next = 15;
|
|
3597
|
+
return sessionRes == null ? void 0 : sessionRes.json();
|
|
3598
|
+
case 15:
|
|
3599
|
+
providers = _context.sent;
|
|
3600
|
+
_context.next = 22;
|
|
3601
|
+
break;
|
|
3602
|
+
case 18:
|
|
3603
|
+
_context.prev = 18;
|
|
3604
|
+
_context.t0 = _context["catch"](12);
|
|
3605
|
+
info(sessionUrl, {
|
|
3606
|
+
sessionRes: sessionRes
|
|
3607
|
+
});
|
|
3608
|
+
error(_context.t0);
|
|
3609
|
+
case 22:
|
|
3610
|
+
info('Obtaining csrf');
|
|
3611
|
+
csrf = new URL("" + ORIGIN + routes.CSRF);
|
|
3612
|
+
csrfReq = new Request(csrf, {
|
|
3613
|
+
method: 'GET',
|
|
3614
|
+
headers: new Headers(_extends({}, baseHeaders))
|
|
3615
|
+
});
|
|
3616
|
+
_context.next = 27;
|
|
3617
|
+
return handlers.POST(csrfReq);
|
|
3618
|
+
case 27:
|
|
3619
|
+
csrfRes = _context.sent;
|
|
3620
|
+
_context.prev = 28;
|
|
3621
|
+
_context.next = 31;
|
|
3622
|
+
return csrfRes == null ? void 0 : csrfRes.json();
|
|
3623
|
+
case 31:
|
|
3624
|
+
_context.t1 = _yield$csrfRes$json = _context.sent;
|
|
3625
|
+
if (!(_context.t1 != null)) {
|
|
3626
|
+
_context.next = 36;
|
|
3627
|
+
break;
|
|
3628
|
+
}
|
|
3629
|
+
_context.t2 = _yield$csrfRes$json;
|
|
3630
|
+
_context.next = 37;
|
|
3631
|
+
break;
|
|
3632
|
+
case 36:
|
|
3633
|
+
_context.t2 = {};
|
|
3634
|
+
case 37:
|
|
3635
|
+
json = _context.t2;
|
|
3636
|
+
csrfToken = json == null ? void 0 : json.csrfToken;
|
|
3637
|
+
_context.next = 45;
|
|
3638
|
+
break;
|
|
3639
|
+
case 41:
|
|
3640
|
+
_context.prev = 41;
|
|
3641
|
+
_context.t3 = _context["catch"](28);
|
|
3642
|
+
info(sessionUrl, {
|
|
3643
|
+
csrfRes: csrfRes
|
|
3644
|
+
});
|
|
3645
|
+
error(_context.t3, {
|
|
3646
|
+
csrfRes: csrfRes
|
|
3647
|
+
});
|
|
3648
|
+
case 45:
|
|
3649
|
+
_ref2 = (_providers = providers) != null ? _providers : {}, credentials = _ref2.credentials;
|
|
3650
|
+
csrfCookie = csrfRes == null ? void 0 : csrfRes.headers.get('set-cookie');
|
|
3651
|
+
if (credentials) {
|
|
3652
|
+
_context.next = 49;
|
|
3653
|
+
break;
|
|
3654
|
+
}
|
|
3655
|
+
throw new Error('Unable to obtain credential provider. Aborting server side login.');
|
|
3656
|
+
case 49:
|
|
3657
|
+
signInUrl = new URL(credentials.callbackUrl);
|
|
3658
|
+
if (csrfCookie) {
|
|
3659
|
+
_context.next = 53;
|
|
3660
|
+
break;
|
|
3661
|
+
}
|
|
3662
|
+
debug('CSRF failed', {
|
|
3663
|
+
headers: csrfRes == null ? void 0 : csrfRes.headers
|
|
3664
|
+
});
|
|
3665
|
+
throw new Error('Unable to authenticate REST, CSRF missing.');
|
|
3666
|
+
case 53:
|
|
3667
|
+
info("Attempting sign in with email " + email + " " + signInUrl.href);
|
|
3668
|
+
body = JSON.stringify({
|
|
3669
|
+
email: email,
|
|
3670
|
+
password: password,
|
|
3671
|
+
csrfToken: csrfToken,
|
|
3672
|
+
callbackUrl: credentials.callbackUrl
|
|
3673
|
+
});
|
|
3674
|
+
postReq = new Request(signInUrl, {
|
|
3675
|
+
method: 'POST',
|
|
3676
|
+
headers: new Headers(_extends({}, baseHeaders, {
|
|
3677
|
+
'content-type': 'application/json',
|
|
3678
|
+
cookie: csrfCookie.split(',').join('; ')
|
|
3679
|
+
})),
|
|
3680
|
+
body: body
|
|
3681
|
+
});
|
|
3682
|
+
_context.next = 58;
|
|
3683
|
+
return handlers.POST(postReq);
|
|
3684
|
+
case 58:
|
|
3685
|
+
loginRes = _context.sent;
|
|
3686
|
+
authCookie = loginRes == null ? void 0 : loginRes.headers.get('set-cookie');
|
|
3687
|
+
if (authCookie) {
|
|
3688
|
+
_context.next = 62;
|
|
3689
|
+
break;
|
|
3690
|
+
}
|
|
3691
|
+
throw new Error('authentication failed');
|
|
3692
|
+
case 62:
|
|
3693
|
+
_ref3 = (_exec = /((__Secure-)?nile\.session-token=.+?);/.exec(authCookie)) != null ? _exec : [], token = _ref3[1];
|
|
3694
|
+
if (token) {
|
|
3695
|
+
_context.next = 66;
|
|
3696
|
+
break;
|
|
3697
|
+
}
|
|
3698
|
+
error('Unable to obtain auth token', {
|
|
3699
|
+
authCookie: authCookie
|
|
3700
|
+
});
|
|
3701
|
+
throw new Error('Server login failed');
|
|
3702
|
+
case 66:
|
|
3703
|
+
info('Server login successful', {
|
|
3704
|
+
authCookie: authCookie,
|
|
3705
|
+
csrfCookie: csrfCookie
|
|
3706
|
+
});
|
|
3707
|
+
headers = new Headers(_extends({}, baseHeaders, {
|
|
3708
|
+
cookie: [token, csrfCookie].join('; ')
|
|
3709
|
+
}));
|
|
3710
|
+
return _context.abrupt("return", headers);
|
|
3711
|
+
case 69:
|
|
3712
|
+
case "end":
|
|
3713
|
+
return _context.stop();
|
|
3714
|
+
}
|
|
3715
|
+
}, _callee, null, [[12, 18], [28, 41]]);
|
|
3716
|
+
}));
|
|
3717
|
+
function login(_x) {
|
|
3718
|
+
return _login.apply(this, arguments);
|
|
3719
|
+
}
|
|
3720
|
+
return login;
|
|
3721
|
+
}();
|
|
3722
|
+
}
|
|
3723
|
+
var Auth = /*#__PURE__*/function (_Config) {
|
|
3724
|
+
function Auth(config, headers) {
|
|
3725
|
+
var _this;
|
|
3726
|
+
_this = _Config.call(this, config) || this;
|
|
3727
|
+
_this.headers = void 0;
|
|
3728
|
+
_this.session = /*#__PURE__*/function () {
|
|
3729
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(req, init) {
|
|
3730
|
+
var _requester, _init;
|
|
3731
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
3732
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
3733
|
+
case 0:
|
|
3734
|
+
_requester = new Requester(_this);
|
|
3735
|
+
_init = _this.handleHeaders(init);
|
|
3736
|
+
_context2.next = 4;
|
|
3737
|
+
return _requester.get(req, _this.sessionUrl, _init);
|
|
3738
|
+
case 4:
|
|
3739
|
+
return _context2.abrupt("return", _context2.sent);
|
|
3740
|
+
case 5:
|
|
3741
|
+
case "end":
|
|
3742
|
+
return _context2.stop();
|
|
3743
|
+
}
|
|
3744
|
+
}, _callee2);
|
|
3745
|
+
}));
|
|
3746
|
+
return function (_x2, _x3) {
|
|
3747
|
+
return _ref4.apply(this, arguments);
|
|
3748
|
+
};
|
|
3749
|
+
}();
|
|
3750
|
+
_this.headers = headers;
|
|
3751
|
+
return _this;
|
|
3752
|
+
}
|
|
3753
|
+
_inheritsLoose(Auth, _Config);
|
|
3754
|
+
var _proto = Auth.prototype;
|
|
3755
|
+
_proto.handleHeaders = function handleHeaders(init) {
|
|
3756
|
+
if (this.headers) {
|
|
3757
|
+
if (init) {
|
|
3758
|
+
var _init2;
|
|
3759
|
+
init.headers = new Headers(_extends({}, this.headers, (_init2 = init) == null ? void 0 : _init2.headers));
|
|
3760
|
+
return init;
|
|
3761
|
+
} else {
|
|
3762
|
+
init = {
|
|
3763
|
+
headers: this.headers
|
|
3764
|
+
};
|
|
3765
|
+
return init;
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3768
|
+
return undefined;
|
|
3769
|
+
};
|
|
3770
|
+
return _createClass(Auth, [{
|
|
3771
|
+
key: "sessionUrl",
|
|
3772
|
+
get: function get() {
|
|
3773
|
+
return '/auth/session';
|
|
3774
|
+
}
|
|
3775
|
+
}]);
|
|
3776
|
+
}(Config);
|
|
3777
|
+
|
|
3724
3778
|
var Tenants = /*#__PURE__*/function (_Config) {
|
|
3725
3779
|
function Tenants(config, headers) {
|
|
3726
3780
|
var _this;
|
|
@@ -4061,10 +4115,12 @@ var Api = /*#__PURE__*/function () {
|
|
|
4061
4115
|
function Api(config) {
|
|
4062
4116
|
this.config = void 0;
|
|
4063
4117
|
this.users = void 0;
|
|
4118
|
+
this.auth = void 0;
|
|
4064
4119
|
this.tenants = void 0;
|
|
4065
4120
|
this.routes = void 0;
|
|
4066
4121
|
this.handlers = void 0;
|
|
4067
4122
|
this.config = config;
|
|
4123
|
+
this.auth = new Auth(config);
|
|
4068
4124
|
this.users = new Users(config);
|
|
4069
4125
|
this.tenants = new Tenants(config);
|
|
4070
4126
|
this.routes = _extends({}, appRoutes(config == null ? void 0 : config.routePrefix), config == null ? void 0 : config.routes);
|
|
@@ -4081,7 +4137,7 @@ var Api = /*#__PURE__*/function () {
|
|
|
4081
4137
|
while (1) switch (_context.prev = _context.next) {
|
|
4082
4138
|
case 0:
|
|
4083
4139
|
_context.next = 2;
|
|
4084
|
-
return
|
|
4140
|
+
return serverLogin(this.config, this.handlers)(payload);
|
|
4085
4141
|
case 2:
|
|
4086
4142
|
this.headers = _context.sent;
|
|
4087
4143
|
case 3:
|