@kirby-tools/licensing 0.2.2 → 0.3.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/index.d.mts CHANGED
@@ -2,9 +2,11 @@ import { Ref, ComponentPublicInstance } from 'vue';
2
2
 
3
3
  type MaybeRef<T = any> = T | Ref<T>;
4
4
  type LicenseKey = string;
5
+ type LicenseStatus = 'active' | 'inactive' | 'invalid' | 'incompatible';
5
6
  interface License {
6
- licenseKey: LicenseKey;
7
- [key: string]: string;
7
+ key: LicenseKey;
8
+ version: number;
9
+ compatibility: string;
8
10
  }
9
11
 
10
12
  interface LicenseOptions {
@@ -16,9 +18,9 @@ interface LicenseModalResult {
16
18
  }
17
19
  declare function useLicense({ label, apiNamespace, }: LicenseOptions): {
18
20
  isLocalhost: boolean;
19
- assertActivationIntegrity: ({ component, license }: {
21
+ assertActivationIntegrity: ({ component, licenseStatus }: {
20
22
  component: MaybeRef<ComponentPublicInstance | null | undefined>;
21
- license: MaybeRef<boolean | string | License>;
23
+ licenseStatus: MaybeRef<LicenseStatus>;
22
24
  }) => Promise<void>;
23
25
  openLicenseModal: () => Promise<LicenseModalResult>;
24
26
  };
package/dist/index.d.ts CHANGED
@@ -2,9 +2,11 @@ import { Ref, ComponentPublicInstance } from 'vue';
2
2
 
3
3
  type MaybeRef<T = any> = T | Ref<T>;
4
4
  type LicenseKey = string;
5
+ type LicenseStatus = 'active' | 'inactive' | 'invalid' | 'incompatible';
5
6
  interface License {
6
- licenseKey: LicenseKey;
7
- [key: string]: string;
7
+ key: LicenseKey;
8
+ version: number;
9
+ compatibility: string;
8
10
  }
9
11
 
10
12
  interface LicenseOptions {
@@ -16,9 +18,9 @@ interface LicenseModalResult {
16
18
  }
17
19
  declare function useLicense({ label, apiNamespace, }: LicenseOptions): {
18
20
  isLocalhost: boolean;
19
- assertActivationIntegrity: ({ component, license }: {
21
+ assertActivationIntegrity: ({ component, licenseStatus }: {
20
22
  component: MaybeRef<ComponentPublicInstance | null | undefined>;
21
- license: MaybeRef<boolean | string | License>;
23
+ licenseStatus: MaybeRef<LicenseStatus>;
22
24
  }) => Promise<void>;
23
25
  openLicenseModal: () => Promise<LicenseModalResult>;
24
26
  };
package/dist/index.mjs CHANGED
@@ -6,6 +6,7 @@ const TRANSLATIONS = {
6
6
  "modal.fields.orderId.help": '<a href="https://app.lemonsqueezy.com/my-orders" target="_blank">Get your order number</a> from Lemon Squeezy or <a href="mailto:hello@kirby.tools">contact us</a> if you cannot find it.',
7
7
  "modal.error.required.fields": "Email address and order ID are required",
8
8
  "modal.error.invalid.licenseKey": "License key invalid for this plugin",
9
+ "modal.error.incompatible.licenseKey": "License key invalid for this plugin version",
9
10
  "modal.error.registered": "License key already registered",
10
11
  "activate": "Activate",
11
12
  "activated": "Plugin activated"
@@ -15,6 +16,7 @@ const TRANSLATIONS = {
15
16
  "modal.fields.orderId.help": 'Rufe die <a href="https://app.lemonsqueezy.com/my-orders" target="_blank">Bestellnummer von Lemon Squeezy ab</a> oder <a href="mailto:hello@kirby.tools">kontaktiere uns</a>, wenn du sie nicht finden kannst.',
16
17
  "modal.error.required.fields": "E-Mail-Adresse und Bestellnummer sind notwendig",
17
18
  "modal.error.invalid.licenseKey": "Lizenzschl\xFCssel ung\xFCltig f\xFCr dieses Plugin",
19
+ "modal.error.incompatible.licenseKey": "Lizenzschl\xFCssel ung\xFCltig f\xFCr diese Plugin-Version",
18
20
  "modal.error.registered": "Lizenzschl\xFCssel bereits registriert",
19
21
  "activate": "Aktivieren",
20
22
  "activated": "Plugin aktiviert"
@@ -24,6 +26,7 @@ const TRANSLATIONS = {
24
26
  "modal.fields.orderId.help": 'Obtenez votre num\xE9ro de commande sur <a href="https://app.lemonsqueezy.com/my-orders" target="_blank">Lemon Squeezy</a> ou <a href="mailto:hello@kirby.tools">contactez-nous</a> si vous ne le trouvez pas.',
25
27
  "modal.error.required.fields": "Adresse e-mail et num\xE9ro de commande requis",
26
28
  "modal.error.invalid.licenseKey": "Cl\xE9 de licence invalide pour ce plugin",
29
+ "modal.error.incompatible.licenseKey": "Cl\xE9 de licence invalide pour cette version du plugin",
27
30
  "modal.error.registered": "Cl\xE9 de licence d\xE9j\xE0 enregistr\xE9e",
28
31
  "activate": "Activer",
29
32
  "activated": "Plugin activ\xE9"
@@ -108,6 +111,8 @@ function useLicense({
108
111
  let message = error.message;
109
112
  if (message === "License key not valid for this plugin") {
110
113
  message = t("modal.error.invalid.licenseKey");
114
+ } else if (message === "License key not valid for this plugin version") {
115
+ message = t("modal.error.incompatible.licenseKey");
111
116
  } else if (message === "License key already registered") {
112
117
  message = t("modal.error.registered");
113
118
  }
@@ -122,14 +127,13 @@ function useLicense({
122
127
  });
123
128
  });
124
129
  };
125
- const assertActivationIntegrity = async ({ component, license }) => {
126
- const _component = unref(component);
127
- const _license = unref(license);
128
- if (_license !== false) {
130
+ const assertActivationIntegrity = async ({ component, licenseStatus }) => {
131
+ if (unref(licenseStatus) === "active") {
129
132
  return;
130
133
  }
131
134
  await nextTick();
132
- if (!_component?.$el || window.getComputedStyle(_component.$el).display === "none" || window.getComputedStyle(_component.$el).visibility === "hidden") {
135
+ const _component = unref(component);
136
+ if (!_component?.$el || window.getComputedStyle(_component.$el).display === "none" || window.getComputedStyle(_component.$el).visibility === "hidden" || window.getComputedStyle(_component.$el).opacity === "0") {
133
137
  throw new Error("Are you trying to hide the activation buttons? Please buy a license.");
134
138
  }
135
139
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kirby-tools/licensing",
3
3
  "type": "module",
4
- "version": "0.2.2",
4
+ "version": "0.3.0",
5
5
  "packageManager": "pnpm@9.4.0",
6
6
  "description": "Shared tooling for licensing in the Panel",
7
7
  "author": "Johann Schopplich <hello@johannschopplich.com>",