react-oauth2-code-pkce
Advanced tools
Comparing version 1.13.1 to 1.13.2
@@ -79,8 +79,13 @@ "use strict"; | ||
setLoginInProgress(true); | ||
// TODO: Raise error on wrong state type in v2 | ||
let typeSafePassedState = state; | ||
if (typeof state !== 'string') { | ||
console.warn(`Passed login state must be of type 'string'. Received '${state}'. Ignoring value...`); | ||
(0, authentication_1.redirectToLogin)(config); | ||
return; | ||
typeSafePassedState = undefined; | ||
} | ||
(0, authentication_1.redirectToLogin)(config, state); | ||
(0, authentication_1.redirectToLogin)(config, typeSafePassedState).catch((error) => { | ||
console.error(error); | ||
setError(error.message); | ||
setLoginInProgress(false); | ||
}); | ||
} | ||
@@ -87,0 +92,0 @@ function handleTokenResponse(response) { |
@@ -23,3 +23,3 @@ "use strict"; | ||
// Hash and Base64URL encode the code_verifier, used as the 'code_challenge' | ||
(0, pkceUtils_1.generateCodeChallenge)(codeVerifier).then((codeChallenge) => { | ||
return (0, pkceUtils_1.generateCodeChallenge)(codeVerifier).then((codeChallenge) => { | ||
// Set query parameters and redirect user to OAuth2 authentication endpoint | ||
@@ -26,0 +26,0 @@ const params = new URLSearchParams(Object.assign({ response_type: 'code', client_id: config.clientId, scope: config.scope, redirect_uri: config.redirectUri, code_challenge: codeChallenge, code_challenge_method: 'S256' }, config.extraAuthParameters)); |
@@ -17,3 +17,3 @@ "use strict"; | ||
const setValue = (value) => { | ||
if (!value) { | ||
if (value === undefined) { | ||
// Delete item if set to undefined. This avoids warning on loading invalid json | ||
@@ -20,0 +20,0 @@ setStoredValue(value); |
@@ -37,3 +37,7 @@ "use strict"; | ||
function generateCodeChallenge(codeVerifier) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!((_a = window.crypto.subtle) === null || _a === void 0 ? void 0 : _a.digest)) { | ||
throw new Error("The context/environment is not secure, and does not support the 'crypto.subtle' module. See: https://developer.mozilla.org/en-US/docs/Web/API/Crypto/subtle for details"); | ||
} | ||
const encoder = new TextEncoder(); | ||
@@ -40,0 +44,0 @@ const bytes = encoder.encode(codeVerifier); // Encode the verifier to a byteArray |
{ | ||
"name": "react-oauth2-code-pkce", | ||
"version": "1.13.1", | ||
"version": "1.13.2", | ||
"description": "Provider agnostic react package for OAuth2 Authorization Code flow with PKCE", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44565
734