@firebase/firestore 3.4.14-canary.a80e29cbb → 3.4.14-canary.fcd4b8ac3

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 (36) hide show
  1. package/dist/firestore/src/api/credentials.d.ts +13 -3
  2. package/dist/firestore/src/api/index_configuration.d.ts +5 -0
  3. package/dist/index.d.ts +1 -91
  4. package/dist/index.esm2017.js +1649 -1639
  5. package/dist/index.esm2017.js.map +1 -1
  6. package/dist/index.esm5.js +2295 -2279
  7. package/dist/index.esm5.js.map +1 -1
  8. package/dist/index.node.cjs.js +36 -18
  9. package/dist/index.node.cjs.js.map +1 -1
  10. package/dist/index.node.mjs +36 -18
  11. package/dist/index.node.mjs.map +1 -1
  12. package/dist/index.rn.js +1649 -1639
  13. package/dist/index.rn.js.map +1 -1
  14. package/dist/internal.d.ts +8 -0
  15. package/dist/lite/firestore/src/api/credentials.d.ts +13 -3
  16. package/dist/lite/firestore/src/api/index_configuration.d.ts +5 -0
  17. package/dist/lite/index.browser.esm2017.js +232 -222
  18. package/dist/lite/index.browser.esm2017.js.map +1 -1
  19. package/dist/lite/index.browser.esm5.js +485 -469
  20. package/dist/lite/index.browser.esm5.js.map +1 -1
  21. package/dist/lite/index.node.cjs.js +36 -18
  22. package/dist/lite/index.node.cjs.js.map +1 -1
  23. package/dist/lite/index.node.mjs +36 -18
  24. package/dist/lite/index.node.mjs.map +1 -1
  25. package/dist/lite/index.rn.esm2017.js +232 -222
  26. package/dist/lite/index.rn.esm2017.js.map +1 -1
  27. package/dist/lite/internal.d.ts +3 -0
  28. package/dist/lite/packages/firestore/dist/lite/index.browser.esm2017.d.ts +23 -23
  29. package/dist/lite/packages/firestore/src/api/credentials.d.ts +13 -3
  30. package/dist/lite/packages/firestore/src/api/index_configuration.d.ts +5 -0
  31. package/dist/lite/private.d.ts +3 -0
  32. package/dist/packages/firestore/dist/index.esm2017.d.ts +50 -50
  33. package/dist/packages/firestore/src/api/credentials.d.ts +13 -3
  34. package/dist/packages/firestore/src/api/index_configuration.d.ts +5 -0
  35. package/dist/private.d.ts +7 -92
  36. package/package.json +9 -9
@@ -33,7 +33,7 @@ var grpc__namespace = /*#__PURE__*/_interopNamespace(grpc);
33
33
  var protoLoader__namespace = /*#__PURE__*/_interopNamespace(protoLoader);
34
34
 
35
35
  const name = "@firebase/firestore";
36
- const version$1 = "3.4.14-canary.a80e29cbb";
36
+ const version$1 = "3.4.14-canary.fcd4b8ac3";
37
37
 
38
38
  /**
39
39
  * @license
@@ -86,7 +86,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
86
86
  User.FIRST_PARTY = new User('first-party-uid');
87
87
  User.MOCK_USER = new User('mock-user');
88
88
 
89
- const version = "9.9.2-canary.a80e29cbb";
89
+ const version = "9.9.2-canary.fcd4b8ac3";
90
90
 
91
91
  /**
92
92
  * @license
@@ -641,19 +641,41 @@ class FirebaseAuthCredentialsProvider {
641
641
  * safer to keep the implementation as-is.
642
642
  */
643
643
  class FirstPartyToken {
644
- constructor(gapi, sessionIndex, iamToken) {
644
+ constructor(gapi, sessionIndex, iamToken, authTokenFactory) {
645
+ this.gapi = gapi;
646
+ this.sessionIndex = sessionIndex;
647
+ this.iamToken = iamToken;
648
+ this.authTokenFactory = authTokenFactory;
645
649
  this.type = 'FirstParty';
646
650
  this.user = User.FIRST_PARTY;
647
- this.headers = new Map();
648
- this.headers.set('X-Goog-AuthUser', sessionIndex);
649
- const authHeader = gapi['auth']['getAuthHeaderValueForFirstParty']([]);
650
- if (authHeader) {
651
- this.headers.set('Authorization', authHeader);
651
+ this._headers = new Map();
652
+ }
653
+ /** Gets an authorization token, using a provided factory function, or falling back to First Party GAPI. */
654
+ getAuthToken() {
655
+ if (this.authTokenFactory) {
656
+ return this.authTokenFactory();
652
657
  }
653
- if (iamToken) {
654
- this.headers.set('X-Goog-Iam-Authorization-Token', iamToken);
658
+ else {
659
+ // Make sure this really is a Gapi client.
660
+ hardAssert(!!(typeof this.gapi === 'object' &&
661
+ this.gapi !== null &&
662
+ this.gapi['auth'] &&
663
+ this.gapi['auth']['getAuthHeaderValueForFirstParty']));
664
+ return this.gapi['auth']['getAuthHeaderValueForFirstParty']([]);
655
665
  }
656
666
  }
667
+ get headers() {
668
+ this._headers.set('X-Goog-AuthUser', this.sessionIndex);
669
+ // Use array notation to prevent minification
670
+ const authHeaderTokenValue = this.getAuthToken();
671
+ if (authHeaderTokenValue) {
672
+ this._headers.set('Authorization', authHeaderTokenValue);
673
+ }
674
+ if (this.iamToken) {
675
+ this._headers.set('X-Goog-Iam-Authorization-Token', this.iamToken);
676
+ }
677
+ return this._headers;
678
+ }
657
679
  }
658
680
  /*
659
681
  * Provides user credentials required for the Firestore JavaScript SDK
@@ -661,13 +683,14 @@ class FirstPartyToken {
661
683
  * to applications hosted by Google.
662
684
  */
663
685
  class FirstPartyAuthCredentialsProvider {
664
- constructor(gapi, sessionIndex, iamToken) {
686
+ constructor(gapi, sessionIndex, iamToken, authTokenFactory) {
665
687
  this.gapi = gapi;
666
688
  this.sessionIndex = sessionIndex;
667
689
  this.iamToken = iamToken;
690
+ this.authTokenFactory = authTokenFactory;
668
691
  }
669
692
  getToken() {
670
- return Promise.resolve(new FirstPartyToken(this.gapi, this.sessionIndex, this.iamToken));
693
+ return Promise.resolve(new FirstPartyToken(this.gapi, this.sessionIndex, this.iamToken, this.authTokenFactory));
671
694
  }
672
695
  start(asyncQueue, changeListener) {
673
696
  // Fire with initial uid.
@@ -778,12 +801,7 @@ function makeAuthCredentialsProvider(credentials) {
778
801
  switch (credentials['type']) {
779
802
  case 'gapi':
780
803
  const client = credentials['client'];
781
- // Make sure this really is a Gapi client.
782
- hardAssert(!!(typeof client === 'object' &&
783
- client !== null &&
784
- client['auth'] &&
785
- client['auth']['getAuthHeaderValueForFirstParty']));
786
- return new FirstPartyAuthCredentialsProvider(client, credentials['sessionIndex'] || '0', credentials['iamToken'] || null);
804
+ return new FirstPartyAuthCredentialsProvider(client, credentials['sessionIndex'] || '0', credentials['iamToken'] || null, credentials['authTokenFactory'] || null);
787
805
  case 'provider':
788
806
  return credentials['client'];
789
807
  default: