@hyve-sdk/js 1.3.1 → 1.3.2-canary.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 +72 -0
- package/dist/index.d.mts +212 -1
- package/dist/index.d.ts +212 -1
- package/dist/index.js +737 -1
- package/dist/index.mjs +735 -1
- package/package.json +21 -12
package/README.md
CHANGED
|
@@ -22,6 +22,7 @@ pnpm add @hyve-sdk/js
|
|
|
22
22
|
- **Telemetry Tracking**: Session-based analytics and event tracking
|
|
23
23
|
- **Ads Integration**: Google H5 Games Ads support (disabled by default)
|
|
24
24
|
- **Native Bridge**: Type-safe communication with React Native WebView apps
|
|
25
|
+
- **Logger**: Environment-aware logging system with configurable log levels
|
|
25
26
|
- **Security Utilities**: Domain validation and referrer checking
|
|
26
27
|
- **URL Parameter Parsing**: Easy extraction of authentication parameters
|
|
27
28
|
- **UUID Generation**: Built-in UUID v4 generation
|
|
@@ -473,6 +474,71 @@ NativeBridge.on("CUSTOM_RESPONSE", (payload) => {
|
|
|
473
474
|
|
|
474
475
|
For complete documentation, see [docs/NATIVE_BRIDGE.md](./docs/NATIVE_BRIDGE.md).
|
|
475
476
|
|
|
477
|
+
## Logger
|
|
478
|
+
|
|
479
|
+
The SDK includes a built-in logger that's automatically enabled in development environments.
|
|
480
|
+
|
|
481
|
+
### Quick Start
|
|
482
|
+
|
|
483
|
+
```typescript
|
|
484
|
+
import { logger } from "@hyve-sdk/js";
|
|
485
|
+
|
|
486
|
+
logger.debug("Debug information", { data: "value" });
|
|
487
|
+
logger.info("Informational message");
|
|
488
|
+
logger.warn("Warning message");
|
|
489
|
+
logger.error("Error message", error);
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
### Configuration
|
|
493
|
+
|
|
494
|
+
**Automatic Behavior:**
|
|
495
|
+
- **Development** (`NODE_ENV !== 'production'`): Logging enabled by default
|
|
496
|
+
- **Production** (`NODE_ENV === 'production'`): Logging disabled by default
|
|
497
|
+
|
|
498
|
+
**Browser Override:**
|
|
499
|
+
```javascript
|
|
500
|
+
// Enable specific log levels
|
|
501
|
+
localStorage.setItem('HYVE_SDK_LOG_LEVEL', 'error,warn');
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
**Node.js Override:**
|
|
505
|
+
```bash
|
|
506
|
+
HYVE_SDK_LOG_LEVEL=error,warn node app.js
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
**Programmatic Control:**
|
|
510
|
+
```typescript
|
|
511
|
+
import { Logger } from "@hyve-sdk/js";
|
|
512
|
+
|
|
513
|
+
const logger = new Logger();
|
|
514
|
+
logger.setLevels(['error', 'warn']);
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
### Child Loggers
|
|
518
|
+
|
|
519
|
+
Create namespaced loggers for different parts of your application:
|
|
520
|
+
|
|
521
|
+
```typescript
|
|
522
|
+
import { logger } from "@hyve-sdk/js";
|
|
523
|
+
|
|
524
|
+
const gameLogger = logger.child('Game');
|
|
525
|
+
gameLogger.info('Game started');
|
|
526
|
+
// Output: [Hyve SDK] [Game] [INFO] [timestamp] Game started
|
|
527
|
+
|
|
528
|
+
const uiLogger = logger.child('UI');
|
|
529
|
+
uiLogger.debug('Button clicked');
|
|
530
|
+
// Output: [Hyve SDK] [UI] [DEBUG] [timestamp] Button clicked
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
### Features
|
|
534
|
+
|
|
535
|
+
- **Automatic environment detection**: Enables/disables based on NODE_ENV
|
|
536
|
+
- **Configurable log levels**: debug, info, warn, error
|
|
537
|
+
- **Timestamps**: All logs include ISO 8601 timestamps
|
|
538
|
+
- **Prefixed output**: All logs prefixed with `[Hyve SDK]`
|
|
539
|
+
- **Child loggers**: Create namespaced loggers for different modules
|
|
540
|
+
- **Browser storage**: Log level persists in localStorage
|
|
541
|
+
|
|
476
542
|
## Client Methods Reference
|
|
477
543
|
|
|
478
544
|
### Authentication
|
|
@@ -495,6 +561,12 @@ For complete documentation, see [docs/NATIVE_BRIDGE.md](./docs/NATIVE_BRIDGE.md)
|
|
|
495
561
|
- `sendTelemetry(location, category, action, subCategory?, subAction?, details?, customData?, platformId?)` - Send JWT-authenticated analytics event (uses game ID from URL)
|
|
496
562
|
- `updateTelemetryConfig(config)` - Update telemetry settings
|
|
497
563
|
|
|
564
|
+
### Ads
|
|
565
|
+
- `configureAds(config)` - Configure ads service
|
|
566
|
+
- `showAd(type)` - Show an ad ('rewarded', 'interstitial', or 'preroll')
|
|
567
|
+
- `areAdsEnabled()` - Check if ads are enabled
|
|
568
|
+
- `areAdsReady()` - Check if ads are ready to show
|
|
569
|
+
|
|
498
570
|
### Configuration
|
|
499
571
|
- `getApiBaseUrl()` - Get current API base URL
|
|
500
572
|
- `updateTelemetryConfig(config)` - Update client configuration
|
package/dist/index.d.mts
CHANGED
|
@@ -303,6 +303,217 @@ declare class HyveClient {
|
|
|
303
303
|
areAdsReady(): boolean;
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
+
/**
|
|
307
|
+
* Product information from the native app or server
|
|
308
|
+
*/
|
|
309
|
+
interface BillingProduct {
|
|
310
|
+
productId: string;
|
|
311
|
+
title: string;
|
|
312
|
+
description: string;
|
|
313
|
+
price: number;
|
|
314
|
+
localizedPrice: string;
|
|
315
|
+
currency: string;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Purchase result
|
|
319
|
+
*/
|
|
320
|
+
interface PurchaseResult {
|
|
321
|
+
success: boolean;
|
|
322
|
+
productId: string;
|
|
323
|
+
transactionId?: string;
|
|
324
|
+
transactionDate?: string;
|
|
325
|
+
error?: {
|
|
326
|
+
code: string;
|
|
327
|
+
message: string;
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Billing configuration
|
|
332
|
+
*/
|
|
333
|
+
interface BillingConfig {
|
|
334
|
+
/**
|
|
335
|
+
* Stripe publishable key (required for web)
|
|
336
|
+
*/
|
|
337
|
+
stripePublishableKey?: string;
|
|
338
|
+
/**
|
|
339
|
+
* Game ID for native purchases
|
|
340
|
+
*/
|
|
341
|
+
gameId?: number;
|
|
342
|
+
/**
|
|
343
|
+
* User ID for purchases
|
|
344
|
+
*/
|
|
345
|
+
userId?: string;
|
|
346
|
+
/**
|
|
347
|
+
* Checkout URL for API calls
|
|
348
|
+
*/
|
|
349
|
+
checkoutUrl?: string;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Platform types
|
|
353
|
+
*/
|
|
354
|
+
declare enum BillingPlatform {
|
|
355
|
+
WEB = "web",
|
|
356
|
+
NATIVE = "native",
|
|
357
|
+
UNKNOWN = "unknown"
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* BillingService - Unified billing service for web and native platforms
|
|
361
|
+
*
|
|
362
|
+
* Automatically detects the platform and routes to the appropriate payment method:
|
|
363
|
+
* - Web: Stripe Embedded Checkout (Stripe Elements)
|
|
364
|
+
* - Native: In-App Purchases via NativeBridge
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```typescript
|
|
368
|
+
* import { BillingService } from '@hyve-sdk/js';
|
|
369
|
+
*
|
|
370
|
+
* // Initialize billing
|
|
371
|
+
* const billing = new BillingService({
|
|
372
|
+
* stripePublishableKey: 'pk_test_...',
|
|
373
|
+
* checkoutUrl: 'https://your-api.com',
|
|
374
|
+
* gameId: 123,
|
|
375
|
+
* userId: 'user_456'
|
|
376
|
+
* });
|
|
377
|
+
*
|
|
378
|
+
* await billing.initialize();
|
|
379
|
+
*
|
|
380
|
+
* // Check which platform we're on
|
|
381
|
+
* const platform = billing.getPlatform();
|
|
382
|
+
* console.log('Running on:', platform);
|
|
383
|
+
*
|
|
384
|
+
* // Get available products
|
|
385
|
+
* const products = await billing.getProducts();
|
|
386
|
+
*
|
|
387
|
+
* // For web: Ensure you have a container element in your HTML
|
|
388
|
+
* // <div id="stripe-checkout-element"></div>
|
|
389
|
+
*
|
|
390
|
+
* // Purchase a product (web will mount Stripe checkout form)
|
|
391
|
+
* const result = await billing.purchase('price_1234', {
|
|
392
|
+
* elementId: 'stripe-checkout-element' // optional, defaults to 'stripe-checkout-element'
|
|
393
|
+
* });
|
|
394
|
+
*
|
|
395
|
+
* // Set up callbacks for purchase events
|
|
396
|
+
* billing.onPurchaseComplete((result) => {
|
|
397
|
+
* console.log('Purchase successful!', result);
|
|
398
|
+
* });
|
|
399
|
+
*
|
|
400
|
+
* billing.onPurchaseError((result) => {
|
|
401
|
+
* console.error('Purchase failed:', result.error);
|
|
402
|
+
* });
|
|
403
|
+
*
|
|
404
|
+
* // Clean up when done
|
|
405
|
+
* billing.dispose();
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
declare class BillingService {
|
|
409
|
+
private config;
|
|
410
|
+
private platform;
|
|
411
|
+
private isInitialized;
|
|
412
|
+
private nativeAvailable;
|
|
413
|
+
private products;
|
|
414
|
+
private stripe;
|
|
415
|
+
private checkoutElement;
|
|
416
|
+
private onPurchaseCompleteCallback?;
|
|
417
|
+
private onPurchaseErrorCallback?;
|
|
418
|
+
private onLogCallback?;
|
|
419
|
+
constructor(config: BillingConfig);
|
|
420
|
+
/**
|
|
421
|
+
* Register a callback to receive all internal logs
|
|
422
|
+
* Useful for displaying logs in a UI
|
|
423
|
+
*/
|
|
424
|
+
onLog(callback: (level: "info" | "warn" | "error", message: string, data?: any) => void): void;
|
|
425
|
+
/**
|
|
426
|
+
* Internal logging method that calls both logger and custom callback
|
|
427
|
+
*/
|
|
428
|
+
private log;
|
|
429
|
+
/**
|
|
430
|
+
* Detects if running on web or native platform
|
|
431
|
+
*/
|
|
432
|
+
private detectPlatform;
|
|
433
|
+
/**
|
|
434
|
+
* Get the current platform
|
|
435
|
+
*/
|
|
436
|
+
getPlatform(): BillingPlatform;
|
|
437
|
+
/**
|
|
438
|
+
* Initialize the billing service
|
|
439
|
+
* Must be called before using any other methods
|
|
440
|
+
*/
|
|
441
|
+
initialize(): Promise<boolean>;
|
|
442
|
+
/**
|
|
443
|
+
* Initialize native billing
|
|
444
|
+
*/
|
|
445
|
+
private initializeNative;
|
|
446
|
+
/**
|
|
447
|
+
* Initialize web billing (Stripe)
|
|
448
|
+
*/
|
|
449
|
+
private initializeWeb;
|
|
450
|
+
/**
|
|
451
|
+
* Load Stripe.js script dynamically
|
|
452
|
+
*/
|
|
453
|
+
private loadStripeScript;
|
|
454
|
+
/**
|
|
455
|
+
* Check if billing is available
|
|
456
|
+
*/
|
|
457
|
+
isAvailable(): boolean;
|
|
458
|
+
/**
|
|
459
|
+
* Get available products
|
|
460
|
+
*/
|
|
461
|
+
getProducts(): Promise<BillingProduct[]>;
|
|
462
|
+
/**
|
|
463
|
+
* Get products from native IAP
|
|
464
|
+
*/
|
|
465
|
+
private getProductsNative;
|
|
466
|
+
/**
|
|
467
|
+
* Get products from web API (Stripe)
|
|
468
|
+
*/
|
|
469
|
+
private getProductsWeb;
|
|
470
|
+
/**
|
|
471
|
+
* Purchase a product
|
|
472
|
+
* @param productId - The product ID (priceId for web/Stripe, productId for native)
|
|
473
|
+
* @param options - Optional purchase options
|
|
474
|
+
* @param options.elementId - For web: DOM element ID to mount Stripe checkout (default: 'stripe-checkout-element')
|
|
475
|
+
*/
|
|
476
|
+
purchase(productId: string, options?: {
|
|
477
|
+
elementId?: string;
|
|
478
|
+
}): Promise<PurchaseResult>;
|
|
479
|
+
/**
|
|
480
|
+
* Purchase via native IAP
|
|
481
|
+
*/
|
|
482
|
+
private purchaseNative;
|
|
483
|
+
/**
|
|
484
|
+
* Purchase via web (Stripe)
|
|
485
|
+
* @param productId - The priceId (Stripe price ID) for web purchases
|
|
486
|
+
* @param elementId - Optional DOM element ID to mount the checkout form (default: 'stripe-checkout-element')
|
|
487
|
+
*/
|
|
488
|
+
private purchaseWeb;
|
|
489
|
+
/**
|
|
490
|
+
* Mount Stripe embedded checkout element to the DOM
|
|
491
|
+
* @param clientSecret - The client secret from the checkout session
|
|
492
|
+
* @param elementId - The ID of the DOM element to mount to
|
|
493
|
+
*/
|
|
494
|
+
private mountCheckoutElement;
|
|
495
|
+
/**
|
|
496
|
+
* Set up event listeners for checkout completion
|
|
497
|
+
*/
|
|
498
|
+
private setupCheckoutEventListeners;
|
|
499
|
+
/**
|
|
500
|
+
* Unmount and destroy the checkout element
|
|
501
|
+
*/
|
|
502
|
+
unmountCheckoutElement(): void;
|
|
503
|
+
/**
|
|
504
|
+
* Set callback for successful purchases
|
|
505
|
+
*/
|
|
506
|
+
onPurchaseComplete(callback: (result: PurchaseResult) => void): void;
|
|
507
|
+
/**
|
|
508
|
+
* Set callback for failed purchases
|
|
509
|
+
*/
|
|
510
|
+
onPurchaseError(callback: (result: PurchaseResult) => void): void;
|
|
511
|
+
/**
|
|
512
|
+
* Clean up resources
|
|
513
|
+
*/
|
|
514
|
+
dispose(): void;
|
|
515
|
+
}
|
|
516
|
+
|
|
306
517
|
/**
|
|
307
518
|
* Logger utility for the Hyve SDK
|
|
308
519
|
* Automatically enabled in development (NODE_ENV !== 'production')
|
|
@@ -576,4 +787,4 @@ declare class NativeBridge {
|
|
|
576
787
|
*/
|
|
577
788
|
declare function generateUUID(): string;
|
|
578
789
|
|
|
579
|
-
export { type AdConfig$1 as AdConfig, type AdResult, type AdType, AdsService, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, Logger, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, handleVerifyMessage, isDomainAllowed, logger, parseUrlParams, validateSignature, verifyAuthentication, verifyHyveToken };
|
|
790
|
+
export { type AdConfig$1 as AdConfig, type AdResult, type AdType, AdsService, type BillingConfig, BillingPlatform, type BillingProduct, BillingService, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, Logger, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, type PurchaseResult, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, handleVerifyMessage, isDomainAllowed, logger, parseUrlParams, validateSignature, verifyAuthentication, verifyHyveToken };
|
package/dist/index.d.ts
CHANGED
|
@@ -303,6 +303,217 @@ declare class HyveClient {
|
|
|
303
303
|
areAdsReady(): boolean;
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
+
/**
|
|
307
|
+
* Product information from the native app or server
|
|
308
|
+
*/
|
|
309
|
+
interface BillingProduct {
|
|
310
|
+
productId: string;
|
|
311
|
+
title: string;
|
|
312
|
+
description: string;
|
|
313
|
+
price: number;
|
|
314
|
+
localizedPrice: string;
|
|
315
|
+
currency: string;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Purchase result
|
|
319
|
+
*/
|
|
320
|
+
interface PurchaseResult {
|
|
321
|
+
success: boolean;
|
|
322
|
+
productId: string;
|
|
323
|
+
transactionId?: string;
|
|
324
|
+
transactionDate?: string;
|
|
325
|
+
error?: {
|
|
326
|
+
code: string;
|
|
327
|
+
message: string;
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Billing configuration
|
|
332
|
+
*/
|
|
333
|
+
interface BillingConfig {
|
|
334
|
+
/**
|
|
335
|
+
* Stripe publishable key (required for web)
|
|
336
|
+
*/
|
|
337
|
+
stripePublishableKey?: string;
|
|
338
|
+
/**
|
|
339
|
+
* Game ID for native purchases
|
|
340
|
+
*/
|
|
341
|
+
gameId?: number;
|
|
342
|
+
/**
|
|
343
|
+
* User ID for purchases
|
|
344
|
+
*/
|
|
345
|
+
userId?: string;
|
|
346
|
+
/**
|
|
347
|
+
* Checkout URL for API calls
|
|
348
|
+
*/
|
|
349
|
+
checkoutUrl?: string;
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Platform types
|
|
353
|
+
*/
|
|
354
|
+
declare enum BillingPlatform {
|
|
355
|
+
WEB = "web",
|
|
356
|
+
NATIVE = "native",
|
|
357
|
+
UNKNOWN = "unknown"
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* BillingService - Unified billing service for web and native platforms
|
|
361
|
+
*
|
|
362
|
+
* Automatically detects the platform and routes to the appropriate payment method:
|
|
363
|
+
* - Web: Stripe Embedded Checkout (Stripe Elements)
|
|
364
|
+
* - Native: In-App Purchases via NativeBridge
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```typescript
|
|
368
|
+
* import { BillingService } from '@hyve-sdk/js';
|
|
369
|
+
*
|
|
370
|
+
* // Initialize billing
|
|
371
|
+
* const billing = new BillingService({
|
|
372
|
+
* stripePublishableKey: 'pk_test_...',
|
|
373
|
+
* checkoutUrl: 'https://your-api.com',
|
|
374
|
+
* gameId: 123,
|
|
375
|
+
* userId: 'user_456'
|
|
376
|
+
* });
|
|
377
|
+
*
|
|
378
|
+
* await billing.initialize();
|
|
379
|
+
*
|
|
380
|
+
* // Check which platform we're on
|
|
381
|
+
* const platform = billing.getPlatform();
|
|
382
|
+
* console.log('Running on:', platform);
|
|
383
|
+
*
|
|
384
|
+
* // Get available products
|
|
385
|
+
* const products = await billing.getProducts();
|
|
386
|
+
*
|
|
387
|
+
* // For web: Ensure you have a container element in your HTML
|
|
388
|
+
* // <div id="stripe-checkout-element"></div>
|
|
389
|
+
*
|
|
390
|
+
* // Purchase a product (web will mount Stripe checkout form)
|
|
391
|
+
* const result = await billing.purchase('price_1234', {
|
|
392
|
+
* elementId: 'stripe-checkout-element' // optional, defaults to 'stripe-checkout-element'
|
|
393
|
+
* });
|
|
394
|
+
*
|
|
395
|
+
* // Set up callbacks for purchase events
|
|
396
|
+
* billing.onPurchaseComplete((result) => {
|
|
397
|
+
* console.log('Purchase successful!', result);
|
|
398
|
+
* });
|
|
399
|
+
*
|
|
400
|
+
* billing.onPurchaseError((result) => {
|
|
401
|
+
* console.error('Purchase failed:', result.error);
|
|
402
|
+
* });
|
|
403
|
+
*
|
|
404
|
+
* // Clean up when done
|
|
405
|
+
* billing.dispose();
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
declare class BillingService {
|
|
409
|
+
private config;
|
|
410
|
+
private platform;
|
|
411
|
+
private isInitialized;
|
|
412
|
+
private nativeAvailable;
|
|
413
|
+
private products;
|
|
414
|
+
private stripe;
|
|
415
|
+
private checkoutElement;
|
|
416
|
+
private onPurchaseCompleteCallback?;
|
|
417
|
+
private onPurchaseErrorCallback?;
|
|
418
|
+
private onLogCallback?;
|
|
419
|
+
constructor(config: BillingConfig);
|
|
420
|
+
/**
|
|
421
|
+
* Register a callback to receive all internal logs
|
|
422
|
+
* Useful for displaying logs in a UI
|
|
423
|
+
*/
|
|
424
|
+
onLog(callback: (level: "info" | "warn" | "error", message: string, data?: any) => void): void;
|
|
425
|
+
/**
|
|
426
|
+
* Internal logging method that calls both logger and custom callback
|
|
427
|
+
*/
|
|
428
|
+
private log;
|
|
429
|
+
/**
|
|
430
|
+
* Detects if running on web or native platform
|
|
431
|
+
*/
|
|
432
|
+
private detectPlatform;
|
|
433
|
+
/**
|
|
434
|
+
* Get the current platform
|
|
435
|
+
*/
|
|
436
|
+
getPlatform(): BillingPlatform;
|
|
437
|
+
/**
|
|
438
|
+
* Initialize the billing service
|
|
439
|
+
* Must be called before using any other methods
|
|
440
|
+
*/
|
|
441
|
+
initialize(): Promise<boolean>;
|
|
442
|
+
/**
|
|
443
|
+
* Initialize native billing
|
|
444
|
+
*/
|
|
445
|
+
private initializeNative;
|
|
446
|
+
/**
|
|
447
|
+
* Initialize web billing (Stripe)
|
|
448
|
+
*/
|
|
449
|
+
private initializeWeb;
|
|
450
|
+
/**
|
|
451
|
+
* Load Stripe.js script dynamically
|
|
452
|
+
*/
|
|
453
|
+
private loadStripeScript;
|
|
454
|
+
/**
|
|
455
|
+
* Check if billing is available
|
|
456
|
+
*/
|
|
457
|
+
isAvailable(): boolean;
|
|
458
|
+
/**
|
|
459
|
+
* Get available products
|
|
460
|
+
*/
|
|
461
|
+
getProducts(): Promise<BillingProduct[]>;
|
|
462
|
+
/**
|
|
463
|
+
* Get products from native IAP
|
|
464
|
+
*/
|
|
465
|
+
private getProductsNative;
|
|
466
|
+
/**
|
|
467
|
+
* Get products from web API (Stripe)
|
|
468
|
+
*/
|
|
469
|
+
private getProductsWeb;
|
|
470
|
+
/**
|
|
471
|
+
* Purchase a product
|
|
472
|
+
* @param productId - The product ID (priceId for web/Stripe, productId for native)
|
|
473
|
+
* @param options - Optional purchase options
|
|
474
|
+
* @param options.elementId - For web: DOM element ID to mount Stripe checkout (default: 'stripe-checkout-element')
|
|
475
|
+
*/
|
|
476
|
+
purchase(productId: string, options?: {
|
|
477
|
+
elementId?: string;
|
|
478
|
+
}): Promise<PurchaseResult>;
|
|
479
|
+
/**
|
|
480
|
+
* Purchase via native IAP
|
|
481
|
+
*/
|
|
482
|
+
private purchaseNative;
|
|
483
|
+
/**
|
|
484
|
+
* Purchase via web (Stripe)
|
|
485
|
+
* @param productId - The priceId (Stripe price ID) for web purchases
|
|
486
|
+
* @param elementId - Optional DOM element ID to mount the checkout form (default: 'stripe-checkout-element')
|
|
487
|
+
*/
|
|
488
|
+
private purchaseWeb;
|
|
489
|
+
/**
|
|
490
|
+
* Mount Stripe embedded checkout element to the DOM
|
|
491
|
+
* @param clientSecret - The client secret from the checkout session
|
|
492
|
+
* @param elementId - The ID of the DOM element to mount to
|
|
493
|
+
*/
|
|
494
|
+
private mountCheckoutElement;
|
|
495
|
+
/**
|
|
496
|
+
* Set up event listeners for checkout completion
|
|
497
|
+
*/
|
|
498
|
+
private setupCheckoutEventListeners;
|
|
499
|
+
/**
|
|
500
|
+
* Unmount and destroy the checkout element
|
|
501
|
+
*/
|
|
502
|
+
unmountCheckoutElement(): void;
|
|
503
|
+
/**
|
|
504
|
+
* Set callback for successful purchases
|
|
505
|
+
*/
|
|
506
|
+
onPurchaseComplete(callback: (result: PurchaseResult) => void): void;
|
|
507
|
+
/**
|
|
508
|
+
* Set callback for failed purchases
|
|
509
|
+
*/
|
|
510
|
+
onPurchaseError(callback: (result: PurchaseResult) => void): void;
|
|
511
|
+
/**
|
|
512
|
+
* Clean up resources
|
|
513
|
+
*/
|
|
514
|
+
dispose(): void;
|
|
515
|
+
}
|
|
516
|
+
|
|
306
517
|
/**
|
|
307
518
|
* Logger utility for the Hyve SDK
|
|
308
519
|
* Automatically enabled in development (NODE_ENV !== 'production')
|
|
@@ -576,4 +787,4 @@ declare class NativeBridge {
|
|
|
576
787
|
*/
|
|
577
788
|
declare function generateUUID(): string;
|
|
578
789
|
|
|
579
|
-
export { type AdConfig$1 as AdConfig, type AdResult, type AdType, AdsService, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, Logger, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, handleVerifyMessage, isDomainAllowed, logger, parseUrlParams, validateSignature, verifyAuthentication, verifyHyveToken };
|
|
790
|
+
export { type AdConfig$1 as AdConfig, type AdResult, type AdType, AdsService, type BillingConfig, BillingPlatform, type BillingProduct, BillingService, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, Logger, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, type PurchaseResult, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, handleVerifyMessage, isDomainAllowed, logger, parseUrlParams, validateSignature, verifyAuthentication, verifyHyveToken };
|