@apocaliss92/scrypted-reolink-native 0.4.2 → 0.4.4
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/main.nodejs.js +1 -1
- package/dist/main.nodejs.js.LICENSE.txt +109 -0
- package/dist/plugin.zip +0 -0
- package/package.json +1 -1
- package/src/utils.ts +27 -6
|
@@ -1,9 +1,118 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2014, GMO GlobalSign
|
|
3
|
+
* Copyright (c) 2015-2022, Peculiar Ventures
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Author 2014-2019, Yury Strozhevsky
|
|
7
|
+
*
|
|
8
|
+
* Redistribution and use in source and binary forms, with or without modification,
|
|
9
|
+
* are permitted provided that the following conditions are met:
|
|
10
|
+
*
|
|
11
|
+
* * Redistributions of source code must retain the above copyright notice, this
|
|
12
|
+
* list of conditions and the following disclaimer.
|
|
13
|
+
*
|
|
14
|
+
* * Redistributions in binary form must reproduce the above copyright notice, this
|
|
15
|
+
* list of conditions and the following disclaimer in the documentation and/or
|
|
16
|
+
* other materials provided with the distribution.
|
|
17
|
+
*
|
|
18
|
+
* * Neither the name of the copyright holder nor the names of its
|
|
19
|
+
* contributors may be used to endorse or promote products derived from
|
|
20
|
+
* this software without specific prior written permission.
|
|
21
|
+
*
|
|
22
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
23
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
24
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
25
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
26
|
+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
27
|
+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
28
|
+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
29
|
+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
30
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
31
|
+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/*!
|
|
36
|
+
* MIT License
|
|
37
|
+
*
|
|
38
|
+
* Copyright (c) Peculiar Ventures. All rights reserved.
|
|
39
|
+
*
|
|
40
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
41
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
42
|
+
* in the Software without restriction, including without limitation the rights
|
|
43
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
44
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
45
|
+
* furnished to do so, subject to the following conditions:
|
|
46
|
+
*
|
|
47
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
48
|
+
* copies or substantial portions of the Software.
|
|
49
|
+
*
|
|
50
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
51
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
52
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
53
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
54
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
55
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
56
|
+
* SOFTWARE.
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/*!
|
|
61
|
+
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
62
|
+
*
|
|
63
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
64
|
+
* Released under the MIT License.
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
/*!
|
|
68
|
+
* isobject <https://github.com/jonschlinkert/isobject>
|
|
69
|
+
*
|
|
70
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
71
|
+
* Released under the MIT License.
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
/*! *****************************************************************************
|
|
75
|
+
Copyright (C) Microsoft. All rights reserved.
|
|
76
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
77
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
78
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
79
|
+
|
|
80
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
81
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
82
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
83
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
84
|
+
|
|
85
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
86
|
+
and limitations under the License.
|
|
87
|
+
***************************************************************************** */
|
|
88
|
+
|
|
89
|
+
/*! *****************************************************************************
|
|
90
|
+
Copyright (c) Microsoft Corporation.
|
|
91
|
+
|
|
92
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
93
|
+
purpose with or without fee is hereby granted.
|
|
94
|
+
|
|
95
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
96
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
97
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
98
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
99
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
100
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
101
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
102
|
+
***************************************************************************** */
|
|
103
|
+
|
|
104
|
+
/*! MIT License. Copyright 2015-2018 Richard Moore <me@ricmoo.com>. See LICENSE.txt. */
|
|
105
|
+
|
|
1
106
|
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
|
2
107
|
|
|
3
108
|
/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
|
|
4
109
|
|
|
5
110
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
6
111
|
|
|
112
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
113
|
+
|
|
114
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
115
|
+
|
|
7
116
|
/*! ws. MIT License. Einar Otto Stangvik <einaros@gmail.com> */
|
|
8
117
|
|
|
9
118
|
/**
|
package/dist/plugin.zip
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -202,9 +202,9 @@ export async function recordingFileToVideoClip(
|
|
|
202
202
|
resources:
|
|
203
203
|
videoHref || thumbnailHref
|
|
204
204
|
? {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
...(videoHref ? { video: { href: videoHref } } : {}),
|
|
206
|
+
...(thumbnailHref ? { thumbnail: { href: thumbnailHref } } : {}),
|
|
207
|
+
}
|
|
208
208
|
: undefined,
|
|
209
209
|
};
|
|
210
210
|
}
|
|
@@ -311,6 +311,21 @@ export async function getVideoClipWebhookUrls(props: {
|
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
+
const getHeader = (headers: Record<string, any> | undefined, key: string) => {
|
|
315
|
+
return headers?.[key] ?? headers?.[key.toLowerCase()] ?? headers?.[key.toUpperCase()];
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export const getVideoclipClientInfo = (request: HttpRequest) => {
|
|
319
|
+
return {
|
|
320
|
+
userAgent: getHeader(request.headers, 'user-agent') ?? getHeader(request.headers, 'User-Agent'),
|
|
321
|
+
accept: getHeader(request.headers, 'accept') ?? getHeader(request.headers, 'Accept'),
|
|
322
|
+
range: getHeader(request.headers, 'range') ?? getHeader(request.headers, 'Range'),
|
|
323
|
+
secChUa: getHeader(request.headers, 'sec-ch-ua') ?? getHeader(request.headers, 'Sec-CH-UA'),
|
|
324
|
+
secChUaMobile: getHeader(request.headers, 'sec-ch-ua-mobile') ?? getHeader(request.headers, 'Sec-CH-UA-Mobile'),
|
|
325
|
+
secChUaPlatform: getHeader(request.headers, 'sec-ch-ua-platform') ?? getHeader(request.headers, 'Sec-CH-UA-Platform'),
|
|
326
|
+
};
|
|
327
|
+
};
|
|
328
|
+
|
|
314
329
|
/**
|
|
315
330
|
* Handle video clip webhook request
|
|
316
331
|
* Uses progressive streaming for immediate playback.
|
|
@@ -380,6 +395,11 @@ export async function handleVideoClipRequest(props: {
|
|
|
380
395
|
};
|
|
381
396
|
api.client.on("error", onClientError);
|
|
382
397
|
|
|
398
|
+
const clientInfo = getVideoclipClientInfo(request);
|
|
399
|
+
const ua = (clientInfo.userAgent ?? '').toLowerCase();
|
|
400
|
+
const isIos = /iphone|ipad|ipod/.test(ua);
|
|
401
|
+
const isIosInstalledApp = ua.includes('installedapp');
|
|
402
|
+
|
|
383
403
|
// Use streaming replay - this starts immediately and produces fMP4 chunks
|
|
384
404
|
// Stream management (stopping previous streams, cooldown) is handled by the API layer
|
|
385
405
|
// Generate a unique session ID based on client fingerprint (UA + IP + other factors)
|
|
@@ -387,8 +407,8 @@ export async function handleVideoClipRequest(props: {
|
|
|
387
407
|
const clientFingerprint = [
|
|
388
408
|
request.headers?.["user-agent"] || "",
|
|
389
409
|
request.headers?.["x-forwarded-for"] ||
|
|
390
|
-
|
|
391
|
-
|
|
410
|
+
request.headers?.["x-real-ip"] ||
|
|
411
|
+
"",
|
|
392
412
|
request.headers?.["accept-language"] || "",
|
|
393
413
|
request.headers?.["accept-encoding"] || "",
|
|
394
414
|
].join("|");
|
|
@@ -405,6 +425,7 @@ export async function handleVideoClipRequest(props: {
|
|
|
405
425
|
isNvr: device.isOnNvr,
|
|
406
426
|
logger,
|
|
407
427
|
deviceId: sessionId,
|
|
428
|
+
transcodeH265ToH264: isIos && isIosInstalledApp,
|
|
408
429
|
});
|
|
409
430
|
|
|
410
431
|
let totalSize = 0;
|
|
@@ -422,7 +443,7 @@ export async function handleVideoClipRequest(props: {
|
|
|
422
443
|
} finally {
|
|
423
444
|
// Remove the error handler
|
|
424
445
|
api.client.off("error", onClientError);
|
|
425
|
-
await stop().catch(() => {});
|
|
446
|
+
await stop().catch(() => { });
|
|
426
447
|
}
|
|
427
448
|
})(),
|
|
428
449
|
{
|