@flink-app/generic-auth-plugin 0.11.14 → 0.11.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- // Generated Mon Feb 24 2025 14:41:52 GMT+0100 (Central European Standard Time)
1
+ // Generated Tue Feb 25 2025 12:57:55 GMT+0100 (Central European Standard Time)
2
2
  import { autoRegisteredHandlers, HttpMethod } from "@flink-app/flink";
3
3
  import * as UserCreate_0 from "../src/handlers/UserCreate";
4
4
  import * as UserLogin_0 from "../src/handlers/UserLogin";
@@ -1,4 +1,4 @@
1
- // Generated Mon Feb 24 2025 14:41:52 GMT+0100 (Central European Standard Time)
1
+ // Generated Tue Feb 25 2025 12:57:55 GMT+0100 (Central European Standard Time)
2
2
  import { autoRegisteredJobs } from "@flink-app/flink";
3
3
  export const jobs = [];
4
4
  autoRegisteredJobs.push(...jobs);
@@ -1,4 +1,4 @@
1
- // Generated Mon Feb 24 2025 14:41:52 GMT+0100 (Central European Standard Time)
1
+ // Generated Tue Feb 25 2025 12:57:55 GMT+0100 (Central European Standard Time)
2
2
  import { autoRegisteredRepos } from "@flink-app/flink";
3
3
  export const repos = [];
4
4
  autoRegisteredRepos.push(...repos);
@@ -29,7 +29,7 @@ import { PutManagementUserRolesByUseridRes } from "../../src/schemas/Management/
29
29
  import { PutManagementUserUsernameByUseridReq } from "../../src/schemas/Management/PutUserUsernameByUseridReq";
30
30
  import { PutManagementUserUsernameByUseridRes } from "../../src/schemas/Management/PutUserUsernameByUseridRes";
31
31
 
32
- // Generated Mon Feb 24 2025 14:41:53 GMT+0100 (Central European Standard Time)
32
+ // Generated Tue Feb 25 2025 12:57:56 GMT+0100 (Central European Standard Time)
33
33
  export interface UserCreate_7_ReqSchema extends UserCreateReq {}
34
34
 
35
35
  export interface UserCreate_7_ResSchema extends UserCreateRes {}
package/.flink/start.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Generated Mon Feb 24 2025 14:41:52 GMT+0100 (Central European Standard Time)
1
+ // Generated Tue Feb 25 2025 12:57:55 GMT+0100 (Central European Standard Time)
2
2
  import "./generatedHandlers";
3
3
  import "./generatedRepos";
4
4
  import "./generatedJobs";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handlers = void 0;
4
- // Generated Mon Feb 24 2025 14:41:52 GMT+0100 (Central European Standard Time)
4
+ // Generated Tue Feb 25 2025 12:57:55 GMT+0100 (Central European Standard Time)
5
5
  var flink_1 = require("@flink-app/flink");
6
6
  exports.handlers = [];
7
7
  flink_1.autoRegisteredHandlers.push.apply(flink_1.autoRegisteredHandlers, exports.handlers);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.jobs = void 0;
4
- // Generated Mon Feb 24 2025 14:41:52 GMT+0100 (Central European Standard Time)
4
+ // Generated Tue Feb 25 2025 12:57:55 GMT+0100 (Central European Standard Time)
5
5
  var flink_1 = require("@flink-app/flink");
6
6
  exports.jobs = [];
7
7
  flink_1.autoRegisteredJobs.push.apply(flink_1.autoRegisteredJobs, exports.jobs);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.repos = void 0;
4
- // Generated Mon Feb 24 2025 14:41:52 GMT+0100 (Central European Standard Time)
4
+ // Generated Tue Feb 25 2025 12:57:55 GMT+0100 (Central European Standard Time)
5
5
  var flink_1 = require("@flink-app/flink");
6
6
  exports.repos = [];
7
7
  flink_1.autoRegisteredRepos.push.apply(flink_1.autoRegisteredRepos, exports.repos);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // Generated Mon Feb 24 2025 14:41:52 GMT+0100 (Central European Standard Time)
3
+ // Generated Tue Feb 25 2025 12:57:55 GMT+0100 (Central European Standard Time)
4
4
  require("./generatedHandlers");
5
5
  require("./generatedRepos");
6
6
  require("./generatedJobs");
@@ -3,4 +3,8 @@ export declare function handleUserPasswordResetForm(_req: ExpressRequest, res: E
3
3
  templateFile?: string;
4
4
  completeUrl: string;
5
5
  }): Promise<void>;
6
+ export declare function resetPasswordFormScript(req: ExpressRequest, res: ExpressResponse, { completeUrl }: {
7
+ completeUrl: string;
8
+ }): Promise<void>;
9
+ export declare function resetPasswordFormCss(res: ExpressResponse): Promise<void>;
6
10
  export declare const __assumedHttpMethod = "", __file = "UserPasswordResetForm.ts", __query: never[], __params: never[];
@@ -39,11 +39,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = exports.handleUserPasswordResetForm = void 0;
42
+ exports.__params = exports.__query = exports.__file = exports.__assumedHttpMethod = exports.resetPasswordFormCss = exports.resetPasswordFormScript = exports.handleUserPasswordResetForm = void 0;
43
43
  var promises_1 = __importDefault(require("fs/promises"));
44
44
  var flink_1 = require("@flink-app/flink");
45
45
  var handlebars_1 = __importDefault(require("handlebars"));
46
- var defaultTemplate = "<html>\n<head>\n <title>Password reset</title>\n <style>\n * {\n box-sizing: border-box;\n font-family: Arial, Helvetica, sans-serif;\n }\n\n p {\n margin: 0.5rem 0;\n }\n\n body {\n padding: 1rem;\n }\n\n form {\n display: block;\n max-width: 320px;\n }\n\n input {\n width: 100%;\n display: block;\n margin: 0.5rem 0;\n }\n\n #success {\n display: none;\n font-size: 1.2rem;\n color: rgb(0, 177, 115);\n max-width: 350px;\n }\n </style>\n <script>\n window.onload = () => {\n const urlSearchParams = new URLSearchParams(window.location.search);\n const params = Object.fromEntries(urlSearchParams.entries());\n const { token, code } = params;\n\n if (!token) {\n alert(\"Missing token\");\n } else if (!code) {\n alert(\"Missing code\");\n }\n\n const submitBtnEl = document.getElementById(\"submit-btn\");\n const [passwordInputEl, confirmPasswordEl] =\n document.getElementsByTagName(\"input\");\n\n submitBtnEl.onclick = async (e) => {\n e.preventDefault();\n e.stopPropagation();\n\n if (!passwordInputEl.value) {\n return alert(\"Enter a new password\");\n } else if (passwordInputEl.value !== confirmPasswordEl.value) {\n return alert(\n \"Passwords does not match, make sure that new and confirmed passwords are the same\"\n );\n }\n\n const res = await window.fetch(\"{{completeUrl}}\", {\n method: \"POST\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n passwordResetToken: token,\n code: code,\n password: passwordInputEl.value,\n }),\n });\n\n if (res.status > 399) {\n alert(\"Failed to set new password\");\n } else {\n document.getElementById(\"form\").style.display = \"none\";\n document.getElementById(\"success\").style.display = \"block\";\n }\n };\n };\n </script>\n</head>\n<body>\n <form id=\"form\">\n <p>Please enter new password</p>\n <input type=\"password\" name=\"password\" placeholder=\"Enter new password\" />\n <input\n type=\"password\"\n name=\"confirmPassword\"\n placeholder=\"Confirm new password\"\n />\n <button id=\"submit-btn\">Submit</button>\n </form>\n <div id=\"success\">Password has been updated, please proceed to login.</div>\n</body>\n</html>\n";
46
+ var defaultTemplate = "<html>\n<head>\n <title>Password reset</title>\n <link rel=\"stylesheet\" href=\"form/style.css\" />\n <script src=\"form/script.js\" type=\"text/javascript\"></script>\n</head>\n<body>\n <form id=\"form\">\n <p>Please enter new password</p>\n <input type=\"password\" name=\"password\" placeholder=\"Enter new password\" />\n <input\n type=\"password\"\n name=\"confirmPassword\"\n placeholder=\"Confirm new password\"\n />\n <button id=\"submit-btn\">Submit</button>\n </form>\n <div id=\"success\">Password has been updated, please proceed to login.</div>\n</body>\n</html>\n";
47
+ var script = "\n window.onload = () => {\n const urlSearchParams = new URLSearchParams(window.location.search);\n const params = Object.fromEntries(urlSearchParams.entries());\n const { token, code } = params;\n\n if (!token) {\n alert(\"Missing token\");\n } else if (!code) {\n alert(\"Missing code\");\n }\n\n const submitBtnEl = document.getElementById(\"submit-btn\");\n const [passwordInputEl, confirmPasswordEl] =\n document.getElementsByTagName(\"input\");\n\n submitBtnEl.onclick = async (e) => {\n e.preventDefault();\n e.stopPropagation();\n\n if (!passwordInputEl.value) {\n return alert(\"Enter a new password\");\n } else if (passwordInputEl.value !== confirmPasswordEl.value) {\n return alert(\n \"Passwords does not match, make sure that new and confirmed passwords are the same\"\n );\n }\n\n const res = await window.fetch(\"{{completeUrl}}\", {\n method: \"POST\",\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n passwordResetToken: token,\n code: code,\n password: passwordInputEl.value,\n }),\n });\n\n if (res.status > 399) {\n alert(\"Failed to set new password\");\n } else {\n document.getElementById(\"form\").style.display = \"none\";\n document.getElementById(\"success\").style.display = \"block\";\n }\n };\n };\n";
48
+ var style = " * {\n box-sizing: border-box;\n font-family: Arial, Helvetica, sans-serif;\n }\n\n p {\n margin: 0.5rem 0;\n }\n\n body {\n padding: 1rem;\n }\n\n form {\n display: block;\n max-width: 320px;\n }\n\n input {\n width: 100%;\n display: block;\n margin: 0.5rem 0;\n }\n\n #success {\n display: none;\n font-size: 1.2rem;\n color: rgb(0, 177, 115);\n max-width: 350px;\n }\n";
47
49
  function handleUserPasswordResetForm(_req, res, _a) {
48
50
  var templateFile = _a.templateFile, completeUrl = _a.completeUrl;
49
51
  return __awaiter(this, void 0, void 0, function () {
@@ -63,6 +65,29 @@ function handleUserPasswordResetForm(_req, res, _a) {
63
65
  });
64
66
  }
65
67
  exports.handleUserPasswordResetForm = handleUserPasswordResetForm;
68
+ function resetPasswordFormScript(req, res, _a) {
69
+ var completeUrl = _a.completeUrl;
70
+ return __awaiter(this, void 0, void 0, function () {
71
+ var js;
72
+ return __generator(this, function (_b) {
73
+ res.header("Content-Type", "application/javascript");
74
+ js = handlebars_1.default.compile(script)({ completeUrl: completeUrl });
75
+ res.send(js);
76
+ return [2 /*return*/];
77
+ });
78
+ });
79
+ }
80
+ exports.resetPasswordFormScript = resetPasswordFormScript;
81
+ function resetPasswordFormCss(res) {
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ return __generator(this, function (_a) {
84
+ res.header("Content-Type", "text/css");
85
+ res.send(style);
86
+ return [2 /*return*/];
87
+ });
88
+ });
89
+ }
90
+ exports.resetPasswordFormCss = resetPasswordFormCss;
66
91
  var cachedTemplate = "";
67
92
  function readTemplate(templateFilename) {
68
93
  return __awaiter(this, void 0, void 0, function () {
package/dist/src/init.js CHANGED
@@ -34,7 +34,7 @@ var postUserRemoveTokenHandler = __importStar(require("./handlers/UserPushRemove
34
34
  var getUserTokenHandler = __importStar(require("./handlers/UserToken"));
35
35
  var UserPasswordResetForm_1 = require("./handlers/UserPasswordResetForm");
36
36
  function init(app, options) {
37
- var _a, _b;
37
+ var _a, _b, _c, _d;
38
38
  if (options.enableUserCreation == null)
39
39
  options.enableUserCreation = true;
40
40
  if (options.enableProfileUpdate == null)
@@ -123,6 +123,12 @@ function init(app, options) {
123
123
  completeUrl: options.baseUrl + "/password/reset/complete",
124
124
  });
125
125
  });
126
+ (_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" });
128
+ });
129
+ (_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);
131
+ });
126
132
  }
127
133
  }
128
134
  if (options.enablePushNotificationTokens) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flink-app/generic-auth-plugin",
3
- "version": "0.11.14",
3
+ "version": "0.11.16",
4
4
  "description": "Flink plugin that provides a generic user authentification solution.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\"",
@@ -30,5 +30,5 @@
30
30
  "ts-node": "^9.1.1",
31
31
  "typescript": "^4.2.4"
32
32
  },
33
- "gitHead": "8172291cf7330d13c7958d170100fe9771fd7dfb"
33
+ "gitHead": "639288292e47f6d1d6329e2929d0cefba3b3e603"
34
34
  }
@@ -6,40 +6,27 @@ import Handlebars from "handlebars";
6
6
  const defaultTemplate = `<html>
7
7
  <head>
8
8
  <title>Password reset</title>
9
- <style>
10
- * {
11
- box-sizing: border-box;
12
- font-family: Arial, Helvetica, sans-serif;
13
- }
14
-
15
- p {
16
- margin: 0.5rem 0;
17
- }
18
-
19
- body {
20
- padding: 1rem;
21
- }
22
-
23
- form {
24
- display: block;
25
- max-width: 320px;
26
- }
27
-
28
- input {
29
- width: 100%;
30
- display: block;
31
- margin: 0.5rem 0;
32
- }
9
+ <link rel="stylesheet" href="form/style.css" />
10
+ <script src="form/script.js" type="text/javascript"></script>
11
+ </head>
12
+ <body>
13
+ <form id="form">
14
+ <p>Please enter new password</p>
15
+ <input type="password" name="password" placeholder="Enter new password" />
16
+ <input
17
+ type="password"
18
+ name="confirmPassword"
19
+ placeholder="Confirm new password"
20
+ />
21
+ <button id="submit-btn">Submit</button>
22
+ </form>
23
+ <div id="success">Password has been updated, please proceed to login.</div>
24
+ </body>
25
+ </html>
26
+ `;
33
27
 
34
- #success {
35
- display: none;
36
- font-size: 1.2rem;
37
- color: rgb(0, 177, 115);
38
- max-width: 350px;
39
- }
40
- </style>
41
- <script>
42
- window.onload = () => {
28
+ const script = `
29
+ window.onload = () => {
43
30
  const urlSearchParams = new URLSearchParams(window.location.search);
44
31
  const params = Object.fromEntries(urlSearchParams.entries());
45
32
  const { token, code } = params;
@@ -87,22 +74,38 @@ const defaultTemplate = `<html>
87
74
  }
88
75
  };
89
76
  };
90
- </script>
91
- </head>
92
- <body>
93
- <form id="form">
94
- <p>Please enter new password</p>
95
- <input type="password" name="password" placeholder="Enter new password" />
96
- <input
97
- type="password"
98
- name="confirmPassword"
99
- placeholder="Confirm new password"
100
- />
101
- <button id="submit-btn">Submit</button>
102
- </form>
103
- <div id="success">Password has been updated, please proceed to login.</div>
104
- </body>
105
- </html>
77
+ `;
78
+
79
+ const style =` * {
80
+ box-sizing: border-box;
81
+ font-family: Arial, Helvetica, sans-serif;
82
+ }
83
+
84
+ p {
85
+ margin: 0.5rem 0;
86
+ }
87
+
88
+ body {
89
+ padding: 1rem;
90
+ }
91
+
92
+ form {
93
+ display: block;
94
+ max-width: 320px;
95
+ }
96
+
97
+ input {
98
+ width: 100%;
99
+ display: block;
100
+ margin: 0.5rem 0;
101
+ }
102
+
103
+ #success {
104
+ display: none;
105
+ font-size: 1.2rem;
106
+ color: rgb(0, 177, 115);
107
+ max-width: 350px;
108
+ }
106
109
  `;
107
110
 
108
111
  export async function handleUserPasswordResetForm(
@@ -119,6 +122,17 @@ export async function handleUserPasswordResetForm(
119
122
  res.send(html);
120
123
  }
121
124
 
125
+ export async function resetPasswordFormScript(req: ExpressRequest, res: ExpressResponse, { completeUrl }: { completeUrl: string }) {
126
+ res.header("Content-Type", "application/javascript");
127
+ const js = Handlebars.compile(script)({completeUrl});
128
+ res.send(js);
129
+ }
130
+
131
+ export async function resetPasswordFormCss(res: ExpressResponse) {
132
+ res.header("Content-Type", "text/css");
133
+ res.send(style);
134
+ }
135
+
122
136
  let cachedTemplate = "";
123
137
 
124
138
  async function readTemplate(templateFilename?: string) {
package/src/init.ts CHANGED
@@ -11,7 +11,11 @@ import { GenericAuthPluginOptions } from "./genericAuthPluginOptions";
11
11
  import * as postUserPushRegisterTokenHandler from "./handlers/UserPushRegisterToken";
12
12
  import * as postUserRemoveTokenHandler from "./handlers/UserPushRemoveToken";
13
13
  import * as getUserTokenHandler from "./handlers/UserToken";
14
- import { handleUserPasswordResetForm } from "./handlers/UserPasswordResetForm";
14
+ import {
15
+ handleUserPasswordResetForm,
16
+ resetPasswordFormCss,
17
+ resetPasswordFormScript,
18
+ } from "./handlers/UserPasswordResetForm";
15
19
 
16
20
  export function init(app: FlinkApp<any>, options: GenericAuthPluginOptions) {
17
21
  if (options.enableUserCreation == null) options.enableUserCreation = true;
@@ -107,6 +111,19 @@ export function init(app: FlinkApp<any>, options: GenericAuthPluginOptions) {
107
111
  completeUrl: options.baseUrl + "/password/reset/complete",
108
112
  })
109
113
  );
114
+ app.expressApp?.get(
115
+ options.baseUrl + "/password/reset/form/script.js",
116
+ (req, res) => {
117
+ resetPasswordFormScript(req, res, { completeUrl: options.baseUrl + "/password/reset/complete"});
118
+ }
119
+ );
120
+
121
+ app.expressApp?.get(
122
+ options.baseUrl + "/password/reset/form/style.css",
123
+ (req, res) => {
124
+ resetPasswordFormCss(res);
125
+ }
126
+ );
110
127
  }
111
128
  }
112
129