prebuilt-tdlib
Advanced tools
Comparing version 0.1008030.0 to 0.1008033.0
@@ -0,5 +1,6 @@ | ||
/** Currently present for forward compatibility only. */ | ||
export type Options = { | ||
libc: 'glibc' | ||
readonly forceLibc?: 'glibc' | 'musl' | ||
} | ||
export declare function getTdjson(options?: Options): string |
58
index.js
// @flow | ||
const path = require('path') | ||
const fs = require('fs') | ||
const { prebuilds } = require('./prebuild-list') | ||
// For now, the `Options` object is present for forward compatibility. | ||
// TODO: Add an option like "fallback"? | ||
const SCOPE = '@prebuilt-tdlib' | ||
/*:: | ||
export type Options = { | ||
// Can be 'glibc' | 'musl' in the future | ||
libc: 'glibc' | ||
+forceLibc?: 'glibc' | 'musl' | ||
} | ||
*/ | ||
function prebuild (pathcomps/*: string[] */) { | ||
return path.resolve(__dirname, 'prebuilds', ...pathcomps) | ||
let libcNameCache = null | ||
function detectLibc ()/*: 'glibc' | 'musl' */ { | ||
// This function can return false results: it currently only checks for | ||
// Alpine Linux as a heuristic (the same approach is used by node-gyp-build). | ||
if (libcNameCache != null) return libcNameCache | ||
let result = 'glibc' | ||
try { | ||
if (fs.existsSync('/etc/alpine-release')) | ||
result = 'musl' | ||
} catch (e) { | ||
// Intentionally empty (defaults to 'glibc') | ||
} | ||
libcNameCache = result | ||
return result | ||
} | ||
// eslint-disable-next-line no-unused-vars | ||
function getTdjson (options/*:: ?: Options */)/*: string */ { | ||
const platform = process.platform + '-' + process.arch | ||
switch (platform) { | ||
case 'win32-x64': return prebuild(['tdlib-windows-x64', 'tdjson.dll']) | ||
case 'darwin-x64': return prebuild(['tdlib-macos', 'libtdjson.dylib']) | ||
case 'darwin-arm64': return prebuild(['tdlib-macos', 'libtdjson.dylib']) | ||
case 'linux-x64': return prebuild(['tdlib-linux-x64', 'libtdjson.so']) | ||
case 'android-x64': return prebuild(['tdlib-linux-x64', 'libtdjson.so']) | ||
default: throw new Error(`The ${platform} platform is not supported`) | ||
exports.getTdjson = function getTdjson (options/*:: ?: Options */)/*: string */ { | ||
let { platform, arch } = process | ||
if (platform === 'android') platform = 'linux' | ||
const libc = options?.forceLibc || (platform === 'linux' ? detectLibc() : null) | ||
for (const prebuild of prebuilds) { | ||
if (prebuild.requirements.os != null) | ||
if (!prebuild.requirements.os.includes(platform)) continue | ||
if (prebuild.requirements.cpu != null) | ||
if (!prebuild.requirements.cpu.includes(arch)) continue | ||
if (prebuild.libc != null && prebuild.libc !== libc) continue | ||
// Found a prebuild for the current platform | ||
const pkg = `${SCOPE}/${prebuild.packageName}/${prebuild.libfile}` | ||
try { | ||
return require.resolve(pkg) | ||
} catch (e) { | ||
throw new Error(`Could not load ${pkg} (are optionalDependencies installed?): ${e?.message}`) | ||
} | ||
} | ||
let entirePlatform = `${platform}-${arch}` | ||
if (libc != null) entirePlatform += '-' + libc | ||
throw new Error(`The ${entirePlatform} platform is not supported`) | ||
} | ||
module.exports = { getTdjson } |
{ | ||
"name": "prebuilt-tdlib", | ||
"version": "0.1008030.0", | ||
"version": "0.1008033.0", | ||
"description": "Pre-built TDLib libraries", | ||
@@ -12,7 +12,14 @@ "main": "index.js", | ||
"index.js", | ||
"prebuild-list.js", | ||
"index.d.ts", | ||
"prebuilds" | ||
"LICENSE.md" | ||
], | ||
"optionalDependencies": { | ||
"@prebuilt-tdlib/win32-x64": "0.1008033.0", | ||
"@prebuilt-tdlib/darwin": "0.1008033.0", | ||
"@prebuilt-tdlib/linux-x64-glibc": "0.1008033.0", | ||
"@prebuilt-tdlib/linux-arm64-glibc": "0.1008033.0" | ||
}, | ||
"author": "Bannerets <comonoid@protonmail.com>", | ||
"license": "MIT", | ||
"license": "BlueOak-1.0.0", | ||
"keywords": [ | ||
@@ -33,5 +40,5 @@ "telegram", | ||
"tdlib": { | ||
"commit": "fab354add5a257a8121a4a7f1ff6b1b9fa9a9073", | ||
"version": "1.8.30" | ||
"commit": "cb164927417f22811c74cd8678ed4a5ab7cb80ba", | ||
"version": "1.8.33" | ||
} | ||
} |
# Prebuilt TDLib | ||
This package distributes pre-built [TDLib][] shared libraries through npm. | ||
The libraries are built on GitHub Actions: [prebuilt-tdlib.yml][]. | ||
The libraries are built on GitHub Actions ([prebuilt-tdlib.yml][]) and published | ||
using [npm publish --provenance][npm-provenance]. | ||
[TDLib]: https://github.com/tdlib/td | ||
[prebuilt-tdlib.yml]: ../../.github/workflows/prebuilt-tdlib.yml | ||
[npm-provenance]: https://docs.npmjs.com/generating-provenance-statements | ||
The shared libraries are statically linked against OpenSSL and zlib to prevent | ||
compatibility issues in Node.js. | ||
Supported systems: | ||
- GNU/Linux x86_64 (requires glibc >= 2.17) | ||
- macOS x86_64, arm64 (universal, requires macOS >= 10.14) | ||
- Linux x86_64, arm64 (requires glibc >= 2.22) | ||
- macOS x86_64, arm64 (universal, requires macOS >= 10.12) | ||
- Windows x86_64 | ||
@@ -24,7 +23,7 @@ | ||
To install `prebuilt-tdlib` for a specific TDLib version, e.g. TDLib v1.8.29, | ||
To install `prebuilt-tdlib` for a specific TDLib version, e.g. TDLib v1.8.30, | ||
run: | ||
```console | ||
$ npm install prebuilt-tdlib@td-1.8.29 | ||
$ npm install prebuilt-tdlib@td-1.8.30 | ||
``` | ||
@@ -36,4 +35,9 @@ | ||
The TDLib version is important: there is no backward compatibility and the | ||
interface you use may significantly change after an update. | ||
interface you use may significantly change after an update. It is, though, | ||
recommended to use the latest TDLib version. | ||
The shared libraries are statically linked against OpenSSL and zlib, for one, to | ||
prevent compatibility issues in Node.js. libstdc++ is also linked statically | ||
(on Linux). | ||
## Usage | ||
@@ -116,3 +120,2 @@ | ||
| [![npm](https://img.shields.io/npm/v/prebuilt-tdlib/td-1.8.26.svg)](https://www.npmjs.com/package/prebuilt-tdlib/v/td-1.8.26) | [tdlib [b1b33cf42790ca10ef34abc2ac8828ae704f1f56](https://github.com/tdlib/td/commit/b1b33cf42790ca10ef34abc2ac8828ae704f1f56)] | | ||
| [![npm](https://img.shields.io/npm/v/prebuilt-tdlib/td-1.8.19.svg)](https://www.npmjs.com/package/prebuilt-tdlib/v/td-1.8.19) | | | ||
| [![npm](https://img.shields.io/npm/v/prebuilt-tdlib/td-1.8.14.svg)](https://www.npmjs.com/package/prebuilt-tdlib/v/td-1.8.14) | [tdlib [66234ae2537a99ec0eaf7b0857245a6e5c2d2bc9](https://github.com/tdlib/td/commit/66234ae2537a99ec0eaf7b0857245a6e5c2d2bc9)] | | ||
@@ -127,2 +130,23 @@ | [![npm](https://img.shields.io/npm/v/prebuilt-tdlib/td-1.8.12.svg)](https://www.npmjs.com/package/prebuilt-tdlib/v/td-1.8.12) | [tdlib [70bee089d492437ce931aa78446d89af3da182fc](https://github.com/tdlib/td/commit/70bee089d492437ce931aa78446d89af3da182fc)] | | ||
### 2024-07-19 | ||
First published as `prebuilt-tdlib@td-1.8.33`. | ||
The building process is significantly changed in this update. | ||
- Changed the structure of the package: instead of packing all binaries into the | ||
prebuilt-tdlib package, every binary is split into a separate package, and all | ||
the packages are specified in `optionalDependencies` of `prebuilt-tdlib`. The | ||
same approach is used by, e.g., esbuild and swc. This installs a binary for | ||
the user's system only, allowing `prebuilt-tdlib` to potentially scale for | ||
more architectures and libc variants. One downside is that `node_modules` | ||
can't simply be copied to a different platform anymore. | ||
- On macOS, TDLib is built using macOS SDK from nixpkgs, and the minimal | ||
supported macOS version is now 10.12 instead of 10.14. The arm64 macOS | ||
library is now tested in the CI using the macos-14 GitHub runner (and not | ||
crosscompiled anymore). | ||
- On Linux, TDLib is now built using zig. The minimal glibc version is 2.22 | ||
instead of 2.17. | ||
- Added a crosscompiled prebuild for Linux arm64. | ||
### 2024-05-08 | ||
@@ -129,0 +153,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 3 instances in 1 package
110
176
0
13478
4
6
2