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.
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +0 -1
- package/lib/apply.js.map +1 -1
- package/lib/cloudflare/api.d.ts +5 -5
- package/lib/cloudflare/api.d.ts.map +1 -1
- package/lib/cloudflare/api.js +51 -10
- package/lib/cloudflare/api.js.map +1 -1
- package/lib/cloudflare/auth.d.ts +24 -55
- package/lib/cloudflare/auth.d.ts.map +1 -1
- package/lib/cloudflare/auth.js +15 -72
- package/lib/cloudflare/auth.js.map +1 -1
- package/lib/cloudflare/bundle/alias-plugin.d.ts +6 -0
- package/lib/cloudflare/bundle/alias-plugin.d.ts.map +1 -0
- package/lib/cloudflare/bundle/alias-plugin.js +36 -0
- package/lib/cloudflare/bundle/alias-plugin.js.map +1 -0
- package/lib/cloudflare/bundle/build-failures.d.ts +12 -0
- package/lib/cloudflare/bundle/build-failures.d.ts.map +1 -0
- package/lib/cloudflare/bundle/build-failures.js +45 -0
- package/lib/cloudflare/bundle/build-failures.js.map +1 -0
- package/lib/cloudflare/bundle/bundle-worker.d.ts +7 -0
- package/lib/cloudflare/bundle/bundle-worker.d.ts.map +1 -0
- package/lib/cloudflare/bundle/bundle-worker.js +69 -0
- package/lib/cloudflare/bundle/bundle-worker.js.map +1 -0
- package/lib/cloudflare/bundle/external.d.ts +1 -0
- package/lib/cloudflare/bundle/external.d.ts.map +1 -1
- package/lib/cloudflare/bundle/external.js +8 -1
- package/lib/cloudflare/bundle/external.js.map +1 -1
- package/lib/cloudflare/bundle/local-dev-cloudflare-shim.d.ts +1 -1
- package/lib/cloudflare/bundle/local-dev-cloudflare-shim.d.ts.map +1 -1
- package/lib/cloudflare/bundle/local-dev-cloudflare-shim.js +6 -6
- package/lib/cloudflare/bundle/local-dev-cloudflare-shim.js.map +1 -1
- package/lib/cloudflare/bundle/nodejs-compat-mode.d.ts +17 -0
- package/lib/cloudflare/bundle/nodejs-compat-mode.d.ts.map +1 -0
- package/lib/cloudflare/bundle/nodejs-compat-mode.js +27 -0
- package/lib/cloudflare/bundle/nodejs-compat-mode.js.map +1 -0
- package/lib/cloudflare/bundle/nodejs-compat.d.ts +11 -0
- package/lib/cloudflare/bundle/nodejs-compat.d.ts.map +1 -0
- package/lib/cloudflare/bundle/{hybrid-nodejs-compat.js → nodejs-compat.js} +6 -5
- package/lib/cloudflare/bundle/nodejs-compat.js.map +1 -0
- package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
- package/lib/cloudflare/queue-consumer.js +0 -4
- package/lib/cloudflare/queue-consumer.js.map +1 -1
- package/lib/cloudflare/user.d.ts +51 -0
- package/lib/cloudflare/user.d.ts.map +1 -0
- package/lib/cloudflare/user.js +62 -0
- package/lib/cloudflare/user.js.map +1 -0
- package/lib/cloudflare/worker.d.ts +18 -3
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +7 -44
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/esbuild/bundle.d.ts.map +1 -1
- package/lib/esbuild/bundle.js +0 -1
- package/lib/esbuild/bundle.js.map +1 -1
- package/lib/test/bun.d.ts.map +1 -1
- package/lib/test/bun.js +2 -8
- package/lib/test/bun.js.map +1 -1
- package/package.json +4 -1
- package/src/apply.ts +0 -1
- package/src/cloudflare/api.ts +63 -14
- package/src/cloudflare/auth.ts +43 -158
- package/src/cloudflare/bundle/alias-plugin.ts +48 -0
- package/src/cloudflare/bundle/build-failures.ts +55 -0
- package/src/cloudflare/bundle/bundle-worker.ts +89 -0
- package/src/cloudflare/bundle/external.ts +9 -1
- package/src/cloudflare/bundle/local-dev-cloudflare-shim.ts +7 -6
- package/src/cloudflare/bundle/nodejs-compat-mode.ts +49 -0
- package/src/cloudflare/bundle/{hybrid-nodejs-compat.ts → nodejs-compat.ts} +6 -5
- package/src/cloudflare/queue-consumer.ts +1 -7
- package/src/cloudflare/user.ts +142 -0
- package/src/cloudflare/worker.ts +26 -51
- package/src/esbuild/bundle.ts +0 -1
- package/src/test/bun.ts +2 -7
- package/lib/cloudflare/account-id.d.ts +0 -6
- package/lib/cloudflare/account-id.d.ts.map +0 -1
- package/lib/cloudflare/account-id.js +0 -6
- package/lib/cloudflare/account-id.js.map +0 -1
- package/lib/cloudflare/bundle/hybrid-nodejs-compat.d.ts +0 -8
- package/lib/cloudflare/bundle/hybrid-nodejs-compat.d.ts.map +0 -1
- package/lib/cloudflare/bundle/hybrid-nodejs-compat.js.map +0 -1
- 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
|
+
}
|
package/src/cloudflare/worker.ts
CHANGED
|
@@ -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 {
|
|
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 {
|
|
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 ??
|
|
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,
|
package/src/esbuild/bundle.ts
CHANGED
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
|
-
|
|
203
|
-
|
|
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 +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 +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,O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C7C,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
|
-
}
|