Add comprehensive installation and setup documentation

- Add GETTING_STARTED.md with quick start guide and development modes
- Add INSTALL.sh automated installation script
- Add INSTALLATION_CHECKLIST.md, INSTALLATION_SUCCESS.md, and INSTALLATION_SUMMARY.md
- Add QUICK_REFERENCE.md for common commands
- Add SETUP_GUIDE.md with detailed setup instructions
- Update README.md with improved project overview
- Add did-wallet app dependencies and node_modules
This commit is contained in:
Dorian
2026-01-27 17:18:21 +00:00
parent a81f655133
commit 0d073fa89e
22658 changed files with 4494151 additions and 6 deletions
+4
View File
@@ -0,0 +1,4 @@
This project is dual licensed under MIT and Apache-2.0.
MIT: https://www.opensource.org/licenses/mit
Apache-2.0: https://www.apache.org/licenses/license-2.0
+106
View File
@@ -0,0 +1,106 @@
# blockstore-core <!-- omit in toc -->
[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)
[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)
[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-stores.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-stores)
[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/js-stores/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/js-stores/actions/workflows/js-test-and-release.yml?query=branch%3Amain)
> Contains various implementations of the API contract described in interface-blockstore
## Table of contents <!-- omit in toc -->
- [Install](#install)
- [Browser `<script>` tag](#browser-script-tag)
- [Implementations](#implementations)
- [Usage](#usage)
- [BaseBlockstore](#baseblockstore)
- [MemoryBlockstore](#memoryblockstore)
- [BlackHoleBlockstore](#blackholeblockstore)
- [API Docs](#api-docs)
- [License](#license)
- [Contribute](#contribute)
## Install
```console
$ npm i blockstore-core
```
### Browser `<script>` tag
Loading this module through a script tag will make it's exports available as `BlockstoreCore` in the global namespace.
```html
<script src="https://unpkg.com/blockstore-core/dist/index.min.js"></script>
```
## Implementations
- Base: [`src/base`](src/base.ts)
- Memory: [`src/memory`](src/memory.ts)
- BlackHole: ['src/blackhole](src/blackhole.ts)
## Usage
### BaseBlockstore
Provides a complete implementation of the Blockstore interface. You must implement `.get`, `.put`, etc.
```js
import { BaseBlockstore } from 'blockstore-core/base'
class MyCustomBlockstore extends BaseBlockstore {
put (key, val, options) {
// store a block
}
get (key, options) {
// retrieve a block
}
// ...etc
}
```
### MemoryBlockstore
A simple Blockstore that stores blocks in memory.
```js
import { MemoryBlockstore } from 'blockstore-core/memory'
const store = new MemoryBlockstore()
```
### BlackHoleBlockstore
A Blockstore that does not store any blocks.
```js
import { BlackHoleBlockstore } from 'blockstore-core/black-hole'
const store = new BlackHoleBlockstore()
```
## API Docs
- <https://ipfs.github.io/js-stores/modules/blockstore_core.html>
## License
Licensed under either of
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
## Contribute
Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-stores/issues).
Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general.
Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)
File diff suppressed because one or more lines are too long
+17
View File
@@ -0,0 +1,17 @@
import type { Blockstore, Pair } from 'interface-blockstore';
import type { AbortOptions, Await, AwaitIterable } from 'interface-store';
import type { CID } from 'multiformats/cid';
export declare class BaseBlockstore implements Blockstore {
has(key: CID, options?: AbortOptions): Await<boolean>;
put(key: CID, val: Uint8Array, options?: AbortOptions): Await<CID>;
putMany(source: AwaitIterable<Pair>, options?: AbortOptions): AwaitIterable<CID>;
get(key: CID, options?: AbortOptions): Await<Uint8Array>;
getMany(source: AwaitIterable<CID>, options?: AbortOptions): AwaitIterable<Pair>;
delete(key: CID, options?: AbortOptions): Promise<void>;
deleteMany(source: AwaitIterable<CID>, options?: AbortOptions): AwaitIterable<CID>;
/**
* Extending classes should override `query` or implement this method
*/
getAll(options?: AbortOptions): AwaitIterable<Pair>;
}
//# sourceMappingURL=base.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AACzE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAE3C,qBAAa,cAAe,YAAW,UAAU;IAC/C,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC;IAItD,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC;IAI3D,OAAO,CAAE,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC;IAOzF,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,KAAK,CAAC,UAAU,CAAC;IAIjD,OAAO,CAAE,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC,IAAI,CAAC;IASnF,MAAM,CAAE,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,UAAU,CAAE,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC,GAAG,CAAC;IAO3F;;OAEG;IACK,MAAM,CAAE,OAAO,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC,IAAI,CAAC;CAG7D"}
+41
View File
@@ -0,0 +1,41 @@
export class BaseBlockstore {
has(key, options) {
return Promise.reject(new Error('.has is not implemented'));
}
put(key, val, options) {
return Promise.reject(new Error('.put is not implemented'));
}
async *putMany(source, options) {
for await (const { cid, block } of source) {
await this.put(cid, block, options);
yield cid;
}
}
get(key, options) {
return Promise.reject(new Error('.get is not implemented'));
}
async *getMany(source, options) {
for await (const key of source) {
yield {
cid: key,
block: await this.get(key, options)
};
}
}
async delete(key, options) {
await Promise.reject(new Error('.delete is not implemented'));
}
async *deleteMany(source, options) {
for await (const key of source) {
await this.delete(key, options);
yield key;
}
}
/**
* Extending classes should override `query` or implement this method
*/
async *getAll(options) {
throw new Error('.getAll is not implemented');
}
}
//# sourceMappingURL=base.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/base.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,cAAc;IACzB,GAAG,CAAE,GAAQ,EAAE,OAAsB;QACnC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAA;IAC7D,CAAC;IAED,GAAG,CAAE,GAAQ,EAAE,GAAe,EAAE,OAAsB;QACpD,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAA;IAC7D,CAAC;IAED,KAAK,CAAC,CAAE,OAAO,CAAE,MAA2B,EAAE,OAAsB;QAClE,IAAI,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,MAAM,EAAE;YACzC,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;YACnC,MAAM,GAAG,CAAA;SACV;IACH,CAAC;IAED,GAAG,CAAE,GAAQ,EAAE,OAAsB;QACnC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAA;IAC7D,CAAC;IAED,KAAK,CAAC,CAAE,OAAO,CAAE,MAA0B,EAAE,OAAsB;QACjE,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,MAAM,EAAE;YAC9B,MAAM;gBACJ,GAAG,EAAE,GAAG;gBACR,KAAK,EAAE,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC;aACpC,CAAA;SACF;IACH,CAAC;IAED,KAAK,CAAC,MAAM,CAAE,GAAQ,EAAE,OAAsB;QAC5C,MAAM,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAA;IAC/D,CAAC;IAED,KAAK,CAAC,CAAE,UAAU,CAAE,MAA0B,EAAE,OAAsB;QACpE,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,MAAM,EAAE;YAC9B,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;YAC/B,MAAM,GAAG,CAAA;SACV;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,CAAE,MAAM,CAAE,OAAsB;QACpC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;IAC/C,CAAC;CACF"}
+12
View File
@@ -0,0 +1,12 @@
import { BaseBlockstore } from './base.js';
import type { Pair } from 'interface-blockstore';
import type { Await, AwaitIterable } from 'interface-store';
import type { CID } from 'multiformats/cid';
export declare class BlackHoleBlockstore extends BaseBlockstore {
put(key: CID): Await<CID>;
get(): Await<Uint8Array>;
has(): Await<boolean>;
delete(): Promise<void>;
getAll(): AwaitIterable<Pair>;
}
//# sourceMappingURL=black-hole.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"black-hole.d.ts","sourceRoot":"","sources":["../../src/black-hole.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE1C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAE3C,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,GAAG,CAAE,GAAG,EAAE,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;IAI1B,GAAG,IAAK,KAAK,CAAC,UAAU,CAAC;IAIzB,GAAG,IAAK,KAAK,CAAC,OAAO,CAAC;IAIhB,MAAM,IAAK,OAAO,CAAC,IAAI,CAAC;IAItB,MAAM,IAAK,aAAa,CAAC,IAAI,CAAC;CAGvC"}
+18
View File
@@ -0,0 +1,18 @@
import { BaseBlockstore } from './base.js';
import * as Errors from './errors.js';
export class BlackHoleBlockstore extends BaseBlockstore {
put(key) {
return key;
}
get() {
throw Errors.notFoundError();
}
has() {
return false;
}
async delete() {
}
async *getAll() {
}
}
//# sourceMappingURL=black-hole.js.map
@@ -0,0 +1 @@
{"version":3,"file":"black-hole.js","sourceRoot":"","sources":["../../src/black-hole.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAKrC,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IACrD,GAAG,CAAE,GAAQ;QACX,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,GAAG;QACD,MAAM,MAAM,CAAC,aAAa,EAAE,CAAA;IAC9B,CAAC;IAED,GAAG;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,CAAC,MAAM;IAEZ,CAAC;IAED,KAAK,CAAC,CAAE,MAAM;IAEd,CAAC;CACF"}
+9
View File
@@ -0,0 +1,9 @@
export declare function openFailedError(err?: Error): Error;
export declare function closeFailedError(err?: Error): Error;
export declare function putFailedError(err?: Error): Error;
export declare function getFailedError(err?: Error): Error;
export declare function deleteFailedError(err?: Error): Error;
export declare function hasFailedError(err?: Error): Error;
export declare function notFoundError(err?: Error): Error;
export declare function abortedError(err?: Error): Error;
//# sourceMappingURL=errors.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAAE,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAGnD;AAED,wBAAgB,gBAAgB,CAAE,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAGpD;AAED,wBAAgB,cAAc,CAAE,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAGlD;AAED,wBAAgB,cAAc,CAAE,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAGlD;AAED,wBAAgB,iBAAiB,CAAE,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAGrD;AAED,wBAAgB,cAAc,CAAE,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAGlD;AAED,wBAAgB,aAAa,CAAE,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAGjD;AAED,wBAAgB,YAAY,CAAE,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAGhD"}
+34
View File
@@ -0,0 +1,34 @@
import errCode from 'err-code';
export function openFailedError(err) {
err = err ?? new Error('Open failed');
return errCode(err, 'ERR_OPEN_FAILED');
}
export function closeFailedError(err) {
err = err ?? new Error('Close failed');
return errCode(err, 'ERR_CLOSE_FAILED');
}
export function putFailedError(err) {
err = err ?? new Error('Put failed');
return errCode(err, 'ERR_PUT_FAILED');
}
export function getFailedError(err) {
err = err ?? new Error('Get failed');
return errCode(err, 'ERR_GET_FAILED');
}
export function deleteFailedError(err) {
err = err ?? new Error('Delete failed');
return errCode(err, 'ERR_DELETE_FAILED');
}
export function hasFailedError(err) {
err = err ?? new Error('Has failed');
return errCode(err, 'ERR_HAS_FAILED');
}
export function notFoundError(err) {
err = err ?? new Error('Not Found');
return errCode(err, 'ERR_NOT_FOUND');
}
export function abortedError(err) {
err = err ?? new Error('Aborted');
return errCode(err, 'ERR_ABORTED');
}
//# sourceMappingURL=errors.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,UAAU,CAAA;AAE9B,MAAM,UAAU,eAAe,CAAE,GAAW;IAC1C,GAAG,GAAG,GAAG,IAAI,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;IACrC,OAAO,OAAO,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAA;AACxC,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAE,GAAW;IAC3C,GAAG,GAAG,GAAG,IAAI,IAAI,KAAK,CAAC,cAAc,CAAC,CAAA;IACtC,OAAO,OAAO,CAAC,GAAG,EAAE,kBAAkB,CAAC,CAAA;AACzC,CAAC;AAED,MAAM,UAAU,cAAc,CAAE,GAAW;IACzC,GAAG,GAAG,GAAG,IAAI,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;IACpC,OAAO,OAAO,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,cAAc,CAAE,GAAW;IACzC,GAAG,GAAG,GAAG,IAAI,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;IACpC,OAAO,OAAO,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAE,GAAW;IAC5C,GAAG,GAAG,GAAG,IAAI,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;IACvC,OAAO,OAAO,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAA;AAC1C,CAAC;AAED,MAAM,UAAU,cAAc,CAAE,GAAW;IACzC,GAAG,GAAG,GAAG,IAAI,IAAI,KAAK,CAAC,YAAY,CAAC,CAAA;IACpC,OAAO,OAAO,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,aAAa,CAAE,GAAW;IACxC,GAAG,GAAG,GAAG,IAAI,IAAI,KAAK,CAAC,WAAW,CAAC,CAAA;IACnC,OAAO,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA;AACtC,CAAC;AAED,MAAM,UAAU,YAAY,CAAE,GAAW;IACvC,GAAG,GAAG,GAAG,IAAI,IAAI,KAAK,CAAC,SAAS,CAAC,CAAA;IACjC,OAAO,OAAO,CAAC,GAAG,EAAE,aAAa,CAAC,CAAA;AACpC,CAAC"}
+13
View File
@@ -0,0 +1,13 @@
export { BaseBlockstore } from './base.js';
export { MemoryBlockstore } from './memory.js';
export declare const Errors: {
openFailedError(err?: Error | undefined): Error;
closeFailedError(err?: Error | undefined): Error;
putFailedError(err?: Error | undefined): Error;
getFailedError(err?: Error | undefined): Error;
deleteFailedError(err?: Error | undefined): Error;
hasFailedError(err?: Error | undefined): Error;
notFoundError(err?: Error | undefined): Error;
abortedError(err?: Error | undefined): Error;
};
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,eAAO,MAAM,MAAM;;;;;;;;;CAElB,CAAA"}
+7
View File
@@ -0,0 +1,7 @@
import * as ErrorsImport from './errors.js';
export { BaseBlockstore } from './base.js';
export { MemoryBlockstore } from './memory.js';
export const Errors = {
...ErrorsImport
};
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,aAAa,CAAA;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,GAAG,YAAY;CAChB,CAAA"}
+14
View File
@@ -0,0 +1,14 @@
import { CID } from 'multiformats/cid';
import { BaseBlockstore } from './base.js';
import type { Pair } from 'interface-blockstore';
import type { Await, AwaitIterable } from 'interface-store';
export declare class MemoryBlockstore extends BaseBlockstore {
private readonly data;
constructor();
put(key: CID, val: Uint8Array): Await<CID>;
get(key: CID): Await<Uint8Array>;
has(key: CID): Await<boolean>;
delete(key: CID): Promise<void>;
getAll(): AwaitIterable<Pair>;
}
//# sourceMappingURL=memory.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/memory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAGtC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE1C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE3D,qBAAa,gBAAiB,SAAQ,cAAc;IAClD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAyB;;IAQ9C,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC;IAM3C,GAAG,CAAE,GAAG,EAAE,GAAG,GAAG,KAAK,CAAC,UAAU,CAAC;IAUjC,GAAG,CAAE,GAAG,EAAE,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC;IAIxB,MAAM,CAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9B,MAAM,IAAK,aAAa,CAAC,IAAI,CAAC;CAQvC"}
+39
View File
@@ -0,0 +1,39 @@
import { base32 } from 'multiformats/bases/base32';
import { CID } from 'multiformats/cid';
import * as raw from 'multiformats/codecs/raw';
import * as Digest from 'multiformats/hashes/digest';
import { BaseBlockstore } from './base.js';
import * as Errors from './errors.js';
export class MemoryBlockstore extends BaseBlockstore {
data;
constructor() {
super();
this.data = new Map();
}
put(key, val) {
this.data.set(base32.encode(key.multihash.bytes), val);
return key;
}
get(key) {
const buf = this.data.get(base32.encode(key.multihash.bytes));
if (buf == null) {
throw Errors.notFoundError();
}
return buf;
}
has(key) {
return this.data.has(base32.encode(key.multihash.bytes));
}
async delete(key) {
this.data.delete(base32.encode(key.multihash.bytes));
}
async *getAll() {
for (const [key, value] of this.data.entries()) {
yield {
cid: CID.createV1(raw.code, Digest.decode(base32.decode(key))),
block: value
};
}
}
}
//# sourceMappingURL=memory.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,KAAK,GAAG,MAAM,yBAAyB,CAAA;AAC9C,OAAO,KAAK,MAAM,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AAIrC,MAAM,OAAO,gBAAiB,SAAQ,cAAc;IACjC,IAAI,CAAyB;IAE9C;QACE,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,EAAE,CAAA;IACvB,CAAC;IAED,GAAG,CAAE,GAAQ,EAAE,GAAe;QAC5B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAA;QAEtD,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,GAAG,CAAE,GAAQ;QACX,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;QAE7D,IAAI,GAAG,IAAI,IAAI,EAAE;YACf,MAAM,MAAM,CAAC,aAAa,EAAE,CAAA;SAC7B;QAED,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,GAAG,CAAE,GAAQ;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;IAC1D,CAAC;IAED,KAAK,CAAC,MAAM,CAAE,GAAQ;QACpB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;IACtD,CAAC;IAED,KAAK,CAAC,CAAE,MAAM;QACZ,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE;YAC9C,MAAM;gBACJ,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC9D,KAAK,EAAE,KAAK;aACb,CAAA;SACF;IACH,CAAC;CACF"}
+14
View File
@@ -0,0 +1,14 @@
{
"BaseBlockstore": "https://ipfs.github.io/js-stores/classes/base.BaseBlockstore.html",
"BlackHoleBlockstore": "https://ipfs.github.io/js-stores/classes/black_hole.BlackHoleBlockstore.html",
"abortedError": "https://ipfs.github.io/js-stores/functions/errors.abortedError.html",
"closeFailedError": "https://ipfs.github.io/js-stores/functions/errors.closeFailedError.html",
"deleteFailedError": "https://ipfs.github.io/js-stores/functions/errors.deleteFailedError.html",
"getFailedError": "https://ipfs.github.io/js-stores/functions/errors.getFailedError.html",
"hasFailedError": "https://ipfs.github.io/js-stores/functions/errors.hasFailedError.html",
"notFoundError": "https://ipfs.github.io/js-stores/functions/errors.notFoundError.html",
"openFailedError": "https://ipfs.github.io/js-stores/functions/errors.openFailedError.html",
"putFailedError": "https://ipfs.github.io/js-stores/functions/errors.putFailedError.html",
"Errors": "https://ipfs.github.io/js-stores/variables/index.Errors.html",
"MemoryBlockstore": "https://ipfs.github.io/js-stores/classes/memory.MemoryBlockstore.html"
}
+190
View File
@@ -0,0 +1,190 @@
{
"name": "blockstore-core",
"version": "4.2.0",
"description": "Contains various implementations of the API contract described in interface-blockstore",
"author": "Alex Potsides <alex.potsides@protocol.ai>",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/ipfs/js-stores/tree/master/packages/blockstore-core#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/ipfs/js-stores.git"
},
"bugs": {
"url": "https://github.com/ipfs/js-stores/issues"
},
"keywords": [
"datastore",
"interface",
"ipfs",
"key-value"
],
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
},
"type": "module",
"types": "./dist/src/index.d.ts",
"typesVersions": {
"*": {
"*": [
"*",
"dist/*",
"dist/src/*",
"dist/src/*/index"
],
"src/*": [
"*",
"dist/*",
"dist/src/*",
"dist/src/*/index"
]
}
},
"files": [
"src",
"dist",
"!dist/test",
"!**/*.tsbuildinfo"
],
"exports": {
".": {
"types": "./dist/src/index.d.ts",
"import": "./dist/src/index.js"
},
"./base": {
"types": "./dist/src/base.d.ts",
"import": "./dist/src/base.js"
},
"./black-hole": {
"types": "./dist/src/black-hole.d.ts",
"import": "./dist/src/black-hole.js"
},
"./errors": {
"types": "./dist/src/errors.d.ts",
"import": "./dist/src/errors.js"
},
"./memory": {
"types": "./dist/src/memory.d.ts",
"import": "./dist/src/memory.js"
}
},
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
"sourceType": "module"
}
},
"release": {
"branches": [
"main"
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{
"breaking": true,
"release": "major"
},
{
"revert": true,
"release": "patch"
},
{
"type": "feat",
"release": "minor"
},
{
"type": "fix",
"release": "patch"
},
{
"type": "docs",
"release": "patch"
},
{
"type": "test",
"release": "patch"
},
{
"type": "deps",
"release": "patch"
},
{
"scope": "no-release",
"release": false
}
]
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"section": "Trivial Changes"
},
{
"type": "docs",
"section": "Documentation"
},
{
"type": "deps",
"section": "Dependencies"
},
{
"type": "test",
"section": "Tests"
}
]
}
}
],
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/github",
"@semantic-release/git"
]
},
"scripts": {
"clean": "aegir clean",
"lint": "aegir lint",
"build": "aegir build",
"release": "aegir release",
"test": "aegir test -t node -t browser -t webworker -t electron-main",
"test:node": "aegir test -t node --cov",
"test:chrome": "aegir test -t browser --cov",
"test:chrome-webworker": "aegir test -t webworker",
"test:firefox": "aegir test -t browser -- --browser firefox",
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
"test:electron-main": "aegir test -t electron-main",
"dep-check": "aegir dep-check",
"docs": "aegir docs"
},
"dependencies": {
"err-code": "^3.0.1",
"interface-blockstore": "^5.0.0",
"interface-store": "^5.0.0",
"multiformats": "^11.0.2"
},
"devDependencies": {
"aegir": "^39.0.9",
"interface-blockstore-tests": "^6.0.0"
},
"typedoc": {
"entryPoint": "./src/index.ts"
}
}
+51
View File
@@ -0,0 +1,51 @@
import type { Blockstore, Pair } from 'interface-blockstore'
import type { AbortOptions, Await, AwaitIterable } from 'interface-store'
import type { CID } from 'multiformats/cid'
export class BaseBlockstore implements Blockstore {
has (key: CID, options?: AbortOptions): Await<boolean> {
return Promise.reject(new Error('.has is not implemented'))
}
put (key: CID, val: Uint8Array, options?: AbortOptions): Await<CID> {
return Promise.reject(new Error('.put is not implemented'))
}
async * putMany (source: AwaitIterable<Pair>, options?: AbortOptions): AwaitIterable<CID> {
for await (const { cid, block } of source) {
await this.put(cid, block, options)
yield cid
}
}
get (key: CID, options?: AbortOptions): Await<Uint8Array> {
return Promise.reject(new Error('.get is not implemented'))
}
async * getMany (source: AwaitIterable<CID>, options?: AbortOptions): AwaitIterable<Pair> {
for await (const key of source) {
yield {
cid: key,
block: await this.get(key, options)
}
}
}
async delete (key: CID, options?: AbortOptions): Promise<void> {
await Promise.reject(new Error('.delete is not implemented'))
}
async * deleteMany (source: AwaitIterable<CID>, options?: AbortOptions): AwaitIterable<CID> {
for await (const key of source) {
await this.delete(key, options)
yield key
}
}
/**
* Extending classes should override `query` or implement this method
*/
async * getAll (options?: AbortOptions): AwaitIterable<Pair> { // eslint-disable-line require-yield
throw new Error('.getAll is not implemented')
}
}
+27
View File
@@ -0,0 +1,27 @@
import { BaseBlockstore } from './base.js'
import * as Errors from './errors.js'
import type { Pair } from 'interface-blockstore'
import type { Await, AwaitIterable } from 'interface-store'
import type { CID } from 'multiformats/cid'
export class BlackHoleBlockstore extends BaseBlockstore {
put (key: CID): Await<CID> {
return key
}
get (): Await<Uint8Array> {
throw Errors.notFoundError()
}
has (): Await<boolean> {
return false
}
async delete (): Promise<void> {
}
async * getAll (): AwaitIterable<Pair> {
}
}
+41
View File
@@ -0,0 +1,41 @@
import errCode from 'err-code'
export function openFailedError (err?: Error): Error {
err = err ?? new Error('Open failed')
return errCode(err, 'ERR_OPEN_FAILED')
}
export function closeFailedError (err?: Error): Error {
err = err ?? new Error('Close failed')
return errCode(err, 'ERR_CLOSE_FAILED')
}
export function putFailedError (err?: Error): Error {
err = err ?? new Error('Put failed')
return errCode(err, 'ERR_PUT_FAILED')
}
export function getFailedError (err?: Error): Error {
err = err ?? new Error('Get failed')
return errCode(err, 'ERR_GET_FAILED')
}
export function deleteFailedError (err?: Error): Error {
err = err ?? new Error('Delete failed')
return errCode(err, 'ERR_DELETE_FAILED')
}
export function hasFailedError (err?: Error): Error {
err = err ?? new Error('Has failed')
return errCode(err, 'ERR_HAS_FAILED')
}
export function notFoundError (err?: Error): Error {
err = err ?? new Error('Not Found')
return errCode(err, 'ERR_NOT_FOUND')
}
export function abortedError (err?: Error): Error {
err = err ?? new Error('Aborted')
return errCode(err, 'ERR_ABORTED')
}
+8
View File
@@ -0,0 +1,8 @@
import * as ErrorsImport from './errors.js'
export { BaseBlockstore } from './base.js'
export { MemoryBlockstore } from './memory.js'
export const Errors = {
...ErrorsImport
}
+51
View File
@@ -0,0 +1,51 @@
import { base32 } from 'multiformats/bases/base32'
import { CID } from 'multiformats/cid'
import * as raw from 'multiformats/codecs/raw'
import * as Digest from 'multiformats/hashes/digest'
import { BaseBlockstore } from './base.js'
import * as Errors from './errors.js'
import type { Pair } from 'interface-blockstore'
import type { Await, AwaitIterable } from 'interface-store'
export class MemoryBlockstore extends BaseBlockstore {
private readonly data: Map<string, Uint8Array>
constructor () {
super()
this.data = new Map()
}
put (key: CID, val: Uint8Array): Await<CID> { // eslint-disable-line require-await
this.data.set(base32.encode(key.multihash.bytes), val)
return key
}
get (key: CID): Await<Uint8Array> {
const buf = this.data.get(base32.encode(key.multihash.bytes))
if (buf == null) {
throw Errors.notFoundError()
}
return buf
}
has (key: CID): Await<boolean> {
return this.data.has(base32.encode(key.multihash.bytes))
}
async delete (key: CID): Promise<void> {
this.data.delete(base32.encode(key.multihash.bytes))
}
async * getAll (): AwaitIterable<Pair> {
for (const [key, value] of this.data.entries()) {
yield {
cid: CID.createV1(raw.code, Digest.decode(base32.decode(key))),
block: value
}
}
}
}