@riffdb/client 0.2.3 → 0.2.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.
package/README.md CHANGED
@@ -7,8 +7,8 @@ compiler IDs, storage keys, or an authorization bypass.
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- npm install --save-dev @riffdb/cli@0.2.3
11
- npm install @riffdb/client@0.2.3
10
+ npm install --save-dev @riffdb/cli@0.2.4
11
+ npm install @riffdb/client@0.2.4
12
12
  ```
13
13
 
14
14
  ## Four-step application story
package/dist/driver.d.ts CHANGED
@@ -159,6 +159,7 @@ export interface DriverErrorDetails {
159
159
  readonly category: string;
160
160
  readonly operation?: string;
161
161
  readonly symbolPath: ReadonlyArray<string>;
162
+ readonly authorizationDiagnostic?: string;
162
163
  readonly contractLineage?: string;
163
164
  readonly contractVersion?: bigint;
164
165
  readonly traceId?: string;
package/dist/driver.js CHANGED
@@ -50,7 +50,14 @@ export class DriverApplicationError extends Error {
50
50
  details;
51
51
  name = "DriverApplicationError";
52
52
  constructor(details) {
53
- super(`${details.code}: ${details.message}`);
53
+ let text = `${details.code}: ${details.message}`;
54
+ if (details.symbolPath.length > 0) {
55
+ text += ` (${details.symbolPath.join(".")})`;
56
+ }
57
+ if (details.authorizationDiagnostic !== undefined) {
58
+ text += ` [diagnostic: ${details.authorizationDiagnostic}]`;
59
+ }
60
+ super(text);
54
61
  this.details = details;
55
62
  }
56
63
  }
@@ -940,6 +947,17 @@ function decodeBatchResult(response, expectedTotal, requestedCheckpoint) {
940
947
  });
941
948
  return { items, checkpoint, total };
942
949
  }
950
+ const AUTHORIZATION_DIAGNOSTIC_CODES = new Set([
951
+ "missing_permission",
952
+ "scan_budget_exceeded",
953
+ "tenant_scope_mismatch",
954
+ "partition_scope_mismatch",
955
+ "field_visibility_denied",
956
+ "row_policy_denied",
957
+ "approval_required",
958
+ "delegation_exceeds_authority",
959
+ "inactive_or_stale_capability",
960
+ ]);
943
961
  function decodeError(response) {
944
962
  const code = boundedPattern(response.code, /^[A-Z0-9-]{1,64}$/);
945
963
  const category = boundedPattern(response.category, /^[a-z_]{1,64}$/);
@@ -950,6 +968,11 @@ function decodeError(response) {
950
968
  throw new Error("RiffDB driver returned invalid error context");
951
969
  }
952
970
  const symbolPath = response.symbol_path.map((value) => boundedPattern(value, SYMBOL));
971
+ const authorizationDiagnostic = optionalPattern(response.authorization_diagnostic, SYMBOL);
972
+ if (authorizationDiagnostic !== undefined &&
973
+ (code !== "RDB-AUTH-0214" || !AUTHORIZATION_DIAGNOSTIC_CODES.has(authorizationDiagnostic))) {
974
+ throw new Error("RiffDB driver returned invalid error context");
975
+ }
953
976
  const operation = optionalPattern(response.operation, SYMBOL);
954
977
  const contractLineage = optionalPattern(response.contract_lineage, SYMBOL);
955
978
  const contractVersion = optionalPositiveBigInt(response.contract_version);
@@ -963,6 +986,7 @@ function decodeError(response) {
963
986
  return new DriverApplicationError({
964
987
  code, category, symbolPath, message, retryability, recoveryAction,
965
988
  outcomeUncertain: response.outcome_uncertain,
989
+ ...(authorizationDiagnostic === undefined ? {} : { authorizationDiagnostic }),
966
990
  ...(operation === undefined ? {} : { operation }),
967
991
  ...(contractLineage === undefined ? {} : { contractLineage }),
968
992
  ...(contractVersion === undefined ? {} : { contractVersion }),
package/dist/index.js CHANGED
@@ -2040,6 +2040,8 @@ function normalizeError(input) {
2040
2040
  output.contractVersion = Number(expectDecimal(input.contract_version));
2041
2041
  if (input.operation_symbol !== undefined)
2042
2042
  output.operationSymbol = input.operation_symbol;
2043
+ if (input.authorization_diagnostic !== undefined)
2044
+ output.authorizationDiagnostic = input.authorization_diagnostic;
2043
2045
  if (input.source_span !== undefined) {
2044
2046
  const span = exactObject(input.source_span);
2045
2047
  output.sourceSpan = { start: Number(expectDecimal(span.start)), end: Number(expectDecimal(span.end)) };
package/package.json CHANGED
@@ -1 +1 @@
1
- {"description":"First-party application runtime for the Rust-owned RiffDB driver host","engines":{"node":">=22"},"exports":{".":"./dist/index.js","./operator":"./dist/operator.js"},"files":["dist","README.md","conformance-manifest-v1.json"],"license":"MIT OR Apache-2.0","name":"@riffdb/client","repository":{"type":"git","url":"git+https://github.com/riffdb/riffdb.git"},"type":"module","types":"./dist/index.d.ts","version":"0.2.3"}
1
+ {"description":"First-party application runtime for the Rust-owned RiffDB driver host","engines":{"node":">=22"},"exports":{".":"./dist/index.js","./operator":"./dist/operator.js"},"files":["dist","README.md","conformance-manifest-v1.json"],"license":"MIT OR Apache-2.0","name":"@riffdb/client","repository":{"type":"git","url":"git+https://github.com/riffdb/riffdb.git"},"type":"module","types":"./dist/index.d.ts","version":"0.2.4"}