@24i/bigscreen-sdk 1.0.54-alpha.2828 → 1.0.54-alpha.2835
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 +2 -2
- package/packages/driver-androidtv/src/DeviceAndroidTV.ts +6 -0
- package/packages/driver-base/src/DeviceBase.ts +12 -1
- package/packages/driver-base/src/__mocks__/DeviceBase.ts +6 -0
- package/packages/driver-base/src/types/InAppPurchase.ts +10 -5
- package/packages/driver-browser/src/DeviceBrowser.ts +6 -0
- package/packages/driver-entone/src/DeviceEntone.ts +6 -0
- package/packages/driver-firetv/src/DeviceFireTV.ts +12 -1
- package/packages/driver-hbbtv/src/DeviceHbbTV.ts +6 -0
- package/packages/driver-kreatv/src/DeviceKreaTV.ts +6 -0
- package/packages/driver-saphi/src/DeviceSaphi.ts +6 -0
- package/packages/driver-smartcast/src/DeviceSmartCast.ts +21 -1
- package/packages/driver-smartcast/src/__mocks__/api.ts +10 -0
- package/packages/driver-smartcast/src/types.ts +9 -0
- package/packages/driver-tizen/src/DeviceTizen.ts +53 -1
- package/packages/driver-vidaa/src/DeviceVidaa.ts +6 -0
- package/packages/driver-webos/src/DeviceWebos.ts +6 -0
- package/packages/driver-xbox/src/DeviceXbox.ts +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@24i/bigscreen-sdk",
|
|
3
|
-
"version": "1.0.54-alpha.
|
|
3
|
+
"version": "1.0.54-alpha.2835",
|
|
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.
|
|
45
|
+
"@24i/smartapps-datalayer": "3.0.24",
|
|
46
46
|
"@sentry/browser": "7.35.0",
|
|
47
47
|
"@sentry/types": "7.35.0",
|
|
48
48
|
"csstype": "^3.1.3",
|
|
@@ -253,4 +253,10 @@ export class DeviceAndroidTV extends DeviceBase {
|
|
|
253
253
|
// not supported
|
|
254
254
|
throw new Error('Not supported');
|
|
255
255
|
}
|
|
256
|
+
|
|
257
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
258
|
+
async cancelSubscription(data: IAPPurchaseProductData): Promise<void> {
|
|
259
|
+
// not supported
|
|
260
|
+
throw new Error('Not supported');
|
|
261
|
+
}
|
|
256
262
|
}
|
|
@@ -10,12 +10,16 @@ import { KeycodeKeyMap } from './types/KeycodeKeyMap';
|
|
|
10
10
|
import { DeviceEventMap } from './types/DeviceEvent';
|
|
11
11
|
import { AdInfo } from './types/AdInfo';
|
|
12
12
|
import { ScreenSaverStatus } from './types/ScreenSaverStatus';
|
|
13
|
+
import {
|
|
14
|
+
SubscriptionFeaturesConfiguration,
|
|
15
|
+
IAPPurchaseProductData,
|
|
16
|
+
IAPSuccessPayload,
|
|
17
|
+
} from './types/InAppPurchase';
|
|
13
18
|
import { ExitOptions } from './types/ExitOptions';
|
|
14
19
|
import { inRange } from './utils';
|
|
15
20
|
import { ErrorTemplate } from './errors';
|
|
16
21
|
import { bindPreventDefaultEvent } from './bindPreventDefaultEvent';
|
|
17
22
|
import { LEFT, RIGHT, UP, DOWN, ENTER, BACK, ESC } from './KeyMap';
|
|
18
|
-
import { IAPPurchaseProductData, IAPSuccessPayload } from './types/InAppPurchase';
|
|
19
23
|
|
|
20
24
|
export const STORAGE_UUID_KEY = '__UUID__';
|
|
21
25
|
|
|
@@ -57,6 +61,11 @@ export abstract class DeviceBase<
|
|
|
57
61
|
|
|
58
62
|
isOffline: boolean = false;
|
|
59
63
|
|
|
64
|
+
subscriptionFeaturesConfiguration: SubscriptionFeaturesConfiguration = {
|
|
65
|
+
purchase: false,
|
|
66
|
+
management: false,
|
|
67
|
+
};
|
|
68
|
+
|
|
60
69
|
// MARK: Initialization
|
|
61
70
|
|
|
62
71
|
/**
|
|
@@ -182,6 +191,8 @@ export abstract class DeviceBase<
|
|
|
182
191
|
|
|
183
192
|
abstract purchaseProduct(data: IAPPurchaseProductData): Promise<IAPSuccessPayload>;
|
|
184
193
|
|
|
194
|
+
abstract cancelSubscription(data: IAPPurchaseProductData): Promise<void>;
|
|
195
|
+
|
|
185
196
|
// MARK: Private functions
|
|
186
197
|
|
|
187
198
|
private bindPreventDefaultEvents(rootElement: HTMLElement) {
|
|
@@ -115,4 +115,10 @@ export class DeviceBase extends AbstractDeviceBase {
|
|
|
115
115
|
// not supported
|
|
116
116
|
throw new Error('Not supported');
|
|
117
117
|
}
|
|
118
|
+
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
120
|
+
async cancelSubscription(data: IAPPurchaseProductData): Promise<void> {
|
|
121
|
+
// not supported
|
|
122
|
+
throw new Error('Not supported');
|
|
123
|
+
}
|
|
118
124
|
}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { Product } from '@24i/smartapps-datalayer/models';
|
|
2
2
|
import { VendorType } from '@24i/smartapps-datalayer/src/api';
|
|
3
3
|
|
|
4
|
+
export type SubscriptionFeaturesConfiguration = {
|
|
5
|
+
purchase: boolean,
|
|
6
|
+
management: boolean,
|
|
7
|
+
};
|
|
8
|
+
|
|
4
9
|
export type IAPSuccessPayload = {
|
|
5
10
|
platform: VendorType,
|
|
6
11
|
receiptPayload: object
|
|
7
12
|
};
|
|
8
13
|
|
|
9
|
-
export type IAPPurchaseProductData = {
|
|
14
|
+
export type IAPPurchaseProductData = Partial<{
|
|
10
15
|
sku: string,
|
|
11
|
-
serviceId
|
|
12
|
-
product
|
|
13
|
-
appId
|
|
14
|
-
}
|
|
16
|
+
serviceId: string,
|
|
17
|
+
product: Product,
|
|
18
|
+
appId: string,
|
|
19
|
+
}>;
|
|
15
20
|
|
|
16
21
|
export type IAPErrorPayload = { message: string };
|
|
17
22
|
|
|
@@ -187,4 +187,10 @@ export class DeviceBrowser extends DeviceBase {
|
|
|
187
187
|
// not supported
|
|
188
188
|
throw new Error('Not supported');
|
|
189
189
|
}
|
|
190
|
+
|
|
191
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
192
|
+
async cancelSubscription(data: IAPPurchaseProductData): Promise<void> {
|
|
193
|
+
// not supported
|
|
194
|
+
throw new Error('Not supported');
|
|
195
|
+
}
|
|
190
196
|
}
|
|
@@ -253,4 +253,10 @@ export class DeviceEntone extends DeviceBase {
|
|
|
253
253
|
// not supported
|
|
254
254
|
throw new Error('Not supported');
|
|
255
255
|
}
|
|
256
|
+
|
|
257
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
258
|
+
async cancelSubscription(data: IAPPurchaseProductData): Promise<void> {
|
|
259
|
+
// not supported
|
|
260
|
+
throw new Error('Not supported');
|
|
261
|
+
}
|
|
256
262
|
}
|
|
@@ -16,6 +16,11 @@ import { Receipt } from './types';
|
|
|
16
16
|
* See https://github.com/24i/prd-smart-ott-androidtv
|
|
17
17
|
*/
|
|
18
18
|
export class DeviceFireTV extends DeviceAndroidTV {
|
|
19
|
+
subscriptionFeaturesConfiguration = {
|
|
20
|
+
purchase: true,
|
|
21
|
+
management: false,
|
|
22
|
+
};
|
|
23
|
+
|
|
19
24
|
async getPlatformName(): Promise<string> {
|
|
20
25
|
return 'FireTV';
|
|
21
26
|
}
|
|
@@ -74,7 +79,13 @@ export class DeviceFireTV extends DeviceAndroidTV {
|
|
|
74
79
|
return new Promise((resolve, reject) => {
|
|
75
80
|
document.addEventListener('iapSuccess', this.onIAPSuccess(resolve, reject));
|
|
76
81
|
document.addEventListener('iapError', this.onIAPError(resolve, reject));
|
|
77
|
-
window.JavaScriptBridge.bridgeReceiptAmazonIAPValidation(data.sku);
|
|
82
|
+
window.JavaScriptBridge.bridgeReceiptAmazonIAPValidation(data.sku!);
|
|
78
83
|
});
|
|
79
84
|
}
|
|
85
|
+
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
87
|
+
async cancelSubscription(data: IAPPurchaseProductData): Promise<void> {
|
|
88
|
+
// not supported
|
|
89
|
+
throw new Error('Not supported');
|
|
90
|
+
}
|
|
80
91
|
}
|
|
@@ -330,4 +330,10 @@ export class DeviceHbbTV extends DeviceBase {
|
|
|
330
330
|
// not supported
|
|
331
331
|
throw new Error('Not supported');
|
|
332
332
|
}
|
|
333
|
+
|
|
334
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
335
|
+
async cancelSubscription(data: IAPPurchaseProductData): Promise<void> {
|
|
336
|
+
// not supported
|
|
337
|
+
throw new Error('Not supported');
|
|
338
|
+
}
|
|
333
339
|
}
|
|
@@ -288,4 +288,10 @@ export class DeviceKreaTV extends DeviceBase {
|
|
|
288
288
|
// not supported
|
|
289
289
|
throw new Error('Not supported');
|
|
290
290
|
}
|
|
291
|
+
|
|
292
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
293
|
+
async cancelSubscription(data: IAPPurchaseProductData): Promise<void> {
|
|
294
|
+
// not supported
|
|
295
|
+
throw new Error('Not supported');
|
|
296
|
+
}
|
|
291
297
|
}
|
|
@@ -161,4 +161,10 @@ export class DeviceSaphi extends DeviceBase {
|
|
|
161
161
|
// not supported
|
|
162
162
|
throw new Error('Not supported');
|
|
163
163
|
}
|
|
164
|
+
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
166
|
+
async cancelSubscription(data: IAPPurchaseProductData): Promise<void> {
|
|
167
|
+
// not supported
|
|
168
|
+
throw new Error('Not supported');
|
|
169
|
+
}
|
|
164
170
|
}
|
|
@@ -52,6 +52,7 @@ export class DeviceSmartCast extends DeviceBase {
|
|
|
52
52
|
this.initVisibilityChangeListener();
|
|
53
53
|
this.initMouseActiveListener();
|
|
54
54
|
await this.initPlatformApiListeners();
|
|
55
|
+
this.setSubscriptionFeaturesConfiguration();
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
async initPlatformApiListeners(): Promise<void> {
|
|
@@ -248,6 +249,12 @@ export class DeviceSmartCast extends DeviceBase {
|
|
|
248
249
|
.replace('{{us_privacy}}', IFAObject.LMT ? '1YYN' : '1YNN');
|
|
249
250
|
}
|
|
250
251
|
|
|
252
|
+
async getUserMetadata() {
|
|
253
|
+
await this.checkAndLinkTv();
|
|
254
|
+
const result = await this.API!.Account.getUserMetadata();
|
|
255
|
+
return result?.data || null;
|
|
256
|
+
}
|
|
257
|
+
|
|
251
258
|
async getManufacturerName() {
|
|
252
259
|
return 'VIZIO';
|
|
253
260
|
}
|
|
@@ -347,6 +354,13 @@ export class DeviceSmartCast extends DeviceBase {
|
|
|
347
354
|
return '';
|
|
348
355
|
}
|
|
349
356
|
|
|
357
|
+
setSubscriptionFeaturesConfiguration() {
|
|
358
|
+
try {
|
|
359
|
+
this.subscriptionFeaturesConfiguration.purchase = this.API?.Account.isSVODEnabled?.()
|
|
360
|
+
|| false;
|
|
361
|
+
} catch {}
|
|
362
|
+
}
|
|
363
|
+
|
|
350
364
|
registerPartner(callback: (challenge: string) => Promise<string>, appKeyId: string) {
|
|
351
365
|
this.API!.Account.registerPartner(callback, appKeyId);
|
|
352
366
|
}
|
|
@@ -360,7 +374,7 @@ export class DeviceSmartCast extends DeviceBase {
|
|
|
360
374
|
await this.checkAndLinkTv();
|
|
361
375
|
await this.API!.Account.getPlans({ includeBundlePlans: true });
|
|
362
376
|
const purchaseResult = await this.API!.Account.startSVODPurchase(
|
|
363
|
-
sku
|
|
377
|
+
sku!, serviceId ?? '',
|
|
364
378
|
);
|
|
365
379
|
const receiptPayload: PurchaseData = {
|
|
366
380
|
customerId: purchaseResult.data.customerId,
|
|
@@ -371,4 +385,10 @@ export class DeviceSmartCast extends DeviceBase {
|
|
|
371
385
|
};
|
|
372
386
|
return { platform: VendorType.VIZIO, receiptPayload };
|
|
373
387
|
}
|
|
388
|
+
|
|
389
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
390
|
+
async cancelSubscription(data: IAPPurchaseProductData): Promise<void> {
|
|
391
|
+
// not supported
|
|
392
|
+
throw new Error('Not supported');
|
|
393
|
+
}
|
|
374
394
|
}
|
|
@@ -52,6 +52,7 @@ export const SmartCastMockApi: ISmartCastApi = {
|
|
|
52
52
|
},
|
|
53
53
|
|
|
54
54
|
Account: {
|
|
55
|
+
isSVODEnabled: () => true,
|
|
55
56
|
startSVODPurchase: async () => ({
|
|
56
57
|
id: 'id',
|
|
57
58
|
data: {
|
|
@@ -63,6 +64,15 @@ export const SmartCastMockApi: ISmartCastApi = {
|
|
|
63
64
|
}),
|
|
64
65
|
registerPartner: jest.fn(),
|
|
65
66
|
getLinkStatus: async () => true,
|
|
67
|
+
getUserMetadata: async () => ({
|
|
68
|
+
id: 'id',
|
|
69
|
+
data: {
|
|
70
|
+
customerId: 'customerId',
|
|
71
|
+
email: 'email@example.com',
|
|
72
|
+
firstName: 'First',
|
|
73
|
+
lastName: 'Last',
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
66
76
|
startTVLink: async () => ({}),
|
|
67
77
|
getPlans: async () => ({ id: 'id', data: [] }),
|
|
68
78
|
},
|
|
@@ -40,6 +40,7 @@ export type ISmartCastApi = {
|
|
|
40
40
|
setDeviceLanguageHandler: (callback: (deviceLanguage: DeviceLanguage) => void) => void;
|
|
41
41
|
|
|
42
42
|
Account: {
|
|
43
|
+
isSVODEnabled: () => boolean,
|
|
43
44
|
startSVODPurchase: (
|
|
44
45
|
planCode: string,
|
|
45
46
|
partnerAccountId: string,
|
|
@@ -49,6 +50,7 @@ export type ISmartCastApi = {
|
|
|
49
50
|
) => Promise<{ id: string, data: PurchaseData }>
|
|
50
51
|
registerPartner: (callback:(challenge: string) => Promise<string>, keyId: string) => void
|
|
51
52
|
getLinkStatus: () => Promise<boolean>
|
|
53
|
+
getUserMetadata: () => Promise<{ id: string, data: UserMetadata }>
|
|
52
54
|
startTVLink: () => Promise<object>
|
|
53
55
|
getPlans: (options: { includeBundlePlans?: boolean }) => Promise<{
|
|
54
56
|
id: string, data: object[]
|
|
@@ -80,6 +82,13 @@ export type PurchaseData = {
|
|
|
80
82
|
subscriptionId: string
|
|
81
83
|
};
|
|
82
84
|
|
|
85
|
+
export type UserMetadata = {
|
|
86
|
+
customerId: string;
|
|
87
|
+
email: string;
|
|
88
|
+
firstName: string;
|
|
89
|
+
lastName: string;
|
|
90
|
+
};
|
|
91
|
+
|
|
83
92
|
/**
|
|
84
93
|
* Identifier For Advertising (IFA) and Limited Tracking parameter object
|
|
85
94
|
*/
|
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
NetworkState,
|
|
17
17
|
NetworkActiveConnectionType,
|
|
18
18
|
AppCommonScreenSaverState,
|
|
19
|
+
CancelSubscriptionData,
|
|
20
|
+
CancelSubscriptionAPIResult,
|
|
19
21
|
} from './IWebapis';
|
|
20
22
|
import { Tizen, Application } from './ITizen';
|
|
21
23
|
import { TizenKeys } from './TizenKeys';
|
|
@@ -53,6 +55,11 @@ export class DeviceTizen extends DeviceBase {
|
|
|
53
55
|
|
|
54
56
|
screenSaverStatus: AppCommonScreenSaverState = AppCommonScreenSaverState.SCREEN_SAVER_OFF;
|
|
55
57
|
|
|
58
|
+
subscriptionFeaturesConfiguration = {
|
|
59
|
+
purchase: true,
|
|
60
|
+
management: true,
|
|
61
|
+
};
|
|
62
|
+
|
|
56
63
|
// MARK: Initialization
|
|
57
64
|
|
|
58
65
|
async initDevice(): Promise<void> {
|
|
@@ -359,7 +366,52 @@ export class DeviceTizen extends DeviceBase {
|
|
|
359
366
|
reject(e);
|
|
360
367
|
}
|
|
361
368
|
};
|
|
362
|
-
webapis.billing.buyItem(
|
|
369
|
+
webapis.billing.buyItem(
|
|
370
|
+
appId!, 'PRD', JSON.stringify(paymentDetails), onSuccess, reject,
|
|
371
|
+
);
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
async cancelSubscription(
|
|
376
|
+
{ product, appId }: IAPPurchaseProductData,
|
|
377
|
+
): Promise<void> {
|
|
378
|
+
return new Promise((resolve, reject) => {
|
|
379
|
+
if (!product || !appId) {
|
|
380
|
+
reject(new Error('Missing product or appId'));
|
|
381
|
+
}
|
|
382
|
+
const UID = webapis.sso.getLoginUid();
|
|
383
|
+
const countryCode = webapis.productinfo.getSystemConfig(
|
|
384
|
+
webapis.productinfo.ProductInfoConfigKey.CONFIG_KEY_SERVICE_COUNTRY,
|
|
385
|
+
);
|
|
386
|
+
try {
|
|
387
|
+
const vendorTransactionId = product?.vendorTransactionId;
|
|
388
|
+
if (!vendorTransactionId) {
|
|
389
|
+
reject(new Error('Missing vendorTransactionId'));
|
|
390
|
+
}
|
|
391
|
+
const onSuccess = (data: CancelSubscriptionData) => {
|
|
392
|
+
try {
|
|
393
|
+
const result: CancelSubscriptionAPIResult = JSON.parse(data.apiResult);
|
|
394
|
+
if (result.CPStatus === '100000') {
|
|
395
|
+
resolve();
|
|
396
|
+
} else {
|
|
397
|
+
reject(new Error(`Cancel subscription failed: ${result.CPStatus}`));
|
|
398
|
+
}
|
|
399
|
+
} catch (e) {
|
|
400
|
+
reject(e);
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
webapis.billing.cancelSubscription(
|
|
404
|
+
appId!,
|
|
405
|
+
product!.vendorTransactionId!.toString(),
|
|
406
|
+
UID,
|
|
407
|
+
countryCode,
|
|
408
|
+
'PRD',
|
|
409
|
+
onSuccess,
|
|
410
|
+
reject,
|
|
411
|
+
);
|
|
412
|
+
} catch (e) {
|
|
413
|
+
reject(e);
|
|
414
|
+
}
|
|
363
415
|
});
|
|
364
416
|
}
|
|
365
417
|
}
|
|
@@ -158,4 +158,10 @@ export class DeviceVidaa extends DeviceBase {
|
|
|
158
158
|
// not supported
|
|
159
159
|
throw new Error('Not supported');
|
|
160
160
|
}
|
|
161
|
+
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
163
|
+
async cancelSubscription(data: IAPPurchaseProductData): Promise<void> {
|
|
164
|
+
// not supported
|
|
165
|
+
throw new Error('Not supported');
|
|
166
|
+
}
|
|
161
167
|
}
|
|
@@ -351,4 +351,10 @@ export class DeviceWebos extends DeviceBase {
|
|
|
351
351
|
// not supported
|
|
352
352
|
throw new Error('Not supported');
|
|
353
353
|
}
|
|
354
|
+
|
|
355
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
356
|
+
async cancelSubscription(data: IAPPurchaseProductData): Promise<void> {
|
|
357
|
+
// not supported
|
|
358
|
+
throw new Error('Not supported');
|
|
359
|
+
}
|
|
354
360
|
}
|
|
@@ -251,4 +251,10 @@ export class DeviceXbox extends DeviceBase {
|
|
|
251
251
|
// not supported
|
|
252
252
|
throw new Error('Not supported');
|
|
253
253
|
}
|
|
254
|
+
|
|
255
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
256
|
+
async cancelSubscription(data: IAPPurchaseProductData): Promise<void> {
|
|
257
|
+
// not supported
|
|
258
|
+
throw new Error('Not supported');
|
|
259
|
+
}
|
|
254
260
|
}
|