Skip to content

Commit

Permalink
SwG Release 3579668c - Fix a payment issue caused by O2 migration on …
Browse files Browse the repository at this point in the history
…mWeb and web (#39611)

* SwG Release 3579668c

* empty commit

* empty commit 2
  • Loading branch information
oyj9109 authored Nov 10, 2023
1 parent 22512e8 commit f85f4f7
Show file tree
Hide file tree
Showing 3 changed files with 593 additions and 591 deletions.
2 changes: 1 addition & 1 deletion third_party/subscriptions-project/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** Version: 216488bf */
/** Version: 3579668c */
/**
* Copyright 2018 The Subscribe with Google Authors. All Rights Reserved.
*
Expand Down
68 changes: 34 additions & 34 deletions third_party/subscriptions-project/swg-gaa.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** Version: 216488bf */
/** Version: 3579668c */
/**
* Copyright 2018 The Subscribe with Google Authors. All Rights Reserved.
*
Expand Down Expand Up @@ -332,9 +332,9 @@ function toString(val) {

/**
* Character mapping from base64url to base64.
* @const {!{[key: string]: string}}
* @const {!Object<string, string>}
*/
const base64UrlDecodeSubs = { '-': '+', '_': '/' };
const base64UrlDecodeSubs = {'-': '+', '_': '/'};

/**
* Converts a string which holds 8-bit code points, such as the result of atob,
Expand Down Expand Up @@ -421,7 +421,7 @@ function base64UrlDecodeToBytes(str) {
* @return {?JsonObject|undefined} May be extend to parse arrays.
*/
function parseJson(json) {
return /** @type {?JsonObject} */ (JSON.parse(/** @type {string} */(json)));
return /** @type {?JsonObject} */ (JSON.parse(/** @type {string} */ (json)));
}

/**
Expand Down Expand Up @@ -464,7 +464,7 @@ function tryParseJson(json, onFailed) {
* Provides helper methods to decode and verify JWT tokens.
*/
class JwtHelper {
constructor() { }
constructor() {}

/**
* Decodes JWT token and returns its payload.
Expand Down Expand Up @@ -795,7 +795,7 @@ let a;
* We cached all parsed URLs. As of now there are no use cases
* of AMP docs that would ever parse an actual large number of URLs,
* but we often parse the same one over and over again.
* @type {{[key: string]: !LocationDef}}
* @type {Object<string, !LocationDef>}
*/
let cache;

Expand Down Expand Up @@ -859,7 +859,7 @@ function parseUrlWithA(a, url) {
/**
* Parses and builds Object of URL query string.
* @param {string} query The URL query string.
* @return {!{[key: string]: string}}
* @return {!Object<string, string>}
*/
function parseQueryString(query) {
if (!query) {
Expand Down Expand Up @@ -931,7 +931,7 @@ const DEFAULT_LANGUAGE_CODE = 'en';

/**
* Gets a message for a given language code, from a map of messages.
* @param {!{[key: string]: string}} map
* @param {!Object<string, string>} map
* @param {?string|?Element} languageCodeOrElement
* @return {?string}
*/
Expand Down Expand Up @@ -1036,7 +1036,7 @@ function startsWith(string, prefix) {
* limitations under the License.
*/

/** @type {{[key: string]: string}} */
/** @type {Object<string, string>} */
let propertyNameCache;

/** @const {!Array<string>} */
Expand Down Expand Up @@ -1108,7 +1108,7 @@ function getVendorJsPropertyName(style, camelCase, bypassCache) {
* Sets the CSS styles of the specified element with !important. The styles
* are specified as a map from CSS property names to their values.
* @param {!Element} element
* @param {!{[key: string]: string|number}} styles
* @param {!Object<string, string|number>} styles
*/
function setImportantStyles(element, styles) {
for (const k in styles) {
Expand Down Expand Up @@ -1145,7 +1145,7 @@ function setStyle(element, property, value, units, bypassCache) {
* Sets the CSS styles of the specified element. The styles
* a specified as a map from CSS property names to their values.
* @param {!Element} element
* @param {!{[key: string]: ?string|number|boolean}} styles
* @param {!Object<string, ?string|number|boolean>} styles
*/
function setStyles(element, styles) {
for (const k in styles) {
Expand Down Expand Up @@ -1175,21 +1175,21 @@ const styleType = 'text/css';
/**
* Add attributes to an element.
* @param {!Element} element
* @param {!{[key: string]: string|number|boolean|!{[key: string]: string|number|boolean}}} attributes
* @param {!Object<string, string|number|boolean|!Object<string, string|number|boolean>>} attributes
* @return {!Element} updated element.
*/
function addAttributesToElement(element, attributes) {
for (const attr in attributes) {
if (attr == 'style') {
setStyles(
element,
/** @type {!{[key: string]: string|boolean|number}} */
/** @type {!Object<string, string|boolean|number>} */
(attributes[attr])
);
} else {
element.setAttribute(
attr,
/** @type {string|boolean|number} */(attributes[attr])
/** @type {string|boolean|number} */ (attributes[attr])
);
}
}
Expand All @@ -1200,7 +1200,7 @@ function addAttributesToElement(element, attributes) {
* Create a new element on document with specified tagName and attributes.
* @param {!Document} doc
* @param {string} tagName
* @param {!{[key: string]: string}} attributes
* @param {!Object<string, string>} attributes
* @param {?(string|!Node|!ArrayLike<!Node>|!Array<!Node>)=} content
* @return {!Element} created element.
*/
Expand All @@ -1211,7 +1211,7 @@ function createElement(doc, tagName, attributes, content) {
if (typeof content == 'string') {
element.textContent = content;
} else if (content.nodeType) {
element.appendChild(/** @type {!Node} */(content));
element.appendChild(/** @type {!Node} */ (content));
} else if ('length' in content) {
for (let i = 0; i < content.length; i++) {
element.appendChild(content[i]);
Expand Down Expand Up @@ -1401,11 +1401,11 @@ class GlobalDoc {
function resolveDoc(input) {
// Is it a `Document`
if (/** @type {!Document} */ (input).nodeType === /* DOCUMENT */ 9) {
return new GlobalDoc(/** @type {!Document} */(input));
return new GlobalDoc(/** @type {!Document} */ (input));
}
// Is it a `Window`?
if (/** @type {!Window} */ (input).document) {
return new GlobalDoc(/** @type {!Window} */(input));
return new GlobalDoc(/** @type {!Window} */ (input));
}
return /** @type {!Doc} */ (input);
}
Expand All @@ -1426,7 +1426,7 @@ function resolveDoc(input) {
* limitations under the License.
*/

/** @const {!{[key: string]: ?Array<AnalyticsEvent}>} */
/** @const {!Object<string,?Array<AnalyticsEvent>>} */
const ShowcaseEvents = {
// Events related to content being potentially unlockable
[ShowcaseEvent.EVENT_SHOWCASE_METER_OFFERED]: [
Expand Down Expand Up @@ -1896,7 +1896,7 @@ class GaaMeteringRegwall {
* @param {{ iframeUrl: string, caslUrl: string }} params
* @return {!Promise<!GaaUserDef|!GoogleIdentityV1|!Object>}
*/
static show({ iframeUrl, caslUrl }) {
static show({iframeUrl, caslUrl}) {
const queryString = GaaUtils.getQueryString();
if (!queryStringHasFreshGaaParams(queryString)) {
const errorMessage =
Expand All @@ -1910,8 +1910,8 @@ class GaaMeteringRegwall {
isFromUserAction: false,
});

GaaMeteringRegwall.render_({ iframeUrl, caslUrl });
GaaMeteringRegwall.sendIntroMessageToGsiIframe_({ iframeUrl });
GaaMeteringRegwall.render_({iframeUrl, caslUrl});
GaaMeteringRegwall.sendIntroMessageToGsiIframe_({iframeUrl});
GaaMeteringRegwall.logButtonClickEvents_();
return GaaMeteringRegwall.getGaaUser_()
.then((gaaUser) => {
Expand Down Expand Up @@ -1981,7 +1981,7 @@ class GaaMeteringRegwall {
* @param {{ caslUrl: string, authorizationUrl: string }} params
* @return {boolean}
*/
static showWithNative3PRegistrationButton({ caslUrl, authorizationUrl }) {
static showWithNative3PRegistrationButton({caslUrl, authorizationUrl}) {
logEvent({
showcaseEvent: ShowcaseEvent.EVENT_SHOWCASE_NO_ENTITLEMENTS_REGWALL,
isFromUserAction: false,
Expand Down Expand Up @@ -2027,7 +2027,7 @@ class GaaMeteringRegwall {
* @nocollapse
* @param {{ iframeUrl: string, caslUrl: string, useNativeMode: (boolean|undefined)}} params
*/
static render_({ iframeUrl, caslUrl, useNativeMode = false }) {
static render_({iframeUrl, caslUrl, useNativeMode = false}) {
const languageCode = getLanguageCodeFromElement(self.document.body);
const publisherName = GaaMeteringRegwall.getPublisherNameFromPageConfig_();
const placeholderPatternForPublication = /<ph name="PUBLICATION".+?\/ph>/g;
Expand Down Expand Up @@ -2118,7 +2118,7 @@ class GaaMeteringRegwall {
// Trigger a fade-in transition.
/** @suppress {suspiciousCode} */
containerEl.offsetHeight; // Trigger a repaint (to prepare the CSS transition).
setImportantStyles(containerEl, { 'opacity': 1 });
setImportantStyles(containerEl, {'opacity': 1});

// Listen for clicks.
GaaMeteringRegwall.addClickListenerOnPublisherSignInButton_();
Expand Down Expand Up @@ -2175,7 +2175,7 @@ class GaaMeteringRegwall {

// Search for publisher name, breadth-first.
for (let i = 0; i < jsonQueue.length; i++) {
const json = /** @type {!{[key: ?]: ?}} */ (jsonQueue[i]);
const json = /** @type {!Object<?,?>} */ (jsonQueue[i]);

// Return publisher name, if possible.
const publisherName = json?.publisher?.name;
Expand Down Expand Up @@ -2226,7 +2226,7 @@ class GaaMeteringRegwall {
isFromUserAction: true,
});

callSwg((swg) => swg.triggerLoginRequest({ linkRequested: false }));
callSwg((swg) => swg.triggerLoginRequest({linkRequested: false}));
});
}

Expand Down Expand Up @@ -2303,7 +2303,7 @@ class GaaMeteringRegwall {
* @nocollapse
* @param {{ iframeUrl: string }} params
*/
static sendIntroMessageToGsiIframe_({ iframeUrl }) {
static sendIntroMessageToGsiIframe_({iframeUrl}) {
// Introduce this window to the publisher's Google Sign-In iframe.
// This lets the iframe send post messages back to this window.
// Without the introduction, the iframe wouldn't have a reference to this window.
Expand All @@ -2321,7 +2321,7 @@ class GaaMeteringRegwall {
};
}

static createNativeRegistrationButton({ googleApiClientId }) {
static createNativeRegistrationButton({googleApiClientId}) {
const languageCode = getLanguageCodeFromElement(self.document.body);
const parentElement = self.document.getElementById(
REGISTRATION_BUTTON_CONTAINER_ID
Expand Down Expand Up @@ -2367,7 +2367,7 @@ class GaaMeteringRegwall {
});
}

static createNative3PRegistrationButton({ authorizationUrl }) {
static createNative3PRegistrationButton({authorizationUrl}) {
const languageCode = getLanguageCodeFromElement(self.document.body);
const parentElement = self.document.getElementById(
REGISTRATION_BUTTON_CONTAINER_ID
Expand Down Expand Up @@ -2413,7 +2413,7 @@ class GaaGoogleSignInButton {
* @nocollapse
* @param {{ allowedOrigins: !Array<string> }} params
*/
static show({ allowedOrigins }) {
static show({allowedOrigins}) {
// Optionally grab language code from URL.
const queryString = GaaUtils.getQueryString();
const queryParams = parseQueryString(queryString);
Expand Down Expand Up @@ -2638,7 +2638,7 @@ class GaaGoogle3pSignInButton {
* the same window, set redirectMode to true. For webview applications
* redirectMode is recommended.
*/
static show({ allowedOrigins, authorizationUrl, redirectMode = false }) {
static show({allowedOrigins, authorizationUrl, redirectMode = false}) {
// Optionally grab language code from URL.
const queryString = GaaUtils.getQueryString();
const queryParams = parseQueryString(queryString);
Expand Down Expand Up @@ -2739,7 +2739,7 @@ class GaaGoogle3pSignInButton {
* @nocollapse
* @param {{ gaaUser: GaaUserDef}} params
*/
static gaaNotifySignIn({ gaaUser }) {
static gaaNotifySignIn({gaaUser}) {
self.opener.postMessage({
stamp: POST_MESSAGE_STAMP,
command: POST_MESSAGE_COMMAND_USER,
Expand All @@ -2756,7 +2756,7 @@ class GaaGoogle3pSignInButton {
* isFromUserAction: boolean,
* }} params
*/
function logEvent({ analyticsEvent, showcaseEvent, isFromUserAction } = {}) {
function logEvent({analyticsEvent, showcaseEvent, isFromUserAction} = {}) {
callSwg((swg) => {
// Get reference to event manager.
swg.getEventManager().then((eventManager) => {
Expand Down
Loading

0 comments on commit f85f4f7

Please sign in to comment.