Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ CHANGELOG
9.3.0 (unreleased)
------------------

* Deprecated the `isHighRisk` property on `response.shippingAddress`. The

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, optional: when this library deprecated the Factors subscores (8.0.0), the CHANGELOG entry linked to the minFraud release notes. Consider a link to the release note for this removal, so users can find the date and the reason. If this release ships before that release note is published, ignore this.

🤖 Comment by Claude Opus 5.5.

minFraud web service is removing the `shipping_address.is_high_risk` field
from its responses. The property will be removed in 10.0.0.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entry says that 10.0.0 removes the property. It does not say that the value can be undefined before then. The web service already leaves out shipping_address.is_high_risk for some requests that have a shipping address. After the web service change deploys, the property is undefined in all responses, whatever library version the user has. The TypeScript type stays boolean, so users who read only the CHANGELOG can think the value stays valid until they upgrade to 10.0.0.

Suggest a sentence such as: "The property is undefined when the web service does not return the field. This already happens for some requests, and will happen for all requests once the web service change deploys."

🤖 Comment by Claude Opus 5.5.

* Updated the documentation for the email and phone verification inputs. Set
`wasVerificationSuccessful` and `phoneWasVerificationSuccessful` to `true`
if your system considers the email address or phone number verified as of
Expand Down
18 changes: 10 additions & 8 deletions src/response/records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,17 +335,19 @@ export interface Phone {
*/
export interface ShippingAddress {
/**
* This property is `true` if the shipping address is in the IP country. The
* property is `false` when the address is not in the IP country. If the
* shipping address could not be parsed or was not provided or the IP address
* could not be geolocated, then the property is `null`.
* This is `true` if the shipping address is associated with fraudulent
* transactions. The minFraud web service deprecated this field. This is

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this comment says the web service "deprecated this field", but the CHANGELOG entry says the web service "is removing" it from its responses. "Deprecated" can suggest that the web service still sends the field. The web service already leaves the field out of some responses, and after the change it leaves it out of all responses.

Suggest the CHANGELOG wording here, for example: "The minFraud web service is removing this field from its responses. This is undefined when the web service does not return it."

🤖 Comment by Claude Opus 5.5.

* `undefined` when the web service does not return it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: no test covers the undefined case that this comment describes. The shipping address assertions in src/webServiceClient.spec.ts (lines 329, 590, 697) use only the fixture that has is_high_risk: true. Consider a case that removes shipping_address.is_high_risk from the response and asserts that got.shippingAddress?.isHighRisk is undefined and that the other shipping address properties still map. The web service already leaves out the field for some requests, so this case becomes the normal one.

🤖 Comment by Claude Opus 5.5.

*
* @category Deprecated
* @deprecated This property will be removed in 10.0.0.
*/
readonly isHighRisk: boolean;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above says this property is undefined when the web service does not return it, but the type is still boolean. The PR description gives the reason: a change to isHighRisk?: boolean can break code that compiles today.

But the web service already leaves out shipping_address.is_high_risk for some requests that have a shipping address. After STF-2444 deploys, it leaves the field out for all requests. So the boolean type is already wrong at runtime for some responses. With strictNullChecks, code such as addr.isHighRisk.toString() or const risky: boolean = addr.isHighRisk compiles and then throws or gets undefined. A compile error would point users to code that is already broken. Email.isHighRisk (line 291) is already optional.

Consider readonly isHighRisk?: boolean here and readonly is_high_risk?: boolean in ShippingAddressWebRecord (src/response/web-records.ts). If you keep boolean on purpose for semver, that is a fair tradeoff. In that case, see the CHANGELOG comment.

🤖 Comment by Claude Opus 5.5.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it is intentional to leave it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is intentional as changing it would be a breaking change. I agree that it was wrong, but it is deprecated now and we will be removing it.

/**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing, not caused by this PR: the new isHighRisk comment correctly says undefined for a missing field. The comments on isPostalInCity (line 350) and isInIpCountry (line 373) say the property "will be null". The client does not add missing keys (maybeGet only runs camelcaseKeys), so the value is undefined. BillingAddress.isPostalInCity (line 383) and BillingAddress.isInIpCountry (line 402) have the same text. The comments in this interface now disagree. Optional follow-up: change "will be null" to "is undefined".

🤖 Comment by Claude Opus 5.5.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be worth fixing given we fixed it for this one?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment from Claude Opus 5.5, an agent working on behalf of Greg.

Fixed in 01b173b. The isPostalInCity and isInIpCountry comments on BillingAddress and ShippingAddress now say undefined, not null.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pre-existing, not caused by this PR: latitude, longitude, distanceToIpLocation, and distanceToBillingAddress (lines 356-368) are typed as always present (number). I believe the web service leaves them out when it cannot locate the address, but please confirm. If it does, code such as addr.distanceToIpLocation > 500 compiles, and at runtime compares undefined, which is always false. BillingAddress and the *WebRecord types have the same shape. A fix probably belongs in 10.0.0 if the team treats it as a breaking type change.

🤖 Comment by Claude Opus 5.5.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll make an issue for this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment from Claude Opus 5.5, an agent working on behalf of Greg.

Filed as ENG-5895. I checked the web service code: it can leave out these address fields. The issue also lists the other Node response properties that are typed as always present but that the service can leave out, for example on the credit card, phone, email, and device. The fix is a breaking type change, so it is planned for 10.0.0.

* This property is `true` if the postal code provided with the address is in
* the city for the address. The property is `false` when the postal code is
* not in the city. If the address was not provided or could not be parsed,
* the property will be `null`.
* the property is `undefined`.
*/
readonly isPostalInCity?: boolean;
/**
Expand All @@ -368,7 +370,7 @@ export interface ShippingAddress {
* This property is `true` if the address is in the IP country. The property
* is `false` when the address is not in the IP country. If the address could
* not be parsed or was not provided or if the IP address could not be
* geolocated, the property will be `null`.
* geolocated, the property is `undefined`.
*/
readonly isInIpCountry?: boolean;
}
Expand All @@ -378,7 +380,7 @@ export interface BillingAddress {
* This property is `true` if the postal code provided with the address is in
* the city for the address. The property is `false` when the postal code is
* not in the city. If the address was not provided or could not be parsed,
* the property will be `null`.
* the property is `undefined`.
*/
readonly isPostalInCity?: boolean;
/**
Expand All @@ -397,7 +399,7 @@ export interface BillingAddress {
* This property is `true` if the address is in the IP country. The property
* is `false` when the address is not in the IP country. If the address could
* not be parsed or was not provided or if the IP address could not be
* geolocated, the property will be `null`.
* geolocated, the property is `undefined`.
*/
readonly isInIpCountry?: boolean;
}
Expand Down
1 change: 1 addition & 0 deletions src/response/web-records.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export interface EmailWebRecord {
}

export interface ShippingAddressWebRecord {
/** @deprecated This property will be removed in 10.0.0. */
readonly is_high_risk: boolean;
readonly is_postal_in_city?: boolean;
readonly latitude: number;
Expand Down
Loading