Problem/Motivation

Currently, the external ALTCHA javascript files are committed directly into the module’s repository under /assets/vendor. This approach makes it difficult to:

  • Track and manage library updates in a controlled, automated way.
  • Comply with Drupal.org’s best practices for third-party libraries
  • Keep the repository lightweight and avoid shipping third-party code directly.

Proposed resolution

Move the ALTCHA javascript dependencies to be managed via the composer libraries system, using a composer.json repository entry in the module.

  1. Remove the committed ALTCHA javascript files from the module’s /assets/vendor directory.
  2. Add the external library to the module’s composer.json, for example:
    {
      "require": {
        "altcha/altcha": "^1.0"
      },
      "repositories": [
        {
          "type": "package",
          "package": {
            "name": "altcha/altcha",
            "version": "1.0.0",
            "type": "drupal-library",
            "dist": {
              "url": "https://cdn.jsdelivr.net/npm/altcha@1.0.0/dist/",
              "type": "zip"
            }
          }
        }
      ]
    }
  3. Reference the library in the module’s .libraries.yml file using the libraries system path (e.g. /libraries/altcha/altcha.js), rather than from /modules/custom/....
  4. Update the README and installation instructions to reflect this change.

Comments

filsterjisah created an issue. See original summary.

filsterjisah’s picture

Issue summary: View changes
anybody’s picture

Big +1! Definitely shouldn't be included. Maybe you could take a look at similiar third party js integration modules for best practices. Status report should be used to report if the library is missing. Should never be loaded from external by default (GDPR).

robindh’s picture

Status: Active » Closed (won't fix)

We did think about this when we originally released the module, since I agree it's not ideal to include the third party script in the module itself. The main reason why we chose this approach is to make it work out of the box for Drupal CMS. The alternative would be to load it by default via CDN - but this is even worse because of possible CSP issues and as you mentioned: GDPR. Webform's approach to this is to include a webform:libraries:download drush command, which is convenient for standard drupal sites - but not for Drupal CMS as far as I'm aware.

We did include the ability to override the ALTCHA library via the settings form; this way sites can choose to use a composer-required dependency or CDN URL if they wish to do so.

I'm going to close this one as a won't fix, but feel free to re-open if there's a better solution for this that would also work out of the box for Drupal CMS.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.