amazon-cognito-identity-js
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -49,2 +49,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
return resp; | ||
}, function (err) { | ||
// If error happens here, the request failed | ||
// if it is TypeError throw network error | ||
if (err instanceof TypeError) { | ||
throw new Error('Network error'); | ||
} | ||
throw err; | ||
}).then(function (resp) { | ||
@@ -66,11 +73,27 @@ return resp.json().catch(function () { | ||
return callback(error); | ||
}).catch(function () { | ||
// Taken from aws-sdk-js/lib/protocol/json.js | ||
var code = (response.headers.get('x-amzn-errortype') || 'UnknownError').split(':')[0]; | ||
var error = { | ||
code: code, | ||
name: code, | ||
statusCode: response.status, | ||
message: response.status.toString() | ||
}; | ||
}).catch(function (err) { | ||
// default to return 'UnknownError' | ||
var error = { code: 'UnknownError', message: 'Unkown error' }; | ||
// first check if we have a service error | ||
if (response && response.headers && response.headers.get('x-amzn-errortype')) { | ||
try { | ||
var code = response.headers.get('x-amz-errortype').split(':')[0]; | ||
error = { | ||
code: code, | ||
name: code, | ||
statusCode: response.status, | ||
message: response.status ? response.status.toString() : null | ||
}; | ||
} catch (ex) {} | ||
// pass through so it doesn't get swallowed if we can't parse it | ||
// otherwise check if error is Network error | ||
} else if (err instanceof Error && err.message === 'Network error') { | ||
error = { | ||
code: err.name, | ||
name: err.name, | ||
message: err.message | ||
}; | ||
} | ||
return callback(error); | ||
@@ -77,0 +100,0 @@ }); |
@@ -95,2 +95,3 @@ declare module "amazon-cognito-identity-js" { | ||
public verifySoftwareToken(totpCode: string, friendlyDeviceName: string, callbacks: {onSuccess: (session: CognitoUserSession) => void, onFailure: (err: Error) => void}): void; | ||
public setUserMfaPreference(smsMfaSettings: string[], softwareTokenMfaSettings: string[], callback: NodeCallback<Error, string>): void; | ||
} | ||
@@ -97,0 +98,0 @@ |
@@ -57,2 +57,9 @@ 'use strict'; | ||
return resp; | ||
}, function (err) { | ||
// If error happens here, the request failed | ||
// if it is TypeError throw network error | ||
if (err instanceof TypeError) { | ||
throw new Error('Network error'); | ||
} | ||
throw err; | ||
}).then(function (resp) { | ||
@@ -74,11 +81,27 @@ return resp.json().catch(function () { | ||
return callback(error); | ||
}).catch(function () { | ||
// Taken from aws-sdk-js/lib/protocol/json.js | ||
var code = (response.headers.get('x-amzn-errortype') || 'UnknownError').split(':')[0]; | ||
var error = { | ||
code: code, | ||
name: code, | ||
statusCode: response.status, | ||
message: response.status.toString() | ||
}; | ||
}).catch(function (err) { | ||
// default to return 'UnknownError' | ||
var error = { code: 'UnknownError', message: 'Unkown error' }; | ||
// first check if we have a service error | ||
if (response && response.headers && response.headers.get('x-amzn-errortype')) { | ||
try { | ||
var code = response.headers.get('x-amz-errortype').split(':')[0]; | ||
error = { | ||
code: code, | ||
name: code, | ||
statusCode: response.status, | ||
message: response.status ? response.status.toString() : null | ||
}; | ||
} catch (ex) {} | ||
// pass through so it doesn't get swallowed if we can't parse it | ||
// otherwise check if error is Network error | ||
} else if (err instanceof Error && err.message === 'Network error') { | ||
error = { | ||
code: err.name, | ||
name: err.name, | ||
message: err.message | ||
}; | ||
} | ||
return callback(error); | ||
@@ -85,0 +108,0 @@ }); |
{ | ||
"name": "amazon-cognito-identity-js", | ||
"description": "Amazon Cognito Identity Provider JavaScript SDK", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Amazon Web Services", |
@@ -219,3 +219,3 @@ # Amazon Cognito Identity SDK for JavaScript | ||
if (err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
return; | ||
@@ -245,3 +245,3 @@ } | ||
if (err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
return; | ||
@@ -258,3 +258,3 @@ } | ||
if (err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
return; | ||
@@ -313,3 +313,3 @@ } | ||
onFailure: function(err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
}, | ||
@@ -329,3 +329,3 @@ | ||
if (err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
return; | ||
@@ -349,3 +349,3 @@ } | ||
onFailure: function(err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
}, | ||
@@ -367,3 +367,3 @@ inputVerificationCode: function() { | ||
if (err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
return; | ||
@@ -388,3 +388,3 @@ } | ||
if (err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
return; | ||
@@ -401,3 +401,3 @@ } | ||
if (err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
return; | ||
@@ -414,3 +414,3 @@ } | ||
if (err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
return; | ||
@@ -427,3 +427,3 @@ } | ||
if (err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
return; | ||
@@ -444,3 +444,3 @@ } | ||
onFailure: function(err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
}, | ||
@@ -471,3 +471,3 @@ //Optional automatic callback | ||
if (err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
return; | ||
@@ -524,3 +524,3 @@ } | ||
if (err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
return; | ||
@@ -594,3 +594,3 @@ } | ||
onFailure: function(err) { | ||
alert(err); | ||
alert(err.message); | ||
} | ||
@@ -610,3 +610,3 @@ }); | ||
onFailure: function(err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
} | ||
@@ -626,3 +626,3 @@ }); | ||
onFailure: function(err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
} | ||
@@ -641,3 +641,3 @@ }); | ||
onFailure: function(err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
} | ||
@@ -657,3 +657,3 @@ }); | ||
onFailure: function(err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
} | ||
@@ -700,3 +700,3 @@ }); | ||
if (err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
return; | ||
@@ -781,3 +781,3 @@ } | ||
onFailure: function(err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
}, | ||
@@ -820,3 +820,3 @@ | ||
if (err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
} | ||
@@ -836,3 +836,3 @@ console.log('call result ' + result) | ||
if (err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
} | ||
@@ -868,3 +868,3 @@ console.log('call result ' + result) | ||
if (err) { | ||
alert(err); | ||
alert(err.message || JSON.stringify(err)); | ||
return; | ||
@@ -871,0 +871,0 @@ } |
@@ -26,3 +26,3 @@ import UserAgent from './UserAgent'; | ||
'X-Amz-Target': `AWSCognitoIdentityProviderService.${operation}`, | ||
'X-Amz-User-Agent': this.userAgent | ||
'X-Amz-User-Agent': this.userAgent, | ||
}; | ||
@@ -44,2 +44,9 @@ | ||
return resp; | ||
}, err => { | ||
// If error happens here, the request failed | ||
// if it is TypeError throw network error | ||
if (err instanceof TypeError) { | ||
throw new Error('Network error'); | ||
} | ||
throw err; | ||
}) | ||
@@ -60,11 +67,27 @@ .then(resp => resp.json().catch(() => ({}))) | ||
}) | ||
.catch(() => { | ||
// Taken from aws-sdk-js/lib/protocol/json.js | ||
const code = (response.headers.get('x-amzn-errortype') || 'UnknownError').split(':')[0]; | ||
const error = { | ||
code, | ||
name: code, | ||
statusCode: response.status, | ||
message: response.status.toString(), | ||
}; | ||
.catch(err => { | ||
// default to return 'UnknownError' | ||
let error = { code: 'UnknownError', message: 'Unkown error' }; | ||
// first check if we have a service error | ||
if (response && response.headers && response.headers.get('x-amzn-errortype')) { | ||
try { | ||
const code = (response.headers.get('x-amz-errortype')).split(':')[0]; | ||
error = { | ||
code, | ||
name: code, | ||
statusCode: response.status, | ||
message: (response.status) ? response.status.toString() : null, | ||
}; | ||
} catch (ex) { | ||
// pass through so it doesn't get swallowed if we can't parse it | ||
} | ||
// otherwise check if error is Network error | ||
} else if (err instanceof Error && err.message === 'Network error') { | ||
error = { | ||
code: err.name, | ||
name: err.name, | ||
message: err.message, | ||
}; | ||
} | ||
return callback(error); | ||
@@ -71,0 +94,0 @@ }); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
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
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 26 instances 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
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
1
6
1601575
84
17246