@conarium-ai/core 0.2.8 → 0.2.10
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/CHANGELOG.md +26 -0
- package/LIMITATIONS.md +49 -0
- package/LIMITATIONS.tr.md +49 -0
- package/README.md +42 -4
- package/SECURITY.md +14 -0
- package/assets/conarium-mark-512.png +0 -0
- package/assets/conarium-mark.icns +0 -0
- package/assets/conarium-mark.ico +0 -0
- package/assets/conarium-mark.svg +4 -0
- package/assets/hero/eye-base.webp +0 -0
- package/assets/hero/iris.webp +0 -0
- package/bin/conarium-anchor-upgrade.mjs +10 -43
- package/bin/conarium-console.mjs +3 -0
- package/bin/conarium-doctor.mjs +13 -17
- package/bin/conarium-stamp.mjs +4 -13
- package/bin/conarium-verify.mjs +13 -62
- package/deploy/anchor-service/README.md +3 -4
- package/dist/anchor-service.d.ts.map +1 -1
- package/dist/anchor-service.js +11 -26
- package/dist/anchor-service.js.map +1 -1
- package/dist/anchor.d.ts +6 -31
- package/dist/anchor.d.ts.map +1 -1
- package/dist/anchor.js +15 -65
- package/dist/anchor.js.map +1 -1
- package/dist/audit.d.ts +3 -1
- package/dist/audit.d.ts.map +1 -1
- package/dist/audit.js +7 -1
- package/dist/audit.js.map +1 -1
- package/dist/config.d.ts +68 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +38 -1
- package/dist/config.js.map +1 -1
- package/dist/console-shortcut.d.ts +9 -1
- package/dist/console-shortcut.d.ts.map +1 -1
- package/dist/console-shortcut.js +47 -13
- package/dist/console-shortcut.js.map +1 -1
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +12 -2
- package/dist/console.js.map +1 -1
- package/dist/custom_patterns.d.ts +42 -0
- package/dist/custom_patterns.d.ts.map +1 -0
- package/dist/custom_patterns.js +164 -0
- package/dist/custom_patterns.js.map +1 -0
- package/dist/governance.d.ts +7 -1
- package/dist/governance.d.ts.map +1 -1
- package/dist/governance.js +38 -13
- package/dist/governance.js.map +1 -1
- package/dist/ots/calendar.d.ts +11 -0
- package/dist/ots/calendar.d.ts.map +1 -0
- package/dist/ots/calendar.js +93 -0
- package/dist/ots/calendar.js.map +1 -0
- package/dist/ots/client.d.ts +29 -0
- package/dist/ots/client.d.ts.map +1 -0
- package/dist/ots/client.js +102 -0
- package/dist/ots/client.js.map +1 -0
- package/dist/ots/codec.d.ts +26 -0
- package/dist/ots/codec.d.ts.map +1 -0
- package/dist/ots/codec.js +92 -0
- package/dist/ots/codec.js.map +1 -0
- package/dist/ots/format.d.ts +60 -0
- package/dist/ots/format.d.ts.map +1 -0
- package/dist/ots/format.js +232 -0
- package/dist/ots/format.js.map +1 -0
- package/dist/receipt-view.d.ts +1 -0
- package/dist/receipt-view.d.ts.map +1 -1
- package/dist/receipt-view.js +25 -4
- package/dist/receipt-view.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -0
- package/dist/server.js.map +1 -1
- package/dist/types.d.ts +20 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/security/PENTEST-SCOPE.md +90 -0
- package/docs/security/THREAT-MODEL.md +116 -0
- package/docs/specs/2026-08-14-oracle-mssql-dialect-design.md +232 -0
- package/package.json +6 -12
- package/public/app.js +43 -66
- package/public/index.html +2 -1
- package/public/receipts-panel.js +87 -0
- package/public/style.css +2 -4
- package/scripts/render-conarium-mark.py +70 -0
- package/scripts/start-mcp-c1.mjs +23 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
- **Built-in OpenTimestamps client.** Stamp / upgrade / verify no longer
|
|
6
|
+
load `javascript-opentimestamps`. The `web3` / `request` / `bitcore` tree
|
|
7
|
+
is not installed. Old proofs still verify (pending fixture + dogfood
|
|
8
|
+
block 960327).
|
|
9
|
+
- **Threat model and pentest scope** in `docs/security/`.
|
|
10
|
+
|
|
11
|
+
- **LIMITATIONS.md** (and `LIMITATIONS.tr.md`) lists what this repository has
|
|
12
|
+
not done. README links it in the body, not a footnote. Comparison stays on
|
|
13
|
+
the site only.
|
|
14
|
+
- **`test:checks` runs every check even if one fails.** The old `&&` chain
|
|
15
|
+
went silent after the first failure. `test/init.mjs` resolves temp paths
|
|
16
|
+
with `fs.realpathSync` (`/var` vs `/private/var` on macOS).
|
|
17
|
+
- **OpenTimestamps opt-in warning.** Enabling the feature pulls a tree with
|
|
18
|
+
7 critical and 3 high known advisories. Default install still does not.
|
|
19
|
+
|
|
20
|
+
- **c1 launcher sets `CONARIUM_AUDIT_SIGNING_KEY`** from
|
|
21
|
+
`~/.conarium/audit-ed25519.pem` when `receiptSink` is set. Cursor MCP env
|
|
22
|
+
did not; the process could not boot receipts. The sink file is still not
|
|
23
|
+
invented empty.
|
|
24
|
+
- **Desktop / panel mark.** `assets/conarium-mark.svg` (extracted, not
|
|
25
|
+
redesigned) plus `.ico` / `.icns` / 512 PNG. Shortcuts set Icon; missing
|
|
26
|
+
file warns. Panel CSS gradient square is gone.
|
|
27
|
+
- **`/proof` HTML shows known English sentences in Turkish.** The JSON
|
|
28
|
+
bytes are unchanged; unknown strings are left as-is.
|
|
29
|
+
- **Makbuzlar tab paints "Yükleniyor…" on the same click that switches the tab.**
|
|
30
|
+
The list was filled only after `await`; the first click left a blank card.
|
|
5
31
|
- **Console Makbuzlar tab.** Lists `audit.receiptSink` newest-first, opens the
|
|
6
32
|
same receipt HTML as `/proof`, and writes **zincir sağlam** / **kırık (satır N)**.
|
|
7
33
|
Renderer is `src/receipt-view.ts` — demo must not keep a second copy.
|
package/LIMITATIONS.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Limitations
|
|
2
|
+
|
|
3
|
+
What Conarium has not done. Measured. No dates.
|
|
4
|
+
|
|
5
|
+
## No certification
|
|
6
|
+
|
|
7
|
+
No SOC 2. No ISO. No independent penetration test. On the roadmap.
|
|
8
|
+
|
|
9
|
+
## Not 1.0
|
|
10
|
+
|
|
11
|
+
Version is 0.2.x. The API can break.
|
|
12
|
+
|
|
13
|
+
## SQL is Postgres only
|
|
14
|
+
|
|
15
|
+
Oracle, Microsoft SQL Server, and MySQL are not implemented.
|
|
16
|
+
A design note exists: [`docs/specs/2026-08-14-oracle-mssql-dialect-design.md`](docs/specs/2026-08-14-oracle-mssql-dialect-design.md).
|
|
17
|
+
There is no code.
|
|
18
|
+
This is a second parser layer, not a connector. Today's security gate sits on `pgsql-ast-parser`. A new dialect rebuilds that layer.
|
|
19
|
+
|
|
20
|
+
## Names in free text are not guaranteed
|
|
21
|
+
|
|
22
|
+
Structured columns: deterministic (`maskColumns`).
|
|
23
|
+
Free text: best effort (carry-over of values this policy already masks; labelled names).
|
|
24
|
+
A bare name in running prose is not detected.
|
|
25
|
+
|
|
26
|
+
## One production install
|
|
27
|
+
|
|
28
|
+
The only production deployment is the author's own company.
|
|
29
|
+
There is no external reference customer.
|
|
30
|
+
The figure 121,366 identities masked comes from that company's ERP. It cannot be verified from outside.
|
|
31
|
+
|
|
32
|
+
## One-person team
|
|
33
|
+
|
|
34
|
+
Bus factor 1.
|
|
35
|
+
|
|
36
|
+
## Anchors may stay pending
|
|
37
|
+
|
|
38
|
+
An OpenTimestamps stamp can take hours to confirm on Bitcoin. Receipts already show `pending`.
|
|
39
|
+
|
|
40
|
+
## Cryptography is not independently audited
|
|
41
|
+
|
|
42
|
+
The Ed25519 implementation has not had a formal audit.
|
|
43
|
+
|
|
44
|
+
## OpenTimestamps client
|
|
45
|
+
|
|
46
|
+
Stamping uses a built-in calendar client (Node `crypto` + HTTPS to the public calendars).
|
|
47
|
+
`javascript-opentimestamps` is not a dependency. The `web3` / `elliptic` / `crypto-js` / `request` / `lodash` tree is not installed.
|
|
48
|
+
Bitcoin confirmation still takes hours; receipts still show `pending` until upgrade.
|
|
49
|
+
Bitcoin-block verification talks to `blockstream.info`. If that host is unreachable the verifier reports "could not check", not "valid".
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Sınırlar
|
|
2
|
+
|
|
3
|
+
Conarium'un yapmadıkları. Ölçülmüş. Tarih yok.
|
|
4
|
+
|
|
5
|
+
## Sertifikasyon yok
|
|
6
|
+
|
|
7
|
+
SOC 2 yok. ISO yok. Bağımsız sızma testi yok. Yol haritasında.
|
|
8
|
+
|
|
9
|
+
## 1.0 değil
|
|
10
|
+
|
|
11
|
+
Sürüm 0.2.x. API kırılabilir.
|
|
12
|
+
|
|
13
|
+
## SQL yalnız Postgres
|
|
14
|
+
|
|
15
|
+
Oracle, Microsoft SQL Server ve MySQL yok.
|
|
16
|
+
Tasarım notu var: [`docs/specs/2026-08-14-oracle-mssql-dialect-design.md`](docs/specs/2026-08-14-oracle-mssql-dialect-design.md).
|
|
17
|
+
Kod yok.
|
|
18
|
+
Bu bir konnektör değil, ikinci ayrıştırıcı katmanı. Bugünkü güvenlik kapısı `pgsql-ast-parser` üstünde duruyor. Yeni lehçe o katmanı yeniden kurar.
|
|
19
|
+
|
|
20
|
+
## Serbest metinde isim garantisi yok
|
|
21
|
+
|
|
22
|
+
Yapılandırılmış kolonlar: deterministik (`maskColumns`).
|
|
23
|
+
Serbest metin: en iyi çaba (bu politikanın zaten maskelediği değerlerin taşınması; etiketli isimler).
|
|
24
|
+
Düz cümledeki çıplak isim yakalanmaz.
|
|
25
|
+
|
|
26
|
+
## Tek üretim kurulumu
|
|
27
|
+
|
|
28
|
+
Tek üretim kurulumu yazarın kendi şirketi.
|
|
29
|
+
Dış referans müşteri yok.
|
|
30
|
+
121.366 kimlik maskelendi rakamı o şirketin ERP'sinden gelir. Dışarıdan doğrulanamaz.
|
|
31
|
+
|
|
32
|
+
## Tek kişilik ekip
|
|
33
|
+
|
|
34
|
+
Bus factor 1.
|
|
35
|
+
|
|
36
|
+
## Çıpa beklemede kalabilir
|
|
37
|
+
|
|
38
|
+
OpenTimestamps damgasının Bitcoin'de onaylanması saatler sürebilir. Makbuzda `pending` zaten görünür.
|
|
39
|
+
|
|
40
|
+
## Denetlenmemiş kriptografi
|
|
41
|
+
|
|
42
|
+
Ed25519 uygulaması resmî denetimden geçmedi.
|
|
43
|
+
|
|
44
|
+
## OpenTimestamps istemcisi
|
|
45
|
+
|
|
46
|
+
Damgalama yerleşik takvim istemcisiyle yapılır (Node `crypto` + herkese açık takvimlere HTTPS).
|
|
47
|
+
`javascript-opentimestamps` bağımlılık değil. `web3` / `elliptic` / `crypto-js` / `request` / `lodash` ağacı kurulmaz.
|
|
48
|
+
Bitcoin onayı yine saatler sürebilir; makbuz `pending` gösterir.
|
|
49
|
+
Bitcoin blok doğrulaması `blockstream.info`'ya sorar. O host yoksa doğrulayıcı "kontrol edemedim" der, "geçerli" demez.
|
package/README.md
CHANGED
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
|
|
16
16
|
The site lives at [conarium.dev](https://conarium.dev); this repository is the product.
|
|
17
17
|
|
|
18
|
+
## Limitations
|
|
19
|
+
|
|
20
|
+
What this repository has **not** done is in [LIMITATIONS.md](LIMITATIONS.md)
|
|
21
|
+
([Türkçe](LIMITATIONS.tr.md)). The dated comparison page is
|
|
22
|
+
[conarium.dev/compare.html](https://conarium.dev/compare.html) — that is the
|
|
23
|
+
only copy; this repo does not keep a second one.
|
|
24
|
+
|
|
18
25
|
## 👁️ The Problem
|
|
19
26
|
|
|
20
27
|
Point Cursor or Copilot at a production database and it drinks the raw stream—SSNs, credit cards, salaries, and live keys. One rogue prompt can expose your most sensitive tables. Security teams simply can't allow that.
|
|
@@ -77,6 +84,8 @@ npx conarium-verify ./receipts.jsonl --pubkey ./audit-ed25519.pub.pem --anchor-c
|
|
|
77
84
|
|
|
78
85
|
Opt-in anchoring: `CONARIUM_ANCHOR_SINK=opentimestamps`. Upgrade pending proofs later with
|
|
79
86
|
`npx conarium-anchor-upgrade ./audit.jsonl.anchors.jsonl`.
|
|
87
|
+
The client is in-tree (Node `crypto` + calendar HTTPS). It does not install
|
|
88
|
+
`javascript-opentimestamps`. See [LIMITATIONS.md](LIMITATIONS.md).
|
|
80
89
|
|
|
81
90
|
### Per-person masking profiles
|
|
82
91
|
|
|
@@ -405,8 +414,9 @@ Export `CONARIUM_CONSOLE_TOKEN` before `--install-shortcut` so the launcher
|
|
|
405
414
|
can read it from `~/.conarium/console.token` (created `0600`). The shortcut
|
|
406
415
|
file itself does not contain the token.
|
|
407
416
|
|
|
408
|
-
|
|
409
|
-
|
|
417
|
+
The shortcut uses `assets/conarium-mark.ico` / `.icns` / `-512.png`,
|
|
418
|
+
all from the same SVG. If those files are missing the shortcut is still
|
|
419
|
+
created and the command warns.
|
|
410
420
|
|
|
411
421
|
The console **Makbuzlar** tab lists signed receipts from `audit.receiptSink`
|
|
412
422
|
(newest first) and shows the same receipt HTML as `demo.conarium.dev/proof`.
|
|
@@ -487,6 +497,34 @@ product: masking that a bank can disable from a JSON file is not masking.
|
|
|
487
497
|
}
|
|
488
498
|
```
|
|
489
499
|
|
|
500
|
+
### `policy.customPatterns`
|
|
501
|
+
|
|
502
|
+
Formats the built-in detectors do not know — a bank customer number, a
|
|
503
|
+
house account code — can be registered as extra rules on the **same**
|
|
504
|
+
scanner. This is not a second masking path and it does not replace
|
|
505
|
+
`maskColumns`.
|
|
506
|
+
|
|
507
|
+
Each rule needs a name (what the receipt records), a pattern, optional
|
|
508
|
+
column globs, and a mask label. A broken or ReDoS-shaped pattern rejects
|
|
509
|
+
the config; the pattern text is never written to logs or receipts.
|
|
510
|
+
|
|
511
|
+
```json
|
|
512
|
+
{
|
|
513
|
+
"customPatterns": [
|
|
514
|
+
{
|
|
515
|
+
"name": "teb-hesap",
|
|
516
|
+
"pattern": "HSP-[0-9]{8}",
|
|
517
|
+
"columns": ["*.hesap_no"],
|
|
518
|
+
"label": "[MASKED_HESAP]"
|
|
519
|
+
}
|
|
520
|
+
]
|
|
521
|
+
}
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
Quantifiers must be bounded (`{8}`, `{4,12}`). `+`, `*`, nested groups and
|
|
525
|
+
lookaround are rejected at load. A rule names a format you already know;
|
|
526
|
+
it does not invent one.
|
|
527
|
+
|
|
490
528
|
`conarium-suggest-policy --sql schema.sql` prints a `maskColumns` guess from
|
|
491
529
|
column names (`*name*`, `*address*`, `*tckn*`, …). It does not write your
|
|
492
530
|
config. The first line of the output says so.
|
|
@@ -518,8 +556,8 @@ publishing `@conarium-ai/core` to npm so `npx conarium-init` works without a clo
|
|
|
518
556
|
- **SOC 2.** It audits organisations that hold customer data. We never receive
|
|
519
557
|
yours. If that ever stops being true, this line changes first.
|
|
520
558
|
|
|
521
|
-
Known gaps
|
|
522
|
-
[`docs/RECEIPT-SPEC.md`](docs/RECEIPT-SPEC.md)
|
|
559
|
+
Known gaps: [LIMITATIONS.md](LIMITATIONS.md), the README above, and
|
|
560
|
+
[`docs/RECEIPT-SPEC.md`](docs/RECEIPT-SPEC.md).
|
|
523
561
|
|
|
524
562
|
## 📜 License
|
|
525
563
|
|
package/SECURITY.md
CHANGED
|
@@ -29,6 +29,20 @@ a 2-second timeout, never blocks startup, and never throws.
|
|
|
29
29
|
it issues no network request at all. Everything else — connectors, receipts, audit
|
|
30
30
|
log, verification — is local to your infrastructure by construction.
|
|
31
31
|
|
|
32
|
+
## OpenTimestamps client
|
|
33
|
+
|
|
34
|
+
Anchoring is implemented in-tree (`src/ots/`). It talks to the public
|
|
35
|
+
OpenTimestamps calendars over HTTPS and hashes with Node `crypto`.
|
|
36
|
+
`javascript-opentimestamps` is not a dependency. Enabling
|
|
37
|
+
`CONARIUM_ANCHOR_SINK=opentimestamps` does not install `web3`, `elliptic`,
|
|
38
|
+
`crypto-js`, `request`, or `lodash`.
|
|
39
|
+
Bitcoin-block checks use `blockstream.info`. Unreachable explorer → exit 15
|
|
40
|
+
("could not check"), never a silent pass.
|
|
41
|
+
|
|
42
|
+
The tester pack is [`docs/security/THREAT-MODEL.md`](docs/security/THREAT-MODEL.md)
|
|
43
|
+
and [`docs/security/PENTEST-SCOPE.md`](docs/security/PENTEST-SCOPE.md).
|
|
44
|
+
Those documents are not an audit.
|
|
45
|
+
|
|
32
46
|
## Threat model
|
|
33
47
|
|
|
34
48
|
**Conarium protects against**
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -4,23 +4,12 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Usage: conarium-anchor-upgrade <anchors.jsonl>
|
|
6
6
|
*
|
|
7
|
-
* For each state:"pending" row,
|
|
8
|
-
* ots/state/bitcoinBlock/upgradedAt.
|
|
7
|
+
* For each state:"pending" row, asks the calendars for a fuller proof.
|
|
8
|
+
* On success refreshes ots/state/bitcoinBlock/upgradedAt.
|
|
9
|
+
* If nothing changed, leaves the file untouched.
|
|
9
10
|
*/
|
|
10
11
|
import { readFileSync, writeFileSync, existsSync } from 'fs'
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
const require = createRequire(import.meta.url)
|
|
14
|
-
|
|
15
|
-
function hashPrefixToBuffer(hash) {
|
|
16
|
-
const hex = hash.startsWith('sha256:') ? hash.slice('sha256:'.length) : hash
|
|
17
|
-
if (!/^[0-9a-fA-F]{64}$/.test(hex)) {
|
|
18
|
-
throw new Error(`bad hash: ${hash}`)
|
|
19
|
-
}
|
|
20
|
-
const buf = Buffer.from(hex, 'hex')
|
|
21
|
-
if (buf.length !== 32) throw new Error('hash must be 32 bytes')
|
|
22
|
-
return buf
|
|
23
|
-
}
|
|
12
|
+
import { upgradeProof } from '../dist/ots/client.js'
|
|
24
13
|
|
|
25
14
|
function loadRows(path) {
|
|
26
15
|
if (!existsSync(path)) {
|
|
@@ -39,15 +28,6 @@ async function main() {
|
|
|
39
28
|
process.exit(2)
|
|
40
29
|
}
|
|
41
30
|
|
|
42
|
-
let OpenTimestamps
|
|
43
|
-
try {
|
|
44
|
-
OpenTimestamps = require('javascript-opentimestamps')
|
|
45
|
-
if (OpenTimestamps && OpenTimestamps.default) OpenTimestamps = OpenTimestamps.default
|
|
46
|
-
} catch {
|
|
47
|
-
console.error('javascript-opentimestamps is required')
|
|
48
|
-
process.exit(2)
|
|
49
|
-
}
|
|
50
|
-
|
|
51
31
|
const rows = loadRows(path)
|
|
52
32
|
let changedAny = false
|
|
53
33
|
const out = []
|
|
@@ -58,34 +38,21 @@ async function main() {
|
|
|
58
38
|
continue
|
|
59
39
|
}
|
|
60
40
|
try {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
new OpenTimestamps.Ops.OpSHA256(),
|
|
64
|
-
hashBuf,
|
|
65
|
-
)
|
|
66
|
-
const detachedOts = OpenTimestamps.DetachedTimestampFile.deserialize(
|
|
67
|
-
Buffer.from(row.ots, 'base64'),
|
|
68
|
-
)
|
|
69
|
-
const changed = await OpenTimestamps.upgrade(detachedOts)
|
|
70
|
-
if (!changed) {
|
|
41
|
+
const up = await upgradeProof(Buffer.from(row.ots, 'base64'))
|
|
42
|
+
if (!up.changed) {
|
|
71
43
|
out.push(row)
|
|
72
44
|
continue
|
|
73
45
|
}
|
|
74
|
-
const verified = await OpenTimestamps.verify(detachedOts, detached, {
|
|
75
|
-
ignoreBitcoinNode: true,
|
|
76
|
-
timeout: 15000,
|
|
77
|
-
})
|
|
78
|
-
const height = verified?.bitcoin?.height
|
|
79
46
|
const next = {
|
|
80
47
|
...row,
|
|
81
|
-
ots:
|
|
82
|
-
state:
|
|
83
|
-
bitcoinBlock:
|
|
48
|
+
ots: up.otsBytes.toString('base64'),
|
|
49
|
+
state: up.bitcoinBlock != null ? 'bitcoin' : 'pending',
|
|
50
|
+
bitcoinBlock: up.bitcoinBlock,
|
|
84
51
|
upgradedAt: new Date().toISOString(),
|
|
85
52
|
}
|
|
86
53
|
out.push(next)
|
|
87
54
|
changedAny = true
|
|
88
|
-
console.error(`[upgrade] seq=${row.seq} → ${next.state}${
|
|
55
|
+
console.error(`[upgrade] seq=${row.seq} → ${next.state}${up.bitcoinBlock != null ? ` block=${up.bitcoinBlock}` : ''}`)
|
|
89
56
|
} catch (err) {
|
|
90
57
|
console.error(`[upgrade] seq=${row.seq} failed: ${err.message || err}`)
|
|
91
58
|
out.push(row)
|
package/bin/conarium-console.mjs
CHANGED
|
@@ -95,6 +95,9 @@ if (has('--install-shortcut') || has('--uninstall-shortcut')) {
|
|
|
95
95
|
token: token || undefined,
|
|
96
96
|
})
|
|
97
97
|
console.error(`conarium-console: shortcut at ${out.dest}${out.collided ? ' (name was taken, used -2)' : ''}`)
|
|
98
|
+
if (out.iconMissing) {
|
|
99
|
+
console.error('conarium-console: assets/ mark icon is missing; shortcut has no custom icon')
|
|
100
|
+
}
|
|
98
101
|
if (!token) {
|
|
99
102
|
console.error('conarium-console: CONARIUM_CONSOLE_TOKEN was not set; the shortcut will need it in the environment, or re-run install with the token exported')
|
|
100
103
|
}
|
package/bin/conarium-doctor.mjs
CHANGED
|
@@ -369,25 +369,21 @@ if (config) {
|
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
-
// 10. Anchoring
|
|
372
|
+
// 10. Anchoring uses the built-in calendar client (no extra package).
|
|
373
373
|
{
|
|
374
|
-
const
|
|
374
|
+
const sink = (process.env.CONARIUM_ANCHOR_SINK || '').toLowerCase()
|
|
375
|
+
const anchoring = Boolean(
|
|
376
|
+
sink === 'opentimestamps' ||
|
|
377
|
+
sink === 'ots' ||
|
|
378
|
+
envSet('CONARIUM_ANCHOR_BASE_URL') ||
|
|
379
|
+
envSet('CONARIUM_ANCHOR_STORE') ||
|
|
380
|
+
config?.audit?.anchor,
|
|
381
|
+
)
|
|
375
382
|
if (anchoring) {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
} catch {
|
|
381
|
-
present = false
|
|
382
|
-
}
|
|
383
|
-
if (present) ok('Anchoring', 'configured, javascript-opentimestamps present')
|
|
384
|
-
else
|
|
385
|
-
fail(
|
|
386
|
-
'Anchoring',
|
|
387
|
-
'configured, but javascript-opentimestamps is not installed',
|
|
388
|
-
'It is an OPTIONAL peer dependency (its transitive tree carried known vulnerabilities, so it is not installed by default). ' +
|
|
389
|
-
'Run: npm install javascript-opentimestamps — or turn anchoring off. Until then the verifier reports exit 15 (could not check).',
|
|
390
|
-
)
|
|
383
|
+
ok(
|
|
384
|
+
'Anchoring',
|
|
385
|
+
'configured — built-in OpenTimestamps client (Node crypto + calendar HTTPS). No javascript-opentimestamps.',
|
|
386
|
+
)
|
|
391
387
|
}
|
|
392
388
|
}
|
|
393
389
|
|
package/bin/conarium-stamp.mjs
CHANGED
|
@@ -26,9 +26,8 @@
|
|
|
26
26
|
*/
|
|
27
27
|
import { createHash } from 'crypto'
|
|
28
28
|
import { readFileSync, existsSync, appendFileSync } from 'fs'
|
|
29
|
-
import {
|
|
29
|
+
import { stampHash } from '../dist/ots/client.js'
|
|
30
30
|
|
|
31
|
-
const require = createRequire(import.meta.url)
|
|
32
31
|
const STAMP_TIMEOUT_MS = 30_000
|
|
33
32
|
|
|
34
33
|
function usage(msg) {
|
|
@@ -60,12 +59,6 @@ function parseArgs(argv) {
|
|
|
60
59
|
return out
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
function loadOts() {
|
|
64
|
-
let mod = require('javascript-opentimestamps')
|
|
65
|
-
if (mod && mod.default) mod = mod.default
|
|
66
|
-
return mod
|
|
67
|
-
}
|
|
68
|
-
|
|
69
62
|
async function main(argv = process.argv.slice(2)) {
|
|
70
63
|
let opts
|
|
71
64
|
try {
|
|
@@ -98,15 +91,13 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
98
91
|
let otsBase64
|
|
99
92
|
const submittedAt = new Date().toISOString()
|
|
100
93
|
try {
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
await Promise.race([
|
|
104
|
-
mod.stamp(detached),
|
|
94
|
+
const otsBytes = await Promise.race([
|
|
95
|
+
stampHash(digest, { timeoutMs: STAMP_TIMEOUT_MS }),
|
|
105
96
|
new Promise((_, reject) =>
|
|
106
97
|
setTimeout(() => reject(new Error(`stamp timed out after ${STAMP_TIMEOUT_MS}ms`)), STAMP_TIMEOUT_MS),
|
|
107
98
|
),
|
|
108
99
|
])
|
|
109
|
-
otsBase64 =
|
|
100
|
+
otsBase64 = otsBytes.toString('base64')
|
|
110
101
|
} catch (err) {
|
|
111
102
|
console.error(`stamping failed: ${err.message}`)
|
|
112
103
|
process.exit(50)
|
package/bin/conarium-verify.mjs
CHANGED
|
@@ -25,9 +25,6 @@
|
|
|
25
25
|
import { createHash, createPublicKey, verify as cryptoVerify } from 'crypto'
|
|
26
26
|
import { readFileSync, existsSync, statSync, readdirSync } from 'fs'
|
|
27
27
|
import { join, extname } from 'path'
|
|
28
|
-
import { createRequire } from 'module'
|
|
29
|
-
|
|
30
|
-
const require = createRequire(import.meta.url)
|
|
31
28
|
|
|
32
29
|
const RECEIPT_V1 = 'conarium-receipt/0.1'
|
|
33
30
|
const RECEIPT_V2 = 'conarium-receipt/0.2'
|
|
@@ -175,70 +172,24 @@ function findAnchorRecord(rows, ref) {
|
|
|
175
172
|
return null
|
|
176
173
|
}
|
|
177
174
|
|
|
178
|
-
/**
|
|
179
|
-
* "Kontrol edemedim" ile "kanıt geçersiz" ayrımı.
|
|
180
|
-
*
|
|
181
|
-
* Yalnızca KESİN ulaşılamama durumları buraya girer. Tanımadığımız bir hata
|
|
182
|
-
* `unknown` sayılmaz, 14 (kanıt başarısız) tarafında kalır: belirsizliği
|
|
183
|
-
* "sorun yok" yönüne yuvarlamak, bu ayrımı yapmanın amacını yok ederdi.
|
|
184
|
-
*/
|
|
185
|
-
const AG_HATA_KODLARI = new Set([
|
|
186
|
-
'ESOCKETTIMEDOUT', 'ETIMEDOUT', 'ECONNREFUSED', 'ECONNRESET', 'ENOTFOUND',
|
|
187
|
-
'EAI_AGAIN', 'ENETUNREACH', 'EHOSTUNREACH', 'ECONNABORTED', 'EPIPE',
|
|
188
|
-
])
|
|
189
|
-
const AG_HATA_DESENI = /socket hang up|socket timed? ?out|network (is )?unreachable|getaddrinfo|request-promise|ESOCKETTIMEDOUT|ETIMEDOUT|ECONNREFUSED|ECONNRESET|ENOTFOUND|EAI_AGAIN/i
|
|
190
|
-
|
|
191
|
-
function ulasilamadiMi(err) {
|
|
192
|
-
if (!err) return false
|
|
193
|
-
if (err.code && AG_HATA_KODLARI.has(String(err.code))) return true
|
|
194
|
-
if (err.cause && err.cause.code && AG_HATA_KODLARI.has(String(err.cause.code))) return true
|
|
195
|
-
return AG_HATA_DESENI.test(String(err.message || err))
|
|
196
|
-
}
|
|
197
|
-
|
|
198
175
|
async function verifyOtsProof(otsBase64, hash) {
|
|
199
|
-
let
|
|
176
|
+
let client
|
|
200
177
|
try {
|
|
201
|
-
|
|
202
|
-
if (OpenTimestamps && OpenTimestamps.default) OpenTimestamps = OpenTimestamps.default
|
|
178
|
+
client = await import(new URL('../dist/ots/client.js', import.meta.url))
|
|
203
179
|
} catch {
|
|
204
|
-
//
|
|
205
|
-
//
|
|
206
|
-
|
|
207
|
-
return { unknown: true, detail: 'javascript-opentimestamps not installed — anchor not checked' }
|
|
180
|
+
// Built-in client lives in dist/. A lone copy of this file cannot check
|
|
181
|
+
// anchors — that is "could not check" (15), not "invalid" (14).
|
|
182
|
+
return { unknown: true, detail: 'ots client not available — anchor not checked' }
|
|
208
183
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
// Digest mismatch (proof for another hash) → fail closed before calendar I/O when possible
|
|
217
|
-
if (typeof detachedOts.fileDigest === 'function') {
|
|
218
|
-
const fileDigest = Buffer.from(detachedOts.fileDigest())
|
|
219
|
-
if (!fileDigest.equals(hashBuf)) {
|
|
220
|
-
return { ok: false, pending: false, detail: 'ots proof digest does not match chain hash' }
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
const verified = await OpenTimestamps.verify(detachedOts, detached, {
|
|
224
|
-
ignoreBitcoinNode: true,
|
|
225
|
-
timeout: 15000,
|
|
226
|
-
})
|
|
227
|
-
if (!verified || Object.keys(verified).length === 0) {
|
|
228
|
-
return { ok: true, pending: true }
|
|
229
|
-
}
|
|
230
|
-
return { ok: true, pending: !verified.bitcoin }
|
|
231
|
-
} catch (err) {
|
|
232
|
-
// Takvime/blok gezginine ulaşılamaması bir KANIT BAŞARISIZLIĞI değildir.
|
|
233
|
-
// Bu projenin bütün iddiası "kaydedilmedi ≠ olmadı" ayrımını yapmak; kendi
|
|
234
|
-
// doğrulayıcısı içeride bu ayrımı yapmazsa iddia kendi kodunda çürür.
|
|
235
|
-
// Dijest karşılaştırması zaten yukarıda ÇEVRİMDIŞI yapıldı, yani yerel
|
|
236
|
-
// gerçek kaybolmuyor — kaybolan yalnızca zaman kanıtının teyidi.
|
|
237
|
-
if (ulasilamadiMi(err)) {
|
|
238
|
-
return { unknown: true, detail: `anchor calendar unreachable: ${err.message || String(err)}` }
|
|
239
|
-
}
|
|
240
|
-
return { ok: false, pending: false, detail: err.message || String(err) }
|
|
184
|
+
const hashBuf = hashPrefixToBuffer(hash)
|
|
185
|
+
const result = await client.verifyProof(Buffer.from(otsBase64, 'base64'), hashBuf)
|
|
186
|
+
if (result.unknown) {
|
|
187
|
+
return { unknown: true, detail: result.detail || 'anchor calendar unreachable' }
|
|
188
|
+
}
|
|
189
|
+
if (!result.ok) {
|
|
190
|
+
return { ok: false, pending: false, detail: result.detail }
|
|
241
191
|
}
|
|
192
|
+
return { ok: true, pending: result.pending }
|
|
242
193
|
}
|
|
243
194
|
|
|
244
195
|
function loadVerifyKeys(paths) {
|
|
@@ -73,7 +73,6 @@ Then: `curl -fsS http://127.0.0.1:8797/healthz`
|
|
|
73
73
|
|
|
74
74
|
## Peer dependency
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
not
|
|
79
|
-
calendar library.
|
|
76
|
+
The OpenTimestamps client is built in (`src/ots/`). A live anchoring service
|
|
77
|
+
needs outbound HTTPS to the calendars, or `POST /anchor` returns 502.
|
|
78
|
+
`/healthz` does not stamp — a health probe does not depend on a calendar.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchor-service.d.ts","sourceRoot":"","sources":["../src/anchor-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"anchor-service.d.ts","sourceRoot":"","sources":["../src/anchor-service.ts"],"names":[],"mappings":"AA4BA,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,gBAAgB,CAAA;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,SAAS,GAAG,SAAS,CAAA;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,mFAAmF;IACnF,SAAS,EAAE,MAAM,CAAA;IACjB,0EAA0E;IAC1E,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC3B,yEAAyE;IACzE,aAAa,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,sEAAsE;IACtE,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;IAC3C,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC9F;AA0BD,8EAA8E;AAC9E,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,EAAE,CAKtD;AAUD,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAUhE;AAaD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,oBAAoB;;sBA4H/B,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;;EA0B5E"}
|
package/dist/anchor-service.js
CHANGED
|
@@ -22,42 +22,27 @@ import express from 'express';
|
|
|
22
22
|
import { randomBytes, timingSafeEqual } from 'crypto';
|
|
23
23
|
import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
24
24
|
import { dirname } from 'path';
|
|
25
|
-
import { createRequire } from 'module';
|
|
26
25
|
import { hashPrefixToBuffer } from './anchor.js';
|
|
27
|
-
|
|
28
|
-
// Vite/vitest resolve it wrongly through import analysis.
|
|
29
|
-
const require = createRequire(import.meta.url);
|
|
26
|
+
import { stampHash, upgradeProof } from './ots/client.js';
|
|
30
27
|
// Matches conarium-stamp. One slow calendar out of four is normal; 20s was not
|
|
31
28
|
// enough in practice and produced a 502 for a submission that would have landed.
|
|
32
29
|
const OTS_TIMEOUT_MS = 30_000;
|
|
33
|
-
function loadOts() {
|
|
34
|
-
const mod = require('javascript-opentimestamps');
|
|
35
|
-
return mod?.default ?? mod;
|
|
36
|
-
}
|
|
37
30
|
async function defaultStamp(digest) {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
await Promise.race([
|
|
41
|
-
mod.stamp(detached),
|
|
31
|
+
const otsBytes = await Promise.race([
|
|
32
|
+
stampHash(digest, { timeoutMs: OTS_TIMEOUT_MS }),
|
|
42
33
|
new Promise((_, reject) => setTimeout(() => reject(new Error(`stamp timed out after ${OTS_TIMEOUT_MS}ms`)), OTS_TIMEOUT_MS)),
|
|
43
34
|
]);
|
|
44
|
-
return
|
|
35
|
+
return otsBytes.toString('base64');
|
|
45
36
|
}
|
|
46
37
|
async function defaultUpgrade(otsBase64) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
const changed = await mod.upgrade(detached);
|
|
50
|
-
if (!changed)
|
|
38
|
+
const up = await upgradeProof(Buffer.from(otsBase64, 'base64'));
|
|
39
|
+
if (!up.changed)
|
|
51
40
|
return { upgraded: false };
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
else if (height && typeof height.toNumber === 'function')
|
|
58
|
-
block = height.toNumber();
|
|
59
|
-
}
|
|
60
|
-
return { upgraded: true, block, ots: Buffer.from(detached.serializeToBytes()).toString('base64') };
|
|
41
|
+
return {
|
|
42
|
+
upgraded: true,
|
|
43
|
+
block: up.bitcoinBlock ?? undefined,
|
|
44
|
+
ots: up.otsBytes.toString('base64'),
|
|
45
|
+
};
|
|
61
46
|
}
|
|
62
47
|
/** Reads every record. The store is small by design — one line per anchor. */
|
|
63
48
|
export function readStore(path) {
|