@vendia/aws-signed-fetch

0.1.0 • Public • Published

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)
})

Dependencies (2)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @vendia/aws-signed-fetch

    Weekly Downloads

    30

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    48.5 kB

    Total Files

    10

    Last publish

    Collaborators

    • silversteez
    • davidwells
    • brettstack
    • vendibot