master
Niko PLP 8 months ago
parent 7045a717bb
commit 59f63aef17
  1. 47
      Cargo.lock
  2. 1
      Cargo.toml
  3. 6
      ng-app/README.md
  4. 1
      ng-app/package.json
  5. 1
      ng-app/src-tauri/Cargo.toml
  6. 10
      ng-app/src-tauri/src/lib.rs
  7. 49
      ng-app/src/api.ts
  8. 10
      ng-app/src/routes/Grid.svelte
  9. 10
      ng-app/src/routes/Install.svelte
  10. 445
      ng-app/src/routes/WalletCreate.svelte
  11. 4
      ng-app/src/styles.css
  12. 23
      ng-sdk-js/README.md
  13. 2
      ng-sdk-js/app-node/index.js
  14. 2233
      ng-sdk-js/js/bowser.js
  15. 17
      ng-sdk-js/js/browser.js
  16. 122
      ng-sdk-js/js/node.js
  17. 91
      ng-sdk-js/src/lib.rs
  18. 54
      ng-wallet/src/lib.rs
  19. 64
      ng-wallet/src/types.rs
  20. 28
      ngaccount/Cargo.toml
  21. 37
      ngaccount/README.md
  22. 82
      ngaccount/src/main.rs
  23. 30
      ngaccount/src/types.rs
  24. 24
      ngaccount/web/.gitignore
  25. 3
      ngaccount/web/.vscode/extensions.json
  26. 61
      ngaccount/web/index.html
  27. 32
      ngaccount/web/jsconfig.json
  28. 27
      ngaccount/web/package.json
  29. 1310
      ngaccount/web/pnpm-lock.yaml
  30. 13
      ngaccount/web/postcss.config.cjs
  31. 2
      ngaccount/web/public/robots.txt
  32. 1
      ngaccount/web/public/vite.svg
  33. 26
      ngaccount/web/src/App.svelte
  34. 4
      ngaccount/web/src/app.postcss
  35. 4
      ngaccount/web/src/assets/EU.svg
  36. 16
      ngaccount/web/src/assets/nextgraph.svg
  37. 9
      ngaccount/web/src/main.js
  38. 27
      ngaccount/web/src/routes/Home.svelte
  39. 20
      ngaccount/web/src/routes/NotFound.svelte
  40. 2
      ngaccount/web/src/vite-env.d.ts
  41. 7
      ngaccount/web/svelte.config.js
  42. 23
      ngaccount/web/tailwind.config.cjs
  43. 36
      ngaccount/web/vite.config.js
  44. 8
      ngd/src/cli.rs
  45. 9
      ngd/src/main.rs
  46. 13
      ngone/README.md
  47. 5
      ngone/src/main.rs
  48. 6
      ngone/web/src/routes/WalletCreate.svelte
  49. 186
      p2p-broker/src/broker_store/account.rs
  50. 157
      p2p-broker/src/broker_store/invitation.rs
  51. 4
      p2p-broker/src/broker_store/mod.rs
  52. 4
      p2p-broker/src/broker_store/overlay.rs
  53. 2
      p2p-broker/src/broker_store/topic.rs
  54. 2
      p2p-broker/src/lib.rs
  55. 83
      p2p-broker/src/server_ws.rs
  56. 37
      p2p-broker/src/storage.rs
  57. 10
      p2p-broker/src/types.rs
  58. 3
      p2p-net/Cargo.toml
  59. 7
      p2p-net/src/broker.rs
  60. 17
      p2p-net/src/broker_storage.rs
  61. 4
      p2p-net/src/lib.rs
  62. 287
      p2p-net/src/types.rs
  63. 56
      p2p-net/src/utils.rs
  64. 2
      p2p-repo/src/errors.rs
  65. 2
      p2p-repo/src/kcv_store.rs
  66. 8
      pnpm-lock.yaml
  67. 5
      stores-lmdb/src/kcv_store.rs

47
Cargo.lock generated

@ -2736,6 +2736,7 @@ dependencies = [
"serde_json",
"tauri",
"tauri-build",
"tauri-plugin-window",
]
[[package]]
@ -2787,6 +2788,30 @@ dependencies = [
"zeroize",
]
[[package]]
name = "ngaccount"
version = "0.1.0"
dependencies = [
"base64-url",
"bytes",
"env_logger",
"log",
"ng-wallet",
"p2p-net",
"p2p-repo",
"rust-embed",
"serde",
"serde-big-array",
"serde_bare",
"serde_bytes",
"serde_json",
"slice_as_array",
"stores-lmdb",
"tokio",
"warp",
"warp-embed",
]
[[package]]
name = "ngcli"
version = "0.1.0"
@ -3024,6 +3049,15 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-src"
version = "111.26.0+1.1.1u"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efc62c9f12b22b8f5208c23a7200a442b2e5999f8bdf80233852122b5a4f6f37"
dependencies = [
"cc",
]
[[package]]
name = "openssl-sys"
version = "0.9.90"
@ -3032,6 +3066,7 @@ checksum = "374533b0e45f3a7ced10fcaeccca020e66656bc03dac384f852e4e5a7a8104a6"
dependencies = [
"cc",
"libc",
"openssl-src",
"pkg-config",
"vcpkg",
]
@ -3129,6 +3164,7 @@ dependencies = [
"unique_id",
"url",
"wasm-bindgen",
"web-time",
]
[[package]]
@ -4629,6 +4665,17 @@ dependencies = [
"tauri-utils",
]
[[package]]
name = "tauri-plugin-window"
version = "2.0.0-alpha.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "209fef1a00a981949e2440924b4be267c7639daeba51b29179004fa1c6d74900"
dependencies = [
"serde",
"tauri",
"thiserror",
]
[[package]]
name = "tauri-runtime"
version = "0.13.0-alpha.6"

@ -9,6 +9,7 @@ members = [
"ngcli",
"ngd",
"ngone",
"ngaccount",
"ng-sdk-js",
"ng-app/src-tauri",
"ng-wallet"

@ -101,6 +101,12 @@ rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-andro
- follow the steps for Android in the [Prerquisites guide of Tauri](https://next--tauri.netlify.app/next/guides/getting-started/prerequisites/)
Until I find out how to do this properly, if you are compiling the android app from a macos station, you need to override an env var. this is due to reqwest needing SSL support, and on linux and android it compiles it from source. apparently the compiler (cc-rs) doesn't know that when cross compiling to android targets, the tool ranlib is called llvm-ranlib (and not [target]-ranlib)
```
export RANLIB=/Users/[user]/Library/Android/sdk/ndk/[yourNDKversion]/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ranlib
```
to launch the dev app :
```

@ -17,6 +17,7 @@
"dependencies": {
"@popperjs/core": "^2.11.8",
"@tauri-apps/api": "2.0.0-alpha.4",
"@tauri-apps/plugin-window": "2.0.0-alpha.0",
"async-proxy": "^0.4.1",
"classnames": "^2.3.2",
"flowbite": "^1.6.5",

@ -24,6 +24,7 @@ p2p-repo = { path = "../../p2p-repo" }
p2p-net = { path = "../../p2p-net" }
ng-wallet = { path = "../../ng-wallet" }
async-std = { version = "1.12.0", features = ["attributes","unstable"] }
tauri-plugin-window = "2.0.0-alpha"
[features]
# this feature is used for production builds or when `devPath` points to the filesystem

@ -13,7 +13,7 @@ use p2p_net::broker::*;
use p2p_net::utils::{spawn_and_log_error, Receiver, ResultSend};
use p2p_repo::log::*;
use p2p_repo::types::*;
use tauri::{App, Manager};
use tauri::{App, Manager, Window};
#[cfg(mobile)]
mod mobile;
@ -78,6 +78,7 @@ async fn wallet_create_wallet(mut params: CreateWalletV0) -> Result<CreateWallet
#[tauri::command(rename_all = "snake_case")]
async fn doc_sync_branch(nuri: &str, stream_id: &str, app: tauri::AppHandle) -> Result<(), ()> {
log_info!("doc_sync_branch {} {}", nuri, stream_id);
let main_window = app.get_window("main").unwrap();
let mut reader;
{
@ -91,10 +92,10 @@ async fn doc_sync_branch(nuri: &str, stream_id: &str, app: tauri::AppHandle) ->
async fn inner_task(
mut reader: Receiver<Commit>,
stream_id: String,
app: tauri::AppHandle,
main_window: tauri::Window,
) -> ResultSend<()> {
while let Some(commit) = reader.next().await {
app.emit_all(&stream_id, commit).unwrap();
main_window.emit(&stream_id, commit).unwrap();
}
BROKER.write().await.tauri_stream_cancel(stream_id);
@ -103,7 +104,7 @@ async fn doc_sync_branch(nuri: &str, stream_id: &str, app: tauri::AppHandle) ->
Ok(())
}
spawn_and_log_error(inner_task(reader, stream_id.to_string(), app));
spawn_and_log_error(inner_task(reader, stream_id.to_string(), main_window));
Ok(())
}
@ -173,6 +174,7 @@ impl AppBuilder {
Ok(())
})
.plugin(tauri_plugin_window::init())
.invoke_handler(tauri::generate_handler![
test,
doc_sync_branch,

@ -8,6 +8,8 @@
// according to those terms.
import {createAsyncProxy} from "async-proxy";
import { writable } from "svelte/store";
import { Bowser } from "../../ng-sdk-js/js/bowser.js";
import {version} from '../package.json';
const mapping = {
@ -26,18 +28,51 @@ const handler = {
if (import.meta.env.NG_APP_WEB) {
let sdk = await import("ng-sdk-js")
return Reflect.apply(sdk[path], caller, args)
if (path[0] === "client_info") {
let client_info = await Reflect.apply(sdk[path], caller, args);
client_info.version=version;
//console.log(client_info);
return client_info;
} else {
return Reflect.apply(sdk[path], caller, args)
}
} else {
let tauri = await import("@tauri-apps/api/tauri");
if (path[0] === "client_info") {
if (path[0] === "doc_sync_branch") {
let tauri_platform = import.meta.env.TAURI_PLATFORM;
let client_type;
switch (tauri_platform) {
case 'macos': client_type = "NativeMacOS";break;
case 'linux': client_type = "NativeLinux";break;
case 'windows': client_type = "NativeWindows";break;
case 'android': client_type = "NativeAndroid";break;
case 'ios': client_type = "NativeIos";break;
}
let info = Bowser.parse(window.navigator.userAgent);
info.platform.arch = import.meta.env.TAURI_ARCH;
info.platform.tauri = {
family: import.meta.env.TAURI_FAMILY,
os_version: import.meta.env.TAURI_PLATFORM_VERSION,
type: import.meta.env.TAURI_PLATFORM_TYPE,
debug: import.meta.env.TAURI_DEBUG,
target: import.meta.env.TAURI_TARGET_TRIPLE
};
info.browser.ua = window.navigator.userAgent;
let res = {
// TODO: install timestamp
ClientInfoV0 : { client_type, details: JSON.stringify(info), version, timestamp_install:0, timestamp_updated:0 }
};
//console.log(res);
return res;
} else if (path[0] === "doc_sync_branch") {
let stream_id = (lastStreamId += 1).toString();
console.log("stream_id",stream_id);
let { listen } = await import("@tauri-apps/api/event");
let { appWindow } = await import("@tauri-apps/plugin-window");
let nuri = args[0];
let callback = args[1];
let unlisten = await listen(stream_id, (event) => {
let unlisten = await appWindow.listen(stream_id, (event) => {
callback(event.payload).then(()=> {})
})
await tauri.invoke("doc_sync_branch",{nuri, stream_id});
@ -58,6 +93,8 @@ const handler = {
params.result_with_wallet_file = false;
params.security_img = Array.from(new Uint8Array(params.security_img));
return await tauri.invoke(path[0],{params})
} else if (path[0] === "get_local_bootstrap") {
return false;
}
else {
let arg = {};
@ -70,4 +107,8 @@ const handler = {
const api = createAsyncProxy({}, handler);
export const NG_EU_BSP = "https://nextgraph.eu";
export const NG_NET_BSP = "https://nextgraph.net";
export default api;

@ -55,16 +55,10 @@
security_txt: " know yourself ",
pin: [5, 2, 9, 1],
pazzle_length: 9,
send_bootstrap: undefined,
send_bootstrap: false,
send_wallet: false,
result_with_wallet_file: true,
peer_id: {
Ed25519PubKey: [
119, 251, 253, 29, 135, 199, 254, 50, 134, 67, 1, 208, 117, 196, 167,
107, 2, 113, 98, 243, 49, 90, 7, 0, 157, 58, 14, 187, 14, 3, 116, 86,
],
},
nonce: 0,
local_save: false,
};
try {

@ -78,7 +78,7 @@
</a>
</div>
<div class="row mt-5">
<a href="#">
<a href="https://nextgraph.org/download/#android">
<button
tabindex="-1"
class="text-primary-700 bg-primary-100 hover:bg-primary-100/90 focus:ring-4 focus:outline-none focus:ring-primary-100/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-100/55 mr-2 mb-2"
@ -119,7 +119,7 @@
</div>
<div class="row mt-5">
<a href="#">
<a href="https://nextgraph.org/download/#macos">
<button
tabindex="-1"
class="text-primary-700 bg-primary-100 hover:bg-primary-100/90 focus:ring-4 focus:outline-none focus:ring-primary-100/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-100/55 mr-2 mb-2"
@ -140,7 +140,7 @@
</div>
<div class="row mt-5">
<a href="#">
<a href="https://nextgraph.org/download/#linux">
<button
tabindex="-1"
class="text-primary-700 bg-primary-100 hover:bg-primary-100/90 focus:ring-4 focus:outline-none focus:ring-primary-100/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-100/55 mr-2 mb-2"
@ -161,7 +161,7 @@
</div>
<div class="row mt-5">
<a href="#">
<a href="https://nextgraph.org/download/#windows">
<button
tabindex="-1"
class="text-primary-700 bg-primary-100 hover:bg-primary-100/90 focus:ring-4 focus:outline-none focus:ring-primary-100/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-100/55 mr-2 mb-2"
@ -182,7 +182,7 @@
</div>
<div class="row mt-5 mb-12">
<a href="https://docs.nextgraph.org/en/self-hosted">
<a href="https://nextgraph.org/self-host">
<button
tabindex="-1"
class="text-primary-700 bg-primary-100 hover:bg-primary-100/90 focus:ring-4 focus:outline-none focus:ring-primary-100/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-100/55 mr-2 mb-2"

@ -11,17 +11,19 @@
<script>
import { Button, Alert, Dropzone, Toggle } from "flowbite-svelte";
import { link } from "svelte-spa-router";
import { link, querystring } from "svelte-spa-router";
import EULogo from "../assets/EU.svg?component";
import Logo from "../assets/nextgraph.svg?component";
import ng from "../api";
import { NG_EU_BSP, NG_NET_BSP, default as ng } from "../api";
import { display_pazzle } from "../wallet_emojis";
import { onMount, tick } from "svelte";
let mobile =
import.meta.env.TAURI_PLATFORM == "android" ||
import.meta.env.TAURI_PLATFORM == "ios";
const params = new URLSearchParams($querystring);
let tauri_platform = import.meta.env.TAURI_PLATFORM;
let mobile = tauri_platform == "android" || tauri_platform == "ios";
const onFileSelected = (image) => {
animate_bounce = false;
@ -92,6 +94,7 @@
let download_name;
let cloud_link;
let animateDownload = true;
let invitation;
function scrollToTop() {
top.scrollIntoView();
@ -115,9 +118,18 @@
? "api/v1/"
: "http://localhost:3030/api/v1/";
let display_note_on_local_wallets = true;
let display_note_on_local_wallets = false;
async function bootstrap() {
console.log(await ng.client_info());
invitation = await ng.get_local_bootstrap(location.href, params.get("i"));
console.log(invitation);
// TODO: implement this error screen and link button
if (!invitation && params.get("i")) {
console.error(
"got an invitation for another broker. click on the link below to be redirected to the right broker"
);
}
scrollToTop();
let bs;
try {
@ -152,15 +164,8 @@
security_txt,
pin,
pazzle_length: 9,
send_bootstrap: undefined, //options.cloud || options.bootstrap ? : undefined,
send_bootstrap: false, //options.cloud || options.bootstrap ? : undefined,
send_wallet: options.cloud,
peer_id: {
Ed25519PubKey: [
119, 251, 253, 29, 135, 199, 254, 50, 134, 67, 1, 208, 117, 196, 167,
107, 2, 113, 98, 243, 49, 90, 7, 0, 157, 58, 14, 187, 14, 3, 116, 86,
],
},
nonce: 0,
local_save: options.trusted, // this is only used for tauri apps
result_with_wallet_file: false, // this will be automatically changed to true for browser app
};
@ -203,7 +208,16 @@
console.log("Result:", result);
}
onMount(() => bootstrap());
onMount(async () => await bootstrap());
const selectEU = (event) => {
if (!tauri_platform) {
window.open(NG_EU_BSP + "/#/wallet/create", "_blank").focus();
}
};
const selectNET = (event) => {};
const enterINVITE = (event) => {};
const enterQRcode = (event) => {};
</script>
<main class="container3" bind:this={top}>
@ -215,14 +229,14 @@
{#if intro}
<div class=" max-w-6xl lg:px-8 mx-auto px-4">
<p class="max-w-xl md:mx-auto lg:max-w-2xl">
A <b>NextGraph Wallet</b> is unique to each individual. It stores your
A <b>NextGraph Wallet</b> is unique to each person. It stores your
credentials and authorizations to access documents. <br /><br />If you
already have a wallet, you should not create a new one, instead,
<a href="/wallet/login" use:link
>login here with your existing wallet.</a
>
If you never created a NextGraph Wallet before, please follow the instructions
below in order to create your personal wallet.
below in order to create your unique personal wallet.
</p>
</div>
{#if display_note_on_local_wallets}
@ -277,8 +291,8 @@
/>
</svg>
<span
>In it, we store all the permissions to access documents you have
been granted with, or that you have created yourself.</span
>In your wallet, we store all the permissions to access documents
you have been granted with, or that you have created yourself.</span
>
</li>
<li class="flex space-x-3">
@ -422,10 +436,10 @@
</svg>
<span
>For the same reason, we won't be able to help you if you forget
your pazzle or PIN code. There is no "password recovery" option in
this case. You can note your pazzle down on a piece of paper until
you remember it, but don't forget to destroy this note after a
while.</span
your pazzle or PIN code, or if you loose the wallet file. There is
no "password recovery" option in this case. You can note your
pazzle down on a piece of paper until you remember it, but don't
forget to destroy this note after a while.</span
>
</li>
</ul>
@ -435,7 +449,7 @@
<button
on:click|once={create_wallet}
role="button"
class="text-white bg-primary-700 hover:bg-primary-700/90 focus:ring-4 focus:outline-none focus:ring-primary-700/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-700/55 mr-2 mb-2"
class="text-white bg-primary-700 hover:bg-primary-700/90 focus:ring-4 focus:outline-none focus:ring-primary-700/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-700/55 mb-2"
>
<svg
class="w-8 h-8 mr-2 -ml-1"
@ -455,14 +469,374 @@
Ok, I create my wallet now !
</button>
</div>
{:else if !invitation}
<div class=" max-w-6xl lg:px-8 mx-auto px-4">
<p class="max-w-xl md:mx-auto lg:max-w-2xl">
NextGraph is based on an efficient decentralized P2P network, and in
order to join this network and start using the app, you need to first
select a <b>broker&nbsp;server</b>.
</p>
</div>
<div class="px-4 pt-3 mx-auto max-w-6xl lg:px-8 lg:pt-10 dark:bg-slate-800">
<div class="max-w-xl md:mx-auto sm:text-center lg:max-w-2xl">
<h2 class="pb-5 text-xl">
What is a broker? <span class="text-sm">Please read</span>
</h2>
<ul class="mb-8 space-y-4 text-left text-gray-500 dark:text-gray-400">
<li class="flex space-x-3">
<svg
fill="none"
stroke="currentColor"
stroke-width="1.5"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
class="flex-shrink-0 w-5 h-5 text-green-500 dark:text-green-400"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"
/>
</svg>
<span>
The broker helps you keep all your data in <b>sync</b>, as it is
connected to the internet 24/7 and keeps a copy of the updates for
you. This way, even if the devices of the other participants are
offline, you can still see their changes</span
>
</li>
<li class="flex space-x-3">
<svg
class="flex-shrink-0 w-5 h-5 text-green-500 dark:text-green-400"
fill="none"
stroke="currentColor"
stroke-width="1.5"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M15.75 5.25a3 3 0 013 3m3 0a6 6 0 01-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1121.75 8.25z"
/>
</svg>
<span>
All your data is secure and <b>end-to-end encrypted</b>, and the
broker cannot see the content of the documents as it does not have
the keys to decrypt them.</span
>
</li>
<li class="flex space-x-3">
<svg
class="flex-shrink-0 w-5 h-5 text-green-500 dark:text-green-400"
fill="none"
stroke="currentColor"
stroke-width="1.5"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M3.98 8.223A10.477 10.477 0 001.934 12C3.226 16.338 7.244 19.5 12 19.5c.993 0 1.953-.138 2.863-.395M6.228 6.228A10.45 10.45 0 0112 4.5c4.756 0 8.773 3.162 10.065 7.498a10.523 10.523 0 01-4.293 5.774M6.228 6.228L3 3m3.228 3.228l3.65 3.65m7.894 7.894L21 21m-3.228-3.228l-3.65-3.65m0 0a3 3 0 10-4.243-4.243m4.242 4.242L9.88 9.88"
/>
</svg>
<span>
The broker helps you enforce your <b>privacy</b> as it hides your internet
address (IP) from other users you share documents with.</span
>
</li>
<li class="flex space-x-3">
<svg
class="flex-shrink-0 w-5 h-5 text-green-500 dark:text-green-400"
fill="none"
stroke="currentColor"
stroke-width="1.5"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M9.75 9.75l4.5 4.5m0-4.5l-4.5 4.5M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
/>
</svg>
<span>
It will be possible in the future to use NextGraph without any
broker and to have direct connections between peers, but this will
imply a less smooth experience.</span
>
</li>
<li class="flex space-x-3">
<svg
class="flex-shrink-0 w-5 h-5 text-green-500 dark:text-green-400"
fill="none"
stroke="currentColor"
stroke-width="1.5"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M7.5 21L3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"
/>
</svg>
<span>
At anytime you can decide to switch to another broker service
provider or host it yourself. Your data is totally <b>portable</b>
and can freely move to another broker.</span
>
</li>
<li class="flex space-x-3">
<svg
class="flex-shrink-0 w-5 h-5 text-green-500 dark:text-green-400"
fill="none"
stroke="currentColor"
stroke-width="1.5"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25"
/>
</svg>
<span>
Very soon we will offer you the opportunity to host your own
broker at <b>home</b> or <b>office</b>. Instead of using a "broker
service provider", you will own a small device that you connect
behind your internet router. It is called NG Box and will be
available soon.</span
>
</li>
<li class="flex space-x-3">
<svg
class="flex-shrink-0 w-5 h-5 text-green-500 dark:text-green-400"
fill="none"
stroke="currentColor"
stroke-width="1.5"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M5.25 14.25h13.5m-13.5 0a3 3 0 01-3-3m3 3a3 3 0 100 6h13.5a3 3 0 100-6m-16.5-3a3 3 0 013-3h13.5a3 3 0 013 3m-19.5 0a4.5 4.5 0 01.9-2.7L5.737 5.1a3.375 3.375 0 012.7-1.35h7.126c1.062 0 2.062.5 2.7 1.35l2.587 3.45a4.5 4.5 0 01.9 2.7m0 0a3 3 0 01-3 3m0 3h.008v.008h-.008v-.008zm0-6h.008v.008h-.008v-.008zm-3 6h.008v.008h-.008v-.008zm0-6h.008v.008h-.008v-.008z"
/>
</svg>
<span>
Large organizations and companies have the opportunity to host a
broker <b>on-premise</b> or in the cloud, as the software is open
source. Individuals can also <b>self-host</b> a broker on any VPS server
or at home.</span
>
</li>
</ul>
<h2 class="mt-3 text-xl">Please choose one broker among the list</h2>
</div>
</div>
<div class="row mt-5">
{#if !tauri_platform}
<a href="https://nextgraph.eu/#/wallet/create">
<button
tabindex="-1"
class="text-primary-700 bg-primary-100 hover:bg-primary-100/90 focus:ring-4 focus:outline-none focus:ring-primary-100/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-100/55 mb-2"
>
<EULogo class="mr-4 block h-10 w-10" alt="European Union flag" />
For European Union citizens
</button>
</a>
{:else}
<button
on:click|once={selectEU}
class="choice-button text-primary-700 bg-primary-100 hover:bg-primary-100/90 focus:ring-4 focus:outline-none focus:ring-primary-100/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-100/55 mb-2"
>
<EULogo class="mr-4 block h-10 w-10" alt="European Union flag" />
For European Union citizens
</button>
{/if}
</div>
<div class="row mt-5">
{#if !tauri_platform}
<a href="https://nextgraph.net/#/wallet/create">
<button
tabindex="-1"
class="text-primary-700 bg-primary-100 hover:bg-primary-100/90 focus:ring-4 focus:outline-none focus:ring-primary-100/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-100/55 mb-2"
>
<svg
fill="none"
stroke="currentColor"
stroke-width="1.5"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
class="mr-4 block h-10 w-10"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0112 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 013 12c0-1.605.42-3.113 1.157-4.418"
/>
</svg>
For the rest of the world
</button>
</a>
{:else}
<button
on:click|once={selectNET}
class="choice-button text-primary-700 bg-primary-100 hover:bg-primary-100/90 focus:ring-4 focus:outline-none focus:ring-primary-100/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-100/55 mb-2"
>
<svg
fill="none"
stroke="currentColor"
stroke-width="1.5"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
class="mr-4 block h-10 w-10"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0112 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 013 12c0-1.605.42-3.113 1.157-4.418"
/>
</svg>
For the rest of the world
</button>
{/if}
</div>
<div class="row mt-5">
<button
on:click|once={enterINVITE}
class="choice-button text-primary-700 bg-primary-100 hover:bg-primary-100/90 focus:ring-4 focus:outline-none focus:ring-primary-100/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-100/55 mb-2"
>
<svg
fill="none"
stroke="currentColor"
stroke-width="1.5"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
class="mr-4 block h-10 w-10"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M13.19 8.688a4.5 4.5 0 011.242 7.244l-4.5 4.5a4.5 4.5 0 01-6.364-6.364l1.757-1.757m13.35-.622l1.757-1.757a4.5 4.5 0 00-6.364-6.364l-4.5 4.5a4.5 4.5 0 001.242 7.244"
/>
</svg>
Enter an invitation link
</button>
</div>
{#if mobile}
<div class="row mt-5">
<button
on:click|once={enterQRcode}
class="choice-button text-primary-700 bg-primary-100 hover:bg-primary-100/90 focus:ring-4 focus:outline-none focus:ring-primary-100/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-100/55 mb-2"
><svg
class="mr-4 block h-10 w-10"
fill="none"
stroke="currentColor"
stroke-width="1.5"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M3.75 4.875c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5A1.125 1.125 0 013.75 9.375v-4.5zM3.75 14.625c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5a1.125 1.125 0 01-1.125-1.125v-4.5zM13.5 4.875c0-.621.504-1.125 1.125-1.125h4.5c.621 0 1.125.504 1.125 1.125v4.5c0 .621-.504 1.125-1.125 1.125h-4.5A1.125 1.125 0 0113.5 9.375v-4.5z"
/>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6.75 6.75h.75v.75h-.75v-.75zM6.75 16.5h.75v.75h-.75v-.75zM16.5 6.75h.75v.75h-.75v-.75zM13.5 13.5h.75v.75h-.75v-.75zM13.5 19.5h.75v.75h-.75v-.75zM19.5 13.5h.75v.75h-.75v-.75zM19.5 19.5h.75v.75h-.75v-.75zM16.5 16.5h.75v.75h-.75v-.75z"
/>
</svg>
Scan an invitation QRcode
</button>
</div>
{/if}
<div class="row mt-5">
<a href="https://nextgraph.org/self-host">
<button
tabindex="-1"
class="choice-button text-primary-700 bg-primary-100 hover:bg-primary-100/90 focus:ring-4 focus:outline-none focus:ring-primary-100/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-100/55 mb-2"
>
<svg
fill="none"
stroke="currentColor"
stroke-width="1.5"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
class="mr-4 block h-10 w-10"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M5.25 14.25h13.5m-13.5 0a3 3 0 01-3-3m3 3a3 3 0 100 6h13.5a3 3 0 100-6m-16.5-3a3 3 0 013-3h13.5a3 3 0 013 3m-19.5 0a4.5 4.5 0 01.9-2.7L5.737 5.1a3.375 3.375 0 012.7-1.35h7.126c1.062 0 2.062.5 2.7 1.35l2.587 3.45a4.5 4.5 0 01.9 2.7m0 0a3 3 0 01-3 3m0 3h.008v.008h-.008v-.008zm0-6h.008v.008h-.008v-.008zm-3 6h.008v.008h-.008v-.008zm0-6h.008v.008h-.008v-.008z"
/>
</svg>
Self-hosted broker
</button>
</a>
</div>
<div class="row mt-5 mb-12">
<a href="https://nextgraph.org/ng-box/">
<button
tabindex="-1"
class="choice-button text-primary-700 bg-primary-100 hover:bg-primary-100/90 focus:ring-4 focus:outline-none focus:ring-primary-100/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-100/55 mb-2"
>
<svg
xmlns="http://www.w3.org/2000/svg"
version="1.1"
viewBox="0 0 225 225"
class="mr-4 block h-10 w-10"
stroke="currentColor"
stroke-width="12"
fill="none"
>
<path
d="M 88.332599,179.77884 C 72.858008,177.42608 59.581081,170.564 48.8817,159.38898 36.800075,146.77026 30.396139,130.74266 30.396139,113.12381 c 0,-8.81477 1.466462,-16.772273 4.503812,-24.439156 3.697755,-9.333883 8.658122,-16.726264 15.988284,-23.827148 4.07992,-3.952299 5.699054,-5.267377 9.730928,-7.903581 10.263753,-6.710853 20.852276,-10.247623 32.861256,-10.976317 17.083161,-1.036581 33.737521,4.410501 47.100151,15.404873 1.30009,1.069669 2.35446,2.035155 2.34305,2.145524 -0.0114,0.110369 -3.32807,3.135042 -7.37038,6.721489 -4.04229,3.586437 -8.6667,7.731233 -10.27646,9.210635 -1.60975,1.479412 -3.05439,2.689839 -3.21032,2.689839 -0.15591,0 -1.2075,-0.642795 -2.33686,-1.428431 -6.49544,-4.518567 -13.79659,-6.747116 -22.104843,-6.747116 -10.982241,0 -20.054641,3.741852 -27.727158,11.435891 -5.517107,5.532575 -9.233107,12.555305 -10.782595,20.377588 -0.596045,3.00901 -0.594915,11.67153 0.0017,14.67182 3.195984,16.0665 15.801761,28.55358 31.607491,31.30987 3.592183,0.62643 10.334745,0.61437 13.792675,-0.0247 12.10383,-2.2368 22.30712,-9.80603 27.83192,-20.64689 0.66747,-1.30971 1.08703,-2.48825 0.93235,-2.61898 -0.1547,-0.13073 -5.9299,-1.01605 -12.83381,-1.96739 -8.43575,-1.16241 -12.87296,-1.9096 -13.52955,-2.27826 -1.31171,-0.73647 -2.44642,-2.49122 -2.44642,-3.78325 0,-1.012 1.74837,-13.68832 2.1486,-15.57814 0.25598,-1.20873 2.0923,-3.01339 3.3151,-3.25795 0.53677,-0.10735 7.61424,0.73799 15.7688,1.88346 8.13723,1.14303 14.89071,1.97925 15.00772,1.85826 0.11702,-0.12098 0.96445,-5.648553 1.88315,-12.283473 0.95557,-6.900944 1.90122,-12.59548 2.20977,-13.306594 0.29667,-0.683692 0.95765,-1.595052 1.46889,-2.025218 1.77972,-1.497534 2.7114,-1.539742 10.52745,-0.476938 8.31229,1.130266 9.2373,1.347581 10.59333,2.488613 1.41776,1.192951 1.96085,2.424677 1.94866,4.419342 -0.006,0.950347 -0.79507,7.156475 -1.75393,13.791395 -0.95885,6.634933 -1.70069,12.111623 -1.64854,12.170443 0.0522,0.0588 6.18174,0.95872 13.62132,1.99978 9.57969,1.34053 13.80866,2.0595 14.49353,2.46406 1.3199,0.77969 2.13943,2.28402 2.1135,3.87957 -0.0399,2.45278 -2.08103,15.63263 -2.5664,16.57122 -0.57073,1.10369 -2.24485,2.197 -3.38232,2.20889 -0.44831,0.004 -6.79249,-0.82755 -14.09817,-1.84941 -7.3057,-1.02186 -13.34942,-1.79161 -13.43049,-1.71053 -0.0811,0.0811 -1.02469,6.33285 -2.09694,13.89286 -1.24218,8.75802 -2.1547,14.1778 -2.51495,14.93697 -0.62565,1.31846 -2.38302,2.64205 -3.91461,2.94836 -0.8254,0.16509 -9.4024,-0.80047 -11.73007,-1.32049 -0.47193,-0.10544 -1.63157,0.58011 -3.8898,2.29957 -9.71515,7.39729 -20.99725,11.99799 -33.08692,13.49241 -3.79574,0.46921 -13.565667,0.37348 -17.125664,-0.16779 z"
/>
<rect
ry="37.596001"
y="10.583322"
x="14.363095"
height="204.86308"
width="195.79167"
/>
</svg>
NG Box (owned or invited)
</button>
</a>
</div>
{:else if pin.length < 4}
<div class=" max-w-6xl lg:px-8 mx-auto px-4">
<p class="max-w-xl md:mx-auto lg:max-w-2xl">
<span class="text-xl">Let's start by choosing a PIN code</span>
<Alert color="yellow" class="mt-5">
We recommend you to choose a PIN code that you already know very well
:<br />
your credit card PIN, by example, is a good choice
We recommend you to choose a PIN code that you already know very well.
<br />
Your credit card PIN, by example, is a good choice. (We at NextGraph will
never see your PIN)
</Alert>
</p>
<p class="text-left mt-5">Here are the rules for the PIN :</p>
@ -610,7 +984,7 @@
<button
on:click|once={save_security}
bind:this={validate_button}
class="animate-bounce mt-10 text-white bg-primary-700 hover:bg-primary-700/90 focus:ring-4 focus:outline-none focus:ring-primary-700/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-700/55 mr-2 mb-2"
class="animate-bounce mt-10 text-white bg-primary-700 hover:bg-primary-700/90 focus:ring-4 focus:outline-none focus:ring-primary-700/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-700/55 mb-2"
>
<svg
class="w-8 h-8 mr-2 -ml-1"
@ -695,8 +1069,8 @@
with your security and privacy.<br /><br />
Remember that in any case, once your wallet will be created, you will download
a file that you should keep privately somewhere on your device, USB key or
harddisk. This is the default way you can use and keep your wallet. Now let's
look at some options that can make your life a bit easier.
hard-disk. This is the default way you can use and keep your wallet. Now
let's look at some options that can make your life a bit easier.
</p>
<p class="max-w-xl md:mx-auto lg:max-w-2xl text-left">
<span class="text-xl">Do you trust this device? </span> <br />
@ -704,8 +1078,8 @@
family or workplace, and you would like to login again from this device in
the future, then you can save your wallet on this device. To the contrary,
if this device is public and shared by strangers, do not save your wallet
here. {#if !import.meta.env.TAURI_PLATFORM}By selecting this option, you
agree to save some cookies on your browser.{/if}<br />
here. {#if !tauri_platform}By selecting this option, you agree to save
some cookies on your browser.{/if}<br />
<Toggle class="mt-3" bind:checked={options.trusted}
>Save your wallet on this device?</Toggle
>
@ -755,7 +1129,7 @@
{/if}
<button
on:click|once={do_wallet}
class="mt-10 mb-8 text-white bg-primary-700 hover:bg-primary-700/90 focus:ring-4 focus:outline-none focus:ring-primary-700/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-700/55 mr-2"
class="mt-10 mb-8 text-white bg-primary-700 hover:bg-primary-700/90 focus:ring-4 focus:outline-none focus:ring-primary-700/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-700/55"
>
<svg
class="w-8 h-8 mr-2 -ml-1"
@ -827,7 +1201,7 @@
tabindex="-1"
class:animate-bounce={animateDownload}
on:click={() => (animateDownload = false)}
class="mt-10 mb-8 text-white bg-primary-700 hover:bg-primary-700/90 focus:ring-4 focus:outline-none focus:ring-primary-700/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-700/55 mr-2"
class="mt-10 mb-8 text-white bg-primary-700 hover:bg-primary-700/90 focus:ring-4 focus:outline-none focus:ring-primary-700/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-700/55"
>
<svg
class="w-8 h-8 mr-2 -ml-1"
@ -896,3 +1270,6 @@
</div>
{/if}
</main>
<style>
</style>

@ -29,6 +29,10 @@ div[role="alert"] div {
display: block;
}
.choice-button {
min-width: 340px;
}
.row {
display: flex;
justify-content: center;

@ -37,17 +37,10 @@ npm i ng-sdk-js
## For contributors
```
wasm-pack build --target bundler
cd pkg
// if you have access to npm registry and want to publish the package
// npm publish --access=public
wasm-pack build --dev --target bundler
cd ..
wasm-pack build -t nodejs -d pkg-node
wasm-pack build --dev -t nodejs -d pkg-node
node prepare-node.js
cd pkg-node
// if you have access to npm registry and want to publish the package
// npm publish --access=public
```
For testing in vanilla JS
@ -65,6 +58,18 @@ Or automated testing with headless chrome:
wasm-pack test --chrome --headless
```
## Production built
```
wasm-pack build --target bundler
wasm-pack build -t nodejs -d pkg-node
node prepare-node.js
cd pkg
npm publish --access=public
cd ../pkg-node
npm publish --access=public
```
### Plain JS web app
```

@ -14,6 +14,6 @@ global.WebSocket = WebSocket;
const test = require("./test")
console.log("FROM INDEX");
ng.test();
test.random();
//test.random();
console.log(ng.start());

File diff suppressed because it is too large Load Diff

@ -1,3 +1,14 @@
export function random(max) {
return Math.round(Math.random() * max)
}
import {version} from '../../../package.json';
export function client_details() {
return window.navigator.userAgent;
}
export function client_details2(obj) {
obj.browser.appVersion = navigator?.appVersion;
obj.browser.arch = navigator?.platform;
obj.browser.vendor = navigator?.vendor;
obj.browser.ua = window.navigator.userAgent;
obj.engine.sdk = version;
return JSON.stringify(obj);
}

@ -1,4 +1,122 @@
module.exports.random = function (max) {
return 0
const macNameMap = new Map([
[23, ['Sonoma', '14']],
[22, ['Ventura', '13']],
[21, ['Monterey', '12']],
[20, ['Big Sur', '11']],
[19, ['Catalina', '10.15']],
[18, ['Mojave', '10.14']],
[17, ['High Sierra', '10.13']],
[16, ['Sierra', '10.12']],
[15, ['El Capitan', '10.11']],
[14, ['Yosemite', '10.10']],
[13, ['Mavericks', '10.9']],
[12, ['Mountain Lion', '10.8']],
[11, ['Lion', '10.7']],
[10, ['Snow Leopard', '10.6']],
[9, ['Leopard', '10.5']],
[8, ['Tiger', '10.4']],
[7, ['Panther', '10.3']],
[6, ['Jaguar', '10.2']],
[5, ['Puma', '10.1']],
]);
function macosRelease(release) {
let split = (release).split('.');
rel = Number(split[0]);
let [name, version] = macNameMap.get(rel) || ['Unknown', release];
if (name!='Unknown') {
if (split.length>1) version += '.'+split[1];
//if (split.length>2 && split[2]) version += '.'+split[2];
}
return {
name: "macOS",
versionName: name,
version,
release
};
}
const winNames = new Map([
['10.0.2', '11'], // It's unclear whether future Windows 11 versions will use this version scheme: https://github.com/sindresorhus/windows-release/pull/26/files#r744945281
['10.0.22', 'Server 2022'],
['10.0', '10 or Server 2016/2019'],
['6.3', '8.1 or Server 2012 R2'],
['6.2', '8 or Server 2012'],
['6.1', '7 or Server 2008 R2'],
['6.0', 'Vista or Server 2008'],
['5.2', 'Server 2003'],
['5.1', 'XP'],
['5.0', '2000'],
['4.90', 'ME'],
['4.10', '98'],
['4.03', '95'],
['4.00', '95'],
['3.00', 'NT'],
]);
function windowsRelease(release) {
const version = /(\d+\.\d+)(?:\.(\d+))?/.exec(release);
let ver = version[1] || '';
const build = version[2] || '';
if (ver.startsWith('3.')) {
ver = '3.00';
}
if (ver === '10.0' && build.startsWith('20348')) {
// Windows Server 2022
ver = '10.0.22';
} else if (ver === '10.0' && build.startsWith('2')) {
// Windows 11
ver = '10.0.2';
}
return {
name: "Windows",
versionName: winNames.get(ver),
version: build,
release
};
}
function osName(platform, release) {
if (platform === 'darwin') {
return release? macosRelease(release) : {name: "macOS"};
}
if (platform === 'linux') {
id = release ? release.replace(/^(\d+\.\d+).*/, '$1') : '';
return {name:'Linux', version: id || release, release};
}
if (platform === 'win32') {
return release ? windowsRelease(release) : {name: "Windows"};
}
return {name:platform, version:release};
}
module.exports.version = function () {
return require('../../../package.json').version;
}
module.exports.client_details = function () {
const process = require('process');
const osnode = require('os');
let os = osName(osnode.platform(),osnode.release());
if (osnode.version) os.uname = osnode.version();
os.type = osnode.type();
return JSON.stringify({
platform: { type: "server", arch: osnode.machine? osnode.machine() : process.arch },
os,
engine: {
name: "nodejs",
version: process.version,
arch : process.arch,
versions: process.versions
}
});
};

@ -21,12 +21,13 @@ use ng_wallet::*;
use p2p_client_ws::remote_ws_wasm::ConnectionWebSocket;
use p2p_net::broker::*;
use p2p_net::connection::{ClientConfig, StartConfig};
use p2p_net::types::{DirectPeerId, IP};
use p2p_net::utils::{spawn_and_log_error, Receiver, ResultSend, Sender};
use p2p_net::types::{BootstrapContentV0, ClientInfoV0, ClientType, DirectPeerId, IP};
use p2p_net::utils::{retrieve_local_bootstrap, spawn_and_log_error, Receiver, ResultSend, Sender};
use p2p_net::WS_PORT;
use p2p_repo::log::*;
use p2p_repo::types::*;
use p2p_repo::utils::generate_keypair;
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::net::IpAddr;
use std::str::FromStr;
@ -35,6 +36,17 @@ use wasm_bindgen::prelude::*;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_futures::{future_to_promise, JsFuture};
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
pub async fn get_local_bootstrap(location: String, invite: JsValue) -> JsValue {
let res = retrieve_local_bootstrap(location, invite.as_string()).await;
if res.is_some() {
serde_wasm_bindgen::to_value(&res.unwrap()).unwrap()
} else {
JsValue::FALSE
}
}
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
pub fn wallet_gen_shuffle_for_pazzle_opening(pazzle_length: u8) -> JsValue {
@ -88,14 +100,8 @@ pub fn test_create_wallet() -> JsValue {
" know yourself ".to_string(),
pin,
9,
None,
false,
PubKey::Ed25519PubKey([
119, 251, 253, 29, 135, 199, 254, 50, 134, 67, 1, 208, 117, 196, 167, 107, 2, 113, 98,
243, 49, 90, 7, 0, 157, 58, 14, 187, 14, 3, 116, 86,
]),
0,
ClientV0::dummy(),
false,
);
serde_wasm_bindgen::to_value(&r).unwrap()
}
@ -103,19 +109,77 @@ pub fn test_create_wallet() -> JsValue {
#[cfg(wasmpack_target = "nodejs")]
#[wasm_bindgen(module = "/js/node.js")]
extern "C" {
fn random(max: usize) -> usize;
fn client_details() -> String;
}
#[cfg(wasmpack_target = "nodejs")]
#[wasm_bindgen(module = "/js/node.js")]
extern "C" {
fn version() -> String;
}
#[cfg(wasmpack_target = "nodejs")]
#[wasm_bindgen]
pub fn client_info() -> JsValue {
let res = ClientInfoV0 {
client_type: ClientType::NodeService,
details: client_details(),
version: version(),
timestamp_install: 0,
timestamp_updated: 0,
};
serde_wasm_bindgen::to_value(&res).unwrap()
}
#[cfg(not(wasmpack_target = "nodejs"))]
#[wasm_bindgen(module = "/js/browser.js")]
extern "C" {
fn random(max: usize) -> usize;
fn client_details() -> String;
}
#[cfg(not(wasmpack_target = "nodejs"))]
#[wasm_bindgen(module = "/js/bowser.js")]
extern "C" {
type Bowser;
#[wasm_bindgen(static_method_of = Bowser)]
fn parse(UA: String) -> JsValue;
}
#[cfg(not(wasmpack_target = "nodejs"))]
#[wasm_bindgen(module = "/js/browser.js")]
extern "C" {
fn client_details2(val: JsValue) -> String;
}
#[cfg(all(not(wasmpack_target = "nodejs"), target_arch = "wasm32"))]
#[wasm_bindgen]
pub fn client_info() -> JsValue {
let ua = client_details();
let bowser = Bowser::parse(ua);
//log_info!("{:?}", bowser);
let details_string = client_details2(bowser);
let res = ClientInfoV0 {
client_type: ClientType::Web,
details: details_string,
version: "".to_string(),
timestamp_install: 0,
timestamp_updated: 0,
};
serde_wasm_bindgen::to_value(&res).unwrap()
}
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
pub async fn test() {
log_info!("test is {}", BROKER.read().await.test());
//let client_info = client_info();
//log_info!("{:?}", client_info);
//let b = Bowser::parse(ua);
//log_info!("{:?}", b);
}
#[cfg(target_arch = "wasm32")]
@ -220,11 +284,6 @@ pub async fn probe() {
#[cfg(target_arch = "wasm32")]
#[wasm_bindgen]
pub async fn start() {
log_info!("random {}", random(10));
// let mut random_buf = [0u8; 32];
// getrandom::getrandom(&mut random_buf).unwrap();
async fn inner_task() -> ResultSend<()> {
let server_key: PubKey = "X0nh-gOTGKSx0yL0LYJviOWRNacyqIzjQW_LKdK6opU".try_into()?;
log_debug!("server_key:{}", server_key);

@ -356,11 +356,6 @@ pub async fn create_wallet_v0(
return Err(NgWalletError::InvalidPazzleLength);
}
// cannot submit wallet if we don't submit also the bootstrap
if params.send_bootstrap.is_none() && params.send_wallet {
return Err(NgWalletError::SubmissionError);
}
// check validity of PIN
// shouldn't start with 0
@ -462,16 +457,30 @@ pub async fn create_wallet_v0(
//.ok_or(NgWalletError::InternalError)?
//.clone(),
let user = site.site_key.to_pub();
// Creating a new client
let client = ClientV0::new(user);
let create_op = WalletOpCreateV0 {
wallet_privkey: wallet_privkey.clone(