@buoy-gg/license 1.7.2
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/lib/commonjs/LicenseManager.js +887 -0
- package/lib/commonjs/api.js +198 -0
- package/lib/commonjs/config.js +26 -0
- package/lib/commonjs/device-info.js +93 -0
- package/lib/commonjs/fingerprint.js +30 -0
- package/lib/commonjs/hooks.js +216 -0
- package/lib/commonjs/index.js +103 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/types.js +1 -0
- package/lib/module/LicenseManager.js +884 -0
- package/lib/module/api.js +187 -0
- package/lib/module/config.js +22 -0
- package/lib/module/device-info.js +87 -0
- package/lib/module/fingerprint.js +10 -0
- package/lib/module/hooks.js +208 -0
- package/lib/module/index.js +43 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +1 -0
- package/lib/typescript/commonjs/LicenseManager.d.ts +132 -0
- package/lib/typescript/commonjs/LicenseManager.d.ts.map +1 -0
- package/lib/typescript/commonjs/api.d.ts +38 -0
- package/lib/typescript/commonjs/api.d.ts.map +1 -0
- package/lib/typescript/commonjs/config.d.ts +13 -0
- package/lib/typescript/commonjs/config.d.ts.map +1 -0
- package/lib/typescript/commonjs/device-info.d.ts +23 -0
- package/lib/typescript/commonjs/device-info.d.ts.map +1 -0
- package/lib/typescript/commonjs/fingerprint.d.ts +8 -0
- package/lib/typescript/commonjs/fingerprint.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks.d.ts +68 -0
- package/lib/typescript/commonjs/hooks.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +13 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/types.d.ts +200 -0
- package/lib/typescript/commonjs/types.d.ts.map +1 -0
- package/lib/typescript/module/LicenseManager.d.ts +132 -0
- package/lib/typescript/module/LicenseManager.d.ts.map +1 -0
- package/lib/typescript/module/api.d.ts +38 -0
- package/lib/typescript/module/api.d.ts.map +1 -0
- package/lib/typescript/module/config.d.ts +13 -0
- package/lib/typescript/module/config.d.ts.map +1 -0
- package/lib/typescript/module/device-info.d.ts +23 -0
- package/lib/typescript/module/device-info.d.ts.map +1 -0
- package/lib/typescript/module/fingerprint.d.ts +8 -0
- package/lib/typescript/module/fingerprint.d.ts.map +1 -0
- package/lib/typescript/module/hooks.d.ts +68 -0
- package/lib/typescript/module/hooks.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +13 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/types.d.ts +200 -0
- package/lib/typescript/module/types.d.ts.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keygen REST API client for React Buoy
|
|
3
|
+
*/
|
|
4
|
+
import type { KeygenValidationResponse, KeygenMachineResponse, KeygenMachine, LicenseValidationResult } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* Validate a license key with Keygen
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateLicense(licenseKey: string, fingerprint?: string): Promise<KeygenValidationResponse>;
|
|
9
|
+
/**
|
|
10
|
+
* Activate a machine for a license
|
|
11
|
+
*/
|
|
12
|
+
export declare function activateMachine(licenseId: string, licenseKey: string, fingerprint: string, name: string, metadata?: Record<string, string>): Promise<KeygenMachineResponse>;
|
|
13
|
+
/**
|
|
14
|
+
* Deactivate a machine from a license
|
|
15
|
+
*/
|
|
16
|
+
export declare function deactivateMachine(machineId: string, licenseKey: string): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Get all machines for a license
|
|
19
|
+
*/
|
|
20
|
+
export declare function getLicenseMachines(licenseId: string, licenseKey: string): Promise<KeygenMachine[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Parse validation response into a simpler result
|
|
23
|
+
* Note: response.data can be null when license is invalid (e.g., NOT_FOUND)
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseValidationResult(response: KeygenValidationResponse): LicenseValidationResult;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a validation code indicates the license needs machine activation
|
|
28
|
+
*/
|
|
29
|
+
export declare function needsMachineActivation(code: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Check if a validation code indicates too many machines
|
|
32
|
+
*/
|
|
33
|
+
export declare function hasTooManyMachines(code: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Check if a validation code indicates a fatal error (license invalid)
|
|
36
|
+
*/
|
|
37
|
+
export declare function isFatalLicenseError(code: string): boolean;
|
|
38
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACrB,aAAa,EAEb,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAyBjB;;GAEG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,wBAAwB,CAAC,CA0CnC;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,OAAO,CAAC,qBAAqB,CAAC,CAsDhC;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAc5F;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,EAAE,CAAC,CAiB1B;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,wBAAwB,GACjC,uBAAuB,CAUzB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQzD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keygen configuration for React Buoy
|
|
3
|
+
*/
|
|
4
|
+
export declare const KEYGEN_CONFIG: {
|
|
5
|
+
readonly accountId: "b0eba0e8-e904-4906-b644-38f9aab57bed";
|
|
6
|
+
readonly productId: "1037431d-b2fe-48db-aca9-10c5e9c4d944";
|
|
7
|
+
readonly productToken: "prod-4467c14b75b715e91884945cd3e69705846ccbce7dd5e380236a1ab3bc03139fv3";
|
|
8
|
+
readonly apiUrl: "https://api.keygen.sh/v1/accounts";
|
|
9
|
+
};
|
|
10
|
+
export declare const LICENSE_CACHE_DURATION: number;
|
|
11
|
+
export declare const LICENSE_REVALIDATION_INTERVAL: number;
|
|
12
|
+
export declare const LICENSE_STORAGE_KEY = "@buoy-gg/license";
|
|
13
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,aAAa;;;;;CAMhB,CAAC;AAGX,eAAO,MAAM,sBAAsB,QAA2B,CAAC;AAG/D,eAAO,MAAM,6BAA6B,QAAqB,CAAC;AAGhE,eAAO,MAAM,mBAAmB,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure JS device info utilities
|
|
3
|
+
*
|
|
4
|
+
* No native module dependencies - uses only React Native core APIs.
|
|
5
|
+
* Device fingerprint is a generated UUID stored alongside license data.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Generate a UUID v4
|
|
9
|
+
*/
|
|
10
|
+
export declare function generateUUID(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Check if running on a simulator/emulator using Platform constants
|
|
13
|
+
*/
|
|
14
|
+
export declare function isSimulator(): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Get basic device metadata from Platform APIs
|
|
17
|
+
*/
|
|
18
|
+
export declare function getDeviceMetadata(): Record<string, string>;
|
|
19
|
+
/**
|
|
20
|
+
* Get a default device name suggestion based on platform
|
|
21
|
+
*/
|
|
22
|
+
export declare function getDefaultDeviceName(): string;
|
|
23
|
+
//# sourceMappingURL=device-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-info.d.ts","sourceRoot":"","sources":["../../../src/device-info.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAMrC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAoCrC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAuB1D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAI7C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device fingerprint utilities for license activation
|
|
3
|
+
*
|
|
4
|
+
* The fingerprint is a generated UUID that is stored alongside the license.
|
|
5
|
+
* It's created when the user registers their device and persists with the license data.
|
|
6
|
+
*/
|
|
7
|
+
export { generateUUID, isSimulator, getDeviceMetadata, getDefaultDeviceName, } from "./device-info";
|
|
8
|
+
//# sourceMappingURL=fingerprint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../../../src/fingerprint.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React hooks for license management
|
|
3
|
+
*/
|
|
4
|
+
import { type LicenseValidationResult, type DeviceRegistrationResult } from "./LicenseManager";
|
|
5
|
+
import type { LicenseState, RegisteredDevice } from "./types";
|
|
6
|
+
/**
|
|
7
|
+
* Hook to access the current license state
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* function MyComponent() {
|
|
12
|
+
* const { isPro, isValidating, error } = useLicense();
|
|
13
|
+
*
|
|
14
|
+
* if (isValidating) return <Loading />;
|
|
15
|
+
* if (isPro) return <ProFeature />;
|
|
16
|
+
* return <UpgradePrompt />;
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function useLicense(): LicenseState & {
|
|
21
|
+
/** Legacy method - validates and auto-registers */
|
|
22
|
+
setLicenseKey: (key: string) => Promise<boolean>;
|
|
23
|
+
/** Validate a license key - returns info about what action is needed */
|
|
24
|
+
validateLicenseKey: (key: string) => Promise<LicenseValidationResult>;
|
|
25
|
+
/** Register a new device with a user-provided name */
|
|
26
|
+
registerDevice: (deviceName: string) => Promise<DeviceRegistrationResult>;
|
|
27
|
+
/** Claim an existing device (after storage was cleared) */
|
|
28
|
+
claimDevice: (machineId: string, existingDevices: RegisteredDevice[]) => Promise<boolean>;
|
|
29
|
+
/** Clear the current license */
|
|
30
|
+
clearLicense: () => Promise<void>;
|
|
31
|
+
/** Clear cache and revalidate */
|
|
32
|
+
clearCacheAndRevalidate: () => Promise<boolean>;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Hook to check if a feature is available based on license
|
|
36
|
+
*/
|
|
37
|
+
export declare function useFeatureAccess(featureCode?: string): {
|
|
38
|
+
hasAccess: boolean;
|
|
39
|
+
isPro: boolean;
|
|
40
|
+
isLoading: boolean;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Hook to get seat/machine information
|
|
44
|
+
*/
|
|
45
|
+
export declare function useSeats(): {
|
|
46
|
+
used: number;
|
|
47
|
+
total: number | null;
|
|
48
|
+
remaining: number | null;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Hook that returns true only when Pro and not loading
|
|
52
|
+
*/
|
|
53
|
+
export declare function useIsPro(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Hook for device management
|
|
56
|
+
*/
|
|
57
|
+
export declare function useDevices(): {
|
|
58
|
+
devices: RegisteredDevice[];
|
|
59
|
+
isLoading: boolean;
|
|
60
|
+
error: string | null;
|
|
61
|
+
refreshDevices: () => Promise<void>;
|
|
62
|
+
registerDevice: (deviceName: string) => Promise<DeviceRegistrationResult>;
|
|
63
|
+
deactivateDevice: (machineId: string) => Promise<boolean>;
|
|
64
|
+
isCurrentDeviceRegistered: boolean;
|
|
65
|
+
};
|
|
66
|
+
export type { RegisteredDevice } from "./types";
|
|
67
|
+
export type { LicenseValidationResult, DeviceRegistrationResult } from "./LicenseManager";
|
|
68
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/hooks.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAkB,KAAK,uBAAuB,EAAE,KAAK,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC/G,OAAO,KAAK,EAAE,YAAY,EAAgB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE5E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,IAAI,YAAY,GAAG;IAC3C,mDAAmD;IACnD,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACj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,yBAAyB,EAAE,OAAO,CAAC;CACpC,CA6EA;AAGD,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,YAAY,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @buoy-gg/license
|
|
3
|
+
*
|
|
4
|
+
* License validation for React Buoy Pro features
|
|
5
|
+
*/
|
|
6
|
+
export { LicenseManager, type LicenseValidationResult } from "./LicenseManager";
|
|
7
|
+
export { useLicense, useFeatureAccess, useSeats, useIsPro, useDevices, } from "./hooks";
|
|
8
|
+
export type { LicenseState, LicenseEvent, LicenseListener, LicenseValidationResult as LicenseValidationResultType, CachedLicense, RegisteredDevice, } from "./types";
|
|
9
|
+
export { generateUUID, isSimulator, getDeviceMetadata, getDefaultDeviceName, } from "./fingerprint";
|
|
10
|
+
export declare function setLicenseKey(key: string): Promise<boolean>;
|
|
11
|
+
export declare function isPro(): boolean;
|
|
12
|
+
export declare function hasEntitlement(code: string): boolean;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,cAAc,EAAE,KAAK,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAGhF,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,QAAQ,EACR,UAAU,GACX,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,uBAAuB,IAAI,2BAA2B,EACtD,aAAa,EACb,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAGvB,wBAAsB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAIjE;AAGD,wBAAgB,KAAK,IAAI,OAAO,CAG/B;AAGD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* License types for React Buoy
|
|
3
|
+
*/
|
|
4
|
+
export interface LicenseValidationResult {
|
|
5
|
+
valid: boolean;
|
|
6
|
+
code: "VALID" | "NOT_FOUND" | "SUSPENDED" | "EXPIRED" | "OVERDUE" | "NO_MACHINE" | "NO_MACHINES" | "TOO_MANY_MACHINES" | "TOO_MANY_CORES" | "TOO_MANY_PROCESSES" | "FINGERPRINT_SCOPE_MISMATCH" | "HEARTBEAT_NOT_STARTED" | "HEARTBEAT_DEAD" | "PRODUCT_SCOPE_REQUIRED" | "PRODUCT_SCOPE_MISMATCH" | "POLICY_SCOPE_REQUIRED" | "POLICY_SCOPE_MISMATCH" | "MACHINE_SCOPE_REQUIRED" | "MACHINE_SCOPE_MISMATCH" | "ENTITLEMENTS_MISSING" | "ENTITLEMENTS_SCOPE_MISMATCH" | "BANNED";
|
|
7
|
+
detail: string;
|
|
8
|
+
metadata?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
export interface KeygenLicense {
|
|
11
|
+
id: string;
|
|
12
|
+
type: "licenses";
|
|
13
|
+
attributes: {
|
|
14
|
+
name: string | null;
|
|
15
|
+
key: string;
|
|
16
|
+
expiry: string | null;
|
|
17
|
+
status: "ACTIVE" | "INACTIVE" | "EXPIRED" | "SUSPENDED" | "BANNED";
|
|
18
|
+
uses: number;
|
|
19
|
+
suspended: boolean;
|
|
20
|
+
scheme: string | null;
|
|
21
|
+
encrypted: boolean;
|
|
22
|
+
floating: boolean;
|
|
23
|
+
strict: boolean;
|
|
24
|
+
maxMachines: number | null;
|
|
25
|
+
maxProcesses: number | null;
|
|
26
|
+
maxUsers: number | null;
|
|
27
|
+
maxCores: number | null;
|
|
28
|
+
maxUses: number | null;
|
|
29
|
+
requireHeartbeat: boolean;
|
|
30
|
+
requireCheckIn: boolean;
|
|
31
|
+
lastValidated: string | null;
|
|
32
|
+
lastCheckIn: string | null;
|
|
33
|
+
nextCheckIn: string | null;
|
|
34
|
+
metadata: Record<string, unknown>;
|
|
35
|
+
created: string;
|
|
36
|
+
updated: string;
|
|
37
|
+
};
|
|
38
|
+
relationships: {
|
|
39
|
+
account: {
|
|
40
|
+
data: {
|
|
41
|
+
type: "accounts";
|
|
42
|
+
id: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
product: {
|
|
46
|
+
data: {
|
|
47
|
+
type: "products";
|
|
48
|
+
id: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
policy: {
|
|
52
|
+
data: {
|
|
53
|
+
type: "policies";
|
|
54
|
+
id: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
user?: {
|
|
58
|
+
data: {
|
|
59
|
+
type: "users";
|
|
60
|
+
id: string;
|
|
61
|
+
} | null;
|
|
62
|
+
};
|
|
63
|
+
machines?: {
|
|
64
|
+
data?: Array<{
|
|
65
|
+
type: "machines";
|
|
66
|
+
id: string;
|
|
67
|
+
}>;
|
|
68
|
+
meta?: {
|
|
69
|
+
count: number;
|
|
70
|
+
cores?: number;
|
|
71
|
+
memory?: number;
|
|
72
|
+
disk?: number;
|
|
73
|
+
};
|
|
74
|
+
links?: {
|
|
75
|
+
related: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
entitlements?: {
|
|
79
|
+
data: Array<{
|
|
80
|
+
type: "entitlements";
|
|
81
|
+
id: string;
|
|
82
|
+
}>;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export interface KeygenMachine {
|
|
87
|
+
id: string;
|
|
88
|
+
type: "machines";
|
|
89
|
+
attributes: {
|
|
90
|
+
fingerprint: string;
|
|
91
|
+
name: string | null;
|
|
92
|
+
ip: string | null;
|
|
93
|
+
hostname: string | null;
|
|
94
|
+
platform: string | null;
|
|
95
|
+
cores: number | null;
|
|
96
|
+
created: string;
|
|
97
|
+
updated: string;
|
|
98
|
+
metadata: Record<string, unknown>;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export interface KeygenEntitlement {
|
|
102
|
+
id: string;
|
|
103
|
+
type: "entitlements";
|
|
104
|
+
attributes: {
|
|
105
|
+
name: string;
|
|
106
|
+
code: string;
|
|
107
|
+
metadata: Record<string, unknown>;
|
|
108
|
+
created: string;
|
|
109
|
+
updated: string;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export interface KeygenValidationResponse {
|
|
113
|
+
/**
|
|
114
|
+
* License data - CAN BE NULL when license is invalid (e.g., NOT_FOUND)
|
|
115
|
+
* Always check this before accessing .attributes
|
|
116
|
+
*/
|
|
117
|
+
data: KeygenLicense | null;
|
|
118
|
+
meta: {
|
|
119
|
+
ts: string;
|
|
120
|
+
valid: boolean;
|
|
121
|
+
detail: string;
|
|
122
|
+
code: LicenseValidationResult["code"];
|
|
123
|
+
};
|
|
124
|
+
included?: Array<KeygenMachine | KeygenEntitlement>;
|
|
125
|
+
}
|
|
126
|
+
export interface KeygenMachineResponse {
|
|
127
|
+
data: KeygenMachine;
|
|
128
|
+
}
|
|
129
|
+
export interface KeygenErrorResponse {
|
|
130
|
+
errors: Array<{
|
|
131
|
+
title: string;
|
|
132
|
+
detail: string;
|
|
133
|
+
code: string;
|
|
134
|
+
source?: {
|
|
135
|
+
pointer?: string;
|
|
136
|
+
parameter?: string;
|
|
137
|
+
};
|
|
138
|
+
}>;
|
|
139
|
+
}
|
|
140
|
+
export interface CachedLicense {
|
|
141
|
+
licenseKey: string;
|
|
142
|
+
licenseId: string;
|
|
143
|
+
valid: boolean;
|
|
144
|
+
isPro: boolean;
|
|
145
|
+
entitlements: string[];
|
|
146
|
+
machineId: string | null;
|
|
147
|
+
maxMachines: number | null;
|
|
148
|
+
machineCount: number;
|
|
149
|
+
expiresAt: string | null;
|
|
150
|
+
cachedAt: number;
|
|
151
|
+
lastValidatedAt: number;
|
|
152
|
+
/** Device fingerprint (generated UUID) */
|
|
153
|
+
fingerprint?: string;
|
|
154
|
+
/** User-provided device name */
|
|
155
|
+
deviceName?: string;
|
|
156
|
+
}
|
|
157
|
+
export interface LicenseState {
|
|
158
|
+
isInitialized: boolean;
|
|
159
|
+
isValidating: boolean;
|
|
160
|
+
isPro: boolean;
|
|
161
|
+
licenseKey: string | null;
|
|
162
|
+
error: string | null;
|
|
163
|
+
machineId: string | null;
|
|
164
|
+
maxMachines: number | null;
|
|
165
|
+
machineCount: number;
|
|
166
|
+
expiresAt: Date | null;
|
|
167
|
+
}
|
|
168
|
+
export type LicenseEventType = "initialized" | "validating" | "validated" | "error" | "activated" | "deactivated";
|
|
169
|
+
export interface LicenseEvent {
|
|
170
|
+
type: LicenseEventType;
|
|
171
|
+
isPro: boolean;
|
|
172
|
+
error?: string;
|
|
173
|
+
}
|
|
174
|
+
export type LicenseListener = (event: LicenseEvent) => void;
|
|
175
|
+
/**
|
|
176
|
+
* User-friendly device representation for UI display
|
|
177
|
+
*/
|
|
178
|
+
export interface RegisteredDevice {
|
|
179
|
+
/** Machine ID from Keygen */
|
|
180
|
+
id: string;
|
|
181
|
+
/** Device fingerprint */
|
|
182
|
+
fingerprint: string;
|
|
183
|
+
/** Device name (e.g., "iPhone 14 Pro", "Pixel 7") */
|
|
184
|
+
name: string;
|
|
185
|
+
/** Platform (ios, android) */
|
|
186
|
+
platform: string;
|
|
187
|
+
/** Device model from metadata */
|
|
188
|
+
model: string | null;
|
|
189
|
+
/** OS version from metadata */
|
|
190
|
+
osVersion: string | null;
|
|
191
|
+
/** App version when registered */
|
|
192
|
+
appVersion: string | null;
|
|
193
|
+
/** Registration date */
|
|
194
|
+
registeredAt: Date;
|
|
195
|
+
/** Last updated date */
|
|
196
|
+
lastSeenAt: Date;
|
|
197
|
+
/** Whether this is the current device */
|
|
198
|
+
isCurrentDevice: boolean;
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EACA,OAAO,GACP,WAAW,GACX,WAAW,GACX,SAAS,GACT,SAAS,GACT,YAAY,GACZ,aAAa,GACb,mBAAmB,GACnB,gBAAgB,GAChB,oBAAoB,GACpB,4BAA4B,GAC5B,uBAAuB,GACvB,gBAAgB,GAChB,wBAAwB,GACxB,wBAAwB,GACxB,uBAAuB,GACvB,uBAAuB,GACvB,wBAAwB,GACxB,wBAAwB,GACxB,sBAAsB,GACtB,6BAA6B,GAC7B,QAAQ,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE;QACV,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QACpB,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,MAAM,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;QACnE,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,OAAO,CAAC;QACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,SAAS,EAAE,OAAO,CAAC;QACnB,QAAQ,EAAE,OAAO,CAAC;QAClB,MAAM,EAAE,OAAO,CAAC;QAChB,WAAW,EAAE,MAAM,GAAG,IAAI,CAA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,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,YAAY,GACZ,WAAW,GACX,OAAO,GACP,WAAW,GACX,aAAa,CAAC;AAElB,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,6BAA6B;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,iCAAiC;IACjC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,+BAA+B;IAC/B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,kCAAkC;IAClC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,wBAAwB;IACxB,YAAY,EAAE,IAAI,CAAC;IACnB,wBAAwB;IACxB,UAAU,EAAE,IAAI,CAAC;IACjB,yCAAyC;IACzC,eAAe,EAAE,OAAO,CAAC;CAC1B"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LicenseManager - Singleton for managing React Buoy Pro licenses
|
|
3
|
+
*
|
|
4
|
+
* Handles license validation, machine activation, caching, and state management.
|
|
5
|
+
*
|
|
6
|
+
* New flow:
|
|
7
|
+
* 1. validateLicenseKey() - Check if license is valid, returns existing devices
|
|
8
|
+
* 2. registerDevice(deviceName) - Register new device with user-provided name
|
|
9
|
+
* 3. claimDevice(machineId) - Re-claim an existing device after storage clear
|
|
10
|
+
*/
|
|
11
|
+
import type { LicenseState, LicenseListener, RegisteredDevice } from "./types";
|
|
12
|
+
/**
|
|
13
|
+
* Result of license validation - indicates what action is needed
|
|
14
|
+
*/
|
|
15
|
+
export interface LicenseValidationResult {
|
|
16
|
+
valid: boolean;
|
|
17
|
+
needsDeviceRegistration: boolean;
|
|
18
|
+
existingDevices: RegisteredDevice[];
|
|
19
|
+
error?: string;
|
|
20
|
+
maxDevices?: number;
|
|
21
|
+
currentDeviceCount?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Result of device registration
|
|
25
|
+
*/
|
|
26
|
+
export interface DeviceRegistrationResult {
|
|
27
|
+
success: boolean;
|
|
28
|
+
error?: string;
|
|
29
|
+
}
|
|
30
|
+
declare class LicenseManagerImpl {
|
|
31
|
+
private state;
|
|
32
|
+
private listeners;
|
|
33
|
+
private revalidationTimer;
|
|
34
|
+
private cachedLicense;
|
|
35
|
+
private pendingLicenseId;
|
|
36
|
+
private validationInProgress;
|
|
37
|
+
private registrationInProgress;
|
|
38
|
+
private initPromise;
|
|
39
|
+
/**
|
|
40
|
+
* Initialize the license manager and load cached license
|
|
41
|
+
*/
|
|
42
|
+
initialize(): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Internal initialization logic
|
|
45
|
+
*/
|
|
46
|
+
private _doInitialize;
|
|
47
|
+
/**
|
|
48
|
+
* Validate a license key and check what action is needed
|
|
49
|
+
* Returns info about whether device registration is needed
|
|
50
|
+
*/
|
|
51
|
+
validateLicenseKey(licenseKey: string): Promise<LicenseValidationResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Register a new device with a user-provided name
|
|
54
|
+
*/
|
|
55
|
+
registerDevice(deviceName: string): Promise<DeviceRegistrationResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Claim an existing device (use its fingerprint)
|
|
58
|
+
* This is for when the user wants to re-use a device slot after clearing storage
|
|
59
|
+
*/
|
|
60
|
+
claimDevice(machineId: string, existingDevices: RegisteredDevice[]): Promise<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* Legacy method - validates and auto-registers if needed (for backward compatibility)
|
|
63
|
+
* Note: This won't work well with the new flow - use validateLicenseKey + registerDevice instead
|
|
64
|
+
*/
|
|
65
|
+
setLicenseKey(licenseKey: string): Promise<boolean>;
|
|
66
|
+
/**
|
|
67
|
+
* Check if an error is a network error (not an API validation error)
|
|
68
|
+
*/
|
|
69
|
+
private isNetworkError;
|
|
70
|
+
/**
|
|
71
|
+
* Clear the current license
|
|
72
|
+
*/
|
|
73
|
+
clearLicense(): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Check if the user has Pro features
|
|
76
|
+
*/
|
|
77
|
+
isPro(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Check if a specific entitlement is available
|
|
80
|
+
*/
|
|
81
|
+
hasEntitlement(code: string): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Get current license state
|
|
84
|
+
*/
|
|
85
|
+
getState(): Readonly<LicenseState>;
|
|
86
|
+
/**
|
|
87
|
+
* Get seat information
|
|
88
|
+
*/
|
|
89
|
+
getSeatsInfo(): {
|
|
90
|
+
used: number;
|
|
91
|
+
total: number | null;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Subscribe to license events
|
|
95
|
+
*/
|
|
96
|
+
subscribe(listener: LicenseListener): () => void;
|
|
97
|
+
/**
|
|
98
|
+
* Get all registered devices for the current license
|
|
99
|
+
*/
|
|
100
|
+
getRegisteredDevices(): Promise<RegisteredDevice[]>;
|
|
101
|
+
/**
|
|
102
|
+
* Deactivate a specific device by machine ID
|
|
103
|
+
*/
|
|
104
|
+
deactivateDevice(machineId: string): Promise<boolean>;
|
|
105
|
+
/**
|
|
106
|
+
* Register the current device for the license (legacy - use registerDevice instead)
|
|
107
|
+
*/
|
|
108
|
+
registerCurrentDevice(): Promise<boolean>;
|
|
109
|
+
/**
|
|
110
|
+
* Check if the current device is registered
|
|
111
|
+
*/
|
|
112
|
+
isCurrentDeviceRegistered(): boolean;
|
|
113
|
+
private emit;
|
|
114
|
+
private countMachines;
|
|
115
|
+
private isCacheValid;
|
|
116
|
+
private loadCachedLicense;
|
|
117
|
+
private saveLicenseToCache;
|
|
118
|
+
private clearCachedLicense;
|
|
119
|
+
private validateInBackground;
|
|
120
|
+
private startRevalidationTimer;
|
|
121
|
+
/**
|
|
122
|
+
* Stop the revalidation timer
|
|
123
|
+
*/
|
|
124
|
+
stopRevalidationTimer(): void;
|
|
125
|
+
/**
|
|
126
|
+
* Clear cache and revalidate
|
|
127
|
+
*/
|
|
128
|
+
clearCacheAndRevalidate(): Promise<boolean>;
|
|
129
|
+
}
|
|
130
|
+
export declare const LicenseManager: LicenseManagerImpl;
|
|
131
|
+
export {};
|
|
132
|
+
//# sourceMappingURL=LicenseManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LicenseManager.d.ts","sourceRoot":"","sources":["../../../src/LicenseManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA0DH,OAAO,KAAK,EAEV,YAAY,EAEZ,eAAe,EAEf,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,uBAAuB,EAAE,OAAO,CAAC;IACjC,eAAe,EAAE,gBAAgB,EAAE,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,cAAM,kBAAkB;IAC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AAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAkD3D;;OAEG;IACG,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC;IAU/C;;OAEG;IACH,yBAAyB,IAAI,OAAO;IAMpC,OAAO,CAAC,IAAI;IAYZ,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,YAAY;YAkBN,iBAAiB;YAajB,kBAAkB;YAoClB,kBAAkB;IAWhC,OAAO,CAAC,oBAAoB;IAsB5B,OAAO,CAAC,sBAAsB;IAiB9B;;OAEG;IACH,qBAAqB,IAAI,IAAI;IAO7B;;OAEG;IACG,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC;CAalD;AAGD,eAAO,MAAM,cAAc,oBAA2B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keygen REST API client for React Buoy
|
|
3
|
+
*/
|
|
4
|
+
import type { KeygenValidationResponse, KeygenMachineResponse, KeygenMachine, LicenseValidationResult } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* Validate a license key with Keygen
|
|
7
|
+
*/
|
|
8
|
+
export declare function validateLicense(licenseKey: string, fingerprint?: string): Promise<KeygenValidationResponse>;
|
|
9
|
+
/**
|
|
10
|
+
* Activate a machine for a license
|
|
11
|
+
*/
|
|
12
|
+
export declare function activateMachine(licenseId: string, licenseKey: string, fingerprint: string, name: string, metadata?: Record<string, string>): Promise<KeygenMachineResponse>;
|
|
13
|
+
/**
|
|
14
|
+
* Deactivate a machine from a license
|
|
15
|
+
*/
|
|
16
|
+
export declare function deactivateMachine(machineId: string, licenseKey: string): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Get all machines for a license
|
|
19
|
+
*/
|
|
20
|
+
export declare function getLicenseMachines(licenseId: string, licenseKey: string): Promise<KeygenMachine[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Parse validation response into a simpler result
|
|
23
|
+
* Note: response.data can be null when license is invalid (e.g., NOT_FOUND)
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseValidationResult(response: KeygenValidationResponse): LicenseValidationResult;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a validation code indicates the license needs machine activation
|
|
28
|
+
*/
|
|
29
|
+
export declare function needsMachineActivation(code: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Check if a validation code indicates too many machines
|
|
32
|
+
*/
|
|
33
|
+
export declare function hasTooManyMachines(code: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Check if a validation code indicates a fatal error (license invalid)
|
|
36
|
+
*/
|
|
37
|
+
export declare function isFatalLicenseError(code: string): boolean;
|
|
38
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACrB,aAAa,EAEb,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAyBjB;;GAEG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,MAAM,EAClB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,wBAAwB,CAAC,CA0CnC;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,OAAO,CAAC,qBAAqB,CAAC,CAsDhC;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAc5F;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,EAAE,CAAC,CAiB1B;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,wBAAwB,GACjC,uBAAuB,CAUzB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQzD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keygen configuration for React Buoy
|
|
3
|
+
*/
|
|
4
|
+
export declare const KEYGEN_CONFIG: {
|
|
5
|
+
readonly accountId: "b0eba0e8-e904-4906-b644-38f9aab57bed";
|
|
6
|
+
readonly productId: "1037431d-b2fe-48db-aca9-10c5e9c4d944";
|
|
7
|
+
readonly productToken: "prod-4467c14b75b715e91884945cd3e69705846ccbce7dd5e380236a1ab3bc03139fv3";
|
|
8
|
+
readonly apiUrl: "https://api.keygen.sh/v1/accounts";
|
|
9
|
+
};
|
|
10
|
+
export declare const LICENSE_CACHE_DURATION: number;
|
|
11
|
+
export declare const LICENSE_REVALIDATION_INTERVAL: number;
|
|
12
|
+
export declare const LICENSE_STORAGE_KEY = "@buoy-gg/license";
|
|
13
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,aAAa;;;;;CAMhB,CAAC;AAGX,eAAO,MAAM,sBAAsB,QAA2B,CAAC;AAG/D,eAAO,MAAM,6BAA6B,QAAqB,CAAC;AAGhE,eAAO,MAAM,mBAAmB,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure JS device info utilities
|
|
3
|
+
*
|
|
4
|
+
* No native module dependencies - uses only React Native core APIs.
|
|
5
|
+
* Device fingerprint is a generated UUID stored alongside license data.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Generate a UUID v4
|
|
9
|
+
*/
|
|
10
|
+
export declare function generateUUID(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Check if running on a simulator/emulator using Platform constants
|
|
13
|
+
*/
|
|
14
|
+
export declare function isSimulator(): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Get basic device metadata from Platform APIs
|
|
17
|
+
*/
|
|
18
|
+
export declare function getDeviceMetadata(): Record<string, string>;
|
|
19
|
+
/**
|
|
20
|
+
* Get a default device name suggestion based on platform
|
|
21
|
+
*/
|
|
22
|
+
export declare function getDefaultDeviceName(): string;
|
|
23
|
+
//# sourceMappingURL=device-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-info.d.ts","sourceRoot":"","sources":["../../../src/device-info.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAMrC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAoCrC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAuB1D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAI7C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device fingerprint utilities for license activation
|
|
3
|
+
*
|
|
4
|
+
* The fingerprint is a generated UUID that is stored alongside the license.
|
|
5
|
+
* It's created when the user registers their device and persists with the license data.
|
|
6
|
+
*/
|
|
7
|
+
export { generateUUID, isSimulator, getDeviceMetadata, getDefaultDeviceName, } from "./device-info";
|
|
8
|
+
//# sourceMappingURL=fingerprint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../../../src/fingerprint.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,eAAe,CAAC"}
|