@whippsp/auth0-helper 1.0.1 → 1.0.3

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 +13 -19
  2. package/package.json +1 -1
package/Auth0Helper.js CHANGED
@@ -1,30 +1,24 @@
1
1
  module.exports = function(userModule) {
2
- let originalHandler = null;
3
-
4
- // Use a getter/setter on exports to "trap" the function definition
5
- Object.defineProperty(userModule.exports, 'onExecutePostLogin', {
6
- get: () => {
7
- return async (event, api) => {
8
- // 1. Logic to check skip flag
2
+ // Use a short delay to ensure the user has defined their exports
3
+ setImmediate(() => {
4
+ const original = userModule.exports.onExecutePostLogin;
5
+
6
+ if (typeof original === 'function') {
7
+ userModule.exports.onExecutePostLogin = async (event, api) => {
8
+ // 1. Automatic skip logic
9
9
  if (event.transaction?.metadata?.skipremainingactions === 'true') {
10
- return;
10
+ console.log("Skipping.");
11
+ return;
11
12
  }
12
13
 
13
- // 2. Inject the helper
14
+ // 2. Inject your custom method directly into the api object
14
15
  api.skipRemaining = () => {
15
16
  api.transaction.setMetadata('skipremainingactions', 'true');
16
17
  };
17
18
 
18
- // 3. Run original logic if it exists
19
- if (originalHandler) {
20
- return await originalHandler(event, api);
21
- }
19
+ // 3. Call the original code
20
+ return await original(event, api);
22
21
  };
23
- },
24
- set: (value) => {
25
- originalHandler = value; // Capture the user's function
26
- },
27
- configurable: true,
28
- enumerable: true
22
+ }
29
23
  });
30
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whippsp/auth0-helper",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A helper to override Auth0 Actions handlers with skip logic.",
5
5
  "main": "Auth0Helper.js",
6
6
  "publishConfig": {