@buoy-gg/license 7.0.22 → 7.0.24

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.
Files changed (68) hide show
  1. package/LICENSE +46 -0
  2. package/lib/commonjs/DeviceRegistrationModal.js +1 -189
  3. package/lib/commonjs/LicenseManager.js +14 -610
  4. package/lib/commonjs/api.js +1 -172
  5. package/lib/commonjs/cacheSignature.js +15 -0
  6. package/lib/commonjs/config.js +16 -28
  7. package/lib/commonjs/device-info.js +1 -93
  8. package/lib/commonjs/device-info.web.js +1 -227
  9. package/lib/commonjs/fingerprint.js +1 -30
  10. package/lib/commonjs/fingerprint.web.js +1 -30
  11. package/lib/commonjs/hooks.js +13 -120
  12. package/lib/commonjs/index.js +17 -106
  13. package/lib/commonjs/index.web.js +17 -98
  14. package/lib/commonjs/tier.js +16 -0
  15. package/lib/commonjs/types.js +1 -1
  16. package/lib/commonjs/weekendPro.js +15 -41
  17. package/lib/module/DeviceRegistrationModal.js +1 -185
  18. package/lib/module/LicenseManager.js +14 -607
  19. package/lib/module/api.js +1 -165
  20. package/lib/module/cacheSignature.js +15 -0
  21. package/lib/module/config.js +16 -24
  22. package/lib/module/device-info.js +1 -87
  23. package/lib/module/device-info.web.js +1 -220
  24. package/lib/module/fingerprint.js +1 -10
  25. package/lib/module/fingerprint.web.js +1 -10
  26. package/lib/module/hooks.js +13 -114
  27. package/lib/module/index.js +15 -54
  28. package/lib/module/index.web.js +15 -52
  29. package/lib/module/tier.js +16 -0
  30. package/lib/module/types.js +1 -1
  31. package/lib/module/weekendPro.js +15 -37
  32. package/lib/typescript/commonjs/LicenseManager.d.ts +31 -6
  33. package/lib/typescript/commonjs/LicenseManager.d.ts.map +1 -1
  34. package/lib/typescript/commonjs/cacheSignature.d.ts +42 -0
  35. package/lib/typescript/commonjs/cacheSignature.d.ts.map +1 -0
  36. package/lib/typescript/commonjs/config.d.ts +62 -1
  37. package/lib/typescript/commonjs/config.d.ts.map +1 -1
  38. package/lib/typescript/commonjs/hooks.d.ts +27 -5
  39. package/lib/typescript/commonjs/hooks.d.ts.map +1 -1
  40. package/lib/typescript/commonjs/index.d.ts +20 -2
  41. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  42. package/lib/typescript/commonjs/index.web.d.ts +20 -2
  43. package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
  44. package/lib/typescript/commonjs/tier.d.ts +55 -0
  45. package/lib/typescript/commonjs/tier.d.ts.map +1 -0
  46. package/lib/typescript/commonjs/types.d.ts +44 -0
  47. package/lib/typescript/commonjs/types.d.ts.map +1 -1
  48. package/lib/typescript/commonjs/weekendPro.d.ts +30 -7
  49. package/lib/typescript/commonjs/weekendPro.d.ts.map +1 -1
  50. package/lib/typescript/module/LicenseManager.d.ts +31 -6
  51. package/lib/typescript/module/LicenseManager.d.ts.map +1 -1
  52. package/lib/typescript/module/cacheSignature.d.ts +42 -0
  53. package/lib/typescript/module/cacheSignature.d.ts.map +1 -0
  54. package/lib/typescript/module/config.d.ts +62 -1
  55. package/lib/typescript/module/config.d.ts.map +1 -1
  56. package/lib/typescript/module/hooks.d.ts +27 -5
  57. package/lib/typescript/module/hooks.d.ts.map +1 -1
  58. package/lib/typescript/module/index.d.ts +20 -2
  59. package/lib/typescript/module/index.d.ts.map +1 -1
  60. package/lib/typescript/module/index.web.d.ts +20 -2
  61. package/lib/typescript/module/index.web.d.ts.map +1 -1
  62. package/lib/typescript/module/tier.d.ts +55 -0
  63. package/lib/typescript/module/tier.d.ts.map +1 -0
  64. package/lib/typescript/module/types.d.ts +44 -0
  65. package/lib/typescript/module/types.d.ts.map +1 -1
  66. package/lib/typescript/module/weekendPro.d.ts +30 -7
  67. package/lib/typescript/module/weekendPro.d.ts.map +1 -1
  68. package/package.json +7 -4
@@ -1,172 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.activateMachine = activateMachine;
7
- exports.isFatalLicenseError = isFatalLicenseError;
8
- exports.parseValidationResult = parseValidationResult;
9
- exports.validateLicense = validateLicense;
10
- var _config = require("./config.js");
11
- /**
12
- * Keygen REST API client for React Buoy
13
- *
14
- * License validation + device registration for visibility.
15
- * No limits enforced - we trust our customers.
16
- */
17
-
18
- const {
19
- accountId,
20
- productToken,
21
- apiUrl
22
- } = _config.KEYGEN_CONFIG;
23
-
24
- /**
25
- * Base headers for Keygen API requests
26
- */
27
- function getBaseHeaders() {
28
- return {
29
- "Content-Type": "application/vnd.api+json",
30
- Accept: "application/vnd.api+json"
31
- };
32
- }
33
-
34
- /**
35
- * Headers for license-authenticated API requests
36
- */
37
- function getLicenseAuthHeaders(licenseKey) {
38
- return {
39
- ...getBaseHeaders(),
40
- Authorization: `License ${licenseKey}`
41
- };
42
- }
43
-
44
- /**
45
- * Headers for product token authenticated API requests
46
- */
47
- function getProductTokenHeaders() {
48
- return {
49
- ...getBaseHeaders(),
50
- Authorization: `Bearer ${productToken}`
51
- };
52
- }
53
-
54
- /**
55
- * Validate a license key with Keygen
56
- */
57
- async function validateLicense(licenseKey) {
58
- const url = `${apiUrl}/${accountId}/licenses/actions/validate-key`;
59
- const body = {
60
- meta: {
61
- key: licenseKey
62
- }
63
- };
64
-
65
- // Note: validate-key endpoint doesn't need Authorization header
66
- // The license key in the body is the authentication
67
- const response = await fetch(url, {
68
- method: "POST",
69
- headers: getBaseHeaders(),
70
- body: JSON.stringify(body)
71
- });
72
- if (!response.ok) {
73
- const errorData = await response.json();
74
- const errorMessage = errorData.errors?.[0]?.detail || `HTTP ${response.status}`;
75
- throw new Error(errorMessage);
76
- }
77
- return await response.json();
78
- }
79
-
80
- /**
81
- * Activate a machine for a license (for visibility, not enforcement)
82
- */
83
- async function activateMachine(licenseId, licenseKey, fingerprint, name, metadata) {
84
- const url = `${apiUrl}/${accountId}/machines`;
85
- const body = {
86
- data: {
87
- type: "machines",
88
- attributes: {
89
- fingerprint,
90
- name,
91
- metadata: metadata || {}
92
- },
93
- relationships: {
94
- license: {
95
- data: {
96
- type: "licenses",
97
- id: licenseId
98
- }
99
- }
100
- }
101
- }
102
- };
103
-
104
- // Try license key auth first
105
- let response = await fetch(url, {
106
- method: "POST",
107
- headers: getLicenseAuthHeaders(licenseKey),
108
- body: JSON.stringify(body)
109
- });
110
-
111
- // If license key auth not allowed, retry with product token
112
- if (!response.ok) {
113
- const errorData = await response.json();
114
- const errorMessage = errorData.errors?.[0]?.detail || "";
115
- const errorCode = errorData.errors?.[0]?.code;
116
- if (errorMessage.toLowerCase().includes("authentication is not allowed by policy")) {
117
- response = await fetch(url, {
118
- method: "POST",
119
- headers: getProductTokenHeaders(),
120
- body: JSON.stringify(body)
121
- });
122
- } else if (errorCode === "FINGERPRINT_TAKEN") {
123
- // Device already registered - this is fine, not an error
124
- throw new Error("FINGERPRINT_TAKEN");
125
- } else if (errorCode === "MACHINE_LIMIT_EXCEEDED") {
126
- // Don't block, just log - we trust our customers
127
- //console.log("[Buoy] Machine limit reached but not enforcing - trust mode");
128
- throw new Error("MACHINE_LIMIT_EXCEEDED");
129
- } else {
130
- throw new Error(errorMessage);
131
- }
132
- }
133
- if (!response.ok) {
134
- const errorData = await response.json();
135
- const errorCode = errorData.errors?.[0]?.code;
136
- if (errorCode === "FINGERPRINT_TAKEN") {
137
- throw new Error("FINGERPRINT_TAKEN");
138
- }
139
- if (errorCode === "MACHINE_LIMIT_EXCEEDED") {
140
- // console.log("[Buoy] Machine limit reached but not enforcing - trust mode");
141
- throw new Error("MACHINE_LIMIT_EXCEEDED");
142
- }
143
- const errorMessage = errorData.errors?.[0]?.detail || `HTTP ${response.status}`;
144
- throw new Error(errorMessage);
145
- }
146
- return response.json();
147
- }
148
-
149
- /**
150
- * Parse validation response into a simpler result
151
- * Note: response.data can be null when license is invalid (e.g., NOT_FOUND)
152
- */
153
- function parseValidationResult(response) {
154
- const {
155
- meta,
156
- data
157
- } = response;
158
- return {
159
- valid: meta.valid,
160
- code: meta.code,
161
- detail: meta.detail,
162
- // data can be null for invalid licenses
163
- metadata: data?.attributes?.metadata
164
- };
165
- }
166
-
167
- /**
168
- * Check if a validation code indicates a fatal error (license invalid)
169
- */
170
- function isFatalLicenseError(code) {
171
- return ["NOT_FOUND", "SUSPENDED", "EXPIRED", "BANNED", "PRODUCT_SCOPE_MISMATCH"].includes(code);
172
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.activateMachine=activateMachine;exports.isFatalLicenseError=isFatalLicenseError;exports.parseValidationResult=parseValidationResult;exports.validateLicense=validateLicense;var _config=require("./config.js");const{accountId,productToken,apiUrl}=_config.KEYGEN_CONFIG;function getBaseHeaders(){return{"Content-Type":"application/vnd.api+json",Accept:"application/vnd.api+json"}}function getLicenseAuthHeaders(e){return{...getBaseHeaders(),Authorization:`License ${e}`}}function getProductTokenHeaders(){return{...getBaseHeaders(),Authorization:`Bearer ${productToken}`}}async function validateLicense(e){const t=`${apiUrl}/${accountId}/licenses/actions/validate-key`;const a={meta:{key:e}};const o=await fetch(t,{method:"POST",headers:getBaseHeaders(),body:JSON.stringify(a)});if(!o.ok){const d=await o.json();const i=d.errors?.[0]?.detail||`HTTP ${o.status}`;throw new Error(i)}return await o.json()}async function activateMachine(e,t,a,o,d){const i=`${apiUrl}/${accountId}/machines`;const E={data:{type:"machines",attributes:{fingerprint:a,name:o,metadata:d||{}},relationships:{license:{data:{type:"licenses",id:e}}}}};let r=await fetch(i,{method:"POST",headers:getLicenseAuthHeaders(t),body:JSON.stringify(E)});if(!r.ok){const n=await r.json();const s=n.errors?.[0]?.detail||"";const c=n.errors?.[0]?.code;if(s.toLowerCase().includes("authentication is not allowed by policy")){r=await fetch(i,{method:"POST",headers:getProductTokenHeaders(),body:JSON.stringify(E)})}else if(c==="FINGERPRINT_TAKEN"){throw new Error("FINGERPRINT_TAKEN")}else if(c==="MACHINE_LIMIT_EXCEEDED"){throw new Error("MACHINE_LIMIT_EXCEEDED")}else{throw new Error(s)}}if(!r.ok){const n=await r.json();const s=n.errors?.[0]?.code;if(s==="FINGERPRINT_TAKEN"){throw new Error("FINGERPRINT_TAKEN")}if(s==="MACHINE_LIMIT_EXCEEDED"){throw new Error("MACHINE_LIMIT_EXCEEDED")}const c=n.errors?.[0]?.detail||`HTTP ${r.status}`;throw new Error(c)}return r.json()}function parseValidationResult(e){const{meta:t,data:a}=e;return{valid:t.valid,code:t.code,detail:t.detail,metadata:a?.attributes?.metadata}}function isFatalLicenseError(e){return["NOT_FOUND","SUSPENDED","EXPIRED","BANNED","PRODUCT_SCOPE_MISMATCH"].includes(e)}
@@ -0,0 +1,15 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.cacheSignature=cacheSignature;exports.signCache=signCache;exports.verifyCacheSignature=verifyCacheSignature;/*!
2
+ * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
+ *
4
+ * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
5
+ * (https://buoy.gg/terms), not an OSS license.
6
+ *
7
+ * This file is part of the technological measure that controls access to paid
8
+ * Buoy Pro features. Modifying, patching, aliasing, stubbing, or otherwise
9
+ * altering it so that Pro features unlock without a valid license is a breach
10
+ * of the EULA and, in the United States, circumvention of an access control
11
+ * under 17 U.S.C. § 1201 — which applies whether or not any code is copied.
12
+ *
13
+ * Pro is $9/mo, and is free for everyone every weekend. Buy a key at
14
+ * https://buoy.gg or use it free on Saturday and Sunday.
15
+ */const SIGNATURE_VERSION="v2";const LEGACY_VERSIONS=["v1"];const SIGNING_SALT="buoy.gg/pro:9f3c1d7a4b2e:license-cache";const FIELD_SEPARATOR="\0";function fnv1a(t,e){let n=e>>>0;for(let r=0;r<t.length;r++){n^=t.charCodeAt(r);n=Math.imul(n,16777619)>>>0}return n>>>0}function canonicalize(t,e){const n=[e,t.licenseKey,t.licenseId,t.isPro?"1":"0",t.expiresAt??"",String(t.cachedAt)];if(e!=="v1"){n.push(t.tier??"")}n.push(SIGNING_SALT);return n.join(FIELD_SEPARATOR)}function signatureFor(t,e){const n=canonicalize(t,e);const r=fnv1a(n,2166136261);const i=fnv1a(n,2135587861);return`${e}.${r.toString(16)}${i.toString(16)}`}function cacheSignature(t){return signatureFor(t,SIGNATURE_VERSION)}function signCache(t){return{...t,sig:cacheSignature(t)}}function verifyCacheSignature(t){if(!t||typeof t.sig!=="string"||t.sig.length===0){return false}if(t.sig===cacheSignature(t))return true;return LEGACY_VERSIONS.some(e=>t.sig.startsWith(`${e}.`)&&t.sig===signatureFor(t,e))}
@@ -1,28 +1,16 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.LICENSE_STORAGE_KEY = exports.LICENSE_REVALIDATION_INTERVAL = exports.LICENSE_CACHE_DURATION = exports.KEYGEN_CONFIG = void 0;
7
- /**
8
- * Keygen configuration for React Buoy
9
- */
10
-
11
- const KEYGEN_CONFIG = exports.KEYGEN_CONFIG = {
12
- accountId: "b0eba0e8-e904-4906-b644-38f9aab57bed",
13
- productId: "1037431d-b2fe-48db-aca9-10c5e9c4d944",
14
- // Product token - read-only, safe to embed in SDK
15
- productToken: "prod-4467c14b75b715e91884945cd3e69705846ccbce7dd5e380236a1ab3bc03139fv3",
16
- apiUrl: "https://api.keygen.sh/v1/accounts"
17
- };
18
-
19
- // Cache duration: 30 days in milliseconds
20
- const LICENSE_CACHE_DURATION = exports.LICENSE_CACHE_DURATION = 30 * 24 * 60 * 60 * 1000;
21
-
22
- // How often to revalidate when app is active (24 hours)
23
- // We trust our customers - this is just for usage analytics
24
- const LICENSE_REVALIDATION_INTERVAL = exports.LICENSE_REVALIDATION_INTERVAL = 24 * 60 * 60 * 1000;
25
-
26
- // Storage key for cached license
27
- // IMPORTANT: Use only file-safe characters (no / or special chars)
28
- const LICENSE_STORAGE_KEY = exports.LICENSE_STORAGE_KEY = "buoy-gg-license";
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.LICENSE_STORAGE_KEY=exports.LICENSE_REVALIDATION_INTERVAL=exports.LICENSE_CACHE_DURATION=exports.KEYGEN_POLICIES=exports.KEYGEN_CONFIG=exports.ANONYMOUS_TIER_ENABLED=void 0;/*!
2
+ * PROPRIETARY — Buoy Pro license enforcement. NOT open source.
3
+ *
4
+ * Copyright (c) Buoy. All rights reserved. Licensed under the Buoy EULA
5
+ * (https://buoy.gg/terms), not an OSS license.
6
+ *
7
+ * This file configures the technological measure that controls access to paid
8
+ * Buoy Pro features. Modifying, patching, aliasing, stubbing, or otherwise
9
+ * altering it — including repointing `apiUrl` at a stand-in license server — so
10
+ * that Pro features unlock without a valid license is a breach of the EULA and,
11
+ * in the United States, circumvention of an access control under 17 U.S.C.
12
+ * § 1201, which applies whether or not any code is copied.
13
+ *
14
+ * Pro is $9/mo, and is free for everyone every weekend. Buy a key at
15
+ * https://buoy.gg or use it free on Saturday and Sunday.
16
+ */const KEYGEN_CONFIG=exports.KEYGEN_CONFIG={accountId:"b0eba0e8-e904-4906-b644-38f9aab57bed",productId:"bf67cb43-eeef-40ca-b308-e6e1b22c0eaa",productToken:"prod-4467c14b75b715e91884945cd3e69705846ccbce7dd5e380236a1ab3bc03139fv3",apiUrl:"https://api.keygen.sh/v1/accounts"};const KEYGEN_POLICIES=exports.KEYGEN_POLICIES={free:"394e3351-1249-4f73-807a-703408604c0e",solo:"fa5d3c8f-5379-40f1-b63e-ab8a974b2f28",business:"690c2212-8e54-426f-b4b4-002ee1c0ae2b"};const LICENSE_CACHE_DURATION=exports.LICENSE_CACHE_DURATION=30*24*60*60*1e3;const LICENSE_REVALIDATION_INTERVAL=exports.LICENSE_REVALIDATION_INTERVAL=24*60*60*1e3;const LICENSE_STORAGE_KEY=exports.LICENSE_STORAGE_KEY="buoy-gg-license";const ANONYMOUS_TIER_ENABLED=exports.ANONYMOUS_TIER_ENABLED=false;
@@ -1,93 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.generateUUID = generateUUID;
7
- exports.getDefaultDeviceName = getDefaultDeviceName;
8
- exports.getDeviceMetadata = getDeviceMetadata;
9
- exports.isSimulator = isSimulator;
10
- var _reactNative = require("react-native");
11
- /**
12
- * Pure JS device info utilities
13
- *
14
- * No native module dependencies - uses only React Native core APIs.
15
- * Device fingerprint is a generated UUID stored alongside license data.
16
- */
17
-
18
- /**
19
- * Generate a UUID v4
20
- */
21
- function generateUUID() {
22
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => {
23
- const r = Math.random() * 16 | 0;
24
- const v = c === "x" ? r : r & 0x3 | 0x8;
25
- return v.toString(16);
26
- });
27
- }
28
-
29
- /**
30
- * Check if running on a simulator/emulator using Platform constants
31
- */
32
- function isSimulator() {
33
- if (_reactNative.Platform.OS === "ios") {
34
- // On iOS simulator, we can check various indicators
35
- const constants = _reactNative.Platform.constants;
36
-
37
- // Check for simulator interface idiom
38
- if (constants?.interfaceIdiom === "simulator") {
39
- return true;
40
- }
41
-
42
- // Check if running in a testing environment
43
- if ("isTesting" in _reactNative.Platform && _reactNative.Platform.isTesting) {
44
- return true;
45
- }
46
- return false;
47
- }
48
- if (_reactNative.Platform.OS === "android") {
49
- const constants = _reactNative.Platform.constants;
50
- const brand = String(constants?.Brand || "").toLowerCase();
51
- const model = String(constants?.Model || "").toLowerCase();
52
- const fingerprint = String(constants?.Fingerprint || "").toLowerCase();
53
- const isEmulator = brand.includes("generic") || model.includes("sdk") || model.includes("emulator") || model.includes("android sdk") || fingerprint.includes("generic");
54
- return isEmulator;
55
- }
56
- return false;
57
- }
58
-
59
- /**
60
- * Get basic device metadata from Platform APIs
61
- */
62
- function getDeviceMetadata() {
63
- const metadata = {
64
- platform: _reactNative.Platform.OS,
65
- osVersion: String(_reactNative.Platform.Version),
66
- isSimulator: String(isSimulator())
67
- };
68
-
69
- // Add Android-specific constants if available
70
- if (_reactNative.Platform.OS === "android") {
71
- const constants = _reactNative.Platform.constants;
72
- if (constants?.Brand) metadata.brand = String(constants.Brand);
73
- if (constants?.Model) metadata.model = String(constants.Model);
74
- if (constants?.Manufacturer) metadata.manufacturer = String(constants.Manufacturer);
75
- }
76
-
77
- // Add iOS-specific constants if available
78
- if (_reactNative.Platform.OS === "ios") {
79
- const constants = _reactNative.Platform.constants;
80
- if (constants?.systemName) metadata.systemName = String(constants.systemName);
81
- if (constants?.interfaceIdiom) metadata.interfaceIdiom = String(constants.interfaceIdiom);
82
- }
83
- return metadata;
84
- }
85
-
86
- /**
87
- * Get a default device name suggestion based on platform
88
- */
89
- function getDefaultDeviceName() {
90
- const platformName = _reactNative.Platform.OS === "ios" ? "iOS" : _reactNative.Platform.OS === "android" ? "Android" : _reactNative.Platform.OS;
91
- const sim = isSimulator() ? " Simulator" : "";
92
- return `My ${platformName} Device${sim}`;
93
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.generateUUID=generateUUID;exports.getDefaultDeviceName=getDefaultDeviceName;exports.getDeviceMetadata=getDeviceMetadata;exports.isSimulator=isSimulator;var _reactNative=require("react-native");function generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;const r=e==="x"?t:t&3|8;return r.toString(16)})}function isSimulator(){if(_reactNative.Platform.OS==="ios"){const e=_reactNative.Platform.constants;if(e?.interfaceIdiom==="simulator"){return true}if("isTesting"in _reactNative.Platform&&_reactNative.Platform.isTesting){return true}return false}if(_reactNative.Platform.OS==="android"){const e=_reactNative.Platform.constants;const t=String(e?.Brand||"").toLowerCase();const r=String(e?.Model||"").toLowerCase();const n=String(e?.Fingerprint||"").toLowerCase();const a=t.includes("generic")||r.includes("sdk")||r.includes("emulator")||r.includes("android sdk")||n.includes("generic");return a}return false}function getDeviceMetadata(){const e={platform:_reactNative.Platform.OS,osVersion:String(_reactNative.Platform.Version),isSimulator:String(isSimulator())};if(_reactNative.Platform.OS==="android"){const t=_reactNative.Platform.constants;if(t?.Brand)e.brand=String(t.Brand);if(t?.Model)e.model=String(t.Model);if(t?.Manufacturer)e.manufacturer=String(t.Manufacturer)}if(_reactNative.Platform.OS==="ios"){const t=_reactNative.Platform.constants;if(t?.systemName)e.systemName=String(t.systemName);if(t?.interfaceIdiom)e.interfaceIdiom=String(t.interfaceIdiom)}return e}function getDefaultDeviceName(){const e=_reactNative.Platform.OS==="ios"?"iOS":_reactNative.Platform.OS==="android"?"Android":_reactNative.Platform.OS;const t=isSimulator()?" Simulator":"";return`My ${e} Device${t}`}
@@ -1,227 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.generateUUID = generateUUID;
7
- exports.getDefaultDeviceName = getDefaultDeviceName;
8
- exports.getDeviceMetadata = getDeviceMetadata;
9
- exports.isSimulator = isSimulator;
10
- /**
11
- * Web/Electron device info utilities
12
- *
13
- * Platform-specific implementation for web browsers and Electron apps.
14
- * Uses browser APIs instead of React Native Platform.
15
- */
16
-
17
- /**
18
- * Generate a UUID v4
19
- */
20
- function generateUUID() {
21
- // Use crypto.randomUUID if available (modern browsers/Node)
22
- if (typeof crypto !== "undefined" && crypto.randomUUID) {
23
- return crypto.randomUUID();
24
- }
25
-
26
- // Fallback to manual generation
27
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, c => {
28
- const r = Math.random() * 16 | 0;
29
- const v = c === "x" ? r : r & 0x3 | 0x8;
30
- return v.toString(16);
31
- });
32
- }
33
-
34
- /**
35
- * Check if running on a simulator/emulator
36
- * Always returns false for web/Electron
37
- */
38
- function isSimulator() {
39
- return false;
40
- }
41
-
42
- /**
43
- * Detect the platform from userAgent
44
- */
45
- function detectPlatform() {
46
- if (typeof navigator === "undefined") {
47
- return "unknown";
48
- }
49
- const ua = navigator.userAgent.toLowerCase();
50
- const platform = navigator.platform?.toLowerCase() || "";
51
-
52
- // Check for Electron first
53
- if (ua.includes("electron")) {
54
- if (platform.includes("mac") || ua.includes("mac")) {
55
- return "electron-macos";
56
- }
57
- if (platform.includes("win") || ua.includes("win")) {
58
- return "electron-windows";
59
- }
60
- if (platform.includes("linux") || ua.includes("linux")) {
61
- return "electron-linux";
62
- }
63
- return "electron";
64
- }
65
-
66
- // Regular browser detection
67
- if (platform.includes("mac") || ua.includes("mac")) {
68
- return "macos";
69
- }
70
- if (platform.includes("win") || ua.includes("win")) {
71
- return "windows";
72
- }
73
- if (platform.includes("linux") || ua.includes("linux")) {
74
- return "linux";
75
- }
76
- if (/iphone|ipad|ipod/.test(ua)) {
77
- return "ios-web";
78
- }
79
- if (ua.includes("android")) {
80
- return "android-web";
81
- }
82
- return "web";
83
- }
84
-
85
- /**
86
- * Get OS version from userAgent
87
- */
88
- function getOSVersion() {
89
- if (typeof navigator === "undefined") {
90
- return "unknown";
91
- }
92
- const ua = navigator.userAgent;
93
-
94
- // macOS version
95
- const macMatch = ua.match(/Mac OS X ([\d_.]+)/);
96
- if (macMatch) {
97
- return macMatch[1].replace(/_/g, ".");
98
- }
99
-
100
- // Windows version
101
- const winMatch = ua.match(/Windows NT ([\d.]+)/);
102
- if (winMatch) {
103
- const versions = {
104
- "10.0": "10/11",
105
- "6.3": "8.1",
106
- "6.2": "8",
107
- "6.1": "7"
108
- };
109
- return versions[winMatch[1]] || winMatch[1];
110
- }
111
-
112
- // Linux (usually doesn't have version in UA)
113
- if (ua.includes("Linux")) {
114
- return "Linux";
115
- }
116
- return "unknown";
117
- }
118
-
119
- /**
120
- * Get browser name and version
121
- */
122
- function getBrowserInfo() {
123
- if (typeof navigator === "undefined") {
124
- return {
125
- name: "unknown",
126
- version: "unknown"
127
- };
128
- }
129
- const ua = navigator.userAgent;
130
-
131
- // Electron
132
- const electronMatch = ua.match(/Electron\/([\d.]+)/);
133
- if (electronMatch) {
134
- return {
135
- name: "Electron",
136
- version: electronMatch[1]
137
- };
138
- }
139
-
140
- // Chrome
141
- const chromeMatch = ua.match(/Chrome\/([\d.]+)/);
142
- if (chromeMatch && !ua.includes("Edg")) {
143
- return {
144
- name: "Chrome",
145
- version: chromeMatch[1]
146
- };
147
- }
148
-
149
- // Edge
150
- const edgeMatch = ua.match(/Edg\/([\d.]+)/);
151
- if (edgeMatch) {
152
- return {
153
- name: "Edge",
154
- version: edgeMatch[1]
155
- };
156
- }
157
-
158
- // Firefox
159
- const firefoxMatch = ua.match(/Firefox\/([\d.]+)/);
160
- if (firefoxMatch) {
161
- return {
162
- name: "Firefox",
163
- version: firefoxMatch[1]
164
- };
165
- }
166
-
167
- // Safari
168
- const safariMatch = ua.match(/Version\/([\d.]+).*Safari/);
169
- if (safariMatch) {
170
- return {
171
- name: "Safari",
172
- version: safariMatch[1]
173
- };
174
- }
175
- return {
176
- name: "unknown",
177
- version: "unknown"
178
- };
179
- }
180
-
181
- /**
182
- * Get basic device metadata for web/Electron
183
- */
184
- function getDeviceMetadata() {
185
- const metadata = {
186
- platform: detectPlatform(),
187
- osVersion: getOSVersion(),
188
- isSimulator: "false"
189
- };
190
- const browserInfo = getBrowserInfo();
191
- metadata.browser = browserInfo.name;
192
- metadata.browserVersion = browserInfo.version;
193
-
194
- // Add screen info if available
195
- if (typeof window !== "undefined" && window.screen) {
196
- metadata.screenResolution = `${window.screen.width}x${window.screen.height}`;
197
- }
198
-
199
- // Add language
200
- if (typeof navigator !== "undefined" && navigator.language) {
201
- metadata.language = navigator.language;
202
- }
203
-
204
- // Add timezone
205
- try {
206
- metadata.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
207
- } catch {
208
- // Ignore timezone detection errors
209
- }
210
- return metadata;
211
- }
212
-
213
- /**
214
- * Get a default device name suggestion based on platform
215
- */
216
- function getDefaultDeviceName() {
217
- const platform = detectPlatform();
218
- const browserInfo = getBrowserInfo();
219
- if (platform.startsWith("electron")) {
220
- const os = platform.replace("electron-", "").replace("electron", "Desktop");
221
- return `${os.charAt(0).toUpperCase() + os.slice(1)} App`;
222
- }
223
- if (browserInfo.name !== "unknown") {
224
- return `${browserInfo.name} Browser`;
225
- }
226
- return "Web Browser";
227
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.generateUUID=generateUUID;exports.getDefaultDeviceName=getDefaultDeviceName;exports.getDeviceMetadata=getDeviceMetadata;exports.isSimulator=isSimulator;function generateUUID(){if(typeof crypto!=="undefined"&&crypto.randomUUID){return crypto.randomUUID()}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const n=Math.random()*16|0;const r=e==="x"?n:n&3|8;return r.toString(16)})}function isSimulator(){return false}function detectPlatform(){if(typeof navigator==="undefined"){return"unknown"}const e=navigator.userAgent.toLowerCase();const n=navigator.platform?.toLowerCase()||"";if(e.includes("electron")){if(n.includes("mac")||e.includes("mac")){return"electron-macos"}if(n.includes("win")||e.includes("win")){return"electron-windows"}if(n.includes("linux")||e.includes("linux")){return"electron-linux"}return"electron"}if(n.includes("mac")||e.includes("mac")){return"macos"}if(n.includes("win")||e.includes("win")){return"windows"}if(n.includes("linux")||e.includes("linux")){return"linux"}if(/iphone|ipad|ipod/.test(e)){return"ios-web"}if(e.includes("android")){return"android-web"}return"web"}function getOSVersion(){if(typeof navigator==="undefined"){return"unknown"}const e=navigator.userAgent;const n=e.match(/Mac OS X ([\d_.]+)/);if(n){return n[1].replace(/_/g,".")}const r=e.match(/Windows NT ([\d.]+)/);if(r){const t={"10.0":"10/11","6.3":"8.1","6.2":"8","6.1":"7"};return t[r[1]]||r[1]}if(e.includes("Linux")){return"Linux"}return"unknown"}function getBrowserInfo(){if(typeof navigator==="undefined"){return{name:"unknown",version:"unknown"}}const e=navigator.userAgent;const n=e.match(/Electron\/([\d.]+)/);if(n){return{name:"Electron",version:n[1]}}const r=e.match(/Chrome\/([\d.]+)/);if(r&&!e.includes("Edg")){return{name:"Chrome",version:r[1]}}const t=e.match(/Edg\/([\d.]+)/);if(t){return{name:"Edge",version:t[1]}}const o=e.match(/Firefox\/([\d.]+)/);if(o){return{name:"Firefox",version:o[1]}}const i=e.match(/Version\/([\d.]+).*Safari/);if(i){return{name:"Safari",version:i[1]}}return{name:"unknown",version:"unknown"}}function getDeviceMetadata(){const e={platform:detectPlatform(),osVersion:getOSVersion(),isSimulator:"false"};const n=getBrowserInfo();e.browser=n.name;e.browserVersion=n.version;if(typeof window!=="undefined"&&window.screen){e.screenResolution=`${window.screen.width}x${window.screen.height}`}if(typeof navigator!=="undefined"&&navigator.language){e.language=navigator.language}try{e.timezone=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}return e}function getDefaultDeviceName(){const e=detectPlatform();const n=getBrowserInfo();if(e.startsWith("electron")){const r=e.replace("electron-","").replace("electron","Desktop");return`${r.charAt(0).toUpperCase()+r.slice(1)} App`}if(n.name!=="unknown"){return`${n.name} Browser`}return"Web Browser"}
@@ -1,30 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "generateUUID", {
7
- enumerable: true,
8
- get: function () {
9
- return _deviceInfo.generateUUID;
10
- }
11
- });
12
- Object.defineProperty(exports, "getDefaultDeviceName", {
13
- enumerable: true,
14
- get: function () {
15
- return _deviceInfo.getDefaultDeviceName;
16
- }
17
- });
18
- Object.defineProperty(exports, "getDeviceMetadata", {
19
- enumerable: true,
20
- get: function () {
21
- return _deviceInfo.getDeviceMetadata;
22
- }
23
- });
24
- Object.defineProperty(exports, "isSimulator", {
25
- enumerable: true,
26
- get: function () {
27
- return _deviceInfo.isSimulator;
28
- }
29
- });
30
- var _deviceInfo = require("./device-info");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"generateUUID",{enumerable:true,get:function(){return _deviceInfo.generateUUID}});Object.defineProperty(exports,"getDefaultDeviceName",{enumerable:true,get:function(){return _deviceInfo.getDefaultDeviceName}});Object.defineProperty(exports,"getDeviceMetadata",{enumerable:true,get:function(){return _deviceInfo.getDeviceMetadata}});Object.defineProperty(exports,"isSimulator",{enumerable:true,get:function(){return _deviceInfo.isSimulator}});var _deviceInfo=require("./device-info");
@@ -1,30 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "generateUUID", {
7
- enumerable: true,
8
- get: function () {
9
- return _deviceInfoWeb.generateUUID;
10
- }
11
- });
12
- Object.defineProperty(exports, "getDefaultDeviceName", {
13
- enumerable: true,
14
- get: function () {
15
- return _deviceInfoWeb.getDefaultDeviceName;
16
- }
17
- });
18
- Object.defineProperty(exports, "getDeviceMetadata", {
19
- enumerable: true,
20
- get: function () {
21
- return _deviceInfoWeb.getDeviceMetadata;
22
- }
23
- });
24
- Object.defineProperty(exports, "isSimulator", {
25
- enumerable: true,
26
- get: function () {
27
- return _deviceInfoWeb.isSimulator;
28
- }
29
- });
30
- var _deviceInfoWeb = require("./device-info.web.js");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"generateUUID",{enumerable:true,get:function(){return _deviceInfoWeb.generateUUID}});Object.defineProperty(exports,"getDefaultDeviceName",{enumerable:true,get:function(){return _deviceInfoWeb.getDefaultDeviceName}});Object.defineProperty(exports,"getDeviceMetadata",{enumerable:true,get:function(){return _deviceInfoWeb.getDeviceMetadata}});Object.defineProperty(exports,"isSimulator",{enumerable:true,get:function(){return _deviceInfoWeb.isSimulator}});var _deviceInfoWeb=require("./device-info.web.js");