@modernman00/shared-js-lib 1.2.65 โ†’ 1.2.67

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/AcctMgt/code.js CHANGED
@@ -58,6 +58,18 @@ export function createCodeSubmitHandler({
58
58
  };
59
59
 
60
60
  loginSubmission(formId, route, redirect, theme, lengthLimit);
61
+ loginSubmission({
62
+ 'formId': formId,
63
+ 'loginURL': route,
64
+ 'redirect': redirect,
65
+ 'css': theme,
66
+ 'lengthLimit': lengthLimit,
67
+ 'optionalFields': [],
68
+ 'recaptchaToken':{
69
+ siteKey: recaptchaToken,
70
+ action: 'LOGIN'
71
+ }
72
+ })
61
73
  };
62
74
 
63
75
  bindEvent({ id: buttonId, handler });
@@ -18,8 +18,8 @@ import FormHelper from '../FormHelper.js';
18
18
  * @throws {Error} - If there is an error with the submission
19
19
  * @param {Object} [options.recaptchaV3=null] - reCAPTCHA v3 configuration ({ siteKey: 'OUR_ENTERPRISE_SITE_KEY', action: 'LOGIN' }).
20
20
  */
21
- export const loginSubmission = async (formId, loginURL, redirect, css = null, lengthLimit = null, optionalFields = [], recaptchaToken = null
22
- ) => {
21
+ export const loginSubmission = async ({formId, loginURL, redirect, css = null, lengthLimit = null, optionalFields = [], recaptchaToken = null
22
+ }) => {
23
23
 
24
24
  try {
25
25
 
@@ -0,0 +1,86 @@
1
+ import { loginSubmission } from './processAll.js';
2
+ import { id } from '../UtilityHtml.js';
3
+ import { bindEvent, showPassword } from '../Utility.js';
4
+ import { showError } from '../ShowResponse.js';
5
+
6
+
7
+ /**
8
+ * use this handler to submit forms.
9
+ *
10
+ * This handler:
11
+ * - Binds the submit button to an async login workflow
12
+ * - Optionally executes reCAPTCHA v3 (Enterprise) and attaches the token
13
+ * - Passes configuration (route, redirect, theme, optional fields, length limits)
14
+ * to `loginSubmission`
15
+ * - Supports custom UI themes and optional field handling
16
+ *
17
+ * @function registerHandler
18
+ * @param {Object} options - Configuration for the login handler.
19
+ * @param {string} options.formId - ID of the login form.
20
+ * @param {Object} options.lengthLimitArray - Max-length configuration for form fields.
21
+ * @param {string} [options.buttonId='button'] - ID of the submit button.
22
+
23
+ * @param {string} options.route - API endpoint for login submission.
24
+ * @param {string} options.redirect - URL to redirect to after successful login.
25
+ * @param {string} [options.theme='bootstrap'] - UI theme identifier.
26
+ * @param {string} [options.recaptchaAction='SUBMIT'] - Action name for reCAPTCHA v3 execution.
27
+ * @param {string[]} [options.optionalFields=[]] - Optional form fields to include in submission.
28
+ *
29
+ * @example
30
+ * formHandler({
31
+ * formId: 'loginForm',
32
+ * lengthLimitArray: { id: ['email', 'password'], max: [30, 50] },
33
+ * buttonId: 'loginBtn',
34
+ * route: appRoutes.login,
35
+ * redirect: appRoutes.dashboard,
36
+ * optionalFields: ['remember_me', 'captcha']
37
+ * });
38
+ */
39
+
40
+ export function registerHandler({
41
+ formId, lengthLimitArray,
42
+ buttonId = 'button',
43
+ route,
44
+ redirect,
45
+ theme = 'bootstrap',
46
+ recaptchaAction = 'SUBMIT',
47
+ optionalFields = []
48
+ }) {
49
+ const handler = async (e) => {
50
+ e.preventDefault();
51
+
52
+ let token = null;
53
+ // Only run v3 if configured AND grecaptcha is available
54
+ if (window.RECAPTCHA_SITE_KEY && window.grecaptcha && window.grecaptcha.enterprise) {
55
+ try {
56
+ token = await window.grecaptcha.enterprise.execute(
57
+ window.RECAPTCHA_SITE_KEY,
58
+ { action: recaptchaAction || 'SUBMIT' });
59
+ } catch (err) {
60
+ showError(err);
61
+ }
62
+ }
63
+
64
+ if (lengthLimitArray) {
65
+ const lengthLimit = {
66
+ maxLength: lengthLimitArray
67
+ };
68
+ }
69
+
70
+ loginSubmission(
71
+ {
72
+ 'formId': formId,
73
+ 'loginUrl': route,
74
+ 'redirect': redirect,
75
+ 'lengthLimit': lengthLimitArray,
76
+ 'css': theme,
77
+ 'optionalFields': optionalFields,
78
+ 'recaptchaToken': token
79
+ }
80
+ );
81
+
82
+ return;
83
+ }
84
+ bindEvent({ id: buttonId, handler });
85
+
86
+ };
@@ -1,3 +1,3 @@
1
1
  <?php
2
- define('APP_VERSION', 'v1.2.65');
2
+ define('APP_VERSION', 'v1.2.66');
3
3
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modernman00/shared-js-lib",
3
- "version": "1.2.65",
3
+ "version": "1.2.67",
4
4
  "description": "Reusable JS utilities for numerous js problems",
5
5
  "homepage": "https://github.com/modernman00/shared-js-lib#readme",
6
6
  "keywords": [
@@ -65,3 +65,9 @@
65
65
 
66
66
  - ๐Ÿ”– Bump version to v1.2.65 _(by modernman00)_
67
67
  - ๐Ÿงน Auto-commit before release _(by modernman00)_
68
+
69
+ ## v1.2.66 โ€” 2026-04-30 17:50
70
+ ### Changelog for v1.2.66
71
+
72
+ - ๐Ÿ”– Bump version to v1.2.66 _(by modernman00)_
73
+ - ๐Ÿงน Auto-commit before release _(by modernman00)_