@kynver-app/runtime 0.2.17 → 0.2.19
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/chat/chat-claim-loop.d.ts +2 -0
- package/dist/chat/chat-primary-cli.d.ts +2 -0
- package/dist/chat/command-auth-proof.d.ts +12 -2
- package/dist/chat/command-auth-proof.js +1 -1
- package/dist/cli.js +61 -61
- package/dist/index.js +80 -80
- package/package.json +1 -1
- package/dist/server/adapter-contract.d.ts +0 -1
- package/dist/server/adapter-contract.js +0 -1
- package/dist/server/context-budget.d.ts +0 -2
- package/dist/server/context-budget.js +0 -19
- package/dist/server/db-credentials.d.ts +0 -3
- package/dist/server/db-credentials.js +0 -2
- package/dist/server/dispatch-routing.d.ts +0 -3
- package/dist/server/dispatch-routing.js +0 -5
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type ChatTurnPayload } from "./anthropic-stream.js";
|
|
2
|
+
/** Stable box id for sticky chat routing (config/env before hostname). */
|
|
3
|
+
export declare function resolveChatClaimBoxId(env?: Record<string, string | undefined>): string;
|
|
2
4
|
export interface ChatBridgeTarget {
|
|
3
5
|
bridgeUrl: string;
|
|
4
6
|
agentOsId: string;
|
|
@@ -31,8 +31,18 @@ export interface CommandAuthSigningKey {
|
|
|
31
31
|
usingDevFallbackKey: boolean;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* Committed DEV fallback public key
|
|
35
|
-
*
|
|
34
|
+
* Committed DEV fallback public key id. Matching private seed is committed for
|
|
35
|
+
* local/dev signing — NOT a production trust root (verifier refuses it when
|
|
36
|
+
* `NODE_ENV=production` unless `KYNVER_COMMAND_AUTH_PUBLIC_KEY` overrides).
|
|
37
|
+
*/
|
|
38
|
+
export declare const COMMAND_AUTH_DEV_FALLBACK_PUBLIC_KEY_ID = "ca-6297fb8e1773";
|
|
39
|
+
/**
|
|
40
|
+
* keyId → raw Ed25519 public key (hex). Public material ships in the published
|
|
41
|
+
* package on purpose — baking it in is what lets bridge + daemon verify
|
|
42
|
+
* command proofs without a per-host env. Rotation path:
|
|
43
|
+
* `KYNVER_COMMAND_AUTH_PUBLIC_KEY` env override (raw 32-byte hex or base64)
|
|
44
|
+
* outranks the pinned set (must match the proof's `publicKeyId`), then a
|
|
45
|
+
* package republish pins the new key.
|
|
36
46
|
*/
|
|
37
47
|
export declare const PINNED_COMMAND_AUTH_PUBLIC_KEYS: Readonly<Record<string, string>>;
|
|
38
48
|
export declare function deriveCommandAuthKeyId(rawPublicKey: Uint8Array): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createHash as c,createPrivateKey as d,createPublicKey as l,randomBytes as
|
|
1
|
+
import{createHash as c,createPrivateKey as d,createPublicKey as l,randomBytes as m,sign as b,verify as h}from"node:crypto";function f(e){return JSON.stringify(u(e))}function u(e){if(Array.isArray(e))return e.map(u);if(e&&typeof e=="object"){let r={};for(let n of Object.keys(e).sort())r[n]=u(e[n]);return r}return e}function o(e){if(!e)return null;let r=e.trim();if(!r)return null;if(/^[0-9a-fA-F]{64}$/.test(r))return new Uint8Array(r.match(/.{2}/g).map(n=>parseInt(n,16)));try{let n=Buffer.from(r,"base64");if(n.length===32)return new Uint8Array(n)}catch{}return null}var A=120,I=Buffer.from("302a300506032b6570032100","hex"),g=Buffer.from("302e020100300506032b657004220420","hex"),P="c0021e9312b0a479dbd2eb8dec0deedbe0dd6445eff431e372fa49fa21d42ffa",y="ca-6297fb8e1773",K={[y]:"16ae5cb2a61f8c94cf1b86e8258f9c2f2ff6aba5e6136250a422209b6e866881","ca-456fd128f3b3":"f29cbd559410c2578d7f9732ccd86570073355ccdb36af0d1b7dff15908466e7"};function p(e){return`ca-${c("sha256").update(Buffer.from(e)).digest("hex").slice(0,12)}`}function B(e,r=process.env){let n=o(r.KYNVER_COMMAND_AUTH_PUBLIC_KEY);if(n)return p(n)!==e?null:n;let t=K[e];return!t||r.NODE_ENV==="production"&&e===y?null:o(t)}function C(e){return l({key:Buffer.concat([I,Buffer.from(e)]),format:"der",type:"spki"})}function x(e,r){return!Array.isArray(e)||e.length!==r.length?!1:e.every((n,t)=>typeof n=="string"&&n===r[t])}function _(e){if(!e||typeof e!="object")return!1;let r=e;if(typeof r.signature!="string"||!r.signature||typeof r.publicKeyId!="string"||!r.publicKeyId)return!1;let n=r.payload;return!(!n||typeof n!="object"||n.v!==1||typeof n.agentOsId!="string"||!n.agentOsId||!Array.isArray(n.argv)||n.argv.some(t=>typeof t!="string")||typeof n.userId!="string"||!n.userId||typeof n.exp!="number"||!Number.isFinite(n.exp)||typeof n.nonce!="string"||!n.nonce)}function D(e,r,n=process.env,t=Math.floor(Date.now()/1e3)){if(!_(e))return{ok:!1,reason:"malformed command authorization proof"};if(e.payload.agentOsId!==r.agentOsId)return{ok:!1,reason:"agentOsId mismatch"};if(!x(e.payload.argv,r.argv))return{ok:!1,reason:"argv mismatch"};if(e.payload.exp<=t)return{ok:!1,reason:"proof expired"};let i=B(e.publicKeyId,n);if(!i)return{ok:!1,reason:`no verification key for publicKeyId "${e.publicKeyId}"`};let a;try{a=Buffer.from(e.signature,"base64url")}catch{return{ok:!1,reason:"signature is not base64url"}}if(a.length!==64)return{ok:!1,reason:"signature is not a 64-byte Ed25519 signature"};try{let s=Buffer.from(f(e.payload),"utf8");return h(null,s,C(i),a)?{ok:!0,payload:e.payload}:{ok:!1,reason:"Ed25519 signature mismatch"}}catch(s){return{ok:!1,reason:`signature verification failed: ${s.message}`}}}function k(e){let r=d({key:Buffer.concat([g,Buffer.from(e)]),format:"der",type:"pkcs8"}),n=l(r).export({format:"der",type:"spki"});return new Uint8Array(n.subarray(n.length-32))}function v(e=process.env){let r=o(e.KYNVER_COMMAND_AUTH_KEY);if(!r&&e.NODE_ENV==="production")throw new Error("KYNVER_COMMAND_AUTH_KEY must be set in production; refusing to sign command proofs with the committed dev key.");let n=r??o(P),t=k(n);return{seed:n,rawPublicKey:t,publicKeyId:p(t),usingDevFallbackKey:!r}}function S(e,r){let n=d({key:Buffer.concat([g,Buffer.from(r.seed)]),format:"der",type:"pkcs8"}),t=Buffer.from(f(e),"utf8");return{payload:e,signature:b(null,t,n).toString("base64url"),publicKeyId:r.publicKeyId}}function U(e){let r=e.env??process.env,n=e.nowSec??Math.floor(Date.now()/1e3),t=e.ttlSec??A,i={v:1,agentOsId:e.agentOsId,argv:[...e.argv],userId:e.userId,exp:n+t,nonce:m(16).toString("base64url")};return S(i,v(r))}function N(e){return c("sha256").update(Buffer.from(e.rawPublicKey)).digest("hex").slice(0,16)}export{y as COMMAND_AUTH_DEV_FALLBACK_PUBLIC_KEY_ID,A as COMMAND_AUTH_PROOF_TTL_SEC,K as PINNED_COMMAND_AUTH_PUBLIC_KEYS,x as argvMatchesProof,N as commandAuthProofKeyFingerprint,p as deriveCommandAuthKeyId,_ as isSignedCommandAuthProofShape,U as issueCommandAuthorizationProof,B as resolveCommandAuthPublicKey,v as resolveCommandAuthSigningKey,D as verifyCommandAuthorizationProof};
|