@proteinjs/user-server 1.0.10 → 1.0.12
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/.eslintrc.js +20 -0
- package/.prettierignore +3 -0
- package/.prettierrc +8 -0
- package/CHANGELOG.md +8 -2
- package/dist/src/authentication/DbSessionStore.d.ts.map +1 -1
- package/dist/src/authentication/DbSessionStore.js +11 -6
- package/dist/src/authentication/DbSessionStore.js.map +1 -1
- package/dist/src/authentication/DefaultAdminCredentials.d.ts.map +1 -1
- package/dist/src/authentication/DefaultAdminCredentials.js +2 -1
- package/dist/src/authentication/DefaultAdminCredentials.js.map +1 -1
- package/dist/src/authentication/authenticate.d.ts.map +1 -1
- package/dist/src/authentication/authenticate.js +8 -5
- package/dist/src/authentication/authenticate.js.map +1 -1
- package/dist/src/authentication/destroySession.d.ts.map +1 -1
- package/dist/src/authentication/destroySession.js +2 -1
- package/dist/src/authentication/destroySession.js.map +1 -1
- package/dist/src/authorization/userCache.d.ts.map +1 -1
- package/dist/src/authorization/userCache.js +11 -2
- package/dist/src/authorization/userCache.js.map +1 -1
- package/dist/src/routes/createUser.d.ts.map +1 -1
- package/dist/src/routes/createUser.js +1 -1
- package/dist/src/routes/createUser.js.map +1 -1
- package/dist/src/routes/login.d.ts.map +1 -1
- package/dist/src/routes/login.js +1 -1
- package/dist/src/routes/login.js.map +1 -1
- package/dist/src/routes/logout.d.ts.map +1 -1
- package/dist/src/routes/logout.js +1 -1
- package/dist/src/routes/logout.js.map +1 -1
- package/generated/index.ts +8 -11
- package/index.ts +1 -1
- package/jest.config.js +8 -17
- package/package.json +46 -41
- package/src/authentication/DbSessionStore.ts +85 -77
- package/src/authentication/DefaultAdminCredentials.ts +10 -10
- package/src/authentication/authenticate.ts +24 -18
- package/src/authentication/destroySession.ts +5 -4
- package/src/authorization/userCache.ts +24 -15
- package/src/routes/createUser.ts +24 -24
- package/src/routes/login.ts +22 -22
- package/src/routes/logout.ts +22 -22
- package/tsconfig.json +17 -17
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended', 'prettier'],
|
|
3
|
+
parser: '@typescript-eslint/parser',
|
|
4
|
+
plugins: ['@typescript-eslint', 'prettier'],
|
|
5
|
+
root: true,
|
|
6
|
+
ignorePatterns: ['**/dist/*', '**/node_modules/*'],
|
|
7
|
+
|
|
8
|
+
rules: {
|
|
9
|
+
'prettier/prettier': ['warn'],
|
|
10
|
+
curly: ['warn'],
|
|
11
|
+
'eol-last': ['warn', 'always'],
|
|
12
|
+
'keyword-spacing': ['warn', { before: true }],
|
|
13
|
+
'no-undef': 'off',
|
|
14
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
15
|
+
'@typescript-eslint/no-var-requires': 'off',
|
|
16
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
17
|
+
'@typescript-eslint/prefer-as-const': 'off',
|
|
18
|
+
'@typescript-eslint/ban-types': 'off',
|
|
19
|
+
},
|
|
20
|
+
};
|
package/.prettierignore
ADDED
package/.prettierrc
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -3,16 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [1.0.
|
|
6
|
+
## [1.0.12](https://github.com/proteinjs/user/compare/@proteinjs/user-server@1.0.11...@proteinjs/user-server@1.0.12) (2024-05-10)
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
### Bug Fixes
|
|
10
10
|
|
|
11
|
-
*
|
|
11
|
+
* add linting and lint all files ([71defcd](https://github.com/proteinjs/user/commit/71defcd78dc479d2eef1f624c746c879f4e31daa))
|
|
12
|
+
|
|
13
|
+
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
|
|
17
|
+
## [1.0.10](https://github.com/proteinjs/user/compare/@proteinjs/user-server@1.0.9...@proteinjs/user-server@1.0.10) (2024-05-09)
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
15
20
|
|
|
21
|
+
- do not name a column the same name as a table ([1442a9f](https://github.com/proteinjs/user/commit/1442a9f665f88feafa8ccb83631ef2fb7d741f20))
|
|
16
22
|
|
|
17
23
|
## 1.0.1 (2024-04-19)
|
|
18
24
|
|
|
@@ -1 +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;
|
|
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;IACvC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAuB;;IAO3D,GAAG,cAAe,MAAM,cAAc,GAAG,YAAY,QAAQ,WAAW,GAAG,IAAI,KAAK,IAAI,UAUtF;IAEF,GAAG,cAAe,MAAM,WAAW,QAAQ,WAAW,iBAAgB,GAAG,KAAK,IAAI,uBAEhF;IAEF,KAAK,cAAe,MAAM,WAAW,QAAQ,WAAW,iBAAgB,GAAG,KAAK,IAAI,uBAElF;IAEF;;;OAGG;IACH,OAAO,cAAe,MAAM,iBAAgB,GAAG,KAAK,IAAI,uBAQtD;YAEY,cAAc;YA2Cd,KAAK;CAYpB"}
|
|
@@ -95,8 +95,9 @@ var DbSessionStore = /** @class */ (function (_super) {
|
|
|
95
95
|
case 0: return [4 /*yield*/, (0, destroySession_1.destroySession)(sessionId)];
|
|
96
96
|
case 1:
|
|
97
97
|
_a.sent();
|
|
98
|
-
if (cb)
|
|
98
|
+
if (cb) {
|
|
99
99
|
cb();
|
|
100
|
+
}
|
|
100
101
|
return [2 /*return*/];
|
|
101
102
|
}
|
|
102
103
|
});
|
|
@@ -114,8 +115,9 @@ var DbSessionStore = /** @class */ (function (_super) {
|
|
|
114
115
|
case 0:
|
|
115
116
|
// Only persist authenticated sessions
|
|
116
117
|
if (!((_a = session.passport) === null || _a === void 0 ? void 0 : _a.user)) {
|
|
117
|
-
if (cb)
|
|
118
|
+
if (cb) {
|
|
118
119
|
cb();
|
|
120
|
+
}
|
|
119
121
|
return [2 /*return*/];
|
|
120
122
|
}
|
|
121
123
|
return [4 /*yield*/, (0, db_1.getSystemDb)().get(user_1.tables.Session, { sessionId: sessionId })];
|
|
@@ -143,7 +145,7 @@ var DbSessionStore = /** @class */ (function (_super) {
|
|
|
143
145
|
sessionId: sessionId,
|
|
144
146
|
session: JSON.stringify(session),
|
|
145
147
|
expires: session.cookie.expires,
|
|
146
|
-
userEmail: (_c = session.passport) === null || _c === void 0 ? void 0 : _c.user
|
|
148
|
+
userEmail: (_c = session.passport) === null || _c === void 0 ? void 0 : _c.user,
|
|
147
149
|
})];
|
|
148
150
|
case 7:
|
|
149
151
|
_d.sent();
|
|
@@ -154,8 +156,9 @@ var DbSessionStore = /** @class */ (function (_super) {
|
|
|
154
156
|
console.error('Failed to create session', error_2);
|
|
155
157
|
return [3 /*break*/, 9];
|
|
156
158
|
case 9:
|
|
157
|
-
if (cb)
|
|
159
|
+
if (cb) {
|
|
158
160
|
cb();
|
|
161
|
+
}
|
|
159
162
|
return [2 /*return*/];
|
|
160
163
|
}
|
|
161
164
|
});
|
|
@@ -168,10 +171,12 @@ var DbSessionStore = /** @class */ (function (_super) {
|
|
|
168
171
|
switch (_a.label) {
|
|
169
172
|
case 0: return [4 /*yield*/, (0, db_1.getSystemDb)().tableExists(user_1.tables.Session)];
|
|
170
173
|
case 1:
|
|
171
|
-
if (!(_a.sent()))
|
|
174
|
+
if (!(_a.sent())) {
|
|
172
175
|
return [2 /*return*/];
|
|
176
|
+
}
|
|
173
177
|
console.info("Sweeping expired sessions");
|
|
174
|
-
qb = new db_1.QueryBuilderFactory()
|
|
178
|
+
qb = new db_1.QueryBuilderFactory()
|
|
179
|
+
.getQueryBuilder(user_1.tables.Session)
|
|
175
180
|
.condition({ field: 'expires', operator: '<=', value: new Date() });
|
|
176
181
|
return [4 /*yield*/, (0, db_1.getSystemDb)().delete(user_1.tables.Session, qb)];
|
|
177
182
|
case 2:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DbSessionStore.js","sourceRoot":"","sources":["../../../src/authentication/DbSessionStore.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAwC;AACxC,oCAAiE;AACjE,wCAAyC;AACzC,mDAAkD;AAElD;IAAoC,kCAAK;
|
|
1
|
+
{"version":3,"file":"DbSessionStore.js","sourceRoot":"","sources":["../../../src/authentication/DbSessionStore.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultAdminCredentials.d.ts","sourceRoot":"","sources":["../../../src/authentication/DefaultAdminCredentials.ts"],"names":[],"mappings":"AAAA,qBAAa,uBAAuB;
|
|
1
|
+
{"version":3,"file":"DefaultAdminCredentials.d.ts","sourceRoot":"","sources":["../../../src/authentication/DefaultAdminCredentials.ts"],"names":[],"mappings":"AAAA,qBAAa,uBAAuB;IAClC,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;;;;CAGtB"}
|
|
@@ -5,8 +5,9 @@ var DefaultAdminCredentials = /** @class */ (function () {
|
|
|
5
5
|
function DefaultAdminCredentials() {
|
|
6
6
|
}
|
|
7
7
|
DefaultAdminCredentials.setCredentials = function (credentials) {
|
|
8
|
-
if (DefaultAdminCredentials.CREDENTIALS)
|
|
8
|
+
if (DefaultAdminCredentials.CREDENTIALS) {
|
|
9
9
|
return;
|
|
10
|
+
}
|
|
10
11
|
DefaultAdminCredentials.CREDENTIALS = credentials;
|
|
11
12
|
};
|
|
12
13
|
DefaultAdminCredentials.getCredentials = function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultAdminCredentials.js","sourceRoot":"","sources":["../../../src/authentication/DefaultAdminCredentials.ts"],"names":[],"mappings":";;;AAAA;IAAA;IAcA,CAAC;
|
|
1
|
+
{"version":3,"file":"DefaultAdminCredentials.js","sourceRoot":"","sources":["../../../src/authentication/DefaultAdminCredentials.ts"],"names":[],"mappings":";;;AAAA;IAAA;IAcA,CAAC;IAXQ,sCAAc,GAArB,UAAsB,WAAmD;QACvE,IAAI,uBAAuB,CAAC,WAAW,EAAE;YACvC,OAAO;SACR;QAED,uBAAuB,CAAC,WAAW,GAAG,WAAW,CAAC;IACpD,CAAC;IAEM,sCAAc,GAArB;QACE,OAAO,uBAAuB,CAAC,WAAW,CAAC;IAC7C,CAAC;IACH,8BAAC;AAAD,CAAC,AAdD,IAcC;AAdY,0DAAuB"}
|
|
@@ -1 +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,
|
|
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,uBAMpG;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAoB1F"}
|
|
@@ -45,8 +45,9 @@ var db_1 = require("@proteinjs/db");
|
|
|
45
45
|
var user_1 = require("@proteinjs/user");
|
|
46
46
|
var DefaultAdminCredentials_1 = require("./DefaultAdminCredentials");
|
|
47
47
|
function createAuthentication(defaultAdminCredentials) {
|
|
48
|
-
if (defaultAdminCredentials)
|
|
48
|
+
if (defaultAdminCredentials) {
|
|
49
49
|
DefaultAdminCredentials_1.DefaultAdminCredentials.setCredentials(defaultAdminCredentials);
|
|
50
|
+
}
|
|
50
51
|
return authenticate;
|
|
51
52
|
}
|
|
52
53
|
exports.createAuthentication = createAuthentication;
|
|
@@ -57,23 +58,25 @@ function authenticate(email, password) {
|
|
|
57
58
|
switch (_a.label) {
|
|
58
59
|
case 0:
|
|
59
60
|
defaultAdminCredentials = DefaultAdminCredentials_1.DefaultAdminCredentials.getCredentials();
|
|
60
|
-
if (defaultAdminCredentials &&
|
|
61
|
+
if (defaultAdminCredentials &&
|
|
62
|
+
defaultAdminCredentials.username == email &&
|
|
63
|
+
defaultAdminCredentials.password == password) {
|
|
61
64
|
console.info('Authenitcated default admin user');
|
|
62
65
|
return [2 /*return*/, true];
|
|
63
66
|
}
|
|
64
67
|
return [4 /*yield*/, (0, db_1.getSystemDb)().query(user_1.tables.User, {
|
|
65
68
|
email: email,
|
|
66
|
-
password: (0, sha256_1.default)(password).toString()
|
|
69
|
+
password: (0, sha256_1.default)(password).toString(),
|
|
67
70
|
})];
|
|
68
71
|
case 1:
|
|
69
72
|
users = _a.sent();
|
|
70
|
-
if (users.length < 1)
|
|
73
|
+
if (users.length < 1) {
|
|
71
74
|
return [2 /*return*/, 'User name or password incorrect'];
|
|
75
|
+
}
|
|
72
76
|
return [2 /*return*/, true];
|
|
73
77
|
}
|
|
74
78
|
});
|
|
75
79
|
});
|
|
76
80
|
}
|
|
77
81
|
exports.authenticate = authenticate;
|
|
78
|
-
;
|
|
79
82
|
//# sourceMappingURL=authenticate.js.map
|
|
@@ -1 +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;
|
|
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;IACnG,IAAI,uBAAuB,EAAE;QAC3B,iDAAuB,CAAC,cAAc,CAAC,uBAAuB,CAAC,CAAC;KACjE;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAND,oDAMC;AAED,SAAsB,YAAY,CAAC,KAAa,EAAE,QAAgB;;;;;;oBAC1D,uBAAuB,GAAG,iDAAuB,CAAC,cAAc,EAAE,CAAC;oBACzE,IACE,uBAAuB;wBACvB,uBAAuB,CAAC,QAAQ,IAAI,KAAK;wBACzC,uBAAuB,CAAC,QAAQ,IAAI,QAAQ,EAC5C;wBACA,OAAO,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;wBACjD,sBAAO,IAAI,EAAC;qBACb;oBAEa,qBAAM,IAAA,gBAAW,GAAE,CAAC,KAAK,CAAC,aAAM,CAAC,IAAI,EAAE;4BACnD,KAAK,OAAA;4BACL,QAAQ,EAAE,IAAA,gBAAM,EAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE;yBACtC,CAAC,EAAA;;oBAHI,KAAK,GAAG,SAGZ;oBACF,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;wBACpB,sBAAO,iCAAiC,EAAC;qBAC1C;oBAED,sBAAO,IAAI,EAAC;;;;CACb;AApBD,oCAoBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"destroySession.d.ts","sourceRoot":"","sources":["../../../src/authentication/destroySession.ts"],"names":[],"mappings":"AAGA,wBAAsB,cAAc,CAAC,SAAS,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"destroySession.d.ts","sourceRoot":"","sources":["../../../src/authentication/destroySession.ts"],"names":[],"mappings":"AAGA,wBAAsB,cAAc,CAAC,SAAS,CAAC,EAAE,MAAM,iBAMtD"}
|
|
@@ -44,8 +44,9 @@ function destroySession(sessionId) {
|
|
|
44
44
|
return __generator(this, function (_a) {
|
|
45
45
|
switch (_a.label) {
|
|
46
46
|
case 0:
|
|
47
|
-
if (!sessionId)
|
|
47
|
+
if (!sessionId) {
|
|
48
48
|
return [2 /*return*/];
|
|
49
|
+
}
|
|
49
50
|
return [4 /*yield*/, (0, db_1.getSystemDb)().delete(user_1.tables.Session, { sessionId: sessionId })];
|
|
50
51
|
case 1:
|
|
51
52
|
_a.sent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"destroySession.js","sourceRoot":"","sources":["../../../src/authentication/destroySession.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAA4C;AAC5C,wCAAyC;AAEzC,SAAsB,cAAc,CAAC,SAAkB;;;;;
|
|
1
|
+
{"version":3,"file":"destroySession.js","sourceRoot":"","sources":["../../../src/authentication/destroySession.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAA4C;AAC5C,wCAAyC;AAEzC,SAAsB,cAAc,CAAC,SAAkB;;;;;oBACrD,IAAI,CAAC,SAAS,EAAE;wBACd,sBAAO;qBACR;oBAED,qBAAM,IAAA,gBAAW,GAAE,CAAC,MAAM,CAAC,aAAM,CAAC,OAAO,EAAE,EAAE,SAAS,WAAA,EAAE,CAAC,EAAA;;oBAAzD,SAAyD,CAAC;;;;;CAC3D;AAND,wCAMC"}
|
|
@@ -1 +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,
|
|
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,CAyB5C,CAAC"}
|
|
@@ -55,7 +55,16 @@ exports.userCache = {
|
|
|
55
55
|
if (!userEmail) return [3 /*break*/, 3];
|
|
56
56
|
adminCredentials = DefaultAdminCredentials_1.DefaultAdminCredentials.getCredentials();
|
|
57
57
|
if (!(adminCredentials && userEmail == adminCredentials.username)) return [3 /*break*/, 1];
|
|
58
|
-
adminUser = {
|
|
58
|
+
adminUser = {
|
|
59
|
+
name: 'Admin',
|
|
60
|
+
email: adminCredentials.username,
|
|
61
|
+
password: adminCredentials.password,
|
|
62
|
+
emailVerified: true,
|
|
63
|
+
roles: 'admin',
|
|
64
|
+
created: (0, moment_1.default)(),
|
|
65
|
+
updated: (0, moment_1.default)(),
|
|
66
|
+
id: 'admin',
|
|
67
|
+
};
|
|
59
68
|
user = adminUser;
|
|
60
69
|
return [3 /*break*/, 3];
|
|
61
70
|
case 1: return [4 /*yield*/, (0, db_1.getSystemDb)().get(user_1.tables.User, { email: userEmail })];
|
|
@@ -65,6 +74,6 @@ exports.userCache = {
|
|
|
65
74
|
case 3: return [2 /*return*/, user];
|
|
66
75
|
}
|
|
67
76
|
});
|
|
68
|
-
}); }
|
|
77
|
+
}); },
|
|
69
78
|
};
|
|
70
79
|
//# sourceMappingURL=userCache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userCache.js","sourceRoot":"","sources":["../../../src/authorization/userCache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA4B;AAE5B,oCAA4C;AAC5C,wCAAkF;AAClF,qFAAoF;AAEvE,QAAA,SAAS,GAA2B;
|
|
1
|
+
{"version":3,"file":"userCache.js","sourceRoot":"","sources":["../../../src/authorization/userCache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA4B;AAE5B,oCAA4C;AAC5C,wCAAkF;AAClF,qFAAoF;AAEvE,QAAA,SAAS,GAA2B;IAC/C,GAAG,EAAE,6BAAsB;IAC3B,MAAM,EAAE,UAAO,SAAiB,EAAE,SAAiB;;;;;oBAC7C,IAAI,GAAG,gBAAS,CAAC;yBACjB,SAAS,EAAT,wBAAS;oBACL,gBAAgB,GAAG,iDAAuB,CAAC,cAAc,EAAE,CAAC;yBAC9D,CAAA,gBAAgB,IAAI,SAAS,IAAI,gBAAgB,CAAC,QAAQ,CAAA,EAA1D,wBAA0D;oBACtD,SAAS,GAAS;wBACtB,IAAI,EAAE,OAAO;wBACb,KAAK,EAAE,gBAAgB,CAAC,QAAQ;wBAChC,QAAQ,EAAE,gBAAgB,CAAC,QAAQ;wBACnC,aAAa,EAAE,IAAI;wBACnB,KAAK,EAAE,OAAO;wBACd,OAAO,EAAE,IAAA,gBAAM,GAAE;wBACjB,OAAO,EAAE,IAAA,gBAAM,GAAE;wBACjB,EAAE,EAAE,OAAO;qBACZ,CAAC;oBACF,IAAI,GAAG,SAAS,CAAC;;wBAEV,qBAAM,IAAA,gBAAW,GAAE,CAAC,GAAG,CAAC,aAAM,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,EAAA;;oBAAjE,IAAI,GAAG,SAA0D,CAAC;;wBAItE,sBAAO,IAAI,EAAC;;;SACb;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUser.d.ts","sourceRoot":"","sources":["../../../src/routes/createUser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAK9C,eAAO,MAAM,UAAU,EAAE,KAyBxB,
|
|
1
|
+
{"version":3,"file":"createUser.d.ts","sourceRoot":"","sources":["../../../src/routes/createUser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAK9C,eAAO,MAAM,UAAU,EAAE,KAyBxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUser.js","sourceRoot":"","sources":["../../../src/routes/createUser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAsC;AAEtC,oCAA4C;AAC5C,wCAAuD;AACvD,wCAAyC;AAE5B,QAAA,UAAU,GAAU;
|
|
1
|
+
{"version":3,"file":"createUser.js","sourceRoot":"","sources":["../../../src/routes/createUser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAsC;AAEtC,oCAA4C;AAC5C,wCAAuD;AACvD,wCAAyC;AAE5B,QAAA,UAAU,GAAU;IAC/B,IAAI,EAAE,aAAM,CAAC,UAAU,CAAC,IAAI;IAC5B,MAAM,EAAE,aAAM,CAAC,UAAU,CAAC,MAAM;IAChC,SAAS,EAAE,UAAO,OAAO,EAAE,QAAQ;;;;;oBAC3B,MAAM,GAAG,IAAI,aAAM,CAAC,YAAY,CAAC,CAAC;oBAClC,IAAI,GAAG,OAAO,CAAC,IAAY,CAAC;oBAC5B,EAAE,GAAG,IAAA,gBAAW,GAAE,CAAC;oBACN,qBAAM,EAAE,CAAC,GAAG,CAAC,aAAM,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,EAAA;;oBAA7D,UAAU,GAAG,SAAgD;oBACnE,IAAI,UAAU,EAAE;wBACR,KAAK,GAAG,qCAAqC,CAAC;wBACpD,OAAO,CAAC,KAAK,CAAC,UAAG,KAAK,eAAK,IAAI,CAAC,KAAK,CAAE,CAAC,CAAC;wBACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC;wBACzB,sBAAO;qBACR;oBAED,qBAAM,EAAE,CAAC,MAAM,CAAC,aAAM,CAAC,IAAI,EAAE;4BAC3B,IAAI,EAAE,IAAI,CAAC,IAAI;4BACf,KAAK,EAAE,IAAI,CAAC,KAAK;4BACjB,QAAQ,EAAE,IAAA,gBAAM,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE;4BAC1C,aAAa,EAAE,KAAK;4BACpB,KAAK,EAAE,EAAE;yBACV,CAAC,EAAA;;oBANF,SAME,CAAC;oBACH,MAAM,CAAC,IAAI,CAAC,wBAAiB,IAAI,CAAC,KAAK,CAAE,CAAC,CAAC;oBAC3C,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;;;;SACnB;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/routes/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAI9C,eAAO,MAAM,KAAK,EAAE,KAwBnB,
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/routes/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAI9C,eAAO,MAAM,KAAK,EAAE,KAwBnB,CAAC"}
|
package/dist/src/routes/login.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/routes/login.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wCAAyC;AACzC,+DAA8D;AAEjD,QAAA,KAAK,GAAU;
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/routes/login.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wCAAyC;AACzC,+DAA8D;AAEjD,QAAA,KAAK,GAAU;IAC1B,IAAI,EAAE,aAAM,CAAC,KAAK,CAAC,IAAI;IACvB,MAAM,EAAE,aAAM,CAAC,KAAK,CAAC,MAAM;IAC3B,SAAS,EAAE,UAAO,OAAY,EAAE,QAAQ;;;;;oBAChC,WAAW,GAAwC,OAAO,CAAC,IAAI,CAAC;oBACtE,IAAI,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE;wBACzC,KAAK,GAAG,oCAAoC,CAAC;wBACnD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;wBACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC;wBACzB,sBAAO;qBACR;oBAEc,qBAAM,IAAA,2BAAY,EAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAA;;oBAApE,MAAM,GAAG,SAA2D;oBAC1E,IAAI,MAAM,KAAK,IAAI,EAAE;wBACnB,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;wBACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;wBACjC,sBAAO;qBACR;oBAED,qBAAM,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;4BAChC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;wBAC5C,CAAC,CAAC,EAAA;;oBAFF,SAEE,CAAC;oBACH,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;;;;SACnB;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/routes/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAI9C,eAAO,MAAM,MAAM,EAAE,KAuBpB,
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/routes/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAI9C,eAAO,MAAM,MAAM,EAAE,KAuBpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/routes/logout.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wCAAyC;AACzC,mEAAkE;AAErD,QAAA,MAAM,GAAU;
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/routes/logout.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wCAAyC;AACzC,mEAAkE;AAErD,QAAA,MAAM,GAAU;IAC3B,IAAI,EAAE,aAAM,CAAC,MAAM,CAAC,IAAI;IACxB,MAAM,EAAE,aAAM,CAAC,MAAM,CAAC,MAAM;IAC5B,SAAS,EAAE,UAAO,OAAY,EAAE,QAAQ;;;;gBACtC,oBAAoB;gBACpB,mCAAmC;gBACnC,2CAA2C;gBAC3C,iDAAiD;gBACjD,uBAAuB;gBACvB,6BAA6B;gBAC7B,sBAAsB;gBACtB,YAAY;gBAEZ,qBAAqB;gBACrB,UAAU;gBACV,MAAM;gBACN,2CAA2C;gBAC3C,2DAA2D;gBAC3D,+DAA+D;gBAC/D,qBAAM,IAAA,+BAAc,EAAC,OAAO,CAAC,SAAS,CAAC,EAAA;;oBAfvC,oBAAoB;oBACpB,mCAAmC;oBACnC,2CAA2C;oBAC3C,iDAAiD;oBACjD,uBAAuB;oBACvB,6BAA6B;oBAC7B,sBAAsB;oBACtB,YAAY;oBAEZ,qBAAqB;oBACrB,UAAU;oBACV,MAAM;oBACN,2CAA2C;oBAC3C,2DAA2D;oBAC3D,+DAA+D;oBAC/D,SAAuC,CAAC;oBACxC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC;oBACrC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;;;SAC7B;CACF,CAAC"}
|
package/generated/index.ts
CHANGED
|
@@ -9,11 +9,10 @@ import 'crypto-js';
|
|
|
9
9
|
import 'express-session';
|
|
10
10
|
import 'moment';
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
/** Generate Source Graph */
|
|
14
13
|
|
|
15
|
-
const sourceGraph =
|
|
16
|
-
|
|
14
|
+
const sourceGraph =
|
|
15
|
+
'{"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"}]}';
|
|
17
16
|
|
|
18
17
|
/** Generate Source Links */
|
|
19
18
|
|
|
@@ -24,18 +23,16 @@ import { login } from '../src/routes/login';
|
|
|
24
23
|
import { logout } from '../src/routes/logout';
|
|
25
24
|
|
|
26
25
|
const sourceLinks = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
'@proteinjs/user-server/DbSessionStore': DbSessionStore,
|
|
27
|
+
'@proteinjs/user-server/userCache': userCache,
|
|
28
|
+
'@proteinjs/user-server/createUser': createUser,
|
|
29
|
+
'@proteinjs/user-server/login': login,
|
|
30
|
+
'@proteinjs/user-server/logout': logout,
|
|
32
31
|
};
|
|
33
32
|
|
|
34
|
-
|
|
35
33
|
/** Load Source Graph and Links */
|
|
36
34
|
|
|
37
35
|
import { SourceRepository } from '@proteinjs/reflection';
|
|
38
36
|
SourceRepository.merge(sourceGraph, sourceLinks);
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
export * from '../index';
|
|
38
|
+
export * from '../index';
|
package/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { createAuthentication } from './src/authentication/authenticate';
|
|
2
|
-
export * from './src/authentication/DbSessionStore';
|
|
2
|
+
export * from './src/authentication/DbSessionStore';
|
package/jest.config.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"ts",
|
|
11
|
-
"tsx",
|
|
12
|
-
"js",
|
|
13
|
-
"jsx",
|
|
14
|
-
"json",
|
|
15
|
-
"node"
|
|
16
|
-
],
|
|
17
|
-
"testEnvironment": "node"
|
|
18
|
-
}
|
|
2
|
+
roots: ['<rootDir>/test'],
|
|
3
|
+
transform: {
|
|
4
|
+
'^.+\\.tsx?$': 'ts-jest',
|
|
5
|
+
},
|
|
6
|
+
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
|
|
7
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
|
|
8
|
+
testEnvironment: 'node',
|
|
9
|
+
};
|
package/package.json
CHANGED
|
@@ -1,43 +1,48 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
2
|
+
"name": "@proteinjs/user-server",
|
|
3
|
+
"version": "1.0.12",
|
|
4
|
+
"description": "User server components",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/proteinjs/user.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/proteinjs/user/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/proteinjs/user#readme",
|
|
16
|
+
"author": "Brent Bahry",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"clean": "rm -rf dist/ generated/ node_modules/",
|
|
20
|
+
"build": "reflection-build && tsc",
|
|
21
|
+
"watch": "reflection-watch"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@proteinjs/db": "1.0.15",
|
|
25
|
+
"@proteinjs/reflection": "1.1.1",
|
|
26
|
+
"@proteinjs/server-api": "1.1.1",
|
|
27
|
+
"@proteinjs/user": "^1.0.13",
|
|
28
|
+
"@proteinjs/util": "1.1.0",
|
|
29
|
+
"crypto-js": "4.0.0",
|
|
30
|
+
"express-session": "1.17.1",
|
|
31
|
+
"moment": "2.29.4"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@proteinjs/reflection-build": "1.0.16",
|
|
35
|
+
"@types/crypto-js": "4.0.1",
|
|
36
|
+
"@types/express-session": "1.17.0",
|
|
37
|
+
"@types/node": "14.0.13",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "7.8.0",
|
|
39
|
+
"@typescript-eslint/parser": "7.8.0",
|
|
40
|
+
"eslint": "8.57.0",
|
|
41
|
+
"eslint-config-prettier": "9.1.0",
|
|
42
|
+
"eslint-plugin-prettier": "5.1.3",
|
|
43
|
+
"typescript": "5.2.2"
|
|
44
|
+
},
|
|
45
|
+
"main": "./dist/generated/index.js",
|
|
46
|
+
"types": "./dist/generated/index.d.ts",
|
|
47
|
+
"gitHead": "2fd5a5ee7f68e33bf8b6ba045fd5bbd043b36e3b"
|
|
43
48
|
}
|
|
@@ -4,92 +4,100 @@ import { tables } from '@proteinjs/user';
|
|
|
4
4
|
import { destroySession } from './destroySession';
|
|
5
5
|
|
|
6
6
|
export class DbSessionStore extends Store {
|
|
7
|
-
|
|
7
|
+
private static readonly TWELVE_HOURS = 1000 * 60 * 60 * 12;
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
setInterval(this.sweep, DbSessionStore.TWELVE_HOURS);
|
|
12
|
+
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
get = (sessionId: string, cb: (error: any, session?: Express.SessionData | null) => void) => {
|
|
15
|
+
(async () => {
|
|
16
|
+
const result = await getSystemDb().get(tables.Session, { sessionId });
|
|
17
|
+
if (!result) {
|
|
18
|
+
cb(null);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
return cb(null, JSON.parse(result.session));
|
|
23
|
+
})();
|
|
24
|
+
};
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
set = (sessionId: string, session: Express.SessionData, cb?: (error?: any) => void) => {
|
|
27
|
+
this.insertOrUpdate(sessionId, session, cb);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
touch = (sessionId: string, session: Express.SessionData, cb?: (error?: any) => void) => {
|
|
31
|
+
this.insertOrUpdate(sessionId, session, cb);
|
|
32
|
+
};
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Does not get called since request.logout is broken
|
|
36
|
+
* See logout.ts
|
|
37
|
+
*/
|
|
38
|
+
destroy = (sessionId: string, cb?: (error?: any) => void) => {
|
|
39
|
+
// console.info('in destroy');
|
|
40
|
+
(async () => {
|
|
41
|
+
await destroySession(sessionId);
|
|
42
|
+
if (cb) {
|
|
43
|
+
cb();
|
|
44
|
+
}
|
|
45
|
+
})();
|
|
46
|
+
};
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
private async insertOrUpdate(
|
|
49
|
+
sessionId: string,
|
|
50
|
+
session: Express.SessionData,
|
|
51
|
+
cb?: (error?: any) => void
|
|
52
|
+
): Promise<void> {
|
|
53
|
+
// Only persist authenticated sessions
|
|
54
|
+
if (!session.passport?.user) {
|
|
55
|
+
if (cb) {
|
|
56
|
+
cb();
|
|
57
|
+
}
|
|
52
58
|
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
55
61
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
62
|
+
const sessionRecord = await getSystemDb().get(tables.Session, { sessionId });
|
|
63
|
+
if (sessionRecord) {
|
|
64
|
+
try {
|
|
65
|
+
sessionRecord.session = JSON.stringify(session);
|
|
66
|
+
sessionRecord.expires = <Date>session.cookie.expires;
|
|
67
|
+
sessionRecord.userEmail = session.passport?.user;
|
|
68
|
+
await getSystemDb().update(tables.Session, sessionRecord, { sessionId });
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error('Failed to update session', error);
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
try {
|
|
74
|
+
await getSystemDb().insert(tables.Session, {
|
|
75
|
+
sessionId,
|
|
76
|
+
session: JSON.stringify(session),
|
|
77
|
+
expires: <Date>session.cookie.expires,
|
|
78
|
+
userEmail: session.passport?.user,
|
|
79
|
+
});
|
|
80
|
+
} catch (error) {
|
|
81
|
+
// race condition on insert
|
|
82
|
+
console.error('Failed to create session', error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
79
85
|
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
if (cb) {
|
|
87
|
+
cb();
|
|
82
88
|
}
|
|
89
|
+
}
|
|
83
90
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
private async sweep(): Promise<void> {
|
|
92
|
+
if (!(await getSystemDb().tableExists(tables.Session))) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
87
95
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
+
console.info(`Sweeping expired sessions`);
|
|
97
|
+
const qb = new QueryBuilderFactory()
|
|
98
|
+
.getQueryBuilder(tables.Session)
|
|
99
|
+
.condition({ field: 'expires', operator: '<=', value: new Date() });
|
|
100
|
+
const deleteCount = await getSystemDb().delete(tables.Session, qb);
|
|
101
|
+
console.info(`Swept ${deleteCount} expired sessions`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export class DefaultAdminCredentials {
|
|
2
|
-
|
|
2
|
+
private static CREDENTIALS: { username: string; password: string } | undefined;
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
DefaultAdminCredentials.CREDENTIALS = credentials;
|
|
4
|
+
static setCredentials(credentials: { username: string; password: string }) {
|
|
5
|
+
if (DefaultAdminCredentials.CREDENTIALS) {
|
|
6
|
+
return;
|
|
9
7
|
}
|
|
10
8
|
|
|
9
|
+
DefaultAdminCredentials.CREDENTIALS = credentials;
|
|
10
|
+
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
12
|
+
static getCredentials() {
|
|
13
|
+
return DefaultAdminCredentials.CREDENTIALS;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -3,26 +3,32 @@ import { getSystemDb } from '@proteinjs/db';
|
|
|
3
3
|
import { tables } from '@proteinjs/user';
|
|
4
4
|
import { DefaultAdminCredentials } from './DefaultAdminCredentials';
|
|
5
5
|
|
|
6
|
-
export function createAuthentication(defaultAdminCredentials?: { username: string
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export function createAuthentication(defaultAdminCredentials?: { username: string; password: string }) {
|
|
7
|
+
if (defaultAdminCredentials) {
|
|
8
|
+
DefaultAdminCredentials.setCredentials(defaultAdminCredentials);
|
|
9
|
+
}
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
return authenticate;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
export async function authenticate(email: string, password: string): Promise<true|string> {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
export async function authenticate(email: string, password: string): Promise<true | string> {
|
|
15
|
+
const defaultAdminCredentials = DefaultAdminCredentials.getCredentials();
|
|
16
|
+
if (
|
|
17
|
+
defaultAdminCredentials &&
|
|
18
|
+
defaultAdminCredentials.username == email &&
|
|
19
|
+
defaultAdminCredentials.password == password
|
|
20
|
+
) {
|
|
21
|
+
console.info('Authenitcated default admin user');
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
19
24
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const users = await getSystemDb().query(tables.User, {
|
|
26
|
+
email,
|
|
27
|
+
password: sha256(password).toString(),
|
|
28
|
+
});
|
|
29
|
+
if (users.length < 1) {
|
|
30
|
+
return 'User name or password incorrect';
|
|
31
|
+
}
|
|
26
32
|
|
|
27
|
-
|
|
28
|
-
}
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
@@ -2,8 +2,9 @@ import { getSystemDb } from '@proteinjs/db';
|
|
|
2
2
|
import { tables } from '@proteinjs/user';
|
|
3
3
|
|
|
4
4
|
export async function destroySession(sessionId?: string) {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
if (!sessionId) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
}
|
|
9
|
+
await getSystemDb().delete(tables.Session, { sessionId });
|
|
10
|
+
}
|
|
@@ -5,19 +5,28 @@ import { User, tables, guestUser, USER_SESSION_CACHE_KEY } from '@proteinjs/user
|
|
|
5
5
|
import { DefaultAdminCredentials } from '../authentication/DefaultAdminCredentials';
|
|
6
6
|
|
|
7
7
|
export const userCache: SessionDataCache<User> = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
key: USER_SESSION_CACHE_KEY,
|
|
9
|
+
create: async (sessionId: string, userEmail: string): Promise<User> => {
|
|
10
|
+
let user = guestUser;
|
|
11
|
+
if (userEmail) {
|
|
12
|
+
const adminCredentials = DefaultAdminCredentials.getCredentials();
|
|
13
|
+
if (adminCredentials && userEmail == adminCredentials.username) {
|
|
14
|
+
const adminUser: User = {
|
|
15
|
+
name: 'Admin',
|
|
16
|
+
email: adminCredentials.username,
|
|
17
|
+
password: adminCredentials.password,
|
|
18
|
+
emailVerified: true,
|
|
19
|
+
roles: 'admin',
|
|
20
|
+
created: moment(),
|
|
21
|
+
updated: moment(),
|
|
22
|
+
id: 'admin',
|
|
23
|
+
};
|
|
24
|
+
user = adminUser;
|
|
25
|
+
} else {
|
|
26
|
+
user = await getSystemDb().get(tables.User, { email: userEmail });
|
|
27
|
+
}
|
|
22
28
|
}
|
|
23
|
-
|
|
29
|
+
|
|
30
|
+
return user;
|
|
31
|
+
},
|
|
32
|
+
};
|
package/src/routes/createUser.ts
CHANGED
|
@@ -5,28 +5,28 @@ import { User, tables, routes } from '@proteinjs/user';
|
|
|
5
5
|
import { Logger } from '@proteinjs/util';
|
|
6
6
|
|
|
7
7
|
export const createUser: Route = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
await db.insert(tables.User, {
|
|
23
|
-
name: user.name,
|
|
24
|
-
email: user.email,
|
|
25
|
-
password: sha256(user.password).toString(),
|
|
26
|
-
emailVerified: false,
|
|
27
|
-
roles: '',
|
|
28
|
-
});
|
|
29
|
-
logger.info(`Created user: ${user.email}`);
|
|
30
|
-
response.send({});
|
|
8
|
+
path: routes.createUser.path,
|
|
9
|
+
method: routes.createUser.method,
|
|
10
|
+
onRequest: async (request, response): Promise<void> => {
|
|
11
|
+
const logger = new Logger('createUser');
|
|
12
|
+
const user = request.body as User;
|
|
13
|
+
const db = getSystemDb();
|
|
14
|
+
const userRecord = await db.get(tables.User, { email: user.email });
|
|
15
|
+
if (userRecord) {
|
|
16
|
+
const error = `User with this email already exists`;
|
|
17
|
+
console.error(`${error}: ${user.email}`);
|
|
18
|
+
response.send({ error });
|
|
19
|
+
return;
|
|
31
20
|
}
|
|
32
|
-
|
|
21
|
+
|
|
22
|
+
await db.insert(tables.User, {
|
|
23
|
+
name: user.name,
|
|
24
|
+
email: user.email,
|
|
25
|
+
password: sha256(user.password).toString(),
|
|
26
|
+
emailVerified: false,
|
|
27
|
+
roles: '',
|
|
28
|
+
});
|
|
29
|
+
logger.info(`Created user: ${user.email}`);
|
|
30
|
+
response.send({});
|
|
31
|
+
},
|
|
32
|
+
};
|
package/src/routes/login.ts
CHANGED
|
@@ -3,27 +3,27 @@ import { routes } from '@proteinjs/user';
|
|
|
3
3
|
import { authenticate } from '../authentication/authenticate';
|
|
4
4
|
|
|
5
5
|
export const login: Route = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const result = await authenticate(credentials.email, credentials.password);
|
|
18
|
-
if (result !== true) {
|
|
19
|
-
console.error(result);
|
|
20
|
-
response.send({ error: result });
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
6
|
+
path: routes.login.path,
|
|
7
|
+
method: routes.login.method,
|
|
8
|
+
onRequest: async (request: any, response): Promise<void> => {
|
|
9
|
+
const credentials: { email: string; password: string } = request.body;
|
|
10
|
+
if (!credentials.email || !credentials.password) {
|
|
11
|
+
const error = `Email and password cannot be blank`;
|
|
12
|
+
console.error(error);
|
|
13
|
+
response.send({ error });
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
23
16
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
const result = await authenticate(credentials.email, credentials.password);
|
|
18
|
+
if (result !== true) {
|
|
19
|
+
console.error(result);
|
|
20
|
+
response.send({ error: result });
|
|
21
|
+
return;
|
|
28
22
|
}
|
|
29
|
-
|
|
23
|
+
|
|
24
|
+
await new Promise((resolve, reject) => {
|
|
25
|
+
request.login(credentials.email, resolve);
|
|
26
|
+
});
|
|
27
|
+
response.send({});
|
|
28
|
+
},
|
|
29
|
+
};
|
package/src/routes/logout.ts
CHANGED
|
@@ -3,26 +3,26 @@ import { routes } from '@proteinjs/user';
|
|
|
3
3
|
import { destroySession } from '../authentication/destroySession';
|
|
4
4
|
|
|
5
5
|
export const logout: Route = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
path: routes.logout.path,
|
|
7
|
+
method: routes.logout.method,
|
|
8
|
+
onRequest: async (request: any, response): Promise<void> => {
|
|
9
|
+
// request.logout();
|
|
10
|
+
// await request.session.destroy();
|
|
11
|
+
// await new Promise((resolve, reject) => {
|
|
12
|
+
// request.session?.destroy((error: any) => {
|
|
13
|
+
// if (error) {
|
|
14
|
+
// reject(error);
|
|
15
|
+
// return;
|
|
16
|
+
// }
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
18
|
+
// resolve();
|
|
19
|
+
// });
|
|
20
|
+
// });
|
|
21
|
+
// delete request._passport?.session?.user;
|
|
22
|
+
// console.info(`request.sessionID: ${request.sessionID}`);
|
|
23
|
+
// console.info(`request.session?.id: ${request.session?.id}`);
|
|
24
|
+
await destroySession(request.sessionID);
|
|
25
|
+
request.session.passport.user = null;
|
|
26
|
+
response.redirect('/login');
|
|
27
|
+
},
|
|
28
|
+
};
|
package/tsconfig.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"rootDir": "./",
|
|
4
|
+
"target": "es5",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"declarationMap": true,
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"outDir": "./dist/",
|
|
10
|
+
"strict": true,
|
|
11
|
+
"noImplicitAny": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"jsx": "react"
|
|
17
|
+
}
|
|
18
|
+
}
|