alchemy 0.5.1 → 0.6.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 (44) hide show
  1. package/lib/cloudflare/account-api-token.d.ts +6 -1
  2. package/lib/cloudflare/account-api-token.js +5 -1
  3. package/lib/cloudflare/account-id.d.ts +5 -1
  4. package/lib/cloudflare/account-id.js +5 -0
  5. package/lib/cloudflare/api-error.d.ts +32 -0
  6. package/lib/cloudflare/api-error.js +47 -0
  7. package/lib/cloudflare/api.d.ts +16 -49
  8. package/lib/cloudflare/api.js +50 -151
  9. package/lib/cloudflare/auth.d.ts +55 -38
  10. package/lib/cloudflare/auth.js +148 -77
  11. package/lib/cloudflare/bucket.d.ts +30 -5
  12. package/lib/cloudflare/bucket.js +12 -11
  13. package/lib/cloudflare/custom-domain.d.ts +2 -1
  14. package/lib/cloudflare/custom-domain.js +3 -2
  15. package/lib/cloudflare/dns-records.d.ts +2 -1
  16. package/lib/cloudflare/dns-records.js +2 -2
  17. package/lib/cloudflare/kv-namespace.d.ts +7 -1
  18. package/lib/cloudflare/kv-namespace.js +72 -71
  19. package/lib/cloudflare/permission-groups.d.ts +4 -0
  20. package/lib/cloudflare/permission-groups.js +5 -1
  21. package/lib/cloudflare/r2-rest-state-store.d.ts +3 -17
  22. package/lib/cloudflare/r2-rest-state-store.js +4 -12
  23. package/lib/cloudflare/worker.d.ts +2 -6
  24. package/lib/cloudflare/worker.js +4 -62
  25. package/lib/cloudflare/zone.d.ts +2 -6
  26. package/lib/cloudflare/zone.js +1 -3
  27. package/lib/index.d.ts +1 -0
  28. package/lib/internal/docs/providers.js +0 -7
  29. package/package.json +5 -1
  30. package/src/cloudflare/account-api-token.ts +7 -3
  31. package/src/cloudflare/account-id.ts +12 -0
  32. package/src/cloudflare/api-error.ts +58 -0
  33. package/src/cloudflare/api.ts +70 -219
  34. package/src/cloudflare/auth.ts +262 -119
  35. package/src/cloudflare/bucket.ts +52 -29
  36. package/src/cloudflare/custom-domain.ts +8 -3
  37. package/src/cloudflare/dns-records.ts +7 -3
  38. package/src/cloudflare/kv-namespace.ts +117 -105
  39. package/src/cloudflare/permission-groups.ts +5 -1
  40. package/src/cloudflare/r2-rest-state-store.ts +8 -31
  41. package/src/cloudflare/worker.ts +11 -103
  42. package/src/cloudflare/zone.ts +17 -25
  43. package/src/index.ts +1 -0
  44. package/src/internal/docs/providers.ts +0 -7
@@ -1,6 +1,7 @@
1
1
  import type { Context } from "../context";
2
2
  import { Resource } from "../resource";
3
3
  import { Secret } from "../secret";
4
+ import { type CloudflareApiOptions } from "./api";
4
5
  /**
5
6
  * Permission group for a token policy
6
7
  */
@@ -52,7 +53,7 @@ export interface TokenCondition {
52
53
  /**
53
54
  * Properties for creating or updating an Account API Token
54
55
  */
55
- export interface AccountApiTokenProps {
56
+ export interface AccountApiTokenProps extends CloudflareApiOptions {
56
57
  /**
57
58
  * Name of the token
58
59
  */
@@ -113,6 +114,10 @@ export interface AccountApiToken extends Resource<"cloudflare::AccountApiToken">
113
114
  /**
114
115
  * Creates a Cloudflare Account API Token with specified permissions.
115
116
  *
117
+ * Note: Requires a Cloudflare API Key or Token with admin-level account access.
118
+ * The OAuth token from `wrangler login` is NOT sufficient for this operation.
119
+ * You must use an API token with permission to manage account API tokens.
120
+ *
116
121
  * @see https://developers.cloudflare.com/api/resources/accounts/subresources/tokens/methods/create/
117
122
  *
118
123
  * @example
@@ -6,6 +6,10 @@ import { createCloudflareApi } from "./api";
6
6
  /**
7
7
  * Creates a Cloudflare Account API Token with specified permissions.
8
8
  *
9
+ * Note: Requires a Cloudflare API Key or Token with admin-level account access.
10
+ * The OAuth token from `wrangler login` is NOT sufficient for this operation.
11
+ * You must use an API token with permission to manage account API tokens.
12
+ *
9
13
  * @see https://developers.cloudflare.com/api/resources/accounts/subresources/tokens/methods/create/
10
14
  *
11
15
  * @example
@@ -60,7 +64,7 @@ import { createCloudflareApi } from "./api";
60
64
  */
61
65
  export const AccountApiToken = Resource("cloudflare::AccountApiToken", async function (id, props) {
62
66
  // Create Cloudflare API client with automatic account discovery
63
- const api = await createCloudflareApi();
67
+ const api = await createCloudflareApi(props);
64
68
  if (this.phase === "delete") {
65
69
  // Delete token if we have an ID
66
70
  if (this.output?.id) {
@@ -1 +1,5 @@
1
- export {};
1
+ import { type CloudflareAuthOptions } from "./auth";
2
+ export type CloudflareAccountId = string & {
3
+ readonly __brand: "CloudflareAccountId";
4
+ };
5
+ export declare function CloudflareAccountId(options: CloudflareAuthOptions): Promise<CloudflareAccountId>;
@@ -0,0 +1,5 @@
1
+ import { getCloudflareUserInfo } from "./auth";
2
+ export async function CloudflareAccountId(options) {
3
+ const userInfo = await getCloudflareUserInfo(options);
4
+ return userInfo.accounts[0].id;
5
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Custom error class for Cloudflare API errors
3
+ * Includes HTTP status information from the Response
4
+ */
5
+ export declare class CloudflareApiError extends Error {
6
+ /**
7
+ * HTTP status code
8
+ */
9
+ status: number;
10
+ /**
11
+ * HTTP status text
12
+ */
13
+ statusText: string;
14
+ /**
15
+ * Raw error data from the API
16
+ */
17
+ errorData?: any;
18
+ /**
19
+ * Create a new CloudflareApiError
20
+ */
21
+ constructor(message: string, response: Response, errorData?: any);
22
+ }
23
+ /**
24
+ * Helper function to handle API errors
25
+ *
26
+ * @param response The fetch Response object
27
+ * @param action The action being performed (e.g., "creating", "deleting")
28
+ * @param resourceType The type of resource being acted upon (e.g., "R2 bucket", "Worker")
29
+ * @param resourceName The name/identifier of the specific resource
30
+ * @returns Never returns - always throws an error
31
+ */
32
+ export declare function handleApiError(response: Response, action: string, resourceType: string, resourceName: string): Promise<never>;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Custom error class for Cloudflare API errors
3
+ * Includes HTTP status information from the Response
4
+ */
5
+ export class CloudflareApiError extends Error {
6
+ /**
7
+ * HTTP status code
8
+ */
9
+ status;
10
+ /**
11
+ * HTTP status text
12
+ */
13
+ statusText;
14
+ /**
15
+ * Raw error data from the API
16
+ */
17
+ errorData;
18
+ /**
19
+ * Create a new CloudflareApiError
20
+ */
21
+ constructor(message, response, errorData) {
22
+ super(message);
23
+ this.name = "CloudflareApiError";
24
+ this.status = response.status;
25
+ this.statusText = response.statusText;
26
+ this.errorData = errorData;
27
+ // Ensure instanceof works correctly
28
+ Object.setPrototypeOf(this, CloudflareApiError.prototype);
29
+ }
30
+ }
31
+ /**
32
+ * Helper function to handle API errors
33
+ *
34
+ * @param response The fetch Response object
35
+ * @param action The action being performed (e.g., "creating", "deleting")
36
+ * @param resourceType The type of resource being acted upon (e.g., "R2 bucket", "Worker")
37
+ * @param resourceName The name/identifier of the specific resource
38
+ * @returns Never returns - always throws an error
39
+ */
40
+ export async function handleApiError(response, action, resourceType, resourceName) {
41
+ const json = await response.json();
42
+ const errors = json.errors || [
43
+ { message: response.statusText },
44
+ ];
45
+ const errorMessage = `Error ${action} ${resourceType} '${resourceName}': ${errors[0]?.message || response.statusText}`;
46
+ throw new CloudflareApiError(errorMessage, response, errors);
47
+ }
@@ -3,10 +3,20 @@ import type { Secret } from "../secret";
3
3
  * Options for Cloudflare API requests
4
4
  */
5
5
  export interface CloudflareApiOptions {
6
+ /**
7
+ * Base URL for Cloudflare API
8
+ *
9
+ * @default https://api.cloudflare.com/client/v4
10
+ */
11
+ baseUrl?: string;
6
12
  /**
7
13
  * API Key to use (overrides CLOUDFLARE_API_KEY env var)
8
14
  */
9
15
  apiKey?: Secret;
16
+ /**
17
+ * API Token to use (overrides CLOUDFLARE_API_TOKEN env var)
18
+ */
19
+ apiToken?: Secret;
10
20
  /**
11
21
  * Account ID to use (overrides CLOUDFLARE_ACCOUNT_ID env var)
12
22
  * If not provided, will be automatically retrieved from the Cloudflare API
@@ -22,65 +32,20 @@ export interface CloudflareApiOptions {
22
32
  */
23
33
  email?: string;
24
34
  }
25
- /**
26
- * Custom error class for Cloudflare API errors
27
- * Includes HTTP status information from the Response
28
- */
29
- export declare class CloudflareApiError extends Error {
30
- /**
31
- * HTTP status code
32
- */
33
- status: number;
34
- /**
35
- * HTTP status text
36
- */
37
- statusText: string;
38
- /**
39
- * Raw error data from the API
40
- */
41
- errorData?: any;
42
- /**
43
- * Create a new CloudflareApiError
44
- */
45
- constructor(message: string, response: Response, errorData?: any);
46
- }
47
- /**
48
- * Helper function to handle API errors
49
- *
50
- * @param response The fetch Response object
51
- * @param action The action being performed (e.g., "creating", "deleting")
52
- * @param resourceType The type of resource being acted upon (e.g., "R2 bucket", "Worker")
53
- * @param resourceName The name/identifier of the specific resource
54
- * @returns Never returns - always throws an error
55
- */
56
- export declare function handleApiError(response: Response, action: string, resourceType: string, resourceName: string): Promise<never>;
57
35
  /**
58
36
  * Creates a CloudflareApi instance with automatic account ID discovery if not provided
59
37
  *
60
38
  * @param options API options
61
39
  * @returns Promise resolving to a CloudflareApi instance
62
40
  */
63
- export declare function createCloudflareApi(options?: CloudflareApiOptions): Promise<CloudflareApi>;
64
- export type CloudflareAccountId = string & {
65
- readonly __brand: "CloudflareAccountId";
66
- };
67
- export declare function CloudflareAccountId(options?: CloudflareApiOptions): Promise<CloudflareAccountId>;
41
+ export declare function createCloudflareApi(options?: Partial<CloudflareApiOptions>): Promise<CloudflareApi>;
68
42
  /**
69
43
  * Cloudflare API client using raw fetch
70
44
  */
71
45
  export declare class CloudflareApi {
72
- /** Base URL for Cloudflare API */
73
- readonly baseUrl: string;
74
- /** Cloudflare API Key */
75
- readonly apiKey: string;
76
- /** Cloudflare account ID */
46
+ private readonly options;
77
47
  readonly accountId: string;
78
- /** Cloudflare zone ID (if provided) */
79
- readonly zoneId: string | null;
80
- /** User email (when using API Key auth) */
81
- readonly email?: string;
82
- /** Auth options for making requests */
83
- private readonly authOptions;
48
+ readonly baseUrl: string;
84
49
  /**
85
50
  * Create a new Cloudflare API client
86
51
  * Use createCloudflareApi factory function instead of direct constructor
@@ -88,7 +53,9 @@ export declare class CloudflareApi {
88
53
  *
89
54
  * @param options API options
90
55
  */
91
- constructor(options?: CloudflareApiOptions);
56
+ constructor(options: CloudflareApiOptions & {
57
+ accountId: string;
58
+ });
92
59
  /**
93
60
  * Make a fetch request to the Cloudflare API
94
61
  *
@@ -1,50 +1,5 @@
1
- import { getCloudflareHeaders } from "./auth";
2
- /**
3
- * Custom error class for Cloudflare API errors
4
- * Includes HTTP status information from the Response
5
- */
6
- export class CloudflareApiError extends Error {
7
- /**
8
- * HTTP status code
9
- */
10
- status;
11
- /**
12
- * HTTP status text
13
- */
14
- statusText;
15
- /**
16
- * Raw error data from the API
17
- */
18
- errorData;
19
- /**
20
- * Create a new CloudflareApiError
21
- */
22
- constructor(message, response, errorData) {
23
- super(message);
24
- this.name = "CloudflareApiError";
25
- this.status = response.status;
26
- this.statusText = response.statusText;
27
- this.errorData = errorData;
28
- // Ensure instanceof works correctly
29
- Object.setPrototypeOf(this, CloudflareApiError.prototype);
30
- }
31
- }
32
- /**
33
- * Helper function to handle API errors
34
- *
35
- * @param response The fetch Response object
36
- * @param action The action being performed (e.g., "creating", "deleting")
37
- * @param resourceType The type of resource being acted upon (e.g., "R2 bucket", "Worker")
38
- * @param resourceName The name/identifier of the specific resource
39
- * @returns Never returns - always throws an error
40
- */
41
- export async function handleApiError(response, action, resourceType, resourceName) {
42
- const json = await response.json();
43
- console.log(json);
44
- const errorData = json.errors || [{ message: response.statusText }];
45
- const errorMessage = `Error ${action} ${resourceType} '${resourceName}': ${errorData.errors?.[0]?.message || response.statusText}`;
46
- throw new CloudflareApiError(errorMessage, response, errorData);
47
- }
1
+ import { withExponentialBackoff } from "../util/retry";
2
+ import { getCloudflareAuthHeaders, getCloudflareUserInfo } from "./auth";
48
3
  /**
49
4
  * Creates a CloudflareApi instance with automatic account ID discovery if not provided
50
5
  *
@@ -52,38 +7,23 @@ export async function handleApiError(response, action, resourceType, resourceNam
52
7
  * @returns Promise resolving to a CloudflareApi instance
53
8
  */
54
9
  export async function createCloudflareApi(options = {}) {
55
- try {
56
- return new CloudflareApi({
57
- ...options,
58
- accountId: await CloudflareAccountId(options),
59
- });
60
- }
61
- catch (error) {
62
- console.error("Error during Cloudflare account ID discovery:", error);
63
- throw new Error("Failed to automatically discover Cloudflare account ID. Please provide an account ID explicitly or ensure your API token/key has sufficient permissions.");
64
- }
65
- }
66
- export async function CloudflareAccountId(options = {}) {
67
- return (options.accountId ||
68
- process.env.CLOUDFLARE_ACCOUNT_ID ||
69
- (await fetchAccountId()));
10
+ const userInfo = await getCloudflareUserInfo(options);
11
+ return new CloudflareApi({
12
+ baseUrl: options.baseUrl,
13
+ accountId: options.accountId ?? userInfo.accounts[0].id,
14
+ email: userInfo.email,
15
+ apiKey: userInfo.apiKey,
16
+ apiToken: userInfo.apiToken,
17
+ zoneId: options.zoneId,
18
+ });
70
19
  }
71
20
  /**
72
21
  * Cloudflare API client using raw fetch
73
22
  */
74
23
  export class CloudflareApi {
75
- /** Base URL for Cloudflare API */
76
- baseUrl;
77
- /** Cloudflare API Key */
78
- apiKey;
79
- /** Cloudflare account ID */
24
+ options;
80
25
  accountId;
81
- /** Cloudflare zone ID (if provided) */
82
- zoneId;
83
- /** User email (when using API Key auth) */
84
- email;
85
- /** Auth options for making requests */
86
- authOptions;
26
+ baseUrl;
87
27
  /**
88
28
  * Create a new Cloudflare API client
89
29
  * Use createCloudflareApi factory function instead of direct constructor
@@ -91,31 +31,10 @@ export class CloudflareApi {
91
31
  *
92
32
  * @param options API options
93
33
  */
94
- constructor(options = {}) {
95
- this.baseUrl = "https://api.cloudflare.com/client/v4";
96
- const apiKey = options.apiKey?.unencrypted ||
97
- process.env.CLOUDFLARE_API_KEY ||
98
- undefined;
99
- if (!apiKey) {
100
- throw new Error("No API key provided. Use createCloudflareApi() instead for automatic account discovery.");
101
- }
102
- this.apiKey = apiKey;
103
- this.email = options.email || process.env.CLOUDFLARE_EMAIL;
104
- if (!this.email) {
105
- throw new Error("No email provided. Use createCloudflareApi() instead for automatic account discovery.");
106
- }
107
- // Get account ID from options or environment
108
- this.accountId =
109
- options.accountId || process.env.CLOUDFLARE_ACCOUNT_ID || "";
110
- if (!this.accountId) {
111
- throw new Error("No account ID provided. Use createCloudflareApi() instead for automatic account discovery.");
112
- }
113
- // Zone ID is optional for some operations
114
- this.zoneId = options.zoneId || process.env.CLOUDFLARE_ZONE_ID || null;
115
- // Store auth options for later use
116
- this.authOptions = {
117
- email: this.email,
118
- };
34
+ constructor(options) {
35
+ this.options = options;
36
+ this.accountId = options.accountId;
37
+ this.baseUrl = options.baseUrl ?? "https://api.cloudflare.com/client/v4";
119
38
  }
120
39
  /**
121
40
  * Make a fetch request to the Cloudflare API
@@ -125,37 +44,45 @@ export class CloudflareApi {
125
44
  * @returns Raw Response object from fetch
126
45
  */
127
46
  async fetch(path, init = {}) {
128
- // Get content type from init headers or default to application/json
129
- let contentType = "application/json";
130
- if (init.headers) {
131
- const initHeaders = init.headers;
132
- if (initHeaders["Content-Type"]) {
133
- contentType = initHeaders["Content-Type"];
134
- }
135
- }
136
- // Get auth headers (async now)
137
- const authHeaders = await getCloudflareHeaders(contentType, this.authOptions);
138
- // Combine all headers
139
- const combinedHeaders = {
140
- ...authHeaders,
47
+ let headers = {
48
+ "Content-Type": "application/json",
141
49
  };
142
- // Add headers from init if provided
143
- if (init.headers) {
144
- const initHeadersObj = init.headers;
145
- Object.keys(initHeadersObj).forEach((key) => {
146
- combinedHeaders[key] = initHeadersObj[key];
50
+ if (Array.isArray(init.headers)) {
51
+ init.headers.forEach(([key, value]) => {
52
+ headers[key] = value;
53
+ });
54
+ }
55
+ else if (init.headers instanceof Headers) {
56
+ init.headers.forEach((value, key) => {
57
+ headers[key] = value;
147
58
  });
148
59
  }
149
- // If using FormData, remove Content-Type to let browser set it with boundary
60
+ else if (init.headers) {
61
+ headers = init.headers;
62
+ }
63
+ headers = {
64
+ ...(await getCloudflareAuthHeaders(this.options)),
65
+ ...headers,
66
+ };
67
+ // TODO(sam): is this necessary?
150
68
  if (init.body instanceof FormData) {
151
- delete combinedHeaders["Content-Type"];
69
+ delete headers["Content-Type"];
152
70
  }
153
- const url = `${this.baseUrl}${path}`;
154
- // Make the request
155
- return fetch(url, {
71
+ // Use withExponentialBackoff for automatic retry on network errors
72
+ return withExponentialBackoff(() => fetch(`${this.baseUrl}${path}`, {
156
73
  ...init,
157
- headers: combinedHeaders,
158
- });
74
+ headers,
75
+ }), (error) => {
76
+ // Only retry on network-related errors
77
+ const errorMsg = error.message || "";
78
+ const isNetworkError = errorMsg.includes("socket connection was closed") ||
79
+ errorMsg.includes("ECONNRESET") ||
80
+ errorMsg.includes("ETIMEDOUT") ||
81
+ errorMsg.includes("ECONNREFUSED");
82
+ return isNetworkError;
83
+ }, 5, // Maximum 5 attempts (1 initial + 4 retries)
84
+ 1000 // Start with 1s delay, will exponentially increase
85
+ );
159
86
  }
160
87
  /**
161
88
  * Helper for GET requests
@@ -204,31 +131,3 @@ export class CloudflareApi {
204
131
  return this.fetch(path, { ...init, method: "DELETE" });
205
132
  }
206
133
  }
207
- /**
208
- * Create a temporary API client for bootstrapping
209
- * This client can only be used to fetch the account ID
210
- */
211
- async function fetchAccountId() {
212
- // Create a minimal API client for bootstrapping
213
- const baseUrl = "https://api.cloudflare.com/client/v4";
214
- // Get content type and auth headers
215
- const authHeaders = await getCloudflareHeaders("application/json");
216
- // Make the request to get accounts
217
- const response = await fetch(`${baseUrl}/accounts`, {
218
- method: "GET",
219
- headers: authHeaders,
220
- });
221
- if (!response.ok) {
222
- const errorData = await response.json().catch(() => ({
223
- errors: [{ message: response.statusText }],
224
- }));
225
- throw new Error(`Error fetching Cloudflare accounts: ${errorData.errors?.[0]?.message || response.statusText}`);
226
- }
227
- const data = await response.json();
228
- const accounts = data.result;
229
- if (!accounts || accounts.length === 0) {
230
- throw new Error("No Cloudflare accounts found. Check your API token/key permissions.");
231
- }
232
- // Return the first account ID
233
- return accounts[0].id;
234
- }
@@ -1,51 +1,68 @@
1
+ import type { Secret } from "../secret";
2
+ import type { CloudflareAccountId } from "./account-id";
1
3
  /**
2
4
  * Authentication options for Cloudflare API
3
5
  */
4
6
  export interface CloudflareAuthOptions {
5
7
  /**
6
- * If true, throw an error when no authentication is found
7
- * @default true
8
+ * API Key to use with API Key
8
9
  */
9
- required?: boolean;
10
+ apiKey?: Secret;
11
+ /**
12
+ * API Token to use with API Key
13
+ */
14
+ apiToken?: Secret;
10
15
  /**
11
16
  * Email to use with API Key
12
17
  * If not provided, will attempt to discover from Cloudflare API
13
18
  */
14
19
  email?: string;
15
20
  }
16
- /**
17
- * Authentication headers for Cloudflare API
18
- */
19
- export interface CloudflareAuthHeaders {
20
- /**
21
- * Authentication headers to use with fetch
22
- */
23
- headers: Record<string, string>;
24
- /**
25
- * Type of authentication being used
26
- */
27
- type: "token" | "key" | "none";
28
- /**
29
- * User email (only present when using API Key auth)
30
- */
31
- email?: string;
21
+ export interface CloudflareAccount {
22
+ name: string;
23
+ id: CloudflareAccountId;
24
+ type: "standard" | "zero_rating" | "full_control";
25
+ settings: {
26
+ enforce_twofactor: boolean;
27
+ api_access_enabled: null;
28
+ access_approval_expiry: null;
29
+ abuse_contact_email: null;
30
+ };
31
+ legacy_flags: {
32
+ enterprise_zone_quota: {
33
+ maximum: number;
34
+ current: number;
35
+ available: number;
36
+ };
37
+ };
32
38
  }
33
- /**
34
- * Get authentication headers for Cloudflare API
35
- *
36
- * Priority:
37
- * 1. API Token (CLOUDFLARE_API_TOKEN) - Recommended by Cloudflare
38
- * 2. API Key (CLOUDFLARE_API_KEY) - Will attempt to discover email automatically
39
- *
40
- * @param options Authentication options
41
- * @returns Authentication headers
42
- */
43
- export declare function getCloudflareAuth(options?: CloudflareAuthOptions): Promise<CloudflareAuthHeaders>;
44
- /**
45
- * Get headers for a Cloudflare API request, including content-type
46
- *
47
- * @param contentType Content type for the request
48
- * @param options Authentication options
49
- * @returns Complete headers for the request
50
- */
51
- export declare function getCloudflareHeaders(contentType?: string, options?: CloudflareAuthOptions): Promise<Record<string, string>>;
39
+ export interface CloudflareUserInfo {
40
+ apiToken?: Secret;
41
+ apiKey?: Secret;
42
+ email: string;
43
+ username: string;
44
+ accounts: CloudflareAccount[];
45
+ organizations: CloudflareOrganization[];
46
+ tokenPermissions: string[] | undefined;
47
+ first_name: string | null;
48
+ last_name: string | null;
49
+ telephone: string | null;
50
+ country: string | null;
51
+ zipcode: string | null;
52
+ two_factor_authentication_enabled: boolean;
53
+ two_factor_authentication_locked: boolean;
54
+ has_pro_zones: boolean;
55
+ has_business_zones: boolean;
56
+ has_enterprise_zones: boolean;
57
+ suspended: boolean;
58
+ betas: string[];
59
+ }
60
+ export interface CloudflareOrganization {
61
+ id: string;
62
+ name: string;
63
+ status: string;
64
+ permissions: string[];
65
+ roles: string[];
66
+ }
67
+ export declare function getCloudflareUserInfo(options: CloudflareAuthOptions): Promise<CloudflareUserInfo>;
68
+ export declare function getCloudflareAuthHeaders(options?: CloudflareAuthOptions): Promise<Record<string, string>>;