alchemy 0.13.0 → 0.14.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 (80) hide show
  1. package/lib/apply.d.ts.map +1 -1
  2. package/lib/apply.js +0 -1
  3. package/lib/apply.js.map +1 -1
  4. package/lib/cloudflare/api.d.ts +5 -5
  5. package/lib/cloudflare/api.d.ts.map +1 -1
  6. package/lib/cloudflare/api.js +51 -10
  7. package/lib/cloudflare/api.js.map +1 -1
  8. package/lib/cloudflare/auth.d.ts +24 -55
  9. package/lib/cloudflare/auth.d.ts.map +1 -1
  10. package/lib/cloudflare/auth.js +15 -72
  11. package/lib/cloudflare/auth.js.map +1 -1
  12. package/lib/cloudflare/bundle/alias-plugin.d.ts +6 -0
  13. package/lib/cloudflare/bundle/alias-plugin.d.ts.map +1 -0
  14. package/lib/cloudflare/bundle/alias-plugin.js +36 -0
  15. package/lib/cloudflare/bundle/alias-plugin.js.map +1 -0
  16. package/lib/cloudflare/bundle/build-failures.d.ts +12 -0
  17. package/lib/cloudflare/bundle/build-failures.d.ts.map +1 -0
  18. package/lib/cloudflare/bundle/build-failures.js +45 -0
  19. package/lib/cloudflare/bundle/build-failures.js.map +1 -0
  20. package/lib/cloudflare/bundle/bundle-worker.d.ts +7 -0
  21. package/lib/cloudflare/bundle/bundle-worker.d.ts.map +1 -0
  22. package/lib/cloudflare/bundle/bundle-worker.js +69 -0
  23. package/lib/cloudflare/bundle/bundle-worker.js.map +1 -0
  24. package/lib/cloudflare/bundle/external.d.ts +1 -0
  25. package/lib/cloudflare/bundle/external.d.ts.map +1 -1
  26. package/lib/cloudflare/bundle/external.js +8 -1
  27. package/lib/cloudflare/bundle/external.js.map +1 -1
  28. package/lib/cloudflare/bundle/local-dev-cloudflare-shim.d.ts +1 -1
  29. package/lib/cloudflare/bundle/local-dev-cloudflare-shim.d.ts.map +1 -1
  30. package/lib/cloudflare/bundle/local-dev-cloudflare-shim.js +6 -6
  31. package/lib/cloudflare/bundle/local-dev-cloudflare-shim.js.map +1 -1
  32. package/lib/cloudflare/bundle/nodejs-compat-mode.d.ts +17 -0
  33. package/lib/cloudflare/bundle/nodejs-compat-mode.d.ts.map +1 -0
  34. package/lib/cloudflare/bundle/nodejs-compat-mode.js +27 -0
  35. package/lib/cloudflare/bundle/nodejs-compat-mode.js.map +1 -0
  36. package/lib/cloudflare/bundle/nodejs-compat.d.ts +11 -0
  37. package/lib/cloudflare/bundle/nodejs-compat.d.ts.map +1 -0
  38. package/lib/cloudflare/bundle/{hybrid-nodejs-compat.js → nodejs-compat.js} +6 -5
  39. package/lib/cloudflare/bundle/nodejs-compat.js.map +1 -0
  40. package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
  41. package/lib/cloudflare/queue-consumer.js +0 -4
  42. package/lib/cloudflare/queue-consumer.js.map +1 -1
  43. package/lib/cloudflare/user.d.ts +51 -0
  44. package/lib/cloudflare/user.d.ts.map +1 -0
  45. package/lib/cloudflare/user.js +62 -0
  46. package/lib/cloudflare/user.js.map +1 -0
  47. package/lib/cloudflare/worker.d.ts +18 -3
  48. package/lib/cloudflare/worker.d.ts.map +1 -1
  49. package/lib/cloudflare/worker.js +7 -44
  50. package/lib/cloudflare/worker.js.map +1 -1
  51. package/lib/esbuild/bundle.d.ts.map +1 -1
  52. package/lib/esbuild/bundle.js +0 -1
  53. package/lib/esbuild/bundle.js.map +1 -1
  54. package/lib/test/bun.d.ts.map +1 -1
  55. package/lib/test/bun.js +2 -8
  56. package/lib/test/bun.js.map +1 -1
  57. package/package.json +4 -1
  58. package/src/apply.ts +0 -1
  59. package/src/cloudflare/api.ts +63 -14
  60. package/src/cloudflare/auth.ts +43 -158
  61. package/src/cloudflare/bundle/alias-plugin.ts +48 -0
  62. package/src/cloudflare/bundle/build-failures.ts +55 -0
  63. package/src/cloudflare/bundle/bundle-worker.ts +89 -0
  64. package/src/cloudflare/bundle/external.ts +9 -1
  65. package/src/cloudflare/bundle/local-dev-cloudflare-shim.ts +7 -6
  66. package/src/cloudflare/bundle/nodejs-compat-mode.ts +49 -0
  67. package/src/cloudflare/bundle/{hybrid-nodejs-compat.ts → nodejs-compat.ts} +6 -5
  68. package/src/cloudflare/queue-consumer.ts +1 -7
  69. package/src/cloudflare/user.ts +142 -0
  70. package/src/cloudflare/worker.ts +26 -51
  71. package/src/esbuild/bundle.ts +0 -1
  72. package/src/test/bun.ts +2 -7
  73. package/lib/cloudflare/account-id.d.ts +0 -6
  74. package/lib/cloudflare/account-id.d.ts.map +0 -1
  75. package/lib/cloudflare/account-id.js +0 -6
  76. package/lib/cloudflare/account-id.js.map +0 -1
  77. package/lib/cloudflare/bundle/hybrid-nodejs-compat.d.ts +0 -8
  78. package/lib/cloudflare/bundle/hybrid-nodejs-compat.d.ts.map +0 -1
  79. package/lib/cloudflare/bundle/hybrid-nodejs-compat.js.map +0 -1
  80. package/src/cloudflare/account-id.ts +0 -12
@@ -0,0 +1,142 @@
1
+ import { handleApiError } from "../neon/api-error.js";
2
+ import type { Secret } from "../secret.js";
3
+ import {
4
+ getCloudflareAuthHeaders,
5
+ type CloudflareAuthOptions,
6
+ } from "./auth.js";
7
+
8
+ export interface CloudflareAccount {
9
+ name: string;
10
+ id: string;
11
+ type: "standard" | "zero_rating" | "full_control";
12
+ settings: {
13
+ enforce_twofactor: boolean;
14
+ api_access_enabled: null;
15
+ access_approval_expiry: null;
16
+ abuse_contact_email: null;
17
+ };
18
+ legacy_flags: {
19
+ enterprise_zone_quota: {
20
+ maximum: number;
21
+ current: number;
22
+ available: number;
23
+ };
24
+ };
25
+ }
26
+
27
+ export interface CloudflareUserInfo {
28
+ apiToken?: Secret;
29
+ apiKey?: Secret;
30
+ email: string;
31
+ username: string;
32
+ accounts: CloudflareAccount[];
33
+ organizations: CloudflareOrganization[];
34
+ tokenPermissions: string[] | undefined;
35
+ first_name: string | null;
36
+ last_name: string | null;
37
+ telephone: string | null;
38
+ country: string | null;
39
+ zipcode: string | null;
40
+ two_factor_authentication_enabled: boolean;
41
+ two_factor_authentication_locked: boolean;
42
+ has_pro_zones: boolean;
43
+ has_business_zones: boolean;
44
+ has_enterprise_zones: boolean;
45
+ suspended: boolean;
46
+ betas: string[];
47
+ }
48
+
49
+ export interface CloudflareOrganization {
50
+ id: string;
51
+ name: string;
52
+ status: string;
53
+ permissions: string[];
54
+ roles: string[];
55
+ }
56
+
57
+ const userInfoCache: Record<string, CloudflareUserInfo> = {};
58
+
59
+ export async function getCloudflareUserInfo(
60
+ options: CloudflareAuthOptions,
61
+ ): Promise<CloudflareUserInfo> {
62
+ const cacheKey = JSON.stringify({
63
+ apiKey: options.apiKey?.unencrypted,
64
+ apiToken: options.apiToken?.unencrypted,
65
+ email: options.email,
66
+ });
67
+ if (userInfoCache[cacheKey]) {
68
+ return userInfoCache[cacheKey];
69
+ }
70
+ const headers = await getCloudflareAuthHeaders(options);
71
+ const user = await fetch("https://api.cloudflare.com/client/v4/user", {
72
+ headers,
73
+ });
74
+ if (!user.ok) {
75
+ if (user.status === 403) {
76
+ throw new Error(
77
+ "Cloudflare authentication required. Did you forget to login with `wrangler login` or set CLOUDFLARE_API_TOKEN, CLOUDFLARE_API_KEY, or CLOUDFLARE_EMAIL, or CLOUDFLARE_API_KEY?",
78
+ );
79
+ }
80
+ await handleApiError(user, "get", "user", "user");
81
+ }
82
+ const accounts = await fetch(
83
+ "https://api.cloudflare.com/client/v4/accounts",
84
+ {
85
+ headers,
86
+ },
87
+ );
88
+ const userInfo: CloudflareUserInfo = {
89
+ ...((await user.json()) as any).result,
90
+ accounts: ((await accounts.json()) as any).result,
91
+ };
92
+ userInfoCache[cacheKey] = userInfo;
93
+ return userInfo;
94
+ }
95
+
96
+ const emailCache: Record<string, string> = {};
97
+
98
+ export async function getUserEmailFromApiKey(apiKey: string): Promise<string> {
99
+ if (emailCache[apiKey]) {
100
+ return emailCache[apiKey];
101
+ }
102
+
103
+ try {
104
+ const baseUrl = "https://api.cloudflare.com/client/v4";
105
+
106
+ // Call the /user endpoint to get user information
107
+ const response = await fetch(`${baseUrl}/user`, {
108
+ headers: {
109
+ "Content-Type": "application/json",
110
+ "X-Auth-Key": apiKey,
111
+ },
112
+ });
113
+
114
+ if (!response.ok) {
115
+ throw new Error(
116
+ `Failed to get user information: ${response.status} ${response.statusText}`,
117
+ );
118
+ }
119
+
120
+ const data = (await response.json()) as {
121
+ success: boolean;
122
+ result: {
123
+ id: string;
124
+ email: string;
125
+ name: string;
126
+ [key: string]: any;
127
+ };
128
+ };
129
+
130
+ if (!data.success || !data.result || !data.result.email) {
131
+ throw new Error("Cloudflare API did not return valid user information");
132
+ }
133
+
134
+ emailCache[apiKey] = data.result.email;
135
+ return data.result.email;
136
+ } catch (error) {
137
+ console.error("Error retrieving email from Cloudflare API:", error);
138
+ throw new Error(
139
+ "Failed to automatically discover email for API Key authentication",
140
+ );
141
+ }
142
+ }
@@ -1,7 +1,7 @@
1
1
  import * as crypto from "node:crypto";
2
2
  import * as fs from "node:fs/promises";
3
3
  import type { Context } from "../context.js";
4
- import { Bundle, type BundleProps } from "../esbuild/bundle.js";
4
+ import type { BundleProps } from "../esbuild/bundle.js";
5
5
  import { Resource } from "../resource.js";
6
6
  import { getContentType } from "../util/content-type.js";
7
7
  import { withExponentialBackoff } from "../util/retry.js";
@@ -15,8 +15,7 @@ import {
15
15
  import type { Assets } from "./assets.js";
16
16
  import type { Bindings, WorkerBindingSpec } from "./bindings.js";
17
17
  import type { Bound } from "./bound.js";
18
- import { external } from "./bundle/external.js";
19
- import { nodejsHybridPlugin } from "./bundle/hybrid-nodejs-compat.js";
18
+ import { bundleWorkerScript } from "./bundle/bundle-worker.js";
20
19
  import type { DurableObjectNamespace } from "./durable-object-namespace.js";
21
20
  import { type EventSource, isQueueEventSource } from "./event-source.js";
22
21
  import {
@@ -86,21 +85,31 @@ export interface WorkerProps<B extends Bindings = Bindings>
86
85
 
87
86
  /**
88
87
  * Path to the entry point file
88
+ *
89
89
  * Will be bundled using esbuild
90
+ *
90
91
  * One of script, entryPoint, or bundle must be provided
91
92
  */
92
93
  entrypoint?: string;
93
94
 
95
+ /**
96
+ * The project root directory used to resolve aliases.
97
+ *
98
+ * @default process.cwd()
99
+ */
100
+ projectRoot?: string;
101
+
94
102
  /**
95
103
  * Bundle options when using entryPoint
104
+ *
96
105
  * Ignored if bundle is provided
97
106
  */
98
107
  bundle?: Omit<BundleProps, "entryPoint">;
99
108
 
100
109
  /**
101
110
  * Module format for the worker script
102
- * 'esm' - ECMAScript modules (default)
103
- * 'cjs' - CommonJS modules
111
+ * - 'esm' - ECMAScript modules (default)
112
+ * - 'cjs' - CommonJS modules
104
113
  * @default 'esm'
105
114
  */
106
115
  format?: "esm" | "cjs";
@@ -119,6 +128,7 @@ export interface WorkerProps<B extends Bindings = Bindings>
119
128
 
120
129
  /**
121
130
  * Environment variables to attach to the worker
131
+ *
122
132
  * These will be converted to plain_text bindings
123
133
  */
124
134
  env?: {
@@ -127,6 +137,7 @@ export interface WorkerProps<B extends Bindings = Bindings>
127
137
 
128
138
  /**
129
139
  * Whether to enable a workers.dev URL for this worker
140
+ *
130
141
  * If true, the worker will be available at {name}.{subdomain}.workers.dev
131
142
  * @default false
132
143
  */
@@ -134,6 +145,7 @@ export interface WorkerProps<B extends Bindings = Bindings>
134
145
 
135
146
  /**
136
147
  * Observability configuration for the worker
148
+ *
137
149
  * Controls whether worker logs are enabled
138
150
  * @default { enabled: true }
139
151
  */
@@ -173,7 +185,9 @@ export interface WorkerProps<B extends Bindings = Bindings>
173
185
 
174
186
  /**
175
187
  * Cron expressions for the trigger.
188
+ *
176
189
  * Uses standard cron syntax (e.g. "0 0 * * *" for daily at midnight)
190
+ *
177
191
  * To clear all cron triggers, pass an empty array.
178
192
  *
179
193
  * @see https://developers.cloudflare.com/workers/configuration/cron-triggers/#examples
@@ -182,6 +196,7 @@ export interface WorkerProps<B extends Bindings = Bindings>
182
196
 
183
197
  /**
184
198
  * Event sources that this worker will consume.
199
+ *
185
200
  * Can include queues, streams, or other event sources.
186
201
  */
187
202
  eventSources?: EventSource[];
@@ -371,7 +386,12 @@ export const Worker = Resource(
371
386
 
372
387
  // Get the script content - either from props.script, or by bundling
373
388
  const scriptContent =
374
- props.script ?? (await bundleWorkerScript(compatibilityDate, props));
389
+ props.script ??
390
+ (await bundleWorkerScript({
391
+ ...props,
392
+ compatibilityDate,
393
+ compatibilityFlags,
394
+ }));
375
395
 
376
396
  // Find any assets bindings
377
397
  const assetsBindings: { name: string; assets: Assets }[] = [];
@@ -929,51 +949,6 @@ async function assertWorkerDoesNotExist<B extends Bindings>(
929
949
  );
930
950
  }
931
951
 
932
- async function bundleWorkerScript<B extends Bindings>(
933
- compatibilityDate: string,
934
- props: WorkerProps<B>,
935
- ) {
936
- const bundle = await Bundle("bundle", {
937
- entryPoint: props.entrypoint!,
938
- format: props.format === "cjs" ? "cjs" : "esm", // Use the specified format or default to ESM
939
- target: "esnext",
940
- platform: "neutral",
941
- minify: false,
942
- ...(props.bundle || {}),
943
- options: {
944
- ...(props.bundle?.options || {}),
945
- keepNames: true, // Important for Durable Object classes
946
- loader: {
947
- ".sql": "text",
948
- ".json": "json",
949
- },
950
- plugins:
951
- compatibilityDate >= "2024-09-23" &&
952
- props.compatibilityFlags?.find((flag) => flag === "nodejs_compat")
953
- ? [await nodejsHybridPlugin()]
954
- : [],
955
- },
956
- external: [
957
- ...external,
958
- ...(props.bundle?.external ?? []),
959
- ...(props.bundle?.options?.external ?? []),
960
- ],
961
- });
962
-
963
- try {
964
- if (bundle.content) {
965
- return bundle.content;
966
- }
967
- if (bundle.path) {
968
- return await fs.readFile(bundle.path, "utf-8");
969
- }
970
- throw new Error("Failed to create bundle");
971
- } catch (error) {
972
- console.error("Error reading bundle:", error);
973
- throw new Error("Error reading bundle");
974
- }
975
- }
976
-
977
952
  async function configureURL<B extends Bindings>(
978
953
  ctx: Context<Worker<B>>,
979
954
  api: CloudflareApi,
@@ -126,7 +126,6 @@ export const Bundle = Resource(
126
126
  props: Props,
127
127
  ): Promise<Bundle<Props>> {
128
128
  if (this.phase === "delete") {
129
- console.log("delete", this.output.path);
130
129
  if (this.output.path) {
131
130
  try {
132
131
  await fs.rm(this.output.path, { force: true });
package/src/test/bun.ts CHANGED
@@ -199,13 +199,8 @@ export function test(meta: ImportMeta, defaultOptions?: TestOptions): test {
199
199
  parent: scope,
200
200
  },
201
201
  async (scope) => {
202
- try {
203
- // Enter test scope since bun calls from different scope
204
- await scope.run(() => fn(scope));
205
- } catch (err) {
206
- console.error(err);
207
- throw err;
208
- }
202
+ // Enter test scope since bun calls from different scope
203
+ await scope.run(() => fn(scope));
209
204
  },
210
205
  ),
211
206
  timeout,
@@ -1,6 +0,0 @@
1
- import { type CloudflareAuthOptions } from "./auth.js";
2
- export type CloudflareAccountId = string & {
3
- readonly __brand: "CloudflareAccountId";
4
- };
5
- export declare function CloudflareAccountId(options: CloudflareAuthOptions): Promise<CloudflareAccountId>;
6
- //# sourceMappingURL=account-id.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"account-id.d.ts","sourceRoot":"","sources":["../../src/cloudflare/account-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAE9E,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG;IACzC,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC;CACzC,CAAC;AAEF,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CAG9B"}
@@ -1,6 +0,0 @@
1
- import { getCloudflareUserInfo } from "./auth.js";
2
- export async function CloudflareAccountId(options) {
3
- const userInfo = await getCloudflareUserInfo(options);
4
- return userInfo.accounts[0].id;
5
- }
6
- //# sourceMappingURL=account-id.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"account-id.js","sourceRoot":"","sources":["../../src/cloudflare/account-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAA8B,MAAM,WAAW,CAAC;AAM9E,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAA8B;IAE9B,MAAM,QAAQ,GAAG,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACtD,OAAO,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAyB,CAAC;AACxD,CAAC"}
@@ -1,8 +0,0 @@
1
- import type { Plugin } from "esbuild";
2
- /**
3
- * ESBuild plugin to apply the unenv preset.
4
- *
5
- * @returns ESBuild plugin
6
- */
7
- export declare function nodejsHybridPlugin(): Promise<Plugin>;
8
- //# sourceMappingURL=hybrid-nodejs-compat.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hybrid-nodejs-compat.d.ts","sourceRoot":"","sources":["../../../src/cloudflare/bundle/hybrid-nodejs-compat.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,SAAS,CAAC;AAanD;;;;GAIG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAkB1D"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"hybrid-nodejs-compat.js","sourceRoot":"","sources":["../../../src/cloudflare/bundle/hybrid-nodejs-compat.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C;;GAEG;AAEH,MAAM,gCAAgC,GAAG,uBAAuB,CAAC;AACjE,MAAM,8BAA8B,GAAG,sBAAsB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,0DAA0D;IAC1D,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,0BAA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C,CAAC,CAAC;KAC3C,CAAC;IAEF,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,uBAAuB,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAClE,IAAI;KACL,CAAC,CAAC,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,uBAAuB,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;QAC7D,MAAM,MAAM,GAAG,4BAA4B,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtD,MAAM,CAAC,MAAM,EAAE,YAAY,IAAI,qCAAqC,CAAC,CAAC;QACtE,MAAM,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC5C,MAAM,CAAC,OAAO,EAAE,YAAY,MAAM,mBAAmB,CAAC,CAAC;QAEvD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,EAAE,CACzD,UAAU,KAAK,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,OAAO,UAAU,EAAE,CAC1E,CAAC;QAEF,OAAO;YACL,QAAQ,EAAE,MAAM,CAAA;mBACH,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,MAAM;UAC7C,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,cAAc,YAAY,MAAM,UAAU,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;SAC9G,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,12 +0,0 @@
1
- import { getCloudflareUserInfo, type CloudflareAuthOptions } from "./auth.js";
2
-
3
- export type CloudflareAccountId = string & {
4
- readonly __brand: "CloudflareAccountId";
5
- };
6
-
7
- export async function CloudflareAccountId(
8
- options: CloudflareAuthOptions,
9
- ): Promise<CloudflareAccountId> {
10
- const userInfo = await getCloudflareUserInfo(options);
11
- return userInfo.accounts[0].id as CloudflareAccountId;
12
- }