@tinycloud/sdk-core 3.2.0-beta.5 → 3.2.0-beta.8
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/delegations/index.cjs.map +1 -1
- package/dist/delegations/index.js.map +1 -1
- package/dist/index.cjs +34 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +40 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -189,6 +189,8 @@ __export(index_exports, {
|
|
|
189
189
|
SQLAction: () => import_sdk_services9.SQLAction,
|
|
190
190
|
SQLService: () => import_sdk_services9.SQLService,
|
|
191
191
|
STORAGE_FULL_MESSAGE: () => import_sdk_services9.STORAGE_FULL_MESSAGE,
|
|
192
|
+
STORAGE_MANAGE_URL: () => import_sdk_services9.STORAGE_MANAGE_URL,
|
|
193
|
+
STORAGE_NEARLY_FULL_RATIO: () => import_sdk_services9.STORAGE_NEARLY_FULL_RATIO,
|
|
192
194
|
STORAGE_WRITE_TOO_LARGE_MESSAGE: () => import_sdk_services9.STORAGE_WRITE_TOO_LARGE_MESSAGE,
|
|
193
195
|
SecretsService: () => import_sdk_services9.SecretsService,
|
|
194
196
|
SenderShareStore: () => SenderShareStore,
|
|
@@ -217,6 +219,7 @@ __export(index_exports, {
|
|
|
217
219
|
Space: () => Space,
|
|
218
220
|
SpaceErrorCodes: () => SpaceErrorCodes,
|
|
219
221
|
SpaceService: () => SpaceService,
|
|
222
|
+
StorageFullMonitor: () => import_sdk_services9.StorageFullMonitor,
|
|
220
223
|
TC832_RESERVED_SCOPES: () => import_sdk_services9.TC832_RESERVED_SCOPES,
|
|
221
224
|
TINYCLOUD_ACCOUNT_SPACE_MANIFEST: () => import_bootstrap4.TINYCLOUD_ACCOUNT_SPACE_MANIFEST,
|
|
222
225
|
TINYCLOUD_AGENTS_SPACE_MANIFEST: () => import_bootstrap4.TINYCLOUD_AGENTS_SPACE_MANIFEST,
|
|
@@ -406,6 +409,8 @@ __export(index_exports, {
|
|
|
406
409
|
parseShareUrl: () => parseShareUrl,
|
|
407
410
|
parseSignedCompactUcanAttenuation: () => parseSignedCompactUcanAttenuation,
|
|
408
411
|
parseSpaceUri: () => parseSpaceUri,
|
|
412
|
+
parseStorageRejection: () => import_sdk_services9.parseStorageRejection,
|
|
413
|
+
parseStorageStatus: () => import_sdk_services9.parseStorageStatus,
|
|
409
414
|
pkhDid: () => pkhDid,
|
|
410
415
|
policyCidFromCanonicalBytes: () => policyCidFromCanonicalBytes,
|
|
411
416
|
policyDigestHex: () => policyDigestHex,
|
|
@@ -442,6 +447,7 @@ __export(index_exports, {
|
|
|
442
447
|
signPolicyCredentialPresentationV4: () => signPolicyCredentialPresentationV4,
|
|
443
448
|
signShareEnvelope: () => signShareEnvelope,
|
|
444
449
|
signedObjectIdFor: () => signedObjectIdFor,
|
|
450
|
+
storageUsageState: () => import_sdk_services9.storageUsageState,
|
|
445
451
|
submitHostDelegation: () => submitHostDelegation,
|
|
446
452
|
tinyCloudDebugLogger: () => import_sdk_services9.tinyCloudDebugLogger,
|
|
447
453
|
toSignedObjectError: () => toSignedObjectError,
|
|
@@ -8020,8 +8026,9 @@ async function loadManifest(url) {
|
|
|
8020
8026
|
}
|
|
8021
8027
|
const res = await fetchFn(url);
|
|
8022
8028
|
if (!res.ok) {
|
|
8023
|
-
throw
|
|
8024
|
-
`failed to fetch manifest from ${url}: HTTP ${res.status}`
|
|
8029
|
+
throw Object.assign(
|
|
8030
|
+
new ManifestValidationError(`failed to fetch manifest from ${url}: HTTP ${res.status}`),
|
|
8031
|
+
{ status: res.status }
|
|
8025
8032
|
);
|
|
8026
8033
|
}
|
|
8027
8034
|
const json = await res.json();
|
|
@@ -12787,7 +12794,11 @@ var SpaceServiceConfigSchema = import_zod9.z.object({
|
|
|
12787
12794
|
/** Optional SharingService for v2 sharing links (client-side) */
|
|
12788
12795
|
sharingService: import_zod9.z.unknown().optional(),
|
|
12789
12796
|
/** Factory function to create delegations using SIWE-based flow */
|
|
12790
|
-
createDelegation: import_zod9.z.function().optional()
|
|
12797
|
+
createDelegation: import_zod9.z.function().optional(),
|
|
12798
|
+
/** Best-effort hook after the SDK discovers or creates a space */
|
|
12799
|
+
onSpaceRegistered: import_zod9.z.function().optional(),
|
|
12800
|
+
/** True once the owner's storage is known full; list() then skips registration */
|
|
12801
|
+
isStorageFull: import_zod9.z.function().optional()
|
|
12791
12802
|
});
|
|
12792
12803
|
var SpaceDelegationParamsSchema = CreateDelegationParamsSchema.extend({
|
|
12793
12804
|
/** The space ID to create the delegation for */
|
|
@@ -13042,6 +13053,7 @@ var SpaceService = class {
|
|
|
13042
13053
|
this.sharingService = config.sharingService;
|
|
13043
13054
|
this.createDelegationFn = config.createDelegation;
|
|
13044
13055
|
this.onSpaceRegisteredFn = config.onSpaceRegistered;
|
|
13056
|
+
this.isStorageFullFn = config.isStorageFull;
|
|
13045
13057
|
}
|
|
13046
13058
|
/**
|
|
13047
13059
|
* Update the service configuration.
|
|
@@ -13059,6 +13071,7 @@ var SpaceService = class {
|
|
|
13059
13071
|
if (config.sharingService) this.sharingService = config.sharingService;
|
|
13060
13072
|
if (config.createDelegation) this.createDelegationFn = config.createDelegation;
|
|
13061
13073
|
if (config.onSpaceRegistered) this.onSpaceRegisteredFn = config.onSpaceRegistered;
|
|
13074
|
+
if (config.isStorageFull) this.isStorageFullFn = config.isStorageFull;
|
|
13062
13075
|
this.spaceCache.clear();
|
|
13063
13076
|
this.infoCache.clear();
|
|
13064
13077
|
}
|
|
@@ -13112,8 +13125,10 @@ var SpaceService = class {
|
|
|
13112
13125
|
spaces.push(...delegatedSpaces);
|
|
13113
13126
|
}
|
|
13114
13127
|
const uniqueSpaces = this.deduplicateSpaces(spaces);
|
|
13115
|
-
|
|
13116
|
-
|
|
13128
|
+
if (!this.isStorageFullFn?.()) {
|
|
13129
|
+
for (const space of uniqueSpaces) {
|
|
13130
|
+
this.notifySpaceRegistered(space);
|
|
13131
|
+
}
|
|
13117
13132
|
}
|
|
13118
13133
|
return (0, import_sdk_services5.ok)(uniqueSpaces);
|
|
13119
13134
|
} catch (error) {
|
|
@@ -16455,7 +16470,7 @@ async function checkNodeInfo(host, sdkProtocol, fetchFn = globalThis.fetch.bind(
|
|
|
16455
16470
|
throw new VersionCheckError(host, err6);
|
|
16456
16471
|
}
|
|
16457
16472
|
if (!response.ok) {
|
|
16458
|
-
throw new VersionCheckError(host);
|
|
16473
|
+
throw new VersionCheckError(host, await httpResponseError(response, "node info fetch failed"));
|
|
16459
16474
|
}
|
|
16460
16475
|
const data = await response.json();
|
|
16461
16476
|
if (sdkProtocol !== data.protocol) {
|
|
@@ -18196,6 +18211,16 @@ var CloudLocationResolutionError = class extends Error {
|
|
|
18196
18211
|
super(`Unable to resolve TinyCloud location for ${subject}`);
|
|
18197
18212
|
this.name = "CloudLocationResolutionError";
|
|
18198
18213
|
this.attempts = attempts;
|
|
18214
|
+
let failure;
|
|
18215
|
+
for (const attempt of attempts) {
|
|
18216
|
+
if (attempt.error === void 0) continue;
|
|
18217
|
+
if (failure !== void 0) {
|
|
18218
|
+
failure = void 0;
|
|
18219
|
+
break;
|
|
18220
|
+
}
|
|
18221
|
+
failure = attempt.error;
|
|
18222
|
+
}
|
|
18223
|
+
this.cause = failure;
|
|
18199
18224
|
}
|
|
18200
18225
|
};
|
|
18201
18226
|
function locationPayloadForRecord(record2) {
|
|
@@ -18697,7 +18722,9 @@ async function verifyOwnerNodeBinding(options2) {
|
|
|
18697
18722
|
signal: lookup.signal
|
|
18698
18723
|
});
|
|
18699
18724
|
if (!response.ok) {
|
|
18700
|
-
|
|
18725
|
+
const failure = new LocationRecordValidationError(`target node /info returned HTTP ${response.status}`);
|
|
18726
|
+
Object.assign(failure, { status: response.status });
|
|
18727
|
+
throw failure;
|
|
18701
18728
|
}
|
|
18702
18729
|
const text2 = await boundedResponseText(response, "target node /info", 16 * 1024);
|
|
18703
18730
|
let body;
|