adversarial.js icon indicating copy to clipboard operation
adversarial.js copied to clipboard

NPM Package

Open harrislapiroff opened this issue 4 years ago • 4 comments

Love this proof of concept. Would you consider packaging it for NPM installation?

harrislapiroff avatar Feb 19 '21 18:02 harrislapiroff

Thanks! The library is designed for in-browser use rather than in Node. On the server side, there are many equivalent Python packages (e.g. CleverHans).

Happy to consider if there's a good use case though.

kennysong avatar Feb 20 '21 02:02 kennysong

Lots of projects use npm for client-side package mangement! It's quite common to use npm with webpack to install packages from npm and process them into a client-side bundle with webpack for preprocessing. This is why there's actually lots of client-side only projects on npm, e.g., react-dom, d3 and others.

The particular use case that prompted me to want this is that Observable (an in-browser javascript notebook environment) uses a require function that pulls from jsDelivr, which ultimately pulls from npm. If this were packaged for npm, I could import it into an observable notebook like so. This code does not currently work:

advjs = require('adversarial-js')

However, I did manage to find a workaround using jsDelivr's GitHub functionality—also had to swap in import for require for compatibility with ES6-style modules. This code works:

advjs = import('https://cdn.jsdelivr.net/gh/kennysong/adversarial.js@main/src/adversarial.js')

Let me know if you have any questions about these use cases!

harrislapiroff avatar Feb 22 '21 16:02 harrislapiroff

Ah, thanks for the explanation! For now, I created a release on GitHub so you can import a stable version from jsDelivr:

advjs = import('https://cdn.jsdelivr.net/gh/kennysong/[email protected]/src/adversarial.js')

This should work for your in-browser use case w/ Observable, so please use it for now.

It'll take some time to properly publish the library on npm with tests, so I'll leave this issue open until then.

kennysong avatar Feb 23 '21 01:02 kennysong

Thanks! Will use the stable release :) Much appreciated

harrislapiroff avatar Feb 23 '21 05:02 harrislapiroff