omnigateway 0.13.5 → 0.13.6

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.
Files changed (3) hide show
  1. package/bin/omni.js +29 -5
  2. package/gateway.js +29 -5
  3. package/package.json +1 -1
package/bin/omni.js CHANGED
@@ -6582,10 +6582,6 @@ function prepareArtifact(input) {
6582
6582
  const stripped = { ...omitted, error: marker };
6583
6583
  return { artifact: stripped, json: JSON.stringify(stripped) };
6584
6584
  }
6585
- async function sealArtifact(key, json) {
6586
- const bytes = encoder2.encode(await encrypt(key, json));
6587
- return { bytes, sha256: await sha256Hex(bytes) };
6588
- }
6589
6585
  var MAX_ENVELOPE_BYTES = 2 * MAX_ARTIFACT_BYTES + 65;
6590
6586
  var BINARY_MAGIC = encoder2.encode("OGBA");
6591
6587
  var LEGACY_PREFIX = encoder2.encode("enc:v1:");
@@ -6603,6 +6599,34 @@ var gunzipAsync = promisify(gunzip);
6603
6599
  function own2(bytes, start, end) {
6604
6600
  return bytes.slice(start, end);
6605
6601
  }
6602
+ function plaintextOf(json) {
6603
+ const plain = encoder2.encode(json);
6604
+ if (plain.length < 1 || plain.length > MAX_ARTIFACT_BYTES) {
6605
+ throw new Error("artifact plaintext is outside the binary envelope's bounds");
6606
+ }
6607
+ return plain;
6608
+ }
6609
+ async function sealArtifact(key, json) {
6610
+ const plain = plaintextOf(json);
6611
+ return sealBinary(key, plain.length, CODEC_RAW, plain);
6612
+ }
6613
+ async function sealBinary(key, claimed, codec, payload) {
6614
+ const bytes = new Uint8Array(BINARY_OVERHEAD + payload.length);
6615
+ bytes.set(BINARY_MAGIC, 0);
6616
+ bytes[4] = BINARY_VERSION;
6617
+ bytes[5] = codec;
6618
+ new DataView(bytes.buffer).setUint32(6, claimed, false);
6619
+ const iv = crypto.getRandomValues(new Uint8Array(BINARY_IV_BYTES));
6620
+ const sealed = await crypto.subtle.encrypt({
6621
+ name: "AES-GCM",
6622
+ iv,
6623
+ additionalData: own2(bytes, 0, BINARY_HEADER_BYTES),
6624
+ tagLength: BINARY_TAG_BYTES * 8
6625
+ }, key, own2(payload, 0));
6626
+ bytes.set(iv, BINARY_HEADER_BYTES);
6627
+ bytes.set(new Uint8Array(sealed), BINARY_HEADER_BYTES + BINARY_IV_BYTES);
6628
+ return { bytes, sha256: await sha256Hex(bytes) };
6629
+ }
6606
6630
  async function readArtifact(key, dir, relPath, expectedSha256) {
6607
6631
  const acquired = await acquireArtifact(join(dir, relPath));
6608
6632
  if (!(acquired instanceof Uint8Array))
@@ -25263,7 +25287,7 @@ function createServiceDeps(input) {
25263
25287
  }
25264
25288
 
25265
25289
  // apps/cli/src/version.ts
25266
- var VERSION = "0.13.5";
25290
+ var VERSION = "0.13.6";
25267
25291
 
25268
25292
  // apps/cli/src/commands/service.ts
25269
25293
  function gatewayArgv(root) {
package/gateway.js CHANGED
@@ -11884,10 +11884,6 @@ function prepareArtifact(input) {
11884
11884
  const stripped = { ...omitted, error: marker };
11885
11885
  return { artifact: stripped, json: JSON.stringify(stripped) };
11886
11886
  }
11887
- async function sealArtifact(key, json) {
11888
- const bytes = encoder2.encode(await encrypt(key, json));
11889
- return { bytes, sha256: await sha256Hex(bytes) };
11890
- }
11891
11887
  var MAX_ENVELOPE_BYTES = 2 * MAX_ARTIFACT_BYTES + 65;
11892
11888
  var BINARY_MAGIC = encoder2.encode("OGBA");
11893
11889
  var LEGACY_PREFIX = encoder2.encode("enc:v1:");
@@ -11905,6 +11901,34 @@ var gunzipAsync = promisify(gunzip);
11905
11901
  function own2(bytes, start, end) {
11906
11902
  return bytes.slice(start, end);
11907
11903
  }
11904
+ function plaintextOf(json) {
11905
+ const plain = encoder2.encode(json);
11906
+ if (plain.length < 1 || plain.length > MAX_ARTIFACT_BYTES) {
11907
+ throw new Error("artifact plaintext is outside the binary envelope's bounds");
11908
+ }
11909
+ return plain;
11910
+ }
11911
+ async function sealArtifact(key, json) {
11912
+ const plain = plaintextOf(json);
11913
+ return sealBinary(key, plain.length, CODEC_RAW, plain);
11914
+ }
11915
+ async function sealBinary(key, claimed, codec, payload) {
11916
+ const bytes = new Uint8Array(BINARY_OVERHEAD + payload.length);
11917
+ bytes.set(BINARY_MAGIC, 0);
11918
+ bytes[4] = BINARY_VERSION;
11919
+ bytes[5] = codec;
11920
+ new DataView(bytes.buffer).setUint32(6, claimed, false);
11921
+ const iv = crypto.getRandomValues(new Uint8Array(BINARY_IV_BYTES));
11922
+ const sealed = await crypto.subtle.encrypt({
11923
+ name: "AES-GCM",
11924
+ iv,
11925
+ additionalData: own2(bytes, 0, BINARY_HEADER_BYTES),
11926
+ tagLength: BINARY_TAG_BYTES * 8
11927
+ }, key, own2(payload, 0));
11928
+ bytes.set(iv, BINARY_HEADER_BYTES);
11929
+ bytes.set(new Uint8Array(sealed), BINARY_HEADER_BYTES + BINARY_IV_BYTES);
11930
+ return { bytes, sha256: await sha256Hex(bytes) };
11931
+ }
11908
11932
  async function readArtifact(key, dir, relPath, expectedSha256) {
11909
11933
  const acquired = await acquireArtifact(join(dir, relPath));
11910
11934
  if (!(acquired instanceof Uint8Array))
@@ -49233,7 +49257,7 @@ function createRing(limits = DEFAULT_RING_LIMITS) {
49233
49257
  }
49234
49258
 
49235
49259
  // apps/gateway/src/version.ts
49236
- var VERSION = "0.13.5";
49260
+ var VERSION = "0.13.6";
49237
49261
 
49238
49262
  // apps/gateway/src/app.ts
49239
49263
  var ADMIN_SESSION_TTL_MS = 12 * 60 * 60 * 1000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omnigateway",
3
- "version": "0.13.5",
3
+ "version": "0.13.6",
4
4
  "description": "Self-hosted AI gateway with Anthropic- and OpenAI-compatible APIs, an admin console, and a CLI",
5
5
  "license": "MIT",
6
6
  "author": "Harismawan <mail@harismawan.com>",