From 93baba20a1b1a20bfac6742703d5701e523b535d Mon Sep 17 00:00:00 2001 From: Casey Occhialini <1508707+littlespex@users.noreply.github.com> Date: Thu, 23 Mar 2023 13:45:40 -0700 Subject: [PATCH] fix: stream property of request context obfuscated in production builds (#5118) Co-authored-by: Dan Sparacio --- externs/shaka/net.js | 25 +++++++++++++++++-- lib/hls/hls_parser.js | 2 +- lib/net/networking_engine.js | 31 ++++-------------------- lib/util/cmcd_manager.js | 8 +++--- lib/util/fairplay_utils.js | 12 ++++----- test/test/util/fake_networking_engine.js | 8 +++--- 6 files changed, 43 insertions(+), 43 deletions(-) diff --git a/externs/shaka/net.js b/externs/shaka/net.js index 34a26b6afd..1ca903ae65 100644 --- a/externs/shaka/net.js +++ b/externs/shaka/net.js @@ -200,6 +200,27 @@ shaka.extern.ProgressUpdated; shaka.extern.HeadersReceived; +/** + * @typedef {{ + * type: (shaka.net.NetworkingEngine.AdvancedRequestType|undefined), + * stream: (shaka.extern.Stream|undefined), + * segment: (shaka.media.SegmentReference|undefined) + * }} + * + * @description + * Defines contextual data about a request + * + * @property {shaka.net.NetworkingEngine.AdvancedRequestType=} type + * The advanced type + * @property {shaka.extern.Stream=} stream + * The duration of the segment in seconds + * @property {shaka.media.SegmentReference=} segment + * The request's segment reference + * @exportDoc + */ +shaka.extern.RequestContext; + + /** * Defines a filter for requests. This filter takes the request and modifies * it before it is sent to the scheme plugin. @@ -211,7 +232,7 @@ shaka.extern.HeadersReceived; * * @typedef {!function(shaka.net.NetworkingEngine.RequestType, * shaka.extern.Request, - * shaka.net.NetworkingEngine.RequestContext=): + * shaka.extern.RequestContext=): * (Promise|undefined)} * @exportDoc */ @@ -228,7 +249,7 @@ shaka.extern.RequestFilter; * * @typedef {!function(shaka.net.NetworkingEngine.RequestType, * shaka.extern.Response, - * shaka.net.NetworkingEngine.RequestContext=): + * shaka.extern.RequestContext=): * (Promise|undefined)} * @exportDoc */ diff --git a/lib/hls/hls_parser.js b/lib/hls/hls_parser.js index a2ba5e9b34..69fea3934a 100644 --- a/lib/hls/hls_parser.js +++ b/lib/hls/hls_parser.js @@ -3386,7 +3386,7 @@ shaka.hls.HlsParser = class { * * @param {shaka.extern.Request} request * @param {shaka.net.NetworkingEngine.RequestType} type - * @param {shaka.net.NetworkingEngine.RequestContext=} context + * @param {shaka.extern.RequestContext=} context * @return {!Promise.} * @private */ diff --git a/lib/net/networking_engine.js b/lib/net/networking_engine.js index 9074449f0c..c09fdb9405 100644 --- a/lib/net/networking_engine.js +++ b/lib/net/networking_engine.js @@ -5,12 +5,12 @@ */ goog.provide('shaka.net.NetworkingEngine'); +goog.provide('shaka.net.NetworkingEngine.AdvancedRequestType'); goog.provide('shaka.net.NetworkingEngine.RequestType'); goog.provide('shaka.net.NetworkingEngine.PendingRequest'); goog.require('goog.Uri'); goog.require('goog.asserts'); -goog.require('shaka.media.SegmentReference'); goog.require('shaka.net.Backoff'); goog.require('shaka.util.AbortableOperation'); goog.require('shaka.util.BufferUtils'); @@ -254,7 +254,7 @@ shaka.net.NetworkingEngine = class extends shaka.util.FakeEventTarget { * * @param {shaka.net.NetworkingEngine.RequestType} type * @param {shaka.extern.Request} request - * @param {shaka.net.NetworkingEngine.RequestContext=} context + * @param {shaka.extern.RequestContext=} context * @return {!shaka.net.NetworkingEngine.PendingRequest} * @export */ @@ -349,7 +349,7 @@ shaka.net.NetworkingEngine = class extends shaka.util.FakeEventTarget { /** * @param {shaka.net.NetworkingEngine.RequestType} type * @param {shaka.extern.Request} request - * @param {shaka.net.NetworkingEngine.RequestContext=} context + * @param {shaka.extern.RequestContext=} context * @return {!shaka.util.AbortableOperation.} * @private */ @@ -624,7 +624,7 @@ shaka.net.NetworkingEngine = class extends shaka.util.FakeEventTarget { * @param {shaka.net.NetworkingEngine.RequestType} type * @param {shaka.net.NetworkingEngine.ResponseAndGotProgress} * responseAndGotProgress - * @param {shaka.net.NetworkingEngine.RequestContext=} context + * @param {shaka.extern.RequestContext=} context * @return {!shaka.extern.IAbortableOperation.< * shaka.net.NetworkingEngine.ResponseAndGotProgress>} * @private @@ -845,27 +845,6 @@ shaka.net.NetworkingEngine.schemes_ = {}; shaka.net.NetworkingEngine.ResponseAndGotProgress; -/** - * @typedef {{ - * type: (shaka.net.NetworkingEngine.AdvancedRequestType|undefined), - * stream: (shaka.extern.Stream|undefined), - * segment: (shaka.media.SegmentReference|undefined) - * }} - * - * @description - * Defines contextual data about a request - * - * @property {shaka.net.NetworkingEngine.AdvancedRequestType=} type - * The advanced type - * @property {shaka.extern.Stream=} stream - * The duration of the segment in seconds - * @property {shaka.media.SegmentReference=} segment - * The request's segment reference - * @export - */ -shaka.net.NetworkingEngine.RequestContext; - - /** * @typedef {function( * !Object., @@ -899,7 +878,7 @@ shaka.net.NetworkingEngine.OnDownloadFailed; * @typedef {function( * !shaka.net.NetworkingEngine.RequestType, * !shaka.extern.Request, - * (shaka.net.NetworkingEngine.RequestContext|undefined))} + * (shaka.extern.RequestContext|undefined))} * * @description * A callback function called on every request diff --git a/lib/util/cmcd_manager.js b/lib/util/cmcd_manager.js index 2d26728b20..9051b6655a 100644 --- a/lib/util/cmcd_manager.js +++ b/lib/util/cmcd_manager.js @@ -81,7 +81,7 @@ shaka.util.CmcdManager = class { * The request type * @param {!shaka.extern.Request} request * The request to apply CMCD data to - * @param {shaka.net.NetworkingEngine.RequestContext=} context + * @param {shaka.extern.RequestContext=} context * The request context */ applyData(type, request, context = {}) { @@ -123,7 +123,7 @@ shaka.util.CmcdManager = class { * * @param {!shaka.extern.Request} request * The request to apply CMCD data to - * @param {shaka.net.NetworkingEngine.RequestContext} context + * @param {shaka.extern.RequestContext} context * The request context */ applyManifestData(request, context) { @@ -150,7 +150,7 @@ shaka.util.CmcdManager = class { * Apply CMCD data to a segment request * * @param {!shaka.extern.Request} request - * @param {shaka.net.NetworkingEngine.RequestContext} context + * @param {shaka.extern.RequestContext} context * The request context */ applySegmentData(request, context) { @@ -349,7 +349,7 @@ shaka.util.CmcdManager = class { /** * The CMCD object type. * - * @param {shaka.net.NetworkingEngine.RequestContext} context + * @param {shaka.extern.RequestContext} context * The request context * @private */ diff --git a/lib/util/fairplay_utils.js b/lib/util/fairplay_utils.js index e83b4e3443..dcc016b5a5 100644 --- a/lib/util/fairplay_utils.js +++ b/lib/util/fairplay_utils.js @@ -233,7 +233,7 @@ shaka.util.FairPlayUtils = class { * * @param {shaka.net.NetworkingEngine.RequestType} type * @param {shaka.extern.Request} request - * @param {shaka.net.NetworkingEngine.RequestContext=} context + * @param {shaka.extern.RequestContext=} context * @export */ static verimatrixFairPlayRequest(type, request, context) { @@ -252,7 +252,7 @@ shaka.util.FairPlayUtils = class { * * @param {shaka.net.NetworkingEngine.RequestType} type * @param {shaka.extern.Request} request - * @param {shaka.net.NetworkingEngine.RequestContext=} context + * @param {shaka.extern.RequestContext=} context * @private */ static octetStreamFairPlayRequest_(type, request, context) { @@ -267,7 +267,7 @@ shaka.util.FairPlayUtils = class { * * @param {shaka.net.NetworkingEngine.RequestType} type * @param {shaka.extern.Request} request - * @param {shaka.net.NetworkingEngine.RequestContext=} context + * @param {shaka.extern.RequestContext=} context * @export */ static ezdrmFairPlayRequest(type, request, context) { @@ -279,7 +279,7 @@ shaka.util.FairPlayUtils = class { * * @param {shaka.net.NetworkingEngine.RequestType} type * @param {shaka.extern.Request} request - * @param {shaka.net.NetworkingEngine.RequestContext=} context + * @param {shaka.extern.RequestContext=} context * @export */ static conaxFairPlayRequest(type, request, context) { @@ -291,7 +291,7 @@ shaka.util.FairPlayUtils = class { * * @param {shaka.net.NetworkingEngine.RequestType} type * @param {shaka.extern.Request} request - * @param {shaka.net.NetworkingEngine.RequestContext=} context + * @param {shaka.extern.RequestContext=} context * @export */ static expressplayFairPlayRequest(type, request, context) { @@ -303,7 +303,7 @@ shaka.util.FairPlayUtils = class { * * @param {shaka.net.NetworkingEngine.RequestType} type * @param {shaka.extern.Response} response - * @param {shaka.net.NetworkingEngine.RequestContext=} context + * @param {shaka.extern.RequestContext=} context * @export */ static commonFairPlayResponse(type, response, context) { diff --git a/test/test/util/fake_networking_engine.js b/test/test/util/fake_networking_engine.js index 632687ef71..e09539a1e4 100644 --- a/test/test/util/fake_networking_engine.js +++ b/test/test/util/fake_networking_engine.js @@ -174,7 +174,7 @@ shaka.test.FakeNetworkingEngine = class { * * @param {string} uri * @param {shaka.net.NetworkingEngine.RequestType} type - * @param {shaka.net.NetworkingEngine.RequestContext=} context + * @param {shaka.extern.RequestContext=} context */ expectRequest(uri, type, context) { shaka.test.FakeNetworkingEngine.expectRequest( @@ -186,7 +186,7 @@ shaka.test.FakeNetworkingEngine = class { * * @param {string} uri * @param {shaka.net.NetworkingEngine.RequestType} type - * @param {shaka.net.NetworkingEngine.RequestContext=} context + * @param {shaka.extern.RequestContext=} context */ expectNoRequest(uri, type, context) { shaka.test.FakeNetworkingEngine.expectNoRequest( @@ -294,7 +294,7 @@ shaka.test.FakeNetworkingEngine = class { * @param {!Object} requestSpy * @param {string} uri * @param {shaka.net.NetworkingEngine.RequestType} type - * @param {shaka.net.NetworkingEngine.RequestContext=} context + * @param {shaka.extern.RequestContext=} context */ static expectRequest(requestSpy, uri, type, context) { // Jasmine "toHaveBeenCalledWith" doesn't handle optional parameters well. @@ -314,7 +314,7 @@ shaka.test.FakeNetworkingEngine = class { * @param {!Object} requestSpy * @param {string} uri * @param {shaka.net.NetworkingEngine.RequestType} type - * @param {shaka.net.NetworkingEngine.RequestContext=} context + * @param {shaka.extern.RequestContext=} context */ static expectNoRequest(requestSpy, uri, type, context) { // Jasmine "toHaveBeenCalledWith" doesn't handle optional parameters well.