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 +8 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/lib/GoogleSpreadsheet.ts +9 -6
- package/src/lib/types/auth-types.ts +1 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "google-spreadsheet",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Google Sheets API -- simple interface to read/write data and manage sheets",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"google spreadsheets",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
54
54
|
"eslint-plugin-import": "^2.27.5",
|
|
55
55
|
"eslint-plugin-no-floating-promise": "^1.0.2",
|
|
56
|
-
"google-auth-library": "^10.1
|
|
56
|
+
"google-auth-library": "^10.2.1",
|
|
57
57
|
"ky": "^1.8.2",
|
|
58
58
|
"tsup": "^8.5.0",
|
|
59
59
|
"typescript": "^5.5.4",
|
|
@@ -43,7 +43,14 @@ async function getRequestAuthConfig(auth: GoogleApiAuth): Promise<{
|
|
|
43
43
|
// JWT | OAuth2Client | GoogleAuth | Impersonate | AuthClient
|
|
44
44
|
if ('getRequestHeaders' in auth) {
|
|
45
45
|
const headers = await auth.getRequestHeaders();
|
|
46
|
-
|
|
46
|
+
|
|
47
|
+
// google-auth-library v10 uses a Headers object rather than a plain object
|
|
48
|
+
if ('entries' in headers) {
|
|
49
|
+
return { headers: Object.fromEntries(headers.entries()) };
|
|
50
|
+
} if (_.isObject(headers)) {
|
|
51
|
+
return { headers: headers as Record<string, string> };
|
|
52
|
+
}
|
|
53
|
+
throw new Error('unexpected headers returned from getRequestHeaders');
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
// API key only access passes through the api key as a query param
|
|
@@ -139,11 +146,7 @@ export class GoogleSpreadsheet {
|
|
|
139
146
|
async _setAuthRequestHook(req: Request) {
|
|
140
147
|
const authConfig = await getRequestAuthConfig(this.auth);
|
|
141
148
|
if (authConfig.headers) {
|
|
142
|
-
|
|
143
|
-
const headers = 'entries' in authConfig.headers
|
|
144
|
-
? Object.fromEntries((authConfig.headers as any).entries())
|
|
145
|
-
: authConfig.headers;
|
|
146
|
-
Object.entries(headers).forEach(([key, val]) => {
|
|
149
|
+
Object.entries(authConfig.headers).forEach(([key, val]) => {
|
|
147
150
|
req.headers.set(key, String(val));
|
|
148
151
|
});
|
|
149
152
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
// optional peer dependency - this ts-ignore should help when user is not using it
|
|
2
|
-
// @ts-ignore
|
|
3
|
-
import type { Headers } from 'google-auth-library/build/src/auth/oauth2client';
|
|
4
|
-
|
|
5
1
|
/** single type to handle all valid auth types */
|
|
6
2
|
export type GoogleApiAuth =
|
|
7
3
|
// this simple interface should cover all google-auth-library auth methods
|
|
8
|
-
| { getRequestHeaders: () => Promise<
|
|
4
|
+
| { getRequestHeaders: () => Promise<any> }
|
|
9
5
|
// used to pass in an API key only
|
|
10
6
|
| { apiKey: string }
|
|
11
7
|
// used to pass in a raw token
|