alchemy 0.80.1 → 0.81.0

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 (48) hide show
  1. package/bin/alchemy.js +11 -5
  2. package/bin/services/execute-alchemy.ts +18 -6
  3. package/lib/alchemy.js +1 -1
  4. package/lib/alchemy.js.map +1 -1
  5. package/lib/cloudflare/compatibility-date.gen.d.ts +1 -1
  6. package/lib/cloudflare/compatibility-date.gen.js +1 -1
  7. package/lib/cloudflare/hyperdrive.d.ts +23 -5
  8. package/lib/cloudflare/hyperdrive.d.ts.map +1 -1
  9. package/lib/cloudflare/hyperdrive.js.map +1 -1
  10. package/lib/cloudflare/index.d.ts +3 -0
  11. package/lib/cloudflare/index.d.ts.map +1 -1
  12. package/lib/cloudflare/index.js +3 -0
  13. package/lib/cloudflare/index.js.map +1 -1
  14. package/lib/cloudflare/miniflare/miniflare-worker-proxy.d.ts.map +1 -1
  15. package/lib/cloudflare/miniflare/miniflare-worker-proxy.js +7 -0
  16. package/lib/cloudflare/miniflare/miniflare-worker-proxy.js.map +1 -1
  17. package/lib/cloudflare/queue.d.ts +0 -3
  18. package/lib/cloudflare/queue.d.ts.map +1 -1
  19. package/lib/cloudflare/queue.js +53 -31
  20. package/lib/cloudflare/queue.js.map +1 -1
  21. package/lib/cloudflare/tunnel-route.d.ts +172 -0
  22. package/lib/cloudflare/tunnel-route.d.ts.map +1 -0
  23. package/lib/cloudflare/tunnel-route.js +251 -0
  24. package/lib/cloudflare/tunnel-route.js.map +1 -0
  25. package/lib/cloudflare/warp-default-profile.d.ts +133 -0
  26. package/lib/cloudflare/warp-default-profile.d.ts.map +1 -0
  27. package/lib/cloudflare/warp-default-profile.js +138 -0
  28. package/lib/cloudflare/warp-default-profile.js.map +1 -0
  29. package/lib/cloudflare/warp-device-profile.d.ts +272 -0
  30. package/lib/cloudflare/warp-device-profile.d.ts.map +1 -0
  31. package/lib/cloudflare/warp-device-profile.js +291 -0
  32. package/lib/cloudflare/warp-device-profile.js.map +1 -0
  33. package/lib/scope.d.ts +1 -1
  34. package/lib/scope.d.ts.map +1 -1
  35. package/lib/scope.js +1 -1
  36. package/lib/scope.js.map +1 -1
  37. package/package.json +1 -1
  38. package/src/alchemy.ts +1 -1
  39. package/src/cloudflare/compatibility-date.gen.ts +1 -1
  40. package/src/cloudflare/hyperdrive.ts +27 -5
  41. package/src/cloudflare/index.ts +3 -0
  42. package/src/cloudflare/miniflare/miniflare-worker-proxy.ts +11 -0
  43. package/src/cloudflare/queue.ts +97 -56
  44. package/src/cloudflare/tunnel-route.ts +495 -0
  45. package/src/cloudflare/warp-default-profile.ts +320 -0
  46. package/src/cloudflare/warp-device-profile.ts +616 -0
  47. package/src/scope.ts +2 -2
  48. package/workers/tunnel-proxy.js +1 -1
@@ -0,0 +1,172 @@
1
+ import type { Context } from "../context.ts";
2
+ import { type CloudflareApi, type CloudflareApiOptions } from "./api.ts";
3
+ import type { Tunnel } from "./tunnel.ts";
4
+ /**
5
+ * Route data as returned by Cloudflare API
6
+ * @internal
7
+ */
8
+ interface CloudflareRoute {
9
+ id: string;
10
+ network: string;
11
+ tunnel_id: string;
12
+ comment?: string;
13
+ virtual_network_id?: string;
14
+ created_at: string;
15
+ deleted_at: string | null;
16
+ }
17
+ /**
18
+ * Properties for creating or updating a Cloudflare Tunnel Route
19
+ */
20
+ export interface TunnelRouteProps extends CloudflareApiOptions {
21
+ /**
22
+ * The private IPv4 or IPv6 range connected by the route, in CIDR notation
23
+ * (e.g., "172.16.0.0/16" or "2001:db8::/32")
24
+ *
25
+ * Note: The network CIDR is immutable and cannot be changed after creation.
26
+ * When updating a route, any network change will trigger a replacement.
27
+ */
28
+ network: string;
29
+ /**
30
+ * The tunnel to route traffic through
31
+ * Can be a Tunnel resource or a tunnel ID (UUID)
32
+ */
33
+ tunnel: string | Tunnel;
34
+ /**
35
+ * Optional remark describing the route
36
+ * @maxLength 100
37
+ */
38
+ comment?: string;
39
+ /**
40
+ * UUID of the virtual network
41
+ * If not provided, the route will be added to the default virtual network
42
+ */
43
+ virtualNetworkId?: string;
44
+ /**
45
+ * Whether to adopt an existing route with the same network and tunnel if it exists
46
+ * If true and a route with the same network and tunnel exists, it will be adopted rather than creating a new one
47
+ *
48
+ * @default false
49
+ */
50
+ adopt?: boolean;
51
+ /**
52
+ * Whether to delete the route when removed from Alchemy
53
+ * If set to false, the route will remain but the resource will be removed from state
54
+ *
55
+ * @default true
56
+ */
57
+ delete?: boolean;
58
+ /**
59
+ * Internal route ID for lifecycle management
60
+ * @internal
61
+ */
62
+ routeId?: string;
63
+ }
64
+ export declare function isTunnelRoute(resource: any): resource is TunnelRoute;
65
+ /**
66
+ * Output returned after TunnelRoute creation/update
67
+ */
68
+ export interface TunnelRoute extends Omit<TunnelRouteProps, "delete" | "tunnel" | "routeId"> {
69
+ /**
70
+ * The ID of the route
71
+ */
72
+ id: string;
73
+ /**
74
+ * The private IPv4 or IPv6 range connected by the route, in CIDR notation
75
+ */
76
+ network: string;
77
+ /**
78
+ * The UUID of the tunnel this route uses
79
+ */
80
+ tunnelId: string;
81
+ /**
82
+ * Optional remark describing the route
83
+ */
84
+ comment?: string;
85
+ /**
86
+ * UUID of the virtual network
87
+ */
88
+ virtualNetworkId?: string;
89
+ /**
90
+ * Time at which the route was created
91
+ */
92
+ createdAt: string;
93
+ /**
94
+ * Time at which the route was deleted (null if active)
95
+ */
96
+ deletedAt: string | null;
97
+ /**
98
+ * Resource type identifier for binding
99
+ * @internal
100
+ */
101
+ type: "cloudflare::TunnelRoute";
102
+ }
103
+ /**
104
+ * Creates and manages a Cloudflare Tunnel Route, which routes private network traffic
105
+ * through a Cloudflare Tunnel. This resource handles the route lifecycle (create, update, delete).
106
+ *
107
+ * @remarks
108
+ * Tunnel Routes enable private network access by routing CIDR ranges through Cloudflare Tunnels.
109
+ * This is commonly used for Zero Trust network access scenarios where you need to connect
110
+ * private networks to Cloudflare's edge.
111
+ *
112
+ * @see https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/private-net/
113
+ * @see https://developers.cloudflare.com/api/operations/zero-trust-networks-routes-create-a-tunnel-route
114
+ *
115
+ * @example
116
+ * // Create a basic tunnel route for a private network
117
+ * const tunnel = await Tunnel("my-tunnel", {
118
+ * name: "my-tunnel"
119
+ * });
120
+ *
121
+ * const route = await TunnelRoute("private-network", {
122
+ * network: "172.16.0.0/16",
123
+ * tunnel: tunnel
124
+ * });
125
+ *
126
+ * @example
127
+ * // Create a route with a comment and virtual network
128
+ * const route = await TunnelRoute("vpc-route", {
129
+ * network: "10.0.0.0/8",
130
+ * tunnel: "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415",
131
+ * comment: "Main VPC network route",
132
+ * virtualNetworkId: "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415"
133
+ * });
134
+ *
135
+ * @example
136
+ * // Adopt an existing route if it already exists
137
+ * const route = await TunnelRoute("existing-route", {
138
+ * network: "192.168.1.0/24",
139
+ * tunnel: tunnel,
140
+ * adopt: true,
141
+ * comment: "Updated comment"
142
+ * });
143
+ *
144
+ * @example
145
+ * // Create a route without deleting it when removed from Alchemy
146
+ * const route = await TunnelRoute("persistent-route", {
147
+ * network: "10.1.0.0/16",
148
+ * tunnel: tunnel,
149
+ * delete: false
150
+ * });
151
+ */
152
+ export declare const TunnelRoute: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<TunnelRoute>, id: string, props: TunnelRouteProps) => Promise<TunnelRoute>);
153
+ /**
154
+ * Get tunnel route details
155
+ * @internal
156
+ */
157
+ export declare function getTunnelRoute(api: CloudflareApi, routeId: string): Promise<CloudflareRoute>;
158
+ /**
159
+ * List all tunnel routes with pagination support
160
+ * @internal
161
+ */
162
+ export declare function listTunnelRoutes(api: CloudflareApi, options?: {
163
+ /** Maximum number of routes to return */
164
+ limit?: number;
165
+ }): Promise<CloudflareRoute[]>;
166
+ /**
167
+ * Find a route by network and tunnel ID
168
+ * @internal
169
+ */
170
+ export declare function findRouteByNetworkAndTunnel(api: CloudflareApi, network: string, tunnelId: string): Promise<CloudflareRoute | null>;
171
+ export {};
172
+ //# sourceMappingURL=tunnel-route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tunnel-route.d.ts","sourceRoot":"","sources":["../../src/cloudflare/tunnel-route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAQ7C,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAC1B,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,UAAU,eAAe;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,oBAAoB;IAC5D;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAExB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,GAAG,GAAG,QAAQ,IAAI,WAAW,CAEpE;AAED;;GAEG;AACH,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,gBAAgB,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC/D;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzB;;;OAGG;IACH,IAAI,EAAE,yBAAyB,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,eAAO,MAAM,WAAW,yFAGd,OAAO,CAAC,WAAW,CAAC,MACtB,MAAM,SACH,gBAAgB,KACtB,OAAO,CAAC,WAAW,CAAC,CAuHxB,CAAC;AAEF;;;GAGG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,eAAe,CAAC,CAY1B;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,aAAa,EAClB,OAAO,CAAC,EAAE;IACR,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GACA,OAAO,CAAC,eAAe,EAAE,CAAC,CAuC5B;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CASjC"}
@@ -0,0 +1,251 @@
1
+ import { Resource, ResourceKind } from "../resource.js";
2
+ import { logger } from "../util/logger.js";
3
+ import { handleApiError } from "./api-error.js";
4
+ import { createCloudflareApi, } from "./api.js";
5
+ export function isTunnelRoute(resource) {
6
+ return resource?.[ResourceKind] === "cloudflare::TunnelRoute";
7
+ }
8
+ /**
9
+ * Creates and manages a Cloudflare Tunnel Route, which routes private network traffic
10
+ * through a Cloudflare Tunnel. This resource handles the route lifecycle (create, update, delete).
11
+ *
12
+ * @remarks
13
+ * Tunnel Routes enable private network access by routing CIDR ranges through Cloudflare Tunnels.
14
+ * This is commonly used for Zero Trust network access scenarios where you need to connect
15
+ * private networks to Cloudflare's edge.
16
+ *
17
+ * @see https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/private-net/
18
+ * @see https://developers.cloudflare.com/api/operations/zero-trust-networks-routes-create-a-tunnel-route
19
+ *
20
+ * @example
21
+ * // Create a basic tunnel route for a private network
22
+ * const tunnel = await Tunnel("my-tunnel", {
23
+ * name: "my-tunnel"
24
+ * });
25
+ *
26
+ * const route = await TunnelRoute("private-network", {
27
+ * network: "172.16.0.0/16",
28
+ * tunnel: tunnel
29
+ * });
30
+ *
31
+ * @example
32
+ * // Create a route with a comment and virtual network
33
+ * const route = await TunnelRoute("vpc-route", {
34
+ * network: "10.0.0.0/8",
35
+ * tunnel: "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415",
36
+ * comment: "Main VPC network route",
37
+ * virtualNetworkId: "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415"
38
+ * });
39
+ *
40
+ * @example
41
+ * // Adopt an existing route if it already exists
42
+ * const route = await TunnelRoute("existing-route", {
43
+ * network: "192.168.1.0/24",
44
+ * tunnel: tunnel,
45
+ * adopt: true,
46
+ * comment: "Updated comment"
47
+ * });
48
+ *
49
+ * @example
50
+ * // Create a route without deleting it when removed from Alchemy
51
+ * const route = await TunnelRoute("persistent-route", {
52
+ * network: "10.1.0.0/16",
53
+ * tunnel: tunnel,
54
+ * delete: false
55
+ * });
56
+ */
57
+ export const TunnelRoute = Resource("cloudflare::TunnelRoute", async function (id, props) {
58
+ // Create Cloudflare API client with automatic account discovery
59
+ const api = await createCloudflareApi(props);
60
+ // Resolve tunnel ID from either string or Tunnel resource
61
+ const tunnelId = typeof props.tunnel === "string" ? props.tunnel : props.tunnel.tunnelId;
62
+ const routeId = props.routeId || this.output?.id;
63
+ const adopt = props.adopt ?? this.scope.adopt;
64
+ if (this.phase === "delete") {
65
+ // For delete operations, check if the route ID exists in the output
66
+ if (routeId && props.delete !== false) {
67
+ await deleteRoute(api, routeId);
68
+ }
69
+ // Return destroyed state
70
+ return this.destroy();
71
+ }
72
+ // Check if network is being changed - network is immutable
73
+ if (this.phase === "update" &&
74
+ this.output?.network &&
75
+ this.output.network !== props.network) {
76
+ logger.log(`Network changed from '${this.output.network}' to '${props.network}', replacing route`);
77
+ this.replace(true);
78
+ }
79
+ // Check if tunnel is being changed - tunnel is immutable
80
+ if (this.phase === "update" &&
81
+ this.output?.tunnelId &&
82
+ this.output.tunnelId !== tunnelId) {
83
+ logger.log(`Tunnel changed from '${this.output.tunnelId}' to '${tunnelId}', replacing route`);
84
+ this.replace(true);
85
+ }
86
+ let routeData;
87
+ if (this.phase === "update" && routeId) {
88
+ // Update existing route (only comment and virtualNetworkId can be updated)
89
+ routeData = await updateRoute(api, routeId, {
90
+ comment: props.comment,
91
+ virtualNetworkId: props.virtualNetworkId,
92
+ });
93
+ }
94
+ else {
95
+ // Create new route
96
+ try {
97
+ routeData = await createRoute(api, {
98
+ network: props.network,
99
+ tunnelId,
100
+ comment: props.comment,
101
+ virtualNetworkId: props.virtualNetworkId,
102
+ });
103
+ }
104
+ catch (error) {
105
+ // Check if this is a "route already exists" error and adopt is enabled
106
+ if (adopt &&
107
+ error instanceof Error &&
108
+ (error.message.includes("already exists") ||
109
+ error.message.includes("duplicate") ||
110
+ error.status === 409)) {
111
+ logger.log(`Route for network '${props.network}' and tunnel '${tunnelId}' already exists, adopting it`);
112
+ // Find the existing route by network and tunnel
113
+ const existingRoute = await findRouteByNetworkAndTunnel(api, props.network, tunnelId);
114
+ if (!existingRoute) {
115
+ throw new Error(`Failed to find existing route for network '${props.network}' and tunnel '${tunnelId}' for adoption`);
116
+ }
117
+ routeData = existingRoute;
118
+ // Update comment/virtualNetworkId if provided
119
+ if (props.comment !== undefined ||
120
+ props.virtualNetworkId !== undefined) {
121
+ routeData = await updateRoute(api, existingRoute.id, {
122
+ comment: props.comment,
123
+ virtualNetworkId: props.virtualNetworkId,
124
+ });
125
+ }
126
+ }
127
+ else {
128
+ // Re-throw the error if adopt is false or it's not an "already exists" error
129
+ throw error;
130
+ }
131
+ }
132
+ }
133
+ // Transform API response to our interface
134
+ return {
135
+ id: routeData.id,
136
+ network: routeData.network,
137
+ tunnelId: routeData.tunnel_id,
138
+ comment: routeData.comment,
139
+ virtualNetworkId: routeData.virtual_network_id,
140
+ createdAt: routeData.created_at,
141
+ deletedAt: routeData.deleted_at,
142
+ type: "cloudflare::TunnelRoute",
143
+ };
144
+ });
145
+ /**
146
+ * Get tunnel route details
147
+ * @internal
148
+ */
149
+ export async function getTunnelRoute(api, routeId) {
150
+ const response = await api.get(`/accounts/${api.accountId}/teamnet/routes/${routeId}`);
151
+ if (!response.ok) {
152
+ await handleApiError(response, "get", "route", routeId);
153
+ }
154
+ const data = (await response.json());
155
+ return data.result;
156
+ }
157
+ /**
158
+ * List all tunnel routes with pagination support
159
+ * @internal
160
+ */
161
+ export async function listTunnelRoutes(api, options) {
162
+ const routes = [];
163
+ let page = 1;
164
+ const perPage = 100; // Maximum allowed by API
165
+ let hasMorePages = true;
166
+ const limit = options?.limit;
167
+ while (hasMorePages) {
168
+ const params = new URLSearchParams({
169
+ page: page.toString(),
170
+ per_page: perPage.toString(),
171
+ });
172
+ const response = await api.get(`/accounts/${api.accountId}/teamnet/routes?${params.toString()}`);
173
+ if (!response.ok) {
174
+ await handleApiError(response, "list", "route", "all");
175
+ }
176
+ const data = (await response.json());
177
+ routes.push(...data.result);
178
+ const resultInfo = data.result_info;
179
+ // Check if we've reached the limit
180
+ if (limit && routes.length >= limit) {
181
+ return routes.slice(0, limit);
182
+ }
183
+ // Check if we've seen all pages
184
+ hasMorePages =
185
+ resultInfo.page * resultInfo.per_page < resultInfo.total_count;
186
+ page++;
187
+ }
188
+ return routes;
189
+ }
190
+ /**
191
+ * Find a route by network and tunnel ID
192
+ * @internal
193
+ */
194
+ export async function findRouteByNetworkAndTunnel(api, network, tunnelId) {
195
+ const routes = await listTunnelRoutes(api);
196
+ // Look for a route with matching network and tunnel_id
197
+ const match = routes.find((route) => route.network === network && route.tunnel_id === tunnelId);
198
+ return match || null;
199
+ }
200
+ /**
201
+ * Delete a route
202
+ * @internal
203
+ */
204
+ async function deleteRoute(api, routeId) {
205
+ const response = await api.delete(`/accounts/${api.accountId}/teamnet/routes/${routeId}`);
206
+ if (!response.ok && response.status !== 404) {
207
+ await handleApiError(response, "delete", "route", routeId);
208
+ }
209
+ }
210
+ /**
211
+ * Create a new route
212
+ * @internal
213
+ */
214
+ async function createRoute(api, props) {
215
+ const payload = {
216
+ network: props.network,
217
+ tunnel_id: props.tunnelId,
218
+ };
219
+ if (props.comment !== undefined) {
220
+ payload.comment = props.comment;
221
+ }
222
+ if (props.virtualNetworkId !== undefined) {
223
+ payload.virtual_network_id = props.virtualNetworkId;
224
+ }
225
+ const response = await api.post(`/accounts/${api.accountId}/teamnet/routes`, payload);
226
+ if (!response.ok) {
227
+ await handleApiError(response, "create", "route", `${props.network} -> ${props.tunnelId}`);
228
+ }
229
+ const data = (await response.json());
230
+ return data.result;
231
+ }
232
+ /**
233
+ * Update route configuration
234
+ * @internal
235
+ */
236
+ async function updateRoute(api, routeId, props) {
237
+ const payload = {};
238
+ if (props.comment !== undefined) {
239
+ payload.comment = props.comment;
240
+ }
241
+ if (props.virtualNetworkId !== undefined) {
242
+ payload.virtual_network_id = props.virtualNetworkId;
243
+ }
244
+ const response = await api.patch(`/accounts/${api.accountId}/teamnet/routes/${routeId}`, payload);
245
+ if (!response.ok) {
246
+ await handleApiError(response, "update", "route", routeId);
247
+ }
248
+ const data = (await response.json());
249
+ return data.result;
250
+ }
251
+ //# sourceMappingURL=tunnel-route.js.map
@@ -0,0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S,EAAE,CAAC;QACzC,OAAO,CAAC,kBAAkB,GAAG,KAAK,CAAC,gBAAgB,CAAC;IACtD,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,KAAK,CAC9B,aAAa,GAAG,CAAC,SAAS,mBAAmB,OAAO,EAAE,EACtD,OAAO,CACR,CAAC;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC7D,CAAC;IAED,MAAM,IAAI,GACR,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA2C,CAAC;IACpE,OAAO,IAAI,CAAC,MAAM,CAAC;AACrB,CAAC"}
@@ -0,0 +1,133 @@
1
+ import type { Context } from "../context.ts";
2
+ import { type CloudflareApiOptions } from "./api.ts";
3
+ import type { ServiceModeV2, SplitTunnelConfig } from "./warp-device-profile.ts";
4
+ /**
5
+ * Properties for updating the WARP Default Profile
6
+ */
7
+ export interface WarpDefaultProfileProps extends CloudflareApiOptions {
8
+ /**
9
+ * Service mode configuration for WARP client
10
+ */
11
+ serviceModeV2?: ServiceModeV2;
12
+ /**
13
+ * Disable automatic fallback to direct connection if tunnel fails
14
+ */
15
+ disableAutoFallback?: boolean;
16
+ /**
17
+ * Allow users to manually switch WARP modes
18
+ */
19
+ allowModeSwitch?: boolean;
20
+ /**
21
+ * Lock the WARP toggle switch (users cannot change it)
22
+ */
23
+ switchLocked?: boolean;
24
+ /**
25
+ * Tunnel protocol to use
26
+ */
27
+ tunnelProtocol?: "wireguard" | "masque";
28
+ /**
29
+ * Auto-connect timeout in seconds
30
+ * Set to 0 to disable auto-connect
31
+ */
32
+ autoConnect?: number;
33
+ /**
34
+ * Allow users to disconnect from WARP
35
+ */
36
+ allowedToLeave?: boolean;
37
+ /**
38
+ * Captive portal timeout in seconds
39
+ * Time before showing captive portal
40
+ */
41
+ captivePortal?: number;
42
+ /**
43
+ * Support URL for feedback button in WARP client
44
+ */
45
+ supportUrl?: string;
46
+ /**
47
+ * Exclude office IPs from WARP tunnel
48
+ */
49
+ excludeOfficeIps?: boolean;
50
+ /**
51
+ * LAN allow duration in minutes
52
+ */
53
+ lanAllowMinutes?: number;
54
+ /**
55
+ * LAN subnet size for local network access
56
+ */
57
+ lanAllowSubnetSize?: number;
58
+ /**
59
+ * Split tunnel configuration
60
+ * Controls which routes bypass or use the WARP tunnel
61
+ */
62
+ splitTunnel?: SplitTunnelConfig;
63
+ /**
64
+ * Whether to delete the default profile settings when removed from Alchemy
65
+ * Note: This does not actually delete the default profile (which always exists),
66
+ * but removes it from Alchemy state management
67
+ *
68
+ * @default false
69
+ */
70
+ delete?: boolean;
71
+ }
72
+ export declare function isWarpDefaultProfile(resource: any): resource is WarpDefaultProfile;
73
+ /**
74
+ * Output returned after WARP Default Profile update
75
+ */
76
+ export type WarpDefaultProfile = WarpDefaultProfileProps & {
77
+ /**
78
+ * Time at which the profile was last modified
79
+ */
80
+ modifiedAt: number;
81
+ };
82
+ /**
83
+ * Manages the Cloudflare WARP Default Device Profile, which defines the
84
+ * account-wide default WARP client settings that apply when no custom profile matches.
85
+ *
86
+ * The default profile always exists and cannot be deleted. This resource allows you
87
+ * to update its settings programmatically.
88
+ *
89
+ * @see https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/configure-warp/device-profiles/
90
+ *
91
+ * @example
92
+ * ## Update default WARP settings
93
+ *
94
+ * Configure the default behavior for all devices
95
+ *
96
+ * const defaultProfile = await WarpDefaultProfile("default", {
97
+ * serviceModeV2: { mode: "warp" },
98
+ * autoConnect: 0,
99
+ * captivePortal: 180,
100
+ * supportUrl: "https://support.example.com"
101
+ * });
102
+ *
103
+ * @example
104
+ * ## Default profile with split tunnel
105
+ *
106
+ * Configure default split tunnel behavior for all devices
107
+ *
108
+ * const defaultWithSplitTunnel = await WarpDefaultProfile("default", {
109
+ * serviceModeV2: { mode: "warp" },
110
+ * splitTunnel: {
111
+ * mode: "exclude",
112
+ * entries: [
113
+ * { address: "10.0.0.0/8", description: "Internal network" },
114
+ * { address: "192.168.0.0/16", description: "Local network" }
115
+ * ]
116
+ * }
117
+ * });
118
+ *
119
+ * @example
120
+ * ## Locked default profile
121
+ *
122
+ * Create a locked-down default configuration
123
+ *
124
+ * const lockedDefault = await WarpDefaultProfile("default", {
125
+ * serviceModeV2: { mode: "warp" },
126
+ * switchLocked: true,
127
+ * allowedToLeave: false,
128
+ * disableAutoFallback: true,
129
+ * tunnelProtocol: "wireguard"
130
+ * });
131
+ */
132
+ export declare const WarpDefaultProfile: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<WarpDefaultProfile>, id: string, props?: WarpDefaultProfileProps) => Promise<WarpDefaultProfile>);
133
+ //# sourceMappingURL=warp-default-profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warp-default-profile.d.ts","sourceRoot":"","sources":["../../src/cloudflare/warp-default-profile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,EAGL,KAAK,oBAAoB,EAC1B,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,aAAa,EACb,iBAAiB,EAClB,MAAM,0BAA0B,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,oBAAoB;IACnE;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;OAEG;IACH,cAAc,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC;IAExC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;OA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