@tinycloud/node-sdk 3.2.0-beta.8 → 3.2.0-beta.9
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/{WasmKeyProvider-DlfIZM_l.d.cts → WasmKeyProvider-6_YwgSkd.d.cts} +9 -0
- package/dist/{WasmKeyProvider-DlfIZM_l.d.ts → WasmKeyProvider-6_YwgSkd.d.ts} +9 -0
- package/dist/core.cjs +35 -5
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +35 -5
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +35 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +35 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -2583,6 +2583,15 @@ declare class TinyCloudNode {
|
|
|
2583
2583
|
*/
|
|
2584
2584
|
private buildActivationAbilities;
|
|
2585
2585
|
private selectInvocationSession;
|
|
2586
|
+
/**
|
|
2587
|
+
* A non-primary grant's session, aimed at `spaceId`. The grant's delegation
|
|
2588
|
+
* may span spaces (the widened default bootstrap session also carries
|
|
2589
|
+
* account-space entries, TC-957); its session's own `spaceId` is the space
|
|
2590
|
+
* it was minted for, so an op on another covered space must keep the grant's
|
|
2591
|
+
* key and proof but target that space. A grant on the target space itself is
|
|
2592
|
+
* returned unchanged, keeping its own spelling of the space id.
|
|
2593
|
+
*/
|
|
2594
|
+
private grantSessionForSpace;
|
|
2586
2595
|
private findGrantForOperations;
|
|
2587
2596
|
private findGrantForOperation;
|
|
2588
2597
|
private pruneExpiredRuntimePermissionGrants;
|
|
@@ -2583,6 +2583,15 @@ declare class TinyCloudNode {
|
|
|
2583
2583
|
*/
|
|
2584
2584
|
private buildActivationAbilities;
|
|
2585
2585
|
private selectInvocationSession;
|
|
2586
|
+
/**
|
|
2587
|
+
* A non-primary grant's session, aimed at `spaceId`. The grant's delegation
|
|
2588
|
+
* may span spaces (the widened default bootstrap session also carries
|
|
2589
|
+
* account-space entries, TC-957); its session's own `spaceId` is the space
|
|
2590
|
+
* it was minted for, so an op on another covered space must keep the grant's
|
|
2591
|
+
* key and proof but target that space. A grant on the target space itself is
|
|
2592
|
+
* returned unchanged, keeping its own spelling of the space id.
|
|
2593
|
+
*/
|
|
2594
|
+
private grantSessionForSpace;
|
|
2586
2595
|
private findGrantForOperations;
|
|
2587
2596
|
private findGrantForOperation;
|
|
2588
2597
|
private pruneExpiredRuntimePermissionGrants;
|
package/dist/core.cjs
CHANGED
|
@@ -397,6 +397,10 @@ var import_sdk_core3 = require("@tinycloud/sdk-core");
|
|
|
397
397
|
var defaultSignStrategy = { type: "auto-sign" };
|
|
398
398
|
|
|
399
399
|
// src/authorization/NodeUserAuthorization.ts
|
|
400
|
+
function pkhSpaceIdentity(spaceId) {
|
|
401
|
+
const match = /^(tinycloud:pkh:eip155:\d+:)(0x[0-9a-fA-F]{40})(:.+)$/.exec(spaceId);
|
|
402
|
+
return match === null ? spaceId : `${match[1]}${match[2].toLowerCase()}${match[3]}`;
|
|
403
|
+
}
|
|
400
404
|
var DECRYPT_ACTION = import_sdk_core4.ENCRYPTION.DECRYPT;
|
|
401
405
|
var NETWORK_CREATE_ACTION = import_sdk_core4.ENCRYPTION.NETWORK_CREATE;
|
|
402
406
|
function describeHostFailure(result) {
|
|
@@ -1195,11 +1199,26 @@ var NodeUserAuthorization = class {
|
|
|
1195
1199
|
const jwk = JSON.parse(jwkString);
|
|
1196
1200
|
const now = /* @__PURE__ */ new Date();
|
|
1197
1201
|
const expirationTime = new Date(now.getTime() + this.sessionExpirationMs);
|
|
1198
|
-
const
|
|
1199
|
-
|
|
1200
|
-
)
|
|
1202
|
+
const primaryIdentity = pkhSpaceIdentity(options.spaceId);
|
|
1203
|
+
const resourcesBySpace = /* @__PURE__ */ new Map();
|
|
1204
|
+
for (const resource of options.capabilityRequest.resources) {
|
|
1205
|
+
const resolved = this.resolveSpaceName(resource.space, address, chainId);
|
|
1206
|
+
const identity = pkhSpaceIdentity(resolved);
|
|
1207
|
+
const group = resourcesBySpace.get(identity) ?? {
|
|
1208
|
+
spaceId: identity === primaryIdentity ? options.spaceId : resolved,
|
|
1209
|
+
resources: []
|
|
1210
|
+
};
|
|
1211
|
+
group.resources.push(resource);
|
|
1212
|
+
resourcesBySpace.set(identity, group);
|
|
1213
|
+
}
|
|
1214
|
+
const spaceAbilities = {};
|
|
1215
|
+
for (const { spaceId, resources } of resourcesBySpace.values()) {
|
|
1216
|
+
spaceAbilities[spaceId] = (0, import_sdk_core4.resourceCapabilitiesToAbilitiesMap)(resources);
|
|
1217
|
+
}
|
|
1218
|
+
const abilities = spaceAbilities[options.spaceId] ?? (0, import_sdk_core4.resourceCapabilitiesToAbilitiesMap)([]);
|
|
1201
1219
|
const prepared = this.wasm.prepareSession({
|
|
1202
1220
|
abilities,
|
|
1221
|
+
spaceAbilities,
|
|
1203
1222
|
...options.rawAbilities !== void 0 ? { rawAbilities: options.rawAbilities } : {},
|
|
1204
1223
|
address,
|
|
1205
1224
|
chainId,
|
|
@@ -3456,7 +3475,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3456
3475
|
const grantedOperation = grant?.operations.find(
|
|
3457
3476
|
(candidate) => this.operationCovers(candidate, operation)
|
|
3458
3477
|
);
|
|
3459
|
-
const invocationSession = !grant || grant.provenance === "primary" ? session : grant.
|
|
3478
|
+
const invocationSession = !grant || grant.provenance === "primary" ? session : this.grantSessionForSpace(grant, session.spaceId);
|
|
3460
3479
|
if ((grantedOperation?.caveats?.length ?? 0) > 0) {
|
|
3461
3480
|
if (!this.wasmBindings.invokeAny) {
|
|
3462
3481
|
throw new Error("WASM binding does not support caveat-preserving invocation");
|
|
@@ -8372,7 +8391,18 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8372
8391
|
if (!grant) {
|
|
8373
8392
|
return fallback;
|
|
8374
8393
|
}
|
|
8375
|
-
return grant.provenance === "primary" ? fallback : grant.
|
|
8394
|
+
return grant.provenance === "primary" ? fallback : this.grantSessionForSpace(grant, fallback.spaceId);
|
|
8395
|
+
}
|
|
8396
|
+
/**
|
|
8397
|
+
* A non-primary grant's session, aimed at `spaceId`. The grant's delegation
|
|
8398
|
+
* may span spaces (the widened default bootstrap session also carries
|
|
8399
|
+
* account-space entries, TC-957); its session's own `spaceId` is the space
|
|
8400
|
+
* it was minted for, so an op on another covered space must keep the grant's
|
|
8401
|
+
* key and proof but target that space. A grant on the target space itself is
|
|
8402
|
+
* returned unchanged, keeping its own spelling of the space id.
|
|
8403
|
+
*/
|
|
8404
|
+
grantSessionForSpace(grant, spaceId) {
|
|
8405
|
+
return this.spaceIdsEqual(grant.session.spaceId, spaceId) ? grant.session : { ...grant.session, spaceId };
|
|
8376
8406
|
}
|
|
8377
8407
|
findGrantForOperations(operations, options) {
|
|
8378
8408
|
if (operations.length === 0) {
|