Nodejs-storage: "SubtleCrypto not found" when calling getSignedUrl

Created on 4 May 2019  ยท  16Comments  ยท  Source: googleapis/nodejs-storage

Environment details

  • OS: Windows 10
  • Node.js version: 10.9.0
  • npm version: 6.2.0
  • @google-cloud/storage version: 2.5.0

Steps to reproduce

  1. Attempt the example given here

I have recently started seeing the following error when trying to get a signed url:

SubtleCrypto not found. Make sure it's an https:// website.

Following the stack trace, it seems like the node library is trying to call some sort of browser crypto library - it looks like this:

at new BrowserCrypto(C:\...\node_modules\google-auth-library\build\src\crypto\browser\crypto.js

I've reverted back to version 2.3.0 of the library and the bug went away, so it seems as it if was introduced somewhere between 2.3 and 2.5.

storage needs more info question web

Most helpful comment

@AVaksman, the upgraded version does fix the error for me, thank you!

To upgrade I just issued:
npm upgrade firebase-admin

All 16 comments

Hi @artemzakharov. I tried both the examples in the documentation, they worked for me. Can you please provide the exact code you are trying with or the complete error you are getting?

Greetings @artemzakharov! Are you by chance running your code in electron, a chrome app, or some other non-nodejs native environment?

Hey guys, I updated back to 2.5.0 to re-create the issue and have found that it's no longer occurring... no idea what changed, but I can no longer reproduce it either, so I suppose that's a good thing! I'll re-open the issue if it starts showing up again.

I have encountered this issue on 2.5.0.

    SubtleCrypto not found. Make sure it's an https:// website.

      at new BrowserCrypto (node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/crypto/browser/crypto.js:40:19)
      at Object.createCrypto (node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/crypto/crypto.js:23:16)
      at GoogleAuth.<anonymous> (node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/googleauth.js:629:37)
      at fulfilled (node_modules/@google-cloud/common/node_modules/google-auth-library/build/src/auth/googleauth.js:19:58)

I get it from running a test written in typescript with jest and ts-jest. our tsconfig is:

{
  "compilerOptions": {
    "module": "commonjs",
    "outDir": "build",
    "rootDir": "src",
    "strict": true,
    "inlineSourceMap": true,
    "target": "es2017",
    "lib": ["es2017", "esnext.asynciterable", "dom"],
    "noImplicitAny": false
  },
  "include": [
    "./src/"
  ]
}

I'm using jest to test my firebase functions and hit the same issue when calling getSignedUrl, from what I can tell all my configuration is setup to properly talk with the storage service.

Going to go ahead and re-open the issue since it looks like others are running into this.

@bag-man @mpalmerlee, Please test with the latest version (3.0.x) and see if the same issue is still occurs

๐Ÿ‘‹ hey folks, I think I fixed this one. It does require the latest version of google-auth-library to be installed, so if you wouldn't mind:

$ rm -rf node_modules package-lock.json
$ npm install

And try again :)

Thanks @vishald123 and @JustinBeckwith I'll give it a try, I'm using the getSignedUrl method through the firebase-admin library, so I might have to do some package.json gymnastics to get the correct versions.

Hmmm, I'm having trouble forcing firebase-admin to use @google-cloud/storage version ^3.0.0, if I try to force it through the package-lock.json file it shows up as invalid and fails to load the library.

With my current configuration, here is the results of npm list google-auth-library:

โ””โ”€โ”ฌ [email protected]
  โ”œโ”€โ”ฌ @google-cloud/[email protected]
  โ”‚ โ””โ”€โ”ฌ [email protected]
  โ”‚   โ””โ”€โ”€ [email protected]
  โ””โ”€โ”ฌ @google-cloud/[email protected]
    โ”œโ”€โ”ฌ @google-cloud/[email protected]
    โ”‚ โ””โ”€โ”€ [email protected]
    โ””โ”€โ”ฌ [email protected]
      โ””โ”€โ”€ [email protected]

Yar. I submitted this to pull it all up to date:
https://github.com/firebase/firebase-admin-node/pull/588

Thank you @JustinBeckwith! I've subscribed to that PR, once it is released I'll be able to test this.

firebase/firebase-admin-node#588

I tried update the the package of storage to v 3++ still not working. or Is it about IAM in google cloud?

@mpalmerlee does it work fine with the new release?

@modernduck can you please try with the new release as well.
Also have you tried loading everything fresh as mentioned above?

$ rm -rf node_modules package-lock.json
$ npm install

@AVaksman, the upgraded version does fix the error for me, thank you!

To upgrade I just issued:
npm upgrade firebase-admin

Was this page helpful?
0 / 5 - 0 ratings