@runeditrun/rer 0.2.19 → 0.2.20
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 +7 -7
- package/cli/README.md +22 -21
- package/cli/adapter.mjs +5 -0
- package/cli/container.mjs +7 -2
- package/cli/contract.mjs +3 -4
- package/cli/delivery-declarations.mjs +36 -0
- package/cli/demo-host.mjs +2 -2
- package/cli/demo.mjs +16 -5
- package/cli/deploy-command.mjs +3 -0
- package/cli/deploy.mjs +4 -1
- package/cli/detached-server.mjs +2 -2
- package/cli/dev-identity.mjs +1 -1
- package/cli/export.mjs +1 -1
- package/cli/inspect.mjs +13 -13
- package/cli/lifecycle.mjs +16 -49
- package/cli/listen.mjs +31 -0
- package/cli/local.mjs +12 -18
- package/cli/main.mjs +5 -0
- package/cli/managed-server.mjs +26 -44
- package/cli/output.mjs +1 -1
- package/cli/parse.mjs +3 -3
- package/cli/port.mjs +20 -20
- package/cli/production-auth.mjs +38 -0
- package/cli/server-proxy.mjs +2 -6
- package/cli/server-registry.mjs +7 -2
- package/cli/setup-input.mjs +3 -0
- package/global/CHANGELOG.md +9 -0
- package/global/README.md +7 -7
- package/global/cli/install.mjs +4 -28
- package/global/cli/path-link.mjs +25 -21
- package/global/launch/dev.mjs +1 -1
- package/global/launch/facts.mjs +11 -14
- package/global/launch/failure.mjs +20 -0
- package/global/launch/render.mjs +2 -6
- package/global/launch/worker.mjs +3 -3
- package/global/main.mjs +1 -1
- package/modules/container/build.mjs +2 -2
- package/modules/container/demo-egress.mjs +35 -0
- package/modules/container/worker-engine.mjs +3 -3
- package/modules/d1-transport/index.d.mts +9 -0
- package/modules/d1-transport/index.mjs +124 -0
- package/modules/delivery-producer/bindings.mjs +140 -0
- package/modules/delivery-producer/declarations.mjs +49 -0
- package/modules/demo/README.md +34 -0
- package/modules/demo/effects.mjs +73 -0
- package/modules/demo/index.d.mts +15 -0
- package/modules/demo/index.mjs +63 -0
- package/modules/demo/label.d.mts +2 -0
- package/modules/demo/label.mjs +24 -0
- package/modules/demo/responses.mjs +26 -0
- package/modules/demo/sockets.mjs +13 -0
- package/modules/demo/vite.d.mts +2 -0
- package/modules/demo/vite.mjs +19 -0
- package/modules/demo-host/README.md +5 -1
- package/modules/demo-host/container.mjs +4 -4
- package/modules/demo-host/pages.mjs +1 -1
- package/modules/demo-host/worker.mjs +1 -1
- package/modules/deploy-kit/owner.mjs +2 -2
- package/modules/deploy-kit/r2-objects.mjs +8 -5
- package/modules/job-queue/storage.mjs +4 -1
- package/modules/mail/README.md +19 -86
- package/modules/mail/src/core/validation.mjs +0 -1
- package/modules/mail/src/development/index.d.mts +1 -6
- package/modules/mail/src/development/index.mjs +3 -16
- package/modules/operator-auth/README.md +10 -9
- package/modules/operator-auth/csp.mjs +1 -2
- package/modules/operator-auth/dev/cli-session.mjs +32 -0
- package/modules/operator-auth/dev/index.mjs +18 -11
- package/modules/operator-auth/identity/email-link/index.mjs +3 -0
- package/modules/operator-auth/page.mjs +1 -1
- package/modules/operator-auth/signin/index.d.mts +1 -1
- package/modules/portability/README.md +6 -0
- package/modules/portability/catalogue.mjs +1 -1
- package/modules/portability/copies.mjs +17 -2
- package/modules/portability/index.mjs +2 -0
- package/modules/portability/storage.mjs +5 -1
- package/onboarding/README.md +8 -11
- package/onboarding/adapter-auth.mjs +6 -38
- package/onboarding/adapter-labels.mjs +1 -1
- package/onboarding/adapter.mjs +8 -11
- package/onboarding/app-fetch.mjs +1 -1
- package/onboarding/dependency-approval.mjs +5 -15
- package/onboarding/dev-identity.mjs +1 -1
- package/onboarding/operator-install.mjs +6 -7
- package/onboarding/operator-installer.mjs +5 -5
- package/onboarding/operator-prerequisites.mjs +4 -5
- package/onboarding/port-probe.mjs +38 -0
- package/onboarding/process-diagnostics.mjs +36 -20
- package/onboarding/server.mjs +1 -1
- package/onboarding/ui/app.js +1 -1
- package/operations/README.md +3 -0
- package/package.json +4 -2
- package/scripts/publish-check/public_hygiene.py +31 -10
- package/modules/mail/src/development/viewer-html.mjs +0 -42
- package/modules/mail/src/development/viewer.mjs +0 -72
- package/modules/operator-auth/dev/badge.mjs +0 -44
|
@@ -3,7 +3,6 @@ import { appFetch } from './app-fetch.mjs';
|
|
|
3
3
|
import { createHmac } from 'node:crypto';
|
|
4
4
|
import {commandFailure,installationFailure} from './failures.mjs';
|
|
5
5
|
import { labels } from './adapter-labels.mjs';
|
|
6
|
-
const outboxPath = '/__dev/outbox'; // modules/mail/src/development default path
|
|
7
6
|
|
|
8
7
|
// The CLI's own requests to its loopback server prove they come from the
|
|
9
8
|
// installation's owner-side tooling (modules/operator-auth/local-cli.mjs), so
|
|
@@ -27,11 +26,11 @@ const errorCode = async response => { try { const code = (await response.json())
|
|
|
27
26
|
export async function owner(context, hook) {
|
|
28
27
|
const { store } = context;
|
|
29
28
|
await store.step(labels.owner);
|
|
30
|
-
await approveSetupDependencies(context, post
|
|
29
|
+
await approveSetupDependencies(context, post);
|
|
31
30
|
if(context.ownerClaim?.mode==='idp'){context.ownerClaimed='pending-idp';await store.step('The linked provider must grant the designated installation owner');return;}
|
|
32
31
|
const { path = '/auth/bootstrap', tokenKey = context.ownerClaim?.tokenField ?? 'SETUP_TOKEN', displayName = input => input.displayName || input.name || 'Owner', returnTo = '/' } = hook;
|
|
33
32
|
const token = context.vars[tokenKey];
|
|
34
|
-
if (!token && hook.existingOwnerViaSignIn) { await store.step('
|
|
33
|
+
if (!token && hook.existingOwnerViaSignIn) { await store.step('Keeping the existing owner'); return; }
|
|
35
34
|
if (!token) {
|
|
36
35
|
throw authFailure(context,labels.owner,`${tokenKey} is missing from the private settings.`);
|
|
37
36
|
}
|
|
@@ -46,44 +45,13 @@ export async function owner(context, hook) {
|
|
|
46
45
|
throw authFailure(context,labels.owner,`HTTP ${response.status} (${code}).`);
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
// needs no mail provider and no email is sent.
|
|
48
|
+
// Keep only the destination in installer state. The browser obtains its
|
|
49
|
+
// one-click dev identity through the authenticated /api/open-app response.
|
|
52
50
|
export async function signIn(context, hook) {
|
|
53
|
-
const { store } = context;
|
|
54
51
|
if(context.ownerClaim?.mode==='idp' && context.ownerClaimed==='pending-idp')return;
|
|
55
|
-
await store.step(labels.signIn);
|
|
52
|
+
await context.store.step(labels.signIn);
|
|
56
53
|
if (typeof hook === 'function') { context.appUrl = await hook(context); return; }
|
|
57
|
-
|
|
58
|
-
const address = context.signInEmail ?? (emailKey ? context.vars[emailKey] : email(context.input));
|
|
59
|
-
if (typeof address !== 'string' || !address.includes('@')) { throw authFailure(context,labels.signIn,'no owner email.'); }
|
|
60
|
-
const before = new Set(await outboxMessages(context, outbox, address, true));
|
|
61
|
-
let response;
|
|
62
|
-
try { response = await post(context, magicLink, { email: address, returnTo }); } catch (error) {
|
|
63
|
-
if (context.signal?.aborted) throw error;
|
|
64
|
-
throw authFailure(context,labels.signIn,'the application did not answer.');
|
|
65
|
-
}
|
|
66
|
-
if (response.status !== 202) { throw authFailure(context,labels.signIn,`HTTP ${response.status} (${await errorCode(response)}).`); }
|
|
67
|
-
await response.body?.cancel();
|
|
68
|
-
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
69
|
-
const id = (await outboxMessages(context, outbox, address)).find(message => !before.has(message));
|
|
70
|
-
if (id) { context.appUrl = new URL(`${outbox}?message=${encodeURIComponent(id)}`, context.origin).href; await store.step('Your sign-in link is waiting in the development outbox'); return; }
|
|
71
|
-
await new Promise(resolve => setTimeout(resolve, 200));
|
|
72
|
-
}
|
|
73
|
-
throw authFailure(context,labels.signIn,'no message reached the development outbox. Check that the retained database owner matches the private owner settings; preserve data or run rer reset --yes.');
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async function outboxMessages(context, path, address, required = false) {
|
|
77
|
-
let response;
|
|
78
|
-
// A dev-identity seed gates its outbox with the checkout's key; present it.
|
|
79
|
-
try { response = await appFetch(new URL(path, context.origin), { signal: context.signal, headers: context.devKey ? { 'x-rer-dev-key': context.devKey } : {} }); } catch (error) {
|
|
80
|
-
if (context.signal?.aborted) throw error;
|
|
81
|
-
if(required){context.store.report?.('Local development outbox is unavailable. Run rer setup before requesting sign-in.');throw context.fail('setup');}
|
|
82
|
-
return [];
|
|
83
|
-
}
|
|
84
|
-
if (!response.ok) { await response.body?.cancel();if(required){context.store.report?.('Local development outbox is unavailable. Run rer setup before requesting sign-in.');throw context.fail('setup');}return []; }
|
|
85
|
-
const html = await response.text(), wanted = `To: ${address.replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]))}</p>`;
|
|
86
|
-
return html.split('<article>').slice(1).filter(article => article.toLowerCase().includes(wanted.toLowerCase())).map(article => /\?message=([^"&]+)"/.exec(article)?.[1]).filter(Boolean).map(decodeURIComponent);
|
|
54
|
+
context.appUrl = new URL(hook.returnTo ?? '/', context.origin).href;
|
|
87
55
|
}
|
|
88
56
|
|
|
89
57
|
function authFailure(context,label,reason){const message=context.store.redact?.(`${label}: ${reason}`)??`${label}: ${reason}`;context.store.report?.(message);return installationFailure('command_failed',{step:'setup',diagnostic:commandFailure(message)});}
|
|
@@ -6,7 +6,7 @@ export const labels = Object.freeze({
|
|
|
6
6
|
migrate: 'Applying database migrations',
|
|
7
7
|
start: 'Starting your application on this computer',
|
|
8
8
|
owner: 'Claiming the first owner',
|
|
9
|
-
signIn: 'Opening
|
|
9
|
+
signIn: 'Opening your application',
|
|
10
10
|
hosting: 'Deploying to your Cloudflare account',
|
|
11
11
|
complete: 'Your application is running locally',
|
|
12
12
|
built: 'Your application is built',
|
package/onboarding/adapter.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { credentialValues } from './redaction.mjs';
|
|
|
10
10
|
import { dependencyEnvironment } from './dependency-environment.mjs';
|
|
11
11
|
import { labels } from './adapter-labels.mjs';
|
|
12
12
|
import { chooseOrigin, prepareSettings, readSettings } from './adapter-settings.mjs';
|
|
13
|
-
import {listenerPorts,listenerOwnership} from './process-diagnostics.mjs';
|
|
13
|
+
import {listenerPorts,listenerOwnership,inspectionContext} from './process-diagnostics.mjs';
|
|
14
14
|
import { appFetch } from './app-fetch.mjs';
|
|
15
15
|
import { owner, signIn } from './adapter-auth.mjs';
|
|
16
16
|
import { installerDevKey } from './dev-identity.mjs';
|
|
@@ -34,11 +34,10 @@ const hookNames = ['node', 'tools', 'prepare', 'prepareData', 'dependencies', 'o
|
|
|
34
34
|
|
|
35
35
|
// Feature flags shown by the shared browser flow must describe what this
|
|
36
36
|
// adapter really does. localTrialWithoutEmail claims that sign-in works with no
|
|
37
|
-
// mail provider
|
|
38
|
-
// outbox; hosting needs a hosting hook.
|
|
37
|
+
// mail provider; hosting needs a hosting hook.
|
|
39
38
|
export function adapterFeatures(hooks, features = {}) {
|
|
40
39
|
const result = { hosting: false, github: false, artwork: false, ...features };
|
|
41
|
-
if (result.localTrialWithoutEmail === true && !hooks.signIn) throw new TypeError('localTrialWithoutEmail needs a signIn hook
|
|
40
|
+
if (result.localTrialWithoutEmail === true && !hooks.signIn) throw new TypeError('localTrialWithoutEmail needs a signIn hook.');
|
|
42
41
|
if (result.hosting === true && !hooks.hosting) throw new TypeError('features.hosting needs a hosting hook.');
|
|
43
42
|
if (hooks.hosting && result.hosting !== true) throw new TypeError('A hosting hook must be declared with features.hosting.');
|
|
44
43
|
return Object.freeze(result);
|
|
@@ -57,7 +56,7 @@ export function localInstaller(hooks = {}) {
|
|
|
57
56
|
context.ownerClaim=context.manifest?.steps.find(step=>step.type==='owner-claim');
|
|
58
57
|
options.onContext?.(context);
|
|
59
58
|
const verb = options.verb ?? 'installer';
|
|
60
|
-
|
|
59
|
+
await store.configureQueue?.({verb});
|
|
61
60
|
await requirements(context, hooks);
|
|
62
61
|
if (['installer', 'setup'].includes(verb) && hooks.prepare) await hooks.prepare(context);
|
|
63
62
|
if (verb === 'installer' && hooks.dependencies !== false) await phase(context, hooks, 'dependencies', hooks.dependencies ?? ['pnpm', ['install', '--frozen-lockfile']]);
|
|
@@ -76,9 +75,7 @@ export function localInstaller(hooks = {}) {
|
|
|
76
75
|
if (typeof hooks.owner === 'function' || Array.isArray(hooks.owner)) await phase(context, hooks, 'owner', hooks.owner);
|
|
77
76
|
else await owner(context, hooks.owner);
|
|
78
77
|
}
|
|
79
|
-
|
|
80
|
-
const devIdentity = verb === 'dev' && options.devKey && !options.devLogin;
|
|
81
|
-
if ((['installer', 'setup', 'dev', 'preview'].includes(verb) || (verb === 'outbox' && options.requestSignIn)) && hooks.signIn && !devIdentity) await signIn(context, hooks.signIn);
|
|
78
|
+
if (['installer', 'setup', 'dev', 'preview'].includes(verb) && hooks.signIn) await signIn(context, hooks.signIn);
|
|
82
79
|
if (verb === 'installer' && hooks.hosting) await hosting(context, hooks.hosting);
|
|
83
80
|
store.state.appUrl = context.appUrl ?? (context.app ? context.origin : context.hostedUrl ?? context.origin);
|
|
84
81
|
if (context.hostedUrl) store.state.hostedUrl = context.hostedUrl;
|
|
@@ -91,7 +88,7 @@ export function localInstaller(hooks = {}) {
|
|
|
91
88
|
try {
|
|
92
89
|
let operation;
|
|
93
90
|
if(store.ownCleanup){operation=await recoverInterrupted(root)??await localOperation(root);let released=false;release=async()=>{if(!released){released=true;await operation.release();}};store.ownCleanup(signal,release);}
|
|
94
|
-
//
|
|
91
|
+
// The installer page offers the checkout's one-click dev entry after setup.
|
|
95
92
|
const devKey = await installerDevKey(root);
|
|
96
93
|
if (devKey) store.addSecrets?.([devKey]);
|
|
97
94
|
await run(root, input, store, child => { app = child; onApp(child); }, signal, { operationToken:operation?.token,devKey:devKey??undefined,onContext(value) { context = value; } });
|
|
@@ -233,12 +230,12 @@ async function start(context, hooks) {
|
|
|
233
230
|
// its /health would pass. Claim and sign in only against the process this
|
|
234
231
|
// setup started.
|
|
235
232
|
let ownership;
|
|
236
|
-
try { ownership=await listenerOwnership(child.pid,expectedPort,context.runtimePort?'127.0.0.1':new URL(url).hostname); }
|
|
233
|
+
try { ownership=await listenerOwnership(child.pid,expectedPort,context.runtimePort?'127.0.0.1':new URL(url).hostname,inspectionContext({port:expectedPort,verb:context.verb??'setup'})); }
|
|
237
234
|
catch(error){throw installationFailure('command_failed',{step:'start',diagnostic:error});}
|
|
238
235
|
if (ownership.status !== 'owned') {
|
|
239
236
|
const message = (store.redact??(value=>value))(ownership.status==='other'
|
|
240
237
|
? `Another process answered on port ${expectedPort}; the application did not bind it. Listener PID ${ownership.pid}. Nothing was sent. Stop that process or choose another port, then run setup again.`
|
|
241
|
-
: `
|
|
238
|
+
: `Could not confirm the application on port ${expectedPort}: repeated inspection found no listener on the health address. Nothing was sent. Check the application binding, then run rer ${context.verb??'setup'} again.`);
|
|
242
239
|
store.report?.(message);
|
|
243
240
|
throw installationFailure('command_failed', { step: 'start', diagnostic: commandFailure(message, {}) });
|
|
244
241
|
}
|
package/onboarding/app-fetch.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Requests rer itself makes to a local app's own origin (health, sign-in,
|
|
2
|
-
//
|
|
2
|
+
// dev identity). A directly served origin uses fetch. A front-door
|
|
3
3
|
// origin (http://NAME.localhost:PORT) is never resolved and never goes through
|
|
4
4
|
// the door: rer connects with node:http to that checkout's own proxy on
|
|
5
5
|
// 127.0.0.1, which keeps the Host header (fetch drops a Host override, and musl
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { appFetch } from './app-fetch.mjs';
|
|
2
2
|
// Setup opens app-local approvals before native bootstrap. Existing owners must
|
|
3
|
-
// prove
|
|
4
|
-
export async function approveSetupDependencies(context, post
|
|
3
|
+
// prove possession of their private local session secret through the dev entry.
|
|
4
|
+
export async function approveSetupDependencies(context, post) {
|
|
5
5
|
const selected=(context.manifest?.dependencies??[]).filter(d=>context.input[d.address]);
|
|
6
6
|
if(!selected.length)return;
|
|
7
7
|
const failure=()=>Error('Application dependency approval failed. Complete fresh app-owner approval before linking.');
|
|
@@ -16,19 +16,9 @@ export async function approveSetupDependencies(context, post, messages) {
|
|
|
16
16
|
if(setup.status!==409)throw failure();
|
|
17
17
|
await setup.body?.cancel();
|
|
18
18
|
if(!cookie) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
let id;
|
|
23
|
-
for(let attempt=0;attempt<50 && !id;attempt++) {id=(await messages(context,path,email)).find(value=>!before.has(value));if(!id)await new Promise(resolve=>setTimeout(resolve,200));}
|
|
24
|
-
if(!id)throw failure();
|
|
25
|
-
const response=await appFetch(new URL(path+'?message='+encodeURIComponent(id),context.origin),{signal:context.signal,headers:context.devKey?{'x-rer-dev-key':context.devKey}:{}});
|
|
26
|
-
if(!response.ok)throw failure();
|
|
27
|
-
const html=await response.text(),href=/<a\b[^>]*class="open"[^>]*href="([^"]+)"/.exec(html)?.[1];
|
|
28
|
-
if(!href)throw failure();
|
|
29
|
-
const url=new URL(href.replaceAll('&','&'));if(url.origin!==context.origin || url.pathname!=='/auth/confirm')throw failure();
|
|
30
|
-
const confirmed=await post(context,'/auth/confirm',{token:url.searchParams.get('token')});
|
|
31
|
-
if(confirmed.status!==303)throw failure();cookie=confirmed.headers.get('set-cookie')?.split(';')[0];await confirmed.body?.cancel();
|
|
19
|
+
const confirmed=await post(context,'/auth/local/cli-session',{});
|
|
20
|
+
if(confirmed.status!==303)throw failure();
|
|
21
|
+
cookie=confirmed.headers.get('set-cookie')?.split(';')[0];await confirmed.body?.cancel();
|
|
32
22
|
if(!cookie)throw failure();context.store.addSecrets?.([cookie]);
|
|
33
23
|
}
|
|
34
24
|
const approved=await appFetch(new URL('/auth/dependencies/relink',context.origin),{method:'POST',redirect:'manual',signal:context.signal,headers:{Origin:context.origin,'Content-Type':'application/json',Cookie:cookie},body:JSON.stringify(body)});
|
|
@@ -17,7 +17,7 @@ export async function declaresDevIdentity(root) {
|
|
|
17
17
|
|
|
18
18
|
// The checkout's dev key for a devIdentity seed's installer, created as rer setup
|
|
19
19
|
// does, or null for any other seed. The temporary app must receive it (the start
|
|
20
|
-
// hook's context.devKey)
|
|
20
|
+
// hook's context.devKey) for its one-click development sign-in.
|
|
21
21
|
export async function installerDevKey(root) {
|
|
22
22
|
return await declaresDevIdentity(root) ? (await keys()).ensureDevKey(root) : null;
|
|
23
23
|
}
|
|
@@ -13,7 +13,7 @@ import { labels } from './adapter-labels.mjs';
|
|
|
13
13
|
const rerEntry=root=>existsSync(join(root,'scripts/rer.mjs'))?'scripts/rer.mjs':fileURLToPath(new URL('../bin/rer.mjs',import.meta.url));
|
|
14
14
|
|
|
15
15
|
// The browser and terminal use the same bounded setup journey. Its temporary
|
|
16
|
-
// runtime is gone before that lease releases. The foreground
|
|
16
|
+
// runtime is gone before that lease releases. The foreground development server belongs
|
|
17
17
|
// to the installer process, outside the bounded job's descendant tree.
|
|
18
18
|
export async function installOperator(root,input,store,onApp,signal,hooks){
|
|
19
19
|
let answer,app,step='setup';
|
|
@@ -30,20 +30,19 @@ export async function installOperator(root,input,store,onApp,signal,hooks){
|
|
|
30
30
|
step='dependencies';await store.step(labels.dependencies);await run(labels.dependencies,['install']);
|
|
31
31
|
step='setup';await store.step(labels.build);await run(labels.build,['setup','--answers',relative(root,answer),'--host',address.hostname.replace(/^\[|\]$/g,''),'--port',address.port]);
|
|
32
32
|
await unlink(answer);answer=undefined;
|
|
33
|
-
//
|
|
33
|
+
// Dev's ready event carries RER_OPEN; keep the checkout's dev key out of this log.
|
|
34
34
|
const devKey=/^RER_DEV_KEY=(\S+)$/m.exec(await readFile(join(root,'.rer/local/dev-key.env'),'utf8').catch(()=>''))?.[1];if(devKey)store.addSecrets?.([devKey]);
|
|
35
35
|
step='start';await store.step(labels.start);
|
|
36
|
-
app=store.spawn(labels.start,process.execPath,[rerEntry(root),'
|
|
36
|
+
app=store.spawn(labels.start,process.execPath,[rerEntry(root),'dev','--non-interactive','--json'],{cwd:root,signal,env});onApp(app);
|
|
37
37
|
let buffer='',ready=false,openUrl;
|
|
38
|
-
app.stdout.on('data',chunk=>{buffer+=chunk;let end;while((end=buffer.indexOf('\n'))>=0){const line=buffer.slice(0,end);buffer=buffer.slice(end+1);try{const event=JSON.parse(line);if(event.version===1&&event.verb==='
|
|
38
|
+
app.stdout.on('data',chunk=>{buffer+=chunk;let end;while((end=buffer.indexOf('\n'))>=0){const line=buffer.slice(0,end);buffer=buffer.slice(end+1);try{const event=JSON.parse(line);if(event.version===1&&event.verb==='dev'&&event.event==='ready'&&event.url===origin){ready=true;openUrl=event.openUrl;}}catch{}}});
|
|
39
39
|
await store.waitForReady(labels.start,app,async probeSignal=>{
|
|
40
40
|
if(!ready)return {ready:false,message:'Waiting for managed application readiness'};
|
|
41
41
|
const response=await fetch(origin+'/health',{signal:probeSignal});
|
|
42
42
|
return {ready:response.ok&&(await response.json()).status==='ok'};
|
|
43
43
|
},{signal,timeoutMs:1200000});
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
store.state.appUrl=origin+'/__dev/outbox';store.state.devOpen=Boolean(openUrl?.startsWith(origin+'/'));await store.step(labels.complete);await store.phase('complete');
|
|
44
|
+
// State never holds the key; /api/open-app supplies the browser entry.
|
|
45
|
+
store.state.appUrl=origin+'/setup';store.state.devOpen=Boolean(openUrl?.startsWith(origin+'/'));await store.step(labels.complete);await store.phase('complete');
|
|
47
46
|
}catch(error){
|
|
48
47
|
if(app)await store.stop(app);await store.stopCommands?.(signal);
|
|
49
48
|
store.state.error=installationFailureMessage(installationFailure('command_failed',{step,diagnostic:error}));await store.phase('failed');
|
|
@@ -21,25 +21,25 @@ export function operatorInstaller({ database, features, prepare, prepareData })
|
|
|
21
21
|
build: ['pnpm', ['run', 'build:app']],
|
|
22
22
|
// A demo migrates its own fresh state folder, never the checkout's.
|
|
23
23
|
migrate: ({ demo }) => ['pnpm', ['exec', 'wrangler', 'd1', 'migrations', 'apply', database, '--local', '--persist-to', demo?.state ?? '.wrangler/state', '--config', 'dist/server/wrangler.json']],
|
|
24
|
-
// Setup uses
|
|
25
|
-
start:
|
|
24
|
+
// Setup uses the local entry for owner-side dependency approval without mail.
|
|
25
|
+
start: developmentTarget,
|
|
26
26
|
owner: { existingOwnerViaSignIn: true, displayName: input => input.displayName || 'Owner' },
|
|
27
27
|
signIn: { emailKey: 'OWNER_EMAIL', returnTo: '/setup' },
|
|
28
28
|
});
|
|
29
29
|
// A demo migrates and claims the owner in its own state, so it never opens the
|
|
30
30
|
// checkout's database: even read-only, SQLite rewrites its -shm index.
|
|
31
|
-
return {...lifecycle,localPrerequisites:async({root,vars,
|
|
31
|
+
return {...lifecycle,localPrerequisites:async({root,vars,demo})=>vars.AUTH_LOCAL==='true'&&vars.MAIL_PROVIDER==='development'&&Boolean(vars.SESSION_SECRET)&&(demo||await operatorPrerequisites(root)),install:(root,input,store,onApp,signal)=>installOperator(root,input,store,onApp,signal,lifecycle.hooks)};
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
// Only local runtimes receive the dev key; vite.config.ts passes it to `vite dev` alone.
|
|
35
35
|
// No runtime rer starts serves the Local Explorer: it reads and writes the store
|
|
36
36
|
// without the key. trafficProxy also refuses /cdn-cgi/* on the public listener.
|
|
37
|
-
const devBindings =
|
|
37
|
+
const devBindings = devKey => devKey ? { RER_DEV_KEY: devKey, RER_DEV_IDENTITY: 'on' } : {};
|
|
38
38
|
const internalPort = port => { if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error('A local runtime requires the traffic proxy internal port.'); return String(port); };
|
|
39
39
|
const developmentEnvironment = () => { const { RER_MODELS_SERVICE, RER_MODELS_KEY, RER_DEMO, RER_DEMO_EXPIRES, RER_STATE_DIR, ...env } = process.env; return env; };
|
|
40
40
|
// A demo's Vite persists to its own folder (the seed's vite.config reads RER_STATE_DIR)
|
|
41
41
|
// and its Worker sees RER_DEMO=1 and the demo's end (modules/demo).
|
|
42
42
|
const demoBindings = demo => demo ? { RER_DEMO: '1', RER_DEMO_EXPIRES: demo.ends, RER_STATE_DIR: demo.state } : {};
|
|
43
|
-
export const developmentTarget = ({ root, origin, runtimePort, devKey,
|
|
43
|
+
export const developmentTarget = ({ root, origin, runtimePort, devKey, modelsLive, demo }) => [process.execPath, [projectViteBinary(root), 'dev', '--host', '127.0.0.1', '--port', internalPort(runtimePort), '--strictPort'], { env: { ...developmentEnvironment(), PATH: join(root, 'node_modules', '.bin') + delimiter + (process.env.PATH ?? ''), RER_DEV_ORIGIN: origin, WRANGLER_SEND_METRICS: 'false', X_LOCAL_EXPLORER: 'false', ...devBindings(devKey), ...(modelsLive ? { RER_MODELS_SERVICE: modelsLive.baseUrl, RER_MODELS_KEY: modelsLive.apiKey } : {}), ...demoBindings(demo) } }];
|
|
44
44
|
|
|
45
45
|
export const previewTarget = ({ origin, runtimePort, devKey, scheduled }) => [process.execPath, [fileURLToPath(new URL('./production-runtime.mjs', import.meta.url))], { env: { ...process.env, RER_DEV_ORIGIN: origin, RER_RUNTIME_HOST: '127.0.0.1', RER_RUNTIME_PORT: internalPort(runtimePort), WRANGLER_SEND_METRICS: 'false', CLOUDFLARE_INCLUDE_PROCESS_ENV: 'false', X_LOCAL_EXPLORER: 'false', RER_RUNTIME_TRIGGERS: scheduled ? '1' : '0', ...(devKey ? { RER_DEV_KEY: devKey } : {}) } }];
|
|
@@ -5,7 +5,7 @@ import { DatabaseSync } from 'node:sqlite';
|
|
|
5
5
|
// A read-only preflight prevents an empty resource directory from being treated
|
|
6
6
|
// as completed setup. Ordinary application sign-in then verifies the actual
|
|
7
7
|
// configured binding before readiness; no database or owner is created here.
|
|
8
|
-
export async function operatorPrerequisites(root
|
|
8
|
+
export async function operatorPrerequisites(root){
|
|
9
9
|
const migrations=(await readdir(join(root,'migrations/core'))).filter(name=>name.endsWith('.sql'));
|
|
10
10
|
const directory=join(root,'.wrangler/state/v3/d1/miniflare-D1DatabaseObject');
|
|
11
11
|
let files;try{
|
|
@@ -18,11 +18,10 @@ export async function operatorPrerequisites(root,email){
|
|
|
18
18
|
db=new DatabaseSync(join(directory,file.name),{readOnly:true});
|
|
19
19
|
const applied=new Set(db.prepare('SELECT name FROM d1_migrations').all().map(row=>row.name));
|
|
20
20
|
const claimed=db.prepare('SELECT COUNT(*) AS count FROM oa_bootstrap').get().count;
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
const saved=db.prepare('SELECT COUNT(*) AS count FROM oa_operators WHERE email=?').get(email).count;
|
|
21
|
+
// The durable claim survives email corrections and owner transfers. Dev
|
|
22
|
+
// signs in as the active owner selected by its owner persona.
|
|
24
23
|
const owners=db.prepare("SELECT COUNT(*) AS count FROM oa_operators WHERE role='owner' AND status='active'").get().count;
|
|
25
|
-
if(claimed===1&&
|
|
24
|
+
if(claimed===1&&owners>0&&migrations.every(name=>applied.has(name)))return true;
|
|
26
25
|
}catch{/* A missing/corrupt/unrelated database cannot prove prior setup. */}
|
|
27
26
|
finally{db?.close();}
|
|
28
27
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createServer } from 'node:net';
|
|
2
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
3
|
+
import { inspectionContext, portListener, uncheckedInspection } from './process-diagnostics.mjs';
|
|
4
|
+
|
|
5
|
+
async function bind(host, port) {
|
|
6
|
+
const socket = createServer();
|
|
7
|
+
try {
|
|
8
|
+
await new Promise((resolve, reject) => { socket.once('error', reject); socket.listen({ host, port, exclusive: true }, resolve); });
|
|
9
|
+
return { available: true };
|
|
10
|
+
} catch (error) {
|
|
11
|
+
// IPv6 can be disabled on the host; it must not prevent an IPv4 launch.
|
|
12
|
+
return { available: host === '::1' && ['EADDRNOTAVAIL', 'EAFNOSUPPORT'].includes(error.code), code: error.code };
|
|
13
|
+
} finally { if (socket.listening) await new Promise(resolve => socket.close(resolve)); }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// A failed diagnostic is unknown, never evidence of a foreign owner. A real
|
|
17
|
+
// bind can still prove availability. If a bind loses a race but inspection
|
|
18
|
+
// finds no listener, retry the bind within the same inspection deadline.
|
|
19
|
+
export async function probePort(host, port, { context = inspectionContext({ port }), hosts = [host], anyAddress = false } = {}) {
|
|
20
|
+
const bindings = async () => {
|
|
21
|
+
for (const address of hosts) { const result = await bind(address, port); if (!result.available) return result; }
|
|
22
|
+
return { available: true };
|
|
23
|
+
};
|
|
24
|
+
let bound = await bindings(), listener, unchecked;
|
|
25
|
+
if (!bound.available && bound.code !== 'EADDRINUSE') return bound;
|
|
26
|
+
try { listener = await portListener(port, anyAddress ? undefined : host, context); }
|
|
27
|
+
catch (error) { if (!uncheckedInspection(error)) throw error; unchecked = error; }
|
|
28
|
+
if (listener) return { available: false, listener };
|
|
29
|
+
// Inspecting sockets may have taken seconds. Bind again against the current
|
|
30
|
+
// state, including when the inspection consumed the rest of the budget.
|
|
31
|
+
do {
|
|
32
|
+
bound = await bindings();
|
|
33
|
+
if (bound.available || bound.code !== 'EADDRINUSE') return bound;
|
|
34
|
+
const remaining = context.deadline - performance.now();
|
|
35
|
+
if (remaining <= 0) return { ...bound, unchecked };
|
|
36
|
+
await delay(Math.min(100, remaining));
|
|
37
|
+
} while (true);
|
|
38
|
+
}
|
|
@@ -4,13 +4,15 @@ import {lstat,realpath,readFile,readdir,readlink} from 'node:fs/promises';
|
|
|
4
4
|
import {basename,join} from 'node:path';
|
|
5
5
|
import {homedir} from 'node:os';
|
|
6
6
|
import {isIP} from 'node:net';
|
|
7
|
-
import {
|
|
7
|
+
import {setTimeout as delay} from 'node:timers/promises';
|
|
8
|
+
import {commandFailure,approvedFailure} from './failures.mjs';
|
|
8
9
|
const exec=promisify(execFile);
|
|
9
10
|
// macOS supplies lsof in /usr/sbin, which a command PATH may omit.
|
|
10
11
|
// Diagnose sockets with the system utility even when that PATH is constrained.
|
|
11
12
|
const lsof=process.platform==='darwin'?'/usr/sbin/lsof':'lsof';
|
|
12
13
|
// One monotonic budget covers every command in an ownership decision.
|
|
13
|
-
export const inspectionContext=()=>({deadline:performance.now()+15000});
|
|
14
|
+
export const inspectionContext=(details={})=>({deadline:performance.now()+15000,...details});
|
|
15
|
+
export const uncheckedInspection=error=>approvedFailure(error)?.ownershipUnchecked===true;
|
|
14
16
|
const run=async(command,args,context=inspectionContext(),{maxBuffer=1024*1024,noMatch=false}={})=>{
|
|
15
17
|
const invocation=[command,...args].join(' ').replaceAll(homedir(),'~');
|
|
16
18
|
let failure;
|
|
@@ -27,7 +29,9 @@ const run=async(command,args,context=inspectionContext(),{maxBuffer=1024*1024,no
|
|
|
27
29
|
failure=error.killed ? `timed out after ${timeout} ms` : `failed (${error.code??error.signal??'unknown error'}${typeof error.stderr==='string'&&error.stderr.trim()?'; diagnostic output':''}; attempt bound ${timeout} ms)`;
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
|
-
|
|
32
|
+
const subject=context.port?`who uses port ${context.port}`:'local process ownership';
|
|
33
|
+
const cause=failure?.startsWith('timed out')||performance.now()>=context.deadline?'in time (system busy)':'because the system process check failed';
|
|
34
|
+
throw commandFailure(`Could not check ${subject} ${cause}. Run rer ${context.verb??'dev'} again. No other owner was identified.\nOwnership check: ${invocation} ${failure??'total inspection deadline exhausted'} (at most 2 attempts; shared total bound 15000 ms).`,{ownershipUnchecked:true});
|
|
31
35
|
};
|
|
32
36
|
|
|
33
37
|
export async function processName(pid,context=inspectionContext()){
|
|
@@ -126,12 +130,17 @@ function matchingListener(rows,port,host){
|
|
|
126
130
|
const row=rows.find(row=>row.sockets.some(socket=>serves(socket,port,host)===true));
|
|
127
131
|
if(row)return row;
|
|
128
132
|
if(rows.some(row=>row.sockets.some(socket=>serves(socket,port,host)===undefined))){
|
|
129
|
-
throw commandFailure(`
|
|
133
|
+
throw commandFailure(`Could not check who uses port ${port}: a wildcard socket's address family does not prove it serves ${host}. No other owner was identified. Bind the application to the health address explicitly, then run rer dev again.`,{ownershipUnchecked:true});
|
|
130
134
|
}
|
|
131
135
|
}
|
|
132
136
|
export async function portListener(port,host,context=inspectionContext()){
|
|
137
|
+
context.port=port;
|
|
133
138
|
const row=matchingListener(await listeners(undefined,context,port),port,host);
|
|
134
|
-
|
|
139
|
+
if(!row)return;
|
|
140
|
+
// Labels improve the instruction, but a slow optional label cannot erase a
|
|
141
|
+
// positive PID/socket observation or turn it into an unchecked accusation.
|
|
142
|
+
const optional=async action=>{try{return await action();}catch(error){if(!uncheckedInspection(error))throw error;}};
|
|
143
|
+
return {pid:row.pid,command:await optional(()=>processName(row.pid,context))??'process',cwd:await optional(()=>processCwd(row.pid,context))};
|
|
135
144
|
}
|
|
136
145
|
async function descendants(pid,context){
|
|
137
146
|
const rows=(await run('/bin/ps',['-axo','pid=,ppid='],context)).trim().split('\n').map(line=>line.trim().split(/\s+/).map(Number));
|
|
@@ -146,6 +155,8 @@ export async function listenerPorts(pid,context=inspectionContext()){
|
|
|
146
155
|
// reach either loopback family, so it also needs a completed inspection with
|
|
147
156
|
// no foreign listener on either address before owner/sign-in can proceed.
|
|
148
157
|
export async function listenerOwnership(pid,port,host,context=inspectionContext()){
|
|
158
|
+
context.port=port;
|
|
159
|
+
do {
|
|
149
160
|
const owned=await descendants(pid,context);
|
|
150
161
|
const ownRows=await listeners([...owned],context);
|
|
151
162
|
const own=ownRows.find(row=>owned.has(row.pid)&&row.sockets.some(socket=>serves(socket,port,host)===true));
|
|
@@ -157,7 +168,12 @@ export async function listenerOwnership(pid,port,host,context=inspectionContext(
|
|
|
157
168
|
if(foreign)return {status:'other',pid:foreign.pid};
|
|
158
169
|
}
|
|
159
170
|
const row=matchingListener(rows,port,host);
|
|
160
|
-
return
|
|
171
|
+
if(row)return {status:owned.has(row.pid)?'owned':'other',pid:row.pid};
|
|
172
|
+
const remaining=context.deadline-performance.now();
|
|
173
|
+
if(remaining<=0)return {status:'none'};
|
|
174
|
+
await delay(Math.min(100,remaining));
|
|
175
|
+
}while(performance.now()<context.deadline);
|
|
176
|
+
return {status:'none'};
|
|
161
177
|
}
|
|
162
178
|
// The caller and the chain that launched it (an installer server running setup,
|
|
163
179
|
// pnpm, a shell) act for this command, never against it.
|
|
@@ -168,7 +184,20 @@ async function callerLineage(context){
|
|
|
168
184
|
return lineage;
|
|
169
185
|
}
|
|
170
186
|
export async function localProcessConflict(root,savedOrigin,context=inspectionContext()){
|
|
171
|
-
root=await realpath(root);const
|
|
187
|
+
root=await realpath(root);const lineage=await callerLineage(context);
|
|
188
|
+
// Inspect canonical state before optional socket diagnostics spend the shared
|
|
189
|
+
// budget. This is file custody, not a claim that another process owns a port.
|
|
190
|
+
const state=join(root,'.wrangler/state');
|
|
191
|
+
let hasState=true;try{await lstat(state);}catch(error){if(error.code==='ENOENT')hasState=false;else throw error;}
|
|
192
|
+
let held;
|
|
193
|
+
if(hasState){
|
|
194
|
+
if(process.platform==='linux'){for(const pid of await linuxPids())if(!lineage.has(pid)&&(await descriptors(pid)).some(path=>path.startsWith(state+'/'))){held={pid};break;}}
|
|
195
|
+
else held=records(await run(lsof,['-nP','-b','-w','-Fpn'],context,{maxBuffer:16*1024*1024})).find(row=>!lineage.has(row.pid)&&row.names.some(path=>path.startsWith(state+'/')));
|
|
196
|
+
if(held)return {pid:held.pid,command:await processName(held.pid,context),reason:'the canonical local state'};
|
|
197
|
+
}
|
|
198
|
+
let all;
|
|
199
|
+
try{all=await listeners(undefined,context);}
|
|
200
|
+
catch(error){if(!uncheckedInspection(error)||context.verb==='reset')throw error;return;}
|
|
172
201
|
const cwdRecords=process.platform!=='linux'&&all.length?records(await run(lsof,['-nP','-b','-w','-a','-p',all.map(row=>row.pid).join(','),'-d','cwd','-Fpn'],context)):[];
|
|
173
202
|
let port;try{const url=new URL(savedOrigin);port=Number(url.port||80);}catch{}
|
|
174
203
|
for(const row of all){
|
|
@@ -181,17 +210,4 @@ export async function localProcessConflict(root,savedOrigin,context=inspectionCo
|
|
|
181
210
|
if(onSavedPort&&places.length&&!places.some(place=>place===root||place.startsWith(root+'/')))continue;
|
|
182
211
|
if(onSavedPort||inCheckout)return {pid:row.pid,command:await processName(row.pid,context),reason:onSavedPort?`saved local port ${port}`:'this checkout'};
|
|
183
212
|
}
|
|
184
|
-
// A process may hold the canonical database without listening. Inspect only
|
|
185
|
-
// actual state files, never broad checkout contents or a process environment.
|
|
186
|
-
const state=join(root,'.wrangler/state');
|
|
187
|
-
try{await lstat(state);}catch(error){if(error.code==='ENOENT')return;throw error;}
|
|
188
|
-
let held;
|
|
189
|
-
if(process.platform==='linux'){for(const pid of await linuxPids())if(!lineage.has(pid)&&(await descriptors(pid)).some(path=>path.startsWith(state+'/'))){held={pid};break;}}
|
|
190
|
-
else {
|
|
191
|
-
// +D requires blocking pathname metadata even for a narrow directory. Read
|
|
192
|
-
// kernel-provided open paths instead, then match only canonical state files.
|
|
193
|
-
// This preflight protects data held by processes outside the app's tree.
|
|
194
|
-
held=records(await run(lsof,['-nP','-b','-w','-Fpn'],context,{maxBuffer:16*1024*1024})).find(row=>!lineage.has(row.pid)&&row.names.some(path=>path.startsWith(state+'/')));
|
|
195
|
-
}
|
|
196
|
-
if(held)return {pid:held.pid,command:await processName(held.pid,context),reason:'the canonical local state'};
|
|
197
213
|
}
|
package/onboarding/server.mjs
CHANGED
|
@@ -98,7 +98,7 @@ export async function startInstaller(root,{seed,port=0,answers,secretInput,noPre
|
|
|
98
98
|
if(req.method==='GET'&&path==='/api/open-app'){
|
|
99
99
|
const key=store.state.phase==='complete'&&store.state.devOpen?/^RER_DEV_KEY=([A-Za-z0-9_-]{43,256})$/m.exec(await readFile(join(root,'.rer/local/dev-key.env'),'utf8').catch(()=>''))?.[1]:undefined;
|
|
100
100
|
if(!key)return json(404,{error:'No dev key for this installation.'});
|
|
101
|
-
const app=new URL(store.state.appUrl);return json(200,{url:`${app.origin}/__dev/key#${new URLSearchParams({'rer-dev':key,next:'/
|
|
101
|
+
const app=new URL(store.state.appUrl);return json(200,{url:`${app.origin}/__dev/key#${new URLSearchParams({'rer-dev':key,as:'owner',next:'/auth/dev/enter?as=owner&returnTo='+encodeURIComponent(app.pathname+app.search)})}`});
|
|
102
102
|
}
|
|
103
103
|
if(req.method==='GET'&&path==='/api/agent-handoff')return json(200,(seed.handoff||agentHandoff)(root,origin,store.state.sessionId,seed));
|
|
104
104
|
if(req.method==='GET'&&path==='/api/state'){await workspaceArt?.refresh();store.state.known.secretReadiness=vault.readiness(store.state.draft);return json(200,store.state);}
|
package/onboarding/ui/app.js
CHANGED
|
@@ -327,7 +327,7 @@ function applyState(next) {
|
|
|
327
327
|
else if (next.phase === 'failed') error(failureHeadline(next.error, failure.step));
|
|
328
328
|
else error();
|
|
329
329
|
if (next.phase === 'complete' && next.appUrl) { try { const url = new URL(next.appUrl); if (['http:', 'https:'].includes(url.protocol)) { $('#open').href = url.href; $('#open').hidden = false; } } catch { error('The application address is invalid. Check the installer terminal.'); } }
|
|
330
|
-
//
|
|
330
|
+
// One-click development entry uses a key exchange; the key stays out of saved state.
|
|
331
331
|
if (next.phase === 'complete' && next.devOpen && !$('#open').dataset.devOpen) { $('#open').dataset.devOpen = 'pending'; request('/api/open-app').then(({ url }) => { if (new URL(url).origin === new URL(next.appUrl).origin) { $('#open').href = url; $('#open').dataset.devOpen = 'ready'; } }).catch(() => { delete $('#open').dataset.devOpen; }); }
|
|
332
332
|
}
|
|
333
333
|
function failureHeadline(message, step) {
|
package/operations/README.md
CHANGED
|
@@ -15,6 +15,9 @@ adapter; it does not return the operations manifest itself or test environment
|
|
|
15
15
|
values.
|
|
16
16
|
|
|
17
17
|
`check` validates declared command input files and required enabled loops.
|
|
18
|
+
It also validates surface and setup declarations in the standard delivery
|
|
19
|
+
packaging policies and committed integration spec, including unique
|
|
20
|
+
`originVariable` values across surfaces.
|
|
18
21
|
The first-party profile also enforces the manifest's `seedContract` marker,
|
|
19
22
|
adapter hooks and flags, command targets, package aliases, tool pins, complete
|
|
20
23
|
portable source inventory and copied source hashes. An explicit
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runeditrun/rer",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.20",
|
|
4
4
|
"description": "The rer command: install, set up, run and launch Run Edit Run checkouts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -76,8 +76,10 @@
|
|
|
76
76
|
"./modules/operator-auth/accounts/native": "./modules/operator-auth/accounts/native.mjs",
|
|
77
77
|
"./modules/operator-auth/dev": "./modules/operator-auth/dev/index.mjs",
|
|
78
78
|
"./modules/operator-auth/dev-admission": "./modules/operator-auth/dev-admission.mjs",
|
|
79
|
-
"./modules/operator-auth/dev/badge": "./modules/operator-auth/dev/badge.mjs",
|
|
80
79
|
"./modules/operator-auth/identity/email-link": "./modules/operator-auth/identity/email-link/index.mjs",
|
|
80
|
+
"./modules/demo": "./modules/demo/index.mjs",
|
|
81
|
+
"./modules/demo/label": "./modules/demo/label.mjs",
|
|
82
|
+
"./modules/demo/vite": "./modules/demo/vite.mjs",
|
|
81
83
|
"./modules/owner-claim": "./modules/owner-claim/index.mjs",
|
|
82
84
|
"./modules/dependencies": "./modules/dependencies/index.mjs",
|
|
83
85
|
"./internal/*": "./*",
|
|
@@ -11,7 +11,8 @@ from trust_bundle import anchor_values
|
|
|
11
11
|
from png_text import text_chunks
|
|
12
12
|
from media import sample_spans
|
|
13
13
|
from c2pa import certificate_spans
|
|
14
|
-
URI_AUTHORITY = re.compile(r'''(?
|
|
14
|
+
URI_AUTHORITY = re.compile(r'''//(?P<authority>[^/?#\s<>"']+)''')
|
|
15
|
+
SCHEME_CHARACTERS = frozenset('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+.-')
|
|
15
16
|
# Match raw, complete commit trailer lines; decoded or embedded prose cannot
|
|
16
17
|
# acquire trailer privileges. Only the address span is omitted from email checks.
|
|
17
18
|
COAUTHOR = re.compile(
|
|
@@ -37,19 +38,39 @@ def without_public_coauthor_addresses(data):
|
|
|
37
38
|
return bytes(result)
|
|
38
39
|
|
|
39
40
|
|
|
40
|
-
def
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
def without_transport_hosts(text):
|
|
42
|
+
pieces, offset = [], 0
|
|
43
|
+
for match in URI_AUTHORITY.finditer(text):
|
|
44
|
+
start = match.start()
|
|
45
|
+
colon = start - 1
|
|
46
|
+
if colon >= offset and text[colon] == ':':
|
|
47
|
+
# The optional scheme regex retried every suffix of a long run.
|
|
48
|
+
# Walk this gap once, stopping at the previous authority's end so
|
|
49
|
+
# matches keep the original substitution's non-overlapping bounds.
|
|
50
|
+
scheme = colon
|
|
51
|
+
while scheme > offset and text[scheme - 1] in SCHEME_CHARACTERS:
|
|
52
|
+
scheme -= 1
|
|
53
|
+
while scheme < colon and not text[scheme].isalpha():
|
|
54
|
+
scheme += 1
|
|
55
|
+
if scheme < colon:
|
|
56
|
+
start = scheme
|
|
57
|
+
userinfo, _, host = match['authority'].rpartition('@')
|
|
58
|
+
# Without a scheme, arbitrary //text can also be a source comment.
|
|
59
|
+
if start == match.start() and host.lower().split(':', 1)[0] not in REPOSITORY_HOSTS:
|
|
60
|
+
pieces.append(text[offset:match.end()])
|
|
61
|
+
else:
|
|
62
|
+
pieces.append(text[offset:start])
|
|
63
|
+
# Keep actual email-valued userinfo, including a decoded %40,
|
|
64
|
+
# while excluding an ordinary transport username@host delimiter.
|
|
65
|
+
pieces.append(userinfo)
|
|
66
|
+
offset = match.end()
|
|
67
|
+
pieces.append(text[offset:])
|
|
68
|
+
return ''.join(pieces)
|
|
48
69
|
|
|
49
70
|
|
|
50
71
|
def private_emails(text, config):
|
|
51
72
|
# URL paths, queries and fragments remain visible to email inspection.
|
|
52
|
-
email_text =
|
|
73
|
+
email_text = without_transport_hosts(without_required_notices(text))
|
|
53
74
|
email_text = re.sub(r'(?i)\b(?a:git@github\.com:)(?=[A-Za-z0-9]|\$\{[A-Za-z_$][A-Za-z0-9_.$]*\})', '', email_text)
|
|
54
75
|
# A package manager's patch filename joins the name and version with an at sign.
|
|
55
76
|
version = r'(?:v?[0-9]+(?:\.[0-9]+)*(?:-[A-Za-z0-9-]+)?|[a-f0-9]{40})(?:\.patch)?(?![A-Za-z0-9_.-])'
|