docs: function login(opts, cb) {
      assert.object(opts, 'opts');
      assert.string(opts.username, 'opts.username');
      assert.string(opts.password, 'opts.password');
      assert.optionalString(opts.email, 'opts.email');
      assert.func(cb, 'cb');
  
      reg2.ping(opts, function (pingErr, body, pingRes, req) {
          if (!pingRes) {
              assert.ok(pingErr, 'no err *or* res from v2 ping');
              cb(pingErr);
              return;
          }
          if (pingRes.statusCode === 404) {
              // The index doesn't support v2, so try v1 if we can.
              if (opts.email) {
                  reg1.login(opts, cb);
              } else {
                  cb(pingErr);
              }
          } else {
              reg2.login(common.objMerge({
                  // Pass this in so v2 login doesn't need to retry it for the
                  // WWW-Authenticate header.
                  pingRes: pingRes,
                  pingErr: pingErr
              }, opts), cb);
          }
      });
  }