react-pkce-oauth2
Version:
Plug-and-play react package for OAuth2 Authorization Code flow with PKCE
19 lines (18 loc) • 986 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateAuthConfig = void 0;
function stringIsUnset(value) {
const unset = ['', undefined, null];
return unset.includes(value);
}
function validateAuthConfig(config) {
if (stringIsUnset(config?.clientId))
throw Error("'clientId' must be set in the 'AuthConfig' object passed to 'react-pkce-oauth2' AuthProvider");
if (stringIsUnset(config?.authorizationEndpoint))
throw Error("'authorizationEndpoint' must be set in the 'AuthConfig' object passed to 'react-pkce-oauth2' AuthProvider");
if (stringIsUnset(config?.tokenEndpoint))
throw Error("'tokenEndpoint' must be set in the 'AuthConfig' object passed to 'react-pkce-oauth2' AuthProvider");
if (stringIsUnset(config?.redirectUri))
throw Error("'redirectUri' must be set in the 'AuthConfig' object passed to 'react-pkce-oauth2' AuthProvider");
}
exports.validateAuthConfig = validateAuthConfig;