@niledatabase/server 3.0.0-alpha.12 → 3.0.0-alpha.13
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/utils/request.d.ts +1 -1
- package/dist/server.cjs.development.js +114 -84
- 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 +114 -84
- package/dist/server.esm.js.map +1 -1
- package/package.json +2 -2
|
@@ -1283,9 +1283,7 @@ function _request() {
|
|
|
1283
1283
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1284
1284
|
while (1) switch (_context.prev = _context.next) {
|
|
1285
1285
|
case 0:
|
|
1286
|
-
_Logger = Logger(
|
|
1287
|
-
debug: config == null ? void 0 : config.debug
|
|
1288
|
-
}), '[REQUEST]', "[" + url + "]"), info = _Logger.info, error = _Logger.error;
|
|
1286
|
+
_Logger = Logger(config, '[REQUEST]'), info = _Logger.info, error = _Logger.error;
|
|
1289
1287
|
request = _init.request, init = _objectWithoutPropertiesLoose(_init, _excluded);
|
|
1290
1288
|
requestUrl = new URL(request.url);
|
|
1291
1289
|
updatedHeaders = new Headers(request.headers);
|
|
@@ -1358,18 +1356,18 @@ var key$7 = 'ME';
|
|
|
1358
1356
|
* description: Unauthorized
|
|
1359
1357
|
* content: {}
|
|
1360
1358
|
*/
|
|
1361
|
-
function GET$3(_x, _x2, _x3) {
|
|
1359
|
+
function GET$3(_x, _x2, _x3, _x4) {
|
|
1362
1360
|
return _GET$3.apply(this, arguments);
|
|
1363
1361
|
}
|
|
1364
1362
|
function _GET$3() {
|
|
1365
|
-
_GET$3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url, init, log) {
|
|
1363
|
+
_GET$3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url, init, log, config) {
|
|
1366
1364
|
var res;
|
|
1367
1365
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1368
1366
|
while (1) switch (_context.prev = _context.next) {
|
|
1369
1367
|
case 0:
|
|
1370
1368
|
log('[GET]', url);
|
|
1371
1369
|
_context.next = 3;
|
|
1372
|
-
return request(url, init);
|
|
1370
|
+
return request(url, init, config);
|
|
1373
1371
|
case 3:
|
|
1374
1372
|
res = _context.sent;
|
|
1375
1373
|
return _context.abrupt("return", res);
|
|
@@ -1381,7 +1379,7 @@ function _GET$3() {
|
|
|
1381
1379
|
}));
|
|
1382
1380
|
return _GET$3.apply(this, arguments);
|
|
1383
1381
|
}
|
|
1384
|
-
function route$a(
|
|
1382
|
+
function route$a(_x5, _x6) {
|
|
1385
1383
|
return _route$a.apply(this, arguments);
|
|
1386
1384
|
}
|
|
1387
1385
|
function _route$a() {
|
|
@@ -1401,7 +1399,7 @@ function _route$a() {
|
|
|
1401
1399
|
_context2.next = 7;
|
|
1402
1400
|
return GET$3(url, {
|
|
1403
1401
|
request: request
|
|
1404
|
-
}, info);
|
|
1402
|
+
}, info, config);
|
|
1405
1403
|
case 7:
|
|
1406
1404
|
return _context2.abrupt("return", _context2.sent);
|
|
1407
1405
|
case 8:
|
|
@@ -1440,7 +1438,7 @@ function _auth() {
|
|
|
1440
1438
|
_context.next = 7;
|
|
1441
1439
|
return request(sessionUrl, {
|
|
1442
1440
|
request: req
|
|
1443
|
-
});
|
|
1441
|
+
}, config);
|
|
1444
1442
|
case 7:
|
|
1445
1443
|
res = _context.sent;
|
|
1446
1444
|
if (res) {
|
|
@@ -1594,60 +1592,68 @@ function _fetch2() {
|
|
|
1594
1592
|
case 38:
|
|
1595
1593
|
return _context.abrupt("return", response);
|
|
1596
1594
|
case 39:
|
|
1597
|
-
if (!((response == null ? void 0 : response.status) ===
|
|
1595
|
+
if (!((response == null ? void 0 : response.status) === 404)) {
|
|
1598
1596
|
_context.next = 41;
|
|
1599
1597
|
break;
|
|
1600
1598
|
}
|
|
1599
|
+
return _context.abrupt("return", new ResponseError('Not found', {
|
|
1600
|
+
status: 404
|
|
1601
|
+
}));
|
|
1602
|
+
case 41:
|
|
1603
|
+
if (!((response == null ? void 0 : response.status) === 401)) {
|
|
1604
|
+
_context.next = 43;
|
|
1605
|
+
break;
|
|
1606
|
+
}
|
|
1601
1607
|
return _context.abrupt("return", new ResponseError('Unauthorized', {
|
|
1602
1608
|
status: 401
|
|
1603
1609
|
}));
|
|
1604
|
-
case
|
|
1610
|
+
case 43:
|
|
1605
1611
|
if (!((response == null ? void 0 : response.status) === 405)) {
|
|
1606
|
-
_context.next =
|
|
1612
|
+
_context.next = 45;
|
|
1607
1613
|
break;
|
|
1608
1614
|
}
|
|
1609
1615
|
return _context.abrupt("return", new ResponseError('Method not allowed', {
|
|
1610
1616
|
status: 405
|
|
1611
1617
|
}));
|
|
1612
|
-
case
|
|
1618
|
+
case 45:
|
|
1613
1619
|
errorHandler = typeof (response == null ? void 0 : response.clone) === 'function' ? response.clone() : null;
|
|
1614
1620
|
msg = '';
|
|
1615
|
-
_context.prev =
|
|
1616
|
-
_context.next =
|
|
1621
|
+
_context.prev = 47;
|
|
1622
|
+
_context.next = 50;
|
|
1617
1623
|
return response == null ? void 0 : response.json();
|
|
1618
|
-
case
|
|
1624
|
+
case 50:
|
|
1619
1625
|
res = _context.sent;
|
|
1620
|
-
_context.next =
|
|
1626
|
+
_context.next = 61;
|
|
1621
1627
|
break;
|
|
1622
|
-
case
|
|
1623
|
-
_context.prev =
|
|
1624
|
-
_context.t5 = _context["catch"](
|
|
1628
|
+
case 53:
|
|
1629
|
+
_context.prev = 53;
|
|
1630
|
+
_context.t5 = _context["catch"](47);
|
|
1625
1631
|
if (!errorHandler) {
|
|
1626
|
-
_context.next =
|
|
1632
|
+
_context.next = 60;
|
|
1627
1633
|
break;
|
|
1628
1634
|
}
|
|
1629
|
-
_context.next =
|
|
1635
|
+
_context.next = 58;
|
|
1630
1636
|
return errorHandler.text();
|
|
1631
|
-
case
|
|
1637
|
+
case 58:
|
|
1632
1638
|
msg = _context.sent;
|
|
1633
1639
|
if (msg) {
|
|
1634
1640
|
error('[fetch]', '[response]', "[status: " + errorHandler.status + "]", msg);
|
|
1635
1641
|
}
|
|
1636
|
-
case
|
|
1642
|
+
case 60:
|
|
1637
1643
|
if (!msg) {
|
|
1638
1644
|
error('[fetch]', '[response]', _context.t5);
|
|
1639
1645
|
}
|
|
1640
|
-
case
|
|
1646
|
+
case 61:
|
|
1641
1647
|
if (!msg) {
|
|
1642
|
-
_context.next =
|
|
1648
|
+
_context.next = 63;
|
|
1643
1649
|
break;
|
|
1644
1650
|
}
|
|
1645
1651
|
return _context.abrupt("return", new ResponseError(msg, {
|
|
1646
1652
|
status: errorHandler == null ? void 0 : errorHandler.status
|
|
1647
1653
|
}));
|
|
1648
|
-
case
|
|
1654
|
+
case 63:
|
|
1649
1655
|
if (!(res && 'message' in res)) {
|
|
1650
|
-
_context.next =
|
|
1656
|
+
_context.next = 67;
|
|
1651
1657
|
break;
|
|
1652
1658
|
}
|
|
1653
1659
|
_res = res, message = _res.message;
|
|
@@ -1655,9 +1661,9 @@ function _fetch2() {
|
|
|
1655
1661
|
return _context.abrupt("return", new ResponseError(message, {
|
|
1656
1662
|
status: 400
|
|
1657
1663
|
}));
|
|
1658
|
-
case
|
|
1664
|
+
case 67:
|
|
1659
1665
|
if (!(res && 'errors' in res)) {
|
|
1660
|
-
_context.next =
|
|
1666
|
+
_context.next = 71;
|
|
1661
1667
|
break;
|
|
1662
1668
|
}
|
|
1663
1669
|
_res2 = res, _res2$errors = _res2.errors, _message = _res2$errors[0];
|
|
@@ -1665,16 +1671,16 @@ function _fetch2() {
|
|
|
1665
1671
|
return _context.abrupt("return", new ResponseError(_message, {
|
|
1666
1672
|
status: 400
|
|
1667
1673
|
}));
|
|
1668
|
-
case
|
|
1674
|
+
case 71:
|
|
1669
1675
|
error('[fetch]', '[response]', "[status: " + (errorHandler == null ? void 0 : errorHandler.status) + "]", 'UNHANDLED ERROR');
|
|
1670
1676
|
return _context.abrupt("return", new ResponseError(null, {
|
|
1671
1677
|
status: (_response$status = response == null ? void 0 : response.status) != null ? _response$status : 500
|
|
1672
1678
|
}));
|
|
1673
|
-
case
|
|
1679
|
+
case 73:
|
|
1674
1680
|
case "end":
|
|
1675
1681
|
return _context.stop();
|
|
1676
1682
|
}
|
|
1677
|
-
}, _callee, null, [[23, 31], [
|
|
1683
|
+
}, _callee, null, [[23, 31], [47, 53]]);
|
|
1678
1684
|
}));
|
|
1679
1685
|
return _fetch2.apply(this, arguments);
|
|
1680
1686
|
}
|
|
@@ -1766,7 +1772,7 @@ function _POST$2() {
|
|
|
1766
1772
|
url = apiRoutes(config).USERS(tenant ? tenant : undefined);
|
|
1767
1773
|
log && log('[POST]', url);
|
|
1768
1774
|
_context.next = 11;
|
|
1769
|
-
return request(url, init);
|
|
1775
|
+
return request(url, init, config);
|
|
1770
1776
|
case 11:
|
|
1771
1777
|
return _context.abrupt("return", _context.sent);
|
|
1772
1778
|
case 12:
|
|
@@ -1834,7 +1840,7 @@ function _GET$2() {
|
|
|
1834
1840
|
log('[GET]', url);
|
|
1835
1841
|
init.method = 'GET';
|
|
1836
1842
|
_context.next = 11;
|
|
1837
|
-
return request(url, init);
|
|
1843
|
+
return request(url, init, config);
|
|
1838
1844
|
case 11:
|
|
1839
1845
|
return _context.abrupt("return", _context.sent);
|
|
1840
1846
|
case 12:
|
|
@@ -1906,7 +1912,7 @@ function _PUT$1() {
|
|
|
1906
1912
|
url = apiRoutes(config).USER(userId);
|
|
1907
1913
|
log('[PUT]', url);
|
|
1908
1914
|
_context.next = 9;
|
|
1909
|
-
return request(url, init);
|
|
1915
|
+
return request(url, init, config);
|
|
1910
1916
|
case 9:
|
|
1911
1917
|
return _context.abrupt("return", _context.sent);
|
|
1912
1918
|
case 10:
|
|
@@ -2028,7 +2034,7 @@ function _GET$1() {
|
|
|
2028
2034
|
url = "" + apiRoutes(config).TENANT_USERS(tenantId);
|
|
2029
2035
|
log('[GET]', '[TENANT_USERS]', url);
|
|
2030
2036
|
_context.next = 8;
|
|
2031
|
-
return request(url, init);
|
|
2037
|
+
return request(url, init, config);
|
|
2032
2038
|
case 8:
|
|
2033
2039
|
return _context.abrupt("return", _context.sent);
|
|
2034
2040
|
case 9:
|
|
@@ -2099,7 +2105,7 @@ function _POST$1() {
|
|
|
2099
2105
|
url = apiRoutes(config).TENANT_USERS(tenantId);
|
|
2100
2106
|
log('[PUT]', url);
|
|
2101
2107
|
_context.next = 8;
|
|
2102
|
-
return request(url, init);
|
|
2108
|
+
return request(url, init, config);
|
|
2103
2109
|
case 8:
|
|
2104
2110
|
return _context.abrupt("return", _context.sent);
|
|
2105
2111
|
case 9:
|
|
@@ -2163,7 +2169,7 @@ function _DELETE$1() {
|
|
|
2163
2169
|
url = "" + apiRoutes(config).TENANT_USER(tenantId, userId);
|
|
2164
2170
|
log('[DELETE]', url);
|
|
2165
2171
|
_context.next = 10;
|
|
2166
|
-
return request(url, init);
|
|
2172
|
+
return request(url, init, config);
|
|
2167
2173
|
case 10:
|
|
2168
2174
|
return _context.abrupt("return", _context.sent);
|
|
2169
2175
|
case 11:
|
|
@@ -2223,7 +2229,7 @@ function _PUT() {
|
|
|
2223
2229
|
url = "" + apiRoutes(config).TENANT_USERS(tenantId);
|
|
2224
2230
|
log('[PUT]', url);
|
|
2225
2231
|
_context.next = 9;
|
|
2226
|
-
return request(url, init);
|
|
2232
|
+
return request(url, init, config);
|
|
2227
2233
|
case 9:
|
|
2228
2234
|
return _context.abrupt("return", _context.sent);
|
|
2229
2235
|
case 10:
|
|
@@ -2360,7 +2366,7 @@ function _GET() {
|
|
|
2360
2366
|
}
|
|
2361
2367
|
log('[GET]', url);
|
|
2362
2368
|
_context.next = 5;
|
|
2363
|
-
return request(url, init);
|
|
2369
|
+
return request(url, init, config);
|
|
2364
2370
|
case 5:
|
|
2365
2371
|
res = _context.sent;
|
|
2366
2372
|
return _context.abrupt("return", res);
|
|
@@ -2426,7 +2432,7 @@ function _DELETE() {
|
|
|
2426
2432
|
url = "" + apiRoutes(config).TENANT(tenantId);
|
|
2427
2433
|
log('[DELETE]', url);
|
|
2428
2434
|
_context.next = 9;
|
|
2429
|
-
return request(url, init);
|
|
2435
|
+
return request(url, init, config);
|
|
2430
2436
|
case 9:
|
|
2431
2437
|
return _context.abrupt("return", _context.sent);
|
|
2432
2438
|
case 10:
|
|
@@ -2493,7 +2499,7 @@ function _POST() {
|
|
|
2493
2499
|
url = "" + apiRoutes(config).TENANTS;
|
|
2494
2500
|
log('[POST]', url);
|
|
2495
2501
|
_context.next = 6;
|
|
2496
|
-
return request(url, init);
|
|
2502
|
+
return request(url, init, config);
|
|
2497
2503
|
case 6:
|
|
2498
2504
|
return _context.abrupt("return", _context.sent);
|
|
2499
2505
|
case 7:
|
|
@@ -2611,7 +2617,7 @@ function _route$6() {
|
|
|
2611
2617
|
_context.next = 8;
|
|
2612
2618
|
return request(url, _extends({}, init, {
|
|
2613
2619
|
request: req
|
|
2614
|
-
}));
|
|
2620
|
+
}), config);
|
|
2615
2621
|
case 8:
|
|
2616
2622
|
res = _context.sent;
|
|
2617
2623
|
return _context.abrupt("return", res);
|
|
@@ -2662,7 +2668,7 @@ function _route$4() {
|
|
|
2662
2668
|
return _context.abrupt("return", request(proxyRoutes(config).PROVIDERS, {
|
|
2663
2669
|
method: req.method,
|
|
2664
2670
|
request: req
|
|
2665
|
-
}));
|
|
2671
|
+
}, config));
|
|
2666
2672
|
case 1:
|
|
2667
2673
|
case "end":
|
|
2668
2674
|
return _context.stop();
|
|
@@ -2686,7 +2692,7 @@ function _route$3() {
|
|
|
2686
2692
|
return _context.abrupt("return", request(proxyRoutes(config).CSRF, {
|
|
2687
2693
|
method: req.method,
|
|
2688
2694
|
request: req
|
|
2689
|
-
}));
|
|
2695
|
+
}, config));
|
|
2690
2696
|
case 1:
|
|
2691
2697
|
case "end":
|
|
2692
2698
|
return _context.stop();
|
|
@@ -2720,7 +2726,7 @@ function _route$2() {
|
|
|
2720
2726
|
return request(url, {
|
|
2721
2727
|
request: request$1,
|
|
2722
2728
|
method: request$1.method
|
|
2723
|
-
})["catch"](function (e) {
|
|
2729
|
+
}, config)["catch"](function (e) {
|
|
2724
2730
|
error('an error as occurred', e);
|
|
2725
2731
|
});
|
|
2726
2732
|
case 7:
|
|
@@ -2773,7 +2779,7 @@ function _route$1() {
|
|
|
2773
2779
|
_context.next = 5;
|
|
2774
2780
|
return request(url, _extends({}, init, {
|
|
2775
2781
|
request: request$1
|
|
2776
|
-
}));
|
|
2782
|
+
}), config);
|
|
2777
2783
|
case 5:
|
|
2778
2784
|
res = _context.sent;
|
|
2779
2785
|
return _context.abrupt("return", res);
|
|
@@ -2801,7 +2807,7 @@ function _route() {
|
|
|
2801
2807
|
return _context.abrupt("return", request(proxyRoutes(config)[key], {
|
|
2802
2808
|
method: req.method,
|
|
2803
2809
|
request: req
|
|
2804
|
-
}));
|
|
2810
|
+
}, config));
|
|
2805
2811
|
case 1:
|
|
2806
2812
|
case "end":
|
|
2807
2813
|
return _context.stop();
|
|
@@ -3091,16 +3097,23 @@ var appRoutes = function appRoutes(prefix) {
|
|
|
3091
3097
|
*/
|
|
3092
3098
|
function serverAuth(config, handlers) {
|
|
3093
3099
|
var _Logger = Logger(config, '[server side login]'),
|
|
3094
|
-
info = _Logger.info
|
|
3100
|
+
info = _Logger.info,
|
|
3101
|
+
error = _Logger.error;
|
|
3095
3102
|
return /*#__PURE__*/function () {
|
|
3096
3103
|
var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
3097
|
-
var
|
|
3098
|
-
var email, password, sessionUrl, sessionReq, sessionRes, providers, csrf, csrfReq, csrfRes,
|
|
3104
|
+
var _exec;
|
|
3105
|
+
var email, password, sessionUrl, sessionReq, sessionRes, providers, csrf, csrfReq, csrfRes, csrfToken, _yield$csrfRes$json, json, _providers, credentials, csrfCookie, signInUrl, postReq, loginRes, authCookie, _ref2, token;
|
|
3099
3106
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3100
3107
|
while (1) switch (_context.prev = _context.next) {
|
|
3101
3108
|
case 0:
|
|
3102
3109
|
email = _ref.email, password = _ref.password;
|
|
3103
|
-
|
|
3110
|
+
if (!(!email || !password)) {
|
|
3111
|
+
_context.next = 3;
|
|
3112
|
+
break;
|
|
3113
|
+
}
|
|
3114
|
+
throw new Error('Server side login requires a user email and password.');
|
|
3115
|
+
case 3:
|
|
3116
|
+
info('Obtaining providers for', email);
|
|
3104
3117
|
sessionUrl = new URL(config.api.localPath + "/api/auth/providers");
|
|
3105
3118
|
sessionReq = new Request(sessionUrl, {
|
|
3106
3119
|
method: 'GET',
|
|
@@ -3108,14 +3121,23 @@ function serverAuth(config, handlers) {
|
|
|
3108
3121
|
host: sessionUrl.host
|
|
3109
3122
|
})
|
|
3110
3123
|
});
|
|
3111
|
-
_context.next =
|
|
3124
|
+
_context.next = 8;
|
|
3112
3125
|
return handlers.POST(sessionReq);
|
|
3113
|
-
case
|
|
3126
|
+
case 8:
|
|
3114
3127
|
sessionRes = _context.sent;
|
|
3115
|
-
_context.
|
|
3128
|
+
_context.prev = 9;
|
|
3129
|
+
_context.next = 12;
|
|
3116
3130
|
return sessionRes == null ? void 0 : sessionRes.json();
|
|
3117
|
-
case
|
|
3131
|
+
case 12:
|
|
3118
3132
|
providers = _context.sent;
|
|
3133
|
+
_context.next = 19;
|
|
3134
|
+
break;
|
|
3135
|
+
case 15:
|
|
3136
|
+
_context.prev = 15;
|
|
3137
|
+
_context.t0 = _context["catch"](9);
|
|
3138
|
+
info(sessionRes);
|
|
3139
|
+
error(_context.t0);
|
|
3140
|
+
case 19:
|
|
3119
3141
|
info('Obtaining csrf');
|
|
3120
3142
|
csrf = new URL(config.api.localPath + "/api/auth/csrf");
|
|
3121
3143
|
csrfReq = new Request(csrf, {
|
|
@@ -3124,42 +3146,50 @@ function serverAuth(config, handlers) {
|
|
|
3124
3146
|
host: sessionUrl.host
|
|
3125
3147
|
})
|
|
3126
3148
|
});
|
|
3127
|
-
_context.next =
|
|
3149
|
+
_context.next = 24;
|
|
3128
3150
|
return handlers.POST(csrfReq);
|
|
3129
|
-
case
|
|
3151
|
+
case 24:
|
|
3130
3152
|
csrfRes = _context.sent;
|
|
3131
|
-
_context.
|
|
3153
|
+
_context.prev = 25;
|
|
3154
|
+
_context.next = 28;
|
|
3132
3155
|
return csrfRes == null ? void 0 : csrfRes.json();
|
|
3133
|
-
case
|
|
3134
|
-
_context.
|
|
3135
|
-
if (!(_context.
|
|
3136
|
-
_context.next =
|
|
3156
|
+
case 28:
|
|
3157
|
+
_context.t1 = _yield$csrfRes$json = _context.sent;
|
|
3158
|
+
if (!(_context.t1 != null)) {
|
|
3159
|
+
_context.next = 33;
|
|
3137
3160
|
break;
|
|
3138
3161
|
}
|
|
3139
|
-
_context.
|
|
3140
|
-
_context.next =
|
|
3162
|
+
_context.t2 = _yield$csrfRes$json;
|
|
3163
|
+
_context.next = 34;
|
|
3141
3164
|
break;
|
|
3142
|
-
case
|
|
3143
|
-
_context.
|
|
3144
|
-
case
|
|
3145
|
-
|
|
3146
|
-
csrfToken =
|
|
3147
|
-
|
|
3165
|
+
case 33:
|
|
3166
|
+
_context.t2 = {};
|
|
3167
|
+
case 34:
|
|
3168
|
+
json = _context.t2;
|
|
3169
|
+
csrfToken = json == null ? void 0 : json.csrfToken;
|
|
3170
|
+
_context.next = 41;
|
|
3171
|
+
break;
|
|
3172
|
+
case 38:
|
|
3173
|
+
_context.prev = 38;
|
|
3174
|
+
_context.t3 = _context["catch"](25);
|
|
3175
|
+
error(_context.t3, csrfRes);
|
|
3176
|
+
case 41:
|
|
3177
|
+
_providers = providers, credentials = _providers.credentials;
|
|
3148
3178
|
csrfCookie = csrfRes == null ? void 0 : csrfRes.headers.get('set-cookie');
|
|
3149
3179
|
if (credentials) {
|
|
3150
|
-
_context.next =
|
|
3180
|
+
_context.next = 45;
|
|
3151
3181
|
break;
|
|
3152
3182
|
}
|
|
3153
3183
|
throw new Error('Unable to obtain credential provider. Aborting server side login.');
|
|
3154
|
-
case
|
|
3184
|
+
case 45:
|
|
3155
3185
|
signInUrl = new URL(credentials.callbackUrl);
|
|
3156
3186
|
if (csrfCookie) {
|
|
3157
|
-
_context.next =
|
|
3187
|
+
_context.next = 48;
|
|
3158
3188
|
break;
|
|
3159
3189
|
}
|
|
3160
3190
|
throw new Error('Unable to authenticate REST');
|
|
3161
|
-
case
|
|
3162
|
-
info('Attempting sign in via', signInUrl.href, '
|
|
3191
|
+
case 48:
|
|
3192
|
+
info('Attempting sign in via proxy', signInUrl.href, 'with email', email);
|
|
3163
3193
|
postReq = new Request(signInUrl, {
|
|
3164
3194
|
method: 'POST',
|
|
3165
3195
|
headers: new Headers({
|
|
@@ -3173,27 +3203,27 @@ function serverAuth(config, handlers) {
|
|
|
3173
3203
|
callbackUrl: credentials.callbackUrl
|
|
3174
3204
|
})
|
|
3175
3205
|
});
|
|
3176
|
-
_context.next =
|
|
3206
|
+
_context.next = 52;
|
|
3177
3207
|
return handlers.POST(postReq);
|
|
3178
|
-
case
|
|
3208
|
+
case 52:
|
|
3179
3209
|
loginRes = _context.sent;
|
|
3180
3210
|
authCookie = loginRes == null ? void 0 : loginRes.headers.get('set-cookie');
|
|
3181
3211
|
if (authCookie) {
|
|
3182
|
-
_context.next =
|
|
3212
|
+
_context.next = 56;
|
|
3183
3213
|
break;
|
|
3184
3214
|
}
|
|
3185
3215
|
throw new Error('authentication failed');
|
|
3186
|
-
case
|
|
3187
|
-
|
|
3216
|
+
case 56:
|
|
3217
|
+
_ref2 = (_exec = /(nile\.session-token=.+?);/.exec(authCookie)) != null ? _exec : [], token = _ref2[1];
|
|
3188
3218
|
info('Server login successful', authCookie, csrfCookie);
|
|
3189
3219
|
return _context.abrupt("return", new Headers({
|
|
3190
3220
|
cookie: [token, csrfCookie].join('; ')
|
|
3191
3221
|
}));
|
|
3192
|
-
case
|
|
3222
|
+
case 59:
|
|
3193
3223
|
case "end":
|
|
3194
3224
|
return _context.stop();
|
|
3195
3225
|
}
|
|
3196
|
-
}, _callee);
|
|
3226
|
+
}, _callee, null, [[9, 15], [25, 38]]);
|
|
3197
3227
|
}));
|
|
3198
3228
|
function login(_x) {
|
|
3199
3229
|
return _login.apply(this, arguments);
|