leadconduit-trustedform 2.2.0 → 2.2.2

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/lib/helpers.js CHANGED
@@ -79,22 +79,14 @@ const tfFacebookRegex = /^https?:\/\/cert.trustedform.com\/0\./;
79
79
  const tfStagingRegex = /^https?:\/\/cert.staging.trustedform.com\/([-_a-zA-Z0-9]{40}|[-_a-zA-Z0-9]{80})$/;
80
80
  const tfStagingFacebook = /^https?:\/\/cert.staging.trustedform.com\/0\./;
81
81
 
82
- // same as above, for development
83
- const tfDevelopmentRegex = /^https?:\/\/cert.trustedform-dev.com\/([-_a-zA-Z0-9]{40}|[-_a-zA-Z0-9]{80})$/;
84
- const tfDevelopmentFacebook = /^https?:\/\/cert.trustedform-dev.com\/0\./;
85
-
86
82
  const validate = (vars) => {
87
83
  const certUrl = _.get(vars.lead, 'trustedform_cert_url');
88
84
  if (!certUrl) return 'TrustedForm cert URL must not be blank';
89
- const productionValid = (tfRegex.test(getUrlString(certUrl)) || tfFacebookRegex.test(getUrlString(certUrl)));
90
- const developmentValid = (process.env.NODE_ENV === 'development' && (tfDevelopmentRegex.test(getUrlString(certUrl)) || tfDevelopmentFacebook.test(getUrlString(certUrl))));
91
- const stagingValid = (process.env.NODE_ENV === 'staging' && (tfStagingRegex.test(getUrlString(certUrl)) || tfStagingFacebook.test(getUrlString(certUrl))));
92
85
 
93
- if (!productionValid && !stagingValid && !developmentValid) return 'TrustedForm cert URL must be valid';
94
- };
86
+ const productionValid = (tfRegex.test(certUrl) || tfFacebookRegex.test(certUrl));
87
+ const stagingValid = (process.env.NODE_ENV !== 'production' && (tfStagingRegex.test(certUrl) || tfStagingFacebook.test(certUrl)));
95
88
 
96
- const getUrlString = (url) => {
97
- return typeof url === 'object' ? url.raw : url;
89
+ if (!productionValid && !stagingValid) return 'TrustedForm cert URL must be valid';
98
90
  };
99
91
 
100
92
  const getLeadConduitUrl = (env = process.env.NODE_ENV) => {
@@ -19,7 +19,7 @@ const request = (vars) => {
19
19
  if (trustedform.insights.valueOf()) {
20
20
  body.insights = {
21
21
  properties: formatProperties(insights)
22
- };
22
+ }
23
23
  if (insights.page_scan?.valueOf()) {
24
24
  body.insights.scans = {
25
25
  required: trustedform.scan_required_text,
@@ -28,9 +28,6 @@ const request = (vars) => {
28
28
  };
29
29
  }
30
30
  }
31
- if (trustedform.verify.valueOf()) {
32
- body.verify = {};
33
- }
34
31
 
35
32
  return {
36
33
  method: 'POST',
@@ -41,7 +38,7 @@ const request = (vars) => {
41
38
  'api-version': '4.0',
42
39
  Authorization: `Basic ${Buffer.from(`X:${vars.activeprospect.api_key}`).toString('base64')}`
43
40
  }
44
- };
41
+ }
45
42
  };
46
43
 
47
44
  const formatProperties = (insights) => {
@@ -102,24 +99,19 @@ request.variables = () => [
102
99
  { name: 'insights.time_on_page', type: 'boolean', required: false, description: 'Request TrustedForm Insights time on page data?' },
103
100
  { name: 'insights.page_url', type: 'boolean', required: false, description: 'Request TrustedForm Insights page URL data?' },
104
101
  { name: 'insights.page_scan', type: 'boolean', required: false, description: 'Request TrustedForm Insights page scan data?' },
105
- { name: 'trustedform.scan_required_text', type: 'string', required: false, description: 'A list of required text to scan for. TrustedForm will then perform a case and whitespace insensitive search for the string.' },
106
- { name: 'trustedform.scan_forbidden_text', type: 'string', required: false, description: 'A list of forbidden text to scan for. TrustedForm will then perform a case and whitespace insensitive search for the string.' },
107
- { name: 'trustedform.scan_delimiter', type: 'string', required: false, description: 'Use this parameter to designate a delimiter when wrapping wildcards or template variables; defaults to |.' },
108
-
109
- { name: 'trustedform.verify', type: 'boolean', required: true, description: 'If true, a request to the Verify product will be made'}
102
+ { name: 'trustedform.scan_required_text', type: 'array', required: false, description: 'A list of required text to scan for. TrustedForm will then perform a case and whitespace insensitive search for the string.' },
103
+ { name: 'trustedform.scan_forbidden_text', type: 'array', required: false, description: 'A list of forbidden text to scan for. TrustedForm will then perform a case and whitespace insensitive search for the string.' },
104
+ { name: 'trustedform.scan_delimiter', type: 'string', required: false, description: 'Use this parameter to designate a delimiter when wrapping wildcards or template variables; defaults to |.' }
110
105
  ];
111
106
 
112
107
  const validate = (vars) => {
113
- const certError = helpers.validate(vars);
108
+ const certError = helpers.validate(vars)
114
109
  if (certError) return certError;
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';
118
- };
110
+ if (!vars.trustedform?.retain?.valueOf() && !vars.trustedform?.insights.valueOf()) return 'a TrustedForm product must be selected';
111
+ 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'
112
+ if (!vars.trustedform?.retain?.valueOf() && formatProperties(vars.insights).length === 0 && !vars.insights.page_scan?.valueOf()) return 'no properties selected for TrustedForm Insights';
113
+ }
119
114
 
120
- const hasTrustedFormProduct = (vars) => {
121
- return vars.trustedform?.retain?.valueOf() || vars.trustedform?.insights?.valueOf() || vars.trustedform?.verify?.valueOf();
122
- };
123
115
  const response = (vars, req, res) => {
124
116
  if (res.status < 500) {
125
117
  try {
@@ -170,12 +162,8 @@ const response = (vars, req, res) => {
170
162
  is_mobile: parsed.insights?.properties?.os?.is_mobile,
171
163
  os_name: parsed.insights?.properties?.os?.name,
172
164
  page_url: parsed.insights?.properties?.page_url,
173
- parent_page_url: parsed.insights?.properties?.parent_page_url,
174
-
175
- languages: parsed.insights?.properties?.languages,
176
- language_approved: parsed.insights?.properties?.language_approved,
177
- success: parsed.verify?.results?.success,
178
- }, (v) => { return !isUndefined(v); });
165
+ parent_page_url: parsed.insights?.properties?.parent_page_url
166
+ }, (v) => { return !isUndefined(v) });
179
167
  } else {
180
168
  return {
181
169
  outcome: parsed.outcome,
@@ -238,14 +226,11 @@ response.variables = () => [
238
226
  { name: 'is_mobile', type: 'boolean', description: 'A boolean indicating that the form was filled out on a mobile device or tablet, based on user-agent' },
239
227
  { name: 'os_name', type: 'string', description: 'Operating system name' },
240
228
  { name: 'page_url', type: 'string', description: 'The URL of the page hosting TrustedForm Certify.' },
241
- { name: 'parent_page_url', type: 'string', description: 'The parent URL of the page hosting TrustedForm Certify, if framed.' },
242
- { name: 'verify.languages', type: 'array', description: 'A list of the consent languages detected within the certificate' },
243
- { name: 'verify.language_approved', type: 'string', description: 'A boolean indicating if any of the consent languages found have been approved in your account\'s consent language manager.' },
244
- { name: 'verify.success', type: 'boolean', description: 'A boolean indicating if any of the consent languages found meet the success criteria defined for your account.' },
229
+ { name: 'parent_page_url', type: 'string', description: 'The parent URL of the page hosting TrustedForm Certify, if framed.' }
245
230
  ];
246
231
 
247
232
  module.exports = {
248
233
  request,
249
234
  response,
250
235
  validate
251
- };
236
+ }
@@ -5,13 +5,7 @@ module.exports = (req, res) => {
5
5
  const { apiKey } = req.query;
6
6
  if (!apiKey) return res.status(422).send({ error: 'missing required field: apiKey' });
7
7
 
8
- const trustedFormUrl = {
9
- 'production': 'https://app.trustedform.com/account',
10
- 'staging': 'https://app.staging.trustedform.com/account',
11
- 'development': 'https://app.trustedform-dev.com/account',
12
- };
13
- const environment = get(process, 'env.NODE_ENV') || 'development';
14
- const url = trustedFormUrl[environment];
8
+ const url = get(process, 'env.NODE_ENV') === 'production' ? 'https://app.trustedform.com/account' : 'https://app.staging.trustedform.com/account';
15
9
 
16
10
  const options = {
17
11
  url,
@@ -5,4 +5,4 @@ const account = require('./account');
5
5
  module.exports =
6
6
  express.Router()
7
7
  .use(json())
8
- .use('/account', account);
8
+ .use('/account', account)
@@ -16,10 +16,6 @@
16
16
  <input type="checkbox" :disabled="!products.insights.enabled" v-model="products.insights.selected"><span> Insights</span>
17
17
  <p class="help-text">TrustedForm Insights helps buyers identify the leads that are most likely to convert and effectively manage returns and rejections.</p>
18
18
  </li>
19
- <li>
20
- <input type="checkbox" :disabled="!products.verify.enabled" v-model="products.verify.selected"><span> Verify</span>
21
- <p class="help-text">Confirm that your leads were shown consent language that meets your compliance requirements.</p>
22
- </li>
23
19
  </ul>
24
20
  </form>
25
21
  </section>
@@ -27,12 +23,12 @@
27
23
  :showPrevious="false"
28
24
  :onNext="!showFinish ? next : undefined"
29
25
  :onFinish="showFinish ? finish : undefined"
30
- :disableNext="!products.retain.selected && !products.insights.selected && !products.verify.selected"
26
+ :disableNext="!products.retain.selected && !products.insights.selected"
31
27
  />
32
28
  </div>
33
29
  </template>
34
30
  <script>
35
- import { Navigation } from '@activeprospect/integration-components';
31
+ import { Navigation } from '@activeprospect/integration-components'
36
32
 
37
33
  export default {
38
34
  data () {
@@ -46,7 +42,7 @@ export default {
46
42
  },
47
43
  computed: {
48
44
  showFinish () {
49
- return (this.products.retain.selected ||this.products.verify.selected ) && !this.products.insights.selected;
45
+ return this.products.retain.selected && !this.products.insights.selected;
50
46
  }
51
47
  },
52
48
  methods: {
@@ -60,7 +56,7 @@ export default {
60
56
  }
61
57
  },
62
58
  created () {
63
- this.$store.dispatch('getProducts');
59
+ this.$store.dispatch('getProducts')
64
60
  }
65
61
  };
66
62
  </script>
@@ -16,10 +16,8 @@ const initStore = (config, ui) => new Vuex.Store({
16
16
  errors: undefined,
17
17
  products: {
18
18
  retain: { enabled: false, selected: false },
19
- insights: { enabled: false, selected: false },
20
- verify: { enabled: false, selected: false }
21
- },
22
- filters: []
19
+ insights: { enabled: false, selected: false }
20
+ }
23
21
  },
24
22
  mutations: {
25
23
  setErrors (state, errors) {
@@ -27,9 +25,6 @@ const initStore = (config, ui) => new Vuex.Store({
27
25
  },
28
26
  setProduct (state, { product, value }) {
29
27
  state.products[product] = value;
30
- },
31
- setFilters(state, filters) {
32
- state.filters = filters;
33
28
  }
34
29
  },
35
30
  getters: {
@@ -50,10 +45,9 @@ const initStore = (config, ui) => new Vuex.Store({
50
45
  .then(function (response) {
51
46
  const availableProducts = [
52
47
  'retain',
53
- 'insights',
54
- 'verify'
55
- ];
56
- const products = get(response, 'data.product_components');
48
+ 'insights'
49
+ ]
50
+ const products = get(response, 'data.product_components');
57
51
  availableProducts.forEach(function (product) {
58
52
  context.commit('setProduct', { product, value: {
59
53
  enabled: products.includes(product),
@@ -69,25 +63,7 @@ const initStore = (config, ui) => new Vuex.Store({
69
63
  }
70
64
  });
71
65
  },
72
- createFilter(context, filterConfig) {
73
- const filter = {
74
- type: 'filter',
75
- reason: filterConfig.reason,
76
- outcome: filterConfig.outcome,
77
- rule_set: {
78
- op: 'and',
79
- rules: [{
80
- op: filterConfig.rulesOp,
81
- lhv: filterConfig.lhv,
82
- rhv: filterConfig.rhv
83
- }]
84
- },
85
- description: filterConfig.description,
86
- enabled: true
87
- };
88
- context.commit('setFilters', [...context.state.filters, filter]);
89
- },
90
- async finish (context) {
66
+ finish (context) {
91
67
  const { products, v4Fields } = context.state;
92
68
  const flow = {
93
69
  steps: [{
@@ -100,9 +76,8 @@ const initStore = (config, ui) => new Vuex.Store({
100
76
  module_id: config.integration,
101
77
  mappings: []
102
78
  }
103
- }],
79
+ }]
104
80
  };
105
-
106
81
  if (config.integration === 'leadconduit-trustedform.outbound.trustedform') {
107
82
  Object.keys(products).forEach((product) => {
108
83
  flow.steps[0].integration.mappings.push({
@@ -116,24 +91,9 @@ const initStore = (config, ui) => new Vuex.Store({
116
91
  flow.steps[0].integration.mappings.push({
117
92
  property: `insights.${field}`,
118
93
  value: v4Fields[field].selected ? 'true' : 'false'
119
- });
94
+ })
120
95
  });
121
96
  }
122
-
123
- if (products.verify.selected) {
124
- const filterConfig = {
125
- reason: '{{trustedform.reason}}',
126
- rulesOp: 'is not equal to',
127
- lhv: 'trustedform.outcome',
128
- rhv: 'success',
129
- outcome: 'failure',
130
- description: 'Filter leads that fail on Trustedform Verify check'
131
- };
132
- await context.dispatch('createFilter', filterConfig);
133
- }
134
- context.state.filters.forEach(filter => {
135
- flow.steps.push(filter);
136
- });
137
97
  }
138
98
  context.state.ui.create({ flow });
139
99
  }
@@ -93,5 +93,5 @@ module.exports = {
93
93
  name: 'Time On Page',
94
94
  description: 'The amount of time, in seconds, that the consumer spent on the page during the lead event.',
95
95
  enabled: false
96
- },
97
- };
96
+ }
97
+ }