@24i/bigscreen-sdk 1.0.54-alpha.2819 → 1.0.54-alpha.2822

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/bigscreen-sdk",
3
- "version": "1.0.54-alpha.2819",
3
+ "version": "1.0.54-alpha.2822",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -42,7 +42,7 @@
42
42
  "@24i/appstage-shared-events-manager": "1.0.11",
43
43
  "@24i/appstage-shared-perf-utils": "1.0.11",
44
44
  "@24i/bigscreen-players-engine-base": "4.1.0",
45
- "@24i/smartapps-datalayer": "3.0.22",
45
+ "@24i/smartapps-datalayer": "3.0.23",
46
46
  "@sentry/browser": "7.35.0",
47
47
  "@sentry/types": "7.35.0",
48
48
  "csstype": "^3.1.3",
@@ -4,6 +4,7 @@ import {
4
4
  ScreenSaverStatus,
5
5
  VolumeRange,
6
6
  IAPSuccessPayload,
7
+ IAPPurchaseProductData,
7
8
  } from '@24i/bigscreen-sdk/driver-base';
8
9
  import { IJavaScriptBridge, DeviceInfo } from './types';
9
10
  import { getFirmware } from './formatUserAgent';
@@ -248,7 +249,7 @@ export class DeviceAndroidTV extends DeviceBase {
248
249
  }
249
250
 
250
251
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
251
- async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
252
+ async purchaseProduct(data: IAPPurchaseProductData): Promise<IAPSuccessPayload> {
252
253
  // not supported
253
254
  throw new Error('Not supported');
254
255
  }
@@ -15,7 +15,7 @@ import { inRange } from './utils';
15
15
  import { ErrorTemplate } from './errors';
16
16
  import { bindPreventDefaultEvent } from './bindPreventDefaultEvent';
17
17
  import { LEFT, RIGHT, UP, DOWN, ENTER, BACK, ESC } from './KeyMap';
18
- import { IAPSuccessPayload } from './types/InAppPurchase';
18
+ import { IAPPurchaseProductData, IAPSuccessPayload } from './types/InAppPurchase';
19
19
 
20
20
  export const STORAGE_UUID_KEY = '__UUID__';
21
21
 
@@ -180,7 +180,7 @@ export abstract class DeviceBase<
180
180
 
181
181
  abstract getMacAddress(): Promise<string>;
182
182
 
183
- abstract purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload>;
183
+ abstract purchaseProduct(data: IAPPurchaseProductData): Promise<IAPSuccessPayload>;
184
184
 
185
185
  // MARK: Private functions
186
186
 
@@ -1,7 +1,7 @@
1
1
  import { DeviceBase as AbstractDeviceBase } from '../DeviceBase';
2
2
  import { ScreenSaverStatus } from '../types/ScreenSaverStatus';
3
3
  import { ConnectionType } from '../ConnectionType';
4
- import { IAPSuccessPayload } from '../types/InAppPurchase';
4
+ import { IAPPurchaseProductData, IAPSuccessPayload } from '../types/InAppPurchase';
5
5
 
6
6
  export class DeviceBase extends AbstractDeviceBase {
7
7
  volume = 0;
@@ -111,7 +111,7 @@ export class DeviceBase extends AbstractDeviceBase {
111
111
  }
112
112
 
113
113
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
114
- async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
114
+ async purchaseProduct(data: IAPPurchaseProductData): Promise<IAPSuccessPayload> {
115
115
  // not supported
116
116
  throw new Error('Not supported');
117
117
  }
@@ -6,7 +6,7 @@ export type { ScreenSize } from './ScreenSize';
6
6
  export type { KeycodeKeyMap } from './types/KeycodeKeyMap';
7
7
  export type { DeviceEventMap } from './types/DeviceEvent';
8
8
  export type {
9
- IAPSuccessPayload, IAPErrorPayload, IAPPromiseResolve, IAPPromiseReject,
9
+ IAPSuccessPayload, IAPErrorPayload, IAPPromiseResolve, IAPPromiseReject, IAPPurchaseProductData,
10
10
  } from './types/InAppPurchase';
11
11
  export type { ScreenSaverStatus } from './types/ScreenSaverStatus';
12
12
  export type { ExitOptions } from './types/ExitOptions';
@@ -1,3 +1,4 @@
1
+ import { Product } from '@24i/smartapps-datalayer/models';
1
2
  import { VendorType } from '@24i/smartapps-datalayer/src/api';
2
3
 
3
4
  export type IAPSuccessPayload = {
@@ -5,6 +6,13 @@ export type IAPSuccessPayload = {
5
6
  receiptPayload: object
6
7
  };
7
8
 
9
+ export type IAPPurchaseProductData = {
10
+ sku: string,
11
+ serviceId?: string,
12
+ product?: Product,
13
+ appId?: string,
14
+ };
15
+
8
16
  export type IAPErrorPayload = { message: string };
9
17
 
10
18
  export type IAPPromiseResolve = (value: IAPSuccessPayload | PromiseLike<IAPSuccessPayload>) => void;
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  DeviceBase, ConnectionType, ScreenSaverStatus, VolumeRange,
3
3
  IAPSuccessPayload,
4
+ IAPPurchaseProductData,
4
5
  } from '@24i/bigscreen-sdk/driver-base';
5
6
  import { runAsync } from '@24i/bigscreen-sdk/utils/timers';
6
7
  import { generateUuid } from '@24i/bigscreen-sdk/utils';
@@ -182,7 +183,7 @@ export class DeviceBrowser extends DeviceBase {
182
183
  }
183
184
 
184
185
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
185
- async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
186
+ async purchaseProduct(data: IAPPurchaseProductData): Promise<IAPSuccessPayload> {
186
187
  // not supported
187
188
  throw new Error('Not supported');
188
189
  }
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  DeviceBase,
3
+ IAPPurchaseProductData,
3
4
  IAPSuccessPayload,
4
5
  ScreenSaverStatus,
5
6
  VolumeRange,
@@ -248,7 +249,7 @@ export class DeviceEntone extends DeviceBase {
248
249
  }
249
250
 
250
251
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
251
- async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
252
+ async purchaseProduct(data: IAPPurchaseProductData): Promise<IAPSuccessPayload> {
252
253
  // not supported
253
254
  throw new Error('Not supported');
254
255
  }
@@ -5,6 +5,7 @@ import {
5
5
  } from '@24i/bigscreen-sdk/driver-androidtv';
6
6
  import {
7
7
  IAPSuccessPayload, IAPPromiseReject, IAPPromiseResolve,
8
+ IAPPurchaseProductData,
8
9
  } from '@24i/bigscreen-sdk/driver-base';
9
10
  import { VendorType } from '@24i/smartapps-datalayer/api';
10
11
  import { Receipt } from './types';
@@ -69,12 +70,11 @@ export class DeviceFireTV extends DeviceAndroidTV {
69
70
  document.removeEventListener('iapError', this.onIAPError(resolve, reject));
70
71
  }
71
72
 
72
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
73
- async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
73
+ async purchaseProduct(data: IAPPurchaseProductData): Promise<IAPSuccessPayload> {
74
74
  return new Promise((resolve, reject) => {
75
75
  document.addEventListener('iapSuccess', this.onIAPSuccess(resolve, reject));
76
76
  document.addEventListener('iapError', this.onIAPError(resolve, reject));
77
- window.JavaScriptBridge.bridgeReceiptAmazonIAPValidation(sku);
77
+ window.JavaScriptBridge.bridgeReceiptAmazonIAPValidation(data.sku);
78
78
  });
79
79
  }
80
80
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  DeviceBase, ConnectionType, ScreenSaverStatus, loadObject, VolumeRange,
3
3
  IAPSuccessPayload,
4
+ IAPPurchaseProductData,
4
5
  } from '@24i/bigscreen-sdk/driver-base';
5
6
  import { generateUuid } from '@24i/bigscreen-sdk/utils';
6
7
  import { getKeyMap } from './keymap';
@@ -325,7 +326,7 @@ export class DeviceHbbTV extends DeviceBase {
325
326
  }
326
327
 
327
328
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
328
- async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
329
+ async purchaseProduct(data: IAPPurchaseProductData): Promise<IAPSuccessPayload> {
329
330
  // not supported
330
331
  throw new Error('Not supported');
331
332
  }
@@ -4,6 +4,7 @@ import {
4
4
  ScreenSaverStatus,
5
5
  VolumeRange,
6
6
  IAPSuccessPayload,
7
+ IAPPurchaseProductData,
7
8
  } from '@24i/bigscreen-sdk/driver-base';
8
9
  import { generateUuid } from '@24i/bigscreen-sdk/utils';
9
10
  import { getKeyMap } from './keymap';
@@ -283,7 +284,7 @@ export class DeviceKreaTV extends DeviceBase {
283
284
  }
284
285
 
285
286
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
286
- async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
287
+ async purchaseProduct(data: IAPPurchaseProductData): Promise<IAPSuccessPayload> {
287
288
  // not supported
288
289
  throw new Error('Not supported');
289
290
  }
@@ -4,6 +4,7 @@ import {
4
4
  ScreenSaverStatus,
5
5
  VolumeRange,
6
6
  IAPSuccessPayload,
7
+ IAPPurchaseProductData,
7
8
  } from '@24i/bigscreen-sdk/driver-base';
8
9
  import { generateUuid } from '@24i/bigscreen-sdk/utils';
9
10
  import { getDeviceInfo, getFirmware, getPlatformInfo } from './formatUserAgent';
@@ -156,7 +157,7 @@ export class DeviceSaphi extends DeviceBase {
156
157
  }
157
158
 
158
159
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
159
- async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
160
+ async purchaseProduct(data: IAPPurchaseProductData): Promise<IAPSuccessPayload> {
160
161
  // not supported
161
162
  throw new Error('Not supported');
162
163
  }
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  DeviceBase, ConnectionType, ScreenSaverStatus, VolumeRange,
3
3
  IAPSuccessPayload,
4
+ IAPPurchaseProductData,
4
5
  } from '@24i/bigscreen-sdk/driver-base';
5
6
  import { runAsync } from '@24i/bigscreen-sdk/utils/timers';
6
7
  import { ipify } from '@24i/bigscreen-sdk/ipify';
@@ -355,19 +356,19 @@ export class DeviceSmartCast extends DeviceBase {
355
356
  if (!isLinked) await this.API!.Account.startTVLink();
356
357
  }
357
358
 
358
- async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
359
+ async purchaseProduct({ sku, serviceId }: IAPPurchaseProductData): Promise<IAPSuccessPayload> {
359
360
  await this.checkAndLinkTv();
360
361
  await this.API!.Account.getPlans({ includeBundlePlans: true });
361
362
  const purchaseResult = await this.API!.Account.startSVODPurchase(
362
363
  sku, serviceId ?? '',
363
364
  );
364
- const data: PurchaseData = {
365
+ const receiptPayload: PurchaseData = {
365
366
  customerId: purchaseResult.data.customerId,
366
367
  partnerAccountId: purchaseResult.data.partnerAccountId,
367
368
  planCode: purchaseResult.data.planCode,
368
369
  addOnCodes: purchaseResult.data.addOnCodes,
369
370
  subscriptionId: purchaseResult.data.subscriptionId,
370
371
  };
371
- return { platform: VendorType.VIZIO, receiptPayload: data };
372
+ return { platform: VendorType.VIZIO, receiptPayload };
372
373
  }
373
374
  }
@@ -5,20 +5,26 @@ import {
5
5
  VolumeRange,
6
6
  ExitOptions,
7
7
  IAPSuccessPayload,
8
+ IAPPurchaseProductData,
8
9
  } from '@24i/bigscreen-sdk/driver-base';
9
10
  import { Storage } from '@24i/bigscreen-sdk/storage';
10
11
  import { runAsync } from '@24i/bigscreen-sdk/utils/timers';
11
- import { TizenKeys } from './TizenKeys';
12
+ import { VendorType } from '@24i/smartapps-datalayer/api';
12
13
  import {
13
- VENDOR,
14
+ type Webapis,
15
+ BillingBuyData,
14
16
  NetworkState,
15
17
  NetworkActiveConnectionType,
16
18
  AppCommonScreenSaverState,
19
+ } from './IWebapis';
20
+ import { Tizen, Application } from './ITizen';
21
+ import { TizenKeys } from './TizenKeys';
22
+ import {
23
+ VENDOR,
17
24
  } from './constants';
18
- import { IWebapis, ITizen, TizenApplication } from './types';
19
25
 
20
- declare const webapis: IWebapis;
21
- declare const tizen: ITizen;
26
+ declare const webapis: Webapis;
27
+ declare const tizen: Tizen;
22
28
 
23
29
  const isNetworkConnected = (state: NetworkState) => {
24
30
  switch (state) {
@@ -37,7 +43,7 @@ const isNetworkConnected = (state: NetworkState) => {
37
43
  export class DeviceTizen extends DeviceBase {
38
44
  // MARK: Properties
39
45
 
40
- application: TizenApplication = tizen.application.getCurrentApplication();
46
+ application: Application = tizen.application.getCurrentApplication();
41
47
 
42
48
  keys: TizenKeys = new TizenKeys();
43
49
 
@@ -271,7 +277,7 @@ export class DeviceTizen extends DeviceBase {
271
277
  ? AppCommonScreenSaverState.SCREEN_SAVER_ON
272
278
  : AppCommonScreenSaverState.SCREEN_SAVER_OFF;
273
279
  return new Promise((resolve) => {
274
- webapis.appCommon.setScreenSaver(
280
+ webapis.appcommon.setScreenSaver(
275
281
  status,
276
282
  () => {
277
283
  this.screenSaverStatus = status;
@@ -321,9 +327,39 @@ export class DeviceTizen extends DeviceBase {
321
327
  return webapis.network.getMac();
322
328
  }
323
329
 
324
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
325
- async purchaseProduct(sku: string, serviceId?: string): Promise<IAPSuccessPayload> {
326
- // not supported
327
- throw new Error('Not supported');
330
+ async purchaseProduct({
331
+ sku, product, appId,
332
+ }: IAPPurchaseProductData): Promise<IAPSuccessPayload> {
333
+ return new Promise((resolve, reject) => {
334
+ if (!product || !appId) reject(new Error('Missing product or appId'));
335
+ const paymentDetails = {
336
+ OrderItemID: sku,
337
+ OrderTitle: product!.title,
338
+ OrderTotal: product!.price![0].amount,
339
+ OrderCurrencyID: product!.price![0].currency,
340
+ OrderCustomID: webapis.sso.getLoginUid(),
341
+ };
342
+ const onSuccess = (data: BillingBuyData) => {
343
+ try {
344
+ if (data.payResult !== 'SUCCESS') throw new Error('Purchase failed');
345
+ const countryCode = webapis.productinfo.getSystemConfig(
346
+ webapis.productinfo.ProductInfoConfigKey.CONFIG_KEY_SERVICE_COUNTRY,
347
+ );
348
+ const detail = JSON.parse(data.payDetail);
349
+ resolve({
350
+ platform: VendorType.SAMSUNG,
351
+ receiptPayload: {
352
+ appId,
353
+ samsungInvoiceId: detail.InvoiceID,
354
+ samsungCustomId: paymentDetails.OrderCustomID,
355
+ countryCode,
356
+ },
357
+ });
358
+ } catch (e) {
359
+ reject(e);
360
+ }
361
+ };
362
+ webapis.billing.buyItem(appId!, 'DEV', JSON.stringify(paymentDetails), onSuccess);
363
+ });
328
364
  }
329
365
  }