@n8n_io/license-sdk 3.2.1 → 4.0.0-rc.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.
@@ -9,6 +9,9 @@ export declare const default_alias: {
9
9
  postRequest: typeof postRequest;
10
10
  };
11
11
 
12
+ /** Default for `renewalNotFoundGracePeriodMs` (in ms): 24 hours */
13
+ export declare const DEFAULT_RENEWAL_NOT_FOUND_GRACE_PERIOD_MS: number;
14
+
12
15
  export declare function generateCertContainerStr(options?: {}): Promise<string>;
13
16
 
14
17
  export declare function generateCertContainerStrWithSigningScheme(signingScheme: 'pkcs1' | 'pss', options?: {}): Promise<string>;
@@ -32,6 +35,7 @@ export declare class LicenseManager {
32
35
  private expirySoonCallbackFired;
33
36
  private currentFeatures?;
34
37
  private isShuttingDown;
38
+ private firstRenewalNotFoundAt?;
35
39
  get isInitialized(): boolean;
36
40
  constructor(config: TLicenseManagerConfig);
37
41
  log(msg: string, logLevel: LogLevel): void;
@@ -72,7 +76,13 @@ export declare class LicenseManager {
72
76
  getManagementJwt(): string;
73
77
  getCertStr(): Promise<TLicenseBlock>;
74
78
  getConsumerId(): string | undefined;
79
+ /** Returns the cert's ephemeral flag, or false when no cert is loaded. */
80
+ isEphemeral(): boolean;
81
+ /** Returns this instance's fingerprint, or undefined before initialize() and after reset(). */
82
+ getDeviceFingerprint(): string | undefined;
75
83
  isRenewalDue(): boolean;
84
+ /** Starts or continues the NOT_FOUND streak and says whether its grace period has run out. */
85
+ private trackRenewalNotFound;
76
86
  private formatDuration;
77
87
  toString(): string;
78
88
  private triggerOnFeatureChangeCallback;
@@ -81,8 +91,9 @@ export declare class LicenseManager {
81
91
  private logCertLoaded;
82
92
  /** Renews when a renewal is due. Throws when the renewal fails. */
83
93
  renewIfDue(): Promise<void>;
84
- /** Replaces the loaded cert with the stored one when it changed. */
85
- private reloadStoredCert;
94
+ /** Replaces the loaded cert with the stored one when it changed, without a renewal. Throws when the store cannot be read. */
95
+ reloadStoredCert(): Promise<void>;
96
+ private loadStoredCertIfChanged;
86
97
  private renewalCron;
87
98
  private initCert;
88
99
  /** Replaces the cert in memory with `containerStr`. Throws when it does not parse. */
@@ -135,19 +146,22 @@ export declare function makeEntitlement({ validFrom, validTo, features, featureO
135
146
 
136
147
  export declare function makeRelativeDate(offsetInMinutes: number): Date;
137
148
 
149
+ declare type MetadataValue = boolean | number | string | MetadataValue[] | TMetadata;
150
+
138
151
  export declare function postRequest<T>(url: string, data: Record<string, unknown>, options?: {
139
152
  timeoutInMs?: number;
140
153
  productIdentifier?: string;
141
154
  }): Promise<{
142
155
  status: number;
143
156
  data: T;
157
+ requestId: string;
144
158
  }>;
145
159
 
146
160
  declare type RenewalCause = 'startup' | 'shutdown' | 'request' | 'auto' | 'unknown';
147
161
 
148
162
  declare type RepeatingTimer = NodeJS.Timeout;
149
163
 
150
- export declare const SDK_VERSION = "3.2.1";
164
+ export declare const SDK_VERSION = "4.0.0-rc.1";
151
165
 
152
166
  declare type SingleTimer = NodeJS.Timeout;
153
167
 
@@ -191,6 +205,13 @@ export declare type TLicenseCertObj = {
191
205
  * Specifies whether the license is ephemeral and therefore does not have corresponding entries in the license server DB.
192
206
  */
193
207
  isEphemeral: boolean;
208
+ /**
209
+ * Specifies whether the license is an air-gapped license: a persisted license issued for an
210
+ * offline install that is delivered by hand and never renewed via phone-home. Present only on air-gapped
211
+ * issuances. The SDK does not currently act on this flag; renewal/phone-home for air-gapped installs is
212
+ * suppressed via `autoRenewEnabled: false` / `offlineMode`. Reserved for future SDK-side enforcement.
213
+ */
214
+ isAirgapped?: boolean;
194
215
  };
195
216
 
196
217
  export declare type TLicenseContainer = {
@@ -224,12 +245,20 @@ export declare type TLicenseManagerConfig = {
224
245
  offlineMode?: boolean;
225
246
  renewOnInit?: boolean;
226
247
  autoRenewOffset?: number;
248
+ /**
249
+ * How long consecutive NOT_FOUND renewal failures must last before deleting the local cert, in milliseconds.
250
+ * Tracked in memory and reset by any other renewal response or a transport failure.
251
+ * Set to 0 to delete immediately.
252
+ *
253
+ * @default {@link DEFAULT_RENEWAL_NOT_FOUND_GRACE_PERIOD_MS} (24 hours)
254
+ */
255
+ renewalNotFoundGracePeriodMs?: number;
227
256
  loadCertStr: () => Promise<TLicenseBlock>;
228
257
  saveCertStr: (cert: TLicenseBlock) => Promise<void>;
229
258
  collectUsageMetrics?: () => Promise<Array<TUsageMetric>>;
230
259
  collectPassthroughData?: () => Promise<TPassthroughData>;
231
260
  deviceFingerprint?: () => string | Promise<string>;
232
- onFeatureChange?: (features: TFeatures) => any;
261
+ onFeatureChange?: (features: TFeatures) => unknown;
233
262
  onLicenseRenewed?: () => void;
234
263
  /**
235
264
  * Callback to fire when the license is within `expirySoonOffsetMins` minutes of expiry.
@@ -242,14 +271,14 @@ export declare type TLicenseManagerConfig = {
242
271
  };
243
272
 
244
273
  export declare type TLogger = {
245
- error: Function;
246
- warn: Function;
247
- info: Function;
248
- debug: Function;
274
+ error: (message: string) => void;
275
+ warn: (message: string) => void;
276
+ info: (message: string) => void;
277
+ debug: (message: string) => void;
249
278
  };
250
279
 
251
280
  export declare type TMetadata = {
252
- [key: string]: boolean | number | string | Array<any> | {};
281
+ [key: string]: MetadataValue;
253
282
  };
254
283
 
255
284
  export declare type TPassthroughData = Record<string, unknown>;
@@ -1,2 +1,2 @@
1
- "use strict";var c=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var m=(t,e)=>{for(var r in e)c(t,r,{get:e[r],enumerable:!0})},_=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of g(e))!d.call(t,o)&&o!==r&&c(t,o,{get:()=>e[o],enumerable:!(s=x(e,o))||s.enumerable});return t};var P=t=>_(c({},"__esModule",{value:!0}),t);var I={};m(I,{default:()=>A,postRequest:()=>l});module.exports=P(I);var i=require("undici"),f=require("url");var y="3.2.1";function p(t){let e=process.env[t]||process.env[t.toUpperCase()];return e?new i.ProxyAgent(e):!1}var a=p("http_proxy_license_server")||p("http_proxy"),u=p("https_proxy_license_server")||p("https_proxy"),R={...a?{"http:":a}:{},...u?{"https:":u}:{}},S=((process.env.no_proxy||process.env.NO_PROXY)??"").split(",").map(t=>t.trim()).filter(t=>t.length>0),w=t=>{let{host:e,protocol:r}=t;return!(r==="http:"&&!a||r==="https:"&&!u||S.some(s=>e.endsWith(s)))};async function l(t,e,r={}){let s=new f.URL(t),o;w(s)&&(o=R[s.protocol]);try{let n=await(0,i.fetch)(t,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json","User-Agent":`License-SDK/${y} (Node.js ${process.version}; ${process.platform}) ${r.productIdentifier??""}`},signal:AbortSignal.timeout(r.timeoutInMs??3e4),...o?{dispatcher:o}:{}});return{status:n.status,data:await n.json()}}catch(n){let h=new Error("Connection Error: "+n.message);throw h.cause=n,h}}var A={postRequest:l};0&&(module.exports={postRequest});
1
+ "use strict";var a=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var I=(t,e)=>{for(var r in e)a(t,r,{get:e[r],enumerable:!0})},P=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of m(e))!_.call(t,o)&&o!==r&&a(t,o,{get:()=>e[o],enumerable:!(n=y(e,o))||n.enumerable});return t};var R=t=>P(a({},"__esModule",{value:!0}),t);var v={};I(v,{default:()=>A,postRequest:()=>x});module.exports=R(v);var c=require("undici"),g=require("crypto"),l=require("url");var d="4.0.0-rc.1";function i(t){let e=process.env[t]||process.env[t.toUpperCase()];return e?new c.ProxyAgent(e):!1}var u=i("http_proxy_license_server")||i("http_proxy"),f=i("https_proxy_license_server")||i("https_proxy"),S={...u?{"http:":u}:{},...f?{"https:":f}:{}},U=((process.env.no_proxy||process.env.NO_PROXY)??"").split(",").map(t=>t.trim()).filter(t=>t.length>0),w=t=>{let{host:e,protocol:r}=t;return!(r==="http:"&&!u||r==="https:"&&!f||U.some(n=>e.endsWith(n)))};async function x(t,e,r={}){let n=new l.URL(t),o;w(n)&&(o=S[n.protocol]);let p=(0,g.randomUUID)();try{let s=await(0,c.fetch)(t,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json","x-request-id":p,"User-Agent":`License-SDK/${d} (Node.js ${process.version}; ${process.platform}) ${r.productIdentifier??""}`},signal:AbortSignal.timeout(r.timeoutInMs??3e4),...o?{dispatcher:o}:{}});return p=s.headers.get("x-request-id")??p,{status:s.status,data:await s.json(),requestId:p}}catch(s){let h=new Error(`Connection Error: ${s instanceof Error?s.message:String(s)} (request id: ${p})`);throw h.cause=s,h}}var A={postRequest:x};0&&(module.exports={postRequest});
2
2
  //# sourceMappingURL=httpRequest.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/httpRequest.ts","../src/version.ts"],"sourcesContent":["import { fetch, ProxyAgent } from 'undici'\n\nimport { URL } from 'node:url'\nimport { SDK_VERSION } from './version'\n\nfunction getProxyAgent(envVar: string) {\n const proxyURI = process.env[envVar] || process.env[envVar.toUpperCase()]\n return proxyURI ? new ProxyAgent(proxyURI) : false\n}\n\nconst httpProxy =\n getProxyAgent('http_proxy_license_server') || getProxyAgent('http_proxy')\n\nconst httpsProxy =\n getProxyAgent('https_proxy_license_server') || getProxyAgent('https_proxy')\n\nconst proxyAgents = {\n ...(httpProxy ? { 'http:': httpProxy } : {}),\n ...(httpsProxy ? { 'https:': httpsProxy } : {}),\n}\n\nconst noProxyRules = (\n (process.env['no_proxy'] || process.env['NO_PROXY']) ??\n ''\n)\n .split(',')\n .map((rule) => rule.trim())\n .filter((rule) => rule.length > 0)\n\nconst shouldUseProxy = (url: URL) => {\n const { host, protocol } = url\n\n if (protocol === 'http:' && !httpProxy) {\n return false\n }\n\n if (protocol === 'https:' && !httpsProxy) {\n return false\n }\n\n if (noProxyRules.some((rule) => host.endsWith(rule))) {\n return false\n }\n\n return true\n}\n\nexport async function postRequest<T>(\n url: string,\n data: Record<string, unknown>,\n options: {\n timeoutInMs?: number\n productIdentifier?: string\n } = {}\n) {\n const targetUrl = new URL(url)\n\n let proxyAgent: ProxyAgent | undefined\n\n if (shouldUseProxy(targetUrl)) {\n proxyAgent = proxyAgents[targetUrl.protocol as 'http:' | 'https:']\n }\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n body: JSON.stringify(data),\n headers: {\n 'Content-Type': 'application/json',\n 'User-Agent': `License-SDK/${SDK_VERSION} (Node.js ${\n process.version\n }; ${process.platform}) ${options.productIdentifier ?? ''}`,\n },\n signal: AbortSignal.timeout(options.timeoutInMs ?? 30_000),\n ...(proxyAgent ? { dispatcher: proxyAgent } : {}),\n })\n\n return {\n status: response.status,\n data: (await response.json()) as T,\n }\n } catch (err) {\n const error = new Error('Connection Error: ' + (err as any).message)\n ;(error as any).cause = err\n throw error\n }\n}\n\nexport default {\n postRequest,\n}\n","// '3.2.1' is replaced before publishing to npm at .github/workflows/publish_sdk.yml\nexport const SDK_VERSION = '3.2.1'\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,gBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAkC,kBAElCC,EAAoB,eCDb,IAAMC,EAAc,QDI3B,SAASC,EAAcC,EAAgB,CACrC,IAAMC,EAAW,QAAQ,IAAID,CAAM,GAAK,QAAQ,IAAIA,EAAO,YAAY,CAAC,EACxE,OAAOC,EAAW,IAAI,aAAWA,CAAQ,EAAI,EAC/C,CAEA,IAAMC,EACJH,EAAc,2BAA2B,GAAKA,EAAc,YAAY,EAEpEI,EACJJ,EAAc,4BAA4B,GAAKA,EAAc,aAAa,EAEtEK,EAAc,CAClB,GAAIF,EAAY,CAAE,QAASA,CAAU,EAAI,CAAC,EAC1C,GAAIC,EAAa,CAAE,SAAUA,CAAW,EAAI,CAAC,CAC/C,EAEME,IACH,QAAQ,IAAI,UAAe,QAAQ,IAAI,WACxC,IAEC,MAAM,GAAG,EACT,IAAKC,GAASA,EAAK,KAAK,CAAC,EACzB,OAAQA,GAASA,EAAK,OAAS,CAAC,EAE7BC,EAAkBC,GAAa,CACnC,GAAM,CAAE,KAAAC,EAAM,SAAAC,CAAS,EAAIF,EAU3B,MARI,EAAAE,IAAa,SAAW,CAACR,GAIzBQ,IAAa,UAAY,CAACP,GAI1BE,EAAa,KAAMC,GAASG,EAAK,SAASH,CAAI,CAAC,EAKrD,EAEA,eAAsBK,EACpBH,EACAI,EACAC,EAGI,CAAC,EACL,CACA,IAAMC,EAAY,IAAI,MAAIN,CAAG,EAEzBO,EAEAR,EAAeO,CAAS,IAC1BC,EAAaX,EAAYU,EAAU,QAA8B,GAGnE,GAAI,CACF,IAAME,EAAW,QAAM,SAAMR,EAAK,CAChC,OAAQ,OACR,KAAM,KAAK,UAAUI,CAAI,EACzB,QAAS,CACP,eAAgB,mBAChB,aAAc,eAAeK,CAAW,aACtC,QAAQ,OACV,KAAK,QAAQ,QAAQ,KAAKJ,EAAQ,mBAAqB,EAAE,EAC3D,EACA,OAAQ,YAAY,QAAQA,EAAQ,aAAe,GAAM,EACzD,GAAIE,EAAa,CAAE,WAAYA,CAAW,EAAI,CAAC,CACjD,CAAC,EAED,MAAO,CACL,OAAQC,EAAS,OACjB,KAAO,MAAMA,EAAS,KAAK,CAC7B,CACF,OAASE,EAAK,CACZ,IAAMC,EAAQ,IAAI,MAAM,qBAAwBD,EAAY,OAAO,EAClE,MAACC,EAAc,MAAQD,EAClBC,CACR,CACF,CAEA,IAAOC,EAAQ,CACb,YAAAT,CACF","names":["httpRequest_exports","__export","httpRequest_default","postRequest","__toCommonJS","import_undici","import_node_url","SDK_VERSION","getProxyAgent","envVar","proxyURI","httpProxy","httpsProxy","proxyAgents","noProxyRules","rule","shouldUseProxy","url","host","protocol","postRequest","data","options","targetUrl","proxyAgent","response","SDK_VERSION","err","error","httpRequest_default"]}
1
+ {"version":3,"sources":["../src/httpRequest.ts","../src/version.ts"],"sourcesContent":["import { fetch, ProxyAgent } from 'undici'\n\nimport { randomUUID } from 'node:crypto'\nimport { URL } from 'node:url'\nimport { SDK_VERSION } from './version'\n\nfunction getProxyAgent(envVar: string) {\n const proxyURI = process.env[envVar] || process.env[envVar.toUpperCase()]\n return proxyURI ? new ProxyAgent(proxyURI) : false\n}\n\nconst httpProxy =\n getProxyAgent('http_proxy_license_server') || getProxyAgent('http_proxy')\n\nconst httpsProxy =\n getProxyAgent('https_proxy_license_server') || getProxyAgent('https_proxy')\n\nconst proxyAgents = {\n ...(httpProxy ? { 'http:': httpProxy } : {}),\n ...(httpsProxy ? { 'https:': httpsProxy } : {}),\n}\n\nconst noProxyRules = (\n (process.env['no_proxy'] || process.env['NO_PROXY']) ??\n ''\n)\n .split(',')\n .map((rule) => rule.trim())\n .filter((rule) => rule.length > 0)\n\nconst shouldUseProxy = (url: URL) => {\n const { host, protocol } = url\n\n if (protocol === 'http:' && !httpProxy) {\n return false\n }\n\n if (protocol === 'https:' && !httpsProxy) {\n return false\n }\n\n if (noProxyRules.some((rule) => host.endsWith(rule))) {\n return false\n }\n\n return true\n}\n\nexport async function postRequest<T>(\n url: string,\n data: Record<string, unknown>,\n options: {\n timeoutInMs?: number\n productIdentifier?: string\n } = {}\n) {\n const targetUrl = new URL(url)\n\n let proxyAgent: ProxyAgent | undefined\n\n if (shouldUseProxy(targetUrl)) {\n proxyAgent = proxyAgents[targetUrl.protocol as 'http:' | 'https:']\n }\n\n let requestId: string = randomUUID()\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n body: JSON.stringify(data),\n headers: {\n 'Content-Type': 'application/json',\n 'x-request-id': requestId,\n 'User-Agent': `License-SDK/${SDK_VERSION} (Node.js ${\n process.version\n }; ${process.platform}) ${options.productIdentifier ?? ''}`,\n },\n signal: AbortSignal.timeout(options.timeoutInMs ?? 30_000),\n ...(proxyAgent ? { dispatcher: proxyAgent } : {}),\n })\n\n requestId = response.headers.get('x-request-id') ?? requestId\n\n return {\n status: response.status,\n data: (await response.json()) as T,\n requestId,\n }\n } catch (err) {\n const error = new Error(\n `Connection Error: ${err instanceof Error ? err.message : String(err)} (request id: ${requestId})`\n )\n error.cause = err\n throw error\n }\n}\n\nexport default {\n postRequest,\n}\n","// '4.0.0-rc.1' is replaced before publishing to npm at .github/workflows/publish_sdk.yml\nexport const SDK_VERSION = '4.0.0-rc.1'\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,gBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAkC,kBAElCC,EAA2B,kBAC3BC,EAAoB,eCFb,IAAMC,EAAc,aDK3B,SAASC,EAAcC,EAAgB,CACrC,IAAMC,EAAW,QAAQ,IAAID,CAAM,GAAK,QAAQ,IAAIA,EAAO,YAAY,CAAC,EACxE,OAAOC,EAAW,IAAI,aAAWA,CAAQ,EAAI,EAC/C,CAEA,IAAMC,EACJH,EAAc,2BAA2B,GAAKA,EAAc,YAAY,EAEpEI,EACJJ,EAAc,4BAA4B,GAAKA,EAAc,aAAa,EAEtEK,EAAc,CAClB,GAAIF,EAAY,CAAE,QAASA,CAAU,EAAI,CAAC,EAC1C,GAAIC,EAAa,CAAE,SAAUA,CAAW,EAAI,CAAC,CAC/C,EAEME,IACH,QAAQ,IAAI,UAAe,QAAQ,IAAI,WACxC,IAEC,MAAM,GAAG,EACT,IAAKC,GAASA,EAAK,KAAK,CAAC,EACzB,OAAQA,GAASA,EAAK,OAAS,CAAC,EAE7BC,EAAkBC,GAAa,CACnC,GAAM,CAAE,KAAAC,EAAM,SAAAC,CAAS,EAAIF,EAU3B,MARI,EAAAE,IAAa,SAAW,CAACR,GAIzBQ,IAAa,UAAY,CAACP,GAI1BE,EAAa,KAAMC,GAASG,EAAK,SAASH,CAAI,CAAC,EAKrD,EAEA,eAAsBK,EACpBH,EACAI,EACAC,EAGI,CAAC,EACL,CACA,IAAMC,EAAY,IAAI,MAAIN,CAAG,EAEzBO,EAEAR,EAAeO,CAAS,IAC1BC,EAAaX,EAAYU,EAAU,QAA8B,GAGnE,IAAIE,KAAoB,cAAW,EAEnC,GAAI,CACF,IAAMC,EAAW,QAAM,SAAMT,EAAK,CAChC,OAAQ,OACR,KAAM,KAAK,UAAUI,CAAI,EACzB,QAAS,CACP,eAAgB,mBAChB,eAAgBI,EAChB,aAAc,eAAeE,CAAW,aACtC,QAAQ,OACV,KAAK,QAAQ,QAAQ,KAAKL,EAAQ,mBAAqB,EAAE,EAC3D,EACA,OAAQ,YAAY,QAAQA,EAAQ,aAAe,GAAM,EACzD,GAAIE,EAAa,CAAE,WAAYA,CAAW,EAAI,CAAC,CACjD,CAAC,EAED,OAAAC,EAAYC,EAAS,QAAQ,IAAI,cAAc,GAAKD,EAE7C,CACL,OAAQC,EAAS,OACjB,KAAO,MAAMA,EAAS,KAAK,EAC3B,UAAAD,CACF,CACF,OAASG,EAAK,CACZ,IAAMC,EAAQ,IAAI,MAChB,qBAAqBD,aAAe,MAAQA,EAAI,QAAU,OAAOA,CAAG,CAAC,iBAAiBH,CAAS,GACjG,EACA,MAAAI,EAAM,MAAQD,EACRC,CACR,CACF,CAEA,IAAOC,EAAQ,CACb,YAAAV,CACF","names":["httpRequest_exports","__export","httpRequest_default","postRequest","__toCommonJS","import_undici","import_node_crypto","import_node_url","SDK_VERSION","getProxyAgent","envVar","proxyURI","httpProxy","httpsProxy","proxyAgents","noProxyRules","rule","shouldUseProxy","url","host","protocol","postRequest","data","options","targetUrl","proxyAgent","requestId","response","SDK_VERSION","err","error","httpRequest_default"]}
@@ -1,2 +1,2 @@
1
- import{fetch as h,ProxyAgent as y}from"undici";import{URL as f}from"url";var u="3.2.1";function n(t){let e=process.env[t]||process.env[t.toUpperCase()];return e?new y(e):!1}var i=n("http_proxy_license_server")||n("http_proxy"),c=n("https_proxy_license_server")||n("https_proxy"),l={...i?{"http:":i}:{},...c?{"https:":c}:{}},x=((process.env.no_proxy||process.env.NO_PROXY)??"").split(",").map(t=>t.trim()).filter(t=>t.length>0),g=t=>{let{host:e,protocol:r}=t;return!(r==="http:"&&!i||r==="https:"&&!c||x.some(s=>e.endsWith(s)))};async function d(t,e,r={}){let s=new f(t),p;g(s)&&(p=l[s.protocol]);try{let o=await h(t,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json","User-Agent":`License-SDK/${u} (Node.js ${process.version}; ${process.platform}) ${r.productIdentifier??""}`},signal:AbortSignal.timeout(r.timeoutInMs??3e4),...p?{dispatcher:p}:{}});return{status:o.status,data:await o.json()}}catch(o){let a=new Error("Connection Error: "+o.message);throw a.cause=o,a}}var S={postRequest:d};export{S as default,d as postRequest};
1
+ import{fetch as h,ProxyAgent as d}from"undici";import{randomUUID as g}from"crypto";import{URL as l}from"url";var f="4.0.0-rc.1";function p(t){let r=process.env[t]||process.env[t.toUpperCase()];return r?new d(r):!1}var c=p("http_proxy_license_server")||p("http_proxy"),a=p("https_proxy_license_server")||p("https_proxy"),x={...c?{"http:":c}:{},...a?{"https:":a}:{}},y=((process.env.no_proxy||process.env.NO_PROXY)??"").split(",").map(t=>t.trim()).filter(t=>t.length>0),m=t=>{let{host:r,protocol:o}=t;return!(o==="http:"&&!c||o==="https:"&&!a||y.some(n=>r.endsWith(n)))};async function _(t,r,o={}){let n=new l(t),i;m(n)&&(i=x[n.protocol]);let s=g();try{let e=await h(t,{method:"POST",body:JSON.stringify(r),headers:{"Content-Type":"application/json","x-request-id":s,"User-Agent":`License-SDK/${f} (Node.js ${process.version}; ${process.platform}) ${o.productIdentifier??""}`},signal:AbortSignal.timeout(o.timeoutInMs??3e4),...i?{dispatcher:i}:{}});return s=e.headers.get("x-request-id")??s,{status:e.status,data:await e.json(),requestId:s}}catch(e){let u=new Error(`Connection Error: ${e instanceof Error?e.message:String(e)} (request id: ${s})`);throw u.cause=e,u}}var w={postRequest:_};export{w as default,_ as postRequest};
2
2
  //# sourceMappingURL=httpRequest.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/httpRequest.ts","../src/version.ts"],"sourcesContent":["import { fetch, ProxyAgent } from 'undici'\n\nimport { URL } from 'node:url'\nimport { SDK_VERSION } from './version'\n\nfunction getProxyAgent(envVar: string) {\n const proxyURI = process.env[envVar] || process.env[envVar.toUpperCase()]\n return proxyURI ? new ProxyAgent(proxyURI) : false\n}\n\nconst httpProxy =\n getProxyAgent('http_proxy_license_server') || getProxyAgent('http_proxy')\n\nconst httpsProxy =\n getProxyAgent('https_proxy_license_server') || getProxyAgent('https_proxy')\n\nconst proxyAgents = {\n ...(httpProxy ? { 'http:': httpProxy } : {}),\n ...(httpsProxy ? { 'https:': httpsProxy } : {}),\n}\n\nconst noProxyRules = (\n (process.env['no_proxy'] || process.env['NO_PROXY']) ??\n ''\n)\n .split(',')\n .map((rule) => rule.trim())\n .filter((rule) => rule.length > 0)\n\nconst shouldUseProxy = (url: URL) => {\n const { host, protocol } = url\n\n if (protocol === 'http:' && !httpProxy) {\n return false\n }\n\n if (protocol === 'https:' && !httpsProxy) {\n return false\n }\n\n if (noProxyRules.some((rule) => host.endsWith(rule))) {\n return false\n }\n\n return true\n}\n\nexport async function postRequest<T>(\n url: string,\n data: Record<string, unknown>,\n options: {\n timeoutInMs?: number\n productIdentifier?: string\n } = {}\n) {\n const targetUrl = new URL(url)\n\n let proxyAgent: ProxyAgent | undefined\n\n if (shouldUseProxy(targetUrl)) {\n proxyAgent = proxyAgents[targetUrl.protocol as 'http:' | 'https:']\n }\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n body: JSON.stringify(data),\n headers: {\n 'Content-Type': 'application/json',\n 'User-Agent': `License-SDK/${SDK_VERSION} (Node.js ${\n process.version\n }; ${process.platform}) ${options.productIdentifier ?? ''}`,\n },\n signal: AbortSignal.timeout(options.timeoutInMs ?? 30_000),\n ...(proxyAgent ? { dispatcher: proxyAgent } : {}),\n })\n\n return {\n status: response.status,\n data: (await response.json()) as T,\n }\n } catch (err) {\n const error = new Error('Connection Error: ' + (err as any).message)\n ;(error as any).cause = err\n throw error\n }\n}\n\nexport default {\n postRequest,\n}\n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KN,EAAQ,mBAAqB,EAAE,EAC3D,EACA,OAAQ,YAAY,QAAQA,EAAQ,aAAe,GAAM,EACzD,GAAIG,EAAa,CAAE,WAAYA,CAAW,EAAI,CAAC,CACjD,CAAC,EAED,MAAO,CACL,OAAQC,EAAS,OACjB,KAAO,MAAMA,EAAS,KAAK,CAC7B,CACF,OAASG,EAAK,CACZ,IAAMC,EAAQ,IAAI,MAAM,qBAAwBD,EAAY,OAAO,EAClE,MAACC,EAAc,MAAQD,EAClBC,CACR,CACF,CAEA,IAAOC,EAAQ,CACb,YAAAX,CACF","names":["fetch","ProxyAgent","URL","SDK_VERSION","getProxyAgent","envVar","proxyURI","ProxyAgent","httpProxy","httpsProxy","proxyAgents","noProxyRules","rule","shouldUseProxy","url","host","protocol","postRequest","data","options","targetUrl","URL","proxyAgent","response","fetch","SDK_VERSION","err","error","httpRequest_default"]}
1
+ {"version":3,"sources":["../src/httpRequest.ts","../src/version.ts"],"sourcesContent":["import { fetch, ProxyAgent } from 'undici'\n\nimport { randomUUID } from 'node:crypto'\nimport { URL } from 'node:url'\nimport { SDK_VERSION } from './version'\n\nfunction getProxyAgent(envVar: string) {\n const proxyURI = process.env[envVar] || process.env[envVar.toUpperCase()]\n return proxyURI ? new ProxyAgent(proxyURI) : false\n}\n\nconst httpProxy =\n getProxyAgent('http_proxy_license_server') || getProxyAgent('http_proxy')\n\nconst httpsProxy =\n getProxyAgent('https_proxy_license_server') || getProxyAgent('https_proxy')\n\nconst proxyAgents = {\n ...(httpProxy ? { 'http:': httpProxy } : {}),\n ...(httpsProxy ? { 'https:': httpsProxy } : {}),\n}\n\nconst noProxyRules = (\n (process.env['no_proxy'] || process.env['NO_PROXY']) ??\n ''\n)\n .split(',')\n .map((rule) => rule.trim())\n .filter((rule) => rule.length > 0)\n\nconst shouldUseProxy = (url: URL) => {\n const { host, protocol } = url\n\n if (protocol === 'http:' && !httpProxy) {\n return false\n }\n\n if (protocol === 'https:' && !httpsProxy) {\n return false\n }\n\n if (noProxyRules.some((rule) => host.endsWith(rule))) {\n return false\n }\n\n return true\n}\n\nexport async function postRequest<T>(\n url: string,\n data: Record<string, unknown>,\n options: {\n timeoutInMs?: number\n productIdentifier?: string\n } = {}\n) {\n const targetUrl = new URL(url)\n\n let proxyAgent: ProxyAgent | undefined\n\n if (shouldUseProxy(targetUrl)) {\n proxyAgent = proxyAgents[targetUrl.protocol as 'http:' | 'https:']\n }\n\n let requestId: string = randomUUID()\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n body: JSON.stringify(data),\n headers: {\n 'Content-Type': 'application/json',\n 'x-request-id': requestId,\n 'User-Agent': `License-SDK/${SDK_VERSION} (Node.js ${\n process.version\n }; ${process.platform}) ${options.productIdentifier ?? ''}`,\n },\n signal: AbortSignal.timeout(options.timeoutInMs ?? 30_000),\n ...(proxyAgent ? { dispatcher: proxyAgent } : {}),\n })\n\n requestId = response.headers.get('x-request-id') ?? requestId\n\n return {\n status: response.status,\n data: (await response.json()) as T,\n requestId,\n }\n } catch (err) {\n const error = new Error(\n `Connection Error: ${err instanceof Error ? err.message : String(err)} (request id: ${requestId})`\n )\n error.cause = err\n throw error\n }\n}\n\nexport default {\n postRequest,\n}\n","// '4.0.0-rc.1' is replaced before publishing to npm at .github/workflows/publish_sdk.yml\nexport const SDK_VERSION = '4.0.0-rc.1'\n"],"mappings":"AAAA,OAAS,SAAAA,EAAO,cAAAC,MAAkB,SAElC,OAAS,cAAAC,MAAkB,SAC3B,OAAS,OAAAC,MAAW,MCFb,IAAMC,EAAc,aDK3B,SAASC,EAAcC,EAAgB,CACrC,IAAMC,EAAW,QAAQ,IAAID,CAAM,GAAK,QAAQ,IAAIA,EAAO,YAAY,CAAC,EACxE,OAAOC,EAAW,IAAIC,EAAWD,CAAQ,EAAI,EAC/C,CAEA,IAAME,EACJJ,EAAc,2BAA2B,GAAKA,EAAc,YAAY,EAEpEK,EACJL,EAAc,4BAA4B,GAAKA,EAAc,aAAa,EAEtEM,EAAc,CAClB,GAAIF,E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MAAQD,EACRC,CACR,CACF,CAEA,IAAOC,EAAQ,CACb,YAAAb,CACF","names":["fetch","ProxyAgent","randomUUID","URL","SDK_VERSION","getProxyAgent","envVar","proxyURI","ProxyAgent","httpProxy","httpsProxy","proxyAgents","noProxyRules","rule","shouldUseProxy","url","host","protocol","postRequest","data","options","targetUrl","URL","proxyAgent","requestId","randomUUID","response","fetch","SDK_VERSION","err","error","httpRequest_default"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n8n_io/license-sdk",
3
- "version": "3.2.1",
3
+ "version": "4.0.0-rc.1",
4
4
  "description": "License SDK",
5
5
  "main": "dist/LicenseManager.js",
6
6
  "types": "dist/LicenseManager.d.ts",
@@ -31,13 +31,13 @@
31
31
  },
32
32
  "license": "LicenseRef-n8n-enterprise",
33
33
  "engines": {
34
- "node": ">=20"
34
+ "node": ">=22.19.0"
35
35
  },
36
36
  "dependencies": {
37
37
  "crypto-js": "^4.2.0",
38
38
  "node-machine-id": "^1.1.12",
39
39
  "node-rsa": "^2.0.0",
40
- "undici": "^7.26.0"
40
+ "undici": "8.12.3"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@microsoft/api-extractor": "^7.58.1",
@@ -49,7 +49,7 @@
49
49
  "build": "tsup",
50
50
  "incrementVersion": "npm version from-git --git-tag-version false",
51
51
  "prepublish": "tsup",
52
- "publishToNpm": "pnpm publish --access public --no-git-checks",
52
+ "publishToNpm": "pnpm publish --access public --no-git-checks --tag ${NPM_TAG:-latest}",
53
53
  "test": "jest --collectCoverage -t '.*'"
54
54
  }
55
55
  }