@auth-craft/worker-d1-stack 0.0.0-stage → 0.1.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/README.md +99 -2
- package/assets/check/config.mjs +1826 -0
- package/assets/manifest.json +96 -0
- package/assets/migrations/0001_baseline.sql +234 -0
- package/assets/migrations/0002_email.sql +31 -0
- package/assets/migrations/0003_email_provider_index.sql +7 -0
- package/assets/migrations/0004_audit.sql +27 -0
- package/assets/migrations/0005_allowed_origins.sql +14 -0
- package/assets/sbom/worker.cdx.json +629 -0
- package/assets/worker/worker.js +158 -0
- package/bin/auth-craft-worker.mjs +4 -0
- package/dist/check.d.ts +9 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +122 -0
- package/dist/check.js.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +175 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands.d.ts +27 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +76 -0
- package/dist/commands.js.map +1 -0
- package/dist/init.d.ts +18 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +68 -0
- package/dist/init.js.map +1 -0
- package/dist/paths.d.ts +17 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +13 -0
- package/dist/paths.js.map +1 -0
- package/dist/secrets-file.d.ts +5 -0
- package/dist/secrets-file.d.ts.map +1 -0
- package/dist/secrets-file.js +56 -0
- package/dist/secrets-file.js.map +1 -0
- package/dist/smoke.d.ts +34 -0
- package/dist/smoke.d.ts.map +1 -0
- package/dist/smoke.js +144 -0
- package/dist/smoke.js.map +1 -0
- package/dist/wrangler-config.d.ts +52 -0
- package/dist/wrangler-config.d.ts.map +1 -0
- package/dist/wrangler-config.js +23 -0
- package/dist/wrangler-config.js.map +1 -0
- package/dist/wrangler-runner.d.ts +5 -0
- package/dist/wrangler-runner.d.ts.map +1 -0
- package/dist/wrangler-runner.js +35 -0
- package/dist/wrangler-runner.js.map +1 -0
- package/package.json +34 -3
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The secrets file: KEY=VALUE lines (like .dev.vars), `#` comments, values optionally
|
|
3
|
+
* wrapped in matching quotes. It stays on the operator's machine; values are only ever
|
|
4
|
+
* passed to `wrangler secret bulk`, never printed.
|
|
5
|
+
*/
|
|
6
|
+
import { readFileSync, statSync } from 'node:fs';
|
|
7
|
+
import { CliError } from './wrangler-config.js';
|
|
8
|
+
/** Variables whose values are secrets: never in wrangler.json `vars` (plaintext, often committed). */
|
|
9
|
+
export const SECRET_VARS = [
|
|
10
|
+
'JWT_PRIVATE_KEY',
|
|
11
|
+
'GATEWAY_SECRET',
|
|
12
|
+
'PASSWORD_ENGINE_SIGNING_KEY',
|
|
13
|
+
'MFA_SECRET_KEY',
|
|
14
|
+
'MFA_SECRET_PREVIOUS_KEYS',
|
|
15
|
+
'RESEND_API_KEY',
|
|
16
|
+
'RESEND_WEBHOOK_SECRET',
|
|
17
|
+
'GOOGLE_CLIENT_SECRET',
|
|
18
|
+
'FACEBOOK_CLIENT_SECRET',
|
|
19
|
+
];
|
|
20
|
+
const NAME = /^[A-Z][A-Z0-9_]*$/;
|
|
21
|
+
export function parseSecretsFile(text) {
|
|
22
|
+
const out = {};
|
|
23
|
+
text.split(/\r?\n/).forEach((raw, index) => {
|
|
24
|
+
const line = raw.trim();
|
|
25
|
+
if (line === '' || line.startsWith('#'))
|
|
26
|
+
return;
|
|
27
|
+
const eq = line.indexOf('=');
|
|
28
|
+
const name = eq > 0 ? line.slice(0, eq).trim() : '';
|
|
29
|
+
if (!NAME.test(name))
|
|
30
|
+
throw new CliError(`secrets file line ${index + 1}: expected NAME=value`);
|
|
31
|
+
let value = line.slice(eq + 1).trim();
|
|
32
|
+
const quote = value[0];
|
|
33
|
+
if ((quote === '"' || quote === "'") && value.length >= 2 && value.endsWith(quote))
|
|
34
|
+
value = value.slice(1, -1);
|
|
35
|
+
if (name in out)
|
|
36
|
+
throw new CliError(`secrets file: ${name} is set twice`);
|
|
37
|
+
out[name] = value;
|
|
38
|
+
});
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
export function readSecretsFile(path) {
|
|
42
|
+
let mode;
|
|
43
|
+
let text;
|
|
44
|
+
try {
|
|
45
|
+
mode = statSync(path).mode;
|
|
46
|
+
text = readFileSync(path, 'utf8');
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
throw new CliError(`Cannot read the secrets file ${path}`);
|
|
50
|
+
}
|
|
51
|
+
if (process.platform !== 'win32' && (mode & 0o077) !== 0) {
|
|
52
|
+
throw new CliError(`${path} is readable by other users; chmod 600 it`);
|
|
53
|
+
}
|
|
54
|
+
return parseSecretsFile(text);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=secrets-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets-file.js","sourceRoot":"","sources":["../src/secrets-file.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,sGAAsG;AACtG,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,iBAAiB;IACjB,gBAAgB;IAChB,6BAA6B;IAC7B,gBAAgB;IAChB,0BAA0B;IAC1B,gBAAgB;IAChB,uBAAuB;IACvB,sBAAsB;IACtB,wBAAwB;CAChB,CAAC;AAEX,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAEjC,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QACzC,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC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AC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,QAAQ,CAAC,gCAAgC,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD,MAAM,IAAI,QAAQ,CAAC,GAAG,IAAI,2CAA2C,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC"}
|
package/dist/smoke.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `smoke`: black-box checks of a running Worker over HTTP, with an account that already
|
|
3
|
+
* exists and is verified. Nothing here reads D1 or needs a Cloudflare account, so the
|
|
4
|
+
* same checks run against `wrangler dev` and against a real deployment.
|
|
5
|
+
*
|
|
6
|
+
* What it proves, in order:
|
|
7
|
+
* - /health answers and runs the password engine mode the operator expects;
|
|
8
|
+
* - an app the deployment does not declare is refused (400 APP_UNKNOWN);
|
|
9
|
+
* - a wrong password is INVALID_CREDENTIALS, not 503 (the hasher is reachable);
|
|
10
|
+
* - the right password signs in; /auth/me answers for that account only with the token;
|
|
11
|
+
* - refresh rotates; logout ends the session; the logged-out refresh token is refused;
|
|
12
|
+
* - an origin outside CORS_ORIGINS is not echoed back.
|
|
13
|
+
*
|
|
14
|
+
* Leaves at most one session (logged out) and no failed attempt (the successful login
|
|
15
|
+
* resets the counter). Never prints a token, a password or a response body.
|
|
16
|
+
*/
|
|
17
|
+
export interface SmokeOptions {
|
|
18
|
+
/** Base URL including APP_BASE_PATH, e.g. https://auth.example.com. */
|
|
19
|
+
url: string;
|
|
20
|
+
passwordEngine: 'local' | 'remote';
|
|
21
|
+
email: string;
|
|
22
|
+
password: string;
|
|
23
|
+
/** Sent as X-Gateway-Secret when something sits in front of the Worker. */
|
|
24
|
+
gatewaySecret?: string;
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
fetch?: typeof fetch;
|
|
27
|
+
}
|
|
28
|
+
export interface SmokeStep {
|
|
29
|
+
name: string;
|
|
30
|
+
ok: boolean;
|
|
31
|
+
detail?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function runSmoke(options: SmokeOptions): Promise<SmokeStep[]>;
|
|
34
|
+
//# sourceMappingURL=smoke.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smoke.d.ts","sourceRoot":"","sources":["../src/smoke.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,WAAW,YAAY;IAC3B,uEAAuE;IACvE,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,OAAO,GAAG,QAAQ,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAiBD,wBAAsB,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CA6I1E"}
|
package/dist/smoke.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `smoke`: black-box checks of a running Worker over HTTP, with an account that already
|
|
3
|
+
* exists and is verified. Nothing here reads D1 or needs a Cloudflare account, so the
|
|
4
|
+
* same checks run against `wrangler dev` and against a real deployment.
|
|
5
|
+
*
|
|
6
|
+
* What it proves, in order:
|
|
7
|
+
* - /health answers and runs the password engine mode the operator expects;
|
|
8
|
+
* - an app the deployment does not declare is refused (400 APP_UNKNOWN);
|
|
9
|
+
* - a wrong password is INVALID_CREDENTIALS, not 503 (the hasher is reachable);
|
|
10
|
+
* - the right password signs in; /auth/me answers for that account only with the token;
|
|
11
|
+
* - refresh rotates; logout ends the session; the logged-out refresh token is refused;
|
|
12
|
+
* - an origin outside CORS_ORIGINS is not echoed back.
|
|
13
|
+
*
|
|
14
|
+
* Leaves at most one session (logged out) and no failed attempt (the successful login
|
|
15
|
+
* resets the counter). Never prints a token, a password or a response body.
|
|
16
|
+
*/
|
|
17
|
+
class StepFailure extends Error {
|
|
18
|
+
}
|
|
19
|
+
const FOREIGN_ORIGIN = 'https://auth-craft-smoke.invalid';
|
|
20
|
+
function describeReply(reply) {
|
|
21
|
+
const code = reply.body?.errors?.[0]?.code;
|
|
22
|
+
return `HTTP ${reply.status}${code ? ` ${code}` : ''}`;
|
|
23
|
+
}
|
|
24
|
+
export async function runSmoke(options) {
|
|
25
|
+
const doFetch = options.fetch ?? fetch;
|
|
26
|
+
const base = options.url.replace(/\/+$/, '');
|
|
27
|
+
const steps = [];
|
|
28
|
+
async function call(method, path, body, headers = {}) {
|
|
29
|
+
const response = await doFetch(`${base}${path}`, {
|
|
30
|
+
method,
|
|
31
|
+
headers: {
|
|
32
|
+
...(body !== undefined && { 'Content-Type': 'application/json' }),
|
|
33
|
+
...(options.gatewaySecret && { 'X-Gateway-Secret': options.gatewaySecret }),
|
|
34
|
+
...headers,
|
|
35
|
+
},
|
|
36
|
+
...(body !== undefined && { body: JSON.stringify(body) }),
|
|
37
|
+
signal: AbortSignal.timeout(options.timeoutMs ?? 15_000),
|
|
38
|
+
redirect: 'manual',
|
|
39
|
+
});
|
|
40
|
+
const text = await response.text();
|
|
41
|
+
let parsed = null;
|
|
42
|
+
try {
|
|
43
|
+
parsed = text ? JSON.parse(text) : null;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
parsed = null;
|
|
47
|
+
}
|
|
48
|
+
return { status: response.status, headers: response.headers, body: parsed };
|
|
49
|
+
}
|
|
50
|
+
async function step(name, check) {
|
|
51
|
+
try {
|
|
52
|
+
await check();
|
|
53
|
+
steps.push({ name, ok: true });
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
const detail = error instanceof StepFailure
|
|
58
|
+
? error.message
|
|
59
|
+
: error instanceof Error && error.name === 'TimeoutError'
|
|
60
|
+
? 'timed out'
|
|
61
|
+
: `request failed (${error instanceof Error ? error.name : 'error'})`;
|
|
62
|
+
steps.push({ name, ok: false, detail });
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const expect = (condition, detail) => {
|
|
67
|
+
if (!condition)
|
|
68
|
+
throw new StepFailure(detail);
|
|
69
|
+
};
|
|
70
|
+
const credentials = (password) => ({
|
|
71
|
+
identityType: 'email',
|
|
72
|
+
identityValue: options.email,
|
|
73
|
+
credentialType: 'password',
|
|
74
|
+
credentialValue: password,
|
|
75
|
+
});
|
|
76
|
+
const healthy = await step(`health: up, PASSWORD_ENGINE=${options.passwordEngine}`, async () => {
|
|
77
|
+
const reply = await call('GET', '/health');
|
|
78
|
+
expect(reply.status === 200, describeReply(reply));
|
|
79
|
+
const mode = reply.body?.data?.passwordEngine;
|
|
80
|
+
expect(mode === options.passwordEngine, `the Worker runs PASSWORD_ENGINE=${String(mode)}`);
|
|
81
|
+
});
|
|
82
|
+
// Nothing below means anything against the wrong deployment.
|
|
83
|
+
if (!healthy)
|
|
84
|
+
return steps;
|
|
85
|
+
await step('an undeclared app is refused', async () => {
|
|
86
|
+
const reply = await call('POST', '/auth/authenticate', credentials(options.password), {
|
|
87
|
+
'X-Auth-Context': `smoke-undeclared-${crypto.randomUUID().slice(0, 8)}`,
|
|
88
|
+
});
|
|
89
|
+
expect(reply.status === 400 && reply.body?.errors?.[0]?.code === 'APP_UNKNOWN', describeReply(reply));
|
|
90
|
+
});
|
|
91
|
+
await step('a wrong password is refused by the hasher (not 503)', async () => {
|
|
92
|
+
const reply = await call('POST', '/auth/authenticate', credentials(`${options.password}-wrong`));
|
|
93
|
+
expect(reply.status === 401 && reply.body?.errors?.[0]?.code === 'INVALID_CREDENTIALS', reply.status === 503 ? `${describeReply(reply)}: the password engine is unreachable` : describeReply(reply));
|
|
94
|
+
});
|
|
95
|
+
let accessToken = '';
|
|
96
|
+
let refreshToken = '';
|
|
97
|
+
const signedIn = await step('login', async () => {
|
|
98
|
+
const reply = await call('POST', '/auth/authenticate', credentials(options.password));
|
|
99
|
+
expect(reply.status === 200, describeReply(reply));
|
|
100
|
+
const data = reply.body?.data ?? {};
|
|
101
|
+
expect(!data.requiresVerification, 'the smoke account is not verified');
|
|
102
|
+
expect(!data.requiresChallenge && !data.requiresMfa, 'the smoke account needs a second step (use one without MFA)');
|
|
103
|
+
expect(typeof data.accessToken === 'string', 'no access token in the body');
|
|
104
|
+
expect(typeof data.refreshToken === 'string', 'no refresh token in the body (smoke needs REFRESH_TOKEN_STRATEGY=body or both)');
|
|
105
|
+
accessToken = data.accessToken;
|
|
106
|
+
refreshToken = data.refreshToken;
|
|
107
|
+
});
|
|
108
|
+
if (!signedIn)
|
|
109
|
+
return steps;
|
|
110
|
+
await step('/auth/me with the token, refused without it', async () => {
|
|
111
|
+
const me = await call('GET', '/auth/me', undefined, { Authorization: `Bearer ${accessToken}` });
|
|
112
|
+
expect(me.status === 200, describeReply(me));
|
|
113
|
+
const identities = (me.body?.data?.identities ?? []);
|
|
114
|
+
const want = options.email.trim().toLowerCase();
|
|
115
|
+
expect(identities.some((i) => i.type === 'email' && i.value?.toLowerCase() === want), '/auth/me does not list the smoke email');
|
|
116
|
+
const anonymous = await call('GET', '/auth/me');
|
|
117
|
+
expect(anonymous.status === 401, `without a token: ${describeReply(anonymous)}`);
|
|
118
|
+
});
|
|
119
|
+
let rotated = '';
|
|
120
|
+
await step('refresh rotates the refresh token', async () => {
|
|
121
|
+
const reply = await call('POST', '/auth/refresh', { refreshToken });
|
|
122
|
+
expect(reply.status === 200, describeReply(reply));
|
|
123
|
+
const next = reply.body?.data?.refreshToken;
|
|
124
|
+
expect(typeof next === 'string' && next !== refreshToken, 'the refresh token did not rotate');
|
|
125
|
+
rotated = next;
|
|
126
|
+
});
|
|
127
|
+
await step('logout ends the session', async () => {
|
|
128
|
+
const token = rotated || refreshToken;
|
|
129
|
+
const reply = await call('POST', '/auth/logout', { refreshToken: token });
|
|
130
|
+
expect(reply.status >= 200 && reply.status < 300, describeReply(reply));
|
|
131
|
+
const after = await call('POST', '/auth/refresh', { refreshToken: token });
|
|
132
|
+
expect(after.status === 401, `refresh after logout: ${describeReply(after)}`);
|
|
133
|
+
});
|
|
134
|
+
await step('an origin outside CORS_ORIGINS is not allowed', async () => {
|
|
135
|
+
const reply = await call('OPTIONS', '/auth/authenticate', undefined, {
|
|
136
|
+
Origin: FOREIGN_ORIGIN,
|
|
137
|
+
'Access-Control-Request-Method': 'POST',
|
|
138
|
+
});
|
|
139
|
+
const allowed = reply.headers.get('access-control-allow-origin');
|
|
140
|
+
expect(allowed !== FOREIGN_ORIGIN && allowed !== '*', `the Worker allowed ${FOREIGN_ORIGIN}`);
|
|
141
|
+
});
|
|
142
|
+
return steps;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=smoke.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smoke.js","sourceRoot":"","sources":["../src/smoke.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AA0BH,MAAM,WAAY,SAAQ,KAAK;CAAG;AAElC,MAAM,cAAc,GAAG,kCAAkC,CAAC;AAE1D,SAAS,aAAa,CAAC,KAAY;IACjC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;IAC3C,OAAO,QAAQ,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AACzD,CAAC;A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AE;QAC/C,MAAM,KAAK,GAAG,OAAO,IAAI,YAAY,CAAC;QACtC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,cAAc,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1E,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,GAAG,IAAI,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;QACxE,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,EAAE,eAAe,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;QAC3E,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,yBAAyB,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC;IAEH,MAAM,IAAI,CAAC,+CAA+C,EAAE,KAAK,IAAI,EAAE;QACrE,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,oBAAoB,EAAE,SAAS,EAAE;YACnE,MAAM,EAAE,cAAc;YACtB,+BAA+B,EAAE,MAAM;SACxC,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;QACjE,MAAM,CAAC,OAAO,KAAK,cAAc,IAAI,OAAO,KAAK,GAAG,EAAE,sBAAsB,cAAc,EAAE,CAAC,CAAC;IAChG,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface WranglerConfig {
|
|
2
|
+
name?: string;
|
|
3
|
+
main?: string;
|
|
4
|
+
no_bundle?: boolean;
|
|
5
|
+
compatibility_date?: string;
|
|
6
|
+
compatibility_flags?: string[];
|
|
7
|
+
workers_dev?: boolean;
|
|
8
|
+
preview_urls?: boolean;
|
|
9
|
+
routes?: {
|
|
10
|
+
pattern: string;
|
|
11
|
+
custom_domain?: boolean;
|
|
12
|
+
}[];
|
|
13
|
+
d1_databases?: {
|
|
14
|
+
binding: string;
|
|
15
|
+
database_name: string;
|
|
16
|
+
database_id: string;
|
|
17
|
+
migrations_dir?: string;
|
|
18
|
+
}[];
|
|
19
|
+
durable_objects?: {
|
|
20
|
+
bindings?: {
|
|
21
|
+
name: string;
|
|
22
|
+
class_name: string;
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
migrations?: {
|
|
26
|
+
tag: string;
|
|
27
|
+
new_sqlite_classes?: string[];
|
|
28
|
+
}[];
|
|
29
|
+
triggers?: {
|
|
30
|
+
crons?: string[];
|
|
31
|
+
};
|
|
32
|
+
queues?: {
|
|
33
|
+
producers?: {
|
|
34
|
+
binding: string;
|
|
35
|
+
queue: string;
|
|
36
|
+
}[];
|
|
37
|
+
consumers?: {
|
|
38
|
+
queue: string;
|
|
39
|
+
max_batch_size?: number;
|
|
40
|
+
max_retries?: number;
|
|
41
|
+
dead_letter_queue?: string;
|
|
42
|
+
}[];
|
|
43
|
+
};
|
|
44
|
+
send_email?: {
|
|
45
|
+
name: string;
|
|
46
|
+
}[];
|
|
47
|
+
vars?: Record<string, string>;
|
|
48
|
+
}
|
|
49
|
+
export declare class CliError extends Error {
|
|
50
|
+
}
|
|
51
|
+
export declare function readWranglerConfig(path: string): WranglerConfig;
|
|
52
|
+
//# sourceMappingURL=wrangler-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrangler-config.d.ts","sourceRoot":"","sources":["../src/wrangler-config.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,WAAW,C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AAc,CAc/D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** The part of wrangler.json this package writes and checks. */
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
export class CliError extends Error {
|
|
4
|
+
}
|
|
5
|
+
export function readWranglerConfig(path) {
|
|
6
|
+
let text;
|
|
7
|
+
try {
|
|
8
|
+
text = readFileSync(path, 'utf8');
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
throw new CliError(`Cannot read ${path} (run \`auth-craft-worker init\` first)`);
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const parsed = JSON.parse(text);
|
|
15
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed))
|
|
16
|
+
throw new Error('not an object');
|
|
17
|
+
return parsed;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
throw new CliError(`${path} is not valid JSON (this tool writes and reads wrangler.json, not TOML)`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=wrangler-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrangler-config.js","sourceRoot":"","sources":["../src/wrangler-config.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAuBvC,MAAM,OAAO,QAAS,SAAQ,KAAK;CAAG;AAEtC,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,QAAQ,CAAC,eAAe,IAAI,yCAAyC,CAAC,CAAC;IACnF,CAAC;IACD,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;QAC7G,OAAO,MAAwB,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,QAAQ,CAAC,GAAG,IAAI,yEAAyE,CAAC,CAAC;IACvG,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrangler-runner.d.ts","sourceRoot":"","sources":["../src/wrangler-runner.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAgB7F,eAAO,MAAM,WAAW,EAAE,cAYzB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Runs the consumer's wrangler (their project's, else this package's peer). */
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
import { dirname, join, resolve } from 'node:path';
|
|
6
|
+
import { CliError } from './wrangler-config.js';
|
|
7
|
+
function wranglerBin(cwd) {
|
|
8
|
+
for (const from of [join(resolve(cwd), 'package.json'), import.meta.url]) {
|
|
9
|
+
try {
|
|
10
|
+
const manifestPath = createRequire(from).resolve('wrangler/package.json');
|
|
11
|
+
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
|
|
12
|
+
const bin = typeof manifest.bin === 'string' ? manifest.bin : manifest.bin?.wrangler;
|
|
13
|
+
if (bin)
|
|
14
|
+
return join(dirname(manifestPath), bin);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// try the next place
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
throw new CliError('wrangler is not installed: npm i -D wrangler');
|
|
21
|
+
}
|
|
22
|
+
export const runWrangler = (args, options = {}) => {
|
|
23
|
+
const cwd = options.cwd ?? process.cwd();
|
|
24
|
+
const bin = wranglerBin(cwd);
|
|
25
|
+
return new Promise((resolvePromise, reject) => {
|
|
26
|
+
const child = spawn(process.execPath, [bin, ...args], {
|
|
27
|
+
cwd,
|
|
28
|
+
stdio: 'inherit',
|
|
29
|
+
env: { ...process.env, WRANGLER_SEND_METRICS: 'false' },
|
|
30
|
+
});
|
|
31
|
+
child.on('error', reject);
|
|
32
|
+
child.on('exit', (code) => resolvePromise(code ?? 1));
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=wrangler-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrangler-runner.js","sourceRoot":"","sources":["../src/wrangler-runner.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIhD,SAAS,WAAW,CAAC,GAAW;IAC9B,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,cAAc,CAAC,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACzE,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;YAC1E,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAA8C,CAAC;YAC7G,MAAM,GAAG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
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Self-contained, versioned distribution of the Auth Craft backend on Cloudflare Workers + D1: the prebuilt Worker, its D1 migrations and a CLI to configure, check and deploy it without cloning auth-craft.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"auth-craft-worker": "./bin/auth-craft-worker.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"dist",
|
|
12
|
+
"assets",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^26.6.5",
|
|
17
|
+
"typescript": "^7.0.2",
|
|
18
|
+
"vitest": "^5.0.5",
|
|
19
|
+
"wrangler": "^4.154.0",
|
|
20
|
+
"@auth-craft/password-engine": "0.1.0",
|
|
21
|
+
"@auth-craft/auth-worker-d1": "0.1.0",
|
|
22
|
+
"@auth-craft/repo-plugin-d1": "0.1.0",
|
|
23
|
+
"@auth-craft/tsconfig": "0.1.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"wrangler": "^4.149.0"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=20"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc && node ./scripts/prebuild-assets.mjs",
|
|
33
|
+
"type-check": "tsc --noEmit",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"smoke:local": "node ./scripts/smoke-local.mjs"
|
|
36
|
+
}
|
|
6
37
|
}
|