@helia/interface 6.2.1-eb1908b3 → 6.2.1-ed6c3b79
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 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/blocks.d.ts +8 -8
- package/dist/src/blocks.d.ts.map +1 -1
- package/dist/src/errors.d.ts +4 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +4 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/index.d.ts +61 -16
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/pins.d.ts +1 -1
- package/dist/src/pins.d.ts.map +1 -1
- package/dist/src/routing.d.ts +66 -25
- package/dist/src/routing.d.ts.map +1 -1
- package/package.json +12 -8
- package/src/blocks.ts +8 -8
- package/src/errors.ts +5 -0
- package/src/index.ts +72 -17
- package/src/pins.ts +1 -1
- package/src/routing.ts +72 -25
package/dist/index.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaInterface = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var HeliaInterface=(()=>{var
|
|
2
|
+
"use strict";var HeliaInterface=(()=>{var n=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var y=(r,e)=>{for(var o in e)n(r,o,{get:e[o],enumerable:!0})},I=(r,e,o,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of E(e))!d.call(r,t)&&t!==o&&n(r,t,{get:()=>e[t],enumerable:!(x=l(e,t))||x.enumerable});return r};var h=r=>I(n({},"__esModule",{value:!0}),r);var _={};y(_,{DEFAULT_CID_PEER_FILTER_SIZE:()=>C,DEFAULT_SESSION_MAX_PROVIDERS:()=>U,DEFAULT_SESSION_MIN_PROVIDERS:()=>P,InsufficientProvidersError:()=>c,InvalidCodecError:()=>u,NoRoutersAvailableError:()=>i,UnknownCodecError:()=>p,UnknownCryptoError:()=>f,UnknownHashAlgorithmError:()=>a,isPrivateKey:()=>m,isPublicKey:()=>s});function s(r){return r==null?!1:typeof r.type=="string"&&typeof r.code=="number"&&typeof r.verify=="function"}function m(r){return r==null?!1:typeof r.type=="string"&&typeof r.code=="number"&&typeof r.sign=="function"&&s(r.publicKey)}var P=1,U=5,C=100;var c=class extends Error{static name="InsufficientProvidersError";constructor(e="Insufficient providers found"){super(e),this.name="InsufficientProvidersError"}},i=class extends Error{static name="NoRoutersAvailableError";constructor(e="No routers available"){super(e),this.name="NoRoutersAvailableError"}},a=class extends Error{static name="UnknownHashAlgorithmError";constructor(e="Unknown hash algorithm"){super(e),this.name="UnknownHashAlgorithmError"}},p=class extends Error{static name="UnknownCodecError";constructor(e="Unknown codec"){super(e),this.name="UnknownCodecError"}},u=class extends Error{static name="InvalidCodecError";constructor(e="Invalid codec"){super(e),this.name="InvalidCodecError"}},f=class extends Error{static name="UnknownCryptoError";name="UnknownCryptoError"};return h(_);})();
|
|
3
3
|
return HeliaInterface}));
|
|
4
4
|
//# sourceMappingURL=index.min.js.map
|
package/dist/index.min.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts", "../src/blocks.ts", "../src/errors.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @packageDocumentation\n *\n * The API defined by a {@link Helia} node\n *\n * @example\n *\n * ```typescript\n * import type { Helia } from '@helia/interface'\n *\n * export function doSomething(helia: Helia) {\n * // use helia node functions here\n * }\n * ```\n */\n\nimport type { Blocks } from './blocks.ts'\nimport type { Pins } from './pins.ts'\nimport type { Routing } from './routing.ts'\nimport type { AbortOptions, ComponentLogger, Libp2p, Metrics, TypedEventEmitter } from '@libp2p/interface'\nimport type { DNS } from '@multiformats/dns'\nimport type { Datastore } from 'interface-datastore'\nimport type { Await } from 'interface-store'\nimport type { BlockCodec, MultihashHasher } from 'multiformats'\nimport type { CID } from 'multiformats/cid'\nimport type { ProgressEvent, ProgressOptions } from 'progress-events'\n\nexport type { Await, AwaitIterable } from 'interface-store'\n\nexport interface CodecLoader {\n <T = any, Code extends number = any>(code: Code): Await<BlockCodec<Code, T>>\n}\n\nexport interface HasherLoader {\n (code: number): Await<MultihashHasher>\n}\n\n/**\n * The API presented by a Helia node\n */\nexport interface Helia<T extends Libp2p = Libp2p> {\n /**\n * The libp2p instance\n */\n libp2p: T\n\n /**\n * Where the blocks are stored\n */\n blockstore: Blocks\n\n /**\n * A key/value store\n */\n datastore: Datastore\n\n /**\n * Event emitter for Helia start and stop events\n */\n events: TypedEventEmitter<HeliaEvents<T>>\n\n /**\n * Pinning operations for blocks in the blockstore\n */\n pins: Pins\n\n /**\n * A logging component that can be reused by consumers\n */\n logger: ComponentLogger\n\n /**\n * The routing component allows performing operations such as looking up\n * content providers, information about peers, etc.\n */\n routing: Routing\n\n /**\n * The DNS property can be used to perform lookups of various record types and\n * will use a resolver appropriate to the current platform.\n */\n dns: DNS\n\n /**\n * A metrics object that can be used to collected arbitrary stats about node\n * usage.\n */\n metrics?: Metrics\n\n /**\n * Starts the Helia node\n */\n start(): Promise<void>\n\n /**\n * Stops the Helia node\n */\n stop(): Promise<void>\n\n /**\n * Remove any unpinned blocks from the blockstore\n */\n gc(options?: GCOptions): Promise<void>\n\n /**\n * Load an IPLD codec. Implementations may return a promise if, for example,\n * the codec is being fetched from the network.\n */\n getCodec: CodecLoader\n\n /**\n * Hashers can be used to hash a piece of data with the specified hashing\n * algorithm. Implementations may return a promise if, for example,\n * the hasher is being fetched from the network.\n */\n getHasher: HasherLoader\n}\n\nexport type GcEvents =\n ProgressEvent<'helia:gc:deleted', CID> |\n ProgressEvent<'helia:gc:error', Error>\n\nexport interface GCOptions extends AbortOptions, ProgressOptions<GcEvents> {\n\n}\n\nexport interface HeliaEvents<T extends Libp2p = Libp2p> {\n /**\n * This event notifies listeners that the node has started\n *\n * ```TypeScript\n * helia.addEventListener('start', (event) => {\n * console.info(event.detail.libp2p.isStarted()) // true\n * })\n * ```\n */\n start: CustomEvent<Helia<T>>\n\n /**\n * This event notifies listeners that the node has stopped\n *\n * ```TypeScript\n * helia.addEventListener('stop', (event) => {\n * console.info(event.detail.libp2p.isStarted()) // false\n * })\n * ```\n */\n stop: CustomEvent<Helia<T>>\n}\n\nexport * from './blocks.ts'\nexport * from './errors.ts'\nexport * from './pins.ts'\nexport * from './routing.ts'\n", "import type { RoutingFindProvidersProgressEvents } from './routing.ts'\nimport type { PeerId, AbortOptions } from '@libp2p/interface'\nimport type { Multiaddr } from '@multiformats/multiaddr'\nimport type { Blockstore } from 'interface-blockstore'\nimport type { CID } from 'multiformats/cid'\nimport type { ProgressEvent, ProgressOptions } from 'progress-events'\n\nexport type { Pair, InputPair } from 'interface-blockstore'\n\nexport interface ProviderOptions {\n /**\n * An optional list of peers known to host at least the root block of the DAG\n * that will be fetched.\n *\n * If this list is omitted, or if the peers cannot supply the root or any\n * child blocks, a `findProviders` routing query will be run to find peers\n * that can supply the blocks.\n */\n providers?: Array<PeerId | Multiaddr | Multiaddr[]>\n}\n\n/**\n * A block broker will contact a provider to retrieve a block\n */\nexport interface BlockBrokerConnectProgressEvent {\n broker: string\n type: 'connect'\n provider: PeerId\n cid: CID\n}\n\n/**\n * A block broker has contacted a provider to retrieve a block\n */\nexport interface BlockBrokerConnectedProgressEvent {\n broker: string\n type: 'connected'\n provider: PeerId\n address: Multiaddr\n cid: CID\n}\n\n/**\n * A block broker has retrieved a block from a provider\n */\nexport interface BlockBrokerRequestBlockProgressEvent {\n broker: string\n type: 'request-block'\n provider: PeerId\n cid: CID\n}\n\n/**\n * A block broker has retrieved a block from a provider\n */\nexport interface BlockBrokerReceiveBlockProgressEvent {\n broker: string\n type: 'receive-block'\n provider: PeerId\n cid: CID\n}\n\nexport type BlockBrokerGetBlockProgressEvents = ProgressEvent<'helia:block-broker:connect', BlockBrokerConnectProgressEvent>\n | ProgressEvent<'helia:block-broker:connected', BlockBrokerConnectedProgressEvent>\n | ProgressEvent<'helia:block-broker:request-block', BlockBrokerRequestBlockProgressEvent>\n | ProgressEvent<'helia:block-broker:receive-block', BlockBrokerReceiveBlockProgressEvent>\n\nexport type HasBlockProgressEvents =\n ProgressEvent<'blocks:put:duplicate', CID> |\n ProgressEvent<'blocks:put:providers:notify', CID> |\n ProgressEvent<'blocks:put:blockstore:put', CID>\n\nexport type PutBlockProgressEvents =\n ProgressEvent<'blocks:put:duplicate', CID> |\n ProgressEvent<'blocks:put:providers:notify', CID> |\n ProgressEvent<'blocks:put:blockstore:put', CID>\n\nexport type PutManyBlocksProgressEvents =\n ProgressEvent<'blocks:put-many:duplicate', CID> |\n ProgressEvent<'blocks:put-many:providers:notify', CID> |\n ProgressEvent<'blocks:put-many:blockstore:put-many'>\n\nexport type GetBlockProgressEvents =\n ProgressEvent<'blocks:get:providers:want', CID> |\n ProgressEvent<'blocks:get:blockstore:get', CID> |\n ProgressEvent<'blocks:get:blockstore:put', CID> |\n RoutingFindProvidersProgressEvents |\n BlockBrokerGetBlockProgressEvents\n\nexport type GetManyBlocksProgressEvents =\n ProgressEvent<'blocks:get-many:blockstore:get-many'> |\n ProgressEvent<'blocks:get-many:providers:want', CID> |\n ProgressEvent<'blocks:get-many:blockstore:put', CID>\n\nexport type GetAllBlocksProgressEvents =\n ProgressEvent<'blocks:get-all:blockstore:get-many'>\n\nexport type DeleteBlockProgressEvents =\n ProgressEvent<'blocks:delete:blockstore:delete', CID>\n\nexport type DeleteManyBlocksProgressEvents =\n ProgressEvent<'blocks:delete-many:blockstore:delete-many'>\n\nexport interface GetOfflineOptions {\n /**\n * If true, do not attempt to fetch any missing blocks from the network\n *\n * @default false\n */\n offline?: boolean\n}\n\nexport interface Blocks extends Blockstore<ProgressOptions<HasBlockProgressEvents>,\nProgressOptions<PutBlockProgressEvents>, ProgressOptions<PutManyBlocksProgressEvents>,\nGetOfflineOptions & ProviderOptions & ProgressOptions<GetBlockProgressEvents>,\nGetOfflineOptions & ProviderOptions & ProgressOptions<GetManyBlocksProgressEvents>,\nProgressOptions<GetAllBlocksProgressEvents>,\nProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProgressEvents>\n> {\n /**\n * A blockstore session only fetches blocks from a subset of network peers to\n * reduce network traffic and improve performance.\n *\n * The initial set of peers can be specified, alternatively a `findProviders`\n * routing query will occur to populate the set instead.\n */\n createSession(root: CID, options?: CreateSessionOptions<GetBlockProgressEvents>): SessionBlockstore\n}\n\n/**\n * A session blockstore is a special blockstore that only pulls content from a\n * subset of network peers which respond as having the block for the initial\n * root CID.\n *\n * Any blocks written to the blockstore as part of the session will propagate\n * to the blockstore the session was created from.\n *\n */\nexport interface SessionBlockstore extends Blockstore<ProgressOptions<HasBlockProgressEvents>,\nProgressOptions<PutBlockProgressEvents>, ProgressOptions<PutManyBlocksProgressEvents>,\nGetOfflineOptions & ProgressOptions<GetBlockProgressEvents>, GetOfflineOptions & ProgressOptions<GetManyBlocksProgressEvents>, ProgressOptions<GetAllBlocksProgressEvents>,\nProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProgressEvents>\n> {\n /**\n * Any in-progress operations will be aborted.\n */\n close(): void\n\n /**\n * Adds a new peer to the session if they are supported and are either\n * not already in the session and have not been evicted previously.\n */\n addPeer (peer: PeerId | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<void>\n}\n\nexport interface BlockRetrievalOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents>, ProviderOptions {\n /**\n * A function that blockBrokers should call prior to returning a block to ensure it can maintain control\n * of the block request flow. e.g. TrustedGatewayBlockBroker will use this to ensure that the block\n * is valid from one of the gateways before assuming its work is done. If the block is not valid, it should try another gateway\n * and WILL consider the gateway that returned the invalid blocks completely unreliable.\n */\n validateFn?(block: Uint8Array): Promise<void>\n\n /**\n * The maximum size a block can be in bytes.\n *\n * Attempts to retrieve a block larger than this will cause an error to be thrown.\n *\n * @default 2_097_152\n */\n maxSize?: number\n}\n\nexport interface BlockAnnounceOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents> {\n\n}\n\nexport interface CreateSessionOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents>, ProviderOptions, GetOfflineOptions {\n /**\n * The minimum number of providers for the root CID that are required for\n * successful session creation.\n *\n * The session will become usable once this many providers have been\n * discovered, up to `maxProviders` providers will continue to be added.\n *\n * @default 1\n */\n minProviders?: number\n\n /**\n * The maximum number of providers for the root CID to be added to a session.\n *\n * @default 5\n */\n maxProviders?: number\n\n /**\n * A scalable cuckoo filter is used to ensure we do not query the same peer\n * multiple times for the same CID. This setting controls how the initial\n * maximum number of peers that are expected to be in the filter.\n *\n * @default 100\n */\n cidPeerFilterSize?: number\n}\n\nexport interface BlockBroker<RetrieveProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>, AnnounceProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> {\n /**\n * The name of the block broker, used for logging purposes\n */\n name: string\n\n /**\n * Retrieve a block from a source\n */\n retrieve?(cid: CID, options?: BlockRetrievalOptions<RetrieveProgressEvents>): Promise<Uint8Array>\n\n /**\n * Make a new block available to peers\n */\n announce?(cid: CID, options?: BlockAnnounceOptions<AnnounceProgressEvents>): Promise<void>\n\n /**\n * Create a new session\n */\n createSession?(options?: CreateSessionOptions<RetrieveProgressEvents>): SessionBlockBroker<RetrieveProgressEvents, AnnounceProgressEvents>\n}\n\nexport interface SessionBlockBroker<RetrieveProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>, AnnounceProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends BlockBroker<RetrieveProgressEvents, AnnounceProgressEvents> {\n /**\n * Adds a new peer to the session if they are supported and are either\n * not already in the session and have not been evicted previously.\n */\n addPeer (peer: PeerId | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<void>\n}\n\nexport const DEFAULT_SESSION_MIN_PROVIDERS = 1\nexport const DEFAULT_SESSION_MAX_PROVIDERS = 5\nexport const DEFAULT_CID_PEER_FILTER_SIZE = 100\n", "export class InsufficientProvidersError extends Error {\n static name = 'InsufficientProvidersError'\n\n constructor (message = 'Insufficient providers found') {\n super(message)\n this.name = 'InsufficientProvidersError'\n }\n}\n\nexport class NoRoutersAvailableError extends Error {\n static name = 'NoRoutersAvailableError'\n\n constructor (message = 'No routers available') {\n super(message)\n this.name = 'NoRoutersAvailableError'\n }\n}\n\nexport class UnknownHashAlgorithmError extends Error {\n static name = 'UnknownHashAlgorithmError'\n\n constructor (message = 'Unknown hash algorithm') {\n super(message)\n this.name = 'UnknownHashAlgorithmError'\n }\n}\n\nexport class UnknownCodecError extends Error {\n static name = 'UnknownCodecError'\n\n constructor (message = 'Unknown codec') {\n super(message)\n this.name = 'UnknownCodecError'\n }\n}\n\nexport class InvalidCodecError extends Error {\n static name = 'InvalidCodecError'\n\n constructor (message = 'Invalid codec') {\n super(message)\n this.name = 'InvalidCodecError'\n }\n}\n"],
|
|
5
|
-
"mappings": ";kcAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kCAAAE,EAAA,kCAAAC,EAAA,kCAAAC,EAAA,+BAAAC,EAAA,sBAAAC,EAAA,4BAAAC,EAAA,sBAAAC,EAAA,8BAAAC,
|
|
6
|
-
"names": ["index_exports", "__export", "DEFAULT_CID_PEER_FILTER_SIZE", "DEFAULT_SESSION_MAX_PROVIDERS", "DEFAULT_SESSION_MIN_PROVIDERS", "InsufficientProvidersError", "InvalidCodecError", "NoRoutersAvailableError", "UnknownCodecError", "UnknownHashAlgorithmError", "DEFAULT_SESSION_MIN_PROVIDERS", "DEFAULT_SESSION_MAX_PROVIDERS", "DEFAULT_CID_PEER_FILTER_SIZE", "InsufficientProvidersError", "message", "NoRoutersAvailableError", "UnknownHashAlgorithmError", "UnknownCodecError", "InvalidCodecError"]
|
|
3
|
+
"sources": ["../src/index.ts", "../../../node_modules/@ipshipyard/crypto/src/index.ts", "../src/blocks.ts", "../src/errors.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * @packageDocumentation\n *\n * The API defined by a {@link Helia} node\n *\n * @example\n *\n * ```typescript\n * import type { Helia } from '@helia/interface'\n *\n * export function doSomething(helia: Helia) {\n * // use helia node functions here\n * }\n * ```\n */\n\nimport type { BlockBroker, Blocks } from './blocks.ts'\nimport type { Pins } from './pins.ts'\nimport type { Router, Routing } from './routing.ts'\nimport type { CryptoLoader, Keychain } from '@ipshipyard/keychain'\nimport type { Metrics } from '@libp2p/interface'\nimport type { DNS } from '@multiformats/dns'\nimport type { AbortOptions } from 'abort-error'\nimport type { ComponentLogger } from 'birnam'\nimport type { Datastore } from 'interface-datastore'\nimport type { TypedEventEmitter } from 'main-event'\nimport type { BlockCodec, MultihashHasher } from 'multiformats'\nimport type { CID } from 'multiformats/cid'\nimport type { ProgressEvent, ProgressOptions } from 'progress-events'\n\nexport interface CodecLoader {\n <T = any, Code extends number = any>(code: Code, options?: AbortOptions): BlockCodec<Code, T> | Promise<BlockCodec<Code, T>>\n}\n\nexport interface HasherLoader {\n (code: number, options?: AbortOptions): MultihashHasher | Promise<MultihashHasher>\n}\n\nexport type { CryptoLoader, Keychain } from '@ipshipyard/keychain'\nexport type { Crypto, PrivateKey, PublicKey } from '@ipshipyard/crypto'\nexport { isPrivateKey, isPublicKey } from '@ipshipyard/crypto'\n\nexport interface NodeInfo {\n name: string\n version: string\n}\n\nexport interface HeliaMixin<Start extends Helia = Helia, Stop = Start> {\n start?(helia: Start): Promise<void> | void\n stop?(helia: Stop): Promise<void> | void\n}\n\n/**\n * The API presented by a Helia node\n */\nexport interface Helia {\n /**\n * Runtime information about the node\n */\n info: NodeInfo\n\n /**\n * Where the blocks are stored\n */\n blockstore: Blocks\n\n /**\n * A key/value store\n */\n datastore: Datastore\n\n /**\n * Event emitter for Helia start and stop events\n */\n events: TypedEventEmitter<HeliaEvents<this>>\n\n /**\n * Secure storage for private keys\n */\n keychain: Keychain\n\n /**\n * Pinning operations for blocks in the blockstore\n */\n pins: Pins\n\n /**\n * A logging component that can be reused by consumers\n */\n logger: ComponentLogger\n\n /**\n * The routing component allows performing operations such as looking up\n * content providers, information about peers, etc.\n */\n routing: Routing\n\n /**\n * The DNS property can be used to perform lookups of various record types and\n * will use a resolver appropriate to the current platform.\n */\n dns: DNS\n\n /**\n * A metrics object that can be used to collected arbitrary stats about node\n * usage.\n */\n metrics?: Metrics\n\n /**\n * The current status of the Helia node\n */\n status: 'starting' | 'started' | 'stopping' | 'stopped'\n\n /**\n * Starts the Helia node\n */\n start(options?: AbortOptions): Promise<this>\n\n /**\n * Stops the Helia node\n */\n stop(options?: AbortOptions): Promise<this>\n\n /**\n * Remove any unpinned blocks from the blockstore\n */\n gc(options?: GCOptions): Promise<void>\n\n /**\n * Load an IPLD codec. Implementations may return a promise if, for example,\n * the codec is being fetched from the network.\n */\n getCodec: CodecLoader\n\n /**\n * Hashers can be used to hash a piece of data with the specified hashing\n * algorithm. Implementations may return a promise if, for example,\n * the hasher is being fetched from the network.\n */\n getHasher: HasherLoader\n\n /**\n * Cryptography implementations securely sign and verify data\n */\n getCrypto: CryptoLoader\n\n /**\n * Returns `true` if a router with the passed name has been configured\n */\n hasRouter (name: string): boolean\n\n /**\n * Add a router\n */\n addRouter(router: Router): void\n\n /**\n * Returns `true` if a block broker with the passed name has been configured\n */\n hasBlockBroker (name: string): boolean\n\n /**\n * Add a block broker\n */\n addBlockBroker(blockBroker: BlockBroker): void\n\n /**\n * Add a mixin to extend runtime functionality\n */\n addMixin<T extends Helia = Helia & Record<string, any>>(mixin: HeliaMixin<T>): void\n}\n\nexport type GcEvents =\n ProgressEvent<'helia:gc:deleted', CID> |\n ProgressEvent<'helia:gc:error', Error>\n\nexport interface GCOptions extends AbortOptions, ProgressOptions<GcEvents> {\n\n}\n\nexport interface HeliaEvents<H extends Helia = Helia> {\n /**\n * This event notifies listeners that the node has started\n *\n * ```TypeScript\n * helia.addEventListener('start', (event) => {\n * console.info(event.detail.libp2p.isStarted()) // true\n * })\n * ```\n */\n start: CustomEvent<H>\n\n /**\n * This event notifies listeners that the node has stopped\n *\n * ```TypeScript\n * helia.addEventListener('stop', (event) => {\n * console.info(event.detail.libp2p.isStarted()) // false\n * })\n * ```\n */\n stop: CustomEvent<H>\n}\n\nexport * from './blocks.ts'\nexport * from './errors.ts'\nexport * from './pins.ts'\nexport * from './routing.ts'\n", "/**\n * @packageDocumentation\n *\n * WebCrypto-based implementations of ECDSA, Ed25519, and RSA cryptography.\n */\nimport type { AbortOptions } from 'abort-error'\nimport type { CID, MultihashDigest } from 'multiformats/cid'\n\nexport { ecdsaCrypto } from './ecdsa.ts'\nexport { ed25519Crypto } from './ed25519.ts'\nexport { rsaCrypto } from './rsa.ts'\n\nexport interface PublicKey {\n /**\n * The type of the crypto implementation, e.g. `Ed15519`\n */\n readonly type: string\n\n /**\n * The code that is used as the `Type` field in the protobuf representation of\n * the public/private keys\n */\n readonly code: number\n\n /**\n * Return a MultihashDigest that represents this key\n */\n toMultihash (): MultihashDigest\n\n /**\n * Return the libp2p-key CID that represents this key\n */\n toCID (): CID<unknown, 0x72, number, 1>\n\n /**\n * Return this key encoded as a protobuf PublicKey message\n */\n toProtobuf (): Uint8Array<ArrayBuffer>\n\n /**\n * Return this key as a RFC 7517 Json Web Key\n */\n toJWK (): JsonWebKey\n\n /**\n * Verify the passed message against it's signature\n */\n verify(message: Uint8Array, signature: Uint8Array, options?: AbortOptions): boolean | Promise<boolean>\n}\n\nexport function isPublicKey (obj?: any): obj is PublicKey {\n if (obj == null) {\n return false\n }\n\n return typeof obj.type === 'string' && typeof obj.code === 'number' && typeof obj.verify === 'function'\n}\n\nexport interface PrivateKey {\n /**\n * The type of the crypto implementation, e.g. `Ed15519`\n */\n readonly type: string\n\n /**\n * The code that is used as the `Type` field in the protobuf representation of\n * the public/private keys\n */\n readonly code: number\n\n /**\n * The public key that corresponds to this private key\n */\n readonly publicKey: PublicKey\n\n /**\n * Return this key encoded as a protobuf PrivateKey message\n */\n toProtobuf (): Uint8Array<ArrayBuffer>\n\n /**\n * Return this key as a RFC 7517 Json Web Key\n */\n toJWK (): JsonWebKey\n\n /**\n * Sign the passed message and return a signature\n */\n sign(message: Uint8Array, options?: AbortOptions): Uint8Array<ArrayBuffer> | Promise<Uint8Array<ArrayBuffer>>\n}\n\nexport function isPrivateKey (obj?: any): obj is PrivateKey {\n if (obj == null) {\n return false\n }\n\n return typeof obj.type === 'string' && typeof obj.code === 'number' && typeof obj.sign === 'function' && isPublicKey(obj.publicKey)\n}\n\nexport interface Crypto {\n /**\n * The type of the crypto implementation, e.g. `Ed15519`\n */\n type: string\n\n /**\n * The code that is used as the `Type` field in the protobuf representation of\n * the public/private keys\n */\n code: number\n\n /**\n * Create a new private key\n */\n generatePrivateKey(options?: AbortOptions & Record<string, any>): Promise<PrivateKey>\n\n /**\n * Convert the passed bytes into a public key. The bytes come from the `.Data`\n * field of a `PublicKey` protobuf message.\n */\n publicKeyFromProtobuf(buf: Uint8Array, options?: AbortOptions): PublicKey | Promise<PublicKey>\n\n /**\n * Convert the passed bytes into a public key. The bytes come from the `.Data`\n * field of a `PublicKey` protobuf message.\n */\n privateKeyFromProtobuf(buf: Uint8Array, options?: AbortOptions): PrivateKey | Promise<PrivateKey>\n}\n", "import type { RoutingFindProvidersProgressEvents } from './routing.ts'\nimport type { Multiaddr } from '@multiformats/multiaddr'\nimport type { AbortOptions } from 'abort-error'\nimport type { Blockstore } from 'interface-blockstore'\nimport type { CID } from 'multiformats/cid'\nimport type { ProgressEvent, ProgressOptions } from 'progress-events'\n\nexport type { Pair, InputPair } from 'interface-blockstore'\n\nexport interface ProviderOptions {\n /**\n * An optional list of peers known to host at least the root block of the DAG\n * that will be fetched.\n *\n * If this list is omitted, or if the peers cannot supply the root or any\n * child blocks, a `findProviders` routing query will be run to find peers\n * that can supply the blocks.\n */\n providers?: Array<CID | Multiaddr | Multiaddr[]>\n}\n\n/**\n * A block broker will contact a provider to retrieve a block\n */\nexport interface BlockBrokerConnectProgressEvent {\n broker: string\n type: 'connect'\n provider: CID\n cid: CID\n}\n\n/**\n * A block broker has contacted a provider to retrieve a block\n */\nexport interface BlockBrokerConnectedProgressEvent {\n broker: string\n type: 'connected'\n provider: CID\n address: Multiaddr\n cid: CID\n}\n\n/**\n * A block broker has retrieved a block from a provider\n */\nexport interface BlockBrokerRequestBlockProgressEvent {\n broker: string\n type: 'request-block'\n provider: CID\n cid: CID\n}\n\n/**\n * A block broker has retrieved a block from a provider\n */\nexport interface BlockBrokerReceiveBlockProgressEvent {\n broker: string\n type: 'receive-block'\n provider: CID\n cid: CID\n}\n\nexport type BlockBrokerGetBlockProgressEvents = ProgressEvent<'helia:block-broker:connect', BlockBrokerConnectProgressEvent>\n | ProgressEvent<'helia:block-broker:connected', BlockBrokerConnectedProgressEvent>\n | ProgressEvent<'helia:block-broker:request-block', BlockBrokerRequestBlockProgressEvent>\n | ProgressEvent<'helia:block-broker:receive-block', BlockBrokerReceiveBlockProgressEvent>\n\nexport type HasBlockProgressEvents =\n ProgressEvent<'blocks:put:duplicate', CID> |\n ProgressEvent<'blocks:put:providers:notify', CID> |\n ProgressEvent<'blocks:put:blockstore:put', CID>\n\nexport type PutBlockProgressEvents =\n ProgressEvent<'blocks:put:duplicate', CID> |\n ProgressEvent<'blocks:put:providers:notify', CID> |\n ProgressEvent<'blocks:put:blockstore:put', CID>\n\nexport type PutManyBlocksProgressEvents =\n ProgressEvent<'blocks:put-many:duplicate', CID> |\n ProgressEvent<'blocks:put-many:providers:notify', CID> |\n ProgressEvent<'blocks:put-many:blockstore:put-many'>\n\nexport type GetBlockProgressEvents =\n ProgressEvent<'blocks:get:providers:want', CID> |\n ProgressEvent<'blocks:get:blockstore:get', CID> |\n ProgressEvent<'blocks:get:blockstore:put', CID> |\n RoutingFindProvidersProgressEvents |\n BlockBrokerGetBlockProgressEvents\n\nexport type GetManyBlocksProgressEvents =\n ProgressEvent<'blocks:get-many:blockstore:get-many'> |\n ProgressEvent<'blocks:get-many:providers:want', CID> |\n ProgressEvent<'blocks:get-many:blockstore:put', CID>\n\nexport type GetAllBlocksProgressEvents =\n ProgressEvent<'blocks:get-all:blockstore:get-many'>\n\nexport type DeleteBlockProgressEvents =\n ProgressEvent<'blocks:delete:blockstore:delete', CID>\n\nexport type DeleteManyBlocksProgressEvents =\n ProgressEvent<'blocks:delete-many:blockstore:delete-many'>\n\nexport interface GetOfflineOptions {\n /**\n * If true, do not attempt to fetch any missing blocks from the network\n *\n * @default false\n */\n offline?: boolean\n}\n\nexport interface Blocks extends Blockstore<ProgressOptions<HasBlockProgressEvents>,\nProgressOptions<PutBlockProgressEvents>, ProgressOptions<PutManyBlocksProgressEvents>,\nGetOfflineOptions & ProviderOptions & ProgressOptions<GetBlockProgressEvents>,\nGetOfflineOptions & ProviderOptions & ProgressOptions<GetManyBlocksProgressEvents>,\nProgressOptions<GetAllBlocksProgressEvents>,\nProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProgressEvents>\n> {\n /**\n * A blockstore session only fetches blocks from a subset of network peers to\n * reduce network traffic and improve performance.\n *\n * The initial set of peers can be specified, alternatively a `findProviders`\n * routing query will occur to populate the set instead.\n */\n createSession(root: CID, options?: CreateSessionOptions<GetBlockProgressEvents>): SessionBlockstore\n}\n\n/**\n * A session blockstore is a special blockstore that only pulls content from a\n * subset of network peers which respond as having the block for the initial\n * root CID.\n *\n * Any blocks written to the blockstore as part of the session will propagate\n * to the blockstore the session was created from.\n *\n */\nexport interface SessionBlockstore extends Blockstore<ProgressOptions<HasBlockProgressEvents>,\nProgressOptions<PutBlockProgressEvents>, ProgressOptions<PutManyBlocksProgressEvents>,\nGetOfflineOptions & ProgressOptions<GetBlockProgressEvents>, GetOfflineOptions & ProgressOptions<GetManyBlocksProgressEvents>, ProgressOptions<GetAllBlocksProgressEvents>,\nProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProgressEvents>\n> {\n /**\n * Any in-progress operations will be aborted.\n */\n close(): void\n\n /**\n * Adds a new peer to the session if they are supported and are either\n * not already in the session and have not been evicted previously.\n */\n addPeer (peer: CID | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<void>\n}\n\nexport interface BlockRetrievalOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents>, ProviderOptions {\n /**\n * A function that blockBrokers should call prior to returning a block to ensure it can maintain control\n * of the block request flow. e.g. TrustedGatewayBlockBroker will use this to ensure that the block\n * is valid from one of the gateways before assuming its work is done. If the block is not valid, it should try another gateway\n * and WILL consider the gateway that returned the invalid blocks completely unreliable.\n */\n validateFn?(block: Uint8Array): Promise<void>\n\n /**\n * The maximum size a block can be in bytes.\n *\n * Attempts to retrieve a block larger than this will cause an error to be thrown.\n *\n * @default 2_097_152\n */\n maxSize?: number\n}\n\nexport interface BlockAnnounceOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents> {\n\n}\n\nexport interface CreateSessionOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents>, ProviderOptions, GetOfflineOptions {\n /**\n * The minimum number of providers for the root CID that are required for\n * successful session creation.\n *\n * The session will become usable once this many providers have been\n * discovered, up to `maxProviders` providers will continue to be added.\n *\n * @default 1\n */\n minProviders?: number\n\n /**\n * The maximum number of providers for the root CID to be added to a session.\n *\n * @default 5\n */\n maxProviders?: number\n\n /**\n * A scalable cuckoo filter is used to ensure we do not query the same peer\n * multiple times for the same CID. This setting controls how the initial\n * maximum number of peers that are expected to be in the filter.\n *\n * @default 100\n */\n cidPeerFilterSize?: number\n}\n\nexport interface BlockBroker<RetrieveProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>, AnnounceProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> {\n /**\n * The name of the block broker, used for logging purposes\n */\n name: string\n\n /**\n * Retrieve a block from a source\n */\n retrieve?(cid: CID, options?: BlockRetrievalOptions<RetrieveProgressEvents>): Promise<Uint8Array>\n\n /**\n * Make a new block available to peers\n */\n announce?(cid: CID, options?: BlockAnnounceOptions<AnnounceProgressEvents>): Promise<void>\n\n /**\n * Create a new session\n */\n createSession?(options?: CreateSessionOptions<RetrieveProgressEvents>): SessionBlockBroker<RetrieveProgressEvents, AnnounceProgressEvents>\n}\n\nexport interface SessionBlockBroker<RetrieveProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>, AnnounceProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends BlockBroker<RetrieveProgressEvents, AnnounceProgressEvents> {\n /**\n * Adds a new peer to the session if they are supported and are either\n * not already in the session and have not been evicted previously.\n */\n addPeer (peer: CID | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<void>\n}\n\nexport const DEFAULT_SESSION_MIN_PROVIDERS = 1\nexport const DEFAULT_SESSION_MAX_PROVIDERS = 5\nexport const DEFAULT_CID_PEER_FILTER_SIZE = 100\n", "export class InsufficientProvidersError extends Error {\n static name = 'InsufficientProvidersError'\n\n constructor (message = 'Insufficient providers found') {\n super(message)\n this.name = 'InsufficientProvidersError'\n }\n}\n\nexport class NoRoutersAvailableError extends Error {\n static name = 'NoRoutersAvailableError'\n\n constructor (message = 'No routers available') {\n super(message)\n this.name = 'NoRoutersAvailableError'\n }\n}\n\nexport class UnknownHashAlgorithmError extends Error {\n static name = 'UnknownHashAlgorithmError'\n\n constructor (message = 'Unknown hash algorithm') {\n super(message)\n this.name = 'UnknownHashAlgorithmError'\n }\n}\n\nexport class UnknownCodecError extends Error {\n static name = 'UnknownCodecError'\n\n constructor (message = 'Unknown codec') {\n super(message)\n this.name = 'UnknownCodecError'\n }\n}\n\nexport class InvalidCodecError extends Error {\n static name = 'InvalidCodecError'\n\n constructor (message = 'Invalid codec') {\n super(message)\n this.name = 'InvalidCodecError'\n }\n}\n\nexport class UnknownCryptoError extends Error {\n static name = 'UnknownCryptoError'\n name = 'UnknownCryptoError'\n}\n"],
|
|
5
|
+
"mappings": ";kcAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kCAAAE,EAAA,kCAAAC,EAAA,kCAAAC,EAAA,+BAAAC,EAAA,sBAAAC,EAAA,4BAAAC,EAAA,sBAAAC,EAAA,uBAAAC,EAAA,8BAAAC,EAAA,iBAAAC,EAAA,gBAAAC,ICkDM,SAAUC,EAAaC,EAAS,CACpC,OAAIA,GAAO,KACF,GAGF,OAAOA,EAAI,MAAS,UAAY,OAAOA,EAAI,MAAS,UAAY,OAAOA,EAAI,QAAW,UAC/F,CAmCM,SAAUC,EAAcD,EAAS,CACrC,OAAIA,GAAO,KACF,GAGF,OAAOA,EAAI,MAAS,UAAY,OAAOA,EAAI,MAAS,UAAY,OAAOA,EAAI,MAAS,YAAcD,EAAYC,EAAI,SAAS,CACpI,CC4IO,IAAME,EAAgC,EAChCC,EAAgC,EAChCC,EAA+B,IC/OtC,IAAOC,EAAP,cAA0C,KAAK,CACnD,OAAO,KAAO,6BAEd,YAAaC,EAAU,+BAA8B,CACnD,MAAMA,CAAO,EACb,KAAK,KAAO,4BACd,GAGWC,EAAP,cAAuC,KAAK,CAChD,OAAO,KAAO,0BAEd,YAAaD,EAAU,uBAAsB,CAC3C,MAAMA,CAAO,EACb,KAAK,KAAO,yBACd,GAGWE,EAAP,cAAyC,KAAK,CAClD,OAAO,KAAO,4BAEd,YAAaF,EAAU,yBAAwB,CAC7C,MAAMA,CAAO,EACb,KAAK,KAAO,2BACd,GAGWG,EAAP,cAAiC,KAAK,CAC1C,OAAO,KAAO,oBAEd,YAAaH,EAAU,gBAAe,CACpC,MAAMA,CAAO,EACb,KAAK,KAAO,mBACd,GAGWI,EAAP,cAAiC,KAAK,CAC1C,OAAO,KAAO,oBAEd,YAAaJ,EAAU,gBAAe,CACpC,MAAMA,CAAO,EACb,KAAK,KAAO,mBACd,GAGWK,EAAP,cAAkC,KAAK,CAC3C,OAAO,KAAO,qBACd,KAAO",
|
|
6
|
+
"names": ["index_exports", "__export", "DEFAULT_CID_PEER_FILTER_SIZE", "DEFAULT_SESSION_MAX_PROVIDERS", "DEFAULT_SESSION_MIN_PROVIDERS", "InsufficientProvidersError", "InvalidCodecError", "NoRoutersAvailableError", "UnknownCodecError", "UnknownCryptoError", "UnknownHashAlgorithmError", "isPrivateKey", "isPublicKey", "isPublicKey", "obj", "isPrivateKey", "DEFAULT_SESSION_MIN_PROVIDERS", "DEFAULT_SESSION_MAX_PROVIDERS", "DEFAULT_CID_PEER_FILTER_SIZE", "InsufficientProvidersError", "message", "NoRoutersAvailableError", "UnknownHashAlgorithmError", "UnknownCodecError", "InvalidCodecError", "UnknownCryptoError"]
|
|
7
7
|
}
|
package/dist/src/blocks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RoutingFindProvidersProgressEvents } from './routing.ts';
|
|
2
|
-
import type { PeerId, AbortOptions } from '@libp2p/interface';
|
|
3
2
|
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
3
|
+
import type { AbortOptions } from 'abort-error';
|
|
4
4
|
import type { Blockstore } from 'interface-blockstore';
|
|
5
5
|
import type { CID } from 'multiformats/cid';
|
|
6
6
|
import type { ProgressEvent, ProgressOptions } from 'progress-events';
|
|
@@ -14,7 +14,7 @@ export interface ProviderOptions {
|
|
|
14
14
|
* child blocks, a `findProviders` routing query will be run to find peers
|
|
15
15
|
* that can supply the blocks.
|
|
16
16
|
*/
|
|
17
|
-
providers?: Array<
|
|
17
|
+
providers?: Array<CID | Multiaddr | Multiaddr[]>;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* A block broker will contact a provider to retrieve a block
|
|
@@ -22,7 +22,7 @@ export interface ProviderOptions {
|
|
|
22
22
|
export interface BlockBrokerConnectProgressEvent {
|
|
23
23
|
broker: string;
|
|
24
24
|
type: 'connect';
|
|
25
|
-
provider:
|
|
25
|
+
provider: CID;
|
|
26
26
|
cid: CID;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
@@ -31,7 +31,7 @@ export interface BlockBrokerConnectProgressEvent {
|
|
|
31
31
|
export interface BlockBrokerConnectedProgressEvent {
|
|
32
32
|
broker: string;
|
|
33
33
|
type: 'connected';
|
|
34
|
-
provider:
|
|
34
|
+
provider: CID;
|
|
35
35
|
address: Multiaddr;
|
|
36
36
|
cid: CID;
|
|
37
37
|
}
|
|
@@ -41,7 +41,7 @@ export interface BlockBrokerConnectedProgressEvent {
|
|
|
41
41
|
export interface BlockBrokerRequestBlockProgressEvent {
|
|
42
42
|
broker: string;
|
|
43
43
|
type: 'request-block';
|
|
44
|
-
provider:
|
|
44
|
+
provider: CID;
|
|
45
45
|
cid: CID;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
@@ -50,7 +50,7 @@ export interface BlockBrokerRequestBlockProgressEvent {
|
|
|
50
50
|
export interface BlockBrokerReceiveBlockProgressEvent {
|
|
51
51
|
broker: string;
|
|
52
52
|
type: 'receive-block';
|
|
53
|
-
provider:
|
|
53
|
+
provider: CID;
|
|
54
54
|
cid: CID;
|
|
55
55
|
}
|
|
56
56
|
export type BlockBrokerGetBlockProgressEvents = ProgressEvent<'helia:block-broker:connect', BlockBrokerConnectProgressEvent> | ProgressEvent<'helia:block-broker:connected', BlockBrokerConnectedProgressEvent> | ProgressEvent<'helia:block-broker:request-block', BlockBrokerRequestBlockProgressEvent> | ProgressEvent<'helia:block-broker:receive-block', BlockBrokerReceiveBlockProgressEvent>;
|
|
@@ -98,7 +98,7 @@ export interface SessionBlockstore extends Blockstore<ProgressOptions<HasBlockPr
|
|
|
98
98
|
* Adds a new peer to the session if they are supported and are either
|
|
99
99
|
* not already in the session and have not been evicted previously.
|
|
100
100
|
*/
|
|
101
|
-
addPeer(peer:
|
|
101
|
+
addPeer(peer: CID | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<void>;
|
|
102
102
|
}
|
|
103
103
|
export interface BlockRetrievalOptions<ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents>, ProviderOptions {
|
|
104
104
|
/**
|
|
@@ -168,7 +168,7 @@ export interface SessionBlockBroker<RetrieveProgressEvents extends ProgressEvent
|
|
|
168
168
|
* Adds a new peer to the session if they are supported and are either
|
|
169
169
|
* not already in the session and have not been evicted previously.
|
|
170
170
|
*/
|
|
171
|
-
addPeer(peer:
|
|
171
|
+
addPeer(peer: CID | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<void>;
|
|
172
172
|
}
|
|
173
173
|
export declare const DEFAULT_SESSION_MIN_PROVIDERS = 1;
|
|
174
174
|
export declare const DEFAULT_SESSION_MAX_PROVIDERS = 5;
|
package/dist/src/blocks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,cAAc,CAAA;AACtE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,cAAc,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,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;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAErE,YA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AG,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,sBAAsB,SAAS,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAE,SAAQ,WAAW,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IACzQ;;;OAGG;IACH,OAAO,CAAE,IAAI,EAAE,GAAG,GAAG,SAAS,GAAG,SAAS,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACrF;AAED,eAAO,MAAM,6BAA6B,IAAI,CAAA;AAC9C,eAAO,MAAM,6BAA6B,IAAI,CAAA;AAC9C,eAAO,MAAM,4BAA4B,MAAM,CAAA"}
|
package/dist/src/errors.d.ts
CHANGED
|
@@ -18,4 +18,8 @@ export declare class InvalidCodecError extends Error {
|
|
|
18
18
|
static name: string;
|
|
19
19
|
constructor(message?: string);
|
|
20
20
|
}
|
|
21
|
+
export declare class UnknownCryptoError extends Error {
|
|
22
|
+
static name: string;
|
|
23
|
+
name: string;
|
|
24
|
+
}
|
|
21
25
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/src/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,MAAM,CAAC,IAAI,SAA+B;gBAE7B,OAAO,SAAiC;CAItD;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,MAAM,CAAC,IAAI,SAA4B;gBAE1B,OAAO,SAAyB;CAI9C;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,MAAM,CAAC,IAAI,SAA8B;gBAE5B,OAAO,SAA2B;CAIhD;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,CAAC,IAAI,SAAsB;gBAEpB,OAAO,SAAkB;CAIvC;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,CAAC,IAAI,SAAsB;gBAEpB,OAAO,SAAkB;CAIvC"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,MAAM,CAAC,IAAI,SAA+B;gBAE7B,OAAO,SAAiC;CAItD;AAED,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,MAAM,CAAC,IAAI,SAA4B;gBAE1B,OAAO,SAAyB;CAI9C;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,MAAM,CAAC,IAAI,SAA8B;gBAE5B,OAAO,SAA2B;CAIhD;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,CAAC,IAAI,SAAsB;gBAEpB,OAAO,SAAkB;CAIvC;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,CAAC,IAAI,SAAsB;gBAEpB,OAAO,SAAkB;CAIvC;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,MAAM,CAAC,IAAI,SAAuB;IAClC,IAAI,SAAuB;CAC5B"}
|
package/dist/src/errors.js
CHANGED
package/dist/src/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IACnD,MAAM,CAAC,IAAI,GAAG,4BAA4B,CAAA;IAE1C,YAAa,OAAO,GAAG,8BAA8B;QACnD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAA;IAC1C,CAAC;;AAGH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,MAAM,CAAC,IAAI,GAAG,yBAAyB,CAAA;IAEvC,YAAa,OAAO,GAAG,sBAAsB;QAC3C,KAAK,CAAC,OAAO,CAAC,CA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,MAAM,CAAC,IAAI,GAAG,2BAA2B,CAAA;IAEzC,YAAa,OAAO,GAAG,wBAAwB;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAA;IACzC,CAAC;;AAGH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,CAAC,IAAI,GAAG,mBAAmB,CAAA;IAEjC,YAAa,OAAO,GAAG,eAAe;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;IACjC,CAAC;;AAGH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,MAAM,CAAC,IAAI,GAAG,mBAAmB,CAAA;IAEjC,YAAa,OAAO,GAAG,eAAe;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAA;IACjC,CAAC;;AAGH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,MAAM,CAAC,IAAI,GAAG,oBAAoB,CAAA;IAClC,IAAI,GAAG,oBAAoB,CAAA"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -13,31 +13,44 @@
|
|
|
13
13
|
* }
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
import type { Blocks } from './blocks.ts';
|
|
16
|
+
import type { BlockBroker, Blocks } from './blocks.ts';
|
|
17
17
|
import type { Pins } from './pins.ts';
|
|
18
|
-
import type { Routing } from './routing.ts';
|
|
19
|
-
import type {
|
|
18
|
+
import type { Router, Routing } from './routing.ts';
|
|
19
|
+
import type { CryptoLoader, Keychain } from '@ipshipyard/keychain';
|
|
20
|
+
import type { Metrics } from '@libp2p/interface';
|
|
20
21
|
import type { DNS } from '@multiformats/dns';
|
|
22
|
+
import type { AbortOptions } from 'abort-error';
|
|
23
|
+
import type { ComponentLogger } from 'birnam';
|
|
21
24
|
import type { Datastore } from 'interface-datastore';
|
|
22
|
-
import type {
|
|
25
|
+
import type { TypedEventEmitter } from 'main-event';
|
|
23
26
|
import type { BlockCodec, MultihashHasher } from 'multiformats';
|
|
24
27
|
import type { CID } from 'multiformats/cid';
|
|
25
28
|
import type { ProgressEvent, ProgressOptions } from 'progress-events';
|
|
26
|
-
export type { Await, AwaitIterable } from 'interface-store';
|
|
27
29
|
export interface CodecLoader {
|
|
28
|
-
<T = any, Code extends number = any>(code: Code):
|
|
30
|
+
<T = any, Code extends number = any>(code: Code, options?: AbortOptions): BlockCodec<Code, T> | Promise<BlockCodec<Code, T>>;
|
|
29
31
|
}
|
|
30
32
|
export interface HasherLoader {
|
|
31
|
-
(code: number):
|
|
33
|
+
(code: number, options?: AbortOptions): MultihashHasher | Promise<MultihashHasher>;
|
|
34
|
+
}
|
|
35
|
+
export type { CryptoLoader, Keychain } from '@ipshipyard/keychain';
|
|
36
|
+
export type { Crypto, PrivateKey, PublicKey } from '@ipshipyard/crypto';
|
|
37
|
+
export { isPrivateKey, isPublicKey } from '@ipshipyard/crypto';
|
|
38
|
+
export interface NodeInfo {
|
|
39
|
+
name: string;
|
|
40
|
+
version: string;
|
|
41
|
+
}
|
|
42
|
+
export interface HeliaMixin<Start extends Helia = Helia, Stop = Start> {
|
|
43
|
+
start?(helia: Start): Promise<void> | void;
|
|
44
|
+
stop?(helia: Stop): Promise<void> | void;
|
|
32
45
|
}
|
|
33
46
|
/**
|
|
34
47
|
* The API presented by a Helia node
|
|
35
48
|
*/
|
|
36
|
-
export interface Helia
|
|
49
|
+
export interface Helia {
|
|
37
50
|
/**
|
|
38
|
-
*
|
|
51
|
+
* Runtime information about the node
|
|
39
52
|
*/
|
|
40
|
-
|
|
53
|
+
info: NodeInfo;
|
|
41
54
|
/**
|
|
42
55
|
* Where the blocks are stored
|
|
43
56
|
*/
|
|
@@ -49,7 +62,11 @@ export interface Helia<T extends Libp2p = Libp2p> {
|
|
|
49
62
|
/**
|
|
50
63
|
* Event emitter for Helia start and stop events
|
|
51
64
|
*/
|
|
52
|
-
events: TypedEventEmitter<HeliaEvents<
|
|
65
|
+
events: TypedEventEmitter<HeliaEvents<this>>;
|
|
66
|
+
/**
|
|
67
|
+
* Secure storage for private keys
|
|
68
|
+
*/
|
|
69
|
+
keychain: Keychain;
|
|
53
70
|
/**
|
|
54
71
|
* Pinning operations for blocks in the blockstore
|
|
55
72
|
*/
|
|
@@ -73,14 +90,18 @@ export interface Helia<T extends Libp2p = Libp2p> {
|
|
|
73
90
|
* usage.
|
|
74
91
|
*/
|
|
75
92
|
metrics?: Metrics;
|
|
93
|
+
/**
|
|
94
|
+
* The current status of the Helia node
|
|
95
|
+
*/
|
|
96
|
+
status: 'starting' | 'started' | 'stopping' | 'stopped';
|
|
76
97
|
/**
|
|
77
98
|
* Starts the Helia node
|
|
78
99
|
*/
|
|
79
|
-
start(): Promise<
|
|
100
|
+
start(options?: AbortOptions): Promise<this>;
|
|
80
101
|
/**
|
|
81
102
|
* Stops the Helia node
|
|
82
103
|
*/
|
|
83
|
-
stop(): Promise<
|
|
104
|
+
stop(options?: AbortOptions): Promise<this>;
|
|
84
105
|
/**
|
|
85
106
|
* Remove any unpinned blocks from the blockstore
|
|
86
107
|
*/
|
|
@@ -96,11 +117,35 @@ export interface Helia<T extends Libp2p = Libp2p> {
|
|
|
96
117
|
* the hasher is being fetched from the network.
|
|
97
118
|
*/
|
|
98
119
|
getHasher: HasherLoader;
|
|
120
|
+
/**
|
|
121
|
+
* Cryptography implementations securely sign and verify data
|
|
122
|
+
*/
|
|
123
|
+
getCrypto: CryptoLoader;
|
|
124
|
+
/**
|
|
125
|
+
* Returns `true` if a router with the passed name has been configured
|
|
126
|
+
*/
|
|
127
|
+
hasRouter(name: string): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Add a router
|
|
130
|
+
*/
|
|
131
|
+
addRouter(router: Router): void;
|
|
132
|
+
/**
|
|
133
|
+
* Returns `true` if a block broker with the passed name has been configured
|
|
134
|
+
*/
|
|
135
|
+
hasBlockBroker(name: string): boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Add a block broker
|
|
138
|
+
*/
|
|
139
|
+
addBlockBroker(blockBroker: BlockBroker): void;
|
|
140
|
+
/**
|
|
141
|
+
* Add a mixin to extend runtime functionality
|
|
142
|
+
*/
|
|
143
|
+
addMixin<T extends Helia = Helia & Record<string, any>>(mixin: HeliaMixin<T>): void;
|
|
99
144
|
}
|
|
100
145
|
export type GcEvents = ProgressEvent<'helia:gc:deleted', CID> | ProgressEvent<'helia:gc:error', Error>;
|
|
101
146
|
export interface GCOptions extends AbortOptions, ProgressOptions<GcEvents> {
|
|
102
147
|
}
|
|
103
|
-
export interface HeliaEvents<
|
|
148
|
+
export interface HeliaEvents<H extends Helia = Helia> {
|
|
104
149
|
/**
|
|
105
150
|
* This event notifies listeners that the node has started
|
|
106
151
|
*
|
|
@@ -110,7 +155,7 @@ export interface HeliaEvents<T extends Libp2p = Libp2p> {
|
|
|
110
155
|
* })
|
|
111
156
|
* ```
|
|
112
157
|
*/
|
|
113
|
-
start: CustomEvent<
|
|
158
|
+
start: CustomEvent<H>;
|
|
114
159
|
/**
|
|
115
160
|
* This event notifies listeners that the node has stopped
|
|
116
161
|
*
|
|
@@ -120,7 +165,7 @@ export interface HeliaEvents<T extends Libp2p = Libp2p> {
|
|
|
120
165
|
* })
|
|
121
166
|
* ```
|
|
122
167
|
*/
|
|
123
|
-
stop: CustomEvent<
|
|
168
|
+
stop: CustomEvent<H>;
|
|
124
169
|
}
|
|
125
170
|
export * from './blocks.ts';
|
|
126
171
|
export * from './errors.ts';
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],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zB,cAAc,cAAc,CAAA"}
|
package/dist/src/index.js
CHANGED
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA0BH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAqK9D,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA"}
|
package/dist/src/pins.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GetBlockProgressEvents } from './blocks.ts';
|
|
2
|
-
import type { AbortOptions } from '
|
|
2
|
+
import type { AbortOptions } from 'abort-error';
|
|
3
3
|
import type { CID } from 'multiformats/cid';
|
|
4
4
|
import type { ProgressEvent, ProgressOptions } from 'progress-events';
|
|
5
5
|
export type PinType = 'recursive' | 'direct' | 'indirect';
|
package/dist/src/pins.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pins.d.ts","sourceRoot":"","sources":["../../src/pins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"pins.d.ts","sourceRoot":"","sources":["../../src/pins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,aAAa,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AAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;IAEnD;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAE/D;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9H"}
|
package/dist/src/routing.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
2
|
+
import type { AbortOptions } from 'abort-error';
|
|
2
3
|
import type { CID } from 'multiformats/cid';
|
|
3
4
|
import type { ProgressEvent, ProgressOptions } from 'progress-events';
|
|
4
5
|
/**
|
|
@@ -7,7 +8,7 @@ import type { ProgressEvent, ProgressOptions } from 'progress-events';
|
|
|
7
8
|
* local cache that may be used in preference over network calls, for example
|
|
8
9
|
* when a record has a TTL.
|
|
9
10
|
*/
|
|
10
|
-
export interface RoutingOptions<Event extends ProgressEvent = any> extends AbortOptions, ProgressOptions<Event
|
|
11
|
+
export interface RoutingOptions<Event extends ProgressEvent = any> extends AbortOptions, ProgressOptions<Event> {
|
|
11
12
|
/**
|
|
12
13
|
* Pass `false` to not use the network
|
|
13
14
|
*
|
|
@@ -26,11 +27,36 @@ export interface RoutingOptions<Event extends ProgressEvent = any> extends Abort
|
|
|
26
27
|
* @default true
|
|
27
28
|
*/
|
|
28
29
|
validate?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Where tracing is used, this value carries tracing context
|
|
32
|
+
*/
|
|
33
|
+
trace?: any;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A Peer is another node on the network
|
|
37
|
+
*/
|
|
38
|
+
export interface Peer {
|
|
39
|
+
/**
|
|
40
|
+
* The identifier of the remote peer
|
|
41
|
+
*/
|
|
42
|
+
id: CID;
|
|
43
|
+
/**
|
|
44
|
+
* The multiaddrs a peer is listening on
|
|
45
|
+
*/
|
|
46
|
+
multiaddrs: Multiaddr[];
|
|
29
47
|
}
|
|
30
48
|
/**
|
|
31
49
|
* A provider can supply the content for a CID
|
|
32
50
|
*/
|
|
33
|
-
export interface Provider
|
|
51
|
+
export interface Provider {
|
|
52
|
+
/**
|
|
53
|
+
* The identifier of the remote peer, a CID
|
|
54
|
+
*/
|
|
55
|
+
id: CID;
|
|
56
|
+
/**
|
|
57
|
+
* The multiaddrs a peer is listening on
|
|
58
|
+
*/
|
|
59
|
+
multiaddrs: Multiaddr[];
|
|
34
60
|
/**
|
|
35
61
|
* If present these are the methods that the peer can supply the content via.
|
|
36
62
|
*
|
|
@@ -61,14 +87,14 @@ export interface RoutingFindProvidersEndEvent {
|
|
|
61
87
|
export interface RoutingFindProvidersHttpGatewayProvider {
|
|
62
88
|
routing: 'http-gateway-router';
|
|
63
89
|
cid: CID;
|
|
64
|
-
provider:
|
|
90
|
+
provider: Peer & {
|
|
65
91
|
protocols: ['transport-ipfs-gateway-http'];
|
|
66
92
|
};
|
|
67
93
|
}
|
|
68
94
|
export interface RoutingFindProvidersDelegatedHttpRoutingProvider {
|
|
69
95
|
routing: 'delegated-http-router';
|
|
70
96
|
cid: CID;
|
|
71
|
-
provider:
|
|
97
|
+
provider: Peer & {
|
|
72
98
|
routing: 'delegated-http-routing';
|
|
73
99
|
protocols: string[];
|
|
74
100
|
};
|
|
@@ -76,7 +102,7 @@ export interface RoutingFindProvidersDelegatedHttpRoutingProvider {
|
|
|
76
102
|
export interface RoutingFindProvidersLibp2pProvider {
|
|
77
103
|
routing: 'libp2p-router';
|
|
78
104
|
cid: CID;
|
|
79
|
-
provider:
|
|
105
|
+
provider: Peer;
|
|
80
106
|
}
|
|
81
107
|
export type RoutingFindProvidersProviderEvent = RoutingFindProvidersHttpGatewayProvider | RoutingFindProvidersDelegatedHttpRoutingProvider | RoutingFindProvidersLibp2pProvider;
|
|
82
108
|
export type RoutingFindProvidersProgressEvents = ProgressEvent<'helia:routing:find-providers:start', RoutingFindProvidersStartEvent> | ProgressEvent<'helia:routing:find-providers:provider', RoutingFindProvidersProviderEvent> | ProgressEvent<'helia:routing:find-providers:end', RoutingFindProvidersEndEvent> | RoutingFindPeerProgressEvents;
|
|
@@ -120,11 +146,11 @@ export interface RoutingGetEndEvent {
|
|
|
120
146
|
export type RoutingGetProgressEvents = ProgressEvent<'helia:routing:get:start', RoutingGetStartEvent> | ProgressEvent<'helia:routing:get:end', RoutingGetEndEvent>;
|
|
121
147
|
export interface RoutingFindPeerStartEvent {
|
|
122
148
|
routing: string;
|
|
123
|
-
peerId:
|
|
149
|
+
peerId: CID;
|
|
124
150
|
}
|
|
125
151
|
export interface RoutingFindPeerEndEvent {
|
|
126
152
|
routing: string;
|
|
127
|
-
peerId:
|
|
153
|
+
peerId: CID;
|
|
128
154
|
}
|
|
129
155
|
export type RoutingFindPeerProgressEvents = ProgressEvent<'helia:routing:find-peer:start', RoutingFindPeerStartEvent> | ProgressEvent<'helia:routing:find-peer:end', RoutingFindPeerEndEvent>;
|
|
130
156
|
export interface RoutingGetClosestPeersStartEvent {
|
|
@@ -136,7 +162,7 @@ export interface RoutingGetClosestPeersEndEvent {
|
|
|
136
162
|
key: Uint8Array;
|
|
137
163
|
}
|
|
138
164
|
export type RoutingGetClosestPeersProgressEvents = ProgressEvent<'helia:routing:get-closest-peers:start', RoutingGetClosestPeersStartEvent> | ProgressEvent<'helia:routing:get-closest-peers:end', RoutingGetClosestPeersEndEvent>;
|
|
139
|
-
export interface
|
|
165
|
+
export interface Router {
|
|
140
166
|
/**
|
|
141
167
|
* The name of this routing implementation
|
|
142
168
|
*/
|
|
@@ -149,10 +175,12 @@ export interface Routing {
|
|
|
149
175
|
*
|
|
150
176
|
* ```js
|
|
151
177
|
* // ...
|
|
152
|
-
* await contentRouting.provide(cid
|
|
178
|
+
* await contentRouting.provide(cid, {
|
|
179
|
+
* signal: AbortSignal.timeout(5_000)
|
|
180
|
+
* })
|
|
153
181
|
* ```
|
|
154
182
|
*/
|
|
155
|
-
provide(cid: CID, options?: RoutingOptions<RoutingProvideProgressEvents>): Promise<void>;
|
|
183
|
+
provide?(cid: CID, options?: RoutingOptions<RoutingProvideProgressEvents>): Promise<void>;
|
|
156
184
|
/**
|
|
157
185
|
* Helia will periodically re-provide every previously provided CID. Use this
|
|
158
186
|
* method to no longer re-provide the passed CID.
|
|
@@ -161,10 +189,12 @@ export interface Routing {
|
|
|
161
189
|
*
|
|
162
190
|
* ```js
|
|
163
191
|
* // ...
|
|
164
|
-
* await contentRouting.cancelReprovide(cid
|
|
192
|
+
* await contentRouting.cancelReprovide(cid, {
|
|
193
|
+
* signal: AbortSignal.timeout(5_000)
|
|
194
|
+
* })
|
|
165
195
|
* ```
|
|
166
196
|
*/
|
|
167
|
-
cancelReprovide(key: CID, options?: AbortOptions): Promise<void>;
|
|
197
|
+
cancelReprovide?(key: CID, options?: AbortOptions): Promise<void>;
|
|
168
198
|
/**
|
|
169
199
|
* Find the providers of the passed CID.
|
|
170
200
|
*
|
|
@@ -172,12 +202,14 @@ export interface Routing {
|
|
|
172
202
|
*
|
|
173
203
|
* ```js
|
|
174
204
|
* // Iterate over the providers found for the given cid
|
|
175
|
-
* for await (const provider of contentRouting.findProviders(cid
|
|
205
|
+
* for await (const provider of contentRouting.findProviders(cid, {
|
|
206
|
+
* signal: AbortSignal.timeout(5_000)
|
|
207
|
+
* })) {
|
|
176
208
|
* console.log(provider.id, provider.multiaddrs)
|
|
177
209
|
* }
|
|
178
210
|
* ```
|
|
179
211
|
*/
|
|
180
|
-
findProviders(cid: CID, options?: RoutingOptions<RoutingFindProvidersProgressEvents>): AsyncIterable<Provider>;
|
|
212
|
+
findProviders?(cid: CID, options?: RoutingOptions<RoutingFindProvidersProgressEvents>): AsyncIterable<Provider>;
|
|
181
213
|
/**
|
|
182
214
|
* Puts a value corresponding to the passed key in a way that can later be
|
|
183
215
|
* retrieved by another network peer using the get method.
|
|
@@ -186,13 +218,15 @@ export interface Routing {
|
|
|
186
218
|
*
|
|
187
219
|
* ```js
|
|
188
220
|
* // ...
|
|
189
|
-
* const key = '/key'
|
|
221
|
+
* const key = uint8ArrayFromString('/key')
|
|
190
222
|
* const value = uint8ArrayFromString('oh hello there')
|
|
191
223
|
*
|
|
192
|
-
* await contentRouting.put(key, value
|
|
224
|
+
* await contentRouting.put(key, value, {
|
|
225
|
+
* signal: AbortSignal.timeout(5_000)
|
|
226
|
+
* })
|
|
193
227
|
* ```
|
|
194
228
|
*/
|
|
195
|
-
put(key: Uint8Array, value: Uint8Array, options?: RoutingOptions<RoutingPutProgressEvents>): Promise<void>;
|
|
229
|
+
put?(key: Uint8Array, value: Uint8Array, options?: RoutingOptions<RoutingPutProgressEvents>): Promise<void>;
|
|
196
230
|
/**
|
|
197
231
|
* Retrieves a value from the network corresponding to the passed key.
|
|
198
232
|
*
|
|
@@ -201,11 +235,13 @@ export interface Routing {
|
|
|
201
235
|
* ```js
|
|
202
236
|
* // ...
|
|
203
237
|
*
|
|
204
|
-
* const key = '/key'
|
|
205
|
-
* const value = await contentRouting.get(key
|
|
238
|
+
* const key = uint8ArrayFromString('/key')
|
|
239
|
+
* const value = await contentRouting.get(key, {
|
|
240
|
+
* signal: AbortSignal.timeout(5_000)
|
|
241
|
+
* })
|
|
206
242
|
* ```
|
|
207
243
|
*/
|
|
208
|
-
get(key: Uint8Array, options?: RoutingOptions<RoutingGetProgressEvents>): Promise<Uint8Array>;
|
|
244
|
+
get?(key: Uint8Array, options?: RoutingOptions<RoutingGetProgressEvents>): Promise<Uint8Array>;
|
|
209
245
|
/**
|
|
210
246
|
* Searches the network for peer info corresponding to the passed peer id.
|
|
211
247
|
*
|
|
@@ -213,10 +249,12 @@ export interface Routing {
|
|
|
213
249
|
*
|
|
214
250
|
* ```js
|
|
215
251
|
* // ...
|
|
216
|
-
* const peer = await peerRouting.findPeer(peerId,
|
|
252
|
+
* const peer = await peerRouting.findPeer(peerId, {
|
|
253
|
+
* signal: AbortSignal.timeout(5_000)
|
|
254
|
+
* })
|
|
217
255
|
* ```
|
|
218
256
|
*/
|
|
219
|
-
findPeer(
|
|
257
|
+
findPeer?(peer: CID, options?: RoutingOptions<RoutingFindPeerProgressEvents>): Promise<Peer>;
|
|
220
258
|
/**
|
|
221
259
|
* Search the network for peers that are closer to the passed key. Peer
|
|
222
260
|
* info should be yielded in ever-increasing closeness to the key.
|
|
@@ -225,11 +263,14 @@ export interface Routing {
|
|
|
225
263
|
*
|
|
226
264
|
* ```js
|
|
227
265
|
* // Iterate over the closest peers found for the given key
|
|
228
|
-
* for await (const peer of peerRouting.getClosestPeers(key
|
|
266
|
+
* for await (const peer of peerRouting.getClosestPeers(key, {
|
|
267
|
+
* signal: AbortSignal.timeout(5_000)
|
|
268
|
+
* })) {
|
|
229
269
|
* console.log(peer.id, peer.multiaddrs)
|
|
230
270
|
* }
|
|
231
271
|
* ```
|
|
232
272
|
*/
|
|
233
|
-
getClosestPeers(key: Uint8Array, options?: RoutingOptions<RoutingGetClosestPeersProgressEvents>): AsyncIterable<
|
|
273
|
+
getClosestPeers?(key: Uint8Array, options?: RoutingOptions<RoutingGetClosestPeersProgressEvents>): AsyncIterable<Peer>;
|
|
234
274
|
}
|
|
275
|
+
export type Routing = Required<Omit<Router, 'name'>>;
|
|
235
276
|
//# sourceMappingURL=routing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO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ACvH;AAED,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/interface",
|
|
3
|
-
"version": "6.2.1-
|
|
3
|
+
"version": "6.2.1-ed6c3b79",
|
|
4
4
|
"description": "The Helia API",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia/tree/main/packages/interface#readme",
|
|
@@ -72,17 +72,21 @@
|
|
|
72
72
|
"build": "aegir build"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@
|
|
75
|
+
"@ipshipyard/crypto": "^1.1.0",
|
|
76
|
+
"@ipshipyard/keychain": "^1.0.2",
|
|
77
|
+
"@libp2p/interface": "^3.2.3",
|
|
76
78
|
"@multiformats/dns": "^1.0.13",
|
|
77
|
-
"@multiformats/multiaddr": "^13.0.
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"interface-
|
|
81
|
-
"
|
|
79
|
+
"@multiformats/multiaddr": "^13.0.3",
|
|
80
|
+
"abort-error": "^1.0.2",
|
|
81
|
+
"birnam": "^1.0.0",
|
|
82
|
+
"interface-blockstore": "^7.0.1",
|
|
83
|
+
"interface-datastore": "^10.0.1",
|
|
84
|
+
"main-event": "^1.0.4",
|
|
85
|
+
"multiformats": "^14.0.0",
|
|
82
86
|
"progress-events": "^1.1.0"
|
|
83
87
|
},
|
|
84
88
|
"devDependencies": {
|
|
85
|
-
"aegir": "^
|
|
89
|
+
"aegir": "^48.0.11"
|
|
86
90
|
},
|
|
87
91
|
"sideEffects": false
|
|
88
92
|
}
|
package/src/blocks.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RoutingFindProvidersProgressEvents } from './routing.ts'
|
|
2
|
-
import type { PeerId, AbortOptions } from '@libp2p/interface'
|
|
3
2
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
3
|
+
import type { AbortOptions } from 'abort-error'
|
|
4
4
|
import type { Blockstore } from 'interface-blockstore'
|
|
5
5
|
import type { CID } from 'multiformats/cid'
|
|
6
6
|
import type { ProgressEvent, ProgressOptions } from 'progress-events'
|
|
@@ -16,7 +16,7 @@ export interface ProviderOptions {
|
|
|
16
16
|
* child blocks, a `findProviders` routing query will be run to find peers
|
|
17
17
|
* that can supply the blocks.
|
|
18
18
|
*/
|
|
19
|
-
providers?: Array<
|
|
19
|
+
providers?: Array<CID | Multiaddr | Multiaddr[]>
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -25,7 +25,7 @@ export interface ProviderOptions {
|
|
|
25
25
|
export interface BlockBrokerConnectProgressEvent {
|
|
26
26
|
broker: string
|
|
27
27
|
type: 'connect'
|
|
28
|
-
provider:
|
|
28
|
+
provider: CID
|
|
29
29
|
cid: CID
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -35,7 +35,7 @@ export interface BlockBrokerConnectProgressEvent {
|
|
|
35
35
|
export interface BlockBrokerConnectedProgressEvent {
|
|
36
36
|
broker: string
|
|
37
37
|
type: 'connected'
|
|
38
|
-
provider:
|
|
38
|
+
provider: CID
|
|
39
39
|
address: Multiaddr
|
|
40
40
|
cid: CID
|
|
41
41
|
}
|
|
@@ -46,7 +46,7 @@ export interface BlockBrokerConnectedProgressEvent {
|
|
|
46
46
|
export interface BlockBrokerRequestBlockProgressEvent {
|
|
47
47
|
broker: string
|
|
48
48
|
type: 'request-block'
|
|
49
|
-
provider:
|
|
49
|
+
provider: CID
|
|
50
50
|
cid: CID
|
|
51
51
|
}
|
|
52
52
|
|
|
@@ -56,7 +56,7 @@ export interface BlockBrokerRequestBlockProgressEvent {
|
|
|
56
56
|
export interface BlockBrokerReceiveBlockProgressEvent {
|
|
57
57
|
broker: string
|
|
58
58
|
type: 'receive-block'
|
|
59
|
-
provider:
|
|
59
|
+
provider: CID
|
|
60
60
|
cid: CID
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -150,7 +150,7 @@ ProgressOptions<DeleteBlockProgressEvents>, ProgressOptions<DeleteManyBlocksProg
|
|
|
150
150
|
* Adds a new peer to the session if they are supported and are either
|
|
151
151
|
* not already in the session and have not been evicted previously.
|
|
152
152
|
*/
|
|
153
|
-
addPeer (peer:
|
|
153
|
+
addPeer (peer: CID | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<void>
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
export interface BlockRetrievalOptions <ProgressEvents extends ProgressEvent<any, any> = ProgressEvent<any, any>> extends AbortOptions, ProgressOptions<ProgressEvents>, ProviderOptions {
|
|
@@ -232,7 +232,7 @@ export interface SessionBlockBroker<RetrieveProgressEvents extends ProgressEvent
|
|
|
232
232
|
* Adds a new peer to the session if they are supported and are either
|
|
233
233
|
* not already in the session and have not been evicted previously.
|
|
234
234
|
*/
|
|
235
|
-
addPeer (peer:
|
|
235
|
+
addPeer (peer: CID | Multiaddr | Multiaddr[], options?: AbortOptions): Promise<void>
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
export const DEFAULT_SESSION_MIN_PROVIDERS = 1
|
package/src/errors.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -14,35 +14,50 @@
|
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import type { Blocks } from './blocks.ts'
|
|
17
|
+
import type { BlockBroker, Blocks } from './blocks.ts'
|
|
18
18
|
import type { Pins } from './pins.ts'
|
|
19
|
-
import type { Routing } from './routing.ts'
|
|
20
|
-
import type {
|
|
19
|
+
import type { Router, Routing } from './routing.ts'
|
|
20
|
+
import type { CryptoLoader, Keychain } from '@ipshipyard/keychain'
|
|
21
|
+
import type { Metrics } from '@libp2p/interface'
|
|
21
22
|
import type { DNS } from '@multiformats/dns'
|
|
23
|
+
import type { AbortOptions } from 'abort-error'
|
|
24
|
+
import type { ComponentLogger } from 'birnam'
|
|
22
25
|
import type { Datastore } from 'interface-datastore'
|
|
23
|
-
import type {
|
|
26
|
+
import type { TypedEventEmitter } from 'main-event'
|
|
24
27
|
import type { BlockCodec, MultihashHasher } from 'multiformats'
|
|
25
28
|
import type { CID } from 'multiformats/cid'
|
|
26
29
|
import type { ProgressEvent, ProgressOptions } from 'progress-events'
|
|
27
30
|
|
|
28
|
-
export type { Await, AwaitIterable } from 'interface-store'
|
|
29
|
-
|
|
30
31
|
export interface CodecLoader {
|
|
31
|
-
<T = any, Code extends number = any>(code: Code):
|
|
32
|
+
<T = any, Code extends number = any>(code: Code, options?: AbortOptions): BlockCodec<Code, T> | Promise<BlockCodec<Code, T>>
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export interface HasherLoader {
|
|
35
|
-
(code: number):
|
|
36
|
+
(code: number, options?: AbortOptions): MultihashHasher | Promise<MultihashHasher>
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type { CryptoLoader, Keychain } from '@ipshipyard/keychain'
|
|
40
|
+
export type { Crypto, PrivateKey, PublicKey } from '@ipshipyard/crypto'
|
|
41
|
+
export { isPrivateKey, isPublicKey } from '@ipshipyard/crypto'
|
|
42
|
+
|
|
43
|
+
export interface NodeInfo {
|
|
44
|
+
name: string
|
|
45
|
+
version: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface HeliaMixin<Start extends Helia = Helia, Stop = Start> {
|
|
49
|
+
start?(helia: Start): Promise<void> | void
|
|
50
|
+
stop?(helia: Stop): Promise<void> | void
|
|
36
51
|
}
|
|
37
52
|
|
|
38
53
|
/**
|
|
39
54
|
* The API presented by a Helia node
|
|
40
55
|
*/
|
|
41
|
-
export interface Helia
|
|
56
|
+
export interface Helia {
|
|
42
57
|
/**
|
|
43
|
-
*
|
|
58
|
+
* Runtime information about the node
|
|
44
59
|
*/
|
|
45
|
-
|
|
60
|
+
info: NodeInfo
|
|
46
61
|
|
|
47
62
|
/**
|
|
48
63
|
* Where the blocks are stored
|
|
@@ -57,7 +72,12 @@ export interface Helia<T extends Libp2p = Libp2p> {
|
|
|
57
72
|
/**
|
|
58
73
|
* Event emitter for Helia start and stop events
|
|
59
74
|
*/
|
|
60
|
-
events: TypedEventEmitter<HeliaEvents<
|
|
75
|
+
events: TypedEventEmitter<HeliaEvents<this>>
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Secure storage for private keys
|
|
79
|
+
*/
|
|
80
|
+
keychain: Keychain
|
|
61
81
|
|
|
62
82
|
/**
|
|
63
83
|
* Pinning operations for blocks in the blockstore
|
|
@@ -87,15 +107,20 @@ export interface Helia<T extends Libp2p = Libp2p> {
|
|
|
87
107
|
*/
|
|
88
108
|
metrics?: Metrics
|
|
89
109
|
|
|
110
|
+
/**
|
|
111
|
+
* The current status of the Helia node
|
|
112
|
+
*/
|
|
113
|
+
status: 'starting' | 'started' | 'stopping' | 'stopped'
|
|
114
|
+
|
|
90
115
|
/**
|
|
91
116
|
* Starts the Helia node
|
|
92
117
|
*/
|
|
93
|
-
start(): Promise<
|
|
118
|
+
start(options?: AbortOptions): Promise<this>
|
|
94
119
|
|
|
95
120
|
/**
|
|
96
121
|
* Stops the Helia node
|
|
97
122
|
*/
|
|
98
|
-
stop(): Promise<
|
|
123
|
+
stop(options?: AbortOptions): Promise<this>
|
|
99
124
|
|
|
100
125
|
/**
|
|
101
126
|
* Remove any unpinned blocks from the blockstore
|
|
@@ -114,6 +139,36 @@ export interface Helia<T extends Libp2p = Libp2p> {
|
|
|
114
139
|
* the hasher is being fetched from the network.
|
|
115
140
|
*/
|
|
116
141
|
getHasher: HasherLoader
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Cryptography implementations securely sign and verify data
|
|
145
|
+
*/
|
|
146
|
+
getCrypto: CryptoLoader
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Returns `true` if a router with the passed name has been configured
|
|
150
|
+
*/
|
|
151
|
+
hasRouter (name: string): boolean
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Add a router
|
|
155
|
+
*/
|
|
156
|
+
addRouter(router: Router): void
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Returns `true` if a block broker with the passed name has been configured
|
|
160
|
+
*/
|
|
161
|
+
hasBlockBroker (name: string): boolean
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Add a block broker
|
|
165
|
+
*/
|
|
166
|
+
addBlockBroker(blockBroker: BlockBroker): void
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Add a mixin to extend runtime functionality
|
|
170
|
+
*/
|
|
171
|
+
addMixin<T extends Helia = Helia & Record<string, any>>(mixin: HeliaMixin<T>): void
|
|
117
172
|
}
|
|
118
173
|
|
|
119
174
|
export type GcEvents =
|
|
@@ -124,7 +179,7 @@ export interface GCOptions extends AbortOptions, ProgressOptions<GcEvents> {
|
|
|
124
179
|
|
|
125
180
|
}
|
|
126
181
|
|
|
127
|
-
export interface HeliaEvents<
|
|
182
|
+
export interface HeliaEvents<H extends Helia = Helia> {
|
|
128
183
|
/**
|
|
129
184
|
* This event notifies listeners that the node has started
|
|
130
185
|
*
|
|
@@ -134,7 +189,7 @@ export interface HeliaEvents<T extends Libp2p = Libp2p> {
|
|
|
134
189
|
* })
|
|
135
190
|
* ```
|
|
136
191
|
*/
|
|
137
|
-
start: CustomEvent<
|
|
192
|
+
start: CustomEvent<H>
|
|
138
193
|
|
|
139
194
|
/**
|
|
140
195
|
* This event notifies listeners that the node has stopped
|
|
@@ -145,7 +200,7 @@ export interface HeliaEvents<T extends Libp2p = Libp2p> {
|
|
|
145
200
|
* })
|
|
146
201
|
* ```
|
|
147
202
|
*/
|
|
148
|
-
stop: CustomEvent<
|
|
203
|
+
stop: CustomEvent<H>
|
|
149
204
|
}
|
|
150
205
|
|
|
151
206
|
export * from './blocks.ts'
|
package/src/pins.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { GetBlockProgressEvents } from './blocks.ts'
|
|
2
|
-
import type { AbortOptions } from '
|
|
2
|
+
import type { AbortOptions } from 'abort-error'
|
|
3
3
|
import type { CID } from 'multiformats/cid'
|
|
4
4
|
import type { ProgressEvent, ProgressOptions } from 'progress-events'
|
|
5
5
|
|
package/src/routing.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
2
|
+
import type { AbortOptions } from 'abort-error'
|
|
2
3
|
import type { CID } from 'multiformats/cid'
|
|
3
4
|
import type { ProgressEvent, ProgressOptions } from 'progress-events'
|
|
4
5
|
|
|
@@ -8,7 +9,7 @@ import type { ProgressEvent, ProgressOptions } from 'progress-events'
|
|
|
8
9
|
* local cache that may be used in preference over network calls, for example
|
|
9
10
|
* when a record has a TTL.
|
|
10
11
|
*/
|
|
11
|
-
export interface RoutingOptions<Event extends ProgressEvent = any> extends AbortOptions, ProgressOptions<Event
|
|
12
|
+
export interface RoutingOptions<Event extends ProgressEvent = any> extends AbortOptions, ProgressOptions<Event> {
|
|
12
13
|
/**
|
|
13
14
|
* Pass `false` to not use the network
|
|
14
15
|
*
|
|
@@ -29,12 +30,42 @@ export interface RoutingOptions<Event extends ProgressEvent = any> extends Abort
|
|
|
29
30
|
* @default true
|
|
30
31
|
*/
|
|
31
32
|
validate?: boolean
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Where tracing is used, this value carries tracing context
|
|
36
|
+
*/
|
|
37
|
+
trace?: any
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A Peer is another node on the network
|
|
42
|
+
*/
|
|
43
|
+
export interface Peer {
|
|
44
|
+
/**
|
|
45
|
+
* The identifier of the remote peer
|
|
46
|
+
*/
|
|
47
|
+
id: CID
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The multiaddrs a peer is listening on
|
|
51
|
+
*/
|
|
52
|
+
multiaddrs: Multiaddr[]
|
|
32
53
|
}
|
|
33
54
|
|
|
34
55
|
/**
|
|
35
56
|
* A provider can supply the content for a CID
|
|
36
57
|
*/
|
|
37
|
-
export interface Provider
|
|
58
|
+
export interface Provider {
|
|
59
|
+
/**
|
|
60
|
+
* The identifier of the remote peer, a CID
|
|
61
|
+
*/
|
|
62
|
+
id: CID
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The multiaddrs a peer is listening on
|
|
66
|
+
*/
|
|
67
|
+
multiaddrs: Multiaddr[]
|
|
68
|
+
|
|
38
69
|
/**
|
|
39
70
|
* If present these are the methods that the peer can supply the content via.
|
|
40
71
|
*
|
|
@@ -69,7 +100,7 @@ export interface RoutingFindProvidersEndEvent {
|
|
|
69
100
|
export interface RoutingFindProvidersHttpGatewayProvider {
|
|
70
101
|
routing: 'http-gateway-router'
|
|
71
102
|
cid: CID
|
|
72
|
-
provider:
|
|
103
|
+
provider: Peer & {
|
|
73
104
|
protocols: ['transport-ipfs-gateway-http']
|
|
74
105
|
}
|
|
75
106
|
}
|
|
@@ -77,7 +108,7 @@ export interface RoutingFindProvidersHttpGatewayProvider {
|
|
|
77
108
|
export interface RoutingFindProvidersDelegatedHttpRoutingProvider {
|
|
78
109
|
routing: 'delegated-http-router'
|
|
79
110
|
cid: CID
|
|
80
|
-
provider:
|
|
111
|
+
provider: Peer & {
|
|
81
112
|
routing: 'delegated-http-routing'
|
|
82
113
|
protocols: string[]
|
|
83
114
|
}
|
|
@@ -86,7 +117,7 @@ export interface RoutingFindProvidersDelegatedHttpRoutingProvider {
|
|
|
86
117
|
export interface RoutingFindProvidersLibp2pProvider {
|
|
87
118
|
routing: 'libp2p-router'
|
|
88
119
|
cid: CID
|
|
89
|
-
provider:
|
|
120
|
+
provider: Peer
|
|
90
121
|
}
|
|
91
122
|
|
|
92
123
|
export type RoutingFindProvidersProviderEvent = RoutingFindProvidersHttpGatewayProvider | RoutingFindProvidersDelegatedHttpRoutingProvider | RoutingFindProvidersLibp2pProvider
|
|
@@ -157,12 +188,12 @@ export type RoutingGetProgressEvents =
|
|
|
157
188
|
|
|
158
189
|
export interface RoutingFindPeerStartEvent {
|
|
159
190
|
routing: string
|
|
160
|
-
peerId:
|
|
191
|
+
peerId: CID
|
|
161
192
|
}
|
|
162
193
|
|
|
163
194
|
export interface RoutingFindPeerEndEvent {
|
|
164
195
|
routing: string
|
|
165
|
-
peerId:
|
|
196
|
+
peerId: CID
|
|
166
197
|
}
|
|
167
198
|
|
|
168
199
|
export type RoutingFindPeerProgressEvents =
|
|
@@ -183,7 +214,7 @@ export type RoutingGetClosestPeersProgressEvents =
|
|
|
183
214
|
ProgressEvent<'helia:routing:get-closest-peers:start', RoutingGetClosestPeersStartEvent> |
|
|
184
215
|
ProgressEvent<'helia:routing:get-closest-peers:end', RoutingGetClosestPeersEndEvent>
|
|
185
216
|
|
|
186
|
-
export interface
|
|
217
|
+
export interface Router {
|
|
187
218
|
/**
|
|
188
219
|
* The name of this routing implementation
|
|
189
220
|
*/
|
|
@@ -197,10 +228,12 @@ export interface Routing {
|
|
|
197
228
|
*
|
|
198
229
|
* ```js
|
|
199
230
|
* // ...
|
|
200
|
-
* await contentRouting.provide(cid
|
|
231
|
+
* await contentRouting.provide(cid, {
|
|
232
|
+
* signal: AbortSignal.timeout(5_000)
|
|
233
|
+
* })
|
|
201
234
|
* ```
|
|
202
235
|
*/
|
|
203
|
-
provide(cid: CID, options?: RoutingOptions<RoutingProvideProgressEvents>): Promise<void>
|
|
236
|
+
provide?(cid: CID, options?: RoutingOptions<RoutingProvideProgressEvents>): Promise<void>
|
|
204
237
|
|
|
205
238
|
/**
|
|
206
239
|
* Helia will periodically re-provide every previously provided CID. Use this
|
|
@@ -210,10 +243,12 @@ export interface Routing {
|
|
|
210
243
|
*
|
|
211
244
|
* ```js
|
|
212
245
|
* // ...
|
|
213
|
-
* await contentRouting.cancelReprovide(cid
|
|
246
|
+
* await contentRouting.cancelReprovide(cid, {
|
|
247
|
+
* signal: AbortSignal.timeout(5_000)
|
|
248
|
+
* })
|
|
214
249
|
* ```
|
|
215
250
|
*/
|
|
216
|
-
cancelReprovide(key: CID, options?: AbortOptions): Promise<void>
|
|
251
|
+
cancelReprovide?(key: CID, options?: AbortOptions): Promise<void>
|
|
217
252
|
|
|
218
253
|
/**
|
|
219
254
|
* Find the providers of the passed CID.
|
|
@@ -222,12 +257,14 @@ export interface Routing {
|
|
|
222
257
|
*
|
|
223
258
|
* ```js
|
|
224
259
|
* // Iterate over the providers found for the given cid
|
|
225
|
-
* for await (const provider of contentRouting.findProviders(cid
|
|
260
|
+
* for await (const provider of contentRouting.findProviders(cid, {
|
|
261
|
+
* signal: AbortSignal.timeout(5_000)
|
|
262
|
+
* })) {
|
|
226
263
|
* console.log(provider.id, provider.multiaddrs)
|
|
227
264
|
* }
|
|
228
265
|
* ```
|
|
229
266
|
*/
|
|
230
|
-
findProviders(cid: CID, options?: RoutingOptions<RoutingFindProvidersProgressEvents>): AsyncIterable<Provider>
|
|
267
|
+
findProviders?(cid: CID, options?: RoutingOptions<RoutingFindProvidersProgressEvents>): AsyncIterable<Provider>
|
|
231
268
|
|
|
232
269
|
/**
|
|
233
270
|
* Puts a value corresponding to the passed key in a way that can later be
|
|
@@ -237,13 +274,15 @@ export interface Routing {
|
|
|
237
274
|
*
|
|
238
275
|
* ```js
|
|
239
276
|
* // ...
|
|
240
|
-
* const key = '/key'
|
|
277
|
+
* const key = uint8ArrayFromString('/key')
|
|
241
278
|
* const value = uint8ArrayFromString('oh hello there')
|
|
242
279
|
*
|
|
243
|
-
* await contentRouting.put(key, value
|
|
280
|
+
* await contentRouting.put(key, value, {
|
|
281
|
+
* signal: AbortSignal.timeout(5_000)
|
|
282
|
+
* })
|
|
244
283
|
* ```
|
|
245
284
|
*/
|
|
246
|
-
put(key: Uint8Array, value: Uint8Array, options?: RoutingOptions<RoutingPutProgressEvents>): Promise<void>
|
|
285
|
+
put?(key: Uint8Array, value: Uint8Array, options?: RoutingOptions<RoutingPutProgressEvents>): Promise<void>
|
|
247
286
|
|
|
248
287
|
/**
|
|
249
288
|
* Retrieves a value from the network corresponding to the passed key.
|
|
@@ -253,11 +292,13 @@ export interface Routing {
|
|
|
253
292
|
* ```js
|
|
254
293
|
* // ...
|
|
255
294
|
*
|
|
256
|
-
* const key = '/key'
|
|
257
|
-
* const value = await contentRouting.get(key
|
|
295
|
+
* const key = uint8ArrayFromString('/key')
|
|
296
|
+
* const value = await contentRouting.get(key, {
|
|
297
|
+
* signal: AbortSignal.timeout(5_000)
|
|
298
|
+
* })
|
|
258
299
|
* ```
|
|
259
300
|
*/
|
|
260
|
-
get(key: Uint8Array, options?: RoutingOptions<RoutingGetProgressEvents>): Promise<Uint8Array>
|
|
301
|
+
get?(key: Uint8Array, options?: RoutingOptions<RoutingGetProgressEvents>): Promise<Uint8Array>
|
|
261
302
|
|
|
262
303
|
/**
|
|
263
304
|
* Searches the network for peer info corresponding to the passed peer id.
|
|
@@ -266,10 +307,12 @@ export interface Routing {
|
|
|
266
307
|
*
|
|
267
308
|
* ```js
|
|
268
309
|
* // ...
|
|
269
|
-
* const peer = await peerRouting.findPeer(peerId,
|
|
310
|
+
* const peer = await peerRouting.findPeer(peerId, {
|
|
311
|
+
* signal: AbortSignal.timeout(5_000)
|
|
312
|
+
* })
|
|
270
313
|
* ```
|
|
271
314
|
*/
|
|
272
|
-
findPeer(
|
|
315
|
+
findPeer?(peer: CID, options?: RoutingOptions<RoutingFindPeerProgressEvents>): Promise<Peer>
|
|
273
316
|
|
|
274
317
|
/**
|
|
275
318
|
* Search the network for peers that are closer to the passed key. Peer
|
|
@@ -279,10 +322,14 @@ export interface Routing {
|
|
|
279
322
|
*
|
|
280
323
|
* ```js
|
|
281
324
|
* // Iterate over the closest peers found for the given key
|
|
282
|
-
* for await (const peer of peerRouting.getClosestPeers(key
|
|
325
|
+
* for await (const peer of peerRouting.getClosestPeers(key, {
|
|
326
|
+
* signal: AbortSignal.timeout(5_000)
|
|
327
|
+
* })) {
|
|
283
328
|
* console.log(peer.id, peer.multiaddrs)
|
|
284
329
|
* }
|
|
285
330
|
* ```
|
|
286
331
|
*/
|
|
287
|
-
getClosestPeers(key: Uint8Array, options?: RoutingOptions<RoutingGetClosestPeersProgressEvents>): AsyncIterable<
|
|
332
|
+
getClosestPeers?(key: Uint8Array, options?: RoutingOptions<RoutingGetClosestPeersProgressEvents>): AsyncIterable<Peer>
|
|
288
333
|
}
|
|
334
|
+
|
|
335
|
+
export type Routing = Required<Omit<Router, 'name'>>
|