diff --git a/commitlint.config.mjs b/commitlint.config.mjs index 2454b8e..1eacefd 100644 --- a/commitlint.config.mjs +++ b/commitlint.config.mjs @@ -15,6 +15,7 @@ const config = { 'db', 'auth', 'config', + 'storage', // --- Apps --- 'dash', diff --git a/packages/storage/package.json b/packages/storage/package.json index 7e4015b..26d3fa4 100644 --- a/packages/storage/package.json +++ b/packages/storage/package.json @@ -12,7 +12,7 @@ "dependencies": { "@aws-sdk/client-s3": "^3.712.0", "@domus/core": "workspace:*", - "googleapis": "144.0.0" + "googleapis": "171.4.0" }, "devDependencies": { "@domus/tsconfig": "workspace:*", diff --git a/packages/storage/src/gdrive.ts b/packages/storage/src/gdrive.ts index 9a3d0b7..92169aa 100644 --- a/packages/storage/src/gdrive.ts +++ b/packages/storage/src/gdrive.ts @@ -2,6 +2,14 @@ import { Readable } from 'node:stream'; import type { IPrivateStorage } from '@domus/core'; import { google } from 'googleapis'; +/** + * Service account credentials from Google Cloud Console. + */ +interface ServiceAccountCredentials { + client_email: string; + private_key: string; +} + /** * Private storage implementation using Google Drive (Service Account). */ @@ -13,14 +21,13 @@ export class GDriveStorage implements IPrivateStorage { config.serviceAccountKeyBase64, 'base64', ).toString('utf-8'); - const credentials = JSON.parse(decodedKey); + const credentials = JSON.parse(decodedKey) as ServiceAccountCredentials; - const auth = new google.auth.JWT( - credentials.client_email, - undefined, - credentials.private_key, - ['https://www.googleapis.com/auth/drive.file'], - ); + const auth = new google.auth.JWT({ + email: credentials.client_email, + key: credentials.private_key, + scopes: ['https://www.googleapis.com/auth/drive.file'], + }); this.drive = google.drive({ version: 'v3', auth }); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f5f34c9..9b1d921 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -318,8 +318,8 @@ importers: specifier: workspace:* version: link:../core googleapis: - specifier: 144.0.0 - version: 144.0.0 + specifier: 171.4.0 + version: 171.4.0 devDependencies: '@domus/tsconfig': specifier: workspace:* @@ -3517,13 +3517,13 @@ packages: fuzzysort@3.1.0: resolution: {integrity: sha512-sR9BNCjBg6LNgwvxlBd0sBABvQitkLzoVY9MYYROQVX/FvfJ4Mai9LsGhDgd8qYdds0bY77VzYd5iuB+v5rwQQ==} - gaxios@6.7.1: - resolution: {integrity: sha512-LDODD4TMYx7XXdpwxAVRAIAuB0bzv0s+ywFonY46k126qzQHT9ygyoa9tncmOiQmmDrik65UYsEkv3lbfqQ3yQ==} - engines: {node: '>=14'} + gaxios@7.1.4: + resolution: {integrity: sha512-bTIgTsM2bWn3XklZISBTQX7ZSddGW+IO3bMdGaemHZ3tbqExMENHLx6kKZ/KlejgrMtj8q7wBItt51yegqalrA==} + engines: {node: '>=18'} - gcp-metadata@6.1.1: - resolution: {integrity: sha512-a4tiq7E0/5fTjxPAaH4jpjkSv/uCaU2p5KC6HVGrvl0cDjA8iBZv4vv1gyzlmK0ZUKqwpOyQMKzZQe3lTit77A==} - engines: {node: '>=14'} + gcp-metadata@8.1.2: + resolution: {integrity: sha512-zV/5HKTfCeKWnxG0Dmrw51hEWFGfcF2xiXqcA3+J90WDuP0SvoiSO5ORvcBsifmx/FoIjgQN3oNOGaQ5PhLFkg==} + engines: {node: '>=18'} gensync@1.0.0-beta.2: resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} @@ -3573,21 +3573,21 @@ packages: resolution: {integrity: sha512-wHTUcDUoZ1H5/0iVqEudYW4/kAlN5cZ3j/bXn0Dpbizl9iaUVeWSHqiOjsgk6OW2bkLclbBjzewBz6weQ1zA2Q==} engines: {node: '>=18'} - google-auth-library@9.15.1: - resolution: {integrity: sha512-Jb6Z0+nvECVz+2lzSMt9u98UsoakXxA2HGHMCxh+so3n90XgYWkq5dur19JAJV7ONiJY22yBTyJB1TSkvPq9Ng==} - engines: {node: '>=14'} + google-auth-library@10.6.2: + resolution: {integrity: sha512-e27Z6EThmVNNvtYASwQxose/G57rkRuaRbQyxM2bvYLLX/GqWZ5chWq2EBoUchJbCc57eC9ArzO5wMsEmWftCw==} + engines: {node: '>=18'} - google-logging-utils@0.0.2: - resolution: {integrity: sha512-NEgUnEcBiP5HrPzufUkBzJOD/Sxsco3rLNo1F1TNf7ieU8ryUzBhqba8r756CjLX7rn3fHl6iLEwPYuqpoKgQQ==} + google-logging-utils@1.1.3: + resolution: {integrity: sha512-eAmLkjDjAFCVXg7A1unxHsLf961m6y17QFqXqAXGj/gVkKFrEICfStRfwUlGNfeCEjNRa32JEWOUTlYXPyyKvA==} engines: {node: '>=14'} - googleapis-common@7.2.0: - resolution: {integrity: sha512-/fhDZEJZvOV3X5jmD+fKxMqma5q2Q9nZNSF3kn1F18tpxmA86BcTxAGBQdM0N89Z3bEaIs+HVznSmFJEAmMTjA==} - engines: {node: '>=14.0.0'} + googleapis-common@8.0.1: + resolution: {integrity: sha512-eCzNACUXPb1PW5l0ULTzMHaL/ltPRADoPgjBlT8jWsTbxkCp6siv+qKJ/1ldaybCthGwsYFYallF7u9AkU4L+A==} + engines: {node: '>=18.0.0'} - googleapis@144.0.0: - resolution: {integrity: sha512-ELcWOXtJxjPX4vsKMh+7V+jZvgPwYMlEhQFiu2sa9Qmt5veX8nwXPksOWGGN6Zk4xCiLygUyaz7xGtcMO+Onxw==} - engines: {node: '>=14.0.0'} + googleapis@171.4.0: + resolution: {integrity: sha512-xybFL2SmmUgIifgsbsRQYRdNrSAYwxWZDmkZTGjUIaRnX5jPqR8el/cEvo6rCqh7iaZx6MfEPS/lrDgZ0bymkg==} + engines: {node: '>=18'} gopd@1.2.0: resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} @@ -3600,10 +3600,6 @@ packages: resolution: {integrity: sha512-5bJ+nf/UCpAjHM8i06fl7eLyVC9iuNAjm9qzkiu2ZGhM0VscSvS6WDPfAwkdkBuoXGM9FJSbKl6wylMwP9Ktig==} engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0} - gtoken@7.1.0: - resolution: {integrity: sha512-pCcEwRi+TKpMlxAQObHDQ56KawURgyAf6jtIY046fJ5tIv3zDe/LEIubckAO8fj6JnAxLdmWkUfNyulQ2iKdEw==} - engines: {node: '>=14.0.0'} - has-flag@4.0.0: resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} engines: {node: '>=8'} @@ -4127,15 +4123,6 @@ packages: engines: {node: '>=10.5.0'} deprecated: Use your platform's native DOMException instead - node-fetch@2.7.0: - resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==} - engines: {node: 4.x || >=6.0.0} - peerDependencies: - encoding: ^0.1.0 - peerDependenciesMeta: - encoding: - optional: true - node-fetch@3.3.2: resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -4771,9 +4758,6 @@ packages: resolution: {integrity: sha512-LktZQb3IeoUWB9lqR5EWTHgW/VTITCXg4D21M+lvybRVdylLrRMnqaIONLVb5mav8vM19m44HIcGq4qASeu2Qw==} engines: {node: '>=16'} - tr46@0.0.3: - resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} - tree-kill@1.2.2: resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==} hasBin: true @@ -4919,10 +4903,6 @@ packages: resolution: {integrity: sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w==} hasBin: true - uuid@9.0.1: - resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==} - hasBin: true - uzip@0.20201231.0: resolution: {integrity: sha512-OZeJfZP+R0z9D6TmBgLq2LHzSSptGMGDGigGiEe0pr8UBe/7fdflgHlHBNDASTXB5jnFuxHpNaJywSg8YFeGng==} @@ -5022,12 +5002,6 @@ packages: resolution: {integrity: sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==} engines: {node: '>= 8'} - webidl-conversions@3.0.1: - resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} - - whatwg-url@5.0.0: - resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} - which@2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} @@ -8208,24 +8182,20 @@ snapshots: fuzzysort@3.1.0: {} - gaxios@6.7.1: + gaxios@7.1.4: dependencies: extend: 3.0.2 https-proxy-agent: 7.0.6 - is-stream: 2.0.1 - node-fetch: 2.7.0 - uuid: 9.0.1 + node-fetch: 3.3.2 transitivePeerDependencies: - - encoding - supports-color - gcp-metadata@6.1.1: + gcp-metadata@8.1.2: dependencies: - gaxios: 6.7.1 - google-logging-utils: 0.0.2 + gaxios: 7.1.4 + google-logging-utils: 1.1.3 json-bigint: 1.0.0 transitivePeerDependencies: - - encoding - supports-color gensync@1.0.0-beta.2: {} @@ -8281,38 +8251,34 @@ snapshots: dependencies: ini: 4.1.1 - google-auth-library@9.15.1: + google-auth-library@10.6.2: dependencies: base64-js: 1.5.1 ecdsa-sig-formatter: 1.0.11 - gaxios: 6.7.1 - gcp-metadata: 6.1.1 - gtoken: 7.1.0 + gaxios: 7.1.4 + gcp-metadata: 8.1.2 + google-logging-utils: 1.1.3 jws: 4.0.1 transitivePeerDependencies: - - encoding - supports-color - google-logging-utils@0.0.2: {} + google-logging-utils@1.1.3: {} - googleapis-common@7.2.0: + googleapis-common@8.0.1: dependencies: extend: 3.0.2 - gaxios: 6.7.1 - google-auth-library: 9.15.1 + gaxios: 7.1.4 + google-auth-library: 10.6.2 qs: 6.15.0 url-template: 2.0.8 - uuid: 9.0.1 transitivePeerDependencies: - - encoding - supports-color - googleapis@144.0.0: + googleapis@171.4.0: dependencies: - google-auth-library: 9.15.1 - googleapis-common: 7.2.0 + google-auth-library: 10.6.2 + googleapis-common: 8.0.1 transitivePeerDependencies: - - encoding - supports-color gopd@1.2.0: {} @@ -8321,14 +8287,6 @@ snapshots: graphql@16.13.2: {} - gtoken@7.1.0: - dependencies: - gaxios: 6.7.1 - jws: 4.0.1 - transitivePeerDependencies: - - encoding - - supports-color - has-flag@4.0.0: {} has-symbols@1.1.0: {} @@ -8771,10 +8729,6 @@ snapshots: node-domexception@1.0.0: {} - node-fetch@2.7.0: - dependencies: - whatwg-url: 5.0.0 - node-fetch@3.3.2: dependencies: data-uri-to-buffer: 4.0.1 @@ -9466,8 +9420,6 @@ snapshots: dependencies: tldts: 7.0.28 - tr46@0.0.3: {} - tree-kill@1.2.2: {} ts-essentials@10.1.1(typescript@6.0.2): @@ -9602,8 +9554,6 @@ snapshots: uuid@13.0.0: {} - uuid@9.0.1: {} - uzip@0.20201231.0: {} validate-npm-package-name@7.0.2: {} @@ -9664,13 +9614,6 @@ snapshots: web-streams-polyfill@3.3.3: {} - webidl-conversions@3.0.1: {} - - whatwg-url@5.0.0: - dependencies: - tr46: 0.0.3 - webidl-conversions: 3.0.1 - which@2.0.2: dependencies: isexe: 2.0.0