@niledatabase/server 3.0.0-alpha.14 → 3.0.0-alpha.16
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 +1 -6
- package/dist/server.cjs.development.js +11 -10
- 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 +11 -10
- package/dist/server.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/auth/index.d.ts
CHANGED
|
@@ -2,12 +2,7 @@ import { Config } from '../utils/Config';
|
|
|
2
2
|
/**
|
|
3
3
|
* a helper function to log in server side.
|
|
4
4
|
*/
|
|
5
|
-
export default function
|
|
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, }: {
|
|
5
|
+
export default function login(config: Config): ({ email, password, }: {
|
|
11
6
|
email: string;
|
|
12
7
|
password: string;
|
|
13
8
|
}) => Promise<Headers>;
|
|
@@ -3071,10 +3071,11 @@ var appRoutes = function appRoutes(prefix) {
|
|
|
3071
3071
|
/**
|
|
3072
3072
|
* a helper function to log in server side.
|
|
3073
3073
|
*/
|
|
3074
|
-
function
|
|
3074
|
+
function login(config) {
|
|
3075
3075
|
var _Logger = Logger(config, '[server side login]'),
|
|
3076
3076
|
info = _Logger.info,
|
|
3077
3077
|
error = _Logger.error;
|
|
3078
|
+
var routes = proxyRoutes(config);
|
|
3078
3079
|
return /*#__PURE__*/function () {
|
|
3079
3080
|
var _login = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
3080
3081
|
var _providers, _exec;
|
|
@@ -3090,7 +3091,7 @@ function serverAuth(config, handlers) {
|
|
|
3090
3091
|
throw new Error('Server side login requires a user email and password.');
|
|
3091
3092
|
case 3:
|
|
3092
3093
|
info('Obtaining providers for', email);
|
|
3093
|
-
sessionUrl = new URL(
|
|
3094
|
+
sessionUrl = new URL(routes.PROVIDERS);
|
|
3094
3095
|
sessionReq = new Request(sessionUrl, {
|
|
3095
3096
|
method: 'GET',
|
|
3096
3097
|
headers: new Headers({
|
|
@@ -3098,7 +3099,7 @@ function serverAuth(config, handlers) {
|
|
|
3098
3099
|
})
|
|
3099
3100
|
});
|
|
3100
3101
|
_context.next = 8;
|
|
3101
|
-
return
|
|
3102
|
+
return fetch(sessionReq);
|
|
3102
3103
|
case 8:
|
|
3103
3104
|
sessionRes = _context.sent;
|
|
3104
3105
|
_context.prev = 9;
|
|
@@ -3115,7 +3116,7 @@ function serverAuth(config, handlers) {
|
|
|
3115
3116
|
error(_context.t0);
|
|
3116
3117
|
case 19:
|
|
3117
3118
|
info('Obtaining csrf');
|
|
3118
|
-
csrf = new URL(
|
|
3119
|
+
csrf = new URL(routes.CSRF);
|
|
3119
3120
|
csrfReq = new Request(csrf, {
|
|
3120
3121
|
method: 'GET',
|
|
3121
3122
|
headers: new Headers({
|
|
@@ -3123,7 +3124,7 @@ function serverAuth(config, handlers) {
|
|
|
3123
3124
|
})
|
|
3124
3125
|
});
|
|
3125
3126
|
_context.next = 24;
|
|
3126
|
-
return
|
|
3127
|
+
return fetch(csrfReq);
|
|
3127
3128
|
case 24:
|
|
3128
3129
|
csrfRes = _context.sent;
|
|
3129
3130
|
_context.prev = 25;
|
|
@@ -3159,7 +3160,7 @@ function serverAuth(config, handlers) {
|
|
|
3159
3160
|
}
|
|
3160
3161
|
throw new Error('Unable to obtain credential provider. Aborting server side login.');
|
|
3161
3162
|
case 46:
|
|
3162
|
-
signInUrl = new URL(
|
|
3163
|
+
signInUrl = new URL(routes.SIGNIN);
|
|
3163
3164
|
if (csrfCookie) {
|
|
3164
3165
|
_context.next = 49;
|
|
3165
3166
|
break;
|
|
@@ -3181,7 +3182,7 @@ function serverAuth(config, handlers) {
|
|
|
3181
3182
|
})
|
|
3182
3183
|
});
|
|
3183
3184
|
_context.next = 53;
|
|
3184
|
-
return
|
|
3185
|
+
return fetch(postReq);
|
|
3185
3186
|
case 53:
|
|
3186
3187
|
loginRes = _context.sent;
|
|
3187
3188
|
authCookie = loginRes == null ? void 0 : loginRes.headers.get('set-cookie');
|
|
@@ -3806,7 +3807,7 @@ var Api = /*#__PURE__*/function () {
|
|
|
3806
3807
|
while (1) switch (_context.prev = _context.next) {
|
|
3807
3808
|
case 0:
|
|
3808
3809
|
_context.next = 2;
|
|
3809
|
-
return
|
|
3810
|
+
return login(this.config)(payload);
|
|
3810
3811
|
case 2:
|
|
3811
3812
|
this.headers = _context.sent;
|
|
3812
3813
|
case 3:
|
|
@@ -3815,10 +3816,10 @@ var Api = /*#__PURE__*/function () {
|
|
|
3815
3816
|
}
|
|
3816
3817
|
}, _callee, this);
|
|
3817
3818
|
}));
|
|
3818
|
-
function login(_x) {
|
|
3819
|
+
function login$1(_x) {
|
|
3819
3820
|
return _login.apply(this, arguments);
|
|
3820
3821
|
}
|
|
3821
|
-
return login;
|
|
3822
|
+
return login$1;
|
|
3822
3823
|
}();
|
|
3823
3824
|
return _createClass(Api, [{
|
|
3824
3825
|
key: "headers",
|