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

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 10:27:54 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 10:27:54 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 10:27:54 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 10:27:54 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 10:27:54 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 10:27:54 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 10:27:54 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 10:27:54 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 10:27:54 GMT+0100 (Central European Standard Time)
4
4
  require("./generatedHandlers");
5
5
  require("./generatedRepos");
6
6
  require("./generatedJobs");
@@ -3,4 +3,7 @@ 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>;
6
9
  export declare const __assumedHttpMethod = "", __file = "UserPasswordResetForm.ts", __query: never[], __params: never[];
@@ -39,11 +39,12 @@ 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.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 <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 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";
47
48
  function handleUserPasswordResetForm(_req, res, _a) {
48
49
  var templateFile = _a.templateFile, completeUrl = _a.completeUrl;
49
50
  return __awaiter(this, void 0, void 0, function () {
@@ -63,6 +64,19 @@ function handleUserPasswordResetForm(_req, res, _a) {
63
64
  });
64
65
  }
65
66
  exports.handleUserPasswordResetForm = handleUserPasswordResetForm;
67
+ function resetPasswordFormScript(req, res, _a) {
68
+ var completeUrl = _a.completeUrl;
69
+ return __awaiter(this, void 0, void 0, function () {
70
+ var js;
71
+ return __generator(this, function (_b) {
72
+ res.header("Content-Type", "application/javascript");
73
+ js = handlebars_1.default.compile(script)({ completeUrl: completeUrl });
74
+ res.send(js);
75
+ return [2 /*return*/];
76
+ });
77
+ });
78
+ }
79
+ exports.resetPasswordFormScript = resetPasswordFormScript;
66
80
  var cachedTemplate = "";
67
81
  function readTemplate(templateFilename) {
68
82
  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;
38
38
  if (options.enableUserCreation == null)
39
39
  options.enableUserCreation = true;
40
40
  if (options.enableProfileUpdate == null)
@@ -123,6 +123,9 @@ 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
+ });
126
129
  }
127
130
  }
128
131
  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.15",
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": "0f29761331501ccb5678c5da6801fa12f9a23f9d"
34
34
  }
@@ -38,8 +38,26 @@ const defaultTemplate = `<html>
38
38
  max-width: 350px;
39
39
  }
40
40
  </style>
41
- <script>
42
- window.onload = () => {
41
+ <script src="form/script.js" type="text/javascript"></script>
42
+ </head>
43
+ <body>
44
+ <form id="form">
45
+ <p>Please enter new password</p>
46
+ <input type="password" name="password" placeholder="Enter new password" />
47
+ <input
48
+ type="password"
49
+ name="confirmPassword"
50
+ placeholder="Confirm new password"
51
+ />
52
+ <button id="submit-btn">Submit</button>
53
+ </form>
54
+ <div id="success">Password has been updated, please proceed to login.</div>
55
+ </body>
56
+ </html>
57
+ `;
58
+
59
+ const script = `
60
+ window.onload = () => {
43
61
  const urlSearchParams = new URLSearchParams(window.location.search);
44
62
  const params = Object.fromEntries(urlSearchParams.entries());
45
63
  const { token, code } = params;
@@ -87,22 +105,6 @@ const defaultTemplate = `<html>
87
105
  }
88
106
  };
89
107
  };
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>
106
108
  `;
107
109
 
108
110
  export async function handleUserPasswordResetForm(
@@ -119,6 +121,12 @@ export async function handleUserPasswordResetForm(
119
121
  res.send(html);
120
122
  }
121
123
 
124
+ export async function resetPasswordFormScript(req: ExpressRequest, res: ExpressResponse, { completeUrl }: { completeUrl: string }) {
125
+ res.header("Content-Type", "application/javascript");
126
+ const js = Handlebars.compile(script)({completeUrl});
127
+ res.send(js);
128
+ }
129
+
122
130
  let cachedTemplate = "";
123
131
 
124
132
  async function readTemplate(templateFilename?: string) {
package/src/init.ts CHANGED
@@ -11,7 +11,7 @@ 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 { handleUserPasswordResetForm, resetPasswordFormScript } from "./handlers/UserPasswordResetForm";
15
15
 
16
16
  export function init(app: FlinkApp<any>, options: GenericAuthPluginOptions) {
17
17
  if (options.enableUserCreation == null) options.enableUserCreation = true;
@@ -107,6 +107,12 @@ export function init(app: FlinkApp<any>, options: GenericAuthPluginOptions) {
107
107
  completeUrl: options.baseUrl + "/password/reset/complete",
108
108
  })
109
109
  );
110
+ app.expressApp?.get(
111
+ options.baseUrl + "/password/reset/form/script.js",
112
+ (req, res) => {
113
+ resetPasswordFormScript(req, res, { completeUrl: options.baseUrl + "/password/reset/complete", });
114
+ }
115
+ );
110
116
  }
111
117
  }
112
118