google-spreadsheet 5.0.0 → 5.0.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/dist/index.cjs CHANGED
@@ -3595,7 +3595,13 @@ __name(getAuthMode, "getAuthMode");
3595
3595
  async function getRequestAuthConfig(auth) {
3596
3596
  if ("getRequestHeaders" in auth) {
3597
3597
  const headers = await auth.getRequestHeaders();
3598
- return { headers };
3598
+ if ("entries" in headers) {
3599
+ return { headers: Object.fromEntries(headers.entries()) };
3600
+ }
3601
+ if (isObject2(headers)) {
3602
+ return { headers };
3603
+ }
3604
+ throw new Error("unexpected headers returned from getRequestHeaders");
3599
3605
  }
3600
3606
  if ("apiKey" in auth && auth.apiKey) {
3601
3607
  return { searchParams: { key: auth.apiKey } };
@@ -3663,8 +3669,7 @@ var GoogleSpreadsheet = class _GoogleSpreadsheet {
3663
3669
  async _setAuthRequestHook(req) {
3664
3670
  const authConfig = await getRequestAuthConfig(this.auth);
3665
3671
  if (authConfig.headers) {
3666
- const headers = "entries" in authConfig.headers ? Object.fromEntries(authConfig.headers.entries()) : authConfig.headers;
3667
- Object.entries(headers).forEach(([key, val]) => {
3672
+ Object.entries(authConfig.headers).forEach(([key, val]) => {
3668
3673
  req.headers.set(key, String(val));
3669
3674
  });
3670
3675
  }