@powerhousedao/powerhouse-vetra-packages 6.2.2-dev.43 → 6.2.2-dev.45

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 (59) hide show
  1. package/dist/browser/assets/{entry-CcSqsfaf.js → entry-C2ClkbVN.js} +2 -2
  2. package/dist/browser/assets/{projection-entry-qnPqxpN3.js → projection-entry-S39DdeT-.js} +2 -2
  3. package/dist/browser/{connect-Cs9_OfUW.js → connect-70_1bgIZ.js} +4 -4
  4. package/dist/browser/{connect-Cs9_OfUW.js.map → connect-70_1bgIZ.js.map} +1 -1
  5. package/dist/browser/{dist-Cw08sCbR.js → dist-CXIjN0Ex.js} +4 -4
  6. package/dist/browser/{dist-Cw08sCbR.js.map → dist-CXIjN0Ex.js.map} +1 -1
  7. package/dist/browser/{document-drive-CLF3V3yq.js → document-drive-PYPIaEvw.js} +177 -9
  8. package/dist/browser/document-drive-PYPIaEvw.js.map +1 -0
  9. package/dist/browser/document-models/index.js +1 -1
  10. package/dist/browser/{editor-Clf15hps.js → editor-DOJeQKlN.js} +5 -5
  11. package/dist/browser/{editor-Clf15hps.js.map → editor-DOJeQKlN.js.map} +1 -1
  12. package/dist/browser/{editor-CRj28xcj.js → editor-QW6D3wl8.js} +6 -6
  13. package/dist/browser/{editor-CRj28xcj.js.map → editor-QW6D3wl8.js.map} +1 -1
  14. package/dist/browser/editors/document-model-editor/module.js +1 -1
  15. package/dist/browser/editors/generic-drive-explorer/index.js +4 -4
  16. package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
  17. package/dist/browser/{folder-view-Zc--316o.js → folder-view-VM5cJbvv.js} +3 -3
  18. package/dist/browser/{folder-view-Zc--316o.js.map → folder-view-VM5cJbvv.js.map} +1 -1
  19. package/dist/browser/{graphql-editor-BYiN6EYX.js → graphql-editor-CjpiNMV0.js} +3 -3
  20. package/dist/browser/{graphql-editor-BYiN6EYX.js.map → graphql-editor-CjpiNMV0.js.map} +1 -1
  21. package/dist/browser/index.js +378 -9
  22. package/dist/browser/index.js.map +1 -1
  23. package/dist/browser/{json-editor-BCQBDkoV.js → json-editor-CeIHor4v.js} +3 -3
  24. package/dist/browser/{json-editor-BCQBDkoV.js.map → json-editor-CeIHor4v.js.map} +1 -1
  25. package/dist/browser/{lib-CZf9FJ-n.js → lib-PZlA5c3e.js} +2 -2
  26. package/dist/browser/lib-PZlA5c3e.js.map +1 -0
  27. package/dist/browser/{state-schemas-Co7oWTVF.js → state-schemas-CbPirA44.js} +3 -3
  28. package/dist/browser/{state-schemas-Co7oWTVF.js.map → state-schemas-CbPirA44.js.map} +1 -1
  29. package/dist/node/{connect-DtLHLVuq.mjs → connect-CkBYxX_q.mjs} +4 -4
  30. package/dist/node/{connect-DtLHLVuq.mjs.map → connect-CkBYxX_q.mjs.map} +1 -1
  31. package/dist/node/{dist-Co6sAUR3.mjs → dist-CS8QwZwZ.mjs} +4 -4
  32. package/dist/node/{dist-Co6sAUR3.mjs.map → dist-CS8QwZwZ.mjs.map} +1 -1
  33. package/dist/node/{document-drive-CPxMz8lW.mjs → document-drive-DrBAR9as.mjs} +177 -9
  34. package/dist/node/document-drive-DrBAR9as.mjs.map +1 -0
  35. package/dist/node/document-models/index.mjs +1 -1
  36. package/dist/node/{editor-Dl-takGb.mjs → editor-ClZqmnoh.mjs} +6 -6
  37. package/dist/node/{editor-Dl-takGb.mjs.map → editor-ClZqmnoh.mjs.map} +1 -1
  38. package/dist/node/{editor-CNTEyfKg.mjs → editor-Dv22q5WR.mjs} +5 -5
  39. package/dist/node/{editor-CNTEyfKg.mjs.map → editor-Dv22q5WR.mjs.map} +1 -1
  40. package/dist/node/editors/document-model-editor/module.mjs +1 -1
  41. package/dist/node/editors/generic-drive-explorer/index.mjs +4 -4
  42. package/dist/node/editors/generic-drive-explorer/module.mjs +1 -1
  43. package/dist/node/{folder-view-B2qOsImy.mjs → folder-view-6H-dMp8X.mjs} +3 -3
  44. package/dist/node/{folder-view-B2qOsImy.mjs.map → folder-view-6H-dMp8X.mjs.map} +1 -1
  45. package/dist/node/{graphql-editor-DsX64AUl.mjs → graphql-editor-DP0o3W7f.mjs} +3 -3
  46. package/dist/node/{graphql-editor-DsX64AUl.mjs.map → graphql-editor-DP0o3W7f.mjs.map} +1 -1
  47. package/dist/node/index.mjs +378 -9
  48. package/dist/node/index.mjs.map +1 -1
  49. package/dist/node/{json-editor-H15UPuqD.mjs → json-editor-CNbnXYz6.mjs} +3 -3
  50. package/dist/node/{json-editor-H15UPuqD.mjs.map → json-editor-CNbnXYz6.mjs.map} +1 -1
  51. package/dist/node/{main-7-PK1gTO.mjs → main-aITg389Z.mjs} +2 -2
  52. package/dist/node/main-aITg389Z.mjs.map +1 -0
  53. package/dist/node/{state-schemas-BEbd8zYo.mjs → state-schemas-CylQoH3Q.mjs} +3 -3
  54. package/dist/node/{state-schemas-BEbd8zYo.mjs.map → state-schemas-CylQoH3Q.mjs.map} +1 -1
  55. package/package.json +7 -6
  56. package/dist/browser/document-drive-CLF3V3yq.js.map +0 -1
  57. package/dist/browser/lib-CZf9FJ-n.js.map +0 -1
  58. package/dist/node/document-drive-CPxMz8lW.mjs.map +0 -1
  59. package/dist/node/main-7-PK1gTO.mjs.map +0 -1
@@ -4143,7 +4143,7 @@ function assertValidGrant(grant, documentType) {
4143
4143
  const grantId = isPlainValue(grant) && typeof grant.id === "string" ? grant.id : "";
4144
4144
  const problem = grantProblem(grant);
4145
4145
  if (problem !== null) throw new InvalidGrantError(grantId, problem);
4146
- if (documentType === "@powerhousedao/document-group" && "group" in grant.principal) throw new GroupPrincipalNotAllowedError(grantId);
4146
+ if (documentType === "powerhouse/reactor-group" && "group" in grant.principal) throw new GroupPrincipalNotAllowedError(grantId);
4147
4147
  }
4148
4148
  /**
4149
4149
  * Validates an initial grant list: the count cap, every grant, and — on a
@@ -4217,6 +4217,158 @@ function assertAuthAdministrationRetained(creator, previous, next, grantId) {
4217
4217
  if (creator !== void 0) return;
4218
4218
  if (administrationReachable(previous) && !administrationReachable(next)) throw new AuthAdministrationLockoutError(grantId);
4219
4219
  }
4220
+ /**
4221
+ * An operand whose shape validation would have rejected. Distinguished from
4222
+ * an unresolved path so a structurally malformed operand poisons its whole
4223
+ * condition to false rather than reading as "absent", which `not` would
4224
+ * otherwise widen to true.
4225
+ */
4226
+ const INVALID_OPERAND = Symbol("invalid-operand");
4227
+ /**
4228
+ * Narrows to the values conditions compare. An object, array, or non-finite
4229
+ * number resolves to undefined, and every comparison involving undefined is
4230
+ * false.
4231
+ */
4232
+ function asConditionValue(value) {
4233
+ if (value === null || typeof value === "string" || typeof value === "boolean") return value;
4234
+ if (typeof value === "number" && Number.isFinite(value)) return value;
4235
+ }
4236
+ /**
4237
+ * Resolves one operand. Attr roots: `subject.*`, `doc.<scope>.*` where the
4238
+ * scope must be the executing scope (validation already rejects any other,
4239
+ * but resolution stays total), and `action.input.*`. Path steps read own
4240
+ * properties only, so prototype members can never influence a verdict.
4241
+ */
4242
+ function resolveOperand(operand, subject, request, conditions) {
4243
+ if (!isPlainValue(operand)) return INVALID_OPERAND;
4244
+ const keys = Object.keys(operand);
4245
+ if (keys.length !== 1) return INVALID_OPERAND;
4246
+ if (keys[0] === "lit") {
4247
+ const value = asConditionValue(operand.lit);
4248
+ return value === void 0 ? INVALID_OPERAND : value;
4249
+ }
4250
+ if (keys[0] !== "attr") return INVALID_OPERAND;
4251
+ const attr = operand.attr;
4252
+ if (typeof attr !== "string" || attr.length === 0) return INVALID_OPERAND;
4253
+ const path = attr.split(".");
4254
+ let value;
4255
+ let rest;
4256
+ if (path[0] === "subject") {
4257
+ value = subject;
4258
+ rest = path.slice(1);
4259
+ } else if (path[0] === "doc") {
4260
+ if (path[1] !== request.scope) return;
4261
+ value = conditions.scopeState;
4262
+ rest = path.slice(2);
4263
+ } else if (path[0] === "action" && path[1] === "input") {
4264
+ value = conditions.actionInput;
4265
+ rest = path.slice(2);
4266
+ } else return;
4267
+ for (const segment of rest) {
4268
+ if (!isPlainValue(value) || !Object.hasOwn(value, segment)) return;
4269
+ value = value[segment];
4270
+ }
4271
+ return asConditionValue(value);
4272
+ }
4273
+ /**
4274
+ * Total order within one type: numbers numerically, strings by code point.
4275
+ * Everything else, including mixed types, does not order.
4276
+ */
4277
+ function compareValues(left, right) {
4278
+ if (typeof left === "number" && typeof right === "number") return left < right ? -1 : left > right ? 1 : 0;
4279
+ if (typeof left === "string" && typeof right === "string") {
4280
+ const leftPoints = Array.from(left);
4281
+ const rightPoints = Array.from(right);
4282
+ const shared = Math.min(leftPoints.length, rightPoints.length);
4283
+ for (let i = 0; i < shared; i++) {
4284
+ const a = leftPoints[i].codePointAt(0) ?? 0;
4285
+ const b = rightPoints[i].codePointAt(0) ?? 0;
4286
+ if (a !== b) return a < b ? -1 : 1;
4287
+ }
4288
+ return leftPoints.length === rightPoints.length ? 0 : leftPoints.length < rightPoints.length ? -1 : 1;
4289
+ }
4290
+ }
4291
+ /**
4292
+ * Tri-state evaluation: undefined marks a structurally invalid node, which
4293
+ * poisons the whole tree to false at the top — and a structurally malformed
4294
+ * operand poisons its condition the same way. Both are distinct from an
4295
+ * operand whose path fails to resolve, which is a valid comparison that is
4296
+ * false. The distinction keeps `not` from widening over malformed input.
4297
+ */
4298
+ function evaluateNode(node, subject, request, conditions) {
4299
+ if (!isPlainValue(node)) return;
4300
+ const keys = Object.keys(node);
4301
+ if (keys.length !== 1) return;
4302
+ const kind = keys[0];
4303
+ const body = node[kind];
4304
+ switch (kind) {
4305
+ case "eq":
4306
+ case "ne":
4307
+ case "lt":
4308
+ case "lte":
4309
+ case "gt":
4310
+ case "gte": {
4311
+ if (!Array.isArray(body) || body.length !== 2) return;
4312
+ const left = resolveOperand(body[0], subject, request, conditions);
4313
+ const right = resolveOperand(body[1], subject, request, conditions);
4314
+ if (left === INVALID_OPERAND || right === INVALID_OPERAND) return;
4315
+ if (left === void 0 || right === void 0) return false;
4316
+ if (kind === "eq") return left === right;
4317
+ if (kind === "ne") return left !== right;
4318
+ const order = compareValues(left, right);
4319
+ if (order === void 0) return false;
4320
+ switch (kind) {
4321
+ case "lt": return order < 0;
4322
+ case "lte": return order <= 0;
4323
+ case "gt": return order > 0;
4324
+ case "gte": return order >= 0;
4325
+ }
4326
+ return;
4327
+ }
4328
+ case "in":
4329
+ case "notIn": {
4330
+ if (!Array.isArray(body) || body.length !== 2 || !Array.isArray(body[1])) return;
4331
+ const left = resolveOperand(body[0], subject, request, conditions);
4332
+ if (left === INVALID_OPERAND) return;
4333
+ const elements = body[1].map((element) => resolveOperand(element, subject, request, conditions));
4334
+ if (elements.some((value) => value === INVALID_OPERAND)) return;
4335
+ if (left === void 0) return false;
4336
+ const found = elements.some((value) => value !== void 0 && value === left);
4337
+ return kind === "in" ? found : !found;
4338
+ }
4339
+ case "exists": {
4340
+ const value = resolveOperand(body, subject, request, conditions);
4341
+ if (value === INVALID_OPERAND) return;
4342
+ return value !== void 0;
4343
+ }
4344
+ case "and":
4345
+ case "or": {
4346
+ if (!Array.isArray(body)) return;
4347
+ let result = kind === "and";
4348
+ for (const child of body) {
4349
+ const value = evaluateNode(child, subject, request, conditions);
4350
+ if (value === void 0) return;
4351
+ if (kind === "and") result = result && value;
4352
+ else result = result || value;
4353
+ }
4354
+ return result;
4355
+ }
4356
+ case "not": {
4357
+ const value = evaluateNode(body, subject, request, conditions);
4358
+ return value === void 0 ? void 0 : !value;
4359
+ }
4360
+ default: return;
4361
+ }
4362
+ }
4363
+ /**
4364
+ * Evaluates a version-1 condition. Deterministic, total, and pure: any input
4365
+ * shape yields a boolean and never throws, and a malformed condition is
4366
+ * false. These are consensus semantics, versioned by `PHAuthState.version`;
4367
+ * changing them requires a new version.
4368
+ */
4369
+ function evaluateCondition(condition, subject, request, conditions) {
4370
+ return evaluateNode(condition, subject, request, conditions) === true;
4371
+ }
4220
4372
  function capabilityCovers(capability, request) {
4221
4373
  if (capability.can !== request.verb) return false;
4222
4374
  const scope = capability.scope;
@@ -4227,21 +4379,37 @@ function capabilityCovers(capability, request) {
4227
4379
  }
4228
4380
  return true;
4229
4381
  }
4230
- function principalMatches(principal, subject) {
4382
+ function principalMatches(principal, subject, request, groups, conditions) {
4231
4383
  if ("anyone" in principal) return true;
4232
4384
  if ("address" in principal) return subject.address !== void 0 && subject.address.toLowerCase() === principal.address.toLowerCase();
4385
+ if ("group" in principal) {
4386
+ if (groups === void 0 || subject.address === void 0) return false;
4387
+ const group = groups[principal.group];
4388
+ if (group === void 0 || !Array.isArray(group.members)) return false;
4389
+ const address = subject.address.toLowerCase();
4390
+ return group.members.some((member) => member.toLowerCase() === address);
4391
+ }
4392
+ if ("match" in principal) {
4393
+ if (conditions === void 0) return false;
4394
+ return evaluateCondition(principal.match, subject, request, conditions);
4395
+ }
4233
4396
  return false;
4234
4397
  }
4235
4398
  /**
4236
4399
  * Evaluates a v1 grant stack: default deny, last applicable grant wins, and
4237
- * reports which grant decided it. Group and match principals and `where`
4238
- * conditions are not evaluated yet; a grant that uses any of them never applies.
4400
+ * reports which grant decided it. Group principals match only against a
4401
+ * supplied groups map, and `where` clauses and { match } principals evaluate
4402
+ * only against a supplied condition context; a grant that uses an unsupplied
4403
+ * feature never applies.
4239
4404
  */
4240
- function evaluateGrantStack(grants, subject, request) {
4405
+ function evaluateGrantStack(grants, subject, request, groups, conditions) {
4241
4406
  let applicable;
4242
4407
  for (const grant of grants) {
4243
- if (grant.where !== void 0) continue;
4244
- if (capabilityCovers(grant.capability, request) && principalMatches(grant.principal, subject)) applicable = grant;
4408
+ if (grant.where !== void 0) {
4409
+ if (conditions === void 0) continue;
4410
+ if (!evaluateCondition(grant.where, subject, request, conditions)) continue;
4411
+ }
4412
+ if (capabilityCovers(grant.capability, request) && principalMatches(grant.principal, subject, request, groups, conditions)) applicable = grant;
4245
4413
  }
4246
4414
  if (applicable === void 0) return {
4247
4415
  decision: "deny",
@@ -8139,6 +8307,6 @@ const driveDocumentModelModule = {
8139
8307
  }
8140
8308
  };
8141
8309
  //#endregion
8142
- export { validateStateSchemaName as $, documentModelDocumentType as A, setModelExtension as B, createReducer as C, deleteModule as D, defaultBaseState as E, replayDocumentVersioned as F, setOperationDescription as G, setModelName as H, setAuthorName as I, setOperationSchema as J, setOperationErrorName as K, setAuthorWebsite as L, isDocumentAction as M, redo as N, deleteOperation as O, releaseNewVersion as P, validateModules as Q, setInitialState as R, createPresignedHeader as S, createZip as T, setModuleName as U, setModelId as V, setName as W, undo as X, setStateSchema as Y, validateInitialState as Z, baseCreateDocument as _, handleTargetNameCollisions as a, baseSaveToFileHandle as b, isValidName as c, documentModelDocumentModelModule as d, generateId as et, logger as f, assertAuthPreservedOnDuplicate as g, addOperationError as h, generateNodesCopy as i, hashDocumentStateForScope as j, deleteOperationError as k, moveNode as l, addOperation as m, copyNode as n, isFileNode as o, addModule as p, setOperationName as q, driveDocumentModelModule as r, isFolderNode as s, addFolder as t, updateNode as u, baseLoadFromInput as v, createState as w, buildSignedAction as x, baseLoadFromInputVersioned as y, setModelDescription as z };
8310
+ export { setOperationSchema as $, createZip as A, replayDocumentVersioned as B, baseSaveToFileHandle as C, createPresignedHeader as D, createBaseState as E, documentModelDocumentType as F, setModelExtension as G, setAuthorWebsite as H, hashDocumentStateForScope as I, setModuleName as J, setModelId as K, isDocumentAction as L, deleteModule as M, deleteOperation as N, createReducer as O, deleteOperationError as P, setOperationName as Q, redo as R, baseLoadFromInputVersioned as S, createAction as T, setInitialState as U, setAuthorName as V, setModelDescription as W, setOperationDescription as X, setName as Y, setOperationErrorName as Z, addOperationError as _, handleTargetNameCollisions as a, generateId as at, baseCreateDocument as b, isValidName as c, documentModelDocumentModelModule as d, setStateSchema as et, logger as f, addOperation as g, addModule as h, generateNodesCopy as i, validateStateSchemaName as it, defaultBaseState as j, createState as k, moveNode as l, BaseDocumentStateSchema as m, copyNode as n, validateInitialState as nt, isFileNode as o, BaseDocumentHeaderSchema as p, setModelName as q, driveDocumentModelModule as r, validateModules as rt, isFolderNode as s, addFolder as t, undo as tt, updateNode as u, assertAuthPreservedOnDuplicate as v, buildSignedAction as w, baseLoadFromInput as x, baseActions as y, releaseNewVersion as z };
8143
8311
 
8144
- //# sourceMappingURL=document-drive-CPxMz8lW.mjs.map
8312
+ //# sourceMappingURL=document-drive-DrBAR9as.mjs.map