@okta/okta-auth-js
Advanced tools
Comparing version 2.10.0 to 2.10.1
@@ -1,6 +0,9 @@ | ||
var packageJson = require('./package.json'); | ||
var OktaAuth = '<rootDir>/' + packageJson.browser; | ||
var OktaAuth = '<rootDir>/lib/browser/browserIndex.js'; | ||
var SDK_VERSION = require('./package.json').version; | ||
module.exports = { | ||
'coverageDirectory': './build2/reports/coverage', | ||
'coverageDirectory': '<rootDir>/build2/reports/coverage', | ||
'globals': { | ||
SDK_VERSION: SDK_VERSION | ||
}, | ||
'restoreMocks': true, | ||
@@ -7,0 +10,0 @@ 'moduleNameMapper': { |
@@ -5,3 +5,3 @@ var packageJson = require('./package.json'); | ||
module.exports = { | ||
'coverageDirectory': './build2/reports/coverage', | ||
'coverageDirectory': '<rootDir>/build2/reports/coverage', | ||
'restoreMocks': true, | ||
@@ -8,0 +8,0 @@ 'moduleNameMapper': { |
@@ -14,2 +14,4 @@ /*! | ||
/* eslint-disable max-statements */ | ||
/* SDK_VERSION is defined in webpack config */ | ||
/* global SDK_VERSION */ | ||
@@ -20,3 +22,3 @@ require('../vendor/polyfills'); | ||
var builderUtil = require('../builderUtil'); | ||
var config = require('../config'); | ||
var constants = require('../constants'); | ||
var cookies = require('./browserStorage').storage; | ||
@@ -57,3 +59,3 @@ var http = require('../http'); | ||
this.userAgent = 'okta-auth-js-' + config.SDK_VERSION; | ||
this.userAgent = 'okta-auth-js-' + SDK_VERSION; | ||
@@ -68,3 +70,3 @@ // Digital clocks will drift over time, so the server | ||
if (!args.maxClockSkew && args.maxClockSkew !== 0) { | ||
this.options.maxClockSkew = config.DEFAULT_MAX_CLOCK_SKEW; | ||
this.options.maxClockSkew = constants.DEFAULT_MAX_CLOCK_SKEW; | ||
} else { | ||
@@ -71,0 +73,0 @@ this.options.maxClockSkew = args.maxClockSkew; |
@@ -16,3 +16,3 @@ /*! | ||
var storageBuilder = require('../storageBuilder'); | ||
var config = require('../config'); | ||
var constants = require('../constants'); | ||
@@ -44,7 +44,7 @@ // Building this as an object allows us to mock the functions in our tests | ||
if (storageUtil.browserHasLocalStorage()) { | ||
return storageBuilder(storageUtil.getLocalStorage(), config.PKCE_STORAGE_NAME); | ||
return storageBuilder(storageUtil.getLocalStorage(), constants.PKCE_STORAGE_NAME); | ||
} else if (storageUtil.browserHasSessionStorage()) { | ||
return storageBuilder(storageUtil.getSessionStorage(), config.PKCE_STORAGE_NAME); | ||
return storageBuilder(storageUtil.getSessionStorage(), constants.PKCE_STORAGE_NAME); | ||
} else { | ||
return storageBuilder(storageUtil.getCookieStorage(), config.PKCE_STORAGE_NAME); | ||
return storageBuilder(storageUtil.getCookieStorage(), constants.PKCE_STORAGE_NAME); | ||
} | ||
@@ -55,7 +55,7 @@ }; | ||
if (storageUtil.browserHasLocalStorage()) { | ||
return storageBuilder(storageUtil.getLocalStorage(), config.CACHE_STORAGE_NAME); | ||
return storageBuilder(storageUtil.getLocalStorage(), constants.CACHE_STORAGE_NAME); | ||
} else if (storageUtil.browserHasSessionStorage()) { | ||
return storageBuilder(storageUtil.getSessionStorage(), config.CACHE_STORAGE_NAME); | ||
return storageBuilder(storageUtil.getSessionStorage(), constants.CACHE_STORAGE_NAME); | ||
} else { | ||
return storageBuilder(storageUtil.getCookieStorage(), config.CACHE_STORAGE_NAME); | ||
return storageBuilder(storageUtil.getCookieStorage(), constants.CACHE_STORAGE_NAME); | ||
} | ||
@@ -84,2 +84,15 @@ }; | ||
// Provides an in-memory solution | ||
storageUtil.getInMemoryStorage = function() { | ||
var store = {}; | ||
return { | ||
getItem: function(key) { | ||
return store[key]; | ||
}, | ||
setItem: function(key, value) { | ||
store[key] = value; | ||
} | ||
}; | ||
}; | ||
storageUtil.testStorage = function(storage) { | ||
@@ -86,0 +99,0 @@ var key = 'okta-test-storage'; |
@@ -18,3 +18,3 @@ /*! | ||
var AuthApiError = require('./errors/AuthApiError'); | ||
var config = require('./config'); | ||
var constants = require('./constants'); | ||
@@ -68,3 +68,3 @@ function httpRequest(sdk, options) { | ||
if (!res.stateToken) { | ||
storage.delete(config.STATE_TOKEN_KEY_NAME); | ||
storage.delete(constants.STATE_TOKEN_KEY_NAME); | ||
} | ||
@@ -74,3 +74,3 @@ } | ||
if (res && res.stateToken && res.expiresAt) { | ||
storage.set(config.STATE_TOKEN_KEY_NAME, res.stateToken, res.expiresAt); | ||
storage.set(constants.STATE_TOKEN_KEY_NAME, res.stateToken, res.expiresAt); | ||
} | ||
@@ -80,3 +80,3 @@ | ||
httpCache.updateStorage(url, { | ||
expiresAt: Math.floor(Date.now()/1000) + config.DEFAULT_CACHE_DURATION, | ||
expiresAt: Math.floor(Date.now()/1000) + constants.DEFAULT_CACHE_DURATION, | ||
response: res | ||
@@ -111,3 +111,3 @@ }); | ||
if (err.errorCode === 'E0000011') { | ||
storage.delete(config.STATE_TOKEN_KEY_NAME); | ||
storage.delete(constants.STATE_TOKEN_KEY_NAME); | ||
} | ||
@@ -114,0 +114,0 @@ |
@@ -18,3 +18,3 @@ /*! | ||
var builderUtil = require('../builderUtil'); | ||
var config = require('../config'); | ||
var SDK_VERSION = require('../../package.json').version; | ||
var storage = require('./serverStorage').storage; | ||
@@ -35,3 +35,3 @@ var tx = require('../tx'); | ||
this.userAgent = 'okta-auth-js-server' + config.SDK_VERSION; | ||
this.userAgent = 'okta-auth-js-server' + SDK_VERSION; | ||
@@ -38,0 +38,0 @@ sdk.tx = { |
@@ -15,3 +15,3 @@ /*! | ||
var storageBuilder = require('../storageBuilder'); | ||
var config = require('../config'); | ||
var constants = require('../constants'); | ||
var NodeCache = require('node-cache'); | ||
@@ -24,3 +24,3 @@ var storage = new NodeCache(); | ||
storageUtil.getHttpCache = function() { | ||
return storageBuilder(storageUtil.getStorage(), config.CACHE_STORAGE_NAME); | ||
return storageBuilder(storageUtil.getStorage(), constants.CACHE_STORAGE_NAME); | ||
}; | ||
@@ -27,0 +27,0 @@ |
@@ -22,3 +22,3 @@ /*! | ||
var OAuthError = require('./errors/OAuthError'); | ||
var config = require('./config'); | ||
var constants = require('./constants'); | ||
var cookies = require('./browser/browserStorage').storage; | ||
@@ -471,8 +471,11 @@ var PKCE = require('./pkce'); | ||
function hasClosed(win) { | ||
if (win.closed) { | ||
if (!win || win.closed) { | ||
popupDeferred.reject(new AuthSdkError('Unable to parse OAuth flow response')); | ||
return true; | ||
} | ||
} | ||
var closePoller = setInterval(function() { | ||
hasClosed(windowEl); | ||
if (hasClosed(windowEl)) { | ||
clearInterval(closePoller); | ||
} | ||
}, 500); | ||
@@ -494,4 +497,4 @@ | ||
.fin(function() { | ||
if (!windowEl.closed) { | ||
clearInterval(closePoller); | ||
clearInterval(closePoller); | ||
if (windowEl && !windowEl.closed) { | ||
windowEl.close(); | ||
@@ -609,3 +612,3 @@ } | ||
// Set session cookie to store the oauthParams | ||
cookies.set(config.REDIRECT_OAUTH_PARAMS_COOKIE_NAME, JSON.stringify({ | ||
cookies.set(constants.REDIRECT_OAUTH_PARAMS_COOKIE_NAME, JSON.stringify({ | ||
responseType: oauthParams.responseType, | ||
@@ -621,6 +624,6 @@ state: oauthParams.state, | ||
// Set nonce cookie for servers to validate nonce in id_token | ||
cookies.set(config.REDIRECT_NONCE_COOKIE_NAME, oauthParams.nonce); | ||
cookies.set(constants.REDIRECT_NONCE_COOKIE_NAME, oauthParams.nonce); | ||
// Set state cookie for servers to validate state | ||
cookies.set(config.REDIRECT_STATE_COOKIE_NAME, oauthParams.state); | ||
cookies.set(constants.REDIRECT_STATE_COOKIE_NAME, oauthParams.state); | ||
@@ -678,3 +681,3 @@ sdk.token.getWithRedirect._setLocation(requestUrl); | ||
var oauthParamsCookie = cookies.get(config.REDIRECT_OAUTH_PARAMS_COOKIE_NAME); | ||
var oauthParamsCookie = cookies.get(constants.REDIRECT_OAUTH_PARAMS_COOKIE_NAME); | ||
if (!oauthParamsCookie) { | ||
@@ -688,6 +691,6 @@ return Q.reject(new AuthSdkError('Unable to retrieve OAuth redirect params cookie')); | ||
delete oauthParams.urls; | ||
cookies.delete(config.REDIRECT_OAUTH_PARAMS_COOKIE_NAME); | ||
cookies.delete(constants.REDIRECT_OAUTH_PARAMS_COOKIE_NAME); | ||
} catch(e) { | ||
return Q.reject(new AuthSdkError('Unable to parse the ' + | ||
config.REDIRECT_OAUTH_PARAMS_COOKIE_NAME + ' cookie: ' + e.message)); | ||
constants.REDIRECT_OAUTH_PARAMS_COOKIE_NAME + ' cookie: ' + e.message)); | ||
} | ||
@@ -694,0 +697,0 @@ |
@@ -20,3 +20,3 @@ /*! | ||
var Emitter = require('tiny-emitter'); | ||
var config = require('./config'); | ||
var constants = require('./constants'); | ||
var storageBuilder = require('./storageBuilder'); | ||
@@ -218,17 +218,26 @@ var SdkClock = require('./clock'); | ||
var storage; | ||
switch(options.storage) { | ||
case 'localStorage': | ||
storage = storageBuilder(localStorage, config.TOKEN_STORAGE_NAME); | ||
break; | ||
case 'sessionStorage': | ||
storage = storageBuilder(sessionStorage, config.TOKEN_STORAGE_NAME); | ||
break; | ||
case 'cookie': | ||
storage = storageBuilder(storageUtil.getCookieStorage(options), config.TOKEN_STORAGE_NAME); | ||
break; | ||
default: | ||
throw new AuthSdkError('Unrecognized storage option'); | ||
var storageProvider; | ||
if (typeof options.storage === 'object') { | ||
// A custom storage provider must implement getItem(key) and setItem(key, val) | ||
storageProvider = options.storage; | ||
} else { | ||
switch(options.storage) { | ||
case 'localStorage': | ||
storageProvider = localStorage; | ||
break; | ||
case 'sessionStorage': | ||
storageProvider = sessionStorage; | ||
break; | ||
case 'cookie': | ||
storageProvider = storageUtil.getCookieStorage(options); | ||
break; | ||
case 'memory': | ||
storageProvider = storageUtil.getInMemoryStorage(); | ||
break; | ||
default: | ||
throw new AuthSdkError('Unrecognized storage option'); | ||
} | ||
} | ||
var storageKey = options.storageKey || constants.TOKEN_STORAGE_NAME; | ||
var storage = storageBuilder(storageProvider, storageKey); | ||
var clock = SdkClock.create(sdk, options); | ||
@@ -235,0 +244,0 @@ var tokenMgmtRef = { |
@@ -20,3 +20,3 @@ /*! | ||
var AuthPollStopError = require('./errors/AuthPollStopError'); | ||
var config = require('./config'); | ||
var constants = require('./constants'); | ||
@@ -46,3 +46,3 @@ function addStateToken(res, options) { | ||
if (!args || !args.stateToken) { | ||
var stateToken = sdk.tx.exists._get(config.STATE_TOKEN_KEY_NAME); | ||
var stateToken = sdk.tx.exists._get(constants.STATE_TOKEN_KEY_NAME); | ||
if (stateToken) { | ||
@@ -64,3 +64,3 @@ args = { | ||
if (!args || !args.stateToken) { | ||
var stateToken = sdk.tx.exists._get(config.STATE_TOKEN_KEY_NAME); | ||
var stateToken = sdk.tx.exists._get(constants.STATE_TOKEN_KEY_NAME); | ||
if (stateToken) { | ||
@@ -87,3 +87,3 @@ args = { | ||
// We have a cookie state token | ||
return !!sdk.tx.exists._get(config.STATE_TOKEN_KEY_NAME); | ||
return !!sdk.tx.exists._get(constants.STATE_TOKEN_KEY_NAME); | ||
} | ||
@@ -115,3 +115,3 @@ | ||
if (!delay && delay !== 0) { | ||
delay = config.DEFAULT_POLLING_DELAY; | ||
delay = constants.DEFAULT_POLLING_DELAY; | ||
} | ||
@@ -118,0 +118,0 @@ |
{ | ||
"name": "@okta/okta-auth-js", | ||
"description": "The Okta Auth SDK", | ||
"version": "2.10.0", | ||
"version": "2.10.1", | ||
"homepage": "https://github.com/okta/okta-auth-js", | ||
"license": "Apache-2.0", | ||
"main": "lib/server/serverIndex.js", | ||
"browser": "lib/browser/browserIndex.js", | ||
"browser": "dist/okta-auth-js.min.js", | ||
"repository": { | ||
@@ -18,3 +18,3 @@ "type": "git", | ||
"lint": "eslint .", | ||
"lint:report": "eslint -f checkstyle -o build2/reports/lint/eslint-checkstyle-result.xml .", | ||
"lint:report": "eslint -f checkstyle -o ../../build2/reports/lint/eslint-checkstyle-result.xml .", | ||
"test": "yarn test:karma && yarn test:browser && yarn test:server", | ||
@@ -25,3 +25,3 @@ "test:karma": "karma start --single-run", | ||
"test:report": "yarn test --ci --silent || true", | ||
"build": "node ./writeConfig.js && webpack --config webpack.config.js", | ||
"build": "webpack --config webpack.config.js", | ||
"prepare": "yarn build" | ||
@@ -49,2 +49,3 @@ }, | ||
"eslint": "5.6.1", | ||
"eslint-plugin-jasmine": "^2.10.1", | ||
"istanbul-instrumenter-loader": "^3.0.1", | ||
@@ -68,18 +69,10 @@ "jasmine-ajax": "^4.0.0", | ||
}, | ||
"okta-auth-js": { | ||
"STATE_TOKEN_KEY_NAME": "oktaStateToken", | ||
"DEFAULT_POLLING_DELAY": 500, | ||
"DEFAULT_MAX_CLOCK_SKEW": 300, | ||
"DEFAULT_CACHE_DURATION": 86400, | ||
"FRAME_ID": "okta-oauth-helper-frame", | ||
"REDIRECT_OAUTH_PARAMS_COOKIE_NAME": "okta-oauth-redirect-params", | ||
"REDIRECT_STATE_COOKIE_NAME": "okta-oauth-state", | ||
"REDIRECT_NONCE_COOKIE_NAME": "okta-oauth-nonce", | ||
"TOKEN_STORAGE_NAME": "okta-token-storage", | ||
"CACHE_STORAGE_NAME": "okta-cache-storage", | ||
"PKCE_STORAGE_NAME": "okta-pkce-storage" | ||
"jest-junit": { | ||
"outputDirectory": "../../build2/reports/unit/", | ||
"outputName": "junit-result.xml" | ||
}, | ||
"jest-junit": { | ||
"output": "./build2/reports/unit/junit-result.xml" | ||
"okta": { | ||
"commitSha": "4f67efa34b749bcf1659ea9acdfdbeb9f3ca4289", | ||
"fullVersion": "2.10.1-20191114221208-4f67efa" | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
701114
0
20
36
3324