@mediakind/mkplayer 1.6.0 → 1.8.0

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.
Files changed (116) hide show
  1. package/README.md +6 -6
  2. package/mkplayer.js +1 -1
  3. package/package.json +3 -3
  4. package/types/alias/index.d.ts +1 -1
  5. package/types/classes/common/MKAzukiResponseUtils.js +68 -59
  6. package/types/classes/common/MKAzukiResponseUtils.js.map +1 -1
  7. package/types/classes/common/MKEventBase.js +11 -10
  8. package/types/classes/common/MKEventBase.js.map +1 -1
  9. package/types/classes/common/MKLocalStorage.js +64 -58
  10. package/types/classes/common/MKLocalStorage.js.map +1 -1
  11. package/types/classes/common/MKLog.js +49 -22
  12. package/types/classes/common/MKLog.js.map +1 -1
  13. package/types/classes/common/MKPlatform.js +190 -101
  14. package/types/classes/common/MKPlatform.js.map +1 -1
  15. package/types/classes/common/MKProgramManager.js +37 -32
  16. package/types/classes/common/MKProgramManager.js.map +1 -1
  17. package/types/classes/common/MKSecureUrlManager.js +138 -109
  18. package/types/classes/common/MKSecureUrlManager.js.map +1 -1
  19. package/types/classes/common/MKSubtitleOverlay.js +69 -67
  20. package/types/classes/common/MKSubtitleOverlay.js.map +1 -1
  21. package/types/classes/common/MKThumbnailManager.js +264 -209
  22. package/types/classes/common/MKThumbnailManager.js.map +1 -1
  23. package/types/classes/common/MKUtils.js +164 -97
  24. package/types/classes/common/MKUtils.js.map +1 -1
  25. package/types/classes/error/MKAdobeSessionConcurrencyError.js +6 -5
  26. package/types/classes/error/MKAdobeSessionConcurrencyError.js.map +1 -1
  27. package/types/classes/error/MKAzukiRequestError.js +8 -7
  28. package/types/classes/error/MKAzukiRequestError.js.map +1 -1
  29. package/types/classes/error/MKBitmovinPlayerError.js +31 -12
  30. package/types/classes/error/MKBitmovinPlayerError.js.map +1 -1
  31. package/types/classes/error/MKHttpError.js +4 -3
  32. package/types/classes/error/MKHttpError.js.map +1 -1
  33. package/types/classes/error/MKPlayerError.js +5 -4
  34. package/types/classes/error/MKPlayerError.js.map +1 -1
  35. package/types/classes/error/MKProgramRestrictionError.js +11 -10
  36. package/types/classes/error/MKProgramRestrictionError.js.map +1 -1
  37. package/types/classes/player/MKBitmovinPlayer.js +665 -534
  38. package/types/classes/player/MKBitmovinPlayer.js.map +1 -1
  39. package/types/classes/player/MKPlayer.d.ts +5 -0
  40. package/types/classes/player/MKPlayer.js +790 -526
  41. package/types/classes/player/MKPlayer.js.map +1 -1
  42. package/types/classes/player/MKStubPlayer.d.ts +1 -0
  43. package/types/classes/player/MKStubPlayer.js +367 -0
  44. package/types/classes/player/MKStubPlayer.js.map +1 -0
  45. package/types/classes/request/MKAdobeSessionConcurrencyRequest.js +198 -126
  46. package/types/classes/request/MKAdobeSessionConcurrencyRequest.js.map +1 -1
  47. package/types/classes/request/MKAzukiRequest.js +385 -254
  48. package/types/classes/request/MKAzukiRequest.js.map +1 -1
  49. package/types/classes/request/MKHttpRequest.js +128 -89
  50. package/types/classes/request/MKHttpRequest.js.map +1 -1
  51. package/types/constants/MKAzukiRequestEndpoint.js +24 -24
  52. package/types/constants/MKAzukiRequestEndpoint.js.map +1 -1
  53. package/types/constants/MKConstants.js +1 -1
  54. package/types/enums/MKAnalyticsDataName.d.ts +8 -0
  55. package/types/enums/MKAnalyticsDataName.js +13 -0
  56. package/types/enums/MKAnalyticsDataName.js.map +1 -0
  57. package/types/enums/MKErrorCode.d.ts +1 -0
  58. package/types/enums/MKErrorCode.js +1 -0
  59. package/types/enums/MKErrorCode.js.map +1 -1
  60. package/types/enums/MKPlayerEvent.d.ts +7 -1
  61. package/types/enums/MKPlayerEvent.js +6 -0
  62. package/types/enums/MKPlayerEvent.js.map +1 -1
  63. package/types/enums/MKProgramRestrictionType.js.map +1 -1
  64. package/types/enums/index.d.ts +1 -0
  65. package/types/enums/index.js +3 -1
  66. package/types/enums/index.js.map +1 -1
  67. package/types/interfaces/MKAdVerification.d.ts +5 -0
  68. package/types/interfaces/MKAdVerification.js +3 -0
  69. package/types/interfaces/MKAdVerification.js.map +1 -0
  70. package/types/interfaces/MKAdaptationPlatformConfig.js +1 -1
  71. package/types/interfaces/MKAdaptationPlatformConfig.js.map +1 -1
  72. package/types/interfaces/MKBufferConfig.js +1 -1
  73. package/types/interfaces/MKBufferConfig.js.map +1 -1
  74. package/types/interfaces/MKBufferMediaTypeConfig.js +1 -1
  75. package/types/interfaces/MKBufferMediaTypeConfig.js.map +1 -1
  76. package/types/interfaces/MKDrmConfig.js +1 -1
  77. package/types/interfaces/MKDrmConfig.js.map +1 -1
  78. package/types/interfaces/MKPlayerConfig.d.ts +1 -0
  79. package/types/interfaces/MKRegisteredSource.d.ts +2 -1
  80. package/types/interfaces/events/MKAdVerificationEvent.d.ts +6 -0
  81. package/types/interfaces/events/MKAdVerificationEvent.js +3 -0
  82. package/types/interfaces/events/MKAdVerificationEvent.js.map +1 -0
  83. package/types/interfaces/events/MKAnalyticsDataEvent.d.ts +6 -0
  84. package/types/interfaces/events/MKAnalyticsDataEvent.js +3 -0
  85. package/types/interfaces/events/MKAnalyticsDataEvent.js.map +1 -0
  86. package/types/interfaces/events/MKAudioPlaybackQualityChangedEvent.d.ts +2 -1
  87. package/types/interfaces/events/MKMediaPlaybackQualityChangeEvent.d.ts +3 -3
  88. package/types/interfaces/events/MKVSPPSessionIdEvent.d.ts +4 -0
  89. package/types/interfaces/events/MKVSPPSessionIdEvent.js +3 -0
  90. package/types/interfaces/events/MKVSPPSessionIdEvent.js.map +1 -0
  91. package/types/interfaces/events/MKVideoPlaybackQualityChangedEvent.d.ts +2 -1
  92. package/types/interfaces/events/index.d.ts +3 -0
  93. package/types/interfaces/index.d.ts +2 -1
  94. package/types/src/alias/index.d.ts +1 -1
  95. package/types/src/classes/player/MKPlayer.d.ts +5 -0
  96. package/types/src/classes/player/MKStubPlayer.d.ts +1 -0
  97. package/types/src/enums/MKAnalyticsDataName.d.ts +8 -0
  98. package/types/src/enums/MKErrorCode.d.ts +1 -0
  99. package/types/src/enums/MKPlayerEvent.d.ts +7 -1
  100. package/types/src/enums/index.d.ts +1 -0
  101. package/types/src/interfaces/MKAdVerification.d.ts +5 -0
  102. package/types/src/interfaces/MKPlayerConfig.d.ts +1 -0
  103. package/types/src/interfaces/MKRegisteredSource.d.ts +2 -1
  104. package/types/src/interfaces/events/MKAdVerificationEvent.d.ts +6 -0
  105. package/types/src/interfaces/events/MKAnalyticsDataEvent.d.ts +6 -0
  106. package/types/src/interfaces/events/MKAudioPlaybackQualityChangedEvent.d.ts +2 -1
  107. package/types/src/interfaces/events/MKMediaPlaybackQualityChangeEvent.d.ts +3 -3
  108. package/types/src/interfaces/events/MKVSPPSessionIdEvent.d.ts +4 -0
  109. package/types/src/interfaces/events/MKVideoPlaybackQualityChangedEvent.d.ts +2 -1
  110. package/types/src/interfaces/events/index.d.ts +3 -0
  111. package/types/src/interfaces/index.d.ts +2 -1
  112. package/types/plugins/fmts/MKFMTSConfig.d.ts +0 -10
  113. package/types/plugins/fmts/MKFMTSController.d.ts +0 -39
  114. package/types/plugins/fmts/MKFMTSUtils.d.ts +0 -4
  115. package/types/plugins/fmts/index.d.ts +0 -2
  116. package/types/plugins/omsdk/index.d.ts +0 -0
@@ -1,4 +1,19 @@
1
1
  "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
2
17
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
18
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
19
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,271 +23,387 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
23
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
24
  });
10
25
  };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
11
53
  Object.defineProperty(exports, "__esModule", { value: true });
12
54
  exports.MKAzukiRequest = void 0;
13
- const MKUtils_1 = require("../common/MKUtils");
14
- const MKHttpRequest_1 = require("./MKHttpRequest");
15
- const enums_1 = require("../../enums");
16
- const error_1 = require("../error");
17
- const constants_1 = require("../../constants");
18
- const common_1 = require("../common");
19
- class MKAzukiRequest extends MKHttpRequest_1.MKHttpRequest {
20
- constructor(sourceConfig, errorCallback) {
21
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
22
- super();
23
- this.beaconInterval = 0;
24
- this.errorCallback = errorCallback;
25
- this.localStorage = common_1.MKLocalStorage.getInstance();
26
- this.mediaId = (_b = (_a = sourceConfig.registered) === null || _a === void 0 ? void 0 : _a.mediaId) !== null && _b !== void 0 ? _b : "";
27
- this.ownerUid = (_d = (_c = sourceConfig.registered) === null || _c === void 0 ? void 0 : _c.environmentConfig.ownerUid) !== null && _d !== void 0 ? _d : constants_1.MKConstants.AzukiDefaultOwnerUid;
28
- this.sessionId = (_e = sourceConfig.sessionId) !== null && _e !== void 0 ? _e : MKUtils_1.MKUtils.getUUID();
29
- this.baseUrl = (_g = (_f = sourceConfig.registered) === null || _f === void 0 ? void 0 : _f.environmentConfig.serverUrl) !== null && _g !== void 0 ? _g : "";
30
- this.headers = this.getRequestHeaders(sourceConfig);
31
- this.isLive = (_h = (sourceConfig.assetType === enums_1.MKAssetType.Live || sourceConfig.assetType === enums_1.MKAssetType.Event)) !== null && _h !== void 0 ? _h : false;
32
- this.rightsMode = this.isLive ? enums_1.MKRightsMode.Live : enums_1.MKRightsMode.VOD;
33
- this.adobePrimetimeConfig = (_j = sourceConfig.registered) === null || _j === void 0 ? void 0 : _j.adobePrimetimeConfig;
34
- this.isDvrFromRollingBuffer = (_l = (_k = sourceConfig.registered) === null || _k === void 0 ? void 0 : _k.isDvrFromRollingBuffer) !== null && _l !== void 0 ? _l : false;
35
- this.catchupStartTime = (_m = sourceConfig.registered) === null || _m === void 0 ? void 0 : _m.catchupStartTime;
55
+ var MKUtils_1 = require("../common/MKUtils");
56
+ var MKHttpRequest_1 = require("./MKHttpRequest");
57
+ var enums_1 = require("../../enums");
58
+ var error_1 = require("../error");
59
+ var constants_1 = require("../../constants");
60
+ var common_1 = require("../common");
61
+ var MKAzukiRequest = exports.MKAzukiRequest = (function (_super) {
62
+ __extends(MKAzukiRequest, _super);
63
+ function MKAzukiRequest(sourceConfig, errorCallback) {
64
+ var _this = this;
65
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
66
+ _this = _super.call(this) || this;
67
+ _this.sessionManager = "azuki";
68
+ _this.isPaused = false;
69
+ _this.beaconInterval = 0;
70
+ _this.errorCallback = errorCallback;
71
+ _this.localStorage = common_1.MKLocalStorage.getInstance();
72
+ _this.mediaId = (_b = (_a = sourceConfig.registered) === null || _a === void 0 ? void 0 : _a.mediaId) !== null && _b !== void 0 ? _b : "";
73
+ _this.ownerUid = (_d = (_c = sourceConfig.registered) === null || _c === void 0 ? void 0 : _c.environmentConfig.ownerUid) !== null && _d !== void 0 ? _d : constants_1.MKConstants.AzukiDefaultOwnerUid;
74
+ _this.sessionId = (_e = sourceConfig.sessionId) !== null && _e !== void 0 ? _e : MKUtils_1.MKUtils.getUUID();
75
+ _this.offerId = (_f = sourceConfig.registered) === null || _f === void 0 ? void 0 : _f.offerId;
76
+ _this.isDvrFromRollingBuffer = (_h = (_g = sourceConfig.registered) === null || _g === void 0 ? void 0 : _g.isDvrFromRollingBuffer) !== null && _h !== void 0 ? _h : false;
77
+ _this.baseUrl = (_k = (_j = sourceConfig.registered) === null || _j === void 0 ? void 0 : _j.environmentConfig.serverUrl) !== null && _k !== void 0 ? _k : "";
78
+ _this.headers = _this.getRequestHeaders(sourceConfig);
79
+ _this.isLive = (_l = (sourceConfig.assetType === enums_1.MKAssetType.Live || sourceConfig.assetType === enums_1.MKAssetType.Event)) !== null && _l !== void 0 ? _l : false;
80
+ _this.rightsMode = _this.isLive ? enums_1.MKRightsMode.Live : enums_1.MKRightsMode.VOD;
81
+ _this.adobePrimetimeConfig = (_m = sourceConfig.registered) === null || _m === void 0 ? void 0 : _m.adobePrimetimeConfig;
82
+ _this.startTime = !!((_o = sourceConfig.registered) === null || _o === void 0 ? void 0 : _o.startTime) && (sourceConfig.assetType === enums_1.MKAssetType.Catchup || (sourceConfig.assetType === enums_1.MKAssetType.DVR && _this.isDvrFromRollingBuffer)) ? sourceConfig.registered.startTime : undefined;
83
+ return _this;
36
84
  }
37
- updateAuthToken(authToken) {
38
- this.headers["AuthorizationToken"] = authToken;
39
- }
40
- getBeaconInterval() {
85
+ MKAzukiRequest.prototype.updateAuthToken = function (authToken) {
86
+ if (!!authToken) {
87
+ this.headers["AuthorizationToken"] = authToken;
88
+ }
89
+ };
90
+ MKAzukiRequest.prototype.getBeaconInterval = function () {
41
91
  return this.beaconInterval;
42
- }
43
- registrationRequest() {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- return new Promise((resolve, reject) => {
46
- this.post(constants_1.MKAzukiRequestEndpoint.REGISTRATION.get(this.baseUrl), {
47
- headers: this.headers,
48
- queryParams: {
49
- ownerUid: this.ownerUid
50
- }
51
- })
52
- .then((response) => {
53
- MKAzukiRequest.responseTime.registration = response.responseTime;
54
- if (response.status === 200 || (response.status >= 466 && response.status < 500)) {
55
- return response.json();
56
- }
57
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.REGISTRATION.API, response.status));
58
- })
59
- .then((data) => {
60
- if (data.result === "success") {
61
- return resolve();
62
- }
63
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.REGISTRATION.API, data.response.code, data.response.message));
64
- })
65
- .catch((error) => {
66
- if (error instanceof error_1.MKHttpError) {
67
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.REGISTRATION.API, Number(error.code), error.message));
68
- }
69
- common_1.MKLog.error("[registrationRequest] ", error);
70
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.REGISTRATION.API));
71
- });
92
+ };
93
+ MKAzukiRequest.prototype.getBeaconData = function () {
94
+ return this.localStorage.getBeaconData();
95
+ };
96
+ MKAzukiRequest.prototype.getAdobeData = function () {
97
+ return this.adobePrimetimeConfig;
98
+ };
99
+ MKAzukiRequest.prototype.setAnalyticsDataCallback = function (callback) {
100
+ this.analyticsDataCallback = callback;
101
+ };
102
+ MKAzukiRequest.prototype.registrationRequest = function () {
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ var deviceProfile;
105
+ var _this = this;
106
+ return __generator(this, function (_a) {
107
+ switch (_a.label) {
108
+ case 0:
109
+ if (!!!!this.headers["DeviceProfile"]) return [3, 2];
110
+ return [4, common_1.MKPlatform.getDeviceProfile()];
111
+ case 1:
112
+ deviceProfile = _a.sent();
113
+ if (!!deviceProfile)
114
+ this.headers["DeviceProfile"] = deviceProfile;
115
+ _a.label = 2;
116
+ case 2: return [2, new Promise(function (resolve, reject) {
117
+ _this.post(constants_1.MKAzukiRequestEndpoint.REGISTRATION.get(_this.baseUrl), {
118
+ headers: _this.headers,
119
+ queryParams: {
120
+ ownerUid: _this.ownerUid
121
+ }
122
+ })
123
+ .then(function (response) {
124
+ MKAzukiRequest.responseTime.registration = response.responseTime;
125
+ if (response.status === 200 || (response.status >= 466 && response.status < 500)) {
126
+ return response.json();
127
+ }
128
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.REGISTRATION.API, response.status));
129
+ })
130
+ .then(function (data) {
131
+ if (data.result === "success") {
132
+ return resolve();
133
+ }
134
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.REGISTRATION.API, data.response.code, data.response.message));
135
+ })
136
+ .catch(function (error) {
137
+ if (error instanceof error_1.MKHttpError) {
138
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.REGISTRATION.API, Number(error.code), error.message));
139
+ }
140
+ common_1.MKLog.error("[registrationRequest] ", error);
141
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.REGISTRATION.API));
142
+ });
143
+ })];
144
+ }
72
145
  });
73
146
  });
74
- }
75
- rollRequest() {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- const savedAuthToken = this.localStorage.getRegistered();
78
- const currentAuthToken = this.headers["AuthorizationToken"];
79
- if (currentAuthToken && currentAuthToken !== savedAuthToken) {
80
- this.localStorage.clearRegistered();
81
- try {
82
- yield this.registrationRequest();
83
- this.localStorage.setRegistered(currentAuthToken);
84
- }
85
- catch (error) {
86
- return Promise.reject(error);
87
- }
88
- }
89
- yield this.pendingBeaconRequest();
90
- let queryParams = {
91
- mediaId: this.mediaId,
92
- ownerUid: this.ownerUid,
93
- sessionId: this.sessionId
94
- };
95
- if (this.isDvrFromRollingBuffer) {
96
- queryParams = Object.assign({ is_dvr: this.isDvrFromRollingBuffer }, queryParams);
97
- }
98
- return new Promise((resolve, reject) => {
99
- this.post(constants_1.MKAzukiRequestEndpoint.ROLL.get(this.baseUrl), {
100
- headers: this.headers,
101
- queryParams: queryParams,
102
- body: {
103
- roll: {
104
- isLive: this.isLive,
105
- rightsMode: this.rightsMode,
106
- startTime: this.catchupStartTime,
107
- locationDetail: MKAzukiRequest.locationDetail,
108
- adobePrimeTimeConfig: this.adobePrimetimeConfig,
109
- inhome: MKAzukiRequest.inhomeStatus ? "yes" : "no"
147
+ };
148
+ MKAzukiRequest.prototype.rollRequest = function () {
149
+ return __awaiter(this, void 0, void 0, function () {
150
+ var savedAuthToken, currentAuthToken, error_2, deviceProfile, queryParams;
151
+ var _this = this;
152
+ return __generator(this, function (_a) {
153
+ switch (_a.label) {
154
+ case 0:
155
+ savedAuthToken = this.localStorage.getRegistered();
156
+ currentAuthToken = this.headers["AuthorizationToken"];
157
+ if (!(currentAuthToken && currentAuthToken !== savedAuthToken)) return [3, 4];
158
+ this.localStorage.clearRegistered();
159
+ _a.label = 1;
160
+ case 1:
161
+ _a.trys.push([1, 3, , 4]);
162
+ return [4, this.registrationRequest()];
163
+ case 2:
164
+ _a.sent();
165
+ this.localStorage.setRegistered(currentAuthToken);
166
+ return [3, 4];
167
+ case 3:
168
+ error_2 = _a.sent();
169
+ return [2, Promise.reject(error_2)];
170
+ case 4:
171
+ if (!!!!this.headers["DeviceProfile"]) return [3, 6];
172
+ return [4, common_1.MKPlatform.getDeviceProfile()];
173
+ case 5:
174
+ deviceProfile = _a.sent();
175
+ if (!!deviceProfile)
176
+ this.headers["DeviceProfile"] = deviceProfile;
177
+ _a.label = 6;
178
+ case 6: return [4, this.pendingBeaconRequest()];
179
+ case 7:
180
+ _a.sent();
181
+ queryParams = {
182
+ mediaId: this.mediaId,
183
+ ownerUid: this.ownerUid,
184
+ sessionId: this.sessionId
185
+ };
186
+ if (!!this.offerId)
187
+ queryParams["oid"] = this.offerId;
188
+ if (this.isDvrFromRollingBuffer) {
189
+ queryParams["is_dvr"] = this.isDvrFromRollingBuffer;
110
190
  }
111
- }
112
- })
113
- .then((response) => {
114
- MKAzukiRequest.responseTime.roll = response.responseTime;
115
- if (response.status === 200 || (response.status >= 466 && response.status < 500)) {
116
- return response.json();
117
- }
118
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.ROLL.API, response.status));
119
- })
120
- .then((data) => {
121
- if (data.result === "success") {
122
- const rollInfo = common_1.MKAzukiResponseUtils.getRollInfo(data.response, this.baseUrl, queryParams, this.headers);
123
- this.beaconInterval = rollInfo.beaconInterval;
124
- rollInfo.beaconInterval > 0 ? this.saveBeaconData() : this.clearBeaconData();
125
- return resolve(rollInfo);
126
- }
127
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.ROLL.API, data.response.code, data.response.message));
128
- })
129
- .catch((error) => {
130
- if (error instanceof error_1.MKHttpError) {
131
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.ROLL.API, Number(error.code), error.message));
132
- }
133
- common_1.MKLog.error("[rollRequest] ", error);
134
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.ROLL.API));
135
- });
191
+ else {
192
+ delete queryParams["is_dvr"];
193
+ }
194
+ return [2, new Promise(function (resolve, reject) {
195
+ _this.post(constants_1.MKAzukiRequestEndpoint.ROLL.get(_this.baseUrl), {
196
+ headers: _this.headers,
197
+ queryParams: queryParams,
198
+ body: {
199
+ roll: {
200
+ isLive: _this.isLive,
201
+ rightsMode: _this.rightsMode,
202
+ startTime: _this.startTime,
203
+ locationDetail: MKAzukiRequest.locationDetail,
204
+ adobePrimeTimeConfig: _this.adobePrimetimeConfig,
205
+ inhome: MKAzukiRequest.inhomeStatus ? "yes" : "no"
206
+ }
207
+ }
208
+ })
209
+ .then(function (response) {
210
+ MKAzukiRequest.responseTime.roll = response.responseTime;
211
+ if (response.status === 200 || (response.status >= 466 && response.status < 500)) {
212
+ return response.json();
213
+ }
214
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.ROLL.API, response.status));
215
+ })
216
+ .then(function (data) {
217
+ if (data.result === "success") {
218
+ var rollInfo = common_1.MKAzukiResponseUtils.getRollInfo(data.response, _this.baseUrl, queryParams, _this.headers);
219
+ _this.beaconInterval = rollInfo.beaconInterval;
220
+ rollInfo.beaconInterval > 0 ? _this.saveBeaconData() : _this.clearBeaconData();
221
+ return resolve(rollInfo);
222
+ }
223
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.ROLL.API, data.response.code, data.response.message));
224
+ })
225
+ .catch(function (error) {
226
+ if (error instanceof error_1.MKHttpError) {
227
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.ROLL.API, Number(error.code), error.message));
228
+ }
229
+ common_1.MKLog.error("[rollRequest] ", error);
230
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.ROLL.API));
231
+ });
232
+ })];
233
+ }
136
234
  });
137
235
  });
138
- }
139
- programInfoRequest(startDate, endDate) {
140
- return __awaiter(this, void 0, void 0, function* () {
141
- return new Promise((resolve, _reject) => {
142
- this.get(constants_1.MKAzukiRequestEndpoint.QUERY.get(this.baseUrl), {
143
- queryParams: {
144
- channelId: this.mediaId,
145
- ownerUid: this.ownerUid,
146
- startDate: startDate,
147
- endDate: endDate,
148
- pbr: true,
149
- programs: true,
150
- partialPrograms: true,
151
- externalRecordings: false
152
- },
153
- headers: this.headers
154
- })
155
- .then((response) => {
156
- MKAzukiRequest.responseTime.query = response.responseTime;
157
- if (response.ok) {
158
- return response.json();
159
- }
160
- return resolve([]);
161
- })
162
- .then((data) => {
163
- const programInfoList = [];
164
- if (data.result === "success" && MKUtils_1.MKUtils.isArray(data.response.medias)) {
165
- const programs = data.response.medias;
166
- programs.forEach((program) => {
167
- programInfoList.push(common_1.MKAzukiResponseUtils.getProgramInfo(program));
236
+ };
237
+ MKAzukiRequest.prototype.programInfoRequest = function (startDate, endDate) {
238
+ return __awaiter(this, void 0, void 0, function () {
239
+ var _this = this;
240
+ return __generator(this, function (_a) {
241
+ return [2, new Promise(function (resolve, _reject) {
242
+ _this.get(constants_1.MKAzukiRequestEndpoint.QUERY.get(_this.baseUrl), {
243
+ queryParams: {
244
+ channelId: _this.mediaId,
245
+ ownerUid: _this.ownerUid,
246
+ startDate: startDate,
247
+ endDate: endDate,
248
+ pbr: true,
249
+ programs: true,
250
+ partialPrograms: true,
251
+ externalRecordings: false
252
+ },
253
+ headers: _this.headers
254
+ })
255
+ .then(function (response) {
256
+ MKAzukiRequest.responseTime.query = response.responseTime;
257
+ if (response.ok) {
258
+ return response.json();
259
+ }
260
+ return resolve([]);
261
+ })
262
+ .then(function (data) {
263
+ var programInfoList = [];
264
+ if (data.result === "success" && MKUtils_1.MKUtils.isArray(data.response.medias)) {
265
+ var programs = data.response.medias;
266
+ programs.forEach(function (program) {
267
+ programInfoList.push(common_1.MKAzukiResponseUtils.getProgramInfo(program));
268
+ });
269
+ }
270
+ return resolve(programInfoList);
271
+ })
272
+ .catch(function () {
273
+ return resolve([]);
168
274
  });
169
- }
170
- return resolve(programInfoList);
171
- })
172
- .catch(() => {
173
- return resolve([]);
174
- });
275
+ })];
175
276
  });
176
277
  });
177
- }
178
- startSession() {
179
- return __awaiter(this, void 0, void 0, function* () {
180
- if (this.beaconInterval === 0)
181
- return;
182
- return this.beaconRequest()
183
- .then(() => {
184
- this.scheduleBeaconRequest(this.beaconInterval * 1000);
278
+ };
279
+ MKAzukiRequest.prototype.startSession = function () {
280
+ return __awaiter(this, void 0, void 0, function () {
281
+ var _this = this;
282
+ return __generator(this, function (_a) {
283
+ if (this.beaconInterval === 0)
284
+ return [2];
285
+ this.isPaused = false;
286
+ return [2, this.beaconRequest()
287
+ .then(function () {
288
+ _this.scheduleBeaconRequest(_this.beaconInterval * 1000);
289
+ })];
185
290
  });
186
291
  });
187
- }
188
- stopSession() {
189
- return __awaiter(this, void 0, void 0, function* () {
190
- if (this.beaconInterval === 0)
191
- return;
192
- clearInterval(this.beaconTimer);
193
- return this.beaconRequest(true);
292
+ };
293
+ MKAzukiRequest.prototype.stopSession = function () {
294
+ return __awaiter(this, void 0, void 0, function () {
295
+ return __generator(this, function (_a) {
296
+ if (this.beaconInterval === 0)
297
+ return [2];
298
+ clearInterval(this.beaconTimer);
299
+ return [2, this.beaconRequest(true)];
300
+ });
194
301
  });
195
- }
196
- scheduleBeaconRequest(interval) {
302
+ };
303
+ MKAzukiRequest.prototype.PauseSession = function () {
304
+ this.isPaused = true;
305
+ if (this.beaconInterval === 0)
306
+ return;
307
+ clearInterval(this.beaconTimer);
308
+ };
309
+ MKAzukiRequest.prototype.scheduleBeaconRequest = function (interval) {
310
+ var _this = this;
197
311
  if (this.beaconTimer)
198
312
  clearInterval(this.beaconTimer);
199
- this.beaconTimer = setInterval(() => {
200
- this.beaconRequest()
201
- .catch((error) => {
202
- if (this.errorCallback)
203
- this.errorCallback(error);
313
+ this.beaconTimer = setInterval(function () {
314
+ _this.beaconRequest()
315
+ .catch(function (error) {
316
+ if (_this.errorCallback)
317
+ _this.errorCallback(error);
204
318
  });
205
319
  }, interval);
206
- }
207
- beaconRequest(isFinalBeacon = false) {
208
- return __awaiter(this, void 0, void 0, function* () {
209
- return new Promise((resolve, reject) => {
210
- this.post(constants_1.MKAzukiRequestEndpoint.BEACONS.get(this.baseUrl), {
211
- body: {
212
- beacon: {
213
- isLive: this.isLive,
214
- complete: isFinalBeacon,
215
- inhome: MKAzukiRequest.inhomeStatus ? "yes" : "no"
216
- }
217
- },
218
- queryParams: {
219
- mediaId: this.mediaId,
220
- ownerUid: this.ownerUid,
221
- sessionId: this.sessionId
222
- },
223
- headers: this.headers
224
- })
225
- .then((response) => {
226
- MKAzukiRequest.responseTime.beacons = response.responseTime;
227
- if (response.status === 200 || (response.status >= 466 && response.status < 500)) {
228
- return response.json();
229
- }
230
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.BEACONS.API, response.status));
231
- })
232
- .then((data) => {
233
- var _a;
234
- if (data.result === "success") {
235
- const beaconResponse = data.response;
236
- const beaconInterval = (_a = beaconResponse.interval) !== null && _a !== void 0 ? _a : 0;
237
- if (isFinalBeacon && beaconInterval === 0) {
238
- this.clearBeaconData();
239
- }
240
- return resolve();
241
- }
242
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.BEACONS.API, data.response.code, data.response.message));
243
- })
244
- .catch((error) => {
245
- if (error instanceof error_1.MKHttpError) {
246
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.BEACONS.API, Number(error.code), error.message));
247
- }
248
- common_1.MKLog.error("[beaconRequest] ", error);
249
- return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.BEACONS.API));
250
- });
320
+ };
321
+ MKAzukiRequest.prototype.beaconRequest = function (isFinalBeacon) {
322
+ if (isFinalBeacon === void 0) { isFinalBeacon = false; }
323
+ return __awaiter(this, void 0, void 0, function () {
324
+ var _this = this;
325
+ return __generator(this, function (_a) {
326
+ return [2, new Promise(function (resolve, reject) {
327
+ _this.post(constants_1.MKAzukiRequestEndpoint.BEACONS.get(_this.baseUrl), {
328
+ body: {
329
+ beacon: {
330
+ isLive: _this.isLive,
331
+ complete: isFinalBeacon,
332
+ inhome: MKAzukiRequest.inhomeStatus ? "yes" : "no"
333
+ }
334
+ },
335
+ queryParams: {
336
+ mediaId: _this.mediaId,
337
+ ownerUid: _this.ownerUid,
338
+ sessionId: _this.sessionId
339
+ },
340
+ headers: _this.headers
341
+ })
342
+ .then(function (response) {
343
+ MKAzukiRequest.responseTime.beacons = response.responseTime;
344
+ if (!!_this.analyticsDataCallback) {
345
+ _this.analyticsDataCallback(enums_1.MKAnalyticsDataName.LastBeacon, response.responseTime);
346
+ }
347
+ if (response.status === 200 || (response.status >= 466 && response.status < 500)) {
348
+ return response.json();
349
+ }
350
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.BEACONS.API, response.status));
351
+ })
352
+ .then(function (data) {
353
+ var _a;
354
+ if (data.result === "success") {
355
+ var beaconResponse = data.response;
356
+ var beaconInterval = (_a = beaconResponse.interval) !== null && _a !== void 0 ? _a : 0;
357
+ if (isFinalBeacon && beaconInterval === 0) {
358
+ _this.clearBeaconData();
359
+ }
360
+ return resolve();
361
+ }
362
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.BEACONS.API, data.response.code, data.response.message));
363
+ })
364
+ .catch(function (error) {
365
+ if (error instanceof error_1.MKHttpError) {
366
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.BEACONS.API, Number(error.code), error.message));
367
+ }
368
+ common_1.MKLog.error("[beaconRequest] ", error);
369
+ return reject(new error_1.MKAzukiRequestError(constants_1.MKAzukiRequestEndpoint.BEACONS.API));
370
+ });
371
+ })];
251
372
  });
252
373
  });
253
- }
254
- pendingBeaconRequest() {
255
- return __awaiter(this, void 0, void 0, function* () {
256
- const beaconData = this.localStorage.getBeaconData();
257
- if (beaconData && !!beaconData.requestUrl && beaconData.requestOptions) {
258
- try {
259
- const response = yield this.post(beaconData.requestUrl, beaconData.requestOptions);
260
- common_1.MKLog.debug("Pending beacon notification ", response.ok ? "successful." : "failed.");
261
- this.clearBeaconData();
374
+ };
375
+ MKAzukiRequest.prototype.pendingBeaconRequest = function () {
376
+ return __awaiter(this, void 0, void 0, function () {
377
+ var beaconData, response, error_3;
378
+ return __generator(this, function (_a) {
379
+ switch (_a.label) {
380
+ case 0:
381
+ beaconData = this.localStorage.getBeaconData();
382
+ if (!(beaconData && !!beaconData.requestUrl && beaconData.requestOptions)) return [3, 4];
383
+ _a.label = 1;
384
+ case 1:
385
+ _a.trys.push([1, 3, , 4]);
386
+ return [4, this.post(beaconData.requestUrl, beaconData.requestOptions)];
387
+ case 2:
388
+ response = _a.sent();
389
+ common_1.MKLog.debug("Pending beacon notification ", response.ok ? "successful." : "failed.");
390
+ this.clearBeaconData();
391
+ return [3, 4];
392
+ case 3:
393
+ error_3 = _a.sent();
394
+ common_1.MKLog.debug("Pending beacon notification failed with error: ", error_3);
395
+ this.clearBeaconData();
396
+ return [3, 4];
397
+ case 4: return [2];
262
398
  }
263
- catch (error) {
264
- common_1.MKLog.debug("Pending beacon notification failed with error: ", error);
265
- this.clearBeaconData();
266
- }
267
- }
399
+ });
268
400
  });
269
- }
270
- getRequestHeaders(sourceConfig) {
271
- let requestHeaders = {};
401
+ };
402
+ MKAzukiRequest.prototype.getRequestHeaders = function (sourceConfig) {
403
+ var requestHeaders = {};
272
404
  if (sourceConfig.registered) {
273
405
  requestHeaders["AzukiIMC"] = constants_1.MKConstants.AzukiIMC;
274
406
  requestHeaders["Content-Type"] = "application/json";
275
- requestHeaders["DeviceProfile"] = common_1.MKPlatform.getDeviceProfile();
276
407
  requestHeaders["AuthorizationToken"] = sourceConfig.registered.environmentConfig.authToken;
277
408
  if (sourceConfig.registered.applicationToken) {
278
409
  requestHeaders["ApplicationToken"] = sourceConfig.registered.applicationToken;
@@ -282,9 +413,9 @@ class MKAzukiRequest extends MKHttpRequest_1.MKHttpRequest {
282
413
  }
283
414
  }
284
415
  return requestHeaders;
285
- }
286
- saveBeaconData() {
287
- const beaconData = {
416
+ };
417
+ MKAzukiRequest.prototype.saveBeaconData = function () {
418
+ var beaconData = {
288
419
  requestUrl: constants_1.MKAzukiRequestEndpoint.BEACONS.get(this.baseUrl),
289
420
  requestOptions: {
290
421
  body: {
@@ -303,17 +434,17 @@ class MKAzukiRequest extends MKHttpRequest_1.MKHttpRequest {
303
434
  }
304
435
  };
305
436
  this.localStorage.setBeaconData(beaconData);
306
- }
307
- clearBeaconData() {
437
+ };
438
+ MKAzukiRequest.prototype.clearBeaconData = function () {
308
439
  this.localStorage.clearBeaconData();
309
- }
310
- }
311
- exports.MKAzukiRequest = MKAzukiRequest;
312
- MKAzukiRequest.inhomeStatus = false;
313
- MKAzukiRequest.responseTime = {
314
- registration: 0,
315
- roll: 0,
316
- beacons: 0,
317
- query: 0
318
- };
440
+ };
441
+ MKAzukiRequest.inhomeStatus = false;
442
+ MKAzukiRequest.responseTime = {
443
+ registration: 0,
444
+ roll: 0,
445
+ beacons: 0,
446
+ query: 0
447
+ };
448
+ return MKAzukiRequest;
449
+ }(MKHttpRequest_1.MKHttpRequest));
319
450
  //# sourceMappingURL=MKAzukiRequest.js.map