@powerhousedao/powerhouse-vetra-packages 6.2.2-dev.43 → 6.2.2-dev.44
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/dist/browser/assets/{entry-CcSqsfaf.js → entry-C2ClkbVN.js} +2 -2
- package/dist/browser/assets/{projection-entry-qnPqxpN3.js → projection-entry-S39DdeT-.js} +2 -2
- package/dist/browser/{connect-Cs9_OfUW.js → connect-70_1bgIZ.js} +4 -4
- package/dist/browser/{connect-Cs9_OfUW.js.map → connect-70_1bgIZ.js.map} +1 -1
- package/dist/browser/{dist-Cw08sCbR.js → dist-CXIjN0Ex.js} +4 -4
- package/dist/browser/{dist-Cw08sCbR.js.map → dist-CXIjN0Ex.js.map} +1 -1
- package/dist/browser/{document-drive-CLF3V3yq.js → document-drive-PYPIaEvw.js} +177 -9
- package/dist/browser/document-drive-PYPIaEvw.js.map +1 -0
- package/dist/browser/document-models/index.js +1 -1
- package/dist/browser/{editor-Clf15hps.js → editor-DOJeQKlN.js} +5 -5
- package/dist/browser/{editor-Clf15hps.js.map → editor-DOJeQKlN.js.map} +1 -1
- package/dist/browser/{editor-CRj28xcj.js → editor-QW6D3wl8.js} +6 -6
- package/dist/browser/{editor-CRj28xcj.js.map → editor-QW6D3wl8.js.map} +1 -1
- package/dist/browser/editors/document-model-editor/module.js +1 -1
- package/dist/browser/editors/generic-drive-explorer/index.js +4 -4
- package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
- package/dist/browser/{folder-view-Zc--316o.js → folder-view-VM5cJbvv.js} +3 -3
- package/dist/browser/{folder-view-Zc--316o.js.map → folder-view-VM5cJbvv.js.map} +1 -1
- package/dist/browser/{graphql-editor-BYiN6EYX.js → graphql-editor-CjpiNMV0.js} +3 -3
- package/dist/browser/{graphql-editor-BYiN6EYX.js.map → graphql-editor-CjpiNMV0.js.map} +1 -1
- package/dist/browser/index.js +378 -9
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/{json-editor-BCQBDkoV.js → json-editor-CeIHor4v.js} +3 -3
- package/dist/browser/{json-editor-BCQBDkoV.js.map → json-editor-CeIHor4v.js.map} +1 -1
- package/dist/browser/{lib-CZf9FJ-n.js → lib-PZlA5c3e.js} +2 -2
- package/dist/browser/lib-PZlA5c3e.js.map +1 -0
- package/dist/browser/{state-schemas-Co7oWTVF.js → state-schemas-CbPirA44.js} +3 -3
- package/dist/browser/{state-schemas-Co7oWTVF.js.map → state-schemas-CbPirA44.js.map} +1 -1
- package/dist/node/{connect-DtLHLVuq.mjs → connect-CkBYxX_q.mjs} +4 -4
- package/dist/node/{connect-DtLHLVuq.mjs.map → connect-CkBYxX_q.mjs.map} +1 -1
- package/dist/node/{dist-Co6sAUR3.mjs → dist-CS8QwZwZ.mjs} +4 -4
- package/dist/node/{dist-Co6sAUR3.mjs.map → dist-CS8QwZwZ.mjs.map} +1 -1
- package/dist/node/{document-drive-CPxMz8lW.mjs → document-drive-DrBAR9as.mjs} +177 -9
- package/dist/node/document-drive-DrBAR9as.mjs.map +1 -0
- package/dist/node/document-models/index.mjs +1 -1
- package/dist/node/{editor-Dl-takGb.mjs → editor-ClZqmnoh.mjs} +6 -6
- package/dist/node/{editor-Dl-takGb.mjs.map → editor-ClZqmnoh.mjs.map} +1 -1
- package/dist/node/{editor-CNTEyfKg.mjs → editor-Dv22q5WR.mjs} +5 -5
- package/dist/node/{editor-CNTEyfKg.mjs.map → editor-Dv22q5WR.mjs.map} +1 -1
- package/dist/node/editors/document-model-editor/module.mjs +1 -1
- package/dist/node/editors/generic-drive-explorer/index.mjs +4 -4
- package/dist/node/editors/generic-drive-explorer/module.mjs +1 -1
- package/dist/node/{folder-view-B2qOsImy.mjs → folder-view-6H-dMp8X.mjs} +3 -3
- package/dist/node/{folder-view-B2qOsImy.mjs.map → folder-view-6H-dMp8X.mjs.map} +1 -1
- package/dist/node/{graphql-editor-DsX64AUl.mjs → graphql-editor-DP0o3W7f.mjs} +3 -3
- package/dist/node/{graphql-editor-DsX64AUl.mjs.map → graphql-editor-DP0o3W7f.mjs.map} +1 -1
- package/dist/node/index.mjs +378 -9
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/{json-editor-H15UPuqD.mjs → json-editor-CNbnXYz6.mjs} +3 -3
- package/dist/node/{json-editor-H15UPuqD.mjs.map → json-editor-CNbnXYz6.mjs.map} +1 -1
- package/dist/node/{main-7-PK1gTO.mjs → main-aITg389Z.mjs} +2 -2
- package/dist/node/main-aITg389Z.mjs.map +1 -0
- package/dist/node/{state-schemas-BEbd8zYo.mjs → state-schemas-CylQoH3Q.mjs} +3 -3
- package/dist/node/{state-schemas-BEbd8zYo.mjs.map → state-schemas-CylQoH3Q.mjs.map} +1 -1
- package/package.json +7 -6
- package/dist/browser/document-drive-CLF3V3yq.js.map +0 -1
- package/dist/browser/lib-CZf9FJ-n.js.map +0 -1
- package/dist/node/document-drive-CPxMz8lW.mjs.map +0 -1
- package/dist/node/main-7-PK1gTO.mjs.map +0 -1
|
@@ -4126,7 +4126,7 @@ function assertValidGrant(grant, documentType) {
|
|
|
4126
4126
|
const grantId = isPlainValue(grant) && typeof grant.id === "string" ? grant.id : "";
|
|
4127
4127
|
const problem = grantProblem(grant);
|
|
4128
4128
|
if (problem !== null) throw new InvalidGrantError(grantId, problem);
|
|
4129
|
-
if (documentType === "
|
|
4129
|
+
if (documentType === "powerhouse/reactor-group" && "group" in grant.principal) throw new GroupPrincipalNotAllowedError(grantId);
|
|
4130
4130
|
}
|
|
4131
4131
|
/**
|
|
4132
4132
|
* Validates an initial grant list: the count cap, every grant, and — on a
|
|
@@ -4200,6 +4200,158 @@ function assertAuthAdministrationRetained(creator, previous, next, grantId) {
|
|
|
4200
4200
|
if (creator !== void 0) return;
|
|
4201
4201
|
if (administrationReachable(previous) && !administrationReachable(next)) throw new AuthAdministrationLockoutError(grantId);
|
|
4202
4202
|
}
|
|
4203
|
+
/**
|
|
4204
|
+
* An operand whose shape validation would have rejected. Distinguished from
|
|
4205
|
+
* an unresolved path so a structurally malformed operand poisons its whole
|
|
4206
|
+
* condition to false rather than reading as "absent", which `not` would
|
|
4207
|
+
* otherwise widen to true.
|
|
4208
|
+
*/
|
|
4209
|
+
const INVALID_OPERAND = Symbol("invalid-operand");
|
|
4210
|
+
/**
|
|
4211
|
+
* Narrows to the values conditions compare. An object, array, or non-finite
|
|
4212
|
+
* number resolves to undefined, and every comparison involving undefined is
|
|
4213
|
+
* false.
|
|
4214
|
+
*/
|
|
4215
|
+
function asConditionValue(value) {
|
|
4216
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
4217
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
4218
|
+
}
|
|
4219
|
+
/**
|
|
4220
|
+
* Resolves one operand. Attr roots: `subject.*`, `doc.<scope>.*` where the
|
|
4221
|
+
* scope must be the executing scope (validation already rejects any other,
|
|
4222
|
+
* but resolution stays total), and `action.input.*`. Path steps read own
|
|
4223
|
+
* properties only, so prototype members can never influence a verdict.
|
|
4224
|
+
*/
|
|
4225
|
+
function resolveOperand(operand, subject, request, conditions) {
|
|
4226
|
+
if (!isPlainValue(operand)) return INVALID_OPERAND;
|
|
4227
|
+
const keys = Object.keys(operand);
|
|
4228
|
+
if (keys.length !== 1) return INVALID_OPERAND;
|
|
4229
|
+
if (keys[0] === "lit") {
|
|
4230
|
+
const value = asConditionValue(operand.lit);
|
|
4231
|
+
return value === void 0 ? INVALID_OPERAND : value;
|
|
4232
|
+
}
|
|
4233
|
+
if (keys[0] !== "attr") return INVALID_OPERAND;
|
|
4234
|
+
const attr = operand.attr;
|
|
4235
|
+
if (typeof attr !== "string" || attr.length === 0) return INVALID_OPERAND;
|
|
4236
|
+
const path = attr.split(".");
|
|
4237
|
+
let value;
|
|
4238
|
+
let rest;
|
|
4239
|
+
if (path[0] === "subject") {
|
|
4240
|
+
value = subject;
|
|
4241
|
+
rest = path.slice(1);
|
|
4242
|
+
} else if (path[0] === "doc") {
|
|
4243
|
+
if (path[1] !== request.scope) return;
|
|
4244
|
+
value = conditions.scopeState;
|
|
4245
|
+
rest = path.slice(2);
|
|
4246
|
+
} else if (path[0] === "action" && path[1] === "input") {
|
|
4247
|
+
value = conditions.actionInput;
|
|
4248
|
+
rest = path.slice(2);
|
|
4249
|
+
} else return;
|
|
4250
|
+
for (const segment of rest) {
|
|
4251
|
+
if (!isPlainValue(value) || !Object.hasOwn(value, segment)) return;
|
|
4252
|
+
value = value[segment];
|
|
4253
|
+
}
|
|
4254
|
+
return asConditionValue(value);
|
|
4255
|
+
}
|
|
4256
|
+
/**
|
|
4257
|
+
* Total order within one type: numbers numerically, strings by code point.
|
|
4258
|
+
* Everything else, including mixed types, does not order.
|
|
4259
|
+
*/
|
|
4260
|
+
function compareValues(left, right) {
|
|
4261
|
+
if (typeof left === "number" && typeof right === "number") return left < right ? -1 : left > right ? 1 : 0;
|
|
4262
|
+
if (typeof left === "string" && typeof right === "string") {
|
|
4263
|
+
const leftPoints = Array.from(left);
|
|
4264
|
+
const rightPoints = Array.from(right);
|
|
4265
|
+
const shared = Math.min(leftPoints.length, rightPoints.length);
|
|
4266
|
+
for (let i = 0; i < shared; i++) {
|
|
4267
|
+
const a = leftPoints[i].codePointAt(0) ?? 0;
|
|
4268
|
+
const b = rightPoints[i].codePointAt(0) ?? 0;
|
|
4269
|
+
if (a !== b) return a < b ? -1 : 1;
|
|
4270
|
+
}
|
|
4271
|
+
return leftPoints.length === rightPoints.length ? 0 : leftPoints.length < rightPoints.length ? -1 : 1;
|
|
4272
|
+
}
|
|
4273
|
+
}
|
|
4274
|
+
/**
|
|
4275
|
+
* Tri-state evaluation: undefined marks a structurally invalid node, which
|
|
4276
|
+
* poisons the whole tree to false at the top — and a structurally malformed
|
|
4277
|
+
* operand poisons its condition the same way. Both are distinct from an
|
|
4278
|
+
* operand whose path fails to resolve, which is a valid comparison that is
|
|
4279
|
+
* false. The distinction keeps `not` from widening over malformed input.
|
|
4280
|
+
*/
|
|
4281
|
+
function evaluateNode(node, subject, request, conditions) {
|
|
4282
|
+
if (!isPlainValue(node)) return;
|
|
4283
|
+
const keys = Object.keys(node);
|
|
4284
|
+
if (keys.length !== 1) return;
|
|
4285
|
+
const kind = keys[0];
|
|
4286
|
+
const body = node[kind];
|
|
4287
|
+
switch (kind) {
|
|
4288
|
+
case "eq":
|
|
4289
|
+
case "ne":
|
|
4290
|
+
case "lt":
|
|
4291
|
+
case "lte":
|
|
4292
|
+
case "gt":
|
|
4293
|
+
case "gte": {
|
|
4294
|
+
if (!Array.isArray(body) || body.length !== 2) return;
|
|
4295
|
+
const left = resolveOperand(body[0], subject, request, conditions);
|
|
4296
|
+
const right = resolveOperand(body[1], subject, request, conditions);
|
|
4297
|
+
if (left === INVALID_OPERAND || right === INVALID_OPERAND) return;
|
|
4298
|
+
if (left === void 0 || right === void 0) return false;
|
|
4299
|
+
if (kind === "eq") return left === right;
|
|
4300
|
+
if (kind === "ne") return left !== right;
|
|
4301
|
+
const order = compareValues(left, right);
|
|
4302
|
+
if (order === void 0) return false;
|
|
4303
|
+
switch (kind) {
|
|
4304
|
+
case "lt": return order < 0;
|
|
4305
|
+
case "lte": return order <= 0;
|
|
4306
|
+
case "gt": return order > 0;
|
|
4307
|
+
case "gte": return order >= 0;
|
|
4308
|
+
}
|
|
4309
|
+
return;
|
|
4310
|
+
}
|
|
4311
|
+
case "in":
|
|
4312
|
+
case "notIn": {
|
|
4313
|
+
if (!Array.isArray(body) || body.length !== 2 || !Array.isArray(body[1])) return;
|
|
4314
|
+
const left = resolveOperand(body[0], subject, request, conditions);
|
|
4315
|
+
if (left === INVALID_OPERAND) return;
|
|
4316
|
+
const elements = body[1].map((element) => resolveOperand(element, subject, request, conditions));
|
|
4317
|
+
if (elements.some((value) => value === INVALID_OPERAND)) return;
|
|
4318
|
+
if (left === void 0) return false;
|
|
4319
|
+
const found = elements.some((value) => value !== void 0 && value === left);
|
|
4320
|
+
return kind === "in" ? found : !found;
|
|
4321
|
+
}
|
|
4322
|
+
case "exists": {
|
|
4323
|
+
const value = resolveOperand(body, subject, request, conditions);
|
|
4324
|
+
if (value === INVALID_OPERAND) return;
|
|
4325
|
+
return value !== void 0;
|
|
4326
|
+
}
|
|
4327
|
+
case "and":
|
|
4328
|
+
case "or": {
|
|
4329
|
+
if (!Array.isArray(body)) return;
|
|
4330
|
+
let result = kind === "and";
|
|
4331
|
+
for (const child of body) {
|
|
4332
|
+
const value = evaluateNode(child, subject, request, conditions);
|
|
4333
|
+
if (value === void 0) return;
|
|
4334
|
+
if (kind === "and") result = result && value;
|
|
4335
|
+
else result = result || value;
|
|
4336
|
+
}
|
|
4337
|
+
return result;
|
|
4338
|
+
}
|
|
4339
|
+
case "not": {
|
|
4340
|
+
const value = evaluateNode(body, subject, request, conditions);
|
|
4341
|
+
return value === void 0 ? void 0 : !value;
|
|
4342
|
+
}
|
|
4343
|
+
default: return;
|
|
4344
|
+
}
|
|
4345
|
+
}
|
|
4346
|
+
/**
|
|
4347
|
+
* Evaluates a version-1 condition. Deterministic, total, and pure: any input
|
|
4348
|
+
* shape yields a boolean and never throws, and a malformed condition is
|
|
4349
|
+
* false. These are consensus semantics, versioned by `PHAuthState.version`;
|
|
4350
|
+
* changing them requires a new version.
|
|
4351
|
+
*/
|
|
4352
|
+
function evaluateCondition(condition, subject, request, conditions) {
|
|
4353
|
+
return evaluateNode(condition, subject, request, conditions) === true;
|
|
4354
|
+
}
|
|
4203
4355
|
function capabilityCovers(capability, request) {
|
|
4204
4356
|
if (capability.can !== request.verb) return false;
|
|
4205
4357
|
const scope = capability.scope;
|
|
@@ -4210,21 +4362,37 @@ function capabilityCovers(capability, request) {
|
|
|
4210
4362
|
}
|
|
4211
4363
|
return true;
|
|
4212
4364
|
}
|
|
4213
|
-
function principalMatches(principal, subject) {
|
|
4365
|
+
function principalMatches(principal, subject, request, groups, conditions) {
|
|
4214
4366
|
if ("anyone" in principal) return true;
|
|
4215
4367
|
if ("address" in principal) return subject.address !== void 0 && subject.address.toLowerCase() === principal.address.toLowerCase();
|
|
4368
|
+
if ("group" in principal) {
|
|
4369
|
+
if (groups === void 0 || subject.address === void 0) return false;
|
|
4370
|
+
const group = groups[principal.group];
|
|
4371
|
+
if (group === void 0 || !Array.isArray(group.members)) return false;
|
|
4372
|
+
const address = subject.address.toLowerCase();
|
|
4373
|
+
return group.members.some((member) => member.toLowerCase() === address);
|
|
4374
|
+
}
|
|
4375
|
+
if ("match" in principal) {
|
|
4376
|
+
if (conditions === void 0) return false;
|
|
4377
|
+
return evaluateCondition(principal.match, subject, request, conditions);
|
|
4378
|
+
}
|
|
4216
4379
|
return false;
|
|
4217
4380
|
}
|
|
4218
4381
|
/**
|
|
4219
4382
|
* Evaluates a v1 grant stack: default deny, last applicable grant wins, and
|
|
4220
|
-
* reports which grant decided it. Group
|
|
4221
|
-
*
|
|
4383
|
+
* reports which grant decided it. Group principals match only against a
|
|
4384
|
+
* supplied groups map, and `where` clauses and { match } principals evaluate
|
|
4385
|
+
* only against a supplied condition context; a grant that uses an unsupplied
|
|
4386
|
+
* feature never applies.
|
|
4222
4387
|
*/
|
|
4223
|
-
function evaluateGrantStack(grants, subject, request) {
|
|
4388
|
+
function evaluateGrantStack(grants, subject, request, groups, conditions) {
|
|
4224
4389
|
let applicable;
|
|
4225
4390
|
for (const grant of grants) {
|
|
4226
|
-
if (grant.where !== void 0)
|
|
4227
|
-
|
|
4391
|
+
if (grant.where !== void 0) {
|
|
4392
|
+
if (conditions === void 0) continue;
|
|
4393
|
+
if (!evaluateCondition(grant.where, subject, request, conditions)) continue;
|
|
4394
|
+
}
|
|
4395
|
+
if (capabilityCovers(grant.capability, request) && principalMatches(grant.principal, subject, request, groups, conditions)) applicable = grant;
|
|
4228
4396
|
}
|
|
4229
4397
|
if (applicable === void 0) return {
|
|
4230
4398
|
decision: "deny",
|
|
@@ -8122,6 +8290,6 @@ const driveDocumentModelModule = {
|
|
|
8122
8290
|
}
|
|
8123
8291
|
};
|
|
8124
8292
|
//#endregion
|
|
8125
|
-
export {
|
|
8293
|
+
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 };
|
|
8126
8294
|
|
|
8127
|
-
//# sourceMappingURL=document-drive-
|
|
8295
|
+
//# sourceMappingURL=document-drive-PYPIaEvw.js.map
|