@primeui/license-manager 1.0.0-alpha.1
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/LICENSE.md +62 -0
- package/README.md +167 -0
- package/dist/index.d.mts +187 -0
- package/dist/index.mjs +1 -0
- package/package.json +55 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# PrimeUI License Manager — License
|
|
2
|
+
|
|
3
|
+
Copyright © 2026 PrimeTek Informatics. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This package (`@primeui/license-manager`) is proprietary software owned by
|
|
6
|
+
PrimeTek Informatics ("PrimeTek"). It is distributed in compiled form via the
|
|
7
|
+
public npm registry solely to enable license verification for PrimeUI and
|
|
8
|
+
PrimeUI PRO products.
|
|
9
|
+
|
|
10
|
+
## Grant
|
|
11
|
+
|
|
12
|
+
PrimeTek grants you a non-exclusive, non-transferable, revocable license to
|
|
13
|
+
install and use this package as a runtime dependency of your application, for
|
|
14
|
+
the sole purpose of verifying license tokens issued by PrimeTek for PrimeUI and
|
|
15
|
+
PrimeUI PRO products.
|
|
16
|
+
|
|
17
|
+
## Restrictions
|
|
18
|
+
|
|
19
|
+
You may not:
|
|
20
|
+
|
|
21
|
+
1. Modify, adapt, translate, or create derivative works of this package, in
|
|
22
|
+
source or compiled form, including bundled copies in your own published
|
|
23
|
+
packages.
|
|
24
|
+
2. Reverse engineer, decompile, disassemble, or otherwise attempt to derive the
|
|
25
|
+
source code of, or to circumvent, the license verification mechanism — except
|
|
26
|
+
to the limited extent applicable law expressly permits despite this
|
|
27
|
+
restriction.
|
|
28
|
+
3. Forge, tamper with, replay across customers, or otherwise misuse license
|
|
29
|
+
tokens or signing keys.
|
|
30
|
+
4. Sublicense, sell, rent, lease, lend, or otherwise redistribute this package
|
|
31
|
+
as a standalone product or as part of a competing license-management
|
|
32
|
+
offering.
|
|
33
|
+
5. Remove or alter any copyright, trademark, or proprietary notices contained
|
|
34
|
+
in the package or its accompanying files.
|
|
35
|
+
|
|
36
|
+
## Ownership
|
|
37
|
+
|
|
38
|
+
This package, including all intellectual property rights in it, remains the
|
|
39
|
+
exclusive property of PrimeTek. No rights are granted to you by implication,
|
|
40
|
+
estoppel, or otherwise except as expressly set out in this license.
|
|
41
|
+
|
|
42
|
+
## Open Source Components
|
|
43
|
+
|
|
44
|
+
This package depends on third-party open source software, including
|
|
45
|
+
[`@noble/ed25519`](https://github.com/paulmillr/noble-ed25519) (MIT). Those
|
|
46
|
+
dependencies are governed by their own license terms, which are unaffected by
|
|
47
|
+
this license.
|
|
48
|
+
|
|
49
|
+
## No Warranty
|
|
50
|
+
|
|
51
|
+
THIS PACKAGE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
52
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
53
|
+
FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
54
|
+
PRIMETEK BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN
|
|
55
|
+
ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
|
56
|
+
WITH THIS PACKAGE OR THE USE OR OTHER DEALINGS IN IT.
|
|
57
|
+
|
|
58
|
+
## Termination
|
|
59
|
+
|
|
60
|
+
This license terminates automatically if you breach any of its terms. On
|
|
61
|
+
termination you must cease all use of the package and remove it from your
|
|
62
|
+
systems and distributions.
|
package/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# @primeui/license-manager
|
|
2
|
+
|
|
3
|
+
Offline license verifier for PrimeUI and PrimeUI PRO. Framework-agnostic — no Vue / React / Angular / Lit peer dependencies.
|
|
4
|
+
|
|
5
|
+
License keys are configured **once** at app bootstrap into a process-global registry. Every PrimeUI library and PrimeUI PRO component then reads from the same registry — no `licenseKey` prop on individual components, no second installer to wrap.
|
|
6
|
+
|
|
7
|
+
## App authors
|
|
8
|
+
|
|
9
|
+
If you use a Prime UI library (PrimeVue, PrimeReact, PrimeNG, PrimeFaces), pass your PrimeUI license token through that library's existing installer as a single string — it forwards it into this registry for you. You don't import this package directly in that case.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
// PrimeVue
|
|
13
|
+
app.use(PrimeVue, { theme: { ... }, license: 'PrimeUI-Commercial-key...' });
|
|
14
|
+
|
|
15
|
+
// PrimeReact
|
|
16
|
+
<PrimeReactProvider value={{ theme: { ... }, license: 'PrimeUI-Commercial-key...' }}>
|
|
17
|
+
|
|
18
|
+
// PrimeNG
|
|
19
|
+
providePrimeNG({ theme: { ... }, license: 'PrimeUI-Commercial-key...' });
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
A Commercial or OEM PrimeUI license covers every PRO component via the bundle rule, so this single string is enough for most apps.
|
|
23
|
+
|
|
24
|
+
If you're mixing standalone PRO buys, or using PRO components without a host Prime library, register the keys yourself before any licensed component mounts:
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { registerLicense } from '@primeui/license-manager';
|
|
28
|
+
|
|
29
|
+
registerLicense({
|
|
30
|
+
primeui: 'PrimeUI-Commercial-key...',
|
|
31
|
+
texteditor: 'PrimeUI-PRO-TextEditor-key...',
|
|
32
|
+
scheduler: 'PrimeUI-PRO-Scheduler-key...'
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Standalone PRO buyers configure the specific PRO key without a `primeui` key:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
registerLicense({ texteditor: 'PrimeUI-PRO-TextEditor-key...' });
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## PrimeUI PRO component authors
|
|
43
|
+
|
|
44
|
+
Inside your component, call `verifyLicense()` at mount time and surface a watermark when invalid.
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { verifyLicense } from '@primeui/license-manager';
|
|
48
|
+
import { RELEASE_DATE } from './release-date';
|
|
49
|
+
|
|
50
|
+
onMounted(async () => {
|
|
51
|
+
const result = await verifyLicense('texteditor', { releaseDate: RELEASE_DATE });
|
|
52
|
+
if (!result.valid) console.warn(`[PrimeUI TextEditor] ${result.message}`);
|
|
53
|
+
licenseResult.value = result;
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Verification is async (Ed25519 via WebCrypto). Do it on client mount, not during SSR render — license status is a UI concern, not a server-render concern, and threading async work into SSR is fragile.
|
|
58
|
+
|
|
59
|
+
## Prime library authors (PrimeVue / PrimeReact / PrimeNG integration)
|
|
60
|
+
|
|
61
|
+
Add `license?: string` to your installer's config and forward it to `registerLicense({ primeui: ... })` from the install hook. The user passes one token; you wire it into the registry.
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
// Sketch — inside PrimeVue's install hook
|
|
65
|
+
import { registerLicense } from '@primeui/license-manager';
|
|
66
|
+
|
|
67
|
+
export const PrimeVue = {
|
|
68
|
+
install(app, options) {
|
|
69
|
+
if (options?.license) registerLicense({ primeui: options.license });
|
|
70
|
+
// ... rest of PrimeVue setup
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
For a host-scoped service (rather than the global registry), use `createLicenseService` directly:
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
import { createLicenseService } from '@primeui/license-manager';
|
|
79
|
+
|
|
80
|
+
const service = createLicenseService({ primeui: options.license });
|
|
81
|
+
// stash in PrimeVue's own provide/inject so consumers can read it via usePrimeVue().license
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Short names → product identifiers
|
|
85
|
+
|
|
86
|
+
The `keys` object accepts these short names:
|
|
87
|
+
|
|
88
|
+
| Short name | Product identifier | Covers |
|
|
89
|
+
| ------------- | -------------------------- | -------------------------------------------- |
|
|
90
|
+
| `primeui` | `primeui` | PrimeNG / PrimeVue / PrimeReact / PrimeFaces |
|
|
91
|
+
| `texteditor` | `primeui-pro:text-editor` | PRO Text Editor |
|
|
92
|
+
| `scheduler` | `primeui-pro:scheduler` | PRO Scheduler |
|
|
93
|
+
| `charts` | `primeui-pro:charts` | PRO Charts |
|
|
94
|
+
| `diagram` | `primeui-pro:diagram` | PRO Diagram |
|
|
95
|
+
| `pdfviewer` | `primeui-pro:pdf-viewer` | PRO PDF Viewer |
|
|
96
|
+
| `taskboard` | `primeui-pro:task-board` | PRO Task Board |
|
|
97
|
+
| `datagrid` | `primeui-pro:datagrid` | PRO DataGrid |
|
|
98
|
+
| `ganttchart` | `primeui-pro:gantt-chart` | PRO Gantt |
|
|
99
|
+
| `filemanager` | `primeui-pro:file-manager` | PRO File Manager |
|
|
100
|
+
|
|
101
|
+
The registry first looks up the specific short name. If that key is missing (or returns `wrong-product`), it falls back to `keys.primeui` for any PRO component request. The verifier then accepts that token if its `tier` is `'commercial'`. Community PrimeUI tokens never validate PRO requests.
|
|
102
|
+
|
|
103
|
+
## License Tier + Type
|
|
104
|
+
|
|
105
|
+
Each signed `primeui` token carries two claims:
|
|
106
|
+
|
|
107
|
+
- `tier` — the SKU: `community` (free) or `commercial` (paid).
|
|
108
|
+
- `type` — the usage model: `dev` (standard) or `oem` (redistribution).
|
|
109
|
+
|
|
110
|
+
PRO tokens omit `tier` and carry `type: 'dev'` or `type: 'oem'`.
|
|
111
|
+
|
|
112
|
+
| Tier | Type | Behavior |
|
|
113
|
+
| ------------ | ----- | ------------------------------------------------------------------------------------------ |
|
|
114
|
+
| `community` | `dev` | Free, eligibility-gated. Annual re-confirmation. Time-bound (wall-clock grace). |
|
|
115
|
+
| `commercial` | `dev` | Paid perpetual. Library keeps working forever; only versions released after `exp` blocked. |
|
|
116
|
+
| `commercial` | `oem` | Paid annual redistribution license. Time-bound (wall-clock grace). |
|
|
117
|
+
|
|
118
|
+
Any token with `tier === 'commercial'` unlocks the PRO bundle rule. Community does not.
|
|
119
|
+
|
|
120
|
+
## Result
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
interface VerifyResult {
|
|
124
|
+
valid: boolean; // true when status is 'active' or 'grace'
|
|
125
|
+
status: 'active' | 'grace' | 'expired' | 'invalid' | 'wrong-product' | 'tampered' | 'unconfigured' | 'missing';
|
|
126
|
+
daysUntilExpiry?: number;
|
|
127
|
+
payload?: LicensePayload;
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
| status | meaning |
|
|
132
|
+
| --------------- | -------------------------------------------------------------------- |
|
|
133
|
+
| `active` | Verified, not yet expired |
|
|
134
|
+
| `grace` | Expired but within the 30-day grace period — library still works |
|
|
135
|
+
| `expired` | Past the grace period (or version released after `exp`) — red banner |
|
|
136
|
+
| `wrong-product` | Signed token doesn't cover the requested product |
|
|
137
|
+
| `tampered` | Signature check failed |
|
|
138
|
+
| `invalid` | Malformed token |
|
|
139
|
+
| `missing` | No key configured for this product (and no `primeui` fallback) |
|
|
140
|
+
| `unconfigured` | `registerLicense` was never called |
|
|
141
|
+
|
|
142
|
+
`grace` is a 30-day window after expiry — library remains functional, caller should surface a warning.
|
|
143
|
+
|
|
144
|
+
## SSR
|
|
145
|
+
|
|
146
|
+
Module-scoped state is the correct primitive for license keys (build-time config, not request-time). Under SSR:
|
|
147
|
+
|
|
148
|
+
- The host's installer re-runs per request and calls `registerLicense` again — idempotent with the same keys.
|
|
149
|
+
- PRO components defer the `verifyLicense` call to client-side mount (`onMounted` / `useEffect` / `ngOnInit`), not the SSR render pass. No watermark is rendered server-side; it appears after hydration if invalid.
|
|
150
|
+
|
|
151
|
+
## Low-level `verify()`
|
|
152
|
+
|
|
153
|
+
If you're verifying a single token without the registry:
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
import { verify } from '@primeui/license-manager';
|
|
157
|
+
|
|
158
|
+
const result = await verify(token, { product: 'primeui-pro:scheduler', releaseDate: '2026-04-23' });
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Keygen (internal, not for consumers)
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
pnpm --filter @primeui/license-manager keygen
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Paste `PRIVATE_KEY` into the store server env, embed `PUBLIC_KEY` in `src/constants.ts`, then publish.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SKU (tier) and usage model (type) on each license token. Two orthogonal
|
|
3
|
+
* fields on the store side:
|
|
4
|
+
*
|
|
5
|
+
* - `tier` answers "which SKU?": `community` (free) or `commercial` (paid).
|
|
6
|
+
* Only present on `product: 'primeui'` tokens; absent on PRO tokens.
|
|
7
|
+
* - `type` answers "what usage?": `dev` (standard) or `oem` (redistribution).
|
|
8
|
+
*/
|
|
9
|
+
type LicenseTier = 'community' | 'commercial';
|
|
10
|
+
type LicenseType = 'dev' | 'oem';
|
|
11
|
+
type LicenseStatus = 'active' | 'grace' | 'expired' | 'invalid' | 'wrong-product' | 'tampered' | 'unconfigured' | 'missing';
|
|
12
|
+
/**
|
|
13
|
+
* Short names customers use when configuring licenses. Each maps to a full
|
|
14
|
+
* product identifier via `PRODUCT_MAP`.
|
|
15
|
+
*/
|
|
16
|
+
type LicenseShortName = 'primeui' | 'scheduler' | 'texteditor' | 'charts' | 'diagram' | 'pdfviewer' | 'taskboard' | 'datagrid' | 'ganttchart' | 'filemanager';
|
|
17
|
+
/**
|
|
18
|
+
* Config the customer passes once at app bootstrap. Each entry holds one
|
|
19
|
+
* license token. When a PRO component request is made and the specific PRO
|
|
20
|
+
* key is missing, the registry falls back to `keys.primeui` — the verifier's
|
|
21
|
+
* bundle rule then accepts that token if its `tier` is `'commercial'`.
|
|
22
|
+
*/
|
|
23
|
+
type LicenseKeys = Partial<Record<LicenseShortName, string>>;
|
|
24
|
+
interface LicensePayload {
|
|
25
|
+
/** License key UUID from the store database. */
|
|
26
|
+
id: string;
|
|
27
|
+
/** Product identifier — 'primeui' or 'primeui-pro:<component>'. */
|
|
28
|
+
product: string;
|
|
29
|
+
/** SKU on primeui products: community or commercial. Absent on PRO tokens. */
|
|
30
|
+
tier?: LicenseTier;
|
|
31
|
+
/** Usage model: dev (standard) or oem (redistribution). */
|
|
32
|
+
type: LicenseType;
|
|
33
|
+
/** Issued-at unix seconds. */
|
|
34
|
+
iat: number;
|
|
35
|
+
/** Expiry unix seconds — matches update_ends_at. */
|
|
36
|
+
exp: number;
|
|
37
|
+
}
|
|
38
|
+
interface VerifyOptions {
|
|
39
|
+
/** The product this caller expects — e.g. 'primeui' or 'primeui-pro:scheduler'. */
|
|
40
|
+
product: string;
|
|
41
|
+
/** Display name used in the returned `message` — defaults to 'PrimeUI'. */
|
|
42
|
+
productLabel?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Release date of the package performing the check. ISO string ('2026-04-23')
|
|
45
|
+
* or unix seconds. Tokens whose `exp` is older than this date are rejected,
|
|
46
|
+
* which is how perpetual licenses are enforced: new versions released after
|
|
47
|
+
* the updates window aren't covered.
|
|
48
|
+
*/
|
|
49
|
+
releaseDate?: string | number;
|
|
50
|
+
/** Grace period in days after exp. Defaults to 30. Community / OEM only. */
|
|
51
|
+
graceDays?: number;
|
|
52
|
+
/** Override the embedded public key for dev/test builds. */
|
|
53
|
+
publicKeyOverride?: string;
|
|
54
|
+
}
|
|
55
|
+
interface VerifyResult {
|
|
56
|
+
/** true when status is 'active' or 'grace'. */
|
|
57
|
+
valid: boolean;
|
|
58
|
+
status: LicenseStatus;
|
|
59
|
+
/** Human-readable message suitable for display in a banner or console.warn. */
|
|
60
|
+
message: string;
|
|
61
|
+
/** Days until exp, can be negative if past exp. Only set when payload decoded. */
|
|
62
|
+
daysUntilExpiry?: number;
|
|
63
|
+
/** Decoded payload, only when signature verified. */
|
|
64
|
+
payload?: LicensePayload;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Optional second argument to {@link registerLicense} / `createLicenseService`.
|
|
68
|
+
* Dev/test escape hatches; production callers leave it off.
|
|
69
|
+
*/
|
|
70
|
+
interface LicenseConfig {
|
|
71
|
+
/** Override grace period in days (default 30). */
|
|
72
|
+
graceDays?: number;
|
|
73
|
+
/** Override the embedded public key for dev/test builds. */
|
|
74
|
+
publicKeyOverride?: string;
|
|
75
|
+
}
|
|
76
|
+
interface LicenseVerifyOptions {
|
|
77
|
+
/** Release date of the calling package. ISO string or unix seconds. */
|
|
78
|
+
releaseDate?: string | number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The thing PRO components and Prime libraries consume. Resolved either via
|
|
82
|
+
* {@link getLicenseService} (after a host called {@link registerLicense}) or
|
|
83
|
+
* built ad-hoc with {@link createLicenseService}.
|
|
84
|
+
*/
|
|
85
|
+
interface LicenseService {
|
|
86
|
+
/**
|
|
87
|
+
* Verify the license for a given short product name (e.g. 'texteditor').
|
|
88
|
+
* Falls back to `keys.primeui` for PRO components when the specific PRO key
|
|
89
|
+
* is missing — the verifier's bundle rule accepts a Commercial / OEM
|
|
90
|
+
* PrimeUI token for any PRO component request. Pass the calling package's
|
|
91
|
+
* `releaseDate` so perpetual licenses are enforced against version dates,
|
|
92
|
+
* not wall-clock time.
|
|
93
|
+
*/
|
|
94
|
+
verify(short: LicenseShortName, options?: LicenseVerifyOptions): Promise<VerifyResult>;
|
|
95
|
+
/** Whether any key is configured for this product (exact OR primeui bundle fallback). */
|
|
96
|
+
has(short: LicenseShortName): boolean;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
declare function verify(token: string, options: VerifyOptions): Promise<VerifyResult>;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Build a framework-agnostic license service from a keys object. Used by
|
|
103
|
+
* {@link registerLicense} for the process-global registry, and exported
|
|
104
|
+
* directly for hosts that want to manage their own service instance (e.g. a
|
|
105
|
+
* Prime library that scopes licenses to its own provider).
|
|
106
|
+
*
|
|
107
|
+
* `config` is optional and only used for dev/test overrides.
|
|
108
|
+
*/
|
|
109
|
+
declare function createLicenseService(keys: LicenseKeys, config?: LicenseConfig): LicenseService;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Register license keys with the process-global registry. Typically called by
|
|
113
|
+
* a host Prime library's installer (PrimeVue plugin, `providePrimeNG`,
|
|
114
|
+
* `<PrimeReactProvider>`), or directly by standalone PRO consumers before any
|
|
115
|
+
* licensed component mounts.
|
|
116
|
+
*
|
|
117
|
+
* ```ts
|
|
118
|
+
* registerLicense({
|
|
119
|
+
* primeui: 'PrimeUI-Commercial-key...',
|
|
120
|
+
* texteditor: 'PrimeUI-PRO-TextEditor-key...'
|
|
121
|
+
* });
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* Multiple calls overwrite — last call wins. Idempotent re-registration with
|
|
125
|
+
* the same keys (the common SSR / HMR case) is a no-op as far as consumers see.
|
|
126
|
+
*
|
|
127
|
+
* `config` is optional and only used for dev/test overrides.
|
|
128
|
+
*/
|
|
129
|
+
declare function registerLicense(keys: LicenseKeys, config?: LicenseConfig): LicenseService;
|
|
130
|
+
/**
|
|
131
|
+
* Retrieve the registered license service. Returns `null` when no host has
|
|
132
|
+
* called {@link registerLicense} yet — consumers should treat that as the
|
|
133
|
+
* `unconfigured` status.
|
|
134
|
+
*/
|
|
135
|
+
declare function getLicenseService(): LicenseService | null;
|
|
136
|
+
/**
|
|
137
|
+
* Verify a short product name against the global registry. Returns the
|
|
138
|
+
* `unconfigured` status if {@link registerLicense} has not been called.
|
|
139
|
+
*
|
|
140
|
+
* This is the entry point PRO components call at mount time:
|
|
141
|
+
*
|
|
142
|
+
* ```ts
|
|
143
|
+
* const result = await verifyLicense('scheduler', { releaseDate: __BUILD_DATE__ });
|
|
144
|
+
* if (!result.valid) showWatermark(result);
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
declare function verifyLicense(short: LicenseShortName, options?: LicenseVerifyOptions): Promise<VerifyResult>;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Grace period, in days, that extends past `exp`. Within this window the
|
|
151
|
+
* verifier returns status `grace` — library still works, but callers should
|
|
152
|
+
* surface a warning in the UI.
|
|
153
|
+
*/
|
|
154
|
+
declare const GRACE_DAYS = 30;
|
|
155
|
+
/** Canonical product identifier for the PrimeUI core libraries. */
|
|
156
|
+
declare const PRIMEUI_PRODUCT = "primeui";
|
|
157
|
+
/** Prefix for individual PRO component product identifiers. */
|
|
158
|
+
declare const PRIMEUI_PRO_PREFIX = "primeui-pro:";
|
|
159
|
+
/**
|
|
160
|
+
* Maps each customer-facing short key to the canonical product identifier
|
|
161
|
+
* embedded in signed license tokens. Framework adapters look here.
|
|
162
|
+
*/
|
|
163
|
+
declare const PRODUCT_MAP: {
|
|
164
|
+
readonly primeui: "primeui";
|
|
165
|
+
readonly scheduler: "primeui-pro:scheduler";
|
|
166
|
+
readonly texteditor: "primeui-pro:text-editor";
|
|
167
|
+
readonly charts: "primeui-pro:charts";
|
|
168
|
+
readonly diagram: "primeui-pro:diagram";
|
|
169
|
+
readonly pdfviewer: "primeui-pro:pdf-viewer";
|
|
170
|
+
readonly taskboard: "primeui-pro:task-board";
|
|
171
|
+
readonly datagrid: "primeui-pro:datagrid";
|
|
172
|
+
readonly ganttchart: "primeui-pro:gantt-chart";
|
|
173
|
+
readonly filemanager: "primeui-pro:file-manager";
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Human-readable display name for each short name. Adapters use this to feed
|
|
178
|
+
* `productLabel` into the core verifier so the returned `message` is pretty.
|
|
179
|
+
*/
|
|
180
|
+
declare const SHORT_NAME_LABELS: Record<LicenseShortName, string>;
|
|
181
|
+
/**
|
|
182
|
+
* Produce a standard human-readable message for a license status. Consumers
|
|
183
|
+
* don't usually call this — it's applied automatically to every `VerifyResult`.
|
|
184
|
+
*/
|
|
185
|
+
declare function formatLicenseMessage(status: LicenseStatus, productLabel?: string): string;
|
|
186
|
+
|
|
187
|
+
export { GRACE_DAYS, type LicenseConfig, type LicenseKeys, type LicensePayload, type LicenseService, type LicenseShortName, type LicenseStatus, type LicenseTier, type LicenseType, type LicenseVerifyOptions, PRIMEUI_PRODUCT, PRIMEUI_PRO_PREFIX, PRODUCT_MAP, SHORT_NAME_LABELS, type VerifyOptions, type VerifyResult, createLicenseService, formatLicenseMessage, getLicenseService, registerLicense, verify, verifyLicense };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"@noble/ed25519";var r=Object.defineProperty,t=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,a=(e,t,i)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,o=(e,r,t)=>new Promise((i,n)=>{var a=e=>{try{u(t.next(e))}catch(e){n(e)}},o=e=>{try{u(t.throw(e))}catch(e){n(e)}},u=e=>e.done?i(e.value):Promise.resolve(e.value).then(a,o);u((t=t.apply(e,r)).next())});function u(e){const r={};for(let e=0;e<64;e++)r["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"[e]]=e;const t=e.replace(/=+$/,""),i=Math.floor(6*t.length/8),n=new Uint8Array(i);let a=0,o=0,u=0;for(let e=0;e<t.length;e++){const i=r[t[e]];if(void 0===i)throw new Error("Invalid base64url character");a=a<<6|i,o+=6,o>=8&&(o-=8,n[u++]=a>>o&255)}return n}var c=30,s="primeui",l="primeui-pro:",d={primeui:"primeui",scheduler:"primeui-pro:scheduler",texteditor:"primeui-pro:text-editor",charts:"primeui-pro:charts",diagram:"primeui-pro:diagram",pdfviewer:"primeui-pro:pdf-viewer",taskboard:"primeui-pro:task-board",datagrid:"primeui-pro:datagrid",ganttchart:"primeui-pro:gantt-chart",filemanager:"primeui-pro:file-manager"},p={primeui:"PrimeUI",scheduler:"Scheduler",texteditor:"TextEditor",charts:"Charts",diagram:"Diagram",pdfviewer:"PDF Viewer",taskboard:"Task Board",datagrid:"DataGrid",ganttchart:"Gantt",filemanager:"File Manager"};function f(e,r="PrimeUI"){switch(e){case"active":return`${r} license is active.`;case"grace":return`${r} license is in its grace period. Renew soon to keep using this version.`;case"expired":return`${r} license does not cover this version. Renew at primeui.store, or downgrade to a version released within your updates window.`;case"tampered":return`${r} license signature is invalid.`;case"wrong-product":return`License does not cover ${r}.`;case"missing":return`No license key configured for ${r}.`;case"invalid":return`${r} license is malformed.`;case"unconfigured":return`${r} license is not configured.`;default:return`${r} license status unknown.`}}var m=864e5;function y(e,r,o={}){return((e,r)=>{for(var o in r||(r={}))i.call(r,o)&&a(e,o,r[o]);if(t)for(var o of t(r))n.call(r,o)&&a(e,o,r[o]);return e})({valid:"active"===e||"grace"===e,status:e,message:f(e,r)},o)}function g(r,t){return o(this,null,function*(){var i,n;const a=t.productLabel;if("string"!=typeof r||!r.includes("."))return y("invalid",a);const o=r.split(".");if(2!==o.length)return y("invalid",a);const[c,d]=o;let p,f,g;try{p=function(e){const r=u(e),t=(new TextDecoder).decode(r);return JSON.parse(t)}(c)}catch(e){return y("invalid",a)}if(!p||"object"!=typeof p||"string"!=typeof p.product||"string"!=typeof p.type||"number"!=typeof p.exp||"number"!=typeof p.iat||"string"!=typeof p.id)return y("invalid",a);try{f=u(d),g=(new TextEncoder).encode(c)}catch(e){return y("invalid",a)}const v=null!=(i=t.publicKeyOverride)?i:"dae75e66b9f59bebf87d4bb29ca6494f37deccfcc2b132b98ee159ee7505373b";let h;try{h=function(e){if(e.length%2!=0)throw new Error("Invalid hex length");const r=new Uint8Array(e.length/2);for(let t=0;t<r.length;t++)r[t]=parseInt(e.substr(2*t,2),16);return r}(v)}catch(e){return y("invalid",a)}let b=!1;try{b=yield e.verifyAsync(f,g,h)}catch(e){return y("tampered",a,{payload:p})}if(!b)return y("tampered",a,{payload:p});if(!function(e,r){return e.product===r||!(!r.startsWith(l)||e.product!==s||"commercial"!==e.tier)}(p,t.product))return y("wrong-product",a,{payload:p});const w=1e3*p.exp,x=Date.now(),D=Math.floor((w-x)/m),O=function(e){if(void 0===e)return null;if("number"==typeof e)return 1e3*e;const r=Date.parse(e);return Number.isNaN(r)?null:r}(t.releaseDate);if(null!==O&&O>w)return y("expired",a,{daysUntilExpiry:D,payload:p});if(function(e){return"oem"===e.type||"community"===e.tier}(p)){if(x>w+(null!=(n=t.graceDays)?n:30)*m)return y("expired",a,{daysUntilExpiry:D,payload:p});if(x>w)return y("grace",a,{daysUntilExpiry:D,payload:p})}return y("active",a,{daysUntilExpiry:D,payload:p})})}function v(e,r){return{valid:!1,status:e,message:f(e,r)}}function h(e,r){const t=null==r?void 0:r.graceDays,i=null==r?void 0:r.publicKeyOverride;return{verify(r,n){return o(this,null,function*(){var a;const o=d[r],u=null!=(a=p[r])?a:"PrimeUI",c=null==n?void 0:n.releaseDate;if(!o)return v("invalid",u);const s=e[r],f=e.primeui;if(s){const e=yield g(s,{product:o,productLabel:u,releaseDate:c,graceDays:t,publicKeyOverride:i});if(e.valid)return e;if("wrong-product"!==e.status)return e}return f&&"primeui"!==r&&o.startsWith(l)?g(f,{product:o,productLabel:u,releaseDate:c,graceDays:t,publicKeyOverride:i}):v(s?"wrong-product":"missing",u)})},has(r){const t=d[r];return!!t&&(!!e[r]||"primeui"!==r&&t.startsWith(l)&&!!e.primeui)}}}var b=null;function w(e,r){if(!e)throw new Error("[@primeui/license-manager] registerLicense: keys argument is required.");return b=h(e,r)}function x(){return b}function D(e,r){var t;if(!b){const r=null!=(t=p[e])?t:"PrimeUI";return Promise.resolve({valid:!1,status:"unconfigured",message:f("unconfigured",r)})}return b.verify(e,r)}export{c as GRACE_DAYS,s as PRIMEUI_PRODUCT,l as PRIMEUI_PRO_PREFIX,d as PRODUCT_MAP,p as SHORT_NAME_LABELS,h as createLicenseService,f as formatLicenseMessage,x as getLicenseService,w as registerLicense,g as verify,D as verifyLicense};
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@primeui/license-manager",
|
|
3
|
+
"version": "1.0.0-alpha.1",
|
|
4
|
+
"author": "PrimeTek Informatics",
|
|
5
|
+
"description": "Offline license verifier for PrimeUI and PrimeUI PRO",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"license",
|
|
8
|
+
"ed25519",
|
|
9
|
+
"primeng",
|
|
10
|
+
"primereact",
|
|
11
|
+
"primevue",
|
|
12
|
+
"primeui"
|
|
13
|
+
],
|
|
14
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/primefaces/primeuix.git",
|
|
18
|
+
"directory": "packages/license-manager"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/primefaces/primeuix/issues"
|
|
22
|
+
},
|
|
23
|
+
"main": "./dist/index.mjs",
|
|
24
|
+
"module": "./dist/index.mjs",
|
|
25
|
+
"types": "./dist/index.d.mts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.mts",
|
|
29
|
+
"import": "./dist/index.mjs",
|
|
30
|
+
"default": "./dist/index.mjs"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"sideEffects": false,
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"README.md",
|
|
40
|
+
"LICENSE"
|
|
41
|
+
],
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@noble/ed25519": "^2.3.0"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "cross-env NODE_ENV=production INPUT_DIR=src/ OUTPUT_DIR=dist/ pnpm run build:package",
|
|
47
|
+
"build:dev": "cross-env NODE_ENV=development INPUT_DIR=src/ OUTPUT_DIR=dist/ pnpm run build:dev:package",
|
|
48
|
+
"build:package": "pnpm run test && tsup",
|
|
49
|
+
"build:dev:package": "tsup --watch",
|
|
50
|
+
"test": "vitest run",
|
|
51
|
+
"type:check": "tsc --noEmit",
|
|
52
|
+
"dev:link": "pnpm link --global && npm link",
|
|
53
|
+
"keygen": "node scripts/generate-keys.mjs"
|
|
54
|
+
}
|
|
55
|
+
}
|