@tinycloud/node-sdk 3.8.0-beta.14 → 3.8.0-beta.16

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/index.js CHANGED
@@ -18738,10 +18738,12 @@ import {
18738
18738
  ENCRYPTION_PERMISSION_SERVICE as ENCRYPTION_PERMISSION_SERVICE2,
18739
18739
  CaveatedDelegationUnsupportedError as CaveatedDelegationUnsupportedError2,
18740
18740
  PermissionNotInManifestError,
18741
+ ManifestValidationError as ManifestValidationError2,
18741
18742
  SessionExpiredError,
18742
18743
  canonicalizeRecapCaveats as canonicalizeRecapCaveats2,
18743
18744
  recapCaveatsEqual as recapCaveatsEqual2,
18744
18745
  expandPermissionEntries as expandPermissionEntriesCore,
18746
+ expandDelegationPermissionEntries,
18745
18747
  isCapabilitySubset as isCapabilitySubset2,
18746
18748
  isExplicitOnlyAction,
18747
18749
  parseRecapCapabilities,
@@ -19611,7 +19613,8 @@ var NodeUserAuthorization = class {
19611
19613
  return true;
19612
19614
  }
19613
19615
  const parsed = entry.path.includes("/") ? parseEncryptionResource(entry.path) : { ...parseNetworkId(entry.path), kind: "network" };
19614
- if (parsed.kind !== "network") {
19616
+ const sharePrefix = parsed.kind === "prefix" && parsed.network === "default" && parsed.prefix === "share" && entry.actions.length === 1 && entry.actions[0] === DECRYPT_ACTION && didPrincipalMatches(parsed.ownerDid, currentDid);
19617
+ if (parsed.kind !== "network" && !sharePrefix) {
19615
19618
  throw new ManifestValidationError("named keys go in manifest.keys");
19616
19619
  }
19617
19620
  for (const action of entry.actions) {
@@ -25141,7 +25144,7 @@ var _TinyCloudNode = class _TinyCloudNode {
25141
25144
  graph.assertActive();
25142
25145
  const signed2 = await this.signRawNetworkAuthorization({
25143
25146
  targetNode: input.targetNode,
25144
- networkId: input.networkId,
25147
+ networkId: input.body.keyPath === void 0 ? input.networkId : `${input.networkId}/${input.body.keyPath}`,
25145
25148
  action: DECRYPT_ACTION2,
25146
25149
  facts: input.facts
25147
25150
  }, { graph, session });
@@ -26731,7 +26734,19 @@ var _TinyCloudNode = class _TinyCloudNode {
26731
26734
  "delegateTo requires a non-empty permissions array"
26732
26735
  );
26733
26736
  }
26734
- const expandedEntries = this.expandPermissionEntries(permissions);
26737
+ const expandedEntries = expandDelegationPermissionEntries(permissions);
26738
+ const namedKeyEntries = expandedEntries.filter((entry) => entry.service === ENCRYPTION_PERMISSION_SERVICE2 && entry.path.includes("/"));
26739
+ if (namedKeyEntries.length > 0) {
26740
+ if (expandedEntries.some((entry) => entry.service === ENCRYPTION_PERMISSION_SERVICE2 && !entry.path.includes("/"))) {
26741
+ throw new ManifestValidationError2("named-key delegation cannot include bare-network permissions");
26742
+ }
26743
+ if (options?.forceWalletSign) {
26744
+ throw new ManifestValidationError2("named-key delegation requires a signed session grant");
26745
+ }
26746
+ const granted = this.projectSignedRecapCapabilities(session.siwe);
26747
+ const { subset, missing } = this.signedCapabilitySubset(namedKeyEntries, granted);
26748
+ if (!subset) throw new PermissionNotInManifestError(missing, granted);
26749
+ }
26735
26750
  const now = /* @__PURE__ */ new Date();
26736
26751
  const expiryMs = resolveExpiryMs(options?.expiry);
26737
26752
  const expirationTime = new Date(now.getTime() + expiryMs);
@@ -28334,7 +28349,7 @@ import {
28334
28349
  CaveatedDelegationUnsupportedError as CaveatedDelegationUnsupportedError3,
28335
28350
  PermissionNotInManifestError as PermissionNotInManifestError2,
28336
28351
  SessionExpiredError as SessionExpiredError2,
28337
- ManifestValidationError as ManifestValidationError2,
28352
+ ManifestValidationError as ManifestValidationError3,
28338
28353
  composeManifestRequest as composeManifestRequest2,
28339
28354
  resolveManifest as resolveManifest2,
28340
28355
  validateManifest,
@@ -30999,7 +31014,7 @@ export {
30999
31014
  InvalidRestoredSessionError,
31000
31015
  KVService4 as KVService,
31001
31016
  MAX_SECRET_SCOPE_LENGTH,
31002
- ManifestValidationError2 as ManifestValidationError,
31017
+ ManifestValidationError3 as ManifestValidationError,
31003
31018
  MemorySessionStorage,
31004
31019
  NETWORK_NAME_PATTERN,
31005
31020
  NetworkIdError,