@xemahq/license-verifier 0.1.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.
Files changed (98) hide show
  1. package/README.md +224 -0
  2. package/dist/bin/xema-license-keygen.d.ts +3 -0
  3. package/dist/bin/xema-license-keygen.d.ts.map +1 -0
  4. package/dist/bin/xema-license-keygen.js +63 -0
  5. package/dist/bin/xema-license-keygen.js.map +1 -0
  6. package/dist/bin/xema-license-mint-oss.d.ts +3 -0
  7. package/dist/bin/xema-license-mint-oss.d.ts.map +1 -0
  8. package/dist/bin/xema-license-mint-oss.js +70 -0
  9. package/dist/bin/xema-license-mint-oss.js.map +1 -0
  10. package/dist/embedded/license-material.generated.d.ts +4 -0
  11. package/dist/embedded/license-material.generated.d.ts.map +1 -0
  12. package/dist/embedded/license-material.generated.js +7 -0
  13. package/dist/embedded/license-material.generated.js.map +1 -0
  14. package/dist/index.d.ts +13 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +50 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/lib/base64url.d.ts +4 -0
  19. package/dist/lib/base64url.d.ts.map +1 -0
  20. package/dist/lib/base64url.js +31 -0
  21. package/dist/lib/base64url.js.map +1 -0
  22. package/dist/lib/compact-jws.d.ts +16 -0
  23. package/dist/lib/compact-jws.d.ts.map +1 -0
  24. package/dist/lib/compact-jws.js +47 -0
  25. package/dist/lib/compact-jws.js.map +1 -0
  26. package/dist/lib/effective-license.d.ts +28 -0
  27. package/dist/lib/effective-license.d.ts.map +1 -0
  28. package/dist/lib/effective-license.js +39 -0
  29. package/dist/lib/effective-license.js.map +1 -0
  30. package/dist/lib/embedded-license.d.ts +7 -0
  31. package/dist/lib/embedded-license.d.ts.map +1 -0
  32. package/dist/lib/embedded-license.js +26 -0
  33. package/dist/lib/embedded-license.js.map +1 -0
  34. package/dist/lib/evaluate-entitlement.d.ts +28 -0
  35. package/dist/lib/evaluate-entitlement.d.ts.map +1 -0
  36. package/dist/lib/evaluate-entitlement.js +84 -0
  37. package/dist/lib/evaluate-entitlement.js.map +1 -0
  38. package/dist/lib/evaluate-limit.d.ts +18 -0
  39. package/dist/lib/evaluate-limit.d.ts.map +1 -0
  40. package/dist/lib/evaluate-limit.js +49 -0
  41. package/dist/lib/evaluate-limit.js.map +1 -0
  42. package/dist/lib/license-claims.d.ts +29 -0
  43. package/dist/lib/license-claims.d.ts.map +1 -0
  44. package/dist/lib/license-claims.js +3 -0
  45. package/dist/lib/license-claims.js.map +1 -0
  46. package/dist/lib/license-enums.d.ts +47 -0
  47. package/dist/lib/license-enums.d.ts.map +1 -0
  48. package/dist/lib/license-enums.js +58 -0
  49. package/dist/lib/license-enums.js.map +1 -0
  50. package/dist/lib/license-signer.d.ts +16 -0
  51. package/dist/lib/license-signer.d.ts.map +1 -0
  52. package/dist/lib/license-signer.js +35 -0
  53. package/dist/lib/license-signer.js.map +1 -0
  54. package/dist/lib/oss-license.d.ts +3 -0
  55. package/dist/lib/oss-license.d.ts.map +1 -0
  56. package/dist/lib/oss-license.js +27 -0
  57. package/dist/lib/oss-license.js.map +1 -0
  58. package/dist/lib/parse-license-claims.d.ts +8 -0
  59. package/dist/lib/parse-license-claims.d.ts.map +1 -0
  60. package/dist/lib/parse-license-claims.js +0 -0
  61. package/dist/lib/parse-license-claims.js.map +1 -0
  62. package/dist/lib/render-license-material.d.ts +8 -0
  63. package/dist/lib/render-license-material.d.ts.map +1 -0
  64. package/dist/lib/render-license-material.js +55 -0
  65. package/dist/lib/render-license-material.js.map +1 -0
  66. package/dist/lib/resolve-license-state.d.ts +20 -0
  67. package/dist/lib/resolve-license-state.d.ts.map +1 -0
  68. package/dist/lib/resolve-license-state.js +74 -0
  69. package/dist/lib/resolve-license-state.js.map +1 -0
  70. package/dist/lib/rfc3339.d.ts +2 -0
  71. package/dist/lib/rfc3339.d.ts.map +1 -0
  72. package/dist/lib/rfc3339.js +24 -0
  73. package/dist/lib/rfc3339.js.map +1 -0
  74. package/dist/lib/sign-license.d.ts +4 -0
  75. package/dist/lib/sign-license.d.ts.map +1 -0
  76. package/dist/lib/sign-license.js +27 -0
  77. package/dist/lib/sign-license.js.map +1 -0
  78. package/dist/lib/trust-store.d.ts +7 -0
  79. package/dist/lib/trust-store.d.ts.map +1 -0
  80. package/dist/lib/trust-store.js +32 -0
  81. package/dist/lib/trust-store.js.map +1 -0
  82. package/dist/lib/verification-failure.d.ts +17 -0
  83. package/dist/lib/verification-failure.d.ts.map +1 -0
  84. package/dist/lib/verification-failure.js +19 -0
  85. package/dist/lib/verification-failure.js.map +1 -0
  86. package/dist/lib/verified-license.d.ts +10 -0
  87. package/dist/lib/verified-license.d.ts.map +1 -0
  88. package/dist/lib/verified-license.js +8 -0
  89. package/dist/lib/verified-license.js.map +1 -0
  90. package/dist/lib/verify-license.d.ts +13 -0
  91. package/dist/lib/verify-license.d.ts.map +1 -0
  92. package/dist/lib/verify-license.js +98 -0
  93. package/dist/lib/verify-license.js.map +1 -0
  94. package/dist/signing.d.ts +4 -0
  95. package/dist/signing.d.ts.map +1 -0
  96. package/dist/signing.js +10 -0
  97. package/dist/signing.js.map +1 -0
  98. package/package.json +56 -0
package/README.md ADDED
@@ -0,0 +1,224 @@
1
+ <p align="center">
2
+ <svg width="680" height="120" viewBox="0 0 680 120" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="@xemahq/license-verifier">
3
+ <rect width="680" height="120" rx="14" fill="#0B1020"/>
4
+ <g transform="translate(28,34)">
5
+ <path d="M26 0 L52 15 L52 45 L26 60 L0 45 L0 15 Z" fill="#8B5CF6" opacity="0.18"/>
6
+ <path d="M26 12 L41 21 L41 39 L26 48 L11 39 L11 21 Z" fill="#8B5CF6"/>
7
+ </g>
8
+ <text x="92" y="52" font-family="ui-monospace,SFMono-Regular,Menlo,monospace" font-size="22" fill="#F8FAFC" font-weight="700">@xemahq/license-verifier</text>
9
+ <text x="92" y="80" font-family="ui-sans-serif,system-ui,sans-serif" font-size="15" fill="#94A3B8">Offline verification of a Xema license</text>
10
+ <text x="652" y="105" text-anchor="end" font-family="ui-sans-serif,system-ui,sans-serif" font-size="12" fill="#475569">xema.dev</text>
11
+ </svg>
12
+ </p>
13
+
14
+ <p align="center">
15
+ <a href="https://xema.dev">Website</a> &middot;
16
+ <a href="https://www.npmjs.com/package/@xemahq/license-verifier">npm</a>
17
+ </p>
18
+
19
+ <p align="center">
20
+ <img alt="npm" src="https://img.shields.io/npm/v/%40xemahq%2Flicense-verifier?color=2563eb&label=npm">
21
+ <img alt="license" src="https://img.shields.io/npm/l/%40xemahq%2Flicense-verifier?color=10b981">
22
+ <img alt="types" src="https://img.shields.io/npm/types/%40xemahq%2Flicense-verifier?color=3178c6">
23
+ </p>
24
+
25
+ # @xemahq/license-verifier
26
+
27
+ > Offline verification of a Xema license
28
+
29
+ ## Overview
30
+
31
+ This package belongs to Layer 1 — a framework-agnostic runtime SDK with **zero
32
+ dependencies**, Node built-ins only (`node:crypto`). It verifies a Xema license
33
+ offline: no network, no filesystem, no clock during signature verification.
34
+
35
+ The zero-dependency rule is load-bearing, not stylistic. This code runs inside
36
+ the `xema` CLI, which must work from a bare checkout with nothing installed;
37
+ inside the air-gap installer on a machine that has never resolved a DNS name;
38
+ and inside platform services. It therefore re-declares the license vocabulary
39
+ that `@xemahq/license-contracts` also declares — the same precedent as
40
+ `@xemahq/distribution-source-hash` — and guards the duplication with a parity
41
+ test that loads both packages and fails closed the moment any value or any
42
+ field set stops agreeing.
43
+
44
+ ## What a license is — and what it is not
45
+
46
+ A **license** is long-lived, customer-held and offline-verifiable. It answers
47
+ **"may this customer run this edition at all"**.
48
+
49
+ That is a different artifact from the **image-delivery entitlement
50
+ attestation** (`ImageDeliveryEntitlementPredicate` in
51
+ `@xemahq/kernel-contracts/distribution`, verified by `verifyImageDeliveryEntitlement`),
52
+ which is short-lived, replay-protected by a nonce and an idempotency key,
53
+ bound to one release digest, and answers **"may these exact bits move to this
54
+ customer right now"**.
55
+
56
+ The two **compose**: the license is the credential that authorizes minting a
57
+ delivery entitlement. This package neither duplicates nor weakens that
58
+ attestation, and the `shared | mirror | airgap` delivery axis stays where it
59
+ already lives (`ImageDeliveryMode`, `CustomerImageEntitlement`).
60
+
61
+ ## Verifying
62
+
63
+ ```ts
64
+ import {
65
+ EntitlementAction,
66
+ EntitlementKind,
67
+ evaluateEntitlement,
68
+ getProductionLicenseTrustStore,
69
+ verifyLicense,
70
+ } from '@xemahq/license-verifier';
71
+
72
+ const verification = verifyLicense(token, {
73
+ trustStore: getProductionLicenseTrustStore(),
74
+ });
75
+ if (!verification.ok) {
76
+ throw new Error(`${verification.code}: ${verification.message}`);
77
+ }
78
+
79
+ const decision = evaluateEntitlement(verification, {
80
+ kind: EntitlementKind.Biome,
81
+ id: 'knowledge-base',
82
+ action: EntitlementAction.Install,
83
+ });
84
+ ```
85
+
86
+ Verification is **cryptographic and structural only** — it proves the claims
87
+ are authentic. It does **not** mean the license is in force. Expiry,
88
+ revocation and suspension are resolved by `resolveLicenseState`, and whether
89
+ anything may actually happen is decided by `evaluateEntitlement`. Holding a
90
+ `VerifiedLicense` is never an entitlement.
91
+
92
+ `VerifiedLicense` is branded with a module-private symbol, so it cannot be
93
+ constructed by anything except a successful verification. "Verified" is a
94
+ proof, not a naming convention.
95
+
96
+ ## Fail-closed behaviour
97
+
98
+ Every one of the following is a refusal, with a distinct
99
+ `LicenseVerificationFailureCode` so the CLI can render an actionable message:
100
+
101
+ - a token that is not a compact JWS, has an empty segment, uses non-canonical
102
+ base64url, or exceeds the size ceiling;
103
+ - a header carrying an unknown parameter, an algorithm other than `EdDSA`, a
104
+ media type other than `application/vnd.xema.license+jws`, or no `kid`;
105
+ - a build whose trust store is empty (`TrustStoreEmpty` — reported before the
106
+ signature check, so an unprovisioned build says what is actually wrong);
107
+ - a `kid` the build does not trust;
108
+ - a signature that does not verify over the exact transmitted bytes;
109
+ - claims with an unknown field, a missing field, a value outside a closed
110
+ enum, a duplicate entitlement, a limit that is absent rather than `null`, a
111
+ non-UTC or impossible timestamp, or an expiry before its issuance;
112
+ - a claims version the build was not compiled to understand;
113
+ - an issuer other than the pinned one.
114
+
115
+ There is no fallback, no coercion, and no path that returns success on doubt.
116
+
117
+ ## The expiry ladder
118
+
119
+ Expiry degrades what a customer may do NEXT; it never stops a running
120
+ workload. `evaluateEntitlement` resolves the whole ladder in one table:
121
+
122
+ | effective status | stage | `RunExisting` | `Install` | `Upgrade` |
123
+ | --- | --- | --- | --- | --- |
124
+ | `Active` | `Valid` | yes | yes | yes |
125
+ | `Expired` | `Grace` (30 days) | yes | yes | yes |
126
+ | `Expired` | `Restricted` | yes | no | no |
127
+ | `Suspended` | any | yes | no | no |
128
+ | `Revoked` | any | no | no | no |
129
+
130
+ `Revoked` is the single, deliberate exception to "never stop a workload",
131
+ because a revocation is for cause rather than for a lapsed renewal.
132
+
133
+ A clock rollback — the system clock behind the highest instant this
134
+ installation has seen — is reported on `LicenseState.clockRollbackDetected`
135
+ and changes no decision. Disconnected hardware genuinely drifts backwards, and
136
+ punishing a customer automatically for a dead RTC battery would make the
137
+ licensing plane the cause of the outage. Warn loudly; do not deny.
138
+
139
+ Clock skew is tolerated up to one minute by default and five minutes at most.
140
+ A tolerance is a concession to drift, not a dial for extending a license.
141
+
142
+ ## Key management
143
+
144
+ - The **private signing key never exists inside any repository** and is never
145
+ an input to anything in this package. `xema-license-keygen` refuses to write
146
+ a key inside a git working tree, at any depth.
147
+ - Only the **public** verification key is embedded, in
148
+ `src/embedded/license-material.generated.ts`.
149
+ - `kid` is **derived**, never assigned: `base64url(sha256(SPKI DER))`. The same
150
+ key produces the same id in the ceremony, in the trust store and in every
151
+ issued license, with no bookkeeping in between.
152
+ - **Rotation** is the trust store: it holds several keys at once, so a new key
153
+ becomes trusted by shipping a build that contains it and stops being trusted
154
+ by shipping a build that does not. Both keys coexist across the rollover.
155
+ An unknown `kid` is always a refusal — there is no discovery.
156
+ - Signing goes through the `LicenseSigner` interface, so moving from a local
157
+ key to Vault Transit or a cloud KMS is a provider swap.
158
+
159
+ ### The checked-in material is a deliberate placeholder
160
+
161
+ This package ships with an **empty trust store** and an **unsigned**
162
+ open-source license. Every verification against it fails with
163
+ `TrustStoreEmpty`, including the embedded license itself, and
164
+ `isLicenseMaterialProvisioned()` returns `false`.
165
+
166
+ A placeholder that verified without a real signature would mean the licensing
167
+ plane accepts forgeries in exactly the builds nobody remembered to provision.
168
+ A placeholder that refuses is loud and safe. Tests assert the refusal, so
169
+ replacing the material without running the ceremony cannot pass CI unchanged.
170
+
171
+ ### The signing ceremony
172
+
173
+ Run once, offline, on a machine that is not the build machine.
174
+
175
+ ```bash
176
+ # 1. Generate the Ed25519 signing key OUTSIDE any repository.
177
+ # The command refuses to write into a git working tree and refuses to
178
+ # overwrite an existing key.
179
+ xema-license-keygen --out ~/.xema-license/signing-key.pem
180
+
181
+ # 2. Mint the open-source license and embed the PUBLIC material.
182
+ # Run from this package's root; it self-verifies the minted license through
183
+ # the ordinary verification path before writing anything.
184
+ cd packages/kernel/license-verifier
185
+ xema-license-mint-oss \
186
+ --key ~/.xema-license/signing-key.pem \
187
+ --issued-at 2026-07-31T00:00:00.000Z \
188
+ --write-embedded
189
+
190
+ # 3. Rebuild, run the tests (the placeholder assertions in
191
+ # `embedded-license.test.ts` must be updated in the same change to assert
192
+ # that the embedded license now VERIFIES), and commit only
193
+ # src/embedded/license-material.generated.ts.
194
+ ```
195
+
196
+ Then store the private key SOPS-encrypted in `xema-deploy`, mounted to
197
+ `license-api` only. **Never** commit it, never paste it into an issue, and
198
+ never place it in a directory that a repository might later be initialised in.
199
+ A lost signing key cannot be recovered; a leaked one invalidates every license
200
+ until a rotation build reaches every customer.
201
+
202
+ ## Signing
203
+
204
+ ```ts
205
+ import { LocalKeyLicenseSigner, signLicense } from '@xemahq/license-verifier/signing';
206
+ ```
207
+
208
+ The signing half sits behind its own subpath so importing a verifier never
209
+ pulls in a minter. It lives in this package because signing and verifying must
210
+ share ONE definition of the signing input and ONE claim parser — a second
211
+ implementation in the issuing service is how an issuer starts minting licenses
212
+ its own verifier rejects. `signLicense` validates claims through that parser
213
+ before signing, so a malformed license cannot be produced at all.
214
+
215
+ ## Related packages
216
+
217
+ | Package | Role |
218
+ | --- | --- |
219
+ | `@xemahq/license-contracts` | The Layer 0 claim shape and closed enums. |
220
+ | `@xemahq/kernel-contracts/distribution` | The complementary, short-lived image-delivery entitlement attestation. |
221
+
222
+ ## License
223
+
224
+ Apache-2.0 &copy; Xema — [xema.dev](https://xema.dev)
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=xema-license-keygen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xema-license-keygen.d.ts","sourceRoot":"","sources":["../../src/bin/xema-license-keygen.ts"],"names":[],"mappings":""}
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const node_crypto_1 = require("node:crypto");
5
+ const node_fs_1 = require("node:fs");
6
+ const node_path_1 = require("node:path");
7
+ const trust_store_ts_1 = require("../lib/trust-store.js");
8
+ const USAGE = `xema-license-keygen --out <path>
9
+
10
+ Generate the Ed25519 license signing key (decision D7).
11
+
12
+ The PRIVATE key is written to <path> with mode 0600 and MUST be stored
13
+ outside any repository — SOPS-encrypted in xema-deploy today, Vault Transit
14
+ or a cloud KMS later. The PUBLIC key and its derived key id are printed to
15
+ stdout; those are what get embedded in verifier builds.
16
+
17
+ This command refuses to write inside a git repository.`;
18
+ function parseOutPath(argv) {
19
+ const index = argv.indexOf('--out');
20
+ if (index === -1 || index === argv.length - 1) {
21
+ throw new Error(`--out <path> is required\n\n${USAGE}`);
22
+ }
23
+ return (0, node_path_1.resolve)(argv[index + 1]);
24
+ }
25
+ function assertOutsideAnyRepository(outPath) {
26
+ let directory = (0, node_path_1.dirname)(outPath);
27
+ for (;;) {
28
+ if ((0, node_fs_1.existsSync)((0, node_path_1.resolve)(directory, '.git'))) {
29
+ throw new Error(`refusing to write a signing key inside the git repository at ${directory}`);
30
+ }
31
+ const parent = (0, node_path_1.dirname)(directory);
32
+ if (parent === directory) {
33
+ return;
34
+ }
35
+ directory = parent;
36
+ }
37
+ }
38
+ function main(argv) {
39
+ const outPath = parseOutPath(argv);
40
+ assertOutsideAnyRepository(outPath);
41
+ if ((0, node_fs_1.existsSync)(outPath)) {
42
+ throw new Error(`refusing to overwrite an existing key at ${outPath}; a lost signing key cannot be recovered`);
43
+ }
44
+ const { privateKey, publicKey } = (0, node_crypto_1.generateKeyPairSync)('ed25519');
45
+ const privateKeyPem = privateKey
46
+ .export({ format: 'pem', type: 'pkcs8' })
47
+ .toString();
48
+ const publicKeyPem = publicKey
49
+ .export({ format: 'pem', type: 'spki' })
50
+ .toString();
51
+ (0, node_fs_1.writeFileSync)(outPath, privateKeyPem, { flag: 'wx', mode: 0o600 });
52
+ process.stdout.write(`private key written to ${outPath} (mode 0600)\n`);
53
+ process.stdout.write(`key id: ${(0, trust_store_ts_1.computeLicenseKeyId)(publicKeyPem)}\n`);
54
+ process.stdout.write(`public key:\n${publicKeyPem}`);
55
+ }
56
+ try {
57
+ main(process.argv.slice(2));
58
+ }
59
+ catch (error) {
60
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
61
+ process.exitCode = 1;
62
+ }
63
+ //# sourceMappingURL=xema-license-keygen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xema-license-keygen.js","sourceRoot":"","sources":["../../src/bin/xema-license-keygen.ts"],"names":[],"mappings":";;;AACA,6CAAkD;AAClD,qCAAoD;AACpD,yCAA6C;AAE7C,0DAA4D;AAE5D,MAAM,KAAK,GAAG;;;;;;;;;uDASyC,CAAC;AAExD,SAAS,YAAY,CAAC,IAAuB;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,KAAK,KAAK,IAAI,CAAC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,CAAC;SACvC,QAAQ,EAAE,CAAC;IAId,IAAA,uBAAa,EAAC,OAAO,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAEnE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,OAAO,gBAAgB,CAAC,CAAC;IACxE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,IAAA,oCAAmB,EAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACvE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,YAAY,EAAE,CAAC,CAAC;AACvD,CAAC;AAED,IAAI,CAAC;IACH,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAC9D,CAAC;IACF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=xema-license-mint-oss.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xema-license-mint-oss.d.ts","sourceRoot":"","sources":["../../src/bin/xema-license-mint-oss.ts"],"names":[],"mappings":""}
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const node_fs_1 = require("node:fs");
5
+ const node_path_1 = require("node:path");
6
+ const oss_license_ts_1 = require("../lib/oss-license.js");
7
+ const license_signer_ts_1 = require("../lib/license-signer.js");
8
+ const render_license_material_ts_1 = require("../lib/render-license-material.js");
9
+ const sign_license_ts_1 = require("../lib/sign-license.js");
10
+ const trust_store_ts_1 = require("../lib/trust-store.js");
11
+ const verify_license_ts_1 = require("../lib/verify-license.js");
12
+ const EMBEDDED_MATERIAL_PATH = 'src/embedded/license-material.generated.ts';
13
+ const USAGE = `xema-license-mint-oss --key <path> [--issued-at <rfc3339>] [--write-embedded]
14
+
15
+ Mint the ONE open-source license (decision D1) and, with --write-embedded,
16
+ rewrite ${EMBEDDED_MATERIAL_PATH} so this package's builds carry it.
17
+
18
+ --key must point at the Ed25519 signing key OUTSIDE this repository. The
19
+ minted license is non-secret and is meant to be published; the key is not.
20
+
21
+ --write-embedded must be run from the package root, and rewrites the file in
22
+ place. Rebuild the package afterwards.`;
23
+ function readFlag(argv, flag) {
24
+ const index = argv.indexOf(flag);
25
+ if (index === -1) {
26
+ return null;
27
+ }
28
+ if (index === argv.length - 1) {
29
+ throw new Error(`${flag} requires a value\n\n${USAGE}`);
30
+ }
31
+ return argv[index + 1];
32
+ }
33
+ async function main(argv) {
34
+ const keyPath = readFlag(argv, '--key');
35
+ if (keyPath === null) {
36
+ throw new Error(`--key <path> is required\n\n${USAGE}`);
37
+ }
38
+ const issuedAt = readFlag(argv, '--issued-at') ?? new Date().toISOString();
39
+ const writeEmbedded = argv.includes('--write-embedded');
40
+ const signer = license_signer_ts_1.LocalKeyLicenseSigner.fromPrivateKeyPem((0, node_fs_1.readFileSync)((0, node_path_1.resolve)(keyPath), 'utf8'));
41
+ const publicKeyPem = signer.exportPublicKeyPem();
42
+ const token = await (0, sign_license_ts_1.signLicense)((0, oss_license_ts_1.buildOssLicenseClaims)(issuedAt), signer);
43
+ const verification = (0, verify_license_ts_1.verifyLicense)(token, {
44
+ trustStore: (0, trust_store_ts_1.createLicenseTrustStore)([publicKeyPem]),
45
+ });
46
+ if (!verification.ok) {
47
+ throw new Error(`the minted license failed verification (${verification.code}): ${verification.message}`);
48
+ }
49
+ if (writeEmbedded) {
50
+ const target = (0, node_path_1.resolve)(process.cwd(), EMBEDDED_MATERIAL_PATH);
51
+ if (!(0, node_fs_1.existsSync)(target)) {
52
+ throw new Error(`${target} does not exist; run --write-embedded from the @xemahq/license-verifier package root`);
53
+ }
54
+ (0, node_fs_1.writeFileSync)(target, (0, render_license_material_ts_1.renderLicenseMaterial)({
55
+ publicKeyPems: [publicKeyPem],
56
+ ossLicense: token,
57
+ provisioned: true,
58
+ provenance: `Open-source license ${verification.claims.licenseId} issued ${issuedAt} under key ${signer.keyId}.`,
59
+ }));
60
+ process.stdout.write(`embedded material written to ${target}\n`);
61
+ }
62
+ process.stdout.write(`key id: ${signer.keyId}\n`);
63
+ process.stdout.write(`public key:\n${publicKeyPem}`);
64
+ process.stdout.write(`oss license:\n${token}\n`);
65
+ }
66
+ main(process.argv.slice(2)).catch((error) => {
67
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
68
+ process.exitCode = 1;
69
+ });
70
+ //# sourceMappingURL=xema-license-mint-oss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xema-license-mint-oss.js","sourceRoot":"","sources":["../../src/bin/xema-license-mint-oss.ts"],"names":[],"mappings":";;;AACA,qCAAkE;AAClE,yCAAoC;AAEpC,0DAA8D;AAC9D,gEAAiE;AACjE,kFAA0E;AAC1E,4DAAqD;AACrD,0DAAgE;AAChE,gEAAyD;AAEzD,MAAM,sBAAsB,GAAG,4CAA4C,CAAC;AAE5E,MAAM,KAAK,GAAG;;;UAGJ,sBAAsB;;;;;;uCAMO,CAAC;AAExC,SAAS,QAAQ,CAAC,IAAuB,EAAE,IAAY;IACrD,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,KAAK,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,wBAAwB,KAAK,EAAE,CAAC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EAAC,MAAM,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CACb,GAAG,MAAM,sFAAsF,CAChG,CAAC;QACJ,CAAC;QACD,IAAA,uBAAa,EACX,MAAM,EACN,IAAA,kDAAqB,EAAC;YACpB,aAAa,EAAE,CAAC,YAAY,CAAC;YAC7B,UAAU,EAAE,KAAK;YACjB,WAAW,EAAE,IAAI;YACjB,UAAU,EAAE,uBAAuB,YAAY,CAAC,MAAM,CAAC,SAAS,WAAW,QAAQ,cAAc,MAAM,CAAC,KAAK,GAAG;SACjH,CAAC,CACH,CAAC;QACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,MAAM,IAAI,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,MAAM,CAAC,KAAK,IAAI,CAAC,CAAC;IAClD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,YAAY,EAAE,CAAC,CAAC;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,KAAK,IAAI,CAAC,CAAC;AACnD,CAAC;AAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IACnD,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAC9D,CAAC;IACF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const LICENSE_MATERIAL_PROVISIONED = false;
2
+ export declare const EMBEDDED_LICENSE_PUBLIC_KEYS: readonly string[];
3
+ export declare const EMBEDDED_OSS_LICENSE = "eyJhbGciOiJFZERTQSIsImtpZCI6IlVOUFJPVklTSU9ORUQtUExBQ0VIT0xERVItTk9ULUEtUkVBTC1LRVkiLCJ0eXAiOiJhcHBsaWNhdGlvbi92bmQueGVtYS5saWNlbnNlK2p3cyJ9.eyJ2ZXJzaW9uIjoxLCJsaWNlbnNlSWQiOiJ4ZW1hLW9zcyIsImlzc3VlciI6Imh0dHBzOi8vbGljZW5zZS54ZW1hLmRldiIsInN1YmplY3QiOnsiY3VzdG9tZXJJZCI6InhlbWEtb3Blbi1zb3VyY2UiLCJjdXN0b21lck5hbWUiOiJYZW1hIE9wZW4gU291cmNlIn0sInRpZXIiOiJvcGVuLXNvdXJjZSIsInN0YXR1cyI6ImFjdGl2ZSIsImVudGl0bGVtZW50cyI6W3sia2luZCI6ImRpc3RyaWJ1dGlvbiIsImlkIjoib3NzIn1dLCJsaW1pdHMiOnsibm9kZXMiOm51bGwsInNlYXRzIjpudWxsfSwiaXNzdWVkQXQiOiIxOTcwLTAxLTAxVDAwOjAwOjAwLjAwMFoiLCJleHBpcmVzQXQiOm51bGx9.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
4
+ //# sourceMappingURL=license-material.generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"license-material.generated.d.ts","sourceRoot":"","sources":["../../src/embedded/license-material.generated.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,4BAA4B,QAAQ,CAAC;AAGlD,eAAO,MAAM,4BAA4B,EAAE,SAAS,MAAM,EAAO,CAAC;AAGlE,eAAO,MAAM,oBAAoB,qqBACmoB,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EMBEDDED_OSS_LICENSE = exports.EMBEDDED_LICENSE_PUBLIC_KEYS = exports.LICENSE_MATERIAL_PROVISIONED = void 0;
4
+ exports.LICENSE_MATERIAL_PROVISIONED = false;
5
+ exports.EMBEDDED_LICENSE_PUBLIC_KEYS = [];
6
+ exports.EMBEDDED_OSS_LICENSE = 'eyJhbGciOiJFZERTQSIsImtpZCI6IlVOUFJPVklTSU9ORUQtUExBQ0VIT0xERVItTk9ULUEtUkVBTC1LRVkiLCJ0eXAiOiJhcHBsaWNhdGlvbi92bmQueGVtYS5saWNlbnNlK2p3cyJ9.eyJ2ZXJzaW9uIjoxLCJsaWNlbnNlSWQiOiJ4ZW1hLW9zcyIsImlzc3VlciI6Imh0dHBzOi8vbGljZW5zZS54ZW1hLmRldiIsInN1YmplY3QiOnsiY3VzdG9tZXJJZCI6InhlbWEtb3Blbi1zb3VyY2UiLCJjdXN0b21lck5hbWUiOiJYZW1hIE9wZW4gU291cmNlIn0sInRpZXIiOiJvcGVuLXNvdXJjZSIsInN0YXR1cyI6ImFjdGl2ZSIsImVudGl0bGVtZW50cyI6W3sia2luZCI6ImRpc3RyaWJ1dGlvbiIsImlkIjoib3NzIn1dLCJsaW1pdHMiOnsibm9kZXMiOm51bGwsInNlYXRzIjpudWxsfSwiaXNzdWVkQXQiOiIxOTcwLTAxLTAxVDAwOjAwOjAwLjAwMFoiLCJleHBpcmVzQXQiOm51bGx9.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
7
+ //# sourceMappingURL=license-material.generated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"license-material.generated.js","sourceRoot":"","sources":["../../src/embedded/license-material.generated.ts"],"names":[],"mappings":";;;AAoBa,QAAA,4BAA4B,GAAG,KAAK,CAAC;AAGrC,QAAA,4BAA4B,GAAsB,EAAE,CAAC;AAGrD,QAAA,oBAAoB,GAC/B,kqBAAkqB,CAAC"}
@@ -0,0 +1,13 @@
1
+ export { LicenseSource, resolveEffectiveLicense, type EffectiveLicense, type EffectiveLicenseUnverifiable, type EffectiveLicenseVerified, type ResolveEffectiveLicenseInput, } from './lib/effective-license.ts';
2
+ export { getEmbeddedOssLicense, getProductionLicenseTrustStore, isLicenseMaterialProvisioned, verifyEmbeddedOssLicense, } from './lib/embedded-license.ts';
3
+ export { EntitlementDenialReason, evaluateEntitlement, type EntitlementDecision, type EntitlementQuery, } from './lib/evaluate-entitlement.ts';
4
+ export { LimitDecisionReason, evaluateLimit, type LimitDecision, } from './lib/evaluate-limit.ts';
5
+ export type { LicenseClaims, LicenseEntitlement, LicenseJwsHeader, LicenseLimitValue, LicenseLimits, LicenseSubject, } from './lib/license-claims.ts';
6
+ export { CANONICAL_IDENTIFIER_PATTERN, ENTITLEMENT_ID_WILDCARD, EntitlementAction, EntitlementKind, LICENSE_GRACE_PERIOD_MS, LICENSE_JWS_TYPE, LICENSE_LIMIT_UNLIMITED, LicenseClaimsVersion, LicenseLifecycleStage, LicenseLimitKind, LicenseSignatureAlgorithm, LicenseStatus, LicenseTier, OSS_DISTRIBUTION_ID, OSS_LICENSE_CUSTOMER_ID, OSS_LICENSE_CUSTOMER_NAME, OSS_LICENSE_ID, XEMA_LICENSE_ISSUER, } from './lib/license-enums.ts';
7
+ export { buildOssLicenseClaims } from './lib/oss-license.ts';
8
+ export { DEFAULT_CLOCK_SKEW_TOLERANCE_MS, MAX_CLOCK_SKEW_TOLERANCE_MS, resolveLicenseState, type LicenseState, type ResolveLicenseStateOptions, } from './lib/resolve-license-state.ts';
9
+ export { computeLicenseKeyId, createLicenseTrustStore, type LicenseTrustStore, } from './lib/trust-store.ts';
10
+ export { LicenseVerificationFailureCode, type LicenseVerificationFailure, } from './lib/verification-failure.ts';
11
+ export { verifyLicense, type LicenseVerificationResult, type LicenseVerificationSuccess, type VerifyLicenseOptions, } from './lib/verify-license.ts';
12
+ export type { VerifiedLicense } from './lib/verified-license.ts';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB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AAC;AACjC,YAAY,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyLicense = exports.LicenseVerificationFailureCode = exports.createLicenseTrustStore = exports.computeLicenseKeyId = exports.resolveLicenseState = exports.MAX_CLOCK_SKEW_TOLERANCE_MS = exports.DEFAULT_CLOCK_SKEW_TOLERANCE_MS = exports.buildOssLicenseClaims = exports.XEMA_LICENSE_ISSUER = exports.OSS_LICENSE_ID = exports.OSS_LICENSE_CUSTOMER_NAME = exports.OSS_LICENSE_CUSTOMER_ID = exports.OSS_DISTRIBUTION_ID = exports.LicenseTier = exports.LicenseStatus = exports.LicenseSignatureAlgorithm = exports.LicenseLimitKind = exports.LicenseLifecycleStage = exports.LicenseClaimsVersion = exports.LICENSE_LIMIT_UNLIMITED = exports.LICENSE_JWS_TYPE = exports.LICENSE_GRACE_PERIOD_MS = exports.EntitlementKind = exports.EntitlementAction = exports.ENTITLEMENT_ID_WILDCARD = exports.CANONICAL_IDENTIFIER_PATTERN = exports.evaluateLimit = exports.LimitDecisionReason = exports.evaluateEntitlement = exports.EntitlementDenialReason = exports.verifyEmbeddedOssLicense = exports.isLicenseMaterialProvisioned = exports.getProductionLicenseTrustStore = exports.getEmbeddedOssLicense = exports.resolveEffectiveLicense = exports.LicenseSource = void 0;
4
+ var effective_license_ts_1 = require("./lib/effective-license.js");
5
+ Object.defineProperty(exports, "LicenseSource", { enumerable: true, get: function () { return effective_license_ts_1.LicenseSource; } });
6
+ Object.defineProperty(exports, "resolveEffectiveLicense", { enumerable: true, get: function () { return effective_license_ts_1.resolveEffectiveLicense; } });
7
+ var embedded_license_ts_1 = require("./lib/embedded-license.js");
8
+ Object.defineProperty(exports, "getEmbeddedOssLicense", { enumerable: true, get: function () { return embedded_license_ts_1.getEmbeddedOssLicense; } });
9
+ Object.defineProperty(exports, "getProductionLicenseTrustStore", { enumerable: true, get: function () { return embedded_license_ts_1.getProductionLicenseTrustStore; } });
10
+ Object.defineProperty(exports, "isLicenseMaterialProvisioned", { enumerable: true, get: function () { return embedded_license_ts_1.isLicenseMaterialProvisioned; } });
11
+ Object.defineProperty(exports, "verifyEmbeddedOssLicense", { enumerable: true, get: function () { return embedded_license_ts_1.verifyEmbeddedOssLicense; } });
12
+ var evaluate_entitlement_ts_1 = require("./lib/evaluate-entitlement.js");
13
+ Object.defineProperty(exports, "EntitlementDenialReason", { enumerable: true, get: function () { return evaluate_entitlement_ts_1.EntitlementDenialReason; } });
14
+ Object.defineProperty(exports, "evaluateEntitlement", { enumerable: true, get: function () { return evaluate_entitlement_ts_1.evaluateEntitlement; } });
15
+ var evaluate_limit_ts_1 = require("./lib/evaluate-limit.js");
16
+ Object.defineProperty(exports, "LimitDecisionReason", { enumerable: true, get: function () { return evaluate_limit_ts_1.LimitDecisionReason; } });
17
+ Object.defineProperty(exports, "evaluateLimit", { enumerable: true, get: function () { return evaluate_limit_ts_1.evaluateLimit; } });
18
+ var license_enums_ts_1 = require("./lib/license-enums.js");
19
+ Object.defineProperty(exports, "CANONICAL_IDENTIFIER_PATTERN", { enumerable: true, get: function () { return license_enums_ts_1.CANONICAL_IDENTIFIER_PATTERN; } });
20
+ Object.defineProperty(exports, "ENTITLEMENT_ID_WILDCARD", { enumerable: true, get: function () { return license_enums_ts_1.ENTITLEMENT_ID_WILDCARD; } });
21
+ Object.defineProperty(exports, "EntitlementAction", { enumerable: true, get: function () { return license_enums_ts_1.EntitlementAction; } });
22
+ Object.defineProperty(exports, "EntitlementKind", { enumerable: true, get: function () { return license_enums_ts_1.EntitlementKind; } });
23
+ Object.defineProperty(exports, "LICENSE_GRACE_PERIOD_MS", { enumerable: true, get: function () { return license_enums_ts_1.LICENSE_GRACE_PERIOD_MS; } });
24
+ Object.defineProperty(exports, "LICENSE_JWS_TYPE", { enumerable: true, get: function () { return license_enums_ts_1.LICENSE_JWS_TYPE; } });
25
+ Object.defineProperty(exports, "LICENSE_LIMIT_UNLIMITED", { enumerable: true, get: function () { return license_enums_ts_1.LICENSE_LIMIT_UNLIMITED; } });
26
+ Object.defineProperty(exports, "LicenseClaimsVersion", { enumerable: true, get: function () { return license_enums_ts_1.LicenseClaimsVersion; } });
27
+ Object.defineProperty(exports, "LicenseLifecycleStage", { enumerable: true, get: function () { return license_enums_ts_1.LicenseLifecycleStage; } });
28
+ Object.defineProperty(exports, "LicenseLimitKind", { enumerable: true, get: function () { return license_enums_ts_1.LicenseLimitKind; } });
29
+ Object.defineProperty(exports, "LicenseSignatureAlgorithm", { enumerable: true, get: function () { return license_enums_ts_1.LicenseSignatureAlgorithm; } });
30
+ Object.defineProperty(exports, "LicenseStatus", { enumerable: true, get: function () { return license_enums_ts_1.LicenseStatus; } });
31
+ Object.defineProperty(exports, "LicenseTier", { enumerable: true, get: function () { return license_enums_ts_1.LicenseTier; } });
32
+ Object.defineProperty(exports, "OSS_DISTRIBUTION_ID", { enumerable: true, get: function () { return license_enums_ts_1.OSS_DISTRIBUTION_ID; } });
33
+ Object.defineProperty(exports, "OSS_LICENSE_CUSTOMER_ID", { enumerable: true, get: function () { return license_enums_ts_1.OSS_LICENSE_CUSTOMER_ID; } });
34
+ Object.defineProperty(exports, "OSS_LICENSE_CUSTOMER_NAME", { enumerable: true, get: function () { return license_enums_ts_1.OSS_LICENSE_CUSTOMER_NAME; } });
35
+ Object.defineProperty(exports, "OSS_LICENSE_ID", { enumerable: true, get: function () { return license_enums_ts_1.OSS_LICENSE_ID; } });
36
+ Object.defineProperty(exports, "XEMA_LICENSE_ISSUER", { enumerable: true, get: function () { return license_enums_ts_1.XEMA_LICENSE_ISSUER; } });
37
+ var oss_license_ts_1 = require("./lib/oss-license.js");
38
+ Object.defineProperty(exports, "buildOssLicenseClaims", { enumerable: true, get: function () { return oss_license_ts_1.buildOssLicenseClaims; } });
39
+ var resolve_license_state_ts_1 = require("./lib/resolve-license-state.js");
40
+ Object.defineProperty(exports, "DEFAULT_CLOCK_SKEW_TOLERANCE_MS", { enumerable: true, get: function () { return resolve_license_state_ts_1.DEFAULT_CLOCK_SKEW_TOLERANCE_MS; } });
41
+ Object.defineProperty(exports, "MAX_CLOCK_SKEW_TOLERANCE_MS", { enumerable: true, get: function () { return resolve_license_state_ts_1.MAX_CLOCK_SKEW_TOLERANCE_MS; } });
42
+ Object.defineProperty(exports, "resolveLicenseState", { enumerable: true, get: function () { return resolve_license_state_ts_1.resolveLicenseState; } });
43
+ var trust_store_ts_1 = require("./lib/trust-store.js");
44
+ Object.defineProperty(exports, "computeLicenseKeyId", { enumerable: true, get: function () { return trust_store_ts_1.computeLicenseKeyId; } });
45
+ Object.defineProperty(exports, "createLicenseTrustStore", { enumerable: true, get: function () { return trust_store_ts_1.createLicenseTrustStore; } });
46
+ var verification_failure_ts_1 = require("./lib/verification-failure.js");
47
+ Object.defineProperty(exports, "LicenseVerificationFailureCode", { enumerable: true, get: function () { return verification_failure_ts_1.LicenseVerificationFailureCode; } });
48
+ var verify_license_ts_1 = require("./lib/verify-license.js");
49
+ Object.defineProperty(exports, "verifyLicense", { enumerable: true, get: function () { return verify_license_ts_1.verifyLicense; } });
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mEAOoC;AANlC,qHAAA,aAAa,OAAA;AACb,+HAAA,uBAAuB,OAAA;AAMzB,iEAKmC;AAJjC,4HAAA,qBAAqB,OAAA;AACrB,qIAAA,8BAA8B,OAAA;AAC9B,mIAAA,4BAA4B,OAAA;AAC5B,+HAAA,wBAAwB,OAAA;AAE1B,yEAKuC;AAJrC,kIAAA,uBAAuB,OAAA;AACvB,8HAAA,mBAAmB,OAAA;AAIrB,6DAIiC;AAH/B,wHAAA,mBAAmB,OAAA;AACnB,kHAAA,aAAa,OAAA;AAWf,2DAmBgC;AAlB9B,gIAAA,4BAA4B,OAAA;AAC5B,2HAAA,uBAAuB,OAAA;AACvB,qHAAA,iBAAiB,OAAA;AACjB,mHAAA,eAAe,OAAA;AACf,2HAAA,uBAAuB,OAAA;AACvB,oHAAA,gBAAgB,OAAA;AAChB,2HAAA,uBAAuB,OAAA;AACvB,wHAAA,oBAAoB,OAAA;AACpB,yHAAA,qBAAqB,OAAA;AACrB,oHAAA,gBAAgB,OAAA;AAChB,6HAAA,yBAAyB,OAAA;AACzB,iHAAA,aAAa,OAAA;AACb,+GAAA,WAAW,OAAA;AACX,uHAAA,mBAAmB,OAAA;AACnB,2HAAA,uBAAuB,OAAA;AACvB,6HAAA,yBAAyB,OAAA;AACzB,kHAAA,cAAc,OAAA;AACd,uHAAA,mBAAmB,OAAA;AAErB,uDAA6D;AAApD,uHAAA,qBAAqB,OAAA;AAC9B,2EAMwC;AALtC,2IAAA,+BAA+B,OAAA;AAC/B,uIAAA,2BAA2B,OAAA;AAC3B,+HAAA,mBAAmB,OAAA;AAIrB,uDAI8B;AAH5B,qHAAA,mBAAmB,OAAA;AACnB,yHAAA,uBAAuB,OAAA;AAGzB,yEAGuC;AAFrC,yIAAA,8BAA8B,OAAA;AAGhC,6DAKiC;AAJ/B,kHAAA,aAAa,OAAA"}
@@ -0,0 +1,4 @@
1
+ export declare function encodeBase64Url(bytes: Uint8Array): string;
2
+ export declare function decodeBase64Url(value: string): Uint8Array | null;
3
+ export declare function decodeBase64UrlText(value: string): string | null;
4
+ //# sourceMappingURL=base64url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64url.d.ts","sourceRoot":"","sources":["../../src/lib/base64url.ts"],"names":[],"mappings":"AAGA,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEzD;AAYD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAShE;AAGD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAahE"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encodeBase64Url = encodeBase64Url;
4
+ exports.decodeBase64Url = decodeBase64Url;
5
+ exports.decodeBase64UrlText = decodeBase64UrlText;
6
+ const BASE64URL_PATTERN = /^[A-Za-z0-9_-]+$/;
7
+ function encodeBase64Url(bytes) {
8
+ return Buffer.from(bytes).toString('base64url');
9
+ }
10
+ function decodeBase64Url(value) {
11
+ if (!BASE64URL_PATTERN.test(value)) {
12
+ return null;
13
+ }
14
+ const decoded = Buffer.from(value, 'base64url');
15
+ if (decoded.toString('base64url') !== value) {
16
+ return null;
17
+ }
18
+ return new Uint8Array(decoded);
19
+ }
20
+ function decodeBase64UrlText(value) {
21
+ const bytes = decodeBase64Url(value);
22
+ if (bytes === null) {
23
+ return null;
24
+ }
25
+ const text = Buffer.from(bytes).toString('utf8');
26
+ if (Buffer.compare(Buffer.from(text, 'utf8'), Buffer.from(bytes)) !== 0) {
27
+ return null;
28
+ }
29
+ return text;
30
+ }
31
+ //# sourceMappingURL=base64url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64url.js","sourceRoot":"","sources":["../../src/lib/base64url.ts"],"names":[],"mappings":";;AAGA,0CAEC;AAYD,0CASC;AAGD,kDAaC;AAzCD,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAE7C,SAAgB,eAAe,CAAC,KAAiB;IAC/C,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAClD,CAAC;AAYD,SAAgB,eAAe,CAAC,KAAa;IAC3C,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IAChD,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,KAAK,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAGD,SAAgB,mBAAmB,CAAC,KAAa;IAC/C,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAIjD,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,16 @@
1
+ export declare const MAX_LICENSE_TOKEN_BYTES: number;
2
+ export interface CompactJwsSegments {
3
+ readonly encodedHeader: string;
4
+ readonly encodedPayload: string;
5
+ readonly signature: Uint8Array;
6
+ readonly signingInput: Uint8Array;
7
+ }
8
+ export declare function splitCompactJws(token: string): CompactJwsSegments | null;
9
+ export interface EncodedJwsSegments {
10
+ readonly encodedHeader: string;
11
+ readonly encodedPayload: string;
12
+ readonly signingInput: Uint8Array;
13
+ }
14
+ export declare function encodeJwsSegments(headerJson: string, payloadJson: string): EncodedJwsSegments;
15
+ export declare function assembleCompactJws(segments: EncodedJwsSegments, signature: Uint8Array): string;
16
+ //# sourceMappingURL=compact-jws.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compact-jws.d.ts","sourceRoot":"","sources":["../../src/lib/compact-jws.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,uBAAuB,QAAY,CAAC;AAEjD,MAAM,WAAW,kBAAkB;IAEjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAO/B,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC;CACnC;AAGD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAqCxE;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC;CACnC;AAQD,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,kBAAkB,CAcpB;AAGD,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,kBAAkB,EAC5B,SAAS,EAAE,UAAU,GACpB,MAAM,CAER"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_LICENSE_TOKEN_BYTES = void 0;
4
+ exports.splitCompactJws = splitCompactJws;
5
+ exports.encodeJwsSegments = encodeJwsSegments;
6
+ exports.assembleCompactJws = assembleCompactJws;
7
+ const base64url_ts_1 = require("./base64url.js");
8
+ exports.MAX_LICENSE_TOKEN_BYTES = 64 * 1024;
9
+ function splitCompactJws(token) {
10
+ if (token.length === 0 ||
11
+ Buffer.byteLength(token) > exports.MAX_LICENSE_TOKEN_BYTES) {
12
+ return null;
13
+ }
14
+ const parts = token.split('.');
15
+ if (parts.length !== 3) {
16
+ return null;
17
+ }
18
+ const [encodedHeader, encodedPayload, encodedSignature] = parts;
19
+ if (encodedHeader.length === 0 ||
20
+ encodedPayload.length === 0 ||
21
+ encodedSignature.length === 0) {
22
+ return null;
23
+ }
24
+ const signature = (0, base64url_ts_1.decodeBase64Url)(encodedSignature);
25
+ if (signature === null) {
26
+ return null;
27
+ }
28
+ return {
29
+ encodedHeader,
30
+ encodedPayload,
31
+ signature,
32
+ signingInput: new Uint8Array(Buffer.from(`${encodedHeader}.${encodedPayload}`, 'ascii')),
33
+ };
34
+ }
35
+ function encodeJwsSegments(headerJson, payloadJson) {
36
+ const encodedHeader = (0, base64url_ts_1.encodeBase64Url)(new Uint8Array(Buffer.from(headerJson, 'utf8')));
37
+ const encodedPayload = (0, base64url_ts_1.encodeBase64Url)(new Uint8Array(Buffer.from(payloadJson, 'utf8')));
38
+ return {
39
+ encodedHeader,
40
+ encodedPayload,
41
+ signingInput: new Uint8Array(Buffer.from(`${encodedHeader}.${encodedPayload}`, 'ascii')),
42
+ };
43
+ }
44
+ function assembleCompactJws(segments, signature) {
45
+ return `${segments.encodedHeader}.${segments.encodedPayload}.${(0, base64url_ts_1.encodeBase64Url)(signature)}`;
46
+ }
47
+ //# sourceMappingURL=compact-jws.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compact-jws.js","sourceRoot":"","sources":["../../src/lib/compact-jws.ts"],"names":[],"mappings":";;;AA0BA,0CAqCC;AAeD,8CAiBC;AAGD,gDAKC;AAvGD,iDAAkE;AAOrD,QAAA,uBAAuB,GAAG,EAAE,GAAG,IAAI,CAAC;AAmBjD,SAAgB,eAAe,CAAC,KAAa;IAC3C,IACE,KAAK,CAAC,MAAM,KAAK,CAAC;QAClB,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,+BAAuB,EAClD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,CAAC,aAAa,EAAE,cAAc,EAAE,gBAAgB,CAAC,GAAG,KAIzD,CAAC;IACF,IACE,aAAa,CAAC,MAAM,KAAK,CAAC;QAC1B,cAAc,C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