dialscope 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +127 -2
- package/THIRD-PARTY-NOTICES.md +19 -0
- package/dist/batch.d.ts +3 -0
- package/dist/batch.js +157 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +160 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/lookup.d.ts +24 -0
- package/dist/lookup.js +75 -0
- package/licenses/libphonenumber-js-Apache-2.0.txt +176 -0
- package/licenses/libphonenumber-js-MIT.txt +22 -0
- package/package.json +48 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DialScope contributors
|
|
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
CHANGED
|
@@ -1,3 +1,128 @@
|
|
|
1
|
-
#
|
|
1
|
+
# DialScope
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
DialScope is an offline Node.js terminal application that validates a phone number and reports national, international, and E.164 formats, metadata-backed number type, and available numbering metadata. It does not contact a lookup service or store entered numbers.
|
|
4
|
+
|
|
5
|
+
## Requirements and setup
|
|
6
|
+
|
|
7
|
+
Requires Node.js 22 or newer. From a checkout, install the locked dependencies and run the checks/build:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm ci
|
|
11
|
+
npm run typecheck
|
|
12
|
+
npm test
|
|
13
|
+
npm run build
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Run the CLI during development:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npm run dev
|
|
20
|
+
npm run dev -- "+14155552671"
|
|
21
|
+
npm run dev -- "08031234567" --region NG
|
|
22
|
+
npm run dev -- "08031234567" --format national
|
|
23
|
+
npm run dev -- "+41431234567" --json
|
|
24
|
+
npm run dev -- --help
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The interactive form prompts for a number. With a positional number, surrounding whitespace is trimmed. National-format input defaults to region `NG`; `--region` selects another supported ISO region. A number beginning with `+` uses its explicit calling code, independently of the default region. Unsupported regions and invalid numbers produce clear errors and a nonzero exit code. `--json` emits only JSON, including structured errors. Missing area or carrier metadata is `null` and missing time zones is an empty array. `node dist/cli.js --help` lists both single-number and CSV batch command forms.
|
|
28
|
+
|
|
29
|
+
Human-readable output accepts `--format national`, `--format international` (the default), or `--format e164`. JSON remains compatible with the existing `number` field (international format) and includes `nationalFormat`, `internationalFormat`, `e164`, and `numberType`. Number type comes from numbering metadata; `fixed-line-or-mobile` stays ambiguous, and unavailable or unrecognized metadata is `null`.
|
|
30
|
+
|
|
31
|
+
CSV batch lookup supports CSV and JSON export:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
node dist/cli.js --input examples/numbers.csv --column phone --output results.csv
|
|
35
|
+
node dist/cli.js --input examples/numbers.csv --column phone --output results.json --output-format json
|
|
36
|
+
node dist/cli.js --input numbers.csv --region NG --output results.csv --overwrite
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The header row is required and `--column` defaults to `phone`. `--region` defaults to `NG`; explicit international numbers use their calling code. Input order and duplicate rows are preserved. Every data row gets a result; invalid and empty phone cells do not stop other rows. Empty input files, malformed CSV, missing columns, and file errors are fatal. UTF-8 BOM, CRLF, quoted cells, and commas inside quoted cells are supported. Input is limited to 10 MiB and 10,000 data rows. The example is [examples/numbers.csv](examples/numbers.csv).
|
|
40
|
+
|
|
41
|
+
The stable CSV header is `row_id,input,lookup_status,number,national_format,international_format,e164,country_code,country_name,area_description,original_carrier,number_type,time_zones,error_code,error_message`. `row_id` is a 1-based data-row index. `lookup_status` is `success` or `error`; format/country/metadata columns are empty for row errors, with `error_code` and `error_message` populated. `time_zones` is serialized as a JSON array string. CSV string cells whose first non-space/control character is `=`, `+`, `-`, or `@` receive a leading apostrophe for spreadsheet safety, including the original input cell. JSON output preserves original strings without that escaping.
|
|
42
|
+
|
|
43
|
+
Exit codes are `0` for all successful rows, `3` when output completed with one or more row errors, and `1` for fatal option, CSV, size, or file errors. Existing output is refused unless `--overwrite` is supplied. Input and output cannot refer to the same file, including path aliases. Results are written atomically; temporary output is removed after a failed write. Batch mode stores no phone data except in the output file explicitly requested by the user. `--json` and `--format` single-number options cannot be combined with batch mode.
|
|
44
|
+
|
|
45
|
+
## Node.js library
|
|
46
|
+
|
|
47
|
+
After building or installing a local package tarball, import the side-effect-free lookup API:
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
import { lookupPhoneNumber } from 'dialscope';
|
|
51
|
+
|
|
52
|
+
const result = await lookupPhoneNumber('08031234567', 'NG');
|
|
53
|
+
if (result.ok) console.log(result.e164, result.numberType);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`LookupResult`, `LookupErrorCode`, and `NumberType` are exported TypeScript types. `NumberType` includes mobile, fixed line, fixed line or mobile, VoIP, toll-free, shared-cost, personal-number, pager, universal-access-number, voicemail, and premium-rate. `fixed-line-or-mobile` means metadata cannot distinguish those types; `null` means no recognized type metadata is available. Importing the package root does not start the CLI. The executable remains available separately as `dialscope`.
|
|
57
|
+
|
|
58
|
+
The first npm release is being prepared; it has not been published yet. After release, install the CLI/library package with:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
npm install dialscope
|
|
62
|
+
npx dialscope --help
|
|
63
|
+
npx dialscope "+14155552671" --json
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The package exposes the same lookup API and declarations shown above. In a consuming TypeScript project:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { lookupPhoneNumber } from 'dialscope';
|
|
70
|
+
import type { LookupResult, NumberType } from 'dialscope';
|
|
71
|
+
|
|
72
|
+
const result: LookupResult = await lookupPhoneNumber('08031234567', 'NG');
|
|
73
|
+
const kind: NumberType | null | undefined = result.ok ? result.numberType : undefined;
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
To build and install a local tarball before publication:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
npm ci
|
|
80
|
+
npm pack
|
|
81
|
+
npm install ./dialscope-1.0.0.tgz
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The package requires Node.js 22 or newer. Parsing and metadata lookup run offline; live caller-name lookup is not implemented, metadata may be incomplete or stale, and Python parity has not been verified. See [Metadata and limitations](#metadata-and-limitations) and [Python comparison status](#python-comparison-status).
|
|
85
|
+
|
|
86
|
+
PowerShell's `npm` shim may consume `--help` before forwarding it. In PowerShell, use `npm.cmd run dev -- --help`. The compiled CLI accepts the same arguments directly:
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
node dist/cli.js "+14155552671"
|
|
90
|
+
node dist/cli.js "+41431234567" --json
|
|
91
|
+
node dist/cli.js --help
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Example human output:
|
|
95
|
+
|
|
96
|
+
```text
|
|
97
|
+
International number: +1 415-555-2671
|
|
98
|
+
Number type: fixed-line-or-mobile
|
|
99
|
+
Country calling code: 1
|
|
100
|
+
Country: United States
|
|
101
|
+
Area: San Francisco, CA
|
|
102
|
+
Original carrier: Unknown
|
|
103
|
+
Possible time zones: America/Los_Angeles
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Exact spacing and metadata can vary with the bundled library metadata version.
|
|
107
|
+
|
|
108
|
+
## Metadata and limitations
|
|
109
|
+
|
|
110
|
+
Parsing, validity, number type and international formatting use `libphonenumber-js/max`. Area descriptions, original assigned carrier and possible time zones use the offline metadata in `libphonenumber-geo-carrier`. The dependencies and their data licenses are described in [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md). The data is a bundled snapshot and may be incomplete or lag current numbering changes.
|
|
111
|
+
|
|
112
|
+
Area descriptions describe numbering-plan allocation areas where available; they do not identify a caller's live location. Carrier information is the original assignment recorded in the metadata, not necessarily the current network after number portability. Time zones are possible zones associated with the number's numbering metadata and do not reveal a person's live location. DialScope never substitutes the computer's local time zone.
|
|
113
|
+
|
|
114
|
+
Missing metadata is reported as `Unknown` in human output and as `null` or `[]` in JSON. A valid number is not proof that it is active, reachable, or assigned to a person.
|
|
115
|
+
|
|
116
|
+
DialScope does not provide live caller-name lookup. Additional official products reviewed for Phase 6A offer reverse-name lookup or caller-ID MCP, but none confirms Nigerian `+234` name coverage and terms for an open-source CLI adapter. See [caller-name feasibility](docs/caller-name-feasibility.md). DialScope remains offline and does not send numbers to a lookup service.
|
|
117
|
+
|
|
118
|
+
## Privacy
|
|
119
|
+
|
|
120
|
+
Single and batch lookups run locally using installed package data. DialScope makes no network lookup requests, does not automatically save or log entered numbers, and collects no analytics. Batch output is written only to the output path explicitly requested by the user. Installing dependencies or a package tarball uses npm as usual, but number lookup itself is offline.
|
|
121
|
+
|
|
122
|
+
## Python comparison status
|
|
123
|
+
|
|
124
|
+
Python parity verification was not executed because Python was unavailable in the environment. No Python comparison tooling or Python runtime dependency is included. No parity result is claimed.
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
DialScope's code is licensed under the MIT License. See [LICENSE](LICENSE) and the third-party notices for dependency and metadata licensing.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
DialScope depends on the following packages and their bundled numbering metadata. Versions are locked in `package-lock.json`.
|
|
4
|
+
|
|
5
|
+
## libphonenumber-js 1.12.31
|
|
6
|
+
|
|
7
|
+
The package declares the MIT license for its JavaScript implementation. Its distribution includes the MIT license and an Apache License 2.0 text for the upstream Google libphonenumber metadata/source; copies from the installed distribution are included in `licenses/`. The project describes itself and its upstream relationship at [github.com/catamphetamine/libphonenumber-js](https://github.com/catamphetamine/libphonenumber-js).
|
|
8
|
+
|
|
9
|
+
## libphonenumber-geo-carrier 2.0.0
|
|
10
|
+
|
|
11
|
+
The package metadata declares the MIT license and credits Martin Mende. The published package does not include a standalone license text; its source and license declaration are available at [github.com/mmende/libphonenumber-geo-carrier](https://github.com/mmende/libphonenumber-geo-carrier). Its geocoding, carrier, and time-zone mappings are bundled offline data derived from the Google libphonenumber mapping resources. Those upstream resources are under Apache License 2.0. The Apache license text shipped with `libphonenumber-js` is included in `licenses/` for the upstream metadata. This notice records the package's declared license and metadata provenance; it does not assert a separate metadata version beyond the package version.
|
|
12
|
+
|
|
13
|
+
## Node.js, TypeScript, Vitest, and transitive packages
|
|
14
|
+
|
|
15
|
+
These are build/test/runtime dependencies declared through npm. Their package license declarations and notices are distributed in the npm packages installed by `npm ci`; their resolved versions are recorded in `package-lock.json`. No dependency is bundled or vendored into DialScope's source tree.
|
|
16
|
+
|
|
17
|
+
## csv-parse 7.0.3 and csv-stringify 6.9.0
|
|
18
|
+
|
|
19
|
+
These CSV parsing and serialization packages declare the MIT license. Their package notices are distributed with the installed packages; exact versions and integrity hashes are recorded in `package-lock.json`. DialScope uses their documented synchronous APIs only with bounded input sizes.
|
package/dist/batch.d.ts
ADDED
package/dist/batch.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { open, readFile, realpath, stat, link, rename, unlink } from 'node:fs/promises';
|
|
2
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { parse } from 'csv-parse/sync';
|
|
5
|
+
import { stringify } from 'csv-stringify/sync';
|
|
6
|
+
import { isSupportedRegion, lookupPhoneNumber } from './lookup.js';
|
|
7
|
+
export const MAX_INPUT_BYTES = 10 * 1024 * 1024;
|
|
8
|
+
export const MAX_DATA_ROWS = 10_000;
|
|
9
|
+
const columns = ['row_id', 'input', 'lookup_status', 'number', 'national_format', 'international_format', 'e164', 'country_code', 'country_name', 'area_description', 'original_carrier', 'number_type', 'time_zones', 'error_code', 'error_message'];
|
|
10
|
+
function errorText(error) { return error instanceof Error ? error.message : 'Unknown file or processing error.'; }
|
|
11
|
+
function formulaSafe(value) {
|
|
12
|
+
return /^[\s\u0000-\u001f]*[=+\-@]/.test(value) ? `'${value}` : value;
|
|
13
|
+
}
|
|
14
|
+
function outputRow(id, input, result) {
|
|
15
|
+
if (!result.ok)
|
|
16
|
+
return { row_id: id, input, lookup_status: 'error', number: '', national_format: '', international_format: '', e164: '', country_code: '', country_name: '', area_description: '', original_carrier: '', number_type: '', time_zones: '[]', error_code: result.error.code, error_message: result.error.message };
|
|
17
|
+
return { row_id: id, input, lookup_status: 'success', number: result.number, national_format: result.nationalFormat, international_format: result.internationalFormat, e164: result.e164, country_code: result.countryCode, country_name: result.countryName, area_description: result.areaDescription ?? '', original_carrier: result.originalCarrier ?? '', number_type: result.numberType ?? '', time_zones: JSON.stringify(result.timeZones), error_code: '', error_message: '' };
|
|
18
|
+
}
|
|
19
|
+
async function sameFile(input, output) {
|
|
20
|
+
const inputPath = resolve(input), outputPath = resolve(output);
|
|
21
|
+
if (process.platform === 'win32' ? inputPath.toLowerCase() === outputPath.toLowerCase() : inputPath === outputPath)
|
|
22
|
+
return true;
|
|
23
|
+
try {
|
|
24
|
+
const [a, b] = await Promise.all([stat(inputPath), stat(outputPath)]);
|
|
25
|
+
if (a.dev === b.dev && a.ino === b.ino)
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
catch { /* A not-yet-existing output is checked using its canonical parent below. */ }
|
|
29
|
+
try {
|
|
30
|
+
const [parent, source] = await Promise.all([realpath(dirname(outputPath)), realpath(inputPath)]);
|
|
31
|
+
const canonicalOutput = join(parent, basename(outputPath));
|
|
32
|
+
return process.platform === 'win32' ? source.toLowerCase() === canonicalOutput.toLowerCase() : source === canonicalOutput;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export async function runBatch(args) {
|
|
39
|
+
const options = new Map();
|
|
40
|
+
let overwrite = false;
|
|
41
|
+
let json = false;
|
|
42
|
+
let positional = false;
|
|
43
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
44
|
+
const arg = args[i] ?? '';
|
|
45
|
+
if (arg === '--overwrite') {
|
|
46
|
+
overwrite = true;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (arg === '--json') {
|
|
50
|
+
json = true;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (['--input', '--column', '--output', '--output-format', '--region'].includes(arg)) {
|
|
54
|
+
const value = args[++i];
|
|
55
|
+
if (!value || value.startsWith('--')) {
|
|
56
|
+
console.error(`Fatal error: ${arg} requires a value.`);
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
options.set(arg, value);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (arg === '--help' || arg === '-h')
|
|
63
|
+
return 1;
|
|
64
|
+
if (arg.startsWith('-') || positional) {
|
|
65
|
+
console.error('Fatal error: batch options cannot be combined with a positional phone number or unknown flags.');
|
|
66
|
+
return 1;
|
|
67
|
+
}
|
|
68
|
+
positional = true;
|
|
69
|
+
}
|
|
70
|
+
if (positional) {
|
|
71
|
+
console.error('Fatal error: a single phone number cannot be combined with batch flags.');
|
|
72
|
+
return 1;
|
|
73
|
+
}
|
|
74
|
+
if (!options.has('--input') || !options.has('--output')) {
|
|
75
|
+
console.error('Fatal error: batch mode requires --input and --output.');
|
|
76
|
+
return 1;
|
|
77
|
+
}
|
|
78
|
+
if (json || options.has('--json') || options.has('--format')) {
|
|
79
|
+
console.error('Fatal error: --json/--format single-lookup flags cannot be combined with batch mode.');
|
|
80
|
+
return 1;
|
|
81
|
+
}
|
|
82
|
+
const inputPath = resolve(options.get('--input')), outputPath = resolve(options.get('--output'));
|
|
83
|
+
const region = options.get('--region') ?? 'NG';
|
|
84
|
+
const column = options.get('--column') ?? 'phone';
|
|
85
|
+
const outputFormat = options.get('--output-format') ?? 'csv';
|
|
86
|
+
if (!isSupportedRegion(region)) {
|
|
87
|
+
console.error('Fatal error: unsupported --region.');
|
|
88
|
+
return 1;
|
|
89
|
+
}
|
|
90
|
+
if (outputFormat !== 'csv' && outputFormat !== 'json') {
|
|
91
|
+
console.error('Fatal error: --output-format must be csv or json.');
|
|
92
|
+
return 1;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
if (await sameFile(inputPath, outputPath))
|
|
96
|
+
throw new Error('Input and output paths refer to the same file.');
|
|
97
|
+
if (!overwrite) {
|
|
98
|
+
try {
|
|
99
|
+
await stat(outputPath);
|
|
100
|
+
throw new Error('Output already exists; pass --overwrite to replace it.');
|
|
101
|
+
}
|
|
102
|
+
catch (e) {
|
|
103
|
+
if (e instanceof Error && e.message.includes('already exists'))
|
|
104
|
+
throw e;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const inputBytes = await readFile(inputPath);
|
|
108
|
+
if (inputBytes.byteLength > MAX_INPUT_BYTES)
|
|
109
|
+
throw new Error(`Input exceeds the ${MAX_INPUT_BYTES} byte limit.`);
|
|
110
|
+
if (inputBytes.byteLength === 0)
|
|
111
|
+
throw new Error('Input file is empty; a header row is required.');
|
|
112
|
+
const records = parse(inputBytes, { bom: true, columns: (headers) => {
|
|
113
|
+
if (!headers.length || headers.some(h => !h.trim()) || new Set(headers).size !== headers.length)
|
|
114
|
+
throw new Error('CSV must have non-empty, unique headers.');
|
|
115
|
+
if (!headers.includes(column))
|
|
116
|
+
throw new Error(`CSV is missing the requested ${column} column.`);
|
|
117
|
+
return headers;
|
|
118
|
+
}, skip_empty_lines: true, max_record_size: MAX_INPUT_BYTES });
|
|
119
|
+
if (records.length > MAX_DATA_ROWS)
|
|
120
|
+
throw new Error(`Input exceeds the ${MAX_DATA_ROWS} data-row limit.`);
|
|
121
|
+
const rows = [];
|
|
122
|
+
for (let i = 0; i < records.length; i += 1) {
|
|
123
|
+
const original = records[i]?.[column] ?? '';
|
|
124
|
+
const result = original.trim() ? await lookupPhoneNumber(original, region) : { ok: false, error: { code: 'INVALID_INPUT', message: 'Phone cell is empty.' } };
|
|
125
|
+
rows.push(outputRow(i + 1, original, result));
|
|
126
|
+
}
|
|
127
|
+
const body = outputFormat === 'json' ? JSON.stringify(rows.map(r => Object.fromEntries(Object.entries(r).map(([k, v]) => [k, v]))), null, 2) + '\n'
|
|
128
|
+
: stringify(rows, { header: true, columns: [...columns], record_delimiter: '\r\n', cast: { string: (v) => formulaSafe(v) } });
|
|
129
|
+
await writeAtomic(outputPath, body, overwrite);
|
|
130
|
+
const failures = rows.filter(r => r.lookup_status === 'error').length;
|
|
131
|
+
console.log(`Wrote ${rows.length} rows to ${outputPath}; ${failures} row error(s).`);
|
|
132
|
+
return failures ? 3 : 0;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
console.error(`Fatal error: ${errorText(error)}`);
|
|
136
|
+
return 1;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async function writeAtomic(target, body, overwrite) {
|
|
140
|
+
const temp = join(dirname(target), `.${basename(target)}.${randomUUID()}.tmp`);
|
|
141
|
+
let handle;
|
|
142
|
+
try {
|
|
143
|
+
handle = await open(temp, 'wx', 0o600);
|
|
144
|
+
await handle.writeFile(body, 'utf8');
|
|
145
|
+
await handle.close();
|
|
146
|
+
handle = undefined;
|
|
147
|
+
if (overwrite)
|
|
148
|
+
await rename(temp, target);
|
|
149
|
+
else
|
|
150
|
+
await link(temp, target);
|
|
151
|
+
}
|
|
152
|
+
finally {
|
|
153
|
+
if (handle)
|
|
154
|
+
await handle.close().catch(() => undefined);
|
|
155
|
+
await unlink(temp).catch(() => undefined);
|
|
156
|
+
}
|
|
157
|
+
}
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createInterface } from 'node:readline/promises';
|
|
3
|
+
import { stdin, stdout } from 'node:process';
|
|
4
|
+
import { lookupPhoneNumber, isSupportedRegion } from './lookup.js';
|
|
5
|
+
import { runBatch } from './batch.js';
|
|
6
|
+
const usage = `dialscope - offline phone number information\n\nUsage:\n node dist/cli.js [number] [--region ISO] [--format national|international|e164] [--json]\n node dist/cli.js --input FILE --output FILE [--column NAME] [--region ISO] [--output-format csv|json] [--overwrite]\n node dist/cli.js --help\n\nSingle-number lookup:\n With no number, prompts for one interactively. Default region: NG.\n Numbers beginning with + use their explicit calling code. Human output defaults to international format.\n JSON includes nationalFormat, internationalFormat, e164, and metadata-backed numberType.\n\nCSV batch lookup:\n Input must have a header row; --column defaults to phone and --region defaults to NG.\n Output defaults to CSV; choose JSON with --output-format json. Existing output requires --overwrite.\n Each input row produces a result; completed batches with row errors exit with status 3.\n Input is limited to 10 MiB and 10,000 data rows.\n\nMetadata describes numbering assignments, not a live location.`;
|
|
7
|
+
function renderHuman(result, format = 'international') {
|
|
8
|
+
if (!result.ok) {
|
|
9
|
+
console.error(`Error [${result.error.code}]: ${result.error.message}`);
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const labels = { national: result.nationalFormat, international: result.internationalFormat, e164: result.e164 };
|
|
13
|
+
console.log(`${format[0]?.toUpperCase()}${format.slice(1)} number: ${labels[format]}`);
|
|
14
|
+
console.log(`Number type: ${result.numberType ?? 'Unknown'}`);
|
|
15
|
+
console.log(`Country calling code: ${result.countryCode}`);
|
|
16
|
+
console.log(`Country: ${result.countryName}`);
|
|
17
|
+
console.log(`Area description: ${result.areaDescription ?? 'Unknown'} (numbering-area information)`);
|
|
18
|
+
console.log(`Original assigned carrier: ${result.originalCarrier ?? 'Unknown'} (may differ after porting)`);
|
|
19
|
+
console.log(`Possible time zones: ${result.timeZones.length ? result.timeZones.join(', ') : 'Unknown'}`);
|
|
20
|
+
console.log('Validation does not prove that a number is active or reveal anyone’s live location.');
|
|
21
|
+
}
|
|
22
|
+
function exitCode(result) {
|
|
23
|
+
if (result.ok)
|
|
24
|
+
return 0;
|
|
25
|
+
return result.error.code === 'INVALID_INPUT' || result.error.code === 'INVALID_REGION' ? 2 : 1;
|
|
26
|
+
}
|
|
27
|
+
async function main(args) {
|
|
28
|
+
if (args.includes('--input') || args.some((arg) => arg.startsWith('--input=')))
|
|
29
|
+
return runBatch(args);
|
|
30
|
+
const cliArgs = [...args];
|
|
31
|
+
const npmLifecycle = process.env.npm_lifecycle_event === 'dev';
|
|
32
|
+
let json = npmLifecycle && process.env.npm_config_json === 'true';
|
|
33
|
+
let region = npmLifecycle && process.env.npm_config_region && process.env.npm_config_region !== 'true'
|
|
34
|
+
? process.env.npm_config_region.toUpperCase()
|
|
35
|
+
: 'NG';
|
|
36
|
+
let number;
|
|
37
|
+
let format = 'international';
|
|
38
|
+
if (npmLifecycle && process.env.npm_config_region === 'true') {
|
|
39
|
+
const npmConsumedRegion = cliArgs.at(-1);
|
|
40
|
+
if (npmConsumedRegion) {
|
|
41
|
+
cliArgs.pop();
|
|
42
|
+
cliArgs.push('--region', npmConsumedRegion);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
cliArgs.push('--region');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
for (let index = 0; index < cliArgs.length; index += 1) {
|
|
49
|
+
const argument = cliArgs[index] ?? '';
|
|
50
|
+
if (argument === '--help' || argument === '-h') {
|
|
51
|
+
if (json)
|
|
52
|
+
console.log(JSON.stringify({ help: usage }));
|
|
53
|
+
else
|
|
54
|
+
console.log(usage);
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
if (argument === '--json') {
|
|
58
|
+
json = true;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (argument === '--format') {
|
|
62
|
+
const value = cliArgs[index + 1];
|
|
63
|
+
if (value !== 'national' && value !== 'international' && value !== 'e164') {
|
|
64
|
+
const result = { ok: false, error: { code: 'INVALID_INPUT', message: '--format must be national, international, or e164.' } };
|
|
65
|
+
if (json)
|
|
66
|
+
console.log(JSON.stringify(result));
|
|
67
|
+
else
|
|
68
|
+
renderHuman(result);
|
|
69
|
+
return exitCode(result);
|
|
70
|
+
}
|
|
71
|
+
format = value;
|
|
72
|
+
index += 1;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (argument === '--region') {
|
|
76
|
+
const value = cliArgs[index + 1];
|
|
77
|
+
if (!value || value.startsWith('--')) {
|
|
78
|
+
const result = { ok: false, error: { code: 'INVALID_REGION', message: '--region requires a two-letter ISO region code.' } };
|
|
79
|
+
if (json)
|
|
80
|
+
console.log(JSON.stringify(result));
|
|
81
|
+
else
|
|
82
|
+
renderHuman(result);
|
|
83
|
+
return exitCode(result);
|
|
84
|
+
}
|
|
85
|
+
region = value.toUpperCase();
|
|
86
|
+
index += 1;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (argument.startsWith('-')) {
|
|
90
|
+
const result = { ok: false, error: { code: 'INVALID_INPUT', message: `Unknown flag "${argument}".` } };
|
|
91
|
+
if (json)
|
|
92
|
+
console.log(JSON.stringify(result));
|
|
93
|
+
else
|
|
94
|
+
renderHuman(result);
|
|
95
|
+
return exitCode(result);
|
|
96
|
+
}
|
|
97
|
+
if (number !== undefined) {
|
|
98
|
+
const result = { ok: false, error: { code: 'INVALID_INPUT', message: 'Provide only one phone number.' } };
|
|
99
|
+
if (json)
|
|
100
|
+
console.log(JSON.stringify(result));
|
|
101
|
+
else
|
|
102
|
+
renderHuman(result);
|
|
103
|
+
return exitCode(result);
|
|
104
|
+
}
|
|
105
|
+
number = argument;
|
|
106
|
+
}
|
|
107
|
+
if (!isSupportedRegion(region)) {
|
|
108
|
+
const result = { ok: false, error: { code: 'INVALID_REGION', message: `Unsupported region "${region}". Use a supported two-letter ISO region code.` } };
|
|
109
|
+
if (json)
|
|
110
|
+
console.log(JSON.stringify(result));
|
|
111
|
+
else
|
|
112
|
+
renderHuman(result);
|
|
113
|
+
return exitCode(result);
|
|
114
|
+
}
|
|
115
|
+
if (number === undefined) {
|
|
116
|
+
if (json) {
|
|
117
|
+
const result = { ok: false, error: { code: 'INVALID_INPUT', message: 'A number argument is required in JSON mode.' } };
|
|
118
|
+
console.log(JSON.stringify(result));
|
|
119
|
+
return exitCode(result);
|
|
120
|
+
}
|
|
121
|
+
const prompt = createInterface({ input: stdin, output: stdout });
|
|
122
|
+
try {
|
|
123
|
+
number = (await prompt.question('Phone number: ')).trim();
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
127
|
+
console.error('Input cancelled.');
|
|
128
|
+
return 130;
|
|
129
|
+
}
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
prompt.close();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const result = await lookupPhoneNumber(number, region);
|
|
137
|
+
if (json)
|
|
138
|
+
console.log(JSON.stringify(result));
|
|
139
|
+
else
|
|
140
|
+
renderHuman(result, format);
|
|
141
|
+
return exitCode(result);
|
|
142
|
+
}
|
|
143
|
+
const npmForwardedUnknownFlag = process.env.npm_lifecycle_event === 'dev'
|
|
144
|
+
? Object.entries(process.env).find(([key, value]) => key.startsWith('npm_config_') && key !== 'npm_config_json' && key !== 'npm_config_region' && value === 'true' && !['npm_config_audit', 'npm_config_fund', 'npm_config_save', 'npm_config_update_notifier'].includes(key))?.[0]
|
|
145
|
+
: undefined;
|
|
146
|
+
try {
|
|
147
|
+
const args = process.argv.slice(2);
|
|
148
|
+
if (npmForwardedUnknownFlag)
|
|
149
|
+
args.unshift(`--${npmForwardedUnknownFlag.slice('npm_config_'.length).replaceAll('_', '-')}`);
|
|
150
|
+
process.exitCode = await main(args);
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
const result = { ok: false, error: { code: 'DEPENDENCY_FAILURE', message: 'Phone lookup failed unexpectedly.' } };
|
|
154
|
+
const json = process.argv.includes('--json') || (process.env.npm_lifecycle_event === 'dev' && process.env.npm_config_json === 'true');
|
|
155
|
+
if (json)
|
|
156
|
+
console.log(JSON.stringify(result));
|
|
157
|
+
else
|
|
158
|
+
console.error(`Error [${result.error.code}]: ${result.error.message}`);
|
|
159
|
+
process.exitCode = 1;
|
|
160
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { lookupPhoneNumber, isSupportedRegion } from './lookup.js';
|
package/dist/lookup.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type CountryCode } from 'libphonenumber-js/max';
|
|
2
|
+
export type LookupErrorCode = 'INVALID_INPUT' | 'INVALID_REGION' | 'METADATA_UNAVAILABLE' | 'DEPENDENCY_FAILURE';
|
|
3
|
+
export type NumberType = 'mobile' | 'fixed-line' | 'fixed-line-or-mobile' | 'voip' | 'toll-free' | 'shared-cost' | 'personal-number' | 'pager' | 'universal-access-number' | 'voicemail' | 'premium-rate';
|
|
4
|
+
export type LookupResult = {
|
|
5
|
+
readonly ok: true;
|
|
6
|
+
readonly number: string;
|
|
7
|
+
readonly nationalFormat: string;
|
|
8
|
+
readonly internationalFormat: string;
|
|
9
|
+
readonly e164: string;
|
|
10
|
+
readonly numberType: NumberType | null;
|
|
11
|
+
readonly countryCode: string;
|
|
12
|
+
readonly countryName: string;
|
|
13
|
+
readonly areaDescription: string | null;
|
|
14
|
+
readonly originalCarrier: string | null;
|
|
15
|
+
readonly timeZones: readonly string[];
|
|
16
|
+
} | {
|
|
17
|
+
readonly ok: false;
|
|
18
|
+
readonly error: {
|
|
19
|
+
readonly code: LookupErrorCode;
|
|
20
|
+
readonly message: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare function isSupportedRegion(region: string): region is CountryCode;
|
|
24
|
+
export declare function lookupPhoneNumber(input: string, region?: string): Promise<LookupResult>;
|
package/dist/lookup.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { carrier, geocoder, timezones } from 'libphonenumber-geo-carrier';
|
|
2
|
+
import { getCountries, getCountryCallingCode, parsePhoneNumberFromString } from 'libphonenumber-js/max';
|
|
3
|
+
const regions = new Set(getCountries());
|
|
4
|
+
const countryNames = new Intl.DisplayNames(['en'], { type: 'region' });
|
|
5
|
+
const failure = (code, message) => ({ ok: false, error: { code, message } });
|
|
6
|
+
export function isSupportedRegion(region) {
|
|
7
|
+
return regions.has(region.toUpperCase());
|
|
8
|
+
}
|
|
9
|
+
function metadataText(value) {
|
|
10
|
+
if (typeof value !== 'string')
|
|
11
|
+
return null;
|
|
12
|
+
const normalized = value.trim();
|
|
13
|
+
if (!normalized || /^(?:unknown|undefined|null|n\/a)$/i.test(normalized))
|
|
14
|
+
return null;
|
|
15
|
+
return normalized;
|
|
16
|
+
}
|
|
17
|
+
function normalizedNumberType(value) {
|
|
18
|
+
switch (value) {
|
|
19
|
+
case 'MOBILE': return 'mobile';
|
|
20
|
+
case 'FIXED_LINE': return 'fixed-line';
|
|
21
|
+
case 'FIXED_LINE_OR_MOBILE': return 'fixed-line-or-mobile';
|
|
22
|
+
case 'VOIP': return 'voip';
|
|
23
|
+
case 'TOLL_FREE': return 'toll-free';
|
|
24
|
+
case 'SHARED_COST': return 'shared-cost';
|
|
25
|
+
case 'PERSONAL_NUMBER': return 'personal-number';
|
|
26
|
+
case 'PAGER': return 'pager';
|
|
27
|
+
case 'UAN': return 'universal-access-number';
|
|
28
|
+
case 'VOICEMAIL': return 'voicemail';
|
|
29
|
+
case 'PREMIUM_RATE': return 'premium-rate';
|
|
30
|
+
default: return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export async function lookupPhoneNumber(input, region = 'NG') {
|
|
34
|
+
const trimmed = input.trim();
|
|
35
|
+
const normalizedRegion = region.toUpperCase();
|
|
36
|
+
if (!isSupportedRegion(normalizedRegion))
|
|
37
|
+
return failure('INVALID_REGION', `Unsupported region "${region}". Use a supported two-letter ISO region code.`);
|
|
38
|
+
if (!trimmed)
|
|
39
|
+
return failure('INVALID_INPUT', 'Enter a phone number.');
|
|
40
|
+
let phone;
|
|
41
|
+
try {
|
|
42
|
+
phone = parsePhoneNumberFromString(trimmed, normalizedRegion);
|
|
43
|
+
if (!phone || !phone.isValid())
|
|
44
|
+
return failure('INVALID_INPUT', 'The phone number is malformed or invalid for its numbering region.');
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return failure('INVALID_INPUT', 'The phone number is malformed or invalid for its numbering region.');
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const [area, assignedCarrier, zones] = await Promise.all([
|
|
51
|
+
geocoder(phone, 'en'), carrier(phone, 'en'), timezones(phone),
|
|
52
|
+
]);
|
|
53
|
+
const country = phone.country;
|
|
54
|
+
const countryCallingCode = country ? getCountryCallingCode(country) : phone.countryCallingCode;
|
|
55
|
+
const countryName = country ? countryNames.of(country) : 'Non-geographic';
|
|
56
|
+
return {
|
|
57
|
+
ok: true,
|
|
58
|
+
number: phone.formatInternational(),
|
|
59
|
+
nationalFormat: phone.formatNational(),
|
|
60
|
+
internationalFormat: phone.formatInternational(),
|
|
61
|
+
e164: phone.number,
|
|
62
|
+
numberType: normalizedNumberType(phone.getType()),
|
|
63
|
+
countryCode: `+${countryCallingCode}`,
|
|
64
|
+
countryName: countryName ?? 'Unknown',
|
|
65
|
+
areaDescription: metadataText(area),
|
|
66
|
+
originalCarrier: metadataText(assignedCarrier),
|
|
67
|
+
timeZones: Array.isArray(zones)
|
|
68
|
+
? zones.map(metadataText).filter((zone) => zone !== null)
|
|
69
|
+
: [],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return failure('DEPENDENCY_FAILURE', 'Phone metadata lookup failed. Check the installation and try again.');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 @catamphetamine <purecatamphetamine@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dialscope",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Offline phone-number lookup CLI and Node.js library",
|
|
5
|
+
"author": "shazarkk",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/shazzark/dialscope.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/shazzark/dialscope#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/shazzark/dialscope/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=22"
|
|
18
|
+
},
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": ["dist", "README.md", "LICENSE", "THIRD-PARTY-NOTICES.md", "licenses"],
|
|
28
|
+
"bin": {
|
|
29
|
+
"dialscope": "dist/cli.js"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"dev": "npm run build --silent && node dist/cli.js",
|
|
33
|
+
"prepack": "npm run build",
|
|
34
|
+
"pretest": "npm run build",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"build": "tsc -p tsconfig.build.json"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"csv-parse": "7.0.3",
|
|
41
|
+
"csv-stringify": "6.9.0",
|
|
42
|
+
"libphonenumber-geo-carrier": "2.0.0",
|
|
43
|
+
"libphonenumber-js": "1.12.31"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "22.15.30",
|
|
47
|
+
"typescript": "5.8.3",
|
|
48
|
+
"vitest": "5.0.4"
|
|
49
|
+
}
|
|
50
|
+
}
|