@flink-app/generic-auth-plugin 0.12.1-alpha.0 → 0.12.1-alpha.10
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/.flink/generatedHandlers.ts +1 -1
- package/.flink/generatedJobs.ts +1 -1
- package/.flink/generatedRepos.ts +1 -1
- package/.flink/schemas/schemas.json +2 -4
- package/.flink/schemas/schemas.ts +1 -1
- package/.flink/start.ts +1 -1
- package/dist/.flink/generatedHandlers.js +1 -1
- package/dist/.flink/generatedJobs.js +1 -1
- package/dist/.flink/generatedRepos.js +1 -1
- package/dist/.flink/schemas/schemas.json +2 -4
- package/dist/.flink/start.js +1 -1
- package/dist/src/coreFunctions.js +8 -8
- package/dist/src/handlers/Management/DeleteUserByUserid.js +21 -23
- package/dist/src/handlers/Management/GetSchema.js +12 -14
- package/dist/src/handlers/Management/GetUser.js +21 -23
- package/dist/src/handlers/Management/GetUserByUserid.js +22 -24
- package/dist/src/handlers/Management/GetUserViewByUserid.js +34 -36
- package/dist/src/handlers/Management/PutUserPasswordByUserid.js +46 -48
- package/dist/src/handlers/Management/PutUserProfileByUserid.js +24 -26
- package/dist/src/handlers/Management/PutUserProfileByUseridAppend.js +27 -29
- package/dist/src/handlers/Management/PutUserRolesByUserid.js +24 -26
- package/dist/src/handlers/Management/PutUserUsernameByUserid.js +33 -35
- package/dist/src/handlers/UserCreate.js +44 -46
- package/dist/src/handlers/UserLogin.js +23 -25
- package/dist/src/handlers/UserLoginByToken.js +23 -25
- package/dist/src/handlers/UserPasswordPut.js +21 -23
- package/dist/src/handlers/UserPasswordResetComplete.js +27 -29
- package/dist/src/handlers/UserPasswordResetForm.js +11 -11
- package/dist/src/handlers/UserPasswordResetStart.js +53 -55
- package/dist/src/handlers/UserProfileGet.js +21 -23
- package/dist/src/handlers/UserProfilePut.js +28 -30
- package/dist/src/handlers/UserPushRegisterToken.js +72 -74
- package/dist/src/handlers/UserPushRemoveToken.js +25 -27
- package/dist/src/handlers/UserToken.js +24 -26
- package/dist/src/index.js +7 -8
- package/dist/src/init.js +8 -4
- package/dist/src/management.js +5 -1
- package/package.json +32 -32
- package/CLAUDE.md +0 -32
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
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
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -38,32 +38,30 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
|
|
40
40
|
var flink_1 = require("@flink-app/flink");
|
|
41
|
-
var postUserRemoveTokenHandler = function (_a) {
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
});
|
|
41
|
+
var postUserRemoveTokenHandler = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
42
|
+
var pluginName, repo, user;
|
|
43
|
+
var ctx = _b.ctx, req = _b.req, origin = _b.origin;
|
|
44
|
+
return __generator(this, function (_c) {
|
|
45
|
+
switch (_c.label) {
|
|
46
|
+
case 0:
|
|
47
|
+
pluginName = origin || "genericAuthPlugin";
|
|
48
|
+
repo = ctx.repos[ctx.plugins[pluginName].repoName];
|
|
49
|
+
return [4 /*yield*/, repo.getById(req.user._id)];
|
|
50
|
+
case 1:
|
|
51
|
+
user = _c.sent();
|
|
52
|
+
if (user == null) {
|
|
53
|
+
return [2 /*return*/, (0, flink_1.notFound)("User not found")];
|
|
54
|
+
}
|
|
55
|
+
user.pushNotificationTokens = user.pushNotificationTokens.filter(function (t) { return t.deviceId != req.body.deviceId; });
|
|
56
|
+
return [4 /*yield*/, repo.updateOne(user._id, {
|
|
57
|
+
pushNotificationTokens: user.pushNotificationTokens,
|
|
58
|
+
})];
|
|
59
|
+
case 2:
|
|
60
|
+
_c.sent();
|
|
61
|
+
return [2 /*return*/, { data: { status: "success" } }];
|
|
62
|
+
}
|
|
65
63
|
});
|
|
66
|
-
};
|
|
64
|
+
}); };
|
|
67
65
|
exports.default = postUserRemoveTokenHandler;
|
|
68
66
|
exports.__assumedHttpMethod = "", exports.__file = "UserPushRemoveToken.ts", exports.__query = [], exports.__params = [];
|
|
69
|
-
exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "deviceId": { "type": "string" }, "token": { "type": "string" }, "platform": { "type": "string", "enum": ["ios", "android", "web"] }, "type": { "type": "string", "enum": ["firebase", "apn-voip"]
|
|
67
|
+
exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "deviceId": { "type": "string" }, "token": { "type": "string" }, "platform": { "type": "string", "enum": ["ios", "android", "web"] }, "type": { "type": "string", "enum": ["firebase", "apn-voip"] } }, "required": ["deviceId", "token"], "definitions": {} }, resSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "status": { "type": "string", "enum": ["success", "failed"] } }, "required": ["status"], "definitions": {} } };
|
|
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
14
14
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
15
|
function step(op) {
|
|
16
16
|
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
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
19
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
20
|
switch (op[0]) {
|
|
@@ -38,32 +38,30 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.__schemas = exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = void 0;
|
|
40
40
|
var flink_1 = require("@flink-app/flink");
|
|
41
|
-
var getUserTokenHandler = function (_a) {
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
});
|
|
41
|
+
var getUserTokenHandler = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
42
|
+
var pluginName, repo, user, token;
|
|
43
|
+
var ctx = _b.ctx, req = _b.req, origin = _b.origin;
|
|
44
|
+
return __generator(this, function (_c) {
|
|
45
|
+
switch (_c.label) {
|
|
46
|
+
case 0:
|
|
47
|
+
pluginName = origin || "genericAuthPlugin";
|
|
48
|
+
repo = ctx.repos[ctx.plugins[pluginName].repoName];
|
|
49
|
+
return [4 /*yield*/, repo.getById(req.user._id)];
|
|
50
|
+
case 1:
|
|
51
|
+
user = _c.sent();
|
|
52
|
+
if (user == null) {
|
|
53
|
+
return [2 /*return*/, (0, flink_1.notFound)("User not found")];
|
|
54
|
+
}
|
|
55
|
+
if (ctx.auth == null) {
|
|
56
|
+
return [2 /*return*/, (0, flink_1.internalServerError)()];
|
|
57
|
+
}
|
|
58
|
+
return [4 /*yield*/, ctx.auth.createToken({ username: user.username.toLowerCase(), _id: user._id }, user.roles)];
|
|
59
|
+
case 2:
|
|
60
|
+
token = _c.sent();
|
|
61
|
+
return [2 /*return*/, { data: { token: token } }];
|
|
62
|
+
}
|
|
65
63
|
});
|
|
66
|
-
};
|
|
64
|
+
}); };
|
|
67
65
|
exports.default = getUserTokenHandler;
|
|
68
66
|
exports.__assumedHttpMethod = "", exports.__file = "UserToken.ts", exports.__query = [], exports.__params = [];
|
|
69
67
|
exports.__schemas = { reqSchema: { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": false, "properties": { "token": { "type": "string" } }, "required": ["token"], "definitions": {} }, resSchema: undefined };
|
package/dist/src/index.js
CHANGED
|
@@ -12,7 +12,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
};
|
|
13
13
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
14
|
if (k2 === undefined) k2 = k;
|
|
15
|
-
Object.
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
16
20
|
}) : (function(o, m, k, k2) {
|
|
17
21
|
if (k2 === undefined) k2 = k;
|
|
18
22
|
o[k2] = m[k];
|
|
@@ -46,13 +50,8 @@ var genericAuthPlugin = function (options) {
|
|
|
46
50
|
var sms = options.sms, usernameFormat = options.usernameFormat, restOptions = __rest(options, ["sms", "usernameFormat"]);
|
|
47
51
|
return {
|
|
48
52
|
id: options.pluginId,
|
|
49
|
-
init: function (app) { return init_1.init(app, options); },
|
|
50
|
-
ctx: __assign(__assign({}, restOptions), { loginUser: coreFunctions_1.loginUser,
|
|
51
|
-
loginByToken: coreFunctions_1.loginByToken,
|
|
52
|
-
createUser: coreFunctions_1.createUser,
|
|
53
|
-
changePassword: coreFunctions_1.changePassword,
|
|
54
|
-
passwordResetStart: coreFunctions_1.passwordResetStart,
|
|
55
|
-
passwordResetComplete: coreFunctions_1.passwordResetComplete, usernameFormat: usernameFormat || /.{1,}$/, smsOptions: sms }),
|
|
53
|
+
init: function (app) { return (0, init_1.init)(app, options); },
|
|
54
|
+
ctx: __assign(__assign({}, restOptions), { loginUser: coreFunctions_1.loginUser, loginByToken: coreFunctions_1.loginByToken, createUser: coreFunctions_1.createUser, changePassword: coreFunctions_1.changePassword, passwordResetStart: coreFunctions_1.passwordResetStart, passwordResetComplete: coreFunctions_1.passwordResetComplete, usernameFormat: usernameFormat || /.{1,}$/, smsOptions: sms }),
|
|
56
55
|
};
|
|
57
56
|
};
|
|
58
57
|
exports.genericAuthPlugin = genericAuthPlugin;
|
package/dist/src/init.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -118,16 +122,16 @@ function init(app, options) {
|
|
|
118
122
|
if ((_a = options.passwordResetSettings) === null || _a === void 0 ? void 0 : _a.enablePasswordResetForm) {
|
|
119
123
|
(_b = app.expressApp) === null || _b === void 0 ? void 0 : _b.get(options.baseUrl + "/password/reset/form", function (req, res) {
|
|
120
124
|
var _a;
|
|
121
|
-
return UserPasswordResetForm_1.handleUserPasswordResetForm(req, res, {
|
|
125
|
+
return (0, UserPasswordResetForm_1.handleUserPasswordResetForm)(req, res, {
|
|
122
126
|
templateFile: (_a = options.passwordResetSettings) === null || _a === void 0 ? void 0 : _a.passwordResetForm,
|
|
123
127
|
completeUrl: options.baseUrl + "/password/reset/complete",
|
|
124
128
|
});
|
|
125
129
|
});
|
|
126
130
|
(_c = app.expressApp) === null || _c === void 0 ? void 0 : _c.get(options.baseUrl + "/password/reset/form/script.js", function (req, res) {
|
|
127
|
-
UserPasswordResetForm_1.resetPasswordFormScript(req, res, { completeUrl: options.baseUrl + "/password/reset/complete" });
|
|
131
|
+
(0, UserPasswordResetForm_1.resetPasswordFormScript)(req, res, { completeUrl: options.baseUrl + "/password/reset/complete" });
|
|
128
132
|
});
|
|
129
133
|
(_d = app.expressApp) === null || _d === void 0 ? void 0 : _d.get(options.baseUrl + "/password/reset/form/style.css", function (req, res) {
|
|
130
|
-
UserPasswordResetForm_1.resetPasswordFormCss(res);
|
|
134
|
+
(0, UserPasswordResetForm_1.resetPasswordFormCss)(res);
|
|
131
135
|
});
|
|
132
136
|
}
|
|
133
137
|
}
|
package/dist/src/management.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/package.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
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
|
-
|
|
2
|
+
"name": "@flink-app/generic-auth-plugin",
|
|
3
|
+
"version": "0.12.1-alpha.10",
|
|
4
|
+
"description": "Flink plugin that provides a generic user authentification solution.",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\"",
|
|
7
|
+
"build": "flink build",
|
|
8
|
+
"prepare": "npm run build",
|
|
9
|
+
"watch": "nodemon --exec \"flink build\""
|
|
10
|
+
},
|
|
11
|
+
"author": "johan@frost.se",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"types": "dist/src/index.d.ts",
|
|
17
|
+
"main": "dist/src/index.js",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@flink-app/email-plugin": "^0.12.1-alpha.10",
|
|
20
|
+
"@flink-app/jwt-auth-plugin": "^0.12.1-alpha.10",
|
|
21
|
+
"@flink-app/management-api-plugin": "^0.12.1-alpha.10",
|
|
22
|
+
"@flink-app/sms-plugin": "^0.12.1-alpha.10",
|
|
23
|
+
"handlebars": "^4.7.7",
|
|
24
|
+
"jsonwebtoken": "^8.5.1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@flink-app/flink": "^0.12.1-alpha.10",
|
|
28
|
+
"@types/jsonwebtoken": "^8.5.2",
|
|
29
|
+
"@types/node": "22.13.10",
|
|
30
|
+
"ts-node": "^9.1.1",
|
|
31
|
+
"typescript": "5.4.5"
|
|
32
|
+
},
|
|
33
|
+
"gitHead": "d4019c3af70673f27db4df55d56ba3728e75745e"
|
|
34
34
|
}
|
package/CLAUDE.md
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md - Guidelines for Generic Auth Plugin
|
|
2
|
-
|
|
3
|
-
## Build Commands
|
|
4
|
-
- Build: `npm run build` (runs `flink build`)
|
|
5
|
-
- Watch mode: `npm run watch` (uses nodemon to watch files and trigger builds)
|
|
6
|
-
- Publish: `npm run prepublish` (runs build before publishing)
|
|
7
|
-
|
|
8
|
-
## Code Style
|
|
9
|
-
|
|
10
|
-
### TypeScript
|
|
11
|
-
- Target: ES5, CommonJS modules, strict typing enabled
|
|
12
|
-
- Keep type definitions in separate schema files in the `/schemas` directory
|
|
13
|
-
- Use explicit return types on all functions (eg: `Promise<UserLoginRes>`)
|
|
14
|
-
- Always handle optionality with `?` and `undefined`/`null` checks
|
|
15
|
-
|
|
16
|
-
### Naming Conventions
|
|
17
|
-
- camelCase for variables, functions, and methods
|
|
18
|
-
- PascalCase for interfaces and types
|
|
19
|
-
- Request types use `Req` suffix (UserLoginReq)
|
|
20
|
-
- Response types use `Res` suffix (UserLoginRes)
|
|
21
|
-
- Handler files match their function name (UserLogin.ts)
|
|
22
|
-
|
|
23
|
-
### Error Handling
|
|
24
|
-
- Use structured error responses with status fields and messages
|
|
25
|
-
- Return typed response objects rather than throwing exceptions
|
|
26
|
-
- Use try/catch blocks for operations that might fail (JWT verification)
|
|
27
|
-
|
|
28
|
-
### Code Structure
|
|
29
|
-
- Group imports: framework first, then local, then third-party
|
|
30
|
-
- Separate authentication methods and utility functions
|
|
31
|
-
- Use standard 4-space indentation with semicolons
|
|
32
|
-
- Maintain consistent function parameter ordering
|