fastlane / fastlane

🚀 The easiest way to automate building and releasing your iOS and Android apps
https://fastlane.tools
MIT License
39.73k stars 5.72k forks source link

Two factor client fix for non-breaking-space (0xa0) #26868

Open sebastienreadyeducation opened 1 month ago

sebastienreadyeducation commented 1 month ago

Added the non-breaking space character (0xa0) to the characters to be removed from the phone number in the match_phone_to_masked_phone function.

Checklist

Motivation and Context

It can happen that the phone number returned by Apple contains NBSP characters. When it does, the step of selecting the phone number automatically from the SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER env var fails with this message:

[!] The request could not be completed because:

Could not find a matching phone number to ...

This issue is very weird, we have several different Apple accounts, most of which don't have this issue. This problem only happens on a single specific Apple account, and it doesn't even happen consistently.

When I got stuck with the problem on my machine, I did some debugging by modifying my Fastlane installation files manually and found the source of the problem like this.

This is the output of printing the phone_number and masked_number when entering the match_phone_to_masked_phone function...

With a "normal" Apple account (not having this issue):

image

With an "affected" Apple account (having the issue):

image

I did try setting those env vars, but it didn't help:

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

Description

The change simply adds the NBSP character to the list of characters to be removed from the phone number, so that when Apple somehow sends you the NBSP character with your phone number, the 2FA will still work.

Testing Steps

I've tested this locally on my machine and it fixed the problem for me. Unfortunately it is impossible for me to provide reproduction steps since the issue is random and specific to my Apple account. Things work perfectly fine on other Apple accounts. I don't know what triggers this, but I'm thinking other Apple accounts could encounter this too.