enigma-memory 0.1.14 → 0.1.16
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 +64 -84
- package/apps/cli/bin/enigma.mjs +3151 -3126
- package/apps/native-host/README.md +20 -0
- package/deploy/SIMULATION.md +34 -38
- package/deploy/docker-compose.local-production-simulation.yml +5 -2
- package/docs/benchmark-attestation-network.md +2 -2
- package/docs/benchmark-reproducibility.md +240 -228
- package/docs/browser-extension-install.md +9 -6
- package/docs/client-connectors.md +22 -52
- package/docs/demo-proof-network.md +3 -3
- package/docs/developer-ecosystem.md +205 -223
- package/docs/developer-proof-quickstart.md +3 -3
- package/docs/enigma-memory-ready-conformance.md +1 -1
- package/docs/hosted-cloud-product.md +2 -0
- package/docs/install-anywhere.md +61 -66
- package/docs/memory-benchmarks.md +6 -3
- package/docs/proof-network-build-notes.md +2 -2
- package/docs/proof-network.md +32 -7
- package/docs/sdk-api.md +1 -1
- package/docs/solana-devnet-acceptance.md +1 -1
- package/docs/solana-proof-rail.md +1 -1
- package/package.json +278 -272
- package/packages/connectors/src/index.js +13 -0
- package/packages/mcp-server/README.md +22 -0
- package/packages/mcp-server/src/index.js +1185 -1185
- package/scripts/build-benchmark-proof-release.mjs +106 -5
- package/scripts/build-cloudflare-token-policy.mjs +6 -2
- package/scripts/build-hosted-api-key-lifecycle.mjs +274 -274
- package/scripts/build-hosted-customer-lifecycle.mjs +456 -456
- package/scripts/build-installer-assets.mjs +389 -389
- package/scripts/build-production-handoff-packet.mjs +1 -1
- package/scripts/build-production-unblocker.mjs +409 -409
- package/scripts/build-production-workplan.mjs +3 -1
- package/scripts/build-proof-network-packet.mjs +213 -213
- package/scripts/check.mjs +3 -1
- package/scripts/cloudflare-ops.mjs +35 -0
- package/scripts/collect-hosted-backend-live-evidence.mjs +44 -2
- package/scripts/run-memory-benchmarks.mjs +5 -0
- package/scripts/run-standard-memory-benchmarks.mjs +1194 -1070
- package/scripts/stage-cloudflare-pages-artifact.mjs +145 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { cp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { dirname, resolve } from 'node:path';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { validatePublicSiteSecurity } from './validate-public-site-security.mjs';
|
|
6
|
+
|
|
7
|
+
const STAGE_SCHEMA = 'enigma.cloudflare_pages_stage.v1';
|
|
8
|
+
const DEFAULT_HEADERS = Object.freeze([
|
|
9
|
+
['Permissions-Policy', 'camera=(), microphone=(), geolocation=()'],
|
|
10
|
+
['Content-Security-Policy', "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com https://api.fontshare.com; font-src 'self' https://fonts.gstatic.com https://api.fontshare.com; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'"],
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
class UsageError extends Error {
|
|
14
|
+
constructor(message) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = 'UsageError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function parseArgs(argv = process.argv.slice(2)) {
|
|
21
|
+
const out = { site: null, out: null, help: false };
|
|
22
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
23
|
+
const token = argv[i];
|
|
24
|
+
if (token === '--help') out.help = true;
|
|
25
|
+
else if (token === '--site') out.site = argv[++i] ?? null;
|
|
26
|
+
else if (token === '--out') out.out = argv[++i] ?? null;
|
|
27
|
+
else throw new UsageError(`unknown argument: ${token}`);
|
|
28
|
+
}
|
|
29
|
+
if (out.help) return out;
|
|
30
|
+
if (typeof out.site !== 'string' || out.site.trim().length === 0) throw new UsageError('--site is required');
|
|
31
|
+
if (typeof out.out !== 'string' || out.out.trim().length === 0) throw new UsageError('--out is required');
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function usage() {
|
|
36
|
+
return 'Usage: node scripts/stage-cloudflare-pages-artifact.mjs --site <dir> --out <dir>\n\nCopies a static Pages artifact to a local staging directory and overlays required Cloudflare security headers without mutating the source artifact.\n';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function headerName(line) {
|
|
40
|
+
const match = String(line).trim().match(/^([^:]+):\s*.+$/u);
|
|
41
|
+
return match ? match[1].trim().toLowerCase() : null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function ensureRequiredHeaders(text) {
|
|
45
|
+
const normalized = String(text ?? '').replace(/\r\n/g, '\n');
|
|
46
|
+
const lines = normalized.length > 0 ? normalized.split('\n') : [];
|
|
47
|
+
let blockStart = -1;
|
|
48
|
+
let insertAt = -1;
|
|
49
|
+
const present = new Set();
|
|
50
|
+
|
|
51
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
52
|
+
const trimmed = lines[i].trim();
|
|
53
|
+
if (blockStart === -1) {
|
|
54
|
+
if (trimmed === '/*') {
|
|
55
|
+
blockStart = i;
|
|
56
|
+
insertAt = lines.length;
|
|
57
|
+
}
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (i > blockStart && lines[i] && !lines[i].startsWith(' ') && !lines[i].startsWith('\t')) {
|
|
61
|
+
insertAt = i;
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
const name = headerName(lines[i]);
|
|
65
|
+
if (name) present.add(name);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const missing = DEFAULT_HEADERS.filter(([name]) => !present.has(name.toLowerCase()));
|
|
69
|
+
if (missing.length === 0) return normalized.endsWith('\n') ? normalized : `${normalized}\n`;
|
|
70
|
+
const additions = missing.map(([name, value]) => ` ${name}: ${value}`);
|
|
71
|
+
if (blockStart === -1) {
|
|
72
|
+
return [`/*`, ...additions, '', normalized].join('\n').replace(/\n*$/u, '\n');
|
|
73
|
+
}
|
|
74
|
+
const nextLines = [...lines];
|
|
75
|
+
nextLines.splice(insertAt, 0, ...additions);
|
|
76
|
+
return nextLines.join('\n').replace(/\n*$/u, '\n');
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function publicPathLabel(value, placeholder) {
|
|
80
|
+
const text = String(value ?? '');
|
|
81
|
+
return /^(?:[A-Za-z]:[\\/]|\\\\|\/)/u.test(text) ? placeholder : text;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function safeErrorMessage(error) {
|
|
85
|
+
return String(error?.message ?? error).replace(/[A-Z]:\\[^\r\n"']+/gi, '<local-path>');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export async function stageCloudflarePagesArtifact(input = {}) {
|
|
89
|
+
const source = resolve(String(input.site ?? ''));
|
|
90
|
+
const out = resolve(String(input.out ?? ''));
|
|
91
|
+
const generatedAt = input.generated_at ?? input.generatedAt ?? new Date().toISOString();
|
|
92
|
+
if (source === out) throw new UsageError('--out must be different from --site');
|
|
93
|
+
await rm(out, { recursive: true, force: true });
|
|
94
|
+
await mkdir(dirname(out), { recursive: true });
|
|
95
|
+
await cp(source, out, { recursive: true, dereference: false, force: true, errorOnExist: false });
|
|
96
|
+
const headersPath = resolve(out, '_headers');
|
|
97
|
+
let headers = '';
|
|
98
|
+
try {
|
|
99
|
+
headers = await readFile(headersPath, 'utf8');
|
|
100
|
+
} catch {
|
|
101
|
+
headers = '';
|
|
102
|
+
}
|
|
103
|
+
await writeFile(headersPath, ensureRequiredHeaders(headers), 'utf8');
|
|
104
|
+
const security = await validatePublicSiteSecurity({ site: out }, { generated_at: generatedAt });
|
|
105
|
+
return {
|
|
106
|
+
schema: STAGE_SCHEMA,
|
|
107
|
+
generated_at: generatedAt,
|
|
108
|
+
source_site: '<source-public-site>',
|
|
109
|
+
staged_site: publicPathLabel(input.out, '<staged-public-site>'),
|
|
110
|
+
headers_overlay: {
|
|
111
|
+
file: '_headers',
|
|
112
|
+
ensured: DEFAULT_HEADERS.map(([name]) => name),
|
|
113
|
+
source_mutated: false,
|
|
114
|
+
},
|
|
115
|
+
security: {
|
|
116
|
+
schema: security.schema,
|
|
117
|
+
ok: security.ok,
|
|
118
|
+
status: security.status,
|
|
119
|
+
blocker_count: security.blockers.length,
|
|
120
|
+
blockers: security.blockers,
|
|
121
|
+
checked: security.checked,
|
|
122
|
+
},
|
|
123
|
+
ok: security.ok,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function main() {
|
|
128
|
+
try {
|
|
129
|
+
const args = parseArgs();
|
|
130
|
+
if (args.help) {
|
|
131
|
+
process.stdout.write(usage());
|
|
132
|
+
return 0;
|
|
133
|
+
}
|
|
134
|
+
const result = await stageCloudflarePagesArtifact(args);
|
|
135
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
136
|
+
return result.ok ? 0 : 1;
|
|
137
|
+
} catch (error) {
|
|
138
|
+
process.stderr.write(`${safeErrorMessage(error)}\n`);
|
|
139
|
+
return 1;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
144
|
+
process.exitCode = await main();
|
|
145
|
+
}
|