pushinbr / pam-native-plugin-kit
Scaffold, validate and generate typed PAM Native plugins.
Requires
- php: ^8.5
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
The official toolchain for building PAM Native plugins.
Validate plugin manifests, compile one typed IDL into PHP, Kotlin and Swift, scaffold cross-platform packages with CI, and certify them with a portable conformance report.
Install · Quick example · Typed IDL · Conformance · Docs · Issues
Install
Inside a PAM project, as a development tool:
pam composer require --dev pushinbr/pam-native-plugin-kit
The kit is plain PHP with no runtime dependency. Its CLI is vendor/bin/pam-native-plugin; run it on PAM's PHP runtime with pam exec as shown below. New to PAM? pam init my-app --template native creates a PAM Native project (see the PAM Native overview).
Quick example
pam exec vendor/bin/pam-native-plugin new acme/pam-native-biometric ./pam-native-biometric pam exec vendor/bin/pam-native-plugin validate ./pam-native-biometric/pam-native.plugin.json pam exec vendor/bin/pam-native-plugin compile ./pam-native-biometric/pam-native.idl.json ./generated pam exec vendor/bin/pam-native-plugin conformance ./pam-native-biometric --json > conformance.json
new writes a cross-platform package (pam-native.plugin.json, pam-native.idl.json, src/, android/, ios/, tests/, CI). compile writes Contracts.php, Contracts.kt and Contracts.swift. Every command exits non-zero on failure.
Platform support
| Platform | Support | Notes |
|---|---|---|
| PHP | 8.5+ | No other runtime dependency (composer.json) |
| Generated code | PHP · Kotlin · Swift | From one pam-native.idl.json |
| Scaffolded plugins | Android · iOS | Native SDK builds, device tests and signing stay in the plugin's own CI |
Typed IDL
Coded variants are integer enums with sequential values beginning at 1. The compiler rejects gaps and string variants so PHP, Kotlin and Swift cannot silently disagree about wire values.
{
"version": 1,
"namespace": "Acme.Biometric",
"enums": {
"AuthenticationState": {
"Pending": 1,
"Authenticated": 2,
"Rejected": 3
}
},
"records": {
"AuthenticationResult": {
"state": "AuthenticationState",
"reason": "string?"
}
}
}
Generated sources are deterministic and suitable for committing or checking in CI. The plugin manifest and IDL digests are recorded by PAM Native in .pam-native/plugins.lock.json. The schema is resources/pam-native.idl.schema.json.
Portable contributor certification
conformance is a non-mutating, dependency-free package audit that can run before native SDK jobs. It emits schema 1, Native surfaceCode: 2, sequential integer result/check codes, and SHA-256 evidence for seven bounded checks:
- manifest validation;
- typed IDL compilation;
- byte-for-byte PHP/Kotlin/Swift generation determinism;
- Composer plugin metadata;
- declared Kotlin source evidence;
- declared Swift source evidence;
- the portable PHP test entrypoint.
The runner reads at most 1 MiB per document, 256 native source files and 16 MiB per platform. Package paths are confined segment-by-segment; symlinks, traversal, duplicate source evidence and empty native source sets fail closed. The JSON contract is resources/pam-native-conformance.schema.json. This portable report does not replace Android/iOS compilation, device tests, signing or store validation.
API guide
| API | Responsibility |
|---|---|
Scaffolder |
Create a cross-platform plugin repository with CI. |
ManifestValidator |
Validate plugin metadata, native sources, and declared contracts. |
IdlCompiler |
Generate deterministic PHP, Kotlin, and Swift types from one IDL. |
ConformanceRunner / ConformanceReport |
Run the seven portable checks and export the report. |
Diagnostic / ValidationResult |
Consume typed validation findings in tooling or CI. |
All coded states, kinds, and variants are sequential integer-backed enums. Use enum cases in application code; do not depend on raw wire numbers.
Production checklist
- Commit generated sources and verify regeneration is clean in CI.
- Use sequential integer enums beginning at
1in every wire contract. - Pin native requirements and record manifest/IDL digests.
- Run
pam doctor,pam test, and a signed release build on every supported platform. - Exercise denial, cancellation, backgrounding, process restart, and offline behavior before release.
Troubleshooting
- Validation reports missing files: compare paths with the package root in the manifest.
- Generated languages disagree: remove handwritten copies and regenerate from the IDL.
- CI has a dirty diff: run compile locally and commit deterministic output.
- Native integration is stale: run
pam doctor --fix, rebuild the native host, and inspect the first reported diagnostic.
Report security vulnerabilities through the repository security policy or GitHub private vulnerability reporting, not a public issue.
Docs
- Package guide on pam-docs
- PAM Native overview
- Plugin and native capability model
- Changelog
- Report an issue
Part of the PAM ecosystem
PAM runs PHP natively on servers, desktops and phones. This repository is one piece of it.
| PAM | PAM Desktop | PAM Native | Ecosystem |
|---|---|---|---|
| the runtime and CLI | native desktop apps in PHP | native Android and iOS apps in PHP | every official package and plugin |
Docs: push-in.github.io/pam-docs · Issues
Apache License 2.0 · Made in Brazil by Pushin