@tinycloud/node-sdk 2.4.0-beta.2 → 2.4.0-beta.3

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.
@@ -1538,6 +1538,8 @@ declare class TinyCloudNode {
1538
1538
  private findGrantForOperation;
1539
1539
  private pruneExpiredRuntimePermissionGrants;
1540
1540
  private operationCovers;
1541
+ private spaceIdsEqual;
1542
+ private normalizeSpaceAddress;
1541
1543
  private actionContains;
1542
1544
  private invocationServiceName;
1543
1545
  private isEncryptionNetworkOperation;
@@ -1538,6 +1538,8 @@ declare class TinyCloudNode {
1538
1538
  private findGrantForOperation;
1539
1539
  private pruneExpiredRuntimePermissionGrants;
1540
1540
  private operationCovers;
1541
+ private spaceIdsEqual;
1542
+ private normalizeSpaceAddress;
1541
1543
  private actionContains;
1542
1544
  private invocationServiceName;
1543
1545
  private isEncryptionNetworkOperation;
package/dist/core.cjs CHANGED
@@ -4088,7 +4088,23 @@ var _TinyCloudNode = class _TinyCloudNode {
4088
4088
  if (granted.resource !== void 0 || requested.resource !== void 0) {
4089
4089
  return granted.resource !== void 0 && requested.resource !== void 0 && granted.resource === requested.resource && this.pathContains(granted.path, requested.path);
4090
4090
  }
4091
- return granted.spaceId !== void 0 && requested.spaceId !== void 0 && granted.spaceId === requested.spaceId && this.pathContains(granted.path, requested.path);
4091
+ return granted.spaceId !== void 0 && requested.spaceId !== void 0 && this.spaceIdsEqual(granted.spaceId, requested.spaceId) && this.pathContains(granted.path, requested.path);
4092
+ }
4093
+ // Space IDs are `tinycloud:pkh:eip155:<chain>:<0xADDR>:<name>`. The embedded
4094
+ // EIP-155 address is case-insensitive, but the CLI canonicalizes it to
4095
+ // lowercase when building a space URI while stored runtime delegations keep
4096
+ // the EIP-55 checksummed form — so a byte-for-byte compare spuriously rejects
4097
+ // an otherwise-valid grant. Lowercase ONLY the `eip155:<chain>:0x<addr>`
4098
+ // segment and leave everything else (crucially the case-sensitive space NAME)
4099
+ // byte-exact. Mirrors the CLI's `normalizeSpaceForCompare` (OPENKEY_SCOPE_MISMATCH fix).
4100
+ spaceIdsEqual(a, b) {
4101
+ return this.normalizeSpaceAddress(a) === this.normalizeSpaceAddress(b);
4102
+ }
4103
+ normalizeSpaceAddress(space) {
4104
+ return space.replace(
4105
+ /(eip155:\d+:)(0x[0-9a-fA-F]{40})/,
4106
+ (_match, prefix, addr) => prefix + addr.toLowerCase()
4107
+ );
4092
4108
  }
4093
4109
  actionContains(grantedAction, requestedAction) {
4094
4110
  if (grantedAction === requestedAction) {