phoneoperator 0.1.0

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ - Operator, brand and region lookup for Russian mobile numbers, landlines in `phoneoperator/full`
6
+ - Numbering registry as of 2026-10-01
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MrProLopstar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # phoneoperator
2
+
3
+ [![npm](https://img.shields.io/npm/v/phoneoperator?color=0e7c66)](https://www.npmjs.com/package/phoneoperator)
4
+ [![JSR](https://jsr.io/badges/@mrprolopstar/phoneoperator)](https://jsr.io/@mrprolopstar/phoneoperator)
5
+
6
+ [Русская версия](README.ru.md)
7
+
8
+ Operator and region of a Russian phone number, offline. The data is the official numbering registry of the Ministry of Digital Development, bundled into the package and refreshed every week. No dependencies, no network requests, works in Node, Deno, Bun and browsers.
9
+
10
+ ```sh
11
+ npm install phoneoperator
12
+ ```
13
+
14
+ ```ts
15
+ import { lookup } from 'phoneoperator';
16
+
17
+ lookup('+7 916 123-45-67');
18
+ // {
19
+ // number: '+79161234567',
20
+ // national: '9161234567',
21
+ // code: '916',
22
+ // type: 'mobile',
23
+ // operator: { name: 'ПАО "Мобильные ТелеСистемы"', inn: '7740000076', brand: { id: 'mts', name: 'МТС' } },
24
+ // region: 'Город Москва, Московская область',
25
+ // locality: null
26
+ // }
27
+
28
+ lookup('8 (999) 123-45-67')?.operator.brand?.name; // 'Yota'
29
+ lookup('+1 212 555 0100'); // null
30
+ ```
31
+
32
+ ## Mobile and landline
33
+
34
+ The default entry point covers mobile numbers (9xx), about 45 KB gzipped. Landlines (3xx, 4xx, 8xx) add 433 thousand ranges and about 640 KB, so they live in a separate entry point with the same API:
35
+
36
+ ```ts
37
+ import { lookup } from 'phoneoperator/full';
38
+
39
+ lookup('+7 495 123-45-67'); // { type: 'landline', operator: { name: 'ПАО "Ростелеком"', ... }, region: 'Город Москва', ... }
40
+ lookup('8 800 555 35 35'); // { type: 'landline', region: 'Российская Федерация', ... }
41
+ ```
42
+
43
+ For landlines `locality` holds the town when the registry names one.
44
+
45
+ ## API
46
+
47
+ | Function | Result |
48
+ |---|---|
49
+ | `lookup(input)` | `PhoneInfo` or `null` for invalid input and unassigned ranges |
50
+ | `parsePhone(input)` | 10 national digits or `null`; accepts `+7`, `7`, `8` and the usual separators |
51
+ | `formatPhone(input)` | `'+7 912 345-67-89'` or `null` |
52
+ | `BRANDS` | Brand by operator INN: МТС, МегаФон, Билайн, T2, Yota, Т-Мобайл, СберМобайл and others |
53
+ | `updated` | Date of the bundled registry snapshot |
54
+
55
+ `operator.brand` is `null` for operators without a consumer brand; `operator.name` and `operator.inn` are always the legal entity from the registry.
56
+
57
+ ## Ported numbers
58
+
59
+ The registry says who a number range was assigned to. Since 2013 a number can move to another operator, and the database of ported numbers is not public, so for a ported number `lookup` returns the original operator. Region does not change with porting.
60
+
61
+ ## Data
62
+
63
+ Every week the registry is downloaded, checked (header, every range against its capacity, no overlaps, the big four operators present), compressed and compared with the bundled copy. If it changed, the tests run, including a check of three numbers from every one of the 450 thousand registry rows, and a new minor version is published to npm automatically.
64
+
65
+ ## License
66
+
67
+ MIT. Registry data: [opendata.digital.gov.ru](https://opendata.digital.gov.ru/registry/numeric).
package/README.ru.md ADDED
@@ -0,0 +1,67 @@
1
+ # phoneoperator
2
+
3
+ [![npm](https://img.shields.io/npm/v/phoneoperator?color=0e7c66)](https://www.npmjs.com/package/phoneoperator)
4
+ [![JSR](https://jsr.io/badges/@mrprolopstar/phoneoperator)](https://jsr.io/@mrprolopstar/phoneoperator)
5
+
6
+ [English version](README.md)
7
+
8
+ Оператор и регион российского номера телефона офлайн. Данные взяты из официального реестра нумерации Минцифры, лежат внутри пакета и обновляются каждую неделю. Без зависимостей и сетевых запросов, работает в Node, Deno, Bun и браузере.
9
+
10
+ ```sh
11
+ npm install phoneoperator
12
+ ```
13
+
14
+ ```ts
15
+ import { lookup } from 'phoneoperator';
16
+
17
+ lookup('+7 916 123-45-67');
18
+ // {
19
+ // number: '+79161234567',
20
+ // national: '9161234567',
21
+ // code: '916',
22
+ // type: 'mobile',
23
+ // operator: { name: 'ПАО "Мобильные ТелеСистемы"', inn: '7740000076', brand: { id: 'mts', name: 'МТС' } },
24
+ // region: 'Город Москва, Московская область',
25
+ // locality: null
26
+ // }
27
+
28
+ lookup('8 (999) 123-45-67')?.operator.brand?.name; // 'Yota'
29
+ lookup('+1 212 555 0100'); // null
30
+ ```
31
+
32
+ ## Мобильные и стационарные
33
+
34
+ Основной импорт покрывает мобильные номера (9xx), это около 45 КБ в gzip. Стационарные (3xx, 4xx, 8xx) добавляют 433 тысячи диапазонов и около 640 КБ, поэтому они вынесены в отдельный импорт с тем же API:
35
+
36
+ ```ts
37
+ import { lookup } from 'phoneoperator/full';
38
+
39
+ lookup('+7 495 123-45-67'); // { type: 'landline', operator: { name: 'ПАО "Ростелеком"', ... }, region: 'Город Москва', ... }
40
+ lookup('8 800 555 35 35'); // { type: 'landline', region: 'Российская Федерация', ... }
41
+ ```
42
+
43
+ Для стационарных номеров в `locality` лежит населённый пункт, если реестр его указывает.
44
+
45
+ ## API
46
+
47
+ | Функция | Результат |
48
+ |---|---|
49
+ | `lookup(input)` | `PhoneInfo` или `null` для неверного ввода и невыделенных диапазонов |
50
+ | `parsePhone(input)` | 10 цифр номера или `null`; понимает `+7`, `7`, `8` и обычные разделители |
51
+ | `formatPhone(input)` | `'+7 912 345-67-89'` или `null` |
52
+ | `BRANDS` | Бренд по ИНН оператора: МТС, МегаФон, Билайн, T2, Yota, Т-Мобайл, СберМобайл и другие |
53
+ | `updated` | Дата снимка реестра в пакете |
54
+
55
+ `operator.brand` равен `null` у операторов без потребительского бренда, а `operator.name` и `operator.inn` всегда содержат юрлицо из реестра.
56
+
57
+ ## Перенесённые номера
58
+
59
+ Реестр говорит, какому оператору выделен диапазон. С 2013 года номер можно перенести к другому оператору, а база перенесённых номеров закрыта, поэтому для такого номера `lookup` вернёт исходного оператора. Регион при переносе не меняется.
60
+
61
+ ## Данные
62
+
63
+ Раз в неделю реестр скачивается и проверяется: заголовок, ёмкость каждого диапазона, отсутствие пересечений, наличие большой четвёрки операторов. Затем он сжимается и сравнивается с версией в пакете. Если что-то изменилось, запускаются тесты, в том числе проверка трёх номеров из каждой из 450 тысяч строк реестра, и новая минорная версия сама публикуется в npm.
64
+
65
+ ## Лицензия
66
+
67
+ MIT. Данные реестра: [opendata.digital.gov.ru](https://opendata.digital.gov.ru/registry/numeric).
@@ -0,0 +1,7 @@
1
+ export type BrandId = 'mts' | 'megafon' | 'beeline' | 't2' | 'yota' | 't-mobile' | 'sber-mobile' | 'alfa-mobile' | 'vtb-mobile' | 'motiv' | 'win-mobile' | 'volna' | 'rostelecom' | 'mtt';
2
+ export interface Brand {
3
+ readonly id: BrandId;
4
+ readonly name: string;
5
+ }
6
+ export declare const BRANDS: Readonly<Record<string, Brand>>;
7
+ //# sourceMappingURL=brands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brands.d.ts","sourceRoot":"","sources":["../src/brands.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GACf,KAAK,GACL,SAAS,GACT,SAAS,GACT,IAAI,GACJ,MAAM,GACN,UAAU,GACV,aAAa,GACb,aAAa,GACb,YAAY,GACZ,OAAO,GACP,YAAY,GACZ,OAAO,GACP,YAAY,GACZ,KAAK,CAAC;AAEV,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAelD,CAAC"}
package/dist/brands.js ADDED
@@ -0,0 +1,17 @@
1
+ export const BRANDS = {
2
+ '7740000076': { id: 'mts', name: 'МТС' },
3
+ '7812014560': { id: 'megafon', name: 'МегаФон' },
4
+ '7713076301': { id: 'beeline', name: 'Билайн' },
5
+ '7743895280': { id: 't2', name: 'T2' },
6
+ '7701725181': { id: 'yota', name: 'Yota' },
7
+ '7743200179': { id: 't-mobile', name: 'Т-Мобайл' },
8
+ '7736264044': { id: 'sber-mobile', name: 'СберМобайл' },
9
+ '9725152215': { id: 'alfa-mobile', name: 'Альфа-Мобайл' },
10
+ '9705121882': { id: 'vtb-mobile', name: 'ВТБ Мобайл' },
11
+ '6661079603': { id: 'motiv', name: 'Мотив' },
12
+ '2308210371': { id: 'win-mobile', name: 'Win mobile' },
13
+ '7718999159': { id: 'volna', name: 'Волна мобайл' },
14
+ '7707049388': { id: 'rostelecom', name: 'Ростелеком' },
15
+ '7705017253': { id: 'mtt', name: 'МТТ' },
16
+ };
17
+ //# sourceMappingURL=brands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brands.js","sourceRoot":"","sources":["../src/brands.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAC,MAAM,MAAM,GAAoC;IACrD,YAAY,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;IACxC,YAAY,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;IAChD,YAAY,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC/C,YAAY,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;IACtC,YAAY,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IAC1C,YAAY,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE;IAClD,YAAY,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,EAAE;IACvD,YAAY,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,cAAc,EAAE;IACzD,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE;IACtD,YAAY,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;IAC5C,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE;IACtD,YAAY,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE;IACnD,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAAE;IACtD,YAAY,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;CACzC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const UPDATED: string;
2
+ export declare const OPERATORS: readonly (readonly [inn: string, name: string])[];
3
+ export declare const PLACES: readonly string[];
4
+ export declare const RANGES: string;
5
+ //# sourceMappingURL=landline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"landline.d.ts","sourceRoot":"","sources":["../../src/data/landline.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,EAAE,MAAqB,CAAC;AAC5C,eAAO,MAAM,SAAS,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,EAA+owC,CAAC;AACvtwC,eAAO,MAAM,MAAM,EAAE,SAAS,MAAM,EAA8guG,CAAC;AACnjuG,eAAO,MAAM,MAAM,EAAE,MAAyv89H,CAAC"}