@signalapp/ringrtc 2.23.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/dist/index.d.ts +4 -0
- package/dist/index.js +41 -0
- package/dist/ringrtc/Service.d.ts +520 -0
- package/dist/ringrtc/Service.js +1462 -0
- package/dist/ringrtc/VideoSupport.d.ts +66 -0
- package/dist/ringrtc/VideoSupport.js +421 -0
- package/dist/test/RingRTC-test.d.ts +1 -0
- package/dist/test/RingRTC-test.js +71 -0
- package/package.json +55 -0
- package/scripts/fetch-prebuild.js +86 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 Signal Messenger, LLC
|
|
3
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
/* eslint-disable no-console */
|
|
7
|
+
|
|
8
|
+
const https = require('https');
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const crypto = require('crypto');
|
|
12
|
+
const tar = require('tar');
|
|
13
|
+
const { Transform } = require('stream');
|
|
14
|
+
const { pipeline } = require('stream/promises');
|
|
15
|
+
|
|
16
|
+
const VERSION = process.env.npm_package_version;
|
|
17
|
+
const URL = process.env.npm_package_config_prebuildUrl.replace(
|
|
18
|
+
'${npm_package_version}', // eslint-disable-line no-template-curly-in-string
|
|
19
|
+
VERSION
|
|
20
|
+
);
|
|
21
|
+
const HASH = process.env.npm_package_config_prebuildChecksum;
|
|
22
|
+
|
|
23
|
+
const tmpFile = path.join(__dirname, 'unverified-prebuild.tmp');
|
|
24
|
+
const finalFile = path.join(__dirname, 'prebuild.tar.gz');
|
|
25
|
+
|
|
26
|
+
async function main() {
|
|
27
|
+
if (!HASH) {
|
|
28
|
+
console.log('(no checksum provided; assuming local build)');
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await downloadIfNeeded();
|
|
33
|
+
console.log('extracting...');
|
|
34
|
+
await tar.extract({ file: finalFile, onwarn: process.emitWarning });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function downloadIfNeeded() {
|
|
38
|
+
if (fs.statSync(finalFile, { throwIfNoEntry: false })) {
|
|
39
|
+
const hash = crypto.createHash('sha256');
|
|
40
|
+
await pipeline(fs.createReadStream(finalFile), hash);
|
|
41
|
+
if (hash.digest('hex') === HASH) {
|
|
42
|
+
console.log('local build artifact is up-to-date');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
console.log('local build artifact is outdated');
|
|
47
|
+
}
|
|
48
|
+
await download();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function download() {
|
|
52
|
+
console.log(`downloading ${URL}`);
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
https.get(URL, async res => {
|
|
55
|
+
try {
|
|
56
|
+
const out = fs.createWriteStream(tmpFile);
|
|
57
|
+
|
|
58
|
+
const hash = crypto.createHash('sha256');
|
|
59
|
+
|
|
60
|
+
const t = new Transform({
|
|
61
|
+
transform(chunk, encoding, callback) {
|
|
62
|
+
hash.write(chunk, encoding);
|
|
63
|
+
callback(null, chunk);
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
await pipeline(res, t, out);
|
|
68
|
+
|
|
69
|
+
const actualDigest = hash.digest('hex');
|
|
70
|
+
if (actualDigest !== HASH) {
|
|
71
|
+
fs.unlinkSync(tmpFile);
|
|
72
|
+
throw new Error(
|
|
73
|
+
`Digest mismatch. Expected ${HASH} got ${actualDigest}`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
fs.renameSync(tmpFile, finalFile);
|
|
78
|
+
resolve();
|
|
79
|
+
} catch (error) {
|
|
80
|
+
reject(error);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
main();
|