@inboxsdk/core 2.0.3 → 2.1.1

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": "@inboxsdk/core",
3
- "version": "2.0.3",
3
+ "version": "2.1.1",
4
4
  "description": "Library for building browser extensions for Gmail",
5
5
  "main": "inboxsdk.js",
6
6
  "author": "Streak",
package/pageWorld.js CHANGED
@@ -2864,6 +2864,36 @@ function setupGmailInterceptorOnFrames(mainFrame, jsFrame) {
2864
2864
  }
2865
2865
  });
2866
2866
  }
2867
+
2868
+ // Google API request header values
2869
+ {
2870
+ // harcoding a value observed across multiple accounts to start with.
2871
+ // Will be updated when we see a request, in case Gmail has changed it.
2872
+ let googleApiKey = 'AIzaSyBm7aDMG9actsWSlx-MvrYsepwdnLgz69I';
2873
+ document.addEventListener('inboxSDKgetGoogleRequestHeaders', () => {
2874
+ const authorizationHeader = window.gapi.auth.getAuthHeaderValueForFirstParty([]);
2875
+ const headers = {
2876
+ authorization: authorizationHeader,
2877
+ 'x-goog-api-key': googleApiKey
2878
+ };
2879
+ document.head.setAttribute('data-inboxsdk-google-headers', JSON.stringify(headers));
2880
+ });
2881
+ main_wrappers.push({
2882
+ isRelevantTo(connection) {
2883
+ // check for absolute URLs going to a google domain
2884
+ if (connection.url.startsWith('https://')) {
2885
+ const url = new URL(connection.url);
2886
+ return url.hostname.endsWith('.google.com');
2887
+ }
2888
+ return false;
2889
+ },
2890
+ originalSendBodyLogger(connection) {
2891
+ if (connection.headers['X-Goog-Api-Key']) {
2892
+ googleApiKey = connection.headers['X-Goog-Api-Key'];
2893
+ }
2894
+ }
2895
+ });
2896
+ }
2867
2897
  }
2868
2898
  function triggerEvent(detail) {
2869
2899
  document.dispatchEvent(new CustomEvent('inboxSDKajaxIntercept', {