@kirby-tools/licensing 0.2.2 → 0.3.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/dist/index.d.mts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.mjs +15 -6
- package/package.json +1 -1
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
|
-
|
|
7
|
-
|
|
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,
|
|
21
|
+
assertActivationIntegrity: ({ component, licenseStatus }: {
|
|
20
22
|
component: MaybeRef<ComponentPublicInstance | null | undefined>;
|
|
21
|
-
|
|
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
|
-
|
|
7
|
-
|
|
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,
|
|
21
|
+
assertActivationIntegrity: ({ component, licenseStatus }: {
|
|
20
22
|
component: MaybeRef<ComponentPublicInstance | null | undefined>;
|
|
21
|
-
|
|
23
|
+
licenseStatus: MaybeRef<LicenseStatus>;
|
|
22
24
|
}) => Promise<void>;
|
|
23
25
|
openLicenseModal: () => Promise<LicenseModalResult>;
|
|
24
26
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,9 @@ const TRANSLATIONS = {
|
|
|
5
5
|
"modal.info": "Thanks for purchasing {label}! Please enter your email address and order ID to activate your license.",
|
|
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
|
+
"modal.error.invalid.unauthorized": "Email address or order ID is incorrect",
|
|
8
9
|
"modal.error.invalid.licenseKey": "License key invalid for this plugin",
|
|
10
|
+
"modal.error.incompatible.licenseKey": "License key invalid for this plugin version",
|
|
9
11
|
"modal.error.registered": "License key already registered",
|
|
10
12
|
"activate": "Activate",
|
|
11
13
|
"activated": "Plugin activated"
|
|
@@ -14,7 +16,9 @@ const TRANSLATIONS = {
|
|
|
14
16
|
"modal.info": "Dankesch\xF6n f\xFCr den Kauf von {label}! Bitte gib deine E-Mail-Adresse und Bestellnummer ein, um deine Lizenz zu aktivieren.",
|
|
15
17
|
"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
18
|
"modal.error.required.fields": "E-Mail-Adresse und Bestellnummer sind notwendig",
|
|
19
|
+
"modal.error.invalid.unauthorized": "E-Mail-Adresse oder Bestellnummer ist falsch",
|
|
17
20
|
"modal.error.invalid.licenseKey": "Lizenzschl\xFCssel ung\xFCltig f\xFCr dieses Plugin",
|
|
21
|
+
"modal.error.incompatible.licenseKey": "Lizenzschl\xFCssel ung\xFCltig f\xFCr diese Plugin-Version",
|
|
18
22
|
"modal.error.registered": "Lizenzschl\xFCssel bereits registriert",
|
|
19
23
|
"activate": "Aktivieren",
|
|
20
24
|
"activated": "Plugin aktiviert"
|
|
@@ -23,7 +27,9 @@ const TRANSLATIONS = {
|
|
|
23
27
|
"modal.info": "Merci d'avoir achet\xE9 {label} ! Veuillez saisir votre adresse e-mail et votre num\xE9ro de commande pour activer votre licence.",
|
|
24
28
|
"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
29
|
"modal.error.required.fields": "Adresse e-mail et num\xE9ro de commande requis",
|
|
30
|
+
"modal.error.invalid.unauthorized": "Adresse e-mail ou num\xE9ro de commande incorrect",
|
|
26
31
|
"modal.error.invalid.licenseKey": "Cl\xE9 de licence invalide pour ce plugin",
|
|
32
|
+
"modal.error.incompatible.licenseKey": "Cl\xE9 de licence invalide pour cette version du plugin",
|
|
27
33
|
"modal.error.registered": "Cl\xE9 de licence d\xE9j\xE0 enregistr\xE9e",
|
|
28
34
|
"activate": "Activer",
|
|
29
35
|
"activated": "Plugin activ\xE9"
|
|
@@ -106,8 +112,12 @@ function useLicense({
|
|
|
106
112
|
await register(email, Number(orderId));
|
|
107
113
|
} catch (error) {
|
|
108
114
|
let message = error.message;
|
|
109
|
-
if (message === "
|
|
115
|
+
if (message === "Unauthorized") {
|
|
116
|
+
message = t("modal.error.invalid.unauthorized");
|
|
117
|
+
} else if (message === "License key not valid for this plugin") {
|
|
110
118
|
message = t("modal.error.invalid.licenseKey");
|
|
119
|
+
} else if (message === "License key not valid for this plugin version") {
|
|
120
|
+
message = t("modal.error.incompatible.licenseKey");
|
|
111
121
|
} else if (message === "License key already registered") {
|
|
112
122
|
message = t("modal.error.registered");
|
|
113
123
|
}
|
|
@@ -122,14 +132,13 @@ function useLicense({
|
|
|
122
132
|
});
|
|
123
133
|
});
|
|
124
134
|
};
|
|
125
|
-
const assertActivationIntegrity = async ({ component,
|
|
126
|
-
|
|
127
|
-
const _license = unref(license);
|
|
128
|
-
if (_license !== false) {
|
|
135
|
+
const assertActivationIntegrity = async ({ component, licenseStatus }) => {
|
|
136
|
+
if (unref(licenseStatus) === "active") {
|
|
129
137
|
return;
|
|
130
138
|
}
|
|
131
139
|
await nextTick();
|
|
132
|
-
|
|
140
|
+
const _component = unref(component);
|
|
141
|
+
if (!_component?.$el || window.getComputedStyle(_component.$el).display === "none" || window.getComputedStyle(_component.$el).visibility === "hidden" || window.getComputedStyle(_component.$el).opacity === "0") {
|
|
133
142
|
throw new Error("Are you trying to hide the activation buttons? Please buy a license.");
|
|
134
143
|
}
|
|
135
144
|
};
|
package/package.json
CHANGED