@middag-io/licensing
v0.2.0
Published
MIDDAG protected code delivery — build-time placeholder injection, manifest contract, and runtime loader for licensed JS modules
Downloads
276
Readme
@middag-io/licensing
Protected code delivery for MIDDAG products.
@middag-io/licensing standardizes how MIDDAG plugins (Moodle, WordPress,
and future hosts) ship licensed JavaScript modules through a CDN. The
package owns the technical contract (placeholders, manifest schema, types).
The licensing worker owns the policy (which install gets which module,
when, signed with what key).
Install
npm install @middag-io/licensingPublished to GitHub Packages (@middag-io scope). Configure .npmrc with
a token that has read:packages for installs and write:packages for
releases.
Subpath exports
| Import | Purpose |
|---|---|
| @middag-io/licensing | Shared contract types (CONTRACT_VERSION, PLACEHOLDERS, manifest interfaces). |
| @middag-io/licensing/contract | Same as root — explicit subpath. |
| @middag-io/licensing/build | Vite plugin and CLI helpers that inject placeholders and emit manifest.template.json. Node-only. |
| @middag-io/licensing/client | Runtime loader for the host. Validates the worker-issued manifest and dynamically imports protected modules. |
| @middag-io/licensing/anti-tamper | ADR-014 Layer 2: ClientIntegrityWatcher (prototype freeze + MutationObserver) + ClientIntegrityReporter (POST worker /v1/anti-tamper/client-report). |
| @middag-io/licensing/observability | ADR-015: ObservabilityClient + BatchSender + PerfCollector. Posts batched browser errors / perf / audit events to a host plugin relay (PHP signs+forwards). |
| @middag-io/licensing/telemetry | ADR-015 telemetry redirect: TelemetryClient + UsageTracker sugar over observability audit events. |
| @middag-io/licensing/remote-support | Optional AuditBanner widget rendering active session info on tenant admin dashboards (ADR-013 extended). |
Status
v0.2.0 — adds 4 new client subpaths matching worker contract v0.3.0
(ADR-013 extended remote support, ADR-014 anti-tamper, ADR-015
observability + telemetry). Initial v0.0.2 release shipped ADR-012
protected-delivery loader; that surface is unchanged. The Vite plugin emits manifest.template.json with SHA-384
hashes; the runtime loader verifies the worker-issued JWS against the
worker JWKS, validates the bootstrap (install / host / product /
contract version), and dynamic-imports modules with recomputed SRI.
Locked placeholder set (worker substitutes these per install):
__MIDDAG_HOST_ORIGIN____MIDDAG_INSTALL_ID____MIDDAG_KID____MIDDAG_BUNDLE_EXPIRES_AT____MIDDAG_NONCE__
Adding, removing, or renaming a token is a coordinated worker change
(src/lib/manifest-materialize.ts:PLACEHOLDERS) and a CONTRACT_VERSION
bump.
Design contract:
worker-ts-middag-licensing/docs/explanation/spec-licensing-js-lib.md.
Development
npm install
npm run build
npm run typecheck
npm run test
npm run lintRelease
npm run changesetto record the intent.- Merge to
main. The Release workflow opens a "Version Packages" PR. - Merge that PR to publish.
License
Proprietary — MIDDAG.
