UNPKG

@settlemint/sdk-ipfs

Version:

IPFS integration module for SettleMint SDK, enabling decentralized storage and content addressing

77 lines (76 loc) 2.63 kB
/* SettleMint IPFS SDK - Distributed Storage */ import { KuboRPCClient } from "kubo-rpc-client"; import { z } from "zod"; //#region src/helpers/client-options.schema.d.ts /** * Schema for validating client options for the IPFS client. */ declare const ClientOptionsSchema: z.ZodObject<{ instance: z.ZodString; }, z.core.$strip>; /** * Type definition for client options derived from the ClientOptionsSchema. */ type ClientOptions = z.infer<typeof ClientOptionsSchema>; /** * Schema for validating server client options for the IPFS client. * Extends the ClientOptionsSchema with additional server-specific fields. */ declare const ServerClientOptionsSchema: z.ZodObject<{ instance: z.ZodString; accessToken: z.ZodOptional<z.ZodString>; }, z.core.$strip>; /** * Type definition for server client options derived from the ServerClientOptionsSchema. */ type ServerClientOptions = z.infer<typeof ServerClientOptionsSchema>; //#endregion //#region src/ipfs.d.ts /** * Creates an IPFS client for client-side use * * @param options - Configuration options for the client * @returns An object containing the configured IPFS client instance * @throws Will throw an error if the options fail validation * @example * ```ts * import { createIpfsClient } from '@settlemint/sdk-ipfs'; * * const { client } = createIpfsClient({ * instance: 'https://ipfs.settlemint.com' * }); * * // Upload a file using Blob * const blob = new Blob(['Hello, world!'], { type: 'text/plain' }); * const result = await client.add(blob); * console.log(result.cid.toString()); * ``` */ declare function createIpfsClient(options: ClientOptions): { client: KuboRPCClient; }; /** * Creates an IPFS client for server-side use with authentication * * @param options - Configuration options for the client including authentication * @returns An object containing the authenticated IPFS client instance * @throws Will throw an error if called on the client side or if options validation fails * @example * import { createServerIpfsClient } from '@settlemint/sdk-ipfs'; * * const { client } = createServerIpfsClient({ * instance: process.env.SETTLEMINT_IPFS_ENDPOINT, * accessToken: process.env.SETTLEMINT_ACCESS_TOKEN * }); * * // Upload a file using Blob * const blob = new Blob(['Hello, world!'], { type: 'text/plain' }); * const result = await client.add(blob); * console.log(result.cid.toString()); */ declare function createServerIpfsClient(options: ServerClientOptions): { client: KuboRPCClient; }; //#endregion export { createIpfsClient, createServerIpfsClient }; //# sourceMappingURL=ipfs.d.cts.map