@hyve-sdk/js 1.3.4 → 1.3.6
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 +17 -8
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,11 +36,9 @@ Main client class for SDK operations including authentication, telemetry, and AP
|
|
|
36
36
|
```typescript
|
|
37
37
|
import { HyveClient } from "@hyve-sdk/js";
|
|
38
38
|
|
|
39
|
-
// Initialize
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
apiBaseUrl: 'https://...' // Optional custom API URL
|
|
43
|
-
});
|
|
39
|
+
// Initialize client
|
|
40
|
+
// Environment (dev/prod) is automatically detected from the parent page URL
|
|
41
|
+
const client = new HyveClient();
|
|
44
42
|
|
|
45
43
|
// Authenticate from URL parameters
|
|
46
44
|
// Extracts: hyve-token/signature, hyve-access (JWT), game-id
|
|
@@ -53,6 +51,20 @@ if (authenticated) {
|
|
|
53
51
|
}
|
|
54
52
|
```
|
|
55
53
|
|
|
54
|
+
**Environment Detection:**
|
|
55
|
+
The SDK automatically detects whether to use dev or prod environment by checking the parent page URL:
|
|
56
|
+
- **Dev**: `marvin.dev.hyve.gg` or `dev.hyve.gg`
|
|
57
|
+
- **Prod**: `marvin.hyve.gg` or `hyve.gg`
|
|
58
|
+
|
|
59
|
+
You can optionally override this for testing:
|
|
60
|
+
```typescript
|
|
61
|
+
// Only use for local testing - NOT for production code
|
|
62
|
+
const client = new HyveClient({
|
|
63
|
+
isDev: true, // Force dev mode for testing
|
|
64
|
+
apiBaseUrl: 'https://...' // Optional custom API URL
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
56
68
|
### Authentication Utilities
|
|
57
69
|
|
|
58
70
|
#### Parse URL Parameters
|
|
@@ -292,7 +304,6 @@ import { HyveClient } from "@hyve-sdk/js";
|
|
|
292
304
|
|
|
293
305
|
// Enable ads in initial config
|
|
294
306
|
const client = new HyveClient({
|
|
295
|
-
isDev: true,
|
|
296
307
|
ads: {
|
|
297
308
|
enabled: true, // Must be set to true
|
|
298
309
|
sound: 'on',
|
|
@@ -390,7 +401,6 @@ import { HyveClient } from "@hyve-sdk/js";
|
|
|
390
401
|
|
|
391
402
|
// Enable billing in initial config
|
|
392
403
|
const client = new HyveClient({
|
|
393
|
-
isDev: true,
|
|
394
404
|
billing: {
|
|
395
405
|
stripePublishableKey: 'pk_test_...',
|
|
396
406
|
checkoutUrl: 'https://your-api.com',
|
|
@@ -534,7 +544,6 @@ interface PurchaseResult {
|
|
|
534
544
|
|
|
535
545
|
```typescript
|
|
536
546
|
const client = new HyveClient({
|
|
537
|
-
isDev: true,
|
|
538
547
|
billing: {
|
|
539
548
|
stripePublishableKey: process.env.VITE_STRIPE_KEY,
|
|
540
549
|
checkoutUrl: process.env.VITE_CHECKOUT_URL,
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
* Telemetry configuration options
|
|
3
3
|
*/
|
|
4
4
|
interface TelemetryConfig {
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Environment: true for dev, false for prod.
|
|
7
|
+
* AUTO-DETECTED from parent page URL by default - only set for local testing.
|
|
8
|
+
* Use this ONLY for testing, NOT in production code.
|
|
9
|
+
*/
|
|
6
10
|
isDev?: boolean;
|
|
7
11
|
/** Base API URL for all API calls (telemetry and external). Can be set via env. If not provided, defaults based on isDev */
|
|
8
12
|
apiBaseUrl?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
* Telemetry configuration options
|
|
3
3
|
*/
|
|
4
4
|
interface TelemetryConfig {
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Environment: true for dev, false for prod.
|
|
7
|
+
* AUTO-DETECTED from parent page URL by default - only set for local testing.
|
|
8
|
+
* Use this ONLY for testing, NOT in production code.
|
|
9
|
+
*/
|
|
6
10
|
isDev?: boolean;
|
|
7
11
|
/** Base API URL for all API calls (telemetry and external). Can be set via env. If not provided, defaults based on isDev */
|
|
8
12
|
apiBaseUrl?: string;
|
package/dist/index.js
CHANGED
|
@@ -1344,11 +1344,11 @@ function determineEnvironmentFromParentUrl() {
|
|
|
1344
1344
|
parentUrl = window.location.href;
|
|
1345
1345
|
}
|
|
1346
1346
|
logger.debug("Detected parent URL:", parentUrl);
|
|
1347
|
-
if (parentUrl.includes("dev.hyve.gg")) {
|
|
1347
|
+
if (parentUrl.includes("marvin.dev.hyve.gg") || parentUrl.includes("dev.hyve.gg")) {
|
|
1348
1348
|
logger.info("Environment detected: dev (from parent URL)");
|
|
1349
1349
|
return true;
|
|
1350
1350
|
}
|
|
1351
|
-
if (parentUrl.includes("hyve.gg")) {
|
|
1351
|
+
if (parentUrl.includes("marvin.hyve.gg") || parentUrl.includes("hyve.gg")) {
|
|
1352
1352
|
logger.info("Environment detected: prod (from parent URL)");
|
|
1353
1353
|
return false;
|
|
1354
1354
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1304,11 +1304,11 @@ function determineEnvironmentFromParentUrl() {
|
|
|
1304
1304
|
parentUrl = window.location.href;
|
|
1305
1305
|
}
|
|
1306
1306
|
logger.debug("Detected parent URL:", parentUrl);
|
|
1307
|
-
if (parentUrl.includes("dev.hyve.gg")) {
|
|
1307
|
+
if (parentUrl.includes("marvin.dev.hyve.gg") || parentUrl.includes("dev.hyve.gg")) {
|
|
1308
1308
|
logger.info("Environment detected: dev (from parent URL)");
|
|
1309
1309
|
return true;
|
|
1310
1310
|
}
|
|
1311
|
-
if (parentUrl.includes("hyve.gg")) {
|
|
1311
|
+
if (parentUrl.includes("marvin.hyve.gg") || parentUrl.includes("hyve.gg")) {
|
|
1312
1312
|
logger.info("Environment detected: prod (from parent URL)");
|
|
1313
1313
|
return false;
|
|
1314
1314
|
}
|