@whippsp/auth0-helper 1.0.8 → 1.0.9
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 +21 -10
- package/package.json +1 -1
package/Auth0Helper.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// Auth0Helper.js
|
|
2
|
-
module.exports = function(userModule) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// We don't wait for a getter/setter.
|
|
2
|
+
module.exports = function(userModule, initialConfig = {}) {
|
|
3
|
+
// We don't wait for a getter/setter.
|
|
6
4
|
// We wrap the user's function immediately when they assign it.
|
|
7
5
|
const originalHandler = userModule.exports.onExecutePostLogin;
|
|
8
6
|
|
|
@@ -11,20 +9,33 @@ module.exports = function(userModule) {
|
|
|
11
9
|
enumerable: true,
|
|
12
10
|
get: function() {
|
|
13
11
|
return async (event, api) => {
|
|
14
|
-
|
|
12
|
+
|
|
13
|
+
let runtimeConfig = { ...initialConfig };
|
|
14
|
+
|
|
15
|
+
api.setHelperConfig = (newConfig) => {
|
|
16
|
+
runtimeConfig = { ...runtimeConfig, ...newConfig };
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const log = (message) => {
|
|
20
|
+
if (runtimeConfig.debug === true) {
|
|
21
|
+
console.log(`[${runtimeConfig.ActionName || "Auth0Action"}] ${message}`);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
15
25
|
if (event.transaction?.metadata?.skipremainingactions === 'true') {
|
|
16
|
-
|
|
26
|
+
log(`Auth0Helper: Skipping execution ${runtimeConfig.ActionName}.`);
|
|
17
27
|
return;
|
|
18
28
|
}
|
|
19
29
|
|
|
20
|
-
// 2. Immediate Injection
|
|
21
30
|
api.skipRemaining = () => {
|
|
31
|
+
log("skipRemaining called. Setting metadata flag.");
|
|
22
32
|
api.transaction.setMetadata('skipremainingactions', 'true');
|
|
23
33
|
};
|
|
24
34
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
const targetFn = this._rawHandler || originalHandler;
|
|
36
|
+
if (typeof targetFn === 'function') {
|
|
37
|
+
return await targetFn(event, api);
|
|
38
|
+
}
|
|
28
39
|
};
|
|
29
40
|
},
|
|
30
41
|
set: function(fn) {
|