Browse Source

`bindings/cashu-js` add npm files and fix duplicate names

thesimplekid 1 year ago
parent
commit
e6beabd7e7

+ 7 - 0
bindings/cashu-js/.gitignore

@@ -0,0 +1,7 @@
+/target
+**/*.rs.bk
+Cargo.lock
+bin/
+pkg/
+wasm-pack.log
+*.tgz

+ 12 - 0
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

+ 2 - 0
bindings/cashu-js/Cargo.toml

@@ -5,6 +5,8 @@ edition = "2021"
 description = "Cashu rust implementation, for JavaScript"
 description = "Cashu rust implementation, for JavaScript"
 authors = ["thesimplekid <tsk@thesimplekid.com>"]
 authors = ["thesimplekid <tsk@thesimplekid.com>"]
 publish = false
 publish = false
+repository.workspace = true
+license.workspace = true
 
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 [lib]
 [lib]

+ 29 - 0
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.

+ 21 - 0
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.

+ 44 - 0
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"
+  }
+}

+ 1 - 1
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};
 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 {
 pub struct JsProof {
     inner: Proof,
     inner: Proof,
 }
 }

+ 1 - 1
bindings/cashu-js/src/nuts/nut01/secret_key.rs

@@ -3,7 +3,7 @@ use std::ops::Deref;
 use cashu::nuts::nut01::SecretKey;
 use cashu::nuts::nut01::SecretKey;
 use wasm_bindgen::prelude::*;
 use wasm_bindgen::prelude::*;
 
 
-#[wasm_bindgen(js_name = PublicKey)]
+#[wasm_bindgen(js_name = SecretKey)]
 pub struct JsSecretKey {
 pub struct JsSecretKey {
     inner: SecretKey,
     inner: SecretKey,
 }
 }

+ 2 - 2
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 {
 pub struct JsMintInfo {
     inner: MintInfo,
     inner: MintInfo,
 }
 }
@@ -65,7 +65,7 @@ impl From<MintInfo> for JsMintInfo {
     }
     }
 }
 }
 
 
-#[wasm_bindgen(js_class = MintVersion)]
+#[wasm_bindgen(js_class = MintInfo)]
 impl JsMintInfo {
 impl JsMintInfo {
     #[wasm_bindgen(constructor)]
     #[wasm_bindgen(constructor)]
     #[allow(clippy::too_many_arguments)]
     #[allow(clippy::too_many_arguments)]

+ 9 - 0
bindings/cashu-js/tsconfig.json

@@ -0,0 +1,9 @@
+{
+    "compilerOptions": {
+        "strict": true
+    },
+    "typedocOptions": {
+        "entryPoints": ["pkg/nostr_js.d.ts"],
+        "readme": "README.md"
+    }
+}