snowflake-sdk
Advanced tools
Comparing version 1.10.0 to 1.10.1
@@ -72,3 +72,3 @@ /* | ||
validateURLs(authenticator, ssoUrl, tokenUrl); | ||
this.validateURLs(authenticator, ssoUrl, tokenUrl); | ||
@@ -168,9 +168,21 @@ const responseHtml = await getSAMLResponse( await createAccessToken(tokenUrl, username, password), ssoUrl); | ||
*/ | ||
function validateURLs(authenticator, ssoUrl, tokenUrl) { | ||
authenticator = authenticator.toLowerCase(); | ||
if (!(authenticator.startsWith(ssoUrl.substring(0, authenticator.length)) && | ||
authenticator.startsWith(tokenUrl.substring(0, authenticator.length)))) { | ||
throw new Error('The prefix of the SSO/token URL and the specified authenticator do not match.'); | ||
this.validateURLs = function (authenticator, ssoUrl, tokenUrl) { | ||
const compareUrlsByProtocolAndHost = (firstUrl, secondUrl) => firstUrl.protocol === secondUrl.protocol && firstUrl.host === secondUrl.host; | ||
try { | ||
const aUrl = new URL(authenticator); | ||
const sUrl = new URL(ssoUrl); | ||
const tUrl = new URL(tokenUrl); | ||
if (!(compareUrlsByProtocolAndHost(aUrl, sUrl) && compareUrlsByProtocolAndHost(aUrl, tUrl))) { | ||
throw new Error('The prefix of the SSO/token URL and the specified authenticator do not match.'); | ||
} | ||
} catch (err) { | ||
// we did not get a valid URL to test | ||
if (err instanceof TypeError) { | ||
throw new Error('Authenticator, SSO, or token URL is invalid.'); | ||
} else { | ||
throw err; | ||
} | ||
} | ||
} | ||
}; | ||
@@ -177,0 +189,0 @@ /** |
@@ -105,4 +105,7 @@ /* | ||
// Step 4: get SAML token | ||
const tokenData = await withBrowserActionTimeout(browserActionTimeout, receiveData); | ||
processGet(tokenData); | ||
const tokenGetHttpLine = await withBrowserActionTimeout(browserActionTimeout, receiveData).catch((rejected) => { | ||
server.close(); | ||
throw new Error(util.format('Error while getting SAML token: %s', rejected)); | ||
}); | ||
processGet(tokenGetHttpLine); | ||
}; | ||
@@ -139,7 +142,11 @@ | ||
// Stop accepting connections and close | ||
socket.destroy(); | ||
// Do not close the server until GET request is received | ||
if (!data[0].startsWith('GET /?token=')) { | ||
return; | ||
} | ||
server.close(); | ||
resolve(data); | ||
resolve(data[0]); | ||
}); | ||
@@ -161,23 +168,12 @@ socket.on('error', (socketErr) => { | ||
* | ||
* @param {String[]} data | ||
* @param {String} tokenHttpGetLine | ||
* | ||
* @returns {null} | ||
*/ | ||
function processGet(data) { | ||
let targetLine; | ||
for (const line of data) { | ||
if (line.startsWith('GET ')) { | ||
targetLine = line; | ||
break; | ||
} else { | ||
return; | ||
} | ||
} | ||
function processGet(tokenHttpGetLine) { | ||
// Split the GET request line | ||
targetLine = targetLine.split(' '); | ||
const data = tokenHttpGetLine.split(' '); | ||
// Get value of the "token" query parameter | ||
token = querystring.parse(targetLine[1])['/?token']; | ||
token = querystring.parse(data[1])['/?token']; | ||
} | ||
@@ -184,0 +180,0 @@ |
@@ -10,2 +10,3 @@ /* | ||
const AuthOkta = require('./auth_okta'); | ||
const Logger = require('../logger'); | ||
@@ -80,4 +81,3 @@ let authenticator; | ||
auth = new AuthWeb(connectionConfig, httpClient); | ||
} | ||
if (authType === authenticationTypes.KEY_PAIR_AUTHENTICATOR) { | ||
} else if (authType === authenticationTypes.KEY_PAIR_AUTHENTICATOR) { | ||
auth = new AuthKeypair(connectionConfig.getPrivateKey(), | ||
@@ -92,2 +92,3 @@ connectionConfig.getPrivateKeyPath(), | ||
// Authenticator specified does not exist | ||
Logger.getInstance().warn(`No authenticator found for '${authType}'. Using default authenticator as a fallback`); | ||
auth = new AuthDefault(connectionConfig.password); | ||
@@ -112,2 +113,2 @@ } | ||
return authenticator; | ||
}; | ||
}; |
@@ -9,2 +9,3 @@ /* | ||
const Statement = require('./statement'); | ||
const { isString } = require('util'); | ||
@@ -117,2 +118,9 @@ const STAGE_NAME = 'SYSTEM$BIND'; | ||
} | ||
if (!isString(data)) { | ||
if (data instanceof Date) { | ||
data = data.toJSON(); | ||
} else { | ||
data = JSON.stringify(data); | ||
} | ||
} | ||
if (data.toString().indexOf('"') >= 0 | ||
@@ -119,0 +127,0 @@ || data.toString().indexOf(',') >= 0 |
@@ -163,14 +163,13 @@ /* | ||
this.setupOcspPrivateLink = function (host) { | ||
const ocspCacheServer = `http://ocsp.${host}/ocsp_response_cache.json`; | ||
process.env.SF_OCSP_RESPONSE_CACHE_SERVER_URL = ocspCacheServer; | ||
process.env.SF_OCSP_RESPONSE_CACHE_SERVER_URL = `http://ocsp.${host}/ocsp_response_cache.json`; | ||
}; | ||
/** | ||
* Callback for connect() used to establish a connection. | ||
* | ||
* @param {self} this object | ||
* @param {Function} callback | ||
* | ||
* @returns {function} | ||
*/ | ||
* Callback for connect() used to establish a connection. | ||
* | ||
* @param self | ||
* @param {Function} callback | ||
* | ||
* @returns {function} | ||
*/ | ||
function connectCallback(self, callback) { | ||
@@ -225,28 +224,32 @@ return function (err) { | ||
connectionConfig.account, | ||
connectionConfig.username); | ||
connectionConfig.username).then(() => { | ||
// JSON for connection | ||
const body = Authenticator.formAuthJSON(connectionConfig.getAuthenticator(), | ||
connectionConfig.account, | ||
connectionConfig.username, | ||
connectionConfig.getClientType(), | ||
connectionConfig.getClientVersion(), | ||
connectionConfig.getClientEnvironment()); | ||
// JSON for connection | ||
const body = Authenticator.formAuthJSON(connectionConfig.getAuthenticator(), | ||
connectionConfig.account, | ||
connectionConfig.username, | ||
connectionConfig.getClientType(), | ||
connectionConfig.getClientVersion(), | ||
connectionConfig.getClientEnvironment()); | ||
// Update JSON body with the authentication values | ||
auth.updateBody(body); | ||
// Update JSON body with the authentication values | ||
auth.updateBody(body); | ||
initEasyLogging(connectionConfig.clientConfigFile) | ||
.then(() => { | ||
try { | ||
services.sf.connect({ | ||
callback: connectCallback(self, callback), | ||
json: body | ||
}); | ||
initEasyLogging(connectionConfig.clientConfigFile) | ||
.then(() => { | ||
try { | ||
services.sf.connect({ | ||
callback: connectCallback(self, callback), | ||
json: body | ||
}); | ||
} catch (e) { | ||
// we don't expect an error here since callback method should be called | ||
Logger.getInstance().error('Unexpected error from calling callback function', e); | ||
} | ||
}) | ||
.catch(() => callback(Errors.createClientError(ErrorCodes.ERR_CONN_CONNECT_INVALID_CLIENT_CONFIG, true))); | ||
return this; | ||
} catch (e) { | ||
// we don't expect an error here since callback method should be called | ||
Logger.getInstance().error('Unexpected error from calling callback function', e); | ||
} | ||
}, | ||
() => callback(Errors.createClientError(ErrorCodes.ERR_CONN_CONNECT_INVALID_CLIENT_CONFIG, true))); | ||
}, | ||
(err) => callback(err)); | ||
return this; | ||
@@ -549,2 +552,2 @@ }; | ||
module.exports = Connection; | ||
module.exports = Connection; |
@@ -63,4 +63,5 @@ /* | ||
// compute the epoch milliseconds and create a moment object from them | ||
let moment = Moment((epochSeconds * 1000) + (nanoSeconds / 1000000)); | ||
// create a moment object that includes the epoch seconds and the incremental nano seconds | ||
let moment = Moment(epochSeconds * 1000); | ||
moment.nanoSeconds = nanoSeconds; | ||
@@ -67,0 +68,0 @@ // set the moment's timezone |
@@ -591,3 +591,3 @@ /* | ||
exports.isCorrectSubdomain = function (value) { | ||
const subdomainRegex = RegExp(/^\w[\w.-]+\w$/i); | ||
const subdomainRegex = RegExp(/^\w([\w.-]+\w|)$/i); | ||
return subdomainRegex.test(value); | ||
@@ -594,0 +594,0 @@ }; |
{ | ||
"name": "snowflake-sdk", | ||
"version": "1.10.0", | ||
"version": "1.10.1", | ||
"description": "Node.js driver for Snowflake", | ||
@@ -14,3 +14,3 @@ "dependencies": { | ||
"asn1.js-rfc5280": "^3.0.0", | ||
"axios": "^1.6.5", | ||
"axios": "^1.6.8", | ||
"big-integer": "^1.6.43", | ||
@@ -17,0 +17,0 @@ "bignumber.js": "^9.1.2", |
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
546331
68
15638
Updatedaxios@^1.6.8