Build and sign
Compile, verify and sign a production .ngp package for every plugin kind.
A production plugin is one signed .ngp file. The build command differs by kind; the manifest, verifier and signature rules are identical.
Choose the kind#
| Kind | Payload | Signing | Restart after change |
|---|---|---|---|
ts (script) | script/main.js | Same JAR signature | Not for script-only changes |
java (code) | android/dex/classes.dex | Same JAR signature | Yes |
hybrid | both | Same JAR signature | Yes when the DEX changes |
TypeScript#
From the plugin project:
nextgram-plugin build
nextgram-plugin pack --key key.pem --cert cert.pem
nextgram-plugin verify build/*.ngppack rebuilds, validates plugin.json, collects plugin.json, assets/**, script/main.js, optional android/dex/classes.dex, LICENSE, README.md, CHANGELOG.md and i18n/**, then writes a deterministic ZIP and signs it.
Use --unsigned only for developer-mode testing. An unsigned package carries a permanent warning and is not accepted for a normal install.
Java and Kotlin#
Run these commands from NextGram-android/. The shell builder compiles the sources, produces one DEX at --min-api 23 and signs the package with JAR signing:
./gradlew :nextgram-plugin-sdk:compileJava :nextgram-plugin-sdk-android:assembleDebug
docs/plugins/tools/build-ngp.sh path/to/my-plugin hello.ngp
jarsigner -verify hello.ngpSigning reads NGP_KEYSTORE, NGP_KEY_ALIAS, NGP_STORE_PASS and NGP_KEY_PASS:
export NGP_KEYSTORE="$PWD/keys/release.jks"
export NGP_KEY_ALIAS="nextgram"
export NGP_STORE_PASS="…"
export NGP_KEY_PASS="…"
docs/plugins/tools/build-ngp.sh path/to/my-plugin hello.ngpWithout NGP_KEYSTORE the script creates a temporary development key. Never publish a package signed with it.
Create a signing key#
OpenSSL keys are used by the TypeScript CLI. EC P-256 is the recommended default:
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 \
-keyout key.pem -out cert.pem -days 3650 -nodes \
-subj "/CN=Your Plugin Publisher"RSA 2048 or larger also works:
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out key.pem
openssl req -x509 -new -key key.pem -out cert.pem -days 3650 \
-subj "/CN=Your Plugin Publisher"For the Java builder, create a PKCS#12 keystore:
keytool -genkeypair -keystore release.jks -storetype PKCS12 \
-storepass "$STORE_PASS" -keypass "$KEY_PASS" \
-alias nextgram -keyalg RSA -keysize 2048 -validity 10000 \
-dname "CN=Your Plugin Publisher"Keep the private key out of the repository and back it up. Losing it means you cannot ship an update to the same plugin ID; a different key is a different publisher.
What the signature covers#
The package uses standard JAR signing:
META-INF/MANIFEST.MFcarries a SHA-256 digest for every content entry;META-INF/NGP.SFcarriesSHA-256-Digest-Manifest;META-INF/NGP.RSA(RSA) orMETA-INF/NGP.EC(EC) carries a PKCS#7 detached signature overNGP.SF.
The verifier checks coverage: every content entry must be listed, and an entry added over the signature is rejected. Updates must use the same signing key as the installed version and a strictly higher versionCode. Downgrades are rejected.
Package preflight#
Before publishing, confirm:
- [ ]
idis immutable, lowercase reverse-DNS and not underapp.nextgram.*. - [ ]
versionis semver;versionCodeis higher than the installed and catalog versions. - [ ]
plugin.jsonis at most 256 KB and contains only documented fields. - [ ] The payload matches the kind: only
script/forts, onlyandroid/forjava, both forhybrid. - [ ] The package is at most 64 MB; the uncompressed total is at most 192 MB; there are at most 4096 entries.
- [ ]
script/main.jsis at most 8 MB;classes.dexis at most 32 MB. - [ ]
assets/icon.pngoricon.webpis at most 2 MB and at most 1024×1024. - [ ] No native libraries, nested archives, executable scripts, symlinks or
..paths. - [ ]
verifypasses andjarsigner -verifyreports a valid signature. - [ ] The signing key matches the previous release of this plugin ID.
Install and test#
Open the .ngp from a file manager, a chat document, the share sheet or NextGram Settings → Plugins → Install from file. The consent screen shows the publisher fingerprint, version, permissions and the trusted-code warning.
Test the plugin manager path as well: enable, disable, re-enable, update over an older version, then uninstall. A TypeScript-only plugin should reload live; a Java or hybrid plugin needs a restart when its DEX changes.
Publish#
The signed .ngp is attached to a GitHub Release, never committed. Catalog metadata, tag and asset naming are described in Catalog & updates.