Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libs/pinner/src/adapters/pinata/v2/adapter-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ export interface PinataAdapter {
* Configuration
*/
config: PinataConfig;
/**
* Update the adapter configuration
*/
updateConfig(newConfig: PinataConfig): void;

/**
Expand Down
41 changes: 41 additions & 0 deletions libs/pinner/src/api/ipns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ export interface IpnsClientOptions {
signal?: AbortSignal;
}

/**
* Client for managing IPNS keys and publishing content to IPNS names.
*/
export class IpnsClient {
private config: PinnerConfig;

/**
* Create a new IpnsClient.
* @param config SDK configuration
*/
constructor(config: PinnerConfig) {
if (!config.jwt) {
throw new ConfigurationError("JWT token is required");
Expand Down Expand Up @@ -99,18 +106,32 @@ export class IpnsClient {
}
}

/**
* List all IPNS keys.
* @param options Request options
*/
async listKeys(options?: IpnsClientOptions): Promise<IPNSKeyListResponseResponse> {
return this.request<IPNSKeyListResponseResponse>("api/ipns/keys", {
signal: options?.signal,
});
}

/**
* Get a specific IPNS key by ID.
* @param id Key ID
* @param options Request options
*/
async getKey(id: number, options?: IpnsClientOptions): Promise<IPNSKeyResponse> {
return this.request<IPNSKeyResponse>(`api/ipns/keys/${id}`, {
signal: options?.signal,
});
}

/**
* Create a new IPNS key.
* @param request Key creation parameters
* @param options Request options
*/
async createKey(
request: IPNSKeyRequest,
options?: IpnsClientOptions,
Expand All @@ -122,13 +143,23 @@ export class IpnsClient {
});
}

/**
* Delete an IPNS key by ID.
* @param id Key ID to delete
* @param options Request options
*/
async deleteKey(id: number, options?: IpnsClientOptions): Promise<void> {
await this.request<void>(`api/ipns/keys/${id}`, {
method: "DELETE",
signal: options?.signal,
});
}

/**
* Publish content to an IPNS name.
* @param request Publishing parameters
* @param options Request options
*/
async publish(
request: IPNSPublishRequest,
options?: IpnsClientOptions,
Expand All @@ -140,6 +171,11 @@ export class IpnsClient {
});
}

/**
* Republish (refresh) an existing IPNS record.
* @param id Key ID to republish
* @param options Request options
*/
async republish(
id: number,
options?: IpnsClientOptions,
Expand All @@ -150,6 +186,11 @@ export class IpnsClient {
});
}

/**
* Resolve an IPNS name to its content.
* @param name IPNS name to resolve
* @param options Request options
*/
async resolve(
name: string,
options?: IpnsClientOptions,
Expand Down
51 changes: 51 additions & 0 deletions libs/pinner/src/api/websites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,16 @@ export interface WebsitesClientOptions {
signal?: AbortSignal;
}

/**
* Client for managing websites hosted on IPFS with custom domains and SSL.
*/
export class WebsitesClient {
private config: PinnerConfig;

/**
* Create a new WebsitesClient.
* @param config SDK configuration
*/
constructor(config: PinnerConfig) {
if (!config.jwt) {
throw new ConfigurationError("JWT token is required");
Expand Down Expand Up @@ -145,12 +152,21 @@ export class WebsitesClient {
}
}

/**
* List all websites.
* @param options Request options
*/
async listWebsites(options?: WebsitesClientOptions): Promise<WebsiteItemResponse> {
return this.request<WebsiteItemResponse>("api/websites", {
signal: options?.signal,
});
}

/**
* Create a new website.
* @param request Website creation parameters
* @param options Request options
*/
async createWebsite(
request: WebsiteRequest,
options?: WebsitesClientOptions,
Expand All @@ -162,6 +178,11 @@ export class WebsitesClient {
});
}

/**
* Get website details by ID.
* @param id Website ID
* @param options Request options
*/
async getWebsite(
id: number,
options?: WebsitesClientOptions,
Expand All @@ -171,6 +192,12 @@ export class WebsitesClient {
});
}

/**
* Update a website's configuration.
* @param id Website ID
* @param request Update parameters
* @param options Request options
*/
async updateWebsite(
id: number,
request: WebsiteUpdateRequest,
Expand All @@ -183,6 +210,11 @@ export class WebsitesClient {
});
}

/**
* Delete a website by ID.
* @param id Website ID
* @param options Request options
*/
async deleteWebsite(
id: number,
options?: WebsitesClientOptions,
Expand All @@ -193,6 +225,11 @@ export class WebsitesClient {
});
}

/**
* Validate a website's DNS and SSL configuration.
* @param id Website ID
* @param options Request options
*/
async validateWebsite(
id: number,
options?: WebsitesClientOptions,
Expand All @@ -206,6 +243,11 @@ export class WebsitesClient {
);
}

/**
* Check the SSL certificate status for a domain.
* @param domain Domain name
* @param options Request options
*/
async getSSLStatus(
domain: string,
options?: WebsitesClientOptions,
Expand All @@ -218,6 +260,10 @@ export class WebsitesClient {
);
}

/**
* Get the global website configuration.
* @param options Request options
*/
async getWebsiteConfig(
options?: WebsitesClientOptions,
): Promise<WebsiteConfigResponse> {
Expand All @@ -226,6 +272,11 @@ export class WebsitesClient {
});
}

/**
* Watch SSL status until provisioned, failed, or timed out.
* @param domain Domain name
* @param options Watch interval and timeout
*/
watchSSL(
domain: string,
options?: WatchOptions,
Expand Down
5 changes: 5 additions & 0 deletions libs/pinner/src/blockstore/unstorage-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ import { collectAsyncIterable } from "@/utils/stream";


export interface UnstorageBlockstoreOptions {
/** Unstorage instance to use (bypasses driver creation) */
storage?: Storage;
/** Key prefix for blockstore keys */
prefix?: string;
/** Unstorage driver name or instance */
driver?: Driver;
/** Base path for storage driver */
base?: string;
/** Prefix for datastore keys (defaults to prefix) */
datastorePrefix?: string;
}

Expand Down
21 changes: 21 additions & 0 deletions libs/pinner/src/pinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export class Pinner {
private _websites: WebsitesClient;
private _upload?: UploadMethodAndBuilder;

/**
* Create a new Pinner SDK instance.
* @param config SDK configuration object
*/
constructor(config: PinnerConfig) {
this.uploadManager = new UploadManager(config);
this._pins = new PinClient(config);
Expand Down Expand Up @@ -86,6 +90,8 @@ export class Pinner {
/**
* Upload a file and wait for completion.
* Convenience method for simple use cases where controls aren't needed.
* @param file The file to upload
* @param options Upload configuration
*/
async uploadAndWait(
file: File,
Expand All @@ -110,6 +116,8 @@ export class Pinner {

/**
* Upload a directory to IPFS.
* @param files Array of files to upload as a directory
* @param options Upload configuration
*/
async uploadDirectory(
files: File[],
Expand All @@ -121,6 +129,8 @@ export class Pinner {
/**
* Upload a CAR file without preprocessing.
* This is useful for passthrough of pre-generated CAR files.
* @param file CAR file or stream to upload
* @param options Upload configuration
*/
async uploadCar(
file: File | ReadableStream<Uint8Array>,
Expand All @@ -131,6 +141,8 @@ export class Pinner {

/**
* Pin existing content by CID.
* @param cid CID of content to pin (string or CID object)
* @param options Remote add options
*/
async pinByHash(
cid: string | CID,
Expand All @@ -142,6 +154,7 @@ export class Pinner {

/**
* List pinned content.
* @param options List filtering options
*/
async listPins(options?: RemoteLsOptions): Promise<RemotePin[]> {
const pins: RemotePin[] = [];
Expand All @@ -153,6 +166,7 @@ export class Pinner {

/**
* Get pin status.
* @param cid CID of the pinned content to check
*/
async getPinStatus(cid: string | CID): Promise<RemotePin> {
const cidObj = typeof cid === "string" ? CID.parse(cid) : cid;
Expand All @@ -161,6 +175,7 @@ export class Pinner {

/**
* Check if content is pinned.
* @param cid CID to check
*/
async isPinned(cid: string | CID): Promise<boolean> {
const cidObj = typeof cid === "string" ? CID.parse(cid) : cid;
Expand All @@ -169,6 +184,8 @@ export class Pinner {

/**
* Update pin metadata.
* @param cid CID of the pin
* @param metadata Key-value metadata to set
*/
async setPinMetadata(
cid: string | CID,
Expand All @@ -180,6 +197,8 @@ export class Pinner {

/**
* Remove a pin. The block may be deleted when garbage collection is run.
* @param cid CID to unpin
* @param options Abort options
*/
async unpin(cid: string | CID, options?: AbortOptions): Promise<void> {
const cidObj = typeof cid === "string" ? CID.parse(cid) : cid;
Expand All @@ -191,6 +210,8 @@ export class Pinner {

/**
* Remove a pin by request ID. The block may be deleted when garbage collection is run.
* @param requestId The request ID to remove
* @param options Abort options
*/
async unpinByRequestId(requestId: string, options?: AbortOptions): Promise<void> {
return this.pins.rmByRequestId(requestId, options);
Expand Down
Loading
Loading