@tinycloud/sdk-core 3.11.0-beta.0 → 3.11.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/delegations/index.cjs +1 -3
- package/dist/delegations/index.cjs.map +1 -1
- package/dist/delegations/index.js +1 -3
- package/dist/delegations/index.js.map +1 -1
- package/dist/index.cjs +24 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -4
- package/dist/index.d.ts +28 -4
- package/dist/index.js +24 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -140,6 +140,8 @@ __export(index_exports, {
|
|
|
140
140
|
MAX_SECRET_SCOPE_LENGTH: () => import_sdk_services10.MAX_SECRET_SCOPE_LENGTH,
|
|
141
141
|
MAX_SHARE_ARTIFACT_BYTES: () => MAX_SHARE_ARTIFACT_BYTES,
|
|
142
142
|
MAX_SHARE_CONTENT_BYTES: () => MAX_SHARE_CONTENT_BYTES,
|
|
143
|
+
MAX_SIWE_EXPIRY_MS: () => MAX_SIWE_EXPIRY_MS,
|
|
144
|
+
MAX_UCAN_EXPIRY_MS: () => MAX_UCAN_EXPIRY_MS,
|
|
143
145
|
ManifestValidationError: () => ManifestValidationError,
|
|
144
146
|
MemorySenderShareKeyStorage: () => MemorySenderShareKeyStorage,
|
|
145
147
|
MemorySenderShareRecordStorage: () => MemorySenderShareRecordStorage,
|
|
@@ -259,6 +261,7 @@ __export(index_exports, {
|
|
|
259
261
|
admitPolicyCredentialV4: () => admitPolicyCredentialV4,
|
|
260
262
|
appSecretScope: () => import_sdk_services10.appSecretScope,
|
|
261
263
|
applyPrefix: () => applyPrefix,
|
|
264
|
+
assertExpiryWithinTechnicalLimit: () => assertExpiryWithinTechnicalLimit,
|
|
262
265
|
assertSpaceCreationAllowed: () => assertSpaceCreationAllowed,
|
|
263
266
|
authorizationVerdictOf: () => import_sdk_services10.authorizationVerdictOf,
|
|
264
267
|
bootstrapEncryptionNetworkId: () => import_bootstrap4.bootstrapEncryptionNetworkId,
|
|
@@ -476,6 +479,7 @@ __export(index_exports, {
|
|
|
476
479
|
signedObjectIdFor: () => signedObjectIdFor,
|
|
477
480
|
storageUsageState: () => import_sdk_services10.storageUsageState,
|
|
478
481
|
submitHostDelegation: () => submitHostDelegation,
|
|
482
|
+
technicalExpiryRefusal: () => technicalExpiryRefusal,
|
|
479
483
|
tinyCloudDebugLogger: () => import_sdk_services10.tinyCloudDebugLogger,
|
|
480
484
|
toSignedObjectError: () => toSignedObjectError,
|
|
481
485
|
unauthorizedRecapCapabilities: () => unauthorizedRecapCapabilities,
|
|
@@ -11127,15 +11131,27 @@ var SIGNED_READ_URL_MS = 5 * 60 * 1e3;
|
|
|
11127
11131
|
var SESSION_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
11128
11132
|
var SHARE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
11129
11133
|
var APP_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
11130
|
-
var MAX_MS = 10 * 365 * 24 * 60 * 60 * 1e3;
|
|
11131
11134
|
var EXPIRY = {
|
|
11132
11135
|
EPHEMERAL_MS,
|
|
11133
11136
|
SIGNED_READ_URL_MS,
|
|
11134
11137
|
SESSION_MS,
|
|
11135
11138
|
SHARE_MS,
|
|
11136
|
-
APP_MS
|
|
11137
|
-
MAX_MS
|
|
11139
|
+
APP_MS
|
|
11138
11140
|
};
|
|
11141
|
+
var MAX_SIWE_EXPIRY_MS = 253402300799e3;
|
|
11142
|
+
var MAX_UCAN_EXPIRY_MS = 9007199254e3;
|
|
11143
|
+
function technicalExpiryRefusal(expiresAt, kind) {
|
|
11144
|
+
const ms2 = Number(expiresAt);
|
|
11145
|
+
const siwe = kind === "siwe";
|
|
11146
|
+
const last = siwe ? "9999-12-31" : "2255-06-05";
|
|
11147
|
+
if (!Number.isFinite(ms2) || ms2 < 0) return `expiry is not a valid date or is too far away to hold; choose one before ${last}`;
|
|
11148
|
+
if (ms2 <= (siwe ? MAX_SIWE_EXPIRY_MS : MAX_UCAN_EXPIRY_MS)) return null;
|
|
11149
|
+
return `expiry is later than ${last}, ${siwe ? "the latest date a TinyCloud signed message can carry" : "the latest date an agent or share delegation can carry (UCAN limit); a delegation signed by the wallet (delegateTo with forceWalletSign: true) can go to 9999-12-31"}; choose an earlier expiry`;
|
|
11150
|
+
}
|
|
11151
|
+
function assertExpiryWithinTechnicalLimit(expiresAt, kind) {
|
|
11152
|
+
const refusal = technicalExpiryRefusal(expiresAt, kind);
|
|
11153
|
+
if (refusal) throw new Error(refusal);
|
|
11154
|
+
}
|
|
11139
11155
|
var DEFAULT_SIGNED_READ_URL_EXPIRY_MS = EXPIRY.SIGNED_READ_URL_MS;
|
|
11140
11156
|
|
|
11141
11157
|
// src/delegations/SharingService.ts
|
|
@@ -16729,7 +16745,10 @@ function checkChangedExpiration(input) {
|
|
|
16729
16745
|
if (drift.length > 0) return `altered immutable SIWE fields: ${drift.join(", ")}`;
|
|
16730
16746
|
if (signed.expirationTime === prepared.expirationTime) return null;
|
|
16731
16747
|
const expiresAt = parseInstantMs(signed.expirationTime);
|
|
16732
|
-
if (expiresAt === void 0)
|
|
16748
|
+
if (expiresAt === void 0) {
|
|
16749
|
+
const later = Date.parse(signed.expirationTime ?? "");
|
|
16750
|
+
return later > MAX_SIWE_EXPIRY_MS ? technicalExpiryRefusal(later, "siwe") : "expiry is not a valid timestamp";
|
|
16751
|
+
}
|
|
16733
16752
|
if (expiresAt <= nowMs + CHANGED_EXPIRY_MIN_REMAINING_MS) {
|
|
16734
16753
|
return "expiry must be more than 60 seconds from now; choose a longer expiry";
|
|
16735
16754
|
}
|
|
@@ -16742,10 +16761,7 @@ function checkChangedExpiration(input) {
|
|
|
16742
16761
|
if (maxMs !== void 0 && expiresAt > maxMs) {
|
|
16743
16762
|
return `expiry is later than the maximum for this request (the latest allowed is ${new Date(maxMs).toISOString()}); choose an earlier expiry`;
|
|
16744
16763
|
}
|
|
16745
|
-
|
|
16746
|
-
return "expiry is more than 10 years away, the longest this SDK accepts; choose a shorter expiry";
|
|
16747
|
-
}
|
|
16748
|
-
return null;
|
|
16764
|
+
return technicalExpiryRefusal(expiresAt, "siwe");
|
|
16749
16765
|
}
|
|
16750
16766
|
function extractRecapAttenuations(siwe) {
|
|
16751
16767
|
const merged = {};
|