leadconduit-trustedform 2.4.7 → 2.5.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/CHANGELOG.md CHANGED
@@ -2,11 +2,32 @@
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.4.3] - 2025-01-08
5
+ ## [2.5.0] - 2025-04-08
6
+ ### Added
7
+ - v4 now includes CPL token when present ([sc-87918](https://app.shortcut.com/active-prospect/story/87918/send-cpl-data-to-trustedform))
8
+
9
+ ## [2.4.8] - 2025-03-25
10
+ ### Added
11
+ - v4 Insights now supports `bot_detected` field
12
+ - v4 Verify now appends `min_font_size_px_satisfied` and `min_contrast_ratio_satisfied`
13
+
14
+ ## [2.4.7] - 2025-03-06
15
+ ### Added
16
+ - RUI now supports being re-opened
17
+
18
+ ## [2.4.4] - 2025-01-08
6
19
  ### Fixed
7
20
  - v4 now appends `share_url` ([sc-84484](https://app.shortcut.com/active-prospect/story/84484/trustedform-v4-retain-include-trustedform-share-url-as-an-appended-field))
8
21
  and `verify.form_submitted` ([sc-84576](https://app.shortcut.com/active-prospect/story/84576/trustedform-v4-verify-include-form-submitted-as-an-appended-field))
9
22
 
23
+ ## [2.4.3] - 2024-09-26
24
+ ### Added
25
+ - v4 now supports Advertiser Name mapping and appends `one_to_one`
26
+
27
+ ## [2.4.2] - 2024-09-17
28
+ ### Fixed
29
+ - fixed an issue with appended Verify fields
30
+
10
31
  ## [2.4.1] - 2024-08-12
11
32
  ### Added
12
33
  - added "|" to be the default scan delimiter for TF version 4
@@ -4,6 +4,7 @@ const { compact, get, pickBy, isUndefined } = require('lodash');
4
4
  const request = (vars) => {
5
5
  const { lead, trustedform, insights } = vars;
6
6
  const body = {};
7
+ vars.cplToken = vars.cplToken || process.env.TRUSTEDFORM_CPL_TOKEN;
7
8
 
8
9
  if (trustedform.retain.valueOf() && (lead.email || lead.phone_1)) {
9
10
  body.match_lead = {
@@ -34,16 +35,29 @@ const request = (vars) => {
34
35
  body.verify = pickBy({ advertiser_name: advertiserName }, (v) => { return !isUndefined(v); });
35
36
  }
36
37
 
37
- return {
38
+ const headers = {
39
+ 'Content-Type': 'application/json',
40
+ 'api-version': '4.0',
41
+ Authorization: `Basic ${Buffer.from(`X:${trustedform.api_key || vars.activeprospect.api_key}`).toString('base64')}`
42
+ };
43
+
44
+ if(vars.cplToken) {
45
+ headers['CPL-Token'] = vars.cplToken;
46
+ }
47
+
48
+ const req = {
38
49
  method: 'POST',
39
50
  url: lead.trustedform_cert_url.toString(),
40
51
  body: JSON.stringify(body),
41
- headers: {
42
- 'Content-Type': 'application/json',
43
- 'api-version': '4.0',
44
- Authorization: `Basic ${Buffer.from(`X:${trustedform.api_key || vars.activeprospect.api_key}`).toString('base64')}`
45
- }
52
+ headers
46
53
  };
54
+
55
+ if(vars.cplToken) {
56
+ // mask CPL Token
57
+ vars.cplToken = Array(vars.cplToken.length + 1).join('*');
58
+ }
59
+
60
+ return req;
47
61
  };
48
62
 
49
63
  const formatProperties = (insights) => {
@@ -65,7 +79,8 @@ const formatProperties = (insights) => {
65
79
  { mapping: 'operating_system', value: 'os' },
66
80
  { mapping: 'page_url', value: 'page_url' },
67
81
  { mapping: 'parent_page_url', value: 'parent_page_url' },
68
- { mapping: 'time_on_page', value: 'seconds_on_page' }
82
+ { mapping: 'time_on_page', value: 'seconds_on_page' },
83
+ { mapping: 'bot_detected', value: 'bot_detected' }
69
84
  ];
70
85
 
71
86
  let selectedProps = insightsProps.map((field) => {
@@ -105,6 +120,7 @@ request.variables = () => [
105
120
  { name: 'insights.time_on_page', type: 'boolean', required: false, description: 'Request TrustedForm Insights time on page data?' },
106
121
  { name: 'insights.page_url', type: 'boolean', required: false, description: 'Request TrustedForm Insights page URL data?' },
107
122
  { name: 'insights.page_scan', type: 'boolean', required: false, description: 'Request TrustedForm Insights page scan data?' },
123
+ { name: 'insights.bot_detected', type: 'boolean', required: false, description: 'Request TrustedForm Insights bot detection data?' },
108
124
  { 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.' },
109
125
  { 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.' },
110
126
  { name: 'trustedform.scan_delimiter', type: 'string', required: false, description: 'Use this parameter to designate a delimiter when wrapping wildcards or template variables; defaults to |.' },
@@ -128,7 +144,8 @@ const verifyEnabled = (vars) => vars.trustedform?.verify?.valueOf();
128
144
  const hasRequiredRetainProps = (vars) => !!(vars.lead.email || vars.lead.phone_1);
129
145
  const hasAtLeastOneInsightsProp = (vars) => formatProperties(vars.insights).length > 0 || vars.insights?.page_scan?.valueOf();
130
146
  const hasVerifyData = (data) => {
131
- return data.verify?.languages || data.verify?.result?.language_approved || data.verify?.result?.success || data.verify?.result?.one_to_one;
147
+ return data.verify?.languages
148
+ || data.verify?.result;
132
149
  };
133
150
 
134
151
  const response = (vars, req, res) => {
@@ -139,10 +156,12 @@ const response = (vars, req, res) => {
139
156
  const verify = hasVerifyData(parsed)
140
157
  ? pickBy({
141
158
  languages: parsed.verify.languages.map(lang => lang.text),
142
- form_submitted: parsed.verify.result.form_submitted,
143
- language_approved: parsed.verify.result.language_approved,
159
+ form_submitted: parsed.verify.result?.form_submitted,
160
+ language_approved: parsed.verify.result?.language_approved,
161
+ font_size: parsed.verify.result?.min_font_size_px_satisfied,
162
+ contrast_ratio: parsed.verify.result?.min_contrast_ratio_satisfied,
144
163
  // note that the Verify one_to_one value is handled separately
145
- success: parsed.verify.result.success,
164
+ success: parsed.verify.result?.success,
146
165
  }, (v) => !isUndefined(v))
147
166
  : undefined;
148
167
 
@@ -194,6 +213,7 @@ const response = (vars, req, res) => {
194
213
  os_name: parsed.insights?.properties?.os?.name,
195
214
  page_url: parsed.insights?.properties?.page_url,
196
215
  parent_page_url: parsed.insights?.properties?.parent_page_url,
216
+ bot_detected: parsed.insights?.properties?.bot_detected,
197
217
  one_to_one: parsed.verify?.result?.one_to_one,
198
218
  verify
199
219
  }, (v) => { return !isUndefined(v); });
@@ -270,11 +290,14 @@ response.variables = () => [
270
290
  { name: 'os_name', type: 'string', description: 'Operating system name' },
271
291
  { name: 'page_url', type: 'string', description: 'The URL of the page hosting TrustedForm Certify.' },
272
292
  { name: 'parent_page_url', type: 'string', description: 'The parent URL of the page hosting TrustedForm Certify, if framed.' },
293
+ { name: 'bot_detected', type: 'boolean', description: 'A boolean indicating whether the events documented were likely produced by a non-human entity based on ActiveProspect\'s proprietary algorithms.' },
273
294
  { name: 'one_to_one', type: 'boolean', description: 'A boolean indicating if the cert structure satisfied the requirements for 1:1 consent.' },
274
295
  { name: 'verify.languages', type: 'array', description: 'A list of the consent languages detected within the certificate' },
275
296
  { name: 'verify.language_approved', type: 'boolean', description: 'A boolean indicating if any of the consent languages found have been approved in your account\'s consent language manager.' },
276
297
  { name: 'verify.form_submitted', type: 'boolean', description: 'A boolean indicating whether the form was successfully submitted by the consumer.' },
277
298
  { name: 'verify.success', type: 'boolean', description: 'A boolean indicating if any of the consent languages found meet the success criteria defined for your account.' },
299
+ { name: 'verify.font_size', type: 'boolean', description: 'True when the consent language font size meets or exceeds the value configured in TrustedForm.' },
300
+ { name: 'verify.contrast_ratio', type: 'boolean', description: 'True when the contrast ratio between the consent language text and background meets or exceeds the value configured in TrustedForm.' }
278
301
  ];
279
302
 
280
303
  const editable = true;
@@ -10,7 +10,7 @@ module.exports = (req, res) => {
10
10
  'test': 'https://app.staging.trustedform.com/account',
11
11
  'development': 'https://app.trustedform-dev.com/account',
12
12
  };
13
- const url = trustedFormUrl[process.env.NODE_ENV] || trustedFormUrl['development'];
13
+ const url = trustedFormUrl[process?.env.NODE_ENV] || trustedFormUrl['development'];
14
14
 
15
15
  const options = {
16
16
  url,
@@ -29,6 +29,11 @@ module.exports = {
29
29
  description: 'Whether or not the lead event took place inside of an iframe. <a href="https://www.techtarget.com/whatis/definition/IFrame-Inline-Frame" target="_blank">Learn More.</a>',
30
30
  enabled: false
31
31
  },
32
+ bot_detected: {
33
+ name: 'Bot Detection',
34
+ description: 'A determination of whether the events documented were likely produced by a non-human entity based on ActiveProspect’s proprietary algorithms. <a href="https://community.activeprospect.com/posts/5424099" target="_blank">Learn more.</a>',
35
+ enabled: false
36
+ },
32
37
  form_input_method: {
33
38
  name: 'Form Input Method',
34
39
  description: 'A list of ways the consumer input their data onto the form including one or more of the following: typing, paste, autofill.',