@tinycloud/node-sdk 3.2.0-beta.5 → 3.2.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/{WasmKeyProvider-D2gBxuiY.d.cts → WasmKeyProvider-C3NFgOmv.d.cts} +18 -4
- package/dist/{WasmKeyProvider-D2gBxuiY.d.ts → WasmKeyProvider-C3NFgOmv.d.ts} +18 -4
- package/dist/core.cjs +12 -8
- 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 +12 -8
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +34 -8
- 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 +33 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -17663,6 +17663,7 @@ __export(src_exports, {
|
|
|
17663
17663
|
resourceCapabilitiesToSpaceAbilitiesMap: () => import_sdk_core16.resourceCapabilitiesToSpaceAbilitiesMap,
|
|
17664
17664
|
serializeDelegation: () => serializeDelegation,
|
|
17665
17665
|
signedCompactUcanExpiry: () => signedCompactUcanExpiry,
|
|
17666
|
+
siweRuntimeDelegation: () => siweRuntimeDelegation,
|
|
17666
17667
|
sqliteReplicaStorage: () => sqliteReplicaStorage,
|
|
17667
17668
|
tinyCloudDebugLogger: () => import_sdk_core15.tinyCloudDebugLogger,
|
|
17668
17669
|
validateEnvelope: () => import_sdk_core21.validateEnvelope,
|
|
@@ -18233,18 +18234,45 @@ async function activateCompactRuntimeDelegation(node, input) {
|
|
|
18233
18234
|
throw new Error("Compact runtime delegation CID does not match authorization bytes.");
|
|
18234
18235
|
}
|
|
18235
18236
|
const signed2 = signedAuthorityFromCompactUcan(authorization);
|
|
18237
|
+
return activateValidatedRuntimeDelegation(
|
|
18238
|
+
node,
|
|
18239
|
+
portableFromSignedAuthority(cid, authorization, signed2, input),
|
|
18240
|
+
{ host: input.host }
|
|
18241
|
+
);
|
|
18242
|
+
}
|
|
18243
|
+
function siweRuntimeDelegation(node, input) {
|
|
18244
|
+
const cid = node.computeDelegationCid(input.authorization);
|
|
18245
|
+
if (cid !== input.cid) {
|
|
18246
|
+
throw new Error("SIWE runtime delegation CID does not match authorization bytes.");
|
|
18247
|
+
}
|
|
18248
|
+
const proof = { siwe: input.siwe, signature: input.signature };
|
|
18249
|
+
const signed2 = signedAuthorityFromSessionGrant(
|
|
18250
|
+
node,
|
|
18251
|
+
{ siweProof: proof, spaceId: input.spaceId, ownerAddress: input.ownerAddress, chainId: input.chainId },
|
|
18252
|
+
input.authorization,
|
|
18253
|
+
cid
|
|
18254
|
+
);
|
|
18255
|
+
if (signed2.expiry.getTime() <= Date.now()) {
|
|
18256
|
+
reject("expired", "Runtime delegation is expired.");
|
|
18257
|
+
}
|
|
18258
|
+
return {
|
|
18259
|
+
...portableFromSignedAuthority(cid, input.authorization, signed2, input),
|
|
18260
|
+
siweProof: proof
|
|
18261
|
+
};
|
|
18262
|
+
}
|
|
18263
|
+
function portableFromSignedAuthority(cid, authorization, signed2, transport) {
|
|
18236
18264
|
const primary = signed2.resources[0];
|
|
18237
18265
|
const signedSpace = signed2.permissions.find(
|
|
18238
18266
|
(permission) => permission.service !== "tinycloud.encryption"
|
|
18239
18267
|
)?.space;
|
|
18240
|
-
|
|
18268
|
+
return {
|
|
18241
18269
|
cid,
|
|
18242
18270
|
delegationHeader: { Authorization: authorization },
|
|
18243
|
-
ownerAddress:
|
|
18244
|
-
chainId:
|
|
18271
|
+
ownerAddress: transport.ownerAddress,
|
|
18272
|
+
chainId: transport.chainId,
|
|
18245
18273
|
delegatorDID: signed2.issuer,
|
|
18246
18274
|
authHeader: authorization,
|
|
18247
|
-
spaceId: signedSpace ?? primary.space,
|
|
18275
|
+
spaceId: signedSpace ?? transport.spaceId ?? primary.space,
|
|
18248
18276
|
path: primary.path,
|
|
18249
18277
|
actions: [...primary.actions],
|
|
18250
18278
|
...primary.caveats === void 0 ? {} : { caveats: primary.caveats },
|
|
@@ -18254,11 +18282,8 @@ async function activateCompactRuntimeDelegation(node, input) {
|
|
|
18254
18282
|
})),
|
|
18255
18283
|
expiry: new Date(signed2.expiry),
|
|
18256
18284
|
delegateDID: signed2.audience,
|
|
18257
|
-
host: normalizedHost(
|
|
18285
|
+
host: normalizedHost(transport.host)
|
|
18258
18286
|
};
|
|
18259
|
-
return activateValidatedRuntimeDelegation(node, delegation, {
|
|
18260
|
-
host: input.host
|
|
18261
|
-
});
|
|
18262
18287
|
}
|
|
18263
18288
|
async function grantAuthRequest(authority, request, options) {
|
|
18264
18289
|
if (request.kind !== "tinycloud.auth.request") {
|
|
@@ -27424,6 +27449,7 @@ function sqliteReplicaStorage(options) {
|
|
|
27424
27449
|
resourceCapabilitiesToSpaceAbilitiesMap,
|
|
27425
27450
|
serializeDelegation,
|
|
27426
27451
|
signedCompactUcanExpiry,
|
|
27452
|
+
siweRuntimeDelegation,
|
|
27427
27453
|
sqliteReplicaStorage,
|
|
27428
27454
|
tinyCloudDebugLogger,
|
|
27429
27455
|
validateEnvelope,
|