Coder Social home page Coder Social logo

duncanmak / dwn-sdk-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tbd54566975/dwn-sdk-js

0.0 1.0 0.0 2.11 MB

Decentralized Web Node (DWN) Reference implementation

Home Page: https://identity.foundation/decentralized-web-node/spec/

License: Apache License 2.0

Shell 0.15% JavaScript 3.05% TypeScript 96.80%

dwn-sdk-js's Introduction

Decentralized Web Node (DWN) SDK

Code Coverage Statements Branches Functions Lines

Introduction

This repository contains a reference implementation of Decentralized Web Node (DWN) as per the specification. This specification is in a draft state and very much so a WIP. For the foreseeable future, a lot of the work on DWN will be split across this repo and the repo that houses the specification, which you can find here. The current goal is to produce a beta implementation by March 2023. This won't include all interfaces described in the DWN spec, but will be enough to begin building applications.

This project is used as a dependency by several other projects.

Proposals and issues for the specification itself should be submitted as pull requests to the spec repo.

Installation

npm install @tbd54566975/dwn-sdk-js

Usage

API docs

import { Dwn, DataStream, DidKeyResolver, Jws, RecordsWrite, RecordsQuery } from '@tbd54566975/dwn-sdk-js';

export const dwn = await Dwn.create();

...
const didKey = await DidKeyResolver.generate(); // generate a did:key DID
const signatureMaterial = Jws.createSignatureInput(didKey);
const data = randomBytes(32); // in node.js
// or in web
// const data = new Uint8Array(32);
// window.crypto.getRandomValues(data);

const recordsWrite = await RecordsWrite.create({
  data,
  dataFormat                  : 'application/json',
  published                   : true,
  protocol                    : 'yeeter',
  schema                      : 'yeeter/post',
  authorizationSignatureInput : signatureMaterial
});

const dataStream = DataStream.fromBytes(data);
const result = await dwn.processMessage(didKey.did, recordsWrite.message, dataStream);

With a web wallet installed:

  const result = await window.web5.dwn.processMessage({
    method  : 'RecordsQuery',
    message : {
      filter: {
        schema: 'http://some-schema-registry.org/todo'
      },
      dateSort: 'createdAscending'
    }
  });

Release/Build Process

The DWN JS SDK releases builds to npmjs.com. There are two build types: stable build and unstable build.

Stable Build

This is triggered manually by:

  1. Increment version in package.json in Semantic Versioning (semver) format.
  2. Merge the change into main branch
  3. Create a release from GitHub.

An official build with version matching the package.json will be published to npmjs.com.

Unstable Build

Every push to the main branch will automatically trigger an unstable build to npmjs.com for developers to experiment and test.

The version string contains the date as well as the commit hash of the last change.

An example version string:

0.0.26-unstable-2023-03-16-36ec2ce

  • 0.0.26 came from version in package.json
  • 2023-03-16 indicates the date of March 16th 2023
  • 36ec2ce is the commit hash of the last change

Some projects that use this library:

Architecture

Architecture of DWN SDN

NOTE: The diagram is a conceptual view of the architecture, the actual component abstraction and names in source file may differ.

Project Resources

Resource Description
CODEOWNERS Outlines the project lead(s)
CODE_OF_CONDUCT.md Expected behavior for project contributors, promoting a welcoming environment
CONTRIBUTING.md Developer guide to build, test, run, access CI, chat, discuss, file issues
GOVERNANCE.md Project governance
LICENSE Apache License, Version 2.0

dwn-sdk-js's People

Contributors

alexlemons avatar alrubinger avatar angiejones avatar annmalavet avatar bnonni avatar csuwildcat avatar cxxshyy avatar dcrousso avatar flothjl avatar grahnj avatar gtaylor5 avatar horusgoul avatar joegesualdo avatar michaelneale avatar mistermoe avatar nearlyjuly avatar nwylynko avatar pdxjohnny avatar rajakash-dev avatar thehenrytsai avatar virajjiwane avatar wavesrcool avatar

Watchers

 avatar

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.