KhronosGroup / glTF-Validator

Tool to validate glTF assets.
Apache License 2.0
370 stars 63 forks source link

Add compatibility with npm 2FA #98

Open emackey opened 6 years ago

emackey commented 6 years ago

I enabled 2FA on my npm account some weeks ago, I guess we haven't published the validator since then. Looks like we need to add a publish pre-step that asks for the OTP code and passes it on the command line with --otp=<code> (without the angle brackets). Note that this should be done just prior to the publish step, as the codes only last 60 seconds at most, and entering the code takes some of that time, so we wouldn't want npm install or other pre-process steps in between the code entry and the publish command.

npm ERR! publish Failed PUT 401
npm ERR! code E401
npm ERR! This operation requires a one-time password from your authenticator.
npm ERR! You can provide a one-time password by passing --otp=<code> to the command you ran.
npm ERR! If you already provided a one-time password then it is likely that you either typoed
npm ERR! it, or it timed out. Please try again.

In the meantime I've published 2.0.0-dev.2.5 by halting the script at this point and manually publishing.

emackey commented 6 years ago

@lexaknyazev Do you know how to interactively prompt the user for a bit of text input during a grind task? Specifically:

https://github.com/KhronosGroup/glTF-Validator/blob/e79eeeca4f39164a73e0f816d2082dc54c490665/tool/grind.dart#L160

I'd like to prompt the user "Please enter your NPM 2FA code" and let them type what's typically a 6-digit string. It can be plain text entry; there's no need to conceal it like a normal password.

Then the next line would be something like:

  run(npmExecutable, arguments: ['publish', '-otp=' + userOtp], workingDirectory: _nodeTarget);
lexaknyazev commented 6 years ago

This is partly blocked on upstream issue regarding forwarding stdin to spawned tasks. I'll update this issue as soon as it's unblocked.