@mega-yfue/eufy-sdk 0.2.0-beta.2 → 0.2.0-beta.3
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/core/contracts.d.ts +55 -0
- package/dist/index.js +85 -12
- package/dist/index.js.map +2 -2
- package/dist/transport/p2p/command-router.d.ts +23 -0
- package/dist/transport/p2p/index.d.ts +1 -0
- package/dist/transport/p2p/live-trace.d.ts +84 -6
- package/dist/transport/p2p/p2p-session.d.ts +4 -0
- package/package.json +1 -1
|
@@ -18,6 +18,23 @@ import type { FfmpegLevel } from "../ffmpeg.js";
|
|
|
18
18
|
import { SharedLiveSource } from "./shared-live-source.js";
|
|
19
19
|
import { type PowerTier, type SessionManagerOpts } from "./session-manager.js";
|
|
20
20
|
import { FragmentRecording } from "./fragment-recording.js";
|
|
21
|
+
/**
|
|
22
|
+
* What a caller's own deadline on a station call has to clear, in milliseconds.
|
|
23
|
+
*
|
|
24
|
+
* A caller that bounds one of these calls itself races these waits, and a bound below them reports the
|
|
25
|
+
* caller's own expiry in place of the reason this SDK was about to give — the two are indistinguishable to
|
|
26
|
+
* whoever reads the outcome, and they call for different next steps. Published so that bound can be derived
|
|
27
|
+
* rather than copied: a literal in a caller's source is a second source of truth that goes stale silently
|
|
28
|
+
* when these change.
|
|
29
|
+
*
|
|
30
|
+
* `connect` applies to every call on a station, because nothing can be addressed to one before its session is
|
|
31
|
+
* up. `level2Grace` applies twice where the key is required: the negotiation is re-prompted once.
|
|
32
|
+
*/
|
|
33
|
+
export declare const P2P_STATION_WAITS: {
|
|
34
|
+
readonly connect: 20000;
|
|
35
|
+
readonly level2Grace: 25000;
|
|
36
|
+
readonly level2Settle: 8000;
|
|
37
|
+
};
|
|
21
38
|
/**
|
|
22
39
|
* Options accepted when warming a {@link SharedLiveSource} for a device (all optional).
|
|
23
40
|
*
|
|
@@ -90,6 +107,12 @@ export declare class P2PCommandRouter {
|
|
|
90
107
|
constructor(deps: P2PRouterDeps);
|
|
91
108
|
/** Forward one P2P failure once even when both the session listener and startup waiter observe it. */
|
|
92
109
|
private reportError;
|
|
110
|
+
/**
|
|
111
|
+
* Emit a live trace under a station session's handle, for work this router does ON that session before
|
|
112
|
+
* the session itself records anything — reaching the station, and resolving what a device is on it. Same
|
|
113
|
+
* handle as everything the session goes on to trace, which is what groups one attempt.
|
|
114
|
+
*/
|
|
115
|
+
private traceOnStation;
|
|
93
116
|
/**
|
|
94
117
|
* Whether this transport stack drives `dev`'s `ff09-*` commands — true when the device has its own
|
|
95
118
|
* usable P2P endpoint (a non-empty `p2p_did`). The command sink asks each stack this to route a
|
|
@@ -10,4 +10,5 @@ export * from "./envelope.js";
|
|
|
10
10
|
export * from "./write-commands.js";
|
|
11
11
|
export * from "./lan-ip.js";
|
|
12
12
|
export { LIVE_TRACE_MESSAGE, type LiveTrace } from "./live-trace.js";
|
|
13
|
+
export { P2P_STATION_WAITS } from "./command-router.js";
|
|
13
14
|
export * as p2pCodec from "./codec.js";
|
|
@@ -63,12 +63,37 @@ export type LiveTrace =
|
|
|
63
63
|
phase: "sequence-restart";
|
|
64
64
|
dataType: number;
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Work on a station is holding for its session to connect, with the milliseconds it will wait.
|
|
68
|
+
*
|
|
69
|
+
* The earliest phase there is: nothing else on a station can be attempted until its session is up, and a
|
|
70
|
+
* caller whose own deadline expires inside this wait has this record and no other. Emitted only where a wait
|
|
71
|
+
* actually happens, so its absence states that the session was already connected.
|
|
72
|
+
*/
|
|
73
|
+
| {
|
|
74
|
+
phase: "session-connect-wait";
|
|
75
|
+
waitMs: number;
|
|
76
|
+
}
|
|
77
|
+
/** The session connected, after this long. */
|
|
78
|
+
| {
|
|
79
|
+
phase: "session-connected";
|
|
80
|
+
waitedMs: number;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The session did not connect within its wait, so nothing on this station can be attempted.
|
|
84
|
+
*
|
|
85
|
+
* The one outcome that is otherwise indistinguishable from a station that answered and then refused: both
|
|
86
|
+
* leave a caller with no media and no phase naming a station.
|
|
87
|
+
*/
|
|
88
|
+
| {
|
|
89
|
+
phase: "session-unreachable";
|
|
90
|
+
waitedMs: number;
|
|
91
|
+
}
|
|
66
92
|
/**
|
|
67
93
|
* A live start is holding for the station's level-2 key, with the milliseconds it will wait.
|
|
68
94
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* re-issued — and only these separate them.
|
|
95
|
+
* A start that looks slow is either waiting here, waiting for its session to connect, waiting for the station
|
|
96
|
+
* to serve the channel it was asked for, or being re-issued — and only these phases separate them.
|
|
72
97
|
*/
|
|
73
98
|
| {
|
|
74
99
|
phase: "level2-wait";
|
|
@@ -79,10 +104,63 @@ export type LiveTrace =
|
|
|
79
104
|
phase: "level2-ready";
|
|
80
105
|
cipherId: number;
|
|
81
106
|
}
|
|
82
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* The station's key is not coming, why, and the cipher where a station named one.
|
|
109
|
+
*
|
|
110
|
+
* Every ending of a level-2 wait carries one of these reasons, so a start refused for want of a key is
|
|
111
|
+
* accounted for however it ended. `grace-elapsed` is a wait that ran out and states how long was waited;
|
|
112
|
+
* the rest are answered without waiting, because the negotiation is one-shot per connection and a
|
|
113
|
+
* concluded one is final. `no-cipher-key` and `derivation-failed` are about this account's cipher
|
|
114
|
+
* material, `not-negotiating` and `session-closed` about the station or its connection — and only a
|
|
115
|
+
* reason reached under a negotiation has a cipher to name.
|
|
116
|
+
*
|
|
117
|
+
* A `grace-elapsed` start proceeds at level 1 where it has such a form, and not at all where it does not.
|
|
118
|
+
*/
|
|
119
|
+
| {
|
|
120
|
+
phase: "level2-unavailable";
|
|
121
|
+
reason: "no-cipher-key" | "derivation-failed" | "not-negotiating" | "session-closed" | "grace-elapsed";
|
|
122
|
+
cipherId?: number;
|
|
123
|
+
waitedMs?: number;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* A station's cipher was answered with material for a DIFFERENT cipher, which was used in its place.
|
|
127
|
+
*
|
|
128
|
+
* The one lookup outcome no other phase accounts for: material for the cipher the station named is followed
|
|
129
|
+
* by `level2-ready` or by `level2-unavailable` with `derivation-failed`, an answer holding none by
|
|
130
|
+
* `no-cipher-key`, and a lookup that threw is reported as an error. Substituted material derives to
|
|
131
|
+
* nothing and otherwise reads as a station fault. `cipherId` is the cipher the station asked for,
|
|
132
|
+
* `answeredCipherId` the one whose material was used.
|
|
133
|
+
*/
|
|
134
|
+
| {
|
|
135
|
+
phase: "cipher-fallback";
|
|
136
|
+
cipherId: number;
|
|
137
|
+
answeredCipherId: number;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The station answered its gateway-info prompt, so a key derivation has begun under the cipher it named.
|
|
141
|
+
*
|
|
142
|
+
* What separates a station that never answered the prompt from one that answered and produced no usable key:
|
|
143
|
+
* without it, `level2-unavailable` with `not-negotiating` covers both, and they are a station or network
|
|
144
|
+
* problem and an account cipher-material problem respectively.
|
|
145
|
+
*/
|
|
83
146
|
| {
|
|
84
|
-
phase: "level2-
|
|
85
|
-
|
|
147
|
+
phase: "level2-negotiating";
|
|
148
|
+
cipherId: number;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* A station was resolved for a call, stating what the caller's device is on it and whose station it is.
|
|
152
|
+
*
|
|
153
|
+
* Emitted before anything is sent, so it is the only account of the intended topology on a call that fails
|
|
154
|
+
* during resolution: an attached camera's media start has no unencrypted form, so whether a device was taken
|
|
155
|
+
* as attached decides what its failure means. `stationAdmin` states whether the signed-in account is the
|
|
156
|
+
* station's administrator, which is what a key the account cannot resolve turns on; `unstated` is a device
|
|
157
|
+
* record that names no administrator, which is not the same as naming another.
|
|
158
|
+
*/
|
|
159
|
+
| {
|
|
160
|
+
phase: "station-resolved";
|
|
161
|
+
topology: "attached" | "own";
|
|
162
|
+
channel: number;
|
|
163
|
+
stationAdmin: "self" | "other" | "unstated";
|
|
86
164
|
}
|
|
87
165
|
/** A shared source began warming, with the interval it re-issues on and the deadline it fails at. */
|
|
88
166
|
| {
|
|
@@ -208,6 +208,10 @@ export declare class P2PSession extends EventEmitter {
|
|
|
208
208
|
* cameras from that second group streamed normally at level-1 — including one of the same firmware as an
|
|
209
209
|
* own-session camera that delivered no video at all for a reason of its own. An expired grace therefore
|
|
210
210
|
* separates nothing on this path, and a start failure on such a session is not evidence about it.
|
|
211
|
+
*
|
|
212
|
+
* Every `false` answer carries a `level2-unavailable` trace naming its reason, wherever the wait ended: a
|
|
213
|
+
* `terminal` outcome is the one already stated where the negotiation concluded, since that is where the
|
|
214
|
+
* cipher and the cause are known, and re-stating it here would double every settled negotiation.
|
|
211
215
|
*/
|
|
212
216
|
awaitLevel2Key(graceMs: number, graceFrom?: "call" | "session"): Promise<boolean>;
|
|
213
217
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mega-yfue/eufy-sdk",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.3",
|
|
4
4
|
"description": "One typed TypeScript client for the Anker eufy v6 cloud — capability-driven devices, realtime events over P2P/MQTT/push, and live media",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "mega-yfue",
|