@tinycloud/node-sdk 2.4.0-beta.3 → 2.4.0-beta.6
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-ClOKiSR_.d.cts → core-zT0sxgtZ.d.cts} +14 -2
- package/dist/{core-ClOKiSR_.d.ts → core-zT0sxgtZ.d.ts} +14 -2
- package/dist/core.cjs +287 -201
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +115 -27
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +330 -244
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +119 -31
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/core.cjs
CHANGED
|
@@ -30,94 +30,95 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/core.ts
|
|
31
31
|
var core_exports = {};
|
|
32
32
|
__export(core_exports, {
|
|
33
|
-
ACCOUNT_REGISTRY_PATH: () =>
|
|
34
|
-
ACCOUNT_REGISTRY_SPACE: () =>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
ACCOUNT_REGISTRY_PATH: () => import_sdk_core10.ACCOUNT_REGISTRY_PATH,
|
|
34
|
+
ACCOUNT_REGISTRY_SPACE: () => import_sdk_core10.ACCOUNT_REGISTRY_SPACE,
|
|
35
|
+
AccountService: () => import_sdk_core3.AccountService,
|
|
36
|
+
AutoApproveSpaceCreationHandler: () => import_sdk_core9.AutoApproveSpaceCreationHandler,
|
|
37
|
+
CapabilityKeyRegistry: () => import_sdk_core16.CapabilityKeyRegistry,
|
|
38
|
+
CapabilityKeyRegistryErrorCodes: () => import_sdk_core16.CapabilityKeyRegistryErrorCodes,
|
|
39
|
+
DEFAULT_MANIFEST_SPACE: () => import_sdk_core10.DEFAULT_MANIFEST_SPACE,
|
|
40
|
+
DEFAULT_MANIFEST_VERSION: () => import_sdk_core10.DEFAULT_MANIFEST_VERSION,
|
|
41
|
+
DEFAULT_SIGNED_READ_URL_EXPIRY_MS: () => import_sdk_core11.DEFAULT_SIGNED_READ_URL_EXPIRY_MS,
|
|
42
|
+
DataVaultService: () => import_sdk_core14.DataVaultService,
|
|
43
|
+
DatabaseHandle: () => import_sdk_core12.DatabaseHandle,
|
|
43
44
|
DelegatedAccess: () => DelegatedAccess,
|
|
44
|
-
DelegationErrorCodes: () =>
|
|
45
|
-
DelegationManager: () =>
|
|
46
|
-
DuckDbAction: () =>
|
|
47
|
-
DuckDbDatabaseHandle: () =>
|
|
48
|
-
DuckDbService: () =>
|
|
45
|
+
DelegationErrorCodes: () => import_sdk_core15.DelegationErrorCodes,
|
|
46
|
+
DelegationManager: () => import_sdk_core15.DelegationManager,
|
|
47
|
+
DuckDbAction: () => import_sdk_core13.DuckDbAction,
|
|
48
|
+
DuckDbDatabaseHandle: () => import_sdk_core13.DuckDbDatabaseHandle,
|
|
49
|
+
DuckDbService: () => import_sdk_core13.DuckDbService,
|
|
49
50
|
FileSessionStorage: () => FileSessionStorage,
|
|
50
|
-
IdentityParseError: () =>
|
|
51
|
-
KVService: () =>
|
|
52
|
-
ManifestValidationError: () =>
|
|
51
|
+
IdentityParseError: () => import_sdk_core9.IdentityParseError,
|
|
52
|
+
KVService: () => import_sdk_core11.KVService,
|
|
53
|
+
ManifestValidationError: () => import_sdk_core10.ManifestValidationError,
|
|
53
54
|
MemorySessionStorage: () => MemorySessionStorage,
|
|
54
55
|
NodeUserAuthorization: () => NodeUserAuthorization,
|
|
55
|
-
PermissionNotInManifestError: () =>
|
|
56
|
-
PrefixedKVService: () =>
|
|
57
|
-
ProtocolMismatchError: () =>
|
|
58
|
-
SECRET_NAME_RE: () =>
|
|
59
|
-
SQLAction: () =>
|
|
60
|
-
SQLService: () =>
|
|
61
|
-
SecretsService: () =>
|
|
62
|
-
ServiceContext: () =>
|
|
63
|
-
SessionExpiredError: () =>
|
|
64
|
-
SharingService: () =>
|
|
65
|
-
SilentNotificationHandler: () =>
|
|
66
|
-
Space: () =>
|
|
67
|
-
SpaceErrorCodes: () =>
|
|
68
|
-
SpaceService: () =>
|
|
69
|
-
TinyCloud: () =>
|
|
56
|
+
PermissionNotInManifestError: () => import_sdk_core10.PermissionNotInManifestError,
|
|
57
|
+
PrefixedKVService: () => import_sdk_core11.PrefixedKVService,
|
|
58
|
+
ProtocolMismatchError: () => import_sdk_core18.ProtocolMismatchError,
|
|
59
|
+
SECRET_NAME_RE: () => import_sdk_core14.SECRET_NAME_RE,
|
|
60
|
+
SQLAction: () => import_sdk_core12.SQLAction,
|
|
61
|
+
SQLService: () => import_sdk_core12.SQLService,
|
|
62
|
+
SecretsService: () => import_sdk_core14.SecretsService,
|
|
63
|
+
ServiceContext: () => import_sdk_core19.ServiceContext,
|
|
64
|
+
SessionExpiredError: () => import_sdk_core10.SessionExpiredError,
|
|
65
|
+
SharingService: () => import_sdk_core15.SharingService,
|
|
66
|
+
SilentNotificationHandler: () => import_sdk_core9.SilentNotificationHandler,
|
|
67
|
+
Space: () => import_sdk_core17.Space,
|
|
68
|
+
SpaceErrorCodes: () => import_sdk_core17.SpaceErrorCodes,
|
|
69
|
+
SpaceService: () => import_sdk_core17.SpaceService,
|
|
70
|
+
TinyCloud: () => import_sdk_core8.TinyCloud,
|
|
70
71
|
TinyCloudNode: () => TinyCloudNode,
|
|
71
|
-
UnsupportedFeatureError: () =>
|
|
72
|
-
VAULT_PERMISSION_SERVICE: () =>
|
|
73
|
-
VaultHeaders: () =>
|
|
74
|
-
VaultPublicSpaceKVActions: () =>
|
|
75
|
-
VersionCheckError: () =>
|
|
72
|
+
UnsupportedFeatureError: () => import_sdk_core18.UnsupportedFeatureError,
|
|
73
|
+
VAULT_PERMISSION_SERVICE: () => import_sdk_core10.VAULT_PERMISSION_SERVICE,
|
|
74
|
+
VaultHeaders: () => import_sdk_core14.VaultHeaders,
|
|
75
|
+
VaultPublicSpaceKVActions: () => import_sdk_core14.VaultPublicSpaceKVActions,
|
|
76
|
+
VersionCheckError: () => import_sdk_core18.VersionCheckError,
|
|
76
77
|
WasmKeyProvider: () => WasmKeyProvider,
|
|
77
|
-
addressStorageKey: () =>
|
|
78
|
-
buildSpaceUri: () =>
|
|
79
|
-
canonicalizeAddress: () =>
|
|
80
|
-
canonicalizeDid: () =>
|
|
81
|
-
canonicalizeDidUrl: () =>
|
|
82
|
-
canonicalizeNetworkId: () =>
|
|
83
|
-
canonicalizeSecretScope: () =>
|
|
84
|
-
checkNodeInfo: () =>
|
|
85
|
-
composeManifestRequest: () =>
|
|
86
|
-
createCapabilityKeyRegistry: () =>
|
|
87
|
-
createSharingService: () =>
|
|
88
|
-
createSpaceService: () =>
|
|
89
|
-
createVaultCrypto: () =>
|
|
78
|
+
addressStorageKey: () => import_sdk_core9.addressStorageKey,
|
|
79
|
+
buildSpaceUri: () => import_sdk_core17.buildSpaceUri,
|
|
80
|
+
canonicalizeAddress: () => import_sdk_core9.canonicalizeAddress,
|
|
81
|
+
canonicalizeDid: () => import_sdk_core9.canonicalizeDid,
|
|
82
|
+
canonicalizeDidUrl: () => import_sdk_core9.canonicalizeDidUrl,
|
|
83
|
+
canonicalizeNetworkId: () => import_sdk_core9.canonicalizeNetworkId,
|
|
84
|
+
canonicalizeSecretScope: () => import_sdk_core14.canonicalizeSecretScope,
|
|
85
|
+
checkNodeInfo: () => import_sdk_core18.checkNodeInfo,
|
|
86
|
+
composeManifestRequest: () => import_sdk_core10.composeManifestRequest,
|
|
87
|
+
createCapabilityKeyRegistry: () => import_sdk_core16.createCapabilityKeyRegistry,
|
|
88
|
+
createSharingService: () => import_sdk_core15.createSharingService,
|
|
89
|
+
createSpaceService: () => import_sdk_core17.createSpaceService,
|
|
90
|
+
createVaultCrypto: () => import_sdk_core14.createVaultCrypto,
|
|
90
91
|
createWasmKeyProvider: () => createWasmKeyProvider,
|
|
91
92
|
defaultSignStrategy: () => defaultSignStrategy,
|
|
92
|
-
defaultSpaceCreationHandler: () =>
|
|
93
|
+
defaultSpaceCreationHandler: () => import_sdk_core9.defaultSpaceCreationHandler,
|
|
93
94
|
deserializeDelegation: () => deserializeDelegation,
|
|
94
|
-
didCacheKey: () =>
|
|
95
|
-
didEquals: () =>
|
|
96
|
-
expandActionShortNames: () =>
|
|
97
|
-
expandPermissionEntries: () =>
|
|
98
|
-
expandPermissionEntry: () =>
|
|
99
|
-
isCapabilitySubset: () =>
|
|
100
|
-
isEvmAddress: () =>
|
|
101
|
-
loadManifest: () =>
|
|
102
|
-
makePkhSpaceId: () =>
|
|
103
|
-
makePublicSpaceId: () =>
|
|
104
|
-
parseCanonicalNetworkId: () =>
|
|
105
|
-
parseExpiry: () =>
|
|
106
|
-
parsePkhDid: () =>
|
|
107
|
-
parseSpaceUri: () =>
|
|
108
|
-
pkhDid: () =>
|
|
109
|
-
principalDid: () =>
|
|
110
|
-
principalDidEquals: () =>
|
|
111
|
-
resolveManifest: () =>
|
|
112
|
-
resolveSecretListPrefix: () =>
|
|
113
|
-
resolveSecretPath: () =>
|
|
114
|
-
resourceCapabilitiesToSpaceAbilitiesMap: () =>
|
|
95
|
+
didCacheKey: () => import_sdk_core9.didCacheKey,
|
|
96
|
+
didEquals: () => import_sdk_core9.didEquals,
|
|
97
|
+
expandActionShortNames: () => import_sdk_core10.expandActionShortNames,
|
|
98
|
+
expandPermissionEntries: () => import_sdk_core10.expandPermissionEntries,
|
|
99
|
+
expandPermissionEntry: () => import_sdk_core10.expandPermissionEntry,
|
|
100
|
+
isCapabilitySubset: () => import_sdk_core10.isCapabilitySubset,
|
|
101
|
+
isEvmAddress: () => import_sdk_core9.isEvmAddress,
|
|
102
|
+
loadManifest: () => import_sdk_core10.loadManifest,
|
|
103
|
+
makePkhSpaceId: () => import_sdk_core9.makePkhSpaceId,
|
|
104
|
+
makePublicSpaceId: () => import_sdk_core17.makePublicSpaceId,
|
|
105
|
+
parseCanonicalNetworkId: () => import_sdk_core9.parseCanonicalNetworkId,
|
|
106
|
+
parseExpiry: () => import_sdk_core10.parseExpiry,
|
|
107
|
+
parsePkhDid: () => import_sdk_core9.parsePkhDid,
|
|
108
|
+
parseSpaceUri: () => import_sdk_core17.parseSpaceUri,
|
|
109
|
+
pkhDid: () => import_sdk_core9.pkhDid,
|
|
110
|
+
principalDid: () => import_sdk_core9.principalDid,
|
|
111
|
+
principalDidEquals: () => import_sdk_core9.principalDidEquals,
|
|
112
|
+
resolveManifest: () => import_sdk_core10.resolveManifest,
|
|
113
|
+
resolveSecretListPrefix: () => import_sdk_core14.resolveSecretListPrefix,
|
|
114
|
+
resolveSecretPath: () => import_sdk_core14.resolveSecretPath,
|
|
115
|
+
resourceCapabilitiesToSpaceAbilitiesMap: () => import_sdk_core10.resourceCapabilitiesToSpaceAbilitiesMap,
|
|
115
116
|
serializeDelegation: () => serializeDelegation,
|
|
116
|
-
validateManifest: () =>
|
|
117
|
+
validateManifest: () => import_sdk_core10.validateManifest
|
|
117
118
|
});
|
|
118
119
|
module.exports = __toCommonJS(core_exports);
|
|
119
|
-
var import_sdk_core7 = require("@tinycloud/sdk-core");
|
|
120
120
|
var import_sdk_core8 = require("@tinycloud/sdk-core");
|
|
121
|
+
var import_sdk_core9 = require("@tinycloud/sdk-core");
|
|
121
122
|
|
|
122
123
|
// src/storage/MemorySessionStorage.ts
|
|
123
124
|
var MemorySessionStorage = class {
|
|
@@ -317,6 +318,25 @@ var import_sdk_core2 = require("@tinycloud/sdk-core");
|
|
|
317
318
|
var defaultSignStrategy = { type: "auto-sign" };
|
|
318
319
|
|
|
319
320
|
// src/authorization/NodeUserAuthorization.ts
|
|
321
|
+
var DECRYPT_ACTION = "tinycloud.encryption/decrypt";
|
|
322
|
+
var NETWORK_CREATE_ACTION = "tinycloud.encryption/network.create";
|
|
323
|
+
function didPrincipalMatches(actual, expected) {
|
|
324
|
+
try {
|
|
325
|
+
return (0, import_sdk_core2.principalDidEquals)(actual, expected);
|
|
326
|
+
} catch {
|
|
327
|
+
return actual === expected;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function addRawAbility(rawAbilities, resource, action) {
|
|
331
|
+
const actions = rawAbilities[resource];
|
|
332
|
+
if (actions === void 0) {
|
|
333
|
+
rawAbilities[resource] = [action];
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (!actions.includes(action)) {
|
|
337
|
+
actions.push(action);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
320
340
|
var NodeUserAuthorization = class {
|
|
321
341
|
constructor(config) {
|
|
322
342
|
this.extensions = [];
|
|
@@ -546,20 +566,18 @@ var NodeUserAuthorization = class {
|
|
|
546
566
|
};
|
|
547
567
|
}
|
|
548
568
|
const rawAbilities = {};
|
|
569
|
+
const currentDid = (0, import_sdk_core2.pkhDid)(address, chainId);
|
|
549
570
|
const spaceResources = request.resources.filter((entry) => {
|
|
550
571
|
if (entry.service !== import_sdk_core2.ENCRYPTION_PERMISSION_SERVICE) {
|
|
551
572
|
return true;
|
|
552
573
|
}
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
existing.push(action);
|
|
561
|
-
seen.add(action);
|
|
562
|
-
}
|
|
574
|
+
for (const action of entry.actions) {
|
|
575
|
+
addRawAbility(rawAbilities, entry.path, action);
|
|
576
|
+
}
|
|
577
|
+
if (entry.actions.includes(DECRYPT_ACTION)) {
|
|
578
|
+
const parsed = (0, import_sdk_core2.parseNetworkId)(entry.path);
|
|
579
|
+
if (didPrincipalMatches(parsed.ownerDid, currentDid)) {
|
|
580
|
+
addRawAbility(rawAbilities, entry.path, NETWORK_CREATE_ACTION);
|
|
563
581
|
}
|
|
564
582
|
}
|
|
565
583
|
return false;
|
|
@@ -1119,32 +1137,35 @@ var NodeUserAuthorization = class {
|
|
|
1119
1137
|
};
|
|
1120
1138
|
|
|
1121
1139
|
// src/TinyCloudNode.ts
|
|
1122
|
-
var
|
|
1140
|
+
var import_sdk_core7 = require("@tinycloud/sdk-core");
|
|
1123
1141
|
|
|
1124
|
-
// src/
|
|
1142
|
+
// src/account/AccountService.ts
|
|
1125
1143
|
var import_sdk_core3 = require("@tinycloud/sdk-core");
|
|
1144
|
+
|
|
1145
|
+
// src/DelegatedAccess.ts
|
|
1146
|
+
var import_sdk_core4 = require("@tinycloud/sdk-core");
|
|
1126
1147
|
var DelegatedAccess = class {
|
|
1127
1148
|
constructor(session, delegation, host, invoke, telemetry) {
|
|
1128
1149
|
this.session = session;
|
|
1129
1150
|
this._delegation = delegation;
|
|
1130
1151
|
this.host = host;
|
|
1131
|
-
this._serviceContext = new
|
|
1152
|
+
this._serviceContext = new import_sdk_core4.ServiceContext({
|
|
1132
1153
|
invoke,
|
|
1133
1154
|
fetch: globalThis.fetch.bind(globalThis),
|
|
1134
1155
|
hosts: [host],
|
|
1135
1156
|
telemetry
|
|
1136
1157
|
});
|
|
1137
1158
|
const prefix = this._delegation.path.replace(/\/$/, "");
|
|
1138
|
-
this._kv = new
|
|
1159
|
+
this._kv = new import_sdk_core4.KVService({ prefix });
|
|
1139
1160
|
this._kv.initialize(this._serviceContext);
|
|
1140
1161
|
this._serviceContext.registerService("kv", this._kv);
|
|
1141
|
-
this._sql = new
|
|
1162
|
+
this._sql = new import_sdk_core4.SQLService({});
|
|
1142
1163
|
this._sql.initialize(this._serviceContext);
|
|
1143
1164
|
this._serviceContext.registerService("sql", this._sql);
|
|
1144
|
-
this._duckdb = new
|
|
1165
|
+
this._duckdb = new import_sdk_core4.DuckDbService({});
|
|
1145
1166
|
this._duckdb.initialize(this._serviceContext);
|
|
1146
1167
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
1147
|
-
this._hooks = new
|
|
1168
|
+
this._hooks = new import_sdk_core4.HooksService({});
|
|
1148
1169
|
this._hooks.initialize(this._serviceContext);
|
|
1149
1170
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
1150
1171
|
const serviceSession = {
|
|
@@ -1294,7 +1315,7 @@ function createWasmKeyProvider(sessionManager) {
|
|
|
1294
1315
|
}
|
|
1295
1316
|
|
|
1296
1317
|
// src/delegateToHelpers.ts
|
|
1297
|
-
var
|
|
1318
|
+
var import_sdk_core5 = require("@tinycloud/sdk-core");
|
|
1298
1319
|
function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
1299
1320
|
const byService = /* @__PURE__ */ new Map();
|
|
1300
1321
|
for (const a of actions) {
|
|
@@ -1325,7 +1346,7 @@ function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
|
1325
1346
|
}
|
|
1326
1347
|
return entries;
|
|
1327
1348
|
}
|
|
1328
|
-
var DEFAULT_DELEGATION_EXPIRY_MS =
|
|
1349
|
+
var DEFAULT_DELEGATION_EXPIRY_MS = import_sdk_core5.EXPIRY.SESSION_MS;
|
|
1329
1350
|
function resolveExpiryMs(expiry) {
|
|
1330
1351
|
if (expiry === void 0) {
|
|
1331
1352
|
return DEFAULT_DELEGATION_EXPIRY_MS;
|
|
@@ -1338,10 +1359,10 @@ function resolveExpiryMs(expiry) {
|
|
|
1338
1359
|
}
|
|
1339
1360
|
return expiry;
|
|
1340
1361
|
}
|
|
1341
|
-
return (0,
|
|
1362
|
+
return (0, import_sdk_core5.parseExpiry)(expiry);
|
|
1342
1363
|
}
|
|
1343
1364
|
function extractSiweExpiration(siwe) {
|
|
1344
|
-
const parsed = new
|
|
1365
|
+
const parsed = new import_sdk_core5.SiweMessage(siwe);
|
|
1345
1366
|
if (parsed.expirationTime === void 0 || parsed.expirationTime === null) {
|
|
1346
1367
|
return void 0;
|
|
1347
1368
|
}
|
|
@@ -1355,7 +1376,7 @@ function extractSiweExpiration(siwe) {
|
|
|
1355
1376
|
}
|
|
1356
1377
|
|
|
1357
1378
|
// src/NodeSecretsService.ts
|
|
1358
|
-
var
|
|
1379
|
+
var import_sdk_core6 = require("@tinycloud/sdk-core");
|
|
1359
1380
|
var SECRETS_SPACE = "secrets";
|
|
1360
1381
|
function ok() {
|
|
1361
1382
|
return { ok: true, data: void 0 };
|
|
@@ -1388,7 +1409,7 @@ function secretActionName(action) {
|
|
|
1388
1409
|
}
|
|
1389
1410
|
function secretPermissionEntries(name, options, action, encryptionNetworkId) {
|
|
1390
1411
|
const entries = [];
|
|
1391
|
-
const path = action === "list" ? (0,
|
|
1412
|
+
const path = action === "list" ? (0, import_sdk_core6.resolveSecretListPrefix)(options) : (0, import_sdk_core6.resolveSecretPath)(name, options).permissionPaths.vault;
|
|
1392
1413
|
entries.push({
|
|
1393
1414
|
service: "tinycloud.kv",
|
|
1394
1415
|
space: SECRETS_SPACE,
|
|
@@ -1467,7 +1488,7 @@ var NodeSecretsService = class {
|
|
|
1467
1488
|
);
|
|
1468
1489
|
} catch (error) {
|
|
1469
1490
|
return secretsError(
|
|
1470
|
-
|
|
1491
|
+
import_sdk_core6.ErrorCodes.INVALID_INPUT,
|
|
1471
1492
|
error instanceof Error ? error.message : String(error),
|
|
1472
1493
|
error instanceof Error ? error : void 0
|
|
1473
1494
|
);
|
|
@@ -1477,7 +1498,7 @@ var NodeSecretsService = class {
|
|
|
1477
1498
|
}
|
|
1478
1499
|
if (!this.config.canEscalate()) {
|
|
1479
1500
|
return secretsError(
|
|
1480
|
-
|
|
1501
|
+
import_sdk_core6.ErrorCodes.PERMISSION_DENIED,
|
|
1481
1502
|
`Cannot autosign ${displayActionUrn(action)} for ${target}; TinyCloudNode needs wallet mode with a signer or privateKey.`
|
|
1482
1503
|
);
|
|
1483
1504
|
}
|
|
@@ -1486,7 +1507,7 @@ var NodeSecretsService = class {
|
|
|
1486
1507
|
return this.restoreUnlockAfterEscalation();
|
|
1487
1508
|
} catch (error) {
|
|
1488
1509
|
return secretsError(
|
|
1489
|
-
|
|
1510
|
+
import_sdk_core6.ErrorCodes.PERMISSION_DENIED,
|
|
1490
1511
|
error instanceof Error ? error.message : `Autosign escalation for ${displayActionUrn(action)} on ${target} failed.`,
|
|
1491
1512
|
error instanceof Error ? error : void 0
|
|
1492
1513
|
);
|
|
@@ -1507,10 +1528,10 @@ var NodeSecretsService = class {
|
|
|
1507
1528
|
return false;
|
|
1508
1529
|
}
|
|
1509
1530
|
const manifests = Array.isArray(manifest) ? manifest : [manifest];
|
|
1510
|
-
const requestedEntries = (0,
|
|
1531
|
+
const requestedEntries = (0, import_sdk_core6.expandPermissionEntries)(permissionEntries);
|
|
1511
1532
|
return requestedEntries.every(
|
|
1512
1533
|
(entry) => manifests.some((candidate) => {
|
|
1513
|
-
const resolved = (0,
|
|
1534
|
+
const resolved = (0, import_sdk_core6.resolveManifest)(candidate);
|
|
1514
1535
|
return resolved.resources.some(
|
|
1515
1536
|
(resource) => resource.service === entry.service && resource.space === entry.space && resource.path === entry.path && entry.actions.every((action) => resource.actions.includes(action))
|
|
1516
1537
|
);
|
|
@@ -1522,13 +1543,13 @@ var NodeSecretsService = class {
|
|
|
1522
1543
|
// src/TinyCloudNode.ts
|
|
1523
1544
|
var DEFAULT_HOST = "https://node.tinycloud.xyz";
|
|
1524
1545
|
var DEFAULT_ENCRYPTION_NETWORK_NAME = "default";
|
|
1525
|
-
var
|
|
1526
|
-
var
|
|
1546
|
+
var NETWORK_CREATE_ACTION2 = "tinycloud.encryption/network.create";
|
|
1547
|
+
var DECRYPT_ACTION2 = "tinycloud.encryption/decrypt";
|
|
1527
1548
|
var NETWORK_ADMIN_TYPE = "tinycloud.encryption.network-admin/v1";
|
|
1528
|
-
var DEFAULT_SESSION_EXPIRATION_MS =
|
|
1529
|
-
function
|
|
1549
|
+
var DEFAULT_SESSION_EXPIRATION_MS = import_sdk_core7.EXPIRY.SESSION_MS;
|
|
1550
|
+
function didPrincipalMatches2(actual, expected) {
|
|
1530
1551
|
try {
|
|
1531
|
-
return (0,
|
|
1552
|
+
return (0, import_sdk_core7.principalDidEquals)(actual, expected);
|
|
1532
1553
|
} catch {
|
|
1533
1554
|
return actual === expected;
|
|
1534
1555
|
}
|
|
@@ -1694,12 +1715,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1694
1715
|
throw new Error("Failed to get session key JWK");
|
|
1695
1716
|
}
|
|
1696
1717
|
this.sessionKeyJwk = JSON.parse(jwkStr);
|
|
1697
|
-
this._capabilityRegistry = new
|
|
1718
|
+
this._capabilityRegistry = new import_sdk_core7.CapabilityKeyRegistry();
|
|
1698
1719
|
this._keyProvider = new WasmKeyProvider({
|
|
1699
1720
|
sessionManager: this.sessionManager
|
|
1700
1721
|
});
|
|
1701
|
-
this.notificationHandler = config.notificationHandler ?? new
|
|
1702
|
-
this._sharingService = new
|
|
1722
|
+
this.notificationHandler = config.notificationHandler ?? new import_sdk_core7.SilentNotificationHandler();
|
|
1723
|
+
this._sharingService = new import_sdk_core7.SharingService({
|
|
1703
1724
|
hosts: [this.config.host],
|
|
1704
1725
|
// session: undefined - not needed for receive()
|
|
1705
1726
|
invoke: this.invokeWithRuntimePermissions,
|
|
@@ -1709,8 +1730,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1709
1730
|
// delegationManager: undefined - not needed for receive()
|
|
1710
1731
|
createKVService: (config2) => {
|
|
1711
1732
|
const prefix = config2.pathPrefix?.replace(/\/$/, "");
|
|
1712
|
-
const kvService = new
|
|
1713
|
-
const kvContext = new
|
|
1733
|
+
const kvService = new import_sdk_core7.KVService({ prefix });
|
|
1734
|
+
const kvContext = new import_sdk_core7.ServiceContext({
|
|
1714
1735
|
invoke: config2.invoke,
|
|
1715
1736
|
fetch: config2.fetch ?? globalThis.fetch.bind(globalThis),
|
|
1716
1737
|
hosts: config2.hosts,
|
|
@@ -1770,7 +1791,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1770
1791
|
capabilityRequest: config.capabilityRequest,
|
|
1771
1792
|
includeAccountRegistryPermissions: config.includeAccountRegistryPermissions
|
|
1772
1793
|
});
|
|
1773
|
-
this.tc = new
|
|
1794
|
+
this.tc = new import_sdk_core7.TinyCloud(this.auth, {
|
|
1774
1795
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
1775
1796
|
telemetry: config.telemetry
|
|
1776
1797
|
});
|
|
@@ -1831,7 +1852,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1831
1852
|
*/
|
|
1832
1853
|
get did() {
|
|
1833
1854
|
if (this._address) {
|
|
1834
|
-
return (0,
|
|
1855
|
+
return (0, import_sdk_core7.pkhDid)(this._address, this._chainId);
|
|
1835
1856
|
}
|
|
1836
1857
|
return this.sessionManager.getDID(this.sessionKeyId);
|
|
1837
1858
|
}
|
|
@@ -1865,6 +1886,37 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1865
1886
|
get spaceId() {
|
|
1866
1887
|
return this.auth?.tinyCloudSession?.spaceId;
|
|
1867
1888
|
}
|
|
1889
|
+
/**
|
|
1890
|
+
* Get the account space ID for this wallet identity.
|
|
1891
|
+
* Available after wallet-backed sign-in or a restored session with address metadata.
|
|
1892
|
+
*/
|
|
1893
|
+
get accountSpaceId() {
|
|
1894
|
+
if (!this._address) {
|
|
1895
|
+
return void 0;
|
|
1896
|
+
}
|
|
1897
|
+
return this.wasmBindings.makeSpaceId(this._address, this._chainId, import_sdk_core7.ACCOUNT_REGISTRY_SPACE);
|
|
1898
|
+
}
|
|
1899
|
+
/**
|
|
1900
|
+
* Account-level application and delegation helpers.
|
|
1901
|
+
*/
|
|
1902
|
+
get account() {
|
|
1903
|
+
if (!this._account) {
|
|
1904
|
+
this._account = new import_sdk_core3.AccountService({
|
|
1905
|
+
getDid: () => this.did,
|
|
1906
|
+
getHost: () => this.hosts[0] ?? this.config.host,
|
|
1907
|
+
getPrimarySpaceId: () => this.spaceId,
|
|
1908
|
+
getAccountSpaceId: () => this.accountSpaceId,
|
|
1909
|
+
getSpaces: () => this.spaces,
|
|
1910
|
+
getAccountDb: () => this.accountSpaceId ? this.sqlForSpace(this.accountSpaceId).db("account") : void 0,
|
|
1911
|
+
ensureAccountSpaceHosted: async () => {
|
|
1912
|
+
if (this.accountSpaceId && this.auth) {
|
|
1913
|
+
await this.ensureOwnedSpaceHosted(this.accountSpaceId);
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
return this._account;
|
|
1919
|
+
}
|
|
1868
1920
|
/**
|
|
1869
1921
|
* Get the current TinyCloud session.
|
|
1870
1922
|
* Available after signIn().
|
|
@@ -1886,7 +1938,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1886
1938
|
);
|
|
1887
1939
|
}
|
|
1888
1940
|
await this.wasmBindings.ensureInitialized?.();
|
|
1889
|
-
this._address = (0,
|
|
1941
|
+
this._address = (0, import_sdk_core7.canonicalizeAddress)(await this.signer.getAddress());
|
|
1890
1942
|
this._chainId = await this.signer.getChainId();
|
|
1891
1943
|
this._kv = void 0;
|
|
1892
1944
|
this._sql = void 0;
|
|
@@ -1902,6 +1954,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1902
1954
|
await this.tc.signIn(options);
|
|
1903
1955
|
this.syncResolvedHostFromAuth();
|
|
1904
1956
|
this.initializeServices();
|
|
1957
|
+
await this.ensureRequestedEncryptionNetworks();
|
|
1905
1958
|
if (this.config.manifest === void 0 && this.config.capabilityRequest === void 0) {
|
|
1906
1959
|
await this.ensureOwnedSpaceHosted(this.ownedSpaceId("secrets"));
|
|
1907
1960
|
}
|
|
@@ -1922,7 +1975,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1922
1975
|
if (!this.auth || !this.signer) {
|
|
1923
1976
|
throw new Error("Manifest registry write requires wallet mode");
|
|
1924
1977
|
}
|
|
1925
|
-
const accountSpaceId = this.ownedSpaceId(
|
|
1978
|
+
const accountSpaceId = this.ownedSpaceId(import_sdk_core7.ACCOUNT_REGISTRY_SPACE);
|
|
1926
1979
|
await this.ensureOwnedSpaceHosted(accountSpaceId);
|
|
1927
1980
|
const accountKV = this.spaces.get(accountSpaceId).kv;
|
|
1928
1981
|
for (const record of request.registryRecords) {
|
|
@@ -1938,6 +1991,31 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1938
1991
|
}
|
|
1939
1992
|
}
|
|
1940
1993
|
}
|
|
1994
|
+
requestedEncryptionNetworkIds() {
|
|
1995
|
+
const request = this.capabilityRequest;
|
|
1996
|
+
if (!request) {
|
|
1997
|
+
return [];
|
|
1998
|
+
}
|
|
1999
|
+
const networkIds = /* @__PURE__ */ new Set();
|
|
2000
|
+
for (const resource of request.resources) {
|
|
2001
|
+
if (resource.service === import_sdk_core7.ENCRYPTION_PERMISSION_SERVICE && resource.path.startsWith("urn:tinycloud:encryption:") && resource.actions.includes(DECRYPT_ACTION2)) {
|
|
2002
|
+
networkIds.add(resource.path);
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
return [...networkIds];
|
|
2006
|
+
}
|
|
2007
|
+
async ensureRequestedEncryptionNetworks() {
|
|
2008
|
+
if (!this.signer || !this.auth) {
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2011
|
+
for (const networkId of this.requestedEncryptionNetworkIds()) {
|
|
2012
|
+
const parsed = (0, import_sdk_core7.parseNetworkId)(networkId);
|
|
2013
|
+
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
2014
|
+
continue;
|
|
2015
|
+
}
|
|
2016
|
+
await this.ensureEncryptionNetwork(networkId);
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
1941
2019
|
async ensureOwnedSpaceHosted(spaceId) {
|
|
1942
2020
|
if (!this.auth) {
|
|
1943
2021
|
throw new Error("Owned space hosting requires wallet mode");
|
|
@@ -1950,7 +2028,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1950
2028
|
if (!host) {
|
|
1951
2029
|
throw new Error("Owned space hosting requires a TinyCloud host");
|
|
1952
2030
|
}
|
|
1953
|
-
const activation = await (0,
|
|
2031
|
+
const activation = await (0, import_sdk_core7.activateSessionWithHost)(host, session.delegationHeader);
|
|
1954
2032
|
if (activation.success && !activation.skipped?.includes(spaceId)) {
|
|
1955
2033
|
return;
|
|
1956
2034
|
}
|
|
@@ -1964,7 +2042,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1964
2042
|
throw new Error(`Failed to create owned space: ${spaceId}`);
|
|
1965
2043
|
}
|
|
1966
2044
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1967
|
-
const retry = await (0,
|
|
2045
|
+
const retry = await (0, import_sdk_core7.activateSessionWithHost)(host, session.delegationHeader);
|
|
1968
2046
|
if (!retry.success || retry.skipped?.includes(spaceId)) {
|
|
1969
2047
|
throw new Error(
|
|
1970
2048
|
`Failed to activate session after creating owned space ${spaceId}: ${retry.error ?? "space was skipped"}`
|
|
@@ -2006,7 +2084,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2006
2084
|
if (!hosted) {
|
|
2007
2085
|
throw new Error(`Failed to host owned space: ${spaceId}`);
|
|
2008
2086
|
}
|
|
2009
|
-
const activation = await (0,
|
|
2087
|
+
const activation = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
2010
2088
|
host,
|
|
2011
2089
|
this.auth.tinyCloudSession.delegationHeader
|
|
2012
2090
|
);
|
|
@@ -2039,30 +2117,30 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2039
2117
|
this._spaceService = void 0;
|
|
2040
2118
|
this._serviceContext = void 0;
|
|
2041
2119
|
this.runtimePermissionGrants = [];
|
|
2042
|
-
const restoredAddress = sessionData.address ? (0,
|
|
2120
|
+
const restoredAddress = sessionData.address ? (0, import_sdk_core7.canonicalizeAddress)(sessionData.address) : void 0;
|
|
2043
2121
|
if (restoredAddress) {
|
|
2044
2122
|
this._address = restoredAddress;
|
|
2045
2123
|
}
|
|
2046
2124
|
if (sessionData.chainId) {
|
|
2047
2125
|
this._chainId = sessionData.chainId;
|
|
2048
2126
|
}
|
|
2049
|
-
this._serviceContext = new
|
|
2127
|
+
this._serviceContext = new import_sdk_core7.ServiceContext({
|
|
2050
2128
|
invoke: this.invokeWithRuntimePermissions,
|
|
2051
2129
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
2052
2130
|
fetch: globalThis.fetch.bind(globalThis),
|
|
2053
2131
|
hosts: [this.config.host],
|
|
2054
2132
|
telemetry: this.config.telemetry
|
|
2055
2133
|
});
|
|
2056
|
-
this._kv = new
|
|
2134
|
+
this._kv = new import_sdk_core7.KVService({});
|
|
2057
2135
|
this._kv.initialize(this._serviceContext);
|
|
2058
2136
|
this._serviceContext.registerService("kv", this._kv);
|
|
2059
|
-
this._sql = new
|
|
2137
|
+
this._sql = new import_sdk_core7.SQLService({});
|
|
2060
2138
|
this._sql.initialize(this._serviceContext);
|
|
2061
2139
|
this._serviceContext.registerService("sql", this._sql);
|
|
2062
|
-
this._duckdb = new
|
|
2140
|
+
this._duckdb = new import_sdk_core7.DuckDbService({});
|
|
2063
2141
|
this._duckdb.initialize(this._serviceContext);
|
|
2064
2142
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
2065
|
-
this._hooks = new
|
|
2143
|
+
this._hooks = new import_sdk_core7.HooksService({});
|
|
2066
2144
|
this._hooks.initialize(this._serviceContext);
|
|
2067
2145
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
2068
2146
|
const serviceSession = {
|
|
@@ -2161,7 +2239,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2161
2239
|
capabilityRequest: this.config.capabilityRequest,
|
|
2162
2240
|
includeAccountRegistryPermissions: this.config.includeAccountRegistryPermissions
|
|
2163
2241
|
});
|
|
2164
|
-
this.tc = new
|
|
2242
|
+
this.tc = new import_sdk_core7.TinyCloud(this.auth, {
|
|
2165
2243
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
2166
2244
|
telemetry: this.config.telemetry
|
|
2167
2245
|
});
|
|
@@ -2206,7 +2284,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2206
2284
|
capabilityRequest: this.config.capabilityRequest,
|
|
2207
2285
|
includeAccountRegistryPermissions: this.config.includeAccountRegistryPermissions
|
|
2208
2286
|
});
|
|
2209
|
-
this.tc = new
|
|
2287
|
+
this.tc = new import_sdk_core7.TinyCloud(this.auth, {
|
|
2210
2288
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
2211
2289
|
telemetry: this.config.telemetry
|
|
2212
2290
|
});
|
|
@@ -2222,28 +2300,28 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2222
2300
|
return;
|
|
2223
2301
|
}
|
|
2224
2302
|
this.tc.initializeServices(this.invokeWithRuntimePermissions, [this.config.host]);
|
|
2225
|
-
this._serviceContext = new
|
|
2303
|
+
this._serviceContext = new import_sdk_core7.ServiceContext({
|
|
2226
2304
|
invoke: this.invokeWithRuntimePermissions,
|
|
2227
2305
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
2228
2306
|
fetch: globalThis.fetch.bind(globalThis),
|
|
2229
2307
|
hosts: [this.config.host],
|
|
2230
2308
|
telemetry: this.config.telemetry
|
|
2231
2309
|
});
|
|
2232
|
-
this._kv = new
|
|
2310
|
+
this._kv = new import_sdk_core7.KVService({});
|
|
2233
2311
|
this._kv.initialize(this._serviceContext);
|
|
2234
2312
|
this._serviceContext.registerService("kv", this._kv);
|
|
2235
2313
|
const features = this.nodeFeatures;
|
|
2236
2314
|
if (features.length === 0 || features.includes("sql")) {
|
|
2237
|
-
this._sql = new
|
|
2315
|
+
this._sql = new import_sdk_core7.SQLService({});
|
|
2238
2316
|
this._sql.initialize(this._serviceContext);
|
|
2239
2317
|
this._serviceContext.registerService("sql", this._sql);
|
|
2240
2318
|
}
|
|
2241
2319
|
if (features.length === 0 || features.includes("duckdb")) {
|
|
2242
|
-
this._duckdb = new
|
|
2320
|
+
this._duckdb = new import_sdk_core7.DuckDbService({});
|
|
2243
2321
|
this._duckdb.initialize(this._serviceContext);
|
|
2244
2322
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
2245
2323
|
}
|
|
2246
|
-
this._hooks = new
|
|
2324
|
+
this._hooks = new import_sdk_core7.HooksService({});
|
|
2247
2325
|
this._hooks.initialize(this._serviceContext);
|
|
2248
2326
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
2249
2327
|
const serviceSession = {
|
|
@@ -2261,9 +2339,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2261
2339
|
this.initializeV2Services(serviceSession);
|
|
2262
2340
|
}
|
|
2263
2341
|
createSpaceScopedKVService(spaceId) {
|
|
2264
|
-
const kvService = new
|
|
2342
|
+
const kvService = new import_sdk_core7.KVService({});
|
|
2265
2343
|
if (this._serviceContext) {
|
|
2266
|
-
const spaceScopedContext = new
|
|
2344
|
+
const spaceScopedContext = new import_sdk_core7.ServiceContext({
|
|
2267
2345
|
invoke: this._serviceContext.invoke,
|
|
2268
2346
|
fetch: this._serviceContext.fetch,
|
|
2269
2347
|
hosts: this._serviceContext.hosts,
|
|
@@ -2328,7 +2406,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2328
2406
|
const shared = wasm.vault_x25519_dh(receiverPrivateKey, peerPublic);
|
|
2329
2407
|
return columnDecrypt(shared, ciphertext);
|
|
2330
2408
|
},
|
|
2331
|
-
verifyNodeSignature: (nodeId, message, signature) => (0,
|
|
2409
|
+
verifyNodeSignature: (nodeId, message, signature) => (0, import_sdk_core7.verifyDidKeyEd25519Signature)(nodeId, message, signature)
|
|
2332
2410
|
};
|
|
2333
2411
|
}
|
|
2334
2412
|
async fetchNodeId() {
|
|
@@ -2399,19 +2477,19 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2399
2477
|
return await response.json();
|
|
2400
2478
|
}
|
|
2401
2479
|
};
|
|
2402
|
-
return new
|
|
2480
|
+
return new import_sdk_core7.EncryptionService({
|
|
2403
2481
|
crypto,
|
|
2404
2482
|
signer: {
|
|
2405
2483
|
signDecryptInvocation: async (input) => {
|
|
2406
2484
|
const signed = await this.signRawNetworkAuthorization({
|
|
2407
2485
|
targetNode: input.targetNode,
|
|
2408
2486
|
networkId: input.networkId,
|
|
2409
|
-
action:
|
|
2487
|
+
action: DECRYPT_ACTION2,
|
|
2410
2488
|
facts: input.facts
|
|
2411
2489
|
});
|
|
2412
2490
|
return {
|
|
2413
2491
|
...signed,
|
|
2414
|
-
canonicalBody: (0,
|
|
2492
|
+
canonicalBody: (0, import_sdk_core7.canonicalizeEncryptionJson)(
|
|
2415
2493
|
input.body
|
|
2416
2494
|
)
|
|
2417
2495
|
};
|
|
@@ -2423,14 +2501,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2423
2501
|
},
|
|
2424
2502
|
wellKnown: {
|
|
2425
2503
|
fetchWellKnown: async (principal, discoveryKey) => {
|
|
2426
|
-
if (!this._address || !
|
|
2504
|
+
if (!this._address || !didPrincipalMatches2(principal, this.did)) {
|
|
2427
2505
|
return null;
|
|
2428
2506
|
}
|
|
2429
2507
|
if (!this.config.host) {
|
|
2430
2508
|
return null;
|
|
2431
2509
|
}
|
|
2432
|
-
const publicSpaceId = (0,
|
|
2433
|
-
const result = await
|
|
2510
|
+
const publicSpaceId = (0, import_sdk_core7.makePublicSpaceId)(this._address, this._chainId);
|
|
2511
|
+
const result = await import_sdk_core7.TinyCloud.readPublicSpace(this.config.host, publicSpaceId, discoveryKey);
|
|
2434
2512
|
if (!result.ok) {
|
|
2435
2513
|
return null;
|
|
2436
2514
|
}
|
|
@@ -2453,7 +2531,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2453
2531
|
}
|
|
2454
2532
|
createVaultService(spaceId, kv) {
|
|
2455
2533
|
const wasm = this.wasmBindings;
|
|
2456
|
-
const vaultCrypto = (0,
|
|
2534
|
+
const vaultCrypto = (0, import_sdk_core7.createVaultCrypto)({
|
|
2457
2535
|
vault_encrypt: wasm.vault_encrypt,
|
|
2458
2536
|
vault_decrypt: wasm.vault_decrypt,
|
|
2459
2537
|
vault_derive_key: wasm.vault_derive_key,
|
|
@@ -2463,7 +2541,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2463
2541
|
vault_sha256: wasm.vault_sha256
|
|
2464
2542
|
});
|
|
2465
2543
|
const self = this;
|
|
2466
|
-
return new
|
|
2544
|
+
return new import_sdk_core7.DataVaultService({
|
|
2467
2545
|
spaceId,
|
|
2468
2546
|
crypto: vaultCrypto,
|
|
2469
2547
|
encryption: {
|
|
@@ -2486,8 +2564,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2486
2564
|
get publicKV() {
|
|
2487
2565
|
return self._publicKV ?? self.tc.publicKV;
|
|
2488
2566
|
},
|
|
2489
|
-
readPublicSpace: (host, targetSpaceId, key) =>
|
|
2490
|
-
makePublicSpaceId:
|
|
2567
|
+
readPublicSpace: (host, targetSpaceId, key) => import_sdk_core7.TinyCloud.readPublicSpace(host, targetSpaceId, key),
|
|
2568
|
+
makePublicSpaceId: import_sdk_core7.TinyCloud.makePublicSpaceId,
|
|
2491
2569
|
did: this.did,
|
|
2492
2570
|
address: this._address ?? "",
|
|
2493
2571
|
chainId: this._chainId,
|
|
@@ -2500,7 +2578,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2500
2578
|
* @internal
|
|
2501
2579
|
*/
|
|
2502
2580
|
initializeV2Services(serviceSession) {
|
|
2503
|
-
this._capabilityRegistry = new
|
|
2581
|
+
this._capabilityRegistry = new import_sdk_core7.CapabilityKeyRegistry();
|
|
2504
2582
|
const tcSession = this.auth?.tinyCloudSession;
|
|
2505
2583
|
if (tcSession && this._address) {
|
|
2506
2584
|
const sessionKey = {
|
|
@@ -2574,13 +2652,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2574
2652
|
}
|
|
2575
2653
|
this._capabilityRegistry.registerKey(sessionKey, delegations);
|
|
2576
2654
|
}
|
|
2577
|
-
this._delegationManager = new
|
|
2655
|
+
this._delegationManager = new import_sdk_core7.DelegationManager({
|
|
2578
2656
|
hosts: [this.config.host],
|
|
2579
2657
|
session: serviceSession,
|
|
2580
2658
|
invoke: this.invokeWithRuntimePermissions,
|
|
2581
2659
|
fetch: globalThis.fetch.bind(globalThis)
|
|
2582
2660
|
});
|
|
2583
|
-
this._spaceService = new
|
|
2661
|
+
this._spaceService = new import_sdk_core7.SpaceService({
|
|
2584
2662
|
hosts: [this.config.host],
|
|
2585
2663
|
session: serviceSession,
|
|
2586
2664
|
invoke: this.wasmBindings.invoke,
|
|
@@ -2737,7 +2815,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2737
2815
|
...prepared,
|
|
2738
2816
|
signature
|
|
2739
2817
|
});
|
|
2740
|
-
const activateResult = await (0,
|
|
2818
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
2741
2819
|
host,
|
|
2742
2820
|
delegationSession.delegationHeader
|
|
2743
2821
|
);
|
|
@@ -2747,7 +2825,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2747
2825
|
return {
|
|
2748
2826
|
cid: delegationSession.delegationCid,
|
|
2749
2827
|
delegateDID: params.shareKeyDID,
|
|
2750
|
-
delegatorDID: (0,
|
|
2828
|
+
delegatorDID: (0, import_sdk_core7.pkhDid)(session.address, session.chainId),
|
|
2751
2829
|
spaceId: params.spaceId,
|
|
2752
2830
|
path: params.path,
|
|
2753
2831
|
actions: params.actions,
|
|
@@ -2804,7 +2882,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2804
2882
|
if (!this._sql) {
|
|
2805
2883
|
const features = this.nodeFeatures;
|
|
2806
2884
|
if (features.length > 0 && !features.includes("sql")) {
|
|
2807
|
-
throw new
|
|
2885
|
+
throw new import_sdk_core7.UnsupportedFeatureError("sql", this.config.host, features);
|
|
2808
2886
|
}
|
|
2809
2887
|
throw new Error("Not signed in. Call signIn() first.");
|
|
2810
2888
|
}
|
|
@@ -2828,8 +2906,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2828
2906
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
2829
2907
|
throw new Error("Not signed in. Call signIn() first.");
|
|
2830
2908
|
}
|
|
2831
|
-
const sql = new
|
|
2832
|
-
const spaceScopedContext = new
|
|
2909
|
+
const sql = new import_sdk_core7.SQLService({});
|
|
2910
|
+
const spaceScopedContext = new import_sdk_core7.ServiceContext({
|
|
2833
2911
|
invoke: this._serviceContext.invoke,
|
|
2834
2912
|
fetch: this._serviceContext.fetch,
|
|
2835
2913
|
hosts: this._serviceContext.hosts,
|
|
@@ -2857,8 +2935,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2857
2935
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
2858
2936
|
throw new Error("Not signed in. Call signIn() first.");
|
|
2859
2937
|
}
|
|
2860
|
-
const kv = new
|
|
2861
|
-
const spaceScopedContext = new
|
|
2938
|
+
const kv = new import_sdk_core7.KVService({});
|
|
2939
|
+
const spaceScopedContext = new import_sdk_core7.ServiceContext({
|
|
2862
2940
|
invoke: this._serviceContext.invoke,
|
|
2863
2941
|
fetch: this._serviceContext.fetch,
|
|
2864
2942
|
hosts: this._serviceContext.hosts
|
|
@@ -2874,7 +2952,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2874
2952
|
if (!this._duckdb) {
|
|
2875
2953
|
const features = this.nodeFeatures;
|
|
2876
2954
|
if (features.length > 0 && !features.includes("duckdb")) {
|
|
2877
|
-
throw new
|
|
2955
|
+
throw new import_sdk_core7.UnsupportedFeatureError("duckdb", this.config.host, features);
|
|
2878
2956
|
}
|
|
2879
2957
|
throw new Error("Not signed in. Call signIn() first.");
|
|
2880
2958
|
}
|
|
@@ -2926,16 +3004,16 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2926
3004
|
type: NETWORK_ADMIN_TYPE,
|
|
2927
3005
|
targetNode,
|
|
2928
3006
|
networkId,
|
|
2929
|
-
bodyHash: (0,
|
|
3007
|
+
bodyHash: (0, import_sdk_core7.canonicalHashHex)(
|
|
2930
3008
|
crypto.sha256,
|
|
2931
3009
|
body
|
|
2932
3010
|
),
|
|
2933
|
-
action:
|
|
3011
|
+
action: NETWORK_CREATE_ACTION2
|
|
2934
3012
|
};
|
|
2935
3013
|
const signed = await this.signRawNetworkAuthorization({
|
|
2936
3014
|
targetNode,
|
|
2937
3015
|
networkId,
|
|
2938
|
-
action:
|
|
3016
|
+
action: NETWORK_CREATE_ACTION2,
|
|
2939
3017
|
facts
|
|
2940
3018
|
});
|
|
2941
3019
|
const response = await fetch(`${this.config.host}/encryption/networks`, {
|
|
@@ -2944,7 +3022,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2944
3022
|
Authorization: signed.authorization,
|
|
2945
3023
|
"Content-Type": "application/json"
|
|
2946
3024
|
},
|
|
2947
|
-
body: (0,
|
|
3025
|
+
body: (0, import_sdk_core7.canonicalizeEncryptionJson)(
|
|
2948
3026
|
body
|
|
2949
3027
|
)
|
|
2950
3028
|
});
|
|
@@ -2956,12 +3034,19 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2956
3034
|
const created = await response.json();
|
|
2957
3035
|
return created.descriptor;
|
|
2958
3036
|
}
|
|
2959
|
-
async ensureEncryptionNetwork(
|
|
2960
|
-
const
|
|
3037
|
+
async ensureEncryptionNetwork(nameOrNetworkId = DEFAULT_ENCRYPTION_NETWORK_NAME) {
|
|
3038
|
+
const networkId = nameOrNetworkId.startsWith("urn:tinycloud:encryption:") ? nameOrNetworkId : this.getDefaultEncryptionNetworkId(nameOrNetworkId);
|
|
3039
|
+
const existing = await this.getEncryptionNetwork(networkId);
|
|
2961
3040
|
if (existing) {
|
|
2962
3041
|
return existing;
|
|
2963
3042
|
}
|
|
2964
|
-
|
|
3043
|
+
const parsed = (0, import_sdk_core7.parseNetworkId)(networkId);
|
|
3044
|
+
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
3045
|
+
throw new Error(
|
|
3046
|
+
`Cannot create encryption network ${networkId}: owner ${parsed.ownerDid} does not match signed-in DID ${this.did}`
|
|
3047
|
+
);
|
|
3048
|
+
}
|
|
3049
|
+
return this.createEncryptionNetwork(parsed.name);
|
|
2965
3050
|
}
|
|
2966
3051
|
/**
|
|
2967
3052
|
* App-facing secrets API backed by the `secrets` space vault.
|
|
@@ -2988,7 +3073,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2988
3073
|
throw new Error("Not signed in. Call signIn() first.");
|
|
2989
3074
|
}
|
|
2990
3075
|
if (!this._baseSecrets) {
|
|
2991
|
-
this._baseSecrets = new
|
|
3076
|
+
this._baseSecrets = new import_sdk_core7.SecretsService(() => this.space("secrets").vault);
|
|
2992
3077
|
}
|
|
2993
3078
|
return this._baseSecrets;
|
|
2994
3079
|
}
|
|
@@ -3103,19 +3188,19 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3103
3188
|
async useRuntimeDelegation(delegation) {
|
|
3104
3189
|
const session = this.currentTinyCloudSession();
|
|
3105
3190
|
if (!session) {
|
|
3106
|
-
throw new
|
|
3191
|
+
throw new import_sdk_core7.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
3107
3192
|
}
|
|
3108
3193
|
if (delegation.expiry.getTime() <= Date.now()) {
|
|
3109
|
-
throw new
|
|
3194
|
+
throw new import_sdk_core7.SessionExpiredError(delegation.expiry);
|
|
3110
3195
|
}
|
|
3111
3196
|
const expectedDids = [session.verificationMethod, this.sessionDid];
|
|
3112
|
-
if (!expectedDids.some((did) =>
|
|
3197
|
+
if (!expectedDids.some((did) => didPrincipalMatches2(delegation.delegateDID, did))) {
|
|
3113
3198
|
throw new Error(
|
|
3114
3199
|
`Runtime delegation targets ${delegation.delegateDID} but this session key is ${session.verificationMethod}.`
|
|
3115
3200
|
);
|
|
3116
3201
|
}
|
|
3117
3202
|
const targetHost = delegation.host ?? this.config.host;
|
|
3118
|
-
const activateResult = await (0,
|
|
3203
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
3119
3204
|
targetHost,
|
|
3120
3205
|
delegation.delegationHeader
|
|
3121
3206
|
);
|
|
@@ -3142,13 +3227,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3142
3227
|
}
|
|
3143
3228
|
const session = this.currentTinyCloudSession();
|
|
3144
3229
|
if (!session) {
|
|
3145
|
-
throw new
|
|
3230
|
+
throw new import_sdk_core7.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
3146
3231
|
}
|
|
3147
3232
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
3148
3233
|
if (sessionExpiry !== void 0) {
|
|
3149
3234
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
3150
3235
|
if (sessionExpiry.getTime() <= Date.now() + marginMs) {
|
|
3151
|
-
throw new
|
|
3236
|
+
throw new import_sdk_core7.SessionExpiredError(sessionExpiry);
|
|
3152
3237
|
}
|
|
3153
3238
|
}
|
|
3154
3239
|
const expanded = this.expandPermissionEntries(permissions);
|
|
@@ -3211,7 +3296,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3211
3296
|
...prepared,
|
|
3212
3297
|
signature
|
|
3213
3298
|
});
|
|
3214
|
-
const activateResult = await (0,
|
|
3299
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
3215
3300
|
this.config.host,
|
|
3216
3301
|
delegatedSession.delegationHeader
|
|
3217
3302
|
);
|
|
@@ -3384,7 +3469,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3384
3469
|
];
|
|
3385
3470
|
const abilities = { kv: { "": kvActions } };
|
|
3386
3471
|
const now = /* @__PURE__ */ new Date();
|
|
3387
|
-
const expiryMs =
|
|
3472
|
+
const expiryMs = import_sdk_core7.EXPIRY.EPHEMERAL_MS;
|
|
3388
3473
|
const expirationTime = new Date(now.getTime() + expiryMs);
|
|
3389
3474
|
const prepared = this.wasmBindings.prepareSession({
|
|
3390
3475
|
abilities,
|
|
@@ -3402,7 +3487,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3402
3487
|
...prepared,
|
|
3403
3488
|
signature
|
|
3404
3489
|
});
|
|
3405
|
-
const activateResult = await (0,
|
|
3490
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
3406
3491
|
this.config.host,
|
|
3407
3492
|
delegationSession.delegationHeader
|
|
3408
3493
|
);
|
|
@@ -3429,8 +3514,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3429
3514
|
}]);
|
|
3430
3515
|
}
|
|
3431
3516
|
if (this._serviceContext) {
|
|
3432
|
-
const publicKV = new
|
|
3433
|
-
const publicContext = new
|
|
3517
|
+
const publicKV = new import_sdk_core7.KVService({ prefix: "" });
|
|
3518
|
+
const publicContext = new import_sdk_core7.ServiceContext({
|
|
3434
3519
|
invoke: this.invokeWithRuntimePermissions,
|
|
3435
3520
|
fetch: this._serviceContext.fetch,
|
|
3436
3521
|
hosts: this._serviceContext.hosts,
|
|
@@ -3557,14 +3642,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3557
3642
|
async delegateTo(did, permissions, options) {
|
|
3558
3643
|
const session = this.currentTinyCloudSession();
|
|
3559
3644
|
if (!session) {
|
|
3560
|
-
throw new
|
|
3645
|
+
throw new import_sdk_core7.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
3561
3646
|
}
|
|
3562
3647
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
3563
3648
|
if (sessionExpiry !== void 0) {
|
|
3564
3649
|
const now2 = Date.now();
|
|
3565
3650
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
3566
3651
|
if (sessionExpiry.getTime() <= now2 + marginMs) {
|
|
3567
|
-
throw new
|
|
3652
|
+
throw new import_sdk_core7.SessionExpiredError(sessionExpiry);
|
|
3568
3653
|
}
|
|
3569
3654
|
}
|
|
3570
3655
|
if (!Array.isArray(permissions) || permissions.length === 0) {
|
|
@@ -3593,11 +3678,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3593
3678
|
);
|
|
3594
3679
|
return { delegation: delegation2, prompted: true };
|
|
3595
3680
|
}
|
|
3596
|
-
const granted = (0,
|
|
3681
|
+
const granted = (0, import_sdk_core7.parseRecapCapabilities)(
|
|
3597
3682
|
(siwe) => this.wasmBindings.parseRecapFromSiwe(siwe),
|
|
3598
3683
|
session.siwe
|
|
3599
3684
|
);
|
|
3600
|
-
const { subset, missing } = (0,
|
|
3685
|
+
const { subset, missing } = (0, import_sdk_core7.isCapabilitySubset)(expandedEntries, granted);
|
|
3601
3686
|
if (!subset) {
|
|
3602
3687
|
const runtimeGrant = this.findGrantForOperations(
|
|
3603
3688
|
this.permissionEntriesToOperations(expandedEntries, session)
|
|
@@ -3605,7 +3690,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3605
3690
|
if (runtimeGrant) {
|
|
3606
3691
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
3607
3692
|
if (runtimeGrant.expiresAt.getTime() <= Date.now() + marginMs) {
|
|
3608
|
-
throw new
|
|
3693
|
+
throw new import_sdk_core7.SessionExpiredError(runtimeGrant.expiresAt);
|
|
3609
3694
|
}
|
|
3610
3695
|
const runtimeExpiration = runtimeGrant.expiresAt < effectiveExpiration ? runtimeGrant.expiresAt : effectiveExpiration;
|
|
3611
3696
|
const delegation2 = await this.createDelegationViaRuntimeGrant(
|
|
@@ -3616,7 +3701,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3616
3701
|
);
|
|
3617
3702
|
return { delegation: delegation2, prompted: false };
|
|
3618
3703
|
}
|
|
3619
|
-
throw new
|
|
3704
|
+
throw new import_sdk_core7.PermissionNotInManifestError(missing, granted);
|
|
3620
3705
|
}
|
|
3621
3706
|
const delegation = await this.createDelegationViaWasmPath(
|
|
3622
3707
|
did,
|
|
@@ -3638,7 +3723,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3638
3723
|
);
|
|
3639
3724
|
}
|
|
3640
3725
|
const target = request.delegationTargets.find(
|
|
3641
|
-
(entry) =>
|
|
3726
|
+
(entry) => didPrincipalMatches2(entry.did, did)
|
|
3642
3727
|
);
|
|
3643
3728
|
if (!target) {
|
|
3644
3729
|
throw new Error(`No manifest delegation target found for DID ${did}`);
|
|
@@ -3698,7 +3783,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3698
3783
|
const spaceId = resolvedSpaces.size === 1 ? [...resolvedSpaces][0] : session.spaceId;
|
|
3699
3784
|
const abilities = {};
|
|
3700
3785
|
for (const entry of entries) {
|
|
3701
|
-
const shortService =
|
|
3786
|
+
const shortService = import_sdk_core7.SERVICE_LONG_TO_SHORT[entry.service];
|
|
3702
3787
|
if (shortService === void 0) {
|
|
3703
3788
|
throw new Error(
|
|
3704
3789
|
`delegateTo: unknown service '${entry.service}' \u2014 no short-form mapping`
|
|
@@ -3738,7 +3823,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3738
3823
|
});
|
|
3739
3824
|
const primary = result.resources[0];
|
|
3740
3825
|
const delegationHeader = { Authorization: result.delegation };
|
|
3741
|
-
const activateResult = await (0,
|
|
3826
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
3742
3827
|
this.config.host,
|
|
3743
3828
|
delegationHeader
|
|
3744
3829
|
);
|
|
@@ -3773,7 +3858,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3773
3858
|
const primary = result.resources[0];
|
|
3774
3859
|
const delegationHeader = { Authorization: result.delegation };
|
|
3775
3860
|
const targetHost = grant.delegation.host ?? this.config.host;
|
|
3776
|
-
const activateResult = await (0,
|
|
3861
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
3777
3862
|
targetHost,
|
|
3778
3863
|
delegationHeader
|
|
3779
3864
|
);
|
|
@@ -3814,10 +3899,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3814
3899
|
return this.wasmBindings.makeSpaceId(session.address, session.chainId, space);
|
|
3815
3900
|
}
|
|
3816
3901
|
expandPermissionEntries(permissions) {
|
|
3817
|
-
return (0,
|
|
3902
|
+
return (0, import_sdk_core7.expandPermissionEntries)(permissions);
|
|
3818
3903
|
}
|
|
3819
3904
|
shortServiceName(service) {
|
|
3820
|
-
const short =
|
|
3905
|
+
const short = import_sdk_core7.SERVICE_LONG_TO_SHORT[service];
|
|
3821
3906
|
if (short === void 0) {
|
|
3822
3907
|
throw new Error(
|
|
3823
3908
|
`unknown service '${service}' \u2014 no short-form mapping`
|
|
@@ -3843,7 +3928,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3843
3928
|
return abilities;
|
|
3844
3929
|
}
|
|
3845
3930
|
isEncryptionPermissionEntry(entry) {
|
|
3846
|
-
return entry.service ===
|
|
3931
|
+
return entry.service === import_sdk_core7.ENCRYPTION_PERMISSION_SERVICE && entry.path.startsWith("urn:tinycloud:encryption:");
|
|
3847
3932
|
}
|
|
3848
3933
|
permissionsToRawAbilities(entries) {
|
|
3849
3934
|
const rawAbilities = {};
|
|
@@ -3876,11 +3961,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3876
3961
|
}
|
|
3877
3962
|
sessionCoversPermissionEntries(session, entries) {
|
|
3878
3963
|
try {
|
|
3879
|
-
const granted = (0,
|
|
3964
|
+
const granted = (0, import_sdk_core7.parseRecapCapabilities)(
|
|
3880
3965
|
(siwe) => this.wasmBindings.parseRecapFromSiwe(siwe),
|
|
3881
3966
|
session.siwe
|
|
3882
3967
|
);
|
|
3883
|
-
return (0,
|
|
3968
|
+
return (0, import_sdk_core7.isCapabilitySubset)(entries, granted).subset;
|
|
3884
3969
|
} catch {
|
|
3885
3970
|
return false;
|
|
3886
3971
|
}
|
|
@@ -4211,7 +4296,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4211
4296
|
if (resolvedDelegateDID.endsWith(".eth") && this.config.ensResolver) {
|
|
4212
4297
|
const address = await this.config.ensResolver.resolveAddress(resolvedDelegateDID);
|
|
4213
4298
|
if (!address) throw new Error(`Could not resolve ENS name: ${resolvedDelegateDID}`);
|
|
4214
|
-
resolvedDelegateDID = (0,
|
|
4299
|
+
resolvedDelegateDID = (0, import_sdk_core7.pkhDid)(address, 1);
|
|
4215
4300
|
}
|
|
4216
4301
|
const entries = legacyParamsToPermissionEntries(
|
|
4217
4302
|
params.actions,
|
|
@@ -4226,7 +4311,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4226
4311
|
);
|
|
4227
4312
|
return result.delegation;
|
|
4228
4313
|
} catch (err) {
|
|
4229
|
-
if (err instanceof
|
|
4314
|
+
if (err instanceof import_sdk_core7.PermissionNotInManifestError) {
|
|
4230
4315
|
} else {
|
|
4231
4316
|
throw err;
|
|
4232
4317
|
}
|
|
@@ -4283,7 +4368,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4283
4368
|
...prepared,
|
|
4284
4369
|
signature
|
|
4285
4370
|
});
|
|
4286
|
-
const activateResult = await (0,
|
|
4371
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
4287
4372
|
this.config.host,
|
|
4288
4373
|
delegationSession.delegationHeader
|
|
4289
4374
|
);
|
|
@@ -4305,7 +4390,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4305
4390
|
};
|
|
4306
4391
|
const hasKvActions = params.actions.some((a) => a.startsWith("tinycloud.kv/"));
|
|
4307
4392
|
if (hasKvActions && params.includePublicSpace !== false) {
|
|
4308
|
-
const publicSpaceId = (0,
|
|
4393
|
+
const publicSpaceId = (0, import_sdk_core7.makePublicSpaceId)(
|
|
4309
4394
|
this.wasmBindings.ensureEip55(session.address),
|
|
4310
4395
|
session.chainId
|
|
4311
4396
|
);
|
|
@@ -4328,7 +4413,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4328
4413
|
...publicPrepared,
|
|
4329
4414
|
signature: publicSignature
|
|
4330
4415
|
});
|
|
4331
|
-
const publicActivateResult = await (0,
|
|
4416
|
+
const publicActivateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
4332
4417
|
this.config.host,
|
|
4333
4418
|
publicSession.delegationHeader
|
|
4334
4419
|
);
|
|
@@ -4368,7 +4453,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4368
4453
|
const targetHost = delegation.host ?? this.config.host;
|
|
4369
4454
|
if (this.isSessionOnly) {
|
|
4370
4455
|
const myDid = this.did;
|
|
4371
|
-
if (!
|
|
4456
|
+
if (!didPrincipalMatches2(delegation.delegateDID, myDid)) {
|
|
4372
4457
|
throw new Error(
|
|
4373
4458
|
`Delegation targets ${delegation.delegateDID} but this user's DID is ${myDid}. The delegation must target this user's DID.`
|
|
4374
4459
|
);
|
|
@@ -4433,7 +4518,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4433
4518
|
...prepared,
|
|
4434
4519
|
signature
|
|
4435
4520
|
});
|
|
4436
|
-
const activateResult = await (0,
|
|
4521
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
4437
4522
|
targetHost,
|
|
4438
4523
|
invokerSession.delegationHeader
|
|
4439
4524
|
);
|
|
@@ -4539,7 +4624,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4539
4624
|
...prepared,
|
|
4540
4625
|
signature
|
|
4541
4626
|
});
|
|
4542
|
-
const activateResult = await (0,
|
|
4627
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
4543
4628
|
targetHost,
|
|
4544
4629
|
subDelegationSession.delegationHeader
|
|
4545
4630
|
);
|
|
@@ -4575,7 +4660,7 @@ _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS = 6e4;
|
|
|
4575
4660
|
var TinyCloudNode = _TinyCloudNode;
|
|
4576
4661
|
|
|
4577
4662
|
// src/core.ts
|
|
4578
|
-
var
|
|
4663
|
+
var import_sdk_core10 = require("@tinycloud/sdk-core");
|
|
4579
4664
|
|
|
4580
4665
|
// src/delegation.ts
|
|
4581
4666
|
function serializeDelegation(delegation) {
|
|
@@ -4594,7 +4679,6 @@ function deserializeDelegation(data) {
|
|
|
4594
4679
|
}
|
|
4595
4680
|
|
|
4596
4681
|
// src/core.ts
|
|
4597
|
-
var import_sdk_core10 = require("@tinycloud/sdk-core");
|
|
4598
4682
|
var import_sdk_core11 = require("@tinycloud/sdk-core");
|
|
4599
4683
|
var import_sdk_core12 = require("@tinycloud/sdk-core");
|
|
4600
4684
|
var import_sdk_core13 = require("@tinycloud/sdk-core");
|
|
@@ -4603,10 +4687,12 @@ var import_sdk_core15 = require("@tinycloud/sdk-core");
|
|
|
4603
4687
|
var import_sdk_core16 = require("@tinycloud/sdk-core");
|
|
4604
4688
|
var import_sdk_core17 = require("@tinycloud/sdk-core");
|
|
4605
4689
|
var import_sdk_core18 = require("@tinycloud/sdk-core");
|
|
4690
|
+
var import_sdk_core19 = require("@tinycloud/sdk-core");
|
|
4606
4691
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4607
4692
|
0 && (module.exports = {
|
|
4608
4693
|
ACCOUNT_REGISTRY_PATH,
|
|
4609
4694
|
ACCOUNT_REGISTRY_SPACE,
|
|
4695
|
+
AccountService,
|
|
4610
4696
|
AutoApproveSpaceCreationHandler,
|
|
4611
4697
|
CapabilityKeyRegistry,
|
|
4612
4698
|
CapabilityKeyRegistryErrorCodes,
|