@proteinjs/user-server 1.0.1

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +21 -0
  3. package/dist/generated/index.d.ts +11 -0
  4. package/dist/generated/index.d.ts.map +1 -0
  5. package/dist/generated/index.js +45 -0
  6. package/dist/generated/index.js.map +1 -0
  7. package/dist/index.d.ts +3 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +21 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/src/authentication/DbSessionStore.d.ts +17 -0
  12. package/dist/src/authentication/DbSessionStore.d.ts.map +1 -0
  13. package/dist/src/authentication/DbSessionStore.js +181 -0
  14. package/dist/src/authentication/DbSessionStore.js.map +1 -0
  15. package/dist/src/authentication/DefaultAdminCredentials.d.ts +12 -0
  16. package/dist/src/authentication/DefaultAdminCredentials.d.ts.map +1 -0
  17. package/dist/src/authentication/DefaultAdminCredentials.js +18 -0
  18. package/dist/src/authentication/DefaultAdminCredentials.js.map +1 -0
  19. package/dist/src/authentication/authenticate.d.ts +6 -0
  20. package/dist/src/authentication/authenticate.d.ts.map +1 -0
  21. package/dist/src/authentication/authenticate.js +79 -0
  22. package/dist/src/authentication/authenticate.js.map +1 -0
  23. package/dist/src/authentication/destroySession.d.ts +2 -0
  24. package/dist/src/authentication/destroySession.d.ts.map +1 -0
  25. package/dist/src/authentication/destroySession.js +58 -0
  26. package/dist/src/authentication/destroySession.js.map +1 -0
  27. package/dist/src/authorization/userCache.d.ts +4 -0
  28. package/dist/src/authorization/userCache.d.ts.map +1 -0
  29. package/dist/src/authorization/userCache.js +70 -0
  30. package/dist/src/authorization/userCache.js.map +1 -0
  31. package/dist/src/routes/createUser.d.ts +3 -0
  32. package/dist/src/routes/createUser.d.ts.map +1 -0
  33. package/dist/src/routes/createUser.js +83 -0
  34. package/dist/src/routes/createUser.js.map +1 -0
  35. package/dist/src/routes/login.d.ts +3 -0
  36. package/dist/src/routes/login.d.ts.map +1 -0
  37. package/dist/src/routes/login.js +76 -0
  38. package/dist/src/routes/login.js.map +1 -0
  39. package/dist/src/routes/logout.d.ts +3 -0
  40. package/dist/src/routes/logout.d.ts.map +1 -0
  41. package/dist/src/routes/logout.js +87 -0
  42. package/dist/src/routes/logout.js.map +1 -0
  43. package/generated/index.ts +41 -0
  44. package/index.ts +2 -0
  45. package/jest.config.js +18 -0
  46. package/package.json +43 -0
  47. package/src/authentication/DbSessionStore.ts +91 -0
  48. package/src/authentication/DefaultAdminCredentials.ts +15 -0
  49. package/src/authentication/authenticate.ts +28 -0
  50. package/src/authentication/destroySession.ts +9 -0
  51. package/src/authorization/userCache.ts +23 -0
  52. package/src/routes/createUser.ts +32 -0
  53. package/src/routes/login.ts +29 -0
  54. package/src/routes/logout.ts +28 -0
  55. package/tsconfig.json +18 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## 1.0.1 (2024-04-19)
7
+
8
+ **Note:** Version bump only for package @proteinjs/user-server
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Brent Bahry
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,11 @@
1
+ /** Load Dependency Source Graphs */
2
+ import '@proteinjs/reflection';
3
+ import '@proteinjs/util';
4
+ import '@proteinjs/db';
5
+ import '@proteinjs/server-api';
6
+ import '@proteinjs/user';
7
+ import 'crypto-js';
8
+ import 'express-session';
9
+ import 'moment';
10
+ export * from '../index';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":"AAAA,oCAAoC;AAEpC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,iBAAiB,CAAC;AACzB,OAAO,eAAe,CAAC;AACvB,OAAO,uBAAuB,CAAC;AAC/B,OAAO,iBAAiB,CAAC;AACzB,OAAO,WAAW,CAAC;AACnB,OAAO,iBAAiB,CAAC;AACzB,OAAO,QAAQ,CAAC;AA+BhB,cAAc,UAAU,CAAC"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ /** Load Dependency Source Graphs */
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ require("@proteinjs/reflection");
19
+ require("@proteinjs/util");
20
+ require("@proteinjs/db");
21
+ require("@proteinjs/server-api");
22
+ require("@proteinjs/user");
23
+ require("crypto-js");
24
+ require("express-session");
25
+ require("moment");
26
+ /** Generate Source Graph */
27
+ var sourceGraph = "{\"options\":{\"directed\":true,\"multigraph\":false,\"compound\":false},\"nodes\":[{\"v\":\"@proteinjs/user-server/DbSessionStore\",\"value\":{\"packageName\":\"@proteinjs/user-server\",\"name\":\"DbSessionStore\",\"filePath\":\"/home/runner/work/user/user/packages/server/src/authentication/DbSessionStore.ts\",\"qualifiedName\":\"@proteinjs/user-server/DbSessionStore\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[{\"name\":\"TWELVE_HOURS\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":true,\"visibility\":\"private\"},{\"name\":\"get\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"set\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"touch\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"},{\"name\":\"destroy\",\"type\":null,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\"}],\"methods\":[{\"name\":\"insertOrUpdate\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<void>\",\"filePath\":null,\"qualifiedName\":\"/Promise<void>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\",\"parameters\":[{\"name\":\"sessionId\",\"type\":{\"packageName\":\"\",\"name\":\"string\",\"filePath\":null,\"qualifiedName\":\"/string\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"session\",\"type\":{\"packageName\":\"\",\"name\":\"Express.SessionData\",\"filePath\":null,\"qualifiedName\":\"/Express.SessionData\",\"typeParameters\":null,\"directParents\":null}},{\"name\":\"cb\",\"type\":{\"packageName\":\"\",\"name\":\"(error?: any) => void\",\"filePath\":null,\"qualifiedName\":\"/(error?: any) => void\",\"typeParameters\":null,\"directParents\":null}}]},{\"name\":\"sweep\",\"returnType\":{\"packageName\":\"\",\"name\":\"Promise<void>\",\"filePath\":null,\"qualifiedName\":\"/Promise<void>\",\"typeParameters\":null,\"directParents\":null},\"isAsync\":true,\"isOptional\":false,\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"private\",\"parameters\":[]}],\"typeParameters\":[],\"directParentInterfaces\":[],\"directParentClasses\":[{\"packageName\":\"express-session\",\"name\":\"Store\",\"filePath\":null,\"qualifiedName\":\"express-session/Store\",\"isAbstract\":false,\"isStatic\":false,\"visibility\":\"public\",\"properties\":[],\"methods\":[],\"typeParameters\":[],\"directParentInterfaces\":[],\"directParentClasses\":[]}],\"sourceType\":2}},{\"v\":\"express-session/Store\"},{\"v\":\"@proteinjs/user-server/userCache\",\"value\":{\"packageName\":\"@proteinjs/user-server\",\"name\":\"userCache\",\"filePath\":\"/home/runner/work/user/user/packages/server/src/authorization/userCache.ts\",\"qualifiedName\":\"@proteinjs/user-server/userCache\",\"type\":{\"packageName\":\"\",\"name\":\"SessionDataCache<User>\",\"filePath\":null,\"qualifiedName\":\"/SessionDataCache<User>\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"SessionDataCache\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/SessionDataCache\",\"typeParameters\":[\"@proteinjs/user/User\"],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}},{\"v\":\"@proteinjs/server-api/SessionDataCache\"},{\"v\":\"@proteinjs/user-server/createUser\",\"value\":{\"packageName\":\"@proteinjs/user-server\",\"name\":\"createUser\",\"filePath\":\"/home/runner/work/user/user/packages/server/src/routes/createUser.ts\",\"qualifiedName\":\"@proteinjs/user-server/createUser\",\"type\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}},{\"v\":\"@proteinjs/server-api/Route\"},{\"v\":\"@proteinjs/user-server/login\",\"value\":{\"packageName\":\"@proteinjs/user-server\",\"name\":\"login\",\"filePath\":\"/home/runner/work/user/user/packages/server/src/routes/login.ts\",\"qualifiedName\":\"@proteinjs/user-server/login\",\"type\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}},{\"v\":\"@proteinjs/user-server/logout\",\"value\":{\"packageName\":\"@proteinjs/user-server\",\"name\":\"logout\",\"filePath\":\"/home/runner/work/user/user/packages/server/src/routes/logout.ts\",\"qualifiedName\":\"@proteinjs/user-server/logout\",\"type\":{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":[{\"packageName\":\"@proteinjs/server-api\",\"name\":\"Route\",\"filePath\":null,\"qualifiedName\":\"@proteinjs/server-api/Route\",\"typeParameters\":[],\"directParents\":null}]},\"isExported\":true,\"isConst\":true,\"sourceType\":0}}],\"edges\":[{\"v\":\"@proteinjs/user-server/DbSessionStore\",\"w\":\"express-session/Store\",\"value\":\"extends class\"},{\"v\":\"@proteinjs/user-server/userCache\",\"w\":\"@proteinjs/server-api/SessionDataCache\",\"value\":\"has type\"},{\"v\":\"@proteinjs/user-server/createUser\",\"w\":\"@proteinjs/server-api/Route\",\"value\":\"has type\"},{\"v\":\"@proteinjs/user-server/login\",\"w\":\"@proteinjs/server-api/Route\",\"value\":\"has type\"},{\"v\":\"@proteinjs/user-server/logout\",\"w\":\"@proteinjs/server-api/Route\",\"value\":\"has type\"}]}";
28
+ /** Generate Source Links */
29
+ var DbSessionStore_1 = require("../src/authentication/DbSessionStore");
30
+ var userCache_1 = require("../src/authorization/userCache");
31
+ var createUser_1 = require("../src/routes/createUser");
32
+ var login_1 = require("../src/routes/login");
33
+ var logout_1 = require("../src/routes/logout");
34
+ var sourceLinks = {
35
+ '@proteinjs/user-server/DbSessionStore': DbSessionStore_1.DbSessionStore,
36
+ '@proteinjs/user-server/userCache': userCache_1.userCache,
37
+ '@proteinjs/user-server/createUser': createUser_1.createUser,
38
+ '@proteinjs/user-server/login': login_1.login,
39
+ '@proteinjs/user-server/logout': logout_1.logout,
40
+ };
41
+ /** Load Source Graph and Links */
42
+ var reflection_1 = require("@proteinjs/reflection");
43
+ reflection_1.SourceRepository.merge(sourceGraph, sourceLinks);
44
+ __exportStar(require("../index"), exports);
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../generated/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;;;;;;;;;;;;;;AAEpC,iCAA+B;AAC/B,2BAAyB;AACzB,yBAAuB;AACvB,iCAA+B;AAC/B,2BAAyB;AACzB,qBAAmB;AACnB,2BAAyB;AACzB,kBAAgB;AAGhB,4BAA4B;AAE5B,IAAM,WAAW,GAAG,w7LAAw7L,CAAC;AAG78L,4BAA4B;AAE5B,uEAAsE;AACtE,4DAA2D;AAC3D,uDAAsD;AACtD,6CAA4C;AAC5C,+CAA8C;AAE9C,IAAM,WAAW,GAAG;IACnB,uCAAuC,EAAE,+BAAc;IACvD,kCAAkC,EAAE,qBAAS;IAC7C,mCAAmC,EAAE,uBAAU;IAC/C,8BAA8B,EAAE,aAAK;IACrC,+BAA+B,EAAE,eAAM;CACvC,CAAC;AAGF,kCAAkC;AAElC,oDAAyD;AACzD,6BAAgB,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAGjD,2CAAyB"}
@@ -0,0 +1,3 @@
1
+ export { createAuthentication } from './src/authentication/authenticate';
2
+ export * from './src/authentication/DbSessionStore';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,cAAc,qCAAqC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.createAuthentication = void 0;
18
+ var authenticate_1 = require("./src/authentication/authenticate");
19
+ Object.defineProperty(exports, "createAuthentication", { enumerable: true, get: function () { return authenticate_1.createAuthentication; } });
20
+ __exportStar(require("./src/authentication/DbSessionStore"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kEAAyE;AAAhE,oHAAA,oBAAoB,OAAA;AAC7B,sEAAoD"}
@@ -0,0 +1,17 @@
1
+ /// <reference types="express-serve-static-core" />
2
+ import { Store } from 'express-session';
3
+ export declare class DbSessionStore extends Store {
4
+ private static readonly TWELVE_HOURS;
5
+ constructor();
6
+ get: (sessionId: string, cb: (error: any, session?: Express.SessionData | null) => void) => void;
7
+ set: (sessionId: string, session: Express.SessionData, cb?: ((error?: any) => void) | undefined) => void;
8
+ touch: (sessionId: string, session: Express.SessionData, cb?: ((error?: any) => void) | undefined) => void;
9
+ /**
10
+ * Does not get called since request.logout is broken
11
+ * See logout.ts
12
+ */
13
+ destroy: (sessionId: string, cb?: ((error?: any) => void) | undefined) => void;
14
+ private insertOrUpdate;
15
+ private sweep;
16
+ }
17
+ //# sourceMappingURL=DbSessionStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DbSessionStore.d.ts","sourceRoot":"","sources":["../../../src/authentication/DbSessionStore.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAKxC,qBAAa,cAAe,SAAQ,KAAK;IACrC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAuB;;IAO9D,GAAG,cAAe,MAAM,cAAc,GAAG,YAAY,QAAQ,WAAW,GAAC,IAAI,KAAK,IAAI,UAUrF;IAED,GAAG,cAAe,MAAM,WAAW,QAAQ,WAAW,iBAAgB,GAAG,KAAK,IAAI,uBAE9E;IAED,KAAK,cAAe,MAAM,WAAW,QAAQ,WAAW,iBAAgB,GAAG,KAAK,IAAI,uBAEnF;IAED;;;OAGG;IACN,OAAO,cAAe,MAAM,iBAAgB,GAAG,KAAK,IAAI,uBAOvD;YAEgB,cAAc;YAiCd,KAAK;CAWtB"}
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.DbSessionStore = void 0;
55
+ var express_session_1 = require("express-session");
56
+ var db_1 = require("@proteinjs/db");
57
+ var user_1 = require("@proteinjs/user");
58
+ var destroySession_1 = require("./destroySession");
59
+ var DbSessionStore = /** @class */ (function (_super) {
60
+ __extends(DbSessionStore, _super);
61
+ function DbSessionStore() {
62
+ var _this = _super.call(this) || this;
63
+ _this.get = function (sessionId, cb) {
64
+ (function () { return __awaiter(_this, void 0, void 0, function () {
65
+ var result;
66
+ return __generator(this, function (_a) {
67
+ switch (_a.label) {
68
+ case 0: return [4 /*yield*/, (0, db_1.getSystemDb)().get(user_1.tables.Session, { sessionId: sessionId })];
69
+ case 1:
70
+ result = _a.sent();
71
+ if (!result) {
72
+ cb(null);
73
+ return [2 /*return*/];
74
+ }
75
+ return [2 /*return*/, cb(null, JSON.parse(result.session))];
76
+ }
77
+ });
78
+ }); })();
79
+ };
80
+ _this.set = function (sessionId, session, cb) {
81
+ _this.insertOrUpdate(sessionId, session, cb);
82
+ };
83
+ _this.touch = function (sessionId, session, cb) {
84
+ _this.insertOrUpdate(sessionId, session, cb);
85
+ };
86
+ /**
87
+ * Does not get called since request.logout is broken
88
+ * See logout.ts
89
+ */
90
+ _this.destroy = function (sessionId, cb) {
91
+ // console.info('in destroy');
92
+ (function () { return __awaiter(_this, void 0, void 0, function () {
93
+ return __generator(this, function (_a) {
94
+ switch (_a.label) {
95
+ case 0: return [4 /*yield*/, (0, destroySession_1.destroySession)(sessionId)];
96
+ case 1:
97
+ _a.sent();
98
+ if (cb)
99
+ cb();
100
+ return [2 /*return*/];
101
+ }
102
+ });
103
+ }); })();
104
+ };
105
+ setInterval(_this.sweep, DbSessionStore.TWELVE_HOURS);
106
+ return _this;
107
+ }
108
+ DbSessionStore.prototype.insertOrUpdate = function (sessionId, session, cb) {
109
+ var _a, _b, _c;
110
+ return __awaiter(this, void 0, void 0, function () {
111
+ var sessionRecord, error_1;
112
+ return __generator(this, function (_d) {
113
+ switch (_d.label) {
114
+ case 0:
115
+ // Only persist authenticated sessions
116
+ if (!((_a = session.passport) === null || _a === void 0 ? void 0 : _a.user)) {
117
+ if (cb)
118
+ cb();
119
+ return [2 /*return*/];
120
+ }
121
+ return [4 /*yield*/, (0, db_1.getSystemDb)().get(user_1.tables.Session, { sessionId: sessionId })];
122
+ case 1:
123
+ sessionRecord = _d.sent();
124
+ if (!sessionRecord) return [3 /*break*/, 3];
125
+ sessionRecord.session = JSON.stringify(session);
126
+ sessionRecord.expires = session.cookie.expires;
127
+ sessionRecord.userEmail = (_b = session.passport) === null || _b === void 0 ? void 0 : _b.user;
128
+ return [4 /*yield*/, (0, db_1.getSystemDb)().update(user_1.tables.Session, sessionRecord, { sessionId: sessionId })];
129
+ case 2:
130
+ _d.sent();
131
+ return [3 /*break*/, 6];
132
+ case 3:
133
+ _d.trys.push([3, 5, , 6]);
134
+ return [4 /*yield*/, (0, db_1.getSystemDb)().insert(user_1.tables.Session, {
135
+ sessionId: sessionId,
136
+ session: JSON.stringify(session),
137
+ expires: session.cookie.expires,
138
+ userEmail: (_c = session.passport) === null || _c === void 0 ? void 0 : _c.user
139
+ })];
140
+ case 4:
141
+ _d.sent();
142
+ return [3 /*break*/, 6];
143
+ case 5:
144
+ error_1 = _d.sent();
145
+ // race condition on insert
146
+ console.error('Failed to create session', error_1);
147
+ return [3 /*break*/, 6];
148
+ case 6:
149
+ if (cb)
150
+ cb();
151
+ return [2 /*return*/];
152
+ }
153
+ });
154
+ });
155
+ };
156
+ DbSessionStore.prototype.sweep = function () {
157
+ return __awaiter(this, void 0, void 0, function () {
158
+ var qb, deleteCount;
159
+ return __generator(this, function (_a) {
160
+ switch (_a.label) {
161
+ case 0: return [4 /*yield*/, (0, db_1.getSystemDb)().tableExists(user_1.tables.Session)];
162
+ case 1:
163
+ if (!(_a.sent()))
164
+ return [2 /*return*/];
165
+ console.info("Sweeping expired sessions");
166
+ qb = new db_1.QueryBuilderFactory().getQueryBuilder(user_1.tables.Session)
167
+ .condition({ field: 'expires', operator: '<=', value: new Date() });
168
+ return [4 /*yield*/, (0, db_1.getSystemDb)().delete(user_1.tables.Session, qb)];
169
+ case 2:
170
+ deleteCount = _a.sent();
171
+ console.info("Swept ".concat(deleteCount, " expired sessions"));
172
+ return [2 /*return*/];
173
+ }
174
+ });
175
+ });
176
+ };
177
+ DbSessionStore.TWELVE_HOURS = 1000 * 60 * 60 * 12;
178
+ return DbSessionStore;
179
+ }(express_session_1.Store));
180
+ exports.DbSessionStore = DbSessionStore;
181
+ //# sourceMappingURL=DbSessionStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DbSessionStore.js","sourceRoot":"","sources":["../../../src/authentication/DbSessionStore.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,12 @@
1
+ export declare class DefaultAdminCredentials {
2
+ private static CREDENTIALS;
3
+ static setCredentials(credentials: {
4
+ username: string;
5
+ password: string;
6
+ }): void;
7
+ static getCredentials(): {
8
+ username: string;
9
+ password: string;
10
+ } | undefined;
11
+ }
12
+ //# sourceMappingURL=DefaultAdminCredentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultAdminCredentials.d.ts","sourceRoot":"","sources":["../../../src/authentication/DefaultAdminCredentials.ts"],"names":[],"mappings":"AAAA,qBAAa,uBAAuB;IAChC,OAAO,CAAC,MAAM,CAAC,WAAW,CAAqD;IAE/E,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE;IAQzE,MAAM,CAAC,cAAc;;;;CAGxB"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultAdminCredentials = void 0;
4
+ var DefaultAdminCredentials = /** @class */ (function () {
5
+ function DefaultAdminCredentials() {
6
+ }
7
+ DefaultAdminCredentials.setCredentials = function (credentials) {
8
+ if (DefaultAdminCredentials.CREDENTIALS)
9
+ return;
10
+ DefaultAdminCredentials.CREDENTIALS = credentials;
11
+ };
12
+ DefaultAdminCredentials.getCredentials = function () {
13
+ return DefaultAdminCredentials.CREDENTIALS;
14
+ };
15
+ return DefaultAdminCredentials;
16
+ }());
17
+ exports.DefaultAdminCredentials = DefaultAdminCredentials;
18
+ //# sourceMappingURL=DefaultAdminCredentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultAdminCredentials.js","sourceRoot":"","sources":["../../../src/authentication/DefaultAdminCredentials.ts"],"names":[],"mappings":";;;AAAA;IAAA;IAcA,CAAC;IAXU,sCAAc,GAArB,UAAsB,WAAmD;QACrE,IAAI,uBAAuB,CAAC,WAAW;YACnC,OAAO;QAEX,uBAAuB,CAAC,WAAW,GAAG,WAAW,CAAC;IACtD,CAAC;IAGM,sCAAc,GAArB;QACI,OAAO,uBAAuB,CAAC,WAAW,CAAC;IAC/C,CAAC;IACL,8BAAC;AAAD,CAAC,AAdD,IAcC;AAdY,0DAAuB"}
@@ -0,0 +1,6 @@
1
+ export declare function createAuthentication(defaultAdminCredentials?: {
2
+ username: string;
3
+ password: string;
4
+ }): typeof authenticate;
5
+ export declare function authenticate(email: string, password: string): Promise<true | string>;
6
+ //# sourceMappingURL=authenticate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authenticate.d.ts","sourceRoot":"","sources":["../../../src/authentication/authenticate.ts"],"names":[],"mappings":"AAKA,wBAAgB,oBAAoB,CAAC,uBAAuB,CAAC,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,uBAKpG;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAC,MAAM,CAAC,CAexF"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.authenticate = exports.createAuthentication = void 0;
43
+ var sha256_1 = __importDefault(require("crypto-js/sha256"));
44
+ var db_1 = require("@proteinjs/db");
45
+ var user_1 = require("@proteinjs/user");
46
+ var DefaultAdminCredentials_1 = require("./DefaultAdminCredentials");
47
+ function createAuthentication(defaultAdminCredentials) {
48
+ if (defaultAdminCredentials)
49
+ DefaultAdminCredentials_1.DefaultAdminCredentials.setCredentials(defaultAdminCredentials);
50
+ return authenticate;
51
+ }
52
+ exports.createAuthentication = createAuthentication;
53
+ function authenticate(email, password) {
54
+ return __awaiter(this, void 0, void 0, function () {
55
+ var defaultAdminCredentials, users;
56
+ return __generator(this, function (_a) {
57
+ switch (_a.label) {
58
+ case 0:
59
+ defaultAdminCredentials = DefaultAdminCredentials_1.DefaultAdminCredentials.getCredentials();
60
+ if (defaultAdminCredentials && defaultAdminCredentials.username == email && defaultAdminCredentials.password == password) {
61
+ console.info('Authenitcated default admin user');
62
+ return [2 /*return*/, true];
63
+ }
64
+ return [4 /*yield*/, (0, db_1.getSystemDb)().query(user_1.tables.User, {
65
+ email: email,
66
+ password: (0, sha256_1.default)(password).toString()
67
+ })];
68
+ case 1:
69
+ users = _a.sent();
70
+ if (users.length < 1)
71
+ return [2 /*return*/, 'User name or password incorrect'];
72
+ return [2 /*return*/, true];
73
+ }
74
+ });
75
+ });
76
+ }
77
+ exports.authenticate = authenticate;
78
+ ;
79
+ //# sourceMappingURL=authenticate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../../../src/authentication/authenticate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAsC;AACtC,oCAA4C;AAC5C,wCAAyC;AACzC,qEAAoE;AAEpE,SAAgB,oBAAoB,CAAC,uBAAgE;IACjG,IAAI,uBAAuB;QACvB,iDAAuB,CAAC,cAAc,CAAC,uBAAuB,CAAC,CAAC;IAEpE,OAAO,YAAY,CAAC;AACxB,CAAC;AALD,oDAKC;AAED,SAAsB,YAAY,CAAC,KAAa,EAAE,QAAgB;;;;;;oBACxD,uBAAuB,GAAG,iDAAuB,CAAC,cAAc,EAAE,CAAC;oBACzE,IAAI,uBAAuB,IAAI,uBAAuB,CAAC,QAAQ,IAAI,KAAK,IAAI,uBAAuB,CAAC,QAAQ,IAAI,QAAQ,EAAE;wBACtH,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;wBACjD,sBAAO,IAAI,EAAC;qBACf;oBAEa,qBAAM,IAAA,gBAAW,GAAE,CAAC,KAAK,CAAC,aAAM,CAAC,IAAI,EAAE;4BACjD,KAAK,OAAA;4BACL,QAAQ,EAAE,IAAA,gBAAM,EAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE;yBACxC,CAAC,EAAA;;oBAHI,KAAK,GAAG,SAGZ;oBACF,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;wBAChB,sBAAO,iCAAiC,EAAC;oBAE7C,sBAAO,IAAI,EAAC;;;;CACf;AAfD,oCAeC;AAAA,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function destroySession(sessionId?: string): Promise<void>;
2
+ //# sourceMappingURL=destroySession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destroySession.d.ts","sourceRoot":"","sources":["../../../src/authentication/destroySession.ts"],"names":[],"mappings":"AAGA,wBAAsB,cAAc,CAAC,SAAS,CAAC,EAAE,MAAM,iBAKtD"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.destroySession = void 0;
40
+ var db_1 = require("@proteinjs/db");
41
+ var user_1 = require("@proteinjs/user");
42
+ function destroySession(sessionId) {
43
+ return __awaiter(this, void 0, void 0, function () {
44
+ return __generator(this, function (_a) {
45
+ switch (_a.label) {
46
+ case 0:
47
+ if (!sessionId)
48
+ return [2 /*return*/];
49
+ return [4 /*yield*/, (0, db_1.getSystemDb)().delete(user_1.tables.Session, { sessionId: sessionId })];
50
+ case 1:
51
+ _a.sent();
52
+ return [2 /*return*/];
53
+ }
54
+ });
55
+ });
56
+ }
57
+ exports.destroySession = destroySession;
58
+ //# sourceMappingURL=destroySession.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destroySession.js","sourceRoot":"","sources":["../../../src/authentication/destroySession.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAA4C;AAC5C,wCAAyC;AAEzC,SAAsB,cAAc,CAAC,SAAkB;;;;;oBACnD,IAAI,CAAC,SAAS;wBACV,sBAAO;oBAEX,qBAAM,IAAA,gBAAW,GAAE,CAAC,MAAM,CAAC,aAAM,CAAC,OAAO,EAAE,EAAE,SAAS,WAAA,EAAE,CAAC,EAAA;;oBAAzD,SAAyD,CAAC;;;;;CAC7D;AALD,wCAKC"}
@@ -0,0 +1,4 @@
1
+ import { SessionDataCache } from '@proteinjs/server-api';
2
+ import { User } from '@proteinjs/user';
3
+ export declare const userCache: SessionDataCache<User>;
4
+ //# sourceMappingURL=userCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userCache.d.ts","sourceRoot":"","sources":["../../../src/authorization/userCache.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,IAAI,EAA6C,MAAM,iBAAiB,CAAC;AAGlF,eAAO,MAAM,SAAS,EAAE,gBAAgB,CAAC,IAAI,CAgB5C,CAAA"}