@niledatabase/server 3.0.0-alpha.1 → 3.0.0-alpha.3

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.
@@ -15,8 +15,7 @@ import { ActiveSession } from '../../../../utils/auth';
15
15
  * type: string
16
16
  * requestBody:
17
17
  * description: |
18
- * The email and password combination the user will use to authenticate.
19
- * The `name` is optional; if provided it will be recorded in the `users` table.
18
+ * The email of the user you want to add to a tenant.
20
19
  * content:
21
20
  * application/json:
22
21
  * schema:
@@ -1,7 +1,7 @@
1
1
  import { ActiveSession } from '../../../../../utils/auth';
2
2
  /**
3
3
  * @swagger
4
- * /api/tenants/{tenantId}/users/{userId}:
4
+ * /api/tenants/{tenantId}/users/{email}:
5
5
  * delete:
6
6
  * tags:
7
7
  * - tenants
@@ -15,7 +15,7 @@ import { ActiveSession } from '../../../../../utils/auth';
15
15
  * required: true
16
16
  * schema:
17
17
  * type: string
18
- * - name: userId
18
+ * - name: email
19
19
  * in: path
20
20
  * required: true
21
21
  * schema:
@@ -6,7 +6,7 @@
6
6
  * - users
7
7
  * summary: lists users in the tenant
8
8
  * description: Returns information about the users within the tenant
9
- * provided. You can also pass the a `niledb-tenantId` in the header or in a cookie.
9
+ * provided. You can also pass the a `niledb-tenant-id` in the header or in a cookie.
10
10
  * operationId: listUsers
11
11
  * parameters:
12
12
  * - name: tenantId
@@ -2,5 +2,13 @@ import { Config } from '../../utils/Config';
2
2
  export type ActiveSession = {
3
3
  id: string;
4
4
  email: string;
5
+ expires: Date;
6
+ user?: {
7
+ id: string;
8
+ name: string;
9
+ image: string;
10
+ email: string;
11
+ emailVerified: void | Date;
12
+ };
5
13
  };
6
14
  export default function auth(req: Request, config: Config): Promise<void | ActiveSession>;
@@ -2262,30 +2262,32 @@ function _auth() {
2262
2262
  while (1) switch (_context.prev = _context.next) {
2263
2263
  case 0:
2264
2264
  _Logger = Logger(_extends({}, config, {
2265
- debug: true
2265
+ debug: config.debug
2266
2266
  }), '[nileauth]'), info = _Logger.info;
2267
2267
  info('checking auth');
2268
2268
  sessionUrl = config.api.basePath + "/auth/session";
2269
2269
  info('using session', sessionUrl);
2270
- _context.next = 6;
2270
+ // handle the pass through with posts
2271
+ req.headers["delete"]('content-length');
2272
+ _context.next = 7;
2271
2273
  return request(sessionUrl, {
2272
2274
  request: req
2273
2275
  });
2274
- case 6:
2276
+ case 7:
2275
2277
  res = _context.sent;
2276
2278
  if (res) {
2277
- _context.next = 10;
2279
+ _context.next = 11;
2278
2280
  break;
2279
2281
  }
2280
2282
  info('no session found');
2281
2283
  return _context.abrupt("return", undefined);
2282
- case 10:
2284
+ case 11:
2283
2285
  info('session active');
2284
- _context.next = 13;
2286
+ _context.next = 14;
2285
2287
  return new Response(res.body).json();
2286
- case 13:
2287
- return _context.abrupt("return", _context.sent);
2288
2288
  case 14:
2289
+ return _context.abrupt("return", _context.sent);
2290
+ case 15:
2289
2291
  case "end":
2290
2292
  return _context.stop();
2291
2293
  }
@@ -2401,7 +2403,7 @@ function _POST$2() {
2401
2403
  * - users
2402
2404
  * summary: lists users in the tenant
2403
2405
  * description: Returns information about the users within the tenant
2404
- * provided. You can also pass the a `niledb-tenantId` in the header or in a cookie.
2406
+ * provided. You can also pass the a `niledb-tenant-id` in the header or in a cookie.
2405
2407
  * operationId: listUsers
2406
2408
  * parameters:
2407
2409
  * - name: tenantId
@@ -2728,7 +2730,7 @@ function _POST$1() {
2728
2730
 
2729
2731
  /**
2730
2732
  * @swagger
2731
- * /api/tenants/{tenantId}/users/{userId}:
2733
+ * /api/tenants/{tenantId}/users/{email}:
2732
2734
  * delete:
2733
2735
  * tags:
2734
2736
  * - tenants
@@ -2742,7 +2744,7 @@ function _POST$1() {
2742
2744
  * required: true
2743
2745
  * schema:
2744
2746
  * type: string
2745
- * - name: userId
2747
+ * - name: email
2746
2748
  * in: path
2747
2749
  * required: true
2748
2750
  * schema:
@@ -2772,13 +2774,16 @@ function _DELETE$1() {
2772
2774
  }));
2773
2775
  case 4:
2774
2776
  init.method = 'DELETE';
2777
+ init.body = JSON.stringify({
2778
+ email: userId
2779
+ });
2775
2780
  url = "" + apiRoutes.TENANT_USER(tenantId, userId);
2776
2781
  log('[DELETE]', url);
2777
- _context.next = 9;
2782
+ _context.next = 10;
2778
2783
  return request(url, init);
2779
- case 9:
2780
- return _context.abrupt("return", _context.sent);
2781
2784
  case 10:
2785
+ return _context.abrupt("return", _context.sent);
2786
+ case 11:
2782
2787
  case "end":
2783
2788
  return _context.stop();
2784
2789
  }
@@ -2803,8 +2808,7 @@ function _DELETE$1() {
2803
2808
  * type: string
2804
2809
  * requestBody:
2805
2810
  * description: |
2806
- * The email and password combination the user will use to authenticate.
2807
- * The `name` is optional; if provided it will be recorded in the `users` table.
2811
+ * The email of the user you want to add to a tenant.
2808
2812
  * content:
2809
2813
  * application/json:
2810
2814
  * schema:
@@ -2963,17 +2967,21 @@ function GET(_x, _x2, _x3) {
2963
2967
  }
2964
2968
  function _GET() {
2965
2969
  _GET = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(session, init, log) {
2966
- var url;
2970
+ var url, res;
2967
2971
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2968
2972
  while (1) switch (_context.prev = _context.next) {
2969
2973
  case 0:
2970
2974
  url = "" + apiRoutes.USER_TENANTS(session.id);
2975
+ if (typeof session === 'object' && 'user' in session && session.user) {
2976
+ url = "" + apiRoutes.USER_TENANTS(session.user.id);
2977
+ }
2971
2978
  log('[GET]', url);
2972
- _context.next = 4;
2979
+ _context.next = 5;
2973
2980
  return request(url, init);
2974
- case 4:
2975
- return _context.abrupt("return", _context.sent);
2976
2981
  case 5:
2982
+ res = _context.sent;
2983
+ return _context.abrupt("return", res);
2984
+ case 7:
2977
2985
  case "end":
2978
2986
  return _context.stop();
2979
2987
  }