p2party 0.8.0 → 0.14.2
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/LICENSE.md +202 -661
- package/README.md +736 -404
- package/THIRD_PARTY_NOTICES.md +458 -0
- package/docs/assets/p2party-cat.svg +1 -0
- package/docs/getting-started.md +203 -0
- package/docs/protocol-v4-security.md +158 -0
- package/docs/references.md +157 -0
- package/docs/session-api.md +457 -0
- package/docs/wire-format.md +103 -0
- package/examples/standalone-e2ee.ts +194 -0
- package/lib/api/signalingServerApi.d.ts +6 -7
- package/lib/api/webrtc/baseQuery.d.ts +1 -2
- package/lib/api/webrtc/disconnectFromAllRoomsQuery.d.ts +1 -2
- package/lib/api/webrtc/disconnectFromChannelLabelQuery.d.ts +1 -2
- package/lib/api/webrtc/disconnectFromPeerChannelLabelQuery.d.ts +1 -2
- package/lib/api/webrtc/disconnectFromPeerQuery.d.ts +3 -3
- package/lib/api/webrtc/disconnectFromRoomQuery.d.ts +1 -2
- package/lib/api/webrtc/disconnectQuery.d.ts +1 -2
- package/lib/api/webrtc/iceGeneration.d.ts +17 -0
- package/lib/api/webrtc/iceRepair.d.ts +10 -0
- package/lib/api/webrtc/index.d.ts +13 -13
- package/lib/api/webrtc/interfaces.d.ts +67 -11
- package/lib/api/webrtc/negotiationLock.d.ts +12 -0
- package/lib/api/webrtc/openChannelQuery.d.ts +1 -2
- package/lib/api/webrtc/pendingIceCandidates.d.ts +14 -0
- package/lib/api/webrtc/roomPeer.d.ts +11 -0
- package/lib/api/webrtc/sendMessageQuery.d.ts +7 -4
- package/lib/api/webrtc/setCandidateQuery.d.ts +1 -2
- package/lib/api/webrtc/setDescriptionQuery.d.ts +1 -2
- package/lib/cryptography/coverCell.d.ts +65 -0
- package/lib/cryptography/cpace.d.ts +41 -0
- package/lib/cryptography/ed25519.d.ts +0 -1
- package/lib/cryptography/hashStream.d.ts +15 -0
- package/lib/cryptography/hkdf.d.ts +3 -0
- package/lib/cryptography/identityCrossSig.d.ts +7 -0
- package/lib/cryptography/interfaces.d.ts +28 -13
- package/lib/cryptography/memory.d.ts +2 -4
- package/lib/cryptography/merkle.d.ts +0 -1
- package/lib/cryptography/mlkem.d.ts +117 -0
- package/lib/cryptography/mnemonic.d.ts +0 -1
- package/lib/cryptography/pqHealing.d.ts +268 -0
- package/lib/cryptography/pqHealingFrame.d.ts +39 -0
- package/lib/cryptography/pqMessageKey.d.ts +30 -0
- package/lib/cryptography/random.d.ts +22 -0
- package/lib/cryptography/ratchet.d.ts +146 -0
- package/lib/cryptography/testModule.d.ts +7 -0
- package/lib/cryptography/utils.d.ts +0 -1
- package/lib/cryptography/wasmLoader.d.ts +6 -1
- package/lib/cryptography/x25519.d.ts +15 -0
- package/lib/cryptography/x3dh.d.ts +9 -0
- package/lib/db/api.d.ts +54 -22
- package/lib/db/db.worker.d.ts +0 -1
- package/lib/db/ratchetWrap.d.ts +36 -0
- package/lib/db/src/getDB.d.ts +17 -4
- package/lib/db/types.d.ts +274 -32
- package/lib/db.worker.js +1 -2
- package/lib/handlers/chunkFrame.d.ts +13 -0
- package/lib/handlers/connectionSignal.d.ts +26 -0
- package/lib/handlers/coverEdge.d.ts +42 -0
- package/lib/handlers/coverRuntime.d.ts +91 -0
- package/lib/handlers/coverScheduler.d.ts +184 -0
- package/lib/handlers/coverTransfer.d.ts +46 -0
- package/lib/handlers/frameType.d.ts +10 -0
- package/lib/handlers/handleChallenge.d.ts +0 -1
- package/lib/handlers/handleConnectToPeer.d.ts +0 -1
- package/lib/handlers/handleHandshake.d.ts +74 -0
- package/lib/handlers/handleMessageQueueing.d.ts +53 -4
- package/lib/handlers/handleOpenChannel.d.ts +4 -2
- package/lib/handlers/handleQueuedIceCandidates.d.ts +0 -1
- package/lib/handlers/handleReadReceipt.d.ts +17 -4
- package/lib/handlers/handleReceiveMessage.d.ts +21 -3
- package/lib/handlers/handleSendMessage.d.ts +110 -2
- package/lib/handlers/handleWebSocketMessage.d.ts +1 -3
- package/lib/handlers/handshakeCore.d.ts +95 -0
- package/lib/handlers/messageChunkCrypto.d.ts +70 -0
- package/lib/handlers/peerRosterDelta.d.ts +12 -0
- package/lib/handlers/pqHealingOrchestrator.d.ts +46 -0
- package/lib/handlers/pqHealingRuntime.d.ts +82 -0
- package/lib/handlers/ratchetGate.d.ts +18 -0
- package/lib/handlers/ratchetPersist.d.ts +53 -0
- package/lib/handlers/receiptFrame.d.ts +18 -0
- package/lib/handlers/receiveMessageKeyLifetime.d.ts +24 -0
- package/lib/handlers/reconcile.d.ts +16 -0
- package/lib/handlers/transferAbort.d.ts +42 -0
- package/lib/index.d.ts +203 -46
- package/lib/index.js +1 -2
- package/lib/index.min.js +1 -2
- package/lib/index.mjs +1 -2
- package/lib/libcrypto.provenance.json +45 -0
- package/lib/libcrypto.wasm +0 -0
- package/lib/middleware/keyPairListenerMiddleware.d.ts +0 -1
- package/lib/middleware/roomListenerMiddleware.d.ts +0 -1
- package/lib/reducers/commonSlice.d.ts +0 -1
- package/lib/reducers/keyPairSlice.d.ts +0 -1
- package/lib/reducers/roomSlice.d.ts +65 -3
- package/lib/reducers/signalingServerSlice.d.ts +25 -4
- package/lib/roomInvite.d.ts +18 -0
- package/lib/roomPinAttempts.d.ts +12 -0
- package/lib/roomPinVault.d.ts +26 -0
- package/lib/roomPolicy.d.ts +60 -0
- package/lib/session.d.ts +110 -0
- package/lib/session.js +1 -0
- package/lib/session.mjs +1 -0
- package/lib/store.d.ts +40 -41
- package/lib/utils/channelLabel.d.ts +0 -1
- package/lib/utils/chunkBounds.d.ts +9 -0
- package/lib/utils/constants.d.ts +50 -6
- package/lib/utils/debug.d.ts +25 -0
- package/lib/utils/drainAndClose.d.ts +5 -0
- package/lib/utils/identityRole.d.ts +19 -0
- package/lib/utils/interfaces.d.ts +31 -43
- package/lib/utils/leafHash.d.ts +13 -0
- package/lib/utils/messageTypes.d.ts +0 -1
- package/lib/utils/metadata.d.ts +6 -1
- package/lib/utils/mutex.d.ts +24 -0
- package/lib/utils/protocolVersion.d.ts +5 -0
- package/lib/utils/receiptToken.d.ts +7 -0
- package/lib/utils/sendQueueKey.d.ts +2 -0
- package/lib/utils/signalingAuth.d.ts +8 -0
- package/lib/utils/signalingBounds.d.ts +9 -0
- package/lib/utils/splitToChunks.d.ts +7 -4
- package/lib/utils/uint8array.d.ts +1 -2
- package/lib/utils/waitForOpen.d.ts +3 -0
- package/lib/utils/zeroFree.d.ts +10 -0
- package/package.json +109 -49
- package/lib/api/signalingServerApi.d.ts.map +0 -1
- package/lib/api/webrtc/baseQuery.d.ts.map +0 -1
- package/lib/api/webrtc/disconnectFromAllRoomsQuery.d.ts.map +0 -1
- package/lib/api/webrtc/disconnectFromChannelLabelQuery.d.ts.map +0 -1
- package/lib/api/webrtc/disconnectFromPeerChannelLabelQuery.d.ts.map +0 -1
- package/lib/api/webrtc/disconnectFromPeerQuery.d.ts.map +0 -1
- package/lib/api/webrtc/disconnectFromRoomQuery.d.ts.map +0 -1
- package/lib/api/webrtc/disconnectQuery.d.ts.map +0 -1
- package/lib/api/webrtc/index.d.ts.map +0 -1
- package/lib/api/webrtc/interfaces.d.ts.map +0 -1
- package/lib/api/webrtc/openChannelQuery.d.ts.map +0 -1
- package/lib/api/webrtc/sendMessageQuery.d.ts.map +0 -1
- package/lib/api/webrtc/setCandidateQuery.d.ts.map +0 -1
- package/lib/api/webrtc/setDescriptionQuery.d.ts.map +0 -1
- package/lib/cryptography/chacha20poly1305.d.ts +0 -116
- package/lib/cryptography/chacha20poly1305.d.ts.map +0 -1
- package/lib/cryptography/ed25519.d.ts.map +0 -1
- package/lib/cryptography/interfaces.d.ts.map +0 -1
- package/lib/cryptography/memory.d.ts.map +0 -1
- package/lib/cryptography/merkle.d.ts.map +0 -1
- package/lib/cryptography/mnemonic.d.ts.map +0 -1
- package/lib/cryptography/utils.d.ts.map +0 -1
- package/lib/cryptography/wasmLoader.d.ts.map +0 -1
- package/lib/db/api.d.ts.map +0 -1
- package/lib/db/db.worker.d.ts.map +0 -1
- package/lib/db/src/getDB.d.ts.map +0 -1
- package/lib/db/types.d.ts.map +0 -1
- package/lib/db.worker.js.map +0 -1
- package/lib/handlers/handleChallenge.d.ts.map +0 -1
- package/lib/handlers/handleConnectToPeer.d.ts.map +0 -1
- package/lib/handlers/handleMessageQueueing.d.ts.map +0 -1
- package/lib/handlers/handleOpenChannel.d.ts.map +0 -1
- package/lib/handlers/handleQueuedIceCandidates.d.ts.map +0 -1
- package/lib/handlers/handleReadReceipt.d.ts.map +0 -1
- package/lib/handlers/handleReceiveMessage.d.ts.map +0 -1
- package/lib/handlers/handleSendMessage.d.ts.map +0 -1
- package/lib/handlers/handleWebSocketMessage.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/index.min.js.map +0 -1
- package/lib/index.mjs.map +0 -1
- package/lib/middleware/keyPairListenerMiddleware.d.ts.map +0 -1
- package/lib/middleware/roomListenerMiddleware.d.ts.map +0 -1
- package/lib/reducers/commonSlice.d.ts.map +0 -1
- package/lib/reducers/keyPairSlice.d.ts.map +0 -1
- package/lib/reducers/roomSlice.d.ts.map +0 -1
- package/lib/reducers/signalingServerSlice.d.ts.map +0 -1
- package/lib/store.d.ts.map +0 -1
- package/lib/utils/allocators.d.ts +0 -22
- package/lib/utils/allocators.d.ts.map +0 -1
- package/lib/utils/channelLabel.d.ts.map +0 -1
- package/lib/utils/constants.d.ts.map +0 -1
- package/lib/utils/interfaces.d.ts.map +0 -1
- package/lib/utils/messageTypes.d.ts.map +0 -1
- package/lib/utils/metadata.d.ts.map +0 -1
- package/lib/utils/splitToChunks.d.ts.map +0 -1
- package/lib/utils/uint8array.d.ts.map +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"sources": {
|
|
4
|
+
"libsodium": {
|
|
5
|
+
"releaseLine": "1.0.22-stable",
|
|
6
|
+
"commit": "2ce4d906a68eae82b27b4867f3d4172ec508cb27",
|
|
7
|
+
"tree": "2dabe17c708edd7334e3316b5094b753859395d9",
|
|
8
|
+
"extraction": "git-archive",
|
|
9
|
+
"configuredBuild": true
|
|
10
|
+
},
|
|
11
|
+
"mlkemNative": {
|
|
12
|
+
"release": "v1.2.0",
|
|
13
|
+
"commit": "0ba906cb14b1c241476134d7403a811b382ca498",
|
|
14
|
+
"sourceTreeSha256": "a2e15382a8dc0207752b3f5cdfc907886505fe304948183b4b61e99e7cb92ac6",
|
|
15
|
+
"wrapperSha256": "181160a16f22e30eafc85d7be7a3be47be41026da14b0488f120ededc36ea072",
|
|
16
|
+
"backend": "portable-c",
|
|
17
|
+
"parameterSets": [
|
|
18
|
+
512,
|
|
19
|
+
768,
|
|
20
|
+
1024
|
|
21
|
+
],
|
|
22
|
+
"multilevel": {
|
|
23
|
+
"shared": 768,
|
|
24
|
+
"noShared": [
|
|
25
|
+
512,
|
|
26
|
+
1024
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"toolchain": {
|
|
32
|
+
"emscripten": "6.0.3"
|
|
33
|
+
},
|
|
34
|
+
"build": {
|
|
35
|
+
"mode": "production",
|
|
36
|
+
"linkTimeOptimization": false,
|
|
37
|
+
"publicSodiumApi": true
|
|
38
|
+
},
|
|
39
|
+
"artifact": {
|
|
40
|
+
"file": "libcrypto.wasm",
|
|
41
|
+
"bytes": 209081,
|
|
42
|
+
"sha256": "7eea31157e69ac61f3a512b624d5c210296302fd289fc2b65c63ecc31a056267",
|
|
43
|
+
"sri": "sha384-pBMyUqQ3KBztxgeJMgDFZeohfj9QlAFNwt4/gRlqT0vlZ2kbkKxv+q5DwbZOBuUP"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
Binary file
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
declare const keyPairListenerMiddleware: import("@reduxjs/toolkit").ListenerMiddlewareInstance<unknown, import("redux-thunk").ThunkDispatch<unknown, unknown, import("redux").UnknownAction>, unknown>;
|
|
2
2
|
export default keyPairListenerMiddleware;
|
|
3
|
-
//# sourceMappingURL=keyPairListenerMiddleware.d.ts.map
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
declare const roomListenerMiddleware: import("@reduxjs/toolkit").ListenerMiddlewareInstance<unknown, import("redux-thunk").ThunkDispatch<unknown, unknown, import("redux").UnknownAction>, unknown>;
|
|
2
2
|
export default roomListenerMiddleware;
|
|
3
|
-
//# sourceMappingURL=roomListenerMiddleware.d.ts.map
|
|
@@ -6,4 +6,3 @@ export declare const setCurrentRoomUrl: import("@reduxjs/toolkit").ActionCreator
|
|
|
6
6
|
export declare const commonStateSelector: (state: State) => CommonState;
|
|
7
7
|
declare const _default: import("redux").Reducer<CommonState>;
|
|
8
8
|
export default _default;
|
|
9
|
-
//# sourceMappingURL=commonSlice.d.ts.map
|
|
@@ -30,4 +30,3 @@ export declare const setKeyPair: import("@reduxjs/toolkit").ActionCreatorWithPay
|
|
|
30
30
|
export declare const keyPairSelector: (state: State) => KeyPair;
|
|
31
31
|
declare const _default: import("redux").Reducer<KeyPair>;
|
|
32
32
|
export default _default;
|
|
33
|
-
//# sourceMappingURL=keyPairSlice.d.ts.map
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { State } from "../store";
|
|
2
|
+
import type { RoomPolicyV1 } from "../roomPolicy";
|
|
3
|
+
import type { CoverSchedulerStatus } from "../handlers/coverScheduler";
|
|
2
4
|
export interface Channel {
|
|
3
5
|
label: string;
|
|
4
6
|
peerIds: string[];
|
|
@@ -8,6 +10,8 @@ export interface Peer {
|
|
|
8
10
|
peerPublicKey: string;
|
|
9
11
|
}
|
|
10
12
|
export interface Message {
|
|
13
|
+
/** Sender-only random identity for one logical outbound transfer. */
|
|
14
|
+
transferId?: string;
|
|
11
15
|
merkleRootHex: string;
|
|
12
16
|
sha512Hex: string;
|
|
13
17
|
fromPeerId: string;
|
|
@@ -19,6 +23,16 @@ export interface Message {
|
|
|
19
23
|
totalChunks: number;
|
|
20
24
|
channelLabel: string;
|
|
21
25
|
timestamp: number;
|
|
26
|
+
chunksReceivedTotal?: number;
|
|
27
|
+
chunksReceivedReal?: number;
|
|
28
|
+
retransmits?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface IncrementMessageStatsArgs {
|
|
31
|
+
roomId: string;
|
|
32
|
+
merkleRootHex?: string;
|
|
33
|
+
sha512Hex?: string;
|
|
34
|
+
real?: boolean;
|
|
35
|
+
retransmit?: boolean;
|
|
22
36
|
}
|
|
23
37
|
export interface SetRoomArgs {
|
|
24
38
|
url: string;
|
|
@@ -26,6 +40,12 @@ export interface SetRoomArgs {
|
|
|
26
40
|
canBeConnectionRelay?: boolean;
|
|
27
41
|
onlyConnectWithKnownPeers?: boolean;
|
|
28
42
|
rtcConfig?: RTCConfiguration;
|
|
43
|
+
/** Public/authenticated room settings only. PIN bytes never enter Redux. */
|
|
44
|
+
policy?: RoomPolicyV1;
|
|
45
|
+
}
|
|
46
|
+
export interface SetRoomPolicyArgs {
|
|
47
|
+
roomContext: string;
|
|
48
|
+
policy: RoomPolicyV1;
|
|
29
49
|
}
|
|
30
50
|
export interface SetPeerArgs extends Peer {
|
|
31
51
|
roomId: string;
|
|
@@ -36,6 +56,7 @@ export interface SetIceServersArgs {
|
|
|
36
56
|
}
|
|
37
57
|
export interface SetMessageArgs {
|
|
38
58
|
roomId: string;
|
|
59
|
+
transferId?: string;
|
|
39
60
|
merkleRootHex: string;
|
|
40
61
|
sha512Hex: string;
|
|
41
62
|
chunkSize: number;
|
|
@@ -50,6 +71,7 @@ export interface SetMessageArgs {
|
|
|
50
71
|
}
|
|
51
72
|
export interface SetMessageAllChunksArgs {
|
|
52
73
|
roomId: string;
|
|
74
|
+
transferId?: string;
|
|
53
75
|
merkleRootHex: string;
|
|
54
76
|
sha512Hex: string;
|
|
55
77
|
fromPeerId: string;
|
|
@@ -73,10 +95,13 @@ export interface SetChannelArgs {
|
|
|
73
95
|
label: string;
|
|
74
96
|
}
|
|
75
97
|
export interface DeleteMessageArgs {
|
|
98
|
+
roomId: string;
|
|
99
|
+
transferId?: string;
|
|
76
100
|
merkleRootHex?: string;
|
|
77
101
|
hashHex?: string;
|
|
78
102
|
}
|
|
79
103
|
export interface DeleteChannelArgs {
|
|
104
|
+
roomId?: string;
|
|
80
105
|
peerId?: string;
|
|
81
106
|
label?: string;
|
|
82
107
|
}
|
|
@@ -84,7 +109,30 @@ export interface SetCanOnlyConnectWithKnownPeers {
|
|
|
84
109
|
roomId: string;
|
|
85
110
|
onlyConnectWithKnownPeers: boolean;
|
|
86
111
|
}
|
|
112
|
+
export interface SetPeerCoverStatusArgs {
|
|
113
|
+
roomId: string;
|
|
114
|
+
peerId: string;
|
|
115
|
+
status: CoverSchedulerStatus;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Why the authenticated edge is not (yet) up. "pin-mismatch" also covers a
|
|
119
|
+
* differing room policy on a PIN room — the confirmation transcript cannot
|
|
120
|
+
* distinguish them; "policy" is a nopin-room confirmation failure, which can
|
|
121
|
+
* only be a policy/transcript mismatch.
|
|
122
|
+
*/
|
|
123
|
+
export type PeerHandshakeFailureReason = "pin-mismatch" | "pin-throttled" | "policy" | "transport";
|
|
124
|
+
export interface PeerHandshakeStatus {
|
|
125
|
+
status: "authenticating" | "authenticated" | "failed";
|
|
126
|
+
reason?: PeerHandshakeFailureReason;
|
|
127
|
+
/** Absolute epoch ms after which a throttled PIN retry may succeed. */
|
|
128
|
+
retryAfter?: number;
|
|
129
|
+
}
|
|
130
|
+
export interface SetPeerHandshakeStatusArgs extends PeerHandshakeStatus {
|
|
131
|
+
roomId: string;
|
|
132
|
+
peerId: string;
|
|
133
|
+
}
|
|
87
134
|
export interface Room extends SetRoomArgs {
|
|
135
|
+
policy: RoomPolicyV1;
|
|
88
136
|
connectingToPeers: boolean;
|
|
89
137
|
connectedToPeers: boolean;
|
|
90
138
|
canBeConnectionRelay: boolean;
|
|
@@ -93,9 +141,23 @@ export interface Room extends SetRoomArgs {
|
|
|
93
141
|
peers: Peer[];
|
|
94
142
|
channels: Channel[];
|
|
95
143
|
messages: Message[];
|
|
144
|
+
/**
|
|
145
|
+
* protocol-v4: live scheduled-cover status per authenticated peer edge
|
|
146
|
+
* (peerId → status). Absent means no cover claim may ever be made for that
|
|
147
|
+
* edge — only an explicit "active" from the runtime is a cover claim, so a
|
|
148
|
+
* browser gap ("suspended") or teardown ("stopped") is always visible.
|
|
149
|
+
*/
|
|
150
|
+
coverStatusByPeer?: Record<string, CoverSchedulerStatus>;
|
|
151
|
+
/**
|
|
152
|
+
* Live authenticated-handshake state per peer edge (peerId → status), so a
|
|
153
|
+
* UI can distinguish "still authenticating" from "PIN did not match" from
|
|
154
|
+
* "PIN retries throttled until T" instead of showing an eternal
|
|
155
|
+
* waiting-for-peers state.
|
|
156
|
+
*/
|
|
157
|
+
handshakeStatusByPeer?: Record<string, PeerHandshakeStatus>;
|
|
96
158
|
}
|
|
97
159
|
export declare const defaultRTCConfig: RTCConfiguration;
|
|
98
|
-
export declare const setRoom: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetRoomArgs, "rooms/setRoom">, setConnectingToPeers: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
160
|
+
export declare const setRoom: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetRoomArgs, "rooms/setRoom">, setRoomPolicy: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetRoomPolicyArgs, "rooms/setRoomPolicy">, setConnectingToPeers: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
99
161
|
roomId: string;
|
|
100
162
|
connectingToPeers: boolean;
|
|
101
163
|
}, "rooms/setConnectingToPeers">, setConnectedToPeers: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
@@ -104,10 +166,10 @@ export declare const setRoom: import("@reduxjs/toolkit").ActionCreatorWithPayloa
|
|
|
104
166
|
}, "rooms/setConnectedToPeers">, setConnectionRelay: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
105
167
|
roomId: string;
|
|
106
168
|
canBeConnectionRelay: boolean;
|
|
107
|
-
}, "rooms/setConnectionRelay">, setOnlyConnectWithKnownPeers: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetCanOnlyConnectWithKnownPeers, "rooms/setOnlyConnectWithKnownPeers">, setPeer: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetPeerArgs, "rooms/setPeer">, setChannel: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetChannelArgs, "rooms/setChannel">, setIceServers: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetIceServersArgs, "rooms/setIceServers">, setMessage: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetMessageArgs, "rooms/setMessage">, setMessageAllChunks: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetMessageAllChunksArgs, "rooms/setMessageAllChunks">, deletePeer: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
169
|
+
}, "rooms/setConnectionRelay">, setOnlyConnectWithKnownPeers: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetCanOnlyConnectWithKnownPeers, "rooms/setOnlyConnectWithKnownPeers">, setPeer: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetPeerArgs, "rooms/setPeer">, setPeerCoverStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetPeerCoverStatusArgs, "rooms/setPeerCoverStatus">, setPeerHandshakeStatus: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetPeerHandshakeStatusArgs, "rooms/setPeerHandshakeStatus">, setChannel: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetChannelArgs, "rooms/setChannel">, setIceServers: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetIceServersArgs, "rooms/setIceServers">, setMessage: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetMessageArgs, "rooms/setMessage">, setMessageAllChunks: import("@reduxjs/toolkit").ActionCreatorWithPayload<SetMessageAllChunksArgs, "rooms/setMessageAllChunks">, incrementMessageStats: import("@reduxjs/toolkit").ActionCreatorWithPayload<IncrementMessageStatsArgs, "rooms/incrementMessageStats">, deletePeer: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
108
170
|
peerId: string;
|
|
171
|
+
roomId?: string;
|
|
109
172
|
}, "rooms/deletePeer">, deleteChannel: import("@reduxjs/toolkit").ActionCreatorWithPayload<DeleteChannelArgs, "rooms/deleteChannel">, deleteMessage: import("@reduxjs/toolkit").ActionCreatorWithPayload<DeleteMessageArgs, "rooms/deleteMessage">, deleteRoom: import("@reduxjs/toolkit").ActionCreatorWithPayload<string, "rooms/deleteRoom">;
|
|
110
173
|
export declare const roomSelector: (state: State) => Room[];
|
|
111
174
|
declare const _default: import("redux").Reducer<Room[]>;
|
|
112
175
|
export default _default;
|
|
113
|
-
//# sourceMappingURL=roomSlice.d.ts.map
|
|
@@ -3,14 +3,35 @@ import type { State } from "../store";
|
|
|
3
3
|
export interface SignalingState {
|
|
4
4
|
isEstablishingConnection: boolean;
|
|
5
5
|
isConnected: boolean;
|
|
6
|
+
isVerified: boolean;
|
|
6
7
|
serverUrl: string;
|
|
7
8
|
}
|
|
8
9
|
export declare const signalingServerActions: import("@reduxjs/toolkit").CaseReducerActions<{
|
|
9
|
-
startConnecting: (state:
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
startConnecting: (state: {
|
|
11
|
+
isEstablishingConnection: boolean;
|
|
12
|
+
isConnected: boolean;
|
|
13
|
+
isVerified: boolean;
|
|
14
|
+
serverUrl: string;
|
|
15
|
+
}, action: PayloadAction<string | undefined>) => void;
|
|
16
|
+
connectionEstablished: (state: {
|
|
17
|
+
isEstablishingConnection: boolean;
|
|
18
|
+
isConnected: boolean;
|
|
19
|
+
isVerified: boolean;
|
|
20
|
+
serverUrl: string;
|
|
21
|
+
}) => void;
|
|
22
|
+
connectionVerified: (state: {
|
|
23
|
+
isEstablishingConnection: boolean;
|
|
24
|
+
isConnected: boolean;
|
|
25
|
+
isVerified: boolean;
|
|
26
|
+
serverUrl: string;
|
|
27
|
+
}) => void;
|
|
28
|
+
disconnect: (state: {
|
|
29
|
+
isEstablishingConnection: boolean;
|
|
30
|
+
isConnected: boolean;
|
|
31
|
+
isVerified: boolean;
|
|
32
|
+
serverUrl: string;
|
|
33
|
+
}) => void;
|
|
12
34
|
}, "signalingServer">;
|
|
13
35
|
export declare const signalingServerSelector: (state: State) => SignalingState;
|
|
14
36
|
declare const _default: import("redux").Reducer<SignalingState>;
|
|
15
37
|
export default _default;
|
|
16
|
-
//# sourceMappingURL=signalingServerSlice.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const ROOM_CAPABILITY_BYTES = 32;
|
|
2
|
+
export declare const ROOM_CAPABILITY_HEX_CHARS: number;
|
|
3
|
+
export declare const ROOM_CAPABILITY_BASE64URL_CHARS = 43;
|
|
4
|
+
export declare const ROOM_INVITE_WORDS = 24;
|
|
5
|
+
export declare const ROOM_INVITE_VERSION = 1;
|
|
6
|
+
export declare const ROOM_INVITE_PREFIX: string;
|
|
7
|
+
export declare const ROOM_INVITE_WORDLIST_ID = "p2party-invite-en-v1";
|
|
8
|
+
export declare const generateRoomCapability: () => Uint8Array;
|
|
9
|
+
export declare const encodeRoomCapabilityBase64Url: (capability: Uint8Array) => string;
|
|
10
|
+
export declare const decodeRoomCapabilityBase64Url: (encoded: string) => Uint8Array;
|
|
11
|
+
/** Accept the compact representation or the legacy hex migration form. */
|
|
12
|
+
export declare const decodeRoomCapability: (encoded: string) => Uint8Array;
|
|
13
|
+
/** Canonical internal/server representation while the legacy signaling path exists. */
|
|
14
|
+
export declare const normalizeRoomCapability: (encoded: string) => string;
|
|
15
|
+
export declare const encodeRoomInviteFragment: (capability: Uint8Array) => string;
|
|
16
|
+
export declare const decodeRoomInviteFragment: (fragment: string) => Uint8Array;
|
|
17
|
+
export declare const encodeRoomCapabilityWords: (capability: Uint8Array) => Promise<string>;
|
|
18
|
+
export declare const decodeRoomCapabilityWords: (encoded: string) => Promise<Uint8Array>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const MAX_PIN_ATTEMPTS = 3;
|
|
2
|
+
export declare const PIN_BACKOFF_BASE_MS = 500;
|
|
3
|
+
export declare const PIN_BACKOFF_MAX_MS: number;
|
|
4
|
+
export declare const ROOM_PIN_FAILURE_WINDOW_MS: number;
|
|
5
|
+
export declare const MAX_ROOM_PIN_FAILURES_PER_WINDOW = 30;
|
|
6
|
+
export declare const assertRoomPinAggregateAllowed: (roomId: string, now?: number) => void;
|
|
7
|
+
export declare const recordRoomPinAggregateFailure: (roomId: string, now?: number) => void;
|
|
8
|
+
export declare const clearRoomPinAggregateFailures: (roomId: string) => void;
|
|
9
|
+
export declare const pinBackoffMs: (failures: number) => number;
|
|
10
|
+
export declare const assertPinAttemptAllowed: (roomId: string, peerIdentityEd25519: string, now?: number) => Promise<void>;
|
|
11
|
+
export declare const recordPinFailure: (roomId: string, peerIdentityEd25519: string, now?: number) => Promise<void>;
|
|
12
|
+
export declare const clearPinAttempts: (roomId: string, peerIdentityEd25519?: string) => Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
type PinZeroizer = (pin: Uint8Array) => void;
|
|
2
|
+
/**
|
|
3
|
+
* In-memory-only PIN owner. The production instance below is module-scoped;
|
|
4
|
+
* this class is exported only so its copy/zeroization contract can be tested
|
|
5
|
+
* without exposing the production map.
|
|
6
|
+
*
|
|
7
|
+
* No Redux, database, localStorage, logging, or serialization path touches
|
|
8
|
+
* these bytes. Callers receive copies and should wipe them after handshake use.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare class TransientRoomPinVault {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(zeroize?: PinZeroizer);
|
|
15
|
+
put(roomContext: string, pin: Uint8Array): void;
|
|
16
|
+
get(roomContext: string): Uint8Array | undefined;
|
|
17
|
+
has(roomContext: string): boolean;
|
|
18
|
+
delete(roomContext: string): boolean;
|
|
19
|
+
clear(): void;
|
|
20
|
+
}
|
|
21
|
+
export declare const putRoomPin: (roomContext: string, pin: Uint8Array) => void;
|
|
22
|
+
export declare const getRoomPin: (roomContext: string) => Uint8Array | undefined;
|
|
23
|
+
export declare const hasRoomPin: (roomContext: string) => boolean;
|
|
24
|
+
export declare const deleteRoomPin: (roomContext: string) => boolean;
|
|
25
|
+
export declare const clearRoomPins: () => void;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { RatchetRootSuite } from "./utils/constants";
|
|
2
|
+
/**
|
|
3
|
+
* Canonical, non-secret room policy descriptor.
|
|
4
|
+
*
|
|
5
|
+
* The PIN is deliberately not a field: only the fact that CPace/PIN
|
|
6
|
+
* authentication is required is authenticated with the policy. PIN bytes live
|
|
7
|
+
* exclusively in the transient roomPinVault module.
|
|
8
|
+
*/
|
|
9
|
+
export type RoomAuthMode = "nopin" | "pin";
|
|
10
|
+
/**
|
|
11
|
+
* The room creator fixes one authenticated hybrid bootstrap suite for every
|
|
12
|
+
* edge in the room. Peers never negotiate, downgrade, or fall back: a policy
|
|
13
|
+
* mismatch changes the transcript and makes the handshake fail closed.
|
|
14
|
+
*/
|
|
15
|
+
export type RoomPqMode = "hybrid-mlkem512" | "hybrid-mlkem768" | "hybrid-mlkem1024";
|
|
16
|
+
export type RoomRendezvousMode = "legacy-signaling" | "opaque-token" | "blind-meeting-point";
|
|
17
|
+
export type RoomCoverMode = "immediate" | "scheduled";
|
|
18
|
+
export declare const roomPqModeToParameterSet: (mode: RoomPqMode) => 512 | 768 | 1024;
|
|
19
|
+
export declare const roomPqModeToRootSuite: (mode: RoomPqMode) => RatchetRootSuite;
|
|
20
|
+
export declare const rootSuiteToRoomPqMode: (suite: RatchetRootSuite) => RoomPqMode;
|
|
21
|
+
export interface RoomPolicyV1 {
|
|
22
|
+
version: 1;
|
|
23
|
+
revision: number;
|
|
24
|
+
wireVersion: 4;
|
|
25
|
+
authMode: RoomAuthMode;
|
|
26
|
+
pqMode: RoomPqMode;
|
|
27
|
+
rendezvousMode: RoomRendezvousMode;
|
|
28
|
+
coverMode: RoomCoverMode;
|
|
29
|
+
coverCadenceMs: number;
|
|
30
|
+
coverLanes: number;
|
|
31
|
+
coverFramesPerCell: number;
|
|
32
|
+
coverDurationEpochs: number;
|
|
33
|
+
}
|
|
34
|
+
export declare const ROOM_POLICY_V1_ENCODED_LEN = 32;
|
|
35
|
+
export declare const ROOM_POLICY_V1_HASH_LEN = 32;
|
|
36
|
+
export declare const MIN_COVER_CADENCE_MS = 1000;
|
|
37
|
+
export declare const MAX_COVER_CADENCE_MS = 3600000;
|
|
38
|
+
export declare const MAX_COVER_LANES = 16;
|
|
39
|
+
export declare const MAX_COVER_FRAMES_PER_CELL = 1024;
|
|
40
|
+
export declare const MIN_COVER_SLOT_MS = 25;
|
|
41
|
+
export declare const validateRoomPolicyV1: (policy: RoomPolicyV1) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Fixed-width V1 wire form (all integers big-endian):
|
|
44
|
+
*
|
|
45
|
+
* magic(4) | format(1) | wire(1) | auth(1) | pq(1) |
|
|
46
|
+
* rendezvous(1) | cover(1) | revision(4) | cadence_ms(4) |
|
|
47
|
+
* lanes(2) | frames_per_cell(2) | duration_epochs(2) | reserved_zero(8)
|
|
48
|
+
*/
|
|
49
|
+
export declare const encodeRoomPolicyV1: (policy: RoomPolicyV1) => Uint8Array;
|
|
50
|
+
export declare const decodeRoomPolicyV1: (encoded: Uint8Array) => RoomPolicyV1;
|
|
51
|
+
/** Validate and return a detached plain-object copy suitable for Redux state. */
|
|
52
|
+
export declare const canonicalizeRoomPolicyV1: (policy: RoomPolicyV1) => RoomPolicyV1;
|
|
53
|
+
export declare const roomPoliciesEqualV1: (left: RoomPolicyV1, right: RoomPolicyV1) => boolean;
|
|
54
|
+
/** SHA-256(domain || canonical fixed-width policy); suitable for transcript CI. */
|
|
55
|
+
export declare const hashRoomPolicyV1: (policy: RoomPolicyV1) => Promise<Uint8Array>;
|
|
56
|
+
/**
|
|
57
|
+
* Current v3 behavior: no PIN, mandatory hybrid ML-KEM-768, legacy
|
|
58
|
+
* signaling rendezvous, and immediate/no-cover delivery.
|
|
59
|
+
*/
|
|
60
|
+
export declare const DEFAULT_ROOM_POLICY_V1: Readonly<RoomPolicyV1>;
|
package/lib/session.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type HandshakeTransport } from "./handlers/handshakeCore";
|
|
2
|
+
import { PROTOCOL_VERSION, WIRE_CHUNK_FRAME_LEN } from "./utils/constants";
|
|
3
|
+
import type { RoomPqMode } from "./roomPolicy";
|
|
4
|
+
export type { HandshakeTransport };
|
|
5
|
+
export type { RoomPqMode } from "./roomPolicy";
|
|
6
|
+
/**
|
|
7
|
+
* The wire constants a caller needs to build its own outer framing. The
|
|
8
|
+
* session hands back opaque fixed-size frames and expects the same back, so an
|
|
9
|
+
* adapter has to length-check and version-check records itself; re-exporting
|
|
10
|
+
* these keeps it from hardcoding values that a wire break would silently
|
|
11
|
+
* invalidate.
|
|
12
|
+
*/
|
|
13
|
+
export { PROTOCOL_VERSION, WIRE_CHUNK_FRAME_LEN };
|
|
14
|
+
export interface LocalSessionIdentity {
|
|
15
|
+
ed25519PublicKey: Uint8Array;
|
|
16
|
+
x25519PublicKey: Uint8Array;
|
|
17
|
+
/** The X25519 identity secret used by interactive 3DH; never Ed25519. */
|
|
18
|
+
x25519SecretKey: Uint8Array;
|
|
19
|
+
x25519CrossSignature: Uint8Array;
|
|
20
|
+
}
|
|
21
|
+
export interface GeneratedSessionIdentity extends LocalSessionIdentity {
|
|
22
|
+
ed25519SecretKey: Uint8Array;
|
|
23
|
+
}
|
|
24
|
+
export interface SessionChannelBinding {
|
|
25
|
+
channelId: Uint8Array;
|
|
26
|
+
localFingerprint: Uint8Array;
|
|
27
|
+
remoteFingerprint: Uint8Array;
|
|
28
|
+
}
|
|
29
|
+
export interface SessionCryptoOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Local/self-hosted libcrypto.wasm bytes. Supply this in Node/Bun or offline
|
|
32
|
+
* deployments; when omitted the versioned p2party CDN loader is used.
|
|
33
|
+
*/
|
|
34
|
+
wasmBinary?: ArrayBuffer | Uint8Array;
|
|
35
|
+
}
|
|
36
|
+
export type SessionAuth = {
|
|
37
|
+
mode: "nopin";
|
|
38
|
+
pin?: never;
|
|
39
|
+
} | {
|
|
40
|
+
mode: "pin";
|
|
41
|
+
pin: Uint8Array;
|
|
42
|
+
};
|
|
43
|
+
export type CreateSessionOptions = {
|
|
44
|
+
transport: HandshakeTransport;
|
|
45
|
+
role: "initiator" | "responder";
|
|
46
|
+
identity: LocalSessionIdentity;
|
|
47
|
+
/** Externally pinned (or explicitly TOFU-accepted) peer Ed25519 identity. */
|
|
48
|
+
peerIdentityEd25519PublicKey: Uint8Array;
|
|
49
|
+
channel: SessionChannelBinding;
|
|
50
|
+
/** Exact suite chosen out-of-band for both peers; defaults to ML-KEM-768. */
|
|
51
|
+
pqMode?: RoomPqMode;
|
|
52
|
+
crypto?: SessionCryptoOptions;
|
|
53
|
+
} & SessionAuth;
|
|
54
|
+
export interface EncryptedSessionMessage {
|
|
55
|
+
protocolVersion: 4;
|
|
56
|
+
/** The message Merkle root; authenticated as AEAD additional data. */
|
|
57
|
+
root: Uint8Array;
|
|
58
|
+
/** Uniform protocol-v3 chunk frames. */
|
|
59
|
+
frames: Uint8Array[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* One exact sealed sparse-PQ control cell to dispatch after the caller has
|
|
63
|
+
* persisted the mutated session, plus whether a durable write is required
|
|
64
|
+
* before sending (false for an exact duplicate response).
|
|
65
|
+
*/
|
|
66
|
+
export interface SessionControlOutput {
|
|
67
|
+
readonly frame: Uint8Array | null;
|
|
68
|
+
readonly requiresPersistBeforeSend: boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface P2PartySession {
|
|
71
|
+
readonly protocolVersion: 4;
|
|
72
|
+
readonly pqMode: RoomPqMode;
|
|
73
|
+
/** True for either role after a successful handshake; false after destroy. */
|
|
74
|
+
readonly canEncrypt: boolean;
|
|
75
|
+
/** Current authenticated PQ epoch; 0 before any healing exchange. */
|
|
76
|
+
readonly pqEpoch: bigint;
|
|
77
|
+
/** True while a sparse-PQ healing exchange blocks application traffic. */
|
|
78
|
+
readonly healingInProgress: boolean;
|
|
79
|
+
encrypt(plaintext: Uint8Array): Promise<EncryptedSessionMessage>;
|
|
80
|
+
decrypt(message: EncryptedSessionMessage): Promise<Uint8Array>;
|
|
81
|
+
/**
|
|
82
|
+
* Store-free sparse-PQ healing for custom transports. Contract: after any of
|
|
83
|
+
* these returns a frame, the caller MUST persist `serialize()` BEFORE
|
|
84
|
+
* sending that frame, so a crash cannot fork the OFFER/ADVANCE/ACK sequence.
|
|
85
|
+
*
|
|
86
|
+
* `prepareHealing` starts a due local exchange (returns null when not due or
|
|
87
|
+
* not this side's turn). `acceptControlFrame` processes an inbound OFFER,
|
|
88
|
+
* ADVANCE, or ACK and returns the exact response to send. `pendingControl`
|
|
89
|
+
* returns the exact frame to retransmit for a dropped flight.
|
|
90
|
+
*/
|
|
91
|
+
prepareHealing(): Promise<SessionControlOutput>;
|
|
92
|
+
acceptControlFrame(frame: Uint8Array): Promise<SessionControlOutput>;
|
|
93
|
+
pendingControl(): Promise<Uint8Array | null>;
|
|
94
|
+
/**
|
|
95
|
+
* Plaintext secret snapshot (Double Ratchet + PQ machine/root/epoch/turn/
|
|
96
|
+
* counters + active combined receive keys). Store only under authenticated
|
|
97
|
+
* encryption with rollback protection; never send this blob to the peer.
|
|
98
|
+
*/
|
|
99
|
+
serialize(): Promise<Uint8Array>;
|
|
100
|
+
destroy(): Promise<void>;
|
|
101
|
+
}
|
|
102
|
+
export interface GenerateSessionIdentityOptions extends SessionCryptoOptions {
|
|
103
|
+
ed25519KeyPair?: {
|
|
104
|
+
publicKey: Uint8Array;
|
|
105
|
+
secretKey: Uint8Array;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export declare const generateSessionIdentity: (options?: GenerateSessionIdentityOptions) => Promise<GeneratedSessionIdentity>;
|
|
109
|
+
export declare const createSession: (options: CreateSessionOptions) => Promise<P2PartySession>;
|
|
110
|
+
export declare const restoreSession: (snapshot: Uint8Array, crypto?: SessionCryptoOptions) => Promise<P2PartySession>;
|