@naulon/sdk 0.1.0
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/dist/cli/check.d.ts +23 -0
- package/dist/cli/check.d.ts.map +1 -0
- package/dist/cli/check.js +100 -0
- package/dist/cli/check.js.map +1 -0
- package/dist/cli/crawl.d.ts +30 -0
- package/dist/cli/crawl.d.ts.map +1 -0
- package/dist/cli/crawl.js +180 -0
- package/dist/cli/crawl.js.map +1 -0
- package/dist/cli/doctor.d.ts +11 -0
- package/dist/cli/doctor.d.ts.map +1 -0
- package/dist/cli/doctor.js +69 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/init.d.ts +23 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +217 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/naulon.d.ts +3 -0
- package/dist/cli/naulon.d.ts.map +1 -0
- package/dist/cli/naulon.js +50 -0
- package/dist/cli/naulon.js.map +1 -0
- package/dist/contract/credits.d.ts +53 -0
- package/dist/contract/credits.d.ts.map +1 -0
- package/dist/contract/credits.js +56 -0
- package/dist/contract/credits.js.map +1 -0
- package/dist/contract/index.d.ts +4 -0
- package/dist/contract/index.d.ts.map +1 -0
- package/dist/contract/index.js +4 -0
- package/dist/contract/index.js.map +1 -0
- package/dist/contract/settlement.d.ts +67 -0
- package/dist/contract/settlement.d.ts.map +1 -0
- package/dist/contract/settlement.js +52 -0
- package/dist/contract/settlement.js.map +1 -0
- package/dist/contract/wallet.d.ts +23 -0
- package/dist/contract/wallet.d.ts.map +1 -0
- package/dist/contract/wallet.js +26 -0
- package/dist/contract/wallet.js.map +1 -0
- package/dist/crawl/adapters/rss.d.ts +12 -0
- package/dist/crawl/adapters/rss.d.ts.map +1 -0
- package/dist/crawl/adapters/rss.js +119 -0
- package/dist/crawl/adapters/rss.js.map +1 -0
- package/dist/crawl/adapters/sitemap.d.ts +12 -0
- package/dist/crawl/adapters/sitemap.d.ts.map +1 -0
- package/dist/crawl/adapters/sitemap.js +103 -0
- package/dist/crawl/adapters/sitemap.js.map +1 -0
- package/dist/crawl/adapters/wordpress.d.ts +19 -0
- package/dist/crawl/adapters/wordpress.d.ts.map +1 -0
- package/dist/crawl/adapters/wordpress.js +89 -0
- package/dist/crawl/adapters/wordpress.js.map +1 -0
- package/dist/crawl/authors.d.ts +27 -0
- package/dist/crawl/authors.d.ts.map +1 -0
- package/dist/crawl/authors.js +13 -0
- package/dist/crawl/authors.js.map +1 -0
- package/dist/crawl/crawl.d.ts +35 -0
- package/dist/crawl/crawl.d.ts.map +1 -0
- package/dist/crawl/crawl.js +28 -0
- package/dist/crawl/crawl.js.map +1 -0
- package/dist/crawl/credits-file.d.ts +39 -0
- package/dist/crawl/credits-file.d.ts.map +1 -0
- package/dist/crawl/credits-file.js +52 -0
- package/dist/crawl/credits-file.js.map +1 -0
- package/dist/crawl/fetcher.d.ts +15 -0
- package/dist/crawl/fetcher.d.ts.map +1 -0
- package/dist/crawl/fetcher.js +106 -0
- package/dist/crawl/fetcher.js.map +1 -0
- package/dist/crawl/glob.d.ts +19 -0
- package/dist/crawl/glob.d.ts.map +1 -0
- package/dist/crawl/glob.js +59 -0
- package/dist/crawl/glob.js.map +1 -0
- package/dist/crawl/net.d.ts +12 -0
- package/dist/crawl/net.d.ts.map +1 -0
- package/dist/crawl/net.js +93 -0
- package/dist/crawl/net.js.map +1 -0
- package/dist/crawl/registry.d.ts +17 -0
- package/dist/crawl/registry.d.ts.map +1 -0
- package/dist/crawl/registry.js +19 -0
- package/dist/crawl/registry.js.map +1 -0
- package/dist/crawl/slug.d.ts +15 -0
- package/dist/crawl/slug.d.ts.map +1 -0
- package/dist/crawl/slug.js +42 -0
- package/dist/crawl/slug.js.map +1 -0
- package/dist/crawl/types.d.ts +96 -0
- package/dist/crawl/types.d.ts.map +1 -0
- package/dist/crawl/types.js +21 -0
- package/dist/crawl/types.js.map +1 -0
- package/dist/crawl/xml.d.ts +9 -0
- package/dist/crawl/xml.d.ts.map +1 -0
- package/dist/crawl/xml.js +44 -0
- package/dist/crawl/xml.js.map +1 -0
- package/dist/crypto/fixture.d.ts +13 -0
- package/dist/crypto/fixture.d.ts.map +1 -0
- package/dist/crypto/fixture.js +39 -0
- package/dist/crypto/fixture.js.map +1 -0
- package/dist/crypto/sign.d.ts +7 -0
- package/dist/crypto/sign.d.ts.map +1 -0
- package/dist/crypto/sign.js +15 -0
- package/dist/crypto/sign.js.map +1 -0
- package/dist/crypto/verify.d.ts +21 -0
- package/dist/crypto/verify.d.ts.map +1 -0
- package/dist/crypto/verify.js +58 -0
- package/dist/crypto/verify.js.map +1 -0
- package/dist/doctor/doctor.d.ts +27 -0
- package/dist/doctor/doctor.d.ts.map +1 -0
- package/dist/doctor/doctor.js +149 -0
- package/dist/doctor/doctor.js.map +1 -0
- package/dist/express/_bridge.d.ts +32 -0
- package/dist/express/_bridge.d.ts.map +1 -0
- package/dist/express/_bridge.js +34 -0
- package/dist/express/_bridge.js.map +1 -0
- package/dist/express/credits-route.d.ts +6 -0
- package/dist/express/credits-route.d.ts.map +1 -0
- package/dist/express/credits-route.js +23 -0
- package/dist/express/credits-route.js.map +1 -0
- package/dist/express/index.d.ts +10 -0
- package/dist/express/index.d.ts.map +1 -0
- package/dist/express/index.js +9 -0
- package/dist/express/index.js.map +1 -0
- package/dist/express/settlement-receiver.d.ts +14 -0
- package/dist/express/settlement-receiver.d.ts.map +1 -0
- package/dist/express/settlement-receiver.js +31 -0
- package/dist/express/settlement-receiver.js.map +1 -0
- package/dist/idempotency.d.ts +23 -0
- package/dist/idempotency.d.ts.map +1 -0
- package/dist/idempotency.js +19 -0
- package/dist/idempotency.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/init/plan.d.ts +76 -0
- package/dist/init/plan.d.ts.map +1 -0
- package/dist/init/plan.js +132 -0
- package/dist/init/plan.js.map +1 -0
- package/dist/next/credits-route.d.ts +20 -0
- package/dist/next/credits-route.d.ts.map +1 -0
- package/dist/next/credits-route.js +18 -0
- package/dist/next/credits-route.js.map +1 -0
- package/dist/next/index.d.ts +10 -0
- package/dist/next/index.d.ts.map +1 -0
- package/dist/next/index.js +10 -0
- package/dist/next/index.js.map +1 -0
- package/dist/next/settlement-receiver.d.ts +12 -0
- package/dist/next/settlement-receiver.d.ts.map +1 -0
- package/dist/next/settlement-receiver.js +42 -0
- package/dist/next/settlement-receiver.js.map +1 -0
- package/dist/resolver/fixture.d.ts +10 -0
- package/dist/resolver/fixture.d.ts.map +1 -0
- package/dist/resolver/fixture.js +33 -0
- package/dist/resolver/fixture.js.map +1 -0
- package/dist/resolver/http.d.ts +3 -0
- package/dist/resolver/http.d.ts.map +1 -0
- package/dist/resolver/http.js +23 -0
- package/dist/resolver/http.js.map +1 -0
- package/dist/resolver/types.d.ts +11 -0
- package/dist/resolver/types.d.ts.map +1 -0
- package/dist/resolver/types.js +2 -0
- package/dist/resolver/types.js.map +1 -0
- package/package.json +67 -0
package/dist/cli/init.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `naulon init` — the interactive setup wizard (the CLI shell around `buildInitPlan`).
|
|
4
|
+
*
|
|
5
|
+
* naulon init # prompt for everything, sensible defaults in brackets
|
|
6
|
+
* naulon init --yes # non-interactive: flags + defaults, nothing asked (CI)
|
|
7
|
+
* naulon init --mode gateway --origin https://mysite.com --wallet 0x… --yes
|
|
8
|
+
*
|
|
9
|
+
* It writes two files the gate boots from — `.env` and a starter `credits.json` — and
|
|
10
|
+
* refuses to clobber either unless you pass `--force` (the `prisma init` rule). All the
|
|
11
|
+
* value logic lives in `../init/plan.ts`; this file is only prompts + I/O.
|
|
12
|
+
*/
|
|
13
|
+
import * as readline from "node:readline/promises";
|
|
14
|
+
import { existsSync } from "node:fs";
|
|
15
|
+
import { writeFile } from "node:fs/promises";
|
|
16
|
+
import { join, resolve } from "node:path";
|
|
17
|
+
import { WALLET_RE } from "../contract/wallet.js";
|
|
18
|
+
import { buildInitPlan, initAnswersSchema, INIT_DEFAULTS } from "../init/plan.js";
|
|
19
|
+
const DIM = "\x1b[2m";
|
|
20
|
+
const BOLD = "\x1b[1m";
|
|
21
|
+
const RESET = "\x1b[0m";
|
|
22
|
+
const DIAMOND = "◆";
|
|
23
|
+
const FLAG_MAP = {
|
|
24
|
+
"--origin": "originUrl",
|
|
25
|
+
"--price": "priceUsdc",
|
|
26
|
+
"--citation-multiplier": "citationMultiplier",
|
|
27
|
+
"--mode": "paymentMode",
|
|
28
|
+
"--network": "settlementNetwork",
|
|
29
|
+
"--port": "tollgatePort",
|
|
30
|
+
"--prefixes": "articlePrefixes",
|
|
31
|
+
"--credits": "creditsPath",
|
|
32
|
+
"--wallet": "defaultWallet",
|
|
33
|
+
"--slug": "starterSlug",
|
|
34
|
+
"--title": "starterTitle",
|
|
35
|
+
"--author-id": "starterAuthorId",
|
|
36
|
+
};
|
|
37
|
+
export function parseInitFlags(argv) {
|
|
38
|
+
const f = { yes: false, force: false, dir: process.cwd(), help: false };
|
|
39
|
+
for (let i = 0; i < argv.length; i++) {
|
|
40
|
+
const a = argv[i];
|
|
41
|
+
if (a === "--yes" || a === "-y")
|
|
42
|
+
f.yes = true;
|
|
43
|
+
else if (a === "--force" || a === "-f")
|
|
44
|
+
f.force = true;
|
|
45
|
+
else if (a === "--help" || a === "-h")
|
|
46
|
+
f.help = true;
|
|
47
|
+
else if (a === "--dir")
|
|
48
|
+
f.dir = argv[++i] ?? f.dir;
|
|
49
|
+
else if (a) {
|
|
50
|
+
const key = FLAG_MAP[a];
|
|
51
|
+
if (key)
|
|
52
|
+
f[key] = argv[++i];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return f;
|
|
56
|
+
}
|
|
57
|
+
const USAGE = `usage: naulon init [--yes] [--force] [--dir <path>]
|
|
58
|
+
[--origin <url>] [--price <n>] [--citation-multiplier <n>]
|
|
59
|
+
[--mode mock|gateway] [--network arcTestnet|baseSepolia|base]
|
|
60
|
+
[--port <n>] [--prefixes <csv>] [--credits <path>]
|
|
61
|
+
[--wallet 0x…] [--slug <s>] [--title <t>] [--author-id <id>]`;
|
|
62
|
+
function makeReader() {
|
|
63
|
+
const rl = readline.createInterface({ input: process.stdin });
|
|
64
|
+
const it = rl[Symbol.asyncIterator]();
|
|
65
|
+
return {
|
|
66
|
+
async next() {
|
|
67
|
+
const { value, done } = await it.next();
|
|
68
|
+
return done ? null : value;
|
|
69
|
+
},
|
|
70
|
+
close() {
|
|
71
|
+
rl.close();
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/** One prompt: shows the default in brackets, re-asks until the input validates. */
|
|
76
|
+
async function ask(reader, label, def, validate) {
|
|
77
|
+
for (;;) {
|
|
78
|
+
process.stdout.write(` ${DIAMOND} ${label} ${DIM}(${def})${RESET} `);
|
|
79
|
+
const line = await reader.next();
|
|
80
|
+
if (line === null)
|
|
81
|
+
return def; // input ended → accept the default, don't hang
|
|
82
|
+
const value = line.trim() === "" ? def : line.trim();
|
|
83
|
+
const err = validate?.(value) ?? null;
|
|
84
|
+
if (!err)
|
|
85
|
+
return value;
|
|
86
|
+
console.log(` ${DIM}↳ ${err}${RESET}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const vUrl = (v) => {
|
|
90
|
+
try {
|
|
91
|
+
new URL(v);
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return "enter a valid URL, e.g. https://mysite.com";
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const vPositive = (v) => (Number(v) > 0 ? null : "enter a number greater than 0");
|
|
99
|
+
const vPort = (v) => (Number.isInteger(Number(v)) && Number(v) > 0 ? null : "enter a whole port number");
|
|
100
|
+
const vMode = (v) => (v === "mock" || v === "gateway" ? null : "enter 'mock' or 'gateway'");
|
|
101
|
+
const vNetwork = (v) => ["arcTestnet", "baseSepolia", "base"].includes(v) ? null : "arcTestnet | baseSepolia | base";
|
|
102
|
+
const vWallet = (v) => (v === "" || WALLET_RE.test(v) ? null : "a 0x-prefixed 40-hex address, or blank");
|
|
103
|
+
const vNonEmpty = (v) => (v.trim() === "" ? "cannot be blank" : null);
|
|
104
|
+
/** Gather answers from flags + defaults, only prompting for what's missing (unless --yes). */
|
|
105
|
+
async function gather(f, reader) {
|
|
106
|
+
const d = INIT_DEFAULTS;
|
|
107
|
+
if (f.yes) {
|
|
108
|
+
const mode = (f.paymentMode ?? d.paymentMode);
|
|
109
|
+
return initAnswersSchema.parse({
|
|
110
|
+
originUrl: f.originUrl ?? d.originUrl,
|
|
111
|
+
priceUsdc: Number(f.priceUsdc ?? d.priceUsdc),
|
|
112
|
+
citationMultiplier: Number(f.citationMultiplier ?? d.citationMultiplier),
|
|
113
|
+
paymentMode: mode,
|
|
114
|
+
settlementNetwork: f.settlementNetwork ?? d.settlementNetwork,
|
|
115
|
+
tollgatePort: Number(f.tollgatePort ?? d.tollgatePort),
|
|
116
|
+
articlePrefixes: f.articlePrefixes ?? d.articlePrefixes,
|
|
117
|
+
creditsPath: f.creditsPath ?? d.creditsPath,
|
|
118
|
+
starterSlug: f.starterSlug ?? d.starterSlug,
|
|
119
|
+
starterTitle: f.starterTitle ?? d.starterTitle,
|
|
120
|
+
starterAuthorId: f.starterAuthorId ?? d.starterAuthorId,
|
|
121
|
+
defaultWallet: f.defaultWallet && f.defaultWallet !== "" ? f.defaultWallet : undefined,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
console.log(`\n${BOLD}naulon init${RESET} ${DIM}— set up your gate. Enter accepts the default.${RESET}\n`);
|
|
125
|
+
const originUrl = await ask(reader, "Your site's origin URL", f.originUrl ?? d.originUrl, vUrl);
|
|
126
|
+
const priceUsdc = await ask(reader, "Read price (USDC)", f.priceUsdc ?? String(d.priceUsdc), vPositive);
|
|
127
|
+
const citationMultiplier = await ask(reader, "Citation multiplier (× a read)", f.citationMultiplier ?? String(d.citationMultiplier), vPositive);
|
|
128
|
+
const articlePrefixes = await ask(reader, "Gateable path prefixes (csv)", f.articlePrefixes ?? d.articlePrefixes, vNonEmpty);
|
|
129
|
+
const tollgatePort = await ask(reader, "Tollgate port", f.tollgatePort ?? String(d.tollgatePort), vPort);
|
|
130
|
+
const paymentMode = await ask(reader, "Settlement mode", f.paymentMode ?? d.paymentMode, vMode);
|
|
131
|
+
const settlementNetwork = paymentMode === "gateway"
|
|
132
|
+
? await ask(reader, "Settlement network", f.settlementNetwork ?? d.settlementNetwork, vNetwork)
|
|
133
|
+
: d.settlementNetwork;
|
|
134
|
+
const defaultWallet = await ask(reader, "Default author wallet (blank = placeholder)", f.defaultWallet ?? "", vWallet);
|
|
135
|
+
const starterSlug = await ask(reader, "Starter article slug", f.starterSlug ?? d.starterSlug, vNonEmpty);
|
|
136
|
+
const starterTitle = await ask(reader, "Starter article title", f.starterTitle ?? d.starterTitle, vNonEmpty);
|
|
137
|
+
return initAnswersSchema.parse({
|
|
138
|
+
originUrl,
|
|
139
|
+
priceUsdc: Number(priceUsdc),
|
|
140
|
+
citationMultiplier: Number(citationMultiplier),
|
|
141
|
+
paymentMode,
|
|
142
|
+
settlementNetwork,
|
|
143
|
+
tollgatePort: Number(tollgatePort),
|
|
144
|
+
articlePrefixes,
|
|
145
|
+
creditsPath: f.creditsPath ?? d.creditsPath,
|
|
146
|
+
starterSlug,
|
|
147
|
+
starterTitle,
|
|
148
|
+
starterAuthorId: f.starterAuthorId ?? d.starterAuthorId,
|
|
149
|
+
defaultWallet: defaultWallet === "" ? undefined : defaultWallet,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
export async function initMain(argv) {
|
|
153
|
+
const f = parseInitFlags(argv);
|
|
154
|
+
if (f.help) {
|
|
155
|
+
console.log(USAGE);
|
|
156
|
+
return 0;
|
|
157
|
+
}
|
|
158
|
+
// One reader for the whole interactive flow (answers + overwrite confirms). --yes uses none.
|
|
159
|
+
const reader = f.yes ? null : makeReader();
|
|
160
|
+
const written = [];
|
|
161
|
+
const skipped = [];
|
|
162
|
+
try {
|
|
163
|
+
let answers;
|
|
164
|
+
try {
|
|
165
|
+
answers = await gather(f, reader ?? { next: async () => null, close: () => { } });
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
console.error(`✗ ${e instanceof Error ? e.message : String(e)}`);
|
|
169
|
+
return 2;
|
|
170
|
+
}
|
|
171
|
+
const plan = buildInitPlan(answers);
|
|
172
|
+
const dir = resolve(f.dir);
|
|
173
|
+
const files = [plan.env, plan.credits];
|
|
174
|
+
// Refuse to clobber. Interactive → confirm per file; --yes → skip unless --force.
|
|
175
|
+
for (const file of files) {
|
|
176
|
+
const abs = join(dir, file.path);
|
|
177
|
+
if (existsSync(abs) && !f.force) {
|
|
178
|
+
let overwrite = false;
|
|
179
|
+
if (reader) {
|
|
180
|
+
process.stdout.write(` ⚠ ${file.path} exists — overwrite? ${DIM}[y/N]${RESET} `);
|
|
181
|
+
const a = (await reader.next())?.trim().toLowerCase() ?? "";
|
|
182
|
+
overwrite = a === "y" || a === "yes";
|
|
183
|
+
}
|
|
184
|
+
if (!overwrite) {
|
|
185
|
+
skipped.push(file.path);
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
await writeFile(abs, file.contents, "utf8");
|
|
190
|
+
written.push(file.path);
|
|
191
|
+
}
|
|
192
|
+
printOutcome(written, skipped, plan);
|
|
193
|
+
}
|
|
194
|
+
finally {
|
|
195
|
+
reader?.close();
|
|
196
|
+
}
|
|
197
|
+
return 0;
|
|
198
|
+
}
|
|
199
|
+
function printOutcome(written, skipped, plan) {
|
|
200
|
+
console.log("");
|
|
201
|
+
for (const p of written)
|
|
202
|
+
console.log(` ✓ wrote ${p}`);
|
|
203
|
+
for (const p of skipped)
|
|
204
|
+
console.log(` ${DIM}• kept ${p} (exists — pass --force to overwrite)${RESET}`);
|
|
205
|
+
for (const w of plan.warnings)
|
|
206
|
+
console.log(` ⚠ ${w}`);
|
|
207
|
+
if (written.length > 0) {
|
|
208
|
+
console.log(`\n ${BOLD}Next:${RESET}`);
|
|
209
|
+
for (const s of plan.nextSteps)
|
|
210
|
+
console.log(` → ${s}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// Run only when invoked directly as the bin, not when imported (by a test or the dispatcher).
|
|
214
|
+
if (process.argv[1] && /init\.(ts|js)$/.test(process.argv[1])) {
|
|
215
|
+
void initMain(process.argv.slice(2)).then((c) => process.exit(c));
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/cli/init.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,aAAa,EAAoB,MAAM,iBAAiB,CAAC;AAEpG,MAAM,GAAG,GAAG,SAAS,CAAC;AACtB,MAAM,IAAI,GAAG,SAAS,CAAC;AACvB,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,OAAO,GAAG,GAAG,CAAC;AAsBpB,MAAM,QAAQ,GAAgC;IAC5C,UAAU,EAAE,WAAW;IACvB,SAAS,EAAE,WAAW;IACtB,uBAAuB,EAAE,oBAAoB;IAC7C,QAAQ,EAAE,aAAa;IACvB,WAAW,EAAE,mBAAmB;IAChC,QAAQ,EAAE,cAAc;IACxB,YAAY,EAAE,iBAAiB;IAC/B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AK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naulon.d.ts","sourceRoot":"","sources":["../../src/cli/naulon.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `naulon` — the setup CLI entry point. Dispatches to a subcommand.
|
|
4
|
+
*
|
|
5
|
+
* naulon init set up a gate (writes .env + a starter credits.json)
|
|
6
|
+
* naulon check conformance-check a credits endpoint (was `naulon-kit check`)
|
|
7
|
+
*
|
|
8
|
+
* Kept as one thin dispatcher so `naulon-kit check …` (the historical bin) still works
|
|
9
|
+
* unchanged — both bins point here.
|
|
10
|
+
*/
|
|
11
|
+
import { checkMain } from "./check.js";
|
|
12
|
+
import { initMain } from "./init.js";
|
|
13
|
+
import { doctorMain } from "./doctor.js";
|
|
14
|
+
import { crawlMain } from "./crawl.js";
|
|
15
|
+
const HELP = `naulon — the citation-toll setup CLI
|
|
16
|
+
|
|
17
|
+
usage: naulon <command> [options]
|
|
18
|
+
|
|
19
|
+
commands:
|
|
20
|
+
init set up a gate: writes .env + a starter credits.json (--yes for non-interactive)
|
|
21
|
+
crawl draft credits.json from your own origin (WordPress/RSS/sitemap) (--dry-run)
|
|
22
|
+
doctor health-check your own gate (env + credits + live human/agent probe)
|
|
23
|
+
check conformance-check a publisher's /credits endpoint (baseUrl --slug <s>)
|
|
24
|
+
|
|
25
|
+
run \`naulon <command> --help\` for command options.`;
|
|
26
|
+
async function main() {
|
|
27
|
+
const [cmd, ...rest] = process.argv.slice(2);
|
|
28
|
+
switch (cmd) {
|
|
29
|
+
case "init":
|
|
30
|
+
return initMain(rest);
|
|
31
|
+
case "crawl":
|
|
32
|
+
return crawlMain(rest);
|
|
33
|
+
case "doctor":
|
|
34
|
+
return doctorMain(rest);
|
|
35
|
+
case "check":
|
|
36
|
+
return checkMain(rest);
|
|
37
|
+
case undefined:
|
|
38
|
+
case "help":
|
|
39
|
+
case "--help":
|
|
40
|
+
case "-h":
|
|
41
|
+
console.log(HELP);
|
|
42
|
+
return 0;
|
|
43
|
+
default:
|
|
44
|
+
console.error(`unknown command: ${cmd}\n`);
|
|
45
|
+
console.error(HELP);
|
|
46
|
+
return 2;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
void main().then((c) => process.exit(c));
|
|
50
|
+
//# sourceMappingURL=naulon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naulon.js","sourceRoot":"","sources":["../../src/cli/naulon.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,MAAM,IAAI,GAAG;;;;;;;;;;qDAUwC,CAAC;AAEtD,KAAK,UAAU,IAAI;IACjB,MAAM,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7C,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;QACxB,KAAK,OAAO;YACV,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;QACzB,KAAK,QAAQ;YACX,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;QAC1B,KAAK,OAAO;YACV,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;QACzB,KAAK,SAAS,CAAC;QACf,KAAK,MAAM,CAAC;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,IAAI;YACP,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAClB,OAAO,CAAC,CAAC;QACX;YACE,OAAO,CAAC,KAAK,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;YAC3C,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACpB,OAAO,CAAC,CAAC;IACb,CAAC;AACH,CAAC;AAED,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The credits graph — the `/credits/:slug` response shape and its validator.
|
|
3
|
+
*
|
|
4
|
+
* `wallet` ultimately comes from whatever a publisher's credits source returns
|
|
5
|
+
* (an HTTP API, a static file, a DB). If that response is malformed or hostile,
|
|
6
|
+
* payments could route to the wrong wallet or crash the gate mid-flow. So every
|
|
7
|
+
* credits object crossing into the system is parsed through `creditsSchema` first:
|
|
8
|
+
* structure is checked, and crucially every leaf `wallet` must be a well-formed
|
|
9
|
+
* 0x address before it can ever become a `payTo`.
|
|
10
|
+
*
|
|
11
|
+
* A contributor is either a leaf (has a `wallet`) or a composite (has non-empty
|
|
12
|
+
* `members` that re-split recursively) — never both, never neither.
|
|
13
|
+
*/
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
import { type WalletAddress } from "./wallet.ts";
|
|
16
|
+
/**
|
|
17
|
+
* The credits graph node for one article. Co-authors may themselves be composites
|
|
18
|
+
* (e.g. a collective that splits again), hence the recursive shape resolved by the
|
|
19
|
+
* gate's attribution layer.
|
|
20
|
+
*/
|
|
21
|
+
export interface ArticleCredits {
|
|
22
|
+
slug: string;
|
|
23
|
+
title: string;
|
|
24
|
+
/** Direct contributors. Weights are relative; they get normalized to shares. */
|
|
25
|
+
contributors: Contributor[];
|
|
26
|
+
}
|
|
27
|
+
export interface Contributor {
|
|
28
|
+
authorId: string;
|
|
29
|
+
/** Relative weight of this contributor among siblings (default 1). */
|
|
30
|
+
weight?: number;
|
|
31
|
+
/** A leaf author resolves to a wallet... */
|
|
32
|
+
wallet?: WalletAddress;
|
|
33
|
+
/** ...or a composite re-splits among its own members (recursive). */
|
|
34
|
+
members?: Contributor[];
|
|
35
|
+
}
|
|
36
|
+
export declare const creditsSchema: z.ZodObject<{
|
|
37
|
+
slug: z.ZodString;
|
|
38
|
+
title: z.ZodString;
|
|
39
|
+
contributors: z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
40
|
+
}, z.core.$strict>;
|
|
41
|
+
/**
|
|
42
|
+
* Parse + validate one credits object. Throws a descriptive error on anything
|
|
43
|
+
* malformed. `context` (e.g. the slug or source URL) is woven into the message
|
|
44
|
+
* so a bad upstream response is traceable.
|
|
45
|
+
*/
|
|
46
|
+
export declare function parseCredits(raw: unknown, context?: string): ArticleCredits;
|
|
47
|
+
/**
|
|
48
|
+
* A validating builder for publishers producing a credits payload. Runs the same
|
|
49
|
+
* schema as the consume side, so a publisher cannot emit a malformed object that
|
|
50
|
+
* the gate would later reject — the error surfaces at construction instead.
|
|
51
|
+
*/
|
|
52
|
+
export declare function buildCredits(input: unknown): ArticleCredits;
|
|
53
|
+
//# sourceMappingURL=credits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credits.d.ts","sourceRoot":"","sources":["../../src/contract/credits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAE/D;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,gFAAgF;IAChF,YAAY,EAAE,WAAW,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,qEAAqE;IACrE,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;CACzB;AAkBD,eAAO,MAAM,aAAa;;;;kBAMf,CAAC;AAEZ;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,SAAY,GAAG,cAAc,CAS9E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAE3D"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The credits graph — the `/credits/:slug` response shape and its validator.
|
|
3
|
+
*
|
|
4
|
+
* `wallet` ultimately comes from whatever a publisher's credits source returns
|
|
5
|
+
* (an HTTP API, a static file, a DB). If that response is malformed or hostile,
|
|
6
|
+
* payments could route to the wrong wallet or crash the gate mid-flow. So every
|
|
7
|
+
* credits object crossing into the system is parsed through `creditsSchema` first:
|
|
8
|
+
* structure is checked, and crucially every leaf `wallet` must be a well-formed
|
|
9
|
+
* 0x address before it can ever become a `payTo`.
|
|
10
|
+
*
|
|
11
|
+
* A contributor is either a leaf (has a `wallet`) or a composite (has non-empty
|
|
12
|
+
* `members` that re-split recursively) — never both, never neither.
|
|
13
|
+
*/
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
import { walletSchema } from "./wallet.js";
|
|
16
|
+
// Recursive: a composite's members are themselves contributors.
|
|
17
|
+
const contributorSchema = z.lazy(() => z
|
|
18
|
+
.object({
|
|
19
|
+
authorId: z.string().min(1),
|
|
20
|
+
weight: z.number().positive().optional(),
|
|
21
|
+
wallet: walletSchema.optional(),
|
|
22
|
+
members: z.array(contributorSchema).min(1).optional(),
|
|
23
|
+
})
|
|
24
|
+
.strict()
|
|
25
|
+
.refine((c) => (c.wallet === undefined) !== (c.members === undefined), "a contributor must have exactly one of `wallet` (leaf) or `members` (composite)"));
|
|
26
|
+
export const creditsSchema = z
|
|
27
|
+
.object({
|
|
28
|
+
slug: z.string().min(1),
|
|
29
|
+
title: z.string().min(1),
|
|
30
|
+
contributors: z.array(contributorSchema).min(1),
|
|
31
|
+
})
|
|
32
|
+
.strict();
|
|
33
|
+
/**
|
|
34
|
+
* Parse + validate one credits object. Throws a descriptive error on anything
|
|
35
|
+
* malformed. `context` (e.g. the slug or source URL) is woven into the message
|
|
36
|
+
* so a bad upstream response is traceable.
|
|
37
|
+
*/
|
|
38
|
+
export function parseCredits(raw, context = "credits") {
|
|
39
|
+
const result = creditsSchema.safeParse(raw);
|
|
40
|
+
if (!result.success) {
|
|
41
|
+
const issues = result.error.issues
|
|
42
|
+
.map((i) => ` ${i.path.join(".") || "(root)"}: ${i.message}`)
|
|
43
|
+
.join("\n");
|
|
44
|
+
throw new Error(`invalid ${context}:\n${issues}`);
|
|
45
|
+
}
|
|
46
|
+
return result.data;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A validating builder for publishers producing a credits payload. Runs the same
|
|
50
|
+
* schema as the consume side, so a publisher cannot emit a malformed object that
|
|
51
|
+
* the gate would later reject — the error surfaces at construction instead.
|
|
52
|
+
*/
|
|
53
|
+
export function buildCredits(input) {
|
|
54
|
+
return parseCredits(input, "buildCredits");
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=credits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credits.js","sourceRoot":"","sources":["../../src/contract/credits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAsB,MAAM,aAAa,CAAC;AAwB/D,gEAAgE;AAChE,MAAM,iBAAiB,GAAuB,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACxD,CAAC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O,EAAE,CAAC;aAC7D,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,WAAW,OAAO,MAAM,MAAM,EAAE,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,MAAM,CAAC,IAAsB,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,YAAY,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The settlement wire contract — the body naulon POSTs to a publisher's earnings
|
|
3
|
+
* receiver after a paid read settles on-chain (`POST /api/credits/settlement`).
|
|
4
|
+
*
|
|
5
|
+
* The PRODUCER side (`signSettlement` + the gate's `buildSettlementBody`) and the
|
|
6
|
+
* VERIFY side (`verifySettlement`) both speak this shape; before this package the
|
|
7
|
+
* verify-side schema existed nowhere as shared code — it was hand-rolled in the
|
|
8
|
+
* reference publisher. `settlementBodySchema` is that mirror, written once.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { type WalletAddress } from "./wallet.ts";
|
|
12
|
+
/**
|
|
13
|
+
* The contract major version. Advertise it so an agent/publisher can see which
|
|
14
|
+
* contract a gate speaks; bump it (and the package major) on a breaking change.
|
|
15
|
+
* Within a major, only additive-optional fields may be introduced.
|
|
16
|
+
*/
|
|
17
|
+
export declare const CONTRACT_VERSION = 1;
|
|
18
|
+
/** One author's recorded cut of a settled event, in integer micro-USDC. */
|
|
19
|
+
export interface SettlementSplit {
|
|
20
|
+
authorId: string;
|
|
21
|
+
wallet: WalletAddress;
|
|
22
|
+
/** Integer micro-USDC as a string. Σ splits[].amount === grossAmount. */
|
|
23
|
+
amount: string;
|
|
24
|
+
/** Relative share as integer permille (decorative; `amount` is the truth). */
|
|
25
|
+
weight: number;
|
|
26
|
+
/** Exactly one split carries this — the wallet the on-chain leg paid. */
|
|
27
|
+
primary?: true;
|
|
28
|
+
}
|
|
29
|
+
/** The exact JSON body a settlement receiver expects. */
|
|
30
|
+
export interface SettlementBody {
|
|
31
|
+
eventId: string;
|
|
32
|
+
slug: string;
|
|
33
|
+
txHash: string;
|
|
34
|
+
chainId: number;
|
|
35
|
+
currency: "USDC";
|
|
36
|
+
grossAmount: string;
|
|
37
|
+
paidTo: WalletAddress;
|
|
38
|
+
payer: WalletAddress | null;
|
|
39
|
+
settledAt: string;
|
|
40
|
+
splits: SettlementSplit[];
|
|
41
|
+
}
|
|
42
|
+
export declare const settlementSplitSchema: z.ZodObject<{
|
|
43
|
+
authorId: z.ZodString;
|
|
44
|
+
wallet: z.ZodString;
|
|
45
|
+
amount: z.ZodString;
|
|
46
|
+
weight: z.ZodNumber;
|
|
47
|
+
primary: z.ZodOptional<z.ZodLiteral<true>>;
|
|
48
|
+
}, z.core.$strict>;
|
|
49
|
+
export declare const settlementBodySchema: z.ZodObject<{
|
|
50
|
+
eventId: z.ZodString;
|
|
51
|
+
slug: z.ZodString;
|
|
52
|
+
txHash: z.ZodString;
|
|
53
|
+
chainId: z.ZodNumber;
|
|
54
|
+
currency: z.ZodLiteral<"USDC">;
|
|
55
|
+
grossAmount: z.ZodString;
|
|
56
|
+
paidTo: z.ZodString;
|
|
57
|
+
payer: z.ZodNullable<z.ZodString>;
|
|
58
|
+
settledAt: z.ZodString;
|
|
59
|
+
splits: z.ZodArray<z.ZodObject<{
|
|
60
|
+
authorId: z.ZodString;
|
|
61
|
+
wallet: z.ZodString;
|
|
62
|
+
amount: z.ZodString;
|
|
63
|
+
weight: z.ZodNumber;
|
|
64
|
+
primary: z.ZodOptional<z.ZodLiteral<true>>;
|
|
65
|
+
}, z.core.$strict>>;
|
|
66
|
+
}, z.core.$strict>;
|
|
67
|
+
//# sourceMappingURL=settlement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settlement.d.ts","sourceRoot":"","sources":["../../src/contract/settlement.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,2EAA2E;AAC3E,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,aAAa,CAAC;IACtB,yEAAyE;IACzE,MAAM,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,OAAO,CAAC,EAAE,IAAI,CAAC;CAChB;AAED,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,eAAO,MAAM,qBAAqB;;;;;;kBAQvB,CAAC;AAEZ,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;kBAwB7B,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The settlement wire contract — the body naulon POSTs to a publisher's earnings
|
|
3
|
+
* receiver after a paid read settles on-chain (`POST /api/credits/settlement`).
|
|
4
|
+
*
|
|
5
|
+
* The PRODUCER side (`signSettlement` + the gate's `buildSettlementBody`) and the
|
|
6
|
+
* VERIFY side (`verifySettlement`) both speak this shape; before this package the
|
|
7
|
+
* verify-side schema existed nowhere as shared code — it was hand-rolled in the
|
|
8
|
+
* reference publisher. `settlementBodySchema` is that mirror, written once.
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { walletSchema } from "./wallet.js";
|
|
12
|
+
/**
|
|
13
|
+
* The contract major version. Advertise it so an agent/publisher can see which
|
|
14
|
+
* contract a gate speaks; bump it (and the package major) on a breaking change.
|
|
15
|
+
* Within a major, only additive-optional fields may be introduced.
|
|
16
|
+
*/
|
|
17
|
+
export const CONTRACT_VERSION = 1;
|
|
18
|
+
export const settlementSplitSchema = z
|
|
19
|
+
.object({
|
|
20
|
+
authorId: z.string().min(1),
|
|
21
|
+
wallet: walletSchema,
|
|
22
|
+
amount: z.string().regex(/^\d+$/, "amount must be integer micro-USDC"),
|
|
23
|
+
weight: z.number().int().nonnegative(),
|
|
24
|
+
primary: z.literal(true).optional(),
|
|
25
|
+
})
|
|
26
|
+
.strict();
|
|
27
|
+
export const settlementBodySchema = z
|
|
28
|
+
.object({
|
|
29
|
+
eventId: z.string().min(1),
|
|
30
|
+
slug: z.string().min(1),
|
|
31
|
+
txHash: z.string(),
|
|
32
|
+
chainId: z.number().int(),
|
|
33
|
+
currency: z.literal("USDC"),
|
|
34
|
+
grossAmount: z.string().regex(/^\d+$/, "grossAmount must be integer micro-USDC"),
|
|
35
|
+
paidTo: walletSchema,
|
|
36
|
+
payer: walletSchema.nullable(),
|
|
37
|
+
settledAt: z.string(),
|
|
38
|
+
splits: z.array(settlementSplitSchema).min(1),
|
|
39
|
+
})
|
|
40
|
+
.strict()
|
|
41
|
+
.superRefine((b, ctx) => {
|
|
42
|
+
// Money invariant: Σ splits.amount === grossAmount (dust-free).
|
|
43
|
+
const sum = b.splits.reduce((acc, s) => acc + BigInt(s.amount), 0n);
|
|
44
|
+
if (sum !== BigInt(b.grossAmount)) {
|
|
45
|
+
ctx.addIssue({ code: "custom", message: "splits must conserve grossAmount" });
|
|
46
|
+
}
|
|
47
|
+
// Exactly one split is the on-chain recipient.
|
|
48
|
+
if (b.splits.filter((s) => s.primary).length !== 1) {
|
|
49
|
+
ctx.addIssue({ code: "custom", message: "exactly one split must be primary" });
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=settlement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settlement.js","sourceRoot":"","sources":["../../src/contract/settlement.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAsB,MAAM,aAAa,CAAC;AAE/D;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AA4BlC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC;KACnC,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,MAAM,EAAE,YAAY;IACpB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,mCAAmC,CAAC;IACtE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE;IACtC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;CACpC,CAAC;KACD,MAAM,EAAE,CAAC;AAEZ,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC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C,QAAQ,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,mCAAmC,EAAE,CAAC,CAAC;IACjF,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wallet address primitive — the single home for the `0x…40-hex` regex that
|
|
3
|
+
* was previously hand-copied four times across the gate, the publisher, and the
|
|
4
|
+
* settlement receiver.
|
|
5
|
+
*
|
|
6
|
+
* Two faces of the same rule:
|
|
7
|
+
* - `walletSchema` validates a PLAIN string (publisher-friendly; what crosses the
|
|
8
|
+
* wire and what the credits/settlement schemas compose).
|
|
9
|
+
* - the branded `WalletAddress` + `walletAddress()` constructor give internal code
|
|
10
|
+
* type-safety against mixing an arbitrary string with a validated address.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
/** The one regex. An EVM/Arc address: `0x` + 40 hex digits. */
|
|
14
|
+
export declare const WALLET_RE: RegExp;
|
|
15
|
+
/** An on-chain wallet address (Arc / EVM-style 0x...). Branded to avoid mixups. */
|
|
16
|
+
export type WalletAddress = string & {
|
|
17
|
+
readonly __brand: "WalletAddress";
|
|
18
|
+
};
|
|
19
|
+
/** Zod validator over a plain string — composes into the credits + settlement schemas. */
|
|
20
|
+
export declare const walletSchema: z.ZodString;
|
|
21
|
+
/** Validate + brand. Throws on a malformed address so a bad value can never become a `payTo`. */
|
|
22
|
+
export declare function walletAddress(value: string): WalletAddress;
|
|
23
|
+
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/contract/wallet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,+DAA+D;AAC/D,eAAO,MAAM,SAAS,QAAwB,CAAC;AAE/C,mFAAmF;AACnF,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAA;CAAE,CAAC;AAE3E,0FAA0F;AAC1F,eAAO,MAAM,YAAY,aAEyC,CAAC;AAEnE,iGAAiG;AACjG,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAK1D"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wallet address primitive — the single home for the `0x…40-hex` regex that
|
|
3
|
+
* was previously hand-copied four times across the gate, the publisher, and the
|
|
4
|
+
* settlement receiver.
|
|
5
|
+
*
|
|
6
|
+
* Two faces of the same rule:
|
|
7
|
+
* - `walletSchema` validates a PLAIN string (publisher-friendly; what crosses the
|
|
8
|
+
* wire and what the credits/settlement schemas compose).
|
|
9
|
+
* - the branded `WalletAddress` + `walletAddress()` constructor give internal code
|
|
10
|
+
* type-safety against mixing an arbitrary string with a validated address.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
/** The one regex. An EVM/Arc address: `0x` + 40 hex digits. */
|
|
14
|
+
export const WALLET_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
15
|
+
/** Zod validator over a plain string — composes into the credits + settlement schemas. */
|
|
16
|
+
export const walletSchema = z
|
|
17
|
+
.string()
|
|
18
|
+
.regex(WALLET_RE, "wallet must be a 0x-prefixed 40-hex address");
|
|
19
|
+
/** Validate + brand. Throws on a malformed address so a bad value can never become a `payTo`. */
|
|
20
|
+
export function walletAddress(value) {
|
|
21
|
+
if (!WALLET_RE.test(value)) {
|
|
22
|
+
throw new Error(`invalid wallet address: ${value}`);
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/contract/wallet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,+DAA+D;AAC/D,MAAM,CAAC,MAAM,SAAS,GAAG,qBAAqB,CAAC;AAK/C,0FAA0F;AAC1F,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC;KAC1B,MAAM,EAAE;KACR,KAAK,CAAC,SAAS,EAAE,6CAA6C,CAAC,CAAC;AAEnE,iGAAiG;AACjG,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,2BAA2B,KAAK,EAAE,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,KAAsB,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* crawl/adapters/rss.ts — the always-available RSS/Atom feed adapter.
|
|
3
|
+
*
|
|
4
|
+
* The lowest-rank fallback: nearly every CMS exposes an RSS 2.0 or Atom feed. It yields
|
|
5
|
+
* title, URL, author (`<author>`/`<dc:creator>` for RSS, `<author><name>` for Atom), and
|
|
6
|
+
* publish date — enough for the catalog plane. Authors are feed STRINGS only (the map key);
|
|
7
|
+
* never a wallet. All fetches go through the guarded fetcher, so even a derived feed URL can
|
|
8
|
+
* only ever hit the proven origin host.
|
|
9
|
+
*/
|
|
10
|
+
import type { SourceAdapter } from "../types.ts";
|
|
11
|
+
export declare const rssAdapter: SourceAdapter;
|
|
12
|
+
//# sourceMappingURL=rss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rss.d.ts","sourceRoot":"","sources":["../../../src/crawl/adapters/rss.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAuD,aAAa,EAAE,MAAM,aAAa,CAAC;AA4GtG,eAAO,MAAM,UAAU,EAAE,aAUxB,CAAC"}
|