licenx 0.0.0-stage → 1.0.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/CHANGELOG.md +4 -0
- package/LICENSE +21 -0
- package/README.md +6 -2
- package/dist/THIRD_PARTY_NOTICES.txt +15918 -0
- package/dist/background.d.ts +2 -0
- package/dist/background.js +67 -0
- package/dist/build-info.json +8 -0
- package/dist/client.d.ts +37 -0
- package/dist/client.js +322 -0
- package/dist/identity.d.ts +4 -0
- package/dist/identity.js +35 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/messaging.d.ts +11 -0
- package/dist/messaging.js +17 -0
- package/dist/session.d.ts +6 -0
- package/dist/session.js +10 -0
- package/dist/storage.d.ts +14 -0
- package/dist/storage.js +58 -0
- package/dist/transport.d.ts +23 -0
- package/dist/transport.js +98 -0
- package/dist/types.d.ts +83 -0
- package/dist/types.js +26 -0
- package/dist/wasm/licenx_wasm.d.ts +77 -0
- package/dist/wasm/licenx_wasm.js +672 -0
- package/dist/wasm/licenx_wasm_bg.wasm +0 -0
- package/dist/wasm/licenx_wasm_bg.wasm.d.ts +28 -0
- package/dist/wasm-loader.d.ts +3 -0
- package/dist/wasm-loader.js +14 -0
- package/docs/API_REFERENCE.md +21 -0
- package/docs/BUILD_AND_RELEASE.md +9 -0
- package/docs/COMPATIBILITY.md +7 -0
- package/docs/CONFIGURATION.md +17 -0
- package/docs/GUIDE_BN.md +19 -0
- package/docs/GUIDE_EN.md +19 -0
- package/docs/INTEGRATION_EXAMPLES.md +19 -0
- package/docs/LIFECYCLE.md +7 -0
- package/docs/QUICK_START.md +14 -0
- package/docs/README.md +5 -0
- package/docs/SECURITY.md +7 -0
- package/docs/TROUBLESHOOTING.md +19 -0
- package/examples/chrome/background.js +4 -0
- package/examples/chrome/manifest.json +23 -0
- package/examples/chrome/popup.html +4 -0
- package/examples/chrome/popup.js +12 -0
- package/examples/firefox/background.js +4 -0
- package/examples/firefox/manifest.json +36 -0
- package/examples/firefox/popup.html +4 -0
- package/examples/firefox/popup.js +12 -0
- package/licenx.config.example.json +10 -0
- package/package.json +41 -4
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import init, { Bridge } from "../dist/wasm/licenx_wasm.js";
|
|
2
|
+
import { LicenXError } from "./types.js";
|
|
3
|
+
let initialized;
|
|
4
|
+
export async function loadWasm() {
|
|
5
|
+
// Static local module and same-package binary; no remote URL, eval or JS fallback.
|
|
6
|
+
initialized ??= init({ module_or_path: new URL("./wasm/licenx_wasm_bg.wasm", import.meta.url) });
|
|
7
|
+
try {
|
|
8
|
+
await initialized;
|
|
9
|
+
return Bridge;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
throw new LicenXError("INITIALIZATION_FAILED");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# JS/TypeScript public API
|
|
2
|
+
|
|
3
|
+
The local package exports Client, registerBackground, LicenXError and types Config, Options, Status, State, Stats, StatValue, LogoutOutcome, ErrorCode. All network/lifecycle methods are async. Only a single privileged background should own a Client.
|
|
4
|
+
|
|
5
|
+
| Method | Meaning |
|
|
6
|
+
|---|---|
|
|
7
|
+
| Client.create(config, options?) | validates config/permission, stable installation ID, local WASM; does not grant auth |
|
|
8
|
+
| client.login(key) / autoLogin(key) | fresh online verification, candidate-first replacement |
|
|
9
|
+
| client.recover() | fresh signed proof for optional saved active hint; pending reconciliation |
|
|
10
|
+
| client.ping() | signed heartbeat |
|
|
11
|
+
| client.tick() | alarm callback, recover/ping/reconcile |
|
|
12
|
+
| client.status() | current Status, permission checked; stale state reverified |
|
|
13
|
+
| client.isAuthenticated() / isValid() | current verified decision |
|
|
14
|
+
| client.hasLoginSession() | UI hint only |
|
|
15
|
+
| client.deviceIdentity | opaque app-install ID; do not log/export |
|
|
16
|
+
| client.logout() | Released, AlreadyLoggedOut or RemoteUnconfirmed |
|
|
17
|
+
| client.reportStats(stats) | explicit non-sensitive scalar metric report |
|
|
18
|
+
| client.invalidatePermission() | pause and invalidate current permission epoch |
|
|
19
|
+
| registerBackground(config, options?, popupPath?) | synchronous listener registration; singleton lifecycle |
|
|
20
|
+
|
|
21
|
+
Popup messages: {action:"login",key}, {action:"status"}, {action:"ping"}, {action:"logout"}, {action:"reportStats",stats}. Replies contain only ok/status/outcome or ok:false/code, not key/proof/token. Status contains authorized, hasLoginSession, state, tier (null unless authorized), pendingRelease. State: LoggedOut, Online, HttpFallback, OfflineGrace, PausedUnverified. No browser WSS state. Errors are stable typed codes; no raw network body/secret.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Build and release (v1.0.0 candidate)
|
|
2
|
+
|
|
3
|
+
Authorized GitHub-hosted qualification uses the frozen lockfiles and reuses the accepted Rust 1.93.0 / wasm-bindgen 0.2.130 binary only with exact source and SHA256 evidence. Local JS/TS and WASM are packaged with dependency notices, own LICENSE and separate Chromium/Firefox MV3 examples. Candidate files: licenx-chrome.zip, licenx-firefox.zip and licenx-1.0.0.tgz. Exact tarball installation, actual installed browser integration, SHA256 manifest, dependency/security/license audit, SBOM and provenance are required.
|
|
4
|
+
|
|
5
|
+
The proposed npm name is licenx, version 1.0.0. Verify personal account and unscoped first-publication authority, version availability and exact approved bytes before a separately authorized publication. The release preflight is read-only. Browser store signing is separate. No production, registry or store release claim.
|
|
6
|
+
|
|
7
|
+
[English guide](GUIDE_EN.md) · [বাংলা গাইড](GUIDE_BN.md) · [Compatibility](COMPATIBILITY.md)
|
|
8
|
+
|
|
9
|
+
The owner selected the unscoped public npm name `licenx`. After official publication, install with `npm install licenx@1.0.0`. The npm tarball is metadata-only repackaged from the previously qualified archive; Rust crates and browser ZIPs remain byte-identical. Rust crates are GitHub Release assets only; crates.io publication is deferred.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Compatibility — candidate
|
|
2
|
+
|
|
3
|
+
Browser target: Chromium MV3 module service worker, Firefox MV3 nonpersistent module background. Supported exact browser versions require observed hosted test receipts; no Edge/Brave/Safari/store-distribution assertion. Temporary Firefox add-on installation is development testing only. storage.session support required for opt-in; otherwise default RAM-only. Browser trust store supplies TLS roots, no custom insecure options. Local WebAssembly and CSP support required.
|
|
4
|
+
|
|
5
|
+
No browser WebSocket under current native ticket contract; signed HTTPS only. No native hardware fingerprint or automatic Python/Rust native device equivalence. Actual existing backend integration, store/registry package distribution and production parity are separate gates. Existing Python v1.2.9 and native WSS unchanged.
|
|
6
|
+
|
|
7
|
+
Prior installed-extension fixture qualification passed on Chromium 141.0.7390.37 and Firefox 161.0. These versions are observed test targets, not minimum-version guarantees.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
Config is the shared literal JSON shape; options are passed separately to Client.create or registerBackground.
|
|
4
|
+
|
|
5
|
+
| Field | Value |
|
|
6
|
+
|---|---|
|
|
7
|
+
| server_url | HTTPS origin only; exact port/origin pinned; optional trailing /api normalized |
|
|
8
|
+
| public_key_pem | owner-verified SPKI RSA 2048–4096 or Ed25519 PEM |
|
|
9
|
+
| app_name / app_version | exact trimmed slug / actual host version, 1–128 bytes |
|
|
10
|
+
| ping_interval_seconds | 60–1200, default 1200 |
|
|
11
|
+
| offline_grace_seconds | 0–3600, default 0; no offline initial login |
|
|
12
|
+
| request_timeout_seconds | 1–35, default 10, ping max 20 |
|
|
13
|
+
| useWebSocket | false or omitted; true returns UNSUPPORTED_TRANSPORT |
|
|
14
|
+
| options.retainSession | false default; true requires restricted storage.session |
|
|
15
|
+
| popupPath | exact trusted extension popup path, default popup.html |
|
|
16
|
+
|
|
17
|
+
Use the browser trust store; no extra CA or TLS bypass API. Match pattern https://hostname/* scopes a host (browser-specific port behavior); Fetch pins exact configured origin including port. The SDK will not request broad permissions automatically. Do not include secrets in config.
|
package/docs/GUIDE_BN.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# সম্পূর্ণ বাংলা Integration Guide
|
|
2
|
+
|
|
3
|
+
## Installation ও configuration
|
|
4
|
+
Reviewed candidate ZIP extract করে dist folder অক্ষত রাখুন। manifest.json-এ exact HTTPS host pattern এবং background.js-এ server_url, app_name, actual app_version, independently owner-verified public PEM বসান। Chrome/Chromium MV3 module service worker এবং Firefox MV3 nonpersistent module background example আলাদা। storage/alarms ছাড়া অপ্রয়োজনীয় permission দেবেন না। Browser developer page থেকে unpacked/temporary extension load করুন; store signing বা official registry release আলাদা।
|
|
5
|
+
|
|
6
|
+
## Device identity ও key
|
|
7
|
+
প্রতিটি server origin + app slug + installation-এর জন্য CSPRNG দিয়ে random 128-bit ID তৈরি হয়। Durable storage.local-এ শুধু ID, license key/proof/token/authorization নয়। Reset/uninstall-এর পর ID বদলাতে পারে, নতুন device slot লাগতে পারে; আগে logout করুন। Python/native HWID automatic migration নেই। Default RAM-only। retainSession:true দিলে browser-supported restricted storage.session-এ active/pending key hint রাখা যায়; এটি encrypted vault নয়, trusted extension code/user দেখতে পারে। storage.sync/local-এ key রাখবেন না।
|
|
8
|
+
|
|
9
|
+
## Login ও protected action
|
|
10
|
+
Local dist/index.js থেকে registerBackground import করে manifest-এর background-এ ব্যবহার করুন। Configured popup-এর runtime.sendMessage({action:"login",key}) দিয়ে login; input clear করুন। WASM shared Rust core RSA/Ed25519 signature, nonce এবং app/key/installation binding verify করে; server response-এর public_key trust নয়। status.authorized true না হলে protected কাজ চলবে না; hasLoginSession শুধু UI hint। প্রতি protected কাজের আগে fresh status check করুন; server resource-এর authorization server নিজেই করবে।
|
|
11
|
+
|
|
12
|
+
## Worker suspension, heartbeat ও recovery
|
|
13
|
+
Startup/install/alarm/message listener synchronous registration হয়। Browser sleep/throttle করলে alarm দেরি হতে পারে; monotonic freshness/signed expiry পেরোলে authorization বন্ধ। retainSession:true থাকলে restarted worker প্রথমে fresh signed active ping, তারপর signed validation করে; cached status দিয়ে unlock নয়। Opt-in না থাকলে worker suspend-এর পরে আবার key দিন। Signed terminal denial local session clear করে; TLS/signature/permission failure pause করে। Default grace 0, শুধু নির্দিষ্ট transient failure-তে bounded configured grace। Offline first login নেই।
|
|
14
|
+
|
|
15
|
+
## Replacement, statistics ও logout
|
|
16
|
+
Candidate key আগে verify, তারপর পুরোনো binding v2 proof দিয়ে release। Same-key revalidation নিজের slot release করে না। পুরোনো release unconfirmed হলে candidate cleanup চেষ্টা, old UI paused; pending cleanup reconcile না হলে নতুন binding নয়। reportStats explicit non-sensitive scalar metric পাঠায় signed capability নিয়ে; report নিজে lease renew করে না, automatic collection নেই। Logout local auth বন্ধ করে; Released = confirmed HTTPS success; AlreadyLoggedOut = active binding নিশ্চিত নেই; RemoteUnconfirmed = remote release নিশ্চিত নয়, retry করুন। Browser crash/uninstall-এ release guarantee নেই। Storage error হলে আগে ঠিক করুন; orphan slot-এর জন্য operator control প্রয়োজন হতে পারে।
|
|
17
|
+
|
|
18
|
+
## Security ও compatibility
|
|
19
|
+
HTTPS Fetch, browser TLS/hostname check, exact host permission, no redirect/cookie/referrer; local WASM এবং CSP-তে শুধু wasm-unsafe-eval। Browser WSS unsupported: useWebSocket:true reject হয়; existing server Origin/Bearer guard বদলানো হয়নি। Content script বা arbitrary website-এর জন্য generic request proxy করবেন না। কোনো private signing key, Admin token বা license key source/log-এ রাখবেন না। Local WASM tamper-proof নয়। API_REFERENCE, SECURITY, LIFECYCLE, CONFIGURATION ও TROUBLESHOOTING পড়ুন।
|
package/docs/GUIDE_EN.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# English integration guide
|
|
2
|
+
|
|
3
|
+
## Install and configure
|
|
4
|
+
Use reviewed local candidate bytes, not a remote script/CDN. Copy dist into the extension package; add the exact HTTPS hostname in host_permissions and fill the public configuration in background.js. The manifest examples use Chromium MV3 module service worker and Firefox MV3 nonpersistent module background script. Keep only storage/alarms permissions and the required host. Do not expose the SDK as a web-accessible resource, external message API or general fetch proxy. See QUICK_START.
|
|
5
|
+
|
|
6
|
+
## Identity and credentials
|
|
7
|
+
The background creates a cryptographically random 128-bit ID, scoped to exact server origin and app slug. The only durable SDK data is that installation ID. Reinstall/reset can change it and consume a new device slot; release before reset. No hardware fingerprint or automatic Python/native identity migration. Default keys/proofs are RAM-only. Explicit retainSession:true stores active/pending key hints in restricted storage.session, if supported. It is not an encrypted vault; other trusted extension code and the user can inspect it. No proof/ticket/stats capability or authorization flag is stored. Never use storage.local/sync for keys.
|
|
8
|
+
|
|
9
|
+
## Login and authorization
|
|
10
|
+
Use registerBackground from the packaged module; allow only the configured popup sender and login/status/ping/logout/reportStats actions. Popup calls runtime.sendMessage({action:"login",key}) and immediately clears input. The shared WASM verifier uses configured RSA/Ed25519 PEM, fresh CSPRNG nonce and request binding, not a response-supplied key. status.authorized is the licensing decision; hasLoginSession only indicates UI state. Check fresh status on every protected operation; never trust a previously displayed UI label. Server resources require their own authorization.
|
|
11
|
+
|
|
12
|
+
## Recovery and heartbeat
|
|
13
|
+
The background registers startup/install/alarm/message listeners synchronously. Browser alarms are best-effort and may be delayed by sleep/throttling. Authorization expires on monotonic freshness and signed expiry, even when alarms are delayed. With opt-in session storage, a restarted background requires fresh signed active ping then full signed validation; no offline initial login or restore of cached authorization. Without opt-in, re-enter key after worker suspension. Signed terminal denial clears local state. Unverified TLS, permission, signature or format failure pauses; only bounded configured grace for known timeout/rate/service failures. The default is zero grace.
|
|
14
|
+
|
|
15
|
+
## Replacement, stats and logout
|
|
16
|
+
Candidate validation precedes old proof-bound v2 release. Same key does not release its own binding. Failed release retains old UI paused and attempts candidate cleanup; pending keys are reconciled before another binding. Explicit reportStats sends non-sensitive scalar metrics using a fresh signed capability; the report does not renew the lease. No automatic metrics collection. Logout immediately clears local authorization and reconciles proof-bound release. Released confirms success; AlreadyLoggedOut means no active binding was confirmed; RemoteUnconfirmed requires retry. Browser shutdown/uninstall cannot guarantee remote release. If storage is failing, fix it before recovery; use operator/device controls for orphaned slots.
|
|
17
|
+
|
|
18
|
+
## Transport and limits
|
|
19
|
+
HTTPS Fetch only, exact pinned origin/host permission, no redirects/cookies/referrer, bounded response and timeout, browser certificate/hostname validation. Browser WebSocket cannot supply the native one-use Authorization header and existing server refuses Origin-bearing ticket requests; useWebSocket:true is rejected. No header spoofing or server security change. Local WASM/JS is modifiable, so do not claim crack-proof enforcement. See API_REFERENCE, SECURITY, LIFECYCLE and TROUBLESHOOTING.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Integration examples
|
|
2
|
+
|
|
3
|
+
Copy dist into the packaged extension root. See examples/chrome and examples/firefox for separate runnable MV3 manifests and popup. Set background.js public config and exact HTTPS host; use local imports only.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
import {registerBackground} from "./dist/index.js";
|
|
7
|
+
registerBackground(config, {retainSession: false}, "popup.html");
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
In trusted popup (never an externally connectable page):
|
|
11
|
+
```js
|
|
12
|
+
const api = globalThis.browser ?? globalThis.chrome;
|
|
13
|
+
const reply = await api.runtime.sendMessage({action: "status"});
|
|
14
|
+
if (reply.ok && reply.status.authorized) {
|
|
15
|
+
// Enable a local licensed action only for this current verified decision.
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
For a custom background, Client.create(config,{retainSession:true}) plus await client.recover(); register alarms and permission removal and own exactly one serialized Client. Do not run multiple owners for the same app. For explicit telemetry use reportStats({jobs_completed:3}); no secrets or identifiers. On logout inspect outcome and retry RemoteUnconfirmed. Use dedicated noncustomer fixture keys only for test, never embed keys in code.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Lifecycle
|
|
2
|
+
|
|
3
|
+
Create: permission + durable scoped ID + local WASM + optional restricted RAM-session hints -> LoggedOut. Login requires signed active response bound to fresh nonce/key/app/HWID -> Online. Ping is a fresh signed proof -> HttpFallback (shared core label, HTTPS-only). A verified terminal denial -> LoggedOut. Unverified TLS/signature/format/permission -> PausedUnverified. Timeout/rate/service may enter bounded OfflineGrace for an existing valid session, default 0. Expired signed license or monotonic freshness never grants access.
|
|
4
|
+
|
|
5
|
+
Candidate-first replacement verifies new key; same-key no unbind; old v2 release required before committing candidate; failed release pauses old session and attempts candidate cleanup. Pending key hints are reconciled before another binding. Serialized background queue prevents stale response races. Logout clears local state immediately and releases through proof-bound v2; retry signed proof once on 403. Signed DEVICE_UNBOUND establishes no active binding, not a successful release receipt.
|
|
6
|
+
|
|
7
|
+
Worker/event-page startup registers listeners before async init; alarms drive tick, stale status rechecks signed proof. Optional volatile recovery requires active signed ping before full validate; no offline cached authorization. A real browser restart clears storage.session; opt-in does not promise disk recovery. Delayed/suspended alarms do not extend freshness. Shutdown/uninstall may leave remote slot until lease expiration; use explicit logout.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Quick start
|
|
2
|
+
|
|
3
|
+
1. Obtain the reviewed candidate archive for Chromium or Firefox. Unzip it; keep the packaged dist directory intact.
|
|
4
|
+
2. In manifest.json replace https://license.example.invalid/* with your exact approved HTTPS host match pattern (no wildcard hostname). In background.js fill server_url, exact app_name, app_version and owner-verified public signing key PEM. Default retainSession:false, useWebSocket:false. Never embed a license key or private key.
|
|
5
|
+
3. Chromium: load the unpacked directory in the browser extensions developer page. Firefox: temporarily load manifest.json via about:debugging, This Firefox. Store distribution/signing is separate.
|
|
6
|
+
4. Open the example popup, enter a dedicated test key, choose Login, Verify, then Logout. Enable licensed operations only from a fresh background status.authorized; RemoteUnconfirmed means no confirmed remote slot release.
|
|
7
|
+
5. To integrate a custom background, copy dist and use the local module:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import {registerBackground} from "./dist/index.js";
|
|
11
|
+
registerBackground(config,{retainSession:false},"popup.html");
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The manifest's extension_pages CSP needs script-src 'self' 'wasm-unsafe-eval'; object-src 'none'; never add unsafe-eval. Do not use a content script as a privileged license proxy. See the full guides for optional volatile recovery.
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Browser SDK documentation
|
|
2
|
+
|
|
3
|
+
[Quick start](QUICK_START.md) · [English guide](GUIDE_EN.md) · [বাংলা গাইড](GUIDE_BN.md) · [Configuration](CONFIGURATION.md) · [API reference](API_REFERENCE.md) · [Security](SECURITY.md) · [Lifecycle](LIFECYCLE.md) · [Integration examples](INTEGRATION_EXAMPLES.md) · [Compatibility](COMPATIBILITY.md) · [Troubleshooting](TROUBLESHOOTING.md) · [Build and release](BUILD_AND_RELEASE.md).
|
|
4
|
+
|
|
5
|
+
The shared protocol is [SDK/protocol/CONTRACT.md](../../../protocol/CONTRACT.md). Existing server and Python are unchanged. The native Rust SDK still supports WSS; browser does not.
|
package/docs/SECURITY.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Security boundary
|
|
2
|
+
|
|
3
|
+
Use only trusted extension background and exact popup sender URL/runtime ID. No external messaging, content script, web-accessible WASM, generic URL/request/signing proxy or wildcard host. Local WASM verified using the accepted Rust core; no JS fallback. CSP script-src 'self' 'wasm-unsafe-eval'; object-src 'none' allows WebAssembly compilation, not JavaScript eval. No remote scripts or insecure TLS/Origin workaround. Fetch credentials omitted, redirects fail, exact origin and host permission checked before/after requests; permission epoch rejects late response after removal. Unknown Fetch failure is ambiguous TLS/network and pauses, not guessed grace.
|
|
4
|
+
|
|
5
|
+
Durable data only installation ID scoped by origin/app; optional storage.session active/pending key hints restricted to trusted contexts (Chrome explicit access level; Firefox default). Not encrypted against trusted extension/user. No persistent authorization, signing private key, logout proof, WSS ticket or stats token. Never log secrets or expose to popup except user-provided input. Storage failures fail closed locally. A failed write/removal can leave a previous browser-managed record; repair storage, retry explicit logout or operator release. Recovery always requires new signed server proof, never cached grant. Stats must not contain sensitive values even if shape validation passes.
|
|
6
|
+
|
|
7
|
+
Client is modifiable; no tamper-proof DRM or server authorization bypass. Shutdown/uninstall cannot guarantee release. [Shared security](../../../protocol/SECURITY.md).
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Troubleshooting
|
|
2
|
+
|
|
3
|
+
| Codes | Safe action |
|
|
4
|
+
|---|---|
|
|
5
|
+
| CONFIG_INVALID / UNSUPPORTED_TRANSPORT | HTTPS origin, exact app/version/public PEM; disable browser WSS |
|
|
6
|
+
| INITIALIZATION_FAILED | verify local generated WASM+JS, CSP and package integrity; no JS fallback |
|
|
7
|
+
| IDENTITY_UNAVAILABLE / RANDOM_UNAVAILABLE / STORAGE_UNAVAILABLE | restore trusted browser storage/CSPRNG; do not generate arbitrary fallback IDs |
|
|
8
|
+
| PERMISSION_DENIED | grant only configured HTTPS host permission; fresh signed proof required |
|
|
9
|
+
| MESSAGE_DENIED | use exact configured popup and supported action/schema |
|
|
10
|
+
| AUTH_REJECTED | check app/key/version/slot with operator |
|
|
11
|
+
| SIGNATURE_FAILED / VALIDATION_BINDING_FAILED / INVALID_RESPONSE / DENIAL_UNVERIFIED | pause, verify trusted signing key/protocol; no bypass |
|
|
12
|
+
| TLS_OR_TRANSPORT_UNVERIFIED | repair browser CA/hostname/network; no insecure retries |
|
|
13
|
+
| TIMEOUT / SERVER_UNREACHABLE / SERVICE_UNAVAILABLE / RATE_LIMITED | bounded retry, no offline initial auth |
|
|
14
|
+
| LICENSE_TERMINATED | signed terminal denial, explicit new login |
|
|
15
|
+
| NOT_AUTHORIZED / SESSION_CHANGED | refresh signed state, do not trust old UI |
|
|
16
|
+
| PREVIOUS_SESSION_LOGOUT_FAILED / INVALID_LOGOUT_PROOF | retry v2 reconciliation; RemoteUnconfirmed is not released |
|
|
17
|
+
| INVALID_STATS / STATS_UNAVAILABLE | explicit bounded scalar non-sensitive metrics |
|
|
18
|
+
|
|
19
|
+
If worker sleeps, re-open popup or rely on alarm; default RAM-only session requires re-entry, optional session storage must reverify. Never print key/proof/token or raw response.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import {registerBackground} from "./dist/index.js";
|
|
2
|
+
// Replace only with owner-verified public configuration, not a secret.
|
|
3
|
+
const config = {server_url:"https://license.example.invalid",public_key_pem:"REPLACE_WITH_TRUSTED_PUBLIC_PEM",app_name:"your-app",app_version:"1.0.0",ping_interval_seconds:1200,offline_grace_seconds:0,useWebSocket:false};
|
|
4
|
+
registerBackground(config,{retainSession:false});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_version": 3,
|
|
3
|
+
"name": "LicenX SDK Example",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Local WASM signed HTTPS license integration",
|
|
6
|
+
"permissions": [
|
|
7
|
+
"storage",
|
|
8
|
+
"alarms"
|
|
9
|
+
],
|
|
10
|
+
"host_permissions": [
|
|
11
|
+
"https://license.example.invalid/*"
|
|
12
|
+
],
|
|
13
|
+
"action": {
|
|
14
|
+
"default_popup": "popup.html"
|
|
15
|
+
},
|
|
16
|
+
"content_security_policy": {
|
|
17
|
+
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'none';"
|
|
18
|
+
},
|
|
19
|
+
"background": {
|
|
20
|
+
"service_worker": "background.js",
|
|
21
|
+
"type": "module"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>LicenX SDK Example</title></head>
|
|
3
|
+
<body><h1>LicenX</h1><form id="login"><label for="key">License key</label><input id="key" type="password" autocomplete="off" required maxlength="160"><button type="submit">Login</button></form>
|
|
4
|
+
<button id="ping">Verify</button><button id="logout">Logout</button><button id="refresh">Refresh status</button><p id="status" role="status">Checking…</p><script type="module" src="popup.js"></script></body></html>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const api=globalThis.browser??globalThis.chrome;
|
|
2
|
+
const output=document.getElementById("status");
|
|
3
|
+
async function send(message){
|
|
4
|
+
try{const result=await api.runtime.sendMessage(message);
|
|
5
|
+
output.textContent=result?.ok?(result.outcome?result.outcome+" · ":"")+(result.status.authorized?"Verified":"Not authorized")+" · "+result.status.state:(result?.code??"INITIALIZATION_FAILED");
|
|
6
|
+
}catch{output.textContent="INITIALIZATION_FAILED";}
|
|
7
|
+
}
|
|
8
|
+
document.getElementById("login").addEventListener("submit",event=>{
|
|
9
|
+
event.preventDefault();const input=document.getElementById("key");const key=input.value;input.value="";void send({action:"login",key});
|
|
10
|
+
});
|
|
11
|
+
for(const [id,action] of [["ping","ping"],["logout","logout"],["refresh","status"]])document.getElementById(id).addEventListener("click",()=>void send({action}));
|
|
12
|
+
void send({action:"status"});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import {registerBackground} from "./dist/index.js";
|
|
2
|
+
// Replace only with owner-verified public configuration, not a secret.
|
|
3
|
+
const config = {server_url:"https://license.example.invalid",public_key_pem:"REPLACE_WITH_TRUSTED_PUBLIC_PEM",app_name:"your-app",app_version:"1.0.0",ping_interval_seconds:1200,offline_grace_seconds:0,useWebSocket:false};
|
|
4
|
+
registerBackground(config,{retainSession:false});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_version": 3,
|
|
3
|
+
"name": "LicenX SDK Example",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Local WASM signed HTTPS license integration",
|
|
6
|
+
"permissions": [
|
|
7
|
+
"storage",
|
|
8
|
+
"alarms"
|
|
9
|
+
],
|
|
10
|
+
"host_permissions": [
|
|
11
|
+
"https://license.example.invalid/*"
|
|
12
|
+
],
|
|
13
|
+
"action": {
|
|
14
|
+
"default_popup": "popup.html"
|
|
15
|
+
},
|
|
16
|
+
"content_security_policy": {
|
|
17
|
+
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'none';"
|
|
18
|
+
},
|
|
19
|
+
"background": {
|
|
20
|
+
"scripts": [
|
|
21
|
+
"background.js"
|
|
22
|
+
],
|
|
23
|
+
"type": "module"
|
|
24
|
+
},
|
|
25
|
+
"browser_specific_settings": {
|
|
26
|
+
"gecko": {
|
|
27
|
+
"id": "licenx-example@vibtools.invalid",
|
|
28
|
+
"strict_min_version": "128.0",
|
|
29
|
+
"data_collection_permissions": {
|
|
30
|
+
"required": [
|
|
31
|
+
"none"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>LicenX SDK Example</title></head>
|
|
3
|
+
<body><h1>LicenX</h1><form id="login"><label for="key">License key</label><input id="key" type="password" autocomplete="off" required maxlength="160"><button type="submit">Login</button></form>
|
|
4
|
+
<button id="ping">Verify</button><button id="logout">Logout</button><button id="refresh">Refresh status</button><p id="status" role="status">Checking…</p><script type="module" src="popup.js"></script></body></html>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const api=globalThis.browser??globalThis.chrome;
|
|
2
|
+
const output=document.getElementById("status");
|
|
3
|
+
async function send(message){
|
|
4
|
+
try{const result=await api.runtime.sendMessage(message);
|
|
5
|
+
output.textContent=result?.ok?(result.outcome?result.outcome+" · ":"")+(result.status.authorized?"Verified":"Not authorized")+" · "+result.status.state:(result?.code??"INITIALIZATION_FAILED");
|
|
6
|
+
}catch{output.textContent="INITIALIZATION_FAILED";}
|
|
7
|
+
}
|
|
8
|
+
document.getElementById("login").addEventListener("submit",event=>{
|
|
9
|
+
event.preventDefault();const input=document.getElementById("key");const key=input.value;input.value="";void send({action:"login",key});
|
|
10
|
+
});
|
|
11
|
+
for(const [id,action] of [["ping","ping"],["logout","logout"],["refresh","status"]])document.getElementById(id).addEventListener("click",()=>void send({action}));
|
|
12
|
+
void send({action:"status"});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"server_url": "https://license.example.invalid",
|
|
3
|
+
"public_key_pem": "REPLACE_WITH_TRUSTED_PUBLIC_PEM",
|
|
4
|
+
"app_name": "your-app",
|
|
5
|
+
"app_version": "1.0.0",
|
|
6
|
+
"ping_interval_seconds": 1200,
|
|
7
|
+
"offline_grace_seconds": 0,
|
|
8
|
+
"request_timeout_seconds": 10,
|
|
9
|
+
"useWebSocket": false
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "licenx",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "LicenX browser extension SDK with local WASM and signed HTTPS",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"docs",
|
|
19
|
+
"examples",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"CHANGELOG.md",
|
|
23
|
+
"licenx.config.example.json"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "node scripts/build.mjs",
|
|
27
|
+
"package": "node scripts/package.mjs",
|
|
28
|
+
"test": "node --experimental-strip-types --test tests/client.test.ts tests/lifecycle.test.ts tests/security.test.ts",
|
|
29
|
+
"test:browser": "node --experimental-strip-types --test tests/package.test.ts"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"typescript": "5.9.3",
|
|
33
|
+
"playwright": "1.56.1"
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/vibtoolshq/LicenX.git",
|
|
38
|
+
"directory": "SDK/client/browser-extension"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
}
|
|
43
|
+
}
|