Skip to content

Commit 7bee5b5

Browse files
ersinkocclaude
andcommitted
🐛 fix(channels): resolve TypeScript errors in Channel Hub
Fix all TypeScript compilation errors in packages/gateway/src/channels/hub/: - crypto/types.ts: Export PrivacyConfig (with CryptoPrivacyConfig alias) - crypto/node-crypto.ts: Fix X25519 key generation, remove unused imports - crypto/signal-protocol.ts: Fix generateRandomBytes usage, remove unused imports - encrypted-adapter.ts: Remove implements clause (can't implement abstract class), rename handleIncomingMessage to avoid signature conflict - universal-adapter.ts: Remove unused imports and disconnectedAt field - connection-wizard.ts: Fix generateId() call with required prefix - health-monitor.ts: Remove unused HealthStatus import - types.ts: Add decryptionError field to StrippedMetadata - transport/ngrok-provider.ts: Remove unused spawn import - tunnel-service.ts: Remove unused TunnelConfig import All packages now build successfully. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 13adaed commit 7bee5b5

18 files changed

Lines changed: 4347 additions & 0 deletions

packages/gateway/src/channels/hub/connection-wizard.ts

Lines changed: 521 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/**
2+
* Signal Protocol E2E Encryption
3+
*
4+
* End-to-end encryption for Channel Hub using Signal Protocol (Double Ratchet).
5+
*
6+
* @example
7+
* ```typescript
8+
* import { createSignalProtocol, EncryptedMessage } from './crypto/index.js';
9+
*
10+
* // Create protocol instance
11+
* const signal = await createSignalProtocol();
12+
*
13+
* // Initiate session with peer
14+
* const peerBundle = await fetchPeerKeyBundle(peerId);
15+
* const session = await signal.initiateSession(peerBundle, 'peer-device-123');
16+
*
17+
* // Encrypt message
18+
* const { encrypted } = await signal.encrypt(session.sessionId, 'Hello!');
19+
*
20+
* // Decrypt message
21+
* const { plaintext } = await signal.decrypt(encryptedMessage, 'peer-device-123');
22+
* ```
23+
*/
24+
25+
// Types
26+
export type {
27+
// Core types
28+
KeyPair,
29+
IdentityKeyPair,
30+
PreKey,
31+
SignedPreKey,
32+
PublicKeyBundle,
33+
EncryptedMessage,
34+
ChainKey,
35+
MessageKey,
36+
RootKey,
37+
RatchetState,
38+
SessionState,
39+
SessionInitiation,
40+
EncryptionResult,
41+
DecryptionResult,
42+
KeyStoreConfig,
43+
SessionStore,
44+
IKeyStore,
45+
CryptoProvider,
46+
PrivacyConfig,
47+
} from './types.js';
48+
49+
// Implementations
50+
export { NodeCryptoProvider, nodeCrypto } from './node-crypto.js';
51+
export { MemoryKeyStore } from './key-store.js';
52+
export { SignalProtocol } from './signal-protocol.js';
53+
54+
// Factory function for easy setup
55+
import { NodeCryptoProvider } from './node-crypto.js';
56+
import { MemoryKeyStore } from './key-store.js';
57+
import { SignalProtocol } from './signal-protocol.js';
58+
59+
export interface SignalProtocolSetup {
60+
protocol: SignalProtocol;
61+
keyStore: MemoryKeyStore;
62+
crypto: NodeCryptoProvider;
63+
}
64+
65+
/**
66+
* Create a Signal Protocol instance with default Node.js crypto.
67+
* This is the recommended way to initialize the encryption layer.
68+
*/
69+
export async function createSignalProtocol(): Promise<SignalProtocolSetup> {
70+
const crypto = new NodeCryptoProvider();
71+
const keyStore = new MemoryKeyStore(crypto);
72+
73+
// Initialize with default pre-key count
74+
await keyStore.initialize(100);
75+
76+
const protocol = new SignalProtocol(crypto, keyStore, keyStore);
77+
78+
return { protocol, keyStore, crypto };
79+
}
80+
81+
/**
82+
* Create Signal Protocol with custom crypto provider.
83+
* For advanced use cases or hardware security modules.
84+
*/
85+
export async function createSignalProtocolWithProvider(
86+
crypto: import('./types.js').CryptoProvider
87+
): Promise<SignalProtocolSetup> {
88+
const keyStore = new MemoryKeyStore(crypto);
89+
await keyStore.initialize(100);
90+
const protocol = new SignalProtocol(crypto, keyStore, keyStore);
91+
return { protocol, keyStore, crypto };
92+
}

0 commit comments

Comments
 (0)