@ip2geo/sdk 0.0.1

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/README.md ADDED
@@ -0,0 +1,98 @@
1
+ <div align='center'>
2
+ <a href='https://axios-http.com'>
3
+ <img
4
+ src='https://cdn-prod.ip2geo.dev/assets/npm/generals/ip2geo.svg'
5
+ alt='Ip2Geo Logo'
6
+ />
7
+ </a>
8
+
9
+ <br />
10
+ </div>
11
+
12
+ <p align='center'>
13
+ Your go-to IP-to-Geo cloud service — fast, accurate, and built for developers. Start free with 2,000 monthly requests.
14
+ </p>
15
+
16
+ <p align='center'>
17
+ <a href='https://ip2geo.dev'>
18
+ <b>
19
+ Website
20
+ </b>
21
+ </a>
22
+
23
+ <a href='https://app.ip2geo.dev'>
24
+ <b>
25
+ App
26
+ </b>
27
+ </a>
28
+
29
+ <a href='https://docs.ip2geo.dev'>
30
+ <b>
31
+ Documentation
32
+ </b>
33
+ </a>
34
+ </p>
35
+
36
+ <br />
37
+
38
+ ## Intro to the Npm Package
39
+
40
+ This package provides a lightweight, type-safe way to integrate Ip2Geo. Blazingly fast and works with Node, Bun, and Deno out of the box.
41
+
42
+ ### Installing
43
+ ```bun
44
+ npm i @ip2geo/sdk@latest
45
+ ```
46
+
47
+ ### Initializing
48
+ ```typescript
49
+ import { Init } from '@ip2geo/sdk'
50
+ import { Env } from '@/data'
51
+
52
+ await Init(Env.IP2GEO_API_KEY)
53
+ ```
54
+
55
+ ### Using
56
+ ```typescript
57
+ import { ConvertIP, ConvertIPs } from '@ip2geo/sdk'
58
+
59
+ const convertedIp = await ConvertIP({
60
+ ip: '8.8.8.8'
61
+ })
62
+
63
+ const convertedIps = await ConvertIPs({
64
+ ips: [
65
+ '8.8.8.8',
66
+ '1.1.1.1',
67
+ '9.9.9.9',
68
+ '64.6.64.6'
69
+ ]
70
+ })
71
+
72
+ // {
73
+ // success: boolean
74
+ // code: number
75
+ // message: string
76
+ // data: Ip | null
77
+ // _req: {
78
+ // reqId: string | null
79
+ // resTime: number
80
+ // }
81
+ // }
82
+
83
+ // {
84
+ // message: string
85
+ // code: number
86
+ // sucess: boolean
87
+ // data: [
88
+ // {
89
+ // ip: string
90
+ // conversion: Ip | null
91
+ // }
92
+ // ],
93
+ // _req: {
94
+ // reqId: string | null
95
+ // resTime: number
96
+ // }
97
+ // }
98
+ ```
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ const API_ENDPOINT = 'https://api.ip2geo.dev';
4
+ const DOCS_URL = 'https://docs.ip2geo.dev';
5
+ const NPM_REGISTRY_URL = 'https://registry.npmjs.org/@ip2geo/sdk';
6
+ const HTTP_METHODS = {
7
+ GET: 'get',
8
+ POST: 'post'};
9
+ const HEADER_KEYS = {
10
+ X_API_KEY: 'X-Api-Key'
11
+ };
12
+ const FILE_TYPES = {
13
+ JSON: 'json'
14
+ };
15
+ const FILE_FORMATS = {
16
+ APPLICATION_JSON: `application/${FILE_TYPES.JSON}`
17
+ };
18
+ const HEADER_TYPES = {
19
+ CONTENT_TYPE: 'Content-Type'
20
+ };
21
+ const ENDPOINTS = {
22
+ CONVERT: '/convert'
23
+ };
24
+
25
+ exports.API_ENDPOINT = API_ENDPOINT;
26
+ exports.DOCS_URL = DOCS_URL;
27
+ exports.ENDPOINTS = ENDPOINTS;
28
+ exports.FILE_FORMATS = FILE_FORMATS;
29
+ exports.FILE_TYPES = FILE_TYPES;
30
+ exports.HEADER_KEYS = HEADER_KEYS;
31
+ exports.HEADER_TYPES = HEADER_TYPES;
32
+ exports.HTTP_METHODS = HTTP_METHODS;
33
+ exports.NPM_REGISTRY_URL = NPM_REGISTRY_URL;
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ var Constants = require('./Constants.js');
4
+ var Console = require('../helpers/Console.js');
5
+ var Translation = require('../helpers/Translation.js');
6
+
7
+ /* eslint-disable no-control-regex */
8
+ /* eslint-disable quotes */
9
+ const MessageUpdate = (currentVersion, latestVersion) => {
10
+ const boxWidth = 70;
11
+ const topBorder = `┌${'─'.repeat(boxWidth - 2)}┐`;
12
+ const bottomBorder = `└${'─'.repeat(boxWidth - 2)}┘`;
13
+ const stripAnsi = (str) => str.replace(/\x1b\[[0-9;]*m/g, '');
14
+ const centerText = (text) => {
15
+ const visibleLength = stripAnsi(text).length;
16
+ const padding = Math.max(0, Math.floor((boxWidth - 2 - visibleLength) / 2));
17
+ const rightPadding = Math.max(0, boxWidth - 2 - padding - visibleLength);
18
+ return `│${' '.repeat(padding)}${text}${' '.repeat(rightPadding)}│`;
19
+ };
20
+ const updateText = `\x1b[1m\x1b[33m${Translation.default('console.update-available')}\x1b[0m \x1b[2m${currentVersion} → ${latestVersion}\x1b[0m`;
21
+ const changelogText = `${Translation.default('console.changelogs')} \x1b[36m${Constants.DOCS_URL}/sdk/changelogs\x1b[0m`;
22
+ const commandText = `${Translation.default('console.run')} \x1b[32m\`npm i @ip2geo/sdk@latest\`\x1b[0m ${Translation.default('console.to-update')}.`;
23
+ const disableText = `${Translation.default('console.disable-warning-using')}: \x1b[36m{ versionUpdateMessage: false }\x1b[0m ${Translation.default('console.on-init')}.`;
24
+ Console.default.Info('MessageUpdate', '', true);
25
+ Console.default.Info('MessageUpdate', topBorder, true);
26
+ Console.default.Info('MessageUpdate', centerText(updateText), true);
27
+ Console.default.Info('MessageUpdate', centerText(changelogText), true);
28
+ Console.default.Info('MessageUpdate', centerText(commandText), true);
29
+ Console.default.Info('MessageUpdate', centerText(''), true);
30
+ Console.default.Info('MessageUpdate', centerText(disableText), true);
31
+ Console.default.Info('MessageUpdate', bottomBorder, true);
32
+ Console.default.Info('MessageUpdate', '', true);
33
+ };
34
+ const MessageClientRuntime = () => {
35
+ const boxWidth = 70;
36
+ const topBorder = `┌${'─'.repeat(boxWidth - 2)}┐`;
37
+ const bottomBorder = `└${'─'.repeat(boxWidth - 2)}┘`;
38
+ const stripAnsi = (str) => str.replace(/\x1b\[[0-9;]*m/g, '');
39
+ const centerText = (text) => {
40
+ const visibleLength = stripAnsi(text).length;
41
+ const padding = Math.max(0, Math.floor((boxWidth - 2 - visibleLength) / 2));
42
+ const rightPadding = Math.max(0, boxWidth - 2 - padding - visibleLength);
43
+ return `│${' '.repeat(padding)}${text}${' '.repeat(rightPadding)}│`;
44
+ };
45
+ const titleText = `\x1b[1m\x1b[31m⚠ ${Translation.default('console.client-runtime-detected')}!\x1b[0m`;
46
+ const line1 = `${Translation.default('generals.ip2geo')} ${Translation.default('console.must-run-in')} ${Translation.default('console.a')} \x1b[32m${Translation.default('console.server-side-environment')}\x1b[0m ${Translation.default('console.only')}.`;
47
+ const line2 = Translation.default('console.client-side-usage-warning');
48
+ const disableText = `${Translation.default('console.disable-warning-using')}: \x1b[36m{ clientRuntimeMessage: false }\x1b[0m ${Translation.default('console.on-init')}.`;
49
+ Console.default.Info('MessageClientRuntime', '', true);
50
+ Console.default.Info('MessageClientRuntime', topBorder, true);
51
+ Console.default.Info('MessageClientRuntime', centerText(titleText), true);
52
+ Console.default.Info('MessageClientRuntime', centerText(''), true);
53
+ Console.default.Info('MessageClientRuntime', centerText(line1), true);
54
+ Console.default.Info('MessageClientRuntime', centerText(line2), true);
55
+ Console.default.Info('MessageClientRuntime', centerText(''), true);
56
+ Console.default.Info('MessageClientRuntime', centerText(disableText), true);
57
+ Console.default.Info('MessageClientRuntime', bottomBorder, true);
58
+ Console.default.Info('MessageClientRuntime', '', true);
59
+ };
60
+
61
+ exports.MessageClientRuntime = MessageClientRuntime;
62
+ exports.MessageUpdate = MessageUpdate;
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ const STATE = {
4
+ AUTH_KEY: null,
5
+ CLIENT_RUNTIME_MESSAGE: true,
6
+ VERSION_UPDATE_MESSAGE: true,
7
+ IS_VERSION_CHECKED: false
8
+ };
9
+
10
+ exports.STATE = STATE;
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var Messages = require('../data/Messages.js');
6
+ var States = require('../data/States.js');
7
+ var IsBrowser = require('./IsBrowser.js');
8
+
9
+ const CheckRuntime = () => {
10
+ if (States.STATE.CLIENT_RUNTIME_MESSAGE) {
11
+ const isBrowser = IsBrowser.default();
12
+ if (isBrowser)
13
+ Messages.MessageClientRuntime();
14
+ }
15
+ };
16
+
17
+ exports.default = CheckRuntime;
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _package = require('../prebuild/package.json.js');
6
+ var Messages = require('../data/Messages.js');
7
+ var States = require('../data/States.js');
8
+ var GetNpmVersion = require('./GetNpmVersion.js');
9
+
10
+ const CheckVersion = async () => {
11
+ if (!States.STATE.IS_VERSION_CHECKED && States.STATE.VERSION_UPDATE_MESSAGE) {
12
+ States.STATE.IS_VERSION_CHECKED = true;
13
+ const currentVersion = _package.version;
14
+ const latestVersion = await GetNpmVersion.default();
15
+ if (typeof latestVersion === 'string') {
16
+ const isDifferent = currentVersion !== latestVersion;
17
+ if (isDifferent)
18
+ Messages.MessageUpdate(currentVersion, latestVersion);
19
+ }
20
+ }
21
+ };
22
+
23
+ exports.default = CheckVersion;
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const Console = {
6
+ Error: (func, message, ignoreFunName = false) => {
7
+ if (ignoreFunName)
8
+ console.error(message);
9
+ else
10
+ console.error(func, message);
11
+ },
12
+ Info: (func, message, ignoreFunName = false) => {
13
+ if (ignoreFunName)
14
+ console.info(message);
15
+ else
16
+ console.info(func, message);
17
+ },
18
+ Warning: (func, message, ignoreFunName = false) => {
19
+ if (ignoreFunName)
20
+ console.warn(message);
21
+ else
22
+ console.warn(func, message);
23
+ }
24
+ };
25
+
26
+ exports.default = Console;
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var Constants = require('../data/Constants.js');
6
+ var Console = require('./Console.js');
7
+
8
+ const GetNpmVersion = async () => {
9
+ try {
10
+ const response = await fetch(Constants.NPM_REGISTRY_URL);
11
+ const data = await response.json();
12
+ return data['dist-tags']?.latest;
13
+ }
14
+ catch (error) {
15
+ Console.default.Error('GetNpmVersion', error);
16
+ return null;
17
+ }
18
+ };
19
+
20
+ exports.default = GetNpmVersion;
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var Constants = require('../data/Constants.js');
6
+ var States = require('../data/States.js');
7
+ var Console = require('./Console.js');
8
+ var IsBrowser = require('./IsBrowser.js');
9
+
10
+ const Http = async (endpoint, ipAddresses) => {
11
+ const options = {
12
+ method: Constants.HTTP_METHODS.GET,
13
+ headers: {
14
+ [Constants.HEADER_TYPES.CONTENT_TYPE]: Constants.FILE_FORMATS.APPLICATION_JSON,
15
+ [Constants.HEADER_KEYS.X_API_KEY]: States.STATE.AUTH_KEY
16
+ }
17
+ };
18
+ if (Array.isArray(ipAddresses) && ipAddresses?.length > 0) {
19
+ options['method'] = Constants.HTTP_METHODS.POST;
20
+ options['body'] = JSON.stringify({
21
+ ips: ipAddresses
22
+ });
23
+ }
24
+ const isBrowser = IsBrowser.default();
25
+ if (!isBrowser) {
26
+ try {
27
+ const fetchModule = await import('node-fetch');
28
+ const fetch = fetchModule.default;
29
+ const request = await fetch(endpoint, options);
30
+ return await request.json();
31
+ }
32
+ catch (error) {
33
+ Console.default.Error('Http', error);
34
+ return null;
35
+ }
36
+ }
37
+ else {
38
+ try {
39
+ const request = await fetch(endpoint, options);
40
+ const response = await request.json();
41
+ return response;
42
+ }
43
+ catch (error) {
44
+ Console.default.Error('Http', error);
45
+ return null;
46
+ }
47
+ }
48
+ };
49
+
50
+ exports.default = Http;
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var Console = require('./Console.js');
6
+
7
+ const IpValidation = (ipAddress) => {
8
+ const isString = typeof ipAddress === 'string';
9
+ if (!isString)
10
+ return {
11
+ ip4: false,
12
+ ip6: false
13
+ };
14
+ try {
15
+ const ip4 = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipAddress);
16
+ const ip6 = /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$|^([0-9a-fA-F]{1,4}:){1,7}:$|^([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}$|^([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}$|^([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}$|^([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}$|^([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}$|^[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6}|:)$|^:((:[0-9a-fA-F]{1,4}){1,7}|:)$/.test(ipAddress);
17
+ return {
18
+ ip4,
19
+ ip6
20
+ };
21
+ }
22
+ catch (error) {
23
+ Console.default.Error('IpAddressValidation', error);
24
+ return {
25
+ ip4: false,
26
+ ip6: false
27
+ };
28
+ }
29
+ };
30
+
31
+ exports.default = IpValidation;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const IsBrowser = () => {
6
+ return typeof window !== 'undefined' && typeof window.document !== 'undefined';
7
+ };
8
+
9
+ exports.default = IsBrowser;
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var en_US = require('../langs/en_US.js');
6
+
7
+ const Translation = (translationKey) => {
8
+ const lang = en_US.default;
9
+ const keys = translationKey.split('.');
10
+ let result = lang;
11
+ for (const key of keys) {
12
+ if (result && typeof result === 'object' && result !== null && key in result) {
13
+ result = result[key];
14
+ }
15
+ else
16
+ return translationKey;
17
+ }
18
+ return typeof result === 'string' ? result : translationKey;
19
+ };
20
+
21
+ exports.default = Translation;
package/cjs/index.js ADDED
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var ConvertIP = require('./methods/ConvertIP.js');
6
+ var ConvertIPs = require('./methods/ConvertIPs.js');
7
+ var Init = require('./methods/Init.js');
8
+
9
+ const Ip2Geo = {
10
+ ConvertIPs: ConvertIPs.default,
11
+ ConvertIP: ConvertIP.default,
12
+ Init: Init.default
13
+ };
14
+
15
+ exports.ConvertIP = ConvertIP.default;
16
+ exports.ConvertIPs = ConvertIPs.default;
17
+ exports.Init = Init.default;
18
+ exports.default = Ip2Geo;
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const en_US = {
6
+ 'generals': {
7
+ 'ip2geo': 'Ip2Geo'
8
+ },
9
+ 'console': {
10
+ 'update-available': 'Update available!',
11
+ 'changelogs': 'Changelogs:',
12
+ 'run': 'Run',
13
+ 'to-update': 'to update',
14
+ 'disable-warning-using': 'Disable warning using',
15
+ 'on-init': 'on init',
16
+ 'client-runtime-detected': 'Client Runtime Detected',
17
+ 'client-side-usage-warning': 'Client-side usage exposes your API key publicly.',
18
+ 'only': 'only',
19
+ 'server-side-environment': 'Server-side environment',
20
+ 'must-run-in': 'must run in',
21
+ 'a': 'a'
22
+ },
23
+ 'conversions': {
24
+ 'ip-address-is-required-to-convert-it': 'IP address is required to convert it.',
25
+ 'ip-addresses-are-required-to-convert-them': 'IP addresses are required to convert them.',
26
+ 'invalid-ip-address-so-we-could-not-convert-it': 'Invalid IP address so we could not convert it.',
27
+ 'all-ip-addresses-are-invalid': 'All IP addresses are invalid.',
28
+ 'some-ip-addresses-are-invalid': 'Some IP addresses are invalid.'
29
+ }
30
+ };
31
+
32
+ exports.default = en_US;
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var Constants = require('../data/Constants.js');
6
+ var Console = require('../helpers/Console.js');
7
+ var Http = require('../helpers/Http.js');
8
+ var IpValidation = require('../helpers/IpValidation.js');
9
+ var Translation = require('../helpers/Translation.js');
10
+
11
+ const ConvertIP = async (options) => {
12
+ const { ip } = options || {};
13
+ if (!ip)
14
+ return {
15
+ success: false,
16
+ message: Translation.default('conversions.ip-address-is-required-to-convert-it'),
17
+ code: 400,
18
+ data: null,
19
+ _req: {
20
+ reqId: null,
21
+ resTime: 0
22
+ }
23
+ };
24
+ const { ip4, ip6 } = IpValidation.default(ip);
25
+ if (!ip4 && !ip6)
26
+ return {
27
+ success: false,
28
+ message: Translation.default('conversions.invalid-ip-address-so-we-could-not-convert-it'),
29
+ code: 400,
30
+ data: null,
31
+ _req: {
32
+ reqId: null,
33
+ resTime: 0
34
+ }
35
+ };
36
+ try {
37
+ const ipLink = `${Constants.API_ENDPOINT}${Constants.ENDPOINTS.CONVERT}?ip=${ip}`;
38
+ const ipResponse = await Http.default(ipLink);
39
+ if (ipResponse)
40
+ return ipResponse;
41
+ else
42
+ return null;
43
+ }
44
+ catch (error) {
45
+ Console.default.Error('ConvertIP', error);
46
+ return null;
47
+ }
48
+ };
49
+
50
+ exports.default = ConvertIP;
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var Constants = require('../data/Constants.js');
6
+ var Console = require('../helpers/Console.js');
7
+ var Http = require('../helpers/Http.js');
8
+ var IpValidation = require('../helpers/IpValidation.js');
9
+ var Translation = require('../helpers/Translation.js');
10
+
11
+ const ConvertIPs = async (props) => {
12
+ const { ips } = props;
13
+ if (!ips || !Array.isArray(ips) || ips.length === 0)
14
+ return {
15
+ success: false,
16
+ message: Translation.default('conversions.ip-addresses-are-required-to-convert-them'),
17
+ code: 400,
18
+ data: null,
19
+ _req: {
20
+ reqId: null,
21
+ resTime: 0
22
+ }
23
+ };
24
+ const invalidIps = [];
25
+ for (const ip of ips) {
26
+ const { ip4, ip6 } = IpValidation.default(ip);
27
+ if (!ip4 && !ip6)
28
+ invalidIps.push(ip);
29
+ }
30
+ const isAllInvalid = invalidIps?.length === ips?.length;
31
+ if (invalidIps?.length > 0)
32
+ return {
33
+ success: false,
34
+ message: isAllInvalid ? Translation.default('conversions.all-ip-addresses-are-invalid') : Translation.default('conversions.some-ip-addresses-are-invalid'),
35
+ code: 400,
36
+ data: invalidIps?.map(ip => ({
37
+ ip,
38
+ conversion: null
39
+ })),
40
+ _req: {
41
+ reqId: null,
42
+ resTime: 0
43
+ }
44
+ };
45
+ try {
46
+ const ipLink = `${Constants.API_ENDPOINT}${Constants.ENDPOINTS.CONVERT}`;
47
+ const ipResponse = await Http.default(ipLink, ips);
48
+ if (ipResponse)
49
+ return ipResponse;
50
+ else
51
+ return null;
52
+ }
53
+ catch (error) {
54
+ Console.default.Error('ConvertIPs', error);
55
+ return null;
56
+ }
57
+ };
58
+
59
+ exports.default = ConvertIPs;
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var CheckVersion = require('../helpers/CheckVersion.js');
6
+ var CheckRuntime = require('../helpers/CheckRuntime.js');
7
+ var Console = require('../helpers/Console.js');
8
+ var States = require('../data/States.js');
9
+
10
+ const Init = async (key, options) => {
11
+ try {
12
+ const crm = options?.clientRuntimeMessage;
13
+ const vum = options?.versionUpdateMessage;
14
+ States.STATE.AUTH_KEY = key;
15
+ States.STATE.CLIENT_RUNTIME_MESSAGE = typeof crm === 'boolean' ? crm : true;
16
+ States.STATE.VERSION_UPDATE_MESSAGE = typeof vum === 'boolean' ? vum : true;
17
+ return Promise.resolve(true);
18
+ }
19
+ catch (error) {
20
+ States.STATE.AUTH_KEY = null;
21
+ States.STATE.CLIENT_RUNTIME_MESSAGE = true;
22
+ States.STATE.VERSION_UPDATE_MESSAGE = true;
23
+ Console.default.Error('Init', error);
24
+ return Promise.resolve(false);
25
+ }
26
+ finally {
27
+ CheckRuntime.default();
28
+ CheckVersion.default();
29
+ }
30
+ };
31
+
32
+ exports.default = Init;
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ var version = "0.0.1";
4
+
5
+ exports.version = version;
@@ -0,0 +1,23 @@
1
+ const API_ENDPOINT = 'https://api.ip2geo.dev';
2
+ const DOCS_URL = 'https://docs.ip2geo.dev';
3
+ const NPM_REGISTRY_URL = 'https://registry.npmjs.org/@ip2geo/sdk';
4
+ const HTTP_METHODS = {
5
+ GET: 'get',
6
+ POST: 'post'};
7
+ const HEADER_KEYS = {
8
+ X_API_KEY: 'X-Api-Key'
9
+ };
10
+ const FILE_TYPES = {
11
+ JSON: 'json'
12
+ };
13
+ const FILE_FORMATS = {
14
+ APPLICATION_JSON: `application/${FILE_TYPES.JSON}`
15
+ };
16
+ const HEADER_TYPES = {
17
+ CONTENT_TYPE: 'Content-Type'
18
+ };
19
+ const ENDPOINTS = {
20
+ CONVERT: '/convert'
21
+ };
22
+
23
+ export { API_ENDPOINT, DOCS_URL, ENDPOINTS, FILE_FORMATS, FILE_TYPES, HEADER_KEYS, HEADER_TYPES, HTTP_METHODS, NPM_REGISTRY_URL };