@query-farm/vgi 0.48.3 → 0.48.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.
@@ -38,6 +38,14 @@ export declare function shardKeyForAttach(sealed: Uint8Array | undefined, auth:
38
38
  * to the caller's identity and the parent attach envelope it was minted under.
39
39
  */
40
40
  export declare function sealTransaction(plaintext: Uint8Array, attachEnvelope: Uint8Array, auth: AuthContext | undefined, signingKey: Uint8Array | undefined): Promise<Uint8Array>;
41
+ /**
42
+ * Open a transaction_opaque_data envelope (sealed on HTTP only, no UUID prefix).
43
+ * `attachEnvelope` is the request's *sealed* attach, which the transaction
44
+ * envelope's AAD binds. A pass-through without a signing key or for an empty
45
+ * value. Catalog hooks and function bodies must see the same plaintext, or a
46
+ * worker cannot tie a function call to its transaction's commit/rollback.
47
+ */
48
+ export declare function openTransaction(envelope: Uint8Array, attachEnvelope: Uint8Array, auth: AuthContext | undefined, signingKey: Uint8Array | undefined): Promise<Uint8Array>;
41
49
  /**
42
50
  * Wrap a catalog unary handler so its request opaque-data fields are unwrapped
43
51
  * before the body runs. Used for every catalog_* method except catalog_attach
@@ -8295,6 +8295,11 @@ async function sealTransaction(plaintext, attachEnvelope, auth, signingKey) {
8295
8295
  return plaintext;
8296
8296
  return sealBytes(plaintext, signingKey, transactionAad(auth, attachEnvelope), TRANSACTION_ENVELOPE_VERSION);
8297
8297
  }
8298
+ async function openTransaction(envelope, attachEnvelope, auth, signingKey) {
8299
+ if (!signingKey || envelope.length === 0)
8300
+ return envelope;
8301
+ return openBytes(envelope, signingKey, transactionAad(auth, attachEnvelope), TRANSACTION_ENVELOPE_VERSION, "transaction_opaque_data");
8302
+ }
8298
8303
  async function unwrapParamsOpaque(params, ctx, signingKey) {
8299
8304
  const auth = ctx?.auth;
8300
8305
  let sealedAttach = new Uint8Array(0);
@@ -8575,7 +8580,12 @@ async function liveSplitAnchor(catalogInterface, bindCall, auth, signingKey) {
8575
8580
  if (!catalogInterface?.version || bindCall.attach_opaque_data == null)
8576
8581
  return;
8577
8582
  const raw = toUint8Array(bindCall.attach_opaque_data);
8578
- const txn = bindCall.transaction_opaque_data ? toUint8Array(bindCall.transaction_opaque_data) : undefined;
8583
+ let txn = bindCall.transaction_opaque_data ? toUint8Array(bindCall.transaction_opaque_data) : undefined;
8584
+ if (txn && txn.length > 0 && signingKey) {
8585
+ try {
8586
+ txn = await openTransaction(txn, raw, auth, signingKey);
8587
+ } catch {}
8588
+ }
8579
8589
  const forms = [
8580
8590
  async () => raw,
8581
8591
  async () => openAttach(raw, auth, signingKey)
@@ -8613,14 +8623,22 @@ function functionHandlers(config) {
8613
8623
  return env;
8614
8624
  return openAttach(env, ctx?.auth ?? currentRequestAuth(), signingKey);
8615
8625
  }
8626
+ async function openOpaque(bindCall, ctx) {
8627
+ const sealedAttach = bindCall.attach_opaque_data != null ? toUint8Array(bindCall.attach_opaque_data) : new Uint8Array(0);
8628
+ if (bindCall.transaction_opaque_data != null) {
8629
+ bindCall.transaction_opaque_data = await openTransaction(toUint8Array(bindCall.transaction_opaque_data), sealedAttach, ctx?.auth ?? currentRequestAuth(), signingKey);
8630
+ }
8631
+ bindCall.attach_opaque_data = await stripAttach(bindCall.attach_opaque_data, ctx);
8632
+ }
8616
8633
  async function strippedContext(bindCall, ctx) {
8617
- let attach = null;
8634
+ const copy = { ...bindCall };
8618
8635
  try {
8619
- attach = await stripAttach(bindCall.attach_opaque_data, ctx);
8636
+ await openOpaque(copy, ctx);
8620
8637
  } catch {
8621
- attach = null;
8638
+ copy.attach_opaque_data = null;
8639
+ copy.transaction_opaque_data = null;
8622
8640
  }
8623
- return overloadContext({ ...bindCall, attach_opaque_data: attach }, catalogInterface);
8641
+ return overloadContext(copy, catalogInterface);
8624
8642
  }
8625
8643
  const emptySchema = schema2([]);
8626
8644
  const dummyInputSchema = schema2([
@@ -8629,7 +8647,7 @@ function functionHandlers(config) {
8629
8647
  const bind = async (params, ctx) => {
8630
8648
  const innerParams = unwrapRequest(params.request);
8631
8649
  const request = deserializeBindRequest(innerParams);
8632
- request.attach_opaque_data = await stripAttach(request.attach_opaque_data, ctx);
8650
+ await openOpaque(request, ctx);
8633
8651
  const func = registry.get(request.function_name, overloadContext(request, catalogInterface));
8634
8652
  const response = await func.bind(request);
8635
8653
  validateProjectionOffer(response);
@@ -8644,7 +8662,7 @@ function functionHandlers(config) {
8644
8662
  const innerParams = unwrapRequest(params.request);
8645
8663
  const request = deserializeInitRequest(innerParams);
8646
8664
  const auth = ctx?.auth ?? currentRequestAuth();
8647
- request.bind_call.attach_opaque_data = await stripAttach(request.bind_call.attach_opaque_data, ctx);
8665
+ await openOpaque(request.bind_call, ctx);
8648
8666
  await resolveSplitPayloads(request, innerParams, {
8649
8667
  auth,
8650
8668
  signingKey,
@@ -8689,7 +8707,7 @@ function functionHandlers(config) {
8689
8707
  } else {
8690
8708
  const carried = parseCarriedInitRequest(state.initRequestPacked);
8691
8709
  const request = carried.request;
8692
- request.bind_call.attach_opaque_data = await stripAttach(request.bind_call.attach_opaque_data, undefined);
8710
+ await openOpaque(request.bind_call, undefined);
8693
8711
  await resolveSplitPayloads(request, { bind_call: carried.bindCallIpc }, {
8694
8712
  auth: currentRequestAuth(),
8695
8713
  signingKey,
@@ -11250,6 +11268,19 @@ function catalogTableHandlers(getCatalog, signingKey) {
11250
11268
  const scanResult = await cat.tableScanFunctionGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.at_unit, params.at_value, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
11251
11269
  return wrapResult(scanResult, ScanFunctionResultSchema);
11252
11270
  });
11271
+ const optionalTx = (params) => params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined;
11272
+ const catalogTableInsertFunctionGet = catalogHandler(signingKey, async (params) => {
11273
+ const result = await getCatalog().tableInsertFunctionGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, optionalTx(params), params.writable_branch_function_name ?? null);
11274
+ return wrapResult(result, ScanFunctionResultSchema);
11275
+ });
11276
+ const catalogTableUpdateFunctionGet = catalogHandler(signingKey, async (params) => {
11277
+ const result = await getCatalog().tableUpdateFunctionGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, optionalTx(params));
11278
+ return wrapResult(result, ScanFunctionResultSchema);
11279
+ });
11280
+ const catalogTableDeleteFunctionGet = catalogHandler(signingKey, async (params) => {
11281
+ const result = await getCatalog().tableDeleteFunctionGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, optionalTx(params));
11282
+ return wrapResult(result, ScanFunctionResultSchema);
11283
+ });
11253
11284
  const catalogTableScanBranchesGet = catalogHandler(signingKey, async (params) => {
11254
11285
  const cat = getCatalog();
11255
11286
  const branchesResult = await cat.tableScanBranchesGet(toUint8Array(params.attach_opaque_data), params.schema_path, params.name, params.at_unit, params.at_value, params.transaction_opaque_data ? toUint8Array(params.transaction_opaque_data) : undefined);
@@ -11328,6 +11359,9 @@ function catalogTableHandlers(getCatalog, signingKey) {
11328
11359
  catalogTableDrop,
11329
11360
  catalogTableColumnStatisticsGet,
11330
11361
  catalogTableScanFunctionGet,
11362
+ catalogTableInsertFunctionGet,
11363
+ catalogTableUpdateFunctionGet,
11364
+ catalogTableDeleteFunctionGet,
11331
11365
  catalogTableScanBranchesGet,
11332
11366
  catalogTableCommentSet,
11333
11367
  catalogTableRename,
@@ -11909,4 +11943,4 @@ export {
11909
11943
  serveVgiWorker
11910
11944
  };
11911
11945
 
11912
- //# debugId=0D0A3CC5D765A2FD64756E2164756E21
11946
+ //# debugId=448535FCB65D277D64756E2164756E21