0.4.1 • Published 4 years ago

@stringon/tsubasa v0.4.1

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

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

0.4.1

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago