ega-v9 1.0.2 → 1.0.4

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.
@@ -0,0 +1,8 @@
1
+ export type EGAActivationSuccessMessageInput = {
2
+ contactName: string;
3
+ companyName: string;
4
+ workEmail: string;
5
+ issuedAt: string;
6
+ expiresAt: string;
7
+ };
8
+ export declare function buildActivationSuccessMessage(input: EGAActivationSuccessMessageInput): string;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildActivationSuccessMessage = buildActivationSuccessMessage;
4
+ function buildActivationSuccessMessage(input) {
5
+ return [
6
+ "",
7
+ "✓ Evaluation License Activated",
8
+ "",
9
+ `Contact Name: ${input.contactName}`,
10
+ `Company Name: ${input.companyName}`,
11
+ `Work Email: ${input.workEmail}`,
12
+ "",
13
+ `Issued: ${input.issuedAt}`,
14
+ `Expires: ${input.expiresAt}`,
15
+ "",
16
+ "✓ EGA V9 is now activated.",
17
+ "",
18
+ "You can start using Runtime Governance immediately.",
19
+ "",
20
+ "Need help or want to collaborate?",
21
+ "",
22
+ "Community Support",
23
+ "",
24
+ "GitHub Issues",
25
+ "https://github.com/paibyun9/EGA-V9/issues",
26
+ "",
27
+ "Use GitHub Issues for questions, bug reports,",
28
+ "feature requests, documentation feedback,",
29
+ "and independent reproducibility reports.",
30
+ "",
31
+ "Project Resources",
32
+ "",
33
+ "Live Demo",
34
+ "https://ega-v9.vercel.app/",
35
+ "",
36
+ "Official Website",
37
+ "https://lcm3.com/",
38
+ ""
39
+ ].join("\n");
40
+ }
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EGARegisterCommandError = void 0;
4
4
  exports.runRegisterCommand = runRegisterCommand;
5
+ const activation_success_message_1 = require("./activation-success-message");
5
6
  class EGARegisterCommandError extends Error {
6
7
  constructor(code, message) {
7
8
  super(`[${code}] ${message}`);
@@ -37,16 +38,6 @@ function formatDate(value) {
37
38
  .toISOString()
38
39
  .slice(0, 10);
39
40
  }
40
- function calculateDaysRemaining(expiresAt, now = new Date()) {
41
- const expirationDate = new Date(expiresAt);
42
- if (Number.isNaN(expirationDate.getTime())) {
43
- return 0;
44
- }
45
- const dayMilliseconds = 24 * 60 * 60 * 1000;
46
- return Math.max(0, Math.ceil((expirationDate.getTime() -
47
- now.getTime()) /
48
- dayMilliseconds));
49
- }
50
41
  async function runRegisterCommand(dependencies) {
51
42
  dependencies.write("");
52
43
  dependencies.write("Welcome to EGA V9");
@@ -87,16 +78,13 @@ async function runRegisterCommand(dependencies) {
87
78
  overwrite: dependencies.overwrite ??
88
79
  false
89
80
  });
90
- dependencies.write("");
91
- dependencies.write("✓ Evaluation License Activated");
92
- dependencies.write("");
93
- dependencies.write(`Issued: ${formatDate(license.issuedAt)}`);
94
- dependencies.write(`Expires: ${formatDate(license.expiresAt)}`);
95
- dependencies.write(`Days Remaining: ${calculateDaysRemaining(license.expiresAt)}`);
96
- dependencies.write("");
97
- dependencies.write(`License stored: ${licensePath}`);
98
- dependencies.write("");
99
- dependencies.write("Happy Building.");
81
+ dependencies.write((0, activation_success_message_1.buildActivationSuccessMessage)({
82
+ contactName,
83
+ companyName,
84
+ workEmail,
85
+ issuedAt: formatDate(license.issuedAt),
86
+ expiresAt: formatDate(license.expiresAt)
87
+ }));
100
88
  return {
101
89
  license,
102
90
  licensePath
package/dist/index.d.ts CHANGED
@@ -155,7 +155,7 @@ type NextFunction = EGAGuardNext;
155
155
  type EGARequest = EGAGuardRequest;
156
156
  type EGAResponse = EGAGuardResponse;
157
157
  export declare class EGA {
158
- private readonly options;
158
+ #private;
159
159
  private readonly eventLog;
160
160
  private eventSequence;
161
161
  private constructor();
package/dist/index.js CHANGED
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _EGA_options;
2
14
  Object.defineProperty(exports, "__esModule", { value: true });
3
15
  exports.evaluateRuntimeAdmission = exports.assertRuntimeLicenseAdmission = exports.EGARuntimeAdmissionError = exports.ega = exports.EGA = void 0;
4
16
  exports.verifyExecution = verifyExecution;
@@ -166,16 +178,17 @@ function validateGuardInvocation(req, res, next) {
166
178
  }
167
179
  class EGA {
168
180
  constructor(options = {}) {
181
+ _EGA_options.set(this, void 0);
169
182
  this.eventLog = [];
170
183
  this.eventSequence = 0;
171
- this.options = {
184
+ __classPrivateFieldSet(this, _EGA_options, Object.freeze({
172
185
  appName: options.appName ?? "ega-v9-app",
173
186
  trustLevel: options.trustLevel ?? "supported",
174
187
  telemetry: options.telemetry ?? false,
175
188
  failClosed: options.failClosed ?? true,
176
189
  policyId: options.policyId ?? "default-policy",
177
190
  approvalThreshold: options.approvalThreshold ?? 70
178
- };
191
+ }), "f");
179
192
  }
180
193
  static init(options = {}) {
181
194
  validateEGAOptions(options);
@@ -183,9 +196,10 @@ class EGA {
183
196
  }
184
197
  guard() {
185
198
  return (req, res, next) => {
199
+ (0, runtime_admission_provider_1.enforceRuntimeLicenseAdmission)();
186
200
  validateGuardInvocation(req, res, next);
187
201
  const requestId = (0, crypto_1.randomUUID)();
188
- const clientIdentity = buildAnonymousClientIdentity(req, this.options.appName);
202
+ const clientIdentity = buildAnonymousClientIdentity(req, __classPrivateFieldGet(this, _EGA_options, "f").appName);
189
203
  const licenseState = evaluateLicenseState(req);
190
204
  const actualReplayRoot = this.createReplayRoot(req);
191
205
  const expectedReplayRoot = this.getExpectedReplayRoot(req);
@@ -194,7 +208,7 @@ class EGA {
194
208
  timestamp: new Date().toISOString(),
195
209
  requestId,
196
210
  replayRoot: actualReplayRoot,
197
- trustLevel: this.options.trustLevel,
211
+ trustLevel: __classPrivateFieldGet(this, _EGA_options, "f").trustLevel,
198
212
  status: "verified",
199
213
  clientIdentity,
200
214
  licenseState
@@ -207,9 +221,9 @@ class EGA {
207
221
  const businessMetrics = collectBusinessMetrics(req.body);
208
222
  const trust = evaluateTrust({
209
223
  isMismatch,
210
- failClosed: this.options.failClosed,
224
+ failClosed: __classPrivateFieldGet(this, _EGA_options, "f").failClosed,
211
225
  businessMetrics,
212
- approvalThreshold: this.options.approvalThreshold
226
+ approvalThreshold: __classPrivateFieldGet(this, _EGA_options, "f").approvalThreshold
213
227
  });
214
228
  const businessGovernanceProfile = buildBusinessGovernanceProfile(businessMetrics, trust);
215
229
  const provenance = this.buildProvenanceGraph({
@@ -223,7 +237,7 @@ class EGA {
223
237
  const context = {
224
238
  requestId,
225
239
  replayRoot: actualReplayRoot,
226
- trustLevel: this.options.trustLevel,
240
+ trustLevel: __classPrivateFieldGet(this, _EGA_options, "f").trustLevel,
227
241
  status: isMismatch ? "contained" : "verified",
228
242
  scorpLock: true,
229
243
  clientIdentity,
@@ -236,10 +250,10 @@ class EGA {
236
250
  },
237
251
  containment: {
238
252
  activated: isMismatch,
239
- mode: this.options.failClosed ? "fail-closed" : "observe",
253
+ mode: __classPrivateFieldGet(this, _EGA_options, "f").failClosed ? "fail-closed" : "observe",
240
254
  reason: isMismatch ? "replay root mismatch" : undefined,
241
255
  quarantineId,
242
- executionAllowed: !isMismatch || !this.options.failClosed
256
+ executionAllowed: !isMismatch || !__classPrivateFieldGet(this, _EGA_options, "f").failClosed
243
257
  },
244
258
  trust,
245
259
  businessGovernanceProfile,
@@ -408,7 +422,7 @@ class EGA {
408
422
  executionAllowed: context.containment.executionAllowed
409
423
  }
410
424
  });
411
- if (this.options.failClosed) {
425
+ if (__classPrivateFieldGet(this, _EGA_options, "f").failClosed) {
412
426
  this.recordEvent({
413
427
  type: "execution.blocked",
414
428
  timestamp: new Date().toISOString(),
@@ -498,7 +512,7 @@ class EGA {
498
512
  }
499
513
  createReplayRoot(req) {
500
514
  return this.replayRoot({
501
- appName: this.options.appName,
515
+ appName: __classPrivateFieldGet(this, _EGA_options, "f").appName,
502
516
  method: req.method ?? "UNKNOWN",
503
517
  path: req.originalUrl ?? req.url ?? req.path ?? "/",
504
518
  body: req.body ?? null,
@@ -538,9 +552,9 @@ class EGA {
538
552
  type: "policy",
539
553
  label: "Policy",
540
554
  data: {
541
- policyId: this.options.policyId,
555
+ policyId: __classPrivateFieldGet(this, _EGA_options, "f").policyId,
542
556
  scorpLock: true,
543
- failClosed: this.options.failClosed
557
+ failClosed: __classPrivateFieldGet(this, _EGA_options, "f").failClosed
544
558
  }
545
559
  },
546
560
  {
@@ -549,7 +563,7 @@ class EGA {
549
563
  label: "Decision",
550
564
  data: {
551
565
  status: args.isMismatch ? "contained" : "verified",
552
- executionAllowed: !args.isMismatch || !this.options.failClosed
566
+ executionAllowed: !args.isMismatch || !__classPrivateFieldGet(this, _EGA_options, "f").failClosed
553
567
  }
554
568
  },
555
569
  {
@@ -601,6 +615,7 @@ class EGA {
601
615
  }
602
616
  }
603
617
  exports.EGA = EGA;
618
+ _EGA_options = new WeakMap();
604
619
  function buildAnonymousClientIdentity(req, appName) {
605
620
  const headers = req.headers ?? {};
606
621
  const hostValue = headers.host ?? headers.Host;
@@ -0,0 +1 @@
1
+ export declare function buildActivationRequiredMessage(): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildActivationRequiredMessage = buildActivationRequiredMessage;
4
+ function buildActivationRequiredMessage() {
5
+ return [
6
+ "EGA V9 is installed but not activated.",
7
+ "",
8
+ "Activate your FREE 90-Day Evaluation License.",
9
+ "No credit card required.",
10
+ "",
11
+ "Run:",
12
+ "",
13
+ " npx ega-v9 register"
14
+ ].join("\n");
15
+ }
@@ -1,5 +1,14 @@
1
1
  import { KeyObject } from "crypto";
2
+ export declare const EGA_V9_LICENSE_PUBLIC_KEY_FINGERPRINT_SHA256 = "2caf94d33728abd5b61919a230cc2ef142762f98da036c3e2a02dfcdc536377d";
2
3
  export declare class EGALicensePublicKeyError extends Error {
3
4
  constructor(message: string);
4
5
  }
6
+ /**
7
+ * Resolution order:
8
+ *
9
+ * 1. EGA_V9_LICENSE_PUBLIC_KEY_PEM or explicit argument
10
+ * for controlled development and testing.
11
+ * 2. Official EGA V9 Production Public Key bundled
12
+ * with the SDK for normal customer activation.
13
+ */
5
14
  export declare function loadEvaluationLicensePublicKey(publicKeyPem?: string | undefined): KeyObject;
@@ -1,8 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EGALicensePublicKeyError = void 0;
3
+ exports.EGALicensePublicKeyError = exports.EGA_V9_LICENSE_PUBLIC_KEY_FINGERPRINT_SHA256 = void 0;
4
4
  exports.loadEvaluationLicensePublicKey = loadEvaluationLicensePublicKey;
5
5
  const crypto_1 = require("crypto");
6
+ /**
7
+ * EGA V9 Production Root of Trust V1.
8
+ *
9
+ * Public verification material only.
10
+ * The corresponding Private Key must remain exclusively
11
+ * in the LCM License API secret environment.
12
+ */
13
+ const OFFICIAL_EGA_V9_LICENSE_PUBLIC_KEY_PEM = "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAXyuVTginxHK4uxGvwXxc3yMUvmNA4c+NJyIOLvEZx+4=\n-----END PUBLIC KEY-----";
14
+ exports.EGA_V9_LICENSE_PUBLIC_KEY_FINGERPRINT_SHA256 = "2caf94d33728abd5b61919a230cc2ef142762f98da036c3e2a02dfcdc536377d";
6
15
  class EGALicensePublicKeyError extends Error {
7
16
  constructor(message) {
8
17
  super(`[EGA_LICENSE_PUBLIC_KEY] ${message}`);
@@ -12,16 +21,28 @@ class EGALicensePublicKeyError extends Error {
12
21
  }
13
22
  }
14
23
  exports.EGALicensePublicKeyError = EGALicensePublicKeyError;
24
+ /**
25
+ * Resolution order:
26
+ *
27
+ * 1. EGA_V9_LICENSE_PUBLIC_KEY_PEM or explicit argument
28
+ * for controlled development and testing.
29
+ * 2. Official EGA V9 Production Public Key bundled
30
+ * with the SDK for normal customer activation.
31
+ */
15
32
  function loadEvaluationLicensePublicKey(publicKeyPem = process.env
16
33
  .EGA_V9_LICENSE_PUBLIC_KEY_PEM) {
17
- if (typeof publicKeyPem !==
18
- "string" ||
19
- publicKeyPem.trim().length ===
20
- 0) {
21
- throw new EGALicensePublicKeyError("The official EGA V9 Evaluation License public key is not configured.");
22
- }
34
+ const selectedPublicKeyPem = typeof publicKeyPem === "string" &&
35
+ publicKeyPem.trim().length > 0
36
+ ? publicKeyPem.trim()
37
+ : OFFICIAL_EGA_V9_LICENSE_PUBLIC_KEY_PEM;
23
38
  try {
24
- return (0, crypto_1.createPublicKey)(publicKeyPem);
39
+ const publicKey = (0, crypto_1.createPublicKey)(selectedPublicKeyPem);
40
+ if (publicKey.type !== "public" ||
41
+ publicKey.asymmetricKeyType !==
42
+ "ed25519") {
43
+ throw new Error("Unsupported Public Key type.");
44
+ }
45
+ return publicKey;
25
46
  }
26
47
  catch {
27
48
  throw new EGALicensePublicKeyError("The configured EGA V9 Evaluation License public key is invalid.");
package/package.json CHANGED
@@ -1,18 +1,20 @@
1
1
  {
2
2
  "name": "ega-v9",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "EGA V9 TypeScript SDK for replay, provenance, containment, and SCORP LOCK governance.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "files": [
8
8
  "dist",
9
9
  "README.md",
10
- "LICENSE"
10
+ "LICENSE",
11
+ "scripts/postinstall-message.cjs"
11
12
  ],
12
13
  "scripts": {
13
14
  "build": "tsc && node scripts/generate-esm-wrapper.cjs && node scripts/prepare-cli.cjs",
14
15
  "test": "npm run build && node ../../scripts/testing/run-v1-test-suite.cjs",
15
- "dev": "tsc --watch"
16
+ "dev": "tsc --watch",
17
+ "postinstall": "node scripts/postinstall-message.cjs"
16
18
  },
17
19
  "keywords": [
18
20
  "ai-agents",
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ const message = [
4
+ "",
5
+ "────────────────────────────────────────────────────────",
6
+ "",
7
+ "✓ EGA V9 installed successfully.",
8
+ "",
9
+ "EGA V9 is installed but not activated.",
10
+ "",
11
+ "Activate your FREE 90-Day Evaluation License.",
12
+ "No credit card required.",
13
+ "",
14
+ "Run:",
15
+ "",
16
+ " npx ega-v9 register",
17
+ "",
18
+ "────────────────────────────────────────────────────────",
19
+ ""
20
+ ].join("\n");
21
+
22
+ process.stdout.write(message);