@rine-network/cli 0.11.6 → 0.11.8
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 +2 -1
- package/dist/main.js +78 -73
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -56,7 +56,8 @@ npx @rine-network/cli onboard --email you@example.com --name "My Org" --slug my-
|
|
|
56
56
|
| `rine keys ...` | Status, generate, rotate, export, import E2EE key pairs |
|
|
57
57
|
| `rine send / read / inbox / reply` | Messaging (with `--payload-file` for file/stdin input) |
|
|
58
58
|
| `rine group ...` | Group CRUD, join, invite, vote, members |
|
|
59
|
-
| `rine webhook ...` |
|
|
59
|
+
| `rine webhook ...` | Outbound webhook management (rine → a URL you host) |
|
|
60
|
+
| `rine hook ... / rine relay` | Inbound webhook Funnel — hook CRUD + the relay daemon (`--tier zero-trust\|shared-edge`) |
|
|
60
61
|
| `rine discover ...` | Browse and search the agent directory |
|
|
61
62
|
| `rine poll-token` | Generate or revoke inbox polling token |
|
|
62
63
|
| `rine stream` | SSE real-time stream with lifecycle events, persistent mode, heartbeat timeout |
|
package/dist/main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
import { Command } from "commander";
|
|
3
|
-
import { FUNNEL_TIERS, HttpClient, IdempotencyStore, RineApiError, UUID_RE, addMlsGroupMember, agentKeysExist, agentLabel, buildIssueCertDeps, cacheToken, connectTunnel, decryptGroupMessage, decryptMessage, deleteHookSecret, encryptGroupMessage, encryptMessage, encryptMlsGroupMessage, ensureCert, externalJoinMlsGroup, fetchAgents, fetchAndIngestPendingSKDistributions, fetchOAuthToken, fetchRecipientKeys, formatError, fromBase64Url, generateAgentKeys, generateHookSecret, generatePqKeyPair, getAgentPublicKeys, getCredentialEntry, getOrCreateSenderKey, getOrRefreshToken, handleWebhookRequest, ingestSenderKeyDistribution, initMlsGroup, isBareAgentName, isValidHookName, listMyInvites, loadAgentKeys, loadCredentials, loadHookSecret, loadMeta, loadMlsState, loadTokenCache, normalizeHandle, performAgentCreation, performRegistration, processMlsWelcomes, renewalDueWithJitter, resolveAgent, resolveApiUrl, resolveConfigDir, resolveHandleViaWebFinger, resolveToUuid, saveAgentKeys, saveCredentials, saveHookSecret, savePqEncryptionKey, saveTokenCache, sendGroupInviteNotification, startTlsListener, syncMlsGroup, toBase64Url, validateEncryptionKey, validateSigningKey, validateSlug } from "@rine-network/core";
|
|
2
|
+
import { Command, Option } from "commander";
|
|
3
|
+
import { FUNNEL_TIERS, HttpClient, IdempotencyStore, RineApiError, UUID_RE, addMlsGroupMember, agentKeysExist, agentLabel, buildIssueCertDeps, cacheToken, connectTunnel, decryptGroupMessage, decryptMessage, deleteHookSecret, encryptGroupMessage, encryptMessage, encryptMlsGroupMessage, ensureCert, externalJoinMlsGroup, fetchAgents, fetchAndIngestPendingSKDistributions, fetchOAuthToken, fetchRecipientKeys, formatError, fromBase64Url, generateAgentKeys, generateHookSecret, generatePqKeyPair, getAgentPublicKeys, getCredentialEntry, getOrCreateSenderKey, getOrRefreshToken, handleWebhookRequest, ingestSenderKeyDistribution, initMlsGroup, isBareAgentName, isValidHookName, listMyInvites, loadAgentKeys, loadCredentials, loadHookSecret, loadMeta, loadMlsState, loadTokenCache, makeEdgePipeFactory, normalizeHandle, performAgentCreation, performRegistration, processMlsWelcomes, renewalDueWithJitter, resolveAgent, resolveApiUrl, resolveConfigDir, resolveHandleViaWebFinger, resolveToUuid, saveAgentKeys, saveCredentials, saveHookSecret, savePqEncryptionKey, saveTokenCache, sendGroupInviteNotification, startTlsListener, syncMlsGroup, toBase64Url, validateEncryptionKey, validateSigningKey, validateSlug } from "@rine-network/core";
|
|
4
4
|
import readline from "node:readline";
|
|
5
5
|
import * as fs from "node:fs";
|
|
6
6
|
import { readFileSync } from "node:fs";
|
|
@@ -924,7 +924,7 @@ function resolveTier(raw) {
|
|
|
924
924
|
}
|
|
925
925
|
function registerHook(program) {
|
|
926
926
|
const hook = program.command("hook").description("Manage inbound webhook funnel hooks");
|
|
927
|
-
hook.command("create").description("Allocate a funnel hook and print its GitHub setup (secret shown once)").option("--agent <id>", "Agent ID (defaults to your agent)").option("--name <name>", "Hook name (default: default)", "default").
|
|
927
|
+
hook.command("create").description("Allocate a funnel hook and print its GitHub setup (secret shown once)").option("--agent <id>", "Agent ID (defaults to your agent)").option("--name <name>", "Hook name (default: default)", "default").addOption(new Option("--tier <tier>", "Termination tier: zero-trust (your relay terminates TLS; rine never sees the cleartext) or shared-edge (rine's broker terminates TLS for high-scale delivery; brief in-memory cleartext, never stored). Default: by trust tier.").choices(Object.keys(TIER_CLI_TO_WIRE))).action(withClient(program, async ({ client, gOpts, apiUrl, configDir }, opts) => {
|
|
928
928
|
if (!isValidHookName(opts.name)) {
|
|
929
929
|
printError(`Invalid hook name '${opts.name}': use lowercase letters, digits and hyphens (max 32).`);
|
|
930
930
|
process.exitCode = 2;
|
|
@@ -960,7 +960,7 @@ function registerHook(program) {
|
|
|
960
960
|
else printTable(data.items.map((h) => ({
|
|
961
961
|
Name: h.hook_name,
|
|
962
962
|
Hostname: h.hostname,
|
|
963
|
-
Tier: h.termination,
|
|
963
|
+
Tier: h.termination.replace("_", "-"),
|
|
964
964
|
Active: h.active,
|
|
965
965
|
Created: h.created_at
|
|
966
966
|
})));
|
|
@@ -993,7 +993,7 @@ function printCreated(created, secret, json) {
|
|
|
993
993
|
name: created.hook_name,
|
|
994
994
|
hostname: created.hostname,
|
|
995
995
|
agent_id: created.agent_id,
|
|
996
|
-
|
|
996
|
+
tier: created.termination
|
|
997
997
|
},
|
|
998
998
|
public_url: publicUrl,
|
|
999
999
|
secret,
|
|
@@ -1013,7 +1013,7 @@ function printCreated(created, secret, json) {
|
|
|
1013
1013
|
},
|
|
1014
1014
|
{
|
|
1015
1015
|
Field: "Tier",
|
|
1016
|
-
Value: created.termination
|
|
1016
|
+
Value: created.termination.replace("_", "-")
|
|
1017
1017
|
},
|
|
1018
1018
|
{
|
|
1019
1019
|
Field: "Payload URL",
|
|
@@ -1034,6 +1034,7 @@ function printCreated(created, secret, json) {
|
|
|
1034
1034
|
]);
|
|
1035
1035
|
console.log(`\nGitHub: Settings → Webhooks → Payload URL = ${publicUrl}, Content type = ${CONTENT_TYPE}, Secret = the secret above.`);
|
|
1036
1036
|
console.log("Save this secret now — it is not stored on rine and cannot be retrieved.");
|
|
1037
|
+
if (created.termination === "shared_edge") console.log("\nThis hook uses the shared-edge tier: rine's broker briefly handles the decrypted request in memory (never logged or stored) before your relay verifies and re-encrypts it. For delivery where rine never sees the cleartext, recreate with --tier zero-trust.");
|
|
1037
1038
|
}
|
|
1038
1039
|
//#endregion
|
|
1039
1040
|
//#region src/commands/keys.ts
|
|
@@ -1776,33 +1777,55 @@ async function runRelayLoop(ctx) {
|
|
|
1776
1777
|
try {
|
|
1777
1778
|
const hook = await resolveHook(client, agentId, opts.hook);
|
|
1778
1779
|
const { hostname, control_ws_url: controlWsUrl } = hook;
|
|
1779
|
-
|
|
1780
|
-
certHandle = agentLabel(hostname);
|
|
1781
|
-
lastDeps = await buildIssueCertDeps({
|
|
1780
|
+
const onRequest = (req) => handleWebhookRequest({
|
|
1782
1781
|
configDir,
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1782
|
+
agentId,
|
|
1783
|
+
hookName: opts.hook,
|
|
1784
|
+
secret,
|
|
1785
|
+
client,
|
|
1786
|
+
idempotency,
|
|
1787
|
+
emitLifecycle: (ev) => json && console.log(JSON.stringify(ev))
|
|
1788
|
+
}, req).then(() => void 0);
|
|
1789
|
+
const ref = {};
|
|
1790
|
+
let ztCert;
|
|
1791
|
+
let openLocalPipe;
|
|
1792
|
+
if (hook.termination === "shared_edge") {
|
|
1793
|
+
certHandle = void 0;
|
|
1794
|
+
openLocalPipe = makeEdgePipeFactory({ onRequest });
|
|
1795
|
+
emitLifecycle$1(json, {
|
|
1796
|
+
state: "shared_edge_ready",
|
|
1797
|
+
hostname
|
|
1798
|
+
});
|
|
1799
|
+
} else if (hook.termination === "zero_trust") {
|
|
1800
|
+
certHandle = agentLabel(hostname);
|
|
1801
|
+
lastDeps = await buildIssueCertDeps({
|
|
1794
1802
|
configDir,
|
|
1795
1803
|
options,
|
|
1796
|
-
|
|
1804
|
+
http: client,
|
|
1805
|
+
agentId
|
|
1797
1806
|
});
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1807
|
+
certBusy = true;
|
|
1808
|
+
try {
|
|
1809
|
+
ztCert = await ensureCert({
|
|
1810
|
+
handle: certHandle,
|
|
1811
|
+
agentId,
|
|
1812
|
+
delegationId: certHandle,
|
|
1813
|
+
configDir,
|
|
1814
|
+
options,
|
|
1815
|
+
deps: lastDeps
|
|
1816
|
+
});
|
|
1817
|
+
} finally {
|
|
1818
|
+
certBusy = false;
|
|
1819
|
+
}
|
|
1820
|
+
emitLifecycle$1(json, {
|
|
1821
|
+
state: "cert_ready",
|
|
1822
|
+
hostname
|
|
1823
|
+
});
|
|
1824
|
+
openLocalPipe = (frame) => {
|
|
1825
|
+
if (!ref.live) throw new Error("listener not ready");
|
|
1826
|
+
return ref.live.openLocalPipe(frame);
|
|
1827
|
+
};
|
|
1828
|
+
} else throw new UnsupportedTierError(hook.termination);
|
|
1806
1829
|
const tunnel = await connectTunnel({
|
|
1807
1830
|
controlWsUrl,
|
|
1808
1831
|
token: await getOrRefreshToken(configDir, apiUrl, entry, profileName, {
|
|
@@ -1811,38 +1834,29 @@ async function runRelayLoop(ctx) {
|
|
|
1811
1834
|
}),
|
|
1812
1835
|
agentId,
|
|
1813
1836
|
hostname,
|
|
1814
|
-
openLocalPipe
|
|
1815
|
-
if (!ref.live) throw new Error("listener not ready");
|
|
1816
|
-
return ref.live.openLocalPipe(frame);
|
|
1817
|
-
}
|
|
1837
|
+
openLocalPipe
|
|
1818
1838
|
});
|
|
1819
1839
|
emitLifecycle$1(json, { state: "tunnel_connected" });
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
await assertAgentARecord(hostname, json);
|
|
1837
|
-
emitLifecycle$1(json, {
|
|
1838
|
-
state: "listener_ready",
|
|
1839
|
-
port: live.port
|
|
1840
|
-
});
|
|
1841
|
-
startRenewalTimer();
|
|
1840
|
+
if (hook.termination === "zero_trust" && ztCert) {
|
|
1841
|
+
const live = await startTlsListener({
|
|
1842
|
+
port,
|
|
1843
|
+
certPem: ztCert.certPem,
|
|
1844
|
+
keyPem: ztCert.keyPem,
|
|
1845
|
+
onRequest
|
|
1846
|
+
});
|
|
1847
|
+
listener = live;
|
|
1848
|
+
ref.live = live;
|
|
1849
|
+
await assertAgentARecord(hostname, json);
|
|
1850
|
+
emitLifecycle$1(json, {
|
|
1851
|
+
state: "listener_ready",
|
|
1852
|
+
port: live.port
|
|
1853
|
+
});
|
|
1854
|
+
startRenewalTimer();
|
|
1855
|
+
}
|
|
1842
1856
|
backoff = 1;
|
|
1843
1857
|
const close = await waitForClose(tunnel, () => stopped);
|
|
1844
1858
|
tunnel.close();
|
|
1845
|
-
|
|
1859
|
+
listener?.close();
|
|
1846
1860
|
if (stopped) break;
|
|
1847
1861
|
if (close?.clean !== false) {
|
|
1848
1862
|
emitLifecycle$1(json, {
|
|
@@ -1866,7 +1880,7 @@ async function runRelayLoop(ctx) {
|
|
|
1866
1880
|
} catch (err) {
|
|
1867
1881
|
listener?.close();
|
|
1868
1882
|
if (stopped) break;
|
|
1869
|
-
if (err instanceof
|
|
1883
|
+
if (err instanceof UnsupportedTierError) {
|
|
1870
1884
|
if (renewalTimer) clearInterval(renewalTimer);
|
|
1871
1885
|
printError(err.message);
|
|
1872
1886
|
process.exitCode = 2;
|
|
@@ -1928,26 +1942,17 @@ async function resolveHook(client, agentId, hookName) {
|
|
|
1928
1942
|
return hook;
|
|
1929
1943
|
}
|
|
1930
1944
|
/**
|
|
1931
|
-
* Fatal — this build
|
|
1932
|
-
*
|
|
1945
|
+
* Fatal — this build implements the zero-trust and shared-edge tiers; an UNKNOWN
|
|
1946
|
+
* `termination` value from a newer backend is thrown (not retried) so the relay
|
|
1947
|
+
* never enters a backoff loop it cannot escape. Upgrade the CLI to serve it.
|
|
1933
1948
|
*/
|
|
1934
|
-
var
|
|
1935
|
-
constructor() {
|
|
1936
|
-
super(
|
|
1937
|
-
this.name = "
|
|
1949
|
+
var UnsupportedTierError = class extends Error {
|
|
1950
|
+
constructor(tier) {
|
|
1951
|
+
super(`This hook uses a TLS-termination mode ('${tier}') this relay build does not support. Upgrade the CLI to a newer build, or recreate the hook with a supported --tier.`);
|
|
1952
|
+
this.name = "UnsupportedTierError";
|
|
1938
1953
|
}
|
|
1939
1954
|
};
|
|
1940
1955
|
/**
|
|
1941
|
-
* Gate the relay to the zero-trust tier (REQ-TIER-03). The relay branches ONCE on
|
|
1942
|
-
* `hook.termination` and this build implements only zero-trust — the relay
|
|
1943
|
-
* terminates TLS with a per-agent wildcard cert. Shared-edge is broker-terminated
|
|
1944
|
-
* (Phase B); fail LOUD here, BEFORE any `.hook` label/FQDN derivation, so a
|
|
1945
|
-
* `.edge` host is never fed to the zero-trust agentLabel deriver (relay F-4).
|
|
1946
|
-
*/
|
|
1947
|
-
function assertZeroTrustTier(hook) {
|
|
1948
|
-
if (hook.termination !== "zero_trust") throw new SharedEdgeNotSupportedError();
|
|
1949
|
-
}
|
|
1950
|
-
/**
|
|
1951
1956
|
* (AUD-A1) Assert the zero-trust hostname resolves to an A record before
|
|
1952
1957
|
* declaring the listener ready. The per-agent `*.{agentLabel}.hook` A is a
|
|
1953
1958
|
* DELIVERY prerequisite written best-effort by the backend (REQ-OPS-04); a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rine-network/cli",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.8",
|
|
4
4
|
"description": "CLI client for rine.network \u2014 EU-first messaging infrastructure for AI agents",
|
|
5
5
|
"author": "mmmbs <mmmbs@proton.me>",
|
|
6
6
|
"license": "EUPL-1.2",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dev": "tsx src/main.ts"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@rine-network/core": "^0.6.
|
|
31
|
+
"@rine-network/core": "^0.6.5",
|
|
32
32
|
"commander": "^12.0.0",
|
|
33
33
|
"eventsource-client": "^1.1.0"
|
|
34
34
|
},
|