Nebulous Plasma Muffin

    @vendia/aws-signed-fetch

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

    Keywords

    none

    Install

    npm i @vendia/aws-signed-fetch

    DownloadsWeekly Downloads

    68

    Version

    0.0.5

    License

    MIT

    Unpacked Size

    261 kB

    Total Files

    12

    Last publish

    Collaborators

    • silversteez
    • davidwells
    • brettstack
    • vendibot