mirror of
https://github.com/jjbrunton/Sauci.git
synced 2026-11-01 18:19:43 +00:00
fix(mobile): address Apple review onboarding flows
This commit is contained in:
1 parent
6883befff3
commit
7c8d91c89c
20 files changed
+661
-262
No files matched your search
@@ -0,0 +1,24 @@
|
||||
export interface AppleProfileName {
|
||||
givenName?: string | null;
|
||||
middleName?: string | null;
|
||||
familyName?: string | null;
|
||||
}
|
||||
|
||||
const MAX_PROFILE_NAME_LENGTH = 100;
|
||||
|
||||
/**
|
||||
* Apple supplies its name fields only on the first authorization. Keep that
|
||||
* user-provided value as the Sauci display name without retaining email or
|
||||
* other Apple credential fields outside the existing profile contract.
|
||||
*/
|
||||
export function formatAppleProfileName(fullName: AppleProfileName | null | undefined): string | null {
|
||||
const name = [fullName?.givenName, fullName?.middleName, fullName?.familyName]
|
||||
.filter((part): part is string => typeof part === "string")
|
||||
.join(" ")
|
||||
.normalize("NFKC")
|
||||
.replace(/[\u0000-\u001F\u007F-\u009F]/g, "")
|
||||
.replace(/\s+/gu, " ")
|
||||
.trim();
|
||||
|
||||
return name.length > 0 ? name.slice(0, MAX_PROFILE_NAME_LENGTH) : null;
|
||||
}
|
||||
Reference in new issue
Block a user