Drupal - How to add JavaScript or CSS library to Composer project?

The library can be installed into a custom path by utilizing extra : installer-paths to for e.g.:

web/sites/libraries/{$name}

Additional to that, we define the required package repository with the needed type of drupal-library. Example composer.json for a project:

{
    "name"              : "example-composer/example-project",
    "description"       : "Project template for Drupal 8 projects with composer",
    "type"              : "project",
    "minimum-stability" : "dev",
    "prefer-stable"     : true,
    "scripts"           : {
        "post-install-cmd" : "sh ./scripts/composer/post-install.sh"
    },
    "require"           : {
        "composer/installers"       : "^1.0.20",
        "drupal/entity_browser"     : "8.1.0-alpha1",
        "cweagans/composer-patches" : "~1.0",
        "drupal/core"               : "8.0.*",
        "drush/drush"               : "~8.0",
        "drupal/console"            : "~0.9",
        "drupal/devel"              : "dev-8.x-1.x",
        "drupal/entity_browser"     : "8.1.0-alpha1",
        "drupal/inline_entity_form" : "8.1.0-alpha2",
        "drupal/dropzonejs"         : "8.1.*@dev",
        "enyo/dropzone"             : "dev-master"
    },
    "repositories"      : [
        {
            "type" : "composer",
            "url"  : "https://packagist.drupal-composer.org"
        },
        {
            "type"    : "package",
            "package" : {
                "name"    : "enyo/dropzone",
                "version" : "dev-master",
                "type"    : "drupal-library",
                "dist"    : {
                    "url"  : "https://github.com/enyo/dropzone.git",
                    "type" : "drupal-library"
                },
                "source"  : {
                    "url"       : "https://github.com/enyo/dropzone.git",
                    "type"      : "git",
                    "reference" : "origin/master"
                }
            }
        }
    ],
    "extra"             : {
        "installer-paths" : {
            "web/core"                    : [
                "type:drupal-core"
            ],
            ...
            "web/sites/libraries/{$name}" : [
                "type:drupal-library"
            ]
        }
    }
}

The dist part can be left off and is only needed for --prefer-dist cases when installing via php composer.phar update --prefer-dist (opposite: --prefer-source). To install a version and not the latest from the master branch, you need to set the version directly at the package to require then from there. Example:

"require" : {
    "enyo/dropzone" : "v4.2.*@dev"
},
"repositories" : [
    {
        "type"    : "package",
        "package" : {
            "name"    : "enyo/dropzone",
            "version" : "v4.2.0",
            "type"    : "drupal-library",
            "source"  : {
                "url"       : "https://github.com/enyo/dropzone.git",
                "type"      : "git",
                "reference" : "origin/master"
            }
        }
    }
]