@voltro/plugin-licensing 0.32.0 → 0.34.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.
@@ -5,7 +5,7 @@ property of its respective copyright holders and is used under the terms of
5
5
  its license. This file is provided for attribution; it grants no rights in
6
6
  @voltro/plugin-licensing itself, which is proprietary (see LICENSE).
7
7
 
8
- Generated from the resolved runtime dependency closure (52 packages).
8
+ Generated from the resolved runtime dependency closure (51 packages).
9
9
 
10
10
  ---
11
11
 
@@ -37,34 +37,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37
37
  SOFTWARE.
38
38
  ```
39
39
 
40
- ## @effect/opentelemetry@0.64.0
41
-
42
- License: MIT
43
-
44
- ```
45
- MIT License
46
-
47
- Copyright (c) 2020-present The Contributors
48
-
49
- Permission is hereby granted, free of charge, to any person obtaining a copy
50
- of this software and associated documentation files (the "Software"), to deal
51
- in the Software without restriction, including without limitation the rights
52
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
53
- copies of the Software, and to permit persons to whom the Software is
54
- furnished to do so, subject to the following conditions:
55
-
56
- The above copyright notice and this permission notice shall be included in all
57
- copies or substantial portions of the Software.
58
-
59
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
60
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
61
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
62
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
63
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
64
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
65
- SOFTWARE.
66
- ```
67
-
68
40
  ## @effect/platform-node@0.108.0
69
41
 
70
42
  License: MIT
package/dist/index.js CHANGED
@@ -1,58 +1,58 @@
1
1
  import { Data as e, Effect as t } from "effect";
2
- import { definePlugin as n, definePluginService as r } from "@voltro/protocol";
3
- import { pluginEnv as i } from "@voltro/env";
4
- import { importSPKI as a, jwtVerify as o } from "jose";
2
+ import { definePlugin as n, definePluginService as r, pluginInstanceName as i } from "@voltro/protocol";
3
+ import { pluginEnv as a } from "@voltro/env";
4
+ import { importSPKI as o, jwtVerify as s } from "jose";
5
5
  //#region src/verify.ts
6
- var s = class extends e.TaggedError("LicenseVerifyError") {}, c = (e) => typeof e == "object" && e && "code" in e ? String(e.code) : "", l = (e) => {
6
+ var c = class extends e.TaggedError("LicenseVerifyError") {}, l = (e) => typeof e == "object" && e && "code" in e ? String(e.code) : "", u = (e) => {
7
7
  let t = e instanceof Error ? e.message : String(e);
8
- return c(e) === "ERR_JWT_EXPIRED" ? new s({
8
+ return l(e) === "ERR_JWT_EXPIRED" ? new c({
9
9
  reason: "expired",
10
10
  message: t
11
- }) : new s({
11
+ }) : new c({
12
12
  reason: "invalid",
13
13
  message: t
14
14
  });
15
- }, u = (e) => e === "unlimited" || typeof e == "number" && Number.isFinite(e) && e >= 0, d = (e, n) => {
15
+ }, d = (e) => e === "unlimited" || typeof e == "number" && Number.isFinite(e) && e >= 0, f = (e, n) => {
16
16
  let r = e.edition, i = e.entitlements, a = e.features;
17
- if (typeof r != "string" || typeof i != "object" || !i) return t.fail(new s({
17
+ if (typeof r != "string" || typeof i != "object" || !i) return t.fail(new c({
18
18
  reason: "malformed",
19
19
  message: "missing edition/entitlements"
20
20
  }));
21
21
  let o = {};
22
22
  for (let [e, n] of Object.entries(i)) {
23
- if (!u(n)) return t.fail(new s({
23
+ if (!d(n)) return t.fail(new c({
24
24
  reason: "malformed",
25
25
  message: `bad entitlement '${e}'`
26
26
  }));
27
27
  o[e] = n;
28
28
  }
29
- let c = Array.isArray(a) ? a.filter((e) => typeof e == "string") : [], l = e.plugins, d = Array.isArray(l) ? l.filter((e) => typeof e == "string") : [];
29
+ let s = Array.isArray(a) ? a.filter((e) => typeof e == "string") : [], l = e.plugins, u = Array.isArray(l) ? l.filter((e) => typeof e == "string") : [];
30
30
  return t.succeed({
31
31
  ...typeof e.tenant == "string" ? { tenant: e.tenant } : {},
32
32
  edition: r,
33
33
  entitlements: o,
34
- features: c,
35
- plugins: d,
34
+ features: s,
35
+ plugins: u,
36
36
  exp: typeof e.exp == "number" ? e.exp : 0,
37
37
  ...typeof e.iat == "number" ? { iat: e.iat } : {},
38
38
  ...n === void 0 ? {} : { kid: n }
39
39
  });
40
- }, f = (e, n) => t.tryPromise({
41
- try: () => a(n, "EdDSA"),
42
- catch: (e) => new s({
40
+ }, p = (e, n) => t.tryPromise({
41
+ try: () => o(n, "EdDSA"),
42
+ catch: (e) => new c({
43
43
  reason: "key",
44
44
  message: e instanceof Error ? e.message : String(e)
45
45
  })
46
46
  }).pipe(t.flatMap((n) => t.tryPromise({
47
47
  try: async () => {
48
- let { payload: t, protectedHeader: r } = await o(e, n, { algorithms: ["EdDSA"] });
48
+ let { payload: t, protectedHeader: r } = await s(e, n, { algorithms: ["EdDSA"] });
49
49
  return {
50
50
  payload: t,
51
51
  kid: r.kid
52
52
  };
53
53
  },
54
- catch: l
55
- })), t.flatMap(({ payload: e, kid: t }) => d(e, t))), p = (e, t = {}) => {
54
+ catch: u
55
+ })), t.flatMap(({ payload: e, kid: t }) => f(e, t))), m = (e, t = {}) => {
56
56
  let n = new Set(e.features), r = new Set(e.plugins), i = t.graceSeconds ?? 0, a = t.now ?? (() => Date.now() / 1e3), o = () => e.exp <= 0 || a() <= e.exp + i;
57
57
  return {
58
58
  claims: e,
@@ -64,12 +64,12 @@ var s = class extends e.TaggedError("LicenseVerifyError") {}, c = (e) => typeof
64
64
  hasFeature: (e) => o() && n.has(e),
65
65
  allowsPlugin: (e) => o() && r.has(e)
66
66
  };
67
- }, m, h = (e) => {
68
- m = e;
69
- }, g = () => m, _ = (e, n) => t.sync(() => {
70
- let t = g()?.limitFor(e, n);
67
+ }, h, g = (e) => {
68
+ h = e;
69
+ }, _ = () => h, v = (e, n) => t.sync(() => {
70
+ let t = _()?.limitFor(e, n);
71
71
  return t === void 0 ? null : t;
72
- }), v = i([{
72
+ }), y = a([{
73
73
  name: "VOLTRO_LICENSE_PUBLIC_KEY",
74
74
  required: !1,
75
75
  secret: !1,
@@ -79,57 +79,60 @@ var s = class extends e.TaggedError("LicenseVerifyError") {}, c = (e) => typeof
79
79
  required: !1,
80
80
  secret: !1,
81
81
  description: "The signed EdDSA license token, verified offline at boot."
82
- }]), { Tag: y, Live: b } = r("@voltro/plugin-licensing/LicenseService", {
83
- snapshot: () => g(),
84
- limitFor: (e, t) => g()?.limitFor(e, t),
85
- hasFeature: (e) => g()?.hasFeature(e) ?? !1,
86
- allowsPlugin: (e) => g()?.allowsPlugin(e) ?? !1,
87
- edition: () => g()?.claims.edition
88
- }), x = class extends e.TaggedError("PluginNotLicensed") {}, S = (e) => g()?.allowsPlugin(e) ?? !1, C = (e) => S(e) ? t.void : t.fail(new x({ plugin: e })), w = (e = {}) => {
89
- let r = v.read("VOLTRO_LICENSE_PUBLIC_KEY", e.publicKey), i = v.read("VOLTRO_LICENSE_KEY", e.licenseKey), a = e.graceSeconds ?? 0, o = e.refreshMs ?? 15 * 6e4, s, c = (e, n) => f(e, n).pipe(t.match({
82
+ }]), { Tag: b, Live: x } = r("@voltro/plugin-licensing/LicenseService", {
83
+ snapshot: () => _(),
84
+ limitFor: (e, t) => _()?.limitFor(e, t),
85
+ hasFeature: (e) => _()?.hasFeature(e) ?? !1,
86
+ allowsPlugin: (e) => _()?.allowsPlugin(e) ?? !1,
87
+ edition: () => _()?.claims.edition
88
+ }), S = class extends e.TaggedError("PluginNotLicensed") {}, C = (e) => _()?.allowsPlugin(e) ?? !1, w = (e) => C(e) ? t.void : t.fail(new S({ plugin: e })), T = (e = {}) => {
89
+ let r = y.read("VOLTRO_LICENSE_PUBLIC_KEY", e.publicKey), a = y.read("VOLTRO_LICENSE_KEY", e.licenseKey), o = e.graceSeconds ?? 0, s = e.refreshMs ?? 15 * 6e4, c, l = (e, n) => p(e, n).pipe(t.match({
90
90
  onSuccess: (e) => {
91
- h(p(e, { graceSeconds: a })), s?.info("license active", {
91
+ g(m(e, { graceSeconds: o })), c?.info("license active", {
92
92
  edition: e.edition,
93
93
  entitlements: Object.keys(e.entitlements).length,
94
94
  exp: e.exp
95
95
  });
96
96
  },
97
97
  onFailure: (e) => {
98
- s?.warn("license verification failed — entitlements fall back to static plan", {
98
+ c?.warn("license verification failed — entitlements fall back to static plan", {
99
99
  reason: e.reason,
100
100
  message: e.message
101
101
  });
102
102
  }
103
103
  }));
104
104
  return n({
105
- name: e.name ? `@voltro/plugin-licensing#${e.name}` : "@voltro/plugin-licensing",
105
+ name: i({
106
+ base: "@voltro/plugin-licensing",
107
+ instance: e.name
108
+ }),
106
109
  description: "Offline-verified EdDSA license keys + entitlement snapshots; feeds @voltro/plugin-billing via entitlementResolver.",
107
- declaredEnv: v.declared,
108
- services: b,
110
+ declaredEnv: y.declared,
111
+ services: x,
109
112
  onActivate: (e) => t.gen(function* () {
110
- if (s = e.logger, r === void 0 || i === void 0) {
113
+ if (c = e.logger, r === void 0 || a === void 0) {
111
114
  e.logger.debug("licensing: no license configured — static plan entitlements apply");
112
115
  return;
113
116
  }
114
- yield* c(i, r);
117
+ yield* l(a, r);
115
118
  }),
116
119
  bindDataStore: (n, i) => {
117
120
  let a = e.snapshotUrl;
118
121
  if (a === void 0 || r === void 0 || i?.scheduleCoordinated === void 0) return;
119
- let l = r;
120
- i.scheduleCoordinated("licensing.refresh", o, async () => {
122
+ let o = r;
123
+ i.scheduleCoordinated("licensing.refresh", s, async () => {
121
124
  try {
122
125
  let e = await fetch(a);
123
126
  if (!e.ok) return;
124
127
  let n = (await e.text()).trim();
125
- n.length > 0 && await t.runPromise(c(n, l));
128
+ n.length > 0 && await t.runPromise(l(n, o));
126
129
  } catch (e) {
127
- s?.warn("license refresh failed", { message: e instanceof Error ? e.message : String(e) });
130
+ c?.warn("license refresh failed", { message: e instanceof Error ? e.message : String(e) });
128
131
  }
129
132
  });
130
133
  },
131
- onDeactivate: () => t.sync(() => h(void 0))
134
+ onDeactivate: () => t.sync(() => g(void 0))
132
135
  });
133
136
  };
134
137
  //#endregion
135
- export { y as LicenseService, s as LicenseVerifyError, x as PluginNotLicensed, _ as entitlementResolver, S as licenseAllowsPlugin, w as licensingPlugin, C as requireLicensedPlugin, f as verifyLicense };
138
+ export { b as LicenseService, c as LicenseVerifyError, S as PluginNotLicensed, v as entitlementResolver, C as licenseAllowsPlugin, T as licensingPlugin, w as requireLicensedPlugin, p as verifyLicense };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voltro/plugin-licensing",
3
- "version": "0.32.0",
3
+ "version": "0.34.0",
4
4
  "description": "Offline-verified license keys + cloud-issued entitlement snapshots for @voltro apps",
5
5
  "keywords": [
6
6
  "voltro",
@@ -27,7 +27,8 @@
27
27
  "types": "./dist/sign.d.ts",
28
28
  "import": "./dist/sign.js",
29
29
  "default": "./dist/sign.js"
30
- }
30
+ },
31
+ "./package.json": "./package.json"
31
32
  },
32
33
  "main": "./dist/index.js",
33
34
  "module": "./dist/index.js",
@@ -37,10 +38,10 @@
37
38
  "node": ">=24.0.0"
38
39
  },
39
40
  "dependencies": {
40
- "@voltro/database": "0.32.0",
41
- "@voltro/env": "0.32.0",
42
- "@voltro/logger": "0.32.0",
43
- "@voltro/protocol": "0.32.0",
41
+ "@voltro/database": "0.34.0",
42
+ "@voltro/env": "0.34.0",
43
+ "@voltro/logger": "0.34.0",
44
+ "@voltro/protocol": "0.34.0",
44
45
  "jose": "^6.2.4"
45
46
  },
46
47
  "peerDependencies": {