@niledatabase/server 3.0.0-alpha.16 → 3.0.0-alpha.17
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/auth/index.d.ts +6 -1
- package/dist/server.cjs.development.js +154 -103
- 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 +154 -103
- package/dist/server.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/auth/index.d.ts
CHANGED
|
@@ -2,7 +2,12 @@ import { Config } from '../utils/Config';
|
|
|
2
2
|
/**
|
|
3
3
|
* a helper function to log in server side.
|
|
4
4
|
*/
|
|
5
|
-
export default function
|
|
5
|
+
export default function serverAuth(config: Config, handlers: {
|
|
6
|
+
GET: (req: Request) => Promise<void | Response>;
|
|
7
|
+
POST: (req: Request) => Promise<void | Response>;
|
|
8
|
+
DELETE: (req: Request) => Promise<void | Response>;
|
|
9
|
+
PUT: (req: Request) => Promise<void | Response>;
|
|
10
|
+
}): ({ email, password, }: {
|
|
6
11
|
email: string;
|
|
7
12
|
password: string;
|
|
8
13
|
}) => Promise<Headers>;
|
|
@@ -1399,13 +1399,11 @@ function auth(_x, _x2) {
|
|
|
1399
1399
|
}
|
|
1400
1400
|
function _auth() {
|
|
1401
1401
|
_auth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, config) {
|
|
1402
|
-
var _Logger, info, sessionUrl, res;
|
|
1402
|
+
var _Logger, info, error, sessionUrl, res;
|
|
1403
1403
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1404
1404
|
while (1) switch (_context.prev = _context.next) {
|
|
1405
1405
|
case 0:
|
|
1406
|
-
_Logger = Logger(
|
|
1407
|
-
debug: config.debug
|
|
1408
|
-
}), '[nileauth]'), info = _Logger.info;
|
|
1406
|
+
_Logger = Logger(config, '[nileauth]'), info = _Logger.info, error = _Logger.error;
|
|
1409
1407
|
info('checking auth');
|
|
1410
1408
|
sessionUrl = config.api.basePath + "/auth/session";
|
|
1411
1409
|
info('using session', sessionUrl);
|
|
@@ -1425,15 +1423,21 @@ function _auth() {
|
|
|
1425
1423
|
return _context.abrupt("return", undefined);
|
|
1426
1424
|
case 11:
|
|
1427
1425
|
info('session active');
|
|
1428
|
-
_context.
|
|
1426
|
+
_context.prev = 12;
|
|
1427
|
+
_context.next = 15;
|
|
1429
1428
|
return new Response(res.body).json();
|
|
1430
|
-
case 14:
|
|
1431
|
-
return _context.abrupt("return", _context.sent);
|
|
1432
1429
|
case 15:
|
|
1430
|
+
return _context.abrupt("return", _context.sent);
|
|
1431
|
+
case 18:
|
|
1432
|
+
_context.prev = 18;
|
|
1433
|
+
_context.t0 = _context["catch"](12);
|
|
1434
|
+
error(_context.t0);
|
|
1435
|
+
return _context.abrupt("return", undefined);
|
|
1436
|
+
case 22:
|
|
1433
1437
|
case "end":
|
|
1434
1438
|
return _context.stop();
|
|
1435
1439
|
}
|
|
1436
|
-
}, _callee);
|
|
1440
|
+
}, _callee, null, [[12, 18]]);
|
|
1437
1441
|
}));
|
|
1438
1442
|
return _auth.apply(this, arguments);
|
|
1439
1443
|
}
|
|
@@ -2797,81 +2801,96 @@ function matches(configRoutes, request) {
|
|
|
2797
2801
|
}
|
|
2798
2802
|
|
|
2799
2803
|
function GETTER(configRoutes, config) {
|
|
2804
|
+
var _Logger = Logger(config, '[GET MATCHER]'),
|
|
2805
|
+
info = _Logger.info,
|
|
2806
|
+
warn = _Logger.warn;
|
|
2800
2807
|
return /*#__PURE__*/function () {
|
|
2801
2808
|
var _GET = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
|
|
2802
2809
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2803
2810
|
while (1) switch (_context.prev = _context.next) {
|
|
2804
2811
|
case 0:
|
|
2805
2812
|
if (!matches$a(configRoutes, req)) {
|
|
2806
|
-
_context.next =
|
|
2813
|
+
_context.next = 3;
|
|
2807
2814
|
break;
|
|
2808
2815
|
}
|
|
2816
|
+
info('matches me');
|
|
2809
2817
|
return _context.abrupt("return", route$a(req, config));
|
|
2810
|
-
case
|
|
2811
|
-
if (!matches$9(configRoutes, req)) {
|
|
2812
|
-
_context.next = 4;
|
|
2813
|
-
break;
|
|
2814
|
-
}
|
|
2815
|
-
return _context.abrupt("return", route$9(req, config));
|
|
2816
|
-
case 4:
|
|
2818
|
+
case 3:
|
|
2817
2819
|
if (!matches$8(configRoutes, req)) {
|
|
2818
2820
|
_context.next = 6;
|
|
2819
2821
|
break;
|
|
2820
2822
|
}
|
|
2823
|
+
info('matches tenant users');
|
|
2821
2824
|
return _context.abrupt("return", route$8(req, config));
|
|
2822
2825
|
case 6:
|
|
2826
|
+
if (!matches$9(configRoutes, req)) {
|
|
2827
|
+
_context.next = 9;
|
|
2828
|
+
break;
|
|
2829
|
+
}
|
|
2830
|
+
info('matches users');
|
|
2831
|
+
return _context.abrupt("return", route$9(req, config));
|
|
2832
|
+
case 9:
|
|
2823
2833
|
if (!matches$7(configRoutes, req)) {
|
|
2824
|
-
_context.next =
|
|
2834
|
+
_context.next = 12;
|
|
2825
2835
|
break;
|
|
2826
2836
|
}
|
|
2837
|
+
info('matches tenants');
|
|
2827
2838
|
return _context.abrupt("return", route$7(req, config));
|
|
2828
|
-
case
|
|
2839
|
+
case 12:
|
|
2829
2840
|
if (!matches$5(configRoutes, req)) {
|
|
2830
|
-
_context.next =
|
|
2841
|
+
_context.next = 15;
|
|
2831
2842
|
break;
|
|
2832
2843
|
}
|
|
2844
|
+
info('matches session');
|
|
2833
2845
|
return _context.abrupt("return", route$5(req, config));
|
|
2834
|
-
case
|
|
2846
|
+
case 15:
|
|
2835
2847
|
if (!matches$6(configRoutes, req)) {
|
|
2836
|
-
_context.next =
|
|
2848
|
+
_context.next = 18;
|
|
2837
2849
|
break;
|
|
2838
2850
|
}
|
|
2851
|
+
info('matches signin');
|
|
2839
2852
|
return _context.abrupt("return", route$6(req, config));
|
|
2840
|
-
case
|
|
2853
|
+
case 18:
|
|
2841
2854
|
if (!matches$4(configRoutes, req)) {
|
|
2842
|
-
_context.next =
|
|
2855
|
+
_context.next = 21;
|
|
2843
2856
|
break;
|
|
2844
2857
|
}
|
|
2858
|
+
info('matches providers');
|
|
2845
2859
|
return _context.abrupt("return", route$4(req, config));
|
|
2846
|
-
case
|
|
2860
|
+
case 21:
|
|
2847
2861
|
if (!matches$3(configRoutes, req)) {
|
|
2848
|
-
_context.next =
|
|
2862
|
+
_context.next = 24;
|
|
2849
2863
|
break;
|
|
2850
2864
|
}
|
|
2865
|
+
info('matches csrf');
|
|
2851
2866
|
return _context.abrupt("return", route$3(req, config));
|
|
2852
|
-
case
|
|
2867
|
+
case 24:
|
|
2853
2868
|
if (!matches$2(configRoutes, req)) {
|
|
2854
|
-
_context.next =
|
|
2869
|
+
_context.next = 27;
|
|
2855
2870
|
break;
|
|
2856
2871
|
}
|
|
2872
|
+
info('matches callback');
|
|
2857
2873
|
return _context.abrupt("return", route$2(req, config));
|
|
2858
|
-
case
|
|
2874
|
+
case 27:
|
|
2859
2875
|
if (!matches$1(configRoutes, req)) {
|
|
2860
|
-
_context.next =
|
|
2876
|
+
_context.next = 30;
|
|
2861
2877
|
break;
|
|
2862
2878
|
}
|
|
2879
|
+
info('matches signout');
|
|
2863
2880
|
return _context.abrupt("return", route$1(req, config));
|
|
2864
|
-
case
|
|
2881
|
+
case 30:
|
|
2865
2882
|
if (!matches(configRoutes, req)) {
|
|
2866
|
-
_context.next =
|
|
2883
|
+
_context.next = 33;
|
|
2867
2884
|
break;
|
|
2868
2885
|
}
|
|
2886
|
+
info('matches error');
|
|
2869
2887
|
return _context.abrupt("return", route(req, config));
|
|
2870
|
-
case
|
|
2888
|
+
case 33:
|
|
2889
|
+
warn('No GET routes matched');
|
|
2871
2890
|
return _context.abrupt("return", new Response(null, {
|
|
2872
2891
|
status: 404
|
|
2873
2892
|
}));
|
|
2874
|
-
case
|
|
2893
|
+
case 35:
|
|
2875
2894
|
case "end":
|
|
2876
2895
|
return _context.stop();
|
|
2877
2896
|
}
|
|
@@ -2885,69 +2904,82 @@ function GETTER(configRoutes, config) {
|
|
|
2885
2904
|
}
|
|
2886
2905
|
|
|
2887
2906
|
function POSTER(configRoutes, config) {
|
|
2907
|
+
var _Logger = Logger(config, '[POST MATCHER]'),
|
|
2908
|
+
info = _Logger.info,
|
|
2909
|
+
warn = _Logger.warn;
|
|
2888
2910
|
return /*#__PURE__*/function () {
|
|
2889
2911
|
var _POST = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
|
|
2890
2912
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2891
2913
|
while (1) switch (_context.prev = _context.next) {
|
|
2892
2914
|
case 0:
|
|
2893
2915
|
if (!matches$8(configRoutes, req)) {
|
|
2894
|
-
_context.next =
|
|
2916
|
+
_context.next = 3;
|
|
2895
2917
|
break;
|
|
2896
2918
|
}
|
|
2919
|
+
info('matches tenant users');
|
|
2897
2920
|
return _context.abrupt("return", route$8(req, config));
|
|
2898
|
-
case
|
|
2921
|
+
case 3:
|
|
2899
2922
|
if (!matches$9(configRoutes, req)) {
|
|
2900
|
-
_context.next =
|
|
2923
|
+
_context.next = 6;
|
|
2901
2924
|
break;
|
|
2902
2925
|
}
|
|
2926
|
+
info('matches users');
|
|
2903
2927
|
return _context.abrupt("return", route$9(req, config));
|
|
2904
|
-
case
|
|
2928
|
+
case 6:
|
|
2905
2929
|
if (!matches$7(configRoutes, req)) {
|
|
2906
|
-
_context.next =
|
|
2930
|
+
_context.next = 9;
|
|
2907
2931
|
break;
|
|
2908
2932
|
}
|
|
2933
|
+
info('matches tenants');
|
|
2909
2934
|
return _context.abrupt("return", route$7(req, config));
|
|
2910
|
-
case
|
|
2935
|
+
case 9:
|
|
2911
2936
|
if (!matches$5(configRoutes, req)) {
|
|
2912
|
-
_context.next =
|
|
2937
|
+
_context.next = 12;
|
|
2913
2938
|
break;
|
|
2914
2939
|
}
|
|
2940
|
+
info('matches session');
|
|
2915
2941
|
return _context.abrupt("return", route$5(req, config));
|
|
2916
|
-
case
|
|
2942
|
+
case 12:
|
|
2917
2943
|
if (!matches$6(configRoutes, req)) {
|
|
2918
|
-
_context.next =
|
|
2944
|
+
_context.next = 15;
|
|
2919
2945
|
break;
|
|
2920
2946
|
}
|
|
2947
|
+
info('matches signin');
|
|
2921
2948
|
return _context.abrupt("return", route$6(req, config));
|
|
2922
|
-
case
|
|
2949
|
+
case 15:
|
|
2923
2950
|
if (!matches$4(configRoutes, req)) {
|
|
2924
|
-
_context.next =
|
|
2951
|
+
_context.next = 18;
|
|
2925
2952
|
break;
|
|
2926
2953
|
}
|
|
2954
|
+
info('matches providers');
|
|
2927
2955
|
return _context.abrupt("return", route$4(req, config));
|
|
2928
|
-
case
|
|
2956
|
+
case 18:
|
|
2929
2957
|
if (!matches$3(configRoutes, req)) {
|
|
2930
|
-
_context.next =
|
|
2958
|
+
_context.next = 21;
|
|
2931
2959
|
break;
|
|
2932
2960
|
}
|
|
2961
|
+
info('matches csrf');
|
|
2933
2962
|
return _context.abrupt("return", route$3(req, config));
|
|
2934
|
-
case
|
|
2963
|
+
case 21:
|
|
2935
2964
|
if (!matches$2(configRoutes, req)) {
|
|
2936
|
-
_context.next =
|
|
2965
|
+
_context.next = 24;
|
|
2937
2966
|
break;
|
|
2938
2967
|
}
|
|
2968
|
+
info('matches callback');
|
|
2939
2969
|
return _context.abrupt("return", route$2(req, config));
|
|
2940
|
-
case
|
|
2970
|
+
case 24:
|
|
2941
2971
|
if (!matches$1(configRoutes, req)) {
|
|
2942
|
-
_context.next =
|
|
2972
|
+
_context.next = 27;
|
|
2943
2973
|
break;
|
|
2944
2974
|
}
|
|
2975
|
+
info('matches signout');
|
|
2945
2976
|
return _context.abrupt("return", route$1(req, config));
|
|
2946
|
-
case
|
|
2977
|
+
case 27:
|
|
2978
|
+
warn('No POST routes matched');
|
|
2947
2979
|
return _context.abrupt("return", new Response(null, {
|
|
2948
2980
|
status: 404
|
|
2949
2981
|
}));
|
|
2950
|
-
case
|
|
2982
|
+
case 29:
|
|
2951
2983
|
case "end":
|
|
2952
2984
|
return _context.stop();
|
|
2953
2985
|
}
|
|
@@ -2961,27 +2993,33 @@ function POSTER(configRoutes, config) {
|
|
|
2961
2993
|
}
|
|
2962
2994
|
|
|
2963
2995
|
function DELETER(configRoutes, config) {
|
|
2996
|
+
var _Logger = Logger(config, '[DELETE MATCHER]'),
|
|
2997
|
+
info = _Logger.info,
|
|
2998
|
+
warn = _Logger.warn;
|
|
2964
2999
|
return /*#__PURE__*/function () {
|
|
2965
3000
|
var _DELETE = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
|
|
2966
3001
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
2967
3002
|
while (1) switch (_context.prev = _context.next) {
|
|
2968
3003
|
case 0:
|
|
2969
3004
|
if (!matches$8(configRoutes, req)) {
|
|
2970
|
-
_context.next =
|
|
3005
|
+
_context.next = 3;
|
|
2971
3006
|
break;
|
|
2972
3007
|
}
|
|
3008
|
+
info('matches tenant users');
|
|
2973
3009
|
return _context.abrupt("return", route$8(req, config));
|
|
2974
|
-
case
|
|
3010
|
+
case 3:
|
|
2975
3011
|
if (!matches$7(configRoutes, req)) {
|
|
2976
|
-
_context.next =
|
|
3012
|
+
_context.next = 6;
|
|
2977
3013
|
break;
|
|
2978
3014
|
}
|
|
3015
|
+
info('matches tenants');
|
|
2979
3016
|
return _context.abrupt("return", route$7(req, config));
|
|
2980
|
-
case
|
|
3017
|
+
case 6:
|
|
3018
|
+
warn('No DELETE routes matched');
|
|
2981
3019
|
return _context.abrupt("return", new Response(null, {
|
|
2982
3020
|
status: 404
|
|
2983
3021
|
}));
|
|
2984
|
-
case
|
|
3022
|
+
case 8:
|
|
2985
3023
|
case "end":
|
|
2986
3024
|
return _context.stop();
|
|
2987
3025
|
}
|
|
@@ -2995,33 +3033,40 @@ function DELETER(configRoutes, config) {
|
|
|
2995
3033
|
}
|
|
2996
3034
|
|
|
2997
3035
|
function PUTER(configRoutes, config) {
|
|
3036
|
+
var _Logger = Logger(config, '[PUT MATCHER]'),
|
|
3037
|
+
info = _Logger.info,
|
|
3038
|
+
warn = _Logger.warn;
|
|
2998
3039
|
return /*#__PURE__*/function () {
|
|
2999
3040
|
var _PUT = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
|
|
3000
3041
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
3001
3042
|
while (1) switch (_context.prev = _context.next) {
|
|
3002
3043
|
case 0:
|
|
3003
3044
|
if (!matches$8(configRoutes, req)) {
|
|
3004
|
-
_context.next =
|
|
3045
|
+
_context.next = 3;
|
|
3005
3046
|
break;
|
|
3006
3047
|
}
|
|
3048
|
+
info('matches tenant users');
|
|
3007
3049
|
return _context.abrupt("return", route$8(req, config));
|
|
3008
|
-
case
|
|
3050
|
+
case 3:
|
|
3009
3051
|
if (!matches$9(configRoutes, req)) {
|
|
3010
|
-
_context.next =
|
|
3052
|
+
_context.next = 6;
|
|
3011
3053
|
break;
|
|
3012
3054
|
}
|
|
3055
|
+
info('matches users');
|
|
3013
3056
|
return _context.abrupt("return", route$9(req, config));
|
|
3014
|
-
case
|
|
3057
|
+
case 6:
|
|
3015
3058
|
if (!matches$7(configRoutes, req)) {
|
|
3016
|
-
_context.next =
|
|
3059
|
+
_context.next = 9;
|
|
3017
3060
|
break;
|
|
3018
3061
|
}
|
|
3062
|
+
info('matches tenants');
|
|
3019
3063
|
return _context.abrupt("return", route$7(req, config));
|
|
3020
|
-
case
|
|
3064
|
+
case 9:
|
|
3065
|
+
warn('No PUT routes matched');
|
|
3021
3066
|
return _context.abrupt("return", new Response(null, {
|
|
3022
3067
|
status: 404
|
|
3023
3068
|
}));
|
|
3024
|
-
case
|
|
3069
|
+
case 11:
|
|
3025
3070
|
case "end":
|
|
3026
3071
|
return _context.stop();
|
|
3027
3072
|
}
|
|
@@ -3071,7 +3116,7 @@ var appRoutes = function appRoutes(prefix) {
|
|
|
3071
3116
|
/**
|
|
3072
3117
|
* a helper function to log in server side.
|
|
3073
3118
|
*/
|
|
3074
|
-
function
|
|
3119
|
+
function serverAuth(config, handlers) {
|
|
3075
3120
|
var _Logger = Logger(config, '[server side login]'),
|
|
3076
3121
|
info = _Logger.info,
|
|
3077
3122
|
error = _Logger.error;
|
|
@@ -3099,22 +3144,28 @@ function login(config) {
|
|
|
3099
3144
|
})
|
|
3100
3145
|
});
|
|
3101
3146
|
_context.next = 8;
|
|
3102
|
-
return
|
|
3147
|
+
return handlers.POST(sessionReq);
|
|
3103
3148
|
case 8:
|
|
3104
3149
|
sessionRes = _context.sent;
|
|
3105
|
-
|
|
3106
|
-
|
|
3150
|
+
if (!((sessionRes == null ? void 0 : sessionRes.status) === 404)) {
|
|
3151
|
+
_context.next = 11;
|
|
3152
|
+
break;
|
|
3153
|
+
}
|
|
3154
|
+
throw new Error('Unable to login, cannot find region api.');
|
|
3155
|
+
case 11:
|
|
3156
|
+
_context.prev = 11;
|
|
3157
|
+
_context.next = 14;
|
|
3107
3158
|
return sessionRes == null ? void 0 : sessionRes.json();
|
|
3108
|
-
case
|
|
3159
|
+
case 14:
|
|
3109
3160
|
providers = _context.sent;
|
|
3110
|
-
_context.next =
|
|
3161
|
+
_context.next = 21;
|
|
3111
3162
|
break;
|
|
3112
|
-
case
|
|
3113
|
-
_context.prev =
|
|
3114
|
-
_context.t0 = _context["catch"](
|
|
3163
|
+
case 17:
|
|
3164
|
+
_context.prev = 17;
|
|
3165
|
+
_context.t0 = _context["catch"](11);
|
|
3115
3166
|
info(sessionUrl, sessionRes);
|
|
3116
3167
|
error(_context.t0);
|
|
3117
|
-
case
|
|
3168
|
+
case 21:
|
|
3118
3169
|
info('Obtaining csrf');
|
|
3119
3170
|
csrf = new URL(routes.CSRF);
|
|
3120
3171
|
csrfReq = new Request(csrf, {
|
|
@@ -3123,50 +3174,50 @@ function login(config) {
|
|
|
3123
3174
|
host: sessionUrl.host
|
|
3124
3175
|
})
|
|
3125
3176
|
});
|
|
3126
|
-
_context.next =
|
|
3127
|
-
return
|
|
3128
|
-
case
|
|
3177
|
+
_context.next = 26;
|
|
3178
|
+
return handlers.POST(csrfReq);
|
|
3179
|
+
case 26:
|
|
3129
3180
|
csrfRes = _context.sent;
|
|
3130
|
-
_context.prev =
|
|
3131
|
-
_context.next =
|
|
3181
|
+
_context.prev = 27;
|
|
3182
|
+
_context.next = 30;
|
|
3132
3183
|
return csrfRes == null ? void 0 : csrfRes.json();
|
|
3133
|
-
case
|
|
3184
|
+
case 30:
|
|
3134
3185
|
_context.t1 = _yield$csrfRes$json = _context.sent;
|
|
3135
3186
|
if (!(_context.t1 != null)) {
|
|
3136
|
-
_context.next =
|
|
3187
|
+
_context.next = 35;
|
|
3137
3188
|
break;
|
|
3138
3189
|
}
|
|
3139
3190
|
_context.t2 = _yield$csrfRes$json;
|
|
3140
|
-
_context.next =
|
|
3191
|
+
_context.next = 36;
|
|
3141
3192
|
break;
|
|
3142
|
-
case
|
|
3193
|
+
case 35:
|
|
3143
3194
|
_context.t2 = {};
|
|
3144
|
-
case
|
|
3195
|
+
case 36:
|
|
3145
3196
|
json = _context.t2;
|
|
3146
3197
|
csrfToken = json == null ? void 0 : json.csrfToken;
|
|
3147
|
-
_context.next =
|
|
3198
|
+
_context.next = 44;
|
|
3148
3199
|
break;
|
|
3149
|
-
case
|
|
3150
|
-
_context.prev =
|
|
3151
|
-
_context.t3 = _context["catch"](
|
|
3200
|
+
case 40:
|
|
3201
|
+
_context.prev = 40;
|
|
3202
|
+
_context.t3 = _context["catch"](27);
|
|
3152
3203
|
info(sessionUrl, csrfRes);
|
|
3153
3204
|
error(_context.t3, csrfRes);
|
|
3154
|
-
case
|
|
3205
|
+
case 44:
|
|
3155
3206
|
_ref2 = (_providers = providers) != null ? _providers : {}, credentials = _ref2.credentials;
|
|
3156
3207
|
csrfCookie = csrfRes == null ? void 0 : csrfRes.headers.get('set-cookie');
|
|
3157
3208
|
if (credentials) {
|
|
3158
|
-
_context.next =
|
|
3209
|
+
_context.next = 48;
|
|
3159
3210
|
break;
|
|
3160
3211
|
}
|
|
3161
3212
|
throw new Error('Unable to obtain credential provider. Aborting server side login.');
|
|
3162
|
-
case
|
|
3213
|
+
case 48:
|
|
3163
3214
|
signInUrl = new URL(routes.SIGNIN);
|
|
3164
3215
|
if (csrfCookie) {
|
|
3165
|
-
_context.next =
|
|
3216
|
+
_context.next = 51;
|
|
3166
3217
|
break;
|
|
3167
3218
|
}
|
|
3168
3219
|
throw new Error('Unable to authenticate REST');
|
|
3169
|
-
case
|
|
3220
|
+
case 51:
|
|
3170
3221
|
info('Attempting sign in via proxy', signInUrl.href, 'with email', email);
|
|
3171
3222
|
postReq = new Request(signInUrl, {
|
|
3172
3223
|
method: 'POST',
|
|
@@ -3181,27 +3232,27 @@ function login(config) {
|
|
|
3181
3232
|
callbackUrl: credentials.callbackUrl
|
|
3182
3233
|
})
|
|
3183
3234
|
});
|
|
3184
|
-
_context.next =
|
|
3185
|
-
return
|
|
3186
|
-
case
|
|
3235
|
+
_context.next = 55;
|
|
3236
|
+
return handlers.POST(postReq);
|
|
3237
|
+
case 55:
|
|
3187
3238
|
loginRes = _context.sent;
|
|
3188
3239
|
authCookie = loginRes == null ? void 0 : loginRes.headers.get('set-cookie');
|
|
3189
3240
|
if (authCookie) {
|
|
3190
|
-
_context.next =
|
|
3241
|
+
_context.next = 59;
|
|
3191
3242
|
break;
|
|
3192
3243
|
}
|
|
3193
3244
|
throw new Error('authentication failed');
|
|
3194
|
-
case
|
|
3245
|
+
case 59:
|
|
3195
3246
|
_ref3 = (_exec = /(nile\.session-token=.+?);/.exec(authCookie)) != null ? _exec : [], token = _ref3[1];
|
|
3196
3247
|
info('Server login successful', authCookie, csrfCookie);
|
|
3197
3248
|
return _context.abrupt("return", new Headers({
|
|
3198
3249
|
cookie: [token, csrfCookie].join('; ')
|
|
3199
3250
|
}));
|
|
3200
|
-
case
|
|
3251
|
+
case 62:
|
|
3201
3252
|
case "end":
|
|
3202
3253
|
return _context.stop();
|
|
3203
3254
|
}
|
|
3204
|
-
}, _callee, null, [[
|
|
3255
|
+
}, _callee, null, [[11, 17], [27, 40]]);
|
|
3205
3256
|
}));
|
|
3206
3257
|
function login(_x) {
|
|
3207
3258
|
return _login.apply(this, arguments);
|
|
@@ -3807,7 +3858,7 @@ var Api = /*#__PURE__*/function () {
|
|
|
3807
3858
|
while (1) switch (_context.prev = _context.next) {
|
|
3808
3859
|
case 0:
|
|
3809
3860
|
_context.next = 2;
|
|
3810
|
-
return
|
|
3861
|
+
return serverAuth(this.config, this.handlers)(payload);
|
|
3811
3862
|
case 2:
|
|
3812
3863
|
this.headers = _context.sent;
|
|
3813
3864
|
case 3:
|
|
@@ -3816,10 +3867,10 @@ var Api = /*#__PURE__*/function () {
|
|
|
3816
3867
|
}
|
|
3817
3868
|
}, _callee, this);
|
|
3818
3869
|
}));
|
|
3819
|
-
function login
|
|
3870
|
+
function login(_x) {
|
|
3820
3871
|
return _login.apply(this, arguments);
|
|
3821
3872
|
}
|
|
3822
|
-
return login
|
|
3873
|
+
return login;
|
|
3823
3874
|
}();
|
|
3824
3875
|
return _createClass(Api, [{
|
|
3825
3876
|
key: "headers",
|