@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.
package/dist/index.cjs CHANGED
@@ -21105,7 +21105,23 @@ var _TinyCloudNode = class _TinyCloudNode {
21105
21105
  if (granted.resource !== void 0 || requested.resource !== void 0) {
21106
21106
  return granted.resource !== void 0 && requested.resource !== void 0 && granted.resource === requested.resource && this.pathContains(granted.path, requested.path);
21107
21107
  }
21108
- return granted.spaceId !== void 0 && requested.spaceId !== void 0 && granted.spaceId === requested.spaceId && this.pathContains(granted.path, requested.path);
21108
+ return granted.spaceId !== void 0 && requested.spaceId !== void 0 && this.spaceIdsEqual(granted.spaceId, requested.spaceId) && this.pathContains(granted.path, requested.path);
21109
+ }
21110
+ // Space IDs are `tinycloud:pkh:eip155:<chain>:<0xADDR>:<name>`. The embedded
21111
+ // EIP-155 address is case-insensitive, but the CLI canonicalizes it to
21112
+ // lowercase when building a space URI while stored runtime delegations keep
21113
+ // the EIP-55 checksummed form — so a byte-for-byte compare spuriously rejects
21114
+ // an otherwise-valid grant. Lowercase ONLY the `eip155:<chain>:0x<addr>`
21115
+ // segment and leave everything else (crucially the case-sensitive space NAME)
21116
+ // byte-exact. Mirrors the CLI's `normalizeSpaceForCompare` (OPENKEY_SCOPE_MISMATCH fix).
21117
+ spaceIdsEqual(a, b) {
21118
+ return this.normalizeSpaceAddress(a) === this.normalizeSpaceAddress(b);
21119
+ }
21120
+ normalizeSpaceAddress(space) {
21121
+ return space.replace(
21122
+ /(eip155:\d+:)(0x[0-9a-fA-F]{40})/,
21123
+ (_match, prefix, addr) => prefix + addr.toLowerCase()
21124
+ );
21109
21125
  }
21110
21126
  actionContains(grantedAction, requestedAction) {
21111
21127
  if (grantedAction === requestedAction) {