Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support uri parameter #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions aws4.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ RequestSigner.prototype.isSingleRegion = function() {
}

RequestSigner.prototype.createHost = function() {
if(this.request.uri) {
this.request.path = url.parse(this.request.uri).path
return url.parse(this.request.uri).host
}
var region = this.isSingleRegion() ? '' :
(this.service === 's3' && this.region !== 'us-east-1' ? '-' : '.') + this.region,
service = this.service === 'ses' ? 'email' : this.service
Expand Down
13 changes: 13 additions & 0 deletions example.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,16 @@ request(aws4.sign({

//request(aws4.sign({service: 'sdb', path: '/?Action=ListDomains&Version=2009-04-15'}))

// API Gateway with amazonaws domain name
request(aws4.sign({
uri: 'https://xxxxxx.execute-api.us-west-2.amazonaws.com/v1/required-iam-auth',
service: 'execute-api',
region: 'us-west-2'
}))

// API Gateway with custom domain name
request(aws4.sign({
uri: 'https://<custom_domain_name>/required-iam-auth',
service: 'execute-api',
region: 'us-west-2'
}))