SaltwaterC/aws2js — pull request #60 by dordille (2012-08-28 21:28:36+00:00)
Title: Fixed issue where headers would be improperly signed for dynamoDB when request body contained utf8 characters.

When a request body of a dynamoDB contains utf8 characters the client headers will be improperly signed.

The following script can be used to demonstrate the error. With the current version of the api this script fails. With the change made in internals.js the script passes.
```js
// init the STS client for getting the access credentials
var aws = require('aws2js');
var sts = aws.load('sts', process.env.AWS_ACCEESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY);

// init the DynamoDB client
var dynamodb = require('aws2js').load('dynamodb');

sts.request('GetSessionToken', function (err, res) {
if (err) {
console.error(err.message);
process.exit(1);
} else {
var credentials = res.GetSessionTokenResult.Credentials;
dynamodb.setCredentials(credentials.AccessKeyId, credentials.SecretAccessKey, credentials.SessionToken);
var body = {
TableName: "test",
Item: {"id":{"S":"testy"},"string":{"S":"RÂ "}}
}
dynamodb.request('PutItem', body, function(err, res) {
if (err) {
console.error(err.message);
process.exit(2);
} else {
console.log(res);
process.exit(0);
}
});
}
});
```

I also changed the method used to determine if a request is being made to dynamodb in config.request, it looked like there was just a typo and instead of config.prefix being checked client.prefix was being checked. Although no errors were caused by adding the action and session token to the request body it is probably better to only include fields used by dynamo.