leadconduit-trustedform 2.3.0 → 2.3.1

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.
@@ -5,7 +5,7 @@ jobs:
5
5
  runs-on: ubuntu-latest
6
6
  strategy:
7
7
  matrix:
8
- node-version: [16.x, 18.x, latest]
8
+ node-version: [18.x, 20.x, latest]
9
9
  env:
10
10
  NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
11
11
  steps:
package/CHANGELOG.md CHANGED
@@ -2,6 +2,34 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org)
4
4
 
5
+ ## [2.3.1] - 2024-01-10
6
+ ### Fixed
7
+ - v4 `validate` function will properly handle missing `insights` vars ([sc-65226](https://app.shortcut.com/active-prospect/story/65226/trustedform-v4-insights-add-on-with-no-field-mappings-errors-in-validation))
8
+
9
+ ## [2.3.0] - 2023-11-20
10
+ ### Fixed
11
+ - Re-add fixed TrustedForm v4 Verify Add-On ([#105](https://github.com/activeprospect/leadconduit-integration-trustedform/pull/105), [sc-63442](https://app.shortcut.com/active-prospect/story/63442/trustedform-v4-add-verify-to-add-on))
12
+
13
+ ## [2.2.2] - 2023-11-17
14
+ ### Fixed
15
+ - Revert [#102](https://github.com/activeprospect/leadconduit-integration-trustedform/pull/102)
16
+
17
+ ## [2.2.1] - 2023-11-17
18
+ ### Fixed
19
+ - Page scan variables are now typed as arrays ([#103](https://github.com/activeprospect/leadconduit-integration-trustedform/pull/103))
20
+
21
+ ## [2.2.0] - 2023-11-15
22
+ ### Added
23
+ - TrustedForm v4 Verify Add-On ([sc-63442](https://app.shortcut.com/active-prospect/story/63442/trustedform-v4-add-verify-to-add-on))
24
+
25
+ ## [2.1.1] - 2023-07-14
26
+ ### Fixed
27
+ - Updated "Age" and "Age in Seconds" description for TF Inisights and TF Consent + Insights ([sc-48650](https://app.shortcut.com/active-prospect/story/48650/incorrect-description-for-age-in-the-trustedform-enhancements))
28
+
29
+ ## [2.1.0] - 2023-06-20
30
+ ### Added
31
+ - TrustedForm v4 Integration ([sc-50245](https://app.shortcut.com/active-prospect/story/50245/trustedform-v4-new-integration-trustedform))
32
+
5
33
  ## [2.0.3] - 2023-02-21
6
34
  ### Fixed
7
35
  - `domain` data is now appended if returned as part of insights data
package/lib/claim.js CHANGED
@@ -34,6 +34,7 @@ const requestVariables = () => [
34
34
  { name: 'lead.phone_3', type: 'string', required: false, description: 'Lead phone 3 that will be fingerprinted, defaults to the lead\'s "Phone 3" field' }
35
35
  ];
36
36
 
37
+ // eslint-disable-next-line complexity
37
38
  const parseResponse = (res, body, vars) => {
38
39
  let appended = {};
39
40
  const event = body;
package/lib/consent.js CHANGED
@@ -64,6 +64,7 @@ const parseCertData = (cert) => {
64
64
  };
65
65
  };
66
66
 
67
+ // eslint-disable-next-line complexity
67
68
  const parseResponse = (statusCode, body, vars) => {
68
69
  let appended = {};
69
70
  const event = body;
@@ -67,7 +67,7 @@ const formatProperties = (insights) => {
67
67
  ];
68
68
 
69
69
  let selectedProps = insightsProps.map((field) => {
70
- if (insights[field.mapping]?.valueOf()) return field.value;
70
+ if (insights?.[field.mapping]?.valueOf()) return field.value;
71
71
  });
72
72
 
73
73
  return compact(selectedProps);
@@ -113,13 +113,18 @@ const validate = (vars) => {
113
113
  const certError = helpers.validate(vars);
114
114
  if (certError) return certError;
115
115
  if (!hasTrustedFormProduct(vars)) return 'a TrustedForm product must be selected';
116
- if (!vars.trustedform?.insights?.valueOf() && !(vars.lead.email || vars.lead.phone_1)) return 'an email address or phone number is required to use TrustedForm Retain';
117
- if (!vars.trustedform?.retain?.valueOf() && !vars.trustedform?.verify?.valueOf() && formatProperties(vars.insights).length === 0 && !vars.insights.page_scan?.valueOf()) return 'no properties selected for TrustedForm Insights';
116
+ if (retainEnabled(vars) && !hasRequiredRetainProps(vars)) return 'an email address or phone number is required to use TrustedForm Retain';
117
+ if (insightsEnabled(vars) && !hasAtLeastOneInsightsProp(vars)) return 'no properties selected for TrustedForm Insights';
118
118
  };
119
119
 
120
- const hasTrustedFormProduct = (vars) => {
121
- return vars.trustedform?.retain?.valueOf() || vars.trustedform?.insights?.valueOf() || vars.trustedform?.verify?.valueOf();
122
- };
120
+ const hasTrustedFormProduct = (vars) => retainEnabled(vars) || insightsEnabled(vars) || verifyEnabled(vars);
121
+ const retainEnabled = (vars) => vars.trustedform?.retain?.valueOf();
122
+ const insightsEnabled = (vars) => vars.trustedform?.insights?.valueOf();
123
+ const verifyEnabled = (vars) => vars.trustedform?.verify?.valueOf();
124
+ const hasRequiredRetainProps = (vars) => !!(vars.lead.email || vars.lead.phone_1);
125
+ const hasAtLeastOneInsightsProp = (vars) => formatProperties(vars.insights).length > 0 || vars.insights?.page_scan?.valueOf();
126
+
127
+
123
128
  const response = (vars, req, res) => {
124
129
  if (res.status < 500) {
125
130
  try {