0.1.0 • Published 2 years ago

@vendia/aws-signed-fetch v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Signed AWS requests

Isomorphic sig v4 requests

import { createSignedFetcher } from '@vendia/aws-signed-fetch'

async function getCredentials() {
  // Your logic to get valid AWS creds
  return {
    accessKeyId: 'xyz',
    secretAccessKey: '123',
    sessionToken: 'abc'
  }
}

// Create aws sigv4 signed fetch client
const signedFetch = createSignedFetcher({
  method: 'POST',
  region: 'us-east-1',
  baseUrl: 'https://your-api-url.com',
  getCredentials: getCredentials,
  debug: true
})

// Call https://lolololololollolololo.com/nice with signed GET
signedFetch('/nice').then((d) => {
  console.log('d', d.data)
}).catch((e) => {
  console.log('err', e)
})

// Call https://lolololololollolololo.com/nice with signed POST
signedFetch('/nice', {
  method: 'POST',
  body: JSON.stringify({
    wow: 'cool'      
  })
}).then((d) => {
  console.log('d', d.data)
}).catch((e) => {
  console.log('err', e)
})
0.1.0

2 years ago

0.0.5

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago