Skip to content
This repository was archived by the owner on Nov 20, 2025. It is now read-only.
This repository was archived by the owner on Nov 20, 2025. It is now read-only.

Browser/crypto base64 decoding strictly required padding #716

@Quutti

Description

@Quutti

Environment details

  • OS: Windows 10
  • Node.js version: 8.11.1
  • npm version: 5.6
  • google-auth-library version: 4.0.0

Description

Browser implementation of crypto uses npm package base64-js to decode base64 strings. Base64-js package strictly requires padding on base64 strings, so when the base64 string is passed to the function the user is represented with an error "Can't parse token envelope".

For an example OAuth2Client.verifyIdToken (internally calls verifySignedJwtWithCertsAsync) -method uses crypto to decode base64 strings. In this case when id_token is passed, the client implementation might raise an error for user if id_token segment 0 or 1 is non-modular with 4.

NodeJS implementation of crypto uses Buffers which is not strict with padding, so NodeJS implementation is working correctly.

There is an issue on base64-js Github repository issue tracker (beatgammit/base64-js#45), but the issue is quite old. It might be better for you guys to create a simple ADHoC fix for this (I can provide a PR) or change the base64 decoding library.

Metadata

Metadata

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions