@tinycloud/node-sdk 2.4.0-beta.5 → 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-BSQqoLAd.d.cts → core-zT0sxgtZ.d.cts} +11 -1
- package/dist/{core-BSQqoLAd.d.ts → core-zT0sxgtZ.d.ts} +11 -1
- package/dist/core.cjs +217 -181
- 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 +35 -0
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +260 -224
- 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 +35 -0
- 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 {
|
|
@@ -1136,32 +1137,35 @@ var NodeUserAuthorization = class {
|
|
|
1136
1137
|
};
|
|
1137
1138
|
|
|
1138
1139
|
// src/TinyCloudNode.ts
|
|
1139
|
-
var
|
|
1140
|
+
var import_sdk_core7 = require("@tinycloud/sdk-core");
|
|
1140
1141
|
|
|
1141
|
-
// src/
|
|
1142
|
+
// src/account/AccountService.ts
|
|
1142
1143
|
var import_sdk_core3 = require("@tinycloud/sdk-core");
|
|
1144
|
+
|
|
1145
|
+
// src/DelegatedAccess.ts
|
|
1146
|
+
var import_sdk_core4 = require("@tinycloud/sdk-core");
|
|
1143
1147
|
var DelegatedAccess = class {
|
|
1144
1148
|
constructor(session, delegation, host, invoke, telemetry) {
|
|
1145
1149
|
this.session = session;
|
|
1146
1150
|
this._delegation = delegation;
|
|
1147
1151
|
this.host = host;
|
|
1148
|
-
this._serviceContext = new
|
|
1152
|
+
this._serviceContext = new import_sdk_core4.ServiceContext({
|
|
1149
1153
|
invoke,
|
|
1150
1154
|
fetch: globalThis.fetch.bind(globalThis),
|
|
1151
1155
|
hosts: [host],
|
|
1152
1156
|
telemetry
|
|
1153
1157
|
});
|
|
1154
1158
|
const prefix = this._delegation.path.replace(/\/$/, "");
|
|
1155
|
-
this._kv = new
|
|
1159
|
+
this._kv = new import_sdk_core4.KVService({ prefix });
|
|
1156
1160
|
this._kv.initialize(this._serviceContext);
|
|
1157
1161
|
this._serviceContext.registerService("kv", this._kv);
|
|
1158
|
-
this._sql = new
|
|
1162
|
+
this._sql = new import_sdk_core4.SQLService({});
|
|
1159
1163
|
this._sql.initialize(this._serviceContext);
|
|
1160
1164
|
this._serviceContext.registerService("sql", this._sql);
|
|
1161
|
-
this._duckdb = new
|
|
1165
|
+
this._duckdb = new import_sdk_core4.DuckDbService({});
|
|
1162
1166
|
this._duckdb.initialize(this._serviceContext);
|
|
1163
1167
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
1164
|
-
this._hooks = new
|
|
1168
|
+
this._hooks = new import_sdk_core4.HooksService({});
|
|
1165
1169
|
this._hooks.initialize(this._serviceContext);
|
|
1166
1170
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
1167
1171
|
const serviceSession = {
|
|
@@ -1311,7 +1315,7 @@ function createWasmKeyProvider(sessionManager) {
|
|
|
1311
1315
|
}
|
|
1312
1316
|
|
|
1313
1317
|
// src/delegateToHelpers.ts
|
|
1314
|
-
var
|
|
1318
|
+
var import_sdk_core5 = require("@tinycloud/sdk-core");
|
|
1315
1319
|
function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
1316
1320
|
const byService = /* @__PURE__ */ new Map();
|
|
1317
1321
|
for (const a of actions) {
|
|
@@ -1342,7 +1346,7 @@ function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
|
1342
1346
|
}
|
|
1343
1347
|
return entries;
|
|
1344
1348
|
}
|
|
1345
|
-
var DEFAULT_DELEGATION_EXPIRY_MS =
|
|
1349
|
+
var DEFAULT_DELEGATION_EXPIRY_MS = import_sdk_core5.EXPIRY.SESSION_MS;
|
|
1346
1350
|
function resolveExpiryMs(expiry) {
|
|
1347
1351
|
if (expiry === void 0) {
|
|
1348
1352
|
return DEFAULT_DELEGATION_EXPIRY_MS;
|
|
@@ -1355,10 +1359,10 @@ function resolveExpiryMs(expiry) {
|
|
|
1355
1359
|
}
|
|
1356
1360
|
return expiry;
|
|
1357
1361
|
}
|
|
1358
|
-
return (0,
|
|
1362
|
+
return (0, import_sdk_core5.parseExpiry)(expiry);
|
|
1359
1363
|
}
|
|
1360
1364
|
function extractSiweExpiration(siwe) {
|
|
1361
|
-
const parsed = new
|
|
1365
|
+
const parsed = new import_sdk_core5.SiweMessage(siwe);
|
|
1362
1366
|
if (parsed.expirationTime === void 0 || parsed.expirationTime === null) {
|
|
1363
1367
|
return void 0;
|
|
1364
1368
|
}
|
|
@@ -1372,7 +1376,7 @@ function extractSiweExpiration(siwe) {
|
|
|
1372
1376
|
}
|
|
1373
1377
|
|
|
1374
1378
|
// src/NodeSecretsService.ts
|
|
1375
|
-
var
|
|
1379
|
+
var import_sdk_core6 = require("@tinycloud/sdk-core");
|
|
1376
1380
|
var SECRETS_SPACE = "secrets";
|
|
1377
1381
|
function ok() {
|
|
1378
1382
|
return { ok: true, data: void 0 };
|
|
@@ -1405,7 +1409,7 @@ function secretActionName(action) {
|
|
|
1405
1409
|
}
|
|
1406
1410
|
function secretPermissionEntries(name, options, action, encryptionNetworkId) {
|
|
1407
1411
|
const entries = [];
|
|
1408
|
-
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;
|
|
1409
1413
|
entries.push({
|
|
1410
1414
|
service: "tinycloud.kv",
|
|
1411
1415
|
space: SECRETS_SPACE,
|
|
@@ -1484,7 +1488,7 @@ var NodeSecretsService = class {
|
|
|
1484
1488
|
);
|
|
1485
1489
|
} catch (error) {
|
|
1486
1490
|
return secretsError(
|
|
1487
|
-
|
|
1491
|
+
import_sdk_core6.ErrorCodes.INVALID_INPUT,
|
|
1488
1492
|
error instanceof Error ? error.message : String(error),
|
|
1489
1493
|
error instanceof Error ? error : void 0
|
|
1490
1494
|
);
|
|
@@ -1494,7 +1498,7 @@ var NodeSecretsService = class {
|
|
|
1494
1498
|
}
|
|
1495
1499
|
if (!this.config.canEscalate()) {
|
|
1496
1500
|
return secretsError(
|
|
1497
|
-
|
|
1501
|
+
import_sdk_core6.ErrorCodes.PERMISSION_DENIED,
|
|
1498
1502
|
`Cannot autosign ${displayActionUrn(action)} for ${target}; TinyCloudNode needs wallet mode with a signer or privateKey.`
|
|
1499
1503
|
);
|
|
1500
1504
|
}
|
|
@@ -1503,7 +1507,7 @@ var NodeSecretsService = class {
|
|
|
1503
1507
|
return this.restoreUnlockAfterEscalation();
|
|
1504
1508
|
} catch (error) {
|
|
1505
1509
|
return secretsError(
|
|
1506
|
-
|
|
1510
|
+
import_sdk_core6.ErrorCodes.PERMISSION_DENIED,
|
|
1507
1511
|
error instanceof Error ? error.message : `Autosign escalation for ${displayActionUrn(action)} on ${target} failed.`,
|
|
1508
1512
|
error instanceof Error ? error : void 0
|
|
1509
1513
|
);
|
|
@@ -1524,10 +1528,10 @@ var NodeSecretsService = class {
|
|
|
1524
1528
|
return false;
|
|
1525
1529
|
}
|
|
1526
1530
|
const manifests = Array.isArray(manifest) ? manifest : [manifest];
|
|
1527
|
-
const requestedEntries = (0,
|
|
1531
|
+
const requestedEntries = (0, import_sdk_core6.expandPermissionEntries)(permissionEntries);
|
|
1528
1532
|
return requestedEntries.every(
|
|
1529
1533
|
(entry) => manifests.some((candidate) => {
|
|
1530
|
-
const resolved = (0,
|
|
1534
|
+
const resolved = (0, import_sdk_core6.resolveManifest)(candidate);
|
|
1531
1535
|
return resolved.resources.some(
|
|
1532
1536
|
(resource) => resource.service === entry.service && resource.space === entry.space && resource.path === entry.path && entry.actions.every((action) => resource.actions.includes(action))
|
|
1533
1537
|
);
|
|
@@ -1542,10 +1546,10 @@ var DEFAULT_ENCRYPTION_NETWORK_NAME = "default";
|
|
|
1542
1546
|
var NETWORK_CREATE_ACTION2 = "tinycloud.encryption/network.create";
|
|
1543
1547
|
var DECRYPT_ACTION2 = "tinycloud.encryption/decrypt";
|
|
1544
1548
|
var NETWORK_ADMIN_TYPE = "tinycloud.encryption.network-admin/v1";
|
|
1545
|
-
var DEFAULT_SESSION_EXPIRATION_MS =
|
|
1549
|
+
var DEFAULT_SESSION_EXPIRATION_MS = import_sdk_core7.EXPIRY.SESSION_MS;
|
|
1546
1550
|
function didPrincipalMatches2(actual, expected) {
|
|
1547
1551
|
try {
|
|
1548
|
-
return (0,
|
|
1552
|
+
return (0, import_sdk_core7.principalDidEquals)(actual, expected);
|
|
1549
1553
|
} catch {
|
|
1550
1554
|
return actual === expected;
|
|
1551
1555
|
}
|
|
@@ -1711,12 +1715,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1711
1715
|
throw new Error("Failed to get session key JWK");
|
|
1712
1716
|
}
|
|
1713
1717
|
this.sessionKeyJwk = JSON.parse(jwkStr);
|
|
1714
|
-
this._capabilityRegistry = new
|
|
1718
|
+
this._capabilityRegistry = new import_sdk_core7.CapabilityKeyRegistry();
|
|
1715
1719
|
this._keyProvider = new WasmKeyProvider({
|
|
1716
1720
|
sessionManager: this.sessionManager
|
|
1717
1721
|
});
|
|
1718
|
-
this.notificationHandler = config.notificationHandler ?? new
|
|
1719
|
-
this._sharingService = new
|
|
1722
|
+
this.notificationHandler = config.notificationHandler ?? new import_sdk_core7.SilentNotificationHandler();
|
|
1723
|
+
this._sharingService = new import_sdk_core7.SharingService({
|
|
1720
1724
|
hosts: [this.config.host],
|
|
1721
1725
|
// session: undefined - not needed for receive()
|
|
1722
1726
|
invoke: this.invokeWithRuntimePermissions,
|
|
@@ -1726,8 +1730,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1726
1730
|
// delegationManager: undefined - not needed for receive()
|
|
1727
1731
|
createKVService: (config2) => {
|
|
1728
1732
|
const prefix = config2.pathPrefix?.replace(/\/$/, "");
|
|
1729
|
-
const kvService = new
|
|
1730
|
-
const kvContext = new
|
|
1733
|
+
const kvService = new import_sdk_core7.KVService({ prefix });
|
|
1734
|
+
const kvContext = new import_sdk_core7.ServiceContext({
|
|
1731
1735
|
invoke: config2.invoke,
|
|
1732
1736
|
fetch: config2.fetch ?? globalThis.fetch.bind(globalThis),
|
|
1733
1737
|
hosts: config2.hosts,
|
|
@@ -1787,7 +1791,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1787
1791
|
capabilityRequest: config.capabilityRequest,
|
|
1788
1792
|
includeAccountRegistryPermissions: config.includeAccountRegistryPermissions
|
|
1789
1793
|
});
|
|
1790
|
-
this.tc = new
|
|
1794
|
+
this.tc = new import_sdk_core7.TinyCloud(this.auth, {
|
|
1791
1795
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
1792
1796
|
telemetry: config.telemetry
|
|
1793
1797
|
});
|
|
@@ -1848,7 +1852,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1848
1852
|
*/
|
|
1849
1853
|
get did() {
|
|
1850
1854
|
if (this._address) {
|
|
1851
|
-
return (0,
|
|
1855
|
+
return (0, import_sdk_core7.pkhDid)(this._address, this._chainId);
|
|
1852
1856
|
}
|
|
1853
1857
|
return this.sessionManager.getDID(this.sessionKeyId);
|
|
1854
1858
|
}
|
|
@@ -1882,6 +1886,37 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1882
1886
|
get spaceId() {
|
|
1883
1887
|
return this.auth?.tinyCloudSession?.spaceId;
|
|
1884
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
|
+
}
|
|
1885
1920
|
/**
|
|
1886
1921
|
* Get the current TinyCloud session.
|
|
1887
1922
|
* Available after signIn().
|
|
@@ -1903,7 +1938,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1903
1938
|
);
|
|
1904
1939
|
}
|
|
1905
1940
|
await this.wasmBindings.ensureInitialized?.();
|
|
1906
|
-
this._address = (0,
|
|
1941
|
+
this._address = (0, import_sdk_core7.canonicalizeAddress)(await this.signer.getAddress());
|
|
1907
1942
|
this._chainId = await this.signer.getChainId();
|
|
1908
1943
|
this._kv = void 0;
|
|
1909
1944
|
this._sql = void 0;
|
|
@@ -1940,7 +1975,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1940
1975
|
if (!this.auth || !this.signer) {
|
|
1941
1976
|
throw new Error("Manifest registry write requires wallet mode");
|
|
1942
1977
|
}
|
|
1943
|
-
const accountSpaceId = this.ownedSpaceId(
|
|
1978
|
+
const accountSpaceId = this.ownedSpaceId(import_sdk_core7.ACCOUNT_REGISTRY_SPACE);
|
|
1944
1979
|
await this.ensureOwnedSpaceHosted(accountSpaceId);
|
|
1945
1980
|
const accountKV = this.spaces.get(accountSpaceId).kv;
|
|
1946
1981
|
for (const record of request.registryRecords) {
|
|
@@ -1963,7 +1998,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1963
1998
|
}
|
|
1964
1999
|
const networkIds = /* @__PURE__ */ new Set();
|
|
1965
2000
|
for (const resource of request.resources) {
|
|
1966
|
-
if (resource.service ===
|
|
2001
|
+
if (resource.service === import_sdk_core7.ENCRYPTION_PERMISSION_SERVICE && resource.path.startsWith("urn:tinycloud:encryption:") && resource.actions.includes(DECRYPT_ACTION2)) {
|
|
1967
2002
|
networkIds.add(resource.path);
|
|
1968
2003
|
}
|
|
1969
2004
|
}
|
|
@@ -1974,7 +2009,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1974
2009
|
return;
|
|
1975
2010
|
}
|
|
1976
2011
|
for (const networkId of this.requestedEncryptionNetworkIds()) {
|
|
1977
|
-
const parsed = (0,
|
|
2012
|
+
const parsed = (0, import_sdk_core7.parseNetworkId)(networkId);
|
|
1978
2013
|
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
1979
2014
|
continue;
|
|
1980
2015
|
}
|
|
@@ -1993,7 +2028,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1993
2028
|
if (!host) {
|
|
1994
2029
|
throw new Error("Owned space hosting requires a TinyCloud host");
|
|
1995
2030
|
}
|
|
1996
|
-
const activation = await (0,
|
|
2031
|
+
const activation = await (0, import_sdk_core7.activateSessionWithHost)(host, session.delegationHeader);
|
|
1997
2032
|
if (activation.success && !activation.skipped?.includes(spaceId)) {
|
|
1998
2033
|
return;
|
|
1999
2034
|
}
|
|
@@ -2007,7 +2042,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2007
2042
|
throw new Error(`Failed to create owned space: ${spaceId}`);
|
|
2008
2043
|
}
|
|
2009
2044
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
2010
|
-
const retry = await (0,
|
|
2045
|
+
const retry = await (0, import_sdk_core7.activateSessionWithHost)(host, session.delegationHeader);
|
|
2011
2046
|
if (!retry.success || retry.skipped?.includes(spaceId)) {
|
|
2012
2047
|
throw new Error(
|
|
2013
2048
|
`Failed to activate session after creating owned space ${spaceId}: ${retry.error ?? "space was skipped"}`
|
|
@@ -2049,7 +2084,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2049
2084
|
if (!hosted) {
|
|
2050
2085
|
throw new Error(`Failed to host owned space: ${spaceId}`);
|
|
2051
2086
|
}
|
|
2052
|
-
const activation = await (0,
|
|
2087
|
+
const activation = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
2053
2088
|
host,
|
|
2054
2089
|
this.auth.tinyCloudSession.delegationHeader
|
|
2055
2090
|
);
|
|
@@ -2082,30 +2117,30 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2082
2117
|
this._spaceService = void 0;
|
|
2083
2118
|
this._serviceContext = void 0;
|
|
2084
2119
|
this.runtimePermissionGrants = [];
|
|
2085
|
-
const restoredAddress = sessionData.address ? (0,
|
|
2120
|
+
const restoredAddress = sessionData.address ? (0, import_sdk_core7.canonicalizeAddress)(sessionData.address) : void 0;
|
|
2086
2121
|
if (restoredAddress) {
|
|
2087
2122
|
this._address = restoredAddress;
|
|
2088
2123
|
}
|
|
2089
2124
|
if (sessionData.chainId) {
|
|
2090
2125
|
this._chainId = sessionData.chainId;
|
|
2091
2126
|
}
|
|
2092
|
-
this._serviceContext = new
|
|
2127
|
+
this._serviceContext = new import_sdk_core7.ServiceContext({
|
|
2093
2128
|
invoke: this.invokeWithRuntimePermissions,
|
|
2094
2129
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
2095
2130
|
fetch: globalThis.fetch.bind(globalThis),
|
|
2096
2131
|
hosts: [this.config.host],
|
|
2097
2132
|
telemetry: this.config.telemetry
|
|
2098
2133
|
});
|
|
2099
|
-
this._kv = new
|
|
2134
|
+
this._kv = new import_sdk_core7.KVService({});
|
|
2100
2135
|
this._kv.initialize(this._serviceContext);
|
|
2101
2136
|
this._serviceContext.registerService("kv", this._kv);
|
|
2102
|
-
this._sql = new
|
|
2137
|
+
this._sql = new import_sdk_core7.SQLService({});
|
|
2103
2138
|
this._sql.initialize(this._serviceContext);
|
|
2104
2139
|
this._serviceContext.registerService("sql", this._sql);
|
|
2105
|
-
this._duckdb = new
|
|
2140
|
+
this._duckdb = new import_sdk_core7.DuckDbService({});
|
|
2106
2141
|
this._duckdb.initialize(this._serviceContext);
|
|
2107
2142
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
2108
|
-
this._hooks = new
|
|
2143
|
+
this._hooks = new import_sdk_core7.HooksService({});
|
|
2109
2144
|
this._hooks.initialize(this._serviceContext);
|
|
2110
2145
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
2111
2146
|
const serviceSession = {
|
|
@@ -2204,7 +2239,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2204
2239
|
capabilityRequest: this.config.capabilityRequest,
|
|
2205
2240
|
includeAccountRegistryPermissions: this.config.includeAccountRegistryPermissions
|
|
2206
2241
|
});
|
|
2207
|
-
this.tc = new
|
|
2242
|
+
this.tc = new import_sdk_core7.TinyCloud(this.auth, {
|
|
2208
2243
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
2209
2244
|
telemetry: this.config.telemetry
|
|
2210
2245
|
});
|
|
@@ -2249,7 +2284,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2249
2284
|
capabilityRequest: this.config.capabilityRequest,
|
|
2250
2285
|
includeAccountRegistryPermissions: this.config.includeAccountRegistryPermissions
|
|
2251
2286
|
});
|
|
2252
|
-
this.tc = new
|
|
2287
|
+
this.tc = new import_sdk_core7.TinyCloud(this.auth, {
|
|
2253
2288
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
2254
2289
|
telemetry: this.config.telemetry
|
|
2255
2290
|
});
|
|
@@ -2265,28 +2300,28 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2265
2300
|
return;
|
|
2266
2301
|
}
|
|
2267
2302
|
this.tc.initializeServices(this.invokeWithRuntimePermissions, [this.config.host]);
|
|
2268
|
-
this._serviceContext = new
|
|
2303
|
+
this._serviceContext = new import_sdk_core7.ServiceContext({
|
|
2269
2304
|
invoke: this.invokeWithRuntimePermissions,
|
|
2270
2305
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
2271
2306
|
fetch: globalThis.fetch.bind(globalThis),
|
|
2272
2307
|
hosts: [this.config.host],
|
|
2273
2308
|
telemetry: this.config.telemetry
|
|
2274
2309
|
});
|
|
2275
|
-
this._kv = new
|
|
2310
|
+
this._kv = new import_sdk_core7.KVService({});
|
|
2276
2311
|
this._kv.initialize(this._serviceContext);
|
|
2277
2312
|
this._serviceContext.registerService("kv", this._kv);
|
|
2278
2313
|
const features = this.nodeFeatures;
|
|
2279
2314
|
if (features.length === 0 || features.includes("sql")) {
|
|
2280
|
-
this._sql = new
|
|
2315
|
+
this._sql = new import_sdk_core7.SQLService({});
|
|
2281
2316
|
this._sql.initialize(this._serviceContext);
|
|
2282
2317
|
this._serviceContext.registerService("sql", this._sql);
|
|
2283
2318
|
}
|
|
2284
2319
|
if (features.length === 0 || features.includes("duckdb")) {
|
|
2285
|
-
this._duckdb = new
|
|
2320
|
+
this._duckdb = new import_sdk_core7.DuckDbService({});
|
|
2286
2321
|
this._duckdb.initialize(this._serviceContext);
|
|
2287
2322
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
2288
2323
|
}
|
|
2289
|
-
this._hooks = new
|
|
2324
|
+
this._hooks = new import_sdk_core7.HooksService({});
|
|
2290
2325
|
this._hooks.initialize(this._serviceContext);
|
|
2291
2326
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
2292
2327
|
const serviceSession = {
|
|
@@ -2304,9 +2339,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2304
2339
|
this.initializeV2Services(serviceSession);
|
|
2305
2340
|
}
|
|
2306
2341
|
createSpaceScopedKVService(spaceId) {
|
|
2307
|
-
const kvService = new
|
|
2342
|
+
const kvService = new import_sdk_core7.KVService({});
|
|
2308
2343
|
if (this._serviceContext) {
|
|
2309
|
-
const spaceScopedContext = new
|
|
2344
|
+
const spaceScopedContext = new import_sdk_core7.ServiceContext({
|
|
2310
2345
|
invoke: this._serviceContext.invoke,
|
|
2311
2346
|
fetch: this._serviceContext.fetch,
|
|
2312
2347
|
hosts: this._serviceContext.hosts,
|
|
@@ -2371,7 +2406,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2371
2406
|
const shared = wasm.vault_x25519_dh(receiverPrivateKey, peerPublic);
|
|
2372
2407
|
return columnDecrypt(shared, ciphertext);
|
|
2373
2408
|
},
|
|
2374
|
-
verifyNodeSignature: (nodeId, message, signature) => (0,
|
|
2409
|
+
verifyNodeSignature: (nodeId, message, signature) => (0, import_sdk_core7.verifyDidKeyEd25519Signature)(nodeId, message, signature)
|
|
2375
2410
|
};
|
|
2376
2411
|
}
|
|
2377
2412
|
async fetchNodeId() {
|
|
@@ -2442,7 +2477,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2442
2477
|
return await response.json();
|
|
2443
2478
|
}
|
|
2444
2479
|
};
|
|
2445
|
-
return new
|
|
2480
|
+
return new import_sdk_core7.EncryptionService({
|
|
2446
2481
|
crypto,
|
|
2447
2482
|
signer: {
|
|
2448
2483
|
signDecryptInvocation: async (input) => {
|
|
@@ -2454,7 +2489,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2454
2489
|
});
|
|
2455
2490
|
return {
|
|
2456
2491
|
...signed,
|
|
2457
|
-
canonicalBody: (0,
|
|
2492
|
+
canonicalBody: (0, import_sdk_core7.canonicalizeEncryptionJson)(
|
|
2458
2493
|
input.body
|
|
2459
2494
|
)
|
|
2460
2495
|
};
|
|
@@ -2472,8 +2507,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2472
2507
|
if (!this.config.host) {
|
|
2473
2508
|
return null;
|
|
2474
2509
|
}
|
|
2475
|
-
const publicSpaceId = (0,
|
|
2476
|
-
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);
|
|
2477
2512
|
if (!result.ok) {
|
|
2478
2513
|
return null;
|
|
2479
2514
|
}
|
|
@@ -2496,7 +2531,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2496
2531
|
}
|
|
2497
2532
|
createVaultService(spaceId, kv) {
|
|
2498
2533
|
const wasm = this.wasmBindings;
|
|
2499
|
-
const vaultCrypto = (0,
|
|
2534
|
+
const vaultCrypto = (0, import_sdk_core7.createVaultCrypto)({
|
|
2500
2535
|
vault_encrypt: wasm.vault_encrypt,
|
|
2501
2536
|
vault_decrypt: wasm.vault_decrypt,
|
|
2502
2537
|
vault_derive_key: wasm.vault_derive_key,
|
|
@@ -2506,7 +2541,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2506
2541
|
vault_sha256: wasm.vault_sha256
|
|
2507
2542
|
});
|
|
2508
2543
|
const self = this;
|
|
2509
|
-
return new
|
|
2544
|
+
return new import_sdk_core7.DataVaultService({
|
|
2510
2545
|
spaceId,
|
|
2511
2546
|
crypto: vaultCrypto,
|
|
2512
2547
|
encryption: {
|
|
@@ -2529,8 +2564,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2529
2564
|
get publicKV() {
|
|
2530
2565
|
return self._publicKV ?? self.tc.publicKV;
|
|
2531
2566
|
},
|
|
2532
|
-
readPublicSpace: (host, targetSpaceId, key) =>
|
|
2533
|
-
makePublicSpaceId:
|
|
2567
|
+
readPublicSpace: (host, targetSpaceId, key) => import_sdk_core7.TinyCloud.readPublicSpace(host, targetSpaceId, key),
|
|
2568
|
+
makePublicSpaceId: import_sdk_core7.TinyCloud.makePublicSpaceId,
|
|
2534
2569
|
did: this.did,
|
|
2535
2570
|
address: this._address ?? "",
|
|
2536
2571
|
chainId: this._chainId,
|
|
@@ -2543,7 +2578,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2543
2578
|
* @internal
|
|
2544
2579
|
*/
|
|
2545
2580
|
initializeV2Services(serviceSession) {
|
|
2546
|
-
this._capabilityRegistry = new
|
|
2581
|
+
this._capabilityRegistry = new import_sdk_core7.CapabilityKeyRegistry();
|
|
2547
2582
|
const tcSession = this.auth?.tinyCloudSession;
|
|
2548
2583
|
if (tcSession && this._address) {
|
|
2549
2584
|
const sessionKey = {
|
|
@@ -2617,13 +2652,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2617
2652
|
}
|
|
2618
2653
|
this._capabilityRegistry.registerKey(sessionKey, delegations);
|
|
2619
2654
|
}
|
|
2620
|
-
this._delegationManager = new
|
|
2655
|
+
this._delegationManager = new import_sdk_core7.DelegationManager({
|
|
2621
2656
|
hosts: [this.config.host],
|
|
2622
2657
|
session: serviceSession,
|
|
2623
2658
|
invoke: this.invokeWithRuntimePermissions,
|
|
2624
2659
|
fetch: globalThis.fetch.bind(globalThis)
|
|
2625
2660
|
});
|
|
2626
|
-
this._spaceService = new
|
|
2661
|
+
this._spaceService = new import_sdk_core7.SpaceService({
|
|
2627
2662
|
hosts: [this.config.host],
|
|
2628
2663
|
session: serviceSession,
|
|
2629
2664
|
invoke: this.wasmBindings.invoke,
|
|
@@ -2780,7 +2815,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2780
2815
|
...prepared,
|
|
2781
2816
|
signature
|
|
2782
2817
|
});
|
|
2783
|
-
const activateResult = await (0,
|
|
2818
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
2784
2819
|
host,
|
|
2785
2820
|
delegationSession.delegationHeader
|
|
2786
2821
|
);
|
|
@@ -2790,7 +2825,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2790
2825
|
return {
|
|
2791
2826
|
cid: delegationSession.delegationCid,
|
|
2792
2827
|
delegateDID: params.shareKeyDID,
|
|
2793
|
-
delegatorDID: (0,
|
|
2828
|
+
delegatorDID: (0, import_sdk_core7.pkhDid)(session.address, session.chainId),
|
|
2794
2829
|
spaceId: params.spaceId,
|
|
2795
2830
|
path: params.path,
|
|
2796
2831
|
actions: params.actions,
|
|
@@ -2847,7 +2882,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2847
2882
|
if (!this._sql) {
|
|
2848
2883
|
const features = this.nodeFeatures;
|
|
2849
2884
|
if (features.length > 0 && !features.includes("sql")) {
|
|
2850
|
-
throw new
|
|
2885
|
+
throw new import_sdk_core7.UnsupportedFeatureError("sql", this.config.host, features);
|
|
2851
2886
|
}
|
|
2852
2887
|
throw new Error("Not signed in. Call signIn() first.");
|
|
2853
2888
|
}
|
|
@@ -2871,8 +2906,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2871
2906
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
2872
2907
|
throw new Error("Not signed in. Call signIn() first.");
|
|
2873
2908
|
}
|
|
2874
|
-
const sql = new
|
|
2875
|
-
const spaceScopedContext = new
|
|
2909
|
+
const sql = new import_sdk_core7.SQLService({});
|
|
2910
|
+
const spaceScopedContext = new import_sdk_core7.ServiceContext({
|
|
2876
2911
|
invoke: this._serviceContext.invoke,
|
|
2877
2912
|
fetch: this._serviceContext.fetch,
|
|
2878
2913
|
hosts: this._serviceContext.hosts,
|
|
@@ -2900,8 +2935,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2900
2935
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
2901
2936
|
throw new Error("Not signed in. Call signIn() first.");
|
|
2902
2937
|
}
|
|
2903
|
-
const kv = new
|
|
2904
|
-
const spaceScopedContext = new
|
|
2938
|
+
const kv = new import_sdk_core7.KVService({});
|
|
2939
|
+
const spaceScopedContext = new import_sdk_core7.ServiceContext({
|
|
2905
2940
|
invoke: this._serviceContext.invoke,
|
|
2906
2941
|
fetch: this._serviceContext.fetch,
|
|
2907
2942
|
hosts: this._serviceContext.hosts
|
|
@@ -2917,7 +2952,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2917
2952
|
if (!this._duckdb) {
|
|
2918
2953
|
const features = this.nodeFeatures;
|
|
2919
2954
|
if (features.length > 0 && !features.includes("duckdb")) {
|
|
2920
|
-
throw new
|
|
2955
|
+
throw new import_sdk_core7.UnsupportedFeatureError("duckdb", this.config.host, features);
|
|
2921
2956
|
}
|
|
2922
2957
|
throw new Error("Not signed in. Call signIn() first.");
|
|
2923
2958
|
}
|
|
@@ -2969,7 +3004,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2969
3004
|
type: NETWORK_ADMIN_TYPE,
|
|
2970
3005
|
targetNode,
|
|
2971
3006
|
networkId,
|
|
2972
|
-
bodyHash: (0,
|
|
3007
|
+
bodyHash: (0, import_sdk_core7.canonicalHashHex)(
|
|
2973
3008
|
crypto.sha256,
|
|
2974
3009
|
body
|
|
2975
3010
|
),
|
|
@@ -2987,7 +3022,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2987
3022
|
Authorization: signed.authorization,
|
|
2988
3023
|
"Content-Type": "application/json"
|
|
2989
3024
|
},
|
|
2990
|
-
body: (0,
|
|
3025
|
+
body: (0, import_sdk_core7.canonicalizeEncryptionJson)(
|
|
2991
3026
|
body
|
|
2992
3027
|
)
|
|
2993
3028
|
});
|
|
@@ -3005,7 +3040,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3005
3040
|
if (existing) {
|
|
3006
3041
|
return existing;
|
|
3007
3042
|
}
|
|
3008
|
-
const parsed = (0,
|
|
3043
|
+
const parsed = (0, import_sdk_core7.parseNetworkId)(networkId);
|
|
3009
3044
|
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
3010
3045
|
throw new Error(
|
|
3011
3046
|
`Cannot create encryption network ${networkId}: owner ${parsed.ownerDid} does not match signed-in DID ${this.did}`
|
|
@@ -3038,7 +3073,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3038
3073
|
throw new Error("Not signed in. Call signIn() first.");
|
|
3039
3074
|
}
|
|
3040
3075
|
if (!this._baseSecrets) {
|
|
3041
|
-
this._baseSecrets = new
|
|
3076
|
+
this._baseSecrets = new import_sdk_core7.SecretsService(() => this.space("secrets").vault);
|
|
3042
3077
|
}
|
|
3043
3078
|
return this._baseSecrets;
|
|
3044
3079
|
}
|
|
@@ -3153,10 +3188,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3153
3188
|
async useRuntimeDelegation(delegation) {
|
|
3154
3189
|
const session = this.currentTinyCloudSession();
|
|
3155
3190
|
if (!session) {
|
|
3156
|
-
throw new
|
|
3191
|
+
throw new import_sdk_core7.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
3157
3192
|
}
|
|
3158
3193
|
if (delegation.expiry.getTime() <= Date.now()) {
|
|
3159
|
-
throw new
|
|
3194
|
+
throw new import_sdk_core7.SessionExpiredError(delegation.expiry);
|
|
3160
3195
|
}
|
|
3161
3196
|
const expectedDids = [session.verificationMethod, this.sessionDid];
|
|
3162
3197
|
if (!expectedDids.some((did) => didPrincipalMatches2(delegation.delegateDID, did))) {
|
|
@@ -3165,7 +3200,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3165
3200
|
);
|
|
3166
3201
|
}
|
|
3167
3202
|
const targetHost = delegation.host ?? this.config.host;
|
|
3168
|
-
const activateResult = await (0,
|
|
3203
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
3169
3204
|
targetHost,
|
|
3170
3205
|
delegation.delegationHeader
|
|
3171
3206
|
);
|
|
@@ -3192,13 +3227,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3192
3227
|
}
|
|
3193
3228
|
const session = this.currentTinyCloudSession();
|
|
3194
3229
|
if (!session) {
|
|
3195
|
-
throw new
|
|
3230
|
+
throw new import_sdk_core7.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
3196
3231
|
}
|
|
3197
3232
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
3198
3233
|
if (sessionExpiry !== void 0) {
|
|
3199
3234
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
3200
3235
|
if (sessionExpiry.getTime() <= Date.now() + marginMs) {
|
|
3201
|
-
throw new
|
|
3236
|
+
throw new import_sdk_core7.SessionExpiredError(sessionExpiry);
|
|
3202
3237
|
}
|
|
3203
3238
|
}
|
|
3204
3239
|
const expanded = this.expandPermissionEntries(permissions);
|
|
@@ -3261,7 +3296,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3261
3296
|
...prepared,
|
|
3262
3297
|
signature
|
|
3263
3298
|
});
|
|
3264
|
-
const activateResult = await (0,
|
|
3299
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
3265
3300
|
this.config.host,
|
|
3266
3301
|
delegatedSession.delegationHeader
|
|
3267
3302
|
);
|
|
@@ -3434,7 +3469,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3434
3469
|
];
|
|
3435
3470
|
const abilities = { kv: { "": kvActions } };
|
|
3436
3471
|
const now = /* @__PURE__ */ new Date();
|
|
3437
|
-
const expiryMs =
|
|
3472
|
+
const expiryMs = import_sdk_core7.EXPIRY.EPHEMERAL_MS;
|
|
3438
3473
|
const expirationTime = new Date(now.getTime() + expiryMs);
|
|
3439
3474
|
const prepared = this.wasmBindings.prepareSession({
|
|
3440
3475
|
abilities,
|
|
@@ -3452,7 +3487,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3452
3487
|
...prepared,
|
|
3453
3488
|
signature
|
|
3454
3489
|
});
|
|
3455
|
-
const activateResult = await (0,
|
|
3490
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
3456
3491
|
this.config.host,
|
|
3457
3492
|
delegationSession.delegationHeader
|
|
3458
3493
|
);
|
|
@@ -3479,8 +3514,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3479
3514
|
}]);
|
|
3480
3515
|
}
|
|
3481
3516
|
if (this._serviceContext) {
|
|
3482
|
-
const publicKV = new
|
|
3483
|
-
const publicContext = new
|
|
3517
|
+
const publicKV = new import_sdk_core7.KVService({ prefix: "" });
|
|
3518
|
+
const publicContext = new import_sdk_core7.ServiceContext({
|
|
3484
3519
|
invoke: this.invokeWithRuntimePermissions,
|
|
3485
3520
|
fetch: this._serviceContext.fetch,
|
|
3486
3521
|
hosts: this._serviceContext.hosts,
|
|
@@ -3607,14 +3642,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3607
3642
|
async delegateTo(did, permissions, options) {
|
|
3608
3643
|
const session = this.currentTinyCloudSession();
|
|
3609
3644
|
if (!session) {
|
|
3610
|
-
throw new
|
|
3645
|
+
throw new import_sdk_core7.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
3611
3646
|
}
|
|
3612
3647
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
3613
3648
|
if (sessionExpiry !== void 0) {
|
|
3614
3649
|
const now2 = Date.now();
|
|
3615
3650
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
3616
3651
|
if (sessionExpiry.getTime() <= now2 + marginMs) {
|
|
3617
|
-
throw new
|
|
3652
|
+
throw new import_sdk_core7.SessionExpiredError(sessionExpiry);
|
|
3618
3653
|
}
|
|
3619
3654
|
}
|
|
3620
3655
|
if (!Array.isArray(permissions) || permissions.length === 0) {
|
|
@@ -3643,11 +3678,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3643
3678
|
);
|
|
3644
3679
|
return { delegation: delegation2, prompted: true };
|
|
3645
3680
|
}
|
|
3646
|
-
const granted = (0,
|
|
3681
|
+
const granted = (0, import_sdk_core7.parseRecapCapabilities)(
|
|
3647
3682
|
(siwe) => this.wasmBindings.parseRecapFromSiwe(siwe),
|
|
3648
3683
|
session.siwe
|
|
3649
3684
|
);
|
|
3650
|
-
const { subset, missing } = (0,
|
|
3685
|
+
const { subset, missing } = (0, import_sdk_core7.isCapabilitySubset)(expandedEntries, granted);
|
|
3651
3686
|
if (!subset) {
|
|
3652
3687
|
const runtimeGrant = this.findGrantForOperations(
|
|
3653
3688
|
this.permissionEntriesToOperations(expandedEntries, session)
|
|
@@ -3655,7 +3690,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3655
3690
|
if (runtimeGrant) {
|
|
3656
3691
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
3657
3692
|
if (runtimeGrant.expiresAt.getTime() <= Date.now() + marginMs) {
|
|
3658
|
-
throw new
|
|
3693
|
+
throw new import_sdk_core7.SessionExpiredError(runtimeGrant.expiresAt);
|
|
3659
3694
|
}
|
|
3660
3695
|
const runtimeExpiration = runtimeGrant.expiresAt < effectiveExpiration ? runtimeGrant.expiresAt : effectiveExpiration;
|
|
3661
3696
|
const delegation2 = await this.createDelegationViaRuntimeGrant(
|
|
@@ -3666,7 +3701,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3666
3701
|
);
|
|
3667
3702
|
return { delegation: delegation2, prompted: false };
|
|
3668
3703
|
}
|
|
3669
|
-
throw new
|
|
3704
|
+
throw new import_sdk_core7.PermissionNotInManifestError(missing, granted);
|
|
3670
3705
|
}
|
|
3671
3706
|
const delegation = await this.createDelegationViaWasmPath(
|
|
3672
3707
|
did,
|
|
@@ -3748,7 +3783,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3748
3783
|
const spaceId = resolvedSpaces.size === 1 ? [...resolvedSpaces][0] : session.spaceId;
|
|
3749
3784
|
const abilities = {};
|
|
3750
3785
|
for (const entry of entries) {
|
|
3751
|
-
const shortService =
|
|
3786
|
+
const shortService = import_sdk_core7.SERVICE_LONG_TO_SHORT[entry.service];
|
|
3752
3787
|
if (shortService === void 0) {
|
|
3753
3788
|
throw new Error(
|
|
3754
3789
|
`delegateTo: unknown service '${entry.service}' \u2014 no short-form mapping`
|
|
@@ -3788,7 +3823,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3788
3823
|
});
|
|
3789
3824
|
const primary = result.resources[0];
|
|
3790
3825
|
const delegationHeader = { Authorization: result.delegation };
|
|
3791
|
-
const activateResult = await (0,
|
|
3826
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
3792
3827
|
this.config.host,
|
|
3793
3828
|
delegationHeader
|
|
3794
3829
|
);
|
|
@@ -3823,7 +3858,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3823
3858
|
const primary = result.resources[0];
|
|
3824
3859
|
const delegationHeader = { Authorization: result.delegation };
|
|
3825
3860
|
const targetHost = grant.delegation.host ?? this.config.host;
|
|
3826
|
-
const activateResult = await (0,
|
|
3861
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
3827
3862
|
targetHost,
|
|
3828
3863
|
delegationHeader
|
|
3829
3864
|
);
|
|
@@ -3864,10 +3899,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3864
3899
|
return this.wasmBindings.makeSpaceId(session.address, session.chainId, space);
|
|
3865
3900
|
}
|
|
3866
3901
|
expandPermissionEntries(permissions) {
|
|
3867
|
-
return (0,
|
|
3902
|
+
return (0, import_sdk_core7.expandPermissionEntries)(permissions);
|
|
3868
3903
|
}
|
|
3869
3904
|
shortServiceName(service) {
|
|
3870
|
-
const short =
|
|
3905
|
+
const short = import_sdk_core7.SERVICE_LONG_TO_SHORT[service];
|
|
3871
3906
|
if (short === void 0) {
|
|
3872
3907
|
throw new Error(
|
|
3873
3908
|
`unknown service '${service}' \u2014 no short-form mapping`
|
|
@@ -3893,7 +3928,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3893
3928
|
return abilities;
|
|
3894
3929
|
}
|
|
3895
3930
|
isEncryptionPermissionEntry(entry) {
|
|
3896
|
-
return entry.service ===
|
|
3931
|
+
return entry.service === import_sdk_core7.ENCRYPTION_PERMISSION_SERVICE && entry.path.startsWith("urn:tinycloud:encryption:");
|
|
3897
3932
|
}
|
|
3898
3933
|
permissionsToRawAbilities(entries) {
|
|
3899
3934
|
const rawAbilities = {};
|
|
@@ -3926,11 +3961,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3926
3961
|
}
|
|
3927
3962
|
sessionCoversPermissionEntries(session, entries) {
|
|
3928
3963
|
try {
|
|
3929
|
-
const granted = (0,
|
|
3964
|
+
const granted = (0, import_sdk_core7.parseRecapCapabilities)(
|
|
3930
3965
|
(siwe) => this.wasmBindings.parseRecapFromSiwe(siwe),
|
|
3931
3966
|
session.siwe
|
|
3932
3967
|
);
|
|
3933
|
-
return (0,
|
|
3968
|
+
return (0, import_sdk_core7.isCapabilitySubset)(entries, granted).subset;
|
|
3934
3969
|
} catch {
|
|
3935
3970
|
return false;
|
|
3936
3971
|
}
|
|
@@ -4261,7 +4296,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4261
4296
|
if (resolvedDelegateDID.endsWith(".eth") && this.config.ensResolver) {
|
|
4262
4297
|
const address = await this.config.ensResolver.resolveAddress(resolvedDelegateDID);
|
|
4263
4298
|
if (!address) throw new Error(`Could not resolve ENS name: ${resolvedDelegateDID}`);
|
|
4264
|
-
resolvedDelegateDID = (0,
|
|
4299
|
+
resolvedDelegateDID = (0, import_sdk_core7.pkhDid)(address, 1);
|
|
4265
4300
|
}
|
|
4266
4301
|
const entries = legacyParamsToPermissionEntries(
|
|
4267
4302
|
params.actions,
|
|
@@ -4276,7 +4311,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4276
4311
|
);
|
|
4277
4312
|
return result.delegation;
|
|
4278
4313
|
} catch (err) {
|
|
4279
|
-
if (err instanceof
|
|
4314
|
+
if (err instanceof import_sdk_core7.PermissionNotInManifestError) {
|
|
4280
4315
|
} else {
|
|
4281
4316
|
throw err;
|
|
4282
4317
|
}
|
|
@@ -4333,7 +4368,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4333
4368
|
...prepared,
|
|
4334
4369
|
signature
|
|
4335
4370
|
});
|
|
4336
|
-
const activateResult = await (0,
|
|
4371
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
4337
4372
|
this.config.host,
|
|
4338
4373
|
delegationSession.delegationHeader
|
|
4339
4374
|
);
|
|
@@ -4355,7 +4390,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4355
4390
|
};
|
|
4356
4391
|
const hasKvActions = params.actions.some((a) => a.startsWith("tinycloud.kv/"));
|
|
4357
4392
|
if (hasKvActions && params.includePublicSpace !== false) {
|
|
4358
|
-
const publicSpaceId = (0,
|
|
4393
|
+
const publicSpaceId = (0, import_sdk_core7.makePublicSpaceId)(
|
|
4359
4394
|
this.wasmBindings.ensureEip55(session.address),
|
|
4360
4395
|
session.chainId
|
|
4361
4396
|
);
|
|
@@ -4378,7 +4413,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4378
4413
|
...publicPrepared,
|
|
4379
4414
|
signature: publicSignature
|
|
4380
4415
|
});
|
|
4381
|
-
const publicActivateResult = await (0,
|
|
4416
|
+
const publicActivateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
4382
4417
|
this.config.host,
|
|
4383
4418
|
publicSession.delegationHeader
|
|
4384
4419
|
);
|
|
@@ -4483,7 +4518,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4483
4518
|
...prepared,
|
|
4484
4519
|
signature
|
|
4485
4520
|
});
|
|
4486
|
-
const activateResult = await (0,
|
|
4521
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
4487
4522
|
targetHost,
|
|
4488
4523
|
invokerSession.delegationHeader
|
|
4489
4524
|
);
|
|
@@ -4589,7 +4624,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4589
4624
|
...prepared,
|
|
4590
4625
|
signature
|
|
4591
4626
|
});
|
|
4592
|
-
const activateResult = await (0,
|
|
4627
|
+
const activateResult = await (0, import_sdk_core7.activateSessionWithHost)(
|
|
4593
4628
|
targetHost,
|
|
4594
4629
|
subDelegationSession.delegationHeader
|
|
4595
4630
|
);
|
|
@@ -4625,7 +4660,7 @@ _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS = 6e4;
|
|
|
4625
4660
|
var TinyCloudNode = _TinyCloudNode;
|
|
4626
4661
|
|
|
4627
4662
|
// src/core.ts
|
|
4628
|
-
var
|
|
4663
|
+
var import_sdk_core10 = require("@tinycloud/sdk-core");
|
|
4629
4664
|
|
|
4630
4665
|
// src/delegation.ts
|
|
4631
4666
|
function serializeDelegation(delegation) {
|
|
@@ -4644,7 +4679,6 @@ function deserializeDelegation(data) {
|
|
|
4644
4679
|
}
|
|
4645
4680
|
|
|
4646
4681
|
// src/core.ts
|
|
4647
|
-
var import_sdk_core10 = require("@tinycloud/sdk-core");
|
|
4648
4682
|
var import_sdk_core11 = require("@tinycloud/sdk-core");
|
|
4649
4683
|
var import_sdk_core12 = require("@tinycloud/sdk-core");
|
|
4650
4684
|
var import_sdk_core13 = require("@tinycloud/sdk-core");
|
|
@@ -4653,10 +4687,12 @@ var import_sdk_core15 = require("@tinycloud/sdk-core");
|
|
|
4653
4687
|
var import_sdk_core16 = require("@tinycloud/sdk-core");
|
|
4654
4688
|
var import_sdk_core17 = require("@tinycloud/sdk-core");
|
|
4655
4689
|
var import_sdk_core18 = require("@tinycloud/sdk-core");
|
|
4690
|
+
var import_sdk_core19 = require("@tinycloud/sdk-core");
|
|
4656
4691
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4657
4692
|
0 && (module.exports = {
|
|
4658
4693
|
ACCOUNT_REGISTRY_PATH,
|
|
4659
4694
|
ACCOUNT_REGISTRY_SPACE,
|
|
4695
|
+
AccountService,
|
|
4660
4696
|
AutoApproveSpaceCreationHandler,
|
|
4661
4697
|
CapabilityKeyRegistry,
|
|
4662
4698
|
CapabilityKeyRegistryErrorCodes,
|