@lambda-kata/licensing 0.1.9 → 0.1.11
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/README.md +12 -0
- package/out/dist/index.js +1 -1
- package/out/tsc/index.d.ts.map +1 -1
- package/out/tsc/performance-optimizations.d.ts.map +1 -1
- package/package.json +2 -4
- package/prebuilt/amd64/build/Release/lambda_kata_licensing.node +0 -0
- package/prebuilt/arm64/build/Release/lambda_kata_licensing.node +0 -0
- package/scripts/install.js +14 -1
package/README.md
CHANGED
|
@@ -279,6 +279,18 @@ if (result.message === 'Native validator unavailable') {
|
|
|
279
279
|
|
|
280
280
|
**For detailed troubleshooting**, see [Troubleshooting Guide](./docs/TROUBLESHOOTING.md).
|
|
281
281
|
|
|
282
|
+
# 1. Build native binaries via Docker for both architectures
|
|
283
|
+
yarn build:native:docker
|
|
284
|
+
|
|
285
|
+
# 2. Create a prebuilt structure
|
|
286
|
+
./scripts/build-prebuilt.sh package
|
|
287
|
+
|
|
288
|
+
# 3. Verify that the prebuilt directory has been created
|
|
289
|
+
ls -la prebuilt/
|
|
290
|
+
|
|
291
|
+
# 4. Publish
|
|
292
|
+
npm publish
|
|
293
|
+
|
|
282
294
|
## Security Overview
|
|
283
295
|
|
|
284
296
|
The validator implements defense-in-depth security:
|
package/out/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var g=(i,e)=>()=>(i&&(e=i(i=0)),e);var E=(i,e)=>{for(var t in e)d(i,t,{get:e[t],enumerable:!0})},R=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of v(e))!y.call(i,n)&&n!==t&&d(i,n,{get:()=>e[n],enumerable:!(r=f(e,n))||r.enumerable});return i};var z=i=>R(d({},"__esModule",{value:!0}),i);function u(){let i=s.getInstance();i.optimizeMemoryUsage(),i.optimizeStartupTime();let e=i.getMetrics();console.log(`[PERF] Optimizations applied - Loading: ${e.loadingTime}ms, Memory: ${Math.round(e.memoryUsage/1024)}KB`)}var s,h=g(()=>{"use strict";s=class i{static instance=null;metrics;startupTime;memoryBaseline;constructor(){this.startupTime=Date.now(),this.memoryBaseline=process.memoryUsage().heapUsed,this.metrics={memoryUsage:0,loadingTime:0,activeRequests:0,cacheHitRate:0}}static getInstance(){return i.instance||(i.instance=new i),i.instance}optimizeMemoryUsage(){global.gc&&global.gc(),this.configureV8MemoryOptimizations(),this.initializeStringInterning(),this.setupMemoryMonitoring()}optimizeStartupTime(){let e=Date.now();this.precompileRegexPatterns(),this.initializeObjectPools(),this.initializeOptimizedCache(),this.warmupCodePaths();let t=Date.now();this.metrics.loadingTime=t-e,this.metrics.loadingTime>100&&console.warn(`[PERF] Startup time ${this.metrics.loadingTime}ms exceeds 100ms target`)}getMetrics(){let e=process.memoryUsage().heapUsed;return this.metrics.memoryUsage=e-this.memoryBaseline,{...this.metrics}}trackRequestStart(){this.metrics.activeRequests++}trackRequestEnd(e){this.metrics.activeRequests=Math.max(0,this.metrics.activeRequests-1);let t=.1;this.metrics.cacheHitRate=t*(e?1:0)+(1-t)*this.metrics.cacheHitRate}configureV8MemoryOptimizations(){if(process.env.NODE_ENV==="production"){let e=process.env.NODE_OPTIONS??"",t=["--optimize-for-size","--max-old-space-size=64","--gc-interval=100","--expose-gc"],r=e;t.forEach(n=>{r.includes(n)||(r+=` ${n}`)}),process.env.NODE_OPTIONS=r}}initializeStringInterning(){let e=["Invalid account ID format","Native validator unavailable","System error","Network error","Security error","Memory allocation error"],t=new Map;e.forEach(r=>{t.set(r,r)})}setupMemoryMonitoring(){if(process.env.NODE_ENV==="test"||process.env.JEST_WORKER_ID)return;let e=setInterval(()=>{let r=process.memoryUsage().heapUsed-this.memoryBaseline;r>800*1024&&(console.warn(`[PERF] Memory usage ${Math.round(r/1024)}KB approaching 1MB limit`),global.gc&&global.gc()),this.metrics.memoryUsage=r},3e4);process.on("exit",()=>{clearInterval(e)})}precompileRegexPatterns(){let e=/^\d{12}$/;global.__VALIDATOR_REGEX_CACHE={accountId:e}}initializeObjectPools(){let e=[];for(let t=0;t<5;t++)e.push({entitled:!1,message:null,layerArn:null,expiresAt:null});global.__VALIDATOR_OBJECT_POOL={responses:e,nextIndex:0}}initializeOptimizedCache(){let e=[];for(let t=0;t<16;t++)e.push("");global.__VALIDATOR_CACHE_KEYS=e}warmupCodePaths(){(global.__VALIDATOR_REGEX_CACHE?.accountId||/^\d{12}$/).test("123456789012");let r=global.__VALIDATOR_OBJECT_POOL;if(r){let n=r.responses[0];n.entitled=!1}process.memoryUsage()}}});var A={};E(A,{NativeLicensingService:()=>o,createLicensingService:()=>b,default:()=>O});module.exports=z(A);function b(){return new o}var o,O,I=g(()=>{h();u();o=class{addon=null;addonLoadAttempted=!1;performanceOptimizer;constructor(){this.performanceOptimizer=s.getInstance()}async checkEntitlement(e){this.performanceOptimizer.trackRequestStart();try{if(!this.isValidAccountId(e))return this.logError("Invalid account ID format provided",{accountIdLength:typeof e=="string"?e.length:"not-string",accountIdType:typeof e}),this.performanceOptimizer.trackRequestEnd(!1),{entitled:!1,message:"Invalid account ID format"};if(this.addonLoadAttempted||this.loadAddon(),!this.addon)return this.logError("Native validator unavailable",{addonLoadAttempted:this.addonLoadAttempted}),this.performanceOptimizer.trackRequestEnd(!1),{entitled:!1,message:"Native validator unavailable"};let t=await this.addon.checkEntitlement(e);this.logInfo("Validation completed",{entitled:t.entitled,hasLayerArn:!!t.layerArn,hasMessage:!!t.message,hasExpiresAt:!!t.expiresAt});let n=this.performanceOptimizer.getMetrics().cacheHitRate>.3;return this.performanceOptimizer.trackRequestEnd(n),t}catch(t){return this.logError("Unexpected error during validation",{errorType:t instanceof Error?t.constructor.name:typeof t,errorMessage:this.sanitizeErrorMessage(t)}),this.performanceOptimizer.trackRequestEnd(!1),{entitled:!1,message:"System error"}}}checkEntitlementSync(e){this.performanceOptimizer.trackRequestStart();try{if(!this.isValidAccountId(e))return this.logError("Invalid account ID format provided (sync)",{accountIdLength:typeof e=="string"?e.length:"not-string",accountIdType:typeof e}),this.performanceOptimizer.trackRequestEnd(!1),{entitled:!1,message:"Invalid account ID format"};if(this.addonLoadAttempted||this.loadAddon(),!this.addon)return this.logError("Native validator unavailable (sync)",{addonLoadAttempted:this.addonLoadAttempted}),this.performanceOptimizer.trackRequestEnd(!1),{entitled:!1,message:"Native validator unavailable"};let t=this.addon.checkEntitlementSync(e);return this.logInfo("Sync validation completed",{entitled:t.entitled,hasLayerArn:!!t.layerArn,hasMessage:!!t.message,hasExpiresAt:!!t.expiresAt}),this.performanceOptimizer.trackRequestEnd(!0),t}catch(t){return this.logError("Unexpected error during sync validation",{errorType:t instanceof Error?t.constructor.name:typeof t,errorMessage:this.sanitizeErrorMessage(t)}),this.performanceOptimizer.trackRequestEnd(!1),{entitled:!1,message:"System error"}}}getPerformanceMetrics(){return this.performanceOptimizer.getMetrics()}isValidAccountId(e){return typeof e!="string"||e.length!==12?!1:/^\d{12}$/.test(e)}loadAddon(){this.addonLoadAttempted=!0;let e=require("os"),t=require("path"),r=require("fs"),n=e.arch()==="x64"?"amd64":e.arch(),a="lambda_kata_licensing.node",m=t.join(__dirname,"..",".."),p=[t.join(m,"prebuilt",n,"build","Release",a),t.join(m,"build","Release",a),t.join(m,"build",n,"build","Release",a),t.join(__dirname,"..","build","Release",a)];for(let c of p)try{if(r.existsSync(c)){this.addon=require(c),this.logInfo("Native addon loaded successfully",{path:c});return}}catch(l){this.logError("Failed to load native addon from path",{path:c,errorType:l instanceof Error?l.constructor.name:typeof l,errorMessage:this.sanitizeErrorMessage(l)})}this.logError("Failed to load native licensing validator - no addon found",{searchedPaths:p,arch:n,dirname:__dirname}),this.addon=null}isProductionMode(){return process.env.NODE_ENV==="production"}sanitizeErrorMessage(e){return this.isProductionMode()?e instanceof Error?`${e.constructor.name} occurred`:"Unknown error occurred":e instanceof Error?e.message:typeof e=="string"?e:String(e)}logInfo(e,t){this.isProductionMode()?console.log(`[INFO] native-licensing-validator: ${e}`):console.log(`[INFO] native-licensing-validator: ${e}`,t)}logError(e,t){this.isProductionMode()?console.error("[ERROR] native-licensing-validator: System error occurred"):console.error(`[ERROR] native-licensing-validator: ${e}`,t)}},O=o});I();0&&(module.exports={NativeLicensingService,createLicensingService});
|
package/out/tsc/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,QAAQ,EAAE,OAAO,CAAC;IAClB,uDAAuD;IACvD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEhE;;;;;;;;;;;OAWG;IACH,oBAAoB,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,iBAAiB,CAAC;CAC7D;AAaD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,sBAAuB,YAAW,gBAAgB;IAC7D,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,oBAAoB,CAAuB;IAEnD;;;;;OAKG;;IAQH;;;;;;;;;;;;;;;;;OAiBG;IACG,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAoErE;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,oBAAoB,CAAC,SAAS,EAAE,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;IA8CjB;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;;;;;;;;OASG;IACH,OAAO,CAAC,oBAAoB;IAsB5B;;;;;;OAMG;IACH,OAAO,CAAC,OAAO;IAUf;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;CASjB;AAED;;GAEG;AACH,eAAe,sBAAsB,CAAC;AAEtC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,IAAI,gBAAgB,CAEzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"performance-optimizations.d.ts","sourceRoot":"","sources":["../../src/performance-optimizations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,4BAA4B;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,2BAA2B;IAC3B,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAqC;IAC5D,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,cAAc,CAAS;IAE/B,OAAO;IAWP;;;;OAIG;WACW,WAAW,IAAI,oBAAoB;IAOjD;;;;;;;;OAQG;IACI,mBAAmB,IAAI,IAAI;IAiBlC;;;;;;;;OAQG;IACI,mBAAmB,IAAI,IAAI;IAwBlC;;;;OAIG;IACI,UAAU,IAAI,kBAAkB;IAOvC;;OAEG;IACI,iBAAiB,IAAI,IAAI;IAIhC;;;;OAIG;IACI,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAQ/C;;;;OAIG;IACH,OAAO,CAAC,8BAA8B;
|
|
1
|
+
{"version":3,"file":"performance-optimizations.d.ts","sourceRoot":"","sources":["../../src/performance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M,GAAG,OAAO,CAAC,GAAG,CAAC;IAkCvD;;;;OAIG;IACH,qBAAqB,IAAI,kBAAkB;CAG5C;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,IAAI,+BAA+B,CAEjF;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAQ/C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lambda-kata/licensing",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Tamper-resistant native licensing validator for Lambda Kata Integration",
|
|
5
5
|
"main": "out/dist/index.js",
|
|
6
6
|
"types": "out/tsc/index.d.ts",
|
|
@@ -54,8 +54,6 @@
|
|
|
54
54
|
"files": [
|
|
55
55
|
"out/",
|
|
56
56
|
"prebuilt/",
|
|
57
|
-
"build/amd64/build/Release/lambda_kata_licensing.node",
|
|
58
|
-
"build/arm64/build/Release/lambda_kata_licensing.node",
|
|
59
57
|
"scripts/install.js",
|
|
60
58
|
"scripts/postinstall.js",
|
|
61
59
|
"README.md",
|
|
@@ -97,4 +95,4 @@
|
|
|
97
95
|
9
|
|
98
96
|
]
|
|
99
97
|
}
|
|
100
|
-
}
|
|
98
|
+
}
|
|
Binary file
|
|
Binary file
|
package/scripts/install.js
CHANGED
|
@@ -77,11 +77,23 @@ function getPrebuiltPath() {
|
|
|
77
77
|
const prebuiltDir = path.join(__dirname, '..', 'prebuilt');
|
|
78
78
|
const prebuiltPath = path.join(prebuiltDir, mappedArch, 'build', 'Release', ADDON_NAME);
|
|
79
79
|
|
|
80
|
+
log('blue', `Looking for prebuilt binary at: ${prebuiltPath}`);
|
|
81
|
+
|
|
80
82
|
if (fs.existsSync(prebuiltPath)) {
|
|
83
|
+
log('green', `Found prebuilt binary at: ${prebuiltPath}`);
|
|
81
84
|
return prebuiltPath;
|
|
82
85
|
}
|
|
83
86
|
|
|
84
|
-
// Fallback: check
|
|
87
|
+
// Fallback: check architecture-specific build directory (Docker build output)
|
|
88
|
+
const archBuildPath = path.join(__dirname, '..', 'build', mappedArch, 'build', 'Release', ADDON_NAME);
|
|
89
|
+
log('blue', `Looking for arch-specific build at: ${archBuildPath}`);
|
|
90
|
+
|
|
91
|
+
if (fs.existsSync(archBuildPath)) {
|
|
92
|
+
log('green', `Found arch-specific build at: ${archBuildPath}`);
|
|
93
|
+
return archBuildPath;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Fallback: check if already in build directory (from previous install or local build)
|
|
85
97
|
const buildDir = path.join(__dirname, '..', 'build');
|
|
86
98
|
const buildPath = path.join(buildDir, 'Release', ADDON_NAME);
|
|
87
99
|
|
|
@@ -90,6 +102,7 @@ function getPrebuiltPath() {
|
|
|
90
102
|
return null; // Already in place, no need to copy
|
|
91
103
|
}
|
|
92
104
|
|
|
105
|
+
log('yellow', `No prebuilt binary found for ${platformKey}`);
|
|
93
106
|
return null;
|
|
94
107
|
}
|
|
95
108
|
|