atlassian_connect_host 0.5.7

  • Readme
  • Changelog
  • Installing
  • 0

Atlassian Connect Host Services #

Introduction #

Provides services for Atlassian product host related activities such as:

  • automatically installing the addon on startup (dev mode only)
  • handling product host installation lifecycle events
  • signing (jwt) requests to the host
  • persisting host registration information (with pluggable persistence providers)
  • authenticating requests from an Atlassian host
  • creating addon session tokens (based on information from host request)
  • authenticating addon session tokens

This library can be used on it's own (e.g. as part of your own custom Dart based Atlassian Connect client framework) or as part of the Atlassian Connect Shelf based server.

Using #

Basic Usage #

Create a Host Registration Repository #

The library provides an interface for repository implementations. The interface is very simple

abstract class AcHostRegistrationRepository {

  Future<AcHostRegistration> create(AcHostRegistration hostRegistration);

  Future<Option<AcHostRegistration>> findRegistrationByHostKey(String hostKey);

It consists of one method to create a new registration entry and one to look up by host key.

You can create your own implementation to whatever data store you like without much effort.

Currently, two implementations are provided out of the box

  • AcHostRegistrationInMemoryTestRepository. A simple in memory implementation suitable for testing and development mode only. It is very convenient as it doesn't require any set up
  • AcHostRegistrationMongoRepository. A Mongo DB implementation

To create a Mongo DB repository first follow instructions on setting up a mongo instance then call

DB db // create the mongo client DB object

final repo = new AcHostRegistrationMongoRepository(db);

Create an AddonHost object #

An AddonHost represents (surprisingly) the addon host itself. Create one like so

final addonHost = new AddonHost(addonKey, baseUrl, addonSecret);

Note the addonSecret is only needed if you want to use the addon session token mechanism.

Create the AcHostService object #

Now you have all you need to create a host service object

final hostService = new AcHostService(repo, addonHost);

Now you can use it as follows.

Initiate Host Installation (dev mode)

The following will attempt to contact the host with the give base url and initiate installation of the addon


Handle the Installation Event by Registering the Host

When you get an installation lifecycle event from a host, call the registerHost method with the event (after decoding the json)


Send an HTTP Request to a Host

For example the following sends a request to Jira to fetch an issue

final jiraResponse = hostService.httpClientForHostKey(hostKey)
    .then((httpClient) => httpClient.get('rest/api/2/issue/$issueKey', signRequest: true))
    .then((req) => req.close());

    .then((body) {   
       Map issueJson = body.body;
       // do something with the issue json

0.4.0 #

  • Hipchat support
  • use enums
  • remove mutable variants of models

0.3.4 #

  • disable pk check

0.3.2 #

  • updated jwt to 0.2.2

0.3.1 #

  • updated jwt to 0.2.1

0.3.0 #

  • updated jwt to 0.2.0

0.2.0 #

  • Exclude context path from addons canoncial uri when authenticating requests from host

0.1.1 #

  • Make sure no registration exists for host key to prevent hijacking

0.1.0+2 #

  • fixed npe in in memory repo

0.1.0+1 #

  • upgraded min sdk version

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  atlassian_connect_host: ^0.5.7

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:atlassian_connect_host/atlassian_connect_host.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.9.0 <2.0.0