Skip to content

Commit

Permalink
Release v0.18.0 (#280)
Browse files Browse the repository at this point in the history
* npm run format

* npm run build

* bump version
  • Loading branch information
joshcanhelp authored Mar 29, 2021
1 parent 77f172a commit 225050c
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 103 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rules-templates",
"version": "0.17.0",
"version": "0.18.0",
"description": "Auth0 Rules Repository",
"main": "./rules",
"scripts": {
Expand Down
197 changes: 112 additions & 85 deletions rules.json

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions src/rules/arengu-progressive-profiling.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* @title Arengu Progressive Profiling
* @title Arengu Progressive Profiling
* @overview Capture new users' information in your authentication flows.
* @gallery true
* @category marketplace
*/

async function arenguCompleteUserProfile(user, context, callback) {
async function arenguCompleteUserProfile(user, context, callback) {
if (
!configuration.SESSION_TOKEN_SECRET ||
!configuration.ARENGU_PROFILE_FORM_URL
Expand All @@ -17,7 +17,7 @@
const {
Auth0RedirectRuleUtilities,
Auth0UserUpdateUtilities
} = require("@auth0/[email protected]");
} = require('@auth0/[email protected]');

const ruleUtils = new Auth0RedirectRuleUtilities(
user,
Expand All @@ -42,14 +42,16 @@
}

function isEmptyUserMeta(key) {
return userUtils.getUserMeta(key) === undefined ||
return (
userUtils.getUserMeta(key) === undefined ||
userUtils.getUserMeta(key) === null ||
userUtils.getUserMeta(key).length === 0;
userUtils.getUserMeta(key).length === 0
);
}

function isProfileIncomplete() {
// Add your required user_medata keys
return isEmptyUserMeta('job_title') || isEmptyUserMeta('company_name');
return isEmptyUserMeta('job_title') || isEmptyUserMeta('company_name');
}

if (ruleUtils.isRedirectCallback && ruleUtils.queryParams.session_token) {
Expand All @@ -74,4 +76,4 @@
}

return callback(null, user, context);
}
}
8 changes: 6 additions & 2 deletions src/rules/incognia-authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ async function incogniaAuthenticationRule(user, context, callback) {
return callback(null, user, context);
}

const installationId = _.get(context, 'request.query.incognia_installation_id');
const installationId = _.get(
context,
'request.query.incognia_installation_id'
);
if (!installationId) {
console.log('Missing installation_id. Skipping.');
return callback(null, user, context);
Expand Down Expand Up @@ -49,7 +52,8 @@ async function incogniaAuthenticationRule(user, context, callback) {
// Incognia's risk assessment will be in a namespaced claim so it can be used in other rules
// for skipping/prompting MFA or in the mobile app itself to decide whether the user should be
// redirected to step-up auth for example.
context.idToken["https://www.incognia.com/assessment"] = loginAssessment.riskAssessment;
context.idToken['https://www.incognia.com/assessment'] =
loginAssessment.riskAssessment;
} catch (error) {
console.log('Error calling Incognia API for a new login.');
return callback(error);
Expand Down
27 changes: 20 additions & 7 deletions src/rules/incognia-onboarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ async function incogniaOnboardingRule(user, context, callback) {
const { IncogniaAPI } = require('@incognia/[email protected]');
const { Auth0UserUpdateUtilities } = require('@auth0/[email protected]');

const { INCOGNIA_CLIENT_ID, INCOGNIA_CLIENT_SECRET, INCOGNIA_HOME_ADDRESS_PROP } = configuration;
const {
INCOGNIA_CLIENT_ID,
INCOGNIA_CLIENT_SECRET,
INCOGNIA_HOME_ADDRESS_PROP
} = configuration;

if (!INCOGNIA_CLIENT_ID || !INCOGNIA_CLIENT_SECRET) {
console.log('Missing required configuration. Skipping.');
return callback(null, user, context);
}

const installationId = _.get(context, 'request.query.incognia_installation_id');
const installationId = _.get(
context,
'request.query.incognia_installation_id'
);
if (!installationId) {
console.log('Missing installation_id. Skipping.');
return callback(null, user, context);
Expand All @@ -27,7 +34,8 @@ async function incogniaOnboardingRule(user, context, callback) {
// User home address should be set using Auth0's Signup API for example. If the home address is
// not in 'user_metadata.home_address', please specify the path of the field inside the user
// object where the home address is through the INCOGNIA_HOME_ADDRESS_PROP configuration.
const homeAddressProp = INCOGNIA_HOME_ADDRESS_PROP || 'user_metadata.home_address';
const homeAddressProp =
INCOGNIA_HOME_ADDRESS_PROP || 'user_metadata.home_address';
const homeAddress = _.get(user, homeAddressProp);
if (!homeAddress) {
console.log('Missing user home address. Skipping.');
Expand All @@ -39,7 +47,9 @@ async function incogniaOnboardingRule(user, context, callback) {
const status = userUtils.getAppMeta('status');
// This rule was previously run and calculated the assessment successfully.
if (status && status !== 'pending') {
console.log('Assessment is already calculated or is unevaluable. Skipping.');
console.log(
'Assessment is already calculated or is unevaluable. Skipping.'
);
return callback(null, user, context);
}

Expand All @@ -59,12 +69,14 @@ async function incogniaOnboardingRule(user, context, callback) {
// The rule was previously run, but Incognia could not assess the signup.
if (signupId) {
try {
onboardingAssessment = await incogniaAPI.getOnboardingAssessment(signupId);
onboardingAssessment = await incogniaAPI.getOnboardingAssessment(
signupId
);
} catch (error) {
console.log('Error calling Incognia API for signup previously submitted');
return callback(error);
}
// This is the first time the rule is being run with all necessary arguments.
// This is the first time the rule is being run with all necessary arguments.
} else {
try {
onboardingAssessment = await incogniaAPI.registerOnboardingAssessment({
Expand All @@ -90,7 +102,8 @@ async function incogniaOnboardingRule(user, context, callback) {
} else if (!firstAssessmentAt) {
newStatus = 'pending';
} else {
const firstAssessmentAge = Math.round(Date.now() / 1000) - firstAssessmentAt;
const firstAssessmentAge =
Math.round(Date.now() / 1000) - firstAssessmentAt;
// 48 hours limit.
if (firstAssessmentAge > 172800) {
newStatus = 'unevaluable';
Expand Down

0 comments on commit 225050c

Please sign in to comment.