@secondlayer/cli 16.4.0 → 17.0.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/README.md +5 -5
- package/dist/cli.js +22 -33
- package/dist/cli.js.map +16 -16
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -12,14 +12,14 @@ secondlayer --version
|
|
|
12
12
|
|
|
13
13
|
## Auth
|
|
14
14
|
|
|
15
|
-
Default API is `http://127.0.0.1:3800`. Override with `
|
|
15
|
+
Default API is `http://127.0.0.1:3800`. Override with `SECONDLAYER_API_URL`.
|
|
16
16
|
|
|
17
17
|
Writes against a published bind use `INSTANCE_TOKEN` from `secondlayer init`.
|
|
18
18
|
Loopback reads need no token. Hosted API and archive credits use
|
|
19
19
|
`SECONDLAYER_API_KEY` (`sk-sl_*`).
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
export
|
|
22
|
+
export SECONDLAYER_API_URL=http://127.0.0.1:3800
|
|
23
23
|
export INSTANCE_TOKEN=<from secondlayer init>
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -190,9 +190,9 @@ operates on both kinds.
|
|
|
190
190
|
| Var | Purpose |
|
|
191
191
|
|---|---|
|
|
192
192
|
| `INSTANCE_TOKEN` | From `secondlayer init` for writes. Loopback reads need no token |
|
|
193
|
-
| `SECONDLAYER_API_KEY` | Hosted account key (`sk-sl_*`)
|
|
194
|
-
| `
|
|
195
|
-
| `SL_PLATFORM_API_URL` | Alias of `
|
|
193
|
+
| `SECONDLAYER_API_KEY` | Hosted account key (`sk-sl_*`) |
|
|
194
|
+
| `SECONDLAYER_API_URL` | Instance API. Default `http://127.0.0.1:3800` |
|
|
195
|
+
| `SL_PLATFORM_API_URL` | Alias of `SECONDLAYER_API_URL` |
|
|
196
196
|
| `STACKS_NETWORK` | Default network (also via `--network <mainnet\|testnet\|devnet>`) |
|
|
197
197
|
| `DATABASE_URL` | Postgres that `bootstrap`, `verify`, `repair`, and `backup` connect to. `secondlayer setup` writes it into `.env` pointing at the compose Postgres; unset, the shared dev URL `postgres://postgres:postgres@localhost:5432/secondlayer_dev` is used |
|
|
198
198
|
| `HIRO_API_KEY` | Used by `secondlayer codegen contracts` for remote contract fetches |
|
package/dist/cli.js
CHANGED
|
@@ -2143,7 +2143,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2143
2143
|
|
|
2144
2144
|
// src/lib/api-url.ts
|
|
2145
2145
|
function resolveApiUrl() {
|
|
2146
|
-
return (process.env.SECONDLAYER_API_URL ?? process.env.
|
|
2146
|
+
return (process.env.SECONDLAYER_API_URL ?? process.env.SL_PLATFORM_API_URL ?? LOCAL_API_URL).replace(/\/+$/, "");
|
|
2147
2147
|
}
|
|
2148
2148
|
function resolveArchiveOpsUrl() {
|
|
2149
2149
|
return (process.env.SL_CREDITS_API_URL ?? ARCHIVE_OPS_API_URL).replace(/\/+$/, "");
|
|
@@ -2258,7 +2258,6 @@ function resolveEnvKey() {
|
|
|
2258
2258
|
function applyApiKeyFlag(apiKey) {
|
|
2259
2259
|
if (/^s[ks]-sl_/.test(apiKey)) {
|
|
2260
2260
|
process.env.SECONDLAYER_API_KEY = apiKey;
|
|
2261
|
-
process.env.SL_API_KEY = apiKey;
|
|
2262
2261
|
} else {
|
|
2263
2262
|
process.env.INSTANCE_TOKEN = apiKey;
|
|
2264
2263
|
}
|
|
@@ -198407,13 +198406,13 @@ function indexReadFailure(err, ctx) {
|
|
|
198407
198406
|
const credential = resolveApiKey3() ? "INSTANCE_TOKEN is set in this shell" : "no INSTANCE_TOKEN is set in this shell";
|
|
198408
198407
|
return {
|
|
198409
198408
|
message: `Index read rejected (HTTP ${status}) while ${where}.`,
|
|
198410
|
-
hint: `${credential}. This read uses the same
|
|
198409
|
+
hint: `${credential}. This read uses the same SECONDLAYER_API_URL + INSTANCE_TOKEN pair as \`secondlayer subgraphs deploy\` — confirm both point at the instance you deployed to (\`secondlayer status\`), then retry. ${offlineHint}`
|
|
198411
198410
|
};
|
|
198412
198411
|
}
|
|
198413
198412
|
if (status === 404) {
|
|
198414
198413
|
return {
|
|
198415
198414
|
message: `Index read returned 404 while ${where}.`,
|
|
198416
|
-
hint: `${ctx.apiUrl} answered but serves no /v1/index/events — check
|
|
198415
|
+
hint: `${ctx.apiUrl} answered but serves no /v1/index/events — check SECONDLAYER_API_URL points at a Secondlayer instance, not a Stacks node.`
|
|
198417
198416
|
};
|
|
198418
198417
|
}
|
|
198419
198418
|
if (status === 429) {
|
|
@@ -202496,7 +202495,7 @@ var {
|
|
|
202496
202495
|
// package.json
|
|
202497
202496
|
var package_default = {
|
|
202498
202497
|
name: "@secondlayer/cli",
|
|
202499
|
-
version: "
|
|
202498
|
+
version: "17.0.0",
|
|
202500
202499
|
description: "Run a Stacks index on your own hardware — set it up, restore verified history, and keep it current.",
|
|
202501
202500
|
repository: {
|
|
202502
202501
|
type: "git",
|
|
@@ -202535,8 +202534,8 @@ var package_default = {
|
|
|
202535
202534
|
"@inquirer/prompts": "^8.2.0",
|
|
202536
202535
|
"@secondlayer/bundler": "^0.6.1",
|
|
202537
202536
|
"@secondlayer/scaffold": "^1.6.1",
|
|
202538
|
-
"@secondlayer/sdk": "^
|
|
202539
|
-
"@secondlayer/shared": "^11.
|
|
202537
|
+
"@secondlayer/sdk": "^12.0.0",
|
|
202538
|
+
"@secondlayer/shared": "^11.10.1",
|
|
202540
202539
|
"@secondlayer/stacks": "^6.1.0",
|
|
202541
202540
|
"@secondlayer/subgraphs": "^6.1.0",
|
|
202542
202541
|
esbuild: "^0.28.2",
|
|
@@ -206164,7 +206163,7 @@ function dockerCompose(composePath, args) {
|
|
|
206164
206163
|
});
|
|
206165
206164
|
return res.status ?? 1;
|
|
206166
206165
|
}
|
|
206167
|
-
var API_URL =
|
|
206166
|
+
var API_URL = resolveApiUrl();
|
|
206168
206167
|
var INDEXER_URL = process.env.INDEXER_URL ?? "http://localhost:3700";
|
|
206169
206168
|
var SERVICES = [
|
|
206170
206169
|
"indexer",
|
|
@@ -206241,7 +206240,7 @@ ${bold("Secondlayer stack up")}`);
|
|
|
206241
206240
|
console.log(`
|
|
206242
206241
|
${bold("Next:")}`);
|
|
206243
206242
|
console.log(` ${yellow("clarinet devnet start")} ${dim("# auto-deploys + streams to the indexer")}`);
|
|
206244
|
-
console.log(` ${yellow(`
|
|
206243
|
+
console.log(` ${yellow(`SECONDLAYER_API_URL=http://localhost:3800 INSTANCE_TOKEN=${DEV_INSTANCE_TOKEN} secondlayer subgraphs deploy ./subgraph.ts`)}`);
|
|
206245
206244
|
console.log(dim(`
|
|
206246
206245
|
The api is published on 127.0.0.1 only: /v1 reads need no credential.
|
|
206247
206246
|
Writes (deploys, webhooks) send INSTANCE_TOKEN=${DEV_INSTANCE_TOKEN}.`));
|
|
@@ -206940,7 +206939,7 @@ async function runInstanceDoctor(jsonOutput) {
|
|
|
206940
206939
|
detail: unreachableError ?? undefined,
|
|
206941
206940
|
nextSteps: [
|
|
206942
206941
|
"Start the instance from docker/oss: docker compose up -d",
|
|
206943
|
-
`If it runs elsewhere, point the CLI at it:
|
|
206942
|
+
`If it runs elsewhere, point the CLI at it: SECONDLAYER_API_URL=<url> (currently ${apiUrl})`
|
|
206944
206943
|
]
|
|
206945
206944
|
}
|
|
206946
206945
|
];
|
|
@@ -207432,14 +207431,12 @@ function readEnvValue(envPath, key) {
|
|
|
207432
207431
|
return match ? unescapeEnvValue(match[1]) : null;
|
|
207433
207432
|
}
|
|
207434
207433
|
function buildInstanceEnv(input) {
|
|
207435
|
-
const
|
|
207436
|
-
const aliasIsHex = existingAlias && !existingAlias.startsWith("sk-sl_") && !existingAlias.startsWith("ss-sl_");
|
|
207437
|
-
const token = input.existing?.INSTANCE_TOKEN || (aliasIsHex ? existingAlias : undefined) || generateInstanceToken();
|
|
207434
|
+
const token = input.existing?.INSTANCE_TOKEN || generateInstanceToken();
|
|
207438
207435
|
const secrets = input.existing?.SECONDLAYER_SECRETS_KEY || generateSecretsKey();
|
|
207439
207436
|
const signing = input.existing?.STREAMS_SIGNING_PRIVATE_KEY || input.existing?.SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY || generateSigningPrivateKey();
|
|
207440
|
-
const apiUrl = input.existing?.SECONDLAYER_API_URL || input.
|
|
207437
|
+
const apiUrl = input.existing?.SECONDLAYER_API_URL || input.apiUrl || "http://127.0.0.1:3800";
|
|
207441
207438
|
const archiveKey = input.existing?.ARCHIVE_SIGNING_PUBLIC_KEY || input.archivePublicKeyPem || ARCHIVE_ROOT_PUBLIC_KEY_PEM;
|
|
207442
|
-
const hostedCandidate = input.existing?.SECONDLAYER_API_KEY ||
|
|
207439
|
+
const hostedCandidate = input.existing?.SECONDLAYER_API_KEY || undefined;
|
|
207443
207440
|
const hostedKey = hostedCandidate && isHostedAccountKey(hostedCandidate) ? hostedCandidate : undefined;
|
|
207444
207441
|
return {
|
|
207445
207442
|
INSTANCE_MODE: "oss",
|
|
@@ -207450,8 +207447,7 @@ function buildInstanceEnv(input) {
|
|
|
207450
207447
|
SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY: signing,
|
|
207451
207448
|
ALLOW_UNSIGNED_WEBHOOKS: "false",
|
|
207452
207449
|
SECONDLAYER_API_URL: apiUrl,
|
|
207453
|
-
|
|
207454
|
-
...hostedKey ? { SECONDLAYER_API_KEY: hostedKey, SL_API_KEY: hostedKey } : {},
|
|
207450
|
+
...hostedKey ? { SECONDLAYER_API_KEY: hostedKey } : {},
|
|
207455
207451
|
ARCHIVE_SIGNING_PUBLIC_KEY: archiveKey
|
|
207456
207452
|
};
|
|
207457
207453
|
}
|
|
@@ -207467,11 +207463,10 @@ function renderInstanceEnv(env) {
|
|
|
207467
207463
|
`STREAMS_SIGNING_PRIVATE_KEY=${escapeEnvValue(env.STREAMS_SIGNING_PRIVATE_KEY)}`,
|
|
207468
207464
|
`SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY=${escapeEnvValue(env.SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY)}`,
|
|
207469
207465
|
`ALLOW_UNSIGNED_WEBHOOKS=${env.ALLOW_UNSIGNED_WEBHOOKS}`,
|
|
207470
|
-
`SECONDLAYER_API_URL=${env.SECONDLAYER_API_URL}
|
|
207471
|
-
`SL_API_URL=${env.SL_API_URL}`
|
|
207466
|
+
`SECONDLAYER_API_URL=${env.SECONDLAYER_API_URL}`
|
|
207472
207467
|
];
|
|
207473
207468
|
if (env.SECONDLAYER_API_KEY) {
|
|
207474
|
-
lines.push("# Hosted account key for archive credits (sk-sl_*).", `SECONDLAYER_API_KEY=${env.SECONDLAYER_API_KEY}
|
|
207469
|
+
lines.push("# Hosted account key for archive credits (sk-sl_*).", `SECONDLAYER_API_KEY=${env.SECONDLAYER_API_KEY}`);
|
|
207475
207470
|
}
|
|
207476
207471
|
lines.push("# Archive trust root: bootstrap, verify, and repair check manifests", "# against this key. Replace it to pin a different archive.", `ARCHIVE_SIGNING_PUBLIC_KEY=${escapeEnvValue(env.ARCHIVE_SIGNING_PUBLIC_KEY)}`, "");
|
|
207477
207472
|
return lines.join(`
|
|
@@ -207490,9 +207485,7 @@ function loadExistingInstanceEnv(cwd, file = INSTANCE_ENV_FILE) {
|
|
|
207490
207485
|
STREAMS_SIGNING_PRIVATE_KEY: readEnvValue(path, "STREAMS_SIGNING_PRIVATE_KEY"),
|
|
207491
207486
|
SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY: readEnvValue(path, "SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY"),
|
|
207492
207487
|
SECONDLAYER_API_URL: readEnvValue(path, "SECONDLAYER_API_URL"),
|
|
207493
|
-
SL_API_URL: readEnvValue(path, "SL_API_URL"),
|
|
207494
207488
|
SECONDLAYER_API_KEY: readEnvValue(path, "SECONDLAYER_API_KEY"),
|
|
207495
|
-
SL_API_KEY: readEnvValue(path, "SL_API_KEY"),
|
|
207496
207489
|
ARCHIVE_SIGNING_PUBLIC_KEY: readEnvValue(path, "ARCHIVE_SIGNING_PUBLIC_KEY")
|
|
207497
207490
|
};
|
|
207498
207491
|
}
|
|
@@ -207653,7 +207646,7 @@ var SECRET_ENV_KEYS = [
|
|
|
207653
207646
|
"SECONDLAYER_SECRETS_KEY",
|
|
207654
207647
|
"STREAMS_SIGNING_PRIVATE_KEY",
|
|
207655
207648
|
"SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY",
|
|
207656
|
-
"
|
|
207649
|
+
"SECONDLAYER_API_KEY",
|
|
207657
207650
|
"ARCHIVE_SIGNING_PUBLIC_KEY"
|
|
207658
207651
|
];
|
|
207659
207652
|
function readSecretsKey() {
|
|
@@ -207955,7 +207948,7 @@ flags (see \`secondlayer --help\`). Defaults: mainnet, http://127.0.0.1:3800.
|
|
|
207955
207948
|
const env = buildInstanceEnv({
|
|
207956
207949
|
network,
|
|
207957
207950
|
existing,
|
|
207958
|
-
apiUrl: process.env.
|
|
207951
|
+
apiUrl: process.env.SECONDLAYER_API_URL ?? DEFAULT_INIT_API_URL,
|
|
207959
207952
|
archivePublicKeyPem: await resolveArchivePublicKey({
|
|
207960
207953
|
envPem: process.env.ARCHIVE_SIGNING_PUBLIC_KEY ?? process.env.STREAMS_SIGNING_PUBLIC_KEY,
|
|
207961
207954
|
allowHostedApi: !isOssMode()
|
|
@@ -207965,7 +207958,7 @@ flags (see \`secondlayer --help\`). Defaults: mainnet, http://127.0.0.1:3800.
|
|
|
207965
207958
|
success(`Wrote ${INSTANCE_ENV_FILE}`);
|
|
207966
207959
|
note(formatKeyValue([
|
|
207967
207960
|
["network", env.STACKS_NETWORK],
|
|
207968
|
-
["api", env.
|
|
207961
|
+
["api", env.SECONDLAYER_API_URL],
|
|
207969
207962
|
["env", path]
|
|
207970
207963
|
]));
|
|
207971
207964
|
note("Export these or pass --env-file to compose. Do not commit the file.");
|
|
@@ -208343,9 +208336,7 @@ function resolveSecrets(config) {
|
|
|
208343
208336
|
STREAMS_SIGNING_PRIVATE_KEY: existing.STREAMS_SIGNING_PRIVATE_KEY,
|
|
208344
208337
|
SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY: existing.SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY,
|
|
208345
208338
|
SECONDLAYER_API_URL: existing.SECONDLAYER_API_URL,
|
|
208346
|
-
SL_API_URL: existing.SL_API_URL,
|
|
208347
208339
|
SECONDLAYER_API_KEY: existing.SECONDLAYER_API_KEY,
|
|
208348
|
-
SL_API_KEY: existing.SL_API_KEY,
|
|
208349
208340
|
ARCHIVE_SIGNING_PUBLIC_KEY: existing.ARCHIVE_SIGNING_PUBLIC_KEY
|
|
208350
208341
|
},
|
|
208351
208342
|
apiUrl: `http://${normalizeLoopbackHost(config.apiPort)}`,
|
|
@@ -208414,11 +208405,10 @@ function renderSetupEnv(config, secrets) {
|
|
|
208414
208405
|
`STREAMS_SIGNING_PRIVATE_KEY=${escapeEnvValue(i.STREAMS_SIGNING_PRIVATE_KEY)}`,
|
|
208415
208406
|
`SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY=${escapeEnvValue(i.SECONDLAYER_WEBHOOK_SIGNING_PRIVATE_KEY)}`,
|
|
208416
208407
|
`ALLOW_UNSIGNED_WEBHOOKS=${i.ALLOW_UNSIGNED_WEBHOOKS}`,
|
|
208417
|
-
`SECONDLAYER_API_URL=${i.SECONDLAYER_API_URL}
|
|
208418
|
-
`SL_API_URL=${i.SL_API_URL}`
|
|
208408
|
+
`SECONDLAYER_API_URL=${i.SECONDLAYER_API_URL}`
|
|
208419
208409
|
];
|
|
208420
208410
|
if (i.SECONDLAYER_API_KEY) {
|
|
208421
|
-
lines.push("# Hosted account key for archive credits (sk-sl_*).", `SECONDLAYER_API_KEY=${i.SECONDLAYER_API_KEY}
|
|
208411
|
+
lines.push("# Hosted account key for archive credits (sk-sl_*).", `SECONDLAYER_API_KEY=${i.SECONDLAYER_API_KEY}`);
|
|
208422
208412
|
}
|
|
208423
208413
|
lines.push("# Archive trust root: bootstrap, verify, and repair check manifests", "# against this key. Replace it to pin a different archive.", `ARCHIVE_SIGNING_PUBLIC_KEY=${escapeEnvValue(i.ARCHIVE_SIGNING_PUBLIC_KEY)}`);
|
|
208424
208414
|
if (config.nodeMode === "full") {
|
|
@@ -208537,7 +208527,7 @@ function cliEntry() {
|
|
|
208537
208527
|
var CHILD_ENV_KEYS = [
|
|
208538
208528
|
"DATABASE_URL",
|
|
208539
208529
|
"ARCHIVE_SIGNING_PUBLIC_KEY",
|
|
208540
|
-
"
|
|
208530
|
+
"SECONDLAYER_API_URL",
|
|
208541
208531
|
"INSTANCE_TOKEN"
|
|
208542
208532
|
];
|
|
208543
208533
|
function buildChildEnv(envPath, base = process.env) {
|
|
@@ -209023,7 +209013,6 @@ program.hook("preAction", (thisCommand) => {
|
|
|
209023
209013
|
applyApiKeyFlag(apiKey);
|
|
209024
209014
|
if (apiUrl) {
|
|
209025
209015
|
process.env.SECONDLAYER_API_URL = apiUrl;
|
|
209026
|
-
process.env.SL_API_URL = apiUrl;
|
|
209027
209016
|
}
|
|
209028
209017
|
});
|
|
209029
209018
|
program.addHelpText("after", `
|
|
@@ -209069,5 +209058,5 @@ registerCreditsCommand(program);
|
|
|
209069
209058
|
registerArchiveCommand(program);
|
|
209070
209059
|
program.parse();
|
|
209071
209060
|
|
|
209072
|
-
//# debugId=
|
|
209061
|
+
//# debugId=51F0AC96395CA7BC64756E2164756E21
|
|
209073
209062
|
//# sourceMappingURL=cli.js.map
|