@kirby-tools/licensing 0.6.9 → 0.7.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/dist/constants.js CHANGED
@@ -1,50 +1,37 @@
1
1
  //#region src/constants.ts
2
- const ERROR_KEY_MAP = {
3
- "Unauthorized": "kirby-tools.license.error.invalidCredentials",
4
- "License key not valid for this plugin": "kirby-tools.license.error.invalid",
5
- "License key not valid for this plugin version": "kirby-tools.license.error.incompatible",
6
- "License key not valid for this plugin version, please upgrade your license": "kirby-tools.license.error.upgradeable",
7
- "License key already activated": "kirby-tools.license.error.alreadyActivated"
8
- };
9
2
  const INTEGRITY_ERROR = "The activation buttons appear to be hidden. Please purchase a license.";
10
3
  const I18N_MESSAGES = {
11
4
  en: {
12
- "errors.validation.missingFields": "Email address and order ID are required",
13
5
  "activate": "Activate",
14
6
  "buy": "Buy a license",
15
7
  "upgrade": "Upgrade",
16
8
  "notification.success": "Plugin activated!"
17
9
  },
18
10
  de: {
19
- "errors.validation.missingFields": "E-Mail-Adresse und Bestellnummer sind notwendig",
20
11
  "activate": "Aktivieren",
21
12
  "buy": "Lizenz kaufen",
22
13
  "upgrade": "Upgrade",
23
14
  "notification.success": "Plugin aktiviert!"
24
15
  },
25
16
  fr: {
26
- "errors.validation.missingFields": "Adresse e-mail et numéro de commande requis",
27
17
  "activate": "Activer",
28
18
  "buy": "Acheter une licence",
29
19
  "upgrade": "Upgrade",
30
20
  "notification.success": "Plugin activé !"
31
21
  },
32
22
  nl: {
33
- "errors.validation.missingFields": "E-mailadres en bestelnummer zijn verplicht",
34
23
  "activate": "Activeren",
35
24
  "buy": "Koop een licentie",
36
25
  "upgrade": "Upgrade",
37
26
  "notification.success": "Plugin geactiveerd!"
38
27
  },
39
28
  es: {
40
- "errors.validation.missingFields": "La dirección de correo electrónico y el número de pedido son obligatorios",
41
29
  "activate": "Activar",
42
30
  "buy": "Comprar licencia",
43
31
  "upgrade": "Actualizar",
44
32
  "notification.success": "¡Plugin activado!"
45
33
  },
46
34
  it: {
47
- "errors.validation.missingFields": "Indirizzo email e numero d'ordine sono obbligatori",
48
35
  "activate": "Attiva",
49
36
  "buy": "Acquista licenza",
50
37
  "upgrade": "Aggiorna",
@@ -53,4 +40,4 @@ const I18N_MESSAGES = {
53
40
  };
54
41
 
55
42
  //#endregion
56
- export { ERROR_KEY_MAP, I18N_MESSAGES, INTEGRITY_ERROR };
43
+ export { I18N_MESSAGES, INTEGRITY_ERROR };
package/dist/license.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ERROR_KEY_MAP, INTEGRITY_ERROR } from "./constants.js";
1
+ import { INTEGRITY_ERROR } from "./constants.js";
2
2
  import { isLocalHost, t } from "./utils.js";
3
3
  import { unref, useDialog, usePanel } from "kirbyuse";
4
4
 
@@ -17,11 +17,13 @@ function useLicense(licenseOptions) {
17
17
  },
18
18
  email: {
19
19
  label: panel.t("kirby-tools.license.activate.email"),
20
- type: "email"
20
+ type: "email",
21
+ required: true
21
22
  },
22
23
  orderId: {
23
24
  label: panel.t("kirby-tools.license.activate.orderId"),
24
25
  type: "text",
26
+ required: true,
25
27
  help: panel.t("kirby-tools.license.activate.orderId.help")
26
28
  }
27
29
  },
@@ -68,10 +70,7 @@ function useLicense(licenseOptions) {
68
70
  async function activateLicense(event, licenseOptions) {
69
71
  const panel = usePanel();
70
72
  const { email, orderId } = event;
71
- if (!email || !orderId) {
72
- panel.notification.error(t("errors.validation.missingFields"));
73
- return false;
74
- }
73
+ if (!email || !orderId) return false;
75
74
  try {
76
75
  if ((await panel.api.post(`${licenseOptions.apiNamespace}/activate`, {
77
76
  email,
@@ -79,9 +78,7 @@ async function activateLicense(event, licenseOptions) {
79
78
  }))?.status !== "ok") throw new Error("Failed to activate license key");
80
79
  return true;
81
80
  } catch (error) {
82
- const message = error.message;
83
- const translationKey = ERROR_KEY_MAP[message];
84
- panel.notification.error(translationKey ? panel.t(translationKey) : message);
81
+ panel.notification.error(error.message);
85
82
  return false;
86
83
  }
87
84
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kirby-tools/licensing",
3
3
  "type": "module",
4
- "version": "0.6.9",
4
+ "version": "0.7.0",
5
5
  "packageManager": "pnpm@10.28.0",
6
6
  "description": "License system for Kirby Tools plugins within the Kirby Panel",
7
7
  "author": "Johann Schopplich <hello@johannschopplich.com>",