@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
@@ -8,7 +8,7 @@ import * as grpc from '@grpc/grpc-js';
8
8
  import * as protoLoader from '@grpc/proto-loader';
9
9
 
10
10
  const name = "@firebase/firestore";
11
- const version$1 = "3.4.14-canary.a80e29cbb";
11
+ const version$1 = "3.4.14-canary.fcd4b8ac3";
12
12
 
13
13
  /**
14
14
  * @license
@@ -61,7 +61,7 @@ User.GOOGLE_CREDENTIALS = new User('google-credentials-uid');
61
61
  User.FIRST_PARTY = new User('first-party-uid');
62
62
  User.MOCK_USER = new User('mock-user');
63
63
 
64
- const version = "9.9.2-canary.a80e29cbb";
64
+ const version = "9.9.2-canary.fcd4b8ac3";
65
65
 
66
66
  /**
67
67
  * @license
@@ -616,19 +616,41 @@ class FirebaseAuthCredentialsProvider {
616
616
  * safer to keep the implementation as-is.
617
617
  */
618
618
  class FirstPartyToken {
619
- constructor(gapi, sessionIndex, iamToken) {
619
+ constructor(gapi, sessionIndex, iamToken, authTokenFactory) {
620
+ this.gapi = gapi;
621
+ this.sessionIndex = sessionIndex;
622
+ this.iamToken = iamToken;
623
+ this.authTokenFactory = authTokenFactory;
620
624
  this.type = 'FirstParty';
621
625
  this.user = User.FIRST_PARTY;
622
- this.headers = new Map();
623
- this.headers.set('X-Goog-AuthUser', sessionIndex);
624
- const authHeader = gapi['auth']['getAuthHeaderValueForFirstParty']([]);
625
- if (authHeader) {
626
- this.headers.set('Authorization', authHeader);
626
+ this._headers = new Map();
627
+ }
628
+ /** Gets an authorization token, using a provided factory function, or falling back to First Party GAPI. */
629
+ getAuthToken() {
630
+ if (this.authTokenFactory) {
631
+ return this.authTokenFactory();
627
632
  }
628
- if (iamToken) {
629
- this.headers.set('X-Goog-Iam-Authorization-Token', iamToken);
633
+ else {
634
+ // Make sure this really is a Gapi client.
635
+ hardAssert(!!(typeof this.gapi === 'object' &&
636
+ this.gapi !== null &&
637
+ this.gapi['auth'] &&
638
+ this.gapi['auth']['getAuthHeaderValueForFirstParty']));
639
+ return this.gapi['auth']['getAuthHeaderValueForFirstParty']([]);
630
640
  }
631
641
  }
642
+ get headers() {
643
+ this._headers.set('X-Goog-AuthUser', this.sessionIndex);
644
+ // Use array notation to prevent minification
645
+ const authHeaderTokenValue = this.getAuthToken();
646
+ if (authHeaderTokenValue) {
647
+ this._headers.set('Authorization', authHeaderTokenValue);
648
+ }
649
+ if (this.iamToken) {
650
+ this._headers.set('X-Goog-Iam-Authorization-Token', this.iamToken);
651
+ }
652
+ return this._headers;
653
+ }
632
654
  }
633
655
  /*
634
656
  * Provides user credentials required for the Firestore JavaScript SDK
@@ -636,13 +658,14 @@ class FirstPartyToken {
636
658
  * to applications hosted by Google.
637
659
  */
638
660
  class FirstPartyAuthCredentialsProvider {
639
- constructor(gapi, sessionIndex, iamToken) {
661
+ constructor(gapi, sessionIndex, iamToken, authTokenFactory) {
640
662
  this.gapi = gapi;
641
663
  this.sessionIndex = sessionIndex;
642
664
  this.iamToken = iamToken;
665
+ this.authTokenFactory = authTokenFactory;
643
666
  }
644
667
  getToken() {
645
- return Promise.resolve(new FirstPartyToken(this.gapi, this.sessionIndex, this.iamToken));
668
+ return Promise.resolve(new FirstPartyToken(this.gapi, this.sessionIndex, this.iamToken, this.authTokenFactory));
646
669
  }
647
670
  start(asyncQueue, changeListener) {
648
671
  // Fire with initial uid.
@@ -753,12 +776,7 @@ function makeAuthCredentialsProvider(credentials) {
753
776
  switch (credentials['type']) {
754
777
  case 'gapi':
755
778
  const client = credentials['client'];
756
- // Make sure this really is a Gapi client.
757
- hardAssert(!!(typeof client === 'object' &&
758
- client !== null &&
759
- client['auth'] &&
760
- client['auth']['getAuthHeaderValueForFirstParty']));
761
- return new FirstPartyAuthCredentialsProvider(client, credentials['sessionIndex'] || '0', credentials['iamToken'] || null);
779
+ return new FirstPartyAuthCredentialsProvider(client, credentials['sessionIndex'] || '0', credentials['iamToken'] || null, credentials['authTokenFactory'] || null);
762
780
  case 'provider':
763
781
  return credentials['client'];
764
782
  default: