@fireproof/core 0.8.0-dev.3 → 0.8.0-dev.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,8 @@ const chunker = bf(30);
18
18
  const blockOpts = { cache, chunker, codec: dagcbor, hasher: sha256, compare };
19
19
  const NO_ENCRYPT = typeof process !== 'undefined' && !!process.env?.NO_ENCRYPT;
20
20
  const NOT_IMPL = true;
21
- export class Base {
21
+ class Base {
22
+ static format = '0.8';
22
23
  lastCar = null;
23
24
  carLog = [];
24
25
  keyMaterial = null;
@@ -125,6 +126,7 @@ export class Base {
125
126
  header.key && this.setKeyMaterial(header.key);
126
127
  // this.setCarCidMapCarCid(header.car) // instead we should just extract the list of cars from the car
127
128
  const carHeader = await this.readHeaderCar(header.car);
129
+ // console.log('carHeader', this.name, carHeader)
128
130
  this.carLog = carHeader.cars || [];
129
131
  // console.log('stored carHeader', this.name, this.config.type, this.carLog)
130
132
  // this.lastCar = header.car // ?
@@ -421,3 +423,4 @@ export class Base {
421
423
  }
422
424
  }
423
425
  }
426
+ export { Base };
@@ -1,7 +1,7 @@
1
1
  import { openDB } from 'idb';
2
2
  import { Base } from './base.js';
3
3
  const defaultConfig = {
4
- headerKeyPrefix: 'fp.'
4
+ headerKeyPrefix: 'fp.' + Base.format
5
5
  };
6
6
  /* global localStorage */
7
7
  export class Browser extends Base {
@@ -10,7 +10,7 @@ export class Browser extends Base {
10
10
  }
11
11
  withDB = async (dbWorkFun) => {
12
12
  if (!this.idb) {
13
- this.idb = await openDB(`fp.${this.keyId}.${this.name}.valet`, 3, {
13
+ this.idb = await openDB(`fp.${Base.format}.${this.keyId}.${this.name}.valet`, 3, {
14
14
  upgrade(db, oldVersion, newVersion, transaction) {
15
15
  if (oldVersion < 1) {
16
16
  db.createObjectStore('cars');
@@ -7,7 +7,7 @@ import { Base } from './base.js';
7
7
  import fs from 'fs';
8
8
  const readFileSync = fs.readFileSync;
9
9
  export const defaultConfig = {
10
- dataDir: join(homedir(), '.fireproof')
10
+ dataDir: join(homedir(), '.fireproof', 'v' + Base.format)
11
11
  };
12
12
  export class Filesystem extends Base {
13
13
  constructor(name, config = {}) {
@@ -1,7 +1,7 @@
1
1
  import fetch from 'cross-fetch';
2
2
  import { Base } from './base.js';
3
3
  const defaultConfig = {
4
- url: 'http://localhost:4000'
4
+ url: 'http://localhost:4000/v' + Base.format
5
5
  };
6
6
  export class Rest extends Base {
7
7
  constructor(name, config = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fireproof/core",
3
- "version": "0.8.0-dev.3",
3
+ "version": "0.8.0-dev.4",
4
4
  "description": "Live data for React, accelerated by proofs, powered by IPFS",
5
5
  "main": "dist/src/fireproof.js",
6
6
  "module": "dist/src/fireproof.mjs",
@@ -27,6 +27,7 @@ const NO_ENCRYPT = typeof process !== 'undefined' && !!process.env?.NO_ENCRYPT
27
27
  const NOT_IMPL = true
28
28
 
29
29
  export class Base {
30
+ static format = '0.8'
30
31
  lastCar = null
31
32
  carLog = []
32
33
  keyMaterial = null
@@ -143,6 +144,9 @@ export class Base {
143
144
  header.key && this.setKeyMaterial(header.key)
144
145
  // this.setCarCidMapCarCid(header.car) // instead we should just extract the list of cars from the car
145
146
  const carHeader = await this.readHeaderCar(header.car)
147
+
148
+ // console.log('carHeader', this.name, carHeader)
149
+
146
150
  this.carLog = carHeader.cars || []
147
151
  // console.log('stored carHeader', this.name, this.config.type, this.carLog)
148
152
 
@@ -2,7 +2,7 @@ import { openDB } from 'idb'
2
2
  import { Base } from './base.js'
3
3
 
4
4
  const defaultConfig = {
5
- headerKeyPrefix: 'fp.'
5
+ headerKeyPrefix: 'fp.' + Base.format
6
6
  }
7
7
 
8
8
  /* global localStorage */
@@ -14,7 +14,7 @@ export class Browser extends Base {
14
14
 
15
15
  withDB = async dbWorkFun => {
16
16
  if (!this.idb) {
17
- this.idb = await openDB(`fp.${this.keyId}.${this.name}.valet`, 3, {
17
+ this.idb = await openDB(`fp.${Base.format}.${this.keyId}.${this.name}.valet`, 3, {
18
18
  upgrade (db, oldVersion, newVersion, transaction) {
19
19
  if (oldVersion < 1) {
20
20
  db.createObjectStore('cars')
@@ -9,7 +9,7 @@ import fs from 'fs'
9
9
  const readFileSync = fs.readFileSync
10
10
 
11
11
  export const defaultConfig = {
12
- dataDir: join(homedir(), '.fireproof')
12
+ dataDir: join(homedir(), '.fireproof', 'v' + Base.format)
13
13
  }
14
14
 
15
15
  export class Filesystem extends Base {
@@ -2,7 +2,7 @@ import fetch from 'cross-fetch'
2
2
  import { Base } from './base.js'
3
3
 
4
4
  const defaultConfig = {
5
- url: 'http://localhost:4000'
5
+ url: 'http://localhost:4000/v' + Base.format
6
6
  }
7
7
 
8
8
  export class Rest extends Base {