ftown 0.21.0 → 0.25.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/attention-events.d.ts +1 -1
- package/dist/attention-store.d.ts +3 -0
- package/dist/attention-store.js +25 -1
- package/dist/attention-store.js.map +1 -1
- package/dist/centrifugo-client.d.ts +14 -1
- package/dist/centrifugo-client.js +38 -4
- package/dist/centrifugo-client.js.map +1 -1
- package/dist/command-rpc.d.ts +2 -0
- package/dist/command-rpc.js +55 -9
- package/dist/command-rpc.js.map +1 -1
- package/dist/direct-transport/loopback-server.d.ts +10 -3
- package/dist/direct-transport/loopback-server.js +20 -4
- package/dist/direct-transport/loopback-server.js.map +1 -1
- package/dist/direct-transport/peer-manager.d.ts +8 -3
- package/dist/direct-transport/peer-manager.js +20 -5
- package/dist/direct-transport/peer-manager.js.map +1 -1
- package/dist/file-stamp.d.ts +33 -0
- package/dist/file-stamp.js +35 -0
- package/dist/file-stamp.js.map +1 -0
- package/dist/identity-reset.d.ts +3 -1
- package/dist/identity-reset.js +27 -5
- package/dist/identity-reset.js.map +1 -1
- package/dist/index.js +31 -37
- package/dist/index.js.map +1 -1
- package/dist/ledger-pairing-client.d.ts +1 -1
- package/dist/ledger-pairing-client.js +5 -3
- package/dist/ledger-pairing-client.js.map +1 -1
- package/dist/ledger-relay.d.ts +42 -7
- package/dist/ledger-relay.js +175 -33
- package/dist/ledger-relay.js.map +1 -1
- package/dist/ledger-reoffer.d.ts +56 -0
- package/dist/ledger-reoffer.js +210 -0
- package/dist/ledger-reoffer.js.map +1 -0
- package/dist/ledger-startup.d.ts +30 -5
- package/dist/ledger-startup.js +40 -10
- package/dist/ledger-startup.js.map +1 -1
- package/dist/local-api-server.d.ts +3 -0
- package/dist/local-api-server.js +68 -6
- package/dist/local-api-server.js.map +1 -1
- package/dist/mail-delivery.d.ts +26 -3
- package/dist/mail-delivery.js +65 -7
- package/dist/mail-delivery.js.map +1 -1
- package/dist/mail-store.d.ts +15 -1
- package/dist/mail-store.js +78 -16
- package/dist/mail-store.js.map +1 -1
- package/dist/outbound-pipeline-types.d.ts +5 -2
- package/dist/outbound-pipeline-types.js.map +1 -1
- package/dist/preview-protocol.d.ts +19 -3
- package/dist/preview-protocol.js +14 -0
- package/dist/preview-protocol.js.map +1 -1
- package/dist/relay-token.d.ts +6 -0
- package/dist/relay-token.js +9 -1
- package/dist/relay-token.js.map +1 -1
- package/dist/security/bridge/ledger-rpc.d.ts +34 -0
- package/dist/security/bridge/ledger-rpc.js +58 -0
- package/dist/security/bridge/ledger-rpc.js.map +1 -0
- package/dist/security/bridge/ledger-store.d.ts +82 -13
- package/dist/security/bridge/ledger-store.js +394 -54
- package/dist/security/bridge/ledger-store.js.map +1 -1
- package/dist/security/bridge/permissions.js +2 -1
- package/dist/security/bridge/permissions.js.map +1 -1
- package/dist/security/bridge/policy.d.ts +5 -1
- package/dist/security/bridge/policy.js +17 -0
- package/dist/security/bridge/policy.js.map +1 -1
- package/dist/security/bridge/security.d.ts +148 -10
- package/dist/security/bridge/security.js +270 -65
- package/dist/security/bridge/security.js.map +1 -1
- package/dist/security/crypto.d.ts +2 -0
- package/dist/security/crypto.js +43 -4
- package/dist/security/crypto.js.map +1 -1
- package/dist/security/ledger/announce.d.ts +32 -0
- package/dist/security/ledger/announce.js +101 -0
- package/dist/security/ledger/announce.js.map +1 -0
- package/dist/security/ledger/ledger.d.ts +107 -14
- package/dist/security/ledger/ledger.js +364 -83
- package/dist/security/ledger/ledger.js.map +1 -1
- package/dist/security/ledger/proof.d.ts +12 -0
- package/dist/security/ledger/proof.js +40 -8
- package/dist/security/ledger/proof.js.map +1 -1
- package/dist/security/ledger/protocol.d.ts +14 -1
- package/dist/security/ledger/protocol.js.map +1 -1
- package/dist/session-controller.d.ts +9 -3
- package/dist/session-controller.js +120 -20
- package/dist/session-controller.js.map +1 -1
- package/dist/session-inbox-protocol.d.ts +2 -0
- package/dist/session-preview.d.ts +20 -5
- package/dist/session-preview.js +185 -37
- package/dist/session-preview.js.map +1 -1
- package/dist/session-store.d.ts +22 -0
- package/dist/session-store.js +180 -13
- package/dist/session-store.js.map +1 -1
- package/dist/sessions-commands.js +41 -7
- package/dist/sessions-commands.js.map +1 -1
- package/dist/terminal-manager.d.ts +8 -0
- package/dist/terminal-manager.js +23 -1
- package/dist/terminal-manager.js.map +1 -1
- package/dist/terminal-output.d.ts +34 -0
- package/dist/terminal-output.js +68 -0
- package/dist/terminal-output.js.map +1 -0
- package/dist/terminal-pump.d.ts +48 -5
- package/dist/terminal-pump.js +143 -20
- package/dist/terminal-pump.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/opencode-plugin/ftown.js +15 -2
- package/package.json +2 -2
- package/skills/ftown/SKILL.md +18 -7
- package/skills/ftown/references/sessions.md +35 -10
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The two read-only ledger RPCs a trusted browser sends over the encrypted command channel (CONTRACT §9, §11): `ledger_head` (this bridge's
|
|
3
|
+
* account, head and revision) and `ledger_chain` (its stored chain, in pages that fit one encrypted relay frame). Pure: request parsing and
|
|
4
|
+
* paging only. command-rpc.ts authorizes the caller (BridgeSecurityService.memberLedger) and answers.
|
|
5
|
+
*
|
|
6
|
+
* Wire (the usual command envelope; route { kind: 'command', command: <type>, requestId, sessionId: null }):
|
|
7
|
+
* ledger_head payload { bridgeId } -> data { accountId, head, revision }
|
|
8
|
+
* ledger_chain payload { bridgeId, fromRevision?: 0, limit?: 1025 } -> data { accountId, head, revision, fromRevision, records, more }
|
|
9
|
+
* records[i] is the record at revision fromRevision + i (revision 0 is the signed genesis, revision n is transitions[n - 1]), each exactly as
|
|
10
|
+
* stored ({ payload, signature }). A page holds at most `limit` records and, past its first record, at most LEDGER_CHAIN_PAGE_BYTES of
|
|
11
|
+
* record JSON; `more` says records after the page exist. head/revision are the stored tip when the page was cut.
|
|
12
|
+
*/
|
|
13
|
+
import { LEDGER_LIMITS } from '../ledger/protocol.js';
|
|
14
|
+
/** Record JSON per ledger_chain page (as the review and preview chunks): with the envelope it stays far below one relay frame. */
|
|
15
|
+
export const LEDGER_CHAIN_PAGE_BYTES = 98_304;
|
|
16
|
+
/** The largest `limit`, and its default: every record of the largest chain. */
|
|
17
|
+
export const LEDGER_CHAIN_MAX_LIMIT = LEDGER_LIMITS.maxTransitions + 1;
|
|
18
|
+
function isPayload(value) {
|
|
19
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
20
|
+
}
|
|
21
|
+
function isCount(value, min, max) {
|
|
22
|
+
return typeof value === 'number' && Number.isSafeInteger(value) && value >= min && value <= max;
|
|
23
|
+
}
|
|
24
|
+
/** ledger_head: exactly { bridgeId } naming this bridge. */
|
|
25
|
+
export function parseLedgerHeadQuery(payload, bridgeId) {
|
|
26
|
+
return isPayload(payload) && Object.keys(payload).length === 1 && payload.bridgeId === bridgeId;
|
|
27
|
+
}
|
|
28
|
+
/** ledger_chain: { bridgeId, fromRevision?, limit? } naming this bridge, nothing else; null when malformed. */
|
|
29
|
+
export function parseLedgerChainQuery(payload, bridgeId) {
|
|
30
|
+
if (!isPayload(payload) || payload.bridgeId !== bridgeId)
|
|
31
|
+
return null;
|
|
32
|
+
if (Object.keys(payload).some(key => key !== 'bridgeId' && key !== 'fromRevision' && key !== 'limit'))
|
|
33
|
+
return null;
|
|
34
|
+
const fromRevision = payload.fromRevision === undefined ? 0 : payload.fromRevision;
|
|
35
|
+
const limit = payload.limit === undefined ? LEDGER_CHAIN_MAX_LIMIT : payload.limit;
|
|
36
|
+
if (!isCount(fromRevision, 0, LEDGER_LIMITS.maxTransitions) || !isCount(limit, 1, LEDGER_CHAIN_MAX_LIMIT))
|
|
37
|
+
return null;
|
|
38
|
+
return { fromRevision, limit };
|
|
39
|
+
}
|
|
40
|
+
export function ledgerHeadAnswer(held) {
|
|
41
|
+
return { accountId: held.accountId, head: held.head, revision: held.revision };
|
|
42
|
+
}
|
|
43
|
+
/** The page of `held` that starts at query.fromRevision (empty, more false, past the tip). Never splits a record; always makes progress.
|
|
44
|
+
* `held` is only read; the page carries copies of its records. */
|
|
45
|
+
export function ledgerChainPage(held, query, maxBytes = LEDGER_CHAIN_PAGE_BYTES) {
|
|
46
|
+
const all = [held.ledger.genesis, ...held.ledger.transitions];
|
|
47
|
+
const records = [];
|
|
48
|
+
let bytes = 0;
|
|
49
|
+
for (let revision = query.fromRevision; revision < all.length && records.length < query.limit; revision++) {
|
|
50
|
+
const size = Buffer.byteLength(JSON.stringify(all[revision]), 'utf8');
|
|
51
|
+
if (records.length > 0 && bytes + size > maxBytes)
|
|
52
|
+
break;
|
|
53
|
+
records.push(structuredClone(all[revision]));
|
|
54
|
+
bytes += size;
|
|
55
|
+
}
|
|
56
|
+
return { ...ledgerHeadAnswer(held), fromRevision: query.fromRevision, records, more: query.fromRevision + records.length < all.length };
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=ledger-rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ledger-rpc.js","sourceRoot":"","sources":["../../../src/security/bridge/ledger-rpc.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LedgerRelation } from '../ledger/ledger.js';
|
|
1
2
|
import type { BridgePairLink, PairApproval } from '../ledger/pairing.js';
|
|
2
3
|
import type { Ledger, LedgerCheckpoint, LedgerTransition, Signed } from '../ledger/protocol.js';
|
|
3
4
|
export type LedgerSource = 'server' | 'relay';
|
|
@@ -7,36 +8,103 @@ export interface StickyRevocations {
|
|
|
7
8
|
deviceIds: string[];
|
|
8
9
|
bridgeIds: string[];
|
|
9
10
|
}
|
|
11
|
+
/** A valid history of this account from `source` that diverges from the stored chain and was refused. Times are wall-clock ms. */
|
|
12
|
+
export interface LedgerDivergence {
|
|
13
|
+
source: LedgerSource;
|
|
14
|
+
/** The refused chain's last head and revision (the first new head that source showed; an older refused head coming back changes nothing). */
|
|
15
|
+
otherHead: string;
|
|
16
|
+
otherRevision: number;
|
|
17
|
+
/** The revision of the last record both histories share; null when unknown (an entry written by an earlier 0.22 build). */
|
|
18
|
+
forkRevision: number | null;
|
|
19
|
+
/** A refused history from this source removes THIS bridge (status only: never a sticky entry, never an identity reset). */
|
|
20
|
+
removedOnOtherHistory: boolean;
|
|
21
|
+
/** When this source was first seen diverging (kept while it keeps diverging, also when its head moves). */
|
|
22
|
+
firstSeen: number;
|
|
23
|
+
/** When it was last seen; persisted at most every DIVERGENCE_LAST_SEEN_RESOLUTION_MS. */
|
|
24
|
+
lastSeen: number;
|
|
25
|
+
}
|
|
26
|
+
/** The last REFUSED_HEADS_PER_SOURCE refused heads per source, oldest first: a REFUSED line is logged once per head (persisted, so also
|
|
27
|
+
* across restarts and after the divergence entry was cleared). */
|
|
28
|
+
export interface RefusedHeads {
|
|
29
|
+
server: string[];
|
|
30
|
+
relay: string[];
|
|
31
|
+
}
|
|
32
|
+
/** This bridge's own keys, exactly as its add_bridge lists them (and as BridgeSecurityService's 'active' check compares them). */
|
|
33
|
+
export interface OwnBridgeKeys {
|
|
34
|
+
bridgeId: string;
|
|
35
|
+
endpointId: string;
|
|
36
|
+
endpointPublicKey: string;
|
|
37
|
+
authPublicKey: string;
|
|
38
|
+
}
|
|
10
39
|
export interface BridgeLedgerState {
|
|
11
40
|
ledger: Ledger;
|
|
12
41
|
/** The stored chain's own checkpoint (raw). Never use it for a trust decision. */
|
|
13
42
|
checkpoint: LedgerCheckpoint;
|
|
14
43
|
/** applyRevocations(checkpoint, sticky): the checkpoint for every trust decision. */
|
|
15
44
|
trusted: LedgerCheckpoint;
|
|
16
|
-
/**
|
|
45
|
+
/** The revocations of every chain this replica adopted, plus those of records an owner-chosen history discarded, plus the removals
|
|
46
|
+
* chooseLedger saw on refused histories (`seen`, C1c) except this bridge's own id. Trust only, never evidence of this bridge's removal. */
|
|
17
47
|
sticky: StickyRevocations;
|
|
18
48
|
lastServerReadAt: number | null;
|
|
49
|
+
/** At most one entry per source, ordered server first. */
|
|
50
|
+
divergences: LedgerDivergence[];
|
|
51
|
+
refused: RefusedHeads;
|
|
52
|
+
}
|
|
53
|
+
/** The last record of a chain: its revision (0 = genesis) and head (the genesis head is the accountId). */
|
|
54
|
+
export interface LedgerTip {
|
|
55
|
+
revision: number;
|
|
56
|
+
head: string;
|
|
19
57
|
}
|
|
20
58
|
export interface LedgerOfferResult {
|
|
21
59
|
decision: 'adopt' | 'keep' | 'reject';
|
|
60
|
+
/** How the candidate relates to the chain stored before the decision; null when it has none (empty store, malformed, another account). */
|
|
61
|
+
relation: LedgerRelation | null;
|
|
62
|
+
/** The candidate's tip; null when it does not parse. */
|
|
63
|
+
candidate: LedgerTip | null;
|
|
22
64
|
/** The stored state after the decision; null while the store is empty. */
|
|
23
65
|
state: BridgeLedgerState | null;
|
|
24
|
-
/** Local records
|
|
66
|
+
/** Local records an owner-chosen history (adopt + diverged) discarded; empty otherwise. */
|
|
25
67
|
discarded: Signed<LedgerTransition>[];
|
|
68
|
+
/** A diverged candidate that a resolve_fork already in OUR chain discards (the other side is behind the owner's decision): answered
|
|
69
|
+
* keep with relation 'behind' (so a server holding it gets our chain re-offered), never recorded as a divergence, never logged. */
|
|
70
|
+
covered: boolean;
|
|
26
71
|
}
|
|
27
72
|
export interface BridgeLedgerStoreOptions {
|
|
28
73
|
/** The account the bridge identity is bound to: ledgers of any other account are rejected even while the store is empty, and a
|
|
29
74
|
* stored ledger of another account throws LedgerStoreError('ledger_store_wrong_account'). */
|
|
30
75
|
accountId?: string | null;
|
|
31
76
|
now?: () => number;
|
|
77
|
+
/** The `[ledger]` lines (refused history, owner-chosen adoption, ignored chain). Defaults to console.warn. */
|
|
78
|
+
log?: (line: string) => void;
|
|
79
|
+
/** This bridge's own bridgeId. A refused history's removal of it is recorded as status only, never added to the sticky set. Without it,
|
|
80
|
+
* no bridge removal of a refused history is added to the sticky set at all (device removals still are). */
|
|
81
|
+
bridgeId?: string | null;
|
|
32
82
|
}
|
|
33
|
-
|
|
83
|
+
/** Divergence lastSeen is rewritten at most this often while the same other head keeps arriving. */
|
|
84
|
+
export declare const DIVERGENCE_LAST_SEEN_RESOLUTION_MS: number;
|
|
85
|
+
/** "ignored an invalid chain" is logged at most once per this interval per source. */
|
|
86
|
+
export declare const INVALID_CHAIN_LOG_SPACING_MS = 60000;
|
|
87
|
+
/** A REFUSED line for a head not refused before is logged at most once per this interval per source. */
|
|
88
|
+
export declare const REFUSED_LOG_SPACING_MS = 60000;
|
|
89
|
+
/** Refused heads remembered per source (persisted), and verdicts on refused chains cached per process. */
|
|
90
|
+
export declare const REFUSED_HEADS_PER_SOURCE = 16;
|
|
91
|
+
export declare const REFUSED_VERDICT_CACHE_SIZE = 16;
|
|
92
|
+
/** The first 8 characters of a head, as the log lines and the status show it. */
|
|
93
|
+
export declare const shortHead: (head: string) => string;
|
|
94
|
+
export type LedgerStoreErrorCode = 'ledger_store_corrupt' | 'ledger_store_wrong_account' | 'ledger_store_pairing_rejected' | 'ledger_store_pairing_revoked' | 'ledger_store_bound_rejected';
|
|
34
95
|
/** Not retryable; file contents and crypto errors never enter it. Read/write failures throw BridgeSecurityError('storage_unavailable'). */
|
|
35
96
|
export declare class LedgerStoreError extends Error {
|
|
36
97
|
readonly code: LedgerStoreErrorCode;
|
|
37
98
|
readonly retryable = false;
|
|
38
99
|
constructor(code: LedgerStoreErrorCode);
|
|
39
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Proof in the RAW chain `ledger` that THIS bridge was removed: an add_bridge of exactly these keys (bridgeId, endpoint id, endpoint public
|
|
103
|
+
* key and auth key), followed by a revoke_bridge of its bridgeId. A revoke_bridge of an id the chain never added with these keys is only a
|
|
104
|
+
* tombstone (C1b: revoking a non-member is valid) and proves nothing about this bridge. Sticky entries and refused histories never count:
|
|
105
|
+
* this is the only evidence that resets the identity, on a running bridge and at startup alike.
|
|
106
|
+
*/
|
|
107
|
+
export declare function ledgerRemovesBridge(ledger: Ledger, own: OwnBridgeKeys): boolean;
|
|
40
108
|
export declare class BridgeLedgerStore {
|
|
41
109
|
private readonly replica;
|
|
42
110
|
constructor(dataDir: string, options?: BridgeLedgerStoreOptions);
|
|
@@ -44,21 +112,22 @@ export declare class BridgeLedgerStore {
|
|
|
44
112
|
read(): Promise<BridgeLedgerState | null>;
|
|
45
113
|
/** applyRevocations(checkpoint, sticky) of the stored chain, or null while no ledger is stored. */
|
|
46
114
|
trusted(): Promise<LedgerCheckpoint | null>;
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
115
|
+
/** The startup decision (ledger-startup ownStatusAction): 'active' iff trusted() lists this bridge with exactly its keys; 'revoked' iff the
|
|
116
|
+
* stored RAW chain proves its removal (ledgerRemovesBridge: it added these keys, then revoked the id); else 'absent' (a tombstone, a
|
|
117
|
+
* sticky-only id or a removal seen on a refused history is no removal). The same rule as BridgeSecurityService's running check. */
|
|
118
|
+
ownBridgeStatus(own: OwnBridgeKeys): Promise<OwnBridgeStatus>;
|
|
51
119
|
/**
|
|
52
|
-
* Offers an untrusted candidate chain from the server or the relay. Never binds an empty store, and never
|
|
53
|
-
* it is rejected. Throws LedgerStoreError for a corrupted or wrong-account local file, and
|
|
54
|
-
* when the file cannot be read or written.
|
|
120
|
+
* Offers an untrusted candidate chain from the server or the relay (see decide for the rule). Never binds an empty store, and never
|
|
121
|
+
* throws for a bad candidate: it is rejected. Throws LedgerStoreError for a corrupted or wrong-account local file, and
|
|
122
|
+
* BridgeSecurityError('storage_unavailable') when the file cannot be read or written.
|
|
55
123
|
*/
|
|
56
124
|
offer(candidate: unknown, source: LedgerSource): Promise<LedgerOfferResult>;
|
|
57
125
|
/**
|
|
58
126
|
* The pairing path, after openPairApproval. Runs confirmPairedLedger(link, approval, ledger, now, sticky) with this replica's sticky
|
|
59
|
-
* set, then binds the empty store (or applies the
|
|
60
|
-
* the resulting trusted roster. Returns trusted(). Throws LedgerStoreError('
|
|
61
|
-
* pairing failure
|
|
127
|
+
* set, then binds the empty store (or applies the append-only rule to a bound store of the same account); the request's bridge must be in
|
|
128
|
+
* the resulting trusted roster. Returns trusted(). Throws LedgerStoreError('ledger_store_pairing_revoked') when the chain (or this
|
|
129
|
+
* replica's sticky set) revokes the request's bridge id, LedgerStoreError('ledger_store_pairing_rejected') on any other pairing failure;
|
|
130
|
+
* writes nothing in either case.
|
|
62
131
|
*/
|
|
63
132
|
adoptPaired(link: BridgePairLink, approval: PairApproval, ledger: unknown, now?: number): Promise<LedgerCheckpoint>;
|
|
64
133
|
/**
|