{"id":15789915,"url":"https://github.com/gettocat/bitowl","last_synced_at":"2025-03-31T18:27:27.404Z","repository":{"id":94927150,"uuid":"207898225","full_name":"gettocat/bitowl","owner":"gettocat","description":"Compact communication protocol with version control and data verify","archived":false,"fork":false,"pushed_at":"2019-09-12T20:46:50.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-19T21:42:36.805Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gettocat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-11T20:12:24.000Z","updated_at":"2019-09-12T20:46:52.000Z","dependencies_parsed_at":"2023-04-12T08:16:02.087Z","dependency_job_id":null,"html_url":"https://github.com/gettocat/bitowl","commit_stats":{"total_commits":4,"total_committers":2,"mean_commits":2.0,"dds":0.5,"last_synced_commit":"15779016057169e2d5ceef5d86f93df3a86554e8"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettocat%2Fbitowl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettocat%2Fbitowl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettocat%2Fbitowl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettocat%2Fbitowl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gettocat","download_url":"https://codeload.github.com/gettocat/bitowl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246338980,"owners_count":20761469,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T22:04:11.090Z","updated_at":"2025-03-31T18:27:27.381Z","avatar_url":"https://github.com/gettocat.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bitowl\nYou can send any message with owl, bitowl!\nCompact communication protocol with version control and data verify.\n\n# Methods\n\n```js\nlet bitowl = require('bitowl');\n\n```\n\nThere is a three sub modules:\n- `bitowl.string`\n- `bitowl.data`\n- `bitowl.diff`\n\n## Data\n\n### pack\n\n```js\nlet buffer = bitowl.data.pack(object);\n```\n\n### unpack\n\n```js\nlet json = bitowl.data.unpack(bufferOrHex);\n```\n\n## String\n\n### pack\n\n```js\nlet buffer = bitowl.string.pack(object);\n```\n\n### unpack\n\n```js\nlet json = bitowl.string.unpack(bufferOrHex);\n```\n\n### create diff\n\nCreate stringdiff object difference between string and sourcestring, output can be buffer or empty, by default return json \n \n```js\nlet json = bitowl.string.create(string, sourcestring, output);\n```\n\n### apply diff\n\nApply diff to string and return new string. Diff can be hex, buffer or json\n\n```js\nlet str = bitowl.string.apply(diff, string);\n```\n\n## Diff\n\n### pack\n\n```js\nlet buffer = bitowl.diff.pack(object);\n```\n\n### unpack\n\nOffset define where in buffer starts diff. By default offset is 0. \n\n```js\nlet json = bitowl.diff.unpack(bufferOrHex, offset);\n```\n\n### create Diff\n\nCreate diff object difference between object and sourceobject, output can be buffer or empty, by default return json \n \n```js\nlet json = bitowl.diff.create(object, sourceobject, output);\n```\n\n### apply Diff\n\nApply diff to sourceobject and return new object. Diff can be hex, buffer or json\n\n```js\nlet obj = bitowl.diff.apply(diff, sourceobject);\n```\n\n### toData\n\nThis method apply diff to a empty object. It create object from diff. Warning! Can not convert diffstring to a string, so string fields is not apply to object.\n\nDiff can be hex, buffer or json. Return json by default, if output == 'buffer' - return buffer.\n\n```js\nlet obj = bitowl.diff.toData(diff, output);\n```\n\n## BitOwl\n\n### get Type\n\nReturn byte of version from buffer, hex string or json object of diff. From buffer and hex string read first byte,\nfrom json object read field __source_sign (if exist - is diff, else - data). Can return 0x7f and bigger if diff, and smaller when - data.\n\n```js\nlet versionByte = bitowl.getType(bufferOrJson); \n```\n\n### pack\n\nPack object into buffer. Type can be `\u003e= 0x7f` for diff and smaller for data. If type is not defined, use auto define.\n\n```js\nlet buffer = bitowl.pack(object, type); \n```\n\n### unpack\n\nUnpack buffer to object. Returned object: \n\n```js\n{\n    version: 0x1,//version of message, 0x7f and bigger for diff, and smaller for data.\n    type: 'data', //can be data of diff, based on version byte\n    value: unpacked_json_object\n}\n```\n\n```js\nlet d = bitowl.unpack(buffer); \n```\n\n### create Diff\n\nCreate diff object difference between object and sourceobject.  If version of sourceobject \u003e= 0x7f (diff object), create object from diff (toData method) and makes diff between diffs. Object and sourceobject can be buffer, string, object\n \n```js\nlet json = bitowl.createDiff(object, sourceobject); \n```\n\n### apply Diff\n\nApply diff to sourceobject and return new object. If diff object have wrong version, throw Error exception. Diff and sourceobject can be buffer, string, object\n\n```js\nlet obj = bitowl.applyDiff(diff, sourceobject);\n```\n\n# Hex Formats\n\nAll types based on bit sequences, var_str, var_int and other is used from library [bitPony](https://github.com/gettocat/bitPony/wiki) \n\n## Data\n\nData format is different for each version. Now exist 2 versions: `0x1` - data object and `0x7f` - diff object\n\nfor version `\u003c 0x7f`:\n```\nversion(2 bytes, uint16) | payloadsign (4 bytes, uint32) | payload\n```\n\nfor version `\u003e= 0x7f`\n```\nversion(2 bytes, uint16) | payloadsign (4 bytes, uint32) | sourcedatasign (4 bytes, uint32) | payload\n```\n\n- version can be 0x1 for data, and 0x7f for diff. Version can be upgraded in future, so check version must be not with equal operation:  `ver \u003e= 0x7f` and `ver \u003c 0x7f`. \n- Sign its first 4 bytes from double sha256 bytes of payload\n- sourcedatasign is sign of original source data for diff\n- payload is primitive, `byte-object` \n\n### Primitive\n\nAll primitive have this structure:\n\nfor `version \u003c 0x7f` (data):\nitem:\n```\ntype (uint8) | key (var_str) | value\n```\n\nvector:\n```\ntype (uint8) | key(var_str) | value count(var_int) | value1, value2, ... valueN\n```\n\nFor `version \u003e= 0x7f` (diff):\nitem:\n```\ntype (uint8) | version control flag (uint8) | key (var_str) | value\n```\n\nvector:\n```\ntype (uint8) | version control flag (uint8) | key(var_str) | value count(var_int) | value1, value2, ... valueN\n```\n\n### Primitive byte-object\n\nType: `0x5`\n```\ndata type(1 byte, uint8) | key (var_str) | primitive count(var_int) |  primitive1, primitive2,....primitiveN\n```\n\n### Primitive byte-array\n\nType: `0x6`\nFor array key everytime is empty.\n\n```\ndata type(1 byte, uint8) | key (var_str) | primitive count(var_int) |  primitive1, primitive2,....primitiveN\n```\n\n### NULL-type\n\nType: `0x0`\n```\ndata type(1 byte, uint8) | key (var_str) | 0(uint8)\n```\n\n### Boolean\n\nType: `0x1`\n```\ndata type(1 byte, uint8) | key (var_str) | value(uint8)\n```\n\n### Integer\n\nType: `0x2`\n```\ndata type(1 byte, uint8) | key (var_str) | value(var_int)\n```\n\n### Float\n\nType: `0x3`\n```\ndata type(1 byte, uint8) | key (var_str) | value(var_str)\n```\n\n### String\n\nType: `0x4` \n```\ndata type(1 byte, uint8) | key (var_str) | value(var_str)\n```\n\n### Function\n\nType: `0x7` \n```\ndata type(1 byte, uint8) | key (var_str) | value(var_str)\n```\n\n## Types\n\n### Stringdiff\n\nStringdiff data is contain information about difference between str1 and str2, for example:\nstr1: test12345\nstr2: tost54312\ndiff in json format:\n\nDiff string is hex format for json array like this:\n```js\n[ \n    { flag: 'A', sequence: 'a', start: 0, length: 1 },\n    { flag: 'U', sequence: 'o', start: 2, length: 1 },\n    { flag: 'U', sequence: '54', start: 5, length: 2 },\n    { flag: 'U', sequence: '12', start: 8, length: 2 },\n    { flag: 'D', sequence: '44', start: 10, length: 3 } \n]\n```\n\nconverted to:\n```\n050000010161010201016f010502023534010802023132ff0a03023434\n```\n\nFormat is:\n\n```\ncount of items (var_int) | strdiff items\n```\n\nformat strdiff of hex is:\n\n```\nflag(uint8) | start (var_int) | length (var_int) | sequence (var_str)\n```\n\n- flag is modifier of change, can be `0x0` (A, APPEND), `0x1` (U, UPDATE), `0xff` (D, DELETE)\n- start - start of change in string\n- length - length of sequence\n- sequence - change string\n\nString diff hex is vector of strdiff\n\n### Diff\n\n```\nversion(2 bytes, uint16) | payloadsign (4 bytes, uint32) | sourcedatasign (4 bytes, uint32) | payload\n```\n\n- version can be 0x1 for data, and 0x7f for diff. Version can be upgraded in future, so check version must be not with equal operation:  `ver \u003e= 0x7f` and `ver \u003c 0x7f`. \n- Sign its first 4 bytes from double sha256 bytes of payload\n- sourcedatasign is sign of original source data for diff\n- payload is primitive, `byte-object` \n\nprimitive:\n```\ntype (uint8) | version control flag (uint8) | key (var_str) | value\n```\n\nvector:\n```\ntype (uint8) | version control flag (uint8) | key(var_str) | primitive count(var_int) | primitive1, primitive2, ... primitiveN\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgettocat%2Fbitowl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgettocat%2Fbitowl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgettocat%2Fbitowl/lists"}