From e6beabd7e7587844a1b91220e6aa304fc59520a6 Mon Sep 17 00:00:00 2001 From: thesimplekid Date: Tue, 26 Sep 2023 07:07:13 +0100 Subject: [PATCH] `bindings/cashu-js` add npm files and fix duplicate names --- bindings/cashu-js/.gitignore | 7 +++ bindings/cashu-js/.npmignore | 12 +++++ bindings/cashu-js/Cargo.toml | 2 + bindings/cashu-js/LICENSE | 29 ++++++++++++ bindings/cashu-js/LICENSES/NOSTR-MIT | 21 +++++++++ bindings/cashu-js/package.json | 44 +++++++++++++++++++ bindings/cashu-js/src/nuts/nut00/proof.rs | 2 +- .../cashu-js/src/nuts/nut01/secret_key.rs | 2 +- bindings/cashu-js/src/nuts/nut09.rs | 4 +- bindings/cashu-js/tsconfig.json | 9 ++++ 10 files changed, 128 insertions(+), 4 deletions(-) create mode 100644 bindings/cashu-js/.gitignore create mode 100644 bindings/cashu-js/.npmignore create mode 100644 bindings/cashu-js/LICENSE create mode 100644 bindings/cashu-js/LICENSES/NOSTR-MIT create mode 100644 bindings/cashu-js/package.json create mode 100644 bindings/cashu-js/tsconfig.json diff --git a/bindings/cashu-js/.gitignore b/bindings/cashu-js/.gitignore new file mode 100644 index 00000000..bed4e246 --- /dev/null +++ b/bindings/cashu-js/.gitignore @@ -0,0 +1,7 @@ +/target +**/*.rs.bk +Cargo.lock +bin/ +pkg/ +wasm-pack.log +*.tgz diff --git a/bindings/cashu-js/.npmignore b/bindings/cashu-js/.npmignore new file mode 100644 index 00000000..1147df4e --- /dev/null +++ b/bindings/cashu-js/.npmignore @@ -0,0 +1,12 @@ +.cargo/ +target/ +src/ +scripts/ +examples/ +pkg/package.json +pkg/*.md +pkg/*.wasm +.gitignore +Cargo.toml +Cargo.lock +*.tgz diff --git a/bindings/cashu-js/Cargo.toml b/bindings/cashu-js/Cargo.toml index 96c1c428..d73ee4a2 100644 --- a/bindings/cashu-js/Cargo.toml +++ b/bindings/cashu-js/Cargo.toml @@ -5,6 +5,8 @@ edition = "2021" description = "Cashu rust implementation, for JavaScript" authors = ["thesimplekid "] publish = false +repository.workspace = true +license.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] diff --git a/bindings/cashu-js/LICENSE b/bindings/cashu-js/LICENSE new file mode 100644 index 00000000..083823dd --- /dev/null +++ b/bindings/cashu-js/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2023, thesimplekid +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/bindings/cashu-js/LICENSES/NOSTR-MIT b/bindings/cashu-js/LICENSES/NOSTR-MIT new file mode 100644 index 00000000..2ff56442 --- /dev/null +++ b/bindings/cashu-js/LICENSES/NOSTR-MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022-2023 Yuki Kishimoto + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/bindings/cashu-js/package.json b/bindings/cashu-js/package.json new file mode 100644 index 00000000..9b70632b --- /dev/null +++ b/bindings/cashu-js/package.json @@ -0,0 +1,44 @@ +{ + "name": "@rust-cashu/cashu", + "version": "0.0.1", + "description": "Cashu protocol implementation, for JavaScript", + "keywords": [ + "cashu", + "protocol", + "rust", + "bindings" + ], + "license": "BSD-3-Clause", + "homepage": "https://github.com/thesimplekid/cashu-crab", + "repository": { + "type": "git", + "url": "git+https://github.com/thesimplekid/cashu-crab" + }, + "bugs": { + "url": "https://github.com/thesimplekid/cashu-crab/issues" + }, + "author": { + "name": "thesimplekid", + "email": "tsk@thesimplekid.com", + "url": "https://github.com/thesimplekid" + }, + "main": "pkg/cashu_js.js", + "types": "pkg/cashu_js.d.ts", + "files": [ + "pkg/cashu_js_bg.wasm.js", + "pkg/cashu_js_bg.wasm.d.ts", + "pkg/cashu_js.js", + "pkg/cashu_js.d.ts" + ], + "devDependencies": { + "wasm-pack": "^0.10.2" + }, + "engines": { + "node": ">= 10" + }, + "scripts": { + "build": "WASM_PACK_ARGS=--release ./scripts/build.sh", + "build:dev": "WASM_PACK_ARGS=--dev ./scripts/build.sh", + "package": "npm run build && npm pack" + } +} diff --git a/bindings/cashu-js/src/nuts/nut00/proof.rs b/bindings/cashu-js/src/nuts/nut00/proof.rs index 0d747d3e..f65b6cfd 100644 --- a/bindings/cashu-js/src/nuts/nut00/proof.rs +++ b/bindings/cashu-js/src/nuts/nut00/proof.rs @@ -5,7 +5,7 @@ use wasm_bindgen::prelude::*; use crate::{nuts::nut01::JsPublicKey, nuts::nut02::JsId, types::JsAmount, types::JsSecret}; -#[wasm_bindgen(js_name = Token)] +#[wasm_bindgen(js_name = Proof)] pub struct JsProof { inner: Proof, } diff --git a/bindings/cashu-js/src/nuts/nut01/secret_key.rs b/bindings/cashu-js/src/nuts/nut01/secret_key.rs index 8d453312..49276fc1 100644 --- a/bindings/cashu-js/src/nuts/nut01/secret_key.rs +++ b/bindings/cashu-js/src/nuts/nut01/secret_key.rs @@ -3,7 +3,7 @@ use std::ops::Deref; use cashu::nuts::nut01::SecretKey; use wasm_bindgen::prelude::*; -#[wasm_bindgen(js_name = PublicKey)] +#[wasm_bindgen(js_name = SecretKey)] pub struct JsSecretKey { inner: SecretKey, } diff --git a/bindings/cashu-js/src/nuts/nut09.rs b/bindings/cashu-js/src/nuts/nut09.rs index 77dabab6..72a971ce 100644 --- a/bindings/cashu-js/src/nuts/nut09.rs +++ b/bindings/cashu-js/src/nuts/nut09.rs @@ -47,7 +47,7 @@ impl JsMintVersion { } } -#[wasm_bindgen(js_name = MintVersion)] +#[wasm_bindgen(js_name = MintInfo)] pub struct JsMintInfo { inner: MintInfo, } @@ -65,7 +65,7 @@ impl From for JsMintInfo { } } -#[wasm_bindgen(js_class = MintVersion)] +#[wasm_bindgen(js_class = MintInfo)] impl JsMintInfo { #[wasm_bindgen(constructor)] #[allow(clippy::too_many_arguments)] diff --git a/bindings/cashu-js/tsconfig.json b/bindings/cashu-js/tsconfig.json new file mode 100644 index 00000000..84bc409f --- /dev/null +++ b/bindings/cashu-js/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "strict": true + }, + "typedocOptions": { + "entryPoints": ["pkg/nostr_js.d.ts"], + "readme": "README.md" + } +}