···12import {AgeAssuranceAccess} from '#/ageAssurance/types'
13import {type Geolocation, useGeolocation} from '#/geolocation'
1415-const DEFAULT_MIN_AGE = 13
00000000000000001617/**
18 * Get age assurance region config based on geolocation, with fallback to
···30 regionCode: geolocation.regionCode,
31 })
3233- return (
34- region || {
35- countryCode: '*',
36- regionCode: undefined,
37- rules: [
38- {
39- $type: ids.IfDeclaredOverAge,
40- age: DEFAULT_MIN_AGE,
41- access: AgeAssuranceAccess.Full,
42- },
43- {
44- $type: ids.Default,
45- access: AgeAssuranceAccess.None,
46- },
47- ],
48- }
49- )
50}
5152/**
···68}
6970/**
0000000071 * Some users may have erroneously set their birth date to the current date
72 * if one wasn't set on their account. We previously didn't do validation on
73 * the bday dialog, and it defaulted to the current date. This bug _has_ been
···78}
7980/**
81- * Returns whether the user is under the minimum age required to use the app.
82- * This applies to all regions.
83 */
84-export function isUserUnderMinimumAge(birthDate: string) {
85- return getAge(new Date(birthDate)) < DEFAULT_MIN_AGE
86-}
87-88-export function isUserUnderAdultAge(birthDate: string) {
89- return getAge(new Date(birthDate)) < 18
90}
9192export function getBirthdateStringFromAge(age: number) {
···12import {AgeAssuranceAccess} from '#/ageAssurance/types'
13import {type Geolocation, useGeolocation} from '#/geolocation'
1415+export const MIN_ACCESS_AGE = 13
16+const FALLBACK_REGION_CONFIG: AppBskyAgeassuranceDefs.ConfigRegion = {
17+ countryCode: '*',
18+ regionCode: undefined,
19+ minAccessAge: MIN_ACCESS_AGE,
20+ rules: [
21+ {
22+ $type: ids.IfDeclaredOverAge,
23+ age: MIN_ACCESS_AGE,
24+ access: AgeAssuranceAccess.Full,
25+ },
26+ {
27+ $type: ids.Default,
28+ access: AgeAssuranceAccess.None,
29+ },
30+ ],
31+}
3233/**
34 * Get age assurance region config based on geolocation, with fallback to
···46 regionCode: geolocation.regionCode,
47 })
4849+ return region || FALLBACK_REGION_CONFIG
000000000000000050}
5152/**
···68}
6970/**
71+ * Hook to get the age assurance region config based on current geolocation.
72+ * Falls back to our app defaults if no region config is found.
73+ */
74+export function useAgeAssuranceRegionConfigWithFallback() {
75+ return useAgeAssuranceRegionConfig() || FALLBACK_REGION_CONFIG
76+}
77+78+/**
79 * Some users may have erroneously set their birth date to the current date
80 * if one wasn't set on their account. We previously didn't do validation on
81 * the bday dialog, and it defaulted to the current date. This bug _has_ been
···86}
8788/**
89+ * Returns whether the date (converted to an age as a whole integer) is under
90+ * the provided minimum age.
91 */
92+export function isUnderAge(birthDate: string, age: number) {
93+ return getAge(new Date(birthDate)) < age
000094}
9596export function getBirthdateStringFromAge(age: number) {
···12import {mergeGeolocations} from '#/geolocation/util'
13import {device, useStorage} from '#/storage'
1415-export {useRequestDeviceGeolocation} from '#/geolocation/device'
00016export {resolve} from '#/geolocation/service'
17export * from '#/geolocation/types'
18
···12import {mergeGeolocations} from '#/geolocation/util'
13import {device, useStorage} from '#/storage'
1415+export {
16+ useIsDeviceGeolocationGranted,
17+ useRequestDeviceGeolocation,
18+} from '#/geolocation/device'
19export {resolve} from '#/geolocation/service'
20export * from '#/geolocation/types'
21
+3-28
src/screens/Signup/StepInfo/Policies.tsx
···1112export const Policies = ({
13 serviceDescription,
14- needsGuardian,
15- under13,
16}: {
17 serviceDescription: ComAtprotoServerDescribeServer.OutputSchema
18- needsGuardian: boolean
19- under13: boolean
20}) => {
21 const t = useTheme()
22 const {_} = useLingui()
···91 return null
92 }
9394- return (
95- <View style={[a.gap_sm]}>
96- {els ? (
97- <Text style={[a.leading_snug, t.atoms.text_contrast_medium]}>
98- {els}
99- </Text>
100- ) : null}
101-102- {under13 ? (
103- <Admonition type="error">
104- <Trans>
105- You must be 13 years of age or older to create an account.
106- </Trans>
107- </Admonition>
108- ) : needsGuardian ? (
109- <Admonition type="warning">
110- <Trans>
111- If you are not yet an adult according to the laws of your country,
112- your parent or legal guardian must read these Terms on your behalf.
113- </Trans>
114- </Admonition>
115- ) : undefined}
116- </View>
117- )
118}
119120function validWebLink(url?: string): string | undefined {