@webority-technologies/mobile-core 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * English display names for every country libphonenumber-js knows, keyed by
5
+ * ISO 3166-1 alpha-2. GENERATED by scripts/gen-phone-countries.mjs from Node's
6
+ * Intl.DisplayNames('en', { type: 'region' }) over getCountries() on 2026-09-14;
7
+ * '&' is written as 'and'. Re-run the script rather than editing by hand.
8
+ *
9
+ * Lives on its own import path (mobile-core/phone/countries) so an app that
10
+ * never opens a full country list does not carry these 245 strings in its
11
+ * bundle. Pair with getPhoneCountries() from the package root for the calling
12
+ * codes; a country picker that needs another language supplies its own names.
13
+ */
14
+ export const PHONE_COUNTRY_NAMES = {
15
+ AF: 'Afghanistan',
16
+ AX: 'Åland Islands',
17
+ AL: 'Albania',
18
+ DZ: 'Algeria',
19
+ AS: 'American Samoa',
20
+ AD: 'Andorra',
21
+ AO: 'Angola',
22
+ AI: 'Anguilla',
23
+ AG: 'Antigua and Barbuda',
24
+ AR: 'Argentina',
25
+ AM: 'Armenia',
26
+ AW: 'Aruba',
27
+ AC: 'Ascension Island',
28
+ AU: 'Australia',
29
+ AT: 'Austria',
30
+ AZ: 'Azerbaijan',
31
+ BS: 'Bahamas',
32
+ BH: 'Bahrain',
33
+ BD: 'Bangladesh',
34
+ BB: 'Barbados',
35
+ BY: 'Belarus',
36
+ BE: 'Belgium',
37
+ BZ: 'Belize',
38
+ BJ: 'Benin',
39
+ BM: 'Bermuda',
40
+ BT: 'Bhutan',
41
+ BO: 'Bolivia',
42
+ BA: 'Bosnia and Herzegovina',
43
+ BW: 'Botswana',
44
+ BR: 'Brazil',
45
+ IO: 'British Indian Ocean Territory',
46
+ VG: 'British Virgin Islands',
47
+ BN: 'Brunei',
48
+ BG: 'Bulgaria',
49
+ BF: 'Burkina Faso',
50
+ BI: 'Burundi',
51
+ KH: 'Cambodia',
52
+ CM: 'Cameroon',
53
+ CA: 'Canada',
54
+ CV: 'Cape Verde',
55
+ BQ: 'Caribbean Netherlands',
56
+ KY: 'Cayman Islands',
57
+ CF: 'Central African Republic',
58
+ TD: 'Chad',
59
+ CL: 'Chile',
60
+ CN: 'China',
61
+ CX: 'Christmas Island',
62
+ CC: 'Cocos (Keeling) Islands',
63
+ CO: 'Colombia',
64
+ KM: 'Comoros',
65
+ CG: 'Congo - Brazzaville',
66
+ CD: 'Congo - Kinshasa',
67
+ CK: 'Cook Islands',
68
+ CR: 'Costa Rica',
69
+ CI: 'Côte d’Ivoire',
70
+ HR: 'Croatia',
71
+ CU: 'Cuba',
72
+ CW: 'Curaçao',
73
+ CY: 'Cyprus',
74
+ CZ: 'Czechia',
75
+ DK: 'Denmark',
76
+ DJ: 'Djibouti',
77
+ DM: 'Dominica',
78
+ DO: 'Dominican Republic',
79
+ EC: 'Ecuador',
80
+ EG: 'Egypt',
81
+ SV: 'El Salvador',
82
+ GQ: 'Equatorial Guinea',
83
+ ER: 'Eritrea',
84
+ EE: 'Estonia',
85
+ SZ: 'Eswatini',
86
+ ET: 'Ethiopia',
87
+ FK: 'Falkland Islands',
88
+ FO: 'Faroe Islands',
89
+ FJ: 'Fiji',
90
+ FI: 'Finland',
91
+ FR: 'France',
92
+ GF: 'French Guiana',
93
+ PF: 'French Polynesia',
94
+ GA: 'Gabon',
95
+ GM: 'Gambia',
96
+ GE: 'Georgia',
97
+ DE: 'Germany',
98
+ GH: 'Ghana',
99
+ GI: 'Gibraltar',
100
+ GR: 'Greece',
101
+ GL: 'Greenland',
102
+ GD: 'Grenada',
103
+ GP: 'Guadeloupe',
104
+ GU: 'Guam',
105
+ GT: 'Guatemala',
106
+ GG: 'Guernsey',
107
+ GN: 'Guinea',
108
+ GW: 'Guinea-Bissau',
109
+ GY: 'Guyana',
110
+ HT: 'Haiti',
111
+ HN: 'Honduras',
112
+ HK: 'Hong Kong SAR China',
113
+ HU: 'Hungary',
114
+ IS: 'Iceland',
115
+ IN: 'India',
116
+ ID: 'Indonesia',
117
+ IR: 'Iran',
118
+ IQ: 'Iraq',
119
+ IE: 'Ireland',
120
+ IM: 'Isle of Man',
121
+ IL: 'Israel',
122
+ IT: 'Italy',
123
+ JM: 'Jamaica',
124
+ JP: 'Japan',
125
+ JE: 'Jersey',
126
+ JO: 'Jordan',
127
+ KZ: 'Kazakhstan',
128
+ KE: 'Kenya',
129
+ KI: 'Kiribati',
130
+ XK: 'Kosovo',
131
+ KW: 'Kuwait',
132
+ KG: 'Kyrgyzstan',
133
+ LA: 'Laos',
134
+ LV: 'Latvia',
135
+ LB: 'Lebanon',
136
+ LS: 'Lesotho',
137
+ LR: 'Liberia',
138
+ LY: 'Libya',
139
+ LI: 'Liechtenstein',
140
+ LT: 'Lithuania',
141
+ LU: 'Luxembourg',
142
+ MO: 'Macao SAR China',
143
+ MG: 'Madagascar',
144
+ MW: 'Malawi',
145
+ MY: 'Malaysia',
146
+ MV: 'Maldives',
147
+ ML: 'Mali',
148
+ MT: 'Malta',
149
+ MH: 'Marshall Islands',
150
+ MQ: 'Martinique',
151
+ MR: 'Mauritania',
152
+ MU: 'Mauritius',
153
+ YT: 'Mayotte',
154
+ MX: 'Mexico',
155
+ FM: 'Micronesia',
156
+ MD: 'Moldova',
157
+ MC: 'Monaco',
158
+ MN: 'Mongolia',
159
+ ME: 'Montenegro',
160
+ MS: 'Montserrat',
161
+ MA: 'Morocco',
162
+ MZ: 'Mozambique',
163
+ MM: 'Myanmar (Burma)',
164
+ NA: 'Namibia',
165
+ NR: 'Nauru',
166
+ NP: 'Nepal',
167
+ NL: 'Netherlands',
168
+ NC: 'New Caledonia',
169
+ NZ: 'New Zealand',
170
+ NI: 'Nicaragua',
171
+ NE: 'Niger',
172
+ NG: 'Nigeria',
173
+ NU: 'Niue',
174
+ NF: 'Norfolk Island',
175
+ KP: 'North Korea',
176
+ MK: 'North Macedonia',
177
+ MP: 'Northern Mariana Islands',
178
+ NO: 'Norway',
179
+ OM: 'Oman',
180
+ PK: 'Pakistan',
181
+ PW: 'Palau',
182
+ PS: 'Palestinian Territories',
183
+ PA: 'Panama',
184
+ PG: 'Papua New Guinea',
185
+ PY: 'Paraguay',
186
+ PE: 'Peru',
187
+ PH: 'Philippines',
188
+ PL: 'Poland',
189
+ PT: 'Portugal',
190
+ PR: 'Puerto Rico',
191
+ QA: 'Qatar',
192
+ RE: 'Réunion',
193
+ RO: 'Romania',
194
+ RU: 'Russia',
195
+ RW: 'Rwanda',
196
+ WS: 'Samoa',
197
+ SM: 'San Marino',
198
+ ST: 'São Tomé and Príncipe',
199
+ SA: 'Saudi Arabia',
200
+ SN: 'Senegal',
201
+ RS: 'Serbia',
202
+ SC: 'Seychelles',
203
+ SL: 'Sierra Leone',
204
+ SG: 'Singapore',
205
+ SX: 'Sint Maarten',
206
+ SK: 'Slovakia',
207
+ SI: 'Slovenia',
208
+ SB: 'Solomon Islands',
209
+ SO: 'Somalia',
210
+ ZA: 'South Africa',
211
+ KR: 'South Korea',
212
+ SS: 'South Sudan',
213
+ ES: 'Spain',
214
+ LK: 'Sri Lanka',
215
+ BL: 'St. Barthélemy',
216
+ SH: 'St. Helena',
217
+ KN: 'St. Kitts and Nevis',
218
+ LC: 'St. Lucia',
219
+ MF: 'St. Martin',
220
+ PM: 'St. Pierre and Miquelon',
221
+ VC: 'St. Vincent and Grenadines',
222
+ SD: 'Sudan',
223
+ SR: 'Suriname',
224
+ SJ: 'Svalbard and Jan Mayen',
225
+ SE: 'Sweden',
226
+ CH: 'Switzerland',
227
+ SY: 'Syria',
228
+ TW: 'Taiwan',
229
+ TJ: 'Tajikistan',
230
+ TZ: 'Tanzania',
231
+ TH: 'Thailand',
232
+ TL: 'Timor-Leste',
233
+ TG: 'Togo',
234
+ TK: 'Tokelau',
235
+ TO: 'Tonga',
236
+ TT: 'Trinidad and Tobago',
237
+ TA: 'Tristan da Cunha',
238
+ TN: 'Tunisia',
239
+ TR: 'Türkiye',
240
+ TM: 'Turkmenistan',
241
+ TC: 'Turks and Caicos Islands',
242
+ TV: 'Tuvalu',
243
+ VI: 'U.S. Virgin Islands',
244
+ UG: 'Uganda',
245
+ UA: 'Ukraine',
246
+ AE: 'United Arab Emirates',
247
+ GB: 'United Kingdom',
248
+ US: 'United States',
249
+ UY: 'Uruguay',
250
+ UZ: 'Uzbekistan',
251
+ VU: 'Vanuatu',
252
+ VA: 'Vatican City',
253
+ VE: 'Venezuela',
254
+ VN: 'Vietnam',
255
+ WF: 'Wallis and Futuna',
256
+ EH: 'Western Sahara',
257
+ YE: 'Yemen',
258
+ ZM: 'Zambia',
259
+ ZW: 'Zimbabwe'
260
+ };
261
+ //# sourceMappingURL=countries.js.map
@@ -5,6 +5,6 @@ export { formatDate, formatDateTime, formatRelativeTime, formatTime } from './da
5
5
  export { addDays, diffMs, formatDateDDMMMYYYY, formatDateISO, formatDatePattern, formatTime12h, formatTimeInWindowsZone, formatTimeInZone, isDateAfter, isDateBefore, isSameDay, startOfDay } from './dateMath';
6
6
  export { getInitials } from './initials';
7
7
  export { formatCompactNumber, formatNumber, formatPercent } from './number';
8
- export type { FormatPhoneOptions, PhoneCountry, PhoneNumber } from './phone';
9
- export { detectPhoneCountry, formatPhone, isValidPhoneNumber, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString } from './phone';
8
+ export type { FormatPhoneOptions, PhoneCountry, PhoneCountryEntry, PhoneNumber, PhoneNumberType, PhoneParts, PhoneValidationKind } from './phone';
9
+ export { AsYouType, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, formatPhone, formatPhoneAsTyped, getCountries, getCountryCallingCode, getPhoneCountries, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, maxNationalNumberLength, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, validatePhoneNumberLength } from './phone';
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1,13 +1,6 @@
1
- /**
2
- * The bare 'libphonenumber-js' entry point actually resolves to the library's
3
- * OWN slimmed-down min/ metadata internally, not its full data - './max' is
4
- * the variant with complete per-country metadata. Since the reason this
5
- * module exists is validation and formatting accuracy, the more accurate
6
- * variant wins throughout this file, not just for validation.
7
- */
8
1
  import { type CountryCode } from 'libphonenumber-js/max';
9
- export type { PhoneNumber } from 'libphonenumber-js/max';
10
- export { isValidPhoneNumber, parsePhoneNumber, parsePhoneNumberFromString } from 'libphonenumber-js/max';
2
+ export type { NumberType as PhoneNumberType, PhoneNumber } from 'libphonenumber-js/max';
3
+ export { AsYouType, getCountries, getCountryCallingCode, isSupportedCountry, isValidPhoneNumber, parsePhoneNumber, parsePhoneNumberFromString, validatePhoneNumberLength } from 'libphonenumber-js/max';
11
4
  /**
12
5
  * Re-exported under our own name rather than importing CountryCode directly
13
6
  * everywhere, so a future need to diverge (or re-narrow) has one place to do
@@ -47,4 +40,94 @@ export declare const detectPhoneCountry: (input: string, defaultCountryCode?: st
47
40
  */
48
41
  export declare function formatPhone(input: string, defaultCountryCode?: string): string;
49
42
  export declare function formatPhone(input: string, options?: FormatPhoneOptions): string;
43
+ /** Country calling code + national digits, the way a phone field stores them. */
44
+ export interface PhoneParts {
45
+ /** ISO 3166-1 alpha-2 of the country the number belongs to, when it can be told. */
46
+ country: PhoneCountry | null;
47
+ /** Dial prefix WITHOUT the plus, e.g. '91'. */
48
+ callingCode: string;
49
+ /** National digits only, no prefix, no formatting. */
50
+ nationalNumber: string;
51
+ }
52
+ /**
53
+ * Which kinds of number count as valid. `'any'` is libphonenumber's own
54
+ * answer (a fixed line passes). `'mobile'` narrows to MOBILE and
55
+ * FIXED_LINE_OR_MOBILE, which is what an OTP or WhatsApp field wants: in India
56
+ * a 10-digit number starting with 1 to 5 is a real fixed line and passes
57
+ * `'any'`, but no SMS will ever reach it.
58
+ */
59
+ export type PhoneValidationKind = 'any' | 'mobile';
60
+ /**
61
+ * Split a typed or pasted number into calling code + national digits.
62
+ * `'+919876543210'` resolves to IN / 91 / 9876543210 from its own prefix; a
63
+ * bare `'9876543210'` needs `defaultCountry` to resolve at all. Returns null
64
+ * when the input has no digits or no country can be told. A shared calling
65
+ * code (`+1` for US and CA) resolves to the country whose area code matches,
66
+ * which is why the country comes back as part of the answer rather than being
67
+ * looked up again from the code.
68
+ */
69
+ export declare const splitPhoneNumber: (input: string, defaultCountry?: PhoneCountry) => PhoneParts | null;
70
+ /**
71
+ * Cut national digits that run past the longest number the country's plan
72
+ * allows, so a field stops accepting the impossible without a per-country
73
+ * length table. This is the PLAN's ceiling, not a mobile number's: India runs
74
+ * to 13 digits (toll-free 1800 numbers), the US to 10, Germany to 15. A field
75
+ * that should stop where a subscriber's number ends asks
76
+ * `maxNationalNumberLength` instead. Digits within range, including a number
77
+ * still too short, pass through untouched.
78
+ */
79
+ export declare const clampNationalNumber: (nationalDigits: string, country: PhoneCountry) => string;
80
+ /**
81
+ * The most national digits a subscriber's number can have in a country, so a
82
+ * field can refuse the next digit as it is typed rather than trimming after.
83
+ * `'any'` (default) covers mobile and fixed lines, `'mobile'` mobiles only: India
84
+ * is 10 either way (its plan's 13 belongs to toll-free numbers), Germany is 15
85
+ * for `'any'` and 11 for `'mobile'`, the UAE 9. A country whose metadata lists
86
+ * no lengths by type falls back to the plan's longest number.
87
+ */
88
+ export declare const maxNationalNumberLength: (country: PhoneCountry, kind?: PhoneValidationKind) => number;
89
+ /**
90
+ * National digits grouped the way the country writes them, updated on every
91
+ * keystroke: `'98765'` for IN is `'98765'`, `'9876543210'` is `'98765 43210'`,
92
+ * `'2025550123'` for US is `'(202) 555-0123'`. Output is for display only; the
93
+ * digits are what a value stores. Digits past the plan's longest possible
94
+ * number are dropped first, so an overflowing paste never formats as a longer
95
+ * number; digits that fit no pattern come back ungrouped rather than forced
96
+ * into a shape.
97
+ *
98
+ * Countries that write a leading 0 (the UAE, the UK, Australia, Saudi Arabia)
99
+ * only group in national mode when that 0 is typed, and a value never holds
100
+ * it. When national mode hands the digits back untouched, the grouping comes
101
+ * from the international form with the calling code removed: `'501234567'`
102
+ * for AE is `'50 123 4567'`. Countries that group nationally are unaffected.
103
+ */
104
+ export declare const formatPhoneAsTyped: (nationalDigits: string, country: PhoneCountry) => string;
105
+ /**
106
+ * Whether national digits form a real number for the country, by the
107
+ * country's own numbering plan rather than a length check. `kind: 'mobile'`
108
+ * additionally rejects fixed lines; a number whose type the metadata cannot
109
+ * tell is accepted, since the metadata, not the number, is what is missing.
110
+ */
111
+ export declare const isValidNationalNumber: (nationalDigits: string, country: PhoneCountry, kind?: PhoneValidationKind) => boolean;
112
+ /**
113
+ * The flag as an emoji built from the ISO code's two regional-indicator
114
+ * letters, so no font asset ships with the library: iOS and Android both draw
115
+ * these from the system font. An unknown or malformed code returns ''. (Windows
116
+ * browsers render the two letters instead of a flag; that is the platform, not
117
+ * the code.)
118
+ */
119
+ export declare const countryFlagEmoji: (iso: string) => string;
120
+ /** Calling code + ISO for one country, the shape a country picker lists. */
121
+ export interface PhoneCountryEntry {
122
+ iso: PhoneCountry;
123
+ /** Dial prefix WITHOUT the plus, e.g. '91'. */
124
+ callingCode: string;
125
+ }
126
+ /**
127
+ * Every country libphonenumber-js knows, with its calling code, in metadata
128
+ * order. Names are deliberately not here: they are display data, in one
129
+ * language, and live on their own import path (`mobile-core/phone/countries`)
130
+ * so an app that never opens a full country list does not carry them.
131
+ */
132
+ export declare const getPhoneCountries: () => ReadonlyArray<PhoneCountryEntry>;
50
133
  //# sourceMappingURL=phone.d.ts.map
@@ -12,6 +12,10 @@
12
12
  * @webority-technologies/mobile-core/download a filesystem module
13
13
  * @webority-technologies/mobile-core/smsRetriever Android only, own TurboModule
14
14
  *
15
+ * One more path is separate for size, not for a native package:
16
+ *
17
+ * @webority-technologies/mobile-core/phone/countries 245 English country names
18
+ *
15
19
  * react-native-keychain is the exception and is a REQUIRED peer: the HTTP client
16
20
  * reads the bearer token, so it is reachable from the main barrel by design.
17
21
  */
@@ -29,8 +33,8 @@ export type { Config, Environment, LogLevel } from './config';
29
33
  export { getConfig, getConfigValue, resetConfig, setConfig } from './config';
30
34
  export type { DeepLinkConfig, DeepLinkRoute, ParsedLink } from './deepLink';
31
35
  export { DeepLink, parseDeepLink, useDeepLink } from './deepLink';
32
- export type { DateInput, DateStyle, FormatCurrencyOptions, FormatPhoneOptions, PhoneCountry, PhoneNumber, TimeStyle } from './formatters';
33
- export { addDays, detectPhoneCountry, diffMs, formatCompactNumber, formatCurrency, formatDate, formatDateDDMMMYYYY, formatDateISO, formatDatePattern, formatDateTime, formatNumber, formatPercent, formatPhone, formatRelativeTime, formatTime, formatTime12h, formatTimeInWindowsZone, formatTimeInZone, getInitials, isDateAfter, isDateBefore, isSameDay, isValidPhoneNumber, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, startOfDay } from './formatters';
36
+ export type { DateInput, DateStyle, FormatCurrencyOptions, FormatPhoneOptions, PhoneCountry, PhoneCountryEntry, PhoneNumber, PhoneNumberType, PhoneParts, PhoneValidationKind, TimeStyle } from './formatters';
37
+ export { AsYouType, addDays, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, diffMs, formatCompactNumber, formatCurrency, formatDate, formatDateDDMMMYYYY, formatDateISO, formatDatePattern, formatDateTime, formatNumber, formatPercent, formatPhone, formatPhoneAsTyped, formatRelativeTime, formatTime, formatTime12h, formatTimeInWindowsZone, formatTimeInZone, getCountries, getCountryCallingCode, getInitials, getPhoneCountries, isDateAfter, isDateBefore, isSameDay, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, maxNationalNumberLength, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, startOfDay, validatePhoneNumberLength } from './formatters';
34
38
  export type { InitConfig } from './initSDK';
35
39
  export { initWebority } from './initSDK';
36
40
  export type { AuthActions } from './initUserAuth';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * English display names for every country libphonenumber-js knows, keyed by
3
+ * ISO 3166-1 alpha-2. GENERATED by scripts/gen-phone-countries.mjs from Node's
4
+ * Intl.DisplayNames('en', { type: 'region' }) over getCountries() on 2026-09-14;
5
+ * '&' is written as 'and'. Re-run the script rather than editing by hand.
6
+ *
7
+ * Lives on its own import path (mobile-core/phone/countries) so an app that
8
+ * never opens a full country list does not carry these 245 strings in its
9
+ * bundle. Pair with getPhoneCountries() from the package root for the calling
10
+ * codes; a country picker that needs another language supplies its own names.
11
+ */
12
+ export declare const PHONE_COUNTRY_NAMES: Readonly<Record<string, string>>;
13
+ //# sourceMappingURL=countries.d.ts.map
@@ -5,6 +5,6 @@ export { formatDate, formatDateTime, formatRelativeTime, formatTime } from './da
5
5
  export { addDays, diffMs, formatDateDDMMMYYYY, formatDateISO, formatDatePattern, formatTime12h, formatTimeInWindowsZone, formatTimeInZone, isDateAfter, isDateBefore, isSameDay, startOfDay } from './dateMath.js';
6
6
  export { getInitials } from './initials.js';
7
7
  export { formatCompactNumber, formatNumber, formatPercent } from './number.js';
8
- export type { FormatPhoneOptions, PhoneCountry, PhoneNumber } from './phone.js';
9
- export { detectPhoneCountry, formatPhone, isValidPhoneNumber, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString } from './phone.js';
8
+ export type { FormatPhoneOptions, PhoneCountry, PhoneCountryEntry, PhoneNumber, PhoneNumberType, PhoneParts, PhoneValidationKind } from './phone.js';
9
+ export { AsYouType, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, formatPhone, formatPhoneAsTyped, getCountries, getCountryCallingCode, getPhoneCountries, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, maxNationalNumberLength, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, validatePhoneNumberLength } from './phone.js';
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1,13 +1,6 @@
1
- /**
2
- * The bare 'libphonenumber-js' entry point actually resolves to the library's
3
- * OWN slimmed-down min/ metadata internally, not its full data - './max' is
4
- * the variant with complete per-country metadata. Since the reason this
5
- * module exists is validation and formatting accuracy, the more accurate
6
- * variant wins throughout this file, not just for validation.
7
- */
8
1
  import { type CountryCode } from 'libphonenumber-js/max';
9
- export type { PhoneNumber } from 'libphonenumber-js/max';
10
- export { isValidPhoneNumber, parsePhoneNumber, parsePhoneNumberFromString } from 'libphonenumber-js/max';
2
+ export type { NumberType as PhoneNumberType, PhoneNumber } from 'libphonenumber-js/max';
3
+ export { AsYouType, getCountries, getCountryCallingCode, isSupportedCountry, isValidPhoneNumber, parsePhoneNumber, parsePhoneNumberFromString, validatePhoneNumberLength } from 'libphonenumber-js/max';
11
4
  /**
12
5
  * Re-exported under our own name rather than importing CountryCode directly
13
6
  * everywhere, so a future need to diverge (or re-narrow) has one place to do
@@ -47,4 +40,94 @@ export declare const detectPhoneCountry: (input: string, defaultCountryCode?: st
47
40
  */
48
41
  export declare function formatPhone(input: string, defaultCountryCode?: string): string;
49
42
  export declare function formatPhone(input: string, options?: FormatPhoneOptions): string;
43
+ /** Country calling code + national digits, the way a phone field stores them. */
44
+ export interface PhoneParts {
45
+ /** ISO 3166-1 alpha-2 of the country the number belongs to, when it can be told. */
46
+ country: PhoneCountry | null;
47
+ /** Dial prefix WITHOUT the plus, e.g. '91'. */
48
+ callingCode: string;
49
+ /** National digits only, no prefix, no formatting. */
50
+ nationalNumber: string;
51
+ }
52
+ /**
53
+ * Which kinds of number count as valid. `'any'` is libphonenumber's own
54
+ * answer (a fixed line passes). `'mobile'` narrows to MOBILE and
55
+ * FIXED_LINE_OR_MOBILE, which is what an OTP or WhatsApp field wants: in India
56
+ * a 10-digit number starting with 1 to 5 is a real fixed line and passes
57
+ * `'any'`, but no SMS will ever reach it.
58
+ */
59
+ export type PhoneValidationKind = 'any' | 'mobile';
60
+ /**
61
+ * Split a typed or pasted number into calling code + national digits.
62
+ * `'+919876543210'` resolves to IN / 91 / 9876543210 from its own prefix; a
63
+ * bare `'9876543210'` needs `defaultCountry` to resolve at all. Returns null
64
+ * when the input has no digits or no country can be told. A shared calling
65
+ * code (`+1` for US and CA) resolves to the country whose area code matches,
66
+ * which is why the country comes back as part of the answer rather than being
67
+ * looked up again from the code.
68
+ */
69
+ export declare const splitPhoneNumber: (input: string, defaultCountry?: PhoneCountry) => PhoneParts | null;
70
+ /**
71
+ * Cut national digits that run past the longest number the country's plan
72
+ * allows, so a field stops accepting the impossible without a per-country
73
+ * length table. This is the PLAN's ceiling, not a mobile number's: India runs
74
+ * to 13 digits (toll-free 1800 numbers), the US to 10, Germany to 15. A field
75
+ * that should stop where a subscriber's number ends asks
76
+ * `maxNationalNumberLength` instead. Digits within range, including a number
77
+ * still too short, pass through untouched.
78
+ */
79
+ export declare const clampNationalNumber: (nationalDigits: string, country: PhoneCountry) => string;
80
+ /**
81
+ * The most national digits a subscriber's number can have in a country, so a
82
+ * field can refuse the next digit as it is typed rather than trimming after.
83
+ * `'any'` (default) covers mobile and fixed lines, `'mobile'` mobiles only: India
84
+ * is 10 either way (its plan's 13 belongs to toll-free numbers), Germany is 15
85
+ * for `'any'` and 11 for `'mobile'`, the UAE 9. A country whose metadata lists
86
+ * no lengths by type falls back to the plan's longest number.
87
+ */
88
+ export declare const maxNationalNumberLength: (country: PhoneCountry, kind?: PhoneValidationKind) => number;
89
+ /**
90
+ * National digits grouped the way the country writes them, updated on every
91
+ * keystroke: `'98765'` for IN is `'98765'`, `'9876543210'` is `'98765 43210'`,
92
+ * `'2025550123'` for US is `'(202) 555-0123'`. Output is for display only; the
93
+ * digits are what a value stores. Digits past the plan's longest possible
94
+ * number are dropped first, so an overflowing paste never formats as a longer
95
+ * number; digits that fit no pattern come back ungrouped rather than forced
96
+ * into a shape.
97
+ *
98
+ * Countries that write a leading 0 (the UAE, the UK, Australia, Saudi Arabia)
99
+ * only group in national mode when that 0 is typed, and a value never holds
100
+ * it. When national mode hands the digits back untouched, the grouping comes
101
+ * from the international form with the calling code removed: `'501234567'`
102
+ * for AE is `'50 123 4567'`. Countries that group nationally are unaffected.
103
+ */
104
+ export declare const formatPhoneAsTyped: (nationalDigits: string, country: PhoneCountry) => string;
105
+ /**
106
+ * Whether national digits form a real number for the country, by the
107
+ * country's own numbering plan rather than a length check. `kind: 'mobile'`
108
+ * additionally rejects fixed lines; a number whose type the metadata cannot
109
+ * tell is accepted, since the metadata, not the number, is what is missing.
110
+ */
111
+ export declare const isValidNationalNumber: (nationalDigits: string, country: PhoneCountry, kind?: PhoneValidationKind) => boolean;
112
+ /**
113
+ * The flag as an emoji built from the ISO code's two regional-indicator
114
+ * letters, so no font asset ships with the library: iOS and Android both draw
115
+ * these from the system font. An unknown or malformed code returns ''. (Windows
116
+ * browsers render the two letters instead of a flag; that is the platform, not
117
+ * the code.)
118
+ */
119
+ export declare const countryFlagEmoji: (iso: string) => string;
120
+ /** Calling code + ISO for one country, the shape a country picker lists. */
121
+ export interface PhoneCountryEntry {
122
+ iso: PhoneCountry;
123
+ /** Dial prefix WITHOUT the plus, e.g. '91'. */
124
+ callingCode: string;
125
+ }
126
+ /**
127
+ * Every country libphonenumber-js knows, with its calling code, in metadata
128
+ * order. Names are deliberately not here: they are display data, in one
129
+ * language, and live on their own import path (`mobile-core/phone/countries`)
130
+ * so an app that never opens a full country list does not carry them.
131
+ */
132
+ export declare const getPhoneCountries: () => ReadonlyArray<PhoneCountryEntry>;
50
133
  //# sourceMappingURL=phone.d.ts.map
@@ -12,6 +12,10 @@
12
12
  * @webority-technologies/mobile-core/download a filesystem module
13
13
  * @webority-technologies/mobile-core/smsRetriever Android only, own TurboModule
14
14
  *
15
+ * One more path is separate for size, not for a native package:
16
+ *
17
+ * @webority-technologies/mobile-core/phone/countries 245 English country names
18
+ *
15
19
  * react-native-keychain is the exception and is a REQUIRED peer: the HTTP client
16
20
  * reads the bearer token, so it is reachable from the main barrel by design.
17
21
  */
@@ -29,8 +33,8 @@ export type { Config, Environment, LogLevel } from './config/index.js';
29
33
  export { getConfig, getConfigValue, resetConfig, setConfig } from './config/index.js';
30
34
  export type { DeepLinkConfig, DeepLinkRoute, ParsedLink } from './deepLink/index.js';
31
35
  export { DeepLink, parseDeepLink, useDeepLink } from './deepLink/index.js';
32
- export type { DateInput, DateStyle, FormatCurrencyOptions, FormatPhoneOptions, PhoneCountry, PhoneNumber, TimeStyle } from './formatters/index.js';
33
- export { addDays, detectPhoneCountry, diffMs, formatCompactNumber, formatCurrency, formatDate, formatDateDDMMMYYYY, formatDateISO, formatDatePattern, formatDateTime, formatNumber, formatPercent, formatPhone, formatRelativeTime, formatTime, formatTime12h, formatTimeInWindowsZone, formatTimeInZone, getInitials, isDateAfter, isDateBefore, isSameDay, isValidPhoneNumber, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, startOfDay } from './formatters/index.js';
36
+ export type { DateInput, DateStyle, FormatCurrencyOptions, FormatPhoneOptions, PhoneCountry, PhoneCountryEntry, PhoneNumber, PhoneNumberType, PhoneParts, PhoneValidationKind, TimeStyle } from './formatters/index.js';
37
+ export { AsYouType, addDays, clampNationalNumber, countryFlagEmoji, detectPhoneCountry, diffMs, formatCompactNumber, formatCurrency, formatDate, formatDateDDMMMYYYY, formatDateISO, formatDatePattern, formatDateTime, formatNumber, formatPercent, formatPhone, formatPhoneAsTyped, formatRelativeTime, formatTime, formatTime12h, formatTimeInWindowsZone, formatTimeInZone, getCountries, getCountryCallingCode, getInitials, getPhoneCountries, isDateAfter, isDateBefore, isSameDay, isSupportedCountry, isValidNationalNumber, isValidPhoneNumber, maxNationalNumberLength, normalizePhone, parsePhoneNumber, parsePhoneNumberFromString, splitPhoneNumber, startOfDay, validatePhoneNumberLength } from './formatters/index.js';
34
38
  export type { InitConfig } from './initSDK.js';
35
39
  export { initWebority } from './initSDK.js';
36
40
  export type { AuthActions } from './initUserAuth.js';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * English display names for every country libphonenumber-js knows, keyed by
3
+ * ISO 3166-1 alpha-2. GENERATED by scripts/gen-phone-countries.mjs from Node's
4
+ * Intl.DisplayNames('en', { type: 'region' }) over getCountries() on 2026-09-14;
5
+ * '&' is written as 'and'. Re-run the script rather than editing by hand.
6
+ *
7
+ * Lives on its own import path (mobile-core/phone/countries) so an app that
8
+ * never opens a full country list does not carry these 245 strings in its
9
+ * bundle. Pair with getPhoneCountries() from the package root for the calling
10
+ * codes; a country picker that needs another language supplies its own names.
11
+ */
12
+ export declare const PHONE_COUNTRY_NAMES: Readonly<Record<string, string>>;
13
+ //# sourceMappingURL=countries.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority-technologies/mobile-core",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Platform layer for Webority React Native apps: HTTP clients, auth/token storage, config, logging, formatters, validators, network status, permissions, storage and version checks. No UI.",
5
5
  "keywords": [
6
6
  "react-native",
@@ -151,6 +151,16 @@
151
151
  "default": "./lib/commonjs/smsRetriever/index.js"
152
152
  }
153
153
  },
154
+ "./phone/countries": {
155
+ "import": {
156
+ "types": "./lib/typescript/module/phone/countries.d.ts",
157
+ "default": "./lib/module/phone/countries.js"
158
+ },
159
+ "require": {
160
+ "types": "./lib/typescript/commonjs/phone/countries.d.ts",
161
+ "default": "./lib/commonjs/phone/countries.js"
162
+ }
163
+ },
154
164
  "./package.json": "./package.json"
155
165
  },
156
166
  "main": "./lib/commonjs/index.js",