@codeo-engineering/licenserail-embedded 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.
@@ -76,9 +76,11 @@ function createLicenseClient(o) {
76
76
  ...target, licenseKey, machineName: o.machineName, appVersion: o.appVersion, hostUsers: o.hostUsers?.(), floating,
77
77
  })));
78
78
  },
79
- /** Starts (or gets back) this device's or installation's keyless trial. */
80
- async startTrial(keyId) {
81
- return (await unidentified()) ?? accept(await send((0, protocol_js_1.trialRequest)({ ...target, keyId, machineName: o.machineName, appVersion: o.appVersion, hostUsers: o.hostUsers?.() })));
79
+ /** Starts (or gets back) this device's or installation's keyless trial; apps inside a host pass the installation. */
80
+ async startTrial(keyId, host) {
81
+ return (await unidentified()) ?? accept(await send((0, protocol_js_1.trialRequest)({
82
+ ...target, keyId, machineName: o.machineName, appVersion: o.appVersion, hostUsers: o.hostUsers?.(), host,
83
+ })));
82
84
  },
83
85
  /** Refreshes when the token asks for it (or always with force); keeps the token on network errors. */
84
86
  async refresh(force = false) {
@@ -62,7 +62,10 @@ function trialRequest(o) {
62
62
  method: 'POST',
63
63
  url: url(o.apiUrl, '/trial'),
64
64
  headers: headers(o.fingerprint),
65
- body: JSON.stringify(clean({ keyId: o.keyId, product: o.product, fingerprint: o.fingerprint, machineName: o.machineName, appVersion: o.appVersion, hostUsers: o.hostUsers })),
65
+ body: JSON.stringify(clean({
66
+ keyId: o.keyId, product: o.product, fingerprint: o.fingerprint, machineName: o.machineName, appVersion: o.appVersion, hostUsers: o.hostUsers,
67
+ host: o.host,
68
+ })),
66
69
  };
67
70
  }
68
71
  /** Codes on which the local license must be removed; on all others (network errors, 402, 429, 5xx) the app keeps it. */
@@ -1,5 +1,5 @@
1
1
  import { type LicenseStatus, type LicenseSummary } from './evaluate.js';
2
- import { type HttpRequestDescription } from './protocol.js';
2
+ import { type HttpRequestDescription, type TrialHost } from './protocol.js';
3
3
  import { type Fingerprint, type LicensePayload } from './token.js';
4
4
  /** Key-value storage for the token and the last-run time (e.g. chrome.storage, localStorage, a settings store). */
5
5
  export interface LicenseStorage {
@@ -50,8 +50,8 @@ export declare function createLicenseClient(o: ClientOptions): {
50
50
  state: () => Promise<LicenseState>;
51
51
  /** Activates a license key on this device or installation. */
52
52
  activate(licenseKey: string, floating?: boolean): Promise<ActionResult>;
53
- /** Starts (or gets back) this device's or installation's keyless trial. */
54
- startTrial(keyId: string): Promise<ActionResult>;
53
+ /** Starts (or gets back) this device's or installation's keyless trial; apps inside a host pass the installation. */
54
+ startTrial(keyId: string, host?: TrialHost): Promise<ActionResult>;
55
55
  /** Refreshes when the token asks for it (or always with force); keeps the token on network errors. */
56
56
  refresh(force?: boolean): Promise<ActionResult>;
57
57
  /** Releases the license on this device or installation and removes it locally. */
@@ -73,9 +73,11 @@ export function createLicenseClient(o) {
73
73
  ...target, licenseKey, machineName: o.machineName, appVersion: o.appVersion, hostUsers: o.hostUsers?.(), floating,
74
74
  })));
75
75
  },
76
- /** Starts (or gets back) this device's or installation's keyless trial. */
77
- async startTrial(keyId) {
78
- return (await unidentified()) ?? accept(await send(trialRequest({ ...target, keyId, machineName: o.machineName, appVersion: o.appVersion, hostUsers: o.hostUsers?.() })));
76
+ /** Starts (or gets back) this device's or installation's keyless trial; apps inside a host pass the installation. */
77
+ async startTrial(keyId, host) {
78
+ return (await unidentified()) ?? accept(await send(trialRequest({
79
+ ...target, keyId, machineName: o.machineName, appVersion: o.appVersion, hostUsers: o.hostUsers?.(), host,
80
+ })));
79
81
  },
80
82
  /** Refreshes when the token asks for it (or always with force); keeps the token on network errors. */
81
83
  async refresh(force = false) {
@@ -42,9 +42,19 @@ export declare function deactivateRequest(o: Target & {
42
42
  token: string;
43
43
  floating?: boolean;
44
44
  }): HttpRequestDescription;
45
+ /**
46
+ * The host installation a trial is for. The server asks it for its id before a trial starts (YouTrack: the uuid that
47
+ * /api/config returns at baseUrls), so it must be reachable from the internet; otherwise the vendor gives a trial key.
48
+ */
49
+ export interface TrialHost {
50
+ instanceId: string;
51
+ baseUrls?: string[];
52
+ }
45
53
  export interface TrialOptions extends Target {
46
54
  /** The environment's signing key id (public; shown with the public key in the dashboard). */
47
55
  keyId: string;
56
+ /** Required for apps inside a host (fingerprint made with installationFingerprint from the same instance id). */
57
+ host?: TrialHost;
48
58
  machineName?: string;
49
59
  appVersion?: string;
50
60
  hostUsers?: number;
@@ -53,7 +53,10 @@ export function trialRequest(o) {
53
53
  method: 'POST',
54
54
  url: url(o.apiUrl, '/trial'),
55
55
  headers: headers(o.fingerprint),
56
- body: JSON.stringify(clean({ keyId: o.keyId, product: o.product, fingerprint: o.fingerprint, machineName: o.machineName, appVersion: o.appVersion, hostUsers: o.hostUsers })),
56
+ body: JSON.stringify(clean({
57
+ keyId: o.keyId, product: o.product, fingerprint: o.fingerprint, machineName: o.machineName, appVersion: o.appVersion, hostUsers: o.hostUsers,
58
+ host: o.host,
59
+ })),
57
60
  };
58
61
  }
59
62
  /** Codes on which the local license must be removed; on all others (network errors, 402, 429, 5xx) the app keeps it. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeo-engineering/licenserail-embedded",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "LicenseRail client core for apps inside a host platform (YouTrack apps, browser extensions, web apps): offline ES256 verification without WebCrypto, installation identity, activation, trials. No dependencies.",
5
5
  "license": "MIT",
6
6
  "publishConfig": { "access": "public" },