alchemy 0.41.1 → 0.41.2

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.
@@ -2,5 +2,5 @@
2
2
  * The build date used as the default worker compatibility date.
3
3
  * This is set to the date when the package was built.
4
4
  */
5
- export declare const BUILD_DATE = "2025-06-26";
5
+ export declare const BUILD_DATE = "2025-06-27";
6
6
  //# sourceMappingURL=build-date.d.ts.map
package/lib/build-date.js CHANGED
@@ -4,5 +4,5 @@
4
4
  * The build date used as the default worker compatibility date.
5
5
  * This is set to the date when the package was built.
6
6
  */
7
- export const BUILD_DATE = "2025-06-26";
7
+ export const BUILD_DATE = "2025-06-27";
8
8
  //# sourceMappingURL=build-date.js.map
@@ -0,0 +1,216 @@
1
+ import type { Context } from "../context.ts";
2
+ import { Resource } from "../resource.ts";
3
+ import { type CloudflareApi, type CloudflareApiOptions } from "./api.ts";
4
+ import type { Zone } from "./zone.ts";
5
+ /**
6
+ * Certificate Authority options for Advanced Certificate Packs
7
+ */
8
+ export type CertificateAuthority = "google" | "lets_encrypt" | "ssl_com";
9
+ /**
10
+ * Validation method for certificate verification
11
+ */
12
+ export type ValidationMethod = "txt" | "http" | "email";
13
+ /**
14
+ * Validity period options for certificates
15
+ */
16
+ export type ValidityDays = 14 | 30 | 90 | 365;
17
+ /**
18
+ * Certificate pack status values during lifecycle
19
+ */
20
+ export type CertificatePackStatus = "initializing" | "pending_validation" | "deleted" | "pending_issuance" | "pending_deployment" | "pending_deletion" | "pending_expiration" | "expired" | "active" | "initializing_timed_out" | "validation_timed_out" | "issuance_timed_out" | "deployment_timed_out" | "deletion_timed_out" | "pending_cleanup" | "staging_deployment" | "staging_active" | "deactivating" | "inactive" | "backup_issued" | "holding_deployment";
21
+ /**
22
+ * Properties for creating a Certificate Pack
23
+ */
24
+ export interface CertificatePackProps extends CloudflareApiOptions {
25
+ /**
26
+ * The zone to create the certificate pack for
27
+ * Can be a Zone resource, zone ID string, or omitted to auto-infer from hosts
28
+ */
29
+ zone?: string | Zone;
30
+ /**
31
+ * Certificate Authority to use for issuing the certificate
32
+ * - google: Google Trust Services (Enterprise features)
33
+ * - lets_encrypt: Let's Encrypt (Free, shorter validity periods)
34
+ * - ssl_com: SSL.com (Commercial certificates with extended validation)
35
+ *
36
+ * **Note:** This property is immutable after creation. To change the CA,
37
+ * you must delete and recreate the certificate pack.
38
+ */
39
+ certificateAuthority: CertificateAuthority;
40
+ /**
41
+ * List of hostnames to include in the certificate
42
+ * Maximum 50 hosts, must include the zone apex (root domain)
43
+ * Supports wildcards (e.g., "*.example.com")
44
+ *
45
+ * **Note:** This property is immutable after creation.
46
+ */
47
+ hosts: string[];
48
+ /**
49
+ * Certificate type - only "advanced" is supported
50
+ *
51
+ * **Note:** This property is immutable after creation.
52
+ * @default "advanced"
53
+ */
54
+ type?: "advanced";
55
+ /**
56
+ * Method used to validate domain ownership
57
+ * - txt: DNS TXT record validation
58
+ * - http: HTTP file validation
59
+ * - email: Email validation
60
+ *
61
+ * **Note:** This property is immutable after creation.
62
+ */
63
+ validationMethod: ValidationMethod;
64
+ /**
65
+ * Certificate validity period in days
66
+ * Available options: 14, 30, 90, or 365 days
67
+ *
68
+ * **Note:** This property is immutable after creation.
69
+ */
70
+ validityDays: ValidityDays;
71
+ /**
72
+ * Whether to add Cloudflare branding subdomain as Common Name
73
+ * Adds sni.cloudflaressl.com subdomain when enabled
74
+ *
75
+ * **Note:** This is the only property that can be updated after creation.
76
+ * @default false
77
+ */
78
+ cloudflareBranding?: boolean;
79
+ /**
80
+ * Whether to delete the certificate pack
81
+ * If set to false, the pack will remain but the resource will be removed from state
82
+ *
83
+ * @default true
84
+ */
85
+ delete?: boolean;
86
+ }
87
+ /**
88
+ * Output returned after Certificate Pack creation/update
89
+ */
90
+ export interface CertificatePack extends Resource<"cloudflare::CertificatePack"> {
91
+ /**
92
+ * The unique ID of the certificate pack
93
+ */
94
+ id: string;
95
+ /**
96
+ * Certificate Authority used for the certificate
97
+ */
98
+ certificateAuthority: CertificateAuthority;
99
+ /**
100
+ * Whether Cloudflare branding is enabled
101
+ */
102
+ cloudflareBranding: boolean;
103
+ /**
104
+ * List of hostnames included in the certificate
105
+ */
106
+ hosts: string[];
107
+ /**
108
+ * Current status of the certificate pack
109
+ */
110
+ status: CertificatePackStatus;
111
+ /**
112
+ * Certificate type
113
+ */
114
+ type: "advanced";
115
+ /**
116
+ * Validation method used for domain verification
117
+ */
118
+ validationMethod: ValidationMethod;
119
+ /**
120
+ * Certificate validity period in days
121
+ */
122
+ validityDays: ValidityDays;
123
+ /**
124
+ * Zone ID the certificate pack belongs to
125
+ */
126
+ zoneId: string;
127
+ /**
128
+ * Zone name (domain)
129
+ */
130
+ zoneName: string;
131
+ }
132
+ /**
133
+ * Creates and manages Cloudflare Advanced Certificate Packs.
134
+ *
135
+ * Advanced Certificate Packs provide flexible SSL/TLS certificates with
136
+ * multiple Certificate Authority options, custom validity periods, and
137
+ * support for up to 50 hostnames per certificate.
138
+ *
139
+ * **Important Notes:**
140
+ * - Requires a paid Cloudflare plan (not available on Free plans)
141
+ * - Certificate provisioning can take up to 10 minutes
142
+ * - Most properties are immutable after creation (only cloudflareBranding can be updated)
143
+ * - To change immutable properties, you must delete and recreate the certificate pack
144
+ *
145
+ * @example
146
+ * // Create a basic certificate pack with Let's Encrypt
147
+ * const basicCert = await CertificatePack("my-cert", {
148
+ * zone: myZone,
149
+ * certificateAuthority: "lets_encrypt",
150
+ * hosts: ["example.com", "www.example.com"],
151
+ * validationMethod: "txt",
152
+ * validityDays: 90
153
+ * });
154
+ *
155
+ * @example
156
+ * // Create an enterprise certificate with Google Trust Services
157
+ * const enterpriseCert = await CertificatePack("enterprise-cert", {
158
+ * zone: "example.com",
159
+ * certificateAuthority: "google",
160
+ * hosts: ["example.com", "*.example.com", "api.example.com"],
161
+ * validationMethod: "txt",
162
+ * validityDays: 365,
163
+ * cloudflareBranding: true
164
+ * });
165
+ *
166
+ * @example
167
+ * // Create a wildcard certificate with SSL.com
168
+ * const wildcardCert = await CertificatePack("wildcard-cert", {
169
+ * zone: myZone,
170
+ * certificateAuthority: "ssl_com",
171
+ * hosts: ["example.com", "*.example.com"],
172
+ * validationMethod: "email",
173
+ * validityDays: 365
174
+ * });
175
+ *
176
+ * @example
177
+ * // Create a certificate for multiple subdomains
178
+ * const multiDomainCert = await CertificatePack("multi-cert", {
179
+ * zone: "example.com",
180
+ * certificateAuthority: "lets_encrypt",
181
+ * hosts: [
182
+ * "example.com",
183
+ * "www.example.com",
184
+ * "api.example.com",
185
+ * "admin.example.com",
186
+ * "blog.example.com"
187
+ * ],
188
+ * validationMethod: "http",
189
+ * validityDays: 90
190
+ * });
191
+ *
192
+ * @see https://developers.cloudflare.com/api/resources/ssl/subresources/certificate_packs/
193
+ */
194
+ export declare const CertificatePack: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<CertificatePack>, _id: string, props: CertificatePackProps) => Promise<CertificatePack>);
195
+ /**
196
+ * Helper function to wait for certificate pack to reach active status
197
+ * Useful for testing or when you need to ensure the certificate is ready
198
+ *
199
+ * @param api CloudflareApi instance
200
+ * @param zoneId Zone ID
201
+ * @param certificatePackId Certificate pack ID
202
+ * @param timeoutMs Maximum time to wait in milliseconds (default: 15 minutes)
203
+ * @returns Promise resolving to the final certificate pack status
204
+ *
205
+ * @example
206
+ * // Wait for certificate to become active
207
+ * const finalStatus = await waitForCertificatePackActive(
208
+ * api,
209
+ * zoneId,
210
+ * certificatePack.id,
211
+ * 10 * 60 * 1000 // 10 minutes
212
+ * );
213
+ * console.log(`Certificate pack is now: ${finalStatus}`);
214
+ */
215
+ export declare function waitForCertificatePackActive(api: CloudflareApi, zoneId: string, certificatePackId: string, timeoutMs?: number): Promise<CertificatePackStatus>;
216
+ //# sourceMappingURL=certificate-pack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"certificate-pack.d.ts","sourceRoot":"","sources":["../../src/cloudflare/certificate-pack.ts"],"names":[],"mappings":"A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C,EAAE,OAAO,CAAC;IAE7B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eACf,SAAQ,QAAQ,CAAC,6BAA6B,CAAC;IAC/C;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,oBAAoB,EAAE,oBAAoB,CAAC;IAE3C;;OAEG;IACH,kBAAkB,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,KAAK,EAAE,MAAM,EAAE,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,qBAAqB,CAAC;IAE9B;;OAEG;IACH,IAAI,EAAE,UAAU,CAAC;IAEjB;;OAEG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC;IAE3B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,eAAO,MAAM,eAAe,yFAGlB,OAAO,CAAC,eAAe,CAAC,OACzB,MAAM,SACJ,oBAAoB,KAC1B,OAAO,CAAC,eAAe,CAAC,CAoQ5B,CAAC;AAiBF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,4BAA4B,CAChD,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,MAAM,EACzB,SAAS,GAAE,MAAuB,GACjC,OAAO,CAAC,qBAAqB,CAAC,CAuChC"}
@@ -0,0 +1,350 @@
1
+ import { Resource } from "../resource.js";
2
+ import { logger } from "../util/logger.js";
3
+ import { handleApiError } from "./api-error.js";
4
+ import { createCloudflareApi, } from "./api.js";
5
+ /**
6
+ * Creates and manages Cloudflare Advanced Certificate Packs.
7
+ *
8
+ * Advanced Certificate Packs provide flexible SSL/TLS certificates with
9
+ * multiple Certificate Authority options, custom validity periods, and
10
+ * support for up to 50 hostnames per certificate.
11
+ *
12
+ * **Important Notes:**
13
+ * - Requires a paid Cloudflare plan (not available on Free plans)
14
+ * - Certificate provisioning can take up to 10 minutes
15
+ * - Most properties are immutable after creation (only cloudflareBranding can be updated)
16
+ * - To change immutable properties, you must delete and recreate the certificate pack
17
+ *
18
+ * @example
19
+ * // Create a basic certificate pack with Let's Encrypt
20
+ * const basicCert = await CertificatePack("my-cert", {
21
+ * zone: myZone,
22
+ * certificateAuthority: "lets_encrypt",
23
+ * hosts: ["example.com", "www.example.com"],
24
+ * validationMethod: "txt",
25
+ * validityDays: 90
26
+ * });
27
+ *
28
+ * @example
29
+ * // Create an enterprise certificate with Google Trust Services
30
+ * const enterpriseCert = await CertificatePack("enterprise-cert", {
31
+ * zone: "example.com",
32
+ * certificateAuthority: "google",
33
+ * hosts: ["example.com", "*.example.com", "api.example.com"],
34
+ * validationMethod: "txt",
35
+ * validityDays: 365,
36
+ * cloudflareBranding: true
37
+ * });
38
+ *
39
+ * @example
40
+ * // Create a wildcard certificate with SSL.com
41
+ * const wildcardCert = await CertificatePack("wildcard-cert", {
42
+ * zone: myZone,
43
+ * certificateAuthority: "ssl_com",
44
+ * hosts: ["example.com", "*.example.com"],
45
+ * validationMethod: "email",
46
+ * validityDays: 365
47
+ * });
48
+ *
49
+ * @example
50
+ * // Create a certificate for multiple subdomains
51
+ * const multiDomainCert = await CertificatePack("multi-cert", {
52
+ * zone: "example.com",
53
+ * certificateAuthority: "lets_encrypt",
54
+ * hosts: [
55
+ * "example.com",
56
+ * "www.example.com",
57
+ * "api.example.com",
58
+ * "admin.example.com",
59
+ * "blog.example.com"
60
+ * ],
61
+ * validationMethod: "http",
62
+ * validityDays: 90
63
+ * });
64
+ *
65
+ * @see https://developers.cloudflare.com/api/resources/ssl/subresources/certificate_packs/
66
+ */
67
+ export const CertificatePack = Resource("cloudflare::CertificatePack", async function (_id, props) {
68
+ // Create Cloudflare API client with automatic account discovery
69
+ const api = await createCloudflareApi(props);
70
+ // Resolve zone ID and zone name
71
+ let zoneId;
72
+ let zoneName;
73
+ if (props.zone) {
74
+ // Zone provided - use it
75
+ if (typeof props.zone === "string") {
76
+ zoneId = props.zone;
77
+ // Try to get zone name from API for better error messages
78
+ try {
79
+ const zoneResponse = await api.get(`/zones/${zoneId}`);
80
+ if (zoneResponse.ok) {
81
+ const zoneData = (await zoneResponse.json());
82
+ zoneName = zoneData.result.name;
83
+ }
84
+ else {
85
+ zoneName = zoneId; // Fallback to ID
86
+ }
87
+ }
88
+ catch {
89
+ zoneName = zoneId; // Fallback to ID
90
+ }
91
+ }
92
+ else {
93
+ zoneId = props.zone.id;
94
+ zoneName = props.zone.name || props.zone.id;
95
+ }
96
+ }
97
+ else {
98
+ // Auto-infer zone from the first host
99
+ if (props.hosts.length === 0) {
100
+ throw new Error("At least one host must be specified when zone is not provided");
101
+ }
102
+ logger.log(`Auto-inferring zone from hostname: ${props.hosts[0]}`);
103
+ const zoneInfo = await findZoneForHostname(api, props.hosts[0]);
104
+ zoneId = zoneInfo.zoneId;
105
+ zoneName = zoneInfo.zoneName;
106
+ logger.log(`Auto-inferred zone: ${zoneName} (${zoneId})`);
107
+ }
108
+ if (this.phase === "delete") {
109
+ if (this.output?.id && props.delete !== false) {
110
+ const deleteResponse = await api.delete(`/zones/${zoneId}/ssl/certificate_packs/${this.output.id}`);
111
+ if (!deleteResponse.ok && deleteResponse.status !== 404) {
112
+ await handleApiError(deleteResponse, "delete", "certificate pack", this.output.id);
113
+ }
114
+ }
115
+ else {
116
+ logger.warn("Certificate pack not found, skipping delete");
117
+ }
118
+ return this.destroy();
119
+ }
120
+ if (this.phase === "update" && this.output?.id) {
121
+ // Validate immutable properties
122
+ const currentPack = this.output;
123
+ if (props.certificateAuthority !== currentPack.certificateAuthority) {
124
+ throw new Error(`Cannot change certificateAuthority from '${currentPack.certificateAuthority}' to '${props.certificateAuthority}'. Certificate Authority is immutable after creation. You must delete and recreate the certificate pack.`);
125
+ }
126
+ if (JSON.stringify(props.hosts.sort()) !==
127
+ JSON.stringify(currentPack.hosts.sort())) {
128
+ throw new Error(`Cannot change hosts from [${currentPack.hosts.join(", ")}] to [${props.hosts.join(", ")}]. Hosts are immutable after creation. You must delete and recreate the certificate pack.`);
129
+ }
130
+ if (props.validationMethod !== currentPack.validationMethod) {
131
+ throw new Error(`Cannot change validationMethod from '${currentPack.validationMethod}' to '${props.validationMethod}'. Validation method is immutable after creation. You must delete and recreate the certificate pack.`);
132
+ }
133
+ if (props.validityDays !== currentPack.validityDays) {
134
+ throw new Error(`Cannot change validityDays from ${currentPack.validityDays} to ${props.validityDays}. Validity period is immutable after creation. You must delete and recreate the certificate pack.`);
135
+ }
136
+ const type = props.type || "advanced";
137
+ if (type !== currentPack.type) {
138
+ throw new Error(`Cannot change type from '${currentPack.type}' to '${type}'. Type is immutable after creation. You must delete and recreate the certificate pack.`);
139
+ }
140
+ // Only cloudflareBranding can be updated
141
+ if (props.cloudflareBranding !== currentPack.cloudflareBranding) {
142
+ logger.log(`Updating certificate pack cloudflare branding from ${currentPack.cloudflareBranding} to ${props.cloudflareBranding}`);
143
+ const updateResponse = await api.patch(`/zones/${zoneId}/ssl/certificate_packs/${this.output.id}`, {
144
+ cloudflare_branding: props.cloudflareBranding || false,
145
+ });
146
+ if (!updateResponse.ok) {
147
+ await handleApiError(updateResponse, "update", "certificate pack", this.output.id);
148
+ }
149
+ }
150
+ // Get updated certificate pack details
151
+ const response = await api.get(`/zones/${zoneId}/ssl/certificate_packs/${this.output.id}`);
152
+ if (!response.ok) {
153
+ await handleApiError(response, "get", "certificate pack", this.output.id);
154
+ }
155
+ const updatedPack = (await response.json()).result;
156
+ return this({
157
+ id: updatedPack.id,
158
+ certificateAuthority: updatedPack.certificate_authority,
159
+ cloudflareBranding: updatedPack.cloudflare_branding,
160
+ hosts: updatedPack.hosts,
161
+ status: updatedPack.status,
162
+ type: updatedPack.type,
163
+ validationMethod: updatedPack.validation_method,
164
+ validityDays: updatedPack.validity_days,
165
+ zoneId: updatedPack.zone_id,
166
+ zoneName: zoneName,
167
+ });
168
+ }
169
+ // Create new certificate pack
170
+ if (props.hosts.length === 0) {
171
+ throw new Error("At least one host must be specified");
172
+ }
173
+ if (props.hosts.length > 50) {
174
+ throw new Error("Maximum 50 hosts are allowed per certificate pack");
175
+ }
176
+ // Validate that zone apex is included
177
+ const hasZoneApex = props.hosts.some((host) => host === zoneName || (zoneName && host === zoneName));
178
+ if (!hasZoneApex && zoneName) {
179
+ logger.warn(`Zone apex '${zoneName}' is not included in hosts. This may cause certificate validation issues.`);
180
+ }
181
+ // Check for existing certificate pack that matches our configuration
182
+ const existingPack = await findMatchingCertificatePack(api, zoneId, props);
183
+ if (existingPack) {
184
+ // Adopt the existing certificate pack
185
+ logger.log(`Adopting existing certificate pack ${existingPack.id} instead of creating a new one`);
186
+ return this({
187
+ id: existingPack.id,
188
+ certificateAuthority: existingPack.certificate_authority,
189
+ cloudflareBranding: existingPack.cloudflare_branding,
190
+ hosts: existingPack.hosts,
191
+ status: existingPack.status,
192
+ type: existingPack.type,
193
+ validationMethod: existingPack.validation_method,
194
+ validityDays: existingPack.validity_days,
195
+ zoneId: existingPack.zone_id,
196
+ zoneName: zoneName,
197
+ });
198
+ }
199
+ logger.log(`Creating certificate pack with ${props.hosts.length} hosts using ${props.certificateAuthority}`);
200
+ const createResponse = await api.post(`/zones/${zoneId}/ssl/certificate_packs/order`, {
201
+ certificate_authority: props.certificateAuthority,
202
+ cloudflare_branding: props.cloudflareBranding || false,
203
+ hosts: props.hosts,
204
+ type: props.type || "advanced",
205
+ validation_method: props.validationMethod,
206
+ validity_days: props.validityDays,
207
+ });
208
+ if (!createResponse.ok) {
209
+ const errorText = await createResponse.text();
210
+ // Provide helpful error messages for common issues
211
+ if (errorText.includes("subscription")) {
212
+ throw new Error(`Failed to create certificate pack: Advanced Certificate Packs require a paid Cloudflare plan. Please upgrade your subscription to use this feature.\n\nOriginal error: ${errorText}`);
213
+ }
214
+ if (errorText.includes("quota")) {
215
+ throw new Error(`Failed to create certificate pack: Certificate pack quota exceeded. Please check your account limits.\n\nOriginal error: ${errorText}`);
216
+ }
217
+ // Throw generic error for other cases
218
+ throw new Error(`Failed to create certificate pack: ${createResponse.statusText}\n\n${errorText}`);
219
+ }
220
+ const createdPack = (await createResponse.json()).result;
221
+ logger.log(`Certificate pack created with ID ${createdPack.id}. Status: ${createdPack.status}. Note: Certificate provisioning can take up to 10 minutes.`);
222
+ return this({
223
+ id: createdPack.id,
224
+ certificateAuthority: createdPack.certificate_authority,
225
+ cloudflareBranding: createdPack.cloudflare_branding,
226
+ hosts: createdPack.hosts,
227
+ status: createdPack.status,
228
+ type: createdPack.type,
229
+ validationMethod: createdPack.validation_method,
230
+ validityDays: createdPack.validity_days,
231
+ zoneId: createdPack.zone_id,
232
+ zoneName: zoneName,
233
+ });
234
+ });
235
+ /**
236
+ * Helper function to wait for certificate pack to reach active status
237
+ * Useful for testing or when you need to ensure the certificate is ready
238
+ *
239
+ * @param api CloudflareApi instance
240
+ * @param zoneId Zone ID
241
+ * @param certificatePackId Certificate pack ID
242
+ * @param timeoutMs Maximum time to wait in milliseconds (default: 15 minutes)
243
+ * @returns Promise resolving to the final certificate pack status
244
+ *
245
+ * @example
246
+ * // Wait for certificate to become active
247
+ * const finalStatus = await waitForCertificatePackActive(
248
+ * api,
249
+ * zoneId,
250
+ * certificatePack.id,
251
+ * 10 * 60 * 1000 // 10 minutes
252
+ * );
253
+ * console.log(`Certificate pack is now: ${finalStatus}`);
254
+ */
255
+ export async function waitForCertificatePackActive(api, zoneId, certificatePackId, timeoutMs = 15 * 60 * 1000) {
256
+ const startTime = Date.now();
257
+ const pollInterval = 30 * 1000; // Poll every 30 seconds
258
+ while (Date.now() - startTime < timeoutMs) {
259
+ const response = await api.get(`/zones/${zoneId}/ssl/certificate_packs/${certificatePackId}`);
260
+ if (!response.ok) {
261
+ throw new Error(`Failed to check certificate pack status: ${response.statusText}`);
262
+ }
263
+ const pack = (await response.json()).result;
264
+ // Return immediately if active or in a final error state
265
+ if (pack.status === "active") {
266
+ return pack.status;
267
+ }
268
+ if (pack.status.includes("timed_out") ||
269
+ pack.status === "expired" ||
270
+ pack.status === "deleted") {
271
+ return pack.status;
272
+ }
273
+ // Wait before next poll
274
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
275
+ }
276
+ throw new Error(`Certificate pack did not become active within ${timeoutMs / 1000 / 60} minutes`);
277
+ }
278
+ /**
279
+ * Helper function to find zone ID from a hostname
280
+ * Searches for the zone that matches the hostname or its parent domains
281
+ *
282
+ * @param api CloudflareApi instance
283
+ * @param hostname The hostname to find the zone for
284
+ * @returns Promise resolving to the zone ID and zone name
285
+ */
286
+ async function findZoneForHostname(api, hostname) {
287
+ // Remove wildcard prefix if present
288
+ const cleanHostname = hostname.replace(/^\*\./, "");
289
+ // Get all zones and find the best match
290
+ const response = await api.get("/zones");
291
+ if (!response.ok) {
292
+ throw new Error(`Failed to list zones: ${response.statusText}`);
293
+ }
294
+ const zonesData = (await response.json());
295
+ // Find the zone that best matches the hostname
296
+ // We look for the longest matching zone name (most specific)
297
+ let bestMatch = null;
298
+ let longestMatch = 0;
299
+ for (const zone of zonesData.result) {
300
+ if (cleanHostname === zone.name ||
301
+ cleanHostname.endsWith(`.${zone.name}`)) {
302
+ if (zone.name.length > longestMatch) {
303
+ longestMatch = zone.name.length;
304
+ bestMatch = { zoneId: zone.id, zoneName: zone.name };
305
+ }
306
+ }
307
+ }
308
+ if (!bestMatch) {
309
+ throw new Error(`Could not find zone for hostname '${hostname}'. Available zones: ${zonesData.result.map((z) => z.name).join(", ")}`);
310
+ }
311
+ return bestMatch;
312
+ }
313
+ /**
314
+ * Helper function to find existing certificate packs that match the given configuration
315
+ * Used to adopt existing certificates instead of creating duplicates
316
+ *
317
+ * @param api CloudflareApi instance
318
+ * @param zoneId Zone ID to search in
319
+ * @param props Certificate pack properties to match
320
+ * @returns Promise resolving to matching certificate pack or null if none found
321
+ */
322
+ async function findMatchingCertificatePack(api, zoneId, props) {
323
+ const response = await api.get(`/zones/${zoneId}/ssl/certificate_packs`);
324
+ if (!response.ok) {
325
+ throw new Error(`Failed to list certificate packs: ${response.statusText}`);
326
+ }
327
+ const packsData = (await response.json());
328
+ // Find a certificate pack that matches our configuration
329
+ for (const pack of packsData.result) {
330
+ // Skip deleted or expired packs
331
+ if (pack.status === "deleted" || pack.status === "expired") {
332
+ continue;
333
+ }
334
+ // Check if the configuration matches
335
+ if (pack.certificate_authority === props.certificateAuthority &&
336
+ pack.validation_method === props.validationMethod &&
337
+ pack.validity_days === props.validityDays &&
338
+ pack.type === (props.type || "advanced")) {
339
+ // Check if all requested hosts are covered by this certificate pack
340
+ const packHosts = new Set(pack.hosts);
341
+ const allHostsCovered = props.hosts.every((host) => packHosts.has(host));
342
+ if (allHostsCovered) {
343
+ logger.log(`Found existing certificate pack ${pack.id} that covers all requested hosts`);
344
+ return pack;
345
+ }
346
+ }
347
+ }
348
+ return null;
349
+ }
350
+ //# sourceMappingURL=certificate-pack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"certificate-pack.js","sourceRoot":"","sources":["../../src/cloudflare/certificate-pack.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,mBAAmB,GAGpB,MAAM,UAAU,CAAC;AA8KlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CACrC,6BAA6B,EAC7B,KAAK,WAEH,GAAW,EACX,KAA2B;IAE3B,gEAAgE;IAChE,MAAM,GAAG,GAAG,MAAM,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAE7C,g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CAC7E,CAAC;gBACF,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -13,6 +13,7 @@ export * from "./browser-rendering.ts";
13
13
  export * from "./bucket.ts";
14
14
  export * from "./bundle/external.ts";
15
15
  export * from "./bundle/local-dev-cloudflare-shim.ts";
16
+ export * from "./certificate-pack.ts";
16
17
  export * from "./container.ts";
17
18
  export * from "./custom-domain.ts";
18
19
  export * from "./d1-clone.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cloudflare/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,uCAAuC,CAAC;AACtD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc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AC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC"}
@@ -13,6 +13,7 @@ export * from "./browser-rendering.js";
13
13
  export * from "./bucket.js";
14
14
  export * from "./bundle/external.js";
15
15
  export * from "./bundle/local-dev-cloudflare-shim.js";
16
+ export * from "./certificate-pack.js";
16
17
  export * from "./container.js";
17
18
  export * from "./custom-domain.js";
18
19
  export * from "./d1-clone.js";
@@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Ac,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC"}
@@ -559,7 +559,7 @@ export declare function WorkerRef<RPC extends Rpc.WorkerEntrypointBranded = Rpc.
559
559
  */
560
560
  export declare function Worker<const B extends Bindings, RPC extends Rpc.WorkerEntrypointBranded>(id: string, props: WorkerProps<B, RPC>): Promise<Worker<B, RPC>>;
561
561
  export declare function Worker<const B extends Bindings, const E extends EventSource[]>(id: string, meta: ImportMeta, props: FetchWorkerProps<B, E>): Promise<Worker<B>> & globalThis.Service;
562
- export declare const DEFAULT_COMPATIBILITY_DATE = "2025-06-26";
562
+ export declare const DEFAULT_COMPATIBILITY_DATE = "2025-06-27";
563
563
  export declare const _Worker: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | (<const B extends Bindings>(this: Context<Worker<NoInfer<B>>>, id: string, props: WorkerProps<B>) => Promise<Worker<B>>);
564
564
  export declare function deleteWorker(api: CloudflareApi, props: {
565
565
  workerName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alchemy",
3
- "version": "0.41.1",
3
+ "version": "0.41.2",
4
4
  "type": "module",
5
5
  "module": "./lib/index.js",
6
6
  "license": "Apache-2.0",