@whippsp/auth0-helper 1.0.6 → 1.0.8

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.
Files changed (2) hide show
  1. package/Auth0Helper.js +17 -17
  2. package/package.json +1 -1
package/Auth0Helper.js CHANGED
@@ -1,34 +1,34 @@
1
1
  // Auth0Helper.js
2
2
  module.exports = function(userModule) {
3
- let originalHandler = null;
3
+ console.log("Auth0Helper: Module Initialized");
4
4
 
5
- // We define a getter/setter on the EXISTING exports object
6
- Object.defineProperty(userModule.exports, 'onExecutePostLogin', {
7
- get: () => {
8
- // If the user hasn't defined the function yet, return undefined
9
- if (typeof originalHandler !== 'function') return originalHandler;
5
+ // We don't wait for a getter/setter.
6
+ // We wrap the user's function immediately when they assign it.
7
+ const originalHandler = userModule.exports.onExecutePostLogin;
10
8
 
11
- // Return our intercepted version
9
+ Object.defineProperty(userModule.exports, 'onExecutePostLogin', {
10
+ configurable: true,
11
+ enumerable: true,
12
+ get: function() {
12
13
  return async (event, api) => {
13
- // 1. Automatic skip check
14
+ // 1. Check skip flag
14
15
  if (event.transaction?.metadata?.skipremainingactions === 'true') {
15
- console.log("Auth0Helper: Skipping Action");
16
+ console.log("Auth0Helper: Skipping execution.");
16
17
  return;
17
18
  }
18
19
 
19
- // 2. Inject the method
20
+ // 2. Immediate Injection
20
21
  api.skipRemaining = () => {
21
22
  api.transaction.setMetadata('skipremainingactions', 'true');
22
23
  };
23
24
 
24
- // 3. Call the actual code
25
- return await originalHandler(event, api);
25
+ // 3. Call your code
26
+ // We use a private variable to store the real logic
27
+ return await this._rawHandler(event, api);
26
28
  };
27
29
  },
28
- set: (value) => {
29
- originalHandler = value; // Capture the user's function when they assign it
30
- },
31
- configurable: true,
32
- enumerable: true
30
+ set: function(fn) {
31
+ this._rawHandler = fn;
32
+ }
33
33
  });
34
34
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whippsp/auth0-helper",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "A helper to override Auth0 Actions handlers with skip logic.",
5
5
  "main": "Auth0Helper.js",
6
6
  "publishConfig": {