corestore 6.0.1-alpha.9 → 6.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/test-node.yml +5 -6
- package/.nyc_output/54ec436a-390d-4669-925d-0377ac7ed81b.json +1 -0
- package/.nyc_output/processinfo/54ec436a-390d-4669-925d-0377ac7ed81b.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/README.md +16 -4
- package/index.js +182 -51
- package/package.json +9 -11
- package/test/all.js +181 -14
- package/test/cache.js +46 -0
- package/lib/keys.js +0 -104
- package/test/keys.js +0 -65
|
@@ -1,23 +1,22 @@
|
|
|
1
|
-
name:
|
|
2
|
-
|
|
1
|
+
name: Build Status
|
|
3
2
|
on:
|
|
4
3
|
push:
|
|
5
4
|
branches:
|
|
6
|
-
-
|
|
5
|
+
- master
|
|
7
6
|
pull_request:
|
|
8
7
|
branches:
|
|
9
|
-
-
|
|
8
|
+
- master
|
|
10
9
|
jobs:
|
|
11
10
|
build:
|
|
12
11
|
strategy:
|
|
13
12
|
matrix:
|
|
14
|
-
node-version: [
|
|
13
|
+
node-version: [lts/*]
|
|
15
14
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
16
15
|
runs-on: ${{ matrix.os }}
|
|
17
16
|
steps:
|
|
18
17
|
- uses: actions/checkout@v2
|
|
19
18
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
20
|
-
uses: actions/setup-node@
|
|
19
|
+
uses: actions/setup-node@v2
|
|
21
20
|
with:
|
|
22
21
|
node-version: ${{ matrix.node-version }}
|
|
23
22
|
- run: npm install
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"/home/andrewosh/Development/corestore/index.js":{"path":"/home/andrewosh/Development/corestore/index.js","statementMap":{"0":{"start":{"line":1,"column":25},"end":{"line":1,"column":42}},"1":{"start":{"line":3,"column":18},"end":{"line":3,"column":38}},"2":{"start":{"line":4,"column":15},"end":{"line":4,"column":42}},"3":{"start":{"line":5,"column":17},"end":{"line":5,"column":46}},"4":{"start":{"line":6,"column":20},"end":{"line":6,"column":43}},"5":{"start":{"line":7,"column":18},"end":{"line":7,"column":38}},"6":{"start":{"line":8,"column":15},"end":{"line":8,"column":32}},"7":{"start":{"line":9,"column":12},"end":{"line":9,"column":26}},"8":{"start":{"line":10,"column":19},"end":{"line":10,"column":50}},"9":{"start":{"line":11,"column":19},"end":{"line":11,"column":40}},"10":{"start":{"line":12,"column":23},"end":{"line":12,"column":53}},"11":{"start":{"line":13,"column":14},"end":{"line":13,"column":38}},"12":{"start":{"line":14,"column":12},"end":{"line":14,"column":41}},"13":{"start":{"line":16,"column":21},"end":{"line":16,"column":29}},"14":{"start":{"line":17,"column":20},"end":{"line":17,"column":27}},"15":{"start":{"line":18,"column":28},"end":{"line":18,"column":40}},"16":{"start":{"line":19,"column":18},"end":{"line":19,"column":29}},"17":{"start":{"line":23,"column":4},"end":{"line":23,"column":20}},"18":{"start":{"line":24,"column":4},"end":{"line":24,"column":26}},"19":{"start":{"line":25,"column":4},"end":{"line":25,"column":28}},"20":{"start":{"line":26,"column":4},"end":{"line":26,"column":50}},"21":{"start":{"line":30,"column":4},"end":{"line":30,"column":69}},"22":{"start":{"line":30,"column":33},"end":{"line":30,"column":69}},"23":{"start":{"line":31,"column":4},"end":{"line":31,"column":26}},"24":{"start":{"line":32,"column":4},"end":{"line":34,"column":6}},"25":{"start":{"line":33,"column":6},"end":{"line":33,"column":31}},"26":{"start":{"line":35,"column":4},"end":{"line":35,"column":15}},"27":{"start":{"line":39,"column":4},"end":{"line":39,"column":63}},"28":{"start":{"line":39,"column":35},"end":{"line":39,"column":63}},"29":{"start":{"line":40,"column":17},"end":{"line":40,"column":87}},"30":{"start":{"line":41,"column":4},"end":{"line":41,"column":34}},"31":{"start":{"line":45,"column":4},"end":{"line":45,"column":63}},"32":{"start":{"line":45,"column":35},"end":{"line":45,"column":63}},"33":{"start":{"line":46,"column":17},"end":{"line":46,"column":66}},"34":{"start":{"line":47,"column":4},"end":{"line":47,"column":34}},"35":{"start":{"line":52,"column":4},"end":{"line":52,"column":79}},"36":{"start":{"line":56,"column":17},"end":{"line":56,"column":21}},"37":{"start":{"line":57,"column":18},"end":{"line":57,"column":39}},"38":{"start":{"line":58,"column":16},"end":{"line":58,"column":20}},"39":{"start":{"line":60,"column":4},"end":{"line":67,"column":5}},"40":{"start":{"line":61,"column":18},"end":{"line":61,"column":54}},"41":{"start":{"line":62,"column":6},"end":{"line":65,"column":7}},"42":{"start":{"line":63,"column":8},"end":{"line":63,"column":21}},"43":{"start":{"line":64,"column":8},"end":{"line":64,"column":16}},"44":{"start":{"line":66,"column":6},"end":{"line":66,"column":25}},"45":{"start":{"line":68,"column":4},"end":{"line":68,"column":17}},"46":{"start":{"line":71,"column":6},"end":{"line":71,"column":26}},"47":{"start":{"line":71,"column":15},"end":{"line":71,"column":26}},"48":{"start":{"line":72,"column":6},"end":{"line":75,"column":7}},"49":{"start":{"line":73,"column":8},"end":{"line":73,"column":28}},"50":{"start":{"line":74,"column":8},"end":{"line":74,"column":24}},"51":{"start":{"line":82,"column":4},"end":{"line":82,"column":11}},"52":{"start":{"line":84,"column":4},"end":{"line":84,"column":70}},"53":{"start":{"line":84,"column":37},"end":{"line":84,"column":70}},"54":{"start":{"line":85,"column":4},"end":{"line":85,"column":96}},"55":{"start":{"line":85,"column":39},"end":{"line":85,"column":96}},"56":{"start":{"line":86,"column":4},"end":{"line":86,"column":26}},"57":{"start":{"line":87,"column":4},"end":{"line":87,"column":51}},"58":{"start":{"line":89,"column":4},"end":{"line":89,"column":20}},"59":{"start":{"line":91,"column":4},"end":{"line":91,"column":40}},"60":{"start":{"line":92,"column":4},"end":{"line":92,"column":32}},"61":{"start":{"line":93,"column":4},"end":{"line":93,"column":35}},"62":{"start":{"line":94,"column":4},"end":{"line":94,"column":57}},"63":{"start":{"line":95,"column":4},"end":{"line":100,"column":6}},"64":{"start":{"line":96,"column":6},"end":{"line":96,"column":46}},"65":{"start":{"line":96,"column":40},"end":{"line":96,"column":46}},"66":{"start":{"line":97,"column":6},"end":{"line":99,"column":8}},"67":{"start":{"line":98,"column":8},"end":{"line":98,"column":40}},"68":{"start":{"line":98,"column":17},"end":{"line":98,"column":40}},"69":{"start":{"line":102,"column":4},"end":{"line":102,"column":66}},"70":{"start":{"line":102,"column":38},"end":{"line":102,"column":65}},"71":{"start":{"line":103,"column":4},"end":{"line":103,"column":64}},"72":{"start":{"line":103,"column":40},"end":{"line":103,"column":63}},"73":{"start":{"line":106,"column":4},"end":{"line":106,"column":26}},"74":{"start":{"line":107,"column":4},"end":{"line":107,"column":25}},"75":{"start":{"line":108,"column":4},"end":{"line":108,"column":56}},"76":{"start":{"line":112,"column":4},"end":{"line":118,"column":7}},"77":{"start":{"line":113,"column":6},"end":{"line":117,"column":8}},"78":{"start":{"line":114,"column":8},"end":{"line":114,"column":35}},"79":{"start":{"line":114,"column":17},"end":{"line":114,"column":35}},"80":{"start":{"line":115,"column":8},"end":{"line":115,"column":28}},"81":{"start":{"line":116,"column":8},"end":{"line":116,"column":24}},"82":{"start":{"line":122,"column":17},"end":{"line":122,"column":21}},"83":{"start":{"line":123,"column":23},"end":{"line":123,"column":56}},"84":{"start":{"line":124,"column":4},"end":{"line":137,"column":6}},"85":{"start":{"line":125,"column":6},"end":{"line":125,"column":29}},"86":{"start":{"line":125,"column":15},"end":{"line":125,"column":29}},"87":{"start":{"line":126,"column":6},"end":{"line":136,"column":8}},"88":{"start":{"line":127,"column":8},"end":{"line":133,"column":9}},"89":{"start":{"line":128,"column":10},"end":{"line":128,"column":50}},"90":{"start":{"line":129,"column":10},"end":{"line":132,"column":12}},"91":{"start":{"line":130,"column":12},"end":{"line":130,"column":35}},"92":{"start":{"line":130,"column":21},"end":{"line":130,"column":35}},"93":{"start":{"line":131,"column":12},"end":{"line":131,"column":32}},"94":{"start":{"line":134,"column":8},"end":{"line":134,"column":29}},"95":{"start":{"line":135,"column":8},"end":{"line":135,"column":28}},"96":{"start":{"line":141,"column":20},"end":{"line":141,"column":57}},"97":{"start":{"line":142,"column":4},"end":{"line":142,"column":39}},"98":{"start":{"line":143,"column":4},"end":{"line":143,"column":18}},"99":{"start":{"line":147,"column":17},"end":{"line":147,"column":43}},"100":{"start":{"line":148,"column":20},"end":{"line":148,"column":28}},"101":{"start":{"line":149,"column":4},"end":{"line":149,"column":74}},"102":{"start":{"line":149,"column":21},"end":{"line":149,"column":74}},"103":{"start":{"line":150,"column":4},"end":{"line":150,"column":39}},"104":{"start":{"line":151,"column":4},"end":{"line":151,"column":47}},"105":{"start":{"line":151,"column":18},"end":{"line":151,"column":47}},"106":{"start":{"line":152,"column":4},"end":{"line":152,"column":18}},"107":{"start":{"line":156,"column":17},"end":{"line":156,"column":21}},"108":{"start":{"line":158,"column":4},"end":{"line":168,"column":6}},"109":{"start":{"line":159,"column":6},"end":{"line":159,"column":21}},"110":{"start":{"line":159,"column":15},"end":{"line":159,"column":21}},"111":{"start":{"line":161,"column":6},"end":{"line":163,"column":7}},"112":{"start":{"line":162,"column":8},"end":{"line":162,"column":43}},"113":{"start":{"line":162,"column":37},"end":{"line":162,"column":43}},"114":{"start":{"line":164,"column":6},"end":{"line":167,"column":8}},"115":{"start":{"line":172,"column":4},"end":{"line":177,"column":5}},"116":{"start":{"line":172,"column":26},"end":{"line":172,"column":42}},"117":{"start":{"line":173,"column":9},"end":{"line":177,"column":5}},"118":{"start":{"line":173,"column":36},"end":{"line":173,"column":75}},"119":{"start":{"line":174,"column":9},"end":{"line":177,"column":5}},"120":{"start":{"line":175,"column":18},"end":{"line":175,"column":41}},"121":{"start":{"line":176,"column":6},"end":{"line":176,"column":37}},"122":{"start":{"line":178,"column":4},"end":{"line":178,"column":15}},"123":{"start":{"line":182,"column":16},"end":{"line":182,"column":39}},"124":{"start":{"line":183,"column":4},"end":{"line":183,"column":71}},"125":{"start":{"line":187,"column":16},"end":{"line":187,"column":44}},"126":{"start":{"line":188,"column":4},"end":{"line":188,"column":65}},"127":{"start":{"line":188,"column":31},"end":{"line":188,"column":65}},"128":{"start":{"line":189,"column":4},"end":{"line":189,"column":38}},"129":{"start":{"line":193,"column":16},"end":{"line":193,"column":44}},"130":{"start":{"line":194,"column":4},"end":{"line":194,"column":35}},"131":{"start":{"line":195,"column":4},"end":{"line":195,"column":35}},"132":{"start":{"line":199,"column":4},"end":{"line":199,"column":60}},"133":{"start":{"line":199,"column":27},"end":{"line":199,"column":60}},"134":{"start":{"line":200,"column":18},"end":{"line":200,"column":20}},"135":{"start":{"line":201,"column":4},"end":{"line":205,"column":5}},"136":{"start":{"line":202,"column":22},"end":{"line":202,"column":60}},"137":{"start":{"line":203,"column":6},"end":{"line":203,"column":78}},"138":{"start":{"line":204,"column":6},"end":{"line":204,"column":77}},"139":{"start":{"line":206,"column":4},"end":{"line":206,"column":39}},"140":{"start":{"line":210,"column":17},"end":{"line":210,"column":19}},"141":{"start":{"line":211,"column":16},"end":{"line":211,"column":67}},"142":{"start":{"line":212,"column":4},"end":{"line":217,"column":6}},"143":{"start":{"line":213,"column":6},"end":{"line":213,"column":29}},"144":{"start":{"line":213,"column":15},"end":{"line":213,"column":29}},"145":{"start":{"line":214,"column":6},"end":{"line":214,"column":38}},"146":{"start":{"line":214,"column":17},"end":{"line":214,"column":38}},"147":{"start":{"line":215,"column":6},"end":{"line":215,"column":24}},"148":{"start":{"line":216,"column":6},"end":{"line":216,"column":29}},"149":{"start":{"line":221,"column":4},"end":{"line":221,"column":44}},"150":{"start":{"line":221,"column":15},"end":{"line":221,"column":44}},"151":{"start":{"line":222,"column":17},"end":{"line":222,"column":61}},"152":{"start":{"line":223,"column":20},"end":{"line":223,"column":40}},"153":{"start":{"line":224,"column":25},"end":{"line":224,"column":63}},"154":{"start":{"line":225,"column":4},"end":{"line":225,"column":93}},"155":{"start":{"line":229,"column":4},"end":{"line":229,"column":63}},"156":{"start":{"line":229,"column":35},"end":{"line":229,"column":63}},"157":{"start":{"line":231,"column":4},"end":{"line":240,"column":5}},"158":{"start":{"line":232,"column":24},"end":{"line":232,"column":50}},"159":{"start":{"line":233,"column":24},"end":{"line":233,"column":50}},"160":{"start":{"line":234,"column":6},"end":{"line":239,"column":7}},"161":{"start":{"line":241,"column":4},"end":{"line":249,"column":5}},"162":{"start":{"line":242,"column":24},"end":{"line":242,"column":47}},"163":{"start":{"line":243,"column":6},"end":{"line":248,"column":7}},"164":{"start":{"line":250,"column":4},"end":{"line":253,"column":5}},"165":{"start":{"line":251,"column":19},"end":{"line":251,"column":46}},"166":{"start":{"line":252,"column":6},"end":{"line":252,"column":40}},"167":{"start":{"line":254,"column":4},"end":{"line":262,"column":5}},"168":{"start":{"line":255,"column":27},"end":{"line":255,"column":59}},"169":{"start":{"line":256,"column":6},"end":{"line":261,"column":7}},"170":{"start":{"line":263,"column":4},"end":{"line":263,"column":38}},"171":{"start":{"line":267,"column":4},"end":{"line":267,"column":63}},"172":{"start":{"line":267,"column":35},"end":{"line":267,"column":63}},"173":{"start":{"line":268,"column":4},"end":{"line":271,"column":6}},"174":{"start":{"line":275,"column":4},"end":{"line":275,"column":44}},"175":{"start":{"line":275,"column":15},"end":{"line":275,"column":44}},"176":{"start":{"line":276,"column":4},"end":{"line":276,"column":46}},"177":{"start":{"line":280,"column":4},"end":{"line":280,"column":85}},"178":{"start":{"line":280,"column":24},"end":{"line":280,"column":85}},"179":{"start":{"line":281,"column":17},"end":{"line":281,"column":21}},"180":{"start":{"line":283,"column":26},"end":{"line":283,"column":54}},"181":{"start":{"line":284,"column":57},"end":{"line":284,"column":70}},"182":{"start":{"line":285,"column":15},"end":{"line":285,"column":38}},"183":{"start":{"line":287,"column":19},"end":{"line":287,"column":52}},"184":{"start":{"line":288,"column":4},"end":{"line":294,"column":5}},"185":{"start":{"line":289,"column":26},"end":{"line":289,"column":58}},"186":{"start":{"line":290,"column":6},"end":{"line":292,"column":8}},"187":{"start":{"line":291,"column":8},"end":{"line":291,"column":29}},"188":{"start":{"line":293,"column":6},"end":{"line":293,"column":19}},"189":{"start":{"line":296,"column":24},"end":{"line":296,"column":70}},"190":{"start":{"line":298,"column":23},"end":{"line":311,"column":6}},"191":{"start":{"line":299,"column":6},"end":{"line":305,"column":7}},"192":{"start":{"line":300,"column":20},"end":{"line":300,"column":47}},"193":{"start":{"line":301,"column":8},"end":{"line":303,"column":9}},"194":{"start":{"line":302,"column":10},"end":{"line":302,"column":59}},"195":{"start":{"line":304,"column":8},"end":{"line":304,"column":28}},"196":{"start":{"line":306,"column":6},"end":{"line":306,"column":51}},"197":{"start":{"line":306,"column":21},"end":{"line":306,"column":51}},"198":{"start":{"line":307,"column":6},"end":{"line":307,"column":80}},"199":{"start":{"line":307,"column":21},"end":{"line":307,"column":80}},"200":{"start":{"line":308,"column":18},"end":{"line":308,"column":48}},"201":{"start":{"line":309,"column":6},"end":{"line":309,"column":31}},"202":{"start":{"line":310,"column":6},"end":{"line":310,"column":20}},"203":{"start":{"line":313,"column":17},"end":{"line":321,"column":6}},"204":{"start":{"line":314,"column":6},"end":{"line":314,"column":48}},"205":{"start":{"line":314,"column":27},"end":{"line":314,"column":48}},"206":{"start":{"line":315,"column":6},"end":{"line":315,"column":60}},"207":{"start":{"line":315,"column":33},"end":{"line":315,"column":60}},"208":{"start":{"line":316,"column":6},"end":{"line":316,"column":32}},"209":{"start":{"line":322,"column":4},"end":{"line":322,"column":52}},"210":{"start":{"line":323,"column":4},"end":{"line":323,"column":60}},"211":{"start":{"line":323,"column":30},"end":{"line":323,"column":60}},"212":{"start":{"line":325,"column":24},"end":{"line":325,"column":54}},"213":{"start":{"line":327,"column":18},"end":{"line":327,"column":23}},"214":{"start":{"line":328,"column":26},"end":{"line":333,"column":5}},"215":{"start":{"line":329,"column":6},"end":{"line":332,"column":7}},"216":{"start":{"line":331,"column":8},"end":{"line":331,"column":14}},"217":{"start":{"line":334,"column":4},"end":{"line":334,"column":37}},"218":{"start":{"line":335,"column":4},"end":{"line":345,"column":6}},"219":{"start":{"line":336,"column":6},"end":{"line":336,"column":25}},"220":{"start":{"line":336,"column":19},"end":{"line":336,"column":25}},"221":{"start":{"line":337,"column":6},"end":{"line":337,"column":39}},"222":{"start":{"line":338,"column":6},"end":{"line":338,"column":49}},"223":{"start":{"line":339,"column":6},"end":{"line":344,"column":8}},"224":{"start":{"line":340,"column":8},"end":{"line":340,"column":40}},"225":{"start":{"line":340,"column":17},"end":{"line":340,"column":40}},"226":{"start":{"line":341,"column":8},"end":{"line":343,"column":10}},"227":{"start":{"line":342,"column":10},"end":{"line":342,"column":31}},"228":{"start":{"line":346,"column":4},"end":{"line":348,"column":6}},"229":{"start":{"line":347,"column":6},"end":{"line":347,"column":29}},"230":{"start":{"line":350,"column":4},"end":{"line":350,"column":15}},"231":{"start":{"line":353,"column":6},"end":{"line":353,"column":65}},"232":{"start":{"line":354,"column":6},"end":{"line":370,"column":8}},"233":{"start":{"line":355,"column":8},"end":{"line":359,"column":9}},"234":{"start":{"line":356,"column":10},"end":{"line":356,"column":45}},"235":{"start":{"line":357,"column":10},"end":{"line":357,"column":32}},"236":{"start":{"line":357,"column":18},"end":{"line":357,"column":32}},"237":{"start":{"line":358,"column":10},"end":{"line":358,"column":16}},"238":{"start":{"line":361,"column":8},"end":{"line":361,"column":71}},"239":{"start":{"line":362,"column":8},"end":{"line":368,"column":9}},"240":{"start":{"line":363,"column":26},"end":{"line":363,"column":62}},"241":{"start":{"line":364,"column":10},"end":{"line":364,"column":51}},"242":{"start":{"line":364,"column":43},"end":{"line":364,"column":51}},"243":{"start":{"line":365,"column":10},"end":{"line":367,"column":11}},"244":{"start":{"line":366,"column":12},"end":{"line":366,"column":58}},"245":{"start":{"line":369,"column":8},"end":{"line":369,"column":31}},"246":{"start":{"line":369,"column":16},"end":{"line":369,"column":31}},"247":{"start":{"line":374,"column":6},"end":{"line":374,"column":51}},"248":{"start":{"line":379,"column":4},"end":{"line":381,"column":5}},"249":{"start":{"line":380,"column":6},"end":{"line":380,"column":47}},"250":{"start":{"line":382,"column":17},"end":{"line":382,"column":21}},"251":{"start":{"line":384,"column":20},"end":{"line":384,"column":24}},"252":{"start":{"line":385,"column":4},"end":{"line":387,"column":5}},"253":{"start":{"line":386,"column":6},"end":{"line":386,"column":41}},"254":{"start":{"line":390,"column":22},"end":{"line":390,"column":74}},"255":{"start":{"line":391,"column":23},"end":{"line":391,"column":75}},"256":{"start":{"line":392,"column":18},"end":{"line":392,"column":71}},"257":{"start":{"line":393,"column":4},"end":{"line":393,"column":54}},"258":{"start":{"line":394,"column":4},"end":{"line":394,"column":42}},"259":{"start":{"line":396,"column":17},"end":{"line":396,"column":22}},"260":{"start":{"line":398,"column":4},"end":{"line":419,"column":5}},"261":{"start":{"line":400,"column":6},"end":{"line":413,"column":8}},"262":{"start":{"line":401,"column":8},"end":{"line":401,"column":59}},"263":{"start":{"line":401,"column":17},"end":{"line":401,"column":59}},"264":{"start":{"line":402,"column":8},"end":{"line":402,"column":42}},"265":{"start":{"line":404,"column":25},"end":{"line":404,"column":58}},"266":{"start":{"line":405,"column":8},"end":{"line":405,"column":67}},"267":{"start":{"line":407,"column":8},"end":{"line":412,"column":9}},"268":{"start":{"line":408,"column":29},"end":{"line":408,"column":59}},"269":{"start":{"line":409,"column":10},"end":{"line":409,"column":35}},"270":{"start":{"line":409,"column":27},"end":{"line":409,"column":35}},"271":{"start":{"line":410,"column":10},"end":{"line":410,"column":36}},"272":{"start":{"line":411,"column":10},"end":{"line":411,"column":71}},"273":{"start":{"line":416,"column":6},"end":{"line":418,"column":7}},"274":{"start":{"line":417,"column":8},"end":{"line":417,"column":69}},"275":{"start":{"line":421,"column":4},"end":{"line":425,"column":6}},"276":{"start":{"line":423,"column":6},"end":{"line":423,"column":49}},"277":{"start":{"line":424,"column":6},"end":{"line":424,"column":38}},"278":{"start":{"line":427,"column":4},"end":{"line":427,"column":36}},"279":{"start":{"line":428,"column":4},"end":{"line":428,"column":33}},"280":{"start":{"line":429,"column":4},"end":{"line":429,"column":35}},"281":{"start":{"line":431,"column":22},"end":{"line":431,"column":61}},"282":{"start":{"line":432,"column":18},"end":{"line":432,"column":57}},"283":{"start":{"line":433,"column":4},"end":{"line":436,"column":5}},"284":{"start":{"line":434,"column":6},"end":{"line":434,"column":18}},"285":{"start":{"line":435,"column":6},"end":{"line":435,"column":54}},"286":{"start":{"line":437,"column":4},"end":{"line":437,"column":29}},"287":{"start":{"line":439,"column":4},"end":{"line":439,"column":21}},"288":{"start":{"line":442,"column":6},"end":{"line":445,"column":7}},"289":{"start":{"line":443,"column":8},"end":{"line":443,"column":55}},"290":{"start":{"line":444,"column":8},"end":{"line":444,"column":21}},"291":{"start":{"line":450,"column":4},"end":{"line":450,"column":42}},"292":{"start":{"line":454,"column":17},"end":{"line":454,"column":21}},"293":{"start":{"line":455,"column":20},"end":{"line":455,"column":77}},"294":{"start":{"line":456,"column":18},"end":{"line":456,"column":23}},"295":{"start":{"line":457,"column":16},"end":{"line":457,"column":20}},"296":{"start":{"line":459,"column":4},"end":{"line":463,"column":5}},"297":{"start":{"line":460,"column":6},"end":{"line":462,"column":7}},"298":{"start":{"line":461,"column":8},"end":{"line":461,"column":24}},"299":{"start":{"line":464,"column":4},"end":{"line":467,"column":5}},"300":{"start":{"line":465,"column":6},"end":{"line":466,"column":24}},"301":{"start":{"line":465,"column":24},"end":{"line":465,"column":43}},"302":{"start":{"line":466,"column":11},"end":{"line":466,"column":24}},"303":{"start":{"line":468,"column":4},"end":{"line":472,"column":5}},"304":{"start":{"line":469,"column":19},"end":{"line":469,"column":47}},"305":{"start":{"line":470,"column":6},"end":{"line":471,"column":24}},"306":{"start":{"line":470,"column":24},"end":{"line":470,"column":43}},"307":{"start":{"line":471,"column":11},"end":{"line":471,"column":24}},"308":{"start":{"line":473,"column":4},"end":{"line":473,"column":13}},"309":{"start":{"line":476,"column":6},"end":{"line":476,"column":26}},"310":{"start":{"line":476,"column":15},"end":{"line":476,"column":26}},"311":{"start":{"line":477,"column":6},"end":{"line":477,"column":43}},"312":{"start":{"line":477,"column":24},"end":{"line":477,"column":43}},"313":{"start":{"line":481,"column":6},"end":{"line":481,"column":25}},"314":{"start":{"line":481,"column":19},"end":{"line":481,"column":25}},"315":{"start":{"line":482,"column":6},"end":{"line":482,"column":20}},"316":{"start":{"line":483,"column":6},"end":{"line":490,"column":8}},"317":{"start":{"line":484,"column":8},"end":{"line":484,"column":29}},"318":{"start":{"line":484,"column":18},"end":{"line":484,"column":29}},"319":{"start":{"line":485,"column":8},"end":{"line":485,"column":31}},"320":{"start":{"line":485,"column":17},"end":{"line":485,"column":31}},"321":{"start":{"line":486,"column":8},"end":{"line":486,"column":35}},"322":{"start":{"line":487,"column":8},"end":{"line":487,"column":35}},"323":{"start":{"line":488,"column":8},"end":{"line":488,"column":40}},"324":{"start":{"line":489,"column":8},"end":{"line":489,"column":22}},"325":{"start":{"line":495,"column":4},"end":{"line":495,"column":35}},"326":{"start":{"line":501,"column":2},"end":{"line":501,"column":61}},"327":{"start":{"line":505,"column":2},"end":{"line":505,"column":66}},"328":{"start":{"line":509,"column":2},"end":{"line":514,"column":3}},"329":{"start":{"line":510,"column":4},"end":{"line":512,"column":20}},"330":{"start":{"line":511,"column":17},"end":{"line":511,"column":71}},"331":{"start":{"line":513,"column":4},"end":{"line":513,"column":50}},"332":{"start":{"line":517,"column":0},"end":{"line":517,"column":26}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":22,"column":2},"end":{"line":22,"column":3}},"loc":{"start":{"line":22,"column":32},"end":{"line":27,"column":3}},"line":22},"1":{"name":"(anonymous_1)","decl":{"start":{"line":29,"column":2},"end":{"line":29,"column":3}},"loc":{"start":{"line":29,"column":22},"end":{"line":36,"column":3}},"line":29},"2":{"name":"(anonymous_2)","decl":{"start":{"line":32,"column":23},"end":{"line":32,"column":24}},"loc":{"start":{"line":32,"column":29},"end":{"line":34,"column":5}},"line":32},"3":{"name":"(anonymous_3)","decl":{"start":{"line":38,"column":2},"end":{"line":38,"column":3}},"loc":{"start":{"line":38,"column":26},"end":{"line":42,"column":3}},"line":38},"4":{"name":"(anonymous_4)","decl":{"start":{"line":44,"column":2},"end":{"line":44,"column":3}},"loc":{"start":{"line":44,"column":22},"end":{"line":48,"column":3}},"line":44},"5":{"name":"(anonymous_5)","decl":{"start":{"line":50,"column":2},"end":{"line":50,"column":3}},"loc":{"start":{"line":50,"column":33},"end":{"line":53,"column":3}},"line":50},"6":{"name":"(anonymous_6)","decl":{"start":{"line":55,"column":2},"end":{"line":55,"column":3}},"loc":{"start":{"line":55,"column":13},"end":{"line":77,"column":3}},"line":55},"7":{"name":"onclose","decl":{"start":{"line":70,"column":13},"end":{"line":70,"column":20}},"loc":{"start":{"line":70,"column":27},"end":{"line":76,"column":5}},"line":70},"8":{"name":"(anonymous_8)","decl":{"start":{"line":81,"column":2},"end":{"line":81,"column":3}},"loc":{"start":{"line":81,"column":35},"end":{"line":109,"column":3}},"line":81},"9":{"name":"(anonymous_9)","decl":{"start":{"line":95,"column":36},"end":{"line":95,"column":37}},"loc":{"start":{"line":95,"column":62},"end":{"line":100,"column":5}},"line":95},"10":{"name":"(anonymous_10)","decl":{"start":{"line":97,"column":17},"end":{"line":97,"column":18}},"loc":{"start":{"line":97,"column":24},"end":{"line":99,"column":7}},"line":97},"11":{"name":"(anonymous_11)","decl":{"start":{"line":102,"column":33},"end":{"line":102,"column":34}},"loc":{"start":{"line":102,"column":38},"end":{"line":102,"column":65}},"line":102},"12":{"name":"(anonymous_12)","decl":{"start":{"line":103,"column":33},"end":{"line":103,"column":34}},"loc":{"start":{"line":103,"column":40},"end":{"line":103,"column":63}},"line":103},"13":{"name":"(anonymous_13)","decl":{"start":{"line":111,"column":2},"end":{"line":111,"column":3}},"loc":{"start":{"line":111,"column":13},"end":{"line":119,"column":3}},"line":111},"14":{"name":"(anonymous_14)","decl":{"start":{"line":112,"column":33},"end":{"line":112,"column":34}},"loc":{"start":{"line":112,"column":54},"end":{"line":118,"column":5}},"line":112},"15":{"name":"(anonymous_15)","decl":{"start":{"line":113,"column":26},"end":{"line":113,"column":27}},"loc":{"start":{"line":113,"column":33},"end":{"line":117,"column":7}},"line":113},"16":{"name":"(anonymous_16)","decl":{"start":{"line":121,"column":2},"end":{"line":121,"column":3}},"loc":{"start":{"line":121,"column":13},"end":{"line":138,"column":3}},"line":121},"17":{"name":"(anonymous_17)","decl":{"start":{"line":124,"column":22},"end":{"line":124,"column":23}},"loc":{"start":{"line":124,"column":29},"end":{"line":137,"column":5}},"line":124},"18":{"name":"(anonymous_18)","decl":{"start":{"line":126,"column":29},"end":{"line":126,"column":30}},"loc":{"start":{"line":126,"column":43},"end":{"line":136,"column":7}},"line":126},"19":{"name":"(anonymous_19)","decl":{"start":{"line":129,"column":54},"end":{"line":129,"column":55}},"loc":{"start":{"line":129,"column":61},"end":{"line":132,"column":11}},"line":129},"20":{"name":"(anonymous_20)","decl":{"start":{"line":140,"column":2},"end":{"line":140,"column":3}},"loc":{"start":{"line":140,"column":29},"end":{"line":144,"column":3}},"line":140},"21":{"name":"(anonymous_21)","decl":{"start":{"line":146,"column":2},"end":{"line":146,"column":3}},"loc":{"start":{"line":146,"column":29},"end":{"line":153,"column":3}},"line":146},"22":{"name":"(anonymous_22)","decl":{"start":{"line":155,"column":2},"end":{"line":155,"column":3}},"loc":{"start":{"line":155,"column":42},"end":{"line":169,"column":3}},"line":155},"23":{"name":"(anonymous_23)","decl":{"start":{"line":158,"column":15},"end":{"line":158,"column":16}},"loc":{"start":{"line":158,"column":30},"end":{"line":168,"column":5}},"line":158},"24":{"name":"(anonymous_24)","decl":{"start":{"line":171,"column":2},"end":{"line":171,"column":3}},"loc":{"start":{"line":171,"column":28},"end":{"line":179,"column":3}},"line":171},"25":{"name":"(anonymous_25)","decl":{"start":{"line":181,"column":2},"end":{"line":181,"column":3}},"loc":{"start":{"line":181,"column":32},"end":{"line":184,"column":3}},"line":181},"26":{"name":"(anonymous_26)","decl":{"start":{"line":186,"column":2},"end":{"line":186,"column":3}},"loc":{"start":{"line":186,"column":26},"end":{"line":190,"column":3}},"line":186},"27":{"name":"(anonymous_27)","decl":{"start":{"line":192,"column":2},"end":{"line":192,"column":3}},"loc":{"start":{"line":192,"column":22},"end":{"line":196,"column":3}},"line":192},"28":{"name":"(anonymous_28)","decl":{"start":{"line":198,"column":2},"end":{"line":198,"column":3}},"loc":{"start":{"line":198,"column":48},"end":{"line":207,"column":3}},"line":198},"29":{"name":"(anonymous_29)","decl":{"start":{"line":209,"column":2},"end":{"line":209,"column":3}},"loc":{"start":{"line":209,"column":48},"end":{"line":218,"column":3}},"line":209},"30":{"name":"onnext","decl":{"start":{"line":212,"column":22},"end":{"line":212,"column":28}},"loc":{"start":{"line":212,"column":41},"end":{"line":217,"column":5}},"line":212},"31":{"name":"(anonymous_31)","decl":{"start":{"line":220,"column":2},"end":{"line":220,"column":3}},"loc":{"start":{"line":220,"column":26},"end":{"line":226,"column":3}},"line":220},"32":{"name":"(anonymous_32)","decl":{"start":{"line":228,"column":2},"end":{"line":228,"column":3}},"loc":{"start":{"line":228,"column":27},"end":{"line":264,"column":3}},"line":228},"33":{"name":"(anonymous_33)","decl":{"start":{"line":266,"column":2},"end":{"line":266,"column":3}},"loc":{"start":{"line":266,"column":26},"end":{"line":272,"column":3}},"line":266},"34":{"name":"(anonymous_34)","decl":{"start":{"line":274,"column":2},"end":{"line":274,"column":3}},"loc":{"start":{"line":274,"column":19},"end":{"line":277,"column":3}},"line":274},"35":{"name":"(anonymous_35)","decl":{"start":{"line":279,"column":2},"end":{"line":279,"column":3}},"loc":{"start":{"line":279,"column":22},"end":{"line":376,"column":3}},"line":279},"36":{"name":"(anonymous_36)","decl":{"start":{"line":290,"column":43},"end":{"line":290,"column":44}},"loc":{"start":{"line":290,"column":49},"end":{"line":292,"column":7}},"line":290},"37":{"name":"(anonymous_37)","decl":{"start":{"line":298,"column":53},"end":{"line":298,"column":54}},"loc":{"start":{"line":298,"column":67},"end":{"line":311,"column":5}},"line":298},"38":{"name":"(anonymous_38)","decl":{"start":{"line":313,"column":27},"end":{"line":313,"column":28}},"loc":{"start":{"line":313,"column":35},"end":{"line":317,"column":5}},"line":313},"39":{"name":"(anonymous_39)","decl":{"start":{"line":328,"column":26},"end":{"line":328,"column":27}},"loc":{"start":{"line":328,"column":33},"end":{"line":333,"column":5}},"line":328},"40":{"name":"(anonymous_40)","decl":{"start":{"line":335,"column":23},"end":{"line":335,"column":24}},"loc":{"start":{"line":335,"column":29},"end":{"line":345,"column":5}},"line":335},"41":{"name":"(anonymous_41)","decl":{"start":{"line":339,"column":51},"end":{"line":339,"column":52}},"loc":{"start":{"line":339,"column":58},"end":{"line":344,"column":7}},"line":339},"42":{"name":"(anonymous_42)","decl":{"start":{"line":341,"column":43},"end":{"line":341,"column":44}},"loc":{"start":{"line":341,"column":49},"end":{"line":343,"column":9}},"line":341},"43":{"name":"(anonymous_43)","decl":{"start":{"line":346,"column":23},"end":{"line":346,"column":24}},"loc":{"start":{"line":346,"column":29},"end":{"line":348,"column":5}},"line":346},"44":{"name":"injectIntoReplicationStreams","decl":{"start":{"line":352,"column":13},"end":{"line":352,"column":41}},"loc":{"start":{"line":352,"column":53},"end":{"line":371,"column":5}},"line":352},"45":{"name":"(anonymous_45)","decl":{"start":{"line":354,"column":49},"end":{"line":354,"column":50}},"loc":{"start":{"line":354,"column":67},"end":{"line":370,"column":7}},"line":354},"46":{"name":"createStorage","decl":{"start":{"line":373,"column":13},"end":{"line":373,"column":26}},"loc":{"start":{"line":373,"column":34},"end":{"line":375,"column":5}},"line":373},"47":{"name":"(anonymous_47)","decl":{"start":{"line":378,"column":2},"end":{"line":378,"column":3}},"loc":{"start":{"line":378,"column":49},"end":{"line":447,"column":3}},"line":378},"48":{"name":"(anonymous_48)","decl":{"start":{"line":400,"column":55},"end":{"line":400,"column":56}},"loc":{"start":{"line":400,"column":74},"end":{"line":413,"column":7}},"line":400},"49":{"name":"(anonymous_49)","decl":{"start":{"line":421,"column":26},"end":{"line":421,"column":27}},"loc":{"start":{"line":421,"column":34},"end":{"line":425,"column":5}},"line":421},"50":{"name":"onclose","decl":{"start":{"line":441,"column":13},"end":{"line":441,"column":20}},"loc":{"start":{"line":441,"column":24},"end":{"line":446,"column":5}},"line":441},"51":{"name":"(anonymous_51)","decl":{"start":{"line":449,"column":2},"end":{"line":449,"column":3}},"loc":{"start":{"line":449,"column":27},"end":{"line":451,"column":3}},"line":449},"52":{"name":"(anonymous_52)","decl":{"start":{"line":453,"column":2},"end":{"line":453,"column":3}},"loc":{"start":{"line":453,"column":13},"end":{"line":492,"column":3}},"line":453},"53":{"name":"onclose","decl":{"start":{"line":475,"column":13},"end":{"line":475,"column":20}},"loc":{"start":{"line":475,"column":27},"end":{"line":478,"column":5}},"line":475},"54":{"name":"reset","decl":{"start":{"line":480,"column":13},"end":{"line":480,"column":18}},"loc":{"start":{"line":480,"column":25},"end":{"line":491,"column":5}},"line":480},"55":{"name":"(anonymous_55)","decl":{"start":{"line":483,"column":24},"end":{"line":483,"column":25}},"loc":{"start":{"line":483,"column":31},"end":{"line":490,"column":7}},"line":483},"56":{"name":"(anonymous_56)","decl":{"start":{"line":494,"column":2},"end":{"line":494,"column":3}},"loc":{"start":{"line":494,"column":10},"end":{"line":496,"column":3}},"line":494},"57":{"name":"encodeKey","decl":{"start":{"line":500,"column":9},"end":{"line":500,"column":18}},"loc":{"start":{"line":500,"column":25},"end":{"line":502,"column":1}},"line":500},"58":{"name":"decodeKey","decl":{"start":{"line":504,"column":9},"end":{"line":504,"column":18}},"loc":{"start":{"line":504,"column":25},"end":{"line":506,"column":1}},"line":504},"59":{"name":"defaultStorage","decl":{"start":{"line":508,"column":9},"end":{"line":508,"column":23}},"loc":{"start":{"line":508,"column":30},"end":{"line":515,"column":1}},"line":508},"60":{"name":"(anonymous_60)","decl":{"start":{"line":509,"column":9},"end":{"line":509,"column":10}},"loc":{"start":{"line":509,"column":25},"end":{"line":514,"column":3}},"line":509}},"branchMap":{"0":{"loc":{"start":{"line":30,"column":4},"end":{"line":30,"column":69}},"type":"if","locations":[{"start":{"line":30,"column":4},"end":{"line":30,"column":69}},{"start":{"line":30,"column":4},"end":{"line":30,"column":69}}],"line":30},"1":{"loc":{"start":{"line":38,"column":11},"end":{"line":38,"column":24}},"type":"default-arg","locations":[{"start":{"line":38,"column":22},"end":{"line":38,"column":24}}],"line":38},"2":{"loc":{"start":{"line":39,"column":4},"end":{"line":39,"column":63}},"type":"if","locations":[{"start":{"line":39,"column":4},"end":{"line":39,"column":63}},{"start":{"line":39,"column":4},"end":{"line":39,"column":63}}],"line":39},"3":{"loc":{"start":{"line":44,"column":7},"end":{"line":44,"column":20}},"type":"default-arg","locations":[{"start":{"line":44,"column":18},"end":{"line":44,"column":20}}],"line":44},"4":{"loc":{"start":{"line":45,"column":4},"end":{"line":45,"column":63}},"type":"if","locations":[{"start":{"line":45,"column":4},"end":{"line":45,"column":63}},{"start":{"line":45,"column":4},"end":{"line":45,"column":63}}],"line":45},"5":{"loc":{"start":{"line":62,"column":6},"end":{"line":65,"column":7}},"type":"if","locations":[{"start":{"line":62,"column":6},"end":{"line":65,"column":7}},{"start":{"line":62,"column":6},"end":{"line":65,"column":7}}],"line":62},"6":{"loc":{"start":{"line":71,"column":6},"end":{"line":71,"column":26}},"type":"if","locations":[{"start":{"line":71,"column":6},"end":{"line":71,"column":26}},{"start":{"line":71,"column":6},"end":{"line":71,"column":26}}],"line":71},"7":{"loc":{"start":{"line":72,"column":6},"end":{"line":75,"column":7}},"type":"if","locations":[{"start":{"line":72,"column":6},"end":{"line":75,"column":7}},{"start":{"line":72,"column":6},"end":{"line":75,"column":7}}],"line":72},"8":{"loc":{"start":{"line":81,"column":24},"end":{"line":81,"column":33}},"type":"default-arg","locations":[{"start":{"line":81,"column":31},"end":{"line":81,"column":33}}],"line":81},"9":{"loc":{"start":{"line":84,"column":4},"end":{"line":84,"column":70}},"type":"if","locations":[{"start":{"line":84,"column":4},"end":{"line":84,"column":70}},{"start":{"line":84,"column":4},"end":{"line":84,"column":70}}],"line":84},"10":{"loc":{"start":{"line":85,"column":4},"end":{"line":85,"column":96}},"type":"if","locations":[{"start":{"line":85,"column":4},"end":{"line":85,"column":96}},{"start":{"line":85,"column":4},"end":{"line":85,"column":96}}],"line":85},"11":{"loc":{"start":{"line":87,"column":16},"end":{"line":87,"column":51}},"type":"binary-expr","locations":[{"start":{"line":87,"column":16},"end":{"line":87,"column":25}},{"start":{"line":87,"column":29},"end":{"line":87,"column":51}}],"line":87},"12":{"loc":{"start":{"line":94,"column":34},"end":{"line":94,"column":56}},"type":"binary-expr","locations":[{"start":{"line":94,"column":34},"end":{"line":94,"column":48}},{"start":{"line":94,"column":52},"end":{"line":94,"column":56}}],"line":94},"13":{"loc":{"start":{"line":96,"column":6},"end":{"line":96,"column":46}},"type":"if","locations":[{"start":{"line":96,"column":6},"end":{"line":96,"column":46}},{"start":{"line":96,"column":6},"end":{"line":96,"column":46}}],"line":96},"14":{"loc":{"start":{"line":98,"column":8},"end":{"line":98,"column":40}},"type":"if","locations":[{"start":{"line":98,"column":8},"end":{"line":98,"column":40}},{"start":{"line":98,"column":8},"end":{"line":98,"column":40}}],"line":98},"15":{"loc":{"start":{"line":114,"column":8},"end":{"line":114,"column":35}},"type":"if","locations":[{"start":{"line":114,"column":8},"end":{"line":114,"column":35}},{"start":{"line":114,"column":8},"end":{"line":114,"column":35}}],"line":114},"16":{"loc":{"start":{"line":125,"column":6},"end":{"line":125,"column":29}},"type":"if","locations":[{"start":{"line":125,"column":6},"end":{"line":125,"column":29}},{"start":{"line":125,"column":6},"end":{"line":125,"column":29}}],"line":125},"17":{"loc":{"start":{"line":127,"column":8},"end":{"line":133,"column":9}},"type":"if","locations":[{"start":{"line":127,"column":8},"end":{"line":133,"column":9}},{"start":{"line":127,"column":8},"end":{"line":133,"column":9}}],"line":127},"18":{"loc":{"start":{"line":130,"column":12},"end":{"line":130,"column":35}},"type":"if","locations":[{"start":{"line":130,"column":12},"end":{"line":130,"column":35}},{"start":{"line":130,"column":12},"end":{"line":130,"column":35}}],"line":130},"19":{"loc":{"start":{"line":141,"column":21},"end":{"line":141,"column":52}},"type":"binary-expr","locations":[{"start":{"line":141,"column":21},"end":{"line":141,"column":47}},{"start":{"line":141,"column":51},"end":{"line":141,"column":52}}],"line":141},"20":{"loc":{"start":{"line":149,"column":4},"end":{"line":149,"column":74}},"type":"if","locations":[{"start":{"line":149,"column":4},"end":{"line":149,"column":74}},{"start":{"line":149,"column":4},"end":{"line":149,"column":74}}],"line":149},"21":{"loc":{"start":{"line":151,"column":4},"end":{"line":151,"column":47}},"type":"if","locations":[{"start":{"line":151,"column":4},"end":{"line":151,"column":47}},{"start":{"line":151,"column":4},"end":{"line":151,"column":47}}],"line":151},"22":{"loc":{"start":{"line":159,"column":6},"end":{"line":159,"column":21}},"type":"if","locations":[{"start":{"line":159,"column":6},"end":{"line":159,"column":21}},{"start":{"line":159,"column":6},"end":{"line":159,"column":21}}],"line":159},"23":{"loc":{"start":{"line":162,"column":8},"end":{"line":162,"column":43}},"type":"if","locations":[{"start":{"line":162,"column":8},"end":{"line":162,"column":43}},{"start":{"line":162,"column":8},"end":{"line":162,"column":43}}],"line":162},"24":{"loc":{"start":{"line":172,"column":4},"end":{"line":177,"column":5}},"type":"if","locations":[{"start":{"line":172,"column":4},"end":{"line":177,"column":5}},{"start":{"line":172,"column":4},"end":{"line":177,"column":5}}],"line":172},"25":{"loc":{"start":{"line":173,"column":9},"end":{"line":177,"column":5}},"type":"if","locations":[{"start":{"line":173,"column":9},"end":{"line":177,"column":5}},{"start":{"line":173,"column":9},"end":{"line":177,"column":5}}],"line":173},"26":{"loc":{"start":{"line":174,"column":9},"end":{"line":177,"column":5}},"type":"if","locations":[{"start":{"line":174,"column":9},"end":{"line":177,"column":5}},{"start":{"line":174,"column":9},"end":{"line":177,"column":5}}],"line":174},"27":{"loc":{"start":{"line":183,"column":11},"end":{"line":183,"column":71}},"type":"binary-expr","locations":[{"start":{"line":183,"column":11},"end":{"line":183,"column":39}},{"start":{"line":183,"column":43},"end":{"line":183,"column":71}}],"line":183},"28":{"loc":{"start":{"line":188,"column":4},"end":{"line":188,"column":65}},"type":"if","locations":[{"start":{"line":188,"column":4},"end":{"line":188,"column":65}},{"start":{"line":188,"column":4},"end":{"line":188,"column":65}}],"line":188},"29":{"loc":{"start":{"line":188,"column":8},"end":{"line":188,"column":29}},"type":"binary-expr","locations":[{"start":{"line":188,"column":8},"end":{"line":188,"column":12}},{"start":{"line":188,"column":16},"end":{"line":188,"column":29}}],"line":188},"30":{"loc":{"start":{"line":199,"column":4},"end":{"line":199,"column":60}},"type":"if","locations":[{"start":{"line":199,"column":4},"end":{"line":199,"column":60}},{"start":{"line":199,"column":4},"end":{"line":199,"column":60}}],"line":199},"31":{"loc":{"start":{"line":213,"column":6},"end":{"line":213,"column":29}},"type":"if","locations":[{"start":{"line":213,"column":6},"end":{"line":213,"column":29}},{"start":{"line":213,"column":6},"end":{"line":213,"column":29}}],"line":213},"32":{"loc":{"start":{"line":214,"column":6},"end":{"line":214,"column":38}},"type":"if","locations":[{"start":{"line":214,"column":6},"end":{"line":214,"column":38}},{"start":{"line":214,"column":6},"end":{"line":214,"column":38}}],"line":214},"33":{"loc":{"start":{"line":221,"column":4},"end":{"line":221,"column":44}},"type":"if","locations":[{"start":{"line":221,"column":4},"end":{"line":221,"column":44}},{"start":{"line":221,"column":4},"end":{"line":221,"column":44}}],"line":221},"34":{"loc":{"start":{"line":229,"column":4},"end":{"line":229,"column":63}},"type":"if","locations":[{"start":{"line":229,"column":4},"end":{"line":229,"column":63}},{"start":{"line":229,"column":4},"end":{"line":229,"column":63}}],"line":229},"35":{"loc":{"start":{"line":231,"column":4},"end":{"line":240,"column":5}},"type":"if","locations":[{"start":{"line":231,"column":4},"end":{"line":240,"column":5}},{"start":{"line":231,"column":4},"end":{"line":240,"column":5}}],"line":231},"36":{"loc":{"start":{"line":241,"column":4},"end":{"line":249,"column":5}},"type":"if","locations":[{"start":{"line":241,"column":4},"end":{"line":249,"column":5}},{"start":{"line":241,"column":4},"end":{"line":249,"column":5}}],"line":241},"37":{"loc":{"start":{"line":250,"column":4},"end":{"line":253,"column":5}},"type":"if","locations":[{"start":{"line":250,"column":4},"end":{"line":253,"column":5}},{"start":{"line":250,"column":4},"end":{"line":253,"column":5}}],"line":250},"38":{"loc":{"start":{"line":251,"column":19},"end":{"line":251,"column":46}},"type":"binary-expr","locations":[{"start":{"line":251,"column":19},"end":{"line":251,"column":33}},{"start":{"line":251,"column":37},"end":{"line":251,"column":46}}],"line":251},"39":{"loc":{"start":{"line":254,"column":4},"end":{"line":262,"column":5}},"type":"if","locations":[{"start":{"line":254,"column":4},"end":{"line":262,"column":5}},{"start":{"line":254,"column":4},"end":{"line":262,"column":5}}],"line":254},"40":{"loc":{"start":{"line":266,"column":11},"end":{"line":266,"column":24}},"type":"default-arg","locations":[{"start":{"line":266,"column":22},"end":{"line":266,"column":24}}],"line":266},"41":{"loc":{"start":{"line":267,"column":4},"end":{"line":267,"column":63}},"type":"if","locations":[{"start":{"line":267,"column":4},"end":{"line":267,"column":63}},{"start":{"line":267,"column":4},"end":{"line":267,"column":63}}],"line":267},"42":{"loc":{"start":{"line":275,"column":4},"end":{"line":275,"column":44}},"type":"if","locations":[{"start":{"line":275,"column":4},"end":{"line":275,"column":44}},{"start":{"line":275,"column":4},"end":{"line":275,"column":44}}],"line":275},"43":{"loc":{"start":{"line":279,"column":7},"end":{"line":279,"column":20}},"type":"default-arg","locations":[{"start":{"line":279,"column":18},"end":{"line":279,"column":20}}],"line":279},"44":{"loc":{"start":{"line":280,"column":4},"end":{"line":280,"column":85}},"type":"if","locations":[{"start":{"line":280,"column":4},"end":{"line":280,"column":85}},{"start":{"line":280,"column":4},"end":{"line":280,"column":85}}],"line":280},"45":{"loc":{"start":{"line":288,"column":4},"end":{"line":294,"column":5}},"type":"if","locations":[{"start":{"line":288,"column":4},"end":{"line":294,"column":5}},{"start":{"line":288,"column":4},"end":{"line":294,"column":5}}],"line":288},"46":{"loc":{"start":{"line":299,"column":6},"end":{"line":305,"column":7}},"type":"if","locations":[{"start":{"line":299,"column":6},"end":{"line":305,"column":7}},{"start":{"line":299,"column":6},"end":{"line":305,"column":7}}],"line":299},"47":{"loc":{"start":{"line":301,"column":8},"end":{"line":303,"column":9}},"type":"if","locations":[{"start":{"line":301,"column":8},"end":{"line":303,"column":9}},{"start":{"line":301,"column":8},"end":{"line":303,"column":9}}],"line":301},"48":{"loc":{"start":{"line":301,"column":12},"end":{"line":301,"column":70}},"type":"binary-expr","locations":[{"start":{"line":301,"column":12},"end":{"line":301,"column":24}},{"start":{"line":301,"column":29},"end":{"line":301,"column":69}}],"line":301},"49":{"loc":{"start":{"line":306,"column":6},"end":{"line":306,"column":51}},"type":"if","locations":[{"start":{"line":306,"column":6},"end":{"line":306,"column":51}},{"start":{"line":306,"column":6},"end":{"line":306,"column":51}}],"line":306},"50":{"loc":{"start":{"line":307,"column":6},"end":{"line":307,"column":80}},"type":"if","locations":[{"start":{"line":307,"column":6},"end":{"line":307,"column":80}},{"start":{"line":307,"column":6},"end":{"line":307,"column":80}}],"line":307},"51":{"loc":{"start":{"line":314,"column":6},"end":{"line":314,"column":48}},"type":"if","locations":[{"start":{"line":314,"column":6},"end":{"line":314,"column":48}},{"start":{"line":314,"column":6},"end":{"line":314,"column":48}}],"line":314},"52":{"loc":{"start":{"line":315,"column":6},"end":{"line":315,"column":60}},"type":"if","locations":[{"start":{"line":315,"column":6},"end":{"line":315,"column":60}},{"start":{"line":315,"column":6},"end":{"line":315,"column":60}}],"line":315},"53":{"loc":{"start":{"line":323,"column":4},"end":{"line":323,"column":60}},"type":"if","locations":[{"start":{"line":323,"column":4},"end":{"line":323,"column":60}},{"start":{"line":323,"column":4},"end":{"line":323,"column":60}}],"line":323},"54":{"loc":{"start":{"line":329,"column":6},"end":{"line":332,"column":7}},"type":"if","locations":[{"start":{"line":329,"column":6},"end":{"line":332,"column":7}},{"start":{"line":329,"column":6},"end":{"line":332,"column":7}}],"line":329},"55":{"loc":{"start":{"line":336,"column":6},"end":{"line":336,"column":25}},"type":"if","locations":[{"start":{"line":336,"column":6},"end":{"line":336,"column":25}},{"start":{"line":336,"column":6},"end":{"line":336,"column":25}}],"line":336},"56":{"loc":{"start":{"line":340,"column":8},"end":{"line":340,"column":40}},"type":"if","locations":[{"start":{"line":340,"column":8},"end":{"line":340,"column":40}},{"start":{"line":340,"column":8},"end":{"line":340,"column":40}}],"line":340},"57":{"loc":{"start":{"line":355,"column":8},"end":{"line":359,"column":9}},"type":"if","locations":[{"start":{"line":355,"column":8},"end":{"line":359,"column":9}},{"start":{"line":355,"column":8},"end":{"line":359,"column":9}}],"line":355},"58":{"loc":{"start":{"line":357,"column":10},"end":{"line":357,"column":32}},"type":"if","locations":[{"start":{"line":357,"column":10},"end":{"line":357,"column":32}},{"start":{"line":357,"column":10},"end":{"line":357,"column":32}}],"line":357},"59":{"loc":{"start":{"line":364,"column":10},"end":{"line":364,"column":51}},"type":"if","locations":[{"start":{"line":364,"column":10},"end":{"line":364,"column":51}},{"start":{"line":364,"column":10},"end":{"line":364,"column":51}}],"line":364},"60":{"loc":{"start":{"line":364,"column":14},"end":{"line":364,"column":41}},"type":"binary-expr","locations":[{"start":{"line":364,"column":14},"end":{"line":364,"column":22}},{"start":{"line":364,"column":26},"end":{"line":364,"column":41}}],"line":364},"61":{"loc":{"start":{"line":369,"column":8},"end":{"line":369,"column":31}},"type":"if","locations":[{"start":{"line":369,"column":8},"end":{"line":369,"column":31}},{"start":{"line":369,"column":8},"end":{"line":369,"column":31}}],"line":369},"62":{"loc":{"start":{"line":378,"column":27},"end":{"line":378,"column":47}},"type":"default-arg","locations":[{"start":{"line":378,"column":45},"end":{"line":378,"column":47}}],"line":378},"63":{"loc":{"start":{"line":379,"column":4},"end":{"line":381,"column":5}},"type":"if","locations":[{"start":{"line":379,"column":4},"end":{"line":381,"column":5}},{"start":{"line":379,"column":4},"end":{"line":381,"column":5}}],"line":379},"64":{"loc":{"start":{"line":379,"column":8},"end":{"line":379,"column":94}},"type":"binary-expr","locations":[{"start":{"line":379,"column":8},"end":{"line":379,"column":20}},{"start":{"line":379,"column":25},"end":{"line":379,"column":55}},{"start":{"line":379,"column":60},"end":{"line":379,"column":92}}],"line":379},"65":{"loc":{"start":{"line":385,"column":4},"end":{"line":387,"column":5}},"type":"if","locations":[{"start":{"line":385,"column":4},"end":{"line":387,"column":5}},{"start":{"line":385,"column":4},"end":{"line":387,"column":5}}],"line":385},"66":{"loc":{"start":{"line":391,"column":23},"end":{"line":391,"column":75}},"type":"binary-expr","locations":[{"start":{"line":391,"column":23},"end":{"line":391,"column":45}},{"start":{"line":391,"column":49},"end":{"line":391,"column":75}}],"line":391},"67":{"loc":{"start":{"line":392,"column":18},"end":{"line":392,"column":71}},"type":"binary-expr","locations":[{"start":{"line":392,"column":18},"end":{"line":392,"column":39}},{"start":{"line":392,"column":43},"end":{"line":392,"column":71}}],"line":392},"68":{"loc":{"start":{"line":398,"column":4},"end":{"line":419,"column":5}},"type":"if","locations":[{"start":{"line":398,"column":4},"end":{"line":419,"column":5}},{"start":{"line":398,"column":4},"end":{"line":419,"column":5}}],"line":398},"69":{"loc":{"start":{"line":401,"column":8},"end":{"line":401,"column":59}},"type":"if","locations":[{"start":{"line":401,"column":8},"end":{"line":401,"column":59}},{"start":{"line":401,"column":8},"end":{"line":401,"column":59}}],"line":401},"70":{"loc":{"start":{"line":409,"column":10},"end":{"line":409,"column":35}},"type":"if","locations":[{"start":{"line":409,"column":10},"end":{"line":409,"column":35}},{"start":{"line":409,"column":10},"end":{"line":409,"column":35}}],"line":409},"71":{"loc":{"start":{"line":433,"column":4},"end":{"line":436,"column":5}},"type":"if","locations":[{"start":{"line":433,"column":4},"end":{"line":436,"column":5}},{"start":{"line":433,"column":4},"end":{"line":436,"column":5}}],"line":433},"72":{"loc":{"start":{"line":442,"column":6},"end":{"line":445,"column":7}},"type":"if","locations":[{"start":{"line":442,"column":6},"end":{"line":445,"column":7}},{"start":{"line":442,"column":6},"end":{"line":445,"column":7}}],"line":442},"73":{"loc":{"start":{"line":465,"column":6},"end":{"line":466,"column":24}},"type":"if","locations":[{"start":{"line":465,"column":6},"end":{"line":466,"column":24}},{"start":{"line":465,"column":6},"end":{"line":466,"column":24}}],"line":465},"74":{"loc":{"start":{"line":470,"column":6},"end":{"line":471,"column":24}},"type":"if","locations":[{"start":{"line":470,"column":6},"end":{"line":471,"column":24}},{"start":{"line":470,"column":6},"end":{"line":471,"column":24}}],"line":470},"75":{"loc":{"start":{"line":476,"column":6},"end":{"line":476,"column":26}},"type":"if","locations":[{"start":{"line":476,"column":6},"end":{"line":476,"column":26}},{"start":{"line":476,"column":6},"end":{"line":476,"column":26}}],"line":476},"76":{"loc":{"start":{"line":477,"column":6},"end":{"line":477,"column":43}},"type":"if","locations":[{"start":{"line":477,"column":6},"end":{"line":477,"column":43}},{"start":{"line":477,"column":6},"end":{"line":477,"column":43}}],"line":477},"77":{"loc":{"start":{"line":481,"column":6},"end":{"line":481,"column":25}},"type":"if","locations":[{"start":{"line":481,"column":6},"end":{"line":481,"column":25}},{"start":{"line":481,"column":6},"end":{"line":481,"column":25}}],"line":481},"78":{"loc":{"start":{"line":484,"column":8},"end":{"line":484,"column":29}},"type":"if","locations":[{"start":{"line":484,"column":8},"end":{"line":484,"column":29}},{"start":{"line":484,"column":8},"end":{"line":484,"column":29}}],"line":484},"79":{"loc":{"start":{"line":485,"column":8},"end":{"line":485,"column":31}},"type":"if","locations":[{"start":{"line":485,"column":8},"end":{"line":485,"column":31}},{"start":{"line":485,"column":8},"end":{"line":485,"column":31}}],"line":485},"80":{"loc":{"start":{"line":501,"column":9},"end":{"line":501,"column":61}},"type":"cond-expr","locations":[{"start":{"line":501,"column":32},"end":{"line":501,"column":55}},{"start":{"line":501,"column":58},"end":{"line":501,"column":61}}],"line":501},"81":{"loc":{"start":{"line":505,"column":9},"end":{"line":505,"column":66}},"type":"cond-expr","locations":[{"start":{"line":505,"column":37},"end":{"line":505,"column":60}},{"start":{"line":505,"column":63},"end":{"line":505,"column":66}}],"line":505},"82":{"loc":{"start":{"line":511,"column":17},"end":{"line":511,"column":71}},"type":"cond-expr","locations":[{"start":{"line":511,"column":46},"end":{"line":511,"column":64}},{"start":{"line":511,"column":67},"end":{"line":511,"column":71}}],"line":511}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":1,"12":1,"13":1,"14":1,"15":1,"16":1,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":17,"52":17,"53":2,"54":17,"55":0,"56":17,"57":17,"58":17,"59":17,"60":17,"61":17,"62":17,"63":17,"64":0,"65":0,"66":0,"67":0,"68":0,"69":17,"70":102,"71":17,"72":0,"73":17,"74":17,"75":17,"76":17,"77":17,"78":17,"79":0,"80":17,"81":17,"82":17,"83":17,"84":17,"85":17,"86":0,"87":17,"88":17,"89":16,"90":16,"91":16,"92":0,"93":16,"94":1,"95":1,"96":40,"97":40,"98":40,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0,"106":0,"107":59,"108":59,"109":59,"110":0,"111":59,"112":73,"113":28,"114":31,"115":0,"116":0,"117":0,"118":0,"119":0,"120":0,"121":0,"122":0,"123":73,"124":73,"125":40,"126":40,"127":36,"128":40,"129":1,"130":1,"131":1,"132":36,"133":30,"134":6,"135":6,"136":6,"137":6,"138":6,"139":6,"140":69,"141":69,"142":69,"143":91,"144":0,"145":91,"146":69,"147":22,"148":22,"149":22,"150":9,"151":22,"152":22,"153":22,"154":22,"155":71,"156":2,"157":71,"158":0,"159":0,"160":0,"161":71,"162":18,"163":18,"164":53,"165":12,"166":12,"167":41,"168":32,"169":32,"170":9,"171":17,"172":2,"173":17,"174":0,"175":0,"176":0,"177":71,"178":0,"179":71,"180":71,"181":71,"182":71,"183":71,"184":71,"185":31,"186":31,"187":31,"188":31,"189":40,"190":40,"191":44,"192":1,"193":1,"194":0,"195":1,"196":43,"197":20,"198":23,"199":15,"200":8,"201":8,"202":8,"203":40,"204":240,"205":40,"206":200,"207":40,"208":160,"209":40,"210":40,"211":40,"212":40,"213":40,"214":40,"215":4,"216":0,"217":40,"218":40,"219":36,"220":0,"221":36,"222":36,"223":36,"224":36,"225":0,"226":36,"227":36,"228":40,"229":1,"230":40,"231":67,"232":67,"233":67,"234":0,"235":0,"236":0,"237":0,"238":67,"239":67,"240":83,"241":83,"242":52,"243":31,"244":31,"245":67,"246":67,"247":240,"248":20,"249":6,"250":14,"251":14,"252":14,"253":2,"254":14,"255":14,"256":14,"257":14,"258":14,"259":14,"260":14,"261":2,"262":2,"263":0,"264":2,"265":2,"266":2,"267":2,"268":6,"269":6,"270":0,"271":6,"272":6,"273":12,"274":20,"275":14,"276":31,"277":31,"278":14,"279":14,"280":14,"281":14,"282":14,"283":14,"284":14,"285":14,"286":14,"287":14,"288":12,"289":6,"290":6,"291":0,"292":1,"293":1,"294":1,"295":1,"296":1,"297":0,"298":0,"299":1,"300":1,"301":1,"302":0,"303":1,"304":1,"305":1,"306":1,"307":0,"308":1,"309":3,"310":0,"311":3,"312":1,"313":1,"314":0,"315":1,"316":1,"317":1,"318":1,"319":1,"320":0,"321":1,"322":1,"323":1,"324":1,"325":0,"326":193,"327":50,"328":2,"329":26,"330":26,"331":26,"332":1},"f":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":17,"9":0,"10":0,"11":102,"12":0,"13":17,"14":17,"15":17,"16":17,"17":17,"18":17,"19":16,"20":40,"21":0,"22":59,"23":59,"24":0,"25":73,"26":40,"27":1,"28":36,"29":69,"30":91,"31":22,"32":71,"33":17,"34":0,"35":71,"36":31,"37":44,"38":240,"39":4,"40":36,"41":36,"42":36,"43":1,"44":67,"45":67,"46":240,"47":20,"48":2,"49":31,"50":12,"51":0,"52":1,"53":3,"54":1,"55":1,"56":0,"57":193,"58":50,"59":2,"60":26},"b":{"0":[0,0],"1":[0],"2":[0,0],"3":[0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[13],"9":[2,15],"10":[0,17],"11":[17,17],"12":[17,17],"13":[0,0],"14":[0,0],"15":[0,17],"16":[0,17],"17":[16,1],"18":[0,16],"19":[40,40],"20":[0,0],"21":[0,0],"22":[0,59],"23":[28,45],"24":[0,0],"25":[0,0],"26":[0,0],"27":[73,40],"28":[36,4],"29":[40,40],"30":[30,6],"31":[0,91],"32":[69,22],"33":[9,13],"34":[2,69],"35":[0,71],"36":[18,53],"37":[12,41],"38":[12,12],"39":[32,9],"40":[11],"41":[2,15],"42":[0,0],"43":[5],"44":[0,71],"45":[31,40],"46":[1,43],"47":[0,1],"48":[1,1],"49":[20,23],"50":[15,8],"51":[40,200],"52":[40,160],"53":[40,0],"54":[0,4],"55":[0,36],"56":[0,36],"57":[0,67],"58":[0,0],"59":[52,31],"60":[83,31],"61":[67,0],"62":[12],"63":[6,14],"64":[20,8,6],"65":[2,12],"66":[14,14],"67":[14,14],"68":[2,12],"69":[0,2],"70":[0,6],"71":[14,0],"72":[6,6],"73":[1,0],"74":[1,0],"75":[0,3],"76":[1,2],"77":[0,1],"78":[1,0],"79":[0,1],"80":[189,4],"81":[1,49],"82":[4,22]},"_coverageSchema":"43e27e138ebf9cfc5966b082cf9a028302ed4184","hash":"0fab12664e05a8795d878628bfefbe47ae1ff8a2","contentHash":"b2660bc8a4f4ceab6f8b35c2aeb0779bd786bd1c33fe8f4bb002d3c9cfce533a"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"uuid":"54ec436a-390d-4669-925d-0377ac7ed81b","parent":null,"pid":5631,"argv":["/home/andrewosh/.nvm/versions/node/v10.15.3/bin/node","/home/andrewosh/.nvm/versions/node/v10.15.3/bin/tape","test/all.js"],"execArgv":[],"cwd":"/home/andrewosh/Development/corestore","time":1568281258781,"ppid":5624,"root":"8c35dffb-372c-452b-a42f-204bb4ad5916","coverageFilename":"/home/andrewosh/Development/corestore/.nyc_output/54ec436a-390d-4669-925d-0377ac7ed81b.json","files":["/home/andrewosh/Development/corestore/index.js"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"processes":{"54ec436a-390d-4669-925d-0377ac7ed81b":{"parent":null,"children":[]}},"files":{"/home/andrewosh/Development/corestore/index.js":["54ec436a-390d-4669-925d-0377ac7ed81b"]},"externalIds":{}}
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Corestore
|
|
1
|
+
# Corestore
|
|
2
2
|
|
|
3
3
|
Corestore is a Hypercore factory that makes it easier to manage large collections of named Hypercores.
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ Corestore provides:
|
|
|
9
9
|
4. __Namespacing__ - You can share a single Corestore instance between multiple applications or components without worrying about naming collisions by creating "namespaces" (e.g. `corestore.namespace('my-app').get({ name: 'main' })
|
|
10
10
|
|
|
11
11
|
### Installation
|
|
12
|
-
`npm install corestore
|
|
12
|
+
`npm install corestore`
|
|
13
13
|
|
|
14
14
|
### Usage
|
|
15
15
|
A corestore instance can be constructed with a random-access-storage module, a function that returns a random-access-storage module given a path, or a string. If a string is specified, it will be assumed to be a path to a local storage directory:
|
|
@@ -34,14 +34,26 @@ If that Hypercore has previously been loaded, subsequent calls to `get` will ret
|
|
|
34
34
|
|
|
35
35
|
All other options besides `name` and `key` will be forwarded to the Hypercore constructor.
|
|
36
36
|
|
|
37
|
-
#### `const stream = store.replicate(
|
|
37
|
+
#### `const stream = store.replicate(optsOrStream)`
|
|
38
38
|
Creates a replication stream that's capable of replicating all Hypercores that are managed by the Corestore, assuming the remote peer has the correct capabilities.
|
|
39
39
|
|
|
40
40
|
`opts` will be forwarded to Hypercore's `replicate` function.
|
|
41
41
|
|
|
42
42
|
Corestore replicates in an "all-to-all" fashion, meaning that when replication begins, it will attempt to replicate every Hypercore that's currently loaded and in memory. These attempts will fail if the remote side doesn't have a Hypercore's capability -- Corestore replication does not exchange Hypercore keys.
|
|
43
43
|
|
|
44
|
-
If the remote side dynamically adds a new Hypercore to the replication stream, Corestore will load and
|
|
44
|
+
If the remote side dynamically adds a new Hypercore to the replication stream, Corestore will load and replicate that core if possible.
|
|
45
|
+
|
|
46
|
+
Using [Hyperswarm](https://github.com/hyperswarm/hyperswarm) you can easily replicate corestores
|
|
47
|
+
|
|
48
|
+
``` js
|
|
49
|
+
const swarm = new Hyperswarm()
|
|
50
|
+
|
|
51
|
+
// join the relevant topic
|
|
52
|
+
swarm.join(...)
|
|
53
|
+
|
|
54
|
+
// simply pass the connection stream to corestore
|
|
55
|
+
swarm.on('connection', (connection) => store.replicate(connection))
|
|
56
|
+
```
|
|
45
57
|
|
|
46
58
|
#### `const store = store.namespace(name)`
|
|
47
59
|
Create a new namespaced Corestore. Namespacing is useful if you're going to be sharing a single Corestore instance between many applications or components, as it prevents name collisions.
|
package/index.js
CHANGED
|
@@ -3,45 +3,102 @@ const safetyCatch = require('safety-catch')
|
|
|
3
3
|
const crypto = require('hypercore-crypto')
|
|
4
4
|
const sodium = require('sodium-universal')
|
|
5
5
|
const Hypercore = require('hypercore')
|
|
6
|
+
const Xache = require('xache')
|
|
7
|
+
const b4a = require('b4a')
|
|
6
8
|
|
|
7
|
-
const
|
|
9
|
+
const [NS] = crypto.namespace('corestore', 1)
|
|
10
|
+
const DEFAULT_NAMESPACE = b4a.alloc(32) // This is meant to be 32 0-bytes
|
|
8
11
|
|
|
9
12
|
const CORES_DIR = 'cores'
|
|
10
|
-
const
|
|
11
|
-
const USERDATA_NAME_KEY = '
|
|
12
|
-
const USERDATA_NAMESPACE_KEY = '
|
|
13
|
-
const DEFAULT_NAMESPACE = generateNamespace('@corestore/default')
|
|
13
|
+
const PRIMARY_KEY_FILE_NAME = 'primary-key'
|
|
14
|
+
const USERDATA_NAME_KEY = 'corestore/name'
|
|
15
|
+
const USERDATA_NAMESPACE_KEY = 'corestore/namespace'
|
|
14
16
|
|
|
15
17
|
module.exports = class Corestore extends EventEmitter {
|
|
16
18
|
constructor (storage, opts = {}) {
|
|
17
19
|
super()
|
|
18
20
|
|
|
19
|
-
this.storage = Hypercore.defaultStorage(storage, { lock:
|
|
20
|
-
|
|
21
|
+
this.storage = Hypercore.defaultStorage(storage, { lock: PRIMARY_KEY_FILE_NAME })
|
|
21
22
|
this.cores = opts._cores || new Map()
|
|
22
|
-
this.
|
|
23
|
+
this.primaryKey = null
|
|
24
|
+
this.cache = !!opts.cache
|
|
23
25
|
|
|
24
|
-
this.
|
|
26
|
+
this._keyStorage = null
|
|
27
|
+
this._primaryKey = opts.primaryKey
|
|
28
|
+
this._namespace = opts.namespace || DEFAULT_NAMESPACE
|
|
25
29
|
this._replicationStreams = opts._streams || []
|
|
30
|
+
this._overwrite = opts.overwrite === true
|
|
31
|
+
|
|
32
|
+
this._streamSessions = opts._streamSessions || new Map()
|
|
33
|
+
this._sessions = new Set() // sessions for THIS namespace
|
|
34
|
+
|
|
35
|
+
this._findingPeersCount = 0
|
|
36
|
+
this._findingPeers = []
|
|
37
|
+
|
|
38
|
+
if (this._namespace.byteLength !== 32) throw new Error('Namespace must be a 32-byte Buffer or Uint8Array')
|
|
26
39
|
|
|
27
40
|
this._opening = opts._opening ? opts._opening.then(() => this._open()) : this._open()
|
|
28
|
-
this._opening.catch(
|
|
41
|
+
this._opening.catch(safetyCatch)
|
|
29
42
|
this.ready = () => this._opening
|
|
30
43
|
}
|
|
31
44
|
|
|
45
|
+
findingPeers () {
|
|
46
|
+
let done = false
|
|
47
|
+
this._incFindingPeers()
|
|
48
|
+
|
|
49
|
+
return () => {
|
|
50
|
+
if (done) return
|
|
51
|
+
done = true
|
|
52
|
+
this._decFindingPeers()
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
_incFindingPeers () {
|
|
57
|
+
if (++this._findingPeersCount !== 1) return
|
|
58
|
+
|
|
59
|
+
for (const core of this._sessions) {
|
|
60
|
+
this._findingPeers.push(core.findingPeers())
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
_decFindingPeers () {
|
|
65
|
+
if (--this._findingPeersCount !== 0) return
|
|
66
|
+
|
|
67
|
+
while (this._findingPeers.length > 0) {
|
|
68
|
+
this._findingPeers.pop()()
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
32
72
|
async _open () {
|
|
33
|
-
if (this.
|
|
34
|
-
this.
|
|
35
|
-
|
|
36
|
-
this.keys = await KeyManager.fromStorage(p => this.storage(PROFILES_DIR + '/' + p))
|
|
73
|
+
if (this._primaryKey) {
|
|
74
|
+
this.primaryKey = await this._primaryKey
|
|
75
|
+
return this.primaryKey
|
|
37
76
|
}
|
|
77
|
+
this._keyStorage = this.storage(PRIMARY_KEY_FILE_NAME)
|
|
78
|
+
this.primaryKey = await new Promise((resolve, reject) => {
|
|
79
|
+
this._keyStorage.stat((err, st) => {
|
|
80
|
+
if (err && err.code !== 'ENOENT') return reject(err)
|
|
81
|
+
if (err || st.size < 32 || this._overwrite) {
|
|
82
|
+
const key = crypto.randomBytes(32)
|
|
83
|
+
return this._keyStorage.write(0, key, err => {
|
|
84
|
+
if (err) return reject(err)
|
|
85
|
+
return resolve(key)
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
this._keyStorage.read(0, 32, (err, key) => {
|
|
89
|
+
if (err) return reject(err)
|
|
90
|
+
return resolve(key)
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
return this.primaryKey
|
|
38
95
|
}
|
|
39
96
|
|
|
40
97
|
async _generateKeys (opts) {
|
|
41
98
|
if (opts._discoveryKey) {
|
|
42
99
|
return {
|
|
43
100
|
keyPair: null,
|
|
44
|
-
|
|
101
|
+
auth: null,
|
|
45
102
|
discoveryKey: opts._discoveryKey
|
|
46
103
|
}
|
|
47
104
|
}
|
|
@@ -52,21 +109,23 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
52
109
|
secretKey: opts.secretKey
|
|
53
110
|
},
|
|
54
111
|
sign: opts.sign,
|
|
112
|
+
auth: opts.auth,
|
|
55
113
|
discoveryKey: crypto.discoveryKey(opts.publicKey)
|
|
56
114
|
}
|
|
57
115
|
}
|
|
58
|
-
const { publicKey,
|
|
116
|
+
const { publicKey, auth } = await this.createKeyPair(opts.name)
|
|
59
117
|
return {
|
|
60
118
|
keyPair: {
|
|
61
119
|
publicKey,
|
|
62
120
|
secretKey: null
|
|
63
121
|
},
|
|
64
|
-
|
|
122
|
+
auth,
|
|
65
123
|
discoveryKey: crypto.discoveryKey(publicKey)
|
|
66
124
|
}
|
|
67
125
|
}
|
|
68
126
|
|
|
69
127
|
_getPrereadyUserData (core, key) {
|
|
128
|
+
// Need to manually read the header values before the Hypercore is ready, hence the ugliness.
|
|
70
129
|
for (const { key: savedKey, value } of core.core.header.userData) {
|
|
71
130
|
if (key === savedKey) return value
|
|
72
131
|
}
|
|
@@ -78,11 +137,11 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
78
137
|
if (!name) return
|
|
79
138
|
|
|
80
139
|
const namespace = this._getPrereadyUserData(core, USERDATA_NAMESPACE_KEY)
|
|
81
|
-
const { publicKey,
|
|
82
|
-
if (!
|
|
140
|
+
const { publicKey, auth } = await this.createKeyPair(b4a.toString(name), namespace)
|
|
141
|
+
if (!b4a.equals(publicKey, core.key)) throw new Error('Stored core key does not match the provided name')
|
|
83
142
|
|
|
84
|
-
// TODO: Should Hypercore expose a helper for this, or should preready return keypair/
|
|
85
|
-
core.
|
|
143
|
+
// TODO: Should Hypercore expose a helper for this, or should preready return keypair/auth?
|
|
144
|
+
core.auth = auth
|
|
86
145
|
core.key = publicKey
|
|
87
146
|
core.writable = true
|
|
88
147
|
}
|
|
@@ -90,22 +149,22 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
90
149
|
async _preload (opts) {
|
|
91
150
|
await this.ready()
|
|
92
151
|
|
|
93
|
-
const { discoveryKey, keyPair,
|
|
94
|
-
const id =
|
|
152
|
+
const { discoveryKey, keyPair, auth } = await this._generateKeys(opts)
|
|
153
|
+
const id = b4a.toString(discoveryKey, 'hex')
|
|
95
154
|
|
|
96
155
|
while (this.cores.has(id)) {
|
|
97
156
|
const existing = this.cores.get(id)
|
|
98
|
-
if (existing.opened && !existing.closing) return { from: existing, keyPair,
|
|
99
|
-
if (
|
|
100
|
-
await existing.ready().catch(safetyCatch)
|
|
101
|
-
} else if (existing.closing) {
|
|
157
|
+
if (existing.opened && !existing.closing) return { from: existing, keyPair, auth }
|
|
158
|
+
if (existing.closing) {
|
|
102
159
|
await existing.close()
|
|
160
|
+
} else {
|
|
161
|
+
await existing.ready().catch(safetyCatch)
|
|
103
162
|
}
|
|
104
163
|
}
|
|
105
164
|
|
|
106
165
|
const userData = {}
|
|
107
166
|
if (opts.name) {
|
|
108
|
-
userData[USERDATA_NAME_KEY] =
|
|
167
|
+
userData[USERDATA_NAME_KEY] = b4a.from(opts.name)
|
|
109
168
|
userData[USERDATA_NAMESPACE_KEY] = this._namespace
|
|
110
169
|
}
|
|
111
170
|
|
|
@@ -117,8 +176,9 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
117
176
|
autoClose: true,
|
|
118
177
|
encryptionKey: opts.encryptionKey || null,
|
|
119
178
|
userData,
|
|
120
|
-
|
|
121
|
-
|
|
179
|
+
auth,
|
|
180
|
+
cache: opts.cache,
|
|
181
|
+
createIfMissing: opts.createIfMissing === false ? false : !opts._discoveryKey,
|
|
122
182
|
keyPair: keyPair && keyPair.publicKey
|
|
123
183
|
? {
|
|
124
184
|
publicKey: keyPair.publicKey,
|
|
@@ -130,6 +190,9 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
130
190
|
this.cores.set(id, core)
|
|
131
191
|
core.ready().then(() => {
|
|
132
192
|
for (const { stream } of this._replicationStreams) {
|
|
193
|
+
const sessions = this._streamSessions.get(stream)
|
|
194
|
+
const session = core.session()
|
|
195
|
+
sessions.push(session)
|
|
133
196
|
core.replicate(stream)
|
|
134
197
|
}
|
|
135
198
|
}, () => {
|
|
@@ -139,16 +202,54 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
139
202
|
this.cores.delete(id)
|
|
140
203
|
})
|
|
141
204
|
|
|
142
|
-
return { from: core, keyPair,
|
|
205
|
+
return { from: core, keyPair, auth }
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
async createKeyPair (name, namespace = this._namespace) {
|
|
209
|
+
if (!this.primaryKey) await this._opening
|
|
210
|
+
|
|
211
|
+
const keyPair = {
|
|
212
|
+
publicKey: b4a.allocUnsafe(sodium.crypto_sign_PUBLICKEYBYTES),
|
|
213
|
+
secretKey: b4a.alloc(sodium.crypto_sign_SECRETKEYBYTES),
|
|
214
|
+
auth: {
|
|
215
|
+
sign: (msg) => sign(keyPair, msg),
|
|
216
|
+
verify: (signable, signature) => {
|
|
217
|
+
return crypto.verify(signable, signature, keyPair.publicKey)
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const seed = deriveSeed(this.primaryKey, namespace, name)
|
|
223
|
+
sodium.crypto_sign_seed_keypair(keyPair.publicKey, keyPair.secretKey, seed)
|
|
224
|
+
|
|
225
|
+
return keyPair
|
|
143
226
|
}
|
|
144
227
|
|
|
145
228
|
get (opts = {}) {
|
|
146
229
|
opts = validateGetOptions(opts)
|
|
230
|
+
|
|
231
|
+
if (opts.cache !== false) {
|
|
232
|
+
opts.cache = opts.cache === true || (this.cache && !opts.cache) ? defaultCache() : opts.cache
|
|
233
|
+
}
|
|
234
|
+
|
|
147
235
|
const core = new Hypercore(null, {
|
|
148
236
|
...opts,
|
|
149
237
|
name: null,
|
|
150
238
|
preload: () => this._preload(opts)
|
|
151
239
|
})
|
|
240
|
+
|
|
241
|
+
this._sessions.add(core)
|
|
242
|
+
if (this._findingPeersCount > 0) {
|
|
243
|
+
this._findingPeers.push(core.findingPeers())
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
core.once('close', () => {
|
|
247
|
+
// technically better to also clear _findingPeers if we added it,
|
|
248
|
+
// but the lifecycle for those are pretty short so prob not worth the complexity
|
|
249
|
+
// as _decFindingPeers clear them all.
|
|
250
|
+
this._sessions.delete(core)
|
|
251
|
+
})
|
|
252
|
+
|
|
152
253
|
return core
|
|
153
254
|
}
|
|
154
255
|
|
|
@@ -161,31 +262,46 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
161
262
|
return core.ready().catch(safetyCatch)
|
|
162
263
|
}
|
|
163
264
|
})
|
|
265
|
+
|
|
266
|
+
const sessions = []
|
|
164
267
|
for (const core of this.cores.values()) {
|
|
165
|
-
if (core.opened)
|
|
268
|
+
if (!core.opened) continue // If the core is not opened, it will be replicated in preload.
|
|
269
|
+
const session = core.session()
|
|
270
|
+
sessions.push(session)
|
|
271
|
+
core.replicate(stream)
|
|
166
272
|
}
|
|
273
|
+
|
|
167
274
|
const streamRecord = { stream, isExternal }
|
|
168
275
|
this._replicationStreams.push(streamRecord)
|
|
276
|
+
this._streamSessions.set(stream, sessions)
|
|
277
|
+
|
|
169
278
|
stream.once('close', () => {
|
|
170
279
|
this._replicationStreams.splice(this._replicationStreams.indexOf(streamRecord), 1)
|
|
280
|
+
this._streamSessions.delete(stream)
|
|
281
|
+
Promise.all(sessions.map(s => s.close())).catch(safetyCatch)
|
|
171
282
|
})
|
|
172
283
|
return stream
|
|
173
284
|
}
|
|
174
285
|
|
|
175
286
|
namespace (name) {
|
|
176
|
-
if (!Buffer.isBuffer(name)) name = Buffer.from(name)
|
|
177
287
|
return new Corestore(this.storage, {
|
|
178
|
-
|
|
288
|
+
primaryKey: this._opening.then(() => this.primaryKey),
|
|
289
|
+
namespace: generateNamespace(this._namespace, name),
|
|
290
|
+
cache: this.cache,
|
|
179
291
|
_opening: this._opening,
|
|
180
292
|
_cores: this.cores,
|
|
181
293
|
_streams: this._replicationStreams,
|
|
182
|
-
|
|
294
|
+
_streamSessions: this._streamSessions
|
|
183
295
|
})
|
|
184
296
|
}
|
|
185
297
|
|
|
186
298
|
async _close () {
|
|
187
|
-
if (this._closing) return this._closing
|
|
188
299
|
await this._opening
|
|
300
|
+
if (!b4a.equals(this._namespace, DEFAULT_NAMESPACE)) {
|
|
301
|
+
// namespaces should not release resources on close
|
|
302
|
+
// TODO: Refactor the namespace close logic to actually close sessions with ref counting
|
|
303
|
+
return
|
|
304
|
+
}
|
|
189
305
|
const closePromises = []
|
|
190
306
|
for (const core of this.cores.values()) {
|
|
191
307
|
closePromises.push(core.close())
|
|
@@ -195,23 +311,30 @@ module.exports = class Corestore extends EventEmitter {
|
|
|
195
311
|
// Only close streams that were created by the Corestore
|
|
196
312
|
if (!isExternal) stream.destroy()
|
|
197
313
|
}
|
|
198
|
-
|
|
314
|
+
if (!this._keyStorage) return
|
|
315
|
+
await new Promise((resolve, reject) => {
|
|
316
|
+
this._keyStorage.close(err => {
|
|
317
|
+
if (err) return reject(err)
|
|
318
|
+
return resolve(null)
|
|
319
|
+
})
|
|
320
|
+
})
|
|
199
321
|
}
|
|
200
322
|
|
|
201
323
|
close () {
|
|
202
324
|
if (this._closing) return this._closing
|
|
203
325
|
this._closing = this._close()
|
|
204
|
-
this._closing.catch(
|
|
326
|
+
this._closing.catch(safetyCatch)
|
|
205
327
|
return this._closing
|
|
206
328
|
}
|
|
329
|
+
}
|
|
207
330
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
331
|
+
function sign (keyPair, message) {
|
|
332
|
+
if (!keyPair.secretKey) throw new Error('Invalid key pair')
|
|
333
|
+
return crypto.sign(message, keyPair.secretKey)
|
|
211
334
|
}
|
|
212
335
|
|
|
213
336
|
function validateGetOptions (opts) {
|
|
214
|
-
if (
|
|
337
|
+
if (b4a.isBuffer(opts)) return { key: opts, publicKey: opts }
|
|
215
338
|
if (opts.key) {
|
|
216
339
|
opts.publicKey = opts.key
|
|
217
340
|
}
|
|
@@ -221,22 +344,30 @@ function validateGetOptions (opts) {
|
|
|
221
344
|
}
|
|
222
345
|
if (opts.name && typeof opts.name !== 'string') throw new Error('name option must be a String')
|
|
223
346
|
if (opts.name && opts.secretKey) throw new Error('Cannot provide both a name and a secret key')
|
|
224
|
-
if (opts.publicKey && !
|
|
225
|
-
if (opts.secretKey && !
|
|
347
|
+
if (opts.publicKey && !b4a.isBuffer(opts.publicKey)) throw new Error('publicKey option must be a Buffer or Uint8Array')
|
|
348
|
+
if (opts.secretKey && !b4a.isBuffer(opts.secretKey)) throw new Error('secretKey option must be a Buffer or Uint8Array')
|
|
226
349
|
if (!opts._discoveryKey && (!opts.name && !opts.publicKey)) throw new Error('Must provide either a name or a publicKey')
|
|
227
350
|
return opts
|
|
228
351
|
}
|
|
229
352
|
|
|
230
|
-
function generateNamespace (
|
|
231
|
-
if (!
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
sodium.crypto_generichash(out, second ? Buffer.concat([first, second]) : first)
|
|
353
|
+
function generateNamespace (namespace, name) {
|
|
354
|
+
if (!b4a.isBuffer(name)) name = b4a.from(name)
|
|
355
|
+
const out = b4a.allocUnsafe(32)
|
|
356
|
+
sodium.crypto_generichash_batch(out, [namespace, name])
|
|
235
357
|
return out
|
|
236
358
|
}
|
|
237
359
|
|
|
360
|
+
function deriveSeed (primaryKey, namespace, name) {
|
|
361
|
+
if (!b4a.isBuffer(name)) name = b4a.from(name)
|
|
362
|
+
const out = b4a.alloc(32)
|
|
363
|
+
sodium.crypto_generichash_batch(out, [NS, namespace, name], primaryKey)
|
|
364
|
+
return out
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function defaultCache () {
|
|
368
|
+
return new Xache({ maxSize: 65536, maxAge: 0 })
|
|
369
|
+
}
|
|
370
|
+
|
|
238
371
|
function isStream (s) {
|
|
239
372
|
return typeof s === 'object' && s && typeof s.pipe === 'function'
|
|
240
373
|
}
|
|
241
|
-
|
|
242
|
-
function noop () {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "corestore",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.4",
|
|
4
4
|
"description": "A Hypercore factory that simplifies managing collections of cores.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,18 +20,16 @@
|
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://github.com/hypercore-protocol/corestore#readme",
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"brittle": "^
|
|
24
|
-
"random-access-
|
|
25
|
-
"
|
|
26
|
-
"standardx": "^7.0.0",
|
|
27
|
-
"tmp-promise": "^3.0.2"
|
|
23
|
+
"brittle": "^3.0.0",
|
|
24
|
+
"random-access-memory": "^5.0.1",
|
|
25
|
+
"standardx": "^7.0.0"
|
|
28
26
|
},
|
|
29
27
|
"dependencies": {
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"hypercore": "
|
|
33
|
-
"hypercore-crypto": "^2.3.0",
|
|
28
|
+
"b4a": "^1.3.1",
|
|
29
|
+
"hypercore": "^10.2.0",
|
|
30
|
+
"hypercore-crypto": "^3.2.1",
|
|
34
31
|
"safety-catch": "^1.0.1",
|
|
35
|
-
"sodium-universal": "^3.0.4"
|
|
32
|
+
"sodium-universal": "^3.0.4",
|
|
33
|
+
"xache": "^1.1.0"
|
|
36
34
|
}
|
|
37
35
|
}
|
package/test/all.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
const test = require('brittle')
|
|
2
2
|
const crypto = require('hypercore-crypto')
|
|
3
3
|
const ram = require('random-access-memory')
|
|
4
|
-
const
|
|
4
|
+
const os = require('os')
|
|
5
|
+
const path = require('path')
|
|
6
|
+
const b4a = require('b4a')
|
|
7
|
+
const sodium = require('sodium-universal')
|
|
5
8
|
|
|
6
9
|
const Corestore = require('..')
|
|
7
10
|
|
|
@@ -37,6 +40,24 @@ test('basic get with custom keypair', async function (t) {
|
|
|
37
40
|
t.ok(core2.writable)
|
|
38
41
|
})
|
|
39
42
|
|
|
43
|
+
test('get with createIfMissing=false throws if new core', async function (t) {
|
|
44
|
+
const store = new Corestore(ram)
|
|
45
|
+
const core1a = store.get({ name: 'core-1', createIfMissing: false })
|
|
46
|
+
|
|
47
|
+
await t.exception(core1a.ready(), 'No Hypercore is stored here')
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
test('get with createIfMissing=false works if no new core', async function (t) {
|
|
51
|
+
const store = new Corestore(ram)
|
|
52
|
+
const name = 'core-1'
|
|
53
|
+
|
|
54
|
+
const core1 = store.get({ name })
|
|
55
|
+
await core1.ready()
|
|
56
|
+
|
|
57
|
+
const core1Too = store.get({ name, createIfMissing: false })
|
|
58
|
+
await t.execution(core1Too.ready())
|
|
59
|
+
})
|
|
60
|
+
|
|
40
61
|
test('basic namespaces', async function (t) {
|
|
41
62
|
const store = new Corestore(ram)
|
|
42
63
|
const ns1 = store.namespace('ns1')
|
|
@@ -97,8 +118,8 @@ test('replicating cores created after replication begins', async function (t) {
|
|
|
97
118
|
})
|
|
98
119
|
|
|
99
120
|
test('replicating cores using discovery key hook', async function (t) {
|
|
100
|
-
const dir =
|
|
101
|
-
let store1 = new Corestore(dir
|
|
121
|
+
const dir = tmpdir()
|
|
122
|
+
let store1 = new Corestore(dir)
|
|
102
123
|
const store2 = new Corestore(ram)
|
|
103
124
|
|
|
104
125
|
const core = store1.get({ name: 'main' })
|
|
@@ -106,15 +127,13 @@ test('replicating cores using discovery key hook', async function (t) {
|
|
|
106
127
|
const key = core.key
|
|
107
128
|
|
|
108
129
|
await store1.close()
|
|
109
|
-
store1 = new Corestore(dir
|
|
130
|
+
store1 = new Corestore(dir)
|
|
110
131
|
|
|
111
132
|
const s = store1.replicate(true, { live: true })
|
|
112
133
|
s.pipe(store2.replicate(false, { live: true })).pipe(s)
|
|
113
134
|
|
|
114
135
|
const core2 = store2.get(key)
|
|
115
136
|
t.alike(await core2.get(0), Buffer.from('hello'))
|
|
116
|
-
|
|
117
|
-
await dir.cleanup()
|
|
118
137
|
})
|
|
119
138
|
|
|
120
139
|
test('nested namespaces', async function (t) {
|
|
@@ -142,9 +161,9 @@ test('core uncached when all sessions close', async function (t) {
|
|
|
142
161
|
})
|
|
143
162
|
|
|
144
163
|
test('writable core loaded from name userData', async function (t) {
|
|
145
|
-
const dir =
|
|
164
|
+
const dir = tmpdir()
|
|
146
165
|
|
|
147
|
-
let store = new Corestore(dir
|
|
166
|
+
let store = new Corestore(dir)
|
|
148
167
|
let core = store.get({ name: 'main' })
|
|
149
168
|
await core.ready()
|
|
150
169
|
const key = core.key
|
|
@@ -154,7 +173,7 @@ test('writable core loaded from name userData', async function (t) {
|
|
|
154
173
|
t.is(core.length, 1)
|
|
155
174
|
|
|
156
175
|
await store.close()
|
|
157
|
-
store = new Corestore(dir
|
|
176
|
+
store = new Corestore(dir)
|
|
158
177
|
core = store.get(key)
|
|
159
178
|
await core.ready()
|
|
160
179
|
|
|
@@ -163,23 +182,171 @@ test('writable core loaded from name userData', async function (t) {
|
|
|
163
182
|
t.is(core.length, 2)
|
|
164
183
|
t.alike(await core.get(0), Buffer.from('hello'))
|
|
165
184
|
t.alike(await core.get(1), Buffer.from('world'))
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
test('writable core loaded from name and namespace userData', async function (t) {
|
|
188
|
+
const dir = tmpdir()
|
|
189
|
+
|
|
190
|
+
let store = new Corestore(dir)
|
|
191
|
+
let core = store.namespace('ns1').get({ name: 'main' })
|
|
192
|
+
await core.ready()
|
|
193
|
+
const key = core.key
|
|
194
|
+
|
|
195
|
+
t.ok(core.writable)
|
|
196
|
+
await core.append('hello')
|
|
197
|
+
t.is(core.length, 1)
|
|
198
|
+
|
|
199
|
+
await store.close()
|
|
200
|
+
store = new Corestore(dir)
|
|
201
|
+
core = store.get(key)
|
|
202
|
+
await core.ready()
|
|
166
203
|
|
|
167
|
-
|
|
204
|
+
t.ok(core.writable)
|
|
205
|
+
await core.append('world')
|
|
206
|
+
t.is(core.length, 2)
|
|
207
|
+
t.alike(await core.get(0), Buffer.from('hello'))
|
|
208
|
+
t.alike(await core.get(1), Buffer.from('world'))
|
|
168
209
|
})
|
|
169
210
|
|
|
170
211
|
test('storage locking', async function (t) {
|
|
171
|
-
const dir =
|
|
212
|
+
const dir = tmpdir()
|
|
172
213
|
|
|
173
|
-
const store1 = new Corestore(dir
|
|
214
|
+
const store1 = new Corestore(dir)
|
|
174
215
|
await store1.ready()
|
|
175
216
|
|
|
176
|
-
const store2 = new Corestore(dir
|
|
217
|
+
const store2 = new Corestore(dir)
|
|
177
218
|
try {
|
|
178
219
|
await store2.ready()
|
|
179
220
|
t.fail('dir should have been locked')
|
|
180
221
|
} catch {
|
|
181
222
|
t.pass('dir was locked')
|
|
182
223
|
}
|
|
224
|
+
})
|
|
183
225
|
|
|
184
|
-
|
|
226
|
+
test('closing a namespace does not close cores', async function (t) {
|
|
227
|
+
const store = new Corestore(ram)
|
|
228
|
+
const ns1 = store.namespace('ns1')
|
|
229
|
+
const core1 = ns1.get({ name: 'core-1' })
|
|
230
|
+
const core2 = ns1.get({ name: 'core-2' })
|
|
231
|
+
await Promise.all([core1.ready(), core2.ready()])
|
|
232
|
+
|
|
233
|
+
await ns1.close()
|
|
234
|
+
|
|
235
|
+
t.is(store.cores.size, 2)
|
|
236
|
+
t.not(core1.closed)
|
|
237
|
+
t.not(core1.closed)
|
|
238
|
+
|
|
239
|
+
await store.close()
|
|
240
|
+
|
|
241
|
+
t.is(store.cores.size, 0)
|
|
242
|
+
t.ok(core1.closed)
|
|
243
|
+
t.ok(core2.closed)
|
|
185
244
|
})
|
|
245
|
+
|
|
246
|
+
test('findingPeers', async function (t) {
|
|
247
|
+
t.plan(6)
|
|
248
|
+
|
|
249
|
+
const store = new Corestore(ram)
|
|
250
|
+
|
|
251
|
+
const ns1 = store.namespace('ns1')
|
|
252
|
+
const ns2 = store.namespace('ns2')
|
|
253
|
+
|
|
254
|
+
const a = ns1.get(Buffer.alloc(32).fill('a'))
|
|
255
|
+
const b = ns2.get(Buffer.alloc(32).fill('b'))
|
|
256
|
+
|
|
257
|
+
const done = ns1.findingPeers()
|
|
258
|
+
|
|
259
|
+
let aUpdated = false
|
|
260
|
+
let bUpdated = false
|
|
261
|
+
let cUpdated = false
|
|
262
|
+
|
|
263
|
+
const c = ns1.get(Buffer.alloc(32).fill('c'))
|
|
264
|
+
|
|
265
|
+
a.update().then(function (bool) {
|
|
266
|
+
aUpdated = true
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
b.update().then(function (bool) {
|
|
270
|
+
bUpdated = true
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
c.update().then(function (bool) {
|
|
274
|
+
cUpdated = true
|
|
275
|
+
})
|
|
276
|
+
|
|
277
|
+
await new Promise(resolve => setImmediate(resolve))
|
|
278
|
+
|
|
279
|
+
t.is(aUpdated, false)
|
|
280
|
+
t.is(bUpdated, true)
|
|
281
|
+
t.is(cUpdated, false)
|
|
282
|
+
|
|
283
|
+
done()
|
|
284
|
+
|
|
285
|
+
await new Promise(resolve => setImmediate(resolve))
|
|
286
|
+
|
|
287
|
+
t.is(aUpdated, true)
|
|
288
|
+
t.is(bUpdated, true)
|
|
289
|
+
t.is(cUpdated, true)
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
test('different primary keys yield different keypairs', async function (t) {
|
|
293
|
+
const pk1 = randomBytes(32)
|
|
294
|
+
const pk2 = randomBytes(32)
|
|
295
|
+
t.unlike(pk1, pk2)
|
|
296
|
+
|
|
297
|
+
const store1 = new Corestore(ram, { primaryKey: pk1 })
|
|
298
|
+
const store2 = new Corestore(ram, { primaryKey: pk2 })
|
|
299
|
+
|
|
300
|
+
const kp1 = await store1.createKeyPair('hello')
|
|
301
|
+
const kp2 = await store2.createKeyPair('hello')
|
|
302
|
+
|
|
303
|
+
t.unlike(kp1.publicKey, kp2.publicKey)
|
|
304
|
+
})
|
|
305
|
+
|
|
306
|
+
test('keypair auth sign', async function (t) {
|
|
307
|
+
const store = new Corestore(ram)
|
|
308
|
+
const keyPair = await store.createKeyPair('foo')
|
|
309
|
+
const message = b4a.from('hello world')
|
|
310
|
+
|
|
311
|
+
const sig = keyPair.auth.sign(message)
|
|
312
|
+
|
|
313
|
+
t.is(sig.length, 64)
|
|
314
|
+
t.ok(crypto.verify(message, sig, keyPair.publicKey))
|
|
315
|
+
t.absent(crypto.verify(message, b4a.alloc(64), keyPair.publicKey))
|
|
316
|
+
})
|
|
317
|
+
|
|
318
|
+
test('keypair auth verify', async function (t) {
|
|
319
|
+
const store = new Corestore(ram)
|
|
320
|
+
const keyPair = await store.createKeyPair('foo')
|
|
321
|
+
const message = b4a.from('hello world')
|
|
322
|
+
|
|
323
|
+
const sig = crypto.sign(message, keyPair.secretKey)
|
|
324
|
+
|
|
325
|
+
t.is(sig.length, 64)
|
|
326
|
+
t.ok(keyPair.auth.verify(message, sig))
|
|
327
|
+
t.absent(keyPair.auth.verify(message, b4a.alloc(64)))
|
|
328
|
+
})
|
|
329
|
+
|
|
330
|
+
test('core caching after reopen regression', async function (t) {
|
|
331
|
+
const store = new Corestore(ram)
|
|
332
|
+
const core = store.get({ name: 'test-core' })
|
|
333
|
+
await core.ready()
|
|
334
|
+
|
|
335
|
+
core.close()
|
|
336
|
+
await core.opening
|
|
337
|
+
|
|
338
|
+
const core2 = store.get({ name: 'test-core' })
|
|
339
|
+
await core2.ready()
|
|
340
|
+
|
|
341
|
+
t.pass('did not infinite loop')
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
function tmpdir () {
|
|
345
|
+
return path.join(os.tmpdir(), 'corestore-' + Math.random().toString(16).slice(2))
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function randomBytes (n) {
|
|
349
|
+
const buf = b4a.allocUnsafe(n)
|
|
350
|
+
sodium.randombytes_buf(buf)
|
|
351
|
+
return buf
|
|
352
|
+
}
|
package/test/cache.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const test = require('brittle')
|
|
2
|
+
const RAM = require('random-access-memory')
|
|
3
|
+
|
|
4
|
+
const Corestore = require('..')
|
|
5
|
+
|
|
6
|
+
test('core cache', async function (t) {
|
|
7
|
+
const store = new Corestore(RAM, { cache: true })
|
|
8
|
+
|
|
9
|
+
const core = store.get({ name: 'core' })
|
|
10
|
+
await core.append(['a', 'b', 'c'])
|
|
11
|
+
|
|
12
|
+
const p = core.get(0)
|
|
13
|
+
const q = core.get(0)
|
|
14
|
+
|
|
15
|
+
t.is(await p, await q)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
test('clear cache on truncate', async function (t) {
|
|
19
|
+
const store = new Corestore(RAM, { cache: true })
|
|
20
|
+
|
|
21
|
+
const core = store.get({ name: 'core' })
|
|
22
|
+
await core.append(['a', 'b', 'c'])
|
|
23
|
+
|
|
24
|
+
const p = core.get(0)
|
|
25
|
+
|
|
26
|
+
await core.truncate(0)
|
|
27
|
+
await core.append('d')
|
|
28
|
+
|
|
29
|
+
const q = core.get(0)
|
|
30
|
+
|
|
31
|
+
t.alike(await p, Buffer.from('a'))
|
|
32
|
+
t.alike(await q, Buffer.from('d'))
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
test('core cache on namespace', async function (t) {
|
|
36
|
+
const store = new Corestore(RAM, { cache: true })
|
|
37
|
+
const ns1 = store.namespace('test-namespace-1')
|
|
38
|
+
|
|
39
|
+
const c1 = store.get({ name: 'test-core' })
|
|
40
|
+
const c2 = ns1.get({ name: 'test-core' })
|
|
41
|
+
|
|
42
|
+
await Promise.all([c1.ready(), c2.ready()])
|
|
43
|
+
|
|
44
|
+
t.ok(c1.cache)
|
|
45
|
+
t.ok(c2.cache)
|
|
46
|
+
})
|
package/lib/keys.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
// TODO: Extract this into a standalone module
|
|
2
|
-
|
|
3
|
-
const sodium = require('sodium-universal')
|
|
4
|
-
const blake2b = require('blake2b-universal')
|
|
5
|
-
|
|
6
|
-
const DEFAULT_TOKEN = Buffer.alloc(0)
|
|
7
|
-
const NAMESPACE = Buffer.from('@hyperspace/key-manager')
|
|
8
|
-
|
|
9
|
-
module.exports = class KeyManager {
|
|
10
|
-
constructor (storage, profile, opts = {}) {
|
|
11
|
-
this.storage = storage
|
|
12
|
-
this.profile = profile
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
_sign (keyPair, message) {
|
|
16
|
-
if (!keyPair._secretKey) throw new Error('Invalid key pair')
|
|
17
|
-
const signature = Buffer.allocUnsafe(sodium.crypto_sign_BYTES)
|
|
18
|
-
sodium.crypto_sign_detached(signature, message, keyPair._secretKey)
|
|
19
|
-
return signature
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
createSecret (name, token) {
|
|
23
|
-
return deriveSeed(this.profile, token, name)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
createHypercoreKeyPair (name, token) {
|
|
27
|
-
const keyPair = {
|
|
28
|
-
publicKey: Buffer.allocUnsafe(sodium.crypto_sign_PUBLICKEYBYTES),
|
|
29
|
-
_secretKey: Buffer.alloc(sodium.crypto_sign_SECRETKEYBYTES),
|
|
30
|
-
sign: (msg) => this._sign(keyPair, msg)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
sodium.crypto_sign_seed_keypair(keyPair.publicKey, keyPair._secretKey, this.createSecret(name, token))
|
|
34
|
-
|
|
35
|
-
return keyPair
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
createNetworkIdentity (name, token) {
|
|
39
|
-
const keyPair = {
|
|
40
|
-
publicKey: Buffer.alloc(32),
|
|
41
|
-
secretKey: Buffer.alloc(64)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
sodium.crypto_sign_seed_keypair(keyPair.publicKey, keyPair.secretKey, this.createSecret(name, token))
|
|
45
|
-
|
|
46
|
-
return keyPair
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
close () {
|
|
50
|
-
return new Promise((resolve, reject) => {
|
|
51
|
-
this.storage.close(err => {
|
|
52
|
-
if (err) return reject(err)
|
|
53
|
-
return resolve()
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
static createToken () {
|
|
59
|
-
return randomBytes(32)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
static async fromStorage (storage, opts = {}) {
|
|
63
|
-
const profileStorage = storage(opts.name || 'default')
|
|
64
|
-
|
|
65
|
-
const profile = await new Promise((resolve, reject) => {
|
|
66
|
-
profileStorage.stat((err, st) => {
|
|
67
|
-
if (err && err.code !== 'ENOENT') return reject(err)
|
|
68
|
-
if (err || st.size < 32 || opts.overwrite) {
|
|
69
|
-
const key = randomBytes(32)
|
|
70
|
-
return profileStorage.write(0, key, err => {
|
|
71
|
-
if (err) return reject(err)
|
|
72
|
-
return resolve(key)
|
|
73
|
-
})
|
|
74
|
-
}
|
|
75
|
-
profileStorage.read(0, 32, (err, key) => {
|
|
76
|
-
if (err) return reject(err)
|
|
77
|
-
return resolve(key)
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
return new this(profileStorage, profile, opts)
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function deriveSeed (profile, token, name, output) {
|
|
87
|
-
if (token && token.length < 32) throw new Error('Token must be a Buffer with length >= 32')
|
|
88
|
-
if (!name || typeof name !== 'string') throw new Error('name must be a String')
|
|
89
|
-
if (!output) output = Buffer.alloc(32)
|
|
90
|
-
|
|
91
|
-
blake2b.batch(output, [
|
|
92
|
-
NAMESPACE,
|
|
93
|
-
token || DEFAULT_TOKEN,
|
|
94
|
-
Buffer.from(Buffer.byteLength(name, 'ascii') + '\n' + name, 'ascii')
|
|
95
|
-
], profile)
|
|
96
|
-
|
|
97
|
-
return output
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function randomBytes (n) {
|
|
101
|
-
const buf = Buffer.allocUnsafe(n)
|
|
102
|
-
sodium.randombytes_buf(buf)
|
|
103
|
-
return buf
|
|
104
|
-
}
|
package/test/keys.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
const p = require('path')
|
|
2
|
-
const fs = require('fs')
|
|
3
|
-
|
|
4
|
-
const test = require('brittle')
|
|
5
|
-
const ram = require('random-access-memory')
|
|
6
|
-
const raf = require('random-access-file')
|
|
7
|
-
|
|
8
|
-
const KeyManager = require('../lib/keys')
|
|
9
|
-
|
|
10
|
-
test('can create hypercore keypairs', async t => {
|
|
11
|
-
const keys = await KeyManager.fromStorage(ram)
|
|
12
|
-
|
|
13
|
-
const kp1 = await keys.createHypercoreKeyPair('core1')
|
|
14
|
-
const kp2 = await keys.createHypercoreKeyPair('core2')
|
|
15
|
-
|
|
16
|
-
t.is(kp1.publicKey.length, 32)
|
|
17
|
-
t.is(kp2.publicKey.length, 32)
|
|
18
|
-
t.unlike(kp1.publicKey, kp2.publicKey)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
test('distinct tokens create distinct hypercore keypairs', async t => {
|
|
22
|
-
const keys = await KeyManager.fromStorage(ram)
|
|
23
|
-
const token1 = KeyManager.createToken()
|
|
24
|
-
const token2 = KeyManager.createToken()
|
|
25
|
-
|
|
26
|
-
const kp1 = await keys.createHypercoreKeyPair('core1', token1)
|
|
27
|
-
const kp2 = await keys.createHypercoreKeyPair('core1', token2)
|
|
28
|
-
|
|
29
|
-
t.unlike(kp1.publicKey, kp2.publicKey)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
test('short user-provided token will throw', async t => {
|
|
33
|
-
const keys = await KeyManager.fromStorage(ram)
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
await keys.createHypercoreKeyPair('core1', Buffer.from('hello'))
|
|
37
|
-
t.fail('did not throw')
|
|
38
|
-
} catch {
|
|
39
|
-
t.pass('threw correctly')
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
test('persistent storage regenerates keys correctly', async t => {
|
|
44
|
-
const testPath = p.resolve(__dirname, 'test-data')
|
|
45
|
-
|
|
46
|
-
const keys1 = await KeyManager.fromStorage((name) => raf(testPath, { directory: testPath }))
|
|
47
|
-
const kp1 = await keys1.createHypercoreKeyPair('core1')
|
|
48
|
-
|
|
49
|
-
const keys2 = await KeyManager.fromStorage((name) => raf(testPath, { directory: testPath }))
|
|
50
|
-
const kp2 = await keys2.createHypercoreKeyPair('core1')
|
|
51
|
-
|
|
52
|
-
t.alike(kp1.publicKey, kp2.publicKey)
|
|
53
|
-
|
|
54
|
-
await fs.promises.rm(testPath, { recursive: true })
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
test('different master keys -> different keys', async t => {
|
|
58
|
-
const keys1 = await KeyManager.fromStorage(ram)
|
|
59
|
-
const keys2 = await KeyManager.fromStorage(ram)
|
|
60
|
-
|
|
61
|
-
const kp1 = await keys1.createHypercoreKeyPair('core1')
|
|
62
|
-
const kp2 = await keys2.createHypercoreKeyPair('core1')
|
|
63
|
-
|
|
64
|
-
t.unlike(kp1.publicKey, kp2.publicKey)
|
|
65
|
-
})
|