Giter VIP home page Giter VIP logo

wage's Introduction

wage

A WASM package and web app for encrypting and decrypting age-encrypted files, powered by rage.

Currently in beta. The WASM library and webapp are mostly complete, but their APIs and UX are still expected to change as improvements are made. Known missing features:

  • Multi-file archive-and-encrypt.
  • Optional armoring for encryption.

Development

First, build wage itself as a Rust WASM package:

wasm-pack build

Then set up and run the webapp:

cd www
npm install
npm run serve

The webapp server will hot-reload on changes to the webapp itself. After making changes to the Rust WASM package, rebuild the package and restart the server:

[Ctrl+C]
cd ..
wasm-pack build
cd www
npm run serve

File downloading for encrypted or decrypted files will likely not work unless you are either accessing the webapp via localhost, or have configured it with a TLS certificate.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

wage's People

Contributors

dependabot[bot] avatar str4d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

wage's Issues

Any npm package / docs?

Hi,

I was finding an age-in-js solution and found out this repo (and, of course, the rage repo). It's a really cool idea about using a rust-powered wasm!

However, is there any npm package and/or docs? It seems that the only ("hacker") way to understand the package usage is by reading the source code of App.vue.

Thank you so much for your help! :-)

Trying to initialize wage ends up with fatal i18n error

Environment

  • OS: macOS

  • Browser version: Firefox 102.0.1 / Chrome 103.0.5060.114

  • wage version: ca13a4c

  • wasm-pack version: 0.10.2

  • Rust version: 1.61.0 (fe5b13d68 2022-05-18)

What were you trying to do

Create an identity

What happened

panicked at 'called `Result::unwrap()` on an `Err` value: LanguageNotAvailable("en-US/age.ftl", LanguageIdentifier { language: Language(Some("en")), script: None, region: Some(Region("US")), variants: None })', /Users/mark/.cargo/registry/src/github.com-1ecc6299db9ec823/age-0.7.1/src/i18n.rs:21:69

Stack:

__wbg_new_693216e109162396/<@webpack-internal:///./node_modules/wage/wage_bg.js:1130:17
logError@webpack-internal:///./node_modules/wage/wage_bg.js:339:18
__wbg_new_693216e109162396@webpack-internal:///./node_modules/wage/wage_bg.js:1129:48
__wbg_new_693216e109162396@http://192.168.1.172:8080/js/app.js:864:82
console_error_panic_hook::Error::new::h6473c06b199daf3a@http://192.168.1.172:8080/c6d6eca5ea56f3c37af4.module.wasm:wasm-function[11410]:0x30318a
console_error_panic_hook::hook_impl::he9b02191b67d0b2f@http://192.168.1.172:8080/c6d6eca5ea56f3c37af4.module.wasm:wasm-function[1423]:0x1a82e8
console_error_panic_hook::hook::h424364dd1d88411c@http://192.168.1.172:8080/c6d6eca5ea56f3c37…

Fix file download when running on localhost

We are using StreamSaver.js to download the processed file, which requires a service worker. It works fine if we serve the service worker's page from a secure context (when the webapp is published to a site with HTTPS), but looking at its documentation, it should also be possible to have it work via localhost without HTTPS.

webapp: Encryption fails in Chrome

Environment

  • OS: Windows 10
  • Browser version: Chrome 89.0.4389.90
  • wage version: fce4b8b

What were you trying to do

I generated a new identity, and then tried to encrypt a file to it.

What happened

App.vue:250 Uncaught (in promise) TypeError: Failed to execute 'pipeTo' on 'ReadableStream': parameter 1 is not of type 'WritableStream'.
    at o.encryptSingleFile (App.vue:250)
    at App.vue:231
  encryptSingleFile @ App.vue:250
  (anonymous) @ App.vue:231
  Promise.then (async)    
  encryptSingleFile @ App.vue:250
  (anonymous) @ App.vue:231
  Promise.then (async)    
  (anonymous) @ App.vue:229
  prepareEncryptStream @ App.vue:221
  encryptToRecipients @ App.vue:225

Expose a Rust stream to JavaScript as a user-downloadable file

The wage::decryptor_for_file API takes a JavaScript File and returns a handle to an age::Decryptor that wraps File.stream(). It would be great if there were a way to similarly expose age::stream::StreamReader as a JavaScript ReadableStream that could be passed back out to the browser, giving it the option to stream-process the decrypted file instead of having the entire decrypted file read into memory.

One issue here is that the Rust handle stores a lifetime, and wasm-bindgen doesn't currently support returning objects with lifetimes (rustwasm/wasm-bindgen#1187). So we may need to hack around that with unsafe, or alternatively have an API that takes a JavaScript TransformStream and writes the decrypted file to it (which would make for a somewhat wonky JavaScript API, but should still enable building JS pipelines).

Newtypes for decryptor and streams

In the stream today, I ran into the issue that types with lifetimes cannot be returned from Rust to JavaScript, so instead we boxed the values and returned the pointers as u32s (eww).

It literally just occurred to me that, once we have the pointer as an integer, we can just wrap that in a newtype and then #[wasm_bindgen] to have a JavaScript typed object 🤩

Recipent decryption

This should take a decryptor and a list of identity files, and return the same value as decrypt_with_passphrase:

#[wasm_bindgen]
pub async decrypt_with_identities(decryptor: u32, identities: &[web_sys::File]) -> Result<JsValue, JsValue> {}

webapp: No-network process-in-memory mode

We are currently using StreamSaver.js to stream the processed file back to the user, which requires using a service worker, and thus interacting with a server. It would be great to have a no-network mode that encrypts or decrypts entirely in memory (with corresponding memory limits) and then offers the resulting Blob to the user.

Host the webapp?

It seems like this could be hosted on Github Pages, which would let people do age-based encryption/decryption without needing any setup at all. Are there plans to do so?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.