@tinycloud/node-sdk 3.1.0-beta.14 → 3.1.0-beta.15
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/{core-CMDgVfBj.d.cts → core-AEx5vAa8.d.cts} +17 -0
- package/dist/{core-CMDgVfBj.d.ts → core-AEx5vAa8.d.ts} +17 -0
- package/dist/core.cjs +46 -26
- 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 +46 -26
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +46 -26
- 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 +46 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -23461,8 +23461,18 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23461
23461
|
* @throws {@link PermissionNotInManifestError} when any requested
|
|
23462
23462
|
* entry is not a subset of the granted session capabilities and
|
|
23463
23463
|
* `forceWalletSign` is not set.
|
|
23464
|
+
* @throws when `onPrepared` is combined with `forceWalletSign: true`,
|
|
23465
|
+
* before anything is signed.
|
|
23466
|
+
* @throws the `onPrepared` rejection, unchanged, without activating the
|
|
23467
|
+
* delegation.
|
|
23464
23468
|
*/
|
|
23465
23469
|
async delegateTo(did, permissions, options) {
|
|
23470
|
+
const onPrepared = options?.onPrepared;
|
|
23471
|
+
if (onPrepared && options?.forceWalletSign) {
|
|
23472
|
+
throw new Error(
|
|
23473
|
+
"delegateTo: onPrepared cannot be combined with forceWalletSign=true; the wallet-signed path activates the delegation before it could be handed to onPrepared."
|
|
23474
|
+
);
|
|
23475
|
+
}
|
|
23466
23476
|
const session = this.currentTinyCloudSession();
|
|
23467
23477
|
if (!session) {
|
|
23468
23478
|
throw new import_sdk_core7.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
@@ -23521,7 +23531,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23521
23531
|
expandedEntries,
|
|
23522
23532
|
runtimeExpiration,
|
|
23523
23533
|
runtimeGrant,
|
|
23524
|
-
runtimeOperations
|
|
23534
|
+
runtimeOperations,
|
|
23535
|
+
onPrepared
|
|
23525
23536
|
);
|
|
23526
23537
|
return { delegation: delegation2, prompted: false };
|
|
23527
23538
|
}
|
|
@@ -23531,7 +23542,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23531
23542
|
did,
|
|
23532
23543
|
expandedEntries,
|
|
23533
23544
|
effectiveExpiration,
|
|
23534
|
-
session
|
|
23545
|
+
session,
|
|
23546
|
+
onPrepared
|
|
23535
23547
|
);
|
|
23536
23548
|
return { delegation, prompted: false };
|
|
23537
23549
|
}
|
|
@@ -23585,7 +23597,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23585
23597
|
*
|
|
23586
23598
|
* @internal
|
|
23587
23599
|
*/
|
|
23588
|
-
async createDelegationViaWasmPath(did, entries, expirationTime, session) {
|
|
23600
|
+
async createDelegationViaWasmPath(did, entries, expirationTime, session, onPrepared) {
|
|
23589
23601
|
if (entries.length === 0) {
|
|
23590
23602
|
throw new Error(
|
|
23591
23603
|
"createDelegationViaWasmPath requires a non-empty entries array"
|
|
@@ -23648,17 +23660,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23648
23660
|
});
|
|
23649
23661
|
const primary = result.resources[0];
|
|
23650
23662
|
const delegationHeader = { Authorization: result.delegation };
|
|
23651
|
-
const
|
|
23652
|
-
this.config.host,
|
|
23653
|
-
delegationHeader
|
|
23654
|
-
);
|
|
23655
|
-
if (!activateResult.success) {
|
|
23656
|
-
throw Object.assign(
|
|
23657
|
-
new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
|
|
23658
|
-
{ cause: activateResult }
|
|
23659
|
-
);
|
|
23660
|
-
}
|
|
23661
|
-
return {
|
|
23663
|
+
const delegation = {
|
|
23662
23664
|
cid: result.cid,
|
|
23663
23665
|
delegationHeader,
|
|
23664
23666
|
spaceId,
|
|
@@ -23672,8 +23674,22 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23672
23674
|
chainId: session.chainId,
|
|
23673
23675
|
host: this.config.host
|
|
23674
23676
|
};
|
|
23677
|
+
if (onPrepared) {
|
|
23678
|
+
await onPrepared(delegation);
|
|
23679
|
+
}
|
|
23680
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
23681
|
+
this.config.host,
|
|
23682
|
+
delegationHeader
|
|
23683
|
+
);
|
|
23684
|
+
if (!activateResult.success) {
|
|
23685
|
+
throw Object.assign(
|
|
23686
|
+
new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
|
|
23687
|
+
{ cause: activateResult }
|
|
23688
|
+
);
|
|
23689
|
+
}
|
|
23690
|
+
return delegation;
|
|
23675
23691
|
}
|
|
23676
|
-
async createDelegationViaRuntimeGrant(did, entries, expirationTime, grant, requestedOperations) {
|
|
23692
|
+
async createDelegationViaRuntimeGrant(did, entries, expirationTime, grant, requestedOperations, onPrepared) {
|
|
23677
23693
|
this.assertRuntimeGrantCaveatsPreservable(entries, requestedOperations, grant);
|
|
23678
23694
|
this.assertDelegationCaveatsPreservable(entries);
|
|
23679
23695
|
const result = this.createDelegationWrapper({
|
|
@@ -23686,17 +23702,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23686
23702
|
const primary = result.resources[0];
|
|
23687
23703
|
const delegationHeader = { Authorization: result.delegation };
|
|
23688
23704
|
const targetHost = grant.delegation.host ?? this.config.host;
|
|
23689
|
-
const
|
|
23690
|
-
targetHost,
|
|
23691
|
-
delegationHeader
|
|
23692
|
-
);
|
|
23693
|
-
if (!activateResult.success) {
|
|
23694
|
-
throw Object.assign(
|
|
23695
|
-
new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
|
|
23696
|
-
{ cause: activateResult }
|
|
23697
|
-
);
|
|
23698
|
-
}
|
|
23699
|
-
return {
|
|
23705
|
+
const delegation = {
|
|
23700
23706
|
cid: result.cid,
|
|
23701
23707
|
delegationHeader,
|
|
23702
23708
|
spaceId: grant.session.spaceId,
|
|
@@ -23710,6 +23716,20 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23710
23716
|
chainId: grant.delegation.chainId,
|
|
23711
23717
|
host: targetHost
|
|
23712
23718
|
};
|
|
23719
|
+
if (onPrepared) {
|
|
23720
|
+
await onPrepared(delegation);
|
|
23721
|
+
}
|
|
23722
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
23723
|
+
targetHost,
|
|
23724
|
+
delegationHeader
|
|
23725
|
+
);
|
|
23726
|
+
if (!activateResult.success) {
|
|
23727
|
+
throw Object.assign(
|
|
23728
|
+
new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
|
|
23729
|
+
{ cause: activateResult }
|
|
23730
|
+
);
|
|
23731
|
+
}
|
|
23732
|
+
return delegation;
|
|
23713
23733
|
}
|
|
23714
23734
|
resolvePermissionSpace(space, session) {
|
|
23715
23735
|
if (space === void 0) {
|