@codeo-engineering/licenserail-youtrack 0.1.0 → 0.1.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/app-files/licenserail-core.js +19 -4
- package/dist/app-files/licenserail-license.js +1 -1
- package/dist/app-files/licenserail.js +10 -2
- package/dist/app-files/widgets/licenserail-license/index.html +1 -1
- package/dist/app-files/widgets/licenserail-license/license.js +16 -1
- package/package.json +1 -1
|
@@ -514,7 +514,15 @@ function trialRequest(o) {
|
|
|
514
514
|
method: "POST",
|
|
515
515
|
url: url(o.apiUrl, "/trial"),
|
|
516
516
|
headers: headers(o.fingerprint),
|
|
517
|
-
body: JSON.stringify(clean({
|
|
517
|
+
body: JSON.stringify(clean({
|
|
518
|
+
keyId: o.keyId,
|
|
519
|
+
product: o.product,
|
|
520
|
+
fingerprint: o.fingerprint,
|
|
521
|
+
machineName: o.machineName,
|
|
522
|
+
appVersion: o.appVersion,
|
|
523
|
+
hostUsers: o.hostUsers,
|
|
524
|
+
host: o.host
|
|
525
|
+
}))
|
|
518
526
|
};
|
|
519
527
|
}
|
|
520
528
|
var REVOKING_CODES = [
|
|
@@ -618,9 +626,16 @@ function createLicenseClient(o) {
|
|
|
618
626
|
floating
|
|
619
627
|
})));
|
|
620
628
|
},
|
|
621
|
-
/** Starts (or gets back) this device's or installation's keyless trial. */
|
|
622
|
-
async startTrial(keyId) {
|
|
623
|
-
return await unidentified() ?? accept(await send(trialRequest({
|
|
629
|
+
/** Starts (or gets back) this device's or installation's keyless trial; apps inside a host pass the installation. */
|
|
630
|
+
async startTrial(keyId, host) {
|
|
631
|
+
return await unidentified() ?? accept(await send(trialRequest({
|
|
632
|
+
...target,
|
|
633
|
+
keyId,
|
|
634
|
+
machineName: o.machineName,
|
|
635
|
+
appVersion: o.appVersion,
|
|
636
|
+
hostUsers: o.hostUsers?.(),
|
|
637
|
+
host
|
|
638
|
+
})));
|
|
624
639
|
},
|
|
625
640
|
/** Refreshes when the token asks for it (or always with force); keeps the token on network errors. */
|
|
626
641
|
async refresh(force = false) {
|
|
@@ -60,7 +60,7 @@ exports.httpHandler = {
|
|
|
60
60
|
handle: function (ctx) {
|
|
61
61
|
guard(ctx, function () {
|
|
62
62
|
remember(ctx);
|
|
63
|
-
licenserail.startTrial(ctx);
|
|
63
|
+
licenserail.startTrial(ctx, body(ctx).baseUrls);
|
|
64
64
|
ctx.response.statusCode = 202;
|
|
65
65
|
ctx.response.json(licenserail.status(ctx));
|
|
66
66
|
});
|
|
@@ -122,11 +122,19 @@ function activate(ctx) {
|
|
|
122
122
|
send(ctx, core.activateRequest(Object.assign(t, common(ctx))), RESPONSE, true);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Starts the keyless trial. LicenseRail asks this YouTrack instance for its id at baseUrls (the addresses the admin page was
|
|
127
|
+
* opened from) before the trial starts, so the instance must be reachable from the internet.
|
|
128
|
+
*/
|
|
129
|
+
function startTrial(ctx, baseUrls) {
|
|
126
130
|
const t = target(ctx);
|
|
127
131
|
if (!t.fingerprint) throw new Error('Open the license page once so the app knows this YouTrack instance.');
|
|
132
|
+
const urls = (Array.isArray(baseUrls) ? baseUrls : [])
|
|
133
|
+
.filter(function (u) { return typeof u === 'string' && /^https?:\/\/[^\s/]+$/.test(u); }).slice(0, 3);
|
|
128
134
|
writeState(ctx, { pending: 'trial', lastAttemptAt: new Date().toISOString() });
|
|
129
|
-
send(ctx, core.trialRequest(Object.assign(t, common(ctx), {
|
|
135
|
+
send(ctx, core.trialRequest(Object.assign(t, common(ctx), {
|
|
136
|
+
keyId: config.keyId, host: { instanceId: installationId(ctx), baseUrls: urls },
|
|
137
|
+
})), RESPONSE, false);
|
|
130
138
|
}
|
|
131
139
|
|
|
132
140
|
function refresh(ctx) {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
</section>
|
|
20
20
|
<section class="card" id="trial-card" hidden>
|
|
21
21
|
<h2>Trial</h2>
|
|
22
|
-
<p>Try the app on this YouTrack instance without a key. One trial per instance.</p>
|
|
22
|
+
<p>Try the app on this YouTrack instance without a key. One trial per instance. The instance must be reachable from the internet; otherwise ask the vendor for a trial key.</p>
|
|
23
23
|
<div class="actions"><button id="trial">Start trial</button></div>
|
|
24
24
|
</section>
|
|
25
25
|
<p id="message" class="message" role="status"></p>
|
|
@@ -12,8 +12,23 @@ try {
|
|
|
12
12
|
installationId = null
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
/** Where this YouTrack is reached, as the browser sees it (the page runs inside it); LicenseRail checks the instance there. */
|
|
16
|
+
function baseUrls() {
|
|
17
|
+
const seen = []
|
|
18
|
+
const add = (value) => {
|
|
19
|
+
try {
|
|
20
|
+
const origin = new URL(value).origin
|
|
21
|
+
if (/^https?:/.test(origin) && !seen.includes(origin)) seen.push(origin)
|
|
22
|
+
} catch { /* not a URL */ }
|
|
23
|
+
}
|
|
24
|
+
if (window.location.ancestorOrigins?.length) add(window.location.ancestorOrigins[window.location.ancestorOrigins.length - 1])
|
|
25
|
+
if (document.referrer) add(document.referrer)
|
|
26
|
+
add(window.location.href)
|
|
27
|
+
return seen.slice(0, 3)
|
|
28
|
+
}
|
|
29
|
+
|
|
15
30
|
async function call(path, method = 'GET') {
|
|
16
|
-
return host.fetchApp(`${HANDLER}/${path}`, method === 'GET' ? { method } : { method, body: { installationId } })
|
|
31
|
+
return host.fetchApp(`${HANDLER}/${path}`, method === 'GET' ? { method } : { method, body: { installationId, baseUrls: baseUrls() } })
|
|
17
32
|
}
|
|
18
33
|
|
|
19
34
|
const LABELS = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeo-engineering/licenserail-youtrack",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "LicenseRail for YouTrack apps: license keys, keyless trials and per-user limits for apps sold outside JetBrains Marketplace billing. Adds readable backend modules and a License admin page to your app.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": { "access": "public" },
|