@whippsp/auth0-helper 1.0.0
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 -0
- package/package.json +14 -0
package/Auth0Helper.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// skip-logic-lib.js
|
|
2
|
+
module.exports = function(userModule) {
|
|
3
|
+
// We use a getter/setter approach or a simple timeout to ensure
|
|
4
|
+
// we catch the export even if the user defines it AFTER requiring your lib.
|
|
5
|
+
|
|
6
|
+
process.nextTick(() => {
|
|
7
|
+
const originalHandler = userModule.exports.onExecutePostLogin;
|
|
8
|
+
|
|
9
|
+
if (typeof originalHandler === 'function') {
|
|
10
|
+
userModule.exports.onExecutePostLogin = async (event, api) => {
|
|
11
|
+
// 1. Check for skip flag
|
|
12
|
+
if (event.transaction?.metadata?.skipremainingactions === 'true') {
|
|
13
|
+
console.log("Action skipped by library.");
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 2. Add helper to api object
|
|
18
|
+
api.skipRemaining = () => {
|
|
19
|
+
api.transaction.setMetadata('skipremainingactions', 'true');
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// 3. Run original logic
|
|
23
|
+
return await originalHandler(event, api);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@whippsp/auth0-helper",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A helper to override Auth0 Actions handlers with skip logic.",
|
|
5
|
+
"main": "Auth0Helper.js",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"author": "whippsp",
|
|
13
|
+
"license": "ISC"
|
|
14
|
+
}
|