@powerhousedao/powerhouse-vetra-packages 6.2.2-dev.80 → 6.2.2-dev.82

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 (49) hide show
  1. package/dist/browser/{connect-Df8YBCmF.js → connect-Bpm1qc2o.js} +3 -3
  2. package/dist/browser/{connect-Df8YBCmF.js.map → connect-Bpm1qc2o.js.map} +1 -1
  3. package/dist/browser/{dist-BIpFdiLp.js → dist-DzuQgnp9.js} +2 -2
  4. package/dist/browser/{dist-BIpFdiLp.js.map → dist-DzuQgnp9.js.map} +1 -1
  5. package/dist/browser/{document-drive-DU75CBKf.js → document-drive-BVYCdu_5.js} +24 -222
  6. package/dist/browser/document-drive-BVYCdu_5.js.map +1 -0
  7. package/dist/browser/document-models/index.js +1 -1
  8. package/dist/browser/{editor-y1bqyeB_.js → editor-BhVC9JGB.js} +5 -5
  9. package/dist/browser/{editor-y1bqyeB_.js.map → editor-BhVC9JGB.js.map} +1 -1
  10. package/dist/browser/{editor-BuYbUTIt.js → editor-Cr2SUFnl.js} +6 -6
  11. package/dist/browser/{editor-BuYbUTIt.js.map → editor-Cr2SUFnl.js.map} +1 -1
  12. package/dist/browser/editors/document-model-editor/module.js +1 -1
  13. package/dist/browser/editors/generic-drive-explorer/index.js +4 -4
  14. package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
  15. package/dist/browser/{folder-view-BzERbCoQ.js → folder-view-EDdZl1fJ.js} +3 -3
  16. package/dist/browser/{folder-view-BzERbCoQ.js.map → folder-view-EDdZl1fJ.js.map} +1 -1
  17. package/dist/browser/{graphql-editor-Dv1FDpax.js → graphql-editor-BjkthIT9.js} +3 -3
  18. package/dist/browser/{graphql-editor-Dv1FDpax.js.map → graphql-editor-BjkthIT9.js.map} +1 -1
  19. package/dist/browser/index.js +1 -1
  20. package/dist/browser/{json-editor-ZRgRDikU.js → json-editor-nLgiw_aY.js} +3 -3
  21. package/dist/browser/{json-editor-ZRgRDikU.js.map → json-editor-nLgiw_aY.js.map} +1 -1
  22. package/dist/browser/{state-schemas-BBkkpjRl.js → state-schemas-IiwC01DT.js} +3 -3
  23. package/dist/browser/{state-schemas-BBkkpjRl.js.map → state-schemas-IiwC01DT.js.map} +1 -1
  24. package/dist/node/{connect-DM43aaJZ.mjs → connect-DzMvrvtH.mjs} +3 -3
  25. package/dist/node/{connect-DM43aaJZ.mjs.map → connect-DzMvrvtH.mjs.map} +1 -1
  26. package/dist/node/{dist-4gA6tFmW.mjs → dist-CWqCyPep.mjs} +2 -2
  27. package/dist/node/{dist-4gA6tFmW.mjs.map → dist-CWqCyPep.mjs.map} +1 -1
  28. package/dist/node/{document-drive-CRYbvD0-.mjs → document-drive-lf_0SP-H.mjs} +24 -222
  29. package/dist/node/document-drive-lf_0SP-H.mjs.map +1 -0
  30. package/dist/node/document-models/index.mjs +1 -1
  31. package/dist/node/{editor-B5cnYfC7.mjs → editor-BHFgv5Sn.mjs} +6 -6
  32. package/dist/node/{editor-B5cnYfC7.mjs.map → editor-BHFgv5Sn.mjs.map} +1 -1
  33. package/dist/node/{editor-Dn0DUR0W.mjs → editor-DSlBxXEG.mjs} +5 -5
  34. package/dist/node/{editor-Dn0DUR0W.mjs.map → editor-DSlBxXEG.mjs.map} +1 -1
  35. package/dist/node/editors/document-model-editor/module.mjs +1 -1
  36. package/dist/node/editors/generic-drive-explorer/index.mjs +4 -4
  37. package/dist/node/editors/generic-drive-explorer/module.mjs +1 -1
  38. package/dist/node/{folder-view-BAAfODx_.mjs → folder-view-BU4jkZT4.mjs} +3 -3
  39. package/dist/node/{folder-view-BAAfODx_.mjs.map → folder-view-BU4jkZT4.mjs.map} +1 -1
  40. package/dist/node/{graphql-editor-CUrJvXrG.mjs → graphql-editor-CScEOmFM.mjs} +3 -3
  41. package/dist/node/{graphql-editor-CUrJvXrG.mjs.map → graphql-editor-CScEOmFM.mjs.map} +1 -1
  42. package/dist/node/index.mjs +1 -1
  43. package/dist/node/{json-editor-TvKShKo-.mjs → json-editor-BkdBLGDx.mjs} +3 -3
  44. package/dist/node/{json-editor-TvKShKo-.mjs.map → json-editor-BkdBLGDx.mjs.map} +1 -1
  45. package/dist/node/{state-schemas-CJK5hin3.mjs → state-schemas-BCTGWiNB.mjs} +3 -3
  46. package/dist/node/{state-schemas-CJK5hin3.mjs.map → state-schemas-BCTGWiNB.mjs.map} +1 -1
  47. package/package.json +7 -7
  48. package/dist/browser/document-drive-DU75CBKf.js.map +0 -1
  49. package/dist/node/document-drive-CRYbvD0-.mjs.map +0 -1
@@ -4274,35 +4274,32 @@ const AUTH_ADMINISTRATION_REQUEST = {
4274
4274
  operation: "SET_GRANT"
4275
4275
  };
4276
4276
  /**
4277
- * Whether some subject can still administer the auth scope under this grant list.
4277
+ * Whether some subject can still administer the auth scope under this grant
4278
+ * list.
4278
4279
  *
4279
- * Asks the evaluator rather than pattern-matching a single grant: evaluation is
4280
- * last-applicable-grant-wins, so an allow that some later deny shadows keeps
4281
- * nothing reachable even though it is still present in the list. Only anyone and
4282
- * address principals are candidates, because those are the ones v1 can match at
4283
- * all; a `where` condition or a group or match principal never applies.
4280
+ * Answers exactly what asking {@link evaluateGrantStack} per candidate grant
4281
+ * answered, in one reverse pass instead of one full stack scan per candidate.
4282
+ * Evaluation is last-applicable-grant-wins, so scanning from the end meets each
4283
+ * subject's deciding grant first: an anyone grant decides every subject not
4284
+ * already decided, and an allow reached that way is itself a grant that carries
4285
+ * administration. Only anyone and address principals are candidates, because
4286
+ * those are the ones v1 can match with no groups and no condition context; a
4287
+ * `where` condition or a group or match principal never applies.
4284
4288
  */
4285
4289
  function administrationReachable(grants) {
4286
- return grants.some((grant) => {
4287
- const subject = administrationCandidate(grant);
4288
- if (subject === void 0) return false;
4289
- return evaluateGrantStack(grants, subject, AUTH_ADMINISTRATION_REQUEST).decision === "allow";
4290
- });
4291
- }
4292
- /**
4293
- * The subject to test this grant with, or undefined when the grant could never
4294
- * carry administration for anyone.
4295
- */
4296
- function administrationCandidate(grant) {
4297
- if (grant.effect !== "allow" || grant.where !== void 0 || !capabilityCovers(grant.capability, AUTH_ADMINISTRATION_REQUEST)) return;
4298
- if ("address" in grant.principal) return {
4299
- address: grant.principal.address,
4300
- key: void 0
4301
- };
4302
- if ("anyone" in grant.principal) return {
4303
- address: void 0,
4304
- key: void 0
4305
- };
4290
+ const shadowedAddresses = /* @__PURE__ */ new Set();
4291
+ for (let index = grants.length - 1; index >= 0; index -= 1) {
4292
+ const grant = grants[index];
4293
+ if (grant.where !== void 0 || !grantAnswers(grant, AUTH_ADMINISTRATION_REQUEST)) continue;
4294
+ const allows = grant.effect === "allow";
4295
+ if ("anyone" in grant.principal) return allows;
4296
+ if (!("address" in grant.principal)) continue;
4297
+ const address = grant.principal.address.toLowerCase();
4298
+ if (shadowedAddresses.has(address)) continue;
4299
+ if (allows) return true;
4300
+ shadowedAddresses.add(address);
4301
+ }
4302
+ return false;
4306
4303
  }
4307
4304
  /**
4308
4305
  * A creator-less policy must always retain a grant permitting execute on the
@@ -4314,158 +4311,6 @@ function assertAuthAdministrationRetained(creator, previous, next, grantId) {
4314
4311
  if (creator !== void 0) return;
4315
4312
  if (administrationReachable(previous) && !administrationReachable(next)) throw new AuthAdministrationLockoutError(grantId);
4316
4313
  }
4317
- /**
4318
- * An operand whose shape validation would have rejected. Distinguished from
4319
- * an unresolved path so a structurally malformed operand poisons its whole
4320
- * condition to false rather than reading as "absent", which `not` would
4321
- * otherwise widen to true.
4322
- */
4323
- const INVALID_OPERAND = Symbol("invalid-operand");
4324
- /**
4325
- * Narrows to the values conditions compare. An object, array, or non-finite
4326
- * number resolves to undefined, and every comparison involving undefined is
4327
- * false.
4328
- */
4329
- function asConditionValue(value) {
4330
- if (value === null || typeof value === "string" || typeof value === "boolean") return value;
4331
- if (typeof value === "number" && Number.isFinite(value)) return value;
4332
- }
4333
- /**
4334
- * Resolves one operand. Attr roots: `subject.*`, `doc.<scope>.*` where the
4335
- * scope must be the executing scope (validation already rejects any other,
4336
- * but resolution stays total), and `action.input.*`. Path steps read own
4337
- * properties only, so prototype members can never influence a verdict.
4338
- */
4339
- function resolveOperand(operand, subject, request, conditions) {
4340
- if (!isPlainValue(operand)) return INVALID_OPERAND;
4341
- const keys = Object.keys(operand);
4342
- if (keys.length !== 1) return INVALID_OPERAND;
4343
- if (keys[0] === "lit") {
4344
- const value = asConditionValue(operand.lit);
4345
- return value === void 0 ? INVALID_OPERAND : value;
4346
- }
4347
- if (keys[0] !== "attr") return INVALID_OPERAND;
4348
- const attr = operand.attr;
4349
- if (typeof attr !== "string" || attr.length === 0) return INVALID_OPERAND;
4350
- const path = attr.split(".");
4351
- let value;
4352
- let rest;
4353
- if (path[0] === "subject") {
4354
- value = subject;
4355
- rest = path.slice(1);
4356
- } else if (path[0] === "doc") {
4357
- if (path[1] !== request.scope) return;
4358
- value = conditions.scopeState;
4359
- rest = path.slice(2);
4360
- } else if (path[0] === "action" && path[1] === "input") {
4361
- value = conditions.actionInput;
4362
- rest = path.slice(2);
4363
- } else return;
4364
- for (const segment of rest) {
4365
- if (!isPlainValue(value) || !Object.hasOwn(value, segment)) return;
4366
- value = value[segment];
4367
- }
4368
- return asConditionValue(value);
4369
- }
4370
- /**
4371
- * Total order within one type: numbers numerically, strings by code point.
4372
- * Everything else, including mixed types, does not order.
4373
- */
4374
- function compareValues(left, right) {
4375
- if (typeof left === "number" && typeof right === "number") return left < right ? -1 : left > right ? 1 : 0;
4376
- if (typeof left === "string" && typeof right === "string") {
4377
- const leftPoints = Array.from(left);
4378
- const rightPoints = Array.from(right);
4379
- const shared = Math.min(leftPoints.length, rightPoints.length);
4380
- for (let i = 0; i < shared; i++) {
4381
- const a = leftPoints[i].codePointAt(0) ?? 0;
4382
- const b = rightPoints[i].codePointAt(0) ?? 0;
4383
- if (a !== b) return a < b ? -1 : 1;
4384
- }
4385
- return leftPoints.length === rightPoints.length ? 0 : leftPoints.length < rightPoints.length ? -1 : 1;
4386
- }
4387
- }
4388
- /**
4389
- * Tri-state evaluation: undefined marks a structurally invalid node, which
4390
- * poisons the whole tree to false at the top — and a structurally malformed
4391
- * operand poisons its condition the same way. Both are distinct from an
4392
- * operand whose path fails to resolve, which is a valid comparison that is
4393
- * false. The distinction keeps `not` from widening over malformed input.
4394
- */
4395
- function evaluateNode(node, subject, request, conditions) {
4396
- if (!isPlainValue(node)) return;
4397
- const keys = Object.keys(node);
4398
- if (keys.length !== 1) return;
4399
- const kind = keys[0];
4400
- const body = node[kind];
4401
- switch (kind) {
4402
- case "eq":
4403
- case "ne":
4404
- case "lt":
4405
- case "lte":
4406
- case "gt":
4407
- case "gte": {
4408
- if (!Array.isArray(body) || body.length !== 2) return;
4409
- const left = resolveOperand(body[0], subject, request, conditions);
4410
- const right = resolveOperand(body[1], subject, request, conditions);
4411
- if (left === INVALID_OPERAND || right === INVALID_OPERAND) return;
4412
- if (left === void 0 || right === void 0) return false;
4413
- if (kind === "eq") return left === right;
4414
- if (kind === "ne") return left !== right;
4415
- const order = compareValues(left, right);
4416
- if (order === void 0) return false;
4417
- switch (kind) {
4418
- case "lt": return order < 0;
4419
- case "lte": return order <= 0;
4420
- case "gt": return order > 0;
4421
- case "gte": return order >= 0;
4422
- }
4423
- return;
4424
- }
4425
- case "in":
4426
- case "notIn": {
4427
- if (!Array.isArray(body) || body.length !== 2 || !Array.isArray(body[1])) return;
4428
- const left = resolveOperand(body[0], subject, request, conditions);
4429
- if (left === INVALID_OPERAND) return;
4430
- const elements = body[1].map((element) => resolveOperand(element, subject, request, conditions));
4431
- if (elements.some((value) => value === INVALID_OPERAND)) return;
4432
- if (left === void 0) return false;
4433
- const found = elements.some((value) => value !== void 0 && value === left);
4434
- return kind === "in" ? found : !found;
4435
- }
4436
- case "exists": {
4437
- const value = resolveOperand(body, subject, request, conditions);
4438
- if (value === INVALID_OPERAND) return;
4439
- return value !== void 0;
4440
- }
4441
- case "and":
4442
- case "or": {
4443
- if (!Array.isArray(body)) return;
4444
- let result = kind === "and";
4445
- for (const child of body) {
4446
- const value = evaluateNode(child, subject, request, conditions);
4447
- if (value === void 0) return;
4448
- if (kind === "and") result = result && value;
4449
- else result = result || value;
4450
- }
4451
- return result;
4452
- }
4453
- case "not": {
4454
- const value = evaluateNode(body, subject, request, conditions);
4455
- return value === void 0 ? void 0 : !value;
4456
- }
4457
- default: return;
4458
- }
4459
- }
4460
- /**
4461
- * Evaluates a version-1 condition. Deterministic, total, and pure: any input
4462
- * shape yields a boolean and never throws, and a malformed condition is
4463
- * false. These are consensus semantics, versioned by `PHAuthState.version`;
4464
- * changing them requires a new version.
4465
- */
4466
- function evaluateCondition(condition, subject, request, conditions) {
4467
- return evaluateNode(condition, subject, request, conditions) === true;
4468
- }
4469
4314
  /** Whether a capability's scope reaches the requested one. */
4470
4315
  function scopeCovers(scope, requested) {
4471
4316
  return scope === void 0 || scope === "*" || scope === requested;
@@ -4501,49 +4346,6 @@ function capabilityCovers(capability, request) {
4501
4346
  }
4502
4347
  return true;
4503
4348
  }
4504
- function principalMatches(principal, subject, request, groups, conditions) {
4505
- if ("anyone" in principal) return true;
4506
- if ("address" in principal) return subject.address !== void 0 && subject.address.toLowerCase() === principal.address.toLowerCase();
4507
- if ("group" in principal) {
4508
- if (groups === void 0 || subject.address === void 0) return false;
4509
- const group = groups[principal.group];
4510
- if (group === void 0 || !Array.isArray(group.members)) return false;
4511
- const address = subject.address.toLowerCase();
4512
- return group.members.some((member) => member.toLowerCase() === address);
4513
- }
4514
- if ("match" in principal) {
4515
- if (conditions === void 0) return false;
4516
- return evaluateCondition(principal.match, subject, request, conditions);
4517
- }
4518
- return false;
4519
- }
4520
- /**
4521
- * Evaluates a v1 grant stack: default deny, last applicable grant wins, and
4522
- * reports which grant decided it. Group principals match only against a
4523
- * supplied groups map, and `where` clauses and { match } principals evaluate
4524
- * only against a supplied condition context; a grant that uses an unsupplied
4525
- * feature never applies.
4526
- */
4527
- function evaluateGrantStack(grants, subject, request, groups, conditions) {
4528
- let applicable;
4529
- for (const grant of grants) {
4530
- if (grant.where !== void 0) {
4531
- if (conditions === void 0) continue;
4532
- if (!evaluateCondition(grant.where, subject, request, conditions)) continue;
4533
- }
4534
- if (grantAnswers(grant, request) && principalMatches(grant.principal, subject, request, groups, conditions)) applicable = grant;
4535
- }
4536
- if (applicable === void 0) return {
4537
- decision: "deny",
4538
- refusal: "no-applicable-grant"
4539
- };
4540
- if (applicable.effect === "deny") return {
4541
- decision: "deny",
4542
- refusal: "denied-by-grant",
4543
- grantId: applicable.id
4544
- };
4545
- return { decision: "allow" };
4546
- }
4547
4349
  const documentModelFileExtension = "phdm";
4548
4350
  const documentModelInitialLocalState = {};
4549
4351
  const documentModelInitialGlobalState = {
@@ -8442,4 +8244,4 @@ const driveDocumentModelModule = {
8442
8244
  //#endregion
8443
8245
  export { setOperationDescription as $, createState as A, normalizeDocumentModelVersion as B, baseLoadFromInputVersioned as C, createBaseState as D, createAction as E, deleteOperationError as F, setAuthorWebsite as G, releaseNewVersion as H, deserializeSignature as I, setModelExtension as J, setInitialState as K, documentModelDocumentType as L, defaultBaseState as M, deleteModule as N, createPresignedHeader as O, deleteOperation as P, setName as Q, hashDocumentStateForScope as R, baseLoadFromInput as S, buildSignedAction as T, replayDocumentVersioned as U, redo as V, setAuthorName as W, setModelName as X, setModelId as Y, setModuleName as Z, addOperation as _, handleTargetNameCollisions as a, undo as at, baseActions as b, isValidName as c, validateStateSchemaName as ct, documentModelDocumentModelModule as d, setOperationErrorName as et, logger as f, addModule as g, UnsupportedDocumentModelVersionError as h, generateNodesCopy as i, toTransportAction as it, createZip as j, createReducer as k, moveNode as l, generateId as lt, BaseDocumentStateSchema as m, copyNode as n, setOperationSchema as nt, isFileNode as o, validateInitialState as ot, BaseDocumentHeaderSchema as p, setModelDescription as q, driveDocumentModelModule as r, setStateSchema as rt, isFolderNode as s, validateModules as st, addFolder as t, setOperationName as tt, updateNode as u, addOperationError as v, baseSaveToFileHandle as w, baseCreateDocument as x, assertAuthPreservedOnDuplicate as y, isDocumentAction as z };
8444
8246
 
8445
- //# sourceMappingURL=document-drive-CRYbvD0-.mjs.map
8247
+ //# sourceMappingURL=document-drive-lf_0SP-H.mjs.map