tenjin-cli 0.1.0-alpha.4 → 0.1.0-alpha.7
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 +269 -38
- package/dist/{buy-OOOLUDND.js → buy-XVOMNWKN.js} +21 -18
- package/dist/{candidate-TWCWTFGA.js → candidate-DJB2NNTG.js} +7 -8
- package/dist/{chunk-KXIX7YDV.js → chunk-2KIDDWQO.js} +5 -5
- package/dist/{chunk-NXCJN2FJ.js → chunk-2L73UI6T.js} +51 -42
- package/dist/chunk-2L73UI6T.js.map +1 -0
- package/dist/{chunk-OJD54DIU.js → chunk-2YX6LTCD.js} +5 -5
- package/dist/{chunk-H5ETJRQD.js → chunk-5X4EBGGU.js} +22 -14
- package/dist/chunk-5X4EBGGU.js.map +1 -0
- package/dist/chunk-6S44OLND.js +699 -0
- package/dist/chunk-6S44OLND.js.map +1 -0
- package/dist/{chunk-FU6MCSLG.js → chunk-7WDY4AXV.js} +2 -64
- package/dist/chunk-7WDY4AXV.js.map +1 -0
- package/dist/{chunk-VV4P5RVK.js → chunk-BBUYCDSG.js} +16 -4
- package/dist/chunk-BBUYCDSG.js.map +1 -0
- package/dist/chunk-CYRYVZPN.js +213 -0
- package/dist/chunk-CYRYVZPN.js.map +1 -0
- package/dist/{chunk-FHB3VKZW.js → chunk-DAJ56EUU.js} +5 -3
- package/dist/chunk-DAJ56EUU.js.map +1 -0
- package/dist/chunk-DH6D6QIO.js +239 -0
- package/dist/chunk-DH6D6QIO.js.map +1 -0
- package/dist/chunk-E6BNARCS.js +614 -0
- package/dist/chunk-E6BNARCS.js.map +1 -0
- package/dist/chunk-GABYDXWL.js +190 -0
- package/dist/chunk-GABYDXWL.js.map +1 -0
- package/dist/{chunk-EUQN3L5X.js → chunk-GM4RZUVU.js} +21 -9
- package/dist/chunk-GM4RZUVU.js.map +1 -0
- package/dist/{chunk-C4TIWOAM.js → chunk-GXYNLMUQ.js} +28 -11
- package/dist/chunk-GXYNLMUQ.js.map +1 -0
- package/dist/{chunk-6WWVYYSB.js → chunk-J6CVKC4M.js} +86 -4
- package/dist/chunk-J6CVKC4M.js.map +1 -0
- package/dist/{chunk-5JH7ZB6Z.js → chunk-KT2DGKFT.js} +76 -10
- package/dist/chunk-KT2DGKFT.js.map +1 -0
- package/dist/chunk-L6AV2Q73.js +105 -0
- package/dist/chunk-L6AV2Q73.js.map +1 -0
- package/dist/{chunk-333FOTUJ.js → chunk-MJZZTKCC.js} +108 -2
- package/dist/chunk-MJZZTKCC.js.map +1 -0
- package/dist/{chunk-XNNOR7F7.js → chunk-OTDI5FXG.js} +3 -5
- package/dist/{chunk-XNNOR7F7.js.map → chunk-OTDI5FXG.js.map} +1 -1
- package/dist/chunk-PIIWLEEG.js +337 -0
- package/dist/chunk-PIIWLEEG.js.map +1 -0
- package/dist/{chunk-ULLWHHIT.js → chunk-PLU3E63S.js} +468 -559
- package/dist/chunk-PLU3E63S.js.map +1 -0
- package/dist/chunk-QW2Q2KAH.js +27 -0
- package/dist/chunk-QW2Q2KAH.js.map +1 -0
- package/dist/{chunk-S3KZ3PPK.js → chunk-RGFBBNGP.js} +291 -59
- package/dist/chunk-RGFBBNGP.js.map +1 -0
- package/dist/chunk-SGK2B724.js +67 -0
- package/dist/chunk-SGK2B724.js.map +1 -0
- package/dist/chunk-UYP7G3GZ.js +412 -0
- package/dist/chunk-UYP7G3GZ.js.map +1 -0
- package/dist/{chunk-DPUMEMGM.js → chunk-VZ3AJCO5.js} +3 -5
- package/dist/{chunk-DPUMEMGM.js.map → chunk-VZ3AJCO5.js.map} +1 -1
- package/dist/{chunk-QH6677FJ.js → chunk-WDJTGVKN.js} +2 -2
- package/dist/{chunk-QH6677FJ.js.map → chunk-WDJTGVKN.js.map} +1 -1
- package/dist/{chunk-4GR7DGD6.js → chunk-WI5EOAQQ.js} +33 -256
- package/dist/{chunk-4GR7DGD6.js.map → chunk-WI5EOAQQ.js.map} +1 -1
- package/dist/{chunk-DPET3TW5.js → chunk-WRWCDLVK.js} +13 -12
- package/dist/chunk-WRWCDLVK.js.map +1 -0
- package/dist/chunk-XBJ3VLWX.js +35 -0
- package/dist/chunk-XBJ3VLWX.js.map +1 -0
- package/dist/chunk-ZEWY3RJ3.js +149 -0
- package/dist/chunk-ZEWY3RJ3.js.map +1 -0
- package/dist/chunk-ZFE7STX7.js +143 -0
- package/dist/chunk-ZFE7STX7.js.map +1 -0
- package/dist/{cli-AFSLAKR6.js → cli-7B2QNJG3.js} +247 -26
- package/dist/cli-7B2QNJG3.js.map +1 -0
- package/dist/{config-DBEEM3UA.js → config-SAQEQRFB.js} +7 -6
- package/dist/{doctor-XDA3YU6H.js → doctor-ENJ22XWN.js} +10 -8
- package/dist/{publish-IH7RJXGB.js → edit-2QO5GQDU.js} +19 -17
- package/dist/index.js +1 -1
- package/dist/{inspect-YBGDAG47.js → inspect-IPKKQB2S.js} +16 -15
- package/dist/{install-7J6KKEEP.js → install-7ZIYISQ7.js} +180 -133
- package/dist/install-7ZIYISQ7.js.map +1 -0
- package/dist/outcome-NSDE2KAJ.js +20 -0
- package/dist/publish-7WIFFNFG.js +40 -0
- package/dist/read-5TQR7LCF.js +158 -0
- package/dist/read-5TQR7LCF.js.map +1 -0
- package/dist/{run-DCZFEW2C.js → run-NPKIP26Y.js} +109 -34
- package/dist/{run-DCZFEW2C.js.map → run-NPKIP26Y.js.map} +1 -1
- package/dist/search-63ELMRZH.js +24 -0
- package/dist/send-ENE47KQE.js +222 -0
- package/dist/send-ENE47KQE.js.map +1 -0
- package/dist/session-FZU4VFFE.js +87 -0
- package/dist/session-FZU4VFFE.js.map +1 -0
- package/dist/{usdc-AU6ZIKA6.js → usdc-4VCDHFWX.js} +20 -4
- package/dist/{wallet-UWHSHWC6.js → wallet-OCCGEH6H.js} +8 -8
- package/dist/{wallet-HKG3GSTX.js → wallet-RBDVNZVR.js} +17 -7
- package/dist/wallet-RBDVNZVR.js.map +1 -0
- package/package.json +1 -1
- package/skills/tenjin/SKILL.md +32 -7
- package/skills/tenjin-publish/SKILL.md +109 -16
- package/skills/tenjin-search/SKILL.md +174 -15
- package/dist/chunk-333FOTUJ.js.map +0 -1
- package/dist/chunk-5JH7ZB6Z.js.map +0 -1
- package/dist/chunk-6WWVYYSB.js.map +0 -1
- package/dist/chunk-BXUS5UCT.js +0 -212
- package/dist/chunk-BXUS5UCT.js.map +0 -1
- package/dist/chunk-C4TIWOAM.js.map +0 -1
- package/dist/chunk-CJU555P5.js +0 -333
- package/dist/chunk-CJU555P5.js.map +0 -1
- package/dist/chunk-DPET3TW5.js.map +0 -1
- package/dist/chunk-EUQN3L5X.js.map +0 -1
- package/dist/chunk-FHB3VKZW.js.map +0 -1
- package/dist/chunk-FU6MCSLG.js.map +0 -1
- package/dist/chunk-H5ETJRQD.js.map +0 -1
- package/dist/chunk-MM4TGTST.js +0 -59
- package/dist/chunk-MM4TGTST.js.map +0 -1
- package/dist/chunk-MUBUQVC3.js +0 -67
- package/dist/chunk-MUBUQVC3.js.map +0 -1
- package/dist/chunk-NXCJN2FJ.js.map +0 -1
- package/dist/chunk-R7BMDJZM.js +0 -167
- package/dist/chunk-R7BMDJZM.js.map +0 -1
- package/dist/chunk-S3KZ3PPK.js.map +0 -1
- package/dist/chunk-ULLWHHIT.js.map +0 -1
- package/dist/chunk-VV4P5RVK.js.map +0 -1
- package/dist/chunk-YFREUEUI.js +0 -78
- package/dist/chunk-YFREUEUI.js.map +0 -1
- package/dist/cli-AFSLAKR6.js.map +0 -1
- package/dist/install-7J6KKEEP.js.map +0 -1
- package/dist/outcome-ZFGHX2XW.js +0 -20
- package/dist/search-R6NIQFXI.js +0 -24
- /package/dist/{buy-OOOLUDND.js.map → buy-XVOMNWKN.js.map} +0 -0
- /package/dist/{candidate-TWCWTFGA.js.map → candidate-DJB2NNTG.js.map} +0 -0
- /package/dist/{chunk-KXIX7YDV.js.map → chunk-2KIDDWQO.js.map} +0 -0
- /package/dist/{chunk-OJD54DIU.js.map → chunk-2YX6LTCD.js.map} +0 -0
- /package/dist/{config-DBEEM3UA.js.map → config-SAQEQRFB.js.map} +0 -0
- /package/dist/{doctor-XDA3YU6H.js.map → doctor-ENJ22XWN.js.map} +0 -0
- /package/dist/{inspect-YBGDAG47.js.map → edit-2QO5GQDU.js.map} +0 -0
- /package/dist/{outcome-ZFGHX2XW.js.map → inspect-IPKKQB2S.js.map} +0 -0
- /package/dist/{publish-IH7RJXGB.js.map → outcome-NSDE2KAJ.js.map} +0 -0
- /package/dist/{search-R6NIQFXI.js.map → publish-7WIFFNFG.js.map} +0 -0
- /package/dist/{usdc-AU6ZIKA6.js.map → search-63ELMRZH.js.map} +0 -0
- /package/dist/{wallet-HKG3GSTX.js.map → usdc-4VCDHFWX.js.map} +0 -0
- /package/dist/{wallet-UWHSHWC6.js.map → wallet-OCCGEH6H.js.map} +0 -0
|
@@ -2,14 +2,12 @@ import { createRequire as __tenjinCreateRequire } from 'node:module'; const requ
|
|
|
2
2
|
import {
|
|
3
3
|
hasCode
|
|
4
4
|
} from "./chunk-2I4QTOLB.js";
|
|
5
|
-
import {
|
|
6
|
-
writeFileAtomicExclusive
|
|
7
|
-
} from "./chunk-MUBUQVC3.js";
|
|
8
5
|
import {
|
|
9
6
|
CliError,
|
|
10
7
|
external_exports,
|
|
11
|
-
walletPath
|
|
12
|
-
|
|
8
|
+
walletPath,
|
|
9
|
+
writeFileAtomicExclusive
|
|
10
|
+
} from "./chunk-J6CVKC4M.js";
|
|
13
11
|
|
|
14
12
|
// src/lib/wallet/store.ts
|
|
15
13
|
import { readFile, stat } from "fs/promises";
|
|
@@ -88,6 +86,13 @@ async function readWalletRecord(dir) {
|
|
|
88
86
|
}
|
|
89
87
|
return parsed.data;
|
|
90
88
|
}
|
|
89
|
+
function walletExistsError(dir, cause) {
|
|
90
|
+
const path = walletPath(dir);
|
|
91
|
+
return new CliError("WALLET_EXISTS", `A wallet already exists at ${path}.`, {
|
|
92
|
+
fix: `Run \`tenjin wallet create --replace\` to archive it and create a new one: its keystore is parked beside the new wallet and its passphrase stays preserved in the OS credential store (service tenjin-cli, account = its address), so its funds remain reachable. That passphrase is unrecoverable \u2014 never delete the credential-store entry, or the wallet's funds are stranded.`,
|
|
93
|
+
...cause !== void 0 ? { cause } : {}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
91
96
|
async function writeWalletRecord(dir, record) {
|
|
92
97
|
const validated = WalletRecordSchema.parse(record);
|
|
93
98
|
const path = walletPath(dir);
|
|
@@ -98,12 +103,7 @@ async function writeWalletRecord(dir, record) {
|
|
|
98
103
|
dirMode: 448
|
|
99
104
|
});
|
|
100
105
|
} catch (err) {
|
|
101
|
-
if (hasCode(err, "EEXIST"))
|
|
102
|
-
throw new CliError("WALLET_EXISTS", `A wallet already exists at ${path}.`, {
|
|
103
|
-
fix: `Keys are non-recoverable; move it aside first (e.g. \`mv ${path} ${path}.bak\`) to create a new one.`,
|
|
104
|
-
cause: err
|
|
105
|
-
});
|
|
106
|
-
}
|
|
106
|
+
if (hasCode(err, "EEXIST")) throw walletExistsError(dir, err);
|
|
107
107
|
throw err;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -121,6 +121,7 @@ export {
|
|
|
121
121
|
walletFileExists,
|
|
122
122
|
walletFileMode,
|
|
123
123
|
readWalletRecord,
|
|
124
|
+
walletExistsError,
|
|
124
125
|
writeWalletRecord
|
|
125
126
|
};
|
|
126
|
-
//# sourceMappingURL=chunk-
|
|
127
|
+
//# sourceMappingURL=chunk-WRWCDLVK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/wallet/store.ts"],"sourcesContent":["import { readFile, stat } from 'node:fs/promises';\nimport { z } from 'zod';\nimport * as Keystore from 'ox/Keystore';\nimport { CliError } from '../errors';\nimport { writeFileAtomicExclusive } from '../atomic-json';\nimport { hasCode } from '../errno';\nimport { walletPath } from '../paths';\n\n/** A 0x-prefixed 32-byte hex private key (case-insensitive). */\nexport const PRIVATE_KEY_RE = /^0x[0-9a-f]{64}$/i;\nconst ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;\n\n/**\n * The at-rest shape of a Keystore v3 document (Web3 Secret Storage). Validated\n * structurally on read so an obviously-corrupt keystore fails as\n * WALLET_INVALID_KEY before we ever ask for a passphrase; the real integrity\n * check is the keystore's own MAC, verified by ox at decrypt time. `kdfparams`\n * stays an open object because scrypt and pbkdf2 carry different fields and only\n * ox needs to interpret them.\n */\nconst KeystoreV3Schema = z.object({\n crypto: z.object({\n cipher: z.literal('aes-128-ctr'),\n ciphertext: z.string(),\n cipherparams: z.object({ iv: z.string() }),\n kdf: z.enum(['scrypt', 'pbkdf2']),\n kdfparams: z.record(z.string(), z.unknown()),\n mac: z.string(),\n }),\n id: z.string(),\n version: z.literal(3),\n});\n\n/**\n * The persisted wallet record (schema v2). The private key is NEVER stored in\n * cleartext: `keystore` is a Keystore v3 document (scrypt + AES-128-CTR) and the\n * key is recovered only by decrypting it with the wallet passphrase. `address`\n * stays top-level in cleartext ON PURPOSE so `show`/`balance`/`doctor` keep\n * working without a passphrase; only signing decrypts. The `provider`\n * discriminator keeps the schema from implying every future wallet embeds a\n * keystore. Validated on read (a corrupt file is WALLET_INVALID_KEY, never a\n * silent partial parse).\n */\nexport const WalletRecordSchema = z.object({\n schemaVersion: z.literal(2),\n provider: z.literal('local'),\n address: z.string().regex(ADDRESS_RE, 'expected a 0x-prefixed 20-byte address'),\n keystore: KeystoreV3Schema,\n createdAt: z.string(),\n});\nexport type WalletRecord = Omit<z.infer<typeof WalletRecordSchema>, 'keystore'> & {\n keystore: Keystore.Keystore;\n};\n\nexport async function walletFileExists(dir: string): Promise<boolean> {\n return (await walletFileMode(dir)) !== null;\n}\n\n/** File permission bits (`mode & 0o777`), or null when the wallet file is absent. */\nexport async function walletFileMode(dir: string): Promise<number | null> {\n try {\n return (await stat(walletPath(dir))).mode & 0o777;\n } catch (err) {\n if (isNotFound(err)) return null;\n throw err;\n }\n}\n\n/** Read + validate the wallet record; null when absent, WALLET_INVALID_KEY when corrupt. */\nexport async function readWalletRecord(dir: string): Promise<WalletRecord | null> {\n const path = walletPath(dir);\n let raw: string;\n try {\n raw = await readFile(path, 'utf8');\n } catch (err) {\n if (isNotFound(err)) return null;\n throw new CliError('WALLET_INVALID_KEY', `Could not read the wallet file at ${path}.`, {\n fix: `Check file permissions on ${path}.`,\n cause: err,\n });\n }\n let json: unknown;\n try {\n json = JSON.parse(raw);\n } catch (err) {\n throw new CliError('WALLET_INVALID_KEY', `The wallet file at ${path} is not valid JSON.`, {\n fix: `Move ${path} aside, then run \\`tenjin wallet create\\`.`,\n cause: err,\n });\n }\n // A pre-encryption record (schema v1 stored the raw key). There is no in-place\n // migration: the old key must be swept and a fresh encrypted wallet created.\n if (isPreEncryptionRecord(json)) {\n throw new CliError(\n 'WALLET_INVALID_KEY',\n `The wallet file at ${path} predates encrypted storage.`,\n {\n fix: `Move ${path} aside and run \\`tenjin wallet create\\`; sweep any funds from the old address first.`,\n },\n );\n }\n const parsed = WalletRecordSchema.safeParse(json);\n if (!parsed.success) {\n throw new CliError(\n 'WALLET_INVALID_KEY',\n `The wallet file at ${path} is not a valid wallet record.`,\n {\n fix: `Move ${path} aside, then run \\`tenjin wallet create\\`.`,\n details: parsed.error.issues,\n },\n );\n }\n return parsed.data as WalletRecord;\n}\n\n/**\n * The one WALLET_EXISTS error, shared by the create pre-check and the exclusive\n * write's race loser so the two surfaces can never drift apart.\n */\nexport function walletExistsError(dir: string, cause?: unknown): CliError {\n const path = walletPath(dir);\n return new CliError('WALLET_EXISTS', `A wallet already exists at ${path}.`, {\n fix: `Run \\`tenjin wallet create --replace\\` to archive it and create a new one: its keystore is parked beside the new wallet and its passphrase stays preserved in the OS credential store (service tenjin-cli, account = its address), so its funds remain reachable. That passphrase is unrecoverable — never delete the credential-store entry, or the wallet's funds are stranded.`,\n ...(cause !== undefined ? { cause } : {}),\n });\n}\n\n/**\n * Persist a validated record at 0600 in a 0700 dir, NO-CLOBBER. The exclusive\n * write — not an earlier existence check — is the authority: two concurrent\n * `create` runs can both pass a pre-check, but only one can win the atomic\n * commit; the loser surfaces as WALLET_EXISTS instead of silently overwriting\n * (and losing) a non-recoverable key.\n */\nexport async function writeWalletRecord(dir: string, record: WalletRecord): Promise<void> {\n const validated = WalletRecordSchema.parse(record);\n const path = walletPath(dir);\n try {\n await writeFileAtomicExclusive(path, `${JSON.stringify(validated, null, 2)}\\n`, {\n mode: 0o600,\n dirMode: 0o700,\n });\n } catch (err) {\n if (hasCode(err, 'EEXIST')) throw walletExistsError(dir, err);\n throw err;\n }\n}\n\n/** A cleartext-key record from before encrypted storage: schema v1 or a bare `privateKey`. */\nfunction isPreEncryptionRecord(json: unknown): boolean {\n if (typeof json !== 'object' || json === null) return false;\n const rec = json as Record<string, unknown>;\n return rec.schemaVersion === 1 || 'privateKey' in rec;\n}\n\nfunction isNotFound(err: unknown): boolean {\n return hasCode(err, 'ENOENT');\n}\n"],"mappings":";;;;;;;;;;;;AAAA,SAAS,UAAU,YAAY;AASxB,IAAM,iBAAiB;AAC9B,IAAM,aAAa;AAUnB,IAAM,mBAAmB,iBAAE,OAAO;AAAA,EAChC,QAAQ,iBAAE,OAAO;AAAA,IACf,QAAQ,iBAAE,QAAQ,aAAa;AAAA,IAC/B,YAAY,iBAAE,OAAO;AAAA,IACrB,cAAc,iBAAE,OAAO,EAAE,IAAI,iBAAE,OAAO,EAAE,CAAC;AAAA,IACzC,KAAK,iBAAE,KAAK,CAAC,UAAU,QAAQ,CAAC;AAAA,IAChC,WAAW,iBAAE,OAAO,iBAAE,OAAO,GAAG,iBAAE,QAAQ,CAAC;AAAA,IAC3C,KAAK,iBAAE,OAAO;AAAA,EAChB,CAAC;AAAA,EACD,IAAI,iBAAE,OAAO;AAAA,EACb,SAAS,iBAAE,QAAQ,CAAC;AACtB,CAAC;AAYM,IAAM,qBAAqB,iBAAE,OAAO;AAAA,EACzC,eAAe,iBAAE,QAAQ,CAAC;AAAA,EAC1B,UAAU,iBAAE,QAAQ,OA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A,QACjB,SAAS,OAAO,MAAM;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AACA,SAAO,OAAO;AAChB;AAMO,SAAS,kBAAkB,KAAa,OAA2B;AACxE,QAAM,OAAO,WAAW,GAAG;AAC3B,SAAO,IAAI,SAAS,iBAAiB,8BAA8B,IAAI,KAAK;AAAA,IAC1E,KAAK;AAAA,IACL,GAAI,UAAU,SAAY,EAAE,MAAM,IAAI,CAAC;AAAA,EACzC,CAAC;AACH;AASA,eAAsB,kBAAkB,KAAa,QAAqC;AACxF,QAAM,YAAY,mBAAmB,MAAM,MAAM;AACjD,QAAM,OAAO,WAAW,GAAG;AAC3B,MAAI;AACF,UAAM,yBAAyB,MAAM,GAAG,KAAK,UAAU,WAAW,MAAM,CAAC,CAAC;AAAA,GAAM;AAAA,MAC9E,MAAM;AAAA,MACN,SAAS;AAAA,IACX,CAAC;AAAA,EACH,SAAS,KAAK;AACZ,QAAI,QAAQ,KAAK,QAAQ,EAAG,OAAM,kBAAkB,KAAK,GAAG;AAC5D,UAAM;AAAA,EACR;AACF;AAGA,SAAS,sBAAsB,MAAwB;AACrD,MAAI,OAAO,SAAS,YAAY,SAAS,KAAM,QAAO;AACtD,QAAM,MAAM;AACZ,SAAO,IAAI,kBAAkB,KAAK,gBAAgB;AACpD;AAEA,SAAS,WAAW,KAAuB;AACzC,SAAO,QAAQ,KAAK,QAAQ;AAC9B;","names":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
CliError
|
|
4
|
+
} from "./chunk-J6CVKC4M.js";
|
|
5
|
+
|
|
6
|
+
// src/lib/url.ts
|
|
7
|
+
function trimSlash(url) {
|
|
8
|
+
return url.replace(/\/+$/, "");
|
|
9
|
+
}
|
|
10
|
+
function tryOriginOf(url) {
|
|
11
|
+
let parsed;
|
|
12
|
+
try {
|
|
13
|
+
parsed = new URL(url);
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return null;
|
|
18
|
+
return parsed.origin;
|
|
19
|
+
}
|
|
20
|
+
function originOf(url) {
|
|
21
|
+
const origin = tryOriginOf(url);
|
|
22
|
+
if (origin === null) {
|
|
23
|
+
throw new CliError("USAGE", `Invalid base URL: ${JSON.stringify(url)}`, {
|
|
24
|
+
fix: "Set an absolute http(s) base URL: `tenjin config set baseUrl <url>`."
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return origin;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
trimSlash,
|
|
32
|
+
tryOriginOf,
|
|
33
|
+
originOf
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=chunk-XBJ3VLWX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/url.ts"],"sourcesContent":["import { CliError } from './errors';\n\n/** Drop trailing slashes from a base URL so `${base}/path` never doubles a slash. */\nexport function trimSlash(url: string): string {\n return url.replace(/\\/+$/, '');\n}\n\n/**\n * The `scheme://host[:port]` of an http(s) URL, or null if it is not one.\n *\n * Non-http schemes are rejected rather than passed through, and that is the whole\n * reason this is not a one-line `new URL(url).origin`: for any non-special\n * scheme the WHATWG origin is the opaque string `\"null\"`, so `foo://tenjin.blog`\n * and `bar://evil.example` compare EQUAL. This value binds a wallet-derived\n * credential to one deployment, so an equal-comparing sentinel is exactly the\n * failure it exists to prevent — the same shape as the unparseable case, just\n * spelled differently.\n */\nexport function tryOriginOf(url: string): string | null {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch {\n return null;\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return null;\n return parsed.origin;\n}\n\n/**\n * `tryOriginOf` for callers that cannot proceed without an origin. Throws USAGE\n * rather than returning a sentinel; anything that must survive a bad base URL\n * (diagnostics, above all) uses `tryOriginOf` and handles the null.\n */\nexport function originOf(url: string): string {\n const origin = tryOriginOf(url);\n if (origin === null) {\n throw new CliError('USAGE', `Invalid base URL: ${JSON.stringify(url)}`, {\n fix: 'Set an absolute http(s) base URL: `tenjin config set baseUrl <url>`.',\n });\n }\n return origin;\n}\n"],"mappings":";;;;;;AAGO,SAAS,UAAU,KAAqB;AAC7C,SAAO,IAAI,QAAQ,QAAQ,EAAE;AAC/B;AAaO,SAAS,YAAY,KAA4B;AACtD,MAAI;AACJ,MAAI;AACF,aAAS,IAAI,IAAI,GAAG;AAAA,EACtB,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,OAAO,aAAa,WAAW,OAAO,aAAa,SAAU,QAAO;AACxE,SAAO,OAAO;AAChB;AAOO,SAAS,SAAS,KAAqB;AAC5C,QAAM,SAAS,YAAY,GAAG;AAC9B,MAAI,WAAW,MAAM;AACnB,UAAM,IAAI,SAAS,SAAS,qBAAqB,KAAK,UAAU,GAAG,CAAC,IAAI;AAAA,MACtE,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
fetchRead
|
|
4
|
+
} from "./chunk-KT2DGKFT.js";
|
|
5
|
+
import {
|
|
6
|
+
headingOutline
|
|
7
|
+
} from "./chunk-SGK2B724.js";
|
|
8
|
+
import {
|
|
9
|
+
resolveResourceRef
|
|
10
|
+
} from "./chunk-CYRYVZPN.js";
|
|
11
|
+
import {
|
|
12
|
+
sanitizeForTerminal
|
|
13
|
+
} from "./chunk-BBUYCDSG.js";
|
|
14
|
+
import {
|
|
15
|
+
resolveContextSettings
|
|
16
|
+
} from "./chunk-DAJ56EUU.js";
|
|
17
|
+
import {
|
|
18
|
+
toMoney
|
|
19
|
+
} from "./chunk-UYP7G3GZ.js";
|
|
20
|
+
|
|
21
|
+
// src/commands/inspect.ts
|
|
22
|
+
async function runInspect(args, ctx, deps = {}) {
|
|
23
|
+
const settings = await resolveContextSettings(ctx);
|
|
24
|
+
const ref = await resolveResourceRef(args.ref, ctx.dataDir, settings.baseUrl);
|
|
25
|
+
const result = await fetchRead(ref.url, {
|
|
26
|
+
timeoutMs: ctx.flags.timeout,
|
|
27
|
+
...deps.fetchImpl !== void 0 ? { fetchImpl: deps.fetchImpl } : {}
|
|
28
|
+
});
|
|
29
|
+
if (result.kind === "entitled") {
|
|
30
|
+
const body = result.body;
|
|
31
|
+
return {
|
|
32
|
+
data: {
|
|
33
|
+
url: ref.url,
|
|
34
|
+
resourceId: body.id,
|
|
35
|
+
access: "free",
|
|
36
|
+
title: body.title,
|
|
37
|
+
price: toMoney(body.price),
|
|
38
|
+
headings: headingOutline(body.bodyMd),
|
|
39
|
+
// The free/owned half of the verb split (#42): delivery here costs nothing,
|
|
40
|
+
// so point at the free-only verb, not at the paying one. Machine consumers
|
|
41
|
+
// read this; the human line below says the same thing.
|
|
42
|
+
nextCommand: `tenjin read ${ref.url}`
|
|
43
|
+
},
|
|
44
|
+
humanLines: [
|
|
45
|
+
`${sanitizeForTerminal(body.title)}, free (${body.price} atomic). Read it with \`tenjin read ${sanitizeForTerminal(ref.url)}\`.`
|
|
46
|
+
]
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if (result.kind === "payment_required") {
|
|
50
|
+
const requirement = result.paymentRequired.accepts[0];
|
|
51
|
+
const price = requirement !== void 0 ? toMoney(requirement.amount) : void 0;
|
|
52
|
+
const card = result.preview.card;
|
|
53
|
+
return {
|
|
54
|
+
data: {
|
|
55
|
+
url: ref.url,
|
|
56
|
+
...ref.resourceId !== void 0 ? { resourceId: ref.resourceId } : {},
|
|
57
|
+
access: "paid",
|
|
58
|
+
...price !== void 0 ? { price } : {},
|
|
59
|
+
payment: requirement !== void 0 ? {
|
|
60
|
+
scheme: requirement.scheme,
|
|
61
|
+
network: requirement.network,
|
|
62
|
+
asset: requirement.asset,
|
|
63
|
+
payTo: requirement.payTo,
|
|
64
|
+
amount: requirement.amount
|
|
65
|
+
} : void 0,
|
|
66
|
+
// The card stays where the wire puts it, inside `preview`, and is emitted
|
|
67
|
+
// exactly once: it is the largest object in this envelope, and a second
|
|
68
|
+
// hoisted copy would double every inspect payload to save one key of
|
|
69
|
+
// depth.
|
|
70
|
+
preview: result.preview,
|
|
71
|
+
...result.cardError === true ? { cardError: true } : {},
|
|
72
|
+
// Paid and unowned: this one really does cost money, so it keeps pointing at
|
|
73
|
+
// `buy`. `tenjin read` would refuse it with exit 3.
|
|
74
|
+
nextCommand: `tenjin buy ${ref.url}`
|
|
75
|
+
},
|
|
76
|
+
humanLines: [
|
|
77
|
+
`Paid resource${price !== void 0 ? `, ${price.usd} USD (${price.atomic} atomic)` : ""}.`,
|
|
78
|
+
...cardLines(card),
|
|
79
|
+
// Three distinct states behind an absent card, and they call for three
|
|
80
|
+
// different actions: the piece attests nothing (a signal, judge on that),
|
|
81
|
+
// the server could not load a card it has (transient, retry), or this CLI
|
|
82
|
+
// could not parse what arrived (a client-side bug or server drift). Only
|
|
83
|
+
// the last is ours. `cardUnavailable` is server-sent and never rides
|
|
84
|
+
// alongside a card, so it is only worth saying when there is no card.
|
|
85
|
+
...card === void 0 && result.preview.cardUnavailable === true ? ["The piece has a card the server could not load; retry later."] : [],
|
|
86
|
+
...result.cardError === true ? [
|
|
87
|
+
"The server sent an answer card this CLI could not parse; judging on price and preview only."
|
|
88
|
+
] : [],
|
|
89
|
+
"This is the pre-purchase card; run `tenjin buy` to pay and read (`tenjin read` refuses paid pieces)."
|
|
90
|
+
]
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
data: {
|
|
95
|
+
url: ref.url,
|
|
96
|
+
access: "entitled",
|
|
97
|
+
message: result.message,
|
|
98
|
+
nextCommand: `tenjin read ${ref.url}`
|
|
99
|
+
},
|
|
100
|
+
humanLines: [
|
|
101
|
+
`${sanitizeForTerminal(result.message)} Read it with \`tenjin read ${sanitizeForTerminal(ref.url)}\`.`
|
|
102
|
+
]
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
var CARD_BOUNDS = {
|
|
106
|
+
list: 10 * 200 + 9 * 2,
|
|
107
|
+
appliesTo: 8 * (32 + 1 + 20 * 120 + 19 * 2) + 7 * 2,
|
|
108
|
+
prose: 500,
|
|
109
|
+
cadence: 120,
|
|
110
|
+
// artifactType and temporalMode are open strings on the wire, so the composed
|
|
111
|
+
// freshness line gets a bound of its own rather than trusting them.
|
|
112
|
+
freshness: 200
|
|
113
|
+
};
|
|
114
|
+
var CLIP_MARKER = "...";
|
|
115
|
+
function cardLine(label, value, max) {
|
|
116
|
+
if (value === null) return [];
|
|
117
|
+
const text = sanitizeForTerminal(value).trim();
|
|
118
|
+
if (text.length === 0) return [];
|
|
119
|
+
return [`${label}: ${text.length > max ? `${text.slice(0, max)}${CLIP_MARKER}` : text}`];
|
|
120
|
+
}
|
|
121
|
+
function cardLines(card) {
|
|
122
|
+
if (card === void 0) return [];
|
|
123
|
+
const list = (items) => items.length > 0 ? items.join("; ") : null;
|
|
124
|
+
const appliesTo = Object.entries(card.appliesTo).map(
|
|
125
|
+
([key, values]) => `${key}=${values.join(", ")}`
|
|
126
|
+
);
|
|
127
|
+
return [
|
|
128
|
+
...cardLine("Answers", list(card.questionsAnswered), CARD_BOUNDS.list),
|
|
129
|
+
...cardLine("Tasks", list(card.tasksSupported), CARD_BOUNDS.list),
|
|
130
|
+
...cardLine("Applies to", list(appliesTo), CARD_BOUNDS.appliesTo),
|
|
131
|
+
...cardLine("Scope", card.scope, CARD_BOUNDS.prose),
|
|
132
|
+
...cardLine("Excludes", card.exclusions, CARD_BOUNDS.prose),
|
|
133
|
+
...cardLine("Freshness", freshness(card), CARD_BOUNDS.freshness),
|
|
134
|
+
...cardLine("Provenance", card.provenanceSummary, CARD_BOUNDS.prose),
|
|
135
|
+
...cardLine("Method", card.methodologySummary, CARD_BOUNDS.prose),
|
|
136
|
+
...cardLine("Maintenance", card.maintenanceCadence, CARD_BOUNDS.cadence)
|
|
137
|
+
];
|
|
138
|
+
}
|
|
139
|
+
function freshness(card) {
|
|
140
|
+
const parts = [card.artifactType, card.temporalMode].filter((s) => s.trim().length > 0);
|
|
141
|
+
if (card.asOf !== null) parts.push(`as of ${card.asOf}`);
|
|
142
|
+
if (card.validUntil !== null) parts.push(`valid until ${card.validUntil}`);
|
|
143
|
+
return parts.join(", ");
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export {
|
|
147
|
+
runInspect
|
|
148
|
+
};
|
|
149
|
+
//# sourceMappingURL=chunk-ZEWY3RJ3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/inspect.ts"],"sourcesContent":["import { resolveResourceRef } from '../lib/resource-ref';\nimport { resolveContextSettings } from '../lib/settings';\nimport { fetchRead, type PreviewCard } from '../lib/read-client';\nimport { toMoney } from '../lib/money';\nimport { headingOutline } from '../lib/markdown';\nimport { sanitizeForTerminal } from '../lib/output';\nimport type { CommandContext, CommandResult } from '../context';\n\n/**\n * `tenjin inspect <resource-url-or-id>`, fetch the pre-purchase answer card /\n * preview from the read route's 402 body WITHOUT paying (spec 10). A free\n * resource returns 200 with the whole body; a paid one returns the leak-safe\n * preview plus the advertised price/network, and the answer card when the piece\n * carries one. Never signs, never pays, never saves.\n *\n * The card is the depth half of the search/inspect split: search v2 candidates are\n * lean, so this free call is where an agent gets what it answers, what it applies\n * to, what it excludes, and how it is dated, before spending anything.\n */\n\nexport interface InspectArgs {\n ref: string;\n}\n\nexport interface InspectDeps {\n fetchImpl?: typeof fetch;\n}\n\nexport async function runInspect(\n args: InspectArgs,\n ctx: CommandContext,\n deps: InspectDeps = {},\n): Promise<CommandResult> {\n const settings = await resolveContextSettings(ctx);\n const ref = await resolveResourceRef(args.ref, ctx.dataDir, settings.baseUrl);\n\n const result = await fetchRead(ref.url, {\n timeoutMs: ctx.flags.timeout,\n ...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),\n });\n\n if (result.kind === 'entitled') {\n // Free (or already-entitled) resource: the body is readable now, no payment.\n const body = result.body;\n return {\n data: {\n url: ref.url,\n resourceId: body.id,\n access: 'free',\n title: body.title,\n price: toMoney(body.price),\n headings: headingOutline(body.bodyMd),\n // The free/owned half of the verb split (#42): delivery here costs nothing,\n // so point at the free-only verb, not at the paying one. Machine consumers\n // read this; the human line below says the same thing.\n nextCommand: `tenjin read ${ref.url}`,\n },\n humanLines: [\n `${sanitizeForTerminal(body.title)}, free (${body.price} atomic). Read it with \\`tenjin read ${sanitizeForTerminal(ref.url)}\\`.`,\n ],\n };\n }\n\n if (result.kind === 'payment_required') {\n const requirement = result.paymentRequired.accepts[0];\n const price = requirement !== undefined ? toMoney(requirement.amount) : undefined;\n const card = result.preview.card;\n return {\n data: {\n url: ref.url,\n ...(ref.resourceId !== undefined ? { resourceId: ref.resourceId } : {}),\n access: 'paid',\n ...(price !== undefined ? { price } : {}),\n payment:\n requirement !== undefined\n ? {\n scheme: requirement.scheme,\n network: requirement.network,\n asset: requirement.asset,\n payTo: requirement.payTo,\n amount: requirement.amount,\n }\n : undefined,\n // The card stays where the wire puts it, inside `preview`, and is emitted\n // exactly once: it is the largest object in this envelope, and a second\n // hoisted copy would double every inspect payload to save one key of\n // depth.\n preview: result.preview,\n ...(result.cardError === true ? { cardError: true } : {}),\n // Paid and unowned: this one really does cost money, so it keeps pointing at\n // `buy`. `tenjin read` would refuse it with exit 3.\n nextCommand: `tenjin buy ${ref.url}`,\n },\n humanLines: [\n `Paid resource${price !== undefined ? `, ${price.usd} USD (${price.atomic} atomic)` : ''}.`,\n ...cardLines(card),\n // Three distinct states behind an absent card, and they call for three\n // different actions: the piece attests nothing (a signal, judge on that),\n // the server could not load a card it has (transient, retry), or this CLI\n // could not parse what arrived (a client-side bug or server drift). Only\n // the last is ours. `cardUnavailable` is server-sent and never rides\n // alongside a card, so it is only worth saying when there is no card.\n ...(card === undefined && result.preview.cardUnavailable === true\n ? ['The piece has a card the server could not load; retry later.']\n : []),\n ...(result.cardError === true\n ? [\n 'The server sent an answer card this CLI could not parse; judging on price and preview only.',\n ]\n : []),\n 'This is the pre-purchase card; run `tenjin buy` to pay and read (`tenjin read` refuses paid pieces).',\n ],\n };\n }\n\n // already_purchased without a payment header is unexpected; report it plainly.\n // Owned means delivery is free, so this branch points at `read` too.\n return {\n data: {\n url: ref.url,\n access: 'entitled',\n message: result.message,\n nextCommand: `tenjin read ${ref.url}`,\n },\n humanLines: [\n `${sanitizeForTerminal(result.message)} Read it with \\`tenjin read ${sanitizeForTerminal(ref.url)}\\`.`,\n ],\n };\n}\n\n/**\n * Per-line caps for the rendered card, each derived from the server's write-time\n * bound for that field, so a VALID card is never clipped: the two lists are 10\n * items x 200 chars joined with '; '; appliesTo is 8 keys (<=32 chars) x 20\n * values x 120 chars; the prose fields have a 500-char column bound and cadence\n * 120. Exceeding one means a server that broke its own bounds.\n *\n * When that happens the clip is MARKED. A silently shortened claim reads as a\n * whole one, and \"applies to Postgres 14, 15\" is a different promise from\n * \"applies to Postgres 14, 15, 16\". The `--json` payload stays verbatim either\n * way, because that copy is what an agent decides a non-refundable purchase on.\n */\nconst CARD_BOUNDS = {\n list: 10 * 200 + 9 * 2,\n appliesTo: 8 * (32 + 1 + 20 * 120 + 19 * 2) + 7 * 2,\n prose: 500,\n cadence: 120,\n // artifactType and temporalMode are open strings on the wire, so the composed\n // freshness line gets a bound of its own rather than trusting them.\n freshness: 200,\n} as const;\n\nconst CLIP_MARKER = '...';\n\nfunction cardLine(label: string, value: string | null, max: number): string[] {\n if (value === null) return [];\n const text = sanitizeForTerminal(value).trim();\n if (text.length === 0) return [];\n return [`${label}: ${text.length > max ? `${text.slice(0, max)}${CLIP_MARKER}` : text}`];\n}\n\n/**\n * The answer card off the 402 body, as human lines. This is the depth half of the\n * search/inspect split: search v2 returns lean hits, and the card an agent judges\n * fit on arrives here, for free. Empty when the piece carries no card, so an\n * uncarded inspect renders exactly as it did before.\n */\nfunction cardLines(card: PreviewCard | undefined): string[] {\n if (card === undefined) return [];\n const list = (items: string[]): string | null => (items.length > 0 ? items.join('; ') : null);\n const appliesTo = Object.entries(card.appliesTo).map(\n ([key, values]) => `${key}=${values.join(', ')}`,\n );\n return [\n ...cardLine('Answers', list(card.questionsAnswered), CARD_BOUNDS.list),\n ...cardLine('Tasks', list(card.tasksSupported), CARD_BOUNDS.list),\n ...cardLine('Applies to', list(appliesTo), CARD_BOUNDS.appliesTo),\n ...cardLine('Scope', card.scope, CARD_BOUNDS.prose),\n ...cardLine('Excludes', card.exclusions, CARD_BOUNDS.prose),\n ...cardLine('Freshness', freshness(card), CARD_BOUNDS.freshness),\n ...cardLine('Provenance', card.provenanceSummary, CARD_BOUNDS.prose),\n ...cardLine('Method', card.methodologySummary, CARD_BOUNDS.prose),\n ...cardLine('Maintenance', card.maintenanceCadence, CARD_BOUNDS.cadence),\n ];\n}\n\n/** Type, temporal mode and the two dates on one line: they answer the single\n * question a buyer asks of freshness, which is whether this is still true here.\n *\n * Both labels are open strings on the wire, so an empty one is dropped rather\n * than joined: otherwise the line leads with a comma and reads as a rendering\n * bug. All four empty yields '', and cardLine then omits the line entirely. */\nfunction freshness(card: PreviewCard): string {\n const parts = [card.artifactType, card.temporalMode].filter((s) => s.trim().length > 0);\n if (card.asOf !== null) parts.push(`as of ${card.asOf}`);\n if (card.validUntil !== null) parts.push(`valid until ${card.validUntil}`);\n return parts.join(', ');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA4BA,eAAsB,WACpB,MACA,KACA,OAAoB,CAAC,GACG;AACxB,QAAM,WAAW,MAAM,uBAAuB,GAAG;AACjD,QAAM,MAAM,MAAM,mBAAmB,KAAK,KAAK,IAAI,SAAS,SAAS,OAAO;AAE5E,QAAM,SAAS,MAAM,UAAU,IAAI,KAAK;AAAA,IACtC,WAAW,IAAI,MAAM;AAA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,CAAC,UAAoC,MAAM,SAAS,IAAI,MAAM,KAAK,IAAI,IAAI;AACxF,QAAM,YAAY,OAAO,QAAQ,KAAK,SAAS,EAAE;AAAA,IAC/C,CAAC,CAAC,KAAK,MAAM,MAAM,GAAG,GAAG,IAAI,OAAO,KAAK,IAAI,CAAC;AAAA,EAChD;AACA,SAAO;AAAA,IACL,GAAG,SAAS,WAAW,KAAK,KAAK,iBAAiB,GAAG,YAAY,IAAI;AAAA,IACrE,GAAG,SAAS,SAAS,KAAK,KAAK,cAAc,GAAG,YAAY,IAAI;AAAA,IAChE,GAAG,SAAS,cAAc,KAAK,SAAS,GAAG,YAAY,SAAS;AAAA,IAChE,GAAG,SAAS,SAAS,KAAK,OAAO,YAAY,KAAK;AAAA,IAClD,GAAG,SAAS,YAAY,KAAK,YAAY,YAAY,KAAK;AAAA,IAC1D,GAAG,SAAS,aAAa,UAAU,IAAI,GAAG,YAAY,SAAS;AAAA,IAC/D,GAAG,SAAS,cAAc,KAAK,mBAAmB,YAAY,KAAK;AAAA,IACnE,GAAG,SAAS,UAAU,KAAK,oBAAoB,YAAY,KAAK;AAAA,IAChE,GAAG,SAAS,eAAe,KAAK,oBAAoB,YAAY,OAAO;AAAA,EACzE;AACF;AAQA,SAAS,UAAU,MAA2B;AAC5C,QAAM,QAAQ,CAAC,KAAK,cAAc,KAAK,YAAY,EAAE,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC;AACtF,MAAI,KAAK,SAAS,KAAM,OAAM,KAAK,SAAS,KAAK,IAAI,EAAE;AACvD,MAAI,KAAK,eAAe,KAAM,OAAM,KAAK,eAAe,KAAK,UAAU,EAAE;AACzE,SAAO,MAAM,KAAK,IAAI;AACxB;","names":[]}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
buildSiwxHeader
|
|
4
|
+
} from "./chunk-7WDY4AXV.js";
|
|
5
|
+
import {
|
|
6
|
+
isSessionUsable,
|
|
7
|
+
loadSessionFile,
|
|
8
|
+
signWithSession
|
|
9
|
+
} from "./chunk-GABYDXWL.js";
|
|
10
|
+
import {
|
|
11
|
+
originOf
|
|
12
|
+
} from "./chunk-XBJ3VLWX.js";
|
|
13
|
+
import {
|
|
14
|
+
sessionPath,
|
|
15
|
+
writeFileAtomic
|
|
16
|
+
} from "./chunk-J6CVKC4M.js";
|
|
17
|
+
|
|
18
|
+
// src/lib/session-key.ts
|
|
19
|
+
import { webcrypto } from "crypto";
|
|
20
|
+
var SESSION_CHAIN_ID = "eip155:8453";
|
|
21
|
+
var SESSION_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
22
|
+
var subtle = webcrypto.subtle;
|
|
23
|
+
function generateP256KeyPair() {
|
|
24
|
+
return subtle.generateKey({ name: "ECDSA", namedCurve: "P-256" }, true, [
|
|
25
|
+
"sign",
|
|
26
|
+
"verify"
|
|
27
|
+
]);
|
|
28
|
+
}
|
|
29
|
+
function toBase64Url(bytes) {
|
|
30
|
+
return Buffer.from(bytes).toString("base64url");
|
|
31
|
+
}
|
|
32
|
+
function delegationResources(publicKeyRaw, expIso, scope) {
|
|
33
|
+
return [
|
|
34
|
+
`urn:tenjin:session:pubkey:p256:${publicKeyRaw}`,
|
|
35
|
+
`urn:tenjin:session:exp:${expIso}`,
|
|
36
|
+
`urn:tenjin:session:scope:${scope}`
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
async function establishSession(config, deps = {}) {
|
|
40
|
+
const now = deps.now ?? Date.now;
|
|
41
|
+
const pair = await generateP256KeyPair();
|
|
42
|
+
const rawPub = new Uint8Array(await subtle.exportKey("raw", pair.publicKey));
|
|
43
|
+
const publicKeyRaw = toBase64Url(rawPub);
|
|
44
|
+
const jwk = await subtle.exportKey("jwk", pair.privateKey);
|
|
45
|
+
const expIso = new Date(now() + SESSION_TTL_MS).toISOString();
|
|
46
|
+
const delegation = await buildSiwxHeader(config.signer, {
|
|
47
|
+
baseUrl: config.baseUrl,
|
|
48
|
+
chainId: config.chainId,
|
|
49
|
+
ttlMs: SESSION_TTL_MS,
|
|
50
|
+
statement: "Delegate a Tenjin session key.",
|
|
51
|
+
resources: delegationResources(publicKeyRaw, expIso, config.scope)
|
|
52
|
+
});
|
|
53
|
+
const file = {
|
|
54
|
+
address: config.signer.address.toLowerCase(),
|
|
55
|
+
origin: originOf(config.baseUrl),
|
|
56
|
+
delegation,
|
|
57
|
+
exp: expIso,
|
|
58
|
+
scope: config.scope,
|
|
59
|
+
publicKeyRaw,
|
|
60
|
+
privateKeyJwk: jwk
|
|
61
|
+
};
|
|
62
|
+
await saveSessionFile(config.dataDir, file);
|
|
63
|
+
return file;
|
|
64
|
+
}
|
|
65
|
+
async function saveSessionFile(dir, file) {
|
|
66
|
+
await writeFileAtomic(sessionPath(dir), `${JSON.stringify(file, null, 2)}
|
|
67
|
+
`, {
|
|
68
|
+
mode: 384,
|
|
69
|
+
dirMode: 448
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function recoveryFor(code) {
|
|
73
|
+
switch (code) {
|
|
74
|
+
case "proof_expired":
|
|
75
|
+
return "resign";
|
|
76
|
+
case "session_expired":
|
|
77
|
+
case "proof_revoked":
|
|
78
|
+
case "insufficient_scope":
|
|
79
|
+
return "reestablish";
|
|
80
|
+
case "session_key_unbound":
|
|
81
|
+
return "fatal";
|
|
82
|
+
default:
|
|
83
|
+
return "fatal";
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function createSessionKeyAuth(config, deps = {}) {
|
|
87
|
+
const now = deps.now ?? Date.now;
|
|
88
|
+
let cached = null;
|
|
89
|
+
let forceReestablish = false;
|
|
90
|
+
const ensure = async () => {
|
|
91
|
+
if (!forceReestablish && cached !== null && isSessionUsable(cached, config.signer.address, now(), config.scope, originOf(config.baseUrl))) {
|
|
92
|
+
return cached;
|
|
93
|
+
}
|
|
94
|
+
if (!forceReestablish) {
|
|
95
|
+
const onDisk = await loadSessionFile(config.dataDir);
|
|
96
|
+
const origin = originOf(config.baseUrl);
|
|
97
|
+
if (onDisk !== null && isSessionUsable(onDisk, config.signer.address, now(), config.scope, origin)) {
|
|
98
|
+
cached = onDisk;
|
|
99
|
+
return cached;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
cached = await establishSession(config, deps);
|
|
103
|
+
forceReestablish = false;
|
|
104
|
+
return cached;
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
async headersFor(req) {
|
|
108
|
+
const file = await ensure();
|
|
109
|
+
return signWithSession(file, req, deps);
|
|
110
|
+
},
|
|
111
|
+
async recover(code) {
|
|
112
|
+
const recovery = recoveryFor(code);
|
|
113
|
+
if (recovery === "fatal") return false;
|
|
114
|
+
if (recovery === "reestablish") {
|
|
115
|
+
cached = null;
|
|
116
|
+
forceReestablish = true;
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function createSiwxAuth(config) {
|
|
123
|
+
return {
|
|
124
|
+
async headersFor() {
|
|
125
|
+
const header = await buildSiwxHeader(config.signer, {
|
|
126
|
+
baseUrl: config.baseUrl,
|
|
127
|
+
chainId: config.chainId
|
|
128
|
+
});
|
|
129
|
+
return { "SIGN-IN-WITH-X": header };
|
|
130
|
+
},
|
|
131
|
+
async recover(code) {
|
|
132
|
+
return code === "nonce_already_used" || code === "invalid_proof" || code === "proof_expired";
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export {
|
|
138
|
+
SESSION_CHAIN_ID,
|
|
139
|
+
establishSession,
|
|
140
|
+
createSessionKeyAuth,
|
|
141
|
+
createSiwxAuth
|
|
142
|
+
};
|
|
143
|
+
//# sourceMappingURL=chunk-ZFE7STX7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/session-key.ts"],"sourcesContent":["import { webcrypto } from 'node:crypto';\nimport { sessionPath } from './paths';\nimport { writeFileAtomic } from './atomic-json';\nimport { buildSiwxHeader } from './siwx';\nimport { originOf } from './url';\nimport {\n isSessionUsable,\n loadSessionFile,\n signWithSession,\n type SessionFile,\n type SessionKeyDeps,\n type SessionScope,\n type SignableRequest,\n} from './session-present';\nimport type { TenjinSigner } from './wallet/provider';\n\n/**\n * Session-key delegation (RFC 9421 signed HTTP, RFC 9530-shaped Content-Digest),\n * verified byte-for-byte against the live \"Auth — session keys\" contract in\n * https://tenjin.blog/llms-full.txt (D35).\n *\n * The point: a plain SIWX write burns a single-use nonce, so every write needs a\n * fresh WALLET signature. A session key trades that for ONE wallet signature per\n * session: generate a P-256 keypair, wallet-sign a SIWX message binding its\n * pubkey/exp/scope, then sign each subsequent write with the P-256 key (no wallet\n * popup) until the delegation expires. The delegated key is short-lived (≤24h,\n * server-clamped) and cached 0600, address-bound so a wallet change invalidates it.\n *\n * This module is the MINT half — everything that needs a wallet signer, i.e.\n * `establishSession`, the cache writer, and the two `WriteAuth` implementations.\n * The present-only half (load a file, sign one request with it) lives in\n * `session-present.ts` and is re-exported below, so `posts-api`/`publish`/`edit`\n * keep importing one module while `read` can import the present half ALONE and\n * stay structurally unable to open a keystore. Do not move a signer-touching\n * function down into `session-present.ts`: read's import-graph pin is what makes\n * \"read cannot mint and cannot pay\" a property of the code rather than a promise.\n *\n * A minted delegation is a wallet-derived credential, so it is bound to the\n * ORIGIN it was minted against and every presenter re-checks that binding.\n *\n * Never hand-rolls crypto: P-256 keygen is node:crypto webcrypto (subtle) and the\n * wallet delegation reuses the siwx.ts seam.\n */\n\nexport {\n contentDigest,\n isSessionPresentable,\n readSessionFile,\n isSessionUsable,\n keyidFor,\n loadSessionFile,\n scopeSatisfies,\n signatureBase,\n signatureParams,\n signWithSession,\n targetUri,\n} from './session-present';\nexport type {\n SessionFile,\n SessionFileState,\n SessionKeyDeps,\n SessionScope,\n SignableRequest,\n SignatureParamsInput,\n} from './session-present';\n\n/**\n * The chain a session delegation is signed over. Writes require Base mainnet per\n * the server's SIWX chain constraint, and a session covers reads and writes\n * alike, so there is exactly ONE session chain id rather than a per-caller\n * choice: `session start` and the write path must mint against the same chain or\n * the file they share would flip between two delegations.\n */\nexport const SESSION_CHAIN_ID = 'eip155:8453';\n\nconst SESSION_TTL_MS = 24 * 60 * 60 * 1000; // 24h; the server clamps to ≤24h.\n\n/**\n * The write-auth seam a posts client signs through. `headersFor` attaches the\n * signature headers (establishing the session lazily on first use); `recover`\n * reacts to a 401 by returning whether a retry is worthwhile.\n */\nexport interface WriteAuth {\n headersFor(req: SignableRequest): Promise<Record<string, string>>;\n /** React to a write's 401 `code`; true ⇒ the next headersFor retry may succeed. */\n recover(code: string | undefined): Promise<boolean>;\n}\n\nexport interface SessionKeyConfig {\n signer: TenjinSigner;\n baseUrl: string;\n chainId: string;\n dataDir: string;\n /**\n * The scope this session is minted at, and the scope a cached session must\n * cover to be reused. Required, not defaulted: over-granting silently is the\n * failure mode worth making impossible, so every caller states what it needs.\n */\n scope: SessionScope;\n}\n\nconst subtle = webcrypto.subtle;\n\nfunction generateP256KeyPair(): Promise<webcrypto.CryptoKeyPair> {\n return subtle.generateKey({ name: 'ECDSA', namedCurve: 'P-256' }, true, [\n 'sign',\n 'verify',\n ]) as Promise<webcrypto.CryptoKeyPair>;\n}\n\n/** base64url (no padding) of raw bytes — the pubkey/keyid encoding. */\nfunction toBase64Url(bytes: Uint8Array): string {\n return Buffer.from(bytes).toString('base64url');\n}\n\n/** The three URNs bound into the delegation's SIWX `resources` array (D35). */\nexport function delegationResources(\n publicKeyRaw: string,\n expIso: string,\n scope: SessionScope,\n): string[] {\n return [\n `urn:tenjin:session:pubkey:p256:${publicKeyRaw}`,\n `urn:tenjin:session:exp:${expIso}`,\n `urn:tenjin:session:scope:${scope}`,\n ];\n}\n\n/**\n * Establish a session with ONE wallet signature: generate a P-256 keypair, bind\n * its pubkey/exp/scope into a SIWX message, wallet-sign it, and cache the result\n * 0600 address-bound. The returned file's `delegation` is the constant\n * `Tenjin-Session-Delegation` header for the session's life.\n */\nexport async function establishSession(\n config: SessionKeyConfig,\n deps: SessionKeyDeps = {},\n): Promise<SessionFile> {\n const now = deps.now ?? Date.now;\n const pair = await generateP256KeyPair();\n const rawPub = new Uint8Array(await subtle.exportKey('raw', pair.publicKey));\n const publicKeyRaw = toBase64Url(rawPub);\n const jwk = (await subtle.exportKey('jwk', pair.privateKey)) as SessionFile['privateKeyJwk'];\n\n const expIso = new Date(now() + SESSION_TTL_MS).toISOString();\n const delegation = await buildSiwxHeader(config.signer, {\n baseUrl: config.baseUrl,\n chainId: config.chainId,\n ttlMs: SESSION_TTL_MS,\n statement: 'Delegate a Tenjin session key.',\n resources: delegationResources(publicKeyRaw, expIso, config.scope),\n });\n\n const file: SessionFile = {\n address: config.signer.address.toLowerCase(),\n origin: originOf(config.baseUrl),\n delegation,\n exp: expIso,\n scope: config.scope,\n publicKeyRaw,\n privateKeyJwk: jwk,\n };\n await saveSessionFile(config.dataDir, file);\n return file;\n}\n\n// ---------------------------------------------------------------------------\n// Cache writes (0600, address-bound). The reader lives in session-present.\n// ---------------------------------------------------------------------------\n\nexport async function saveSessionFile(dir: string, file: SessionFile): Promise<void> {\n await writeFileAtomic(sessionPath(dir), `${JSON.stringify(file, null, 2)}\\n`, {\n mode: 0o600,\n dirMode: 0o700,\n });\n}\n\n// ---------------------------------------------------------------------------\n// The WriteAuth implementation: lazy establish, cache reuse, 401 recovery.\n// ---------------------------------------------------------------------------\n\n/** How each 401 `code` maps to recovery (per the llms-full.txt policy section). */\ntype Recovery = 'resign' | 'reestablish' | 'fatal';\n\nexport function recoveryFor(code: string | undefined): Recovery {\n switch (code) {\n case 'proof_expired':\n // The per-request signature is too old; just re-sign (no wallet).\n return 'resign';\n case 'session_expired':\n case 'proof_revoked':\n case 'insufficient_scope':\n // The delegation itself is gone/insufficient; re-establish (one wallet sig).\n return 'reestablish';\n case 'session_key_unbound':\n // keyid ≠ the delegation-bound key: retrying cannot fix it.\n return 'fatal';\n default:\n return 'fatal';\n }\n}\n\n/**\n * A session-key WriteAuth: mints (or loads) the delegation on first use and signs\n * every write with the P-256 key — so a returning agent never wallet-signs again\n * until the session expires. On a 401 it re-signs or re-establishes per the code.\n */\nexport function createSessionKeyAuth(\n config: SessionKeyConfig,\n deps: SessionKeyDeps = {},\n): WriteAuth {\n const now = deps.now ?? Date.now;\n let cached: SessionFile | null = null;\n let forceReestablish = false;\n\n const ensure = async (): Promise<SessionFile> => {\n if (\n !forceReestablish &&\n cached !== null &&\n isSessionUsable(cached, config.signer.address, now(), config.scope, originOf(config.baseUrl))\n ) {\n return cached;\n }\n if (!forceReestablish) {\n const onDisk = await loadSessionFile(config.dataDir);\n const origin = originOf(config.baseUrl);\n if (\n onDisk !== null &&\n isSessionUsable(onDisk, config.signer.address, now(), config.scope, origin)\n ) {\n cached = onDisk;\n return cached;\n }\n }\n cached = await establishSession(config, deps);\n forceReestablish = false;\n return cached;\n };\n\n return {\n async headersFor(req) {\n const file = await ensure();\n return signWithSession(file, req, deps);\n },\n async recover(code) {\n const recovery = recoveryFor(code);\n if (recovery === 'fatal') return false;\n if (recovery === 'reestablish') {\n cached = null;\n forceReestablish = true;\n }\n // 'resign' needs no state change: the next headersFor mints a fresh\n // created/nonce over the same (still-valid) delegation.\n return true;\n },\n };\n}\n\n/**\n * The plain-SIWX fallback (no session): every write carries its own fresh\n * wallet-signed `SIGN-IN-WITH-X` header. Used when session establishment is\n * disabled; a burned/stale nonce (401) is recovered by re-signing.\n */\nexport function createSiwxAuth(config: SessionKeyConfig): WriteAuth {\n return {\n async headersFor() {\n const header = await buildSiwxHeader(config.signer, {\n baseUrl: config.baseUrl,\n chainId: config.chainId,\n });\n return { 'SIGN-IN-WITH-X': header };\n },\n async recover(code) {\n // A single-use nonce burns on every write; a stale/burned nonce (or an\n // expired proof) is recovered by re-signing with a fresh nonce + issuedAt.\n return code === 'nonce_already_used' || code === 'invalid_proof' || code === 'pro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