rn-prodeeplinks 0.0.3 → 0.0.5
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 +1 -1
- package/lib/api.js +20 -16
- package/lib/fingerprint.js +3 -3
- package/lib/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> ⚠️ **License Required**: This package requires a valid license key purchased from our portal. Without a license key, the package will not function.
|
|
6
6
|
|
|
7
|
-
> ℹ️ **Versioning**: Current version is 0.0.
|
|
7
|
+
> ℹ️ **Versioning**: Current version is 0.0.5 (in-progress). It will move to 1.x after stable.
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
package/lib/api.js
CHANGED
|
@@ -8,8 +8,7 @@ exports.matchFingerprintCustom = matchFingerprintCustom;
|
|
|
8
8
|
exports.trackCustomDeepLinkEvent = trackCustomDeepLinkEvent;
|
|
9
9
|
const license_1 = require("./license");
|
|
10
10
|
const DEFAULT_API_ENDPOINT = 'https://api.prodeeplink.com/v1/deeplink';
|
|
11
|
-
const
|
|
12
|
-
const ANALYTICS_ENDPOINT = 'https://s.finprim.com/custom-deep-link/track/event';
|
|
11
|
+
const ANALYTICS_ENDPOINT = `${DEFAULT_API_ENDPOINT}/custom-deep-link/track/event`;
|
|
13
12
|
/**
|
|
14
13
|
* Call API to get deep link URL
|
|
15
14
|
* This function sends device fingerprint and license key to server
|
|
@@ -26,7 +25,7 @@ async function fetchDeepLinkUrl(licenseKey, fingerprint, apiEndpoint, timeout =
|
|
|
26
25
|
};
|
|
27
26
|
}
|
|
28
27
|
const PACKAGE_NAME = 'react-native-pro-deeplink';
|
|
29
|
-
const PACKAGE_VERSION = '0.0.
|
|
28
|
+
const PACKAGE_VERSION = '0.0.5';
|
|
30
29
|
const payload = {
|
|
31
30
|
licenseKey,
|
|
32
31
|
fingerprint: fingerprint,
|
|
@@ -38,14 +37,10 @@ async function fetchDeepLinkUrl(licenseKey, fingerprint, apiEndpoint, timeout =
|
|
|
38
37
|
const controller = new AbortController();
|
|
39
38
|
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
40
39
|
try {
|
|
41
|
-
const PACKAGE_NAME = 'react-native-pro-deeplink';
|
|
42
|
-
const PACKAGE_VERSION = '0.0.3';
|
|
43
40
|
const response = await fetch(endpoint, {
|
|
44
41
|
method: 'POST',
|
|
45
42
|
headers: {
|
|
46
43
|
'Content-Type': 'application/json',
|
|
47
|
-
'X-Package-Name': PACKAGE_NAME,
|
|
48
|
-
'X-Package-Version': PACKAGE_VERSION,
|
|
49
44
|
'x-license-key': licenseKey,
|
|
50
45
|
},
|
|
51
46
|
body: JSON.stringify(payload),
|
|
@@ -60,12 +55,22 @@ async function fetchDeepLinkUrl(licenseKey, fingerprint, apiEndpoint, timeout =
|
|
|
60
55
|
};
|
|
61
56
|
}
|
|
62
57
|
const data = await response.json();
|
|
63
|
-
if (data.success
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
if (data.success) {
|
|
59
|
+
if (data.url) {
|
|
60
|
+
return {
|
|
61
|
+
success: true,
|
|
62
|
+
url: data.url,
|
|
63
|
+
message: data.message,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// Success true but no URL means no match found - this is not an error
|
|
68
|
+
return {
|
|
69
|
+
success: true,
|
|
70
|
+
url: null,
|
|
71
|
+
message: data.message || 'No deep link available',
|
|
72
|
+
};
|
|
73
|
+
}
|
|
69
74
|
}
|
|
70
75
|
else {
|
|
71
76
|
return {
|
|
@@ -145,7 +150,7 @@ async function validateLicenseCustom(licenseKey, opts) {
|
|
|
145
150
|
}
|
|
146
151
|
async function validateLicenseInit(licenseKey) {
|
|
147
152
|
try {
|
|
148
|
-
const endpoint = `${
|
|
153
|
+
const endpoint = `${DEFAULT_API_ENDPOINT}/custom-deep-link/license/validate`;
|
|
149
154
|
const res = await fetch(endpoint, {
|
|
150
155
|
method: 'POST',
|
|
151
156
|
headers: {
|
|
@@ -174,8 +179,7 @@ async function validateLicenseInit(licenseKey) {
|
|
|
174
179
|
}
|
|
175
180
|
async function matchFingerprintCustom(payload, baseUrl, licenseKey) {
|
|
176
181
|
try {
|
|
177
|
-
const
|
|
178
|
-
const endpoint = `${base}/custom-deep-link/fingerprint/match`;
|
|
182
|
+
const endpoint = `${DEFAULT_API_ENDPOINT}/custom-deep-link/fingerprint/match`;
|
|
179
183
|
const res = await fetch(endpoint, {
|
|
180
184
|
method: 'POST',
|
|
181
185
|
headers: {
|
package/lib/fingerprint.js
CHANGED
|
@@ -27,9 +27,9 @@ async function generateDeviceFingerprint() {
|
|
|
27
27
|
? (await (react_native_device_info_1.default.isDeviceRooted?.() ?? false))
|
|
28
28
|
: false;
|
|
29
29
|
const deviceLocales = react_native_device_info_1.default.getDeviceLocales?.();
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const primaryLocale = Array.isArray(deviceLocales) && deviceLocales.length > 0 ? deviceLocales[0] : undefined;
|
|
31
|
+
const legacyLocale = react_native_device_info_1.default.getDeviceLocale?.();
|
|
32
|
+
const locale = (primaryLocale || legacyLocale || Intl.DateTimeFormat().resolvedOptions().locale) || 'en';
|
|
33
33
|
const language = (locale || '').split('-')[0] || 'en';
|
|
34
34
|
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
35
35
|
// Get network info
|
package/lib/index.js
CHANGED
|
@@ -13,7 +13,6 @@ const react_native_1 = require("react-native");
|
|
|
13
13
|
// Global state to store license key and configuration
|
|
14
14
|
let storedLicenseKey = null;
|
|
15
15
|
let isInitialized = false;
|
|
16
|
-
// Hardcoded API endpoint - user doesn't need to know about this
|
|
17
16
|
const DEFAULT_API_ENDPOINT = 'https://api.prodeeplink.com/v1/deeplink';
|
|
18
17
|
/**
|
|
19
18
|
* Initialize the deep link package with license key
|
|
@@ -142,7 +141,8 @@ async function getDeepLink(callback) {
|
|
|
142
141
|
callback(result.url);
|
|
143
142
|
}
|
|
144
143
|
// If API didn't return a usable URL, return null as per requirements
|
|
145
|
-
if
|
|
144
|
+
// But if success is false, propagate the error
|
|
145
|
+
if (result.success && !result.url) {
|
|
146
146
|
return { success: true, url: null, message: 'No deep link available' };
|
|
147
147
|
}
|
|
148
148
|
return result;
|
package/package.json
CHANGED