@runeditrun/rer 0.2.106 → 0.2.107
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/cli/deploy-command.mjs +3 -3
- package/cli/deploy-secrets.mjs +2 -2
- package/cli/deploy.mjs +7 -7
- package/cli/production-auth.mjs +12 -4
- package/cli/production-mail.mjs +8 -1
- package/global/CHANGELOG.md +14 -0
- package/modules/delivery-producer/declarations.mjs +13 -0
- package/modules/delivery-producer/mail.mjs +1 -1
- package/modules/operator-auth/accounts/business-team.mjs +6 -3
- package/onboarding/commands.mjs +11 -1
- package/package.json +1 -1
package/cli/deploy-command.mjs
CHANGED
|
@@ -86,7 +86,7 @@ export async function deployCommand(context) {
|
|
|
86
86
|
const plan = result?.plan ?? (!planned ? undefined : (await owner(['local-plan', '--declaration', path, '--environment', options.environment ?? 'production', ...await deployProductArguments(root, deployProductDirectory(declaration))], production.env, { cwd: root, localOnlyKeys })).plan);
|
|
87
87
|
result = { ...result, dryRun: true, deployed: false, providerChecked: false, plan };
|
|
88
88
|
const { signIn, mailOff } = await requireProductionAuth({ root, declaration, env: production.env, setupManifest, setupSeed: context.setupSeed, adapter, declarationPath: path, options }) ?? {};
|
|
89
|
-
if (mailOff) store.report(mailOffNotice(mailOff, options.environment ?? 'production'));
|
|
89
|
+
if (mailOff) store.report(mailOffNotice(mailOff, options.environment ?? 'production'), { names: mailOff.credentialNames });
|
|
90
90
|
// The one completion line: rer's own plan step (or its deliberate skip) succeeded. A hook's own line says only that the hook finished.
|
|
91
91
|
store.report('deploy: local dry run complete; no credentials were needed, no Cloudflare requests were made and nothing was changed remotely. Target secrets and remote readiness were not checked.');
|
|
92
92
|
const needed = [...new Set([...neededForRealDeploy({ declaration, env: production.env, signIn, secretsChecked: false }), ...(result.neededForRealDeploy ?? []), ...(extraNeeded ?? [])])];
|
|
@@ -124,7 +124,7 @@ export async function deployCommand(context) {
|
|
|
124
124
|
for (const value of [...kinds.privateValues(env), env.CLOUDFLARE_ACCOUNT_ID, ...(declaration.secrets ?? []).map(item => env[item.environment])].filter(Boolean)) addSecret(value);
|
|
125
125
|
const environment = options.environment ?? 'production';
|
|
126
126
|
// The hook uploads every value it is given: a generated secret it gets is the one the Worker keeps.
|
|
127
|
-
if (!options.dryRun) await keepHookSecrets({ root, environment, declaration, setupManifest, env, generated, reused, rotated, again: deployAgain(options), report: line => store.report(line) });
|
|
127
|
+
if (!options.dryRun) await keepHookSecrets({ root, environment, declaration, setupManifest, env, generated, reused, rotated, again: deployAgain(options), report: (line, more) => store.report(line, more) });
|
|
128
128
|
// A hook keeping the kit's record in its own state file named it; every kit
|
|
129
129
|
// step after the hook (inspect, secret, record-owner) reads that record.
|
|
130
130
|
let hookRecord = await hookState(root, environment);
|
|
@@ -187,7 +187,7 @@ export async function deployCommand(context) {
|
|
|
187
187
|
const { setupToken: _, ...result } = deployed;
|
|
188
188
|
return { ...result, ...(claimed ? { owner: claimed } : {}), dependenciesLinked: true };
|
|
189
189
|
});
|
|
190
|
-
if (claimed) store.report(`${claimed === 'claimed' ? 'Claimed the hosted owner' : 'The hosted owner was already claimed and was kept'}${recorded ? '; the one-time setup token was removed' : ''}. ${mailOff ? mailOffNotice(mailOff, environment) : `Sign in by email at ${result.origin}.`}
|
|
190
|
+
if (claimed) store.report(`${claimed === 'claimed' ? 'Claimed the hosted owner' : 'The hosted owner was already claimed and was kept'}${recorded ? '; the one-time setup token was removed' : ''}. ${mailOff ? mailOffNotice(mailOff, environment, recorded?.liveSecrets) : `Sign in by email at ${result.origin}.`}`, { names: mailOff?.credentialNames });
|
|
191
191
|
return result;
|
|
192
192
|
} catch (error) {
|
|
193
193
|
if (error instanceof DeployProductError) throw error;
|
package/cli/deploy-secrets.mjs
CHANGED
|
@@ -96,6 +96,6 @@ export async function keepHookSecrets({ root, environment, declaration, setupMan
|
|
|
96
96
|
export async function keepSecrets({ root, environment, kept, env, generated, reused, report }) {
|
|
97
97
|
await saveSecrets(root, environment, Object.fromEntries(kept.filter(item => generated.includes(item.binding)).map(item => [item.binding, env[item.environment]])));
|
|
98
98
|
const file = savedSecretsFile(environment), them = names => names.length > 1 ? 'them' : 'it';
|
|
99
|
-
if (generated.length) report(`rer generated ${generated.join(', ')} for this deployment and keeps ${them(generated)} in ${file} (private; Git ignores it), so a redeploy reuses ${them(generated)}. To deploy this environment from another checkout, copy that file there
|
|
100
|
-
if (reused.length) report(`rer reused ${reused.join(', ')} kept in ${file}
|
|
99
|
+
if (generated.length) report(`rer generated ${generated.join(', ')} for this deployment and keeps ${them(generated)} in ${file} (private; Git ignores it), so a redeploy reuses ${them(generated)}. To deploy this environment from another checkout, copy that file there.`, { names: generated });
|
|
100
|
+
if (reused.length) report(`rer reused ${reused.join(', ')} kept in ${file}.`, { names: reused });
|
|
101
101
|
}
|
package/cli/deploy.mjs
CHANGED
|
@@ -97,7 +97,7 @@ export function ownerDeploy(declarationPath, lifecycle) {
|
|
|
97
97
|
}
|
|
98
98
|
await owner('secret', ['--set', binding, ...(state ? ['--state', state] : [])]);
|
|
99
99
|
await keepSecrets({ root, environment, kept, env, generated: [binding], reused: [], report: () => {} });
|
|
100
|
-
store.report(`Rotated ${binding} on this environment's Worker to a fresh value kept in .rer/deploy/${environment}.secrets.env, recorded its new version and verified hosted readiness
|
|
100
|
+
store.report(`Rotated ${binding} on this environment's Worker to a fresh value kept in .rer/deploy/${environment}.secrets.env, recorded its new version and verified hosted readiness.`, { names: [binding] });
|
|
101
101
|
}
|
|
102
102
|
return { rotated, deployed: false };
|
|
103
103
|
}
|
|
@@ -105,7 +105,7 @@ export function ownerDeploy(declarationPath, lifecycle) {
|
|
|
105
105
|
step = 'secrets';
|
|
106
106
|
const bindings = (options.setSecret ?? options.unsetSecret).split(','), flag = options.setSecret ? '--set' : '--unset';
|
|
107
107
|
await owner('secret', [...bindings.flatMap(binding => [flag, binding]), ...(state ? ['--state', state] : [])]);
|
|
108
|
-
store.report(`${options.setSecret ? 'Set' : 'Removed'} ${bindings.join(', ')} on this environment's Worker as one new version, recorded it and verified hosted readiness
|
|
108
|
+
store.report(`${options.setSecret ? 'Set' : 'Removed'} ${bindings.join(', ')} on this environment's Worker as one new version, recorded it and verified hosted readiness.`, { names: bindings });
|
|
109
109
|
return { bindings, present: Boolean(options.setSecret), deployed: false };
|
|
110
110
|
}
|
|
111
111
|
store.report(`Deploying the ${environment} environment to your Cloudflare account.`);
|
|
@@ -113,10 +113,10 @@ export function ownerDeploy(declarationPath, lifecycle) {
|
|
|
113
113
|
deployed = await owner('deploy', [], env, { notice: line => store.report(line), onCreated: resource => created.push(redaction.redact(resource)) });
|
|
114
114
|
// A generated value the kit did not send stays unknown: the Worker kept its own.
|
|
115
115
|
const sent = supplied.filter(name => deployed.sentSecrets.includes(name)), keptSent = [...generated, ...reused].filter(name => sent.includes(name));
|
|
116
|
-
await keepSecrets({ root, environment, kept, env, generated: generated.filter(name => sent.includes(name)), reused: reused.filter(name => sent.includes(name)), report: line => store.report(line) });
|
|
116
|
+
await keepSecrets({ root, environment, kept, env, generated: generated.filter(name => sent.includes(name)), reused: reused.filter(name => sent.includes(name)), report: (line, more) => store.report(line, more) });
|
|
117
117
|
const other = sent.filter(name => !keptSent.includes(name));
|
|
118
|
-
if (other.length) store.report(`rer supplied ${other.join(', ')} from the local setup owner and fresh generated values
|
|
119
|
-
if (deployed.optionalUnset) store.report(`Optional secrets not set: ${deployed.optionalUnset.join(', ')}. The application runs without them; set one later with ${again} --set-secret NAME
|
|
118
|
+
if (other.length) store.report(`rer supplied ${other.join(', ')} from the local setup owner and fresh generated values.`, { names: other });
|
|
119
|
+
if (deployed.optionalUnset) store.report(`Optional secrets not set: ${deployed.optionalUnset.join(', ')}. The application runs without them; set one later with ${again} --set-secret NAME.`, { names: deployed.optionalUnset });
|
|
120
120
|
step = 'health';
|
|
121
121
|
await owner('health', [], env, {propagation:deployed.propagation});
|
|
122
122
|
step = 'claim owner';
|
|
@@ -132,8 +132,8 @@ export function ownerDeploy(declarationPath, lifecycle) {
|
|
|
132
132
|
// The app claims the OWNER_EMAIL the Worker holds: the local one only when this run uploaded it.
|
|
133
133
|
const email = declared(claim?.emailField);
|
|
134
134
|
const named = !email ? '' : deployed.sentSecrets.includes(email.binding) && env[email.environment] ? ` (${env[email.environment]})` : ` (the ${email.binding} already set on the Worker)`;
|
|
135
|
-
if (claimed) store.report(`${claimed === 'claimed' ? 'Claimed the hosted owner' : 'The hosted owner was already claimed and was kept'}${named}; the one-time setup token was removed. ${mailOff ? mailOffNotice(mailOff, environment) : `Sign in by email at ${deployed.origin}.`}
|
|
136
|
-
else if (mailOff) store.report(mailOffNotice(mailOff, environment));
|
|
135
|
+
if (claimed) store.report(`${claimed === 'claimed' ? 'Claimed the hosted owner' : 'The hosted owner was already claimed and was kept'}${named}; the one-time setup token was removed. ${mailOff ? mailOffNotice(mailOff, environment, liveSecrets) : `Sign in by email at ${deployed.origin}.`}`, { names: mailOff?.credentialNames });
|
|
136
|
+
else if (mailOff) store.report(mailOffNotice(mailOff, environment, liveSecrets), { names: mailOff.credentialNames });
|
|
137
137
|
return { deployed: true, origin: deployed.origin, ...(claimed ? { owner: claimed } : {}), dependenciesLinked: true };
|
|
138
138
|
} catch (error) {
|
|
139
139
|
if (error instanceof RerError) throw error;
|
package/cli/production-auth.mjs
CHANGED
|
@@ -4,9 +4,17 @@ import { hookState } from './deploy-hook-record.mjs';
|
|
|
4
4
|
import { savedSetupAnswers } from './setup-answers.mjs';
|
|
5
5
|
import { productionMail, mailOffSignInCommand } from './production-mail.mjs';
|
|
6
6
|
|
|
7
|
-
// What a deploy says when outbound email is deliberately off: the state and the way in.
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
// What a deploy says when outbound email is deliberately off: the state and the way in. A seed that
|
|
8
|
+
// declares its mail credential secrets (`mail.credentialSecretNames`) gets this line only when it is
|
|
9
|
+
// true: with the Worker's bound secret names in `live`, a bound mail secret is named instead, and
|
|
10
|
+
// without them (a dry run reads no secrets) the line says the bound secrets were not read.
|
|
11
|
+
export function mailOffNotice({ signIn, credentialNames = [] }, environment = 'production', live) {
|
|
12
|
+
if (credentialNames.length && Array.isArray(live)) {
|
|
13
|
+
const bound = credentialNames.filter(name => live.includes(name));
|
|
14
|
+
if (bound.length) return `Outbound email is configured by the secrets bound on this environment's Worker: ${bound.join(', ')} (names only; values are never printed). This deploy's MAIL_PROVIDER=none setting does not remove them; turn mail off with rer deploy --environment ${environment} --unset-secret and these names. Sign in without mail with \`${signIn}\` for the ${environment} environment, from this checkout with the Cloudflare credentials that deployed it.`;
|
|
15
|
+
}
|
|
16
|
+
const unread = credentialNames.length && !Array.isArray(live) ? ` The bound secrets were not read: if one of ${credentialNames.join(', ')} is bound on the Worker, outbound email is configured by it.` : '';
|
|
17
|
+
return `Outbound email is off (MAIL_PROVIDER=none): no mail credential is bound and this installation sends nothing. Sign in without mail with \`${signIn}\` for the ${environment} environment, from this checkout with the Cloudflare credentials that deployed it. Turn mail on later with rer deploy --environment ${environment} --set-secret and the provider inputs.${unread}`;
|
|
10
18
|
}
|
|
11
19
|
|
|
12
20
|
// Validate the shared email/identity contract using the bindings that will reach
|
|
@@ -23,7 +31,7 @@ export async function requireProductionAuth({ root, declaration, env, setupManif
|
|
|
23
31
|
const mailOffSignIn = mail.off ? declaredSignIn : undefined;
|
|
24
32
|
if (mailOffSignIn) {
|
|
25
33
|
if (mail.offConflicts.length) throw refuse(`MAIL_PROVIDER=none turns outbound email off, and ${mail.offConflicts.join(', ')} would bind a way to send. Remove ${mail.offConflicts.length > 1 ? 'them' : 'it'} or choose a mail provider. Nothing was built or uploaded.`);
|
|
26
|
-
return { mailOff: { signIn: mailOffSignIn } };
|
|
34
|
+
return { mailOff: { signIn: mailOffSignIn, credentialNames: mail.credentialNames } };
|
|
27
35
|
}
|
|
28
36
|
if (mail.senderIssue && options.verb === 'deploy' && !(options.dryRun && mail.fixtureSender)) throw refuse(`${mail.senderIssue} Nothing was built or uploaded.`);
|
|
29
37
|
if (mail.configured()) return;
|
package/cli/production-mail.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { contained } from './project.mjs';
|
|
|
3
3
|
import { refuse } from './errors.mjs';
|
|
4
4
|
import { parseAddress } from '../modules/mail/src/core/validation.mjs';
|
|
5
5
|
import { deliveryDeclarationSources } from './delivery-declarations.mjs';
|
|
6
|
+
import { mailCredentialSecretNames } from '../modules/delivery-producer/declarations.mjs';
|
|
6
7
|
import { validateRerConfig } from '../modules/mail/src/adapters/rer/contract.mjs';
|
|
7
8
|
import { validateMailSenders } from '../modules/delivery-producer/mail.mjs';
|
|
8
9
|
import { sourceMailSenders } from './deploy-variables.mjs';
|
|
@@ -40,7 +41,7 @@ export function mailOffSignInCommand(adapter) {
|
|
|
40
41
|
// root declaration later. Read that source contract, never arbitrary ambient
|
|
41
42
|
// keys or the adapter's executable source, before any build or provider write.
|
|
42
43
|
export async function productionMail(root, declaration, env, declarationPath = 'deploy.json', adapter, mailOffSignIn = mailOffSignInCommand(adapter)) {
|
|
43
|
-
const bindings = { ...declaration.vars }, secrets = new Set(), publicInputs = new Set(), declaredProviders = new Set();
|
|
44
|
+
const bindings = { ...declaration.vars }, secrets = new Set(), publicInputs = new Set(), declaredProviders = new Set(), credentialDeclarations = [];
|
|
44
45
|
const senders = [{ source: `${declarationPath} vars.MAIL_FROM`, value: declaration.vars?.MAIL_FROM }];
|
|
45
46
|
senders.push(...await sourceMailSenders(root, adapter));
|
|
46
47
|
let senderFix = `Edit vars.MAIL_FROM in ${declarationPath}`;
|
|
@@ -79,7 +80,12 @@ export async function productionMail(root, declaration, env, declarationPath = '
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
for (const provider of spec.mail?.providers ?? []) if (providers.includes(provider)) declaredProviders.add(provider);
|
|
83
|
+
try { credentialDeclarations.push(...mailCredentialSecretNames(spec.mail).map(name => ({ name, path }))); }
|
|
84
|
+
catch (error) { throw refuse(`Restore a valid mail credential declaration at ${path}: ${error.message}. Nothing was built or uploaded.`); }
|
|
82
85
|
}
|
|
86
|
+
// The seed's declared mail credentials are secrets of this deployment, or the declaration is wrong.
|
|
87
|
+
for (const { name, path } of credentialDeclarations) if (!secrets.has(name)) throw refuse(`${path} mail.credentialSecretNames names ${name}, which the deployment does not declare as a secret. Declare it in ${declarationPath} secrets or in the secret names of ${path}, or remove it from the list. Nothing was built or uploaded.`);
|
|
88
|
+
const credentialNames = [...new Set(credentialDeclarations.map(item => item.name))];
|
|
83
89
|
for (const name of publicInputs) if (present(env[name])) {
|
|
84
90
|
if (name === 'MAIL_FROM') senders.push({ source: 'public MAIL_FROM (environment or --env-file)', value: env[name] });
|
|
85
91
|
bindings[name] = env[name];
|
|
@@ -128,6 +134,7 @@ export async function productionMail(root, declaration, env, declarationPath = '
|
|
|
128
134
|
});
|
|
129
135
|
return {
|
|
130
136
|
off,
|
|
137
|
+
credentialNames,
|
|
131
138
|
offConflicts: off ? sendingBindings.filter(key => present(bindings[key])) : [],
|
|
132
139
|
declared: 'MAIL_PROVIDER' in bindings || publicInputs.has('MAIL_PROVIDER') || secrets.has('MAIL_API_KEY') || selected.length > 0,
|
|
133
140
|
senderIssue,
|
package/global/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.107
|
|
4
|
+
|
|
5
|
+
### Deploy mail notice and secret names
|
|
6
|
+
|
|
7
|
+
- `rer deploy` no longer says "Outbound email is off (MAIL_PROVIDER=none): no mail credential is bound" when mail secrets are bound. A seed lists its mail credential secrets in the new optional `mail.credentialSecretNames` (beside `mail.providers` in its deployment-spec declaration; a non-empty list, each name a secret the deployment declares, no duplicates, no values; `rer deploy` refuses a name the deployment does not declare). When any listed name is bound on the Worker, the deploy prints one line naming the bound secret names (never values) and saying outbound email is configured by them; when none is, the off line is unchanged, and a dry run says it did not read the bound secrets. rer does not guess mail secrets from name patterns, and a seed without the key is unchanged.
|
|
8
|
+
- rer's confirmation lines no longer redact secret names. `rer deploy --set-secret EMAIL_PROVIDER,...` printed `[REDACTED]_DOMAIN` when a secret's value (`mailgun`) or another name (`MAILGUN_SENDING_KEY`) matched part of a name. The lines that list names (set, unset, rotate, generated, reused, supplied, optional-unset, the mail notice) keep each name whole; values are still redacted everywhere, including in the text around the names.
|
|
9
|
+
|
|
10
|
+
### Business roster erasure
|
|
11
|
+
|
|
12
|
+
- Erasing an operator now also retires them from the Business-signed roster. In the same erasure transaction, `agentErasureStatements` deletes the person's `bs_team` row, removes their entry from the stored `bs_settings.document` (the verified payload; no signature is stored or re-signed), and redacts an editor identity in `bs_overrides`/`bs_audit` to the erasure marker; before, their name, email and operator id stayed there. A seed gets this only by declaring it: its erasure map must declare `agent_door_state` with `retire: { refs }`, and the erasure subject must carry `operatorPolicyRefs`. A seed whose map does not declare it keeps the old behaviour (the roster entry stays), so this release does not close the leak for a seed until that seed has adopted 0.2.107 and added the declaration. A seed without the agent door appends `rosterRetirementStatements(db, refs, { erasure_id })` to its own erasure transaction instead.
|
|
13
|
+
- Value-free digests in the new `bs_retired` table make the Business's next signed revision that still lists an erased person apply as retired: everyone else applies, they get no account, row or invitation, and the ack carries `retired: [email]`, until the Business sends a larger member `invite`.
|
|
14
|
+
- A person erased by an older release, whose roster row and stored document entry an old erasure left behind, is retired at runtime, not by a migration. A team adapter may return `gone` (the `operatorId`s of stored rows whose native identity no longer exists, by the adapter's own check); on the Business's next revision the Business-settings module writes the digests and invite number to `bs_retired`, purges the row and drops the document entry in that apply's batch, so a revision still listing them applies as retired instead of inviting them again. `auth.businessTeam` reports a stored operator it can no longer find (it answered `conflict` for that row before). An adapter that never returns `gone`, such as one bound to another accounts table, changes no stored row.
|
|
15
|
+
- This release is not code only: it adds migration `0044_business_retired.sql` (source `modules/business-settings/schema/0003_business_retired.sql`). It creates the table `bs_retired` and nothing else: no purge, no data rewrite, no row read or changed. Every seed with a Business roster must copy it into its own forward migration sequence and land it; without it person erasure refuses with `business_roster_missing_table:bs_retired` and a revision that lists team members refuses. Seeds get all of this by adopting 0.2.107, landing the migration and declaring the erasure refs; none of it is live in any deployed seed until that seed adopts and deploys it.
|
|
16
|
+
|
|
3
17
|
## 0.2.106
|
|
4
18
|
|
|
5
19
|
### `rer deploy --dry-run`
|
|
@@ -11,8 +11,21 @@ const status = (value, label) => {
|
|
|
11
11
|
if (!Number.isInteger(value) || value < 100 || value > 599) throw Error(`Invalid ${label}`);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* The secret names a seed declares as its outbound mail credentials, `mail.credentialSecretNames`:
|
|
16
|
+
* optional, a non-empty list of binding names, no duplicates, never values. Whether each is a secret
|
|
17
|
+
* the deployment declares is checked where the deployment's secrets are known (`rer deploy`).
|
|
18
|
+
*/
|
|
19
|
+
export function mailCredentialSecretNames(mail) {
|
|
20
|
+
if (mail?.credentialSecretNames === undefined) return [];
|
|
21
|
+
const names = strings(mail.credentialSecretNames, 'mail credentialSecretNames', bindingPattern);
|
|
22
|
+
if (!names.length) throw Error('Invalid mail credentialSecretNames: name at least one secret or remove the list');
|
|
23
|
+
return names;
|
|
24
|
+
}
|
|
25
|
+
|
|
14
26
|
/** Preserve source-owned preview and setup declarations, without authorizing effects. */
|
|
15
27
|
export function validateDeclarations(spec) {
|
|
28
|
+
mailCredentialSecretNames(spec.mail);
|
|
16
29
|
if (spec.providerEffects !== undefined) {
|
|
17
30
|
if (strings(spec.providerEffects, 'providerEffects', /^[a-z][a-z0-9-]{0,63}$/).length > 32) throw Error('Too many provider effects');
|
|
18
31
|
}
|
|
@@ -25,7 +25,7 @@ export function publicMailSender(spec) {
|
|
|
25
25
|
/** Managed mail is an explicit capability, independent of direct provider adapters. */
|
|
26
26
|
export function usesManagedMail(mail) {
|
|
27
27
|
if (mail === undefined) return false;
|
|
28
|
-
keys(mail, ['providers'], 'mail');
|
|
28
|
+
keys(mail, ['providers', 'credentialSecretNames'], 'mail');
|
|
29
29
|
const providers = strings(mail.providers, 'mail providers', /^(rer|resend|sendgrid|cloudflare)$/);
|
|
30
30
|
if (!providers.length) throw Error('Mail requires at least one provider');
|
|
31
31
|
return providers.includes('rer');
|
|
@@ -24,7 +24,7 @@ export function businessTeam(context) {
|
|
|
24
24
|
WHERE o.role='owner' AND o.status='active' ORDER BY b.claim_id IS NULL,o.created_at,o.id LIMIT 1))`,
|
|
25
25
|
args: [...guard.args, operator.id, operator.email, operator.version] }));
|
|
26
26
|
const fence = store.actorFence(actor, clock());
|
|
27
|
-
const pending = [], rows = [];
|
|
27
|
+
const pending = [], rows = [], gone = [];
|
|
28
28
|
// Abort the whole caller transaction if ownership changed, even when this
|
|
29
29
|
// document contains only conflicts or unchanged members.
|
|
30
30
|
const statements = [[`INSERT INTO oa_auth_audit(id,actor_id,action,value,created_at)
|
|
@@ -54,7 +54,10 @@ export function businessTeam(context) {
|
|
|
54
54
|
// current sign-in address. Self-service email changes keep this ID.
|
|
55
55
|
let target = prior ? await store.operator(prior.operatorId) : await store.byEmail(email);
|
|
56
56
|
const oldRole = target?.role;
|
|
57
|
-
|
|
57
|
+
// The native operator is gone (an erasure removed it): the module retires the stored row and its listing,
|
|
58
|
+
// so no conflict row is kept and the Business's next listing of them stays retired.
|
|
59
|
+
if (prior && !target) { gone.push(prior.operatorId); continue; }
|
|
60
|
+
if (target?.role === 'owner' || !prior && (email === owner.email || target)) {
|
|
58
61
|
// Never adopt an unrelated account, or discard a recorded identity
|
|
59
62
|
// because its old address now belongs to another account.
|
|
60
63
|
if (member || prior) rows.push({ email, operatorId: prior?.operatorId ?? null, invite: member?.invite ?? prior.invite, state: 'conflict' });
|
|
@@ -84,7 +87,7 @@ export function businessTeam(context) {
|
|
|
84
87
|
} else if (target.displayName !== name) target = await update(target, { ...target, displayName: name }, 'operators:role');
|
|
85
88
|
rows.push({ email, operatorId: target.id, invite: member.invite, state: target.status });
|
|
86
89
|
}
|
|
87
|
-
return { statements: statements.map(([sql, args]) => store.statement(sql, args)), rows,
|
|
90
|
+
return { statements: statements.map(([sql, args]) => store.statement(sql, args)), rows, gone,
|
|
88
91
|
async afterCommit() { for (const send of pending) await send(); } };
|
|
89
92
|
},
|
|
90
93
|
});
|
package/onboarding/commands.mjs
CHANGED
|
@@ -46,7 +46,17 @@ export async function createCommands(directory,state,{terminal=text=>writeSync(1
|
|
|
46
46
|
if(!closed)log.write(text);
|
|
47
47
|
writeTerminal(text);
|
|
48
48
|
};
|
|
49
|
-
|
|
49
|
+
// A line that lists secret NAMES keeps each name whole: a name is not a secret, even when a value
|
|
50
|
+
// equals it or one of its parts. The text around the names is redacted exactly as any other line.
|
|
51
|
+
const redactBesideNames=(text,names)=>{
|
|
52
|
+
const listed=[...new Set((names??[]).filter(name=>typeof name==='string'&&name))].sort((a,b)=>b.length-a.length);
|
|
53
|
+
if(!listed.length)return redaction.redact(text);
|
|
54
|
+
const pattern=new RegExp(`(?<![A-Za-z0-9_])(?:${listed.map(name=>name.replace(/[.*+?^${}()|[\]\\]/g,'\\$&')).join('|')})(?![A-Za-z0-9_])`,'g');
|
|
55
|
+
let result='',from=0;
|
|
56
|
+
for(const match of text.matchAll(pattern)){result+=redaction.redact(text.slice(from,match.index))+match[0];from=match.index+match[0].length;}
|
|
57
|
+
return result+redaction.redact(text.slice(from));
|
|
58
|
+
};
|
|
59
|
+
const report=(text,{names}={})=>emit(redactBesideNames(String(text),names)+'\n');
|
|
50
60
|
const failure=(label,detail={},capture)=>{
|
|
51
61
|
const outcome=`exit ${detail.code??'none'}, signal ${detail.signal??'none'}`;
|
|
52
62
|
const status=detail.reason==='cancel'?`cancelled (${outcome})`:detail.reason==='deadline'?`readiness deadline exceeded (${outcome})`:detail.error?`could not start${detail.errorCode?` (${detail.errorCode})`:''} (${outcome})`:outcome;
|