@whippsp/auth0-helper 1.0.7 → 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.
- package/Auth0Helper.js +27 -33
- package/package.json +1 -1
package/Auth0Helper.js
CHANGED
|
@@ -1,40 +1,34 @@
|
|
|
1
1
|
// Auth0Helper.js
|
|
2
2
|
module.exports = function(userModule) {
|
|
3
|
-
|
|
4
|
-
if (!userModule || !userModule.exports) {
|
|
5
|
-
console.error("Auth0Helper: userModule.exports is undefined. Ensure you pass 'module'.");
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
3
|
+
console.log("Auth0Helper: Module Initialized");
|
|
8
4
|
|
|
9
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
Object.defineProperty(userModule.exports, 'onExecutePostLogin', {
|
|
10
|
+
configurable: true,
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return async (event, api) => {
|
|
14
|
+
// 1. Check skip flag
|
|
15
|
+
if (event.transaction?.metadata?.skipremainingactions === 'true') {
|
|
16
|
+
console.log("Auth0Helper: Skipping execution.");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// 2. Method Injection
|
|
23
|
-
api.skipRemaining = () => {
|
|
24
|
-
api.transaction.setMetadata('skipremainingactions', 'true');
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// 3. Call your code
|
|
28
|
-
return await originalHandler(event, api);
|
|
20
|
+
// 2. Immediate Injection
|
|
21
|
+
api.skipRemaining = () => {
|
|
22
|
+
api.transaction.setMetadata('skipremainingactions', 'true');
|
|
29
23
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
24
|
+
|
|
25
|
+
// 3. Call your code
|
|
26
|
+
// We use a private variable to store the real logic
|
|
27
|
+
return await this._rawHandler(event, api);
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
set: function(fn) {
|
|
31
|
+
this._rawHandler = fn;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
40
34
|
};
|