sigv4 5.0.0 copy "sigv4: ^5.0.0" to clipboard
sigv4: ^5.0.0 copied to clipboard

Library for signing AWS requests with Signature Version 4, with both convenience wrappers/classes and cryptography methods

logo-long

sigv4 pub style: pedantic license

A Dart library for signing AWS requests with Signature Version 4.

This is not actively maintained. If you're looking for alternatives, check out aws_client. If you'd like to continue using this library and have a fix for an issue, I'll be happy to review PRs.

Usage #

Create a Sigv4Client. This will hold your secrets and configuration. Some omitted default values:

  • region defaults to eu-west-1
  • serviceNamedefaults to execute-api
final client = Sigv4Client(
  keyId: 'your_access_key_id',
  accessKey: 'your_access_key',
  region: 'eu-west-1',.
  serviceName: 'execute-api',
);

The easier way to create a request is by getting a package:http request object:

// A simple GET-request
final request = client.request('https://service.aws.com/endpoint');

get(request.url, headers: request.headers);

// A larger request
final request = client.request(
  'https://service.aws.com/endpoint',
  method: 'POST',
  query: {'key': 'value'},
  headers: {'header': 'value'},
  body: {'content': 'some-content'},
);

post(request.url, headers: request.headers, body: request.body);

Alternatively, you can get the canonical string and signed headers separately:

final path = 'https://service.aws.com/endpoint';
final query = {'key': 'value'};

final url = client.canonicalUrl(path, query: query);
final headers = client.signedHeaders(
  path,
  query: query,
);

get(url, headers: headers);

Extensions #

As of Dart 2.7.0, extensions were introduced. As of this release, sigv4 has extensions for these HTTP clients, as well as any source gen package built on these:

  • http
  • dio
  • chopper

All extensions adds a .sign() method to the request object which uses the client to sign the request. Example using Dio:

  final dio = RequestOptions(method: 'GET', path: 'https://service.aws.com').sign(client);
7
likes
120
pub points
84%
popularity

Publisher

verified publisherarnemolland.com

Library for signing AWS requests with Signature Version 4, with both convenience wrappers/classes and cryptography methods

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

convert, crypto, dio, http

More

Packages that depend on sigv4