Skip to content

Commit

Permalink
fix v4 to append share_url (#122)
Browse files Browse the repository at this point in the history
* fix v4 to append share_url and verify.form_submitted
  • Loading branch information
cgrayson authored Jan 10, 2025
1 parent 4cfaf18 commit 1699001
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org)

## [2.4.3] - 2025-01-08
### Fixed
- 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))
and `verify.form_submitted` ([sc-84576](https://app.shortcut.com/active-prospect/story/84576/trustedform-v4-verify-include-form-submitted-as-an-appended-field))

## [2.4.1] - 2024-08-12
### Added
- added "|" to be the default scan delimiter for TF version 4
Expand Down
17 changes: 11 additions & 6 deletions lib/trustedform.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,16 @@ const response = (vars, req, res) => {
try {
const parsed = JSON.parse(res.body);
if (res.status === 200) {
const verify = hasVerifyData(parsed)
const verify = hasVerifyData(parsed)
? pickBy({
languages: parsed.verify.languages.map(lang => lang.text),
form_submitted: parsed.verify.result.form_submitted,
language_approved: parsed.verify.result.language_approved,
// note that the Verify one_to_one value is handled separately
success: parsed.verify.result.success,
}, (v) => !isUndefined(v))
: undefined;
}, (v) => !isUndefined(v))
: undefined;

const appended = pickBy({
outcome: parsed.outcome,
reason: parsed.reason,
Expand All @@ -153,12 +155,13 @@ const response = (vars, req, res) => {
successful_match: parsed.match_lead?.result?.success,
email_fingerprint_matched: parsed.match_lead?.result?.email_match,
phone_fingerprint_matched: parsed.match_lead?.result?.phone_match,

reference_code: parsed.retain?.reference,
vendor: parsed.retain?.vendor,

previously_retained: parsed.retain?.results?.previously_retained,
expires_at: parsed.retain?.results?.expires_at || parsed.insights?.properties?.expires_at,
masked_cert_url: parsed.retain?.results?.masked_cert_url,
share_url: parsed.retain?.results?.share_url,
expires_at: parsed.retain?.results?.expires_at || parsed.insights?.properties?.expires_at,

scans_result: parsed.insights?.scans?.result?.success,
required_scans_found: parsed.insights?.scans?.result?.required?.found,
Expand Down Expand Up @@ -233,6 +236,7 @@ response.variables = () => [
{ name: 'previously_retained', type: 'boolean', description: 'A boolean indicating whether your account had already retained this certificate.' },
{ name: 'expires_at', type: 'time', description: 'The UTC ISO8601 formatted date and time when this certificate will no longer be available for API requests.' },
{ name: 'masked_cert_url', type: 'url', description: 'The certificate url that masks the lead source url and snapshot' },
{ name: 'share_url', type: 'url', description: 'The expiring share URL of the certificate' },
{ name: 'scans_result', type: 'boolean', description: 'A boolean indicating if all required text was found and none of the forbidden text was found.' },
{ name: 'required_scans_found', type: 'array', description: 'A list of required scan terms that were found in the recorded content.' },
{ name: 'required_scans_not_found', type: 'array', description: 'A list of required scan terms that were not found in the recorded content.' },
Expand Down Expand Up @@ -269,6 +273,7 @@ response.variables = () => [
{ name: 'one_to_one', type: 'boolean', description: 'A boolean indicating if the cert structure satisfied the requirements for 1:1 consent.' },
{ name: 'verify.languages', type: 'array', description: 'A list of the consent languages detected within the certificate' },
{ 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.' },
{ name: 'verify.form_submitted', type: 'boolean', description: 'A boolean indicating whether the form was successfully submitted by the consumer.' },
{ name: 'verify.success', type: 'boolean', description: 'A boolean indicating if any of the consent languages found meet the success criteria defined for your account.' },
];

Expand Down
10 changes: 7 additions & 3 deletions test/trustedform_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ describe('v4', () => {
results: {
expires_at: '2023-08-29T20:43:31Z',
previously_retained: true,
masked_cert_url: 'https://cert.trustedform-dev.com/f1fd052c43f08078a37d840b243daa69a35e8eda'
masked_cert_url: 'https://cert.trustedform-dev.com/f1fd052c43f08078a37d840b243daa69a35e8eda',
share_url: 'https://cert.trustedform-dev.com/1eb8608bdf5b3bc42bb1e33cb0ed57a4bab643ef?shared_token=k6Kw261Tc-55fSPY2_xwPAkSm5r6V2w5h5CggqL2A_f-cph2gXWOonRmV-7aCe8ktjV2acrGQMujmZYPWHgBDd4AEAIeiMeEeqv-Rk8.ISm5ttdJP0FP5wGWyo6O7A.mc_8jwgGZpVBCRsDm0hHgg'
},
vendor: 'Inbound Verbose'
},
Expand All @@ -463,6 +464,7 @@ describe('v4', () => {
result: {
language_approved: true,
success: true,
form_submitted: true,
one_to_one: true
}
}
Expand All @@ -489,6 +491,7 @@ describe('v4', () => {
latitude: 30.2627,
longitude: -97.7467,
masked_cert_url: 'https://cert.trustedform-dev.com/f1fd052c43f08078a37d840b243daa69a35e8eda',
share_url: 'https://cert.trustedform-dev.com/1eb8608bdf5b3bc42bb1e33cb0ed57a4bab643ef?shared_token=k6Kw261Tc-55fSPY2_xwPAkSm5r6V2w5h5CggqL2A_f-cph2gXWOonRmV-7aCe8ktjV2acrGQMujmZYPWHgBDd4AEAIeiMeEeqv-Rk8.ISm5ttdJP0FP5wGWyo6O7A.mc_8jwgGZpVBCRsDm0hHgg',
matched_email: '[email protected]',
os_full: 'Mac OS X 10.15',
os_name: 'Mac OS X',
Expand All @@ -514,6 +517,7 @@ describe('v4', () => {
verify: {
languages: ['I understand that the TrustedForm certificate is sent to the email address I provided above and I will receive product updates as they are released.'],
language_approved: true,
form_submitted: true,
success: true
}
};
Expand Down Expand Up @@ -581,9 +585,9 @@ describe('v4', () => {
const expected = {
verify: {
languages: ['By clicking on the "Get Rates" button below, I consent to be contacted'],
language_approved: false,
language_approved: false,
success: false
},
},
outcome: 'failure',
reason: 'Consent language not detected in the certificate.',
};
Expand Down

0 comments on commit 1699001

Please sign in to comment.