New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@okta/configuration-validation

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@okta/configuration-validation - npm Package Compare versions

Comparing version 0.4.3 to 1.0.0

dist/lib.d.ts

250

dist/lib.js

@@ -1,9 +0,2 @@

'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
"use strict";
/*!

@@ -20,24 +13,30 @@ * Copyright (c) 2018-Present, Okta, Inc. and/or its affiliates. All rights reserved.

*/
var merge = require('lodash/merge');
var ConfigurationValidationError = function (_Error) {
_inherits(ConfigurationValidationError, _Error);
function ConfigurationValidationError() {
_classCallCheck(this, ConfigurationValidationError);
return _possibleConstructorReturn(this, (ConfigurationValidationError.__proto__ || Object.getPrototypeOf(ConfigurationValidationError)).apply(this, arguments));
}
return ConfigurationValidationError;
}(Error);
var configUtil = module.exports;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertAppBaseUrl = exports.assertRedirectUri = exports.assertClientSecret = exports.assertClientId = exports.assertIssuer = exports.buildConfigObject = void 0;
var lodash_1 = require("lodash");
var ConfigurationValidationError = /** @class */ (function (_super) {
__extends(ConfigurationValidationError, _super);
function ConfigurationValidationError() {
return _super !== null && _super.apply(this, arguments) || this;
}
return ConfigurationValidationError;
}(Error));
var findDomainURL = 'https://bit.ly/finding-okta-domain';
var findAppCredentialsURL = 'https://bit.ly/finding-okta-app-credentials';
var copyCredentialsMessage = 'You can copy it from the Okta Developer Console ' + 'in the details for the Application you created. ' + ('Follow these instructions to find it: ' + findAppCredentialsURL);
var copyCredentialsMessage = 'You can copy it from the Okta Developer Console ' +
'in the details for the Application you created. ' +
("Follow these instructions to find it: " + findAppCredentialsURL);
var isHttps = new RegExp('^https://');

@@ -47,105 +46,104 @@ var hasProtocol = new RegExp('://');

var endsInPath = new RegExp('/$');
configUtil.buildConfigObject = function (config) {
// See all supported options: https://github.com/okta/okta-auth-js#configuration-reference
// Support for parameters with an underscore will be deprecated in a future release
// camelCase was added 2/11/2019: https://github.com/okta/okta-oidc-js/commit/9b04ada6a01c9d9aca391abf0de3e5ecc9811e64
config = config || {}; // accept empty
// Legacy support: allow a property named 'scope' to be either an array or a string.
var scopes = config.scopes;
if (!scopes && config.scope) {
if (Array.isArray(config.scope)) {
scopes = config.scope;
} else {
scopes = config.scope.split(/\s+/);
exports.buildConfigObject = function (config) {
// See all supported options: https://github.com/okta/okta-auth-js#configuration-reference
// Support for parameters with an underscore will be deprecated in a future release
// camelCase was added 2/11/2019: https://github.com/okta/okta-oidc-js/commit/9b04ada6a01c9d9aca391abf0de3e5ecc9811e64
config = config || {}; // accept empty
// Legacy support: allow a property named 'scope' to be either an array or a string.
var scopes = config.scopes;
if (!scopes && config.scope) {
if (Array.isArray(config.scope)) {
scopes = config.scope;
}
else {
scopes = config.scope.split(/\s+/);
}
}
}
// Legacy support: allow TokenManager config 'autoRenew' and 'storage' to be defined at top-level
var tokenManager = config.tokenManager;
var autoRenew = config.autoRenew !== undefined ? config.autoRenew : config.auto_renew; // Only check legacy property if necessary
var storage = config.storage;
if (storage !== undefined || autoRenew !== undefined) {
// Properties already defined within the "tokenManager" section will not be overwritten
tokenManager = merge({
autoRenew: autoRenew,
storage: storage
}, tokenManager || {});
}
// Legacy support: allow 'responseType' to be a string or an array
var responseType = config.responseType || config.response_type;
if (typeof responseType === 'string' && responseType.indexOf(' ') >= 0) {
responseType = responseType.split(/\s+/);
}
var normalizedConfig = merge({}, config, {
clientId: config.clientId || config.client_id,
redirectUri: config.redirectUri || config.redirect_uri,
responseType: responseType,
scopes: scopes,
tokenManager: tokenManager
});
return normalizedConfig;
// Legacy support: allow TokenManager config 'autoRenew' and 'storage' to be defined at top-level
var tokenManager = config.tokenManager;
var autoRenew = (config.autoRenew !== undefined ? config.autoRenew : config.auto_renew); // Only check legacy property if necessary
var storage = config.storage;
if (storage !== undefined || autoRenew !== undefined) {
// Properties already defined within the "tokenManager" section will not be overwritten
tokenManager = lodash_1.merge({
autoRenew: autoRenew,
storage: storage,
}, tokenManager || {});
}
// Legacy support: allow 'responseType' to be a string or an array
var responseType = config.responseType || config.response_type;
if (typeof responseType === 'string' && responseType.indexOf(' ') >= 0) {
responseType = responseType.split(/\s+/);
}
var normalizedConfig = lodash_1.merge({}, config, {
clientId: config.clientId || config.client_id,
redirectUri: config.redirectUri || config.redirect_uri,
responseType: responseType,
scopes: scopes,
tokenManager: tokenManager,
});
return normalizedConfig;
};
configUtil.assertIssuer = function (issuer) {
var testing = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var copyMessage = 'You can copy your domain from the Okta Developer ' + 'Console. Follow these instructions to find it: ' + findDomainURL;
if (testing.disableHttpsCheck) {
var httpsWarning = 'Warning: HTTPS check is disabled. ' + 'This allows for insecure configurations and is NOT recommended for production use.';
/* eslint-disable-next-line no-console */
console.warn(httpsWarning);
}
if (!issuer) {
throw new ConfigurationValidationError('Your Okta URL is missing. ' + copyMessage);
} else if (!testing.disableHttpsCheck && !issuer.match(isHttps)) {
throw new ConfigurationValidationError('Your Okta URL must start with https. ' + ('Current value: ' + issuer + '. ' + copyMessage));
} else if (issuer.match(/{yourOktaDomain}/)) {
throw new ConfigurationValidationError('Replace {yourOktaDomain} with your Okta domain. ' + copyMessage);
} else if (issuer.match(hasDomainAdmin)) {
throw new ConfigurationValidationError('Your Okta domain should not contain -admin. ' + ('Current value: ' + issuer + '. ' + copyMessage));
}
exports.assertIssuer = function (issuer, testing) {
if (testing === void 0) { testing = {}; }
var copyMessage = 'You can copy your domain from the Okta Developer ' +
'Console. Follow these instructions to find it: ' + findDomainURL;
if (testing.disableHttpsCheck) {
var httpsWarning = 'Warning: HTTPS check is disabled. ' +
'This allows for insecure configurations and is NOT recommended for production use.';
/* eslint-disable-next-line no-console */
console.warn(httpsWarning);
}
if (!issuer) {
throw new ConfigurationValidationError('Your Okta URL is missing. ' + copyMessage);
}
else if (!testing.disableHttpsCheck && !issuer.match(isHttps)) {
throw new ConfigurationValidationError('Your Okta URL must start with https. ' +
("Current value: " + issuer + ". " + copyMessage));
}
else if (issuer.match(/{yourOktaDomain}/)) {
throw new ConfigurationValidationError('Replace {yourOktaDomain} with your Okta domain. ' + copyMessage);
}
else if (issuer.match(hasDomainAdmin)) {
throw new ConfigurationValidationError('Your Okta domain should not contain -admin. ' +
("Current value: " + issuer + ". " + copyMessage));
}
};
configUtil.assertClientId = function (clientId) {
if (!clientId) {
throw new ConfigurationValidationError('Your client ID is missing. ' + copyCredentialsMessage);
} else if (clientId.match(/{clientId}/)) {
throw new ConfigurationValidationError('Replace {clientId} with the client ID of your Application. ' + copyCredentialsMessage);
}
exports.assertClientId = function (clientId) {
if (!clientId) {
throw new ConfigurationValidationError('Your client ID is missing. ' + copyCredentialsMessage);
}
else if (clientId.match(/{clientId}/)) {
throw new ConfigurationValidationError('Replace {clientId} with the client ID of your Application. ' + copyCredentialsMessage);
}
};
configUtil.assertClientSecret = function (clientSecret) {
if (!clientSecret) {
throw new ConfigurationValidationError('Your client secret is missing. ' + copyCredentialsMessage);
} else if (clientSecret.match(/{clientSecret}/)) {
throw new ConfigurationValidationError('Replace {clientSecret} with the client secret of your Application. ' + copyCredentialsMessage);
}
exports.assertClientSecret = function (clientSecret) {
if (!clientSecret) {
throw new ConfigurationValidationError('Your client secret is missing. ' + copyCredentialsMessage);
}
else if (clientSecret.match(/{clientSecret}/)) {
throw new ConfigurationValidationError('Replace {clientSecret} with the client secret of your Application. ' + copyCredentialsMessage);
}
};
configUtil.assertRedirectUri = function (redirectUri) {
if (!redirectUri) {
throw new ConfigurationValidationError('Your redirect URI is missing.');
} else if (redirectUri.match(/{redirectUri}/)) {
throw new ConfigurationValidationError('Replace {redirectUri} with the redirect URI of your Application.');
}
exports.assertRedirectUri = function (redirectUri) {
if (!redirectUri) {
throw new ConfigurationValidationError('Your redirect URI is missing.');
}
else if (redirectUri.match(/{redirectUri}/)) {
throw new ConfigurationValidationError('Replace {redirectUri} with the redirect URI of your Application.');
}
};
configUtil.assertAppBaseUrl = function (appBaseUrl) {
if (!appBaseUrl) {
throw new ConfigurationValidationError('Your appBaseUrl is missing.');
} else if (appBaseUrl.match(/{appBaseUrl}/)) {
throw new ConfigurationValidationError('Replace {appBaseUrl} with the base URL of your Application.');
} else if (!appBaseUrl.match(hasProtocol)) {
throw new ConfigurationValidationError('Your appBaseUrl must contain a protocol (e.g. https://). Current value: ' + appBaseUrl + '.');
} else if (appBaseUrl.match(endsInPath)) {
throw new ConfigurationValidationError('Your appBaseUrl must not end in a \'/\'. Current value: ' + appBaseUrl + '.');
}
};
exports.assertAppBaseUrl = function (appBaseUrl) {
if (!appBaseUrl) {
throw new ConfigurationValidationError('Your appBaseUrl is missing.');
}
else if (appBaseUrl.match(/{appBaseUrl}/)) {
throw new ConfigurationValidationError('Replace {appBaseUrl} with the base URL of your Application.');
}
else if (!appBaseUrl.match(hasProtocol)) {
throw new ConfigurationValidationError("Your appBaseUrl must contain a protocol (e.g. https://). Current value: " + appBaseUrl + ".");
}
else if (appBaseUrl.match(endsInPath)) {
throw new ConfigurationValidationError("Your appBaseUrl must not end in a '/'. Current value: " + appBaseUrl + ".");
}
};
{
"name": "@okta/configuration-validation",
"version": "0.4.3",
"version": "1.0.0",
"description": "Configuration validation support for Okta JavaScript SDKs",
"main": "./dist/lib.js",
"types": "./dist/lib.d.ts",
"files": [

@@ -11,4 +12,5 @@ "dist",

"scripts": {
"build": "babel src -d dist",
"lint": "eslint .",
"clean": "rimraf dist",
"build": "tsc",
"lint": "eslint . && tsc -p test",
"prepare": "yarn build",

@@ -36,19 +38,41 @@ "test": "yarn lint && yarn test:unit",

"devDependencies": {
"babel-cli": "^6.26.0",
"babel-eslint": "^8.1.1",
"babel-preset-env": "^1.7.0",
"@babel/core": "^7.8.0",
"@babel/plugin-transform-typescript": "^7.11.0",
"@babel/preset-env": "^7.8.2",
"@babel/preset-typescript": "^7.10.4",
"@types/jest": "^25.2.3",
"@types/json-schema": "^7.0.5",
"@types/minimatch": "^3.0.3",
"@types/node": "^14.6.1",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"babel-jest": "^26.3.0",
"deep-extend": "^0.6.0",
"eslint": "^4.7.1",
"jest": "^23.6.0"
"eslint": "^7.7.0",
"eslint-plugin-jest": "^23.20.0",
"jest": "^26.4.2",
"rimraf": "^3.0.2",
"typescript": "^4.0.2"
},
"jest": {
"testEnvironment": "jsdom"
"moduleNameMapper": {
"^@okta/configuration-validation$": "<rootDir>/src/lib"
},
"restoreMocks": true,
"testEnvironment": "jsdom",
"testMatch": [
"**/test/*.{js,ts}"
],
"roots": [
"test"
]
},
"dependencies": {
"@okta/okta-auth-js": "^4.0.0",
"lodash": "^4.17.15"
},
"okta": {
"commitSha": "5266f3bcd9d4285b9dc057e6706810c69466b607",
"fullVersion": "0.4.3-beta.g5266f3b-20200702142818-5266f3b"
"commitSha": "1244b68146ab43e0dbc089daa0f1a7c5bbbb7182",
"fullVersion": "1.0.0-beta.g1244b68-20200831192228-1244b68"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc