@volter/teams 0.2.43 → 0.2.44
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/package.json +1 -1
- package/redact.mjs +17 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/teams",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.44",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Volter Teams, the neutral team plane: machine identity and daemon core, the local door and server link, admission from machine grants, product doors, and the Teams server's neutral routes (company RFC 0008).",
|
|
6
6
|
"license": "MIT",
|
package/redact.mjs
CHANGED
|
@@ -134,23 +134,29 @@ const anyKeyword = new RegExp([...new Set(RULES.flatMap((rule) => rule.keywords)
|
|
|
134
134
|
const CUSTODY_LOOK_MS = 30_000;
|
|
135
135
|
let custodyCache = null, custodyStamp = null, custodyLookedAt = 0;
|
|
136
136
|
const stampOf = (file) => { try { const s = statSync(file); return `${s.ino}:${s.size}:${s.mtimeMs}`; } catch { return '-'; } };
|
|
137
|
-
|
|
137
|
+
const custodyUnreadable=()=>Object.assign(new Error('a declared custody file or its registry could not be read; capture transfer refused'),{code:'custody_unreadable'});
|
|
138
|
+
function custodyFiles(env, fresh) {
|
|
138
139
|
const home = env.SUPERCODE_HOME || join(env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'supercode');
|
|
139
140
|
let files = String(env.SUPERCODE_CUSTODY_FILES ?? '').split(delimiter).filter(Boolean);
|
|
140
|
-
try {
|
|
141
|
+
try {
|
|
142
|
+
const named=JSON.parse(readFileSync(join(home, 'custody.json'), 'utf8')).files??[];
|
|
143
|
+
if(fresh&&(!Array.isArray(named)||named.some(file=>typeof file!=='string')))throw custodyUnreadable();
|
|
144
|
+
files=files.concat(named);
|
|
145
|
+
} catch(error) { if(fresh&&error?.code!=='ENOENT')throw custodyUnreadable(); }
|
|
141
146
|
return { files, stamp: [join(home, 'custody.json'), ...files].map(stampOf).join('|') };
|
|
142
147
|
}
|
|
143
|
-
/** Each custody value (at least 8 characters) with the variable that holds it, longest first.
|
|
144
|
-
|
|
148
|
+
/** Each custody value (at least 8 characters) with the variable that holds it, longest first. `fresh` bypasses both
|
|
149
|
+
* the interval and stat memo and refuses unreadable declared files or a malformed/unreadable registry. */
|
|
150
|
+
export function custodyValues(env = process.env, { fresh = false } = {}) {
|
|
145
151
|
const now = Date.now();
|
|
146
|
-
if (custodyCache && now - custodyLookedAt < CUSTODY_LOOK_MS) return custodyCache;
|
|
152
|
+
if (!fresh && custodyCache && now - custodyLookedAt < CUSTODY_LOOK_MS) return custodyCache;
|
|
147
153
|
custodyLookedAt = now;
|
|
148
|
-
const { files, stamp } = custodyFiles(env);
|
|
149
|
-
if (custodyCache && stamp === custodyStamp) return custodyCache;
|
|
154
|
+
const { files, stamp } = custodyFiles(env, fresh);
|
|
155
|
+
if (!fresh && custodyCache && stamp === custodyStamp) return custodyCache;
|
|
150
156
|
custodyStamp = stamp;
|
|
151
157
|
const values = new Map();
|
|
152
158
|
for (const file of files) {
|
|
153
|
-
let text = ''; try { if (existsSync(file)) text = readFileSync(file, 'utf8'); } catch { continue; }
|
|
159
|
+
let text = ''; try { if (fresh||existsSync(file)) text = readFileSync(file, 'utf8'); } catch { if(fresh)throw custodyUnreadable();continue; }
|
|
154
160
|
for (const line of text.split('\n')) {
|
|
155
161
|
const m = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/.exec(line);
|
|
156
162
|
if (!m) continue;
|
|
@@ -169,10 +175,10 @@ export function custodyValues(env = process.env) {
|
|
|
169
175
|
let custodyBasis = null;
|
|
170
176
|
/** What a redaction was made under (the rule set and the custody values), as a digest: text found clean under one
|
|
171
177
|
* basis is clean under it again, and needs another look only when it changes. */
|
|
172
|
-
export function redactionBasis(env = process.env) { custodyValues(env); return custodyBasis; }
|
|
178
|
+
export function redactionBasis(env = process.env, options) { custodyValues(env, options); return custodyBasis; }
|
|
173
179
|
/** One custody observation and its basis, for a batch that must not change policy between its values. */
|
|
174
|
-
export function redactionSnapshot(env = process.env) {
|
|
175
|
-
const values = custodyValues(env);
|
|
180
|
+
export function redactionSnapshot(env = process.env, options) {
|
|
181
|
+
const values = custodyValues(env, options);
|
|
176
182
|
return { values, basis: custodyBasis };
|
|
177
183
|
}
|
|
178
184
|
|