nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: jshint/jshint
Pull request #2230 (2015-03-03 00:01:58)

[[FIX]] Correctly enforce maxparams:0
It protects against a relatively benign edge case, but it is absolutely incorrect behavior for the parser to fail to enforce `maxparams` when it is set to 0.

Previously setting maxparams:0 would cause the check to short-circuit,
permitting any number of parameters without issuing a warning. This PR
fixes the bug by testing whether maxparams is a number, instead of
whether it is truthy.




Patch:
diff --git a/src/jshint.js b/src/jshint.js
index 9b5d543d..b8721399 100644
--- a/src/jshint.js
+++ b/src/jshint.js
@@ -3110,7 +3110,7 @@ var JSHINT = (function() {
       verifyMaxParametersPerFunction: function(params) {
         params = params || [];
 
-        if (state.option.maxparams && params.length > state.option.maxparams) {
+        if (_.isNumber(state.option.maxparams) && params.length > state.option.maxparams) {
           warning("W072", functionStartToken, params.length);
         }
       },


Test patch:
diff --git a/tests/unit/options.js b/tests/unit/options.js
index 21413d45..97e25fe0 100644
--- a/tests/unit/options.js
+++ b/tests/unit/options.js
@@ -1617,6 +1617,10 @@ exports.maxparams = function (test) {
   TestRun(test)
     .test(src, { es3: true, maxparams: 3 });
 
+  TestRun(test)
+    .addError(4, "This function has too many parameters. (3)")
+    .test(src, {es3: true, maxparams: 0 });
+
   TestRun(test)
     .test(src, { es3: true });
Repository: jshint/jshint
Pull request #2237 (2015-03-06 16:41:57)

Fix issue #1825: use of `!` with `instanceof` should require parentheses


Patch:
diff --git a/src/jshint.js b/src/jshint.js
index 9b5d543d..d6d7d549 100644
--- a/src/jshint.js
+++ b/src/jshint.js
@@ -1147,7 +1147,7 @@ var JSHINT = (function() {
       if (!w) {
         nobreaknonadjacent(state.tokens.prev, state.tokens.curr);
       }
-      if (s === "in" && left.id === "!") {
+      if ((s === "in" || s === "instanceof") && left.id === "!") {
         warning("W018", left, "!");
       }
       if (typeof f === "function") {


Test patch:
diff --git a/tests/unit/parser.js b/tests/unit/parser.js
index 3fafb444..4f24a4a3 100644
--- a/tests/unit/parser.js
+++ b/tests/unit/parser.js
@@ -148,6 +148,7 @@ exports.relations = function (test) {
     "var f = (a === !'hi');",
     "var g = (!2 === 1);",
     "var h = (![1, 2, 3] === []);",
+    "var i = (!([]) instanceof Array);"
   ];
 
   var run = TestRun(test)
@@ -159,7 +160,8 @@ exports.relations = function (test) {
     .addError(6, "Confusing use of '!'.", {character : 10})
     .addError(7, "Confusing use of '!'.", {character : 16})
     .addError(8, "Confusing use of '!'.", {character : 10})
-    .addError(9, "Confusing use of '!'.", {character : 10});
+    .addError(9, "Confusing use of '!'.", {character : 10})
+    .addError(10, "Confusing use of '!'.", {character : 10});
   run.test(code, {es3: true});
   run.test(code, {}); // es5
   run.test(code, {esnext: true});
Repository: auth0/auth0.js
Pull request #316 (2017-01-16 18:39:51)

Fallback to math.random if there is no crypto support

codecov-io: ## [Current coverage](https://codecov.io/gh/auth0/auth0.js/pull/316?src=pr) is 98.83% (diff: 90.00%)
> Merging [#316](https://codecov.io/gh/auth0/auth0.js/pull/316?src=pr) into [master](https://codecov.io/gh/auth0/auth0.js/branch/master?src=pr) will increase coverage by **73.66%**

```diff
@@             master       #316   diff @@
==========================================
  Files            30         30          
  Lines          1025       1032     +7   
  Methods         173        174     +1   
  Messages          0          0          
  Branches        163        164     +1   
==========================================
+ Hits            258       1020   +762   
+ Misses          767         12   -755   
  Partials          0          0          
```

> Powered by [Codecov](https://codecov.io?src=pr). Last update [523b08c...75eb4b8](https://codecov.io/gh/auth0/auth0.js/compare/523b08ce19c9802f7320cc2d8f5710ee2954c753...75eb4b8d2dd0aef8f750805da9638a238a7f6360?src=pr)

Patch:
diff --git a/src/helper/random.js b/src/helper/random.js
index 84cdb6e..cb6efc6 100644
--- a/src/helper/random.js
+++ b/src/helper/random.js
@@ -1,13 +1,28 @@
 var windowHelper = require('./window');
 
+const randomFallback = {
+  getRandomValues: function(buffer) {
+    for(var a = 0; a < buffer.length; a++) {
+      buffer[a] = Math.floor(Math.random() * 255);
+    }
+
+    return buffer;
+  }
+}
+
 function randomString(length) {
-  var bytes = new Uint8Array(length);
+  if (typeof(Uint8Array) !== "undefined") {
+    var bytes = new Uint8Array(length);
+  } else {
+    var bytes = new Array(length);
+  }
+
   var result = [];
   var charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._~';
 
   var cryptoObj = windowHelper.getWindow().crypto || windowHelper.getWindow().msCrypto;
-  if (!cryptoObj) {
-    return null;
+  if (!cryptoObj || typeof(Uint8Array) === "undefined") {
+    cryptoObj = randomFallback;
   }
 
   var random = cryptoObj.getRandomValues(bytes);


Test patch:
diff --git a/test/helper/object.test.js b/test/helper/object.test.js
index 730202e..c6245f5 100644
--- a/test/helper/object.test.js
+++ b/test/helper/object.test.js
@@ -420,7 +420,7 @@ describe('helpers', function () {
       });
     });
 
-    it('should not breack the string', function () {
+    it('should not break the string', function () {
       var object = "some random string";
 
       var newObject = objectHelper.toCamelCase(object);
diff --git a/test/helper/random.test.js b/test/helper/random.test.js
index 4f54c85..6c1cbc2 100644
--- a/test/helper/random.test.js
+++ b/test/helper/random.test.js
@@ -64,7 +64,8 @@ describe('helpers random', function () {
 
     it('return the a random string', function () {
       var string = random.randomString(10);
-      expect(string).to.be(null);
+      expect(string).to.not.be(null);
+      expect(string).to.be.a('string');
     });
   });
 });
Repository: auth0/auth0.js
Pull request #320 (2017-01-17 16:18:31)

Revert "Fallback to math.random if there is no crypto support"
Reverts auth0/auth0.js#316


Patch:
diff --git a/src/helper/random.js b/src/helper/random.js
index cb6efc6..84cdb6e 100644
--- a/src/helper/random.js
+++ b/src/helper/random.js
@@ -1,28 +1,13 @@
 var windowHelper = require('./window');
 
-const randomFallback = {
-  getRandomValues: function(buffer) {
-    for(var a = 0; a < buffer.length; a++) {
-      buffer[a] = Math.floor(Math.random() * 255);
-    }
-
-    return buffer;
-  }
-}
-
 function randomString(length) {
-  if (typeof(Uint8Array) !== "undefined") {
-    var bytes = new Uint8Array(length);
-  } else {
-    var bytes = new Array(length);
-  }
-
+  var bytes = new Uint8Array(length);
   var result = [];
   var charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvwxyz-._~';
 
   var cryptoObj = windowHelper.getWindow().crypto || windowHelper.getWindow().msCrypto;
-  if (!cryptoObj || typeof(Uint8Array) === "undefined") {
-    cryptoObj = randomFallback;
+  if (!cryptoObj) {
+    return null;
   }
 
   var random = cryptoObj.getRandomValues(bytes);


Test patch:
diff --git a/test/helper/object.test.js b/test/helper/object.test.js
index c6245f5..730202e 100644
--- a/test/helper/object.test.js
+++ b/test/helper/object.test.js
@@ -420,7 +420,7 @@ describe('helpers', function () {
       });
     });
 
-    it('should not break the string', function () {
+    it('should not breack the string', function () {
       var object = "some random string";
 
       var newObject = objectHelper.toCamelCase(object);
diff --git a/test/helper/random.test.js b/test/helper/random.test.js
index 6c1cbc2..4f54c85 100644
--- a/test/helper/random.test.js
+++ b/test/helper/random.test.js
@@ -64,8 +64,7 @@ describe('helpers random', function () {
 
     it('return the a random string', function () {
       var string = random.randomString(10);
-      expect(string).to.not.be(null);
-      expect(string).to.be.a('string');
+      expect(string).to.be(null);
     });
   });
 });
Repository: auth0/auth0.js
Pull request #470 (2017-07-18 19:09:29)

Send empty verifier when can't access sessionStorage


Patch:
diff --git a/src/web-auth/cross-origin-authentication.js b/src/web-auth/cross-origin-authentication.js
index efddb7a..24e8d45 100644
--- a/src/web-auth/cross-origin-authentication.js
+++ b/src/web-auth/cross-origin-authentication.js
@@ -79,6 +79,16 @@ CrossOriginAuthentication.prototype.login = function(options, cb) {
   });
 };
 
+function tryGetVerifier(theWindow, key) {
+  try {
+    var verifier = theWindow.sessionStorage[key];
+    theWindow.sessionStorage.removeItem(key);
+    return verifier;
+  } catch (e) {
+    return '';
+  }
+}
+
 /**
  * Runs the callback code for the cross origin authentication call. This method is meant to be called by the cross origin authentication callback url.
  *
@@ -93,8 +103,7 @@ CrossOriginAuthentication.prototype.callback = function() {
       return;
     }
     var key = createKey(evt.origin, evt.data.request.id);
-    var verifier = theWindow.sessionStorage[key];
-    theWindow.sessionStorage.removeItem(key);
+    var verifier = tryGetVerifier(theWindow, key);
 
     evt.source.postMessage(
       {


Test patch:
diff --git a/test/web-auth/cross-origin-authentication.test.js b/test/web-auth/cross-origin-authentication.test.js
index e5ba42a..d9488dc 100644
--- a/test/web-auth/cross-origin-authentication.test.js
+++ b/test/web-auth/cross-origin-authentication.test.js
@@ -344,6 +344,30 @@ describe('auth0.WebAuth.crossOriginAuthentication', function() {
         });
         expect(theCall.args[1]).to.be('https://me.auth0.com');
       });
+      it('should send empty verifier in the response when sessionStorage can not be accessed', function() {
+        global.window.sessionStorage = undefined;
+        this.co.callback();
+        var onMessageHandler = global.window.addEventListener.getCall(0).args[1];
+        var evt = {
+          origin: 'https://me.auth0.com',
+          data: {
+            type: 'co_verifier_request',
+            request: {
+              id: 'co_id'
+            }
+          },
+          source: {
+            postMessage: spy()
+          }
+        };
+        onMessageHandler(evt);
+        var theCall = evt.source.postMessage.getCall(0);
+        expect(theCall.args[0]).to.be.eql({
+          type: 'co_verifier_response',
+          response: { verifier: '' }
+        });
+        expect(theCall.args[1]).to.be('https://me.auth0.com');
+      });
     });
   });
 });
Repository: auth0/auth0.js
Pull request #487 (2017-08-11 12:40:12)

Fixed credentialType url


Patch:
diff --git a/src/web-auth/index.js b/src/web-auth/index.js
index cfce345..e63f927 100644
--- a/src/web-auth/index.js
+++ b/src/web-auth/index.js
@@ -468,7 +468,7 @@ WebAuth.prototype.login = function(options, cb) {
 WebAuth.prototype.passwordlessLogin = function(options, cb) {
   var loginOptions = objectHelper.extend(
     {
-      credentialType: 'http://auth0.com/oauth/credential-type/passwordless/otp',
+      credentialType: 'http://auth0.com/oauth/grant-type/passwordless/otp',
       realm: options.connection,
       username: options.email || options.phoneNumber,
       otp: options.verificationCode


Test patch:
diff --git a/test/web-auth/cross-origin-authentication.test.js b/test/web-auth/cross-origin-authentication.test.js
index d9488dc..137c703 100644
--- a/test/web-auth/cross-origin-authentication.test.js
+++ b/test/web-auth/cross-origin-authentication.test.js
@@ -111,7 +111,7 @@ describe('auth0.WebAuth.crossOriginAuthentication', function() {
         return new RequestMock({
           body: {
             client_id: '...',
-            credential_type: 'http://auth0.com/oauth/credential-type/passwordless/otp',
+            credential_type: 'http://auth0.com/oauth/grant-type/passwordless/otp',
             username: 'me@example.com',
             otp: '123456',
             realm: 'email'
@@ -134,7 +134,7 @@ describe('auth0.WebAuth.crossOriginAuthentication', function() {
         username: 'me@example.com',
         otp: '123456',
         realm: 'email',
-        credentialType: 'http://auth0.com/oauth/credential-type/passwordless/otp'
+        credentialType: 'http://auth0.com/oauth/grant-type/passwordless/otp'
       });
       expect(this.webAuthSpy.authorize.getCall(0).args[0]).to.be.eql({
         loginTicket: 'a_login_ticket',
diff --git a/test/web-auth/web-auth.test.js b/test/web-auth/web-auth.test.js
index 08579c2..9af28d7 100644
--- a/test/web-auth/web-auth.test.js
+++ b/test/web-auth/web-auth.test.js
@@ -840,7 +840,7 @@ describe('auth0.WebAuth', function() {
     });
     it('should call `crossOriginAuthentication.login` with phoneNumber', function(done) {
       var expectedOptions = {
-        credentialType: 'http://auth0.com/oauth/credential-type/passwordless/otp',
+        credentialType: 'http://auth0.com/oauth/grant-type/passwordless/otp',
         realm: 'sms',
         username: '+55165134',
         otp: '123456'
@@ -864,7 +864,7 @@ describe('auth0.WebAuth', function() {
     });
     it('should call `crossOriginAuthentication.login` with email', function(done) {
       var expectedOptions = {
-        credentialType: 'http://auth0.com/oauth/credential-type/passwordless/otp',
+        credentialType: 'http://auth0.com/oauth/grant-type/passwordless/otp',
         realm: 'email',
         username: 'the@email.com',
         otp: '123456'
Repository: auth0/auth0.js
Pull request #544 (2017-11-03 17:59:41)

Don't return errors in getSSOData when the error is login_required


Patch:
diff --git a/src/authentication/index.js b/src/authentication/index.js
index b9e9394..7abf499 100644
--- a/src/authentication/index.js
+++ b/src/authentication/index.js
@@ -361,6 +361,9 @@ Authentication.prototype.getSSOData = function(cb) {
     },
     function(err, result) {
       if (err) {
+        if (err.error === 'login_required') {
+          return cb(null, { sso: false });
+        }
         if (err.error === 'consent_required') {
           err.error_description =
             'Consent required. When using `getSSOData`, the user has to be authenticated with the following the scope: `openid profile email`.';


Test patch:
diff --git a/test/authentication/authentication.test.js b/test/authentication/authentication.test.js
index cb239e2..4c837c1 100644
--- a/test/authentication/authentication.test.js
+++ b/test/authentication/authentication.test.js
@@ -249,6 +249,18 @@ describe('auth0.authentication', function() {
 
       this.webAuthSpy.checkSession.lastCall.args[1]({ some: 'error' });
     });
+    it('do not return error if error === login_required', function(done) {
+      this.auth0.getSSOData(function(err, result) {
+        expect(err).to.be(null);
+        expect(result).to.be.eql({ sso: false });
+        done();
+      });
+
+      this.webAuthSpy.checkSession.lastCall.args[1]({
+        error: 'login_required',
+        error_description: 'foobar'
+      });
+    });
     it('provides a better description for consent_required error', function(done) {
       this.auth0.getSSOData(function(err, result) {
         expect(err).to.be.eql({
Repository: auth0/auth0.js
Pull request #554 (2017-11-07 21:58:40)

Using email as lastUsedUsername in getSSOData


Patch:
diff --git a/src/authentication/index.js b/src/authentication/index.js
index 7abf499..12110ae 100644
--- a/src/authentication/index.js
+++ b/src/authentication/index.js
@@ -376,7 +376,7 @@ Authentication.prototype.getSSOData = function(cb) {
           name: connectionName
         },
         lastUsedUserID: result.idTokenPayload.sub,
-        lastUsedUsername: result.idTokenPayload.name,
+        lastUsedUsername: result.idTokenPayload.email || result.idTokenPayload.name,
         lastUsedClientID: clientId,
         sessionClients: [clientId],
         sso: true


Test patch:
diff --git a/test/authentication/authentication.test.js b/test/authentication/authentication.test.js
index 4c837c1..38061c1 100644
--- a/test/authentication/authentication.test.js
+++ b/test/authentication/authentication.test.js
@@ -276,7 +276,27 @@ describe('auth0.authentication', function() {
         error_description: 'foobar'
       });
     });
-    it('returns ssoData object', function(done) {
+    it('returns ssoData object with email as lastUsedUsername', function(done) {
+      this.auth0.getSSOData(function(err, result) {
+        expect(err).to.be(null);
+        expect(result).to.be.eql({
+          lastUsedConnection: { name: 'the-connection' },
+          lastUsedUserID: 'the-user-id',
+          lastUsedUsername: 'the@user.com',
+          lastUsedClientID: '...',
+          sessionClients: ['...'],
+          sso: true
+        });
+        done();
+      });
+
+      this.webAuthSpy.checkSession.lastCall.args[1](null, {
+        idTokenPayload: { sub: 'the-user-id', email: 'the@user.com', name: 'Will not be used' }
+      });
+    });
+    it('returns ssoData object with name as lastUsedUsername when email is not available', function(
+      done
+    ) {
       this.auth0.getSSOData(function(err, result) {
         expect(err).to.be(null);
         expect(result).to.be.eql({
Repository: auth0/auth0.js
Pull request #555 (2017-11-07 23:44:29)

Fix getSSOData responseType


Patch:
diff --git a/src/authentication/index.js b/src/authentication/index.js
index 12110ae..0c15dbb 100644
--- a/src/authentication/index.js
+++ b/src/authentication/index.js
@@ -356,7 +356,7 @@ Authentication.prototype.getSSOData = function(cb) {
   var clientId = this.baseOptions.clientID;
   this.auth0.checkSession(
     {
-      responseType: 'id_token',
+      responseType: 'token id_token',
       scope: 'openid profile email'
     },
     function(err, result) {


Test patch:
diff --git a/test/authentication/authentication.test.js b/test/authentication/authentication.test.js
index 38061c1..9d0b0ab 100644
--- a/test/authentication/authentication.test.js
+++ b/test/authentication/authentication.test.js
@@ -240,6 +240,13 @@ describe('auth0.authentication', function() {
     after(function() {
       storage.getItem.restore();
     });
+    it('uses correct scope and responseType', function() {
+      this.auth0.getSSOData();
+      expect(this.webAuthSpy.checkSession.lastCall.args[0]).to.be.eql({
+        responseType: 'token id_token',
+        scope: 'openid profile email'
+      });
+    });
     it('returns sso:false if checkSession fails', function(done) {
       this.auth0.getSSOData(function(err, result) {
         expect(err).to.be.eql({ some: 'error' });
Repository: auth0/auth0.js
Pull request #586 (2017-12-07 13:39:54)

Release v9.0.0-beta.9


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1f8f1e4..091bc95 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Change Log
 
+## [v9.0.0-beta.9](https://github.com/auth0/auth0.js/tree/v9.0.0-beta.9) (2017-12-07)
+[Full Changelog](https://github.com/auth0/auth0.js/compare/v9.0.0-beta.8...v9.0.0-beta.9)
+# Change Log
+
 ## [v9.0.0-beta.8](https://github.com/auth0/auth0.js/tree/v9.0.0-beta.8) (2017-11-30)
 [Full Changelog](https://github.com/auth0/auth0.js/compare/v9.0.0-beta.7...v9.0.0-beta.8)
 # Change Log
diff --git a/README.md b/README.md
index 6e1709a..162149d 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ From CDN
 
 ```html
 <!-- Latest patch release -->
-<script src="http://cdn.auth0.com/js/auth0/9.0.0-beta.8/auth0.min.js"></script>
+<script src="http://cdn.auth0.com/js/auth0/9.0.0-beta.9/auth0.min.js"></script>
 ```
 
 From [npm](https://npmjs.org)
diff --git a/package.json b/package.json
index 4ffed92..7bdda51 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "auth0-js",
-  "version": "9.0.0-beta.8",
+  "version": "9.0.0-beta.9",
   "description": "Auth0 headless browser sdk",
   "main": "src/index.js",
   "keywords": [
diff --git a/src/authentication/index.js b/src/authentication/index.js
index 00e6fe2..6eed695 100644
--- a/src/authentication/index.js
+++ b/src/authentication/index.js
@@ -359,7 +359,7 @@ Authentication.prototype.getSSOData = function(cb) {
 
   this.auth0.checkSession(
     {
-      responseType: 'id_token',
+      responseType: 'token id_token',
       scope: 'openid profile email',
       connection: ssodataInformation.lastUsedConnection
     },
diff --git a/src/version.js b/src/version.js
index 6f9bebd..e20c050 100644
--- a/src/version.js
+++ b/src/version.js
@@ -1,1 +1,1 @@
-module.exports = { raw: '9.0.0-beta.8' };
+module.exports = { raw: '9.0.0-beta.9' };


Test patch:
diff --git a/test/authentication/authentication.test.js b/test/authentication/authentication.test.js
index 01ade75..8db3ea4 100644
--- a/test/authentication/authentication.test.js
+++ b/test/authentication/authentication.test.js
@@ -247,7 +247,7 @@ describe('auth0.authentication', function() {
     it('uses correct scope and responseType', function() {
       this.auth0.getSSOData();
       expect(this.webAuthSpy.checkSession.lastCall.args[0]).to.be.eql({
-        responseType: 'id_token',
+        responseType: 'token id_token',
         scope: 'openid profile email',
         connection: 'lastUsedConnection'
       });
Repository: auth0/auth0.js
Pull request #587 (2017-12-07 16:07:12)

adding back withActiveDirectories param


Patch:
diff --git a/src/authentication/index.js b/src/authentication/index.js
index 6eed695..23ccd74 100644
--- a/src/authentication/index.js
+++ b/src/authentication/index.js
@@ -351,9 +351,14 @@ Authentication.prototype.loginWithResourceOwner = function(options, cb) {
  * Uses {@link checkSession} and localStorage to return data from the last successful authentication request.
  *
  * @method getSSOData
+ * @param {Boolean} withActiveDirectories this parameter is not used anymore. It's here to be backward compatible
  * @param {Function} cb
  */
-Authentication.prototype.getSSOData = function(cb) {
+Authentication.prototype.getSSOData = function(withActiveDirectories, cb) {
+  if (typeof withActiveDirectories === 'function') {
+    cb = withActiveDirectories;
+  }
+  assert.check(cb, { type: 'function', message: 'cb parameter is not valid' });
   var clientId = this.baseOptions.clientID;
   var ssodataInformation = ssodata.get() || {};
 


Test patch:
diff --git a/test/authentication/authentication.test.js b/test/authentication/authentication.test.js
index 8db3ea4..cb0fd27 100644
--- a/test/authentication/authentication.test.js
+++ b/test/authentication/authentication.test.js
@@ -244,8 +244,23 @@ describe('auth0.authentication', function() {
     after(function() {
       storage.getItem.restore();
     });
+    it('fails if callback is not a function', function() {
+      var _this = this;
+      expect(function() {
+        _this.auth0.getSSOData(null, null);
+      }).to.throwError();
+    });
+    it('works if callback is the second param', function(done) {
+      this.auth0.getSSOData(null, function(err, result) {
+        done();
+      });
+
+      this.webAuthSpy.checkSession.lastCall.args[1](null, {
+        idTokenPayload: { sub: 'some-other-id' }
+      });
+    });
     it('uses correct scope and responseType', function() {
-      this.auth0.getSSOData();
+      this.auth0.getSSOData(function() {});
       expect(this.webAuthSpy.checkSession.lastCall.args[0]).to.be.eql({
         responseType: 'token id_token',
         scope: 'openid profile email',