@whippsp/auth0-helper 1.0.5 → 1.0.7
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 +36 -20
- package/package.json +1 -1
package/Auth0Helper.js
CHANGED
|
@@ -1,24 +1,40 @@
|
|
|
1
1
|
// Auth0Helper.js
|
|
2
|
-
module.exports = function
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (event.transaction?.metadata?.skipremainingactions === 'true') {
|
|
9
|
-
console.log("Auth0Helper: Skipping this action (flag detected).");
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
2
|
+
module.exports = function(userModule) {
|
|
3
|
+
// Safety check: Ensure we have a valid module object
|
|
4
|
+
if (!userModule || !userModule.exports) {
|
|
5
|
+
console.error("Auth0Helper: userModule.exports is undefined. Ensure you pass 'module'.");
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
// We attach the helper directly to the api object instance for this execution.
|
|
15
|
-
api.skipRemaining = function() {
|
|
16
|
-
api.transaction.setMetadata('skipremainingactions', 'true');
|
|
17
|
-
console.log("Auth0Helper: skipRemaining flag set.");
|
|
18
|
-
};
|
|
9
|
+
let originalHandler = null;
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
try {
|
|
12
|
+
Object.defineProperty(userModule.exports, 'onExecutePostLogin', {
|
|
13
|
+
get: () => {
|
|
14
|
+
if (typeof originalHandler !== 'function') return originalHandler;
|
|
15
|
+
|
|
16
|
+
return async (event, api) => {
|
|
17
|
+
// 1. Skip logic
|
|
18
|
+
if (event.transaction?.metadata?.skipremainingactions === 'true') {
|
|
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);
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
set: (value) => {
|
|
32
|
+
originalHandler = value;
|
|
33
|
+
},
|
|
34
|
+
configurable: true,
|
|
35
|
+
enumerable: true
|
|
36
|
+
});
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.error("Auth0Helper: Failed to define property. Runtime may be restricted.", e);
|
|
39
|
+
}
|
|
24
40
|
};
|