Giter VIP home page Giter VIP logo

zoo-adventures's Introduction

p2panda

All the things a panda needs


This library provides all tools required to write a client, node or even your own protocol implementation for the p2panda network. It is shipped both as a Rust crate p2panda-rs with WebAssembly bindings and a NPM package p2panda-js with TypeScript definitions running in NodeJS or any modern web browser.

The core p2panda specification is fully functional but still under review so please be prepared for breaking API changes until we reach v1.0. Currently no p2panda implementation has recieved a security audit.

Features

  • Generate Ed25519 key pairs.
  • Create and encode Bamboo entries.
  • Publish schemas and validate data.
  • Create, update and delete data collaboratively.
  • Encrypt data with OpenMLS.
  • Materialise documents from data changes.
  • Prepare data for node servers.

Usage

import { KeyPair } from "p2panda-js";
const keyPair = new KeyPair();
console.log(keyPair.publicKey());
use p2panda_rs::identity::KeyPair;
let key_pair = KeyPair::new();
println!("{}", key_pair.public_key());

See the demo application and its source code. More examples can be found in the p2panda-rs and p2panda-js directories.

Installation

If you are using p2panda in web browsers or NodeJS applications run:

$ npm i p2panda-js

For Rust environments run:

$ cargo add p2panda-rs

Documentation

Visit the corresponding folders for development instructions and documentation:

Benchmarks

Performance benchmarks can be found in benches. You can run them using cargo-criterion:

$ cargo install cargo-criterion
$ cargo criterion
# An HTML report with plots is generated automatically
$ open target/criterion/reports/index.html

These benchmarks can be used to compare the performance across branches by running them first in a base branch and then in the comparison branch. The HTML-reports will include a comparison of the two results.

License

GNU Affero General Public License v3.0 AGPL-3.0-or-later

Supported by



This project has received funding from the European Unionโ€™s Horizon 2020 research and innovation programme within the framework of the NGI-POINTER Project funded under grant agreement No 871528 and NGI-ASSURE No 957073

zoo-adventures's People

Contributors

adzialocha avatar cafca avatar sandreae avatar sophiiistika avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

Forkers

doehae

zoo-adventures's Issues

Persist key in Tauri

The local storage is not persisted in this setting, a new key pair is being generated on every app start cry maybe we need a different approach here (like storing the key in the user folder and sending it to the frontend via Tauris RPC interface)

Error running Tauri dev build

Running npm run tauri:start I get a window with a white screen. Opening the developer tools causes the app to terminate.

I get the following output in the terminal:

Running `target/debug/beep-boop`
2021-12-06 14:30:32.930 beep-boop[9429:5364634] NSWindow warning: adding an unknown subview: <WKInspectorWKWebView: 0x7fbdb6a345a0>. Break on NSLog to debug.
2021-12-06 14:30:32.975 beep-boop[9429:5364634] Call stack:
(
        0   AppKit                              0x00007ff81459ea26 -[NSThemeFrame addSubview:] + 112
        1   AppKit                              0x00007ff81459e766 -[NSView addSubview:positioned:relativeTo:] + 203
        2   AppKit                              0x00007ff81459e61e -[NSThemeFrame addSubview:positioned:relativeTo:] + 46
        3   WebKit                              0x00007ff9160ab079 _ZN6WebKit19WebInspectorUIProxy14platformAttachEv + 391
        4   WebKit                              0x00007ff9161a5136 _ZN6WebKit19WebInspectorUIProxy4openEv + 84
        5   WebKit                              0x00007ff9163c3836 _ZN6WebKit19WebInspectorUIProxy17didReceiveMessageERN3IPC10ConnectionERNS1_7DecoderE + 242
        6   WebKit                              0x00007ff915d50bd9 _ZN3IPC18MessageReceiverMap15dispatchMessageERNS_10ConnectionERNS_7DecoderE + 199
        7   WebKit                              0x00007ff9161367d7 _ZN6WebKit15WebProcessProxy17didReceiveMessageERN3IPC10ConnectionERNS1_7DecoderE + 31
        8   WebKit                              0x00007ff915d2e5a4 _ZN3IPC10Connection15dispatchMessageENSt3__110unique_ptrINS_7DecoderENS1_14default_deleteIS3_EEEE + 634
        9   WebKit                              0x00007ff915d2dd76 _ZN3IPC10Connection24dispatchIncomingMessagesEv + 408
        10  JavaScriptCore                      0x00007ff82b6b114f _ZN3WTF7RunLoop11performWorkEv + 287
        11  JavaScriptCore                      0x00007ff82b6b20aa _ZN3WTF7RunLoop11performWorkEPv + 26
        12  CoreFoundation                      0x00007ff811c27b68 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
        13  CoreFoundation                      0x00007ff811c27ad0 __CFRunLoopDoSource0 + 180
        14  CoreFoundation                      0x00007ff811c27843 __CFRunLoopDoSources0 + 242
        15  CoreFoundation                      0x00007ff811c2625f __CFRunLoopRun + 897
        16  CoreFoundation                      0x00007ff811c25809 CFRunLoopRunSpecific + 567
        17  HIToolbox                           0x00007ff81ac923e1 RunCurrentEventLoopInMode + 292
        18  HIToolbox                           0x00007ff81ac92137 ReceiveNextEventCommon + 587
        19  HIToolbox                           0x00007ff81ac91ed5 _BlockUntilNextEventMatchingListInModeWithFilter + 70
        20  AppKit                              0x00007ff8145778f0 _DPSNextEvent + 886
        21  AppKit                              0x00007ff814575f5c -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1411
        22  AppKit                              0x00007ff814568359 -[NSApplication run] + 586
        23  beep-boop                           0x0000000102e3d4c6 _ZN60_$LT$$LP$$RP$$u20$as$u20$objc..message..MessageArguments$GT$6invoke17h648872502edf0d09E + 70
        24  beep-boop                           0x0000000102e3fa9c _ZN4objc7message8platform15send_unverified17he4cc68e0b00226b7E + 92
        25  beep-boop                           0x0000000102d2a55e _ZN3tao13platform_impl8platform10event_loop18EventLoop$LT$T$GT$10run_return17h6de6fafb636874cfE + 1326
        26  beep-boop                           0x0000000102d2b869 _ZN3tao13platform_impl8platform10event_loop18EventLoop$LT$T$GT$3run17hf9a1974c4159004cE + 41
        27  beep-boop                           0x0000000102d429af _ZN3tao10event_loop18EventLoop$LT$T$GT$3run17h09f6e5d501956458E + 79
        28  beep-boop                           0x0000000102d4fe90 _ZN65_$LT$tauri_runtime_wry..Wry$u20$as$u20$tauri_runtime..Runtime$GT$3run17h23bd910626bc0255E + 496
        29  beep-boop                           0x00000001029edb45 _ZN5tauri3app40Builder$LT$E$C$L$C$MID$C$TID$C$A$C$R$GT$3run17h2eba4ebb16d511fcE + 4133
        30  beep-boop                           0x000000010299e4f8 _ZN9beep_boop4main4main28_$u7b$$u7b$closure$u7d$$u7d$17h5e044c86a62d1dfdE + 5960
        31  beep-boop                           0x0000000102987ce0 _ZN97_$LT$core..future..from_generator..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$4poll17hfc835aede33f0d33E + 80
        32  beep-boop                           0x000000010299cd18 _ZN9beep_boop4main28_$u7b$$u7b$closure$u7d$$u7d$17h34a7384804856c20E + 328
        33  beep-boop                           0x0000000102983b60 _ZN97_$LT$core..future..from_generator..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$4poll17h24c645d9e219de26E + 80
        34  beep-boop                           0x0000000102b45425 _ZN101_$LT$async_std..task..builder..SupportTaskLocals$LT$F$GT$$u20$as$u20$core..future..future..Future$GT$4poll28_$u7b$$u7b$closure$u7d$$u7d$17h7f83663d4a801389E + 53
        35  beep-boop                           0x0000000102b5d55d _ZN9async_std4task19task_locals_wrapper17TaskLocalsWrapper11set_current28_$u7b$$u7b$closure$u7d$$u7d$17hd4f46cc7b8dcfe29E + 125
        36  beep-boop                           0x0000000102b5a970 _ZN3std6thread5local17LocalKey$LT$T$GT$8try_with17h3fd90a1d70e2421aE + 192
        37  beep-boop                           0x0000000102b59e2c _ZN3std6thread5local17LocalKey$LT$T$GT$4with17h9467662d3f139c26E + 44
        38  beep-boop                           0x0000000102b5cd34 _ZN9async_std4task19task_locals_wrapper17TaskLocalsWrapper11set_current17h78bfa09f9a937e73E + 52
        39  beep-boop                           0x0000000102b4515e _ZN101_$LT$async_std..task..builder..SupportTaskLocals$LT$F$GT$$u20$as$u20$core..future..future..Future$GT$4poll17h1e6312571c90e934E + 62
        40  beep-boop                           0x0000000102adc3c6 _ZN88_$LT$futures_lite..future..Or$LT$F1$C$F2$GT$$u20$as$u20$core..future..future..Future$GT$4poll17h66ca1856d66210b4E + 54
        41  beep-boop                           0x0000000102a73bf1 _ZN14async_executor8Executor3run28_$u7b$$u7b$closure$u7d$$u7d$17h76a39d97ef8e86abE + 689
        42  beep-boop                           0x0000000102983510 _ZN97_$LT$core..future..from_generator..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$4poll17h0b451598d0f4e3eeE + 80
        43  beep-boop                           0x0000000102a73772 _ZN14async_executor13LocalExecutor3run28_$u7b$$u7b$closure$u7d$$u7d$17he91d8ed297d6d1dfE + 498
        44  beep-boop                           0x0000000102985820 _ZN97_$LT$core..future..from_generator..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$4poll17h877dcca39b3774b2E + 80
        45  beep-boop                           0x00000001029f4ff7 _ZN8async_io6driver8block_on17h7864fe4912c2942bE + 1047
        46  beep-boop                           0x0000000102bd4121 _ZN21async_global_executor7reactor8block_on28_$u7b$$u7b$closure$u7d$$u7d$17h1d6daadd93dd5462E + 49
        47  beep-boop                           0x0000000102bd4079 _ZN21async_global_executor7reactor8block_on17h78eef053429110cbE + 73
        48  beep-boop                           0x0000000102aae959 _ZN21async_global_executor8executor8block_on28_$u7b$$u7b$closure$u7d$$u7d$17h8ffa5ba025a13548E + 89
        49  beep-boop                           0x0000000102b5ac7d _ZN3std6thread5local17LocalKey$LT$T$GT$8try_with17h4f793ab1b7c99c58E + 237
        50  beep-boop                           0x0000000102b59bca _ZN3std6thread5local17LocalKey$LT$T$GT$4with17h56787e5d7a92a97dE + 58
        51  beep-boop                           0x0000000102aae842 _ZN21async_global_executor8executor8block_on17hbf36785d05237fafE + 50
        52  beep-boop                           0x0000000102b47d02 _ZN9async_std4task7builder7Builder8blocking28_$u7b$$u7b$closure$u7d$$u7d$28_$u7b$$u7b$closure$u7d$$u7d$17h131f04b3c9254531E + 114
        53  beep-boop                           0x0000000102b5d094 _ZN9async_std4task19task_locals_wrapper17TaskLocalsWrapper11set_current28_$u7b$$u7b$closure$u7d$$u7d$17h05a7240e10d37230E + 212
        54  beep-boop                           0x0000000102b5a42d _ZN3std6thread5local17LocalKey$LT$T$GT$8try_with17h1635c6307e284899E + 237
        55  beep-boop                           0x0000000102b59b1a _ZN3std6thread5local17LocalKey$LT$T$GT$4with17h4589ede964436a6aE + 58
        56  beep-boop                           0x0000000102b5cde8 _ZN9async_std4task19task_locals_wrapper17TaskLocalsWrapper11set_current17hc370df5f4fce9712E + 72
        57  beep-boop                           0x0000000102b47b19 _ZN9async_std4task7builder7Builder8blocking28_$u7b$$u7b$closure$u7d$$u7d$17h98a82db2a35674d8E + 265
        58  beep-boop                           0x0000000102b5bccd _ZN3std6thread5local17LocalKey$LT$T$GT$8try_with17hd70563252102ccc4E + 237
        59  beep-boop                           0x0000000102b59c3a _ZN3std6thread5local17LocalKey$LT$T$GT$4with17h64ead3c25fd394a3E + 58
        60  beep-boop                           0x0000000102b474e1 _ZN9async_std4task7builder7Builder8blocking17h759cd81ad75af026E + 305
        61  beep-boop                           0x00000001029ead3e _ZN9async_std4task8block_on8block_on17hb9aa763cf627808bE + 94
        62  beep-boop                           0x0000000102b005c4 _ZN9beep_boop4main17he9278523fbd9327fE + 52
        63  beep-boop                           0x0000000102bb698e _ZN4core3ops8function6FnOnce9call_once17h6aaa8ef124a75365E + 14
        64  beep-boop                           0x0000000102b000e1 _ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h4c9b4f4ea8b5e7faE + 17
        65  beep-boop                           0x0000000102b11824 _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h566ed1e29e64f9bfE + 20
        66  beep-boop                           0x000000010451c27a _ZN3std2rt19lang_start_internal17hf65df31c3ffe3b9aE + 650
        67  beep-boop                           0x0000000102b117ee _ZN3std2rt10lang_start17ha6105d1a856f0e47E + 46
        68  beep-boop                           0x0000000102b00626 main + 22
        69  dyld                                0x00000002079294fe start + 462
        70  ???                                 0x0000000000000003 0x0 + 3
)
2021-12-06 14:30:35.792 beep-boop[9429:5366834] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[15]'
*** First throw call stack:
(
        0   CoreFoundation                      0x00007ff811ca262b __exceptionPreprocess + 242
        1   libobjc.A.dylib                     0x00007ff811a04dce objc_exception_throw + 48
        2   CoreFoundation                      0x00007ff811d5da47 _CFThrowFormattedException + 194
        3   CoreFoundation                      0x00007ff811d682b1 -[__NSPlaceholderDictionary initWithCapacity:].cold.1 + 0
        4   CoreFoundation                      0x00007ff811bb2683 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 251
        5   CoreFoundation                      0x00007ff811bb256e +[NSDictionary dictionaryWithObjects:forKeys:count:] + 49
        6   VisionKitCore                       0x00007ffb215f09d1 -[VKAnalyticsAnalyzerEvent coreAnalyticsDictionary] + 1292
        7   VisionKitCore                       0x00007ffb215b407c -[VKAnalyticsProcessor processAndSendEvent:] + 96
        8   VisionKitCore                       0x00007ffb215aa4b6 __69-[VKImageAnalyzer _processRequest:progressHandler:completionHandler:]_block_invoke_2 + 1254
        9   libdispatch.dylib                   0x00007ff8119a6ad8 _dispatch_call_block_and_release + 12
        10  libdispatch.dylib                   0x00007ff8119a7cc9 _dispatch_client_callout + 8
        11  libdispatch.dylib                   0x00007ff8119adcee _dispatch_lane_serial_drain + 696
        12  libdispatch.dylib                   0x00007ff8119ae7c8 _dispatch_lane_invoke + 366
        13  libdispatch.dylib                   0x00007ff8119b87e1 _dispatch_workloop_worker_thread + 758
        14  libsystem_pthread.dylib             0x00007ff811b5e08f _pthread_wqthread + 326
        15  libsystem_pthread.dylib             0x00007ff811b5d01b start_wqthread + 15
)
libc++abi: terminating with uncaught exception of type NSException

Higher-order component for p2panda state

Ideas

  • p2panda-js should have a utility method like getLibraryAsync to load the library as a singleton because of its special dynamic import behaviour
  • PandaProvider is a higher-order component (reference ThemeProvider) accepting user configuration as a prop. It loads the library via getLibraryAsync, generates the key pair when not given, creates a Session instance with the users configuration and exposes the library contents and session instance in PandaContext
  • PandaContext is a react context initialized by PandaProvider and exposed to all of its child components (reference ThemeContext)
  • useSession is a hook (reference useTheme) taking the session instance out of the PandaContext and returning it
  • usePanda is a hook similar to useSession returning the classes and methods of the p2panda-js library (sync)

Draft examples

<PandaProvider configuration={{ endpoint: 'wss://localhost:2022' }}>
  <App />
</PandaProvider>
export default const App = () => {
  const session = useSession();
  const { Instance } = usePanda();
  
  const sendMessage = async (message) => {
    await Instance.create({ message }, { schema: CHAT_MESSAGE_SCHEMA, session });
  };

  // ...
};

Open questions

  • Is PandaProvider, PandaContext, useSession and usePanda part of p2panda-js or not?

@sophiiistika @cafca

Feature: Edit messages afterwards

Making use of our cool UPDATE operations, otherwise we will never show any skiplinks in this demo with our new log organization per document ๐Ÿ˜„

Tasks for demo-app

๐Ÿผ beep-boop (most of this happening here #17)

  • refactor react components
  • use new p2panda-js API (@cafca is working on this)
  • update code examples (to match any changes made when connecting to our real services)
  • Integrate new p2panda-js wasm methods
  • Use to-be-published 0.2.0 release of p2panda-js

๐Ÿผ aquadoggo

๐Ÿผ p2panda-js

  • build API for use in beep-boop (draft here)
  • Merge wasm branch into main and make a 0.2.0 release on npm

๐Ÿผ p2panda-rs (make experimental branch not experimental)

๐Ÿผ p2panda.github.io

  • Add beep boop build to demo subfolder
  • Update website with links to the demo app when it's ready

๐Ÿผ design-document

  • Update docs if anything has changed

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.