@tinycloud/node-sdk 3.6.0-beta.5 → 3.6.0-beta.6

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.cjs CHANGED
@@ -20811,16 +20811,6 @@ function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
20811
20811
  return entries;
20812
20812
  }
20813
20813
  var DEFAULT_DELEGATION_EXPIRY_MS = import_sdk_core7.EXPIRY.SESSION_MS;
20814
- var SHARE_NETWORK_NAME_RE = /^share-[a-z0-9][a-z0-9-]{15,35}$/;
20815
- function grantsCappedDecrypt(path, actions) {
20816
- if (!actions.some((action) => (0, import_sdk_core7.actionContains)(action, import_sdk_core7.ENCRYPTION.DECRYPT))) {
20817
- return false;
20818
- }
20819
- return !((0, import_sdk_core7.isNetworkId)(path) && SHARE_NETWORK_NAME_RE.test((0, import_sdk_core7.parseNetworkId)(path).name));
20820
- }
20821
- function includesDecrypt(entries) {
20822
- return entries.some((entry) => grantsCappedDecrypt(entry.path, entry.actions));
20823
- }
20824
20814
  function resolveExpiryMs(expiry) {
20825
20815
  if (expiry === void 0) {
20826
20816
  return DEFAULT_DELEGATION_EXPIRY_MS;
@@ -21004,8 +20994,7 @@ var NodeSecretsService = class {
21004
20994
  );
21005
20995
  }
21006
20996
  try {
21007
- const grant = action === "get" && this.config.grantGetPermissions !== void 0 ? this.config.grantGetPermissions : this.config.grantPermissions;
21008
- await grant(escalation);
20997
+ await this.config.grantPermissions(escalation);
21009
20998
  return this.restoreUnlockAfterEscalation();
21010
20999
  } catch (error) {
21011
21000
  return this.escalationError(action, target, error);
@@ -21423,8 +21412,6 @@ function ownerPermissionsToAbilities(permissions) {
21423
21412
  return { abilities, rawAbilities };
21424
21413
  }
21425
21414
  var TERMINAL_DELEGATION_REQUIRES_SESSION_KEY = "disableSubDelegation requires a session-key delegation to a did:key (not did:pkh); use the session-key DID or drop the flag";
21426
- var DECRYPT_GRANT_MAX_EXPIRY_MS = 60 * 60 * 1e3;
21427
- var SECRET_GET_GRANT_EXPIRY_MS = 59 * 60 * 1e3;
21428
21415
  function base64UrlEncode(bytes) {
21429
21416
  const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
21430
21417
  let output = "";
@@ -25547,7 +25534,6 @@ var _TinyCloudNode = class _TinyCloudNode {
25547
25534
  getManifest: () => this.manifest,
25548
25535
  hasPermissions: (permissions) => this.hasRuntimePermissions(permissions),
25549
25536
  grantPermissions: (additional) => this.grantRuntimePermissions(additional),
25550
- grantGetPermissions: (additional) => this.grantRuntimePermissions(additional, { expiry: SECRET_GET_GRANT_EXPIRY_MS }),
25551
25537
  uncoveredEntries: (permissions) => permissions.filter((entry) => !this.hasRuntimePermissions([entry])),
25552
25538
  canEscalate: () => this.signer !== void 0 && this.tc !== void 0,
25553
25539
  getEncryptionNetworkId: () => this.getEncryptionNetworkIdForSpace(resolvedSpace),
@@ -25896,13 +25882,6 @@ var _TinyCloudNode = class _TinyCloudNode {
25896
25882
  }
25897
25883
  }
25898
25884
  const expanded = this.expandPermissionEntries(permissions);
25899
- const requestsDecrypt = includesDecrypt(expanded);
25900
- const requestedExpiryMs = requestsDecrypt && options?.expiry === void 0 ? DECRYPT_GRANT_MAX_EXPIRY_MS : resolveExpiryMs(options?.expiry);
25901
- if (requestsDecrypt && requestedExpiryMs > DECRYPT_GRANT_MAX_EXPIRY_MS) {
25902
- throw Object.assign(new Error("decrypt grants last at most one hour"), {
25903
- code: "DECRYPT_EXPIRY_TOO_LONG"
25904
- });
25905
- }
25906
25885
  if (this.sessionCoversPermissionEntries(session, expanded)) {
25907
25886
  return [];
25908
25887
  }
@@ -25933,6 +25912,7 @@ var _TinyCloudNode = class _TinyCloudNode {
25933
25912
  bySpace.set(session.spaceId, []);
25934
25913
  }
25935
25914
  const now = /* @__PURE__ */ new Date();
25915
+ const requestedExpiryMs = resolveExpiryMs(options?.expiry);
25936
25916
  let expiresAt = new Date(now.getTime() + requestedExpiryMs);
25937
25917
  if (sessionExpiry !== void 0 && sessionExpiry < expiresAt) {
25938
25918
  expiresAt = sessionExpiry;