@helia/interface 6.1.1-11802dd6 → 6.1.1-1a2ebead

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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 } from '@libp2p/interface'\nimport type { Multiaddr } from '@multiformats/multiaddr'\nimport type { Blockstore } from 'interface-blockstore'\nimport type { AbortOptions } from 'interface-store'\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\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\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,IC+LO,IAAMC,EAAgC,EAChCC,EAAgC,EAChCC,EAA+B,ICjMtC,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",
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 } from '@libp2p/interface'\nimport type { Multiaddr } from '@multiformats/multiaddr'\nimport type { Blockstore } from 'interface-blockstore'\nimport type { AbortOptions } from 'interface-store'\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,IC8OO,IAAMC,EAAgC,EAChCC,EAAgC,EAChCC,EAA+B,IChPtC,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",
6
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"]
7
7
  }
@@ -17,10 +17,48 @@ export interface ProviderOptions {
17
17
  */
18
18
  providers?: Array<PeerId | Multiaddr | Multiaddr[]>;
19
19
  }
20
+ /**
21
+ * A block broker will contact a provider to retrieve a block
22
+ */
23
+ export interface BlockBrokerConnectProgressEvent {
24
+ broker: string;
25
+ type: 'connect';
26
+ provider: PeerId;
27
+ cid: CID;
28
+ }
29
+ /**
30
+ * A block broker has contacted a provider to retrieve a block
31
+ */
32
+ export interface BlockBrokerConnectedProgressEvent {
33
+ broker: string;
34
+ type: 'connected';
35
+ provider: PeerId;
36
+ address: Multiaddr;
37
+ cid: CID;
38
+ }
39
+ /**
40
+ * A block broker has retrieved a block from a provider
41
+ */
42
+ export interface BlockBrokerRequestBlockProgressEvent {
43
+ broker: string;
44
+ type: 'request-block';
45
+ provider: PeerId;
46
+ cid: CID;
47
+ }
48
+ /**
49
+ * A block broker has retrieved a block from a provider
50
+ */
51
+ export interface BlockBrokerReceiveBlockProgressEvent {
52
+ broker: string;
53
+ type: 'receive-block';
54
+ provider: PeerId;
55
+ cid: CID;
56
+ }
57
+ 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>;
20
58
  export type HasBlockProgressEvents = ProgressEvent<'blocks:put:duplicate', CID> | ProgressEvent<'blocks:put:providers:notify', CID> | ProgressEvent<'blocks:put:blockstore:put', CID>;
21
59
  export type PutBlockProgressEvents = ProgressEvent<'blocks:put:duplicate', CID> | ProgressEvent<'blocks:put:providers:notify', CID> | ProgressEvent<'blocks:put:blockstore:put', CID>;
22
60
  export type PutManyBlocksProgressEvents = ProgressEvent<'blocks:put-many:duplicate', CID> | ProgressEvent<'blocks:put-many:providers:notify', CID> | ProgressEvent<'blocks:put-many:blockstore:put-many'>;
23
- export type GetBlockProgressEvents = ProgressEvent<'blocks:get:providers:want', CID> | ProgressEvent<'blocks:get:blockstore:get', CID> | ProgressEvent<'blocks:get:blockstore:put', CID> | RoutingFindProvidersProgressEvents;
61
+ export type GetBlockProgressEvents = ProgressEvent<'blocks:get:providers:want', CID> | ProgressEvent<'blocks:get:blockstore:get', CID> | ProgressEvent<'blocks:get:blockstore:put', CID> | RoutingFindProvidersProgressEvents | BlockBrokerGetBlockProgressEvents;
24
62
  export type GetManyBlocksProgressEvents = ProgressEvent<'blocks:get-many:blockstore:get-many'> | ProgressEvent<'blocks:get-many:providers:want', CID> | ProgressEvent<'blocks:get-many:blockstore:put', CID>;
25
63
  export type GetAllBlocksProgressEvents = ProgressEvent<'blocks:get-all:blockstore:get-many'>;
26
64
  export type DeleteBlockProgressEvents = ProgressEvent<'blocks:delete:blockstore:delete', CID>;
@@ -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,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAErE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAE3D,MAAM,WAAW,eAAe;IAC9B;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,M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G,CAAC,GAAG,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAE,SAAQ,WAAW,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IACzQ;;;OAGG;IACH,OAAO,CAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACxF;AAED,eAAO,MAAM,6BAA6B,IAAI,CAAA;AAC9C,eAAO,MAAM,6BAA6B,IAAI,CAAA;AAC9C,eAAO,MAAM,4BAA4B,MAAM,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":"AA+LA,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAA;AAC9C,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAA;AAC9C,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAA"}
1
+ {"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../src/blocks.ts"],"names":[],"mappings":"AA8OA,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAA;AAC9C,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAA;AAC9C,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/interface",
3
- "version": "6.1.1-11802dd6",
3
+ "version": "6.1.1-1a2ebead",
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",
@@ -68,7 +68,7 @@
68
68
  "build": "aegir build"
69
69
  },
70
70
  "dependencies": {
71
- "@libp2p/interface": "^3.1.0",
71
+ "@libp2p/interface": "^3.2.0",
72
72
  "@multiformats/dns": "^1.0.9",
73
73
  "@multiformats/multiaddr": "^13.0.1",
74
74
  "interface-blockstore": "^6.0.1",
package/src/blocks.ts CHANGED
@@ -20,6 +20,52 @@ export interface ProviderOptions {
20
20
  providers?: Array<PeerId | Multiaddr | Multiaddr[]>
21
21
  }
22
22
 
23
+ /**
24
+ * A block broker will contact a provider to retrieve a block
25
+ */
26
+ export interface BlockBrokerConnectProgressEvent {
27
+ broker: string
28
+ type: 'connect'
29
+ provider: PeerId
30
+ cid: CID
31
+ }
32
+
33
+ /**
34
+ * A block broker has contacted a provider to retrieve a block
35
+ */
36
+ export interface BlockBrokerConnectedProgressEvent {
37
+ broker: string
38
+ type: 'connected'
39
+ provider: PeerId
40
+ address: Multiaddr
41
+ cid: CID
42
+ }
43
+
44
+ /**
45
+ * A block broker has retrieved a block from a provider
46
+ */
47
+ export interface BlockBrokerRequestBlockProgressEvent {
48
+ broker: string
49
+ type: 'request-block'
50
+ provider: PeerId
51
+ cid: CID
52
+ }
53
+
54
+ /**
55
+ * A block broker has retrieved a block from a provider
56
+ */
57
+ export interface BlockBrokerReceiveBlockProgressEvent {
58
+ broker: string
59
+ type: 'receive-block'
60
+ provider: PeerId
61
+ cid: CID
62
+ }
63
+
64
+ export type BlockBrokerGetBlockProgressEvents = ProgressEvent<'helia:block-broker:connect', BlockBrokerConnectProgressEvent>
65
+ | ProgressEvent<'helia:block-broker:connected', BlockBrokerConnectedProgressEvent>
66
+ | ProgressEvent<'helia:block-broker:request-block', BlockBrokerRequestBlockProgressEvent>
67
+ | ProgressEvent<'helia:block-broker:receive-block', BlockBrokerReceiveBlockProgressEvent>
68
+
23
69
  export type HasBlockProgressEvents =
24
70
  ProgressEvent<'blocks:put:duplicate', CID> |
25
71
  ProgressEvent<'blocks:put:providers:notify', CID> |
@@ -39,7 +85,8 @@ export type GetBlockProgressEvents =
39
85
  ProgressEvent<'blocks:get:providers:want', CID> |
40
86
  ProgressEvent<'blocks:get:blockstore:get', CID> |
41
87
  ProgressEvent<'blocks:get:blockstore:put', CID> |
42
- RoutingFindProvidersProgressEvents
88
+ RoutingFindProvidersProgressEvents |
89
+ BlockBrokerGetBlockProgressEvents
43
90
 
44
91
  export type GetManyBlocksProgressEvents =
45
92
  ProgressEvent<'blocks:get-many:blockstore:get-many'> |