@tinycloud/sdk-core 3.8.0-beta.14 → 3.8.0-beta.15
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/delegations/index.cjs +2 -0
- package/dist/delegations/index.cjs.map +1 -1
- package/dist/delegations/index.js +2 -0
- package/dist/delegations/index.js.map +1 -1
- package/dist/index.cjs +31 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +31 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -361,6 +361,7 @@ __export(index_exports, {
|
|
|
361
361
|
ensureNetworkUsableForDecrypt: () => import_sdk_services9.ensureNetworkUsableForDecrypt,
|
|
362
362
|
err: () => import_sdk_services9.err,
|
|
363
363
|
expandActionShortNames: () => expandActionShortNames,
|
|
364
|
+
expandDelegationPermissionEntries: () => expandDelegationPermissionEntries,
|
|
364
365
|
expandPermissionEntries: () => expandPermissionEntries,
|
|
365
366
|
expandPermissionEntry: () => expandPermissionEntry,
|
|
366
367
|
extractImmutableSiweFields: () => extractImmutableSiweFields,
|
|
@@ -7769,6 +7770,7 @@ function validateEncodedShareData(data) {
|
|
|
7769
7770
|
var import_ms = __toESM(require("ms"), 1);
|
|
7770
7771
|
var import_bootstrap2 = require("@tinycloud/bootstrap");
|
|
7771
7772
|
var import_sdk_services2 = require("@tinycloud/sdk-services");
|
|
7773
|
+
var import_resource = require("@tinycloud/sdk-services/encryption/resource");
|
|
7772
7774
|
var DEFAULT_KNOWLEDGE_ROOT = "knowledge/index.md";
|
|
7773
7775
|
var ManifestValidationError = class extends Error {
|
|
7774
7776
|
constructor(message) {
|
|
@@ -7945,6 +7947,29 @@ function expandEncryptionPermissionEntry(entry) {
|
|
|
7945
7947
|
function expandPermissionEntries(entries) {
|
|
7946
7948
|
return entries.flatMap(expandPermissionEntry);
|
|
7947
7949
|
}
|
|
7950
|
+
function expandDelegationPermissionEntries(entries) {
|
|
7951
|
+
return entries.flatMap((entry) => {
|
|
7952
|
+
if (entry.service !== ENCRYPTION_PERMISSION_SERVICE || typeof entry.path !== "string" || !entry.path.includes("/")) {
|
|
7953
|
+
return expandPermissionEntry(entry);
|
|
7954
|
+
}
|
|
7955
|
+
let resource;
|
|
7956
|
+
try {
|
|
7957
|
+
resource = (0, import_resource.parseEncryptionResource)(entry.path);
|
|
7958
|
+
} catch {
|
|
7959
|
+
throw new ManifestValidationError("delegation requires a canonical exact named-key resource");
|
|
7960
|
+
}
|
|
7961
|
+
if (resource.kind !== "key" || !Array.isArray(entry.actions) || entry.actions.length === 0 || entry.actions.some((action) => action !== "decrypt" && action !== "tinycloud.encryption/decrypt")) {
|
|
7962
|
+
throw new ManifestValidationError("named-key delegation requires an exact key and decrypt only");
|
|
7963
|
+
}
|
|
7964
|
+
return [{
|
|
7965
|
+
...entry,
|
|
7966
|
+
space: ENCRYPTION_MANIFEST_SPACE,
|
|
7967
|
+
path: `${resource.networkId}/${resource.path}`,
|
|
7968
|
+
actions: ["tinycloud.encryption/decrypt"],
|
|
7969
|
+
skipPrefix: true
|
|
7970
|
+
}];
|
|
7971
|
+
});
|
|
7972
|
+
}
|
|
7948
7973
|
function applyPrefix(prefix, path, skipPrefix) {
|
|
7949
7974
|
if (skipPrefix) {
|
|
7950
7975
|
return path;
|
|
@@ -8590,6 +8615,7 @@ function manifestAbilitiesUnion(resolved) {
|
|
|
8590
8615
|
}
|
|
8591
8616
|
|
|
8592
8617
|
// src/capabilities.ts
|
|
8618
|
+
var import_resource2 = require("@tinycloud/sdk-services/encryption/resource");
|
|
8593
8619
|
var PermissionNotInManifestError = class extends Error {
|
|
8594
8620
|
constructor(missing, granted) {
|
|
8595
8621
|
super(
|
|
@@ -8641,10 +8667,9 @@ function isCapabilitySubset(requested, granted) {
|
|
|
8641
8667
|
const grantedActions = matchingScope.flatMap(
|
|
8642
8668
|
(entry) => expandActionShortNames(entry.service, entry.actions)
|
|
8643
8669
|
);
|
|
8670
|
+
const namedKeyRequest = req.service === "tinycloud.encryption" && req.path.startsWith("urn:tinycloud:encryption:") && req.path.includes("/");
|
|
8644
8671
|
const covered = requestedActions.every(
|
|
8645
|
-
(requestedAction) => grantedActions.some(
|
|
8646
|
-
(grantedAction) => actionContains(grantedAction, requestedAction)
|
|
8647
|
-
)
|
|
8672
|
+
(requestedAction) => grantedActions.some((grantedAction) => namedKeyRequest ? grantedAction === requestedAction : actionContains(grantedAction, requestedAction))
|
|
8648
8673
|
);
|
|
8649
8674
|
if (!covered) {
|
|
8650
8675
|
missing.push(cloneEntry(req));
|
|
@@ -8659,7 +8684,9 @@ function canonicalizeEntryScopeMatches(requested, granted) {
|
|
|
8659
8684
|
if (normalizeSpace(requested.space ?? DEFAULT_MANIFEST_SPACE) !== normalizeSpace(granted.space ?? DEFAULT_MANIFEST_SPACE)) {
|
|
8660
8685
|
return false;
|
|
8661
8686
|
}
|
|
8662
|
-
|
|
8687
|
+
const namedKeyRequest = requested.service === "tinycloud.encryption" && requested.path.startsWith("urn:tinycloud:encryption:") && requested.path.includes("/");
|
|
8688
|
+
const coveredPath = namedKeyRequest ? (0, import_resource2.encryptionResourceContains)(granted.path, requested.path) : pathContains2(granted.path, requested.path);
|
|
8689
|
+
if (!coveredPath) {
|
|
8663
8690
|
return false;
|
|
8664
8691
|
}
|
|
8665
8692
|
if (!recapCaveatsEqual(requested.caveats, granted.caveats)) {
|