@fireproof/core 0.6.1 → 0.6.3-dev

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/README.md CHANGED
@@ -1,79 +1,58 @@
1
- # 🔥 Fireproof
2
-
3
- Fireproof is a realtime database for today's interactive applications. It uses immutable data and distributed protocols
4
- to offer a new kind of database that:
1
+ <p align="center" >
2
+ <a href="https://fireproof.storage/">
3
+ <img src="https://fireproof.storage/static/img/logo-animated-black.svg" alt="Fireproof logo" width="200">
4
+ </a>
5
+ </p>
6
+ <h3 align="center">
7
+ Cloudless database for React apps
8
+ </h3>
9
+
10
+ <p align="center">
11
+ <a href="https://github.com/jchris/fireproof/actions/workflows/test.yml">
12
+ <img src="https://github.com/jchris/fireproof/actions/workflows/test.yml/badge.svg" alt="Test" style="max-width: 100%;">
13
+ </a>
14
+ <a href="https://standardjs.com" rel="nofollow">
15
+ <img src="https://img.shields.io/badge/code_style-standard-brightgreen.svg" alt="JavaScript Style Guide" style="max-width: 100%;">
16
+ </a>
17
+ <a href="https://github.com/fireproof-storage/fireproof/blob/main/packages/react/README.md">
18
+ <img src="https://shields.io/badge/react-black?logo=react&style=for-the-badge%22" alt="React" style="max-width: 100%;">
19
+ </a>
20
+ <a href="https://bundlephobia.com/package/@fireproof/core" rel="nofollow">
21
+ <img src="https://deno.bundlejs.com/?q=@fireproof/core&treeshake=[*+as+fireproofCore]&badge" alt="Bundle Size" style="max-width: 100%;">
22
+ </a>
23
+ </p>
24
+
25
+ Fireproof uses immutable data and distributed protocols to offer a new kind of database that:
5
26
  - can be embedded in any page or app, with a flexible data ownership model
6
27
  - can be hosted on any cloud
7
28
  - uses cryptographically verifiable protocols (what plants crave)
8
29
 
9
- Fireproof is optimized to make building React apps fast and fun, with reliable results. The data can be as mission-critical as you want, as everything is encrypted and hash-based proofs are used to verify integrity. [Great use cases](https://fireproof.storage/posts/great-opportunites-to-use-fireproof/) include everything from social media to collaborative world-building (metaverse) to executive decision support tools that can stand up to blockchain levels of scrutiny.
30
+ Fireproof is optimized to make [building React apps](https://github.com/fireproof-storage/fireproof/blob/main/packages/react/README.md) fast and fun, with reliable results. Suitable for mission-critical data workloads like [LLM orchestration](https://fireproof.storage/posts/why-proofs-matter-for-ai/), supply-chain provenance, and field use of auditable data, [ Fireproof is also great](https://fireproof.storage/posts/great-opportunites-to-use-fireproof/) for social media, collaborative world-building, and rapidly implementing executive decision support tools that can stand up to blockchain levels of scrutiny.
31
+
32
+ With Fireproof, you **build first** and connect it to your cloud of choice when you are ready, so there's nothing holding you back from adding it to your existing apps, or [writing something new.](https://hackernoon.com/get-chatgpt-to-focus-on-coding-on-the-right-apis-with-gptdoc-strings)
10
33
 
11
- ## React hooks API
12
34
 
13
- Here's an example app using Fireproof and React. Look out for `useLiveQuery` and `database.put` -- that's all you really need to get started:
35
+ ## React Quick Start
36
+ *One-line preview:* in the context of a React component render, `useLiveQuery` will automatically refresh (even on changes by remote collaborators):
14
37
 
15
38
  ```js
16
- import { useFireproof } from '@fireproof/react'
17
-
18
- export default App = () => {
19
- const { database, useLiveQuery } = useFireproof()
20
- const todoList = useLiveQuery((doc) => doc.date).docs
21
- const [newTodo, setNewTodo] = useState('')
22
-
23
- return (
24
- <div>
25
- <input type="text" onChange={(e) => setNewTodo(e.target.value)} />
26
- <button onClick={() => database.put({text: newTodo, date: Date.now(), completed: false})}>Save</button>
27
- <ul>
28
- {todoList.map((todo) => (
29
- <li key={todo._id}>
30
- <input
31
- type="checkbox"
32
- checked={todo.completed}
33
- onChange={() => database.put({...todo, completed: !todo.completed})} />
34
- {todo.text}
35
- </li>
36
- ))}
37
- </div>
38
- )
39
- }
39
+ const completedTodos = useLiveQuery((doc) => doc.completed, { key: true })
40
40
  ```
41
+ This is the README for the core database technology. [The `useFireproof` hook documentation has features and a getting started guide](https://github.com/fireproof-storage/fireproof/blob/main/packages/react/README.md), like `useLiveDocument` and database setup helpers. Don't forget to star 🌟 this repo on the way over.
41
42
 
42
- ### Features
43
-
44
- * **Realtime** - data is updated as soon as it is available, with no polling or refreshes required.
45
- * **Distributed** - data is stored in a distributed network, so it is always available.
46
- * **Sync** - users can collaborate on data subsets, with changes synced across devices or via the cloud.
47
- * **Proofs** - cryptographic verification makes results verifiable and lowers operating costs
48
-
49
- ### Architecture
50
-
51
- * Powered by IPFS data structures, Fireproof can be hosted on traditional cloud or Filecoin infrastructure.
52
- * Immutable content-addressed data ensures that data is always consistent, accurate, and verified
53
- * Encrypted at rest and in transit, with optional clear-text database publishing for content management use cases.
54
- * Open source, so you can inspect the code and make sure that it meets your security and privacy requirements.
43
+ ## AI Assistant Quick Start
55
44
 
56
- Learn more about the [concepts](https://fireproof.storage/posts/from-mlops-to-point-of-sale:-merkle-proofs-and-data-locality/) and [architecture](https://fireproof.storage/documentation/how-the-database-engine-works/) behind Fireproof, or look in the `examples/` directory for projects using the database, or see [examples on CodePen](https://codepen.io/jchrisa/pen/GRYJJEM).
57
-
58
- ## ChatGPT / Bard Quick Start
59
-
60
- Paste this to GPT 4, 3.5, or Bard to enable it to write React apps using Fireproof:
45
+ Because Fireproof is designed around the mantra of build-first, it's ideal for AI-assisted app development as you can get an app up and running before even considering the cloud. If you are using GPT-3.5, GPT-4, or Bard, you can [easily enable the AI to write React apps using Fireproof](https://hackernoon.com/get-chatgpt-to-focus-on-coding-on-the-right-apis-with-gptdoc-strings). Paste this line of code into your prompt, along with a detailed description of the app to build:
61
46
 
62
47
  ```
63
48
  Fireproof/React/Usage: import { useFireproof } from '@fireproof/react'; function App() { const { useLiveQuery, useLiveDocument, database } = useFireproof(); const result = useLiveQuery(doc => doc.word, { limit: 10 }); const [{ count }, saveCountDocument] = useLiveDocument({_id: 'count', count: 0}); return (<><p>{count} changes</p><input type='text' onChange={() => saveCountDocument({count: count + 1})} onSubmit={e => database.put({word: e.target.value})} /><ul>{result.map(row => (<li key={row.id}>{row.key}</li>))}</ul></>)}
64
49
  ```
65
50
 
66
- In the same prompt, describe the app you want to build. Here are some examples that worked for us:
51
+ Here are some examples that worked for us:
67
52
 
68
53
  * Create a React app using Fireproof for tracking party invites. It should have a text input that creates a new document with the guest name, and an Index that lists all guests in a &lt;ul&gt;. ([Running copy here.](https://codepen.io/jchrisa/pen/zYmogWO))
69
- * Build a React app that allows you to create profiles for dogs, and browse to each profile. It should be optimized for mobile. Use Tailwind.
70
54
  * Build a photo grid app with drag-and-drop ordering that references photos by URL. Use tailwind and render all photos as squares. Keep grid arrangement in Fireproof with one document for each gallery, that is 4-16 photos arranged into a layout.
71
- * Build an app using React, Fireproof, MagicLink, and Tailwind that allows users to create one-question multiple-choice polls and collect the answers.
72
- * Create a note-taking app using React, Tailwind, and Fireproof that stores each note as a large text string in a Fireproof document, and uses an Index to split the text of the documents into tokens for full-text search. The app has an input field to search the documents via an index query.
73
-
74
- Please share your successes with us here or on [Twitter.](https://twitter.com/FireproofStorge)
75
-
76
- #### Advanced AI Docs
55
+ * Build a React app that allows users to create a list of their favorite movies, and then share that list with friends. Use Fireproof to store the list of movies, and to store the list of friends. Use MagicLink to authenticate users. Use Tailwind to make it look good.
77
56
 
78
57
  You can enhance the AI's understanding by adding the core APIs. Use this if you aren't using React, or you are adding additional features to your app and you need to go deeper than the React hooks.
79
58
 
@@ -81,18 +60,27 @@ You can enhance the AI's understanding by adding the core APIs. Use this if you
81
60
  Fireproof/API/Usage: import { Fireproof, Index } from '@fireproof/core'; const db = fireproof.storage('app-db-name'); const ok = await db.put({ any: 'json' }); const doc = await db.get(ok.id); await db.del(doc._id); const all = await db.allDocuments(); all.rows.map(({key, value}) => value); useEffect(()=> db.subscribe(updateReactStateFn), []); const index = new Index(db, (doc, map) => map(doc.any, {custom: Object.keys(doc)})); const result = await index.query({range : ['a', 'z']}); result.rows.map(({ key }) => key);
82
61
  ```
83
62
 
84
- ### Status
63
+ Please share your successes with us here or on [Twitter.](https://twitter.com/FireproofStorge)
64
+
65
+ # Database Features
66
+
67
+ The core features of the database are available on any platform in a compact JavaScript package and a foundational cloud storage service.
85
68
 
86
- Fireproof 0.6.0 is alpha software, 0.7.0 will be the first beta release. It is ready for you to evaluate for your future applications.
69
+ * **Local** - always encrypted, data automatically collocates with your users, for faster and more reliable apps.
70
+ * **Immutable** - [cutting-edge git-like data structures](https://fireproof.storage/posts/from-mlops-to-point-of-sale:-merkle-proofs-and-data-locality/) allow Fireproof to combine cryptographic verification with append-only storage, automatically converging on a verified state.
71
+ * **Distributed** - immutable data can be stored on the Fireproof service, your cloud, and the distributed IPFS network, so it is always available.
72
+ * **Realtime** - use the Fireproof service or APIs like WebRTC, libp2p, PartyKit, or SocketSupply to push changes to connected peers. React hook APIs like `useLiveQuery` are designed for automatic UI refresh.
73
+ * **Verifiable** - [cryptographic proofs make results verifiable](https://fireproof.storage/posts/why-proofs-matter-for-ai/), sync fast, and storage cheap.
74
+ * **[Cloudless](https://www.oreilly.com/radar/the-paradigm-shift-to-cloudless-computing/)** - data can be hosted on any cloud, on the IPFS network, or both. UCAN integration allows for flexible data ownership models.
87
75
 
88
- [![Test](https://github.com/jchris/fireproof/actions/workflows/test.yml/badge.svg)](https://github.com/jchris/fireproof/actions/workflows/test.yml)
89
- [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
90
76
 
91
- ## Features
77
+ Learn more about the [architecture](https://fireproof.storage/documentation/how-the-database-engine-works/) behind Fireproof, or see [examples on CodePen](https://codepen.io/jchrisa/pen/GRYJJEM).
78
+
79
+ ## API Usage
92
80
 
93
81
  ### Encrypted Documents
94
82
 
95
- A simple put, get, and delete interface for keeping track of all your JSON documents. Once your data is in Fireproof you can access it from any app or website. Fireproof document store uses MVCC versioning and Merkle clocks so you can always recover the version you are looking for.
83
+ A simple put, get and delete interface for keeping track of all your JSON documents. Once your data is in Fireproof you can access it from any app or website. Fireproof document store uses MVCC versioning and Merkle clocks so you can always recover the version you are looking for.
96
84
 
97
85
  ```js
98
86
  const { id, ref } = await database.put({
@@ -100,7 +88,9 @@ const { id, ref } = await database.put({
100
88
  name: 'André',
101
89
  age: 47
102
90
  });
103
- const doc = await database.get('three-thousand', { mvcc : true }) // mvcc is optional
91
+
92
+ // mvcc is optional
93
+ const doc = await database.get('three-thousand', { mvcc: true })
104
94
  // {
105
95
  // _id : 'three-thousand'
106
96
  // _clock : CID(bafy84...agfw7)
@@ -109,16 +99,25 @@ const doc = await database.get('three-thousand', { mvcc : true }) // mvcc is opt
109
99
  // }
110
100
  ```
111
101
 
112
- As you can see in the return value above, the `_clock` allows you to query a stable snapshot of that version of the database. Fireproof uses immutable data structures under the hood, so you can always rollback to old data. Files can be embedded anywhere in your document using IPFS links like `{"/":"bafybeih3e3zdiehbqfpxzpppxrb6kaaw4xkbqzyr2f5pwr5refq2te2ape"}`, with API sugar coming soon.
102
+ As you can see in the return value above, the `_clock` allows you to query a stable snapshot of that version of the database. Fireproof uses immutable data structures under the hood, so you can always rollback to old data. Files can be embedded anywhere in your document using IPFS links like `{"/": "bafybeih3e3zdiehbqfpxzpppxrb6kaaw4xkbqzyr2f5pwr5refq2te2ape"}`, with API sugar coming soon.
113
103
 
114
104
  ### Live Query
115
105
 
116
- Fireproof provides a live query interface that allows you to subscribe to changes in your data. This means that your UI will automatically update whenever there is a change to your data.
106
+ Fireproof provides a live query interface that allows you to subscribe to changes in your data. This means that your UI will automatically update whenever there is a change to your data. See the [useFireproof React hooks documentation](https://github.com/fireproof-storage/fireproof/blob/main/packages/react/README.md) for the easiest way to use this feature.
107
+
108
+ Fireproof indexes are defined by custom JavaScript functions that you write, allowing you to easily index and search your data in the way that works best for your application. Easily handle data variety and schema drift by normalizing any data to the desired index. The index function defines the sort order. You can use the index to query for a range of values or to find exact matches. This baseline functionality is all you need to build many kinds of complex queries.
109
+
110
+ ```js
111
+ const index = new Index(database, "byAge", (doc) => doc.age)
112
+ const { rows, proof } = await index.query({ range: [40, 52] })
113
+ ```
114
+
115
+ You can ignore the proof or use it to optimize hydration of your client side components. The `rows` are the results of the query. You can use `database.subscribe(myAppQueryFn)` to get notified of changes and re-issue your query. The React [useLiveQuery](https://fireproof.storage/documentation/usefireproof-hook-for-react/) hook does this for you automatically.
117
116
 
118
- Fireproof indexes are defined by custom JavaScript functions that you write, allowing you to easily index and search your data in the way that works best for your application. Easily handle data variety and schema drift by normalizing any data to the desired index.
117
+ If you need more control over the results, you can use the optional second argument to your map function to specify both keys and values for the index:
119
118
 
120
119
  ```js
121
- const index = new Index(database, function (doc, map) {
120
+ const index = new Index(database, "namesByAge", function (doc, map) {
122
121
  map(doc.age, doc.name)
123
122
  })
124
123
  const { rows, ref } = await index.query({ range: [40, 52] })
@@ -126,37 +125,46 @@ const { rows, ref } = await index.query({ range: [40, 52] })
126
125
  // { key: 47, value: 'André', id: 'three-thousand' } ]
127
126
  ```
128
127
 
128
+ The same mechanism that powers the built-in indexes can all be used to connect secondary [vector indexers](https://github.com/tantaraio/voy) or fulltext indexes to Fireproof. [Follow this tutorial to connect a secondary index](https://fireproof.storage/documentation/external-indexers/).
129
+
129
130
  ### Realtime Updates
130
131
 
131
- Subscribe to query changes in your application, so your UI updates automatically. Use the supplied React hooks, our Redux connector, or simple function calls to be notified of relevant changes.
132
+ Subscribe to query changes in your application, so your UI updates automatically. Use the supplied React hooks, or simple function calls to be notified of relevant changes.
132
133
 
133
134
  ```js
134
- const listener = new Listener(database, function(doc, emit) {
135
- if (doc.type == 'member') {
136
- emit('member')
137
- }
138
- })
139
- listener.on('member', (id) => {
140
- const doc = await db.get(id)
141
- alert(`Member update ${doc.name}`)
135
+ const unsubscribe = database.subscribe(changes) => {
136
+ changes.forEach(change => {
137
+ console.log(change)
138
+ })
142
139
  })
143
140
  ```
144
141
 
145
- ### Self-sovereign Identity
142
+ Return the `unsubscribe` function from `useEffect` and React will handle it for you. (In the code below, we use the arrow function's implicit return to connect the unsubscribe function to the `useEffect` hook. This prevents extra subscriptions from building up on each render.)
146
143
 
147
- Fireproof is so easy to integrate with any site or app because you can get started right away, and set up an account later. By default users write to their own database copy, so you can get pretty far before you even have to think about API keys. [Authorization is via non-extractable keypair](https://ucan.xyz), like TouchID / FaceID.
144
+ ```js
145
+ useEffect(() => database.subscribe((changes) =>
146
+ changes.forEach(change => console.log(change))), [])
147
+ ```
148
+
149
+ ### Cryptographic Proofs
150
+
151
+ Fireproof's Merkle clocks and hash trees are immutable and self-validating, and all query results are offline-capable data slices. Fireproof makes cryptographic proofs available for all of its operations, accelerating replication and making trustless index sharing possible. If you are making a "DocuSign for _____", [proofs make Fireproof the ideal verifiable document database](https://fireproof.storage/posts/from-mlops-to-point-of-sale:-merkle-proofs-and-data-locality/) for smart contracts and other applications where unique, verifiable, and trustworthy data is required. [Proof chains provide performance benefits as well](https://purrfect-tracker-45c.notion.site/Data-Routing-23c37b269b4c4c3dacb60d0077113bcb), by allowing recipients to skip costly I/O operations and instead cryptographically verify that changes contain all of the required context.
148
152
 
149
153
  ### Automatic Replication
150
154
 
151
- Documents changes are persisted to [Filecoin](https://filecoin.io) via [web3.storage](https://web3.storage), and made available over [IPFS] and on a global content delivery network. All you need to do to sync state is send a link to the latest database head, and Fireproof will take care of the rest. [Learn how to enable replication.](#status)
155
+ Documents changes are persisted to [Filecoin](https://filecoin.io) via [web3.storage](https://web3.storage), and made available over IPFS and on a global content delivery network. All you need to do to sync state is send a link to the latest database head, and Fireproof will take care of the rest.
152
156
 
153
- ### Cryptographic Proofs
157
+ ### Peer-to-peer Sync
154
158
 
155
- The [UCAN protocol](https://ucan.xyz) verifiably links Fireproof updates to authorized agents via cryptographic proof chains. These proofs are portable like bearer tokens, but because invocations are signed by end-user device keys, UCAN proofs don't need to be hidden to be secure, allowing for delegation of service capabilities across devices and parties. Additionally, Fireproof's Merkle clocks and hash trees are immutable and self-validating, making merging changes safe and efficient. Fireproof makes cryptographic proofs available for all of its operations, making it an ideal verifiable document database for smart contracts and other applications running in trustless environments. [Proof chains provide performance benefits as well](https://purrfect-tracker-45c.notion.site/Data-Routing-23c37b269b4c4c3dacb60d0077113bcb), by allowing recipients to skip costly I/O operations and instead cryptographically verify that changes contain all of the required context.
159
+ Application instances can be connected using WebRTC or any other stream API library, like [Socket Supply](https://socketsupply.co), [libp2p](https://libp2p.io), or [PartyKit](https://partykit.io). The [first sync demo uses pure WebRTC with no signaling server](https://game.fireproof.storage), which limits its usability. There are demos with other transports coming soon.
160
+
161
+ ### Self-sovereign Identity
162
+
163
+ Fireproof is so easy to integrate with any site or app because you can get started right away, and set up an account later. By default users write to their own database copy, so you can get pretty far before you even have to think about API keys. [Authorization is via non-extractable keypair](https://ucan.xyz), like TouchID / FaceID.
156
164
 
157
165
  ## Thanks 🙏
158
166
 
159
- Fireproof is a synthesis of work done by people in the web community over the years. I couldn't even begin to name all the folks who made pivotal contributions. Without npm, React, and VS Code all this would have taken so much longer. Thanks to everyone who supported me getting into database development via Apache CouchDB, one of the original document databases. The distinguishing work on immutable datastructures comes from the years of consideration [IPFS](https://ipfs.tech), [IPLD](https://ipld.io), and the [Filecoin APIs](https://docs.filecoin.io) have enjoyed.
167
+ Fireproof is a synthesis of work done by people in the web community over the years. I couldn't even begin to name all the folks who made pivotal contributions. Without npm, React, and VS Code all this would have taken so much longer. Thanks to everyone who supported me getting into database development via Apache CouchDB, one of the original document databases. The distinguishing work on immutable data-structures comes from the years of consideration [IPFS](https://ipfs.tech), [IPLD](https://ipld.io), and the [Filecoin APIs](https://docs.filecoin.io) have enjoyed.
160
168
 
161
169
  Thanks to Alan Shaw and Mikeal Rogers without whom this project would have never got started. The core Merkle hash-tree clock is based on [Alan's Pail](https://github.com/alanshaw/pail), and you can see the repository history goes all the way back to work begun as a branch of that repo. Mikeal wrote [the prolly trees implementation](https://github.com/mikeal/prolly-trees).
162
170
 
@@ -0,0 +1,4 @@
1
+ import crypto from 'crypto-browserify';
2
+ export function randomBytes(n) {
3
+ return crypto.randomBytes(n);
4
+ }
@@ -2,7 +2,6 @@
2
2
  import { visMerkleClock, visMerkleTree, vis, put, get, getAll, eventsSince } from './prolly.js';
3
3
  import { doTransaction, TransactionBlockstore } from './blockstore.js';
4
4
  import charwise from 'charwise';
5
- import { localSet } from './utils.js';
6
5
  import { CID } from 'multiformats';
7
6
  // TypeScript Types
8
7
  // eslint-disable-next-line no-unused-vars
@@ -31,7 +30,7 @@ export class Database {
31
30
  this.name = name;
32
31
  this.instanceId = `fp.${this.name}.${Math.random().toString(36).substring(2, 7)}`;
33
32
  this.blocks = new TransactionBlockstore(name, config.key);
34
- this.indexBlocks = new TransactionBlockstore(name + '.indexes', config.key);
33
+ this.indexBlocks = new TransactionBlockstore(name ? name + '.indexes' : null, config.key);
35
34
  this.clock = clock;
36
35
  this.config = config;
37
36
  }
@@ -71,7 +70,7 @@ export class Database {
71
70
  }
72
71
  maybeSaveClock() {
73
72
  if (this.name && this.blocks.valet) {
74
- localSet('fp.' + this.name, JSON.stringify(this));
73
+ this.blocks.valet.saveHeader(JSON.stringify(this));
75
74
  }
76
75
  }
77
76
  index(name) {
@@ -292,6 +291,7 @@ export class Database {
292
291
  console.error('failed', event);
293
292
  throw new Error('failed to put at storage layer');
294
293
  }
294
+ // await new Promise(resolve => setTimeout(resolve, 10)) // makes concurrent tests work
295
295
  this.applyClock(prevClock, result.head);
296
296
  await this.notifyListeners([decodedEvent]); // this type is odd
297
297
  return {
@@ -1,9 +1,33 @@
1
1
  import * as multiformats from 'multiformats';
2
2
  import { Link, CID } from 'multiformats';
3
3
  import * as multiformats_cid from 'multiformats/cid';
4
+ import * as idb from 'idb';
4
5
 
5
6
  type AnyLink = Link<unknown, number, number, 1|0>
6
7
 
8
+ declare class Loader {
9
+ constructor(name: any, keyId: any, config?: {
10
+ dataDir: any;
11
+ headerKeyPrefix: string;
12
+ });
13
+ name: any;
14
+ keyId: any;
15
+ config: {
16
+ dataDir: any;
17
+ headerKeyPrefix: string;
18
+ };
19
+ isBrowser: boolean;
20
+ withDB: (dbWorkFun: any) => Promise<any>;
21
+ idb: idb.IDBPDatabase<unknown>;
22
+ writeCars(cars: any): Promise<void>;
23
+ writeCarsIDB(cars: any): Promise<any>;
24
+ readCar(carCid: any): Promise<any>;
25
+ readCarIDB(carCid: any): Promise<any>;
26
+ getHeader(): any;
27
+ saveHeader(stringValue: any): Promise<void>;
28
+ headerFilename(): any;
29
+ }
30
+
7
31
  declare class Valet {
8
32
  constructor(name: string, keyMaterial: any);
9
33
  idb: any;
@@ -22,6 +46,8 @@ declare class Valet {
22
46
  * @type {null|function(string, Uint8Array):Promise<void>}
23
47
  */
24
48
  uploadFunction: null | ((arg0: string, arg1: Uint8Array) => Promise<void>);
49
+ loader: Loader;
50
+ saveHeader(header: any): Promise<void>;
25
51
  getKeyMaterial(): any;
26
52
  setKeyMaterial(km: any): void;
27
53
  /**
@@ -32,7 +58,6 @@ declare class Valet {
32
58
  * @memberof Valet
33
59
  */
34
60
  writeTransaction(innerBlockstore: InnerBlockstore, cids: Set<string>): Promise<void>;
35
- withDB: (dbWorkFun: any) => Promise<any>;
36
61
  /**
37
62
  * Iterate over all blocks in the store.
38
63
  *
@@ -55,7 +80,6 @@ declare class Valet {
55
80
  * @param {*} value
56
81
  */
57
82
  parkCar(carCid: string, value: any, cids: any): Promise<void>;
58
- writeCars(cars: any): Promise<any>;
59
83
  remoteBlockFunction: any;
60
84
  getCarReader(carCid: any): Promise<{
61
85
  root: any;