@tinycloud/node-sdk 3.2.0-beta.8 → 3.2.0
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 +4 -4
package/dist/index.cjs
CHANGED
|
@@ -18429,6 +18429,10 @@ var MemorySessionStorage = class {
|
|
|
18429
18429
|
};
|
|
18430
18430
|
|
|
18431
18431
|
// src/authorization/NodeUserAuthorization.ts
|
|
18432
|
+
function pkhSpaceIdentity(spaceId) {
|
|
18433
|
+
const match = /^(tinycloud:pkh:eip155:\d+:)(0x[0-9a-fA-F]{40})(:.+)$/.exec(spaceId);
|
|
18434
|
+
return match === null ? spaceId : `${match[1]}${match[2].toLowerCase()}${match[3]}`;
|
|
18435
|
+
}
|
|
18432
18436
|
var DECRYPT_ACTION = import_sdk_core4.ENCRYPTION.DECRYPT;
|
|
18433
18437
|
var NETWORK_CREATE_ACTION = import_sdk_core4.ENCRYPTION.NETWORK_CREATE;
|
|
18434
18438
|
function describeHostFailure(result) {
|
|
@@ -19227,11 +19231,26 @@ var NodeUserAuthorization = class {
|
|
|
19227
19231
|
const jwk = JSON.parse(jwkString);
|
|
19228
19232
|
const now = /* @__PURE__ */ new Date();
|
|
19229
19233
|
const expirationTime = new Date(now.getTime() + this.sessionExpirationMs);
|
|
19230
|
-
const
|
|
19231
|
-
|
|
19232
|
-
)
|
|
19234
|
+
const primaryIdentity = pkhSpaceIdentity(options.spaceId);
|
|
19235
|
+
const resourcesBySpace = /* @__PURE__ */ new Map();
|
|
19236
|
+
for (const resource of options.capabilityRequest.resources) {
|
|
19237
|
+
const resolved = this.resolveSpaceName(resource.space, address, chainId);
|
|
19238
|
+
const identity = pkhSpaceIdentity(resolved);
|
|
19239
|
+
const group = resourcesBySpace.get(identity) ?? {
|
|
19240
|
+
spaceId: identity === primaryIdentity ? options.spaceId : resolved,
|
|
19241
|
+
resources: []
|
|
19242
|
+
};
|
|
19243
|
+
group.resources.push(resource);
|
|
19244
|
+
resourcesBySpace.set(identity, group);
|
|
19245
|
+
}
|
|
19246
|
+
const spaceAbilities = {};
|
|
19247
|
+
for (const { spaceId, resources } of resourcesBySpace.values()) {
|
|
19248
|
+
spaceAbilities[spaceId] = (0, import_sdk_core4.resourceCapabilitiesToAbilitiesMap)(resources);
|
|
19249
|
+
}
|
|
19250
|
+
const abilities = spaceAbilities[options.spaceId] ?? (0, import_sdk_core4.resourceCapabilitiesToAbilitiesMap)([]);
|
|
19233
19251
|
const prepared = this.wasm.prepareSession({
|
|
19234
19252
|
abilities,
|
|
19253
|
+
spaceAbilities,
|
|
19235
19254
|
...options.rawAbilities !== void 0 ? { rawAbilities: options.rawAbilities } : {},
|
|
19236
19255
|
address,
|
|
19237
19256
|
chainId,
|
|
@@ -20966,7 +20985,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20966
20985
|
const grantedOperation = grant?.operations.find(
|
|
20967
20986
|
(candidate) => this.operationCovers(candidate, operation)
|
|
20968
20987
|
);
|
|
20969
|
-
const invocationSession = !grant || grant.provenance === "primary" ? session : grant.
|
|
20988
|
+
const invocationSession = !grant || grant.provenance === "primary" ? session : this.grantSessionForSpace(grant, session.spaceId);
|
|
20970
20989
|
if ((grantedOperation?.caveats?.length ?? 0) > 0) {
|
|
20971
20990
|
if (!this.wasmBindings.invokeAny) {
|
|
20972
20991
|
throw new Error("WASM binding does not support caveat-preserving invocation");
|
|
@@ -25882,7 +25901,18 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25882
25901
|
if (!grant) {
|
|
25883
25902
|
return fallback;
|
|
25884
25903
|
}
|
|
25885
|
-
return grant.provenance === "primary" ? fallback : grant.
|
|
25904
|
+
return grant.provenance === "primary" ? fallback : this.grantSessionForSpace(grant, fallback.spaceId);
|
|
25905
|
+
}
|
|
25906
|
+
/**
|
|
25907
|
+
* A non-primary grant's session, aimed at `spaceId`. The grant's delegation
|
|
25908
|
+
* may span spaces (the widened default bootstrap session also carries
|
|
25909
|
+
* account-space entries, TC-957); its session's own `spaceId` is the space
|
|
25910
|
+
* it was minted for, so an op on another covered space must keep the grant's
|
|
25911
|
+
* key and proof but target that space. A grant on the target space itself is
|
|
25912
|
+
* returned unchanged, keeping its own spelling of the space id.
|
|
25913
|
+
*/
|
|
25914
|
+
grantSessionForSpace(grant, spaceId) {
|
|
25915
|
+
return this.spaceIdsEqual(grant.session.spaceId, spaceId) ? grant.session : { ...grant.session, spaceId };
|
|
25886
25916
|
}
|
|
25887
25917
|
findGrantForOperations(operations, options) {
|
|
25888
25918
|
if (operations.length === 0) {
|