enigma-memory 0.1.11 → 0.1.12
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 +8 -0
- package/apps/cli/bin/enigma.mjs +257 -3
- package/deploy/SIMULATION.md +152 -0
- package/deploy/docker-compose.local-production-simulation.yml +237 -0
- package/deploy/docker-compose.production.example.yml +19 -0
- package/deploy/kms-mock.mjs +64 -0
- package/deploy/nginx.local-production-simulation.conf +33 -0
- package/deploy/siem-mock.mjs +50 -0
- package/docs/benchmark-attestation-network.md +488 -0
- package/docs/benchmark-reproducibility.md +19 -2
- package/docs/blockchain-only-mechanisms.md +388 -0
- package/docs/demo-proof-network.md +275 -0
- package/docs/developer-ecosystem.md +44 -1
- package/docs/developer-proof-quickstart.md +325 -0
- package/docs/enigma-memory-ready-conformance.md +376 -0
- package/docs/enterprise-proof-control-plane.md +365 -0
- package/docs/market-category-narrative.md +398 -0
- package/docs/memory-drive-health-model.md +649 -0
- package/docs/memory-drive-strategy.md +458 -0
- package/docs/memory-passport-standard.md +445 -0
- package/docs/novelty-invention-candidates.md +161 -0
- package/docs/privacy-ledger-model.md +229 -0
- package/docs/proof-network-build-notes.md +240 -0
- package/docs/proof-network-claim-boundaries.md +318 -0
- package/docs/proof-network-dashboard-spec.md +773 -0
- package/docs/proof-network-glossary.md +27 -0
- package/docs/proof-network-launch-plan.md +421 -0
- package/docs/proof-network-operator-protocol.md +432 -0
- package/docs/proof-network-roadmap.md +431 -0
- package/docs/proof-network-test-plan.md +216 -0
- package/docs/proof-network-threat-model.md +373 -0
- package/docs/proof-network.md +257 -0
- package/docs/sdk-api.md +130 -10
- package/docs/solana-devnet-acceptance.md +226 -0
- package/docs/solana-proof-rail.md +453 -0
- package/examples/proof-network-anchor.json +37 -0
- package/examples/proof-network-attestation.json +35 -0
- package/examples/proof-network-grant.json +27 -0
- package/examples/proof-network-packet.json +71 -0
- package/package.json +40 -4
- package/packages/mcp-server/src/index.js +1 -1
- package/packages/proof-network/src/index.js +570 -0
- package/scripts/build-hosted-api-key-lifecycle.mjs +1 -1
- package/scripts/build-hosted-customer-lifecycle.mjs +1 -1
- package/scripts/build-installer-assets.mjs +1 -1
- package/scripts/build-proof-network-packet.mjs +213 -0
- package/scripts/run-standard-memory-benchmarks.mjs +1 -1
- package/scripts/simulate-production-env.mjs +210 -0
- package/scripts/wait-for-backend-ready.mjs +101 -0
- package/specs/goal-completion-audit-v1.schema.json +1 -0
- package/specs/proof-network-anchor-batch-v1.schema.json +125 -0
- package/specs/proof-network-benchmark-attestation-v1.schema.json +103 -0
- package/specs/proof-network-capability-grant-v1.schema.json +132 -0
- package/specs/proof-network-packet-v1.schema.json +171 -0
- package/scripts/install-enigma-local.mjs +0 -270
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.enigma.ai/proof-network-benchmark-attestation-v1.schema.json",
|
|
4
|
+
"title": "Enigma Proof Network Benchmark Attestation v1",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": [
|
|
7
|
+
"schema",
|
|
8
|
+
"attestation_id",
|
|
9
|
+
"generated_at",
|
|
10
|
+
"package_version",
|
|
11
|
+
"dataset_hash",
|
|
12
|
+
"runner_hash",
|
|
13
|
+
"report_hash",
|
|
14
|
+
"metrics_digest",
|
|
15
|
+
"leakage_scan",
|
|
16
|
+
"claim_boundaries",
|
|
17
|
+
"transaction_submitted",
|
|
18
|
+
"public_payload_only"
|
|
19
|
+
],
|
|
20
|
+
"additionalProperties": false,
|
|
21
|
+
"properties": {
|
|
22
|
+
"schema": { "const": "enigma.proof_network.benchmark_attestation.v1" },
|
|
23
|
+
"attestation_id": { "type": "string", "minLength": 8 },
|
|
24
|
+
"generated_at": { "type": "string", "format": "date-time" },
|
|
25
|
+
"package_version": { "type": "string", "minLength": 1 },
|
|
26
|
+
"dataset_hash": { "$ref": "#/$defs/sha256Digest" },
|
|
27
|
+
"dataset_ref": { "$ref": "#/$defs/publicRef" },
|
|
28
|
+
"runner_hash": { "$ref": "#/$defs/sha256Digest" },
|
|
29
|
+
"runner_ref": { "$ref": "#/$defs/publicRef" },
|
|
30
|
+
"report_hash": { "$ref": "#/$defs/sha256Digest" },
|
|
31
|
+
"report_ref": { "$ref": "#/$defs/publicRef" },
|
|
32
|
+
"package_ref": { "$ref": "#/$defs/publicRef" },
|
|
33
|
+
"metrics_digest": { "$ref": "#/$defs/metricsDigest" },
|
|
34
|
+
"leakage_scan": { "$ref": "#/$defs/leakageScan" },
|
|
35
|
+
"claim_boundaries": {
|
|
36
|
+
"type": "array",
|
|
37
|
+
"minItems": 1,
|
|
38
|
+
"items": { "$ref": "#/$defs/claimBoundary" }
|
|
39
|
+
},
|
|
40
|
+
"transaction_submitted": { "const": false },
|
|
41
|
+
"public_payload_only": { "const": true }
|
|
42
|
+
},
|
|
43
|
+
"$defs": {
|
|
44
|
+
"sha256Digest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
|
|
45
|
+
"publicRef": { "type": "string", "minLength": 1 },
|
|
46
|
+
"metricsDigest": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"required": ["digest", "metric_count", "canonicalization"],
|
|
49
|
+
"additionalProperties": false,
|
|
50
|
+
"properties": {
|
|
51
|
+
"digest": { "$ref": "#/$defs/sha256Digest" },
|
|
52
|
+
"metric_count": { "type": "integer", "minimum": 0 },
|
|
53
|
+
"metric_keys": {
|
|
54
|
+
"type": "array",
|
|
55
|
+
"items": { "type": "string", "minLength": 1 },
|
|
56
|
+
"uniqueItems": true
|
|
57
|
+
},
|
|
58
|
+
"canonicalization": { "type": "string", "enum": ["json-c14n-sha256", "canonical-json-sha256"] },
|
|
59
|
+
"metrics_schema_ref": { "$ref": "#/$defs/publicRef" }
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"leakageScan": {
|
|
63
|
+
"type": "object",
|
|
64
|
+
"required": ["scanned", "passed", "policy", "public_payload_only", "private_payload_detected", "forbidden_field_names"],
|
|
65
|
+
"additionalProperties": false,
|
|
66
|
+
"properties": {
|
|
67
|
+
"scanned": { "const": true },
|
|
68
|
+
"passed": { "const": true },
|
|
69
|
+
"policy": { "const": "public_hashes_roots_refs_counts_only" },
|
|
70
|
+
"public_payload_only": { "const": true },
|
|
71
|
+
"private_payload_detected": { "const": false },
|
|
72
|
+
"forbidden_field_names": {
|
|
73
|
+
"type": "array",
|
|
74
|
+
"maxItems": 0,
|
|
75
|
+
"items": { "type": "string" }
|
|
76
|
+
},
|
|
77
|
+
"scanner_ref": { "$ref": "#/$defs/publicRef" },
|
|
78
|
+
"scanned_at": { "type": "string", "format": "date-time" }
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"claimBoundary": {
|
|
82
|
+
"type": "object",
|
|
83
|
+
"required": ["claim_id", "claim", "allowed_scope", "not_proven"],
|
|
84
|
+
"additionalProperties": false,
|
|
85
|
+
"properties": {
|
|
86
|
+
"claim_id": { "type": "string", "minLength": 1 },
|
|
87
|
+
"claim": { "type": "string", "minLength": 1 },
|
|
88
|
+
"allowed_scope": { "type": "string", "minLength": 1 },
|
|
89
|
+
"not_proven": {
|
|
90
|
+
"type": "array",
|
|
91
|
+
"minItems": 1,
|
|
92
|
+
"items": { "type": "string", "minLength": 1 },
|
|
93
|
+
"uniqueItems": true
|
|
94
|
+
},
|
|
95
|
+
"evidence_refs": {
|
|
96
|
+
"type": "array",
|
|
97
|
+
"items": { "$ref": "#/$defs/publicRef" },
|
|
98
|
+
"uniqueItems": true
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.enigma.ai/proof-network-capability-grant-v1.schema.json",
|
|
4
|
+
"title": "Enigma Proof Network Capability Grant v1",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": [
|
|
7
|
+
"schema",
|
|
8
|
+
"capability_grant_id",
|
|
9
|
+
"capability_grant_hash",
|
|
10
|
+
"issued_at",
|
|
11
|
+
"expires_at",
|
|
12
|
+
"grant_ref",
|
|
13
|
+
"issuer_ref",
|
|
14
|
+
"subject_ref",
|
|
15
|
+
"audience_ref",
|
|
16
|
+
"scopes",
|
|
17
|
+
"max_uses",
|
|
18
|
+
"nonce_hash",
|
|
19
|
+
"signature_ref",
|
|
20
|
+
"transaction_submitted",
|
|
21
|
+
"raw_memory_on_chain",
|
|
22
|
+
"raw_data_included"
|
|
23
|
+
],
|
|
24
|
+
"anyOf": [
|
|
25
|
+
{ "required": ["resource_root"] },
|
|
26
|
+
{ "required": ["resource_roots"] }
|
|
27
|
+
],
|
|
28
|
+
"additionalProperties": false,
|
|
29
|
+
"properties": {
|
|
30
|
+
"schema": { "const": "enigma.proof_network.capability_grant.v1" },
|
|
31
|
+
"capability_grant_id": { "type": "string", "minLength": 8 },
|
|
32
|
+
"capability_grant_hash": { "$ref": "#/$defs/sha256Digest" },
|
|
33
|
+
"issued_at": { "type": "string", "format": "date-time" },
|
|
34
|
+
"expires_at": { "type": ["string", "null"], "format": "date-time" },
|
|
35
|
+
"package_version": { "type": "string", "minLength": 1 },
|
|
36
|
+
"grant_ref": { "$ref": "#/$defs/publicRef" },
|
|
37
|
+
"issuer_ref": { "$ref": "#/$defs/publicRef" },
|
|
38
|
+
"subject_ref": { "$ref": "#/$defs/publicRef" },
|
|
39
|
+
"audience_ref": { "$ref": "#/$defs/publicRef" },
|
|
40
|
+
"scopes": {
|
|
41
|
+
"type": "array",
|
|
42
|
+
"minItems": 1,
|
|
43
|
+
"items": { "$ref": "#/$defs/scope" },
|
|
44
|
+
"uniqueItems": true
|
|
45
|
+
},
|
|
46
|
+
"resource_root": { "$ref": "#/$defs/sha256Digest" },
|
|
47
|
+
"resource_roots": {
|
|
48
|
+
"type": "array",
|
|
49
|
+
"minItems": 1,
|
|
50
|
+
"items": { "$ref": "#/$defs/sha256Digest" },
|
|
51
|
+
"uniqueItems": true
|
|
52
|
+
},
|
|
53
|
+
"max_uses": { "type": ["integer", "null"], "minimum": 1 },
|
|
54
|
+
"nonce_hash": { "$ref": "#/$defs/sha256Digest" },
|
|
55
|
+
"signature_ref": { "$ref": "#/$defs/publicRef" },
|
|
56
|
+
"leakage_scan": { "$ref": "#/$defs/leakageScan" },
|
|
57
|
+
"transaction_submitted": { "const": false },
|
|
58
|
+
"raw_memory_on_chain": { "const": false },
|
|
59
|
+
"raw_data_included": { "const": false },
|
|
60
|
+
"private_payload_included": { "const": false }
|
|
61
|
+
},
|
|
62
|
+
"$defs": {
|
|
63
|
+
"sha256Digest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
|
|
64
|
+
"publicRef": { "type": "string", "minLength": 1 },
|
|
65
|
+
"scope": {
|
|
66
|
+
"type": "object",
|
|
67
|
+
"required": ["name", "actions"],
|
|
68
|
+
"additionalProperties": false,
|
|
69
|
+
"properties": {
|
|
70
|
+
"name": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"enum": [
|
|
73
|
+
"anchor_roots",
|
|
74
|
+
"verify_roots",
|
|
75
|
+
"issue_capability_grants",
|
|
76
|
+
"revoke_capability_grants",
|
|
77
|
+
"issue_benchmark_attestations",
|
|
78
|
+
"verify_proof_packets",
|
|
79
|
+
"administer_proof_network"
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"actions": {
|
|
83
|
+
"type": "array",
|
|
84
|
+
"minItems": 1,
|
|
85
|
+
"items": {
|
|
86
|
+
"type": "string",
|
|
87
|
+
"enum": ["anchor", "verify", "grant", "revoke", "attest", "admin"]
|
|
88
|
+
},
|
|
89
|
+
"uniqueItems": true
|
|
90
|
+
},
|
|
91
|
+
"proof_types": {
|
|
92
|
+
"type": "array",
|
|
93
|
+
"items": {
|
|
94
|
+
"type": "string",
|
|
95
|
+
"enum": [
|
|
96
|
+
"enigma.proof_network.anchor_batch.v1",
|
|
97
|
+
"enigma.proof_network.capability_grant.v1",
|
|
98
|
+
"enigma.proof_network.capability_revocation.v1",
|
|
99
|
+
"enigma.proof_network.benchmark_attestation.v1",
|
|
100
|
+
"enigma.proof_network.packet.v1"
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
"uniqueItems": true
|
|
104
|
+
},
|
|
105
|
+
"resource_refs": {
|
|
106
|
+
"type": "array",
|
|
107
|
+
"items": { "$ref": "#/$defs/publicRef" },
|
|
108
|
+
"uniqueItems": true
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"leakageScan": {
|
|
113
|
+
"type": "object",
|
|
114
|
+
"required": ["scanned", "passed", "policy", "raw_data_detected", "private_payload_detected", "forbidden_field_names"],
|
|
115
|
+
"additionalProperties": false,
|
|
116
|
+
"properties": {
|
|
117
|
+
"scanned": { "const": true },
|
|
118
|
+
"passed": { "const": true },
|
|
119
|
+
"policy": { "const": "public_hashes_roots_refs_counts_only" },
|
|
120
|
+
"raw_data_detected": { "const": false },
|
|
121
|
+
"private_payload_detected": { "const": false },
|
|
122
|
+
"forbidden_field_names": {
|
|
123
|
+
"type": "array",
|
|
124
|
+
"maxItems": 0,
|
|
125
|
+
"items": { "type": "string" }
|
|
126
|
+
},
|
|
127
|
+
"scanner_ref": { "$ref": "#/$defs/publicRef" },
|
|
128
|
+
"scanned_at": { "type": "string", "format": "date-time" }
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://schemas.enigma.ai/proof-network-packet-v1.schema.json",
|
|
4
|
+
"title": "Enigma Proof Network Packet v1",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": [
|
|
7
|
+
"schema",
|
|
8
|
+
"packet_id",
|
|
9
|
+
"generated_at",
|
|
10
|
+
"package_version",
|
|
11
|
+
"packet_root",
|
|
12
|
+
"artifact_count",
|
|
13
|
+
"artifacts",
|
|
14
|
+
"benchmark_attestations",
|
|
15
|
+
"leakage_scan",
|
|
16
|
+
"claim_boundaries",
|
|
17
|
+
"transaction_submitted",
|
|
18
|
+
"public_payload_only"
|
|
19
|
+
],
|
|
20
|
+
"additionalProperties": false,
|
|
21
|
+
"properties": {
|
|
22
|
+
"schema": { "const": "enigma.proof_network.packet.v1" },
|
|
23
|
+
"packet_id": { "type": "string", "minLength": 8 },
|
|
24
|
+
"generated_at": { "type": "string", "format": "date-time" },
|
|
25
|
+
"package_version": { "type": "string", "minLength": 1 },
|
|
26
|
+
"packet_root": { "$ref": "#/$defs/sha256Digest" },
|
|
27
|
+
"artifact_count": { "type": "integer", "minimum": 0 },
|
|
28
|
+
"artifacts": {
|
|
29
|
+
"type": "array",
|
|
30
|
+
"items": { "$ref": "#/$defs/publicArtifact" }
|
|
31
|
+
},
|
|
32
|
+
"anchor_batches": {
|
|
33
|
+
"type": "array",
|
|
34
|
+
"items": { "$ref": "#/$defs/publicArtifact" }
|
|
35
|
+
},
|
|
36
|
+
"capability_grants": {
|
|
37
|
+
"type": "array",
|
|
38
|
+
"items": { "$ref": "#/$defs/publicArtifact" }
|
|
39
|
+
},
|
|
40
|
+
"capability_revocations": {
|
|
41
|
+
"type": "array",
|
|
42
|
+
"items": { "$ref": "#/$defs/publicArtifact" }
|
|
43
|
+
},
|
|
44
|
+
"benchmark_attestations": {
|
|
45
|
+
"type": "array",
|
|
46
|
+
"items": { "$ref": "#/$defs/benchmarkAttestation" }
|
|
47
|
+
},
|
|
48
|
+
"leakage_scan": { "$ref": "#/$defs/leakageScan" },
|
|
49
|
+
"claim_boundaries": {
|
|
50
|
+
"type": "array",
|
|
51
|
+
"minItems": 1,
|
|
52
|
+
"items": { "$ref": "#/$defs/claimBoundary" }
|
|
53
|
+
},
|
|
54
|
+
"transaction_submitted": { "const": false },
|
|
55
|
+
"public_payload_only": { "const": true }
|
|
56
|
+
},
|
|
57
|
+
"$defs": {
|
|
58
|
+
"sha256Digest": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
|
|
59
|
+
"publicRef": { "type": "string", "minLength": 1 },
|
|
60
|
+
"publicArtifact": {
|
|
61
|
+
"type": "object",
|
|
62
|
+
"required": ["schema", "artifact_hash"],
|
|
63
|
+
"additionalProperties": false,
|
|
64
|
+
"properties": {
|
|
65
|
+
"schema": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"enum": [
|
|
68
|
+
"enigma.proof_network.anchor_batch.v1",
|
|
69
|
+
"enigma.proof_network.capability_grant.v1",
|
|
70
|
+
"enigma.proof_network.capability_revocation.v1",
|
|
71
|
+
"enigma.proof_network.benchmark_attestation.v1"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"artifact_hash": { "$ref": "#/$defs/sha256Digest" },
|
|
75
|
+
"artifact_ref": { "$ref": "#/$defs/publicRef" },
|
|
76
|
+
"root": { "$ref": "#/$defs/sha256Digest" }
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"benchmarkAttestation": {
|
|
80
|
+
"type": "object",
|
|
81
|
+
"required": [
|
|
82
|
+
"schema",
|
|
83
|
+
"attestation_id",
|
|
84
|
+
"generated_at",
|
|
85
|
+
"package_version",
|
|
86
|
+
"dataset_hash",
|
|
87
|
+
"runner_hash",
|
|
88
|
+
"report_hash",
|
|
89
|
+
"metrics_digest",
|
|
90
|
+
"leakage_scan",
|
|
91
|
+
"claim_boundaries"
|
|
92
|
+
],
|
|
93
|
+
"additionalProperties": false,
|
|
94
|
+
"properties": {
|
|
95
|
+
"schema": { "const": "enigma.proof_network.benchmark_attestation.v1" },
|
|
96
|
+
"attestation_id": { "type": "string", "minLength": 8 },
|
|
97
|
+
"generated_at": { "type": "string", "format": "date-time" },
|
|
98
|
+
"package_version": { "type": "string", "minLength": 1 },
|
|
99
|
+
"dataset_hash": { "$ref": "#/$defs/sha256Digest" },
|
|
100
|
+
"dataset_ref": { "$ref": "#/$defs/publicRef" },
|
|
101
|
+
"runner_hash": { "$ref": "#/$defs/sha256Digest" },
|
|
102
|
+
"runner_ref": { "$ref": "#/$defs/publicRef" },
|
|
103
|
+
"report_hash": { "$ref": "#/$defs/sha256Digest" },
|
|
104
|
+
"report_ref": { "$ref": "#/$defs/publicRef" },
|
|
105
|
+
"metrics_digest": { "$ref": "#/$defs/metricsDigest" },
|
|
106
|
+
"leakage_scan": { "$ref": "#/$defs/leakageScan" },
|
|
107
|
+
"claim_boundaries": {
|
|
108
|
+
"type": "array",
|
|
109
|
+
"minItems": 1,
|
|
110
|
+
"items": { "$ref": "#/$defs/claimBoundary" }
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"metricsDigest": {
|
|
115
|
+
"type": "object",
|
|
116
|
+
"required": ["digest", "metric_count", "canonicalization"],
|
|
117
|
+
"additionalProperties": false,
|
|
118
|
+
"properties": {
|
|
119
|
+
"digest": { "$ref": "#/$defs/sha256Digest" },
|
|
120
|
+
"metric_count": { "type": "integer", "minimum": 0 },
|
|
121
|
+
"metric_keys": {
|
|
122
|
+
"type": "array",
|
|
123
|
+
"items": { "type": "string", "minLength": 1 },
|
|
124
|
+
"uniqueItems": true
|
|
125
|
+
},
|
|
126
|
+
"canonicalization": { "type": "string", "enum": ["json-c14n-sha256", "canonical-json-sha256"] },
|
|
127
|
+
"metrics_schema_ref": { "$ref": "#/$defs/publicRef" }
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"leakageScan": {
|
|
131
|
+
"type": "object",
|
|
132
|
+
"required": ["scanned", "passed", "policy", "public_payload_only", "private_payload_detected", "forbidden_field_names"],
|
|
133
|
+
"additionalProperties": false,
|
|
134
|
+
"properties": {
|
|
135
|
+
"scanned": { "const": true },
|
|
136
|
+
"passed": { "const": true },
|
|
137
|
+
"policy": { "const": "public_hashes_roots_refs_counts_only" },
|
|
138
|
+
"public_payload_only": { "const": true },
|
|
139
|
+
"private_payload_detected": { "const": false },
|
|
140
|
+
"forbidden_field_names": {
|
|
141
|
+
"type": "array",
|
|
142
|
+
"maxItems": 0,
|
|
143
|
+
"items": { "type": "string" }
|
|
144
|
+
},
|
|
145
|
+
"scanner_ref": { "$ref": "#/$defs/publicRef" },
|
|
146
|
+
"scanned_at": { "type": "string", "format": "date-time" }
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
"claimBoundary": {
|
|
150
|
+
"type": "object",
|
|
151
|
+
"required": ["claim_id", "claim", "allowed_scope", "not_proven"],
|
|
152
|
+
"additionalProperties": false,
|
|
153
|
+
"properties": {
|
|
154
|
+
"claim_id": { "type": "string", "minLength": 1 },
|
|
155
|
+
"claim": { "type": "string", "minLength": 1 },
|
|
156
|
+
"allowed_scope": { "type": "string", "minLength": 1 },
|
|
157
|
+
"not_proven": {
|
|
158
|
+
"type": "array",
|
|
159
|
+
"minItems": 1,
|
|
160
|
+
"items": { "type": "string", "minLength": 1 },
|
|
161
|
+
"uniqueItems": true
|
|
162
|
+
},
|
|
163
|
+
"evidence_refs": {
|
|
164
|
+
"type": "array",
|
|
165
|
+
"items": { "$ref": "#/$defs/publicRef" },
|
|
166
|
+
"uniqueItems": true
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { execFile } from 'node:child_process';
|
|
3
|
-
import { mkdir } from 'node:fs/promises';
|
|
4
|
-
import { dirname, isAbsolute, resolve as resolvePath } from 'node:path';
|
|
5
|
-
import { promisify } from 'node:util';
|
|
6
|
-
import { fileURLToPath } from 'node:url';
|
|
7
|
-
|
|
8
|
-
export const INSTALLER_SCHEMA = 'enigma.local_installer.v1';
|
|
9
|
-
export const REQUIRED_NODE_MAJOR = 24;
|
|
10
|
-
export const DEFAULT_BUNDLE_PATH = '.enigma/bundle.json';
|
|
11
|
-
|
|
12
|
-
const execFileAsync = promisify(execFile);
|
|
13
|
-
const SCRIPT_PATH = fileURLToPath(import.meta.url);
|
|
14
|
-
const DEFAULT_PACKAGE_DIR = resolvePath(dirname(SCRIPT_PATH), '..');
|
|
15
|
-
const SAFE_COMMAND_RE = /^[A-Za-z0-9._-]+$/u;
|
|
16
|
-
|
|
17
|
-
function readRequiredValue(argv, index, flag) {
|
|
18
|
-
const value = argv[index + 1];
|
|
19
|
-
if (value === undefined || value.startsWith('--')) throw new Error(`Missing value for ${flag}.`);
|
|
20
|
-
return value;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function usage() {
|
|
24
|
-
return `Usage: node scripts/install-enigma-local.mjs [--dry-run|--execute] [--init-vault] [--bundle <path>]\n\nDry-run is the default. Execute mode runs npm install -g . from the local checkout.\nNo network download command is generated, and vault initialization runs only when --init-vault is present.\n`;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function parseInstallerArgs(argv = process.argv.slice(2)) {
|
|
28
|
-
const options = {
|
|
29
|
-
dryRun: true,
|
|
30
|
-
execute: false,
|
|
31
|
-
initVault: false,
|
|
32
|
-
bundlePath: DEFAULT_BUNDLE_PATH,
|
|
33
|
-
packageDir: DEFAULT_PACKAGE_DIR,
|
|
34
|
-
subject: 'local-user',
|
|
35
|
-
displayName: 'Local user',
|
|
36
|
-
};
|
|
37
|
-
let sawDryRun = false;
|
|
38
|
-
let sawExecute = false;
|
|
39
|
-
|
|
40
|
-
for (let index = 0; index < argv.length; index += 1) {
|
|
41
|
-
const arg = argv[index];
|
|
42
|
-
if (arg === '--help' || arg === '-h') {
|
|
43
|
-
options.help = true;
|
|
44
|
-
} else if (arg === '--dry-run') {
|
|
45
|
-
sawDryRun = true;
|
|
46
|
-
options.dryRun = true;
|
|
47
|
-
options.execute = false;
|
|
48
|
-
} else if (arg === '--execute') {
|
|
49
|
-
sawExecute = true;
|
|
50
|
-
options.dryRun = false;
|
|
51
|
-
options.execute = true;
|
|
52
|
-
} else if (arg === '--init-vault') {
|
|
53
|
-
options.initVault = true;
|
|
54
|
-
} else if (arg === '--no-init-vault') {
|
|
55
|
-
options.initVault = false;
|
|
56
|
-
} else if (arg === '--bundle') {
|
|
57
|
-
options.bundlePath = readRequiredValue(argv, index, arg);
|
|
58
|
-
index += 1;
|
|
59
|
-
} else if (arg === '--package-dir') {
|
|
60
|
-
options.packageDir = readRequiredValue(argv, index, arg);
|
|
61
|
-
index += 1;
|
|
62
|
-
} else if (arg === '--subject') {
|
|
63
|
-
options.subject = readRequiredValue(argv, index, arg);
|
|
64
|
-
index += 1;
|
|
65
|
-
} else if (arg === '--display-name') {
|
|
66
|
-
options.displayName = readRequiredValue(argv, index, arg);
|
|
67
|
-
index += 1;
|
|
68
|
-
} else {
|
|
69
|
-
throw new Error('Unknown argument.');
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (sawDryRun && sawExecute) throw new Error('Use either --dry-run or --execute, not both.');
|
|
74
|
-
return options;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function nodeMajor(version) {
|
|
78
|
-
const match = String(version ?? '').trim().match(/^v?(\d+)(?:\.\d+){0,2}(?:[-+].*)?$/u);
|
|
79
|
-
if (!match) throw new Error('Invalid Node version override.');
|
|
80
|
-
return Number(match[1]);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function validateNodeVersion(version = process.versions.node, requiredMajor = REQUIRED_NODE_MAJOR) {
|
|
84
|
-
const major = nodeMajor(version);
|
|
85
|
-
if (!Number.isSafeInteger(major) || major < requiredMajor) {
|
|
86
|
-
throw new Error(`Node >=${requiredMajor} is required for the local Enigma installer.`);
|
|
87
|
-
}
|
|
88
|
-
return { ok: true, required: `>=${requiredMajor}`, current_major: major };
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function commandForPlatform(base, platform) {
|
|
92
|
-
return platform === 'win32' ? `${base}.cmd` : base;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function rejectUnsafeArg(arg, label) {
|
|
96
|
-
const value = String(arg ?? '');
|
|
97
|
-
if (value.length === 0) throw new Error(`${label} must not be empty.`);
|
|
98
|
-
if (value.includes('\0') || value.includes('\n') || value.includes('\r')) throw new Error(`${label} contains an invalid control character.`);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export function validateCommandSpec(spec) {
|
|
102
|
-
if (!spec || typeof spec !== 'object' || Array.isArray(spec)) throw new Error('Installer command spec must be an object.');
|
|
103
|
-
const command = String(spec.command ?? '');
|
|
104
|
-
if (!SAFE_COMMAND_RE.test(command)) throw new Error('Installer command name is not safe.');
|
|
105
|
-
const args = Array.isArray(spec.args) ? spec.args.map(String) : [];
|
|
106
|
-
for (const [index, arg] of args.entries()) rejectUnsafeArg(arg, `Installer command argument ${index}`);
|
|
107
|
-
|
|
108
|
-
if (command === 'npm' || command === 'npm.cmd') {
|
|
109
|
-
if (args.length !== 3 || args[0] !== 'install' || args[1] !== '-g' || args[2] !== '.') {
|
|
110
|
-
throw new Error('Installer npm command must be exactly npm install -g .');
|
|
111
|
-
}
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (command === 'enigma' || command === 'enigma.cmd') {
|
|
116
|
-
const bundleIndex = args.indexOf('--bundle');
|
|
117
|
-
if (args[0] !== 'init' || bundleIndex === -1 || bundleIndex + 1 >= args.length) {
|
|
118
|
-
throw new Error('Installer Enigma command must initialize a bundle with --bundle.');
|
|
119
|
-
}
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
throw new Error('Installer command is not allowlisted.');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function publicCommand(command) {
|
|
127
|
-
if (command.step === 'install_package') return { command: 'npm', args: ['install', '-g', '.'] };
|
|
128
|
-
return { command: 'enigma', args: ['init', '--bundle', '<bundle-path>', '--subject', '<subject>', '--display-name', '<display-name>'] };
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export function buildInstallerPlan(options = {}, runtime = {}) {
|
|
132
|
-
const platform = runtime.platform ?? process.platform;
|
|
133
|
-
const cwd = runtime.cwd ?? process.cwd();
|
|
134
|
-
const requestedPackageDir = String(options.packageDir ?? DEFAULT_PACKAGE_DIR);
|
|
135
|
-
rejectUnsafeArg(requestedPackageDir, 'Package directory');
|
|
136
|
-
const packageDir = resolvePath(requestedPackageDir);
|
|
137
|
-
const requestedBundlePath = String(options.bundlePath ?? DEFAULT_BUNDLE_PATH);
|
|
138
|
-
rejectUnsafeArg(requestedBundlePath, 'Bundle path');
|
|
139
|
-
const bundlePath = isAbsolute(requestedBundlePath) ? resolvePath(requestedBundlePath) : resolvePath(cwd, requestedBundlePath);
|
|
140
|
-
|
|
141
|
-
const commands = [
|
|
142
|
-
{
|
|
143
|
-
step: 'install_package',
|
|
144
|
-
command: commandForPlatform('npm', platform),
|
|
145
|
-
args: ['install', '-g', '.'],
|
|
146
|
-
cwd: packageDir,
|
|
147
|
-
mutates_global_state: true,
|
|
148
|
-
},
|
|
149
|
-
];
|
|
150
|
-
|
|
151
|
-
if (options.initVault === true) {
|
|
152
|
-
commands.push({
|
|
153
|
-
step: 'initialize_vault',
|
|
154
|
-
command: commandForPlatform('enigma', platform),
|
|
155
|
-
args: ['init', '--bundle', bundlePath, '--subject', String(options.subject ?? 'local-user'), '--display-name', String(options.displayName ?? 'Local user')],
|
|
156
|
-
cwd: packageDir,
|
|
157
|
-
mutates_local_filesystem: true,
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
for (const command of commands) validateCommandSpec(command);
|
|
162
|
-
|
|
163
|
-
return {
|
|
164
|
-
dryRun: options.execute === true ? false : true,
|
|
165
|
-
execute: options.execute === true,
|
|
166
|
-
packageDir,
|
|
167
|
-
bundlePath,
|
|
168
|
-
bundlePathKind: requestedBundlePath === DEFAULT_BUNDLE_PATH ? 'default' : (isAbsolute(requestedBundlePath) ? 'absolute' : 'relative'),
|
|
169
|
-
initVault: options.initVault === true,
|
|
170
|
-
commands,
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function publicCommandRecords(plan, resultByStep = new Map()) {
|
|
175
|
-
return plan.commands.map((command) => {
|
|
176
|
-
const publicSpec = publicCommand(command);
|
|
177
|
-
const runResult = resultByStep.get(command.step);
|
|
178
|
-
return {
|
|
179
|
-
step: command.step,
|
|
180
|
-
command: publicSpec.command,
|
|
181
|
-
args: publicSpec.args,
|
|
182
|
-
status: plan.execute ? (runResult?.ok ? 'executed' : 'pending') : 'preview',
|
|
183
|
-
mutates: command.mutates_global_state === true ? 'global_npm_install' : 'local_bundle_file',
|
|
184
|
-
};
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function publicOutput(plan, node, commandResults = []) {
|
|
189
|
-
const resultByStep = new Map(commandResults.map((result) => [result.step, result]));
|
|
190
|
-
const commands = publicCommandRecords(plan, resultByStep);
|
|
191
|
-
return {
|
|
192
|
-
schema: INSTALLER_SCHEMA,
|
|
193
|
-
ok: commandResults.every((result) => result.ok !== false),
|
|
194
|
-
mode: plan.execute ? 'execute' : 'dry-run',
|
|
195
|
-
dry_run: plan.dryRun,
|
|
196
|
-
execute: plan.execute,
|
|
197
|
-
public_safe: true,
|
|
198
|
-
node,
|
|
199
|
-
package_source: {
|
|
200
|
-
kind: 'local_checkout',
|
|
201
|
-
install_boundary: 'Runs npm install -g . against the checked-out package only; it does not download Enigma from a registry.',
|
|
202
|
-
},
|
|
203
|
-
bundle: {
|
|
204
|
-
path: '<bundle-path>',
|
|
205
|
-
path_kind: plan.bundlePathKind,
|
|
206
|
-
initialize_requested: plan.initVault,
|
|
207
|
-
initialized: plan.execute && plan.initVault && resultByStep.get('initialize_vault')?.ok === true,
|
|
208
|
-
},
|
|
209
|
-
commands,
|
|
210
|
-
preview: {
|
|
211
|
-
commands,
|
|
212
|
-
},
|
|
213
|
-
safety: {
|
|
214
|
-
default_dry_run: true,
|
|
215
|
-
requires_execute_for_mutation: true,
|
|
216
|
-
shell: false,
|
|
217
|
-
network_download_command: false,
|
|
218
|
-
prints_local_absolute_paths: false,
|
|
219
|
-
prints_secrets: false,
|
|
220
|
-
},
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
async function runCommand(command, execFileImpl) {
|
|
225
|
-
try {
|
|
226
|
-
await execFileImpl(command.command, command.args, { cwd: command.cwd, windowsHide: true });
|
|
227
|
-
return { step: command.step, ok: true };
|
|
228
|
-
} catch {
|
|
229
|
-
throw new Error(`Installer command failed at ${command.step}.`);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
export async function runInstallEnigmaLocal(argv = process.argv.slice(2), runtime = {}) {
|
|
234
|
-
const options = Array.isArray(argv) ? parseInstallerArgs(argv) : { ...argv };
|
|
235
|
-
const node = validateNodeVersion(options.nodeVersion ?? runtime.nodeVersion ?? process.versions.node);
|
|
236
|
-
const plan = buildInstallerPlan(options, runtime);
|
|
237
|
-
if (plan.dryRun) return publicOutput(plan, node);
|
|
238
|
-
|
|
239
|
-
const mkdirImpl = runtime.mkdirImpl ?? mkdir;
|
|
240
|
-
if (options.initVault === true) await mkdirImpl(dirname(plan.bundlePath), { recursive: true });
|
|
241
|
-
const execFileImpl = runtime.execFileImpl ?? execFileAsync;
|
|
242
|
-
const commandResults = [];
|
|
243
|
-
for (const command of plan.commands) {
|
|
244
|
-
commandResults.push(await runCommand(command, execFileImpl));
|
|
245
|
-
}
|
|
246
|
-
return publicOutput(plan, node, commandResults);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function safeErrorMessage(error) {
|
|
250
|
-
const message = String(error?.message ?? error);
|
|
251
|
-
if (/^(Missing value|Unknown argument|Use either|Invalid Node version|Node >=|Installer command)/u.test(message)) return message;
|
|
252
|
-
return 'Local Enigma installer failed.';
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
async function main() {
|
|
256
|
-
const args = parseInstallerArgs();
|
|
257
|
-
if (args.help) {
|
|
258
|
-
process.stdout.write(usage());
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
const output = await runInstallEnigmaLocal(args);
|
|
262
|
-
process.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (process.argv[1] && fileURLToPath(import.meta.url) === resolvePath(process.argv[1])) {
|
|
266
|
-
main().catch((error) => {
|
|
267
|
-
process.stdout.write(`${JSON.stringify({ schema: INSTALLER_SCHEMA, ok: false, public_safe: true, error: { code: 'LOCAL_INSTALLER_FAILED', message: safeErrorMessage(error) } }, null, 2)}\n`);
|
|
268
|
-
process.exitCode = 1;
|
|
269
|
-
});
|
|
270
|
-
}
|