@tinycloud/node-sdk 3.0.1-beta.0 → 3.1.0-beta.1
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-DufYfxi-.d.cts → core-Bm76PnOz.d.cts} +7 -1
- package/dist/{core-DufYfxi-.d.ts → core-Bm76PnOz.d.ts} +7 -1
- package/dist/core.cjs +44 -17
- 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 +45 -17
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +44 -17
- 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 +45 -17
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -17832,21 +17832,28 @@ var NodeUserAuthorization = class {
|
|
|
17832
17832
|
});
|
|
17833
17833
|
const signature2 = await this.signMessage(siwe, purpose);
|
|
17834
17834
|
const headers = this.wasm.siweToDelegationHeaders({ siwe, signature: signature2 });
|
|
17835
|
-
|
|
17836
|
-
return result.success;
|
|
17835
|
+
return (0, import_sdk_core2.submitHostDelegation)(host, headers);
|
|
17837
17836
|
}
|
|
17838
17837
|
/**
|
|
17839
17838
|
* Create a specific space on the server via host delegation.
|
|
17840
17839
|
* Used for lazy creation of additional spaces (e.g., public).
|
|
17841
17840
|
*/
|
|
17842
17841
|
async hostPublicSpace(spaceId) {
|
|
17843
|
-
return this.hostSpace(spaceId);
|
|
17842
|
+
return (await this.hostSpace(spaceId)).success;
|
|
17844
17843
|
}
|
|
17845
17844
|
/**
|
|
17846
17845
|
* Create a specific owned space on the server via host delegation.
|
|
17847
17846
|
* Used by manifest registry setup for the account space.
|
|
17848
17847
|
*/
|
|
17849
17848
|
async hostOwnedSpace(spaceId, purpose) {
|
|
17849
|
+
return (await this.hostOwnedSpaceResult(spaceId, purpose)).success;
|
|
17850
|
+
}
|
|
17851
|
+
/**
|
|
17852
|
+
* {@link hostOwnedSpace} with the full host-delegation result, so a failure
|
|
17853
|
+
* keeps its HTTP status (e.g. a typed 401/403) instead of collapsing to
|
|
17854
|
+
* `false`.
|
|
17855
|
+
*/
|
|
17856
|
+
async hostOwnedSpaceResult(spaceId, purpose) {
|
|
17850
17857
|
return this.hostSpace(spaceId, purpose);
|
|
17851
17858
|
}
|
|
17852
17859
|
/**
|
|
@@ -17889,7 +17896,7 @@ var NodeUserAuthorization = class {
|
|
|
17889
17896
|
return;
|
|
17890
17897
|
}
|
|
17891
17898
|
try {
|
|
17892
|
-
const created = await this.hostSpace();
|
|
17899
|
+
const created = (await this.hostSpace()).success;
|
|
17893
17900
|
if (!created) {
|
|
17894
17901
|
const err = new Error(`Failed to create space: ${primarySpaceId}`);
|
|
17895
17902
|
handler.onSpaceCreationFailed?.(creationContext, err);
|
|
@@ -17926,7 +17933,7 @@ var NodeUserAuthorization = class {
|
|
|
17926
17933
|
return;
|
|
17927
17934
|
}
|
|
17928
17935
|
try {
|
|
17929
|
-
const created = await this.hostSpace();
|
|
17936
|
+
const created = (await this.hostSpace()).success;
|
|
17930
17937
|
if (!created) {
|
|
17931
17938
|
const err = new Error(`Failed to create space: ${primarySpaceId}`);
|
|
17932
17939
|
handler.onSpaceCreationFailed?.(creationContext, err);
|
|
@@ -19425,6 +19432,10 @@ function persistedExpiry(value) {
|
|
|
19425
19432
|
function sameInstant(left, right) {
|
|
19426
19433
|
return left.getTime() === right.getTime();
|
|
19427
19434
|
}
|
|
19435
|
+
function describeHostFailure(result) {
|
|
19436
|
+
const text = result.error?.trim();
|
|
19437
|
+
return text ? `${result.status} - ${text}` : `${result.status}`;
|
|
19438
|
+
}
|
|
19428
19439
|
function ownerDelegationPermissions(params) {
|
|
19429
19440
|
const hasPermissions = Object.prototype.hasOwnProperty.call(params, "permissions");
|
|
19430
19441
|
const hasLegacy = Object.prototype.hasOwnProperty.call(params, "path") || Object.prototype.hasOwnProperty.call(params, "actions");
|
|
@@ -20538,8 +20549,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20538
20549
|
await this.ensureOwnedSpaceHostedById(accountSpaceId);
|
|
20539
20550
|
const result = await this.account.applications.register(request.manifests);
|
|
20540
20551
|
if (!result.ok) {
|
|
20541
|
-
throw
|
|
20542
|
-
`Failed to write manifest registry records: ${result.error.message}`
|
|
20552
|
+
throw Object.assign(
|
|
20553
|
+
new Error(`Failed to write manifest registry records: ${result.error.message}`),
|
|
20554
|
+
{ cause: result.error }
|
|
20543
20555
|
);
|
|
20544
20556
|
}
|
|
20545
20557
|
}
|
|
@@ -20564,7 +20576,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20564
20576
|
if (this.currentSessionCanListSpaces()) {
|
|
20565
20577
|
const spaces = await this.account.spaces.syncAccessible();
|
|
20566
20578
|
if (!spaces.ok) {
|
|
20567
|
-
throw
|
|
20579
|
+
throw Object.assign(
|
|
20580
|
+
new Error(`Failed to sync account spaces: ${spaces.error.message}`),
|
|
20581
|
+
{ cause: spaces.error }
|
|
20582
|
+
);
|
|
20568
20583
|
}
|
|
20569
20584
|
}
|
|
20570
20585
|
});
|
|
@@ -20619,8 +20634,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20619
20634
|
await task();
|
|
20620
20635
|
return;
|
|
20621
20636
|
} catch (error) {
|
|
20637
|
+
const verdict = (0, import_sdk_core7.authorizationVerdictOf)(error);
|
|
20622
20638
|
const message = error instanceof Error ? error.message : String(error);
|
|
20623
|
-
|
|
20639
|
+
const isAuthorizationVerdict = verdict === void 0 ? /Unauthorized Action|\b(?:401|403)\b/.test(message) : verdict !== "other";
|
|
20640
|
+
if (isAuthorizationVerdict) {
|
|
20624
20641
|
console.warn(
|
|
20625
20642
|
"TinyCloud account registry sync stopped: authorization verdict is not retryable",
|
|
20626
20643
|
error
|
|
@@ -20700,19 +20717,26 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20700
20717
|
return;
|
|
20701
20718
|
}
|
|
20702
20719
|
if (!activation.success && activation.status !== 404) {
|
|
20703
|
-
throw
|
|
20704
|
-
`Failed to check owned space ${spaceId}: ${activation
|
|
20720
|
+
throw Object.assign(
|
|
20721
|
+
new Error(`Failed to check owned space ${spaceId}: ${describeHostFailure(activation)}`),
|
|
20722
|
+
{ cause: activation }
|
|
20705
20723
|
);
|
|
20706
20724
|
}
|
|
20707
|
-
const created = await this.auth.
|
|
20708
|
-
if (!created) {
|
|
20709
|
-
throw
|
|
20725
|
+
const created = await this.auth.hostOwnedSpaceResult(spaceId);
|
|
20726
|
+
if (!created.success) {
|
|
20727
|
+
throw Object.assign(
|
|
20728
|
+
new Error(`Failed to create owned space ${spaceId}: ${describeHostFailure(created)}`),
|
|
20729
|
+
{ cause: created }
|
|
20730
|
+
);
|
|
20710
20731
|
}
|
|
20711
20732
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
20712
20733
|
const retry = await (0, import_sdk_core7.activateSessionWithHost)(host, session.delegationHeader);
|
|
20713
20734
|
if (!retry.success || retry.skipped?.includes(spaceId)) {
|
|
20714
|
-
throw
|
|
20715
|
-
|
|
20735
|
+
throw Object.assign(
|
|
20736
|
+
new Error(
|
|
20737
|
+
`Failed to activate session after creating owned space ${spaceId}: ${retry.success ? "space was skipped" : describeHostFailure(retry)}`
|
|
20738
|
+
),
|
|
20739
|
+
{ cause: retry }
|
|
20716
20740
|
);
|
|
20717
20741
|
}
|
|
20718
20742
|
this.confirmedHostedSpaceIds.add(spaceId);
|
|
@@ -22260,7 +22284,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22260
22284
|
const activation = await (0, import_sdk_core7.activateSessionWithHost)(host, delegationSession.delegationHeader);
|
|
22261
22285
|
assertOwnerGraphActive();
|
|
22262
22286
|
if (!activation.success) {
|
|
22263
|
-
throw
|
|
22287
|
+
throw Object.assign(
|
|
22288
|
+
new Error(`Owner delegation import failed: ${activation.status} ${activation.error ?? ""}`.trim()),
|
|
22289
|
+
{ cause: activation }
|
|
22290
|
+
);
|
|
22264
22291
|
}
|
|
22265
22292
|
const delegation = {
|
|
22266
22293
|
cid: delegationSession.delegationCid,
|