Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type definitions in google-auth-library >= 9.5.0 incompatible with client libraries #1768

Closed
AlexLloyd0 opened this issue Mar 5, 2024 · 3 comments
Assignees

Comments

@AlexLloyd0
Copy link

Workaround

Use an older version of google-auth-library: "google-auth-library": "^9.4.2 <9.5.0",

Bug report

Environment details

  • which product (packages/*): "@google-cloud/storage": "^7.7.0","google-auth-library": ">=9.5.0",
  • OS: Not relevant
  • Node.js version: 18.14.0
  • npm version: yarn 1.22.19
  • google-cloud-node version: 7.7.0

Steps to reproduce

  1. Add "@google-cloud/storage": "^7.7.0","google-auth-library": ">=9.5.0" to package.json
  2. Yarn install
  3. See type error when building code
  const auth = new GoogleAuth({});

  const client = await auth.getClient();

  const targetServiceAccount =
    'TARGET-SERVICE-ACCOUNT@YOUR-PROJECT.iam.gserviceaccount.com';
  const impersonated = new Impersonated({
    sourceClient: client,
    targetPrincipal: targetServiceAccount,
    lifetime: 3600, // Token lifetime in seconds
    targetScopes: ['https://www.googleapis.com/auth/devstorage.read_write'],
  });

  return new Storage({
    projectId: 'YOUR-PROJECT-ID',
    authClient: impersonated,
  });
       libs/core-services/src/CloudStorageService.ts:36:5 - error TS2322: Type 'Impersonated' is not assignable to type 'AuthClient | GoogleAuth<JSONClient> | undefined'.
         Type 'Impersonated' is not assignable to type 'AuthClient'.
           Property 'addSharedMetadataHeaders' is protected but type 'AuthClient' is not a class derived from 'AuthClient'.
       
         34 |   return new Storage({
         35 |     projectId: 'YOUR-PROJECT-ID',
       > 36 |     authClient: impersonated,
            |     ^
         37 |   });
         38 | };
         39 | 
       
       Found 1 error.

@ddelgrosso1 ddelgrosso1 transferred this issue from googleapis/google-cloud-node Mar 6, 2024
@ddelgrosso1
Copy link

Moving this issue from cloud-node to auth as it seems auth related.

@danielbankhead danielbankhead self-assigned this Mar 6, 2024
@danielbankhead
Copy link
Member

@AlexLloyd0 That's fascinating, do you mind sharing the output of npm ls google-auth-library? Additionally does removing node_modules and the package lock make any difference (rm -rf node_modules/ package-lock.json in the package's root directory)?

@danielbankhead danielbankhead closed this as not planned Won't fix, can't repro, duplicate, stale Mar 12, 2024
@AlexLloyd0
Copy link
Author

Hi @danielbankhead, thanks for the reply. I can't actually repro this any more - I should have recorded the exact package versions and hashes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants