# @stringon/tsubasa

> tsubasa module for stringon

Latest version **0.4.1** (published 2020-11-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install @stringon/tsubasa
pnpm add @stringon/tsubasa
yarn add @stringon/tsubasa
bun add @stringon/tsubasa
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.1 |
| Published | 2020-11-06 |
| First published | 2020-09-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 85.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | noel2004, okdoso |

## Links

- npm: https://www.npmjs.com/package/@stringon/tsubasa
- npm.io page: https://npm.io/package/@stringon/tsubasa

## Dependencies (6)

- [rlp](https://npm.io/package/rlp.md) ^2.2.4
- [bs58](https://npm.io/package/bs58.md) ^4.0.1
- [aes-js](https://npm.io/package/aes-js.md) ^3.1.2
- [keccak](https://npm.io/package/keccak.md) ^3.0.0
- [js-sha256](https://npm.io/package/js-sha256.md) ^0.9.0
- [secp256k1](https://npm.io/package/secp256k1.md) ^4.0.0

## Recent versions

- 0.4.1 (latest) — 2020-11-06
- 0.3.7 — 2020-11-05
- 0.3.6 — 2020-11-02
- 0.3.5 — 2020-10-27
- 0.3.0 — 2020-10-26
- 0.2.0 — 2020-10-19
- 0.1.0 — 2020-09-19

## README

# tsubasa

“翼（つばさ）”是wing用于在云端存储和同步用户敏感数据的模块，采用客户端加密实现，
所有数据内容对服务端完全透明，调用者指定用户数据结构及其初始状态作为全局状态树，并
指定云端的同步API以便从云端同步当前状态。

## Build and Demo

Tsubasa is module installed by `npm i @stringon/tsubasa`

For development, just run `npm run build` to packing the lib and demo (you need a debugToken.json
 file in the root directory for the demo)

+ Notice we have skip 'crypto' library in nodeJs for it enlarge the package 
greatly (from ~150KB current to > 590KB)

## Usage

### Create a tsubasa instance with a chaining style:

```

const my_tsubasa_instance = require('@stringon/tsubasa')
    .topic(...)*[ .prune() | .magicheader(...)]
    .http(...)*[.option(...)]
    .key(...)[.schema(...)]
    1#[.instance | duplicate()]

```

* topic: select a data topic, tsubasa object corresponding different topic will be isolated.

    + You can adopt the result with prune(), which will clean any history you have 
    make, **CAUTION WITH THIS DANGEROUS FLAG**

    + You can specify a series of "magicheader" handler function, which has a getter/
    verfier form, i.e:

```
    magicheader := (h:{string | undefined}) => {boolean | string}

    if h is string check if it is expected
    else return the expected string
```

> A URL-safe string as magic code header is prefixed to the root key. On init, 
> current magic code will be passed to all functions specified in magicheader
> to check if it match to one of them. And the returned string from first 
> function (called without an argument) will be the magic code in the next
> commit. Pass string `'default'` instead of a function will indicate using
> the default one. i.e. check and return the magic code 'SH'


* http: provide a axios like httplib for communication with cloud storage, tsubasa
itself never purpose it

    + You can adopt the result with one or more option(...), passing option objects
    for the api vendor and more axio configs, mutiple option will be merged and
    for duplicated filed which occur in the last option call will be respected

* key: provide the main encrypt/decrypt key

    + You can adopt the result with one or more schema(...), passing schema settings
    and mutiple schema will be merged

Finally you obtain the **Promise** object of tsubasa from the instance field, or
you can create another duplicated object by calling duplicate() method

---
_Source: https://npm.io/package/@stringon/tsubasa · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
