@tinycloud/node-sdk 2.1.0-beta.0 → 2.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.cjs +366 -89
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +92 -3
- package/dist/core.d.ts +92 -3
- package/dist/core.js +294 -8
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +370 -92
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +296 -8
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.cjs
CHANGED
|
@@ -17025,54 +17025,63 @@ var require_utils2 = __commonJS({
|
|
|
17025
17025
|
// src/index.ts
|
|
17026
17026
|
var index_exports = {};
|
|
17027
17027
|
__export(index_exports, {
|
|
17028
|
-
AutoApproveSpaceCreationHandler: () =>
|
|
17029
|
-
CapabilityKeyRegistry: () =>
|
|
17030
|
-
CapabilityKeyRegistryErrorCodes: () =>
|
|
17031
|
-
DataVaultService: () =>
|
|
17032
|
-
DatabaseHandle: () =>
|
|
17028
|
+
AutoApproveSpaceCreationHandler: () => import_sdk_core7.AutoApproveSpaceCreationHandler,
|
|
17029
|
+
CapabilityKeyRegistry: () => import_sdk_core15.CapabilityKeyRegistry,
|
|
17030
|
+
CapabilityKeyRegistryErrorCodes: () => import_sdk_core15.CapabilityKeyRegistryErrorCodes,
|
|
17031
|
+
DataVaultService: () => import_sdk_core12.DataVaultService,
|
|
17032
|
+
DatabaseHandle: () => import_sdk_core10.DatabaseHandle,
|
|
17033
17033
|
DelegatedAccess: () => DelegatedAccess,
|
|
17034
|
-
DelegationErrorCodes: () =>
|
|
17035
|
-
DelegationManager: () =>
|
|
17036
|
-
DuckDbAction: () =>
|
|
17037
|
-
DuckDbDatabaseHandle: () =>
|
|
17038
|
-
DuckDbService: () =>
|
|
17034
|
+
DelegationErrorCodes: () => import_sdk_core14.DelegationErrorCodes,
|
|
17035
|
+
DelegationManager: () => import_sdk_core14.DelegationManager,
|
|
17036
|
+
DuckDbAction: () => import_sdk_core11.DuckDbAction,
|
|
17037
|
+
DuckDbDatabaseHandle: () => import_sdk_core11.DuckDbDatabaseHandle,
|
|
17038
|
+
DuckDbService: () => import_sdk_core11.DuckDbService,
|
|
17039
17039
|
FileSessionStorage: () => FileSessionStorage,
|
|
17040
|
-
HooksService: () =>
|
|
17041
|
-
KVService: () =>
|
|
17040
|
+
HooksService: () => import_sdk_core13.HooksService,
|
|
17041
|
+
KVService: () => import_sdk_core9.KVService,
|
|
17042
|
+
ManifestValidationError: () => import_sdk_core8.ManifestValidationError,
|
|
17042
17043
|
MemorySessionStorage: () => MemorySessionStorage,
|
|
17043
17044
|
NodeUserAuthorization: () => NodeUserAuthorization,
|
|
17044
17045
|
NodeWasmBindings: () => NodeWasmBindings,
|
|
17045
|
-
|
|
17046
|
+
PermissionNotInManifestError: () => import_sdk_core8.PermissionNotInManifestError,
|
|
17047
|
+
PrefixedKVService: () => import_sdk_core9.PrefixedKVService,
|
|
17046
17048
|
PrivateKeySigner: () => PrivateKeySigner,
|
|
17047
|
-
ProtocolMismatchError: () =>
|
|
17048
|
-
SQLAction: () =>
|
|
17049
|
-
SQLService: () =>
|
|
17050
|
-
ServiceContext: () =>
|
|
17051
|
-
|
|
17052
|
-
|
|
17053
|
-
|
|
17054
|
-
|
|
17055
|
-
|
|
17056
|
-
|
|
17049
|
+
ProtocolMismatchError: () => import_sdk_core17.ProtocolMismatchError,
|
|
17050
|
+
SQLAction: () => import_sdk_core10.SQLAction,
|
|
17051
|
+
SQLService: () => import_sdk_core10.SQLService,
|
|
17052
|
+
ServiceContext: () => import_sdk_core18.ServiceContext,
|
|
17053
|
+
SessionExpiredError: () => import_sdk_core8.SessionExpiredError,
|
|
17054
|
+
SharingService: () => import_sdk_core14.SharingService,
|
|
17055
|
+
SilentNotificationHandler: () => import_sdk_core7.SilentNotificationHandler,
|
|
17056
|
+
Space: () => import_sdk_core16.Space,
|
|
17057
|
+
SpaceErrorCodes: () => import_sdk_core16.SpaceErrorCodes,
|
|
17058
|
+
SpaceService: () => import_sdk_core16.SpaceService,
|
|
17059
|
+
TinyCloud: () => import_sdk_core6.TinyCloud,
|
|
17057
17060
|
TinyCloudNode: () => TinyCloudNode,
|
|
17058
|
-
UnsupportedFeatureError: () =>
|
|
17059
|
-
VaultHeaders: () =>
|
|
17060
|
-
VaultPublicSpaceKVActions: () =>
|
|
17061
|
-
VersionCheckError: () =>
|
|
17061
|
+
UnsupportedFeatureError: () => import_sdk_core17.UnsupportedFeatureError,
|
|
17062
|
+
VaultHeaders: () => import_sdk_core12.VaultHeaders,
|
|
17063
|
+
VaultPublicSpaceKVActions: () => import_sdk_core12.VaultPublicSpaceKVActions,
|
|
17064
|
+
VersionCheckError: () => import_sdk_core17.VersionCheckError,
|
|
17062
17065
|
WasmKeyProvider: () => WasmKeyProvider,
|
|
17063
|
-
buildSpaceUri: () =>
|
|
17064
|
-
checkNodeInfo: () =>
|
|
17065
|
-
createCapabilityKeyRegistry: () =>
|
|
17066
|
-
createSharingService: () =>
|
|
17067
|
-
createSpaceService: () =>
|
|
17068
|
-
createVaultCrypto: () =>
|
|
17066
|
+
buildSpaceUri: () => import_sdk_core16.buildSpaceUri,
|
|
17067
|
+
checkNodeInfo: () => import_sdk_core17.checkNodeInfo,
|
|
17068
|
+
createCapabilityKeyRegistry: () => import_sdk_core15.createCapabilityKeyRegistry,
|
|
17069
|
+
createSharingService: () => import_sdk_core14.createSharingService,
|
|
17070
|
+
createSpaceService: () => import_sdk_core16.createSpaceService,
|
|
17071
|
+
createVaultCrypto: () => import_sdk_core12.createVaultCrypto,
|
|
17069
17072
|
createWasmKeyProvider: () => createWasmKeyProvider,
|
|
17070
17073
|
defaultSignStrategy: () => defaultSignStrategy,
|
|
17071
|
-
defaultSpaceCreationHandler: () =>
|
|
17074
|
+
defaultSpaceCreationHandler: () => import_sdk_core7.defaultSpaceCreationHandler,
|
|
17072
17075
|
deserializeDelegation: () => deserializeDelegation,
|
|
17073
|
-
|
|
17074
|
-
|
|
17075
|
-
|
|
17076
|
+
expandActionShortNames: () => import_sdk_core8.expandActionShortNames,
|
|
17077
|
+
isCapabilitySubset: () => import_sdk_core8.isCapabilitySubset,
|
|
17078
|
+
loadManifest: () => import_sdk_core8.loadManifest,
|
|
17079
|
+
makePublicSpaceId: () => import_sdk_core16.makePublicSpaceId,
|
|
17080
|
+
parseExpiry: () => import_sdk_core8.parseExpiry,
|
|
17081
|
+
parseSpaceUri: () => import_sdk_core16.parseSpaceUri,
|
|
17082
|
+
resolveManifest: () => import_sdk_core8.resolveManifest,
|
|
17083
|
+
serializeDelegation: () => serializeDelegation,
|
|
17084
|
+
validateManifest: () => import_sdk_core8.validateManifest
|
|
17076
17085
|
});
|
|
17077
17086
|
module.exports = __toCommonJS(index_exports);
|
|
17078
17087
|
|
|
@@ -17087,6 +17096,7 @@ var _NodeWasmBindings = class _NodeWasmBindings {
|
|
|
17087
17096
|
this.ensureEip55 = import_node_sdk_wasm.ensureEip55;
|
|
17088
17097
|
this.makeSpaceId = import_node_sdk_wasm.makeSpaceId;
|
|
17089
17098
|
this.createDelegation = import_node_sdk_wasm.createDelegation;
|
|
17099
|
+
this.parseRecapFromSiwe = import_node_sdk_wasm.parseRecapFromSiwe;
|
|
17090
17100
|
this.generateHostSIWEMessage = import_node_sdk_wasm.generateHostSIWEMessage;
|
|
17091
17101
|
this.siweToDelegationHeaders = import_node_sdk_wasm.siweToDelegationHeaders;
|
|
17092
17102
|
this.protocolVersion = import_node_sdk_wasm.protocolVersion;
|
|
@@ -17175,7 +17185,7 @@ var PrivateKeySigner = class {
|
|
|
17175
17185
|
};
|
|
17176
17186
|
|
|
17177
17187
|
// src/TinyCloudNode.ts
|
|
17178
|
-
var
|
|
17188
|
+
var import_sdk_core4 = require("@tinycloud/sdk-core");
|
|
17179
17189
|
|
|
17180
17190
|
// src/authorization/NodeUserAuthorization.ts
|
|
17181
17191
|
var import_sdk_core = require("@tinycloud/sdk-core");
|
|
@@ -18001,9 +18011,69 @@ function createWasmKeyProvider(sessionManager) {
|
|
|
18001
18011
|
return new WasmKeyProvider({ sessionManager });
|
|
18002
18012
|
}
|
|
18003
18013
|
|
|
18014
|
+
// src/delegateToHelpers.ts
|
|
18015
|
+
var import_sdk_core3 = require("@tinycloud/sdk-core");
|
|
18016
|
+
function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
18017
|
+
const byService = /* @__PURE__ */ new Map();
|
|
18018
|
+
for (const a of actions) {
|
|
18019
|
+
const slashIdx = a.indexOf("/");
|
|
18020
|
+
if (slashIdx === -1) {
|
|
18021
|
+
continue;
|
|
18022
|
+
}
|
|
18023
|
+
const service = a.slice(0, slashIdx);
|
|
18024
|
+
if (!service.startsWith("tinycloud.")) {
|
|
18025
|
+
continue;
|
|
18026
|
+
}
|
|
18027
|
+
const list = byService.get(service);
|
|
18028
|
+
if (list === void 0) {
|
|
18029
|
+
byService.set(service, [a]);
|
|
18030
|
+
} else {
|
|
18031
|
+
list.push(a);
|
|
18032
|
+
}
|
|
18033
|
+
}
|
|
18034
|
+
const space = spaceIdOverride ?? "default";
|
|
18035
|
+
const entries = [];
|
|
18036
|
+
for (const [service, actionList] of byService) {
|
|
18037
|
+
entries.push({
|
|
18038
|
+
service,
|
|
18039
|
+
space,
|
|
18040
|
+
path,
|
|
18041
|
+
actions: actionList
|
|
18042
|
+
});
|
|
18043
|
+
}
|
|
18044
|
+
return entries;
|
|
18045
|
+
}
|
|
18046
|
+
function resolveExpiryMs(expiry) {
|
|
18047
|
+
if (expiry === void 0) {
|
|
18048
|
+
return 60 * 60 * 1e3;
|
|
18049
|
+
}
|
|
18050
|
+
if (typeof expiry === "number") {
|
|
18051
|
+
if (!Number.isFinite(expiry) || expiry <= 0) {
|
|
18052
|
+
throw new Error(
|
|
18053
|
+
`delegateTo expiry must be a positive finite number (got ${expiry})`
|
|
18054
|
+
);
|
|
18055
|
+
}
|
|
18056
|
+
return expiry;
|
|
18057
|
+
}
|
|
18058
|
+
return (0, import_sdk_core3.parseExpiry)(expiry);
|
|
18059
|
+
}
|
|
18060
|
+
function extractSiweExpiration(siwe) {
|
|
18061
|
+
const parsed = new import_sdk_core3.SiweMessage(siwe);
|
|
18062
|
+
if (parsed.expirationTime === void 0 || parsed.expirationTime === null) {
|
|
18063
|
+
return void 0;
|
|
18064
|
+
}
|
|
18065
|
+
const d = new Date(parsed.expirationTime);
|
|
18066
|
+
if (Number.isNaN(d.getTime())) {
|
|
18067
|
+
throw new Error(
|
|
18068
|
+
`Session SIWE has unparseable expirationTime: ${parsed.expirationTime}`
|
|
18069
|
+
);
|
|
18070
|
+
}
|
|
18071
|
+
return d;
|
|
18072
|
+
}
|
|
18073
|
+
|
|
18004
18074
|
// src/TinyCloudNode.ts
|
|
18005
18075
|
var DEFAULT_HOST = "https://node.tinycloud.xyz";
|
|
18006
|
-
var
|
|
18076
|
+
var _TinyCloudNode = class _TinyCloudNode {
|
|
18007
18077
|
/**
|
|
18008
18078
|
* Create a new TinyCloudNode instance.
|
|
18009
18079
|
*
|
|
@@ -18058,12 +18128,12 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18058
18128
|
throw new Error("Failed to get session key JWK");
|
|
18059
18129
|
}
|
|
18060
18130
|
this.sessionKeyJwk = JSON.parse(jwkStr);
|
|
18061
|
-
this._capabilityRegistry = new
|
|
18131
|
+
this._capabilityRegistry = new import_sdk_core4.CapabilityKeyRegistry();
|
|
18062
18132
|
this._keyProvider = new WasmKeyProvider({
|
|
18063
18133
|
sessionManager: this.sessionManager
|
|
18064
18134
|
});
|
|
18065
|
-
this.notificationHandler = config.notificationHandler ?? new
|
|
18066
|
-
this._sharingService = new
|
|
18135
|
+
this.notificationHandler = config.notificationHandler ?? new import_sdk_core4.SilentNotificationHandler();
|
|
18136
|
+
this._sharingService = new import_sdk_core4.SharingService({
|
|
18067
18137
|
hosts: [this.config.host],
|
|
18068
18138
|
// session: undefined - not needed for receive()
|
|
18069
18139
|
invoke: this.wasmBindings.invoke,
|
|
@@ -18073,8 +18143,8 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18073
18143
|
// delegationManager: undefined - not needed for receive()
|
|
18074
18144
|
createKVService: (config2) => {
|
|
18075
18145
|
const prefix = config2.pathPrefix?.replace(/\/$/, "");
|
|
18076
|
-
const kvService = new
|
|
18077
|
-
const kvContext = new
|
|
18146
|
+
const kvService = new import_sdk_core4.KVService({ prefix });
|
|
18147
|
+
const kvContext = new import_sdk_core4.ServiceContext({
|
|
18078
18148
|
invoke: config2.invoke,
|
|
18079
18149
|
fetch: config2.fetch ?? globalThis.fetch.bind(globalThis),
|
|
18080
18150
|
hosts: config2.hosts
|
|
@@ -18129,7 +18199,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18129
18199
|
nonce: config.nonce,
|
|
18130
18200
|
siweConfig: config.siweConfig
|
|
18131
18201
|
});
|
|
18132
|
-
this.tc = new
|
|
18202
|
+
this.tc = new import_sdk_core4.TinyCloud(this.auth, {
|
|
18133
18203
|
invokeAny: this.wasmBindings.invokeAny
|
|
18134
18204
|
});
|
|
18135
18205
|
}
|
|
@@ -18228,22 +18298,22 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18228
18298
|
if (sessionData.chainId) {
|
|
18229
18299
|
this._chainId = sessionData.chainId;
|
|
18230
18300
|
}
|
|
18231
|
-
this._serviceContext = new
|
|
18301
|
+
this._serviceContext = new import_sdk_core4.ServiceContext({
|
|
18232
18302
|
invoke: this.wasmBindings.invoke,
|
|
18233
18303
|
invokeAny: this.wasmBindings.invokeAny,
|
|
18234
18304
|
fetch: globalThis.fetch.bind(globalThis),
|
|
18235
18305
|
hosts: [this.config.host]
|
|
18236
18306
|
});
|
|
18237
|
-
this._kv = new
|
|
18307
|
+
this._kv = new import_sdk_core4.KVService({});
|
|
18238
18308
|
this._kv.initialize(this._serviceContext);
|
|
18239
18309
|
this._serviceContext.registerService("kv", this._kv);
|
|
18240
|
-
this._sql = new
|
|
18310
|
+
this._sql = new import_sdk_core4.SQLService({});
|
|
18241
18311
|
this._sql.initialize(this._serviceContext);
|
|
18242
18312
|
this._serviceContext.registerService("sql", this._sql);
|
|
18243
|
-
this._duckdb = new
|
|
18313
|
+
this._duckdb = new import_sdk_core4.DuckDbService({});
|
|
18244
18314
|
this._duckdb.initialize(this._serviceContext);
|
|
18245
18315
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
18246
|
-
this._hooks = new
|
|
18316
|
+
this._hooks = new import_sdk_core4.HooksService({});
|
|
18247
18317
|
this._hooks.initialize(this._serviceContext);
|
|
18248
18318
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
18249
18319
|
const serviceSession = {
|
|
@@ -18255,7 +18325,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18255
18325
|
};
|
|
18256
18326
|
this._serviceContext.setSession(serviceSession);
|
|
18257
18327
|
const wasm = this.wasmBindings;
|
|
18258
|
-
const vaultCrypto = (0,
|
|
18328
|
+
const vaultCrypto = (0, import_sdk_core4.createVaultCrypto)({
|
|
18259
18329
|
vault_encrypt: wasm.vault_encrypt,
|
|
18260
18330
|
vault_decrypt: wasm.vault_decrypt,
|
|
18261
18331
|
vault_derive_key: wasm.vault_derive_key,
|
|
@@ -18265,7 +18335,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18265
18335
|
vault_sha256: wasm.vault_sha256
|
|
18266
18336
|
});
|
|
18267
18337
|
const self2 = this;
|
|
18268
|
-
this._vault = new
|
|
18338
|
+
this._vault = new import_sdk_core4.DataVaultService({
|
|
18269
18339
|
spaceId: sessionData.spaceId,
|
|
18270
18340
|
crypto: vaultCrypto,
|
|
18271
18341
|
tc: {
|
|
@@ -18281,8 +18351,8 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18281
18351
|
get publicKV() {
|
|
18282
18352
|
return self2._publicKV ?? self2.tc.publicKV;
|
|
18283
18353
|
},
|
|
18284
|
-
readPublicSpace: (host, spaceId, key2) =>
|
|
18285
|
-
makePublicSpaceId:
|
|
18354
|
+
readPublicSpace: (host, spaceId, key2) => import_sdk_core4.TinyCloud.readPublicSpace(host, spaceId, key2),
|
|
18355
|
+
makePublicSpaceId: import_sdk_core4.TinyCloud.makePublicSpaceId,
|
|
18286
18356
|
did: this.did,
|
|
18287
18357
|
address: sessionData.address ?? this._address ?? "",
|
|
18288
18358
|
chainId: sessionData.chainId ?? this._chainId,
|
|
@@ -18345,7 +18415,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18345
18415
|
nonce: this.config.nonce,
|
|
18346
18416
|
siweConfig: this.config.siweConfig
|
|
18347
18417
|
});
|
|
18348
|
-
this.tc = new
|
|
18418
|
+
this.tc = new import_sdk_core4.TinyCloud(this.auth, {
|
|
18349
18419
|
invokeAny: this.wasmBindings.invokeAny
|
|
18350
18420
|
});
|
|
18351
18421
|
this.config.prefix = prefix;
|
|
@@ -18385,7 +18455,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18385
18455
|
nonce: this.config.nonce,
|
|
18386
18456
|
siweConfig: this.config.siweConfig
|
|
18387
18457
|
});
|
|
18388
|
-
this.tc = new
|
|
18458
|
+
this.tc = new import_sdk_core4.TinyCloud(this.auth, {
|
|
18389
18459
|
invokeAny: this.wasmBindings.invokeAny
|
|
18390
18460
|
});
|
|
18391
18461
|
this.config.prefix = prefix;
|
|
@@ -18400,27 +18470,27 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18400
18470
|
return;
|
|
18401
18471
|
}
|
|
18402
18472
|
this.tc.initializeServices(this.wasmBindings.invoke, [this.config.host]);
|
|
18403
|
-
this._serviceContext = new
|
|
18473
|
+
this._serviceContext = new import_sdk_core4.ServiceContext({
|
|
18404
18474
|
invoke: this.wasmBindings.invoke,
|
|
18405
18475
|
invokeAny: this.wasmBindings.invokeAny,
|
|
18406
18476
|
fetch: globalThis.fetch.bind(globalThis),
|
|
18407
18477
|
hosts: [this.config.host]
|
|
18408
18478
|
});
|
|
18409
|
-
this._kv = new
|
|
18479
|
+
this._kv = new import_sdk_core4.KVService({});
|
|
18410
18480
|
this._kv.initialize(this._serviceContext);
|
|
18411
18481
|
this._serviceContext.registerService("kv", this._kv);
|
|
18412
18482
|
const features = this.nodeFeatures;
|
|
18413
18483
|
if (features.length === 0 || features.includes("sql")) {
|
|
18414
|
-
this._sql = new
|
|
18484
|
+
this._sql = new import_sdk_core4.SQLService({});
|
|
18415
18485
|
this._sql.initialize(this._serviceContext);
|
|
18416
18486
|
this._serviceContext.registerService("sql", this._sql);
|
|
18417
18487
|
}
|
|
18418
18488
|
if (features.length === 0 || features.includes("duckdb")) {
|
|
18419
|
-
this._duckdb = new
|
|
18489
|
+
this._duckdb = new import_sdk_core4.DuckDbService({});
|
|
18420
18490
|
this._duckdb.initialize(this._serviceContext);
|
|
18421
18491
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
18422
18492
|
}
|
|
18423
|
-
this._hooks = new
|
|
18493
|
+
this._hooks = new import_sdk_core4.HooksService({});
|
|
18424
18494
|
this._hooks.initialize(this._serviceContext);
|
|
18425
18495
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
18426
18496
|
const serviceSession = {
|
|
@@ -18433,7 +18503,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18433
18503
|
this._serviceContext.setSession(serviceSession);
|
|
18434
18504
|
this.tc.serviceContext.setSession(serviceSession);
|
|
18435
18505
|
const wasm = this.wasmBindings;
|
|
18436
|
-
const vaultCrypto = (0,
|
|
18506
|
+
const vaultCrypto = (0, import_sdk_core4.createVaultCrypto)({
|
|
18437
18507
|
vault_encrypt: wasm.vault_encrypt,
|
|
18438
18508
|
vault_decrypt: wasm.vault_decrypt,
|
|
18439
18509
|
vault_derive_key: wasm.vault_derive_key,
|
|
@@ -18443,7 +18513,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18443
18513
|
vault_sha256: wasm.vault_sha256
|
|
18444
18514
|
});
|
|
18445
18515
|
const self2 = this;
|
|
18446
|
-
this._vault = new
|
|
18516
|
+
this._vault = new import_sdk_core4.DataVaultService({
|
|
18447
18517
|
spaceId: session.spaceId,
|
|
18448
18518
|
crypto: vaultCrypto,
|
|
18449
18519
|
tc: {
|
|
@@ -18459,8 +18529,8 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18459
18529
|
get publicKV() {
|
|
18460
18530
|
return self2._publicKV ?? self2.tc.publicKV;
|
|
18461
18531
|
},
|
|
18462
|
-
readPublicSpace: (host, spaceId, key2) =>
|
|
18463
|
-
makePublicSpaceId:
|
|
18532
|
+
readPublicSpace: (host, spaceId, key2) => import_sdk_core4.TinyCloud.readPublicSpace(host, spaceId, key2),
|
|
18533
|
+
makePublicSpaceId: import_sdk_core4.TinyCloud.makePublicSpaceId,
|
|
18464
18534
|
did: this.did,
|
|
18465
18535
|
address: this._address,
|
|
18466
18536
|
chainId: this._chainId,
|
|
@@ -18476,7 +18546,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18476
18546
|
* @internal
|
|
18477
18547
|
*/
|
|
18478
18548
|
initializeV2Services(serviceSession) {
|
|
18479
|
-
this._capabilityRegistry = new
|
|
18549
|
+
this._capabilityRegistry = new import_sdk_core4.CapabilityKeyRegistry();
|
|
18480
18550
|
const tcSession = this.auth?.tinyCloudSession;
|
|
18481
18551
|
if (tcSession && this._address) {
|
|
18482
18552
|
const sessionKey = {
|
|
@@ -18550,13 +18620,13 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18550
18620
|
}
|
|
18551
18621
|
this._capabilityRegistry.registerKey(sessionKey, delegations);
|
|
18552
18622
|
}
|
|
18553
|
-
this._delegationManager = new
|
|
18623
|
+
this._delegationManager = new import_sdk_core4.DelegationManager({
|
|
18554
18624
|
hosts: [this.config.host],
|
|
18555
18625
|
session: serviceSession,
|
|
18556
18626
|
invoke: this.wasmBindings.invoke,
|
|
18557
18627
|
fetch: globalThis.fetch.bind(globalThis)
|
|
18558
18628
|
});
|
|
18559
|
-
this._spaceService = new
|
|
18629
|
+
this._spaceService = new import_sdk_core4.SpaceService({
|
|
18560
18630
|
hosts: [this.config.host],
|
|
18561
18631
|
session: serviceSession,
|
|
18562
18632
|
invoke: this.wasmBindings.invoke,
|
|
@@ -18564,9 +18634,9 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18564
18634
|
capabilityRegistry: this._capabilityRegistry,
|
|
18565
18635
|
userDid: this.did,
|
|
18566
18636
|
createKVService: (spaceId) => {
|
|
18567
|
-
const kvService = new
|
|
18637
|
+
const kvService = new import_sdk_core4.KVService({});
|
|
18568
18638
|
if (this._serviceContext) {
|
|
18569
|
-
const spaceScopedContext = new
|
|
18639
|
+
const spaceScopedContext = new import_sdk_core4.ServiceContext({
|
|
18570
18640
|
invoke: this._serviceContext.invoke,
|
|
18571
18641
|
fetch: this._serviceContext.fetch,
|
|
18572
18642
|
hosts: this._serviceContext.hosts
|
|
@@ -18705,7 +18775,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18705
18775
|
...prepared,
|
|
18706
18776
|
signature: signature2
|
|
18707
18777
|
});
|
|
18708
|
-
const activateResult = await (0,
|
|
18778
|
+
const activateResult = await (0, import_sdk_core4.activateSessionWithHost)(
|
|
18709
18779
|
host,
|
|
18710
18780
|
delegationSession.delegationHeader
|
|
18711
18781
|
);
|
|
@@ -18772,7 +18842,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18772
18842
|
if (!this._sql) {
|
|
18773
18843
|
const features = this.nodeFeatures;
|
|
18774
18844
|
if (features.length > 0 && !features.includes("sql")) {
|
|
18775
|
-
throw new
|
|
18845
|
+
throw new import_sdk_core4.UnsupportedFeatureError("sql", this.config.host, features);
|
|
18776
18846
|
}
|
|
18777
18847
|
throw new Error("Not signed in. Call signIn() first.");
|
|
18778
18848
|
}
|
|
@@ -18785,7 +18855,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18785
18855
|
if (!this._duckdb) {
|
|
18786
18856
|
const features = this.nodeFeatures;
|
|
18787
18857
|
if (features.length > 0 && !features.includes("duckdb")) {
|
|
18788
|
-
throw new
|
|
18858
|
+
throw new import_sdk_core4.UnsupportedFeatureError("duckdb", this.config.host, features);
|
|
18789
18859
|
}
|
|
18790
18860
|
throw new Error("Not signed in. Call signIn() first.");
|
|
18791
18861
|
}
|
|
@@ -19024,7 +19094,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
19024
19094
|
...prepared,
|
|
19025
19095
|
signature: signature2
|
|
19026
19096
|
});
|
|
19027
|
-
const activateResult = await (0,
|
|
19097
|
+
const activateResult = await (0, import_sdk_core4.activateSessionWithHost)(
|
|
19028
19098
|
this.config.host,
|
|
19029
19099
|
delegationSession.delegationHeader
|
|
19030
19100
|
);
|
|
@@ -19051,8 +19121,8 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
19051
19121
|
}]);
|
|
19052
19122
|
}
|
|
19053
19123
|
if (this._serviceContext) {
|
|
19054
|
-
const publicKV = new
|
|
19055
|
-
const publicContext = new
|
|
19124
|
+
const publicKV = new import_sdk_core4.KVService({ prefix: "" });
|
|
19125
|
+
const publicContext = new import_sdk_core4.ServiceContext({
|
|
19056
19126
|
invoke: this.wasmBindings.invoke,
|
|
19057
19127
|
fetch: this._serviceContext.fetch,
|
|
19058
19128
|
hosts: this._serviceContext.hosts
|
|
@@ -19137,6 +19207,150 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
19137
19207
|
async checkPermission(path, action) {
|
|
19138
19208
|
return this.delegationManager.checkPermission(path, action);
|
|
19139
19209
|
}
|
|
19210
|
+
/**
|
|
19211
|
+
* Issue a delegation using the capability-chain flow.
|
|
19212
|
+
*
|
|
19213
|
+
* When the requested permissions are a subset of the current session's
|
|
19214
|
+
* recap, the delegation is signed by the session key via WASM — no wallet
|
|
19215
|
+
* prompt. When they are not, a {@link PermissionNotInManifestError} is
|
|
19216
|
+
* raised so the caller can trigger an escalation flow (e.g.
|
|
19217
|
+
* `TinyCloudWeb.requestPermissions`). Passing `forceWalletSign: true`
|
|
19218
|
+
* bypasses the derivability check and always uses the wallet-signed SIWE
|
|
19219
|
+
* path — used by the legacy `createDelegation` fallback and by callers
|
|
19220
|
+
* that want explicit wallet confirmation.
|
|
19221
|
+
*
|
|
19222
|
+
* Current limitation: exactly one {@link PermissionEntry} per call. For
|
|
19223
|
+
* multi-resource delegation, call `delegateTo` multiple times. This keeps
|
|
19224
|
+
* each delegation a single `(spaceId, path)` grant, which matches the
|
|
19225
|
+
* underlying `PortableDelegation` shape.
|
|
19226
|
+
*
|
|
19227
|
+
* @throws {@link SessionExpiredError} when there is no session or the
|
|
19228
|
+
* current session has expired (or will within the 60s safety margin).
|
|
19229
|
+
* @throws {@link PermissionNotInManifestError} when the requested entries
|
|
19230
|
+
* are not a subset of the granted session capabilities and
|
|
19231
|
+
* `forceWalletSign` is not set.
|
|
19232
|
+
*/
|
|
19233
|
+
async delegateTo(did, permissions, options) {
|
|
19234
|
+
const session = this.auth?.tinyCloudSession;
|
|
19235
|
+
if (!session) {
|
|
19236
|
+
throw new import_sdk_core4.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
19237
|
+
}
|
|
19238
|
+
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
19239
|
+
if (sessionExpiry !== void 0) {
|
|
19240
|
+
const now2 = Date.now();
|
|
19241
|
+
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
19242
|
+
if (sessionExpiry.getTime() <= now2 + marginMs) {
|
|
19243
|
+
throw new import_sdk_core4.SessionExpiredError(sessionExpiry);
|
|
19244
|
+
}
|
|
19245
|
+
}
|
|
19246
|
+
if (!Array.isArray(permissions) || permissions.length === 0) {
|
|
19247
|
+
throw new Error(
|
|
19248
|
+
"delegateTo requires a non-empty permissions array"
|
|
19249
|
+
);
|
|
19250
|
+
}
|
|
19251
|
+
if (permissions.length > 1) {
|
|
19252
|
+
throw new Error(
|
|
19253
|
+
"delegateTo currently supports one permission entry per call. Call delegateTo multiple times for multi-resource delegation."
|
|
19254
|
+
);
|
|
19255
|
+
}
|
|
19256
|
+
const entry = permissions[0];
|
|
19257
|
+
const expandedEntry = {
|
|
19258
|
+
...entry,
|
|
19259
|
+
actions: (0, import_sdk_core4.expandActionShortNames)(entry.service, entry.actions)
|
|
19260
|
+
};
|
|
19261
|
+
const now = /* @__PURE__ */ new Date();
|
|
19262
|
+
const expiryMs = resolveExpiryMs(options?.expiry);
|
|
19263
|
+
const expirationTime = new Date(now.getTime() + expiryMs);
|
|
19264
|
+
let effectiveExpiration = expirationTime;
|
|
19265
|
+
if (sessionExpiry !== void 0 && sessionExpiry < expirationTime) {
|
|
19266
|
+
effectiveExpiration = sessionExpiry;
|
|
19267
|
+
}
|
|
19268
|
+
if (options?.forceWalletSign) {
|
|
19269
|
+
const delegation2 = await this.createDelegationLegacyWalletPath(
|
|
19270
|
+
did,
|
|
19271
|
+
expandedEntry,
|
|
19272
|
+
effectiveExpiration
|
|
19273
|
+
);
|
|
19274
|
+
return { delegation: delegation2, prompted: true };
|
|
19275
|
+
}
|
|
19276
|
+
const granted = (0, import_sdk_core4.parseRecapCapabilities)(
|
|
19277
|
+
(siwe) => this.wasmBindings.parseRecapFromSiwe(siwe),
|
|
19278
|
+
session.siwe
|
|
19279
|
+
);
|
|
19280
|
+
const requested = [expandedEntry];
|
|
19281
|
+
const { subset, missing } = (0, import_sdk_core4.isCapabilitySubset)(requested, granted);
|
|
19282
|
+
if (!subset) {
|
|
19283
|
+
throw new import_sdk_core4.PermissionNotInManifestError(missing, granted);
|
|
19284
|
+
}
|
|
19285
|
+
const delegation = await this.createDelegationViaWasmPath(
|
|
19286
|
+
did,
|
|
19287
|
+
expandedEntry,
|
|
19288
|
+
effectiveExpiration,
|
|
19289
|
+
session
|
|
19290
|
+
);
|
|
19291
|
+
return { delegation, prompted: false };
|
|
19292
|
+
}
|
|
19293
|
+
/**
|
|
19294
|
+
* Issue a delegation via the session-key UCAN WASM path.
|
|
19295
|
+
*
|
|
19296
|
+
* The caller has already verified the request is derivable from the
|
|
19297
|
+
* current session; we just need to shape the inputs for
|
|
19298
|
+
* {@link createDelegationWrapper}.
|
|
19299
|
+
*
|
|
19300
|
+
* @internal
|
|
19301
|
+
*/
|
|
19302
|
+
async createDelegationViaWasmPath(did, entry, expirationTime, session) {
|
|
19303
|
+
const spaceId = entry.space === "default" ? session.spaceId : entry.space;
|
|
19304
|
+
const serviceSession = {
|
|
19305
|
+
delegationHeader: session.delegationHeader,
|
|
19306
|
+
delegationCid: session.delegationCid,
|
|
19307
|
+
jwk: session.jwk,
|
|
19308
|
+
spaceId,
|
|
19309
|
+
verificationMethod: session.verificationMethod
|
|
19310
|
+
};
|
|
19311
|
+
const expirationSecs = Math.floor(expirationTime.getTime() / 1e3);
|
|
19312
|
+
const result = this.createDelegationWrapper({
|
|
19313
|
+
session: serviceSession,
|
|
19314
|
+
delegateDID: did,
|
|
19315
|
+
spaceId,
|
|
19316
|
+
path: entry.path,
|
|
19317
|
+
actions: entry.actions,
|
|
19318
|
+
expirationSecs
|
|
19319
|
+
});
|
|
19320
|
+
return {
|
|
19321
|
+
cid: result.cid,
|
|
19322
|
+
delegationHeader: { Authorization: `Bearer ${result.delegation}` },
|
|
19323
|
+
spaceId,
|
|
19324
|
+
path: entry.path,
|
|
19325
|
+
actions: entry.actions,
|
|
19326
|
+
disableSubDelegation: false,
|
|
19327
|
+
expiry: result.expiry,
|
|
19328
|
+
delegateDID: did,
|
|
19329
|
+
ownerAddress: session.address,
|
|
19330
|
+
chainId: session.chainId,
|
|
19331
|
+
host: this.config.host
|
|
19332
|
+
};
|
|
19333
|
+
}
|
|
19334
|
+
/**
|
|
19335
|
+
* Issue a delegation via the legacy wallet-signed SIWE path for a single
|
|
19336
|
+
* {@link PermissionEntry}. Shares the implementation with the public
|
|
19337
|
+
* `createDelegation` method via {@link createDelegationWalletPath} so
|
|
19338
|
+
* both entry points hit exactly the same SIWE / signer / public-space
|
|
19339
|
+
* logic without mutual recursion.
|
|
19340
|
+
*
|
|
19341
|
+
* @internal
|
|
19342
|
+
*/
|
|
19343
|
+
async createDelegationLegacyWalletPath(delegateDID, entry, expirationTime) {
|
|
19344
|
+
const spaceIdOverride = entry.space === "default" ? void 0 : entry.space;
|
|
19345
|
+
return this.createDelegationWalletPath({
|
|
19346
|
+
path: entry.path,
|
|
19347
|
+
actions: entry.actions,
|
|
19348
|
+
delegateDID,
|
|
19349
|
+
includePublicSpace: true,
|
|
19350
|
+
expiryMs: Math.max(0, expirationTime.getTime() - Date.now()),
|
|
19351
|
+
spaceIdOverride
|
|
19352
|
+
});
|
|
19353
|
+
}
|
|
19140
19354
|
/**
|
|
19141
19355
|
* Create a delegation from this user to another user.
|
|
19142
19356
|
*
|
|
@@ -19147,6 +19361,51 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
19147
19361
|
* @returns A portable delegation that can be sent to the recipient
|
|
19148
19362
|
*/
|
|
19149
19363
|
async createDelegation(params) {
|
|
19364
|
+
if (!this.signer) {
|
|
19365
|
+
throw new Error("Cannot createDelegation() in session-only mode. Requires wallet mode.");
|
|
19366
|
+
}
|
|
19367
|
+
if (!this.auth?.tinyCloudSession) {
|
|
19368
|
+
throw new Error("Not signed in. Call signIn() first.");
|
|
19369
|
+
}
|
|
19370
|
+
let resolvedDelegateDID = params.delegateDID;
|
|
19371
|
+
if (resolvedDelegateDID.endsWith(".eth") && this.config.ensResolver) {
|
|
19372
|
+
const address = await this.config.ensResolver.resolveAddress(resolvedDelegateDID);
|
|
19373
|
+
if (!address) throw new Error(`Could not resolve ENS name: ${resolvedDelegateDID}`);
|
|
19374
|
+
resolvedDelegateDID = `did:pkh:eip155:1:${address}`;
|
|
19375
|
+
}
|
|
19376
|
+
const entries = legacyParamsToPermissionEntries(
|
|
19377
|
+
params.actions,
|
|
19378
|
+
params.path,
|
|
19379
|
+
params.spaceIdOverride
|
|
19380
|
+
);
|
|
19381
|
+
if (entries.length === 1) {
|
|
19382
|
+
try {
|
|
19383
|
+
const result = await this.delegateTo(
|
|
19384
|
+
resolvedDelegateDID,
|
|
19385
|
+
[entries[0]],
|
|
19386
|
+
params.expiryMs !== void 0 ? { expiry: params.expiryMs } : void 0
|
|
19387
|
+
);
|
|
19388
|
+
return result.delegation;
|
|
19389
|
+
} catch (err) {
|
|
19390
|
+
if (err instanceof import_sdk_core4.PermissionNotInManifestError) {
|
|
19391
|
+
} else {
|
|
19392
|
+
throw err;
|
|
19393
|
+
}
|
|
19394
|
+
}
|
|
19395
|
+
}
|
|
19396
|
+
return this.createDelegationWalletPath({
|
|
19397
|
+
...params,
|
|
19398
|
+
delegateDID: resolvedDelegateDID
|
|
19399
|
+
});
|
|
19400
|
+
}
|
|
19401
|
+
/**
|
|
19402
|
+
* Legacy wallet-signed SIWE delegation path. Lifted from the original
|
|
19403
|
+
* `createDelegation` body verbatim so both the legacy public method and
|
|
19404
|
+
* `delegateTo({ forceWalletSign: true })` hit the same code.
|
|
19405
|
+
*
|
|
19406
|
+
* @internal
|
|
19407
|
+
*/
|
|
19408
|
+
async createDelegationWalletPath(params) {
|
|
19150
19409
|
if (!this.signer) {
|
|
19151
19410
|
throw new Error("Cannot createDelegation() in session-only mode. Requires wallet mode.");
|
|
19152
19411
|
}
|
|
@@ -19154,11 +19413,6 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
19154
19413
|
if (!session) {
|
|
19155
19414
|
throw new Error("Not signed in. Call signIn() first.");
|
|
19156
19415
|
}
|
|
19157
|
-
if (params.delegateDID.endsWith(".eth") && this.config.ensResolver) {
|
|
19158
|
-
const address = await this.config.ensResolver.resolveAddress(params.delegateDID);
|
|
19159
|
-
if (!address) throw new Error(`Could not resolve ENS name: ${params.delegateDID}`);
|
|
19160
|
-
params = { ...params, delegateDID: `did:pkh:eip155:1:${address}` };
|
|
19161
|
-
}
|
|
19162
19416
|
const abilities = {};
|
|
19163
19417
|
const kvActions = params.actions.filter((a) => a.startsWith("tinycloud.kv/"));
|
|
19164
19418
|
const sqlActions = params.actions.filter((a) => a.startsWith("tinycloud.sql/"));
|
|
@@ -19191,7 +19445,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
19191
19445
|
...prepared,
|
|
19192
19446
|
signature: signature2
|
|
19193
19447
|
});
|
|
19194
|
-
const activateResult = await (0,
|
|
19448
|
+
const activateResult = await (0, import_sdk_core4.activateSessionWithHost)(
|
|
19195
19449
|
this.config.host,
|
|
19196
19450
|
delegationSession.delegationHeader
|
|
19197
19451
|
);
|
|
@@ -19213,7 +19467,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
19213
19467
|
};
|
|
19214
19468
|
const hasKvActions = params.actions.some((a) => a.startsWith("tinycloud.kv/"));
|
|
19215
19469
|
if (hasKvActions && params.includePublicSpace !== false) {
|
|
19216
|
-
const publicSpaceId = (0,
|
|
19470
|
+
const publicSpaceId = (0, import_sdk_core4.makePublicSpaceId)(
|
|
19217
19471
|
this.wasmBindings.ensureEip55(session.address),
|
|
19218
19472
|
session.chainId
|
|
19219
19473
|
);
|
|
@@ -19236,7 +19490,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
19236
19490
|
...publicPrepared,
|
|
19237
19491
|
signature: publicSignature
|
|
19238
19492
|
});
|
|
19239
|
-
const publicActivateResult = await (0,
|
|
19493
|
+
const publicActivateResult = await (0, import_sdk_core4.activateSessionWithHost)(
|
|
19240
19494
|
this.config.host,
|
|
19241
19495
|
publicSession.delegationHeader
|
|
19242
19496
|
);
|
|
@@ -19335,7 +19589,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
19335
19589
|
...prepared,
|
|
19336
19590
|
signature: signature2
|
|
19337
19591
|
});
|
|
19338
|
-
const activateResult = await (0,
|
|
19592
|
+
const activateResult = await (0, import_sdk_core4.activateSessionWithHost)(
|
|
19339
19593
|
targetHost,
|
|
19340
19594
|
invokerSession.delegationHeader
|
|
19341
19595
|
);
|
|
@@ -19424,7 +19678,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
19424
19678
|
...prepared,
|
|
19425
19679
|
signature: signature2
|
|
19426
19680
|
});
|
|
19427
|
-
const activateResult = await (0,
|
|
19681
|
+
const activateResult = await (0, import_sdk_core4.activateSessionWithHost)(
|
|
19428
19682
|
targetHost,
|
|
19429
19683
|
subDelegationSession.delegationHeader
|
|
19430
19684
|
);
|
|
@@ -19446,6 +19700,18 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
19446
19700
|
};
|
|
19447
19701
|
}
|
|
19448
19702
|
};
|
|
19703
|
+
// ===========================================================================
|
|
19704
|
+
// Capability-chain delegation (spec: .claude/specs/capability-chain.md)
|
|
19705
|
+
// ===========================================================================
|
|
19706
|
+
/**
|
|
19707
|
+
* Safety margin before the session's own expiry at which {@link delegateTo}
|
|
19708
|
+
* will refuse to issue a derived delegation. Prevents issuing sub-delegations
|
|
19709
|
+
* that would be invalid by the time the recipient used them. Spec: 60 seconds.
|
|
19710
|
+
*
|
|
19711
|
+
* @internal
|
|
19712
|
+
*/
|
|
19713
|
+
_TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS = 6e4;
|
|
19714
|
+
var TinyCloudNode = _TinyCloudNode;
|
|
19449
19715
|
|
|
19450
19716
|
// src/nodeDefaults.ts
|
|
19451
19717
|
TinyCloudNode.registerNodeDefaults({
|
|
@@ -19454,11 +19720,11 @@ TinyCloudNode.registerNodeDefaults({
|
|
|
19454
19720
|
});
|
|
19455
19721
|
|
|
19456
19722
|
// src/index.ts
|
|
19457
|
-
var import_sdk_core5 = require("@tinycloud/sdk-core");
|
|
19458
19723
|
var import_sdk_core6 = require("@tinycloud/sdk-core");
|
|
19724
|
+
var import_sdk_core7 = require("@tinycloud/sdk-core");
|
|
19459
19725
|
|
|
19460
19726
|
// src/storage/FileSessionStorage.ts
|
|
19461
|
-
var
|
|
19727
|
+
var import_sdk_core5 = require("@tinycloud/sdk-core");
|
|
19462
19728
|
var import_fs = require("fs");
|
|
19463
19729
|
var import_path = require("path");
|
|
19464
19730
|
var FileSessionStorage = class {
|
|
@@ -19513,7 +19779,7 @@ var FileSessionStorage = class {
|
|
|
19513
19779
|
try {
|
|
19514
19780
|
const data = (0, import_fs.readFileSync)(filePath, "utf-8");
|
|
19515
19781
|
const parsed = JSON.parse(data);
|
|
19516
|
-
const validation = (0,
|
|
19782
|
+
const validation = (0, import_sdk_core5.validatePersistedSessionData)(parsed);
|
|
19517
19783
|
if (!validation.ok) {
|
|
19518
19784
|
console.warn(`Invalid session data for ${address}:`, validation.error.message);
|
|
19519
19785
|
(0, import_fs.unlinkSync)(filePath);
|
|
@@ -19577,6 +19843,9 @@ var FileSessionStorage = class {
|
|
|
19577
19843
|
}
|
|
19578
19844
|
};
|
|
19579
19845
|
|
|
19846
|
+
// src/index.ts
|
|
19847
|
+
var import_sdk_core8 = require("@tinycloud/sdk-core");
|
|
19848
|
+
|
|
19580
19849
|
// src/delegation.ts
|
|
19581
19850
|
function serializeDelegation(delegation) {
|
|
19582
19851
|
return JSON.stringify({
|
|
@@ -19594,8 +19863,6 @@ function deserializeDelegation(data) {
|
|
|
19594
19863
|
}
|
|
19595
19864
|
|
|
19596
19865
|
// src/index.ts
|
|
19597
|
-
var import_sdk_core7 = require("@tinycloud/sdk-core");
|
|
19598
|
-
var import_sdk_core8 = require("@tinycloud/sdk-core");
|
|
19599
19866
|
var import_sdk_core9 = require("@tinycloud/sdk-core");
|
|
19600
19867
|
var import_sdk_core10 = require("@tinycloud/sdk-core");
|
|
19601
19868
|
var import_sdk_core11 = require("@tinycloud/sdk-core");
|
|
@@ -19604,6 +19871,8 @@ var import_sdk_core13 = require("@tinycloud/sdk-core");
|
|
|
19604
19871
|
var import_sdk_core14 = require("@tinycloud/sdk-core");
|
|
19605
19872
|
var import_sdk_core15 = require("@tinycloud/sdk-core");
|
|
19606
19873
|
var import_sdk_core16 = require("@tinycloud/sdk-core");
|
|
19874
|
+
var import_sdk_core17 = require("@tinycloud/sdk-core");
|
|
19875
|
+
var import_sdk_core18 = require("@tinycloud/sdk-core");
|
|
19607
19876
|
// Annotate the CommonJS export names for ESM import in node:
|
|
19608
19877
|
0 && (module.exports = {
|
|
19609
19878
|
AutoApproveSpaceCreationHandler,
|
|
@@ -19620,15 +19889,18 @@ var import_sdk_core16 = require("@tinycloud/sdk-core");
|
|
|
19620
19889
|
FileSessionStorage,
|
|
19621
19890
|
HooksService,
|
|
19622
19891
|
KVService,
|
|
19892
|
+
ManifestValidationError,
|
|
19623
19893
|
MemorySessionStorage,
|
|
19624
19894
|
NodeUserAuthorization,
|
|
19625
19895
|
NodeWasmBindings,
|
|
19896
|
+
PermissionNotInManifestError,
|
|
19626
19897
|
PrefixedKVService,
|
|
19627
19898
|
PrivateKeySigner,
|
|
19628
19899
|
ProtocolMismatchError,
|
|
19629
19900
|
SQLAction,
|
|
19630
19901
|
SQLService,
|
|
19631
19902
|
ServiceContext,
|
|
19903
|
+
SessionExpiredError,
|
|
19632
19904
|
SharingService,
|
|
19633
19905
|
SilentNotificationHandler,
|
|
19634
19906
|
Space,
|
|
@@ -19651,9 +19923,15 @@ var import_sdk_core16 = require("@tinycloud/sdk-core");
|
|
|
19651
19923
|
defaultSignStrategy,
|
|
19652
19924
|
defaultSpaceCreationHandler,
|
|
19653
19925
|
deserializeDelegation,
|
|
19926
|
+
expandActionShortNames,
|
|
19927
|
+
isCapabilitySubset,
|
|
19928
|
+
loadManifest,
|
|
19654
19929
|
makePublicSpaceId,
|
|
19930
|
+
parseExpiry,
|
|
19655
19931
|
parseSpaceUri,
|
|
19656
|
-
|
|
19932
|
+
resolveManifest,
|
|
19933
|
+
serializeDelegation,
|
|
19934
|
+
validateManifest
|
|
19657
19935
|
});
|
|
19658
19936
|
/*! Bundled license information:
|
|
19659
19937
|
|