@lumeweb/pinner 0.1.0 → 0.1.3

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.
Files changed (180) hide show
  1. package/README.md +197 -18
  2. package/dist/esm/_virtual/{rolldown_runtime.js → _rolldown/runtime.js} +2 -2
  3. package/dist/esm/adapters/pinata/index.d.ts +4 -4
  4. package/dist/esm/adapters/pinata/index.js +6 -3
  5. package/dist/esm/adapters/pinata/legacy/adapter.d.ts +73 -0
  6. package/dist/esm/adapters/pinata/legacy/adapter.js +124 -0
  7. package/dist/esm/adapters/pinata/legacy/adapter.js.map +1 -0
  8. package/dist/esm/adapters/pinata/legacy/index.d.ts +1 -0
  9. package/dist/esm/adapters/pinata/legacy/index.js +1 -0
  10. package/dist/esm/adapters/pinata/shared/index.d.ts +1 -0
  11. package/dist/esm/adapters/pinata/shared/index.js +1 -0
  12. package/dist/esm/adapters/pinata/shared/types.d.ts +218 -0
  13. package/dist/esm/adapters/pinata/shared/utils.d.ts +1 -0
  14. package/dist/esm/adapters/pinata/shared/utils.js +78 -0
  15. package/dist/esm/adapters/pinata/shared/utils.js.map +1 -0
  16. package/dist/esm/adapters/pinata/v2/adapter-interface.d.ts +197 -0
  17. package/dist/esm/adapters/pinata/v2/adapter.d.ts +16 -0
  18. package/dist/esm/adapters/pinata/v2/adapter.js +636 -0
  19. package/dist/esm/adapters/pinata/v2/adapter.js.map +1 -0
  20. package/dist/esm/adapters/pinata/v2/index.d.ts +3 -0
  21. package/dist/esm/adapters/pinata/v2/index.js +1 -0
  22. package/dist/esm/adapters/pinata/v2/types.d.ts +308 -0
  23. package/dist/esm/api/generated/schemas/iPNSKeyListResponse.d.ts +46 -0
  24. package/dist/esm/api/generated/schemas/iPNSKeyListResponseResponse.d.ts +10 -0
  25. package/dist/esm/api/generated/schemas/iPNSKeyRequest.d.ts +43 -0
  26. package/dist/esm/api/generated/schemas/iPNSKeyResponse.d.ts +46 -0
  27. package/dist/esm/api/generated/schemas/iPNSPublishRequest.d.ts +44 -0
  28. package/dist/esm/api/generated/schemas/iPNSPublishResponse.d.ts +46 -0
  29. package/dist/esm/api/generated/schemas/iPNSResolveResponse.d.ts +47 -0
  30. package/dist/esm/api/generated/schemas/sSLStatusInfo.d.ts +45 -0
  31. package/dist/esm/api/generated/schemas/websiteConfigResponse.d.ts +43 -0
  32. package/dist/esm/api/generated/schemas/websiteItem.d.ts +23 -0
  33. package/dist/esm/api/generated/schemas/websiteItemResponse.d.ts +10 -0
  34. package/dist/esm/api/generated/schemas/websiteRequest.d.ts +45 -0
  35. package/dist/esm/api/generated/schemas/websiteResponse.d.ts +23 -0
  36. package/dist/esm/api/generated/schemas/websiteUpdateRequest.d.ts +45 -0
  37. package/dist/esm/api/generated/schemas/websiteValidateResponse.d.ts +45 -0
  38. package/dist/esm/api/ipns.d.ts +28 -0
  39. package/dist/esm/api/ipns.js +83 -0
  40. package/dist/esm/api/ipns.js.map +1 -0
  41. package/dist/esm/api/websites.d.ts +48 -0
  42. package/dist/esm/api/websites.js +168 -0
  43. package/dist/esm/api/websites.js.map +1 -0
  44. package/dist/esm/blockstore/unstorage-base.d.ts +4 -1
  45. package/dist/esm/blockstore/unstorage-base.js +3 -3
  46. package/dist/esm/blockstore/unstorage-base.js.map +1 -1
  47. package/dist/esm/blockstore/unstorage.d.ts +3 -31
  48. package/dist/esm/blockstore/unstorage.js +2 -2
  49. package/dist/esm/blockstore/unstorage.js.map +1 -1
  50. package/dist/esm/encoder/base64.js.map +1 -1
  51. package/dist/esm/encoder/csv/row-formatter.js.map +1 -1
  52. package/dist/esm/encoder/csv.js.map +1 -1
  53. package/dist/esm/encoder/json.js.map +1 -1
  54. package/dist/esm/encoder/text.js.map +1 -1
  55. package/dist/esm/encoder/url.js.map +1 -1
  56. package/dist/esm/index.d.ts +7 -5
  57. package/dist/esm/index.js +5 -2
  58. package/dist/esm/pin/client.js +8 -5
  59. package/dist/esm/pin/client.js.map +1 -1
  60. package/dist/esm/pinner.d.ts +16 -0
  61. package/dist/esm/pinner.js +24 -0
  62. package/dist/esm/pinner.js.map +1 -1
  63. package/dist/esm/types/constants.js +6 -2
  64. package/dist/esm/types/constants.js.map +1 -1
  65. package/dist/esm/types/pin.d.ts +4 -1
  66. package/dist/esm/types/type-guards.d.ts +0 -1
  67. package/dist/esm/types/upload.d.ts +0 -1
  68. package/dist/esm/upload/base-upload.js +3 -3
  69. package/dist/esm/upload/base-upload.js.map +1 -1
  70. package/dist/esm/upload/builder.d.ts +0 -1
  71. package/dist/esm/upload/car.js +3 -3
  72. package/dist/esm/upload/car.js.map +1 -1
  73. package/dist/esm/upload/manager.js +5 -5
  74. package/dist/esm/upload/manager.js.map +1 -1
  75. package/dist/esm/upload/normalize.js +1 -1
  76. package/dist/esm/upload/normalize.js.map +1 -1
  77. package/dist/esm/utils/stream.d.ts +0 -3
  78. package/dist/esm/utils/tus-patch.js +2 -2
  79. package/dist/esm/utils/tus-patch.js.map +1 -1
  80. package/dist/esm/utils/validation.js.map +1 -1
  81. package/package.json +33 -32
  82. package/dist/cjs/_virtual/rolldown_runtime.cjs +0 -29
  83. package/dist/cjs/adapters/pinata/adapter.cjs +0 -88
  84. package/dist/cjs/adapters/pinata/adapter.cjs.map +0 -1
  85. package/dist/cjs/adapters/pinata/adapter.d.cts +0 -35
  86. package/dist/cjs/adapters/pinata/builder.cjs +0 -194
  87. package/dist/cjs/adapters/pinata/builder.cjs.map +0 -1
  88. package/dist/cjs/adapters/pinata/index.cjs +0 -3
  89. package/dist/cjs/adapters/pinata/list-builder.cjs +0 -52
  90. package/dist/cjs/adapters/pinata/list-builder.cjs.map +0 -1
  91. package/dist/cjs/blockstore/index.cjs +0 -2
  92. package/dist/cjs/blockstore/unstorage-base.cjs +0 -240
  93. package/dist/cjs/blockstore/unstorage-base.cjs.map +0 -1
  94. package/dist/cjs/blockstore/unstorage-base.d.cts +0 -23
  95. package/dist/cjs/blockstore/unstorage.cjs +0 -39
  96. package/dist/cjs/blockstore/unstorage.cjs.map +0 -1
  97. package/dist/cjs/blockstore/unstorage.d.cts +0 -36
  98. package/dist/cjs/config.d.cts +0 -51
  99. package/dist/cjs/encoder/base64.cjs +0 -38
  100. package/dist/cjs/encoder/base64.cjs.map +0 -1
  101. package/dist/cjs/encoder/csv/csv-formatter.cjs +0 -81
  102. package/dist/cjs/encoder/csv/csv-formatter.cjs.map +0 -1
  103. package/dist/cjs/encoder/csv/field-formatter.cjs +0 -76
  104. package/dist/cjs/encoder/csv/field-formatter.cjs.map +0 -1
  105. package/dist/cjs/encoder/csv/row-formatter.cjs +0 -159
  106. package/dist/cjs/encoder/csv/row-formatter.cjs.map +0 -1
  107. package/dist/cjs/encoder/csv.cjs +0 -44
  108. package/dist/cjs/encoder/csv.cjs.map +0 -1
  109. package/dist/cjs/encoder/error.cjs +0 -19
  110. package/dist/cjs/encoder/error.cjs.map +0 -1
  111. package/dist/cjs/encoder/index.cjs +0 -6
  112. package/dist/cjs/encoder/json.cjs +0 -36
  113. package/dist/cjs/encoder/json.cjs.map +0 -1
  114. package/dist/cjs/encoder/text.cjs +0 -35
  115. package/dist/cjs/encoder/text.cjs.map +0 -1
  116. package/dist/cjs/encoder/url.cjs +0 -39
  117. package/dist/cjs/encoder/url.cjs.map +0 -1
  118. package/dist/cjs/errors/index.cjs +0 -104
  119. package/dist/cjs/errors/index.cjs.map +0 -1
  120. package/dist/cjs/errors/index.d.cts +0 -47
  121. package/dist/cjs/index.cjs +0 -42
  122. package/dist/cjs/index.d.cts +0 -14
  123. package/dist/cjs/pin/client.cjs +0 -96
  124. package/dist/cjs/pin/client.cjs.map +0 -1
  125. package/dist/cjs/pin/index.cjs +0 -1
  126. package/dist/cjs/pinner.cjs +0 -126
  127. package/dist/cjs/pinner.cjs.map +0 -1
  128. package/dist/cjs/pinner.d.cts +0 -77
  129. package/dist/cjs/types/constants.cjs +0 -34
  130. package/dist/cjs/types/constants.cjs.map +0 -1
  131. package/dist/cjs/types/mime-types.cjs +0 -11
  132. package/dist/cjs/types/mime-types.cjs.map +0 -1
  133. package/dist/cjs/types/mime-types.d.cts +0 -7
  134. package/dist/cjs/types/pin.d.cts +0 -74
  135. package/dist/cjs/types/pinata.d.cts +0 -99
  136. package/dist/cjs/types/type-guards.cjs +0 -20
  137. package/dist/cjs/types/type-guards.cjs.map +0 -1
  138. package/dist/cjs/types/type-guards.d.cts +0 -15
  139. package/dist/cjs/types/upload.cjs +0 -18
  140. package/dist/cjs/types/upload.cjs.map +0 -1
  141. package/dist/cjs/types/upload.d.cts +0 -189
  142. package/dist/cjs/upload/base-upload.cjs +0 -135
  143. package/dist/cjs/upload/base-upload.cjs.map +0 -1
  144. package/dist/cjs/upload/builder.cjs +0 -174
  145. package/dist/cjs/upload/builder.cjs.map +0 -1
  146. package/dist/cjs/upload/builder.d.cts +0 -60
  147. package/dist/cjs/upload/car.cjs +0 -129
  148. package/dist/cjs/upload/car.cjs.map +0 -1
  149. package/dist/cjs/upload/car.d.cts +0 -19
  150. package/dist/cjs/upload/constants.cjs +0 -9
  151. package/dist/cjs/upload/constants.cjs.map +0 -1
  152. package/dist/cjs/upload/index.cjs +0 -8
  153. package/dist/cjs/upload/manager.cjs +0 -249
  154. package/dist/cjs/upload/manager.cjs.map +0 -1
  155. package/dist/cjs/upload/manager.d.cts +0 -35
  156. package/dist/cjs/upload/normalize.cjs +0 -28
  157. package/dist/cjs/upload/normalize.cjs.map +0 -1
  158. package/dist/cjs/upload/tus-upload.cjs +0 -74
  159. package/dist/cjs/upload/tus-upload.cjs.map +0 -1
  160. package/dist/cjs/upload/xhr-upload.cjs +0 -41
  161. package/dist/cjs/upload/xhr-upload.cjs.map +0 -1
  162. package/dist/cjs/utils/env.cjs +0 -12
  163. package/dist/cjs/utils/env.cjs.map +0 -1
  164. package/dist/cjs/utils/stream.cjs +0 -141
  165. package/dist/cjs/utils/stream.cjs.map +0 -1
  166. package/dist/cjs/utils/stream.d.cts +0 -23
  167. package/dist/cjs/utils/tus-patch.cjs +0 -50
  168. package/dist/cjs/utils/tus-patch.cjs.map +0 -1
  169. package/dist/cjs/utils/validation.cjs +0 -62
  170. package/dist/cjs/utils/validation.cjs.map +0 -1
  171. package/dist/esm/adapters/pinata/adapter.d.ts +0 -35
  172. package/dist/esm/adapters/pinata/adapter.js +0 -87
  173. package/dist/esm/adapters/pinata/adapter.js.map +0 -1
  174. package/dist/esm/adapters/pinata/builder.d.ts +0 -1
  175. package/dist/esm/adapters/pinata/builder.js +0 -187
  176. package/dist/esm/adapters/pinata/builder.js.map +0 -1
  177. package/dist/esm/adapters/pinata/list-builder.d.ts +0 -1
  178. package/dist/esm/adapters/pinata/list-builder.js +0 -51
  179. package/dist/esm/adapters/pinata/list-builder.js.map +0 -1
  180. package/dist/esm/types/pinata.d.ts +0 -99
@@ -0,0 +1,23 @@
1
+ import { SSLStatusInfo } from "./sSLStatusInfo.js";
2
+
3
+ //#region src/api/generated/schemas/websiteItem.d.ts
4
+ interface WebsiteItem {
5
+ created: string;
6
+ dns_hosting_enabled: boolean;
7
+ dns_zone_id?: number;
8
+ domain: string;
9
+ expired: boolean;
10
+ gateway_domain?: string;
11
+ id: number;
12
+ last_checked_at?: string;
13
+ ssl?: SSLStatusInfo;
14
+ status: string;
15
+ target_hash: string;
16
+ target_type: string;
17
+ updated: string;
18
+ validation_expires_at?: string;
19
+ validation_token: string;
20
+ }
21
+ //#endregion
22
+ export { WebsiteItem };
23
+ //# sourceMappingURL=websiteItem.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { WebsiteItem } from "./websiteItem.js";
2
+
3
+ //#region src/api/generated/schemas/websiteItemResponse.d.ts
4
+ interface WebsiteItemResponse {
5
+ data: WebsiteItem[];
6
+ total: number;
7
+ }
8
+ //#endregion
9
+ export { WebsiteItemResponse };
10
+ //# sourceMappingURL=websiteItemResponse.d.ts.map
@@ -0,0 +1,45 @@
1
+ //#region src/api/generated/schemas/websiteRequest.d.ts
2
+ /**
3
+ * Generated by orval v8.10.0 🍺
4
+ * Do not edit manually.
5
+ * Portal IPFS Plugin API
6
+ *
7
+ ## Portal IPFS Plugin API
8
+
9
+ A comprehensive API for IPFS content management, including pinning services, file operations, IPNS key management, and website hosting.
10
+
11
+ ### IPFS Pinning Service API Compatibility
12
+
13
+ This API is fully compatible with the [IPFS Pinning Service API specification](https://github.com/ipfs/pinning-services-api-spec), an implementation-agnostic API standard for pinning service providers. This ensures interoperability with existing IPFS pinning clients and tools.
14
+
15
+ ### Features
16
+
17
+ - **Pinning**: Add, list, update, and remove pinned content
18
+ - **Content**: Upload files, retrieve IPFS content, and manage metadata
19
+ - **IPNS**: Manage IPNS keys and publish content
20
+ - **Files**: Browse and manage pinned files with directory navigation
21
+ - **Websites**: Create and manage website hosting with DNS and SSL automation
22
+
23
+ ### Authentication
24
+
25
+ All API endpoints require authentication using JWT tokens obtained from the Portal authentication service.
26
+
27
+ ### Rate Limiting
28
+
29
+ API requests are rate-limited based on user account tier. See Portal documentation for current limits.
30
+
31
+ ### Documentation
32
+
33
+ For detailed API usage examples and integration guides, visit the Portal documentation website.
34
+
35
+ * OpenAPI spec version: 1.0.0
36
+ */
37
+ interface WebsiteRequest {
38
+ dns_hosting_enabled?: boolean;
39
+ domain: string;
40
+ target_hash: string;
41
+ target_type: string;
42
+ }
43
+ //#endregion
44
+ export { WebsiteRequest };
45
+ //# sourceMappingURL=websiteRequest.d.ts.map
@@ -0,0 +1,23 @@
1
+ import { SSLStatusInfo } from "./sSLStatusInfo.js";
2
+
3
+ //#region src/api/generated/schemas/websiteResponse.d.ts
4
+ interface WebsiteResponse {
5
+ created: string;
6
+ dns_hosting_enabled: boolean;
7
+ dns_zone_id?: number;
8
+ domain: string;
9
+ expired: boolean;
10
+ gateway_domain?: string;
11
+ id: number;
12
+ last_checked_at?: string;
13
+ ssl?: SSLStatusInfo;
14
+ status: string;
15
+ target_hash: string;
16
+ target_type: string;
17
+ updated: string;
18
+ validation_expires_at?: string;
19
+ validation_token: string;
20
+ }
21
+ //#endregion
22
+ export { WebsiteResponse };
23
+ //# sourceMappingURL=websiteResponse.d.ts.map
@@ -0,0 +1,45 @@
1
+ //#region src/api/generated/schemas/websiteUpdateRequest.d.ts
2
+ /**
3
+ * Generated by orval v8.10.0 🍺
4
+ * Do not edit manually.
5
+ * Portal IPFS Plugin API
6
+ *
7
+ ## Portal IPFS Plugin API
8
+
9
+ A comprehensive API for IPFS content management, including pinning services, file operations, IPNS key management, and website hosting.
10
+
11
+ ### IPFS Pinning Service API Compatibility
12
+
13
+ This API is fully compatible with the [IPFS Pinning Service API specification](https://github.com/ipfs/pinning-services-api-spec), an implementation-agnostic API standard for pinning service providers. This ensures interoperability with existing IPFS pinning clients and tools.
14
+
15
+ ### Features
16
+
17
+ - **Pinning**: Add, list, update, and remove pinned content
18
+ - **Content**: Upload files, retrieve IPFS content, and manage metadata
19
+ - **IPNS**: Manage IPNS keys and publish content
20
+ - **Files**: Browse and manage pinned files with directory navigation
21
+ - **Websites**: Create and manage website hosting with DNS and SSL automation
22
+
23
+ ### Authentication
24
+
25
+ All API endpoints require authentication using JWT tokens obtained from the Portal authentication service.
26
+
27
+ ### Rate Limiting
28
+
29
+ API requests are rate-limited based on user account tier. See Portal documentation for current limits.
30
+
31
+ ### Documentation
32
+
33
+ For detailed API usage examples and integration guides, visit the Portal documentation website.
34
+
35
+ * OpenAPI spec version: 1.0.0
36
+ */
37
+ interface WebsiteUpdateRequest {
38
+ dns_hosting_enabled?: boolean;
39
+ domain?: string;
40
+ target_hash?: string;
41
+ target_type?: string;
42
+ }
43
+ //#endregion
44
+ export { WebsiteUpdateRequest };
45
+ //# sourceMappingURL=websiteUpdateRequest.d.ts.map
@@ -0,0 +1,45 @@
1
+ //#region src/api/generated/schemas/websiteValidateResponse.d.ts
2
+ /**
3
+ * Generated by orval v8.10.0 🍺
4
+ * Do not edit manually.
5
+ * Portal IPFS Plugin API
6
+ *
7
+ ## Portal IPFS Plugin API
8
+
9
+ A comprehensive API for IPFS content management, including pinning services, file operations, IPNS key management, and website hosting.
10
+
11
+ ### IPFS Pinning Service API Compatibility
12
+
13
+ This API is fully compatible with the [IPFS Pinning Service API specification](https://github.com/ipfs/pinning-services-api-spec), an implementation-agnostic API standard for pinning service providers. This ensures interoperability with existing IPFS pinning clients and tools.
14
+
15
+ ### Features
16
+
17
+ - **Pinning**: Add, list, update, and remove pinned content
18
+ - **Content**: Upload files, retrieve IPFS content, and manage metadata
19
+ - **IPNS**: Manage IPNS keys and publish content
20
+ - **Files**: Browse and manage pinned files with directory navigation
21
+ - **Websites**: Create and manage website hosting with DNS and SSL automation
22
+
23
+ ### Authentication
24
+
25
+ All API endpoints require authentication using JWT tokens obtained from the Portal authentication service.
26
+
27
+ ### Rate Limiting
28
+
29
+ API requests are rate-limited based on user account tier. See Portal documentation for current limits.
30
+
31
+ ### Documentation
32
+
33
+ For detailed API usage examples and integration guides, visit the Portal documentation website.
34
+
35
+ * OpenAPI spec version: 1.0.0
36
+ */
37
+ interface WebsiteValidateResponse {
38
+ domain: string;
39
+ id: number;
40
+ message: string;
41
+ valid: boolean;
42
+ }
43
+ //#endregion
44
+ export { WebsiteValidateResponse };
45
+ //# sourceMappingURL=websiteValidateResponse.d.ts.map
@@ -0,0 +1,28 @@
1
+ import { PinnerConfig } from "../config.js";
2
+ import { IPNSKeyListResponseResponse } from "./generated/schemas/iPNSKeyListResponseResponse.js";
3
+ import { IPNSKeyRequest } from "./generated/schemas/iPNSKeyRequest.js";
4
+ import { IPNSKeyResponse } from "./generated/schemas/iPNSKeyResponse.js";
5
+ import { IPNSPublishRequest } from "./generated/schemas/iPNSPublishRequest.js";
6
+ import { IPNSPublishResponse } from "./generated/schemas/iPNSPublishResponse.js";
7
+ import { IPNSResolveResponse } from "./generated/schemas/iPNSResolveResponse.js";
8
+
9
+ //#region src/api/ipns.d.ts
10
+ interface IpnsClientOptions {
11
+ signal?: AbortSignal;
12
+ }
13
+ declare class IpnsClient {
14
+ private config;
15
+ constructor(config: PinnerConfig);
16
+ private getEndpoint;
17
+ private request;
18
+ listKeys(options?: IpnsClientOptions): Promise<IPNSKeyListResponseResponse>;
19
+ getKey(id: number, options?: IpnsClientOptions): Promise<IPNSKeyResponse>;
20
+ createKey(request: IPNSKeyRequest, options?: IpnsClientOptions): Promise<IPNSKeyResponse>;
21
+ deleteKey(id: number, options?: IpnsClientOptions): Promise<void>;
22
+ publish(request: IPNSPublishRequest, options?: IpnsClientOptions): Promise<IPNSPublishResponse>;
23
+ republish(name: string, options?: IpnsClientOptions): Promise<void>;
24
+ resolve(name: string, options?: IpnsClientOptions): Promise<IPNSResolveResponse>;
25
+ }
26
+ //#endregion
27
+ export { IpnsClient };
28
+ //# sourceMappingURL=ipns.d.ts.map
@@ -0,0 +1,83 @@
1
+ import { AuthenticationError, ConfigurationError, NetworkError, NotFoundError, ValidationError } from "../errors/index.js";
2
+ import ky, { HTTPError } from "ky";
3
+
4
+ //#region src/api/ipns.ts
5
+ var IpnsClient = class {
6
+ config;
7
+ constructor(config) {
8
+ if (!config.jwt) throw new ConfigurationError("JWT token is required");
9
+ this.config = config;
10
+ }
11
+ getEndpoint() {
12
+ return this.config.endpoint ?? "https://ipfs.pinner.xyz";
13
+ }
14
+ async request(path, options) {
15
+ if (!this.config.jwt) throw new ConfigurationError("JWT token is required");
16
+ try {
17
+ const response = await ky(path, {
18
+ prefix: this.getEndpoint(),
19
+ headers: {
20
+ Authorization: `Bearer ${this.config.jwt}`,
21
+ "Content-Type": "application/json"
22
+ },
23
+ ...options
24
+ });
25
+ if (response.status === 204) return;
26
+ const text = await response.text();
27
+ if (!text) return;
28
+ return JSON.parse(text);
29
+ } catch (error) {
30
+ if (error instanceof HTTPError) {
31
+ const status = error.response.status;
32
+ const body = await error.response.json().catch(() => ({}));
33
+ if (status === 401) throw new AuthenticationError(body.error || "Authentication failed");
34
+ if (status === 403) throw new AuthenticationError(body.error || "Access forbidden");
35
+ if (status === 404) throw new NotFoundError(body.error || "Resource not found");
36
+ if (status === 400) throw new ValidationError(body.error || "Invalid request");
37
+ throw new NetworkError(body.error || `HTTP error: ${status}`, status);
38
+ }
39
+ if (error instanceof Error) throw new NetworkError(error.message);
40
+ throw new NetworkError("Unknown error occurred");
41
+ }
42
+ }
43
+ async listKeys(options) {
44
+ return this.request("api/ipns/keys", { signal: options?.signal });
45
+ }
46
+ async getKey(id, options) {
47
+ return this.request(`api/ipns/keys/${id}`, { signal: options?.signal });
48
+ }
49
+ async createKey(request, options) {
50
+ return this.request("api/ipns/keys", {
51
+ method: "POST",
52
+ body: JSON.stringify(request),
53
+ signal: options?.signal
54
+ });
55
+ }
56
+ async deleteKey(id, options) {
57
+ await this.request(`api/ipns/keys/${id}`, {
58
+ method: "DELETE",
59
+ signal: options?.signal
60
+ });
61
+ }
62
+ async publish(request, options) {
63
+ return this.request("api/ipns/publish", {
64
+ method: "POST",
65
+ body: JSON.stringify(request),
66
+ signal: options?.signal
67
+ });
68
+ }
69
+ async republish(name, options) {
70
+ await this.request("api/ipns/republish", {
71
+ method: "POST",
72
+ body: JSON.stringify({ name }),
73
+ signal: options?.signal
74
+ });
75
+ }
76
+ async resolve(name, options) {
77
+ return this.request(`api/ipns/resolve/${name}`, { signal: options?.signal });
78
+ }
79
+ };
80
+
81
+ //#endregion
82
+ export { IpnsClient };
83
+ //# sourceMappingURL=ipns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ipns.js","names":[],"sources":["../../../src/api/ipns.ts"],"sourcesContent":["import ky, { HTTPError } from \"ky\";\nimport type { PinnerConfig } from \"../config\";\nimport type {\n IPNSKeyListResponseResponse,\n IPNSKeyRequest,\n IPNSKeyResponse,\n IPNSPublishRequest,\n IPNSPublishResponse,\n IPNSResolveResponse,\n} from \"./generated/schemas/index\";\nimport {\n ConfigurationError,\n AuthenticationError,\n NotFoundError,\n NetworkError,\n ValidationError,\n} from \"@/errors\";\n\nexport interface IpnsClientOptions {\n signal?: AbortSignal;\n}\n\nexport class IpnsClient {\n private config: PinnerConfig;\n\n constructor(config: PinnerConfig) {\n if (!config.jwt) {\n throw new ConfigurationError(\"JWT token is required\");\n }\n this.config = config;\n }\n\n private getEndpoint(): string {\n return this.config.endpoint ?? \"https://ipfs.pinner.xyz\";\n }\n\n private async request<T>(\n path: string,\n options?: RequestInit & { signal?: AbortSignal },\n ): Promise<T> {\n if (!this.config.jwt) {\n throw new ConfigurationError(\"JWT token is required\");\n }\n\n try {\n const response = await ky(path, {\n prefix: this.getEndpoint(),\n headers: {\n Authorization: `Bearer ${this.config.jwt}`,\n \"Content-Type\": \"application/json\",\n },\n ...options,\n });\n\n if (response.status === 204) {\n return undefined as T;\n }\n\n const text = await response.text();\n if (!text) {\n return undefined as T;\n }\n\n return JSON.parse(text) as T;\n } catch (error) {\n if (error instanceof HTTPError) {\n const status = error.response.status;\n const body = await error.response.json().catch(() => ({}));\n\n if (status === 401) {\n throw new AuthenticationError(\n body.error || \"Authentication failed\",\n );\n }\n if (status === 403) {\n throw new AuthenticationError(\n body.error || \"Access forbidden\",\n );\n }\n if (status === 404) {\n throw new NotFoundError(body.error || \"Resource not found\");\n }\n if (status === 400) {\n throw new ValidationError(body.error || \"Invalid request\");\n }\n\n throw new NetworkError(\n body.error || `HTTP error: ${status}`,\n status,\n );\n }\n\n if (error instanceof Error) {\n throw new NetworkError(error.message);\n }\n\n throw new NetworkError(\"Unknown error occurred\");\n }\n }\n\n async listKeys(options?: IpnsClientOptions): Promise<IPNSKeyListResponseResponse> {\n return this.request<IPNSKeyListResponseResponse>(\"api/ipns/keys\", {\n signal: options?.signal,\n });\n }\n\n async getKey(id: number, options?: IpnsClientOptions): Promise<IPNSKeyResponse> {\n return this.request<IPNSKeyResponse>(`api/ipns/keys/${id}`, {\n signal: options?.signal,\n });\n }\n\n async createKey(\n request: IPNSKeyRequest,\n options?: IpnsClientOptions,\n ): Promise<IPNSKeyResponse> {\n return this.request<IPNSKeyResponse>(\"api/ipns/keys\", {\n method: \"POST\",\n body: JSON.stringify(request),\n signal: options?.signal,\n });\n }\n\n async deleteKey(id: number, options?: IpnsClientOptions): Promise<void> {\n await this.request<void>(`api/ipns/keys/${id}`, {\n method: \"DELETE\",\n signal: options?.signal,\n });\n }\n\n async publish(\n request: IPNSPublishRequest,\n options?: IpnsClientOptions,\n ): Promise<IPNSPublishResponse> {\n return this.request<IPNSPublishResponse>(\"api/ipns/publish\", {\n method: \"POST\",\n body: JSON.stringify(request),\n signal: options?.signal,\n });\n }\n\n async republish(\n name: string,\n options?: IpnsClientOptions,\n ): Promise<void> {\n await this.request<void>(\"api/ipns/republish\", {\n method: \"POST\",\n body: JSON.stringify({ name }),\n signal: options?.signal,\n });\n }\n\n async resolve(\n name: string,\n options?: IpnsClientOptions,\n ): Promise<IPNSResolveResponse> {\n return this.request<IPNSResolveResponse>(`api/ipns/resolve/${name}`, {\n signal: options?.signal,\n });\n }\n}\n"],"mappings":";;;;AAsBA,IAAa,aAAb,MAAwB;CACtB,AAAQ;CAER,YAAY,QAAsB;AAChC,MAAI,CAAC,OAAO,IACV,OAAM,IAAI,mBAAmB,wBAAwB;AAEvD,OAAK,SAAS;;CAGhB,AAAQ,cAAsB;AAC5B,SAAO,KAAK,OAAO,YAAY;;CAGjC,MAAc,QACZ,MACA,SACY;AACZ,MAAI,CAAC,KAAK,OAAO,IACf,OAAM,IAAI,mBAAmB,wBAAwB;AAGvD,MAAI;GACF,MAAM,WAAW,MAAM,GAAG,MAAM;IAC9B,QAAQ,KAAK,aAAa;IAC1B,SAAS;KACP,eAAe,UAAU,KAAK,OAAO;KACrC,gBAAgB;KACjB;IACD,GAAG;IACJ,CAAC;AAEF,OAAI,SAAS,WAAW,IACtB;GAGF,MAAM,OAAO,MAAM,SAAS,MAAM;AAClC,OAAI,CAAC,KACH;AAGF,UAAO,KAAK,MAAM,KAAK;WAChB,OAAO;AACd,OAAI,iBAAiB,WAAW;IAC9B,MAAM,SAAS,MAAM,SAAS;IAC9B,MAAM,OAAO,MAAM,MAAM,SAAS,MAAM,CAAC,aAAa,EAAE,EAAE;AAE1D,QAAI,WAAW,IACb,OAAM,IAAI,oBACR,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1
+ import { PinnerConfig } from "../config.js";
2
+ import { SSLStatusInfo } from "./generated/schemas/sSLStatusInfo.js";
3
+ import { WebsiteConfigResponse } from "./generated/schemas/websiteConfigResponse.js";
4
+ import { WebsiteItemResponse } from "./generated/schemas/websiteItemResponse.js";
5
+ import { WebsiteRequest } from "./generated/schemas/websiteRequest.js";
6
+ import { WebsiteResponse } from "./generated/schemas/websiteResponse.js";
7
+ import { WebsiteUpdateRequest } from "./generated/schemas/websiteUpdateRequest.js";
8
+ import { WebsiteValidateResponse } from "./generated/schemas/websiteValidateResponse.js";
9
+
10
+ //#region src/api/websites.d.ts
11
+ interface WebsitesClientOptions {
12
+ signal?: AbortSignal;
13
+ }
14
+ declare class WebsitesClient {
15
+ private config;
16
+ constructor(config: PinnerConfig);
17
+ private getEndpoint;
18
+ private request;
19
+ listWebsites(options?: WebsitesClientOptions): Promise<WebsiteItemResponse>;
20
+ createWebsite(request: WebsiteRequest, options?: WebsitesClientOptions): Promise<WebsiteResponse>;
21
+ getWebsite(id: number, options?: WebsitesClientOptions): Promise<WebsiteResponse>;
22
+ updateWebsite(id: number, request: WebsiteUpdateRequest, options?: WebsitesClientOptions): Promise<WebsiteResponse>;
23
+ deleteWebsite(id: number, options?: WebsitesClientOptions): Promise<void>;
24
+ validateWebsite(id: number, options?: WebsitesClientOptions): Promise<WebsiteValidateResponse>;
25
+ getSSLStatus(domain: string, options?: WebsitesClientOptions): Promise<SSLStatusInfo>;
26
+ getWebsiteConfig(options?: WebsitesClientOptions): Promise<WebsiteConfigResponse>;
27
+ watchSSL(domain: string, options?: WatchOptions): SSLWatcher;
28
+ }
29
+ interface WatchOptions {
30
+ interval?: number;
31
+ timeout?: number;
32
+ }
33
+ interface SSLCallbacks {
34
+ onReady?: (status: SSLStatusInfo) => void;
35
+ onError?: (error: SSLError) => void;
36
+ onStatus?: (status: SSLStatusInfo) => void;
37
+ }
38
+ interface SSLWatcher {
39
+ start(callbacks: SSLCallbacks): Promise<void>;
40
+ stop(): void;
41
+ }
42
+ interface SSLError extends Error {
43
+ type: 'timeout' | 'error';
44
+ details?: string;
45
+ }
46
+ //#endregion
47
+ export { WebsitesClient };
48
+ //# sourceMappingURL=websites.d.ts.map
@@ -0,0 +1,168 @@
1
+ import { AuthenticationError, ConfigurationError, NetworkError, NotFoundError, ValidationError } from "../errors/index.js";
2
+ import ky, { HTTPError } from "ky";
3
+ import { createNanoEvents } from "/home/runner/work/web/web/node_modules/.pnpm/nanoevents@9.1.0/node_modules/nanoevents/index.js";
4
+
5
+ //#region src/api/websites.ts
6
+ const SSLStatus = {
7
+ PENDING: "pending",
8
+ VALIDATING: "validating",
9
+ VALID: "valid",
10
+ READY: "ready",
11
+ FAILED: "failed",
12
+ ERROR: "error"
13
+ };
14
+ var WebsitesClient = class {
15
+ config;
16
+ constructor(config) {
17
+ if (!config.jwt) throw new ConfigurationError("JWT token is required");
18
+ this.config = config;
19
+ }
20
+ getEndpoint() {
21
+ return this.config.endpoint ?? "https://ipfs.pinner.xyz";
22
+ }
23
+ async request(path, options) {
24
+ if (!this.config.jwt) throw new ConfigurationError("JWT token is required");
25
+ try {
26
+ const response = await ky(path, {
27
+ prefix: this.getEndpoint(),
28
+ headers: {
29
+ Authorization: `Bearer ${this.config.jwt}`,
30
+ "Content-Type": "application/json"
31
+ },
32
+ ...options
33
+ });
34
+ if (response.status === 204) return;
35
+ const text = await response.text();
36
+ if (!text) return;
37
+ return JSON.parse(text);
38
+ } catch (error) {
39
+ if (error instanceof HTTPError) {
40
+ const status = error.response.status;
41
+ const body = await error.response.json().catch(() => ({}));
42
+ if (status === 401) throw new AuthenticationError(body.error || "Authentication failed");
43
+ if (status === 403) throw new AuthenticationError(body.error || "Access forbidden");
44
+ if (status === 404) throw new NotFoundError(body.error || "Resource not found");
45
+ if (status === 400) throw new ValidationError(body.error || "Invalid request");
46
+ if (status === 410) throw new ValidationError(body.error || "Target is broken or gone");
47
+ throw new NetworkError(body.error || `HTTP error: ${status}`);
48
+ }
49
+ if (error instanceof Error) throw new NetworkError(error.message);
50
+ throw new NetworkError("Unknown error occurred");
51
+ }
52
+ }
53
+ async listWebsites(options) {
54
+ return this.request("api/websites", { signal: options?.signal });
55
+ }
56
+ async createWebsite(request, options) {
57
+ return this.request("api/websites", {
58
+ method: "POST",
59
+ body: JSON.stringify(request),
60
+ signal: options?.signal
61
+ });
62
+ }
63
+ async getWebsite(id, options) {
64
+ return this.request(`api/websites/${id}`, { signal: options?.signal });
65
+ }
66
+ async updateWebsite(id, request, options) {
67
+ return this.request(`api/websites/${id}`, {
68
+ method: "PUT",
69
+ body: JSON.stringify(request),
70
+ signal: options?.signal
71
+ });
72
+ }
73
+ async deleteWebsite(id, options) {
74
+ await this.request(`api/websites/${id}`, {
75
+ method: "DELETE",
76
+ signal: options?.signal
77
+ });
78
+ }
79
+ async validateWebsite(id, options) {
80
+ return this.request(`api/websites/${id}/validate`, {
81
+ method: "POST",
82
+ signal: options?.signal
83
+ });
84
+ }
85
+ async getSSLStatus(domain, options) {
86
+ return this.request(`api/websites/${encodeURIComponent(domain)}/ssl-status`, { signal: options?.signal });
87
+ }
88
+ async getWebsiteConfig(options) {
89
+ return this.request("api/websites/config", { signal: options?.signal });
90
+ }
91
+ watchSSL(domain, options) {
92
+ return new SSLWatcherImpl(this, domain, options);
93
+ }
94
+ };
95
+ const DEFAULT_INTERVAL = 5e3;
96
+ const DEFAULT_TIMEOUT = 3e5;
97
+ var SSLWatcherImpl = class {
98
+ emitter = createNanoEvents();
99
+ unbind = [];
100
+ intervalId = null;
101
+ timeoutId = null;
102
+ stopped = false;
103
+ options;
104
+ runId = 0;
105
+ constructor(client, domain, options = {}) {
106
+ this.client = client;
107
+ this.domain = domain;
108
+ this.options = {
109
+ interval: options.interval ?? DEFAULT_INTERVAL,
110
+ timeout: options.timeout ?? DEFAULT_TIMEOUT
111
+ };
112
+ if (this.options.interval <= 0) this.options.interval = DEFAULT_INTERVAL;
113
+ if (this.options.timeout <= 0) this.options.timeout = DEFAULT_TIMEOUT;
114
+ }
115
+ emitError(message, type = "error", details) {
116
+ const error = new Error(message);
117
+ error.type = type;
118
+ error.details = details;
119
+ this.emitter.emit("error", error);
120
+ this.stop();
121
+ }
122
+ async start(callbacks = {}) {
123
+ this.stop();
124
+ this.stopped = false;
125
+ const currentRunId = ++this.runId;
126
+ if (callbacks.onReady) this.unbind.push(this.emitter.on("ready", callbacks.onReady));
127
+ if (callbacks.onError) this.unbind.push(this.emitter.on("error", callbacks.onError));
128
+ if (callbacks.onStatus) this.unbind.push(this.emitter.on("status", callbacks.onStatus));
129
+ const checkStatus = async () => {
130
+ if (this.stopped || this.runId !== currentRunId) return;
131
+ try {
132
+ const status = await this.client.getSSLStatus(this.domain);
133
+ if (this.stopped || this.runId !== currentRunId) return;
134
+ this.emitter.emit("status", status);
135
+ if (status.status === SSLStatus.VALID || status.status === SSLStatus.READY) {
136
+ this.emitter.emit("ready", status);
137
+ this.stop();
138
+ } else if (status.status === SSLStatus.FAILED || status.status === SSLStatus.ERROR) this.emitError(status.error || "SSL provisioning failed", "error", status.error);
139
+ } catch (err) {
140
+ if (this.stopped || this.runId !== currentRunId) return;
141
+ this.emitError(err instanceof Error ? err.message : "Failed to check SSL status", "error");
142
+ }
143
+ };
144
+ await checkStatus();
145
+ if (this.stopped || this.runId !== currentRunId) return;
146
+ this.intervalId = setInterval(checkStatus, this.options.interval);
147
+ this.timeoutId = setTimeout(() => {
148
+ if (!this.stopped && this.runId === currentRunId) this.emitError("SSL provisioning timeout", "timeout");
149
+ }, this.options.timeout);
150
+ }
151
+ stop() {
152
+ this.stopped = true;
153
+ this.unbind.forEach((unbind) => unbind());
154
+ this.unbind = [];
155
+ if (this.intervalId) {
156
+ clearInterval(this.intervalId);
157
+ this.intervalId = null;
158
+ }
159
+ if (this.timeoutId) {
160
+ clearTimeout(this.timeoutId);
161
+ this.timeoutId = null;
162
+ }
163
+ }
164
+ };
165
+
166
+ //#endregion
167
+ export { WebsitesClient };
168
+ //# sourceMappingURL=websites.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websites.js","names":[],"sources":["../../../src/api/websites.ts"],"sourcesContent":["import ky, { HTTPError } from \"ky\";\nimport { createNanoEvents } from \"nanoevents\";\nimport type { PinnerConfig } from \"../config\";\nimport type {\n WebsiteItemResponse,\n WebsiteRequest,\n WebsiteResponse,\n WebsiteUpdateRequest,\n WebsiteValidateResponse,\n WebsiteConfigResponse,\n SSLStatusInfo,\n} from \"./generated/schemas/index\";\n\n// SSL status constants\nexport const SSLStatus = {\n PENDING: \"pending\",\n VALIDATING: \"validating\",\n VALID: \"valid\",\n READY: \"ready\",\n FAILED: \"failed\",\n ERROR: \"error\",\n} as const;\n\nexport type SSLStatusValue = (typeof SSLStatus)[keyof typeof SSLStatus];\nimport {\n ConfigurationError,\n AuthenticationError,\n NotFoundError,\n NetworkError,\n ValidationError,\n} from \"@/errors\";\n\nexport interface WebsitesClientOptions {\n signal?: AbortSignal;\n}\n\nexport class WebsitesClient {\n private config: PinnerConfig;\n\n constructor(config: PinnerConfig) {\n if (!config.jwt) {\n throw new ConfigurationError(\"JWT token is required\");\n }\n this.config = config;\n }\n\n private getEndpoint(): string {\n return this.config.endpoint ?? \"https://ipfs.pinner.xyz\";\n }\n\n private async request<T>(\n path: string,\n options?: RequestInit & { signal?: AbortSignal },\n ): Promise<T> {\n if (!this.config.jwt) {\n throw new ConfigurationError(\"JWT token is required\");\n }\n\n try {\n const response = await ky(path, {\n prefix: this.getEndpoint(),\n headers: {\n Authorization: `Bearer ${this.config.jwt}`,\n \"Content-Type\": \"application/json\",\n },\n ...options,\n });\n\n if (response.status === 204) {\n return undefined as T;\n }\n\n const text = await response.text();\n if (!text) {\n return undefined as T;\n }\n\n return JSON.parse(text) as T;\n } catch (error) {\n if (error instanceof HTTPError) {\n const status = error.response.status;\n const body = await error.response.json().catch(() => ({}));\n\n if (status === 401) {\n throw new AuthenticationError(\n body.error || \"Authentication failed\",\n );\n }\n if (status === 403) {\n throw new AuthenticationError(\n body.error || \"Access forbidden\",\n );\n }\n if (status === 404) {\n throw new NotFoundError(body.error || \"Resource not found\");\n }\n if (status === 400) {\n throw new ValidationError(body.error || \"Invalid request\");\n }\n if (status === 410) {\n throw new ValidationError(body.error || \"Target is broken or gone\");\n }\n\n throw new NetworkError(\n body.error || `HTTP error: ${status}`,\n );\n }\n\n if (error instanceof Error) {\n throw new NetworkError(error.message);\n }\n\n throw new NetworkError(\"Unknown error occurred\");\n }\n }\n\n async listWebsites(options?: WebsitesClientOptions): Promise<WebsiteItemResponse> {\n return this.request<WebsiteItemResponse>(\"api/websites\", {\n signal: options?.signal,\n });\n }\n\n async createWebsite(\n request: WebsiteRequest,\n options?: WebsitesClientOptions,\n ): Promise<WebsiteResponse> {\n return this.request<WebsiteResponse>(\"api/websites\", {\n method: \"POST\",\n body: JSON.stringify(request),\n signal: options?.signal,\n });\n }\n\n async getWebsite(\n id: number,\n options?: WebsitesClientOptions,\n ): Promise<WebsiteResponse> {\n return this.request<WebsiteResponse>(`api/websites/${id}`, {\n signal: options?.signal,\n });\n }\n\n async updateWebsite(\n id: number,\n request: WebsiteUpdateRequest,\n options?: WebsitesClientOptions,\n ): Promise<WebsiteResponse> {\n return this.request<WebsiteResponse>(`api/websites/${id}`, {\n method: \"PUT\",\n body: JSON.stringify(request),\n signal: options?.signal,\n });\n }\n\n async deleteWebsite(\n id: number,\n options?: WebsitesClientOptions,\n ): Promise<void> {\n await this.request<void>(`api/websites/${id}`, {\n method: \"DELETE\",\n signal: options?.signal,\n });\n }\n\n async validateWebsite(\n id: number,\n options?: WebsitesClientOptions,\n ): Promise<WebsiteValidateResponse> {\n return this.request<WebsiteValidateResponse>(\n `api/websites/${id}/validate`,\n {\n method: \"POST\",\n signal: options?.signal,\n },\n );\n }\n\n async getSSLStatus(\n domain: string,\n options?: WebsitesClientOptions,\n ): Promise<SSLStatusInfo> {\n return this.request<SSLStatusInfo>(\n `api/websites/${encodeURIComponent(domain)}/ssl-status`,\n {\n signal: options?.signal,\n },\n );\n }\n\n async getWebsiteConfig(\n options?: WebsitesClientOptions,\n ): Promise<WebsiteConfigResponse> {\n return this.request<WebsiteConfigResponse>(\"api/websites/config\", {\n signal: options?.signal,\n });\n }\n\n watchSSL(\n domain: string,\n options?: WatchOptions,\n ): SSLWatcher {\n return new SSLWatcherImpl(this, domain, options);\n }\n}\n\nexport interface WatchOptions {\n interval?: number;\n timeout?: number;\n}\n\nexport interface SSLEvents {\n ready: (status: SSLStatusInfo) => void;\n error: (error: SSLError) => void;\n status: (status: SSLStatusInfo) => void;\n}\n\nexport interface SSLCallbacks {\n onReady?: (status: SSLStatusInfo) => void;\n onError?: (error: SSLError) => void;\n onStatus?: (status: SSLStatusInfo) => void;\n}\n\nexport interface SSLWatcher {\n start(callbacks: SSLCallbacks): Promise<void>;\n stop(): void;\n}\n\nexport interface SSLError extends Error {\n type: 'timeout' | 'error';\n details?: string;\n}\n\nconst DEFAULT_INTERVAL = 5000;\nconst DEFAULT_TIMEOUT = 300000;\n\nclass SSLWatcherImpl implements SSLWatcher {\n private emitter = createNanoEvents<SSLEvents>();\n private unbind: (() => void)[] = [];\n private intervalId: ReturnType<typeof setInterval> | null = null;\n private timeoutId: ReturnType<typeof setTimeout> | null = null;\n private stopped = false;\n private options: WatchOptions;\n private runId = 0;\n\n constructor(\n private client: WebsitesClient,\n private domain: string,\n options: WatchOptions = {},\n ) {\n this.options = {\n interval: options.interval ?? DEFAULT_INTERVAL,\n timeout: options.timeout ?? DEFAULT_TIMEOUT,\n };\n\n if (this.options.interval <= 0) {\n this.options.interval = DEFAULT_INTERVAL;\n }\n if (this.options.timeout <= 0) {\n this.options.timeout = DEFAULT_TIMEOUT;\n }\n }\n\n private emitError(\n message: string,\n type: SSLError['type'] = 'error',\n details?: string,\n ): void {\n const error: SSLError = new Error(message) as SSLError;\n error.type = type;\n error.details = details;\n this.emitter.emit('error', error);\n this.stop();\n }\n\n async start(callbacks: SSLCallbacks = {}): Promise<void> {\n this.stop();\n this.stopped = false;\n const currentRunId = ++this.runId;\n\n if (callbacks.onReady) {\n this.unbind.push(this.emitter.on('ready', callbacks.onReady));\n }\n if (callbacks.onError) {\n this.unbind.push(this.emitter.on('error', callbacks.onError));\n }\n if (callbacks.onStatus) {\n this.unbind.push(this.emitter.on('status', callbacks.onStatus));\n }\n\n const checkStatus = async (): Promise<void> => {\n if (this.stopped || this.runId !== currentRunId) {\n return;\n }\n\n try {\n const status = await this.client.getSSLStatus(this.domain);\n if (this.stopped || this.runId !== currentRunId) {\n return;\n }\n this.emitter.emit('status', status);\n\n if (status.status === SSLStatus.VALID || status.status === SSLStatus.READY) {\n this.emitter.emit('ready', status);\n this.stop();\n } else if (status.status === SSLStatus.FAILED || status.status === SSLStatus.ERROR) {\n this.emitError(\n status.error || 'SSL provisioning failed',\n 'error',\n status.error,\n );\n }\n } catch (err) {\n if (this.stopped || this.runId !== currentRunId) {\n return;\n }\n\n this.emitError(\n err instanceof Error ? err.message : 'Failed to check SSL status',\n 'error',\n );\n }\n };\n\n await checkStatus();\n\n if (this.stopped || this.runId !== currentRunId) {\n return;\n }\n\n this.intervalId = setInterval(checkStatus, this.options.interval);\n\n this.timeoutId = setTimeout(() => {\n if (!this.stopped && this.runId === currentRunId) {\n this.emitError('SSL provisioning timeout', 'timeout');\n }\n }, this.options.timeout);\n }\n\n stop(): void {\n this.stopped = true;\n\n this.unbind.forEach(unbind => unbind());\n this.unbind = [];\n\n if (this.intervalId) {\n clearInterval(this.intervalId);\n this.intervalId = null;\n }\n\n if (this.timeoutId) {\n clearTimeout(this.timeoutId);\n this.timeoutId = null;\n }\n }\n}\n"],"mappings":";;;;;AAcA,MAAa,YAAY;CACvB,SAAS;CACT,YAAY;CACZ,OAAO;CACP,OAAO;CACP,QAAQ;CACR,OAAO;CACR;AAeD,IAAa,iBAAb,MAA4B;CAC1B,AAAQ;CAER,YAAY,QAAsB;AAChC,MAAI,CAAC,OAAO,IACV,OAAM,IAAI,mBAAmB,wBAAwB;AAEvD,OAAK,SAAS;;CAGh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K,YAAY,iBAAiB;AAChC,OAAI,CAAC,KAAK,WAAW,KAAK,UAAU,aAClC,MAAK,UAAU,4BAA4B,UAAU;KAEtD,KAAK,QAAQ,QAAQ;;CAG1B,OAAa;AACX,OAAK,UAAU;AAEf,OAAK,OAAO,SAAQ,WAAU,QAAQ,CAAC;AACvC,OAAK,SAAS,EAAE;AAEhB,MAAI,KAAK,YAAY;AACnB,iBAAc,KAAK,WAAW;AAC9B,QAAK,aAAa;;AAGpB,MAAI,KAAK,WAAW;AAClB,gBAAa,KAAK,UAAU;AAC5B,QAAK,YAAY"}
@@ -1,3 +1,4 @@
1
+ import { BaseBlockstore } from "/home/runner/work/web/web/node_modules/.pnpm/blockstore-core@6.1.3/node_modules/blockstore-core/dist/src/index.js";
1
2
  import { Driver, Storage } from "unstorage";
2
3
  import { Datastore } from "interface-datastore";
3
4
 
@@ -18,6 +19,8 @@ interface UnstorageBlockstoreOptions {
18
19
  */
19
20
  type DriverFactory = () => Driver | Promise<Driver>;
20
21
  declare function setDriverFactory(factory: DriverFactory | null): void;
22
+ declare function createUnstorageBlockstore(getDefaultDriver: (base?: string) => Driver | Promise<Driver>): new (options?: UnstorageBlockstoreOptions) => InstanceType<typeof BaseBlockstore>;
23
+ declare function createUnstorageDatastore(getDefaultDriver: (base?: string) => Driver | Promise<Driver>): new (options?: UnstorageBlockstoreOptions) => Datastore;
21
24
  //#endregion
22
- export { UnstorageBlockstoreOptions, setDriverFactory };
25
+ export { UnstorageBlockstoreOptions, createUnstorageBlockstore, createUnstorageDatastore, setDriverFactory };
23
26
  //# sourceMappingURL=unstorage-base.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { collectAsyncIterable } from "../utils/stream.js";
2
2
  import { DEFAULT_BLOCKSTORE_PREFIX } from "../types/constants.js";
3
- import { BaseBlockstore } from "/home/runner/work/web/web/node_modules/.pnpm/blockstore-core@6.1.2/node_modules/blockstore-core/dist/src/index.js";
3
+ import { BaseBlockstore } from "/home/runner/work/web/web/node_modules/.pnpm/blockstore-core@6.1.3/node_modules/blockstore-core/dist/src/index.js";
4
4
  import { CID } from "multiformats/cid";
5
5
  import { createStorage } from "unstorage";
6
6
  import { Key } from "interface-datastore";
@@ -61,7 +61,7 @@ function createUnstorageBlockstore(getDefaultDriver) {
61
61
  base;
62
62
  constructor(options = {}) {
63
63
  super();
64
- this.prefix = options.prefix ?? DEFAULT_BLOCKSTORE_PREFIX;
64
+ this.prefix = options.prefix ?? "pinner-helia-blocks";
65
65
  this.base = createUnstorageBase(options, getDefaultDriver);
66
66
  }
67
67
  keyToStorageKey(key) {
@@ -123,7 +123,7 @@ function createUnstorageDatastore(getDefaultDriver) {
123
123
  prefix;
124
124
  base;
125
125
  constructor(options = {}) {
126
- this.prefix = options.datastorePrefix ?? options.prefix ?? DEFAULT_BLOCKSTORE_PREFIX;
126
+ this.prefix = options.datastorePrefix ?? options.prefix ?? "pinner-helia-blocks";
127
127
  this.base = createUnstorageBase(options, getDefaultDriver);
128
128
  }
129
129
  keyToStorageKey(key) {