@tinycloud/node-sdk 3.3.0-beta.7 → 3.3.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/{TinyCloudNode-BchWB_zv.d.cts → TinyCloudNode-CcNh20QX.d.cts} +19 -3
- package/dist/{TinyCloudNode-BchWB_zv.d.ts → TinyCloudNode-CcNh20QX.d.ts} +19 -3
- package/dist/{authority-lrA-698X.d.cts → authority-Cwotwza3.d.cts} +1 -1
- package/dist/{authority-4HXYteKF.d.ts → authority-D_u9a7Wl.d.ts} +1 -1
- package/dist/core.cjs +32 -21
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +33 -21
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +32 -21
- 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 -21
- package/dist/index.js.map +1 -1
- package/dist/replication/authority.d.cts +2 -2
- package/dist/replication/authority.d.ts +2 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -21175,6 +21175,7 @@ function ownerPermissionsToAbilities(permissions) {
|
|
|
21175
21175
|
}
|
|
21176
21176
|
return { abilities, rawAbilities };
|
|
21177
21177
|
}
|
|
21178
|
+
var TERMINAL_DELEGATION_REQUIRES_SESSION_KEY = "disableSubDelegation requires a session-key delegation";
|
|
21178
21179
|
function base64UrlEncode(bytes) {
|
|
21179
21180
|
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
21180
21181
|
let output = "";
|
|
@@ -24760,11 +24761,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24760
24761
|
* Both SharingService (single-entry) and
|
|
24761
24762
|
* {@link TinyCloudNode.delegateTo} (multi-entry) drive this through
|
|
24762
24763
|
* the same code path so there's exactly one place that touches the
|
|
24763
|
-
* WASM boundary.
|
|
24764
|
+
* WASM boundary. `terminal` adds the node's terminal marker, which the
|
|
24765
|
+
* WASM builder cannot emit.
|
|
24764
24766
|
*
|
|
24765
24767
|
* @internal
|
|
24766
24768
|
*/
|
|
24767
|
-
createDelegationWrapper(params) {
|
|
24769
|
+
createDelegationWrapper(params, terminal = false) {
|
|
24768
24770
|
const wasmSession = {
|
|
24769
24771
|
delegationHeader: params.session.delegationHeader,
|
|
24770
24772
|
delegationCid: params.session.delegationCid,
|
|
@@ -24784,8 +24786,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24784
24786
|
params.notBeforeSecs
|
|
24785
24787
|
);
|
|
24786
24788
|
return {
|
|
24787
|
-
delegation: result.delegation,
|
|
24788
|
-
cid: result.cid,
|
|
24789
|
+
...terminal ? (0, import_sdk_core9.markDelegationTerminal)(result.delegation, params.session.jwk) : { delegation: result.delegation, cid: result.cid },
|
|
24789
24790
|
// Rust serde `rename_all = "camelCase"` emits `delegateDid`
|
|
24790
24791
|
// (lowercase d); the TypeScript interface uses `delegateDID`
|
|
24791
24792
|
// (historical, matches Delegation.delegateDID). Normalize here.
|
|
@@ -24927,7 +24928,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24927
24928
|
};
|
|
24928
24929
|
const requestBodyDigest = base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode((0, import_sdk_core9.canonicalizeEncryptionJson)(body)))));
|
|
24929
24930
|
const request = { ...body, requestBodyDigest };
|
|
24930
|
-
const authorization = authorizationHeader(this.
|
|
24931
|
+
const authorization = authorizationHeader(this.wasmBindings.invoke(serviceSession, "kv", input.resourcePath, "tinycloud.kv/get"));
|
|
24931
24932
|
const response = await fetch(`${this.config.host}/policy/v3/deliveries/authorize`, {
|
|
24932
24933
|
method: "POST",
|
|
24933
24934
|
headers: { accept: "application/json", "content-type": "application/json", authorization },
|
|
@@ -26034,6 +26035,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26034
26035
|
effectiveExpiration = sessionExpiry;
|
|
26035
26036
|
}
|
|
26036
26037
|
if (options?.forceWalletSign) {
|
|
26038
|
+
if (options.disableSubDelegation) {
|
|
26039
|
+
throw new Error(TERMINAL_DELEGATION_REQUIRES_SESSION_KEY);
|
|
26040
|
+
}
|
|
26037
26041
|
if (expandedEntries.length > 1) {
|
|
26038
26042
|
throw new Error(
|
|
26039
26043
|
"delegateTo with forceWalletSign=true supports at most one PermissionEntry. Multi-entry requests must go through the session-key UCAN path (drop forceWalletSign) or the legacy createDelegation method."
|
|
@@ -26069,7 +26073,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26069
26073
|
plan.effectiveExpiration,
|
|
26070
26074
|
plan.grant,
|
|
26071
26075
|
plan.operations,
|
|
26072
|
-
onPrepared
|
|
26076
|
+
onPrepared,
|
|
26077
|
+
options?.disableSubDelegation === true
|
|
26073
26078
|
);
|
|
26074
26079
|
return { delegation: delegation2, prompted: false };
|
|
26075
26080
|
}
|
|
@@ -26078,7 +26083,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26078
26083
|
expandedEntries,
|
|
26079
26084
|
effectiveExpiration,
|
|
26080
26085
|
session,
|
|
26081
|
-
onPrepared
|
|
26086
|
+
onPrepared,
|
|
26087
|
+
options?.disableSubDelegation === true
|
|
26082
26088
|
);
|
|
26083
26089
|
return { delegation, prompted: false };
|
|
26084
26090
|
}
|
|
@@ -26309,7 +26315,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26309
26315
|
*
|
|
26310
26316
|
* @internal
|
|
26311
26317
|
*/
|
|
26312
|
-
async createDelegationViaWasmPath(did, entries, expirationTime, session, onPrepared) {
|
|
26318
|
+
async createDelegationViaWasmPath(did, entries, expirationTime, session, onPrepared, disableSubDelegation = false) {
|
|
26313
26319
|
if (entries.length === 0) {
|
|
26314
26320
|
throw new Error(
|
|
26315
26321
|
"createDelegationViaWasmPath requires a non-empty entries array"
|
|
@@ -26369,7 +26375,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26369
26375
|
spaceId,
|
|
26370
26376
|
abilities,
|
|
26371
26377
|
expirationSecs
|
|
26372
|
-
});
|
|
26378
|
+
}, disableSubDelegation);
|
|
26373
26379
|
const primary = result.resources[0];
|
|
26374
26380
|
const delegationHeader = { Authorization: result.delegation };
|
|
26375
26381
|
const delegation = {
|
|
@@ -26379,7 +26385,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26379
26385
|
path: primary.path,
|
|
26380
26386
|
actions: primary.actions,
|
|
26381
26387
|
resources: result.resources,
|
|
26382
|
-
disableSubDelegation
|
|
26388
|
+
disableSubDelegation,
|
|
26383
26389
|
expiry: result.expiry,
|
|
26384
26390
|
delegateDID: did,
|
|
26385
26391
|
ownerAddress: session.address,
|
|
@@ -26401,7 +26407,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26401
26407
|
}
|
|
26402
26408
|
return delegation;
|
|
26403
26409
|
}
|
|
26404
|
-
async createDelegationViaRuntimeGrant(did, entries, expirationTime, grant, requestedOperations, onPrepared) {
|
|
26410
|
+
async createDelegationViaRuntimeGrant(did, entries, expirationTime, grant, requestedOperations, onPrepared, disableSubDelegation = false) {
|
|
26405
26411
|
this.assertRuntimeGrantCaveatsPreservable(entries, requestedOperations, grant);
|
|
26406
26412
|
this.assertDelegationCaveatsPreservable(entries);
|
|
26407
26413
|
const result = this.createDelegationWrapper({
|
|
@@ -26410,7 +26416,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26410
26416
|
spaceId: grant.session.spaceId,
|
|
26411
26417
|
abilities: this.permissionsToAbilities(entries),
|
|
26412
26418
|
expirationSecs: Math.floor(expirationTime.getTime() / 1e3)
|
|
26413
|
-
});
|
|
26419
|
+
}, disableSubDelegation);
|
|
26414
26420
|
const primary = result.resources[0];
|
|
26415
26421
|
const delegationHeader = { Authorization: result.delegation };
|
|
26416
26422
|
const targetHost = grant.delegation.host ?? this.config.host;
|
|
@@ -26421,7 +26427,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26421
26427
|
path: primary.path,
|
|
26422
26428
|
actions: primary.actions,
|
|
26423
26429
|
resources: result.resources,
|
|
26424
|
-
disableSubDelegation
|
|
26430
|
+
disableSubDelegation,
|
|
26425
26431
|
expiry: result.expiry,
|
|
26426
26432
|
delegateDID: did,
|
|
26427
26433
|
ownerAddress: grant.delegation.ownerAddress,
|
|
@@ -27005,11 +27011,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27005
27011
|
params.spaceIdOverride
|
|
27006
27012
|
);
|
|
27007
27013
|
try {
|
|
27008
|
-
const result = await this.delegateTo(
|
|
27009
|
-
|
|
27010
|
-
|
|
27011
|
-
|
|
27012
|
-
);
|
|
27014
|
+
const result = await this.delegateTo(resolvedDelegateDID, entries, {
|
|
27015
|
+
...params.expiryMs !== void 0 ? { expiry: params.expiryMs } : {},
|
|
27016
|
+
disableSubDelegation: params.disableSubDelegation
|
|
27017
|
+
});
|
|
27013
27018
|
return result.delegation;
|
|
27014
27019
|
} catch (err2) {
|
|
27015
27020
|
if (err2 instanceof import_sdk_core9.PermissionNotInManifestError) {
|
|
@@ -27030,6 +27035,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27030
27035
|
* @internal
|
|
27031
27036
|
*/
|
|
27032
27037
|
async createDelegationWalletPath(params) {
|
|
27038
|
+
if (params.disableSubDelegation) {
|
|
27039
|
+
throw new Error(TERMINAL_DELEGATION_REQUIRES_SESSION_KEY);
|
|
27040
|
+
}
|
|
27033
27041
|
if (!this.signer) {
|
|
27034
27042
|
throw new Error("Cannot createDelegation() in session-only mode. Requires wallet mode.");
|
|
27035
27043
|
}
|
|
@@ -27085,7 +27093,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27085
27093
|
spaceId: params.spaceIdOverride ?? session.spaceId,
|
|
27086
27094
|
path: params.path,
|
|
27087
27095
|
actions: params.actions,
|
|
27088
|
-
disableSubDelegation:
|
|
27096
|
+
disableSubDelegation: false,
|
|
27089
27097
|
expiry: expirationTime,
|
|
27090
27098
|
delegateDID: params.delegateDID,
|
|
27091
27099
|
ownerAddress: session.address,
|
|
@@ -27128,7 +27136,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27128
27136
|
spaceId: publicSpaceId,
|
|
27129
27137
|
path: "",
|
|
27130
27138
|
actions: [import_sdk_core9.KV.GET, import_sdk_core9.KV.PUT, import_sdk_core9.KV.METADATA],
|
|
27131
|
-
disableSubDelegation:
|
|
27139
|
+
disableSubDelegation: false,
|
|
27132
27140
|
expiry: expirationTime,
|
|
27133
27141
|
delegateDID: params.delegateDID,
|
|
27134
27142
|
ownerAddress: session.address,
|
|
@@ -27295,6 +27303,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27295
27303
|
if (parentDelegation.disableSubDelegation) {
|
|
27296
27304
|
throw new Error("Parent delegation does not allow sub-delegation");
|
|
27297
27305
|
}
|
|
27306
|
+
if (params.disableSubDelegation) {
|
|
27307
|
+
throw new Error(TERMINAL_DELEGATION_REQUIRES_SESSION_KEY);
|
|
27308
|
+
}
|
|
27298
27309
|
const parentResources = parentDelegation.resources ?? [{
|
|
27299
27310
|
service: parentDelegation.actions[0]?.split("/", 1)[0]?.replace(/^tinycloud\./, "") ?? "kv",
|
|
27300
27311
|
space: parentDelegation.spaceId,
|
|
@@ -27367,7 +27378,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27367
27378
|
spaceId: parentDelegation.spaceId,
|
|
27368
27379
|
path: requestedResources[0].path,
|
|
27369
27380
|
actions: requestedResources[0].actions,
|
|
27370
|
-
disableSubDelegation:
|
|
27381
|
+
disableSubDelegation: false,
|
|
27371
27382
|
expiry: actualExpiry,
|
|
27372
27383
|
delegateDID: params.delegateDID,
|
|
27373
27384
|
ownerAddress: parentDelegation.ownerAddress,
|