@helia/utils 2.5.2-1361bfa5 → 2.5.2-16d805e1
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/dist/index.min.js +1 -22
- package/dist/index.min.js.map +4 -4
- package/dist/src/index.d.ts +5 -171
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -162
- package/dist/src/index.js.map +1 -1
- package/dist/src/is-cid.d.ts.map +1 -0
- package/dist/src/is-cid.js.map +1 -0
- package/dist/src/is-promise.d.ts.map +1 -0
- package/dist/src/is-promise.js.map +1 -0
- package/package.json +7 -24
- package/src/index.ts +5 -368
- package/dist/src/pins.d.ts +0 -21
- package/dist/src/pins.d.ts.map +0 -1
- package/dist/src/pins.js +0 -141
- package/dist/src/pins.js.map +0 -1
- package/dist/src/routing.d.ts +0 -51
- package/dist/src/routing.d.ts.map +0 -1
- package/dist/src/routing.js +0 -311
- package/dist/src/routing.js.map +0 -1
- package/dist/src/storage.d.ts +0 -62
- package/dist/src/storage.d.ts.map +0 -1
- package/dist/src/storage.js +0 -159
- package/dist/src/storage.js.map +0 -1
- package/dist/src/utils/constants.d.ts +0 -4
- package/dist/src/utils/constants.d.ts.map +0 -1
- package/dist/src/utils/constants.js +0 -4
- package/dist/src/utils/constants.js.map +0 -1
- package/dist/src/utils/datastore-version.d.ts +0 -3
- package/dist/src/utils/datastore-version.d.ts.map +0 -1
- package/dist/src/utils/datastore-version.js +0 -20
- package/dist/src/utils/datastore-version.js.map +0 -1
- package/dist/src/utils/get-codec.d.ts +0 -4
- package/dist/src/utils/get-codec.d.ts.map +0 -1
- package/dist/src/utils/get-codec.js +0 -37
- package/dist/src/utils/get-codec.js.map +0 -1
- package/dist/src/utils/get-crypto.d.ts +0 -4
- package/dist/src/utils/get-crypto.d.ts.map +0 -1
- package/dist/src/utils/get-crypto.js +0 -35
- package/dist/src/utils/get-crypto.js.map +0 -1
- package/dist/src/utils/get-hasher.d.ts +0 -4
- package/dist/src/utils/get-hasher.d.ts.map +0 -1
- package/dist/src/utils/get-hasher.js +0 -32
- package/dist/src/utils/get-hasher.js.map +0 -1
- package/dist/src/utils/is-cid.d.ts.map +0 -1
- package/dist/src/utils/is-cid.js.map +0 -1
- package/dist/src/utils/is-promise.d.ts.map +0 -1
- package/dist/src/utils/is-promise.js.map +0 -1
- package/dist/src/utils/networked-storage.d.ts +0 -28
- package/dist/src/utils/networked-storage.d.ts.map +0 -1
- package/dist/src/utils/networked-storage.js +0 -52
- package/dist/src/utils/networked-storage.js.map +0 -1
- package/dist/src/utils/session-storage.d.ts +0 -47
- package/dist/src/utils/session-storage.d.ts.map +0 -1
- package/dist/src/utils/session-storage.js +0 -148
- package/dist/src/utils/session-storage.js.map +0 -1
- package/dist/src/utils/storage.d.ts +0 -55
- package/dist/src/utils/storage.d.ts.map +0 -1
- package/dist/src/utils/storage.js +0 -225
- package/dist/src/utils/storage.js.map +0 -1
- package/src/pins.ts +0 -209
- package/src/routing.ts +0 -389
- package/src/storage.ts +0 -194
- package/src/utils/constants.ts +0 -3
- package/src/utils/datastore-version.ts +0 -25
- package/src/utils/get-codec.ts +0 -45
- package/src/utils/get-crypto.ts +0 -44
- package/src/utils/get-hasher.ts +0 -40
- package/src/utils/networked-storage.ts +0 -74
- package/src/utils/session-storage.ts +0 -174
- package/src/utils/storage.ts +0 -294
- /package/dist/src/{utils/is-cid.d.ts → is-cid.d.ts} +0 -0
- /package/dist/src/{utils/is-cid.js → is-cid.js} +0 -0
- /package/dist/src/{utils/is-promise.d.ts → is-promise.d.ts} +0 -0
- /package/dist/src/{utils/is-promise.js → is-promise.js} +0 -0
- /package/src/{utils/is-cid.ts → is-cid.ts} +0 -0
- /package/src/{utils/is-promise.ts → is-promise.ts} +0 -0
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { UnknownCodecError } from '@helia/interface';
|
|
2
|
-
import * as dagCbor from '@ipld/dag-cbor';
|
|
3
|
-
import * as dagJson from '@ipld/dag-json';
|
|
4
|
-
import * as dagPb from '@ipld/dag-pb';
|
|
5
|
-
import * as json from 'multiformats/codecs/json';
|
|
6
|
-
import * as raw from 'multiformats/codecs/raw';
|
|
7
|
-
import { isPromise } from "./is-promise.js";
|
|
8
|
-
export function getCodec(initialCodecs = [], loadCodec) {
|
|
9
|
-
const codecs = {
|
|
10
|
-
[dagPb.code]: dagPb,
|
|
11
|
-
[raw.code]: raw,
|
|
12
|
-
[dagCbor.code]: dagCbor,
|
|
13
|
-
[dagJson.code]: dagJson,
|
|
14
|
-
[json.code]: json
|
|
15
|
-
};
|
|
16
|
-
initialCodecs.forEach(codec => {
|
|
17
|
-
codecs[codec.code] = codec;
|
|
18
|
-
});
|
|
19
|
-
return async (code) => {
|
|
20
|
-
let codec = codecs[code];
|
|
21
|
-
if (codec == null && loadCodec != null) {
|
|
22
|
-
const res = loadCodec(code);
|
|
23
|
-
if (isPromise(res)) {
|
|
24
|
-
codec = await res;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
codec = res;
|
|
28
|
-
}
|
|
29
|
-
codecs[codec.code] = codec;
|
|
30
|
-
}
|
|
31
|
-
if (codec != null) {
|
|
32
|
-
return codec;
|
|
33
|
-
}
|
|
34
|
-
throw new UnknownCodecError(`Could not load codec for ${code}`);
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=get-codec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-codec.js","sourceRoot":"","sources":["../../../src/utils/get-codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,0BAA0B,CAAA;AAChD,OAAO,KAAK,GAAG,MAAM,yBAAyB,CAAA;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],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD,wBAAgB,SAAS,CAAE,cAAc,GAAE,KAAK,CAAC,MAAM,CAAM,EAAE,UAAU,CAAC,EAAE,YAAY,GAAG,YAAY,CAqCtG"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { UnknownCryptoError } from '@helia/interface';
|
|
2
|
-
import { ecdsaCrypto, ed25519Crypto, rsaCrypto } from '@ipshipyard/crypto';
|
|
3
|
-
import { isPromise } from "./is-promise.js";
|
|
4
|
-
export function getCrypto(initialCryptos = [], loadCrypto) {
|
|
5
|
-
const cryptos = {};
|
|
6
|
-
initialCryptos = [
|
|
7
|
-
ecdsaCrypto(),
|
|
8
|
-
ed25519Crypto(),
|
|
9
|
-
rsaCrypto(),
|
|
10
|
-
...initialCryptos
|
|
11
|
-
];
|
|
12
|
-
initialCryptos.forEach(crypto => {
|
|
13
|
-
cryptos[crypto.type] = crypto;
|
|
14
|
-
cryptos[crypto.code] = crypto;
|
|
15
|
-
});
|
|
16
|
-
return async (nameOrCode) => {
|
|
17
|
-
let crypto = cryptos[nameOrCode];
|
|
18
|
-
if (crypto == null && loadCrypto != null) {
|
|
19
|
-
const res = loadCrypto(nameOrCode);
|
|
20
|
-
if (isPromise(res)) {
|
|
21
|
-
crypto = await res;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
crypto = res;
|
|
25
|
-
}
|
|
26
|
-
cryptos[crypto.type] = crypto;
|
|
27
|
-
cryptos[crypto.code] = crypto;
|
|
28
|
-
}
|
|
29
|
-
if (crypto != null) {
|
|
30
|
-
return crypto;
|
|
31
|
-
}
|
|
32
|
-
throw new UnknownCryptoError(`Could not load crypto for ${crypto}`);
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=get-crypto.js.map
|
|
@@ -1 +0,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ACf,CAAC;QAED,MAAM,IAAI,kBAAkB,CAAC,6BAA6B,MAAM,EAAE,CAAC,CAAA;IACrE,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { HasherLoader } from '@helia/interface';
|
|
2
|
-
import type { MultihashHasher } from 'multiformats/hashes/interface';
|
|
3
|
-
export declare function getHasher(initialHashers?: MultihashHasher[], loadHasher?: HasherLoader): HasherLoader;
|
|
4
|
-
//# sourceMappingURL=get-hasher.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-hasher.d.ts","sourceRoot":"","sources":["../../../src/utils/get-hasher.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAEpE,wBAAgB,SAAS,CAAE,cAAc,GAAE,eAAe,EAAO,EAAE,UAAU,CAAC,EAAE,YAAY,GAAG,YAAY,CAgC1G"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { UnknownHashAlgorithmError } from '@helia/interface';
|
|
2
|
-
import { identity } from 'multiformats/hashes/identity';
|
|
3
|
-
import { sha256, sha512 } from 'multiformats/hashes/sha2';
|
|
4
|
-
import { isPromise } from "./is-promise.js";
|
|
5
|
-
export function getHasher(initialHashers = [], loadHasher) {
|
|
6
|
-
const hashers = {
|
|
7
|
-
[sha256.code]: sha256,
|
|
8
|
-
[sha512.code]: sha512,
|
|
9
|
-
[identity.code]: identity
|
|
10
|
-
};
|
|
11
|
-
initialHashers.forEach(hasher => {
|
|
12
|
-
hashers[hasher.code] = hasher;
|
|
13
|
-
});
|
|
14
|
-
return async (code) => {
|
|
15
|
-
let hasher = hashers[code];
|
|
16
|
-
if (hasher == null && loadHasher != null) {
|
|
17
|
-
const res = loadHasher(code);
|
|
18
|
-
if (isPromise(res)) {
|
|
19
|
-
hasher = await res;
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
hasher = res;
|
|
23
|
-
}
|
|
24
|
-
hashers[hasher.code] = hasher;
|
|
25
|
-
}
|
|
26
|
-
if (hasher != null) {
|
|
27
|
-
return hasher;
|
|
28
|
-
}
|
|
29
|
-
throw new UnknownHashAlgorithmError(`No hasher configured for multihash code 0x${code.toString(16)}, please configure one. You can look up which hash this is at https://github.com/multiformats/multicodec/blob/master/table.csv`);
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=get-hasher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-hasher.js","sourceRoot":"","sources":["../../../src/utils/get-hasher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAI3C,MAAM,UAAU,SAAS,CAAE,iBAAoC,EAAE,EAAE,UAAyB;IAC1F,MAAM,OAAO,GAAoC;QAC/C,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM;QACrB,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM;QACrB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ;KAC1B,CAAA;IAED,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC9B,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAA;IAC/B,CAAC,CAAC,CAAA;IAEF,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,IAAI,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;QAE1B,IAAI,MAAM,IAAI,IAAI,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;YACzC,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,CAAA;YAE5B,IAAI,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;gBACnB,MAAM,GAAG,MAAM,GAAG,CAAA;YACpB,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,GAAG,CAAA;YACd,CAAC;YAED,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAA;QAC/B,CAAC;QAED,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;YACnB,OAAO,MAAM,CAAA;QACf,CAAC;QAED,MAAM,IAAI,yBAAyB,CAAC,6CAA6C,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,gIAAgI,CAAC,CAAA;IACrO,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-cid.d.ts","sourceRoot":"","sources":["../../../src/utils/is-cid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAEtC,wBAAgB,KAAK,CAAE,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,IAAI,GAAG,CAM5C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-cid.js","sourceRoot":"","sources":["../../../src/utils/is-cid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAEtC,MAAM,UAAU,KAAK,CAAE,GAAS;IAC9B,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,IAAI,CAAA;AAC/B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-promise.d.ts","sourceRoot":"","sources":["../../../src/utils/is-promise.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAE,CAAC,EAAG,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAEvD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is-promise.js","sourceRoot":"","sources":["../../../src/utils/is-promise.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAM,CAAO;IACpC,OAAO,CAAC,EAAE,IAAI,IAAI,IAAI,CAAA;AACxB,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Storage } from './storage.ts';
|
|
2
|
-
import type { StorageComponents, StorageInit } from './storage.ts';
|
|
3
|
-
import type { BlockBroker, Blocks, CreateSessionOptions, SessionBlockstore } from '@helia/interface';
|
|
4
|
-
import type { Startable } from '@libp2p/interface';
|
|
5
|
-
import type { AbortOptions } from 'abort-error';
|
|
6
|
-
import type { Blockstore } from 'interface-blockstore';
|
|
7
|
-
import type { CID } from 'multiformats/cid';
|
|
8
|
-
export interface GetOptions extends AbortOptions {
|
|
9
|
-
progress?(evt: Event): void;
|
|
10
|
-
}
|
|
11
|
-
export type NetworkedStorageComponents = StorageComponents<BlockBroker>;
|
|
12
|
-
/**
|
|
13
|
-
* Networked storage wraps a regular blockstore - when getting blocks if the
|
|
14
|
-
* blocks are not present, the configured BlockBrokers will be used to fetch them.
|
|
15
|
-
*/
|
|
16
|
-
export declare class NetworkedStorage extends Storage<BlockBroker> implements Blocks, Startable {
|
|
17
|
-
private started;
|
|
18
|
-
/**
|
|
19
|
-
* Create a new BlockStorage
|
|
20
|
-
*/
|
|
21
|
-
constructor(components: NetworkedStorageComponents, init?: StorageInit);
|
|
22
|
-
isStarted(): boolean;
|
|
23
|
-
start(): Promise<void>;
|
|
24
|
-
stop(): Promise<void>;
|
|
25
|
-
unwrap(): Blockstore;
|
|
26
|
-
createSession(root: CID, options?: CreateSessionOptions): SessionBlockstore;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=networked-storage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"networked-storage.d.ts","sourceRoot":"","sources":["../../../src/utils/networked-storage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAE3C,MAAM,WAAW,UAAW,SAAQ,YAAY;IAC9C,QAAQ,CAAC,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,CAAA;CAC5B;AAED,MAAM,MAAM,0BAA0B,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAA;AAEvE;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,OAAO,CAAC,WAAW,CAAE,YAAW,MAAM,EAAE,SAAS;IACrF,OAAO,CAAC,OAAO,CAAS;IAExB;;OAEG;gBACU,UAAU,EAAE,0BAA0B,EAAE,IAAI,GAAE,WAAgB;IAM3E,SAAS,IAAK,OAAO;IAIf,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;IAKvB,IAAI,IAAK,OAAO,CAAC,IAAI,CAAC;IAK5B,MAAM,IAAK,UAAU;IAIrB,aAAa,CAAE,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,iBAAiB;CAsB7E"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { start, stop } from '@libp2p/interface';
|
|
2
|
-
import { InvalidConfigurationError } from "../errors.js";
|
|
3
|
-
import { SessionStorage } from "./session-storage.js";
|
|
4
|
-
import { Storage } from "./storage.js";
|
|
5
|
-
/**
|
|
6
|
-
* Networked storage wraps a regular blockstore - when getting blocks if the
|
|
7
|
-
* blocks are not present, the configured BlockBrokers will be used to fetch them.
|
|
8
|
-
*/
|
|
9
|
-
export class NetworkedStorage extends Storage {
|
|
10
|
-
started;
|
|
11
|
-
/**
|
|
12
|
-
* Create a new BlockStorage
|
|
13
|
-
*/
|
|
14
|
-
constructor(components, init = {}) {
|
|
15
|
-
super(components, init);
|
|
16
|
-
this.started = false;
|
|
17
|
-
}
|
|
18
|
-
isStarted() {
|
|
19
|
-
return this.started;
|
|
20
|
-
}
|
|
21
|
-
async start() {
|
|
22
|
-
await start(this.child, ...this.blockBrokers);
|
|
23
|
-
this.started = true;
|
|
24
|
-
}
|
|
25
|
-
async stop() {
|
|
26
|
-
await stop(this.child, ...this.blockBrokers);
|
|
27
|
-
this.started = false;
|
|
28
|
-
}
|
|
29
|
-
unwrap() {
|
|
30
|
-
return this.child;
|
|
31
|
-
}
|
|
32
|
-
createSession(root, options) {
|
|
33
|
-
if (this.blockBrokers.length === 0) {
|
|
34
|
-
throw new InvalidConfigurationError('No block brokers configured');
|
|
35
|
-
}
|
|
36
|
-
const blockBrokers = this.blockBrokers
|
|
37
|
-
.map(broker => broker.createSession?.(options))
|
|
38
|
-
.filter(broker => broker != null);
|
|
39
|
-
if (blockBrokers.length === 0) {
|
|
40
|
-
throw new InvalidConfigurationError(`No configured block brokers support sessions - tried ${this.blockBrokers.map(b => b.name).join(', ')}`);
|
|
41
|
-
}
|
|
42
|
-
return new SessionStorage({
|
|
43
|
-
blockstore: this.child,
|
|
44
|
-
blockBrokers,
|
|
45
|
-
getHasher: this.getHasher,
|
|
46
|
-
logger: this.logger
|
|
47
|
-
}, {
|
|
48
|
-
root
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=networked-storage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
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AO,CAAC,CAAC;aAC9C,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,IAAI,IAAI,CAAC,CAAA;QAEnC,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,yBAAyB,CAAC,wDAAwD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC9I,CAAC;QAED,OAAO,IAAI,cAAc,CAAC;YACxB,UAAU,EAAE,IAAI,CAAC,KAAK;YACtB,YAAY;YACZ,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,EAAE;YACD,IAAI;SACL,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Storage } from './storage.ts';
|
|
2
|
-
import type { StorageComponents } from './storage.ts';
|
|
3
|
-
import type { Pair, DeleteManyBlocksProgressEvents, DeleteBlockProgressEvents, GetBlockProgressEvents, GetManyBlocksProgressEvents, PutManyBlocksProgressEvents, PutBlockProgressEvents, GetAllBlocksProgressEvents, GetOfflineOptions, SessionBlockstore, SessionBlockBroker } from '@helia/interface';
|
|
4
|
-
import type { AbortOptions } from '@libp2p/interface';
|
|
5
|
-
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
6
|
-
import type { InputPair } from 'interface-blockstore';
|
|
7
|
-
import type { CID } from 'multiformats/cid';
|
|
8
|
-
import type { ProgressOptions } from 'progress-events';
|
|
9
|
-
export interface SessionStorageInit {
|
|
10
|
-
root: CID;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Storage subclass that can cancel any ongoing operation at any point.
|
|
14
|
-
*/
|
|
15
|
-
export declare class SessionStorage extends Storage<SessionBlockBroker> implements SessionBlockstore {
|
|
16
|
-
private readonly closeController;
|
|
17
|
-
constructor(components: StorageComponents<SessionBlockBroker>, init: SessionStorageInit);
|
|
18
|
-
close(): void;
|
|
19
|
-
addPeer(peer: CID | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Put a block to the underlying datastore
|
|
22
|
-
*/
|
|
23
|
-
put(cid: CID, block: Uint8Array, options?: AbortOptions & ProgressOptions<PutBlockProgressEvents>): Promise<CID>;
|
|
24
|
-
/**
|
|
25
|
-
* Put a multiple blocks to the underlying datastore
|
|
26
|
-
*/
|
|
27
|
-
putMany(blocks: Iterable<InputPair> | AsyncIterable<InputPair>, options?: AbortOptions & ProgressOptions<PutManyBlocksProgressEvents>): AsyncGenerator<CID>;
|
|
28
|
-
/**
|
|
29
|
-
* Get a block by cid
|
|
30
|
-
*/
|
|
31
|
-
get(cid: CID, options?: GetOfflineOptions & AbortOptions & ProgressOptions<GetBlockProgressEvents>): AsyncGenerator<Uint8Array>;
|
|
32
|
-
/**
|
|
33
|
-
* Get multiple blocks back from an (async) iterable of cids
|
|
34
|
-
*/
|
|
35
|
-
getMany(cids: Iterable<CID> | AsyncIterable<CID>, options?: GetOfflineOptions & AbortOptions & ProgressOptions<GetManyBlocksProgressEvents>): AsyncGenerator<Pair>;
|
|
36
|
-
/**
|
|
37
|
-
* Delete a block from the blockstore
|
|
38
|
-
*/
|
|
39
|
-
delete(cid: CID, options?: AbortOptions & ProgressOptions<DeleteBlockProgressEvents>): Promise<void>;
|
|
40
|
-
/**
|
|
41
|
-
* Delete multiple blocks from the blockstore
|
|
42
|
-
*/
|
|
43
|
-
deleteMany(cids: Iterable<CID> | AsyncIterable<CID>, options?: AbortOptions & ProgressOptions<DeleteManyBlocksProgressEvents>): AsyncGenerator<CID>;
|
|
44
|
-
has(cid: CID, options?: AbortOptions): Promise<boolean>;
|
|
45
|
-
getAll(options?: AbortOptions & ProgressOptions<GetAllBlocksProgressEvents>): AsyncGenerator<Pair>;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=session-storage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-storage.d.ts","sourceRoot":"","sources":["../../../src/utils/session-storage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,KAAK,EAAE,IAAI,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACvS,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,GAAG,CAAA;CACV;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,OAAO,CAAC,kBAAkB,CAAE,YAAW,iBAAiB;IAC1F,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAiB;gBAEpC,UAAU,EAAE,iBAAiB,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,kBAAkB;IAYxF,KAAK,IAAK,IAAI;IAIR,OAAO,CAAE,IAAI,EAAE,GAAG,GAAG,SAAS,GAAG,SAAS,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAO1F;;OAEG;IACG,GAAG,CAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,GAAE,YAA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{ Storage } from "./storage.js";
|
|
4
|
-
/**
|
|
5
|
-
* Storage subclass that can cancel any ongoing operation at any point.
|
|
6
|
-
*/
|
|
7
|
-
export class SessionStorage extends Storage {
|
|
8
|
-
closeController;
|
|
9
|
-
constructor(components, init) {
|
|
10
|
-
super(components);
|
|
11
|
-
// because brokers are allowed to continue searching for providers after the
|
|
12
|
-
// session has been created, we need a way to tell them that the user has
|
|
13
|
-
// finished using the session any in-flight requests should be cancelled
|
|
14
|
-
this.closeController = new AbortController();
|
|
15
|
-
setMaxListeners(Infinity, this.closeController.signal);
|
|
16
|
-
this.log = components.logger.forComponent(`helia:session-storage:${init.root}`);
|
|
17
|
-
}
|
|
18
|
-
close() {
|
|
19
|
-
this.closeController.abort();
|
|
20
|
-
}
|
|
21
|
-
async addPeer(peer, options) {
|
|
22
|
-
await Promise.all(this.blockBrokers
|
|
23
|
-
.map(broker => broker.addPeer(peer, options)));
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Put a block to the underlying datastore
|
|
27
|
-
*/
|
|
28
|
-
async put(cid, block, options = {}) {
|
|
29
|
-
const signal = anySignal([this.closeController.signal, options.signal]);
|
|
30
|
-
setMaxListeners(Infinity, signal);
|
|
31
|
-
try {
|
|
32
|
-
return await super.put(cid, block, {
|
|
33
|
-
...options,
|
|
34
|
-
signal
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
finally {
|
|
38
|
-
signal.clear();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Put a multiple blocks to the underlying datastore
|
|
43
|
-
*/
|
|
44
|
-
async *putMany(blocks, options = {}) {
|
|
45
|
-
const signal = anySignal([this.closeController.signal, options.signal]);
|
|
46
|
-
setMaxListeners(Infinity, signal);
|
|
47
|
-
try {
|
|
48
|
-
yield* super.putMany(blocks, {
|
|
49
|
-
...options,
|
|
50
|
-
signal
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
finally {
|
|
54
|
-
signal.clear();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Get a block by cid
|
|
59
|
-
*/
|
|
60
|
-
async *get(cid, options = {}) {
|
|
61
|
-
const signal = anySignal([this.closeController.signal, options.signal]);
|
|
62
|
-
setMaxListeners(Infinity, signal);
|
|
63
|
-
try {
|
|
64
|
-
yield* super.get(cid, {
|
|
65
|
-
...options,
|
|
66
|
-
signal
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
finally {
|
|
70
|
-
signal.clear();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Get multiple blocks back from an (async) iterable of cids
|
|
75
|
-
*/
|
|
76
|
-
async *getMany(cids, options = {}) {
|
|
77
|
-
const signal = anySignal([this.closeController.signal, options.signal]);
|
|
78
|
-
setMaxListeners(Infinity, signal);
|
|
79
|
-
try {
|
|
80
|
-
yield* super.getMany(cids, {
|
|
81
|
-
...options,
|
|
82
|
-
signal
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
finally {
|
|
86
|
-
signal.clear();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Delete a block from the blockstore
|
|
91
|
-
*/
|
|
92
|
-
async delete(cid, options = {}) {
|
|
93
|
-
const signal = anySignal([this.closeController.signal, options.signal]);
|
|
94
|
-
setMaxListeners(Infinity, signal);
|
|
95
|
-
try {
|
|
96
|
-
await super.delete(cid, {
|
|
97
|
-
...options,
|
|
98
|
-
signal
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
finally {
|
|
102
|
-
signal.clear();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Delete multiple blocks from the blockstore
|
|
107
|
-
*/
|
|
108
|
-
async *deleteMany(cids, options = {}) {
|
|
109
|
-
const signal = anySignal([this.closeController.signal, options.signal]);
|
|
110
|
-
setMaxListeners(Infinity, signal);
|
|
111
|
-
try {
|
|
112
|
-
yield* super.deleteMany(cids, {
|
|
113
|
-
...options,
|
|
114
|
-
signal
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
finally {
|
|
118
|
-
signal.clear();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
async has(cid, options = {}) {
|
|
122
|
-
const signal = anySignal([this.closeController.signal, options.signal]);
|
|
123
|
-
setMaxListeners(Infinity, signal);
|
|
124
|
-
try {
|
|
125
|
-
return await super.has(cid, {
|
|
126
|
-
...options,
|
|
127
|
-
signal
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
finally {
|
|
131
|
-
signal.clear();
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
async *getAll(options = {}) {
|
|
135
|
-
const signal = anySignal([this.closeController.signal, options.signal]);
|
|
136
|
-
setMaxListeners(Infinity, signal);
|
|
137
|
-
try {
|
|
138
|
-
yield* super.getAll({
|
|
139
|
-
...options,
|
|
140
|
-
signal
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
finally {
|
|
144
|
-
signal.clear();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
//# sourceMappingURL=session-storage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-storage.js","sourceRoot":"","sources":["../../../src/utils/session-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAatC;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,OAA2B;IAC5C,eAAe,CAAiB;IAEjD,YAAa,UAAiD,EAAE,IAAwB;QACtF,KAAK,CAAC,UAAU,CAAC,CAAA;QAEjB,4EAA4E;QAC5E,yEAAyE;QACzE,wEAAwE;QACxE,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,EAAE,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AI,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;QACvE,eAAe,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAEjC,IAAI,CAAC;YACH,KAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;gBACnB,GAAG,OAAO;gBACV,MAAM;aACP,CAAC,CAAA;QACJ,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,KAAK,EAAE,CAAA;QAChB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { HasherLoader } from '@helia/interface';
|
|
2
|
-
import type { BlockBroker, Pair, DeleteManyBlocksProgressEvents, DeleteBlockProgressEvents, GetBlockProgressEvents, GetManyBlocksProgressEvents, PutManyBlocksProgressEvents, PutBlockProgressEvents, GetAllBlocksProgressEvents, GetOfflineOptions, BlockRetrievalOptions } from '@helia/interface';
|
|
3
|
-
import type { AbortOptions, ComponentLogger, Logger } from '@libp2p/interface';
|
|
4
|
-
import type { Blockstore, InputPair } from 'interface-blockstore';
|
|
5
|
-
import type { CID } from 'multiformats/cid';
|
|
6
|
-
import type { MultihashHasher } from 'multiformats/hashes/interface';
|
|
7
|
-
import type { ProgressEvent, ProgressOptions } from 'progress-events';
|
|
8
|
-
export interface StorageComponents<Broker extends BlockBroker<ProgressEvent<any, any>, ProgressEvent<any, any>>> {
|
|
9
|
-
blockstore: Blockstore;
|
|
10
|
-
logger: ComponentLogger;
|
|
11
|
-
blockBrokers: Broker[];
|
|
12
|
-
getHasher: HasherLoader;
|
|
13
|
-
}
|
|
14
|
-
export interface StorageInit {
|
|
15
|
-
maxIdentityHashDigestLength?: number;
|
|
16
|
-
}
|
|
17
|
-
export declare class Storage<Broker extends BlockBroker<ProgressEvent<any, any>, ProgressEvent<any, any>>> implements Blockstore {
|
|
18
|
-
protected readonly child: Blockstore;
|
|
19
|
-
protected readonly getHasher: HasherLoader;
|
|
20
|
-
protected log: Logger;
|
|
21
|
-
protected readonly logger: ComponentLogger;
|
|
22
|
-
protected readonly blockBrokers: Broker[];
|
|
23
|
-
/**
|
|
24
|
-
* Create a new BlockStorage
|
|
25
|
-
*/
|
|
26
|
-
constructor(components: StorageComponents<Broker>, init?: StorageInit);
|
|
27
|
-
/**
|
|
28
|
-
* Put a block to the underlying datastore
|
|
29
|
-
*/
|
|
30
|
-
put(cid: CID, block: Uint8Array, options?: AbortOptions & ProgressOptions<PutBlockProgressEvents>): Promise<CID>;
|
|
31
|
-
/**
|
|
32
|
-
* Put a multiple blocks to the underlying datastore
|
|
33
|
-
*/
|
|
34
|
-
putMany(blocks: Iterable<InputPair> | AsyncIterable<InputPair>, options?: AbortOptions & ProgressOptions<PutManyBlocksProgressEvents>): AsyncGenerator<CID>;
|
|
35
|
-
/**
|
|
36
|
-
* Get a block by cid
|
|
37
|
-
*/
|
|
38
|
-
get(cid: CID, options?: GetOfflineOptions & AbortOptions & ProgressOptions<GetBlockProgressEvents>): AsyncGenerator<Uint8Array>;
|
|
39
|
-
/**
|
|
40
|
-
* Get multiple blocks back from an (async) iterable of cids
|
|
41
|
-
*/
|
|
42
|
-
getMany(cids: Iterable<CID> | AsyncIterable<CID>, options?: GetOfflineOptions & AbortOptions & ProgressOptions<GetManyBlocksProgressEvents>): AsyncGenerator<Pair>;
|
|
43
|
-
/**
|
|
44
|
-
* Delete a block from the blockstore
|
|
45
|
-
*/
|
|
46
|
-
delete(cid: CID, options?: AbortOptions & ProgressOptions<DeleteBlockProgressEvents>): Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* Delete multiple blocks from the blockstore
|
|
49
|
-
*/
|
|
50
|
-
deleteMany(cids: Iterable<CID> | AsyncIterable<CID>, options?: AbortOptions & ProgressOptions<DeleteManyBlocksProgressEvents>): AsyncGenerator<CID>;
|
|
51
|
-
has(cid: CID, options?: AbortOptions): Promise<boolean>;
|
|
52
|
-
getAll(options?: AbortOptions & ProgressOptions<GetAllBlocksProgressEvents>): AsyncGenerator<Pair>;
|
|
53
|
-
}
|
|
54
|
-
export declare const getCidBlockVerifierFunction: (cid: CID, hasher: MultihashHasher) => Required<BlockRetrievalOptions>["validateFn"];
|
|
55
|
-
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/utils/storage.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AACpS,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,EAAiB,MAAM,mBAAmB,CAAA;AAC7F,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAmB,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAErE,MAAM,WAAW,iBAAiB,CAAC,MAAM,SAAS,WAAW,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC7G,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,eAAe,CAAA;IACvB,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,SAAS,EAAE,YAAY,CAAA;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,2BAA2B,CAAC,EAAE,MAAM,CAAA;CACrC;AAID,qBAAa,OAAO,CAAE,MAAM,SAAS,WAAW,CAAC,aA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