{"_id":"@duniter-cesium/cordova-plugin-minisodium","_rev":"2-6c97c03f0453c3146e6bc804d03f1b77","name":"@duniter-cesium/cordova-plugin-minisodium","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.3":{"name":"@duniter-cesium/cordova-plugin-minisodium","version":"1.0.3","keywords":["ecosystem:cordova","cordova","cordova-ios","cordova-android","libsodium","sodium","NaCl","curve25519","ed25519","X25519","scrypt","blake2b","ecdh","eddsa","secretbox","box","sealed-box","hash","crypto","cryptography"],"author":{"name":"Ahmad Benmrad"},"license":"MIT","_id":"@duniter-cesium/cordova-plugin-minisodium@1.0.3","maintainers":[{"name":"blavenie","email":"benoit.lavenier@e-is.pro"}],"homepage":"https://github.com/duniter-cesium/cordova-plugin-minisodium#readme","bugs":{"url":"https://github.com/duniter-cesium/cordova-plugin-minisodium/issues"},"dist":{"shasum":"2f6c0fdbca837675f6ebb1c1af8023ddb8f624c4","tarball":"https://registry.npmjs.org/@duniter-cesium/cordova-plugin-minisodium/-/cordova-plugin-minisodium-1.0.3.tgz","fileCount":1430,"integrity":"sha512-KVvVzbl8ZjAGrjqA6ytsOORVYqGCpoCNdeyTv5QexpMmmgcP5P8XPgHKv0P/Zb5hZky9zlc4xWb0qHncrtPcNQ==","signatures":[{"sig":"MEYCIQDFbTjBW6x41UWEq4AtKWQ+GcIVNYIqW7OOPt5c23RvxgIhAIv0WaVRI0cR7pK1P3OuWEomg+QDBtW7Lggwjx3M4YWr","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18094940},"main":"index.js","cordova":{"id":"cordova-plugin-minisodium","platforms":["ios","android"]},"gitHead":"d0ab304dfca6c59ad61fddf30c77b9b84c974a7e","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":""},"_npmUser":{"name":"blavenie","email":"benoit.lavenier@e-is.pro"},"repository":{"url":"git+ssh://git@github.com/duniter-cesium/cordova-plugin-minisodium.git","type":"git"},"_npmVersion":"6.14.12","description":"A minimal binding to the libsodium library, as a plugin for Cordova applications on iOS and Android","directories":{"test":"tests"},"_nodeVersion":"10.24.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"grunt":"^1.0.1","grunt-jsvalidate":"^0.2.2","cordova-plugin-test-framework":">=1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/cordova-plugin-minisodium_1.0.3_1684229165319_0.06801323680819471","host":"s3://npm-registry-packages"}}},"time":{"created":"2023-05-16T09:26:05.227Z","modified":"2025-08-01T07:04:50.758Z","1.0.3":"2023-05-16T09:26:05.607Z"},"bugs":{"url":"https://github.com/duniter-cesium/cordova-plugin-minisodium/issues"},"author":{"name":"Ahmad Benmrad"},"license":"MIT","homepage":"https://github.com/duniter-cesium/cordova-plugin-minisodium#readme","keywords":["ecosystem:cordova","cordova","cordova-ios","cordova-android","libsodium","sodium","NaCl","curve25519","ed25519","X25519","scrypt","blake2b","ecdh","eddsa","secretbox","box","sealed-box","hash","crypto","cryptography"],"repository":{"url":"git+ssh://git@github.com/duniter-cesium/cordova-plugin-minisodium.git","type":"git"},"description":"A minimal binding to the libsodium library, as a plugin for Cordova applications on iOS and Android","maintainers":[{"email":"benoit.lavenier@e-is.pro","name":"blavenie"},{"email":"marine.archer@e-is.pro","name":"khornya"}],"readme":"# A minimal sodium plugin for Cordova - for iOS and Android\n\nA minimal build of the [libsodium](https://github.com/jedisct1/libsodium.git) library, as a plugin for Cordova applications on iOS and Android.\n\n## Bound methods and constants\n\n### Secretbox construction\n* `crypto_secretbox_easy`\n* `crypto_secretbox_open_easy`\n* `crypto_secretbox_KEYBYTES`\n* `crypto_secretbox_MACBYTES`\n* `crypto_secretbox_NONCEBYTES`\n\n### Public key signatures (Ed25519)\n* `crypto_sign`\n* `crypto_sign_open`\n* `crypto_sign_detached`\n* `crypto_sign_verify_detached`\n* `crypto_sign_keypair`\n* `crypto_sign_seed_keypair`\n* `crypto_sign_ed25519_sk_to_pk`\n* `crypto_sign_ed25519_sk_to_seed`\n* `crypto_sign_BYTES`\n* `crypto_sign_PUBLICKEYBYTES`\n* `crypto_sign_SECRETKEYBYTES`\n* `crypto_sign_SEEDBYTES`\n\n### Key exchange (Curve25519)\n\n* `crypto_scalarmult`\n* `crypto_scalarmult_base`\n* `crypto_scalarmult_BYTES`\n* `crypto_scalarmult_SCALARBYTES`\n\n### X25519 (Ed25519 -> Curve25519 conversion)\n\n* `crypto_sign_ed25519_pk_to_curve25519`\n* `crypto_sign_ed25519_sk_to_curve25519`\n\n### Memory-hard password derivation (Scrypt)\n\n* `crypto_pwhash_scryptsalsa208sha256`\n* `crypto_pwhash_scryptsalsa208sha256_ll`\n* `crypto_pwhash_scryptsalsa208sha256_SALTBYTES`\n* `crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE`\n* `crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE`\n\n__NOTE:__ the constants `crypto_pwhash_scryptsalsa208sha256_*_SENSITIVE` have not been bound. Not that they were forgotten, but it's a design choice. A standard smartphone will most likely be too slow if these constants are used in scrypt. These values are not forbidden though...\n\n### Box construction\n\n* `crypto_box_keypair`\n* `crypto_box_easy`\n* `crypto_box_open_easy`\n* `crypto_box_PUBLICKEYBYTES`\n* `crypto_box_SECRETKEYBYTES`\n* `crypto_box_NONCEBYTES`\n* `crypto_box_SEEDBYTES`\n* `crypto_box_MACBYTES`\n\n### Sealed box construction\n\n* `crypto_box_seal`\n* `crypto_box_seal_open`\n* `crypto_box_SEALBYTES`\n\n### Generic hashing\n\n* `crypto_generichash`\n* `crypto_generichash_BYTES`\n* `crypto_generichash_BYTES_MIN`\n* `crypto_generichash_BYTES_MAX`\n* `crypto_generichash_KEYBYTES`\n* `crypto_generichash_KEYBYTES_MIN`\n* `crypto_generichash_KEYBYTES_MAX`\n\n### Helper methods\n\n`HexString <-> Uint8Array` conversion\n* `to_hex`\n* `from_hex`\n\n`UTF8String <-> Uint8Array` conversion\n* `to_string`\n* `from_string`\n\n`Base64String <-> Uint8Array` conversion\n* `to_base64`\n* `from_base64`\n\n## Installation\n\n\tcordova plugin add cordova-plugin-minisodium\n\n__Note:__ This plugin is not built for Android API levels below 21. To set the `minSdkVersion` property in your Cordova app (if needed), add the following line in `config.xml`:\n```\n<preference name=\"android-minSdkVersion\" value=\"21\"/>\n```\n\n## Usage\n\nOnce the plugin is installed, all the methods of this plugin are available in `window.plugins.MiniSodium`.\n\nResults of these methods are not returned, but rather passed to a callback function. The callback function will receive 2 parameters : `(err, result)`, where:\n* `err` is an error (either a string or an `Error` instance), defined if an error occurred in the method\n* `result` is the result of the method call (such as a ciphertext, a plaintext, a derived key, a key pair,...). Results are always `Uint8Array` instances, except for `keypair` generation methods, where `result` is a `{pk, sk}` object (`pk` and `sk` are Uint8Array containing the public and private/secret keys respectively)\n\nRaw data parameters (e.g: message, ciphertext, keys, nonces, hashes,...) must provided either as `Uint8Array` instances or as hexadecimal strings.\n\nThe order of parameters in the bound methods is nearly respected (compared to the original [libsodium](https://github.com/jedisct1/libsodium) library)\n\nIf you have questions about the parameters of the methods, we advise you to [read the documentation](https://download.libsodium.org/libsodium/content/) of the original library\n\nAnyway, here is this plugin's API:\n\n__[Secretbox](https://download.libsodium.org/libsodium/content/secret-key_cryptography/authenticated_encryption.html)__\n* `MiniSodium.crypto_secretbox_easy(message, nonce, key, callback)`\n* `MiniSodium.crypto_secretbox_open_easy(ciphertext, nonce, key, callback)`\n\n__[Sign](https://download.libsodium.org/libsodium/content/public-key_cryptography/public-key_signatures.html)__\n* `MiniSodium.crypto_sign_keypair(callback)`\n* `MiniSodium.crypto_sign_seed_keypair(seed, callback)`\n* `MiniSodium.crypto_sign(message, secretKey, callback)`\n* `MiniSodium.crypto_sign_open(signedMessage, publicKey, callback)` __NOTE:__ This method passes the message (without the signature) to the callback if the signature is valid. If the signature is invalid it passes `0` or `false` instead\n* `MiniSodium.crypto_sign_detached(message, secretKey, callback)`\n* `MiniSodium.crypto_sign_verify_detached(signature, message, publicKey, callback)` __NOTE:__ The result of this method is a boolean. The callback receives `true` or `1` if the signature is valid `false` or `0` otherwise\n* `MiniSodium.crypto_sign_ed25519_sk_to_seed(secretKey, callback)`\n* `MiniSodium.crypto_sign_ed25519_sk_to_pk(secretKey, callback)`\n\n__[Ed25519 -> Curve25519 conversion](https://download.libsodium.org/libsodium/content/advanced/ed25519-curve25519.html)__\n* `MiniSodium.crypto_sign_ed25519_pk_to_curve25519(ed25519Pk, callback)`\n* `MiniSodium.crypto_sign_ed25519_sk_to_curve25519(ed25519Sk, callback)`\n\n__[Scalarmult (Curve25519)](https://download.libsodium.org/libsodium/content/advanced/scalar_multiplication.html)__\n* `MiniSodium.crypto_scalarmult_base(n, callback)`\n* `MiniSodium.crypto_scalarmult(n, p, callback)`\n\n__[Password-hashing (Scrypt)](https://download.libsodium.org/libsodium/content/password_hashing/scrypt.html)__\n* `MiniSodium.crypto_pwhash_scryptsalsa208sha256(keyLength, password, salt, opsLimit, memLimit, callback)`\n* `MiniSodium.crypto_pwhash_scryptsalsa208sha256_ll(password, salt, opsLimit, r, p, keyLength, callback)`\n\n__[Box](https://download.libsodium.org/libsodium/content/public-key_cryptography/authenticated_encryption.html)__\n* `MiniSodium.crypto_box_keypair(callback)`\n* `MiniSodium.crypto_box_easy(message, nonce, receiverPk, senderSk, callback)`\n* `MiniSodium.crypto_box_open_easy(cipher, nonce, senderPk, receiverSk, callback)`\n\n__[Sealed box](https://download.libsodium.org/libsodium/content/public-key_cryptography/sealed_boxes.html)__\n* `MiniSodium.crypto_box_seal(message, receiverPk, callback)`\n* `MiniSodium.crypto_box_seal_open(message, receiverPk, receiverSk, callback)`\n\n__[Generic hashing](https://download.libsodium.org/libsodium/content/hashing/generic_hashing.html)__\n* `MiniSodium.crypto_generichash(hashLength, message, [key], callback)` Please note that `key` is an optional parameter. If omitted, you should put `undefined` or `null` in its place when calling this method\n\n## Testing\n\n1. Create a Cordova/Phonegap application\n2. Add the iOS and/or the Android platforms\n3. Add the [testing framework](https://github.com/apache/cordova-plugin-test-framework) and [bind its page](https://github.com/apache/cordova-plugin-test-framework#running-plugin-tests) as the main page of the app\n4. Add the following preference in `config.xml`\n```\n<preference name=\"android-minSdkVersion\" value=\"21\"/>\n```\n5. Add this plugin\n6. Add this plugin's test cases, by adding the plugin located in the `tests` folder\n```\n\tphonegap plugin add https://github.com/LockateMe/cordova-plugin-minisodium.git#:/tests\n```\n\n## License\n\nMIT license\n","readmeFilename":"README.md"}