werift 0.27.0 → 0.28.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/README.md +119 -8
- package/lib/common/src/event.d.ts +26 -0
- package/lib/common/src/event.js +87 -2
- package/lib/common/src/event.js.map +1 -1
- package/lib/common/src/network.d.ts +6 -1
- package/lib/common/src/network.js +8 -2
- package/lib/common/src/network.js.map +1 -1
- package/lib/common/src/transport.d.ts +12 -5
- package/lib/common/src/transport.js +3 -2
- package/lib/common/src/transport.js.map +1 -1
- package/lib/dtls/src/alert.d.ts +49 -0
- package/lib/dtls/src/alert.js +103 -0
- package/lib/dtls/src/alert.js.map +1 -0
- package/lib/dtls/src/client.js +15 -1
- package/lib/dtls/src/client.js.map +1 -1
- package/lib/dtls/src/context/dtls.d.ts +2 -0
- package/lib/dtls/src/context/dtls.js +7 -0
- package/lib/dtls/src/context/dtls.js.map +1 -1
- package/lib/dtls/src/context/transport.d.ts +17 -1
- package/lib/dtls/src/context/transport.js +38 -2
- package/lib/dtls/src/context/transport.js.map +1 -1
- package/lib/dtls/src/flight/client/flight5.js +4 -1
- package/lib/dtls/src/flight/client/flight5.js.map +1 -1
- package/lib/dtls/src/flight/flight.d.ts +5 -0
- package/lib/dtls/src/flight/flight.js +10 -1
- package/lib/dtls/src/flight/flight.js.map +1 -1
- package/lib/dtls/src/flight/server/flight6.js +4 -1
- package/lib/dtls/src/flight/server/flight6.js.map +1 -1
- package/lib/dtls/src/index.d.ts +3 -1
- package/lib/dtls/src/index.js +10 -1
- package/lib/dtls/src/index.js.map +1 -1
- package/lib/dtls/src/record/const.d.ts +9 -0
- package/lib/dtls/src/record/const.js +9 -1
- package/lib/dtls/src/record/const.js.map +1 -1
- package/lib/dtls/src/record/receive.d.ts +6 -0
- package/lib/dtls/src/record/receive.js +50 -19
- package/lib/dtls/src/record/receive.js.map +1 -1
- package/lib/dtls/src/server.js +19 -1
- package/lib/dtls/src/server.js.map +1 -1
- package/lib/dtls/src/socket.d.ts +134 -2
- package/lib/dtls/src/socket.js +322 -6
- package/lib/dtls/src/socket.js.map +1 -1
- package/lib/ice/src/candidateError.d.ts +155 -0
- package/lib/ice/src/candidateError.js +246 -0
- package/lib/ice/src/candidateError.js.map +1 -0
- package/lib/ice/src/candidateGatherer.d.ts +127 -0
- package/lib/ice/src/candidateGatherer.js +745 -0
- package/lib/ice/src/candidateGatherer.js.map +1 -0
- package/lib/ice/src/consent.d.ts +49 -0
- package/lib/ice/src/consent.js +258 -0
- package/lib/ice/src/consent.js.map +1 -0
- package/lib/ice/src/ice.d.ts +223 -71
- package/lib/ice/src/ice.js +873 -975
- package/lib/ice/src/ice.js.map +1 -1
- package/lib/ice/src/iceBase.d.ts +207 -8
- package/lib/ice/src/iceBase.js +94 -31
- package/lib/ice/src/iceBase.js.map +1 -1
- package/lib/ice/src/index.d.ts +1 -0
- package/lib/ice/src/index.js +1 -0
- package/lib/ice/src/index.js.map +1 -1
- package/lib/ice/src/internal/checkMessages.d.ts +41 -0
- package/lib/ice/src/internal/checkMessages.js +63 -0
- package/lib/ice/src/internal/checkMessages.js.map +1 -0
- package/lib/ice/src/internal/defaultRoute.d.ts +20 -0
- package/lib/ice/src/internal/defaultRoute.js +134 -0
- package/lib/ice/src/internal/defaultRoute.js.map +1 -0
- package/lib/ice/src/internal/hostInterfaces.d.ts +17 -0
- package/lib/ice/src/internal/hostInterfaces.js +77 -0
- package/lib/ice/src/internal/hostInterfaces.js.map +1 -0
- package/lib/ice/src/internal/hostPreference.d.ts +24 -0
- package/lib/ice/src/internal/hostPreference.js +38 -0
- package/lib/ice/src/internal/hostPreference.js.map +1 -0
- package/lib/ice/src/internal/resolveHostAddresses.d.ts +56 -8
- package/lib/ice/src/internal/resolveHostAddresses.js +127 -24
- package/lib/ice/src/internal/resolveHostAddresses.js.map +1 -1
- package/lib/ice/src/internal/selectAddresses.d.ts +27 -0
- package/lib/ice/src/internal/selectAddresses.js +37 -18
- package/lib/ice/src/internal/selectAddresses.js.map +1 -1
- package/lib/ice/src/nomination/regularNomination.d.ts +200 -0
- package/lib/ice/src/nomination/regularNomination.js +311 -0
- package/lib/ice/src/nomination/regularNomination.js.map +1 -0
- package/lib/ice/src/nomination/selectionReplacement.d.ts +138 -0
- package/lib/ice/src/nomination/selectionReplacement.js +371 -0
- package/lib/ice/src/nomination/selectionReplacement.js.map +1 -0
- package/lib/ice/src/provisional.d.ts +139 -0
- package/lib/ice/src/provisional.js +468 -0
- package/lib/ice/src/provisional.js.map +1 -0
- package/lib/ice/src/stun/protocol.d.ts +9 -2
- package/lib/ice/src/stun/protocol.js +16 -17
- package/lib/ice/src/stun/protocol.js.map +1 -1
- package/lib/ice/src/stun/tcpProtocol.d.ts +1 -1
- package/lib/ice/src/stun/tcpProtocol.js +7 -7
- package/lib/ice/src/stun/tcpProtocol.js.map +1 -1
- package/lib/ice/src/stun/transaction.js +4 -2
- package/lib/ice/src/stun/transaction.js.map +1 -1
- package/lib/ice/src/turn/protocol.d.ts +2 -2
- package/lib/ice/src/turn/protocol.js +6 -3
- package/lib/ice/src/turn/protocol.js.map +1 -1
- package/lib/ice/src/types/model.d.ts +16 -5
- package/lib/ice/src/types/model.js.map +1 -1
- package/lib/ice-server/src/stun/attributes.js +4 -0
- package/lib/ice-server/src/stun/attributes.js.map +1 -1
- package/lib/ice-server/src/stun/const.d.ts +20 -1
- package/lib/ice-server/src/stun/const.js +9 -1
- package/lib/ice-server/src/stun/const.js.map +1 -1
- package/lib/ice-server/src/stun/message.d.ts +28 -1
- package/lib/ice-server/src/stun/message.js +102 -15
- package/lib/ice-server/src/stun/message.js.map +1 -1
- package/lib/index.mjs +13394 -7732
- package/lib/nonstandard/index.mjs +680 -286
- package/lib/polyfill/dom.mjs +19605 -14243
- package/lib/polyfill/index.mjs +19605 -14243
- package/lib/rtp/src/index.d.ts +1 -0
- package/lib/rtp/src/index.js +1 -0
- package/lib/rtp/src/index.js.map +1 -1
- package/lib/rtp/src/rtp/continuity.d.ts +14 -1
- package/lib/rtp/src/rtp/continuity.js +24 -4
- package/lib/rtp/src/rtp/continuity.js.map +1 -1
- package/lib/rtp/src/rtp/timelineRewriter.d.ts +178 -0
- package/lib/rtp/src/rtp/timelineRewriter.js +417 -0
- package/lib/rtp/src/rtp/timelineRewriter.js.map +1 -0
- package/lib/sctp/src/sctp.d.ts +5 -0
- package/lib/sctp/src/sctp.js +81 -47
- package/lib/sctp/src/sctp.js.map +1 -1
- package/lib/webrtc/src/api/compatibilityOptions.d.ts +33 -0
- package/lib/webrtc/src/api/compatibilityOptions.js +33 -0
- package/lib/webrtc/src/api/compatibilityOptions.js.map +1 -0
- package/lib/webrtc/src/api/peerConfig.d.ts +348 -34
- package/lib/webrtc/src/api/peerConfig.js +90 -24
- package/lib/webrtc/src/api/peerConfig.js.map +1 -1
- package/lib/webrtc/src/api/peerConnectionEvents.d.ts +77 -1
- package/lib/webrtc/src/api/peerConnectionEvents.js +105 -1
- package/lib/webrtc/src/api/peerConnectionEvents.js.map +1 -1
- package/lib/webrtc/src/helper.d.ts +8 -0
- package/lib/webrtc/src/helper.js +40 -4
- package/lib/webrtc/src/helper.js.map +1 -1
- package/lib/webrtc/src/media/codecCompatibility.d.ts +87 -1
- package/lib/webrtc/src/media/codecCompatibility.js +338 -12
- package/lib/webrtc/src/media/codecCompatibility.js.map +1 -1
- package/lib/webrtc/src/media/receiver/nack.d.ts +43 -10
- package/lib/webrtc/src/media/receiver/nack.js +245 -88
- package/lib/webrtc/src/media/receiver/nack.js.map +1 -1
- package/lib/webrtc/src/media/router.d.ts +239 -51
- package/lib/webrtc/src/media/router.js +664 -237
- package/lib/webrtc/src/media/router.js.map +1 -1
- package/lib/webrtc/src/media/routing/pendingRoutes.d.ts +26 -0
- package/lib/webrtc/src/media/routing/pendingRoutes.js +48 -0
- package/lib/webrtc/src/media/routing/pendingRoutes.js.map +1 -0
- package/lib/webrtc/src/media/routing/ridRouting.d.ts +37 -0
- package/lib/webrtc/src/media/routing/ridRouting.js +74 -0
- package/lib/webrtc/src/media/routing/ridRouting.js.map +1 -0
- package/lib/webrtc/src/media/routing/routeTable.d.ts +60 -0
- package/lib/webrtc/src/media/routing/routeTable.js +95 -0
- package/lib/webrtc/src/media/routing/routeTable.js.map +1 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.d.ts +34 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.js +165 -0
- package/lib/webrtc/src/media/routing/rtcpRouting.js.map +1 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.d.ts +55 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.js +117 -0
- package/lib/webrtc/src/media/routing/unknownSsrc.js.map +1 -0
- package/lib/webrtc/src/media/rtpReceiver.d.ts +222 -0
- package/lib/webrtc/src/media/rtpReceiver.js +668 -28
- package/lib/webrtc/src/media/rtpReceiver.js.map +1 -1
- package/lib/webrtc/src/media/rtpSender.d.ts +7 -0
- package/lib/webrtc/src/media/rtpSender.js +9 -3
- package/lib/webrtc/src/media/rtpSender.js.map +1 -1
- package/lib/webrtc/src/media/rtpTransceiver.d.ts +18 -0
- package/lib/webrtc/src/media/rtpTransceiver.js +64 -2
- package/lib/webrtc/src/media/rtpTransceiver.js.map +1 -1
- package/lib/webrtc/src/media/sender/senderReportHistory.d.ts +51 -0
- package/lib/webrtc/src/media/sender/senderReportHistory.js +111 -0
- package/lib/webrtc/src/media/sender/senderReportHistory.js.map +1 -0
- package/lib/webrtc/src/media/sender/senderStats.d.ts +6 -5
- package/lib/webrtc/src/media/sender/senderStats.js +14 -19
- package/lib/webrtc/src/media/sender/senderStats.js.map +1 -1
- package/lib/webrtc/src/media/track.d.ts +9 -0
- package/lib/webrtc/src/media/track.js +9 -0
- package/lib/webrtc/src/media/track.js.map +1 -1
- package/lib/webrtc/src/negotiation/remoteMediaApplication.d.ts +23 -6
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js +46 -22
- package/lib/webrtc/src/negotiation/remoteMediaApplication.js.map +1 -1
- package/lib/webrtc/src/negotiation/transceiverPairing.d.ts +1 -0
- package/lib/webrtc/src/negotiation/transceiverPairing.js +62 -0
- package/lib/webrtc/src/negotiation/transceiverPairing.js.map +1 -0
- package/lib/webrtc/src/negotiation/transportActivation.d.ts +8 -1
- package/lib/webrtc/src/negotiation/transportActivation.js +21 -0
- package/lib/webrtc/src/negotiation/transportActivation.js.map +1 -1
- package/lib/webrtc/src/negotiationTransaction.d.ts +35 -4
- package/lib/webrtc/src/negotiationTransaction.js +111 -8
- package/lib/webrtc/src/negotiationTransaction.js.map +1 -1
- package/lib/webrtc/src/peerConnection.d.ts +65 -6
- package/lib/webrtc/src/peerConnection.js +283 -28
- package/lib/webrtc/src/peerConnection.js.map +1 -1
- package/lib/webrtc/src/polyfill/globals.d.ts +2 -1
- package/lib/webrtc/src/polyfill/globals.js.map +1 -1
- package/lib/webrtc/src/polyfill/install.js +2 -0
- package/lib/webrtc/src/polyfill/install.js.map +1 -1
- package/lib/webrtc/src/sctpManager.js +4 -0
- package/lib/webrtc/src/sctpManager.js.map +1 -1
- package/lib/webrtc/src/sdp.d.ts +69 -0
- package/lib/webrtc/src/sdp.js +139 -14
- package/lib/webrtc/src/sdp.js.map +1 -1
- package/lib/webrtc/src/sdpManager.d.ts +85 -4
- package/lib/webrtc/src/sdpManager.js +214 -14
- package/lib/webrtc/src/sdpManager.js.map +1 -1
- package/lib/webrtc/src/secureTransportManager.d.ts +38 -1
- package/lib/webrtc/src/secureTransportManager.js +82 -7
- package/lib/webrtc/src/secureTransportManager.js.map +1 -1
- package/lib/webrtc/src/transceiverManager.d.ts +82 -4
- package/lib/webrtc/src/transceiverManager.js +231 -38
- package/lib/webrtc/src/transceiverManager.js.map +1 -1
- package/lib/webrtc/src/transport/dtls.d.ts +95 -1
- package/lib/webrtc/src/transport/dtls.js +324 -28
- package/lib/webrtc/src/transport/dtls.js.map +1 -1
- package/lib/webrtc/src/transport/ice.d.ts +61 -4
- package/lib/webrtc/src/transport/ice.js +180 -11
- package/lib/webrtc/src/transport/ice.js.map +1 -1
- package/lib/webrtc/src/transport/sctp.d.ts +23 -0
- package/lib/webrtc/src/transport/sctp.js +87 -2
- package/lib/webrtc/src/transport/sctp.js.map +1 -1
- package/lib/webrtc/src/utils.d.ts +33 -0
- package/lib/webrtc/src/utils.js +52 -3
- package/lib/webrtc/src/utils.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Candidate } from "./candidate";
|
|
2
|
+
import type { MdnsLookup } from "./dns/lookup";
|
|
3
|
+
import { CandidatePair, type IceOptions } from "./iceBase";
|
|
4
|
+
import { type Address } from "./imports/common";
|
|
5
|
+
import { type NominationOutcome, RegularNomination } from "./nomination/regularNomination";
|
|
6
|
+
import type { Message } from "./stun/message";
|
|
7
|
+
import type { Protocol } from "./types/model";
|
|
8
|
+
/**
|
|
9
|
+
* The checklist of an ICE restart negotiated with a pranswer: checked beside
|
|
10
|
+
* the selected pair of the live checklist, which keeps carrying data until
|
|
11
|
+
* the final answer commits (or discards) the restart.
|
|
12
|
+
*/
|
|
13
|
+
export type ProvisionalGeneration = {
|
|
14
|
+
localUsername: string;
|
|
15
|
+
localPassword: string;
|
|
16
|
+
/** The options the staged generation gathers with (stageLocalCredentials). */
|
|
17
|
+
gatherOptions?: Partial<IceOptions>;
|
|
18
|
+
remoteUsername?: string;
|
|
19
|
+
remotePassword?: string;
|
|
20
|
+
remoteCandidates: Candidate[];
|
|
21
|
+
remoteCandidatesEnd: boolean;
|
|
22
|
+
/** End-of-candidates arrived; waiting for earlier mDNS resolutions. */
|
|
23
|
+
remoteCandidatesEndRequested: boolean;
|
|
24
|
+
resolutions: Set<Promise<string>>;
|
|
25
|
+
/** Incremented when a replacement pranswer restarts this checklist. */
|
|
26
|
+
revision: number;
|
|
27
|
+
pairs: CandidatePair[];
|
|
28
|
+
nominated?: CandidatePair;
|
|
29
|
+
/** The ICE-lite nomination (first valid pair) is in flight. */
|
|
30
|
+
liteNominating?: boolean;
|
|
31
|
+
/** Regular nomination toward a full ICE peer (shares the live rules). */
|
|
32
|
+
nomination: RegularNomination;
|
|
33
|
+
started: boolean;
|
|
34
|
+
/** Aborts the checks in flight when the checklist is replaced or dropped. */
|
|
35
|
+
checks: AbortController;
|
|
36
|
+
};
|
|
37
|
+
/** What the agent supplies to its `ProvisionalChecklist`. */
|
|
38
|
+
export type ProvisionalHost = {
|
|
39
|
+
closed: () => boolean;
|
|
40
|
+
iceLite: () => boolean;
|
|
41
|
+
iceControlling: () => boolean;
|
|
42
|
+
remoteIsLite: () => boolean;
|
|
43
|
+
localCandidatesEnd: () => boolean;
|
|
44
|
+
options: () => IceOptions;
|
|
45
|
+
/** The agent's sockets and TURN allocations. */
|
|
46
|
+
protocols: () => readonly Protocol[];
|
|
47
|
+
/** The agent's mDNS resolver (created on first use). */
|
|
48
|
+
mdnsLookup: () => MdnsLookup;
|
|
49
|
+
/** A pair the agent never checks itself (forceTurn). */
|
|
50
|
+
isUncheckedPair: (pair: CandidatePair) => boolean;
|
|
51
|
+
/** A wildcard socket (`CandidateGatherer.isWildcardProtocol`). */
|
|
52
|
+
isWildcardProtocol: (protocol: Protocol) => boolean;
|
|
53
|
+
/**
|
|
54
|
+
* The wildcard socket should check `remoteCandidate`: no host socket
|
|
55
|
+
* covers its path (`CandidateGatherer.wildcardPathUncovered`).
|
|
56
|
+
*/
|
|
57
|
+
wildcardPathUncovered: (remoteCandidate: Candidate) => Promise<boolean>;
|
|
58
|
+
/** Full ICE on both sides and this agent controlling. */
|
|
59
|
+
nominatesFullPeer: () => boolean;
|
|
60
|
+
usesRegularNomination: () => boolean;
|
|
61
|
+
/** A pair semi-aggressive nomination and renomination may select. */
|
|
62
|
+
replacesWith: (pair: CandidatePair) => boolean;
|
|
63
|
+
/** The pairs `RegularNomination` nominates from. */
|
|
64
|
+
regularNominationPairs: (pairs: readonly CandidatePair[]) => readonly CandidatePair[];
|
|
65
|
+
bestValidPair: (pairs: CandidatePair[]) => CandidatePair | undefined;
|
|
66
|
+
outranks: (pair: CandidatePair, other: CandidatePair) => boolean;
|
|
67
|
+
nominationDelayMs: () => number;
|
|
68
|
+
buildRequest: (params: {
|
|
69
|
+
nominate: boolean;
|
|
70
|
+
localUsername: string;
|
|
71
|
+
remoteUsername: string;
|
|
72
|
+
iceControlling: boolean;
|
|
73
|
+
localCandidate: Candidate;
|
|
74
|
+
}) => Message;
|
|
75
|
+
switchRole: (iceControlling: boolean) => void;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* The provisional generation of an ICE restart (`ProvisionalGeneration`):
|
|
79
|
+
* staged by `stage()` with the local credentials of the restart offer,
|
|
80
|
+
* given the pranswer's credentials and candidates, checked (`start()`) and
|
|
81
|
+
* nominated with the same rules as the live checklist, and dropped by
|
|
82
|
+
* `end()` when the final answer commits or discards the restart. It never
|
|
83
|
+
* touches the live checklist.
|
|
84
|
+
*/
|
|
85
|
+
export declare class ProvisionalChecklist {
|
|
86
|
+
/** The staged generation, if any. */
|
|
87
|
+
generation?: ProvisionalGeneration;
|
|
88
|
+
private readonly host;
|
|
89
|
+
constructor(host: ProvisionalHost);
|
|
90
|
+
/**
|
|
91
|
+
* Drop the provisional generation and stop the checks still in flight for
|
|
92
|
+
* it (their retransmissions would outlive it).
|
|
93
|
+
*/
|
|
94
|
+
end(): void;
|
|
95
|
+
/** Stage a provisional generation for the local credentials of an ICE restart offer. */
|
|
96
|
+
stage(usernameFragment: string, password: string, gatherOptions?: Partial<IceOptions>): void;
|
|
97
|
+
/** Remote credentials of the provisional generation (pranswer). */
|
|
98
|
+
setRemoteParams({ usernameFragment, password, }: {
|
|
99
|
+
usernameFragment: string;
|
|
100
|
+
password: string;
|
|
101
|
+
}): void;
|
|
102
|
+
/** A remote candidate (or end-of-candidates) of the pranswer. */
|
|
103
|
+
addRemoteCandidate(remoteCandidate: Candidate | undefined): Promise<void>;
|
|
104
|
+
/** Start checks for the provisional generation; the selected pair is kept. */
|
|
105
|
+
start(): void;
|
|
106
|
+
get nominated(): CandidatePair | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* @param routeChecked a wildcard socket's pair whose path no host socket
|
|
109
|
+
* covers (checked by `wildcardPathUncovered`, as the live checklist does).
|
|
110
|
+
*/
|
|
111
|
+
private tryPair;
|
|
112
|
+
private check;
|
|
113
|
+
/** Put `pair` on the provisional checklist (see `addPair`). */
|
|
114
|
+
private addPair;
|
|
115
|
+
/**
|
|
116
|
+
* The provisional checklist's side of regular nomination: the same rules
|
|
117
|
+
* as the live checklist (`liveNominationHost`), on its own pairs,
|
|
118
|
+
* credentials and end-of-candidates.
|
|
119
|
+
*/
|
|
120
|
+
private nominationHost;
|
|
121
|
+
/**
|
|
122
|
+
* Send a USE-CANDIDATE check for a provisional `pair` (see
|
|
123
|
+
* `NominationOutcome`). `signal` stops it: the checklist's checks
|
|
124
|
+
* (`end()`, a replacement pranswer) and, for regular nomination,
|
|
125
|
+
* the attempt.
|
|
126
|
+
*/
|
|
127
|
+
nominate(generation: ProvisionalGeneration, pair: CandidatePair, signal: AbortSignal): Promise<NominationOutcome>;
|
|
128
|
+
/** Incoming check for the provisional ufrag; never touches the current checklist. */
|
|
129
|
+
checkIncoming(generation: ProvisionalGeneration, message: Message, addr: Address, protocol: Protocol): void;
|
|
130
|
+
/**
|
|
131
|
+
* Whether the provisional generation may use `protocol`: the staged
|
|
132
|
+
* generation drops the sockets its gather options exclude at the commit,
|
|
133
|
+
* so its checks never use them. A kept TURN allocation serves it only when
|
|
134
|
+
* the generation still uses that TURN server, credential and transport (any of its
|
|
135
|
+
* TURN servers): one whose server was removed or replaced (a credential
|
|
136
|
+
* rotation) is not part of it.
|
|
137
|
+
*/
|
|
138
|
+
allows(generation: ProvisionalGeneration, protocol: Protocol): boolean;
|
|
139
|
+
}
|
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProvisionalChecklist = void 0;
|
|
4
|
+
const candidate_1 = require("./candidate");
|
|
5
|
+
const exceptions_1 = require("./exceptions");
|
|
6
|
+
const helper_1 = require("./helper");
|
|
7
|
+
const iceBase_1 = require("./iceBase");
|
|
8
|
+
const common_1 = require("./imports/common");
|
|
9
|
+
const checkMessages_1 = require("./internal/checkMessages");
|
|
10
|
+
const regularNomination_1 = require("./nomination/regularNomination");
|
|
11
|
+
const protocol_1 = require("./turn/protocol");
|
|
12
|
+
const log = (0, common_1.debug)("werift-ice : packages/ice/src/provisional.ts : log");
|
|
13
|
+
/**
|
|
14
|
+
* The provisional generation of an ICE restart (`ProvisionalGeneration`):
|
|
15
|
+
* staged by `stage()` with the local credentials of the restart offer,
|
|
16
|
+
* given the pranswer's credentials and candidates, checked (`start()`) and
|
|
17
|
+
* nominated with the same rules as the live checklist, and dropped by
|
|
18
|
+
* `end()` when the final answer commits or discards the restart. It never
|
|
19
|
+
* touches the live checklist.
|
|
20
|
+
*/
|
|
21
|
+
class ProvisionalChecklist {
|
|
22
|
+
constructor(host) {
|
|
23
|
+
/** The staged generation, if any. */
|
|
24
|
+
Object.defineProperty(this, "generation", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: void 0
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(this, "host", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: void 0
|
|
35
|
+
});
|
|
36
|
+
this.host = host;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Drop the provisional generation and stop the checks still in flight for
|
|
40
|
+
* it (their retransmissions would outlive it).
|
|
41
|
+
*/
|
|
42
|
+
end() {
|
|
43
|
+
if (this.generation) {
|
|
44
|
+
this.generation.checks.abort();
|
|
45
|
+
this.generation.nomination.reset();
|
|
46
|
+
}
|
|
47
|
+
this.generation = undefined;
|
|
48
|
+
}
|
|
49
|
+
/** Stage a provisional generation for the local credentials of an ICE restart offer. */
|
|
50
|
+
stage(usernameFragment, password, gatherOptions) {
|
|
51
|
+
this.end();
|
|
52
|
+
const generation = {
|
|
53
|
+
localUsername: usernameFragment,
|
|
54
|
+
localPassword: password,
|
|
55
|
+
gatherOptions,
|
|
56
|
+
remoteCandidates: [],
|
|
57
|
+
remoteCandidatesEnd: false,
|
|
58
|
+
remoteCandidatesEndRequested: false,
|
|
59
|
+
resolutions: new Set(),
|
|
60
|
+
revision: 0,
|
|
61
|
+
pairs: [],
|
|
62
|
+
nomination: new regularNomination_1.RegularNomination(this.nominationHost(() => generation)),
|
|
63
|
+
started: false,
|
|
64
|
+
checks: new AbortController(),
|
|
65
|
+
};
|
|
66
|
+
this.generation = generation;
|
|
67
|
+
}
|
|
68
|
+
/** Remote credentials of the provisional generation (pranswer). */
|
|
69
|
+
setRemoteParams({ usernameFragment, password, }) {
|
|
70
|
+
const generation = this.generation;
|
|
71
|
+
if (!generation)
|
|
72
|
+
return;
|
|
73
|
+
if (generation.remoteUsername === usernameFragment &&
|
|
74
|
+
generation.remotePassword === password) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// A replacement pranswer starts a new provisional checklist; candidates
|
|
78
|
+
// still resolving for the replaced one are dropped by `revision`.
|
|
79
|
+
generation.remoteUsername = usernameFragment;
|
|
80
|
+
generation.remotePassword = password;
|
|
81
|
+
generation.remoteCandidates = [];
|
|
82
|
+
generation.remoteCandidatesEnd = false;
|
|
83
|
+
generation.remoteCandidatesEndRequested = false;
|
|
84
|
+
generation.resolutions.clear();
|
|
85
|
+
generation.revision++;
|
|
86
|
+
generation.checks.abort();
|
|
87
|
+
generation.checks = new AbortController();
|
|
88
|
+
generation.pairs = [];
|
|
89
|
+
generation.nominated = undefined;
|
|
90
|
+
generation.liteNominating = false;
|
|
91
|
+
generation.nomination.reset();
|
|
92
|
+
}
|
|
93
|
+
/** A remote candidate (or end-of-candidates) of the pranswer. */
|
|
94
|
+
async addRemoteCandidate(remoteCandidate) {
|
|
95
|
+
const generation = this.generation;
|
|
96
|
+
if (!generation || this.host.closed())
|
|
97
|
+
return;
|
|
98
|
+
const revision = generation.revision;
|
|
99
|
+
const current = () => !this.host.closed() &&
|
|
100
|
+
this.generation === generation &&
|
|
101
|
+
generation.revision === revision;
|
|
102
|
+
if (!remoteCandidate) {
|
|
103
|
+
if (generation.remoteCandidatesEnd ||
|
|
104
|
+
generation.remoteCandidatesEndRequested) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
// Candidates that arrived before end-of-candidates finish first.
|
|
108
|
+
generation.remoteCandidatesEndRequested = true;
|
|
109
|
+
if (generation.resolutions.size > 0) {
|
|
110
|
+
await Promise.allSettled([...generation.resolutions]);
|
|
111
|
+
if (!current())
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
generation.remoteCandidatesEnd = true;
|
|
115
|
+
generation.nomination.evaluate();
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
// RFC 8838: a completed generation takes no further candidates.
|
|
119
|
+
if (generation.remoteCandidatesEnd ||
|
|
120
|
+
generation.remoteCandidatesEndRequested) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (remoteCandidate.host.includes(".local")) {
|
|
124
|
+
try {
|
|
125
|
+
const resolution = this.host.mdnsLookup().lookup(remoteCandidate.host);
|
|
126
|
+
generation.resolutions.add(resolution);
|
|
127
|
+
try {
|
|
128
|
+
remoteCandidate.host = await resolution;
|
|
129
|
+
}
|
|
130
|
+
finally {
|
|
131
|
+
generation.resolutions.delete(resolution);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
// The generation may have been replaced or completed while resolving.
|
|
138
|
+
if (!current() || generation.remoteCandidatesEnd)
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
(0, iceBase_1.validateRemoteCandidate)(remoteCandidate);
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (!current() ||
|
|
148
|
+
generation.remoteCandidates.some((c) => c.host === remoteCandidate.host &&
|
|
149
|
+
c.port === remoteCandidate.port &&
|
|
150
|
+
c.transport.toLowerCase() === remoteCandidate.transport.toLowerCase())) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
generation.remoteCandidates.push(remoteCandidate);
|
|
154
|
+
for (const protocol of this.host.protocols()) {
|
|
155
|
+
this.tryPair(generation, protocol, remoteCandidate);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/** Start checks for the provisional generation; the selected pair is kept. */
|
|
159
|
+
start() {
|
|
160
|
+
const generation = this.generation;
|
|
161
|
+
if (!generation || generation.started)
|
|
162
|
+
return;
|
|
163
|
+
generation.started = true;
|
|
164
|
+
for (const remoteCandidate of generation.remoteCandidates) {
|
|
165
|
+
for (const protocol of this.host.protocols()) {
|
|
166
|
+
this.tryPair(generation, protocol, remoteCandidate);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
for (const pair of generation.pairs) {
|
|
170
|
+
if (!this.host.isUncheckedPair(pair)) {
|
|
171
|
+
void this.check(generation, pair);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
get nominated() {
|
|
176
|
+
return this.generation?.nominated;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* @param routeChecked a wildcard socket's pair whose path no host socket
|
|
180
|
+
* covers (checked by `wildcardPathUncovered`, as the live checklist does).
|
|
181
|
+
*/
|
|
182
|
+
tryPair(generation, protocol, remoteCandidate, routeChecked = false) {
|
|
183
|
+
if (!routeChecked && this.host.isWildcardProtocol(protocol)) {
|
|
184
|
+
void this.host
|
|
185
|
+
.wildcardPathUncovered(remoteCandidate)
|
|
186
|
+
.then((uncovered) => {
|
|
187
|
+
if (uncovered && this.generation === generation) {
|
|
188
|
+
this.tryPair(generation, protocol, remoteCandidate, true);
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (!protocol.localCandidate?.canPairWith(remoteCandidate) ||
|
|
194
|
+
!this.allows(generation, protocol) ||
|
|
195
|
+
(protocol.localCandidate.transport.toLowerCase() === "tcp" &&
|
|
196
|
+
protocol.localCandidate.tcptype === "passive" &&
|
|
197
|
+
remoteCandidate.type !== "prflx") ||
|
|
198
|
+
generation.pairs.some((pair) => pair.protocol === protocol &&
|
|
199
|
+
pair.remoteCandidate === remoteCandidate)) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const pair = new iceBase_1.CandidatePair(protocol, remoteCandidate, this.host.iceControlling());
|
|
203
|
+
// The provisional checklist admits the same pairs as the live one.
|
|
204
|
+
const { filterCandidatePair } = this.host.options();
|
|
205
|
+
if (filterCandidatePair && !filterCandidatePair(pair)) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
pair.updateState(iceBase_1.CandidatePairState.WAITING);
|
|
209
|
+
this.addPair(generation, pair);
|
|
210
|
+
// As the live schedule does, forceTurn leaves host pairs unchecked.
|
|
211
|
+
if (generation.started && !this.host.isUncheckedPair(pair)) {
|
|
212
|
+
void this.check(generation, pair);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async check(generation, pair, retry = true) {
|
|
216
|
+
const revision = generation.revision;
|
|
217
|
+
// A check belongs to one checklist: a replacement pranswer (new revision)
|
|
218
|
+
// or a replaced generation makes its outcome meaningless.
|
|
219
|
+
const belongs = () => this.generation === generation &&
|
|
220
|
+
generation.revision === revision &&
|
|
221
|
+
generation.pairs.includes(pair);
|
|
222
|
+
if (
|
|
223
|
+
// An ICE-lite agent only answers checks (RFC 8445 §2.5), in the
|
|
224
|
+
// provisional generation as in the live one.
|
|
225
|
+
this.host.iceLite() ||
|
|
226
|
+
!belongs() ||
|
|
227
|
+
!generation.started ||
|
|
228
|
+
!generation.remoteUsername ||
|
|
229
|
+
!generation.remotePassword ||
|
|
230
|
+
[
|
|
231
|
+
iceBase_1.CandidatePairState.IN_PROGRESS,
|
|
232
|
+
iceBase_1.CandidatePairState.SUCCEEDED,
|
|
233
|
+
].includes(pair.state)) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
pair.updateState(iceBase_1.CandidatePairState.IN_PROGRESS);
|
|
237
|
+
// Regular nomination: a check never carries USE-CANDIDATE; the
|
|
238
|
+
// nomination is a separate check (`generation.nomination`). Otherwise
|
|
239
|
+
// (semi-aggressive nomination, renomination) checks carry USE-CANDIDATE
|
|
240
|
+
// until a pair is selected: the provisional checklist only selects once,
|
|
241
|
+
// and the final answer checks the live one from scratch.
|
|
242
|
+
const nominate = this.host.nominatesFullPeer() &&
|
|
243
|
+
!this.host.usesRegularNomination() &&
|
|
244
|
+
!generation.nominated &&
|
|
245
|
+
this.host.replacesWith(pair);
|
|
246
|
+
const request = this.host.buildRequest({
|
|
247
|
+
nominate,
|
|
248
|
+
localUsername: generation.localUsername,
|
|
249
|
+
remoteUsername: generation.remoteUsername,
|
|
250
|
+
iceControlling: this.host.iceControlling(),
|
|
251
|
+
localCandidate: pair.localCandidate,
|
|
252
|
+
});
|
|
253
|
+
try {
|
|
254
|
+
pair.requestsSent++;
|
|
255
|
+
const [, addr] = await pair.protocol.request(request, pair.remoteAddr, Buffer.from(generation.remotePassword, "utf8"), {
|
|
256
|
+
retransmissions: pair.localCandidate.transport.toLowerCase() === "tcp" ? 0 : 4,
|
|
257
|
+
signal: generation.checks.signal,
|
|
258
|
+
integrityAlgorithm: this.host.options().messageIntegrity,
|
|
259
|
+
});
|
|
260
|
+
pair.responsesReceived++;
|
|
261
|
+
if (!belongs())
|
|
262
|
+
return;
|
|
263
|
+
if (addr[0] !== pair.remoteAddr[0] || addr[1] !== pair.remoteAddr[1]) {
|
|
264
|
+
pair.updateState(iceBase_1.CandidatePairState.FAILED);
|
|
265
|
+
generation.nomination.evaluate();
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
if (!belongs())
|
|
271
|
+
return;
|
|
272
|
+
const code = error.response?.getAttributeValue("ERROR-CODE")?.[0];
|
|
273
|
+
pair.updateState(iceBase_1.CandidatePairState.FAILED);
|
|
274
|
+
if (code === 487 && retry) {
|
|
275
|
+
this.host.switchRole(request.attributesKeys.includes("ICE-CONTROLLED"));
|
|
276
|
+
pair.updateState(iceBase_1.CandidatePairState.WAITING);
|
|
277
|
+
return this.check(generation, pair, false);
|
|
278
|
+
}
|
|
279
|
+
generation.nomination.evaluate();
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
// Only a controlled agent takes the peer's nomination (see checkStart).
|
|
283
|
+
if (pair.remoteNominated && !this.host.iceControlling())
|
|
284
|
+
pair.nominated = true;
|
|
285
|
+
else if (nominate && this.host.iceControlling())
|
|
286
|
+
pair.nominated = true;
|
|
287
|
+
pair.updateState(iceBase_1.CandidatePairState.SUCCEEDED);
|
|
288
|
+
if (!pair.nominated &&
|
|
289
|
+
this.host.iceControlling() &&
|
|
290
|
+
this.host.remoteIsLite() &&
|
|
291
|
+
!generation.nominated &&
|
|
292
|
+
!generation.liteNominating) {
|
|
293
|
+
// Toward an ICE-lite peer, as the live checklist does: nominate the
|
|
294
|
+
// first pair that succeeded with a check that carries USE-CANDIDATE.
|
|
295
|
+
generation.liteNominating = true;
|
|
296
|
+
const result = await this.nominate(generation, pair, generation.checks.signal);
|
|
297
|
+
if (belongs()) {
|
|
298
|
+
generation.liteNominating = false;
|
|
299
|
+
if (result === "nominated")
|
|
300
|
+
pair.nominated = true;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (pair.nominated && !generation.nominated) {
|
|
304
|
+
log("provisional nominated", pair.toJSON());
|
|
305
|
+
generation.nominated = pair;
|
|
306
|
+
generation.nomination.stop();
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if (belongs())
|
|
310
|
+
generation.nomination.evaluate();
|
|
311
|
+
}
|
|
312
|
+
/** Put `pair` on the provisional checklist (see `addPair`). */
|
|
313
|
+
addPair(generation, pair) {
|
|
314
|
+
const best = this.host.bestValidPair(generation.pairs);
|
|
315
|
+
generation.pairs.push(pair);
|
|
316
|
+
generation.nomination.pairAdded(pair, best);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* The provisional checklist's side of regular nomination: the same rules
|
|
320
|
+
* as the live checklist (`liveNominationHost`), on its own pairs,
|
|
321
|
+
* credentials and end-of-candidates.
|
|
322
|
+
*/
|
|
323
|
+
nominationHost(generationOf) {
|
|
324
|
+
const current = () => this.generation === generationOf();
|
|
325
|
+
return {
|
|
326
|
+
active: () => current() &&
|
|
327
|
+
this.host.nominatesFullPeer() &&
|
|
328
|
+
generationOf().started &&
|
|
329
|
+
!generationOf().nominated,
|
|
330
|
+
checking: () => generationOf().started,
|
|
331
|
+
pairs: () => {
|
|
332
|
+
const pairs = [
|
|
333
|
+
...this.host.regularNominationPairs(generationOf().pairs),
|
|
334
|
+
];
|
|
335
|
+
(0, iceBase_1.sortCandidatePairs)(pairs, this.host.iceControlling());
|
|
336
|
+
return pairs;
|
|
337
|
+
},
|
|
338
|
+
remoteCandidatesEnd: () => generationOf().remoteCandidatesEnd,
|
|
339
|
+
localCandidatesEnd: () => this.host.localCandidatesEnd(),
|
|
340
|
+
delayMs: () => this.host.nominationDelayMs(),
|
|
341
|
+
unchecked: (pair) => this.host.isUncheckedPair(pair),
|
|
342
|
+
outranks: (pair, other) => this.host.outranks(pair, other),
|
|
343
|
+
preferred: () => undefined,
|
|
344
|
+
owns: (pair) => current() && generationOf().pairs.includes(pair),
|
|
345
|
+
send: (pair, signal) => this.nominate(generationOf(), pair, AbortSignal.any([generationOf().checks.signal, signal])),
|
|
346
|
+
nominated: (pair) => {
|
|
347
|
+
const generation = generationOf();
|
|
348
|
+
pair.nominated = true;
|
|
349
|
+
if (!generation.nominated) {
|
|
350
|
+
log("provisional nominated", pair.toJSON());
|
|
351
|
+
generation.nominated = pair;
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
rejected: (pair) => {
|
|
355
|
+
pair.updateState(iceBase_1.CandidatePairState.FAILED);
|
|
356
|
+
generationOf().nomination.evaluate();
|
|
357
|
+
},
|
|
358
|
+
// As in the live checklist: become controlled, keep the pair valid.
|
|
359
|
+
roleConflict: () => this.host.switchRole(false),
|
|
360
|
+
abandoned: (pair) => pair?.updateState(iceBase_1.CandidatePairState.FAILED),
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Send a USE-CANDIDATE check for a provisional `pair` (see
|
|
365
|
+
* `NominationOutcome`). `signal` stops it: the checklist's checks
|
|
366
|
+
* (`end()`, a replacement pranswer) and, for regular nomination,
|
|
367
|
+
* the attempt.
|
|
368
|
+
*/
|
|
369
|
+
async nominate(generation, pair, signal) {
|
|
370
|
+
const request = this.host.buildRequest({
|
|
371
|
+
nominate: true,
|
|
372
|
+
localUsername: generation.localUsername,
|
|
373
|
+
remoteUsername: generation.remoteUsername,
|
|
374
|
+
iceControlling: this.host.iceControlling(),
|
|
375
|
+
localCandidate: pair.localCandidate,
|
|
376
|
+
});
|
|
377
|
+
try {
|
|
378
|
+
pair.requestsSent++;
|
|
379
|
+
await pair.protocol.request(request, pair.remoteAddr, Buffer.from(generation.remotePassword, "utf8"), {
|
|
380
|
+
retransmissions: pair.localCandidate.transport.toLowerCase() === "tcp" ? 0 : 4,
|
|
381
|
+
// end() / a replacement pranswer stops it with the checks.
|
|
382
|
+
signal: AbortSignal.any([signal, generation.checks.signal]),
|
|
383
|
+
integrityAlgorithm: this.host.options().messageIntegrity,
|
|
384
|
+
});
|
|
385
|
+
pair.responsesReceived++;
|
|
386
|
+
return "nominated";
|
|
387
|
+
}
|
|
388
|
+
catch (error) {
|
|
389
|
+
log("provisional regular nomination failed", error);
|
|
390
|
+
if ((0, checkMessages_1.isRoleConflict)(error))
|
|
391
|
+
return "role-conflict";
|
|
392
|
+
return error instanceof exceptions_1.TransactionTimeout ? "unanswered" : "rejected";
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
/** Incoming check for the provisional ufrag; never touches the current checklist. */
|
|
396
|
+
checkIncoming(generation, message, addr, protocol) {
|
|
397
|
+
// A socket the staged generation drops at the commit takes no pair.
|
|
398
|
+
if (!this.allows(generation, protocol))
|
|
399
|
+
return;
|
|
400
|
+
// Only checks from the remote credentials of the current checklist count
|
|
401
|
+
// (a replacement pranswer replaced any earlier ones).
|
|
402
|
+
const txUsername = message.getAttributeValue("USERNAME");
|
|
403
|
+
const sender = typeof txUsername === "string"
|
|
404
|
+
? (0, checkMessages_1.decodeTxUsername)(txUsername).localUsername
|
|
405
|
+
: undefined;
|
|
406
|
+
if (generation.remoteUsername && sender !== generation.remoteUsername) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
const [host, port] = addr;
|
|
410
|
+
let remoteCandidate = generation.remoteCandidates.find((c) => c.host === host && c.port === port);
|
|
411
|
+
if (!remoteCandidate) {
|
|
412
|
+
remoteCandidate = new candidate_1.Candidate((0, helper_1.randomString)(10), 1, protocol.localCandidate?.transport ?? "udp", message.getAttributeValue("PRIORITY"), host, port, "prflx", undefined, undefined, protocol.localCandidate?.transport === "tcp"
|
|
413
|
+
? (0, candidate_1.remoteTcpTypeForIncoming)(protocol.localCandidate.tcptype)
|
|
414
|
+
: undefined, undefined, undefined);
|
|
415
|
+
generation.remoteCandidates.push(remoteCandidate);
|
|
416
|
+
}
|
|
417
|
+
let pair = generation.pairs.find((p) => p.protocol === protocol && p.remoteCandidate === remoteCandidate);
|
|
418
|
+
if (!pair) {
|
|
419
|
+
pair = new iceBase_1.CandidatePair(protocol, remoteCandidate, this.host.iceControlling());
|
|
420
|
+
pair.updateState(iceBase_1.CandidatePairState.WAITING);
|
|
421
|
+
this.addPair(generation, pair);
|
|
422
|
+
}
|
|
423
|
+
pair.noteIncomingRequest(message.transactionIdHex);
|
|
424
|
+
pair.requestsReceived++;
|
|
425
|
+
pair.responsesSent++;
|
|
426
|
+
if ((0, checkMessages_1.receivedNomination)(message) > 0 && !this.host.iceControlling()) {
|
|
427
|
+
pair.remoteNominated = true;
|
|
428
|
+
if (this.host.iceLite() || pair.state === iceBase_1.CandidatePairState.SUCCEEDED) {
|
|
429
|
+
pair.nominated = true;
|
|
430
|
+
pair.updateState(iceBase_1.CandidatePairState.SUCCEEDED);
|
|
431
|
+
generation.nominated ?? (generation.nominated = pair);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
if (!this.host.iceLite() &&
|
|
435
|
+
[
|
|
436
|
+
iceBase_1.CandidatePairState.WAITING,
|
|
437
|
+
iceBase_1.CandidatePairState.FAILED,
|
|
438
|
+
].includes(pair.state)) {
|
|
439
|
+
void this.check(generation, pair);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Whether the provisional generation may use `protocol`: the staged
|
|
444
|
+
* generation drops the sockets its gather options exclude at the commit,
|
|
445
|
+
* so its checks never use them. A kept TURN allocation serves it only when
|
|
446
|
+
* the generation still uses that TURN server, credential and transport (any of its
|
|
447
|
+
* TURN servers): one whose server was removed or replaced (a credential
|
|
448
|
+
* rotation) is not part of it.
|
|
449
|
+
*/
|
|
450
|
+
allows(generation, protocol) {
|
|
451
|
+
const options = generation.gatherOptions ?? this.host.options();
|
|
452
|
+
if (!protocol.localCandidate ||
|
|
453
|
+
!(0, iceBase_1.isCandidateAllowedByGatherOptions)(protocol.localCandidate, options)) {
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
if (protocol instanceof protocol_1.StunOverTurnProtocol) {
|
|
457
|
+
const { configuredServer, username, password } = protocol.turn;
|
|
458
|
+
return (0, iceBase_1.normalizeIceServerOptions)(options).turnServers.some((server) => configuredServer[0] === server.address[0] &&
|
|
459
|
+
configuredServer[1] === server.address[1] &&
|
|
460
|
+
username === server.username &&
|
|
461
|
+
password === server.password &&
|
|
462
|
+
protocol.configuredTransport === server.transport);
|
|
463
|
+
}
|
|
464
|
+
return true;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
exports.ProvisionalChecklist = ProvisionalChecklist;
|
|
468
|
+
//# sourceMappingURL=provisional.js.map
|