@tinycloud/node-sdk 3.3.0-beta.22 → 3.3.0-beta.24
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-BPDOmuf6.d.cts → TinyCloudNode-Cm8kblSj.d.cts} +11 -41
- package/dist/{TinyCloudNode-BPDOmuf6.d.ts → TinyCloudNode-Cm8kblSj.d.ts} +11 -41
- package/dist/{authority-C-pzOYXq.d.ts → authority-CPSGMw2l.d.ts} +1 -1
- package/dist/{authority-21H2cKmO.d.cts → authority-S-huUKlr.d.cts} +1 -1
- package/dist/core.cjs +22 -63
- 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 +26 -66
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +22 -63
- 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 +26 -66
- 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
|
@@ -21154,6 +21154,12 @@ function describeHostFailure2(result) {
|
|
|
21154
21154
|
const text = result.error?.trim();
|
|
21155
21155
|
return text ? `${result.status} - ${text}` : `${result.status}`;
|
|
21156
21156
|
}
|
|
21157
|
+
function assertDelegationActivated(result, delegation, requireActivation) {
|
|
21158
|
+
const skipped = requireActivation ? (delegation.resources?.map((r2) => r2.space) ?? [delegation.spaceId]).filter((space) => result.skipped?.includes(space)) : [];
|
|
21159
|
+
if (result.success && skipped.length === 0) return;
|
|
21160
|
+
const detail = result.success ? `the node skipped ${[...new Set(skipped)].join(", ")} (space not hosted on the node)` : describeHostFailure2(result);
|
|
21161
|
+
throw Object.assign(new Error(`Failed to activate delegation with host: ${detail}`), { cause: result });
|
|
21162
|
+
}
|
|
21157
21163
|
function ownerDelegationPermissions(params) {
|
|
21158
21164
|
const hasPermissions = Object.prototype.hasOwnProperty.call(params, "permissions");
|
|
21159
21165
|
const hasLegacy = Object.prototype.hasOwnProperty.call(params, "path") || Object.prototype.hasOwnProperty.call(params, "actions");
|
|
@@ -21787,7 +21793,6 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21787
21793
|
if (!this.wasmBindings.computeCid) throw new Error("computeCid is unavailable");
|
|
21788
21794
|
return this.wasmBindings.computeCid(data, codec);
|
|
21789
21795
|
},
|
|
21790
|
-
// delegationManager: undefined - not needed for receive()
|
|
21791
21796
|
createKVService: (config) => {
|
|
21792
21797
|
const prefix = config.pathPrefix?.replace(/\/$/, "");
|
|
21793
21798
|
const kvService = new import_sdk_core9.KVService({ prefix });
|
|
@@ -22906,6 +22911,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22906
22911
|
return;
|
|
22907
22912
|
}
|
|
22908
22913
|
if (!this.currentSessionCoversAccountRegistry()) {
|
|
22914
|
+
if (!_TinyCloudNode.accountRegistrySkipLogged) {
|
|
22915
|
+
_TinyCloudNode.accountRegistrySkipLogged = true;
|
|
22916
|
+
import_sdk_services2.tinyCloudDebugLogger.log("registry.skip");
|
|
22917
|
+
}
|
|
22909
22918
|
return;
|
|
22910
22919
|
}
|
|
22911
22920
|
const controller = new AbortController();
|
|
@@ -23871,7 +23880,6 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23871
23880
|
});
|
|
23872
23881
|
sharingService.updateConfig({
|
|
23873
23882
|
session: input.serviceSession,
|
|
23874
|
-
delegationManager,
|
|
23875
23883
|
sessionExpiry: input.sessionExpiry,
|
|
23876
23884
|
createDelegationWasm: (params) => {
|
|
23877
23885
|
graph.assertActive();
|
|
@@ -24811,7 +24819,6 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24811
24819
|
assertActive: () => graph.assertActive(),
|
|
24812
24820
|
keyProvider: this._keyProvider,
|
|
24813
24821
|
registry: this._capabilityRegistry,
|
|
24814
|
-
delegationManager: this._delegationManager,
|
|
24815
24822
|
sessionExpiry: this.getSessionExpiry(),
|
|
24816
24823
|
createDelegationWasm: (params) => {
|
|
24817
24824
|
graph.assertActive();
|
|
@@ -25794,16 +25801,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25794
25801
|
* ```typescript
|
|
25795
25802
|
* const delegations = alice.delegationManager;
|
|
25796
25803
|
*
|
|
25797
|
-
* //
|
|
25798
|
-
* const
|
|
25799
|
-
* delegateDID: bob.did,
|
|
25800
|
-
* path: "shared/",
|
|
25801
|
-
* actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
|
|
25802
|
-
* expiry: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours
|
|
25803
|
-
* });
|
|
25804
|
-
*
|
|
25805
|
-
* // List delegations
|
|
25806
|
-
* const listResult = await delegations.list();
|
|
25804
|
+
* // Query account delegations
|
|
25805
|
+
* const page = await delegations.query();
|
|
25807
25806
|
*
|
|
25808
25807
|
* // Revoke a delegation
|
|
25809
25808
|
* await delegations.revoke(delegationCid);
|
|
@@ -26004,32 +26003,6 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26004
26003
|
// ===========================================================================
|
|
26005
26004
|
// v2 Delegation Convenience Methods
|
|
26006
26005
|
// ===========================================================================
|
|
26007
|
-
/**
|
|
26008
|
-
* Create a delegation using the v2 DelegationManager.
|
|
26009
|
-
*
|
|
26010
|
-
* This is a convenience method that wraps DelegationManager.create().
|
|
26011
|
-
* For more control, use `this.delegationManager` directly.
|
|
26012
|
-
*
|
|
26013
|
-
* @param params - Delegation parameters
|
|
26014
|
-
* @returns Result containing the created Delegation
|
|
26015
|
-
*
|
|
26016
|
-
* @example
|
|
26017
|
-
* ```typescript
|
|
26018
|
-
* const result = await alice.delegate({
|
|
26019
|
-
* delegateDID: bob.did,
|
|
26020
|
-
* path: "shared/",
|
|
26021
|
-
* actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
|
|
26022
|
-
* expiry: new Date(Date.now() + 24 * 60 * 60 * 1000),
|
|
26023
|
-
* });
|
|
26024
|
-
*
|
|
26025
|
-
* if (result.ok) {
|
|
26026
|
-
* console.log("Delegation created:", result.data.cid);
|
|
26027
|
-
* }
|
|
26028
|
-
* ```
|
|
26029
|
-
*/
|
|
26030
|
-
async delegate(params) {
|
|
26031
|
-
return this.delegationManager.create(params);
|
|
26032
|
-
}
|
|
26033
26006
|
/**
|
|
26034
26007
|
* Revoke a delegation with the owner wallet when available. Session-only
|
|
26035
26008
|
* clients continue to use their delegated revocation authority.
|
|
@@ -26055,14 +26028,6 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26055
26028
|
0x55n
|
|
26056
26029
|
);
|
|
26057
26030
|
}
|
|
26058
|
-
/**
|
|
26059
|
-
* List all delegations for the current session's space.
|
|
26060
|
-
*
|
|
26061
|
-
* @returns Result containing an array of Delegations
|
|
26062
|
-
*/
|
|
26063
|
-
async listDelegations() {
|
|
26064
|
-
return this.delegationManager.list();
|
|
26065
|
-
}
|
|
26066
26031
|
/**
|
|
26067
26032
|
* Check if the current session has permission for a path and action.
|
|
26068
26033
|
*
|
|
@@ -26190,7 +26155,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26190
26155
|
plan.grant,
|
|
26191
26156
|
plan.operations,
|
|
26192
26157
|
onPrepared,
|
|
26193
|
-
options?.disableSubDelegation === true
|
|
26158
|
+
options?.disableSubDelegation === true,
|
|
26159
|
+
options?.requireActivation === true
|
|
26194
26160
|
);
|
|
26195
26161
|
return { delegation: delegation2, prompted: false };
|
|
26196
26162
|
}
|
|
@@ -26200,7 +26166,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26200
26166
|
effectiveExpiration,
|
|
26201
26167
|
session,
|
|
26202
26168
|
onPrepared,
|
|
26203
|
-
options?.disableSubDelegation === true
|
|
26169
|
+
options?.disableSubDelegation === true,
|
|
26170
|
+
options?.requireActivation === true
|
|
26204
26171
|
);
|
|
26205
26172
|
return { delegation, prompted: false };
|
|
26206
26173
|
}
|
|
@@ -26431,7 +26398,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26431
26398
|
*
|
|
26432
26399
|
* @internal
|
|
26433
26400
|
*/
|
|
26434
|
-
async createDelegationViaWasmPath(did, entries, expirationTime, session, onPrepared, disableSubDelegation = false) {
|
|
26401
|
+
async createDelegationViaWasmPath(did, entries, expirationTime, session, onPrepared, disableSubDelegation = false, requireActivation = false) {
|
|
26435
26402
|
if (entries.length === 0) {
|
|
26436
26403
|
throw new Error(
|
|
26437
26404
|
"createDelegationViaWasmPath requires a non-empty entries array"
|
|
@@ -26515,15 +26482,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26515
26482
|
this.config.host,
|
|
26516
26483
|
delegationHeader
|
|
26517
26484
|
);
|
|
26518
|
-
|
|
26519
|
-
throw Object.assign(
|
|
26520
|
-
new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
|
|
26521
|
-
{ cause: activateResult }
|
|
26522
|
-
);
|
|
26523
|
-
}
|
|
26485
|
+
assertDelegationActivated(activateResult, delegation, requireActivation);
|
|
26524
26486
|
return delegation;
|
|
26525
26487
|
}
|
|
26526
|
-
async createDelegationViaRuntimeGrant(did, entries, expirationTime, grant, requestedOperations, onPrepared, disableSubDelegation = false) {
|
|
26488
|
+
async createDelegationViaRuntimeGrant(did, entries, expirationTime, grant, requestedOperations, onPrepared, disableSubDelegation = false, requireActivation = false) {
|
|
26527
26489
|
this.assertRuntimeGrantCaveatsPreservable(entries, requestedOperations, grant);
|
|
26528
26490
|
this.assertDelegationCaveatsPreservable(entries);
|
|
26529
26491
|
const result = this.createDelegationWrapper({
|
|
@@ -26557,12 +26519,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26557
26519
|
targetHost,
|
|
26558
26520
|
delegationHeader
|
|
26559
26521
|
);
|
|
26560
|
-
|
|
26561
|
-
throw Object.assign(
|
|
26562
|
-
new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
|
|
26563
|
-
{ cause: activateResult }
|
|
26564
|
-
);
|
|
26565
|
-
}
|
|
26522
|
+
assertDelegationActivated(activateResult, delegation, requireActivation);
|
|
26566
26523
|
return delegation;
|
|
26567
26524
|
}
|
|
26568
26525
|
resolvePermissionSpace(space, session) {
|
|
@@ -27509,6 +27466,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27509
27466
|
};
|
|
27510
27467
|
}
|
|
27511
27468
|
};
|
|
27469
|
+
/** Set once per process: the registry sync was skipped for want of account access. */
|
|
27470
|
+
_TinyCloudNode.accountRegistrySkipLogged = false;
|
|
27512
27471
|
// ===========================================================================
|
|
27513
27472
|
// Capability-chain delegation (spec: .claude/specs/capability-chain.md)
|
|
27514
27473
|
// ===========================================================================
|