alchemy 0.80.1 → 0.81.1
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.
- package/bin/alchemy.js +1660 -1382
- package/bin/services/execute-alchemy.ts +18 -6
- package/lib/alchemy.js +1 -1
- package/lib/alchemy.js.map +1 -1
- package/lib/cloudflare/compatibility-date.gen.d.ts +1 -1
- package/lib/cloudflare/compatibility-date.gen.js +1 -1
- package/lib/cloudflare/hyperdrive.d.ts +23 -5
- package/lib/cloudflare/hyperdrive.d.ts.map +1 -1
- package/lib/cloudflare/hyperdrive.js.map +1 -1
- package/lib/cloudflare/index.d.ts +3 -0
- package/lib/cloudflare/index.d.ts.map +1 -1
- package/lib/cloudflare/index.js +3 -0
- package/lib/cloudflare/index.js.map +1 -1
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.js +7 -0
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.js.map +1 -1
- package/lib/cloudflare/queue.d.ts +0 -3
- package/lib/cloudflare/queue.d.ts.map +1 -1
- package/lib/cloudflare/queue.js +53 -31
- package/lib/cloudflare/queue.js.map +1 -1
- package/lib/cloudflare/redirect-rule.d.ts +12 -2
- package/lib/cloudflare/redirect-rule.d.ts.map +1 -1
- package/lib/cloudflare/redirect-rule.js +73 -98
- package/lib/cloudflare/redirect-rule.js.map +1 -1
- package/lib/cloudflare/tunnel-route.d.ts +172 -0
- package/lib/cloudflare/tunnel-route.d.ts.map +1 -0
- package/lib/cloudflare/tunnel-route.js +251 -0
- package/lib/cloudflare/tunnel-route.js.map +1 -0
- package/lib/cloudflare/warp-default-profile.d.ts +133 -0
- package/lib/cloudflare/warp-default-profile.d.ts.map +1 -0
- package/lib/cloudflare/warp-default-profile.js +138 -0
- package/lib/cloudflare/warp-default-profile.js.map +1 -0
- package/lib/cloudflare/warp-device-profile.d.ts +272 -0
- package/lib/cloudflare/warp-device-profile.d.ts.map +1 -0
- package/lib/cloudflare/warp-device-profile.js +291 -0
- package/lib/cloudflare/warp-device-profile.js.map +1 -0
- package/lib/scope.d.ts +1 -1
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +1 -1
- package/lib/scope.js.map +1 -1
- package/package.json +1 -1
- package/src/alchemy.ts +1 -1
- package/src/cloudflare/compatibility-date.gen.ts +1 -1
- package/src/cloudflare/hyperdrive.ts +27 -5
- package/src/cloudflare/index.ts +3 -0
- package/src/cloudflare/miniflare/miniflare-worker-proxy.ts +11 -0
- package/src/cloudflare/queue.ts +97 -56
- package/src/cloudflare/redirect-rule.ts +129 -150
- package/src/cloudflare/tunnel-route.ts +495 -0
- package/src/cloudflare/warp-default-profile.ts +320 -0
- package/src/cloudflare/warp-device-profile.ts +616 -0
- package/src/scope.ts +2 -2
- package/workers/tunnel-proxy.js +1 -1
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import type { Context } from "../context.ts";
|
|
2
|
+
import { type CloudflareApiOptions } from "./api.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Service mode configuration for WARP client
|
|
5
|
+
*/
|
|
6
|
+
export interface ServiceModeV2 {
|
|
7
|
+
/**
|
|
8
|
+
* WARP client operational mode
|
|
9
|
+
*/
|
|
10
|
+
mode: "warp" | "proxy" | "doh_only" | "warp_tunnel_only";
|
|
11
|
+
/**
|
|
12
|
+
* Port number (only used for proxy mode)
|
|
13
|
+
*/
|
|
14
|
+
port?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Split tunnel route entry
|
|
18
|
+
*/
|
|
19
|
+
export interface SplitTunnelEntry {
|
|
20
|
+
/**
|
|
21
|
+
* IP address or CIDR block (e.g., "10.0.0.0/8" or "192.168.1.1")
|
|
22
|
+
* or domain name (e.g., "example.com"). Use either address or host.
|
|
23
|
+
*/
|
|
24
|
+
address?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Domain host for split tunnel (alternative to address)
|
|
27
|
+
*/
|
|
28
|
+
host?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Optional description for this route
|
|
31
|
+
*/
|
|
32
|
+
description?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Split tunnel configuration
|
|
36
|
+
*/
|
|
37
|
+
export interface SplitTunnelConfig {
|
|
38
|
+
/**
|
|
39
|
+
* Split tunnel mode
|
|
40
|
+
* - "include": Only specified routes go through WARP
|
|
41
|
+
* - "exclude": All routes except specified ones go through WARP
|
|
42
|
+
*/
|
|
43
|
+
mode: "include" | "exclude";
|
|
44
|
+
/**
|
|
45
|
+
* List of routes to include or exclude
|
|
46
|
+
*/
|
|
47
|
+
entries: SplitTunnelEntry[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Properties for creating or updating a WARP Device Profile
|
|
51
|
+
*/
|
|
52
|
+
export interface WarpDeviceProfileProps extends CloudflareApiOptions {
|
|
53
|
+
/**
|
|
54
|
+
* Name of the device profile
|
|
55
|
+
*
|
|
56
|
+
* @default ${app}-${stage}-${id}
|
|
57
|
+
*/
|
|
58
|
+
name?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Description of the device profile
|
|
61
|
+
*/
|
|
62
|
+
description?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Wirefilter expression for device matching
|
|
65
|
+
* Determines which devices this profile applies to
|
|
66
|
+
*
|
|
67
|
+
* @example 'identity.groups.name == "Engineering"'
|
|
68
|
+
* @example 'identity.email == "admin@example.com"'
|
|
69
|
+
*/
|
|
70
|
+
match?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Precedence order (lower number = higher priority)
|
|
73
|
+
* Profiles with lower precedence values are evaluated first
|
|
74
|
+
*/
|
|
75
|
+
precedence?: number;
|
|
76
|
+
/**
|
|
77
|
+
* Whether the profile is enabled
|
|
78
|
+
*
|
|
79
|
+
* @default true
|
|
80
|
+
*/
|
|
81
|
+
enabled?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Service mode configuration for WARP client
|
|
84
|
+
*/
|
|
85
|
+
serviceModeV2?: ServiceModeV2;
|
|
86
|
+
/**
|
|
87
|
+
* Disable automatic fallback to direct connection if tunnel fails
|
|
88
|
+
*/
|
|
89
|
+
disableAutoFallback?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Allow users to manually switch WARP modes
|
|
92
|
+
*/
|
|
93
|
+
allowModeSwitch?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Lock the WARP toggle switch (users cannot change it)
|
|
96
|
+
*/
|
|
97
|
+
switchLocked?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Tunnel protocol to use
|
|
100
|
+
*/
|
|
101
|
+
tunnelProtocol?: "wireguard" | "masque";
|
|
102
|
+
/**
|
|
103
|
+
* Auto-connect timeout in seconds
|
|
104
|
+
* Set to 0 to disable auto-connect
|
|
105
|
+
*/
|
|
106
|
+
autoConnect?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Allow users to disconnect from WARP
|
|
109
|
+
*/
|
|
110
|
+
allowedToLeave?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Captive portal timeout in seconds
|
|
113
|
+
* Time before showing captive portal
|
|
114
|
+
*/
|
|
115
|
+
captivePortal?: number;
|
|
116
|
+
/**
|
|
117
|
+
* Support URL for feedback button in WARP client
|
|
118
|
+
*/
|
|
119
|
+
supportUrl?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Exclude office IPs from WARP tunnel
|
|
122
|
+
*/
|
|
123
|
+
excludeOfficeIps?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* LAN allow duration in minutes
|
|
126
|
+
*/
|
|
127
|
+
lanAllowMinutes?: number;
|
|
128
|
+
/**
|
|
129
|
+
* LAN subnet size for local network access
|
|
130
|
+
*/
|
|
131
|
+
lanAllowSubnetSize?: number;
|
|
132
|
+
/**
|
|
133
|
+
* Split tunnel configuration
|
|
134
|
+
* Controls which routes bypass or use the WARP tunnel
|
|
135
|
+
*/
|
|
136
|
+
splitTunnel?: SplitTunnelConfig;
|
|
137
|
+
/**
|
|
138
|
+
* Whether to adopt an existing profile with the same name if it exists
|
|
139
|
+
* If true and a profile with the same name exists, it will be adopted rather than creating a new one
|
|
140
|
+
*
|
|
141
|
+
* @default false
|
|
142
|
+
*/
|
|
143
|
+
adopt?: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* Whether to delete the profile when removed from Alchemy
|
|
146
|
+
* If set to false, the profile will remain but the resource will be removed from state
|
|
147
|
+
*
|
|
148
|
+
* @default true
|
|
149
|
+
*/
|
|
150
|
+
delete?: boolean;
|
|
151
|
+
}
|
|
152
|
+
export declare function isWarpDeviceProfile(resource: any): resource is WarpDeviceProfile;
|
|
153
|
+
/**
|
|
154
|
+
* Output returned after WARP Device Profile creation/update
|
|
155
|
+
*/
|
|
156
|
+
export type WarpDeviceProfile = Omit<WarpDeviceProfileProps, "delete" | "adopt"> & {
|
|
157
|
+
/**
|
|
158
|
+
* The policy ID assigned by Cloudflare
|
|
159
|
+
*/
|
|
160
|
+
policyId: string;
|
|
161
|
+
/**
|
|
162
|
+
* Name of the profile (required in output)
|
|
163
|
+
*/
|
|
164
|
+
name: string;
|
|
165
|
+
/**
|
|
166
|
+
* Time at which the profile was created
|
|
167
|
+
*/
|
|
168
|
+
createdAt: number;
|
|
169
|
+
/**
|
|
170
|
+
* Time at which the profile was last modified
|
|
171
|
+
*/
|
|
172
|
+
modifiedAt: number;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Creates and manages a Cloudflare WARP Device Profile, which defines WARP client
|
|
176
|
+
* settings for specific sets of devices based on matching rules.
|
|
177
|
+
*
|
|
178
|
+
* Device profiles allow you to apply different WARP configurations to different
|
|
179
|
+
* groups of devices based on user identity, groups, operating system, or other criteria.
|
|
180
|
+
*
|
|
181
|
+
* @see https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/configure-warp/device-profiles/
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ## Basic device profile for a user group
|
|
185
|
+
*
|
|
186
|
+
* Create a profile that applies to all devices belonging to the Engineering group
|
|
187
|
+
*
|
|
188
|
+
* const engProfile = await WarpDeviceProfile("engineering", {
|
|
189
|
+
* name: "Engineering Team",
|
|
190
|
+
* match: 'identity.groups.name == "Engineering"',
|
|
191
|
+
* precedence: 100,
|
|
192
|
+
* serviceModeV2: { mode: "warp" },
|
|
193
|
+
* allowedToLeave: false,
|
|
194
|
+
* switchLocked: true
|
|
195
|
+
* });
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ## Profile with split tunnel configuration
|
|
199
|
+
*
|
|
200
|
+
* Create a profile that excludes internal network routes from the WARP tunnel
|
|
201
|
+
*
|
|
202
|
+
* const internalProfile = await WarpDeviceProfile("internal-network", {
|
|
203
|
+
* name: "Internal Network Access",
|
|
204
|
+
* match: 'identity.email.ends_with("@company.com")',
|
|
205
|
+
* precedence: 50,
|
|
206
|
+
* serviceModeV2: { mode: "warp" },
|
|
207
|
+
* splitTunnel: {
|
|
208
|
+
* mode: "exclude",
|
|
209
|
+
* entries: [
|
|
210
|
+
* { address: "10.0.0.0/8", description: "Internal network" },
|
|
211
|
+
* { address: "192.168.0.0/16", description: "Local network" }
|
|
212
|
+
* ]
|
|
213
|
+
* }
|
|
214
|
+
* });
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ## Profile with include mode split tunnel
|
|
218
|
+
*
|
|
219
|
+
* Only route specific networks through WARP
|
|
220
|
+
*
|
|
221
|
+
* const selectiveProfile = await WarpDeviceProfile("selective", {
|
|
222
|
+
* name: "Selective Routing",
|
|
223
|
+
* match: 'identity.groups.name == "Remote Workers"',
|
|
224
|
+
* precedence: 200,
|
|
225
|
+
* serviceModeV2: { mode: "warp" },
|
|
226
|
+
* splitTunnel: {
|
|
227
|
+
* mode: "include",
|
|
228
|
+
* entries: [
|
|
229
|
+
* { address: "10.0.0.0/8", description: "Company network" },
|
|
230
|
+
* { address: "company.com", description: "Company domain" }
|
|
231
|
+
* ]
|
|
232
|
+
* }
|
|
233
|
+
* });
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ## Adopt an existing profile
|
|
237
|
+
*
|
|
238
|
+
* Take over management of an existing device profile
|
|
239
|
+
*
|
|
240
|
+
* const existingProfile = await WarpDeviceProfile("existing", {
|
|
241
|
+
* name: "Existing Profile",
|
|
242
|
+
* adopt: true,
|
|
243
|
+
* match: 'identity.groups.name == "IT"',
|
|
244
|
+
* precedence: 10
|
|
245
|
+
* });
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ## Profile with all WARP settings
|
|
249
|
+
*
|
|
250
|
+
* Configure comprehensive WARP client behavior
|
|
251
|
+
*
|
|
252
|
+
* const fullProfile = await WarpDeviceProfile("comprehensive", {
|
|
253
|
+
* name: "Full Configuration",
|
|
254
|
+
* match: 'identity.email == "admin@example.com"',
|
|
255
|
+
* precedence: 1,
|
|
256
|
+
* enabled: true,
|
|
257
|
+
* serviceModeV2: { mode: "warp" },
|
|
258
|
+
* disableAutoFallback: false,
|
|
259
|
+
* allowModeSwitch: false,
|
|
260
|
+
* switchLocked: true,
|
|
261
|
+
* tunnelProtocol: "wireguard",
|
|
262
|
+
* autoConnect: 0,
|
|
263
|
+
* allowedToLeave: false,
|
|
264
|
+
* captivePortal: 180,
|
|
265
|
+
* supportUrl: "https://support.example.com",
|
|
266
|
+
* excludeOfficeIps: true,
|
|
267
|
+
* lanAllowMinutes: 5,
|
|
268
|
+
* lanAllowSubnetSize: 24
|
|
269
|
+
* });
|
|
270
|
+
*/
|
|
271
|
+
export declare const WarpDeviceProfile: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<WarpDeviceProfile>, id: string, props?: WarpDeviceProfileProps) => Promise<WarpDeviceProfile>);
|
|
272
|
+
//# sourceMappingURL=warp-device-profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warp-device-profile.d.ts","sourceRoot":"","sources":["../../src/cloudfl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";
|
|
3
|
+
import { CloudflareApiError, handleApiError } from "./api-error.js";
|
|
4
|
+
import { extractCloudflareResult } from "./api-response.js";
|
|
5
|
+
import { createCloudflareApi, } from "./api.js";
|
|
6
|
+
export function isWarpDeviceProfile(resource) {
|
|
7
|
+
return resource?.[ResourceKind] === "cloudflare::WarpDeviceProfile";
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Creates and manages a Cloudflare WARP Device Profile, which defines WARP client
|
|
11
|
+
* settings for specific sets of devices based on matching rules.
|
|
12
|
+
*
|
|
13
|
+
* Device profiles allow you to apply different WARP configurations to different
|
|
14
|
+
* groups of devices based on user identity, groups, operating system, or other criteria.
|
|
15
|
+
*
|
|
16
|
+
* @see https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/configure-warp/device-profiles/
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ## Basic device profile for a user group
|
|
20
|
+
*
|
|
21
|
+
* Create a profile that applies to all devices belonging to the Engineering group
|
|
22
|
+
*
|
|
23
|
+
* const engProfile = await WarpDeviceProfile("engineering", {
|
|
24
|
+
* name: "Engineering Team",
|
|
25
|
+
* match: 'identity.groups.name == "Engineering"',
|
|
26
|
+
* precedence: 100,
|
|
27
|
+
* serviceModeV2: { mode: "warp" },
|
|
28
|
+
* allowedToLeave: false,
|
|
29
|
+
* switchLocked: true
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ## Profile with split tunnel configuration
|
|
34
|
+
*
|
|
35
|
+
* Create a profile that excludes internal network routes from the WARP tunnel
|
|
36
|
+
*
|
|
37
|
+
* const internalProfile = await WarpDeviceProfile("internal-network", {
|
|
38
|
+
* name: "Internal Network Access",
|
|
39
|
+
* match: 'identity.email.ends_with("@company.com")',
|
|
40
|
+
* precedence: 50,
|
|
41
|
+
* serviceModeV2: { mode: "warp" },
|
|
42
|
+
* splitTunnel: {
|
|
43
|
+
* mode: "exclude",
|
|
44
|
+
* entries: [
|
|
45
|
+
* { address: "10.0.0.0/8", description: "Internal network" },
|
|
46
|
+
* { address: "192.168.0.0/16", description: "Local network" }
|
|
47
|
+
* ]
|
|
48
|
+
* }
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ## Profile with include mode split tunnel
|
|
53
|
+
*
|
|
54
|
+
* Only route specific networks through WARP
|
|
55
|
+
*
|
|
56
|
+
* const selectiveProfile = await WarpDeviceProfile("selective", {
|
|
57
|
+
* name: "Selective Routing",
|
|
58
|
+
* match: 'identity.groups.name == "Remote Workers"',
|
|
59
|
+
* precedence: 200,
|
|
60
|
+
* serviceModeV2: { mode: "warp" },
|
|
61
|
+
* splitTunnel: {
|
|
62
|
+
* mode: "include",
|
|
63
|
+
* entries: [
|
|
64
|
+
* { address: "10.0.0.0/8", description: "Company network" },
|
|
65
|
+
* { address: "company.com", description: "Company domain" }
|
|
66
|
+
* ]
|
|
67
|
+
* }
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ## Adopt an existing profile
|
|
72
|
+
*
|
|
73
|
+
* Take over management of an existing device profile
|
|
74
|
+
*
|
|
75
|
+
* const existingProfile = await WarpDeviceProfile("existing", {
|
|
76
|
+
* name: "Existing Profile",
|
|
77
|
+
* adopt: true,
|
|
78
|
+
* match: 'identity.groups.name == "IT"',
|
|
79
|
+
* precedence: 10
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ## Profile with all WARP settings
|
|
84
|
+
*
|
|
85
|
+
* Configure comprehensive WARP client behavior
|
|
86
|
+
*
|
|
87
|
+
* const fullProfile = await WarpDeviceProfile("comprehensive", {
|
|
88
|
+
* name: "Full Configuration",
|
|
89
|
+
* match: 'identity.email == "admin@example.com"',
|
|
90
|
+
* precedence: 1,
|
|
91
|
+
* enabled: true,
|
|
92
|
+
* serviceModeV2: { mode: "warp" },
|
|
93
|
+
* disableAutoFallback: false,
|
|
94
|
+
* allowModeSwitch: false,
|
|
95
|
+
* switchLocked: true,
|
|
96
|
+
* tunnelProtocol: "wireguard",
|
|
97
|
+
* autoConnect: 0,
|
|
98
|
+
* allowedToLeave: false,
|
|
99
|
+
* captivePortal: 180,
|
|
100
|
+
* supportUrl: "https://support.example.com",
|
|
101
|
+
* excludeOfficeIps: true,
|
|
102
|
+
* lanAllowMinutes: 5,
|
|
103
|
+
* lanAllowSubnetSize: 24
|
|
104
|
+
* });
|
|
105
|
+
*/
|
|
106
|
+
export const WarpDeviceProfile = Resource("cloudflare::WarpDeviceProfile", async function (id, props = {}) {
|
|
107
|
+
const api = await createCloudflareApi(props);
|
|
108
|
+
const name = props.name ?? this.output?.name ?? this.scope.createPhysicalName(id);
|
|
109
|
+
const adopt = props.adopt ?? this.scope.adopt;
|
|
110
|
+
if (this.phase === "delete") {
|
|
111
|
+
if (this.output?.policyId && props.delete !== false) {
|
|
112
|
+
await deletePolicy(api, this.output.policyId);
|
|
113
|
+
}
|
|
114
|
+
return this.destroy();
|
|
115
|
+
}
|
|
116
|
+
// Handle replacement for immutable properties
|
|
117
|
+
if (this.phase === "update" && this.output?.name !== name) {
|
|
118
|
+
this.replace();
|
|
119
|
+
}
|
|
120
|
+
let policyId;
|
|
121
|
+
let createdAt = this.output?.createdAt ?? Date.now();
|
|
122
|
+
if (this.phase === "update" && this.output?.policyId) {
|
|
123
|
+
// Update existing policy
|
|
124
|
+
await updatePolicy(api, this.output.policyId, { ...props, name });
|
|
125
|
+
policyId = this.output.policyId;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// Create new policy
|
|
129
|
+
try {
|
|
130
|
+
const result = await createPolicy(api, { ...props, name });
|
|
131
|
+
policyId = result.policy_id ?? result.id;
|
|
132
|
+
createdAt = Date.now();
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
if (adopt &&
|
|
136
|
+
error instanceof CloudflareApiError &&
|
|
137
|
+
(error.status === 400 || error.status === 409) &&
|
|
138
|
+
(error.message.includes("already exists") ||
|
|
139
|
+
error.message.includes("duplicate") ||
|
|
140
|
+
error.message.includes("precedence must be unique"))) {
|
|
141
|
+
logger.log(`WARP device profile '${name}' already exists, adopting it`);
|
|
142
|
+
const existing = await findPolicyByName(api, name);
|
|
143
|
+
if (!existing) {
|
|
144
|
+
throw new Error(`Failed to find existing WARP device profile '${name}' for adoption`);
|
|
145
|
+
}
|
|
146
|
+
policyId = existing.policy_id;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Update split tunnel configuration if provided
|
|
154
|
+
if (props.splitTunnel) {
|
|
155
|
+
await updateSplitTunnel(api, policyId, props.splitTunnel);
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
policyId,
|
|
159
|
+
name,
|
|
160
|
+
description: props.description,
|
|
161
|
+
match: props.match,
|
|
162
|
+
precedence: props.precedence,
|
|
163
|
+
enabled: props.enabled ?? true,
|
|
164
|
+
serviceModeV2: props.serviceModeV2,
|
|
165
|
+
disableAutoFallback: props.disableAutoFallback,
|
|
166
|
+
allowModeSwitch: props.allowModeSwitch,
|
|
167
|
+
switchLocked: props.switchLocked,
|
|
168
|
+
tunnelProtocol: props.tunnelProtocol,
|
|
169
|
+
autoConnect: props.autoConnect,
|
|
170
|
+
allowedToLeave: props.allowedToLeave,
|
|
171
|
+
captivePortal: props.captivePortal,
|
|
172
|
+
supportUrl: props.supportUrl,
|
|
173
|
+
excludeOfficeIps: props.excludeOfficeIps,
|
|
174
|
+
lanAllowMinutes: props.lanAllowMinutes,
|
|
175
|
+
lanAllowSubnetSize: props.lanAllowSubnetSize,
|
|
176
|
+
splitTunnel: props.splitTunnel,
|
|
177
|
+
createdAt,
|
|
178
|
+
modifiedAt: Date.now(),
|
|
179
|
+
};
|
|
180
|
+
});
|
|
181
|
+
async function createPolicy(api, props) {
|
|
182
|
+
const requestBody = buildRequestBody(props);
|
|
183
|
+
const response = await api.post(`/accounts/${api.accountId}/devices/policy`, requestBody);
|
|
184
|
+
if (!response.ok) {
|
|
185
|
+
await handleApiError(response, "create", "warp_device_profile", props.name);
|
|
186
|
+
}
|
|
187
|
+
return await extractCloudflareResult(`create WARP device profile "${props.name}"`, Promise.resolve(response));
|
|
188
|
+
}
|
|
189
|
+
async function updatePolicy(api, policyId, props) {
|
|
190
|
+
const requestBody = buildRequestBody(props);
|
|
191
|
+
const response = await api.patch(`/accounts/${api.accountId}/devices/policy/${policyId}`, requestBody);
|
|
192
|
+
if (!response.ok) {
|
|
193
|
+
await handleApiError(response, "update", "warp_device_profile", policyId);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async function deletePolicy(api, policyId) {
|
|
197
|
+
const response = await api.delete(`/accounts/${api.accountId}/devices/policy/${policyId}`);
|
|
198
|
+
if (!response.ok && response.status !== 404) {
|
|
199
|
+
await handleApiError(response, "delete", "warp_device_profile", policyId);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
async function findPolicyByName(api, name) {
|
|
203
|
+
const response = await api.get(`/accounts/${api.accountId}/devices/policies`);
|
|
204
|
+
if (!response.ok) {
|
|
205
|
+
await handleApiError(response, "list", "warp_device_profile", "all");
|
|
206
|
+
}
|
|
207
|
+
const data = (await response.json());
|
|
208
|
+
const policy = data.result?.find((p) => p.name === name);
|
|
209
|
+
if (!policy)
|
|
210
|
+
return null;
|
|
211
|
+
return {
|
|
212
|
+
policy_id: policy.policy_id ?? policy.id,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
async function updateSplitTunnel(api, policyId, config) {
|
|
216
|
+
const routes = config.entries.map((entry) => ({
|
|
217
|
+
...(entry.address && { address: entry.address }),
|
|
218
|
+
...(entry.host && { host: entry.host }),
|
|
219
|
+
...(entry.description && { description: entry.description }),
|
|
220
|
+
}));
|
|
221
|
+
if (config.mode === "include") {
|
|
222
|
+
const response = await api.put(`/accounts/${api.accountId}/devices/policy/${policyId}/include`, routes);
|
|
223
|
+
if (!response.ok) {
|
|
224
|
+
await handleApiError(response, "update split tunnel includes", "warp_device_profile", policyId);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
const response = await api.put(`/accounts/${api.accountId}/devices/policy/${policyId}/exclude`, routes);
|
|
229
|
+
if (!response.ok) {
|
|
230
|
+
await handleApiError(response, "update split tunnel excludes", "warp_device_profile", policyId);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function buildRequestBody(props) {
|
|
235
|
+
const requestBody = {
|
|
236
|
+
name: props.name,
|
|
237
|
+
};
|
|
238
|
+
if (props.description !== undefined) {
|
|
239
|
+
requestBody.description = props.description;
|
|
240
|
+
}
|
|
241
|
+
if (props.match !== undefined) {
|
|
242
|
+
requestBody.match = props.match;
|
|
243
|
+
}
|
|
244
|
+
if (props.precedence !== undefined) {
|
|
245
|
+
requestBody.precedence = props.precedence;
|
|
246
|
+
}
|
|
247
|
+
if (props.enabled !== undefined) {
|
|
248
|
+
requestBody.enabled = props.enabled;
|
|
249
|
+
}
|
|
250
|
+
if (props.serviceModeV2) {
|
|
251
|
+
requestBody.service_mode_v2 = {
|
|
252
|
+
mode: props.serviceModeV2.mode,
|
|
253
|
+
...(props.serviceModeV2.port && { port: props.serviceModeV2.port }),
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
if (props.disableAutoFallback !== undefined) {
|
|
257
|
+
requestBody.disable_auto_fallback = props.disableAutoFallback;
|
|
258
|
+
}
|
|
259
|
+
if (props.allowModeSwitch !== undefined) {
|
|
260
|
+
requestBody.allow_mode_switch = props.allowModeSwitch;
|
|
261
|
+
}
|
|
262
|
+
if (props.switchLocked !== undefined) {
|
|
263
|
+
requestBody.switch_locked = props.switchLocked;
|
|
264
|
+
}
|
|
265
|
+
if (props.tunnelProtocol !== undefined) {
|
|
266
|
+
requestBody.tunnel_protocol = props.tunnelProtocol;
|
|
267
|
+
}
|
|
268
|
+
if (props.autoConnect !== undefined) {
|
|
269
|
+
requestBody.auto_connect = props.autoConnect;
|
|
270
|
+
}
|
|
271
|
+
if (props.allowedToLeave !== undefined) {
|
|
272
|
+
requestBody.allowed_to_leave = props.allowedToLeave;
|
|
273
|
+
}
|
|
274
|
+
if (props.captivePortal !== undefined) {
|
|
275
|
+
requestBody.captive_portal = props.captivePortal;
|
|
276
|
+
}
|
|
277
|
+
if (props.supportUrl !== undefined) {
|
|
278
|
+
requestBody.support_url = props.supportUrl;
|
|
279
|
+
}
|
|
280
|
+
if (props.excludeOfficeIps !== undefined) {
|
|
281
|
+
requestBody.exclude_office_ips = props.excludeOfficeIps;
|
|
282
|
+
}
|
|
283
|
+
if (props.lanAllowMinutes !== undefined) {
|
|
284
|
+
requestBody.lan_allow_minutes = props.lanAllowMinutes;
|
|
285
|
+
}
|
|
286
|
+
if (props.lanAllowSubnetSize !== undefined) {
|
|
287
|
+
requestBody.lan_allow_subnet_size = props.lanAllowSubnetSize;
|
|
288
|
+
}
|
|
289
|
+
return requestBody;
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=warp-device-profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warp-device-profile.js","sourceRoot":"","sources":["../../src/cloudflare/warp-device-profile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EACL,mBAAmB,GAGpB,MAAM,UAAU,CAAC;AAkLlB,MAAM,UAAU,mBAAmB,CACjC,QAAa;IAEb,OAAO,QAAQ,EAAE,CAAC,YAAY,CAAC,KAAK,+BAA+B,CAAC;AACtE,CAAC;AA8BD;;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@ export declare class RootScopeStateAttemptError extends Error {
|
|
|
12
12
|
}
|
|
13
13
|
export interface ScopeOptions extends ProviderCredentials {
|
|
14
14
|
stage?: string;
|
|
15
|
-
parent: Scope | undefined;
|
|
15
|
+
parent: Scope | undefined | null;
|
|
16
16
|
scopeName: string;
|
|
17
17
|
password?: string;
|
|
18
18
|
stateStore?: StateStoreType;
|
package/lib/scope.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAIrD,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAuB,eAAe,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAEL,UAAU,EAIV,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAS,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGpE,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAK7C,qBAAa,0BAA2B,SAAQ,KAAK;;CAIpD;AAED,MAAM,WAAW,YAAa,SAAQ,mBAAmB;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,KAAK,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"scope.d.ts","sourceRoot":"","sources":["../src/scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAIrD,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,KAAK,EAAE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C,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE;IAkFtD,uBAAuB;IA6CpC;;OAEG;IACI,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAmBjD;;;OAGG;IACU,OAAO;IAMpB;;;OAGG;IACI,SAAS,CAAC,EAAE,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC;IAQxC;;OAEG;IACI,QAAQ;CAQhB;AAED,OAAO,CAAC,MAAM,CAAC;IAGb,IAAI,iBAAiB,EAAE,OAAO,KAAK,CAAC;CACrC"}
|
package/lib/scope.js
CHANGED
|
@@ -90,7 +90,7 @@ export class Scope {
|
|
|
90
90
|
const { scopeName, parent, stage, password, stateStore, quiet, phase, local, watch, tunnel, force, destroyStrategy, logger, adopt, dotAlchemy, rootDir, isSelected, noTrack, profile, startedAt, ...providerCredentials } = options;
|
|
91
91
|
this.scopeName = scopeName;
|
|
92
92
|
this.name = this.scopeName;
|
|
93
|
-
this.parent = parent ?? Scope.getScope();
|
|
93
|
+
this.parent = parent === null ? undefined : (parent ?? Scope.getScope());
|
|
94
94
|
this.rootDir = rootDir ?? this.parent?.rootDir ?? ALCHEMY_ROOT;
|
|
95
95
|
this.isSelected = isSelected ?? this.parent?.isSelected;
|
|
96
96
|
this.startedAt = startedAt ?? this.parent?.startedAt ?? performance.now();
|