@tinycloud/node-sdk 3.12.0-beta.4 → 3.12.0-beta.5
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/{NodeUserAuthorization-B_TFUlua.d.cts → NodeUserAuthorization-D41H1_c0.d.cts} +1 -0
- package/dist/{NodeUserAuthorization-B_TFUlua.d.ts → NodeUserAuthorization-D41H1_c0.d.ts} +1 -0
- package/dist/{TinyCloudNode-Brcu8QoX.d.cts → TinyCloudNode-B0pKoTaw.d.cts} +2 -2
- package/dist/{TinyCloudNode-DBJUnsMN.d.ts → TinyCloudNode-DvzCZgJX.d.ts} +2 -2
- package/dist/{authority-DQ6R1HEG.d.cts → authority-Bu8hivr-.d.cts} +1 -1
- package/dist/{authority-BFc5lesl.d.ts → authority-D9JwzD7C.d.ts} +1 -1
- package/dist/core.cjs +347 -346
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +3 -3
- package/dist/core.d.ts +3 -3
- package/dist/core.js +6 -4
- package/dist/core.js.map +1 -1
- package/dist/encryption-keys.d.cts +2 -2
- package/dist/encryption-keys.d.ts +2 -2
- package/dist/index.cjs +147 -144
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/replication/authority.d.cts +3 -3
- package/dist/replication/authority.d.ts +3 -3
- package/dist/space-hosting.d.cts +1 -1
- package/dist/space-hosting.d.ts +1 -1
- package/package.json +2 -2
package/dist/core.cjs
CHANGED
|
@@ -30,117 +30,117 @@ 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
|
-
AccountService: () =>
|
|
36
|
-
AutoApproveSpaceCreationHandler: () =>
|
|
37
|
-
CapabilityKeyRegistry: () =>
|
|
38
|
-
CapabilityKeyRegistryErrorCodes: () =>
|
|
39
|
-
CaveatedDelegationUnsupportedError: () =>
|
|
40
|
-
DEFAULT_MANIFEST_SPACE: () =>
|
|
41
|
-
DEFAULT_MANIFEST_VERSION: () =>
|
|
42
|
-
DEFAULT_SIGNED_READ_URL_EXPIRY_MS: () =>
|
|
43
|
-
DataVaultService: () =>
|
|
44
|
-
DatabaseHandle: () =>
|
|
33
|
+
ACCOUNT_REGISTRY_PATH: () => import_sdk_core15.ACCOUNT_REGISTRY_PATH,
|
|
34
|
+
ACCOUNT_REGISTRY_SPACE: () => import_sdk_core15.ACCOUNT_REGISTRY_SPACE,
|
|
35
|
+
AccountService: () => import_sdk_core8.AccountService,
|
|
36
|
+
AutoApproveSpaceCreationHandler: () => import_sdk_core14.AutoApproveSpaceCreationHandler,
|
|
37
|
+
CapabilityKeyRegistry: () => import_sdk_core21.CapabilityKeyRegistry,
|
|
38
|
+
CapabilityKeyRegistryErrorCodes: () => import_sdk_core21.CapabilityKeyRegistryErrorCodes,
|
|
39
|
+
CaveatedDelegationUnsupportedError: () => import_sdk_core15.CaveatedDelegationUnsupportedError,
|
|
40
|
+
DEFAULT_MANIFEST_SPACE: () => import_sdk_core15.DEFAULT_MANIFEST_SPACE,
|
|
41
|
+
DEFAULT_MANIFEST_VERSION: () => import_sdk_core15.DEFAULT_MANIFEST_VERSION,
|
|
42
|
+
DEFAULT_SIGNED_READ_URL_EXPIRY_MS: () => import_sdk_core16.DEFAULT_SIGNED_READ_URL_EXPIRY_MS,
|
|
43
|
+
DataVaultService: () => import_sdk_core19.DataVaultService,
|
|
44
|
+
DatabaseHandle: () => import_sdk_core17.DatabaseHandle,
|
|
45
45
|
DelegatedAccess: () => DelegatedAccess,
|
|
46
|
-
DelegationErrorCodes: () =>
|
|
47
|
-
DelegationManager: () =>
|
|
48
|
-
DuckDbAction: () =>
|
|
49
|
-
DuckDbDatabaseHandle: () =>
|
|
50
|
-
DuckDbService: () =>
|
|
46
|
+
DelegationErrorCodes: () => import_sdk_core20.DelegationErrorCodes,
|
|
47
|
+
DelegationManager: () => import_sdk_core20.DelegationManager,
|
|
48
|
+
DuckDbAction: () => import_sdk_core18.DuckDbAction,
|
|
49
|
+
DuckDbDatabaseHandle: () => import_sdk_core18.DuckDbDatabaseHandle,
|
|
50
|
+
DuckDbService: () => import_sdk_core18.DuckDbService,
|
|
51
51
|
FileSessionStorage: () => FileSessionStorage,
|
|
52
|
-
IdentityParseError: () =>
|
|
52
|
+
IdentityParseError: () => import_sdk_core14.IdentityParseError,
|
|
53
53
|
InvalidRestoredSessionError: () => InvalidRestoredSessionError,
|
|
54
|
-
KVService: () =>
|
|
55
|
-
ManifestValidationError: () =>
|
|
54
|
+
KVService: () => import_sdk_core16.KVService,
|
|
55
|
+
ManifestValidationError: () => import_sdk_core15.ManifestValidationError,
|
|
56
56
|
MemorySessionStorage: () => MemorySessionStorage,
|
|
57
57
|
NodeIdentityMismatchError: () => import_sdk_services7.NodeIdentityMismatchError,
|
|
58
58
|
NodeNotRespondingError: () => import_sdk_services7.NodeNotRespondingError,
|
|
59
59
|
NodeUserAuthorization: () => NodeUserAuthorization,
|
|
60
60
|
PartialNodeWriteError: () => import_sdk_services7.PartialNodeWriteError,
|
|
61
|
-
PermissionNotInManifestError: () =>
|
|
62
|
-
PrefixedKVService: () =>
|
|
63
|
-
ProtocolMismatchError: () =>
|
|
61
|
+
PermissionNotInManifestError: () => import_sdk_core15.PermissionNotInManifestError,
|
|
62
|
+
PrefixedKVService: () => import_sdk_core16.PrefixedKVService,
|
|
63
|
+
ProtocolMismatchError: () => import_sdk_core23.ProtocolMismatchError,
|
|
64
64
|
RuntimeDelegationRejectedError: () => RuntimeDelegationRejectedError,
|
|
65
|
-
SECRET_NAME_RE: () =>
|
|
66
|
-
SQLAction: () =>
|
|
67
|
-
SQLService: () =>
|
|
68
|
-
SecretsService: () =>
|
|
69
|
-
ServiceContext: () =>
|
|
70
|
-
SessionExpiredError: () =>
|
|
71
|
-
SharingService: () =>
|
|
72
|
-
SilentNotificationHandler: () =>
|
|
73
|
-
Space: () =>
|
|
74
|
-
SpaceErrorCodes: () =>
|
|
75
|
-
SpaceService: () =>
|
|
76
|
-
TinyCloud: () =>
|
|
77
|
-
TinyCloudDebugLogger: () =>
|
|
65
|
+
SECRET_NAME_RE: () => import_sdk_core19.SECRET_NAME_RE,
|
|
66
|
+
SQLAction: () => import_sdk_core17.SQLAction,
|
|
67
|
+
SQLService: () => import_sdk_core17.SQLService,
|
|
68
|
+
SecretsService: () => import_sdk_core19.SecretsService,
|
|
69
|
+
ServiceContext: () => import_sdk_core24.ServiceContext,
|
|
70
|
+
SessionExpiredError: () => import_sdk_core15.SessionExpiredError,
|
|
71
|
+
SharingService: () => import_sdk_core20.SharingService,
|
|
72
|
+
SilentNotificationHandler: () => import_sdk_core14.SilentNotificationHandler,
|
|
73
|
+
Space: () => import_sdk_core22.Space,
|
|
74
|
+
SpaceErrorCodes: () => import_sdk_core22.SpaceErrorCodes,
|
|
75
|
+
SpaceService: () => import_sdk_core22.SpaceService,
|
|
76
|
+
TinyCloud: () => import_sdk_core13.TinyCloud,
|
|
77
|
+
TinyCloudDebugLogger: () => import_sdk_core14.TinyCloudDebugLogger,
|
|
78
78
|
TinyCloudNode: () => TinyCloudNode,
|
|
79
|
-
UnsupportedFeatureError: () =>
|
|
79
|
+
UnsupportedFeatureError: () => import_sdk_core23.UnsupportedFeatureError,
|
|
80
80
|
UnsupportedSessionRestoreError: () => UnsupportedSessionRestoreError,
|
|
81
|
-
VAULT_PERMISSION_SERVICE: () =>
|
|
82
|
-
VaultHeaders: () =>
|
|
83
|
-
VaultPublicSpaceKVActions: () =>
|
|
84
|
-
VersionCheckError: () =>
|
|
81
|
+
VAULT_PERMISSION_SERVICE: () => import_sdk_core15.VAULT_PERMISSION_SERVICE,
|
|
82
|
+
VaultHeaders: () => import_sdk_core19.VaultHeaders,
|
|
83
|
+
VaultPublicSpaceKVActions: () => import_sdk_core19.VaultPublicSpaceKVActions,
|
|
84
|
+
VersionCheckError: () => import_sdk_core23.VersionCheckError,
|
|
85
85
|
WasmKeyProvider: () => WasmKeyProvider,
|
|
86
86
|
activateCompactRuntimeDelegation: () => activateCompactRuntimeDelegation,
|
|
87
87
|
activateValidatedRuntimeDelegation: () => activateValidatedRuntimeDelegation,
|
|
88
|
-
addressStorageKey: () =>
|
|
89
|
-
buildSpaceUri: () =>
|
|
90
|
-
canonicalizeAddress: () =>
|
|
91
|
-
canonicalizeDid: () =>
|
|
92
|
-
canonicalizeDidUrl: () =>
|
|
93
|
-
canonicalizeNetworkId: () =>
|
|
94
|
-
canonicalizeSecretScope: () =>
|
|
95
|
-
checkNodeInfo: () =>
|
|
96
|
-
clearTinyCloudDebugLogs: () =>
|
|
97
|
-
composeManifestRequest: () =>
|
|
98
|
-
createCapabilityKeyRegistry: () =>
|
|
88
|
+
addressStorageKey: () => import_sdk_core14.addressStorageKey,
|
|
89
|
+
buildSpaceUri: () => import_sdk_core22.buildSpaceUri,
|
|
90
|
+
canonicalizeAddress: () => import_sdk_core14.canonicalizeAddress,
|
|
91
|
+
canonicalizeDid: () => import_sdk_core14.canonicalizeDid,
|
|
92
|
+
canonicalizeDidUrl: () => import_sdk_core14.canonicalizeDidUrl,
|
|
93
|
+
canonicalizeNetworkId: () => import_sdk_core14.canonicalizeNetworkId,
|
|
94
|
+
canonicalizeSecretScope: () => import_sdk_core19.canonicalizeSecretScope,
|
|
95
|
+
checkNodeInfo: () => import_sdk_core23.checkNodeInfo,
|
|
96
|
+
clearTinyCloudDebugLogs: () => import_sdk_core14.clearTinyCloudDebugLogs,
|
|
97
|
+
composeManifestRequest: () => import_sdk_core15.composeManifestRequest,
|
|
98
|
+
createCapabilityKeyRegistry: () => import_sdk_core21.createCapabilityKeyRegistry,
|
|
99
99
|
createOpenKeyCallbackSigningStrategy: () => import_sdk_core4.createOpenKeyCallbackSigningStrategy,
|
|
100
|
-
createSharingService: () =>
|
|
101
|
-
createSpaceService: () =>
|
|
102
|
-
createVaultCrypto: () =>
|
|
100
|
+
createSharingService: () => import_sdk_core20.createSharingService,
|
|
101
|
+
createSpaceService: () => import_sdk_core22.createSpaceService,
|
|
102
|
+
createVaultCrypto: () => import_sdk_core19.createVaultCrypto,
|
|
103
103
|
createWasmKeyProvider: () => createWasmKeyProvider,
|
|
104
104
|
defaultSignStrategy: () => defaultSignStrategy,
|
|
105
|
-
defaultSpaceCreationHandler: () =>
|
|
105
|
+
defaultSpaceCreationHandler: () => import_sdk_core14.defaultSpaceCreationHandler,
|
|
106
106
|
deserializeDelegation: () => deserializeDelegation,
|
|
107
|
-
didCacheKey: () =>
|
|
108
|
-
didEquals: () =>
|
|
109
|
-
disableTinyCloudDebug: () =>
|
|
110
|
-
enableTinyCloudDebug: () =>
|
|
111
|
-
expandActionShortNames: () =>
|
|
112
|
-
expandPermissionEntries: () =>
|
|
113
|
-
expandPermissionEntry: () =>
|
|
107
|
+
didCacheKey: () => import_sdk_core14.didCacheKey,
|
|
108
|
+
didEquals: () => import_sdk_core14.didEquals,
|
|
109
|
+
disableTinyCloudDebug: () => import_sdk_core14.disableTinyCloudDebug,
|
|
110
|
+
enableTinyCloudDebug: () => import_sdk_core14.enableTinyCloudDebug,
|
|
111
|
+
expandActionShortNames: () => import_sdk_core15.expandActionShortNames,
|
|
112
|
+
expandPermissionEntries: () => import_sdk_core15.expandPermissionEntries,
|
|
113
|
+
expandPermissionEntry: () => import_sdk_core15.expandPermissionEntry,
|
|
114
114
|
getNodeReplicationLoaders: () => getNodeReplicationLoaders,
|
|
115
|
-
getTinyCloudDebugLogs: () =>
|
|
116
|
-
installTinyCloudDebugGlobals: () =>
|
|
115
|
+
getTinyCloudDebugLogs: () => import_sdk_core14.getTinyCloudDebugLogs,
|
|
116
|
+
installTinyCloudDebugGlobals: () => import_sdk_core14.installTinyCloudDebugGlobals,
|
|
117
117
|
isAppKeyHostBound: () => isAppKeyHostBound,
|
|
118
|
-
isCapabilitySubset: () =>
|
|
119
|
-
isEvmAddress: () =>
|
|
120
|
-
loadManifest: () =>
|
|
121
|
-
makePkhSpaceId: () =>
|
|
122
|
-
makePublicSpaceId: () =>
|
|
123
|
-
parseCanonicalNetworkId: () =>
|
|
124
|
-
parseExpiry: () =>
|
|
125
|
-
parsePkhDid: () =>
|
|
126
|
-
parseSecretCatalogKey: () =>
|
|
127
|
-
parseSpaceUri: () =>
|
|
128
|
-
pkhDid: () =>
|
|
129
|
-
principalDid: () =>
|
|
130
|
-
principalDidEquals: () =>
|
|
118
|
+
isCapabilitySubset: () => import_sdk_core15.isCapabilitySubset,
|
|
119
|
+
isEvmAddress: () => import_sdk_core14.isEvmAddress,
|
|
120
|
+
loadManifest: () => import_sdk_core15.loadManifest,
|
|
121
|
+
makePkhSpaceId: () => import_sdk_core14.makePkhSpaceId,
|
|
122
|
+
makePublicSpaceId: () => import_sdk_core22.makePublicSpaceId,
|
|
123
|
+
parseCanonicalNetworkId: () => import_sdk_core14.parseCanonicalNetworkId,
|
|
124
|
+
parseExpiry: () => import_sdk_core15.parseExpiry,
|
|
125
|
+
parsePkhDid: () => import_sdk_core14.parsePkhDid,
|
|
126
|
+
parseSecretCatalogKey: () => import_sdk_core19.parseSecretCatalogKey,
|
|
127
|
+
parseSpaceUri: () => import_sdk_core22.parseSpaceUri,
|
|
128
|
+
pkhDid: () => import_sdk_core14.pkhDid,
|
|
129
|
+
principalDid: () => import_sdk_core14.principalDid,
|
|
130
|
+
principalDidEquals: () => import_sdk_core14.principalDidEquals,
|
|
131
131
|
refuseCaveated: () => refuseCaveated,
|
|
132
132
|
registerReplicationLoaders: () => registerReplicationLoaders,
|
|
133
|
-
resolveManifest: () =>
|
|
134
|
-
resolveSecretListPrefix: () =>
|
|
135
|
-
resolveSecretPath: () =>
|
|
136
|
-
resourceCapabilitiesToSpaceAbilitiesMap: () =>
|
|
133
|
+
resolveManifest: () => import_sdk_core15.resolveManifest,
|
|
134
|
+
resolveSecretListPrefix: () => import_sdk_core19.resolveSecretListPrefix,
|
|
135
|
+
resolveSecretPath: () => import_sdk_core19.resolveSecretPath,
|
|
136
|
+
resourceCapabilitiesToSpaceAbilitiesMap: () => import_sdk_core15.resourceCapabilitiesToSpaceAbilitiesMap,
|
|
137
137
|
serializeDelegation: () => serializeDelegation,
|
|
138
|
-
tinyCloudDebugLogger: () =>
|
|
139
|
-
validateManifest: () =>
|
|
138
|
+
tinyCloudDebugLogger: () => import_sdk_core14.tinyCloudDebugLogger,
|
|
139
|
+
validateManifest: () => import_sdk_core15.validateManifest,
|
|
140
140
|
wireOpenKeyAuthorize: () => wireOpenKeyAuthorize
|
|
141
141
|
});
|
|
142
142
|
module.exports = __toCommonJS(core_exports);
|
|
143
|
-
var
|
|
143
|
+
var import_sdk_core13 = require("@tinycloud/sdk-core");
|
|
144
144
|
var import_sdk_services7 = require("@tinycloud/sdk-services");
|
|
145
145
|
|
|
146
146
|
// src/replication/module-registry.ts
|
|
@@ -156,7 +156,7 @@ function getNodeReplicationLoaders() {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
// src/core.ts
|
|
159
|
-
var
|
|
159
|
+
var import_sdk_core14 = require("@tinycloud/sdk-core");
|
|
160
160
|
|
|
161
161
|
// src/storage/MemorySessionStorage.ts
|
|
162
162
|
var MemorySessionStorage = class {
|
|
@@ -1893,7 +1893,7 @@ var NodeUserAuthorization = class {
|
|
|
1893
1893
|
const originalRequest = {
|
|
1894
1894
|
protocolVersion: 1,
|
|
1895
1895
|
siwe: prepared.siwe,
|
|
1896
|
-
jwk,
|
|
1896
|
+
jwk: (0, import_sdk_core5.publicJwk)(jwk),
|
|
1897
1897
|
verificationMethod: prepared.verificationMethod,
|
|
1898
1898
|
host: hostHint,
|
|
1899
1899
|
keyId: options?.openkeyKeyId,
|
|
@@ -2389,13 +2389,14 @@ var NodeUserAuthorization = class {
|
|
|
2389
2389
|
};
|
|
2390
2390
|
|
|
2391
2391
|
// src/authorization/openKeyBridge.ts
|
|
2392
|
+
var import_sdk_core6 = require("@tinycloud/sdk-core");
|
|
2392
2393
|
function wireOpenKeyAuthorize(openkey, opts) {
|
|
2393
2394
|
return async (input) => {
|
|
2394
2395
|
const result = await openkey.authorizeTinyCloud({
|
|
2395
2396
|
protocolVersion: 1,
|
|
2396
2397
|
siwe: input.siwe,
|
|
2397
2398
|
keyId: input.keyId,
|
|
2398
|
-
jwk: input.jwk,
|
|
2399
|
+
jwk: (0, import_sdk_core6.publicJwk)(input.jwk),
|
|
2399
2400
|
host: input.host,
|
|
2400
2401
|
// Forward the presentation envelope verbatim — the OpenKey SDK
|
|
2401
2402
|
// validates and size-bounds it before use.
|
|
@@ -2596,7 +2597,7 @@ function rememberInvokeAny(invokeAny, sink, pending) {
|
|
|
2596
2597
|
}
|
|
2597
2598
|
|
|
2598
2599
|
// src/delegation.ts
|
|
2599
|
-
var
|
|
2600
|
+
var import_sdk_core7 = require("@tinycloud/sdk-core");
|
|
2600
2601
|
var import_sdk_services4 = require("@tinycloud/sdk-services");
|
|
2601
2602
|
var RuntimeDelegationRejectedError = class extends Error {
|
|
2602
2603
|
constructor(reason, message) {
|
|
@@ -2638,7 +2639,7 @@ function normalizedHost(host) {
|
|
|
2638
2639
|
}
|
|
2639
2640
|
function didPrincipalsMatch(left, right) {
|
|
2640
2641
|
try {
|
|
2641
|
-
return (0,
|
|
2642
|
+
return (0, import_sdk_core7.principalDidEquals)(left, right);
|
|
2642
2643
|
} catch {
|
|
2643
2644
|
return left === right;
|
|
2644
2645
|
}
|
|
@@ -2653,7 +2654,7 @@ function compactUcanPayload(authorization) {
|
|
|
2653
2654
|
}
|
|
2654
2655
|
try {
|
|
2655
2656
|
const payload = JSON.parse(
|
|
2656
|
-
new TextDecoder("utf-8", { fatal: true }).decode((0,
|
|
2657
|
+
new TextDecoder("utf-8", { fatal: true }).decode((0, import_sdk_core7.decodeBase64Url)(parts[1]))
|
|
2657
2658
|
);
|
|
2658
2659
|
if (payload === null || typeof payload !== "object" || Array.isArray(payload)) {
|
|
2659
2660
|
throw new Error("payload is not an object");
|
|
@@ -2681,7 +2682,7 @@ function canonicalPermissionEntries(permissions) {
|
|
|
2681
2682
|
...permission,
|
|
2682
2683
|
actions: [...permission.actions].sort()
|
|
2683
2684
|
})).sort(
|
|
2684
|
-
(left, right) => left.service.localeCompare(right.service) || (left.space ?? "").localeCompare(right.space ?? "") || left.path.localeCompare(right.path) || left.actions.join("\0").localeCompare(right.actions.join("\0")) || (0,
|
|
2685
|
+
(left, right) => left.service.localeCompare(right.service) || (left.space ?? "").localeCompare(right.space ?? "") || left.path.localeCompare(right.path) || left.actions.join("\0").localeCompare(right.actions.join("\0")) || (0, import_sdk_core7.canonicalizeRecapCaveats)(left.caveats).localeCompare((0, import_sdk_core7.canonicalizeRecapCaveats)(right.caveats))
|
|
2685
2686
|
);
|
|
2686
2687
|
}
|
|
2687
2688
|
function signedCaveats(value) {
|
|
@@ -2691,13 +2692,13 @@ function signedCaveats(value) {
|
|
|
2691
2692
|
throw new Error("Validated runtime delegation has malformed signed ReCap caveats.");
|
|
2692
2693
|
}
|
|
2693
2694
|
const cloned = JSON.parse(JSON.stringify(value));
|
|
2694
|
-
return (0,
|
|
2695
|
+
return (0, import_sdk_core7.canonicalizeRecapCaveats)(cloned) === (0, import_sdk_core7.canonicalizeRecapCaveats)(void 0) ? void 0 : cloned;
|
|
2695
2696
|
}
|
|
2696
2697
|
function groupedSignedEntries(service, space, path, abilities) {
|
|
2697
2698
|
const groups = /* @__PURE__ */ new Map();
|
|
2698
2699
|
for (const [action, rawCaveats] of Object.entries(abilities)) {
|
|
2699
2700
|
const caveats = signedCaveats(rawCaveats);
|
|
2700
|
-
const identity = (0,
|
|
2701
|
+
const identity = (0, import_sdk_core7.canonicalizeRecapCaveats)(caveats);
|
|
2701
2702
|
const group = groups.get(identity) ?? { actions: [], caveats };
|
|
2702
2703
|
group.actions.push(action);
|
|
2703
2704
|
groups.set(identity, group);
|
|
@@ -2849,7 +2850,7 @@ function signedAuthorityFromSessionGrant(node, delegation, authorization, cid) {
|
|
|
2849
2850
|
reject("authority_invalid", "Runtime delegation has signed authority outside its space.");
|
|
2850
2851
|
}
|
|
2851
2852
|
const caveats = signedCaveats(entry.caveats ?? []);
|
|
2852
|
-
const key = JSON.stringify([service, raw ? "" : entry.space, entry.path, (0,
|
|
2853
|
+
const key = JSON.stringify([service, raw ? "" : entry.space, entry.path, (0, import_sdk_core7.canonicalizeRecapCaveats)(caveats)]);
|
|
2853
2854
|
const group = groups.get(key) ?? {
|
|
2854
2855
|
service,
|
|
2855
2856
|
...raw ? {} : { space: entry.space },
|
|
@@ -2873,7 +2874,7 @@ function signedAuthorityFromSessionGrant(node, delegation, authorization, cid) {
|
|
|
2873
2874
|
function canonicalResourcesFromPortableDelegation(delegation) {
|
|
2874
2875
|
if (delegation.resources !== void 0 && delegation.resources.length > 0) {
|
|
2875
2876
|
return delegation.resources.map((resource) => ({ ...resource, actions: [...resource.actions].sort() })).sort(
|
|
2876
|
-
(left, right) => left.service.localeCompare(right.service) || left.space.localeCompare(right.space) || left.path.localeCompare(right.path) || left.actions.join("\0").localeCompare(right.actions.join("\0")) || (0,
|
|
2877
|
+
(left, right) => left.service.localeCompare(right.service) || left.space.localeCompare(right.space) || left.path.localeCompare(right.path) || left.actions.join("\0").localeCompare(right.actions.join("\0")) || (0, import_sdk_core7.canonicalizeRecapCaveats)(left.caveats).localeCompare((0, import_sdk_core7.canonicalizeRecapCaveats)(right.caveats))
|
|
2877
2878
|
);
|
|
2878
2879
|
}
|
|
2879
2880
|
const byService = /* @__PURE__ */ new Map();
|
|
@@ -2897,7 +2898,7 @@ function canonicalResourcesFromPortableDelegation(delegation) {
|
|
|
2897
2898
|
function resourcesMatch(actual, expected) {
|
|
2898
2899
|
const comparable = (resource) => ({
|
|
2899
2900
|
...resource,
|
|
2900
|
-
caveats: (0,
|
|
2901
|
+
caveats: (0, import_sdk_core7.canonicalizeRecapCaveats)(resource.caveats)
|
|
2901
2902
|
});
|
|
2902
2903
|
return JSON.stringify(actual.map(comparable)) === JSON.stringify(expected.map(comparable));
|
|
2903
2904
|
}
|
|
@@ -2991,7 +2992,7 @@ async function activateValidatedRuntimeDelegation(node, delegation, options) {
|
|
|
2991
2992
|
...compact ? {} : { siweProof: delegation.siweProof }
|
|
2992
2993
|
};
|
|
2993
2994
|
try {
|
|
2994
|
-
if (node.isSessionOnly === true && typeof node.did === "string" && (0,
|
|
2995
|
+
if (node.isSessionOnly === true && typeof node.did === "string" && (0, import_sdk_core7.principalDidEquals)(node.did, node.sessionDid) && typeof node.useDelegation === "function") {
|
|
2995
2996
|
await node.useDelegation(installedCandidate);
|
|
2996
2997
|
} else {
|
|
2997
2998
|
await node.useRuntimeDelegation(installedCandidate);
|
|
@@ -3083,16 +3084,16 @@ function deserializeDelegation(data) {
|
|
|
3083
3084
|
var import_sdk_services5 = require("@tinycloud/sdk-services");
|
|
3084
3085
|
var import_siwe2 = require("siwe");
|
|
3085
3086
|
var import_share_envelope = require("@tinycloud/share-envelope");
|
|
3086
|
-
var
|
|
3087
|
+
var import_sdk_core12 = require("@tinycloud/sdk-core");
|
|
3087
3088
|
var import_sdk_services6 = require("@tinycloud/sdk-services");
|
|
3088
3089
|
var import_requestLog2 = require("@tinycloud/sdk-services/telemetry/requestLog");
|
|
3089
3090
|
var import_resource2 = require("@tinycloud/sdk-services/encryption/resource");
|
|
3090
3091
|
|
|
3091
3092
|
// src/account/AccountService.ts
|
|
3092
|
-
var
|
|
3093
|
+
var import_sdk_core8 = require("@tinycloud/sdk-core");
|
|
3093
3094
|
|
|
3094
3095
|
// src/DelegatedAccess.ts
|
|
3095
|
-
var
|
|
3096
|
+
var import_sdk_core9 = require("@tinycloud/sdk-core");
|
|
3096
3097
|
var DelegatedAccess = class {
|
|
3097
3098
|
/**
|
|
3098
3099
|
* @param lifetime - Optional owner of this access: its `fetch` is used for
|
|
@@ -3114,16 +3115,16 @@ var DelegatedAccess = class {
|
|
|
3114
3115
|
});
|
|
3115
3116
|
this._serviceContext = lifetime ? lifetime.track(context) : context;
|
|
3116
3117
|
const prefix = this._delegation.path.replace(/\/$/, "");
|
|
3117
|
-
this._kv = new
|
|
3118
|
+
this._kv = new import_sdk_core9.KVService({ prefix });
|
|
3118
3119
|
this._kv.initialize(this._serviceContext);
|
|
3119
3120
|
this._serviceContext.registerService("kv", this._kv);
|
|
3120
|
-
this._sql = new
|
|
3121
|
+
this._sql = new import_sdk_core9.SQLService({});
|
|
3121
3122
|
this._sql.initialize(this._serviceContext);
|
|
3122
3123
|
this._serviceContext.registerService("sql", this._sql);
|
|
3123
|
-
this._duckdb = new
|
|
3124
|
+
this._duckdb = new import_sdk_core9.DuckDbService({});
|
|
3124
3125
|
this._duckdb.initialize(this._serviceContext);
|
|
3125
3126
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
3126
|
-
this._hooks = new
|
|
3127
|
+
this._hooks = new import_sdk_core9.HooksService({});
|
|
3127
3128
|
this._hooks.initialize(this._serviceContext);
|
|
3128
3129
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
3129
3130
|
const serviceSession = {
|
|
@@ -3273,7 +3274,7 @@ function createWasmKeyProvider(sessionManager) {
|
|
|
3273
3274
|
}
|
|
3274
3275
|
|
|
3275
3276
|
// src/delegateToHelpers.ts
|
|
3276
|
-
var
|
|
3277
|
+
var import_sdk_core10 = require("@tinycloud/sdk-core");
|
|
3277
3278
|
function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
3278
3279
|
const byService = /* @__PURE__ */ new Map();
|
|
3279
3280
|
for (const a of actions) {
|
|
@@ -3304,7 +3305,7 @@ function legacyParamsToPermissionEntries(actions, path, spaceIdOverride) {
|
|
|
3304
3305
|
}
|
|
3305
3306
|
return entries;
|
|
3306
3307
|
}
|
|
3307
|
-
var DEFAULT_DELEGATION_EXPIRY_MS =
|
|
3308
|
+
var DEFAULT_DELEGATION_EXPIRY_MS = import_sdk_core10.EXPIRY.SESSION_MS;
|
|
3308
3309
|
function resolveExpiryMs(expiry) {
|
|
3309
3310
|
if (expiry === void 0) {
|
|
3310
3311
|
return DEFAULT_DELEGATION_EXPIRY_MS;
|
|
@@ -3317,10 +3318,10 @@ function resolveExpiryMs(expiry) {
|
|
|
3317
3318
|
}
|
|
3318
3319
|
return expiry;
|
|
3319
3320
|
}
|
|
3320
|
-
return (0,
|
|
3321
|
+
return (0, import_sdk_core10.parseExpiry)(expiry);
|
|
3321
3322
|
}
|
|
3322
3323
|
function extractSiweExpiration(siwe) {
|
|
3323
|
-
const parsed = new
|
|
3324
|
+
const parsed = new import_sdk_core10.SiweMessage(siwe);
|
|
3324
3325
|
if (parsed.expirationTime === void 0 || parsed.expirationTime === null) {
|
|
3325
3326
|
return void 0;
|
|
3326
3327
|
}
|
|
@@ -3334,7 +3335,7 @@ function extractSiweExpiration(siwe) {
|
|
|
3334
3335
|
}
|
|
3335
3336
|
|
|
3336
3337
|
// src/NodeSecretsService.ts
|
|
3337
|
-
var
|
|
3338
|
+
var import_sdk_core11 = require("@tinycloud/sdk-core");
|
|
3338
3339
|
var SECRETS_SPACE = "secrets";
|
|
3339
3340
|
function ok() {
|
|
3340
3341
|
return { ok: true, data: void 0 };
|
|
@@ -3367,7 +3368,7 @@ function secretActionName(action) {
|
|
|
3367
3368
|
}
|
|
3368
3369
|
function secretPermissionEntries(name, options, action, space, encryptionNetworkId) {
|
|
3369
3370
|
const entries = [];
|
|
3370
|
-
const path = action === "list" ? (0,
|
|
3371
|
+
const path = action === "list" ? (0, import_sdk_core11.resolveSecretListPrefix)(options) : (0, import_sdk_core11.resolveSecretPath)(name, options).permissionPaths.vault;
|
|
3371
3372
|
entries.push({
|
|
3372
3373
|
service: "tinycloud.kv",
|
|
3373
3374
|
space,
|
|
@@ -3464,7 +3465,7 @@ var NodeSecretsService = class {
|
|
|
3464
3465
|
);
|
|
3465
3466
|
} catch (error) {
|
|
3466
3467
|
return secretsError(
|
|
3467
|
-
|
|
3468
|
+
import_sdk_core11.ErrorCodes.INVALID_INPUT,
|
|
3468
3469
|
error instanceof Error ? error.message : String(error),
|
|
3469
3470
|
error instanceof Error ? error : void 0
|
|
3470
3471
|
);
|
|
@@ -3483,7 +3484,7 @@ var NodeSecretsService = class {
|
|
|
3483
3484
|
}
|
|
3484
3485
|
if (!this.config.canEscalate()) {
|
|
3485
3486
|
return secretsError(
|
|
3486
|
-
|
|
3487
|
+
import_sdk_core11.ErrorCodes.PERMISSION_DENIED,
|
|
3487
3488
|
`Cannot autosign ${displayActionUrn(action)} for ${target}; TinyCloudNode needs wallet mode with a signer or privateKey.`
|
|
3488
3489
|
);
|
|
3489
3490
|
}
|
|
@@ -3496,7 +3497,7 @@ var NodeSecretsService = class {
|
|
|
3496
3497
|
}
|
|
3497
3498
|
escalationError(action, target, error) {
|
|
3498
3499
|
return secretsError(
|
|
3499
|
-
|
|
3500
|
+
import_sdk_core11.ErrorCodes.PERMISSION_DENIED,
|
|
3500
3501
|
error instanceof Error ? error.message : `Autosign escalation for ${displayActionUrn(action)} on ${target} failed.`,
|
|
3501
3502
|
error instanceof Error ? error : void 0
|
|
3502
3503
|
);
|
|
@@ -3516,10 +3517,10 @@ var NodeSecretsService = class {
|
|
|
3516
3517
|
return false;
|
|
3517
3518
|
}
|
|
3518
3519
|
const manifests = Array.isArray(manifest) ? manifest : [manifest];
|
|
3519
|
-
const requestedEntries = (0,
|
|
3520
|
+
const requestedEntries = (0, import_sdk_core11.expandPermissionEntries)(permissionEntries);
|
|
3520
3521
|
return requestedEntries.every(
|
|
3521
3522
|
(entry) => manifests.some((candidate) => {
|
|
3522
|
-
const resolved = (0,
|
|
3523
|
+
const resolved = (0, import_sdk_core11.resolveManifest)(candidate);
|
|
3523
3524
|
return resolved.resources.some(
|
|
3524
3525
|
(resource) => resource.service === entry.service && spaceMatches(
|
|
3525
3526
|
resource.space,
|
|
@@ -3535,8 +3536,8 @@ var NodeSecretsService = class {
|
|
|
3535
3536
|
// src/TinyCloudNode.ts
|
|
3536
3537
|
var DEFAULT_HOST = "https://node.tinycloud.xyz";
|
|
3537
3538
|
var DEFAULT_ENCRYPTION_NETWORK_NAME = "default";
|
|
3538
|
-
var NETWORK_CREATE_ACTION2 =
|
|
3539
|
-
var DECRYPT_ACTION2 =
|
|
3539
|
+
var NETWORK_CREATE_ACTION2 = import_sdk_core12.ENCRYPTION.NETWORK_CREATE;
|
|
3540
|
+
var DECRYPT_ACTION2 = import_sdk_core12.ENCRYPTION.DECRYPT;
|
|
3540
3541
|
var BOOTSTRAP_COMPLETION_MARKER_KEY = "system/bootstrap/complete";
|
|
3541
3542
|
var BOOTSTRAP_COMPLETION_MARKER_VERSION = 1;
|
|
3542
3543
|
var ACCEPTED_MARKER_VERSIONS = [BOOTSTRAP_COMPLETION_MARKER_VERSION];
|
|
@@ -3545,24 +3546,24 @@ function isSecretPayload(value) {
|
|
|
3545
3546
|
return typeof value === "object" && value !== null && "value" in value && typeof value.value === "string" && "createdAt" in value && typeof value.createdAt === "string" && "updatedAt" in value && typeof value.updatedAt === "string";
|
|
3546
3547
|
}
|
|
3547
3548
|
var ROOT_DELEGATION_ACTIONS = [
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3549
|
+
import_sdk_core12.KV.PUT,
|
|
3550
|
+
import_sdk_core12.KV.GET,
|
|
3551
|
+
import_sdk_core12.KV.DEL,
|
|
3552
|
+
import_sdk_core12.KV.LIST,
|
|
3553
|
+
import_sdk_core12.KV.METADATA,
|
|
3554
|
+
import_sdk_core12.SQL.READ,
|
|
3555
|
+
import_sdk_core12.SQL.WRITE,
|
|
3556
|
+
import_sdk_core12.SQL.ADMIN,
|
|
3557
|
+
import_sdk_core12.SQL.ALL,
|
|
3558
|
+
import_sdk_core12.DUCKDB.READ,
|
|
3559
|
+
import_sdk_core12.DUCKDB.WRITE,
|
|
3560
|
+
import_sdk_core12.DUCKDB.ADMIN,
|
|
3561
|
+
import_sdk_core12.DUCKDB.DESCRIBE,
|
|
3562
|
+
import_sdk_core12.DUCKDB.EXPORT,
|
|
3563
|
+
import_sdk_core12.DUCKDB.IMPORT,
|
|
3564
|
+
import_sdk_core12.DUCKDB.ALL
|
|
3564
3565
|
];
|
|
3565
|
-
var DEFAULT_SESSION_EXPIRATION_MS =
|
|
3566
|
+
var DEFAULT_SESSION_EXPIRATION_MS = import_sdk_core12.EXPIRY.SESSION_MS;
|
|
3566
3567
|
var OWNER_REVOCATION_WINDOW_MS = 10 * 6e4;
|
|
3567
3568
|
function unifiedRootAttenuation(capabilities) {
|
|
3568
3569
|
const attenuation = {};
|
|
@@ -3614,7 +3615,7 @@ function spaceOwnerKey(spaceId) {
|
|
|
3614
3615
|
}
|
|
3615
3616
|
function didPrincipalMatches2(actual, expected) {
|
|
3616
3617
|
try {
|
|
3617
|
-
return (0,
|
|
3618
|
+
return (0, import_sdk_core12.principalDidEquals)(actual, expected);
|
|
3618
3619
|
} catch {
|
|
3619
3620
|
return actual === expected;
|
|
3620
3621
|
}
|
|
@@ -3853,7 +3854,7 @@ function ownerDelegationPermissions(params) {
|
|
|
3853
3854
|
}
|
|
3854
3855
|
const slash = action.indexOf("/");
|
|
3855
3856
|
const service = slash === -1 ? "" : action.slice(0, slash);
|
|
3856
|
-
if (
|
|
3857
|
+
if (import_sdk_core12.SERVICE_LONG_TO_SHORT[service] === void 0) {
|
|
3857
3858
|
throw new Error("Owner delegation capabilities are unsupported");
|
|
3858
3859
|
}
|
|
3859
3860
|
const actions = byService.get(service) ?? [];
|
|
@@ -3869,7 +3870,7 @@ function ownerDelegationPermissions(params) {
|
|
|
3869
3870
|
}
|
|
3870
3871
|
const resources = /* @__PURE__ */ new Set();
|
|
3871
3872
|
for (const permission of permissions) {
|
|
3872
|
-
if (typeof permission.service !== "string" ||
|
|
3873
|
+
if (typeof permission.service !== "string" || import_sdk_core12.SERVICE_LONG_TO_SHORT[permission.service] === void 0 || typeof permission.path !== "string" || permission.path.length === 0 || permission.path.trim() !== permission.path || /[\u0000-\u001f\u007f\\*]/.test(permission.path) || !Array.isArray(permission.actions) || permission.actions.length === 0 || permission.actions.length > 32) {
|
|
3873
3874
|
throw new Error("Owner delegation requires bounded capabilities");
|
|
3874
3875
|
}
|
|
3875
3876
|
const resourceKey = `${permission.service}\0${permission.path}`;
|
|
@@ -3884,9 +3885,9 @@ function ownerDelegationPermissions(params) {
|
|
|
3884
3885
|
}
|
|
3885
3886
|
actions.add(action);
|
|
3886
3887
|
}
|
|
3887
|
-
if (permission.service ===
|
|
3888
|
+
if (permission.service === import_sdk_core12.ENCRYPTION_PERMISSION_SERVICE) {
|
|
3888
3889
|
try {
|
|
3889
|
-
(0,
|
|
3890
|
+
(0, import_sdk_core12.parseNetworkId)(permission.path);
|
|
3890
3891
|
} catch {
|
|
3891
3892
|
throw new Error("Owner delegation encryption permission requires a canonical network URN");
|
|
3892
3893
|
}
|
|
@@ -3898,11 +3899,11 @@ function ownerPermissionsToAbilities(permissions) {
|
|
|
3898
3899
|
const abilities = {};
|
|
3899
3900
|
const rawAbilities = {};
|
|
3900
3901
|
for (const permission of permissions) {
|
|
3901
|
-
if (permission.service ===
|
|
3902
|
+
if (permission.service === import_sdk_core12.ENCRYPTION_PERMISSION_SERVICE) {
|
|
3902
3903
|
rawAbilities[permission.path] = [...permission.actions];
|
|
3903
3904
|
continue;
|
|
3904
3905
|
}
|
|
3905
|
-
const shortService =
|
|
3906
|
+
const shortService = import_sdk_core12.SERVICE_LONG_TO_SHORT[permission.service];
|
|
3906
3907
|
abilities[shortService] ?? (abilities[shortService] = {});
|
|
3907
3908
|
abilities[shortService][permission.path] = [...permission.actions];
|
|
3908
3909
|
}
|
|
@@ -4085,7 +4086,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4085
4086
|
}
|
|
4086
4087
|
const stamp = await establishReplicaSessionStamp(
|
|
4087
4088
|
replication.storage,
|
|
4088
|
-
(0,
|
|
4089
|
+
(0, import_sdk_core12.pkhDid)(session.address, session.chainId),
|
|
4089
4090
|
anchor
|
|
4090
4091
|
);
|
|
4091
4092
|
if (epoch !== this.sessionEpoch || attempt !== this.latestSessionAttempt) return void 0;
|
|
@@ -4168,7 +4169,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4168
4169
|
* and remembers whose storage is full so sign-in and listing skip their
|
|
4169
4170
|
* best-effort writes. Lives as long as this instance, across sign-ins.
|
|
4170
4171
|
*/
|
|
4171
|
-
this.storageFull = new
|
|
4172
|
+
this.storageFull = new import_sdk_core12.StorageFullMonitor(
|
|
4172
4173
|
(spaceId) => spaceOwnerKey(spaceId) ?? spaceId,
|
|
4173
4174
|
() => this.currentStorageOwner()
|
|
4174
4175
|
);
|
|
@@ -4212,7 +4213,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4212
4213
|
if (!granted?.caveats?.length) {
|
|
4213
4214
|
return entry;
|
|
4214
4215
|
}
|
|
4215
|
-
if (entry.caveats !== void 0 && !(0,
|
|
4216
|
+
if (entry.caveats !== void 0 && !(0, import_sdk_core12.recapCaveatsEqual)(entry.caveats, granted.caveats)) {
|
|
4216
4217
|
throw new Error("Invocation caveats do not match signed ReCap authority.");
|
|
4217
4218
|
}
|
|
4218
4219
|
return { ...entry, caveats: cloneRecapCaveats(granted.caveats) };
|
|
@@ -4226,8 +4227,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4226
4227
|
host: config.host ?? DEFAULT_HOST,
|
|
4227
4228
|
registryPolicy: "fail-closed",
|
|
4228
4229
|
// One store for every authorization this client creates.
|
|
4229
|
-
registrySequenceStore: config.registrySequenceStore ?? (0,
|
|
4230
|
-
registryCacheStore: config.registryCacheStore ?? (0,
|
|
4230
|
+
registrySequenceStore: config.registrySequenceStore ?? (0, import_sdk_core12.createInMemoryRegistrySequenceStore)(),
|
|
4231
|
+
registryCacheStore: config.registryCacheStore ?? (0, import_sdk_core12.createInMemoryRegistryCacheStore)()
|
|
4231
4232
|
};
|
|
4232
4233
|
if (this.config.replication?.enabled) {
|
|
4233
4234
|
const runtime = getNodeReplicationLoaders().runtime().then(({ ReplicationRuntime }) => {
|
|
@@ -4297,11 +4298,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4297
4298
|
this.sessionKeyJwk = sessionKey.jwk;
|
|
4298
4299
|
this._requestLog = config.requestLog === true ? new import_requestLog2.RequestLog() : void 0;
|
|
4299
4300
|
this._serviceGraph = this.createServiceGraphLifetime();
|
|
4300
|
-
this._capabilityRegistry = new
|
|
4301
|
+
this._capabilityRegistry = new import_sdk_core12.CapabilityKeyRegistry();
|
|
4301
4302
|
this._keyProvider = new WasmKeyProvider({
|
|
4302
4303
|
sessionManager: this.sessionManager
|
|
4303
4304
|
});
|
|
4304
|
-
this.notificationHandler = config.notificationHandler ?? new
|
|
4305
|
+
this.notificationHandler = config.notificationHandler ?? new import_sdk_core12.SilentNotificationHandler();
|
|
4305
4306
|
this._sharingService = this.createReceiveOnlySharing();
|
|
4306
4307
|
if (config.signer) {
|
|
4307
4308
|
this.signer = config.signer;
|
|
@@ -4393,13 +4394,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4393
4394
|
async readStorageStatus(options) {
|
|
4394
4395
|
const session = this._serviceContext?.session;
|
|
4395
4396
|
if (!this._serviceContext || !session) {
|
|
4396
|
-
return (0,
|
|
4397
|
+
return (0, import_sdk_core12.err)((0, import_sdk_core12.serviceError)(import_sdk_core12.ErrorCodes.AUTH_REQUIRED, "Not signed in. Call signIn() first.", "storage"));
|
|
4397
4398
|
}
|
|
4398
4399
|
const spaceId = options?.space === void 0 ? session.spaceId : options.space.startsWith("tinycloud:") ? options.space : this.ownedSpaceId(options.space);
|
|
4399
4400
|
const action = "tinycloud.space/info";
|
|
4400
4401
|
if (!this.findGrantForOperation({ spaceId, service: "space", path: "", action })) {
|
|
4401
|
-
return (0,
|
|
4402
|
-
|
|
4402
|
+
return (0, import_sdk_core12.err)((0, import_sdk_core12.serviceError)(
|
|
4403
|
+
import_sdk_core12.ErrorCodes.PERMISSION_DENIED,
|
|
4403
4404
|
`Reading storage status needs ${action} on ${spaceId}, which this session was not granted.`,
|
|
4404
4405
|
"storage",
|
|
4405
4406
|
{ meta: { requiredAction: action, resource: spaceId } }
|
|
@@ -4415,8 +4416,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4415
4416
|
const text = await response.text();
|
|
4416
4417
|
if (!response.ok) {
|
|
4417
4418
|
const unauthorized = response.status === 401 || response.status === 403;
|
|
4418
|
-
return (0,
|
|
4419
|
-
unauthorized ?
|
|
4419
|
+
return (0, import_sdk_core12.err)((0, import_sdk_core12.serviceError)(
|
|
4420
|
+
unauthorized ? import_sdk_core12.ErrorCodes.AUTH_UNAUTHORIZED : import_sdk_core12.ErrorCodes.NETWORK_ERROR,
|
|
4420
4421
|
`Failed to read storage status: ${response.status} - ${text.slice(0, 300)}`,
|
|
4421
4422
|
"storage",
|
|
4422
4423
|
{ meta: { status: response.status, ...unauthorized ? { requiredAction: action, resource: spaceId } : {} } }
|
|
@@ -4428,10 +4429,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4428
4429
|
} catch {
|
|
4429
4430
|
body = void 0;
|
|
4430
4431
|
}
|
|
4431
|
-
const status = (0,
|
|
4432
|
+
const status = (0, import_sdk_core12.parseStorageStatus)(body);
|
|
4432
4433
|
if (!status) {
|
|
4433
|
-
return (0,
|
|
4434
|
-
|
|
4434
|
+
return (0, import_sdk_core12.err)((0, import_sdk_core12.serviceError)(
|
|
4435
|
+
import_sdk_core12.ErrorCodes.STORAGE_STATUS_UNAVAILABLE,
|
|
4435
4436
|
"This TinyCloud node does not report storage usage yet.",
|
|
4436
4437
|
"storage",
|
|
4437
4438
|
{ meta: { status: response.status } }
|
|
@@ -4441,10 +4442,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4441
4442
|
this.storageFull.clearFor(spaceId);
|
|
4442
4443
|
if (spaceOwnerKey(spaceId) === this.currentStorageOwner()) this.storageFull.clearFor(void 0);
|
|
4443
4444
|
}
|
|
4444
|
-
return (0,
|
|
4445
|
+
return (0, import_sdk_core12.ok)(status);
|
|
4445
4446
|
} catch (error) {
|
|
4446
|
-
return (0,
|
|
4447
|
-
|
|
4447
|
+
return (0, import_sdk_core12.err)((0, import_sdk_core12.serviceError)(
|
|
4448
|
+
import_sdk_core12.ErrorCodes.NETWORK_ERROR,
|
|
4448
4449
|
`Failed to read storage status: ${error instanceof Error ? error.message : String(error)}`,
|
|
4449
4450
|
"storage",
|
|
4450
4451
|
{ cause: error instanceof Error ? error : void 0 }
|
|
@@ -4584,7 +4585,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4584
4585
|
*/
|
|
4585
4586
|
createReceiveOnlySharing() {
|
|
4586
4587
|
const receiveOnlyGraph = this._serviceGraph;
|
|
4587
|
-
return new
|
|
4588
|
+
return new import_sdk_core12.SharingService({
|
|
4588
4589
|
hosts: [this.config.host],
|
|
4589
4590
|
// session: undefined - not needed for receive()
|
|
4590
4591
|
invoke: receiveOnlyGraph.invoke,
|
|
@@ -4599,7 +4600,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4599
4600
|
},
|
|
4600
4601
|
createKVService: (config) => {
|
|
4601
4602
|
const prefix = config.pathPrefix?.replace(/\/$/, "");
|
|
4602
|
-
const kvService = new
|
|
4603
|
+
const kvService = new import_sdk_core12.KVService({ prefix });
|
|
4603
4604
|
const kvContext = receiveOnlyGraph.track(createServiceContext({
|
|
4604
4605
|
requestSink: receiveOnlyGraph.requestSink,
|
|
4605
4606
|
invoke: config.invoke,
|
|
@@ -4647,7 +4648,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4647
4648
|
nonce: config.nonce,
|
|
4648
4649
|
siweConfig: config.siweConfig,
|
|
4649
4650
|
manifest: useBootstrapSignInRequest ? void 0 : config.manifest,
|
|
4650
|
-
capabilityRequest: useBootstrapSignInRequest ? config.includeAccountRegistryPermissions === false ?
|
|
4651
|
+
capabilityRequest: useBootstrapSignInRequest ? config.includeAccountRegistryPermissions === false ? import_sdk_core12.BOOTSTRAP_DEFAULT_ONLY_SESSION_REQUEST : import_sdk_core12.BOOTSTRAP_SESSION_REQUESTS.default : config.capabilityRequest,
|
|
4651
4652
|
includeAccountRegistryPermissions: useBootstrapSignInRequest ? false : config.includeAccountRegistryPermissions,
|
|
4652
4653
|
// Sign-in needs only the entry inputs (prefixes + secrets opt-in);
|
|
4653
4654
|
// storage and scheduling never leave TinyCloudNode.
|
|
@@ -4658,7 +4659,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4658
4659
|
syncScope: config.replication.syncScope
|
|
4659
4660
|
} : void 0
|
|
4660
4661
|
});
|
|
4661
|
-
this.tc = new
|
|
4662
|
+
this.tc = new import_sdk_core12.TinyCloud(this.auth, {
|
|
4662
4663
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
4663
4664
|
telemetry: config.telemetry,
|
|
4664
4665
|
retryPolicy: config.retryPolicy
|
|
@@ -4712,15 +4713,15 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4712
4713
|
}
|
|
4713
4714
|
async routingDestinations(resource, access, noEntryHosts) {
|
|
4714
4715
|
const session = this.currentTinyCloudSession();
|
|
4715
|
-
if (session) this.refreshRegistryOwner((0,
|
|
4716
|
+
if (session) this.refreshRegistryOwner((0, import_sdk_core12.pkhDid)(session.address, session.chainId));
|
|
4716
4717
|
if (this.auth) return this.auth.resolveResourceDestinations(resource, access, noEntryHosts);
|
|
4717
|
-
const owner = resource.startsWith("urn:tinycloud:encryption:") ? (0,
|
|
4718
|
+
const owner = resource.startsWith("urn:tinycloud:encryption:") ? (0, import_sdk_core12.parseNetworkId)(resource.split("/")[0]).ownerDid : (0, import_sdk_core12.parseSpaceUri)(resource)?.owner ?? (() => {
|
|
4718
4719
|
const key = /^tinycloud:key:(z[^:]+):[^/]+$/.exec(resource);
|
|
4719
4720
|
return key ? `did:key:${key[1]}` : void 0;
|
|
4720
4721
|
})();
|
|
4721
4722
|
if (!owner) throw new Error(`Cannot determine registry owner for ${resource}`);
|
|
4722
|
-
const subject = owner.startsWith("did:pkh:") ? (0,
|
|
4723
|
-
const resolved = await (0,
|
|
4723
|
+
const subject = owner.startsWith("did:pkh:") ? (0, import_sdk_core12.pkhDid)(owner.slice(owner.lastIndexOf(":") + 1), this.config.registryChainId ?? 1) : owner;
|
|
4724
|
+
const resolved = await (0, import_sdk_core12.resolveRegistryResource)(subject, resource, access, {
|
|
4724
4725
|
registryUrl: this.config.tinycloudRegistryUrl,
|
|
4725
4726
|
registryChainId: this.config.registryChainId,
|
|
4726
4727
|
sequenceStore: this.config.registrySequenceStore,
|
|
@@ -4730,9 +4731,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4730
4731
|
if (resolved.verdict.status === "unregistered") {
|
|
4731
4732
|
const hint = noEntryHosts === void 0 ? this.explicitHost ?? this.config.host : noEntryHosts[0];
|
|
4732
4733
|
const host = hint ?? this.config.newUserHost ?? (this.config.tinycloudFallbackHosts === void 0 ? DEFAULT_HOST : this.config.tinycloudFallbackHosts?.[0]);
|
|
4733
|
-
if (!host || !hint && this.config.newUserHost === null) throw new
|
|
4734
|
-
const url = (0,
|
|
4735
|
-
(0,
|
|
4734
|
+
if (!host || !hint && this.config.newUserHost === null) throw new import_sdk_core12.NodeNotFoundError(subject, resolved.verdict);
|
|
4735
|
+
const url = (0, import_sdk_core12.exactHttpOrigin)(host, "new-user host");
|
|
4736
|
+
(0, import_sdk_core12.warnRegistryDefaultNode)(resolved.verdict, this.config.registryCacheStore, this.config.onRegistryFallback);
|
|
4736
4737
|
return [{ url }];
|
|
4737
4738
|
}
|
|
4738
4739
|
const destinations = resolved.hosts.flatMap((host) => host.urls.map((url) => ({ url, nodeDid: host.nodeDid })));
|
|
@@ -4759,7 +4760,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4759
4760
|
if (access === "host") dataHost ?? (dataHost = destinations[0]?.url);
|
|
4760
4761
|
else encryptionHost ?? (encryptionHost = destinations[0]?.url);
|
|
4761
4762
|
} catch (error) {
|
|
4762
|
-
if (!(error instanceof
|
|
4763
|
+
if (!(error instanceof import_sdk_core12.NodeNotFoundError) || error.verdict.status !== "registered") throw error;
|
|
4763
4764
|
unserved ?? (unserved = error);
|
|
4764
4765
|
}
|
|
4765
4766
|
}
|
|
@@ -4841,7 +4842,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4841
4842
|
/** Publish the active owner Node as a session-signed registry record. */
|
|
4842
4843
|
async publishActiveNodeLocation(registryUrl, fetchFn = globalThis.fetch.bind(globalThis)) {
|
|
4843
4844
|
const node = await this.activeNodeIdentity();
|
|
4844
|
-
return (0,
|
|
4845
|
+
return (0, import_sdk_core12.publishLocationRecord)({
|
|
4845
4846
|
registryUrl,
|
|
4846
4847
|
subject: this.credentialHolderDid,
|
|
4847
4848
|
nodeOrigin: node.origin,
|
|
@@ -4858,7 +4859,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4858
4859
|
*/
|
|
4859
4860
|
get did() {
|
|
4860
4861
|
if (this._address) {
|
|
4861
|
-
return (0,
|
|
4862
|
+
return (0, import_sdk_core12.pkhDid)(this._address, this._chainId);
|
|
4862
4863
|
}
|
|
4863
4864
|
return this.sessionManager.getDID(this.sessionKeyId);
|
|
4864
4865
|
}
|
|
@@ -4896,7 +4897,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4896
4897
|
refreshRegistryForCapabilities(permissions) {
|
|
4897
4898
|
for (const permission of permissions) {
|
|
4898
4899
|
try {
|
|
4899
|
-
const owner = permission.service === "tinycloud.encryption" && permission.path.startsWith("urn:tinycloud:encryption:") ? (0,
|
|
4900
|
+
const owner = permission.service === "tinycloud.encryption" && permission.path.startsWith("urn:tinycloud:encryption:") ? (0, import_sdk_core12.parseNetworkId)(permission.path.split("/")[0]).ownerDid : permission.space ? this.ownerDidFromSpaceId(permission.space) : void 0;
|
|
4900
4901
|
if (owner) this.refreshRegistryOwner(owner);
|
|
4901
4902
|
} catch {
|
|
4902
4903
|
}
|
|
@@ -4904,11 +4905,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4904
4905
|
}
|
|
4905
4906
|
refreshRegistryOwner(owner) {
|
|
4906
4907
|
if (this.config.tinycloudRegistryUrl === null) return;
|
|
4907
|
-
const subject = owner.startsWith("did:pkh:") ? (0,
|
|
4908
|
-
const key = (0,
|
|
4908
|
+
const subject = owner.startsWith("did:pkh:") ? (0, import_sdk_core12.pkhDid)(owner.slice(owner.lastIndexOf(":") + 1), this.config.registryChainId ?? 1) : owner;
|
|
4909
|
+
const key = (0, import_sdk_core12.registryOwnerKeyV2)(subject);
|
|
4909
4910
|
if (this.registryRefreshOwners.has(key)) return;
|
|
4910
4911
|
this.registryRefreshOwners.add(key);
|
|
4911
|
-
void (0,
|
|
4912
|
+
void (0, import_sdk_core12.refreshOwnerRegistry)(subject, {
|
|
4912
4913
|
registryUrl: this.config.tinycloudRegistryUrl,
|
|
4913
4914
|
registryChainId: this.config.registryChainId,
|
|
4914
4915
|
sequenceStore: this.config.registrySequenceStore,
|
|
@@ -4918,7 +4919,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4918
4919
|
/** Normalize signed capabilities without collapsing nested encryption into raw authority. */
|
|
4919
4920
|
projectSignedRecapCapabilities(siwe) {
|
|
4920
4921
|
const projected = this.parseRecapWithCaveats(siwe).map((entry) => {
|
|
4921
|
-
const normalized = (0,
|
|
4922
|
+
const normalized = (0, import_sdk_core12.parseRecapCapabilities)(() => [entry], siwe)[0];
|
|
4922
4923
|
if (normalized.service !== "tinycloud.encryption") return normalized;
|
|
4923
4924
|
if (!this.isEncryptionNetworkOperation("encryption", entry.path, entry.space)) {
|
|
4924
4925
|
return { ...normalized, space: entry.space };
|
|
@@ -4962,14 +4963,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4962
4963
|
if (!this._address) {
|
|
4963
4964
|
return void 0;
|
|
4964
4965
|
}
|
|
4965
|
-
return this.wasmBindings.makeSpaceId(this._address, this._chainId,
|
|
4966
|
+
return this.wasmBindings.makeSpaceId(this._address, this._chainId, import_sdk_core12.ACCOUNT_REGISTRY_SPACE);
|
|
4966
4967
|
}
|
|
4967
4968
|
/**
|
|
4968
4969
|
* Account-level application and delegation helpers.
|
|
4969
4970
|
*/
|
|
4970
4971
|
get account() {
|
|
4971
4972
|
if (!this._account) {
|
|
4972
|
-
this._account = new
|
|
4973
|
+
this._account = new import_sdk_core8.AccountService({
|
|
4973
4974
|
getDid: () => this.did,
|
|
4974
4975
|
getHost: () => this.hosts[0] ?? this.config.host,
|
|
4975
4976
|
getPrimarySpaceId: () => this.spaceId,
|
|
@@ -5027,7 +5028,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5027
5028
|
async endSession() {
|
|
5028
5029
|
const leavingAddress = this.address ?? this._restoredTcSession?.address;
|
|
5029
5030
|
const leavingChainId = this._chainId;
|
|
5030
|
-
const leavingPrincipal = this.replicaSessionPrincipal ?? (leavingAddress ? (0,
|
|
5031
|
+
const leavingPrincipal = this.replicaSessionPrincipal ?? (leavingAddress ? (0, import_sdk_core12.pkhDid)(leavingAddress, leavingChainId) : void 0);
|
|
5031
5032
|
const leavingAuth = this.auth;
|
|
5032
5033
|
const leavingSignature = leavingAuth?.tinyCloudSession?.signature ?? this._restoredTcSession?.signature;
|
|
5033
5034
|
const leavingContext = this._serviceContext;
|
|
@@ -5179,12 +5180,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5179
5180
|
this.replicaRestoreGate = void 0;
|
|
5180
5181
|
this._serviceGraph = this.createServiceGraphLifetime();
|
|
5181
5182
|
this.auth = oldAuth;
|
|
5182
|
-
this.tc = this.auth ? new
|
|
5183
|
+
this.tc = this.auth ? new import_sdk_core12.TinyCloud(this.auth, {
|
|
5183
5184
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
5184
5185
|
telemetry: this.config.telemetry,
|
|
5185
5186
|
retryPolicy: this.config.retryPolicy
|
|
5186
5187
|
}) : null;
|
|
5187
|
-
this._capabilityRegistry = new
|
|
5188
|
+
this._capabilityRegistry = new import_sdk_core12.CapabilityKeyRegistry();
|
|
5188
5189
|
this._keyProvider = new WasmKeyProvider({ sessionManager: this.sessionManager });
|
|
5189
5190
|
this._sharingService = this.createReceiveOnlySharing();
|
|
5190
5191
|
}
|
|
@@ -5211,7 +5212,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5211
5212
|
}
|
|
5212
5213
|
/**
|
|
5213
5214
|
* Fresh OpenKey sign-in. The callback receives the SDK's original SIWE and
|
|
5214
|
-
* session JWK before approval; the signed result is verified against those
|
|
5215
|
+
* public session JWK before approval; the signed result is verified against those
|
|
5215
5216
|
* bytes before the network session or replica stamp is committed.
|
|
5216
5217
|
*/
|
|
5217
5218
|
async signInWithOpenKey(authorizeFn, options) {
|
|
@@ -5272,11 +5273,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5272
5273
|
this.pendingAccountRegistrySync?.controller.abort();
|
|
5273
5274
|
await this.accountRegistryTail;
|
|
5274
5275
|
await this.wasmBindings.ensureInitialized?.();
|
|
5275
|
-
const address = (0,
|
|
5276
|
+
const address = (0, import_sdk_core12.canonicalizeAddress)(await this.signer.getAddress());
|
|
5276
5277
|
const chainId = await this.signer.getChainId();
|
|
5277
5278
|
this.assertSessionEpoch(epoch, "Sign-in");
|
|
5278
|
-
const nextPrincipal = (0,
|
|
5279
|
-
const priorPrincipal = this.replicaSessionPrincipal ?? (this.address ? (0,
|
|
5279
|
+
const nextPrincipal = (0, import_sdk_core12.pkhDid)(address, chainId);
|
|
5280
|
+
const priorPrincipal = this.replicaSessionPrincipal ?? (this.address ? (0, import_sdk_core12.pkhDid)(this.address, this._chainId) : void 0);
|
|
5280
5281
|
if (this.config.replication?.enabled && priorPrincipal && priorPrincipal !== nextPrincipal) {
|
|
5281
5282
|
const denial = await this.denyReplicaGate({ reason: "account_switch", principal: priorPrincipal, next: nextPrincipal });
|
|
5282
5283
|
if (denial) {
|
|
@@ -5328,7 +5329,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5328
5329
|
this.hostedOwnedSpaceIds.add(spaceId);
|
|
5329
5330
|
}
|
|
5330
5331
|
this.replicationDelegateSession = void 0;
|
|
5331
|
-
this.replicaSessionPrincipal = (0,
|
|
5332
|
+
this.replicaSessionPrincipal = (0, import_sdk_core12.pkhDid)(address, chainId);
|
|
5332
5333
|
this.replicationScopeError = void 0;
|
|
5333
5334
|
await this.quiesceReplicaRuntime();
|
|
5334
5335
|
this.assertSessionEpoch(epoch, "Sign-in");
|
|
@@ -5346,7 +5347,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5346
5347
|
const primarySession = this.currentTinyCloudSession();
|
|
5347
5348
|
if (primarySession) {
|
|
5348
5349
|
this.registerPrimarySessionGrant(primarySession);
|
|
5349
|
-
this.refreshRegistryOwner((0,
|
|
5350
|
+
this.refreshRegistryOwner((0, import_sdk_core12.pkhDid)(primarySession.address, primarySession.chainId));
|
|
5350
5351
|
this.refreshRegistryForCapabilities(this.getVerifiedSessionCapabilities());
|
|
5351
5352
|
if (this.auth?.spaceHosting === "unknown") {
|
|
5352
5353
|
await this.checkSpaceHosting();
|
|
@@ -5378,7 +5379,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5378
5379
|
}
|
|
5379
5380
|
}
|
|
5380
5381
|
if (!bootstrapped && this.config.manifest === void 0 && this.config.capabilityRequest === void 0) {
|
|
5381
|
-
await this.ensureOwnedSpaceHostedById(this.ownedSpaceId(
|
|
5382
|
+
await this.ensureOwnedSpaceHostedById(this.ownedSpaceId(import_sdk_core12.SECRETS_SPACE));
|
|
5382
5383
|
}
|
|
5383
5384
|
this.assertSessionEpoch(epoch, "Sign-in");
|
|
5384
5385
|
if (!bootstrapped) {
|
|
@@ -5422,7 +5423,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5422
5423
|
this._bootstrapStatus = { skipped: true, reason: "interactive-signer" };
|
|
5423
5424
|
return false;
|
|
5424
5425
|
}
|
|
5425
|
-
const steps = (0,
|
|
5426
|
+
const steps = (0, import_sdk_core12.bootstrapSteps)(this._address, this._chainId);
|
|
5426
5427
|
try {
|
|
5427
5428
|
const decision = await this.resolveBootstrapDecision(steps);
|
|
5428
5429
|
if (decision.action === "skip") {
|
|
@@ -5465,7 +5466,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5465
5466
|
if (!auth) {
|
|
5466
5467
|
throw new Error("Account bootstrap requires an active wallet session");
|
|
5467
5468
|
}
|
|
5468
|
-
const accountSpaceId = this.ownedSpaceId(
|
|
5469
|
+
const accountSpaceId = this.ownedSpaceId(import_sdk_core12.ACCOUNT_REGISTRY_SPACE);
|
|
5469
5470
|
const skipped = auth.lastActivationSkippedSpaceIds;
|
|
5470
5471
|
if (skipped.includes(accountSpaceId)) return { action: "run", mode: "fresh" };
|
|
5471
5472
|
if (skipped.some((spaceId) => enshrinedSpaceIds.has(spaceId))) {
|
|
@@ -5488,7 +5489,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5488
5489
|
}
|
|
5489
5490
|
return { action: "run", mode: "repair" };
|
|
5490
5491
|
}
|
|
5491
|
-
if (marker.error.code ===
|
|
5492
|
+
if (marker.error.code === import_sdk_core12.ErrorCodes.KV_NOT_FOUND && this.markerReadIsUnhostedSpace(marker.error.meta)) {
|
|
5492
5493
|
return { action: "run", mode: "fresh" };
|
|
5493
5494
|
}
|
|
5494
5495
|
} catch (err2) {
|
|
@@ -5502,7 +5503,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5502
5503
|
return { action: "run", mode: "repair" };
|
|
5503
5504
|
}
|
|
5504
5505
|
async readBootstrapCompletionMarker() {
|
|
5505
|
-
return this.kvForSpace(this.ownedSpaceId(
|
|
5506
|
+
return this.kvForSpace(this.ownedSpaceId(import_sdk_core12.ACCOUNT_REGISTRY_SPACE)).get(
|
|
5506
5507
|
BOOTSTRAP_COMPLETION_MARKER_KEY
|
|
5507
5508
|
);
|
|
5508
5509
|
}
|
|
@@ -5511,7 +5512,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5511
5512
|
throw new Error("Bootstrap completion marker requires an active wallet session");
|
|
5512
5513
|
}
|
|
5513
5514
|
const canonicalStepIds = new Set(
|
|
5514
|
-
(0,
|
|
5515
|
+
(0, import_sdk_core12.bootstrapSteps)(this._address, this._chainId).map((step) => step.id)
|
|
5515
5516
|
);
|
|
5516
5517
|
const providedStepIds = new Set(steps.map((step) => step.id));
|
|
5517
5518
|
if (canonicalStepIds.size !== providedStepIds.size || [...canonicalStepIds].some((stepId) => !providedStepIds.has(stepId))) {
|
|
@@ -5522,7 +5523,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5522
5523
|
stepIds: [...canonicalStepIds],
|
|
5523
5524
|
completedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5524
5525
|
};
|
|
5525
|
-
const written = await this.kvForSpace(this.ownedSpaceId(
|
|
5526
|
+
const written = await this.kvForSpace(this.ownedSpaceId(import_sdk_core12.ACCOUNT_REGISTRY_SPACE)).put(
|
|
5526
5527
|
BOOTSTRAP_COMPLETION_MARKER_KEY,
|
|
5527
5528
|
marker
|
|
5528
5529
|
);
|
|
@@ -5569,7 +5570,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5569
5570
|
const warnings = [];
|
|
5570
5571
|
const primarySession = auth.tinyCloudSession;
|
|
5571
5572
|
const defaultSpaceId = this.ownedSpaceId("default");
|
|
5572
|
-
const canReusePrimaryBootstrapSession = primarySession?.spaceId === defaultSpaceId && auth.capabilityRequest ===
|
|
5573
|
+
const canReusePrimaryBootstrapSession = primarySession?.spaceId === defaultSpaceId && auth.capabilityRequest === import_sdk_core12.BOOTSTRAP_SESSION_REQUESTS.default;
|
|
5573
5574
|
for (const step of steps) {
|
|
5574
5575
|
if (step.kind === "host") await this.assertMayCreateSpace(step.spaceId);
|
|
5575
5576
|
}
|
|
@@ -5588,7 +5589,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5588
5589
|
try {
|
|
5589
5590
|
session = await auth.createBootstrapSession({
|
|
5590
5591
|
spaceId: step.spaceId,
|
|
5591
|
-
capabilityRequest: step.request ??
|
|
5592
|
+
capabilityRequest: step.request ?? import_sdk_core12.BOOTSTRAP_SESSION_REQUESTS[step.space],
|
|
5592
5593
|
rawAbilities
|
|
5593
5594
|
});
|
|
5594
5595
|
} catch (err2) {
|
|
@@ -5625,7 +5626,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5625
5626
|
for (const destination of destinations) {
|
|
5626
5627
|
try {
|
|
5627
5628
|
await (0, import_sdk_services5.verifyResourceDestination)(destination, globalThis.fetch.bind(globalThis));
|
|
5628
|
-
const result = await (0,
|
|
5629
|
+
const result = await (0, import_sdk_core12.activateSessionWithHost)(destination.url, session.delegationHeader, graph.signal);
|
|
5629
5630
|
if (!result.success) throw Object.assign(new Error("Bootstrap activation failed"), { cause: result });
|
|
5630
5631
|
activated = result;
|
|
5631
5632
|
} catch (error) {
|
|
@@ -5645,7 +5646,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5645
5646
|
}
|
|
5646
5647
|
this.registerBootstrapRuntimeGrant(
|
|
5647
5648
|
session,
|
|
5648
|
-
|
|
5649
|
+
import_sdk_core12.BOOTSTRAP_SESSION_REQUESTS[step.space],
|
|
5649
5650
|
rawAbilitiesBySpace.get(step.space)
|
|
5650
5651
|
);
|
|
5651
5652
|
}
|
|
@@ -5695,7 +5696,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5695
5696
|
}
|
|
5696
5697
|
if (step.kind === "seed-applications") {
|
|
5697
5698
|
const registered = await this.account.applications.register(
|
|
5698
|
-
step.manifests.length > 0 ? [...step.manifests] :
|
|
5699
|
+
step.manifests.length > 0 ? [...step.manifests] : import_sdk_core12.TINYCLOUD_SECRETS_BOOTSTRAP_MANIFEST,
|
|
5699
5700
|
// The write is an INSERT OR REPLACE and is safe to repeat during a
|
|
5700
5701
|
// repair, so skip the manifest-hash pre-read.
|
|
5701
5702
|
{ assumeUnregistered: true }
|
|
@@ -5715,7 +5716,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5715
5716
|
migrations: [
|
|
5716
5717
|
{
|
|
5717
5718
|
id: "001_initial",
|
|
5718
|
-
sql: [...
|
|
5719
|
+
sql: [...import_sdk_core12.SECRET_RECORDS_SCHEMA]
|
|
5719
5720
|
}
|
|
5720
5721
|
]
|
|
5721
5722
|
});
|
|
@@ -5890,7 +5891,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5890
5891
|
if (!this.auth || !this.signer) {
|
|
5891
5892
|
throw new Error("Manifest registry write requires wallet mode");
|
|
5892
5893
|
}
|
|
5893
|
-
const accountSpaceId = this.ownedSpaceId(
|
|
5894
|
+
const accountSpaceId = this.ownedSpaceId(import_sdk_core12.ACCOUNT_REGISTRY_SPACE);
|
|
5894
5895
|
await this.ensureOwnedSpaceHostedById(accountSpaceId, signal);
|
|
5895
5896
|
if (signal.aborted) throw signal.reason;
|
|
5896
5897
|
const result = await account.applications.register(request.manifests);
|
|
@@ -5905,7 +5906,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5905
5906
|
const session = context.session;
|
|
5906
5907
|
if (!session) throw new Error("Account registry requires an active service session");
|
|
5907
5908
|
const contexts = [context];
|
|
5908
|
-
const accountSpaceId = this.ownedSpaceId(
|
|
5909
|
+
const accountSpaceId = this.ownedSpaceId(import_sdk_core12.ACCOUNT_REGISTRY_SPACE);
|
|
5909
5910
|
const createScopedContext = (spaceId) => {
|
|
5910
5911
|
const scoped = this._serviceGraph.track(createServiceContext({
|
|
5911
5912
|
requestSink: this._serviceGraph.requestSink,
|
|
@@ -5921,10 +5922,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5921
5922
|
contexts.push(scoped);
|
|
5922
5923
|
return scoped;
|
|
5923
5924
|
};
|
|
5924
|
-
const sql = new
|
|
5925
|
+
const sql = new import_sdk_core12.SQLService({});
|
|
5925
5926
|
const sqlContext = createScopedContext(accountSpaceId);
|
|
5926
5927
|
sql.initialize(sqlContext);
|
|
5927
|
-
const spaces = new
|
|
5928
|
+
const spaces = new import_sdk_core12.SpaceService({
|
|
5928
5929
|
hosts: context.hosts,
|
|
5929
5930
|
session,
|
|
5930
5931
|
invoke: context.invoke,
|
|
@@ -5934,14 +5935,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5934
5935
|
}),
|
|
5935
5936
|
userDid: this.did,
|
|
5936
5937
|
createKVService: (spaceId) => {
|
|
5937
|
-
const kv = new
|
|
5938
|
+
const kv = new import_sdk_core12.KVService({});
|
|
5938
5939
|
kv.initialize(createScopedContext(spaceId));
|
|
5939
5940
|
return kv;
|
|
5940
5941
|
}
|
|
5941
5942
|
});
|
|
5942
5943
|
return {
|
|
5943
5944
|
contexts,
|
|
5944
|
-
account: new
|
|
5945
|
+
account: new import_sdk_core8.AccountService({
|
|
5945
5946
|
getDid: () => this.did,
|
|
5946
5947
|
getHost: () => context.hosts[0] ?? this.config.host,
|
|
5947
5948
|
getPrimarySpaceId: () => session.spaceId,
|
|
@@ -6097,7 +6098,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6097
6098
|
return true;
|
|
6098
6099
|
}
|
|
6099
6100
|
const indexRead = {
|
|
6100
|
-
spaceId: this.ownedSpaceId(
|
|
6101
|
+
spaceId: this.ownedSpaceId(import_sdk_core12.ACCOUNT_REGISTRY_SPACE),
|
|
6101
6102
|
service: "sql",
|
|
6102
6103
|
path: "account",
|
|
6103
6104
|
action: "tinycloud.sql/read"
|
|
@@ -6125,7 +6126,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6125
6126
|
stopped(error);
|
|
6126
6127
|
return;
|
|
6127
6128
|
}
|
|
6128
|
-
const verdict = (0,
|
|
6129
|
+
const verdict = (0, import_sdk_core12.authorizationVerdictOf)(error);
|
|
6129
6130
|
const message = error instanceof Error ? error.message : String(error);
|
|
6130
6131
|
const isAuthorizationVerdict = verdict === void 0 ? /^(?:Unauthorized Action\b|(?:(?:request failed|HTTP request failed|status(?: code)?|response status)\s*:\s*)?(?:HTTP\s*)?(?:401|403)\b)/i.test(message) : verdict !== "other";
|
|
6131
6132
|
if (isAuthorizationVerdict) {
|
|
@@ -6135,7 +6136,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6135
6136
|
);
|
|
6136
6137
|
return;
|
|
6137
6138
|
}
|
|
6138
|
-
if ((0,
|
|
6139
|
+
if ((0, import_sdk_core12.isStorageFullError)(error) || (0, import_sdk_core12.isStorageFullError)(error?.cause) || message.includes(import_sdk_core12.STORAGE_FULL_MESSAGE) || message.includes(import_sdk_core12.STORAGE_WRITE_TOO_LARGE_MESSAGE)) {
|
|
6139
6140
|
console.warn(
|
|
6140
6141
|
"TinyCloud account registry sync stopped: storage is full",
|
|
6141
6142
|
error
|
|
@@ -6173,8 +6174,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6173
6174
|
}
|
|
6174
6175
|
const networkIds = /* @__PURE__ */ new Set();
|
|
6175
6176
|
for (const resource of request.resources) {
|
|
6176
|
-
if (resource.service ===
|
|
6177
|
-
const parsed = resource.path.includes("/") ? (0, import_resource2.parseEncryptionResource)(resource.path) : { ...(0,
|
|
6177
|
+
if (resource.service === import_sdk_core12.ENCRYPTION_PERMISSION_SERVICE && resource.path.startsWith("urn:tinycloud:encryption:") && resource.actions.includes(DECRYPT_ACTION2)) {
|
|
6178
|
+
const parsed = resource.path.includes("/") ? (0, import_resource2.parseEncryptionResource)(resource.path) : { ...(0, import_sdk_core12.parseNetworkId)(resource.path), kind: "network" };
|
|
6178
6179
|
if (parsed.kind === "network") networkIds.add(resource.path);
|
|
6179
6180
|
}
|
|
6180
6181
|
}
|
|
@@ -6185,7 +6186,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6185
6186
|
return;
|
|
6186
6187
|
}
|
|
6187
6188
|
for (const networkId of this.requestedEncryptionNetworkIds()) {
|
|
6188
|
-
const parsed = (0,
|
|
6189
|
+
const parsed = (0, import_sdk_core12.parseNetworkId)(networkId);
|
|
6189
6190
|
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
6190
6191
|
continue;
|
|
6191
6192
|
}
|
|
@@ -6230,7 +6231,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6230
6231
|
if (!host) {
|
|
6231
6232
|
throw new Error("Owned space hosting requires a TinyCloud host");
|
|
6232
6233
|
}
|
|
6233
|
-
const activation = await (0,
|
|
6234
|
+
const activation = await (0, import_sdk_core12.activateSessionWithHost)(host, session.delegationHeader, signal);
|
|
6234
6235
|
if (activation.success && !activation.skipped?.includes(spaceId)) {
|
|
6235
6236
|
this.confirmedHostedSpaceIds.add(spaceId);
|
|
6236
6237
|
return;
|
|
@@ -6251,7 +6252,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6251
6252
|
);
|
|
6252
6253
|
}
|
|
6253
6254
|
if (signal?.aborted) throw signal.reason;
|
|
6254
|
-
const retry = await (0,
|
|
6255
|
+
const retry = await (0, import_sdk_core12.activateSessionWithHost)(host, session.delegationHeader, signal);
|
|
6255
6256
|
if (!retry.success || retry.skipped?.includes(spaceId)) {
|
|
6256
6257
|
throw Object.assign(
|
|
6257
6258
|
new Error(
|
|
@@ -6303,7 +6304,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6303
6304
|
);
|
|
6304
6305
|
}
|
|
6305
6306
|
if (!this.auth.registryRecordPresent) {
|
|
6306
|
-
const activation = await (0,
|
|
6307
|
+
const activation = await (0, import_sdk_core12.activateSessionWithHost)(
|
|
6307
6308
|
host,
|
|
6308
6309
|
session.delegationHeader
|
|
6309
6310
|
);
|
|
@@ -6555,7 +6556,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6555
6556
|
}
|
|
6556
6557
|
let restoredAddress;
|
|
6557
6558
|
try {
|
|
6558
|
-
restoredAddress = hasPersistedProof ? (0,
|
|
6559
|
+
restoredAddress = hasPersistedProof ? (0, import_sdk_core12.canonicalizeAddress)(sessionData.address) : void 0;
|
|
6559
6560
|
} catch {
|
|
6560
6561
|
throw new InvalidRestoredSessionError("Persisted session has an invalid wallet address.");
|
|
6561
6562
|
}
|
|
@@ -6590,14 +6591,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6590
6591
|
stagedSessionExpiry = signedExpiry ?? persistedPolicyExpiry ?? persistedExpiry(void 0);
|
|
6591
6592
|
}
|
|
6592
6593
|
const restoreHints = this.explicitHost ? [this.explicitHost] : sessionData.tinycloudHosts ?? [];
|
|
6593
|
-
const stagedHost = (0,
|
|
6594
|
+
const stagedHost = (0, import_sdk_core12.exactHttpOrigin)(restoreHints[0] ?? this.config.host, "restored host hint");
|
|
6594
6595
|
let restoredNodeFeatures;
|
|
6595
6596
|
let replicaProtocolMismatch = false;
|
|
6596
6597
|
if (this.config.replication?.enabled) {
|
|
6597
6598
|
try {
|
|
6598
|
-
restoredNodeFeatures = (await (0,
|
|
6599
|
+
restoredNodeFeatures = (await (0, import_sdk_core12.checkNodeInfo)(stagedHost, this.wasmBindings.protocolVersion())).features;
|
|
6599
6600
|
} catch (error) {
|
|
6600
|
-
replicaProtocolMismatch = error instanceof
|
|
6601
|
+
replicaProtocolMismatch = error instanceof import_sdk_core12.ProtocolMismatchError;
|
|
6601
6602
|
}
|
|
6602
6603
|
}
|
|
6603
6604
|
const stagedAddress = restoredAddress;
|
|
@@ -6608,7 +6609,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6608
6609
|
let replicationScopeUnavailable = false;
|
|
6609
6610
|
if (this.config.replication?.enabled) {
|
|
6610
6611
|
if (stagedAddress !== void 0) {
|
|
6611
|
-
replicationPrincipal = (0,
|
|
6612
|
+
replicationPrincipal = (0, import_sdk_core12.pkhDid)(stagedAddress, stagedChainId);
|
|
6612
6613
|
} else {
|
|
6613
6614
|
try {
|
|
6614
6615
|
const { replicationScopeFromSignedSession } = await getNodeReplicationLoaders().authority();
|
|
@@ -6657,7 +6658,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6657
6658
|
}
|
|
6658
6659
|
}
|
|
6659
6660
|
}
|
|
6660
|
-
const stagedNodeDid = stagedAddress ? (0,
|
|
6661
|
+
const stagedNodeDid = stagedAddress ? (0, import_sdk_core12.pkhDid)(stagedAddress, stagedChainId) : canonicalVerificationMethod;
|
|
6661
6662
|
const serviceSession = {
|
|
6662
6663
|
delegationHeader: sessionData.delegationHeader,
|
|
6663
6664
|
delegationCid: sessionData.delegationCid,
|
|
@@ -6685,7 +6686,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6685
6686
|
stagedSessionExpiry,
|
|
6686
6687
|
stagedRecap
|
|
6687
6688
|
);
|
|
6688
|
-
const stagedAccountSpaceId = stagedAddress ? this.wasmBindings.makeSpaceId(stagedAddress, stagedChainId,
|
|
6689
|
+
const stagedAccountSpaceId = stagedAddress ? this.wasmBindings.makeSpaceId(stagedAddress, stagedChainId, import_sdk_core12.ACCOUNT_REGISTRY_SPACE) : void 0;
|
|
6689
6690
|
const stagedGraph = this.stageRestoredServiceGraph({
|
|
6690
6691
|
host: stagedHost,
|
|
6691
6692
|
manager: stagedManager,
|
|
@@ -6775,7 +6776,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6775
6776
|
this.assertSessionEpoch(epoch, "Session restore");
|
|
6776
6777
|
}
|
|
6777
6778
|
if (this.config.replication?.enabled) {
|
|
6778
|
-
if (stagedAddress !== void 0) this.refreshRegistryOwner((0,
|
|
6779
|
+
if (stagedAddress !== void 0) this.refreshRegistryOwner((0, import_sdk_core12.pkhDid)(stagedAddress, stagedChainId));
|
|
6779
6780
|
this.refreshRegistryForCapabilities(this.getVerifiedSessionCapabilities());
|
|
6780
6781
|
}
|
|
6781
6782
|
}
|
|
@@ -6827,7 +6828,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6827
6828
|
}
|
|
6828
6829
|
stageRestoredServiceGraph(input) {
|
|
6829
6830
|
const graph = this.createServiceGraphLifetime(input.serviceSession);
|
|
6830
|
-
const core = this.auth ? new
|
|
6831
|
+
const core = this.auth ? new import_sdk_core12.TinyCloud(this.auth, {
|
|
6831
6832
|
invokeAny: graph.invokeAny,
|
|
6832
6833
|
telemetry: this.config.telemetry,
|
|
6833
6834
|
retryPolicy: this.config.retryPolicy
|
|
@@ -6846,16 +6847,16 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6846
6847
|
telemetry: this.config.telemetry,
|
|
6847
6848
|
retryPolicy: this.config.retryPolicy
|
|
6848
6849
|
}));
|
|
6849
|
-
const kv = new
|
|
6850
|
+
const kv = new import_sdk_core12.KVService({});
|
|
6850
6851
|
kv.initialize(serviceContext);
|
|
6851
6852
|
serviceContext.registerService("kv", kv);
|
|
6852
|
-
const sql = new
|
|
6853
|
+
const sql = new import_sdk_core12.SQLService({});
|
|
6853
6854
|
sql.initialize(serviceContext);
|
|
6854
6855
|
serviceContext.registerService("sql", sql);
|
|
6855
|
-
const duckdb = new
|
|
6856
|
+
const duckdb = new import_sdk_core12.DuckDbService({});
|
|
6856
6857
|
duckdb.initialize(serviceContext);
|
|
6857
6858
|
serviceContext.registerService("duckdb", duckdb);
|
|
6858
|
-
const hooks = new
|
|
6859
|
+
const hooks = new import_sdk_core12.HooksService({});
|
|
6859
6860
|
hooks.initialize(serviceContext);
|
|
6860
6861
|
serviceContext.registerService("hooks", hooks);
|
|
6861
6862
|
serviceContext.setSession(input.serviceSession);
|
|
@@ -6878,7 +6879,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6878
6879
|
});
|
|
6879
6880
|
vault.initialize(serviceContext);
|
|
6880
6881
|
serviceContext.registerService("vault", vault);
|
|
6881
|
-
const capabilityRegistry = new
|
|
6882
|
+
const capabilityRegistry = new import_sdk_core12.CapabilityKeyRegistry();
|
|
6882
6883
|
if (input.tinyCloudSession) {
|
|
6883
6884
|
const session = input.tinyCloudSession;
|
|
6884
6885
|
const delegations = input.recap.map((entry) => ({
|
|
@@ -6902,7 +6903,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6902
6903
|
}, delegations);
|
|
6903
6904
|
}
|
|
6904
6905
|
}
|
|
6905
|
-
const delegationManager = new
|
|
6906
|
+
const delegationManager = new import_sdk_core12.DelegationManager({
|
|
6906
6907
|
hosts: [input.host],
|
|
6907
6908
|
accountSpaceId: input.accountSpaceId,
|
|
6908
6909
|
session: input.serviceSession,
|
|
@@ -6913,7 +6914,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6913
6914
|
fetch: graph.fetch
|
|
6914
6915
|
});
|
|
6915
6916
|
const keyProvider = new WasmKeyProvider({ sessionManager: input.manager });
|
|
6916
|
-
const sharingService = new
|
|
6917
|
+
const sharingService = new import_sdk_core12.SharingService({
|
|
6917
6918
|
hosts: [input.host],
|
|
6918
6919
|
invoke: graph.invoke,
|
|
6919
6920
|
fetch: graph.fetch,
|
|
@@ -6926,7 +6927,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6926
6927
|
return this.wasmBindings.computeCid(data, codec);
|
|
6927
6928
|
},
|
|
6928
6929
|
createKVService: (config) => {
|
|
6929
|
-
const service = new
|
|
6930
|
+
const service = new import_sdk_core12.KVService({ prefix: config.pathPrefix?.replace(/\/$/, "") });
|
|
6930
6931
|
const context = graph.track(createServiceContext({
|
|
6931
6932
|
requestSink: graph.requestSink,
|
|
6932
6933
|
invoke: config.invoke,
|
|
@@ -6958,7 +6959,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6958
6959
|
return delegation;
|
|
6959
6960
|
} : void 0
|
|
6960
6961
|
});
|
|
6961
|
-
const spaceService = new
|
|
6962
|
+
const spaceService = new import_sdk_core12.SpaceService({
|
|
6962
6963
|
hosts: [input.host],
|
|
6963
6964
|
session: input.serviceSession,
|
|
6964
6965
|
invoke: graph.invoke,
|
|
@@ -6967,7 +6968,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6967
6968
|
userDid: input.nodeDid,
|
|
6968
6969
|
createKVService: (spaceId) => {
|
|
6969
6970
|
graph.assertActive();
|
|
6970
|
-
const scopedKv = new
|
|
6971
|
+
const scopedKv = new import_sdk_core12.KVService({});
|
|
6971
6972
|
const context = graph.track(createServiceContext({
|
|
6972
6973
|
requestSink: graph.requestSink,
|
|
6973
6974
|
invoke: graph.invoke,
|
|
@@ -6984,7 +6985,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6984
6985
|
},
|
|
6985
6986
|
createVaultService: (spaceId) => {
|
|
6986
6987
|
graph.assertActive();
|
|
6987
|
-
const scopedKv = new
|
|
6988
|
+
const scopedKv = new import_sdk_core12.KVService({});
|
|
6988
6989
|
const context = graph.track(createServiceContext({
|
|
6989
6990
|
requestSink: graph.requestSink,
|
|
6990
6991
|
invoke: graph.invoke,
|
|
@@ -7085,7 +7086,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7085
7086
|
did: () => session.verificationMethod.split("#", 1)[0],
|
|
7086
7087
|
sign: async (attenuation) => {
|
|
7087
7088
|
const now = Math.floor(Date.now() / 1e3);
|
|
7088
|
-
const invocation = await (0,
|
|
7089
|
+
const invocation = await (0, import_sdk_core12.signCompactUcanAuthorization)({
|
|
7089
7090
|
issuerDid: session.verificationMethod.split("#", 1)[0],
|
|
7090
7091
|
audienceDid: await this.fetchNodeId(),
|
|
7091
7092
|
attenuation,
|
|
@@ -7117,7 +7118,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7117
7118
|
nodeAudience: input.nodeAudience,
|
|
7118
7119
|
...input.role === "policy-enforcement" ? { enforcerDid: input.audienceDid } : {}
|
|
7119
7120
|
};
|
|
7120
|
-
const root = await (0,
|
|
7121
|
+
const root = await (0, import_sdk_core12.signCompactUcanRootAuthorization)({
|
|
7121
7122
|
issuerDid: ownerDid,
|
|
7122
7123
|
audienceDid: input.audienceDid,
|
|
7123
7124
|
attenuation: unifiedRootAttenuation(input.capabilities),
|
|
@@ -7159,7 +7160,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7159
7160
|
if (decision.needsApproval) return void 0;
|
|
7160
7161
|
throw new Error(decision.reason ?? "OpenKey automatic credential signing was rejected");
|
|
7161
7162
|
}
|
|
7162
|
-
if (typeof decision.signature !== "string" || !await (0,
|
|
7163
|
+
if (typeof decision.signature !== "string" || !await (0, import_sdk_core12.verifyEip191MessageSignature)(
|
|
7163
7164
|
request.message,
|
|
7164
7165
|
decision.signature,
|
|
7165
7166
|
request.address
|
|
@@ -7184,7 +7185,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7184
7185
|
if (approval) {
|
|
7185
7186
|
const decision = await approval(request);
|
|
7186
7187
|
if (!decision.approved) throw new Error(decision.reason ?? "Credential signing was rejected");
|
|
7187
|
-
if (decision.signature !== void 0 && !await (0,
|
|
7188
|
+
if (decision.signature !== void 0 && !await (0, import_sdk_core12.verifyEip191MessageSignature)(
|
|
7188
7189
|
request.message,
|
|
7189
7190
|
decision.signature,
|
|
7190
7191
|
request.address
|
|
@@ -7276,7 +7277,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7276
7277
|
nonce: this.config.nonce,
|
|
7277
7278
|
siweConfig: this.config.siweConfig,
|
|
7278
7279
|
manifest: useBootstrapSignInRequest ? void 0 : this.config.manifest,
|
|
7279
|
-
capabilityRequest: useBootstrapSignInRequest ? this.config.includeAccountRegistryPermissions === false ?
|
|
7280
|
+
capabilityRequest: useBootstrapSignInRequest ? this.config.includeAccountRegistryPermissions === false ? import_sdk_core12.BOOTSTRAP_DEFAULT_ONLY_SESSION_REQUEST : import_sdk_core12.BOOTSTRAP_SESSION_REQUESTS.default : this.config.capabilityRequest,
|
|
7280
7281
|
includeAccountRegistryPermissions: useBootstrapSignInRequest ? false : this.config.includeAccountRegistryPermissions,
|
|
7281
7282
|
replication: this.config.replication?.enabled === true ? {
|
|
7282
7283
|
enabled: true,
|
|
@@ -7285,7 +7286,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7285
7286
|
syncScope: this.config.replication.syncScope
|
|
7286
7287
|
} : void 0
|
|
7287
7288
|
});
|
|
7288
|
-
this.tc = new
|
|
7289
|
+
this.tc = new import_sdk_core12.TinyCloud(this.auth, {
|
|
7289
7290
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
7290
7291
|
telemetry: this.config.telemetry,
|
|
7291
7292
|
retryPolicy: this.config.retryPolicy
|
|
@@ -7339,7 +7340,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7339
7340
|
nonce: this.config.nonce,
|
|
7340
7341
|
siweConfig: this.config.siweConfig,
|
|
7341
7342
|
manifest: useBootstrapSignInRequest ? void 0 : this.config.manifest,
|
|
7342
|
-
capabilityRequest: useBootstrapSignInRequest ? this.config.includeAccountRegistryPermissions === false ?
|
|
7343
|
+
capabilityRequest: useBootstrapSignInRequest ? this.config.includeAccountRegistryPermissions === false ? import_sdk_core12.BOOTSTRAP_DEFAULT_ONLY_SESSION_REQUEST : import_sdk_core12.BOOTSTRAP_SESSION_REQUESTS.default : this.config.capabilityRequest,
|
|
7343
7344
|
includeAccountRegistryPermissions: useBootstrapSignInRequest ? false : this.config.includeAccountRegistryPermissions,
|
|
7344
7345
|
replication: this.config.replication?.enabled === true ? {
|
|
7345
7346
|
enabled: true,
|
|
@@ -7348,7 +7349,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7348
7349
|
syncScope: this.config.replication.syncScope
|
|
7349
7350
|
} : void 0
|
|
7350
7351
|
});
|
|
7351
|
-
this.tc = new
|
|
7352
|
+
this.tc = new import_sdk_core12.TinyCloud(this.auth, {
|
|
7352
7353
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
7353
7354
|
telemetry: this.config.telemetry,
|
|
7354
7355
|
retryPolicy: this.config.retryPolicy
|
|
@@ -7379,21 +7380,21 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7379
7380
|
telemetry: this.config.telemetry,
|
|
7380
7381
|
retryPolicy: this.config.retryPolicy
|
|
7381
7382
|
}));
|
|
7382
|
-
this._kv = new
|
|
7383
|
+
this._kv = new import_sdk_core12.KVService({});
|
|
7383
7384
|
this._kv.initialize(this._serviceContext);
|
|
7384
7385
|
this._serviceContext.registerService("kv", this._kv);
|
|
7385
7386
|
const features = this.nodeFeatures;
|
|
7386
7387
|
if (features.length === 0 || features.includes("sql")) {
|
|
7387
|
-
this._sql = new
|
|
7388
|
+
this._sql = new import_sdk_core12.SQLService({});
|
|
7388
7389
|
this._sql.initialize(this._serviceContext);
|
|
7389
7390
|
this._serviceContext.registerService("sql", this._sql);
|
|
7390
7391
|
}
|
|
7391
7392
|
if (features.length === 0 || features.includes("duckdb")) {
|
|
7392
|
-
this._duckdb = new
|
|
7393
|
+
this._duckdb = new import_sdk_core12.DuckDbService({});
|
|
7393
7394
|
this._duckdb.initialize(this._serviceContext);
|
|
7394
7395
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
7395
7396
|
}
|
|
7396
|
-
this._hooks = new
|
|
7397
|
+
this._hooks = new import_sdk_core12.HooksService({});
|
|
7397
7398
|
this._hooks.initialize(this._serviceContext);
|
|
7398
7399
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
7399
7400
|
const serviceSession = {
|
|
@@ -7417,7 +7418,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7417
7418
|
kvService.setReadThroughReady(attached);
|
|
7418
7419
|
}
|
|
7419
7420
|
createSpaceScopedKVService(spaceId) {
|
|
7420
|
-
const kvService = new
|
|
7421
|
+
const kvService = new import_sdk_core12.KVService({});
|
|
7421
7422
|
if (this._serviceContext) {
|
|
7422
7423
|
const spaceScopedContext = this._serviceGraph.track(createServiceContext({
|
|
7423
7424
|
requestSink: this._serviceGraph.requestSink,
|
|
@@ -7514,7 +7515,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7514
7515
|
const shared = wasm.vault_x25519_dh(receiverPrivateKey, peerPublic);
|
|
7515
7516
|
return columnDecrypt(shared, ciphertext);
|
|
7516
7517
|
},
|
|
7517
|
-
verifyNodeSignature: (nodeId, message, signature) => (0,
|
|
7518
|
+
verifyNodeSignature: (nodeId, message, signature) => (0, import_sdk_core12.verifyDidKeyEd25519Signature)(nodeId, message, signature)
|
|
7518
7519
|
};
|
|
7519
7520
|
}
|
|
7520
7521
|
/**
|
|
@@ -7530,7 +7531,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7530
7531
|
if (cached) return cached;
|
|
7531
7532
|
const response = await fetch(`${host}/info`);
|
|
7532
7533
|
if (!response.ok) {
|
|
7533
|
-
throw await (0,
|
|
7534
|
+
throw await (0, import_sdk_core12.httpResponseError)(response, "Failed to fetch node info");
|
|
7534
7535
|
}
|
|
7535
7536
|
const info = await response.json();
|
|
7536
7537
|
if (typeof info.nodeId !== "string" || info.nodeId.length === 0) {
|
|
@@ -7596,7 +7597,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7596
7597
|
}
|
|
7597
7598
|
if (response.status === 404) return null;
|
|
7598
7599
|
if (!response.ok) {
|
|
7599
|
-
throw await (0,
|
|
7600
|
+
throw await (0, import_sdk_core12.httpResponseError)(response, `Failed to fetch encryption network ${networkId}`);
|
|
7600
7601
|
}
|
|
7601
7602
|
const body = await response.json();
|
|
7602
7603
|
return "descriptor" in body && body.descriptor ? body.descriptor : body;
|
|
@@ -7632,7 +7633,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7632
7633
|
path: networkId,
|
|
7633
7634
|
actions: ["tinycloud.encryption/decrypt"]
|
|
7634
7635
|
}) : void 0;
|
|
7635
|
-
throw new
|
|
7636
|
+
throw new import_sdk_core12.DecryptTransportResponseError(
|
|
7636
7637
|
response.status,
|
|
7637
7638
|
permissionHint,
|
|
7638
7639
|
response.status === 404 && networkId === this.getDefaultEncryptionNetworkId() && await response.text().catch(() => "") === "network not found" ? `Network not found: ${networkId}. Sign in again with a current SDK to create the account's encryption network.` : void 0
|
|
@@ -7641,7 +7642,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7641
7642
|
return await response.json();
|
|
7642
7643
|
}
|
|
7643
7644
|
};
|
|
7644
|
-
return new
|
|
7645
|
+
return new import_sdk_core12.EncryptionService({
|
|
7645
7646
|
resolveTargetNode: async (networkId) => (await this.encryptionDestination(networkId)).nodeDid,
|
|
7646
7647
|
crypto: crypto2,
|
|
7647
7648
|
signer: {
|
|
@@ -7656,7 +7657,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7656
7657
|
graph.assertActive();
|
|
7657
7658
|
return {
|
|
7658
7659
|
...signed,
|
|
7659
|
-
canonicalBody: (0,
|
|
7660
|
+
canonicalBody: (0, import_sdk_core12.canonicalizeEncryptionJson)(
|
|
7660
7661
|
input.body
|
|
7661
7662
|
)
|
|
7662
7663
|
};
|
|
@@ -7680,7 +7681,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7680
7681
|
if (!address || !didPrincipalMatches2(principal, did)) {
|
|
7681
7682
|
return null;
|
|
7682
7683
|
}
|
|
7683
|
-
const publicSpaceId = (0,
|
|
7684
|
+
const publicSpaceId = (0, import_sdk_core12.makePublicSpaceId)(address, chainId);
|
|
7684
7685
|
const encodedKey = discoveryKey.split("/").map(encodeURIComponent).join("/");
|
|
7685
7686
|
const response = await graph.fetch(
|
|
7686
7687
|
`${destination.url}/public/${encodeURIComponent(publicSpaceId)}/kv/${encodedKey}`,
|
|
@@ -7712,7 +7713,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7712
7713
|
createVaultService(spaceId, kv, encryptionService = this.getEncryptionService(), nodeContext) {
|
|
7713
7714
|
const wasm = this.wasmBindings;
|
|
7714
7715
|
const serviceGraph = nodeContext?.serviceGraph ?? this._serviceGraph;
|
|
7715
|
-
const vaultCrypto = (0,
|
|
7716
|
+
const vaultCrypto = (0, import_sdk_core12.createVaultCrypto)({
|
|
7716
7717
|
vault_encrypt: wasm.vault_encrypt,
|
|
7717
7718
|
vault_decrypt: wasm.vault_decrypt,
|
|
7718
7719
|
vault_derive_key: wasm.vault_derive_key,
|
|
@@ -7727,7 +7728,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7727
7728
|
const chainId = nodeContext?.chainId ?? this._chainId;
|
|
7728
7729
|
const host = nodeContext?.host ?? this.config.host;
|
|
7729
7730
|
const ownerDid = this.ownerDidFromSpaceId(spaceId) ?? did;
|
|
7730
|
-
return new
|
|
7731
|
+
return new import_sdk_core12.DataVaultService({
|
|
7731
7732
|
spaceId,
|
|
7732
7733
|
crypto: vaultCrypto,
|
|
7733
7734
|
encryption: {
|
|
@@ -7752,8 +7753,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7752
7753
|
serviceGraph.assertActive();
|
|
7753
7754
|
return self._publicKV ?? self.tc.publicKV;
|
|
7754
7755
|
},
|
|
7755
|
-
readPublicSpace: (host2, targetSpaceId, key) =>
|
|
7756
|
-
makePublicSpaceId:
|
|
7756
|
+
readPublicSpace: (host2, targetSpaceId, key) => import_sdk_core12.TinyCloud.readPublicSpace(host2, targetSpaceId, key),
|
|
7757
|
+
makePublicSpaceId: import_sdk_core12.TinyCloud.makePublicSpaceId,
|
|
7757
7758
|
did,
|
|
7758
7759
|
address: address ?? "",
|
|
7759
7760
|
chainId,
|
|
@@ -7767,7 +7768,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7767
7768
|
*/
|
|
7768
7769
|
initializeV2Services(serviceSession) {
|
|
7769
7770
|
const graph = this._serviceGraph;
|
|
7770
|
-
this._capabilityRegistry = new
|
|
7771
|
+
this._capabilityRegistry = new import_sdk_core12.CapabilityKeyRegistry();
|
|
7771
7772
|
const tcSession = this.auth?.tinyCloudSession;
|
|
7772
7773
|
if (tcSession && this._address) {
|
|
7773
7774
|
const sessionKey = {
|
|
@@ -7807,7 +7808,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7807
7808
|
}
|
|
7808
7809
|
this._capabilityRegistry.registerKey(sessionKey, delegations);
|
|
7809
7810
|
}
|
|
7810
|
-
this._delegationManager = new
|
|
7811
|
+
this._delegationManager = new import_sdk_core12.DelegationManager({
|
|
7811
7812
|
hosts: [this.config.host],
|
|
7812
7813
|
accountSpaceId: this.accountSpaceId,
|
|
7813
7814
|
session: serviceSession,
|
|
@@ -7817,7 +7818,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7817
7818
|
sessionInvocationSigner: this.sessionInvocationSignerFor(serviceSession),
|
|
7818
7819
|
fetch: graph.fetch
|
|
7819
7820
|
});
|
|
7820
|
-
this._spaceService = new
|
|
7821
|
+
this._spaceService = new import_sdk_core12.SpaceService({
|
|
7821
7822
|
hosts: [this.config.host],
|
|
7822
7823
|
session: serviceSession,
|
|
7823
7824
|
invoke: graph.invoke,
|
|
@@ -7883,7 +7884,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7883
7884
|
},
|
|
7884
7885
|
isStorageFull: () => this.ownStorageFull
|
|
7885
7886
|
});
|
|
7886
|
-
this._sharingService = new
|
|
7887
|
+
this._sharingService = new import_sdk_core12.SharingService({
|
|
7887
7888
|
hosts: [this.config.host],
|
|
7888
7889
|
session: serviceSession,
|
|
7889
7890
|
invoke: graph.invoke,
|
|
@@ -7902,7 +7903,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7902
7903
|
},
|
|
7903
7904
|
createKVService: (config) => {
|
|
7904
7905
|
graph.assertActive();
|
|
7905
|
-
const service = new
|
|
7906
|
+
const service = new import_sdk_core12.KVService({ prefix: config.pathPrefix?.replace(/\/$/, "") });
|
|
7906
7907
|
const context = graph.track(createServiceContext({
|
|
7907
7908
|
requestSink: graph.requestSink,
|
|
7908
7909
|
invoke: config.invoke,
|
|
@@ -7990,7 +7991,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7990
7991
|
// DID here and rejects the fragment as an invalid audience DID.
|
|
7991
7992
|
verificationMethod: params.session.verificationMethod.split("#", 1)[0]
|
|
7992
7993
|
};
|
|
7993
|
-
(0,
|
|
7994
|
+
(0, import_sdk_core12.assertExpiryWithinTechnicalLimit)(params.expirationSecs * 1e3, "ucan");
|
|
7994
7995
|
const result = this.wasmBindings.createDelegation(
|
|
7995
7996
|
wasmSession,
|
|
7996
7997
|
params.delegateDID,
|
|
@@ -8000,7 +8001,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8000
8001
|
params.notBeforeSecs
|
|
8001
8002
|
);
|
|
8002
8003
|
return {
|
|
8003
|
-
...terminal ? (0,
|
|
8004
|
+
...terminal ? (0, import_sdk_core12.markDelegationTerminal)(result.delegation, params.session.jwk) : { delegation: result.delegation, cid: result.cid },
|
|
8004
8005
|
// Rust serde `rename_all = "camelCase"` emits `delegateDid`
|
|
8005
8006
|
// (lowercase d); the TypeScript interface uses `delegateDID`
|
|
8006
8007
|
// (historical, matches Delegation.delegateDID). Normalize here.
|
|
@@ -8026,13 +8027,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8026
8027
|
if (!(params.expiresAt instanceof Date) || params.expiresAt.getTime() <= now.getTime()) {
|
|
8027
8028
|
throw new Error("Owner delegation expiry must be explicit, future, and a valid date");
|
|
8028
8029
|
}
|
|
8029
|
-
(0,
|
|
8030
|
+
(0, import_sdk_core12.assertExpiryWithinTechnicalLimit)(params.expiresAt, "siwe");
|
|
8030
8031
|
if (!this.signer) throw new Error("Owner wallet signer is required");
|
|
8031
8032
|
const session = this.currentTinyCloudSession();
|
|
8032
8033
|
if (!session) throw new Error("Owner session is required");
|
|
8033
|
-
const ownerDid = (0,
|
|
8034
|
+
const ownerDid = (0, import_sdk_core12.pkhDid)(session.address, session.chainId);
|
|
8034
8035
|
for (const permission of permissions) {
|
|
8035
|
-
if (permission.service ===
|
|
8036
|
+
if (permission.service === import_sdk_core12.ENCRYPTION_PERMISSION_SERVICE && !(0, import_sdk_core12.principalDidEquals)((0, import_sdk_core12.parseNetworkId)(permission.path).ownerDid, ownerDid)) {
|
|
8036
8037
|
throw new Error("Owner delegation cannot grant a foreign encryption network");
|
|
8037
8038
|
}
|
|
8038
8039
|
}
|
|
@@ -8114,7 +8115,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8114
8115
|
/** Register a signed policy and sibling roots with this Node's Policy/v3 runtime. */
|
|
8115
8116
|
async registerPolicy(params) {
|
|
8116
8117
|
this._serviceGraph.assertActive();
|
|
8117
|
-
return (0,
|
|
8118
|
+
return (0, import_sdk_core12.registerPolicyV3)({
|
|
8118
8119
|
...params,
|
|
8119
8120
|
nodeOrigin: this.config.host,
|
|
8120
8121
|
fetch: globalThis.fetch.bind(globalThis)
|
|
@@ -8127,8 +8128,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8127
8128
|
* not sent.
|
|
8128
8129
|
*/
|
|
8129
8130
|
async authorizeShareDeliveryV3(input) {
|
|
8130
|
-
(0,
|
|
8131
|
-
const envelopeRef = await (0,
|
|
8131
|
+
(0, import_sdk_core12.assertExpiryWithinTechnicalLimit)(new Date(input.expiresAt), "siwe");
|
|
8132
|
+
const envelopeRef = await (0, import_sdk_core12.shortDeliveryLinkBodyCid)(input.shareUrl, input.trustedOrigins);
|
|
8132
8133
|
const session = this.currentTinyCloudSession();
|
|
8133
8134
|
const serviceSession = this._serviceContext?.session;
|
|
8134
8135
|
if (!session || !serviceSession) throw new Error("Share delivery requires an authenticated session");
|
|
@@ -8145,21 +8146,21 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8145
8146
|
// Re-normalised through Date, so the sent value is always `YYYY-MM-DDTHH:mm:ss.SSSZ` (UTC, three digits).
|
|
8146
8147
|
expiresAt: new Date(input.expiresAt).toISOString()
|
|
8147
8148
|
};
|
|
8148
|
-
const requestBodyDigest = base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode((0,
|
|
8149
|
+
const requestBodyDigest = base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode((0, import_sdk_core12.canonicalizeEncryptionJson)(body)))));
|
|
8149
8150
|
const request = { ...body, requestBodyDigest };
|
|
8150
8151
|
const authorization = authorizationHeader(this.wasmBindings.invoke(serviceSession, "kv", input.resourcePath, "tinycloud.kv/get"));
|
|
8151
8152
|
const response = await fetch(`${this.config.host}/policy/v3/deliveries/authorize`, {
|
|
8152
8153
|
method: "POST",
|
|
8153
8154
|
headers: { accept: "application/json", "content-type": "application/json", authorization },
|
|
8154
|
-
body: (0,
|
|
8155
|
+
body: (0, import_sdk_core12.canonicalizeEncryptionJson)(request)
|
|
8155
8156
|
});
|
|
8156
|
-
if (response.status === 400 || response.status === 422) throw new
|
|
8157
|
+
if (response.status === 400 || response.status === 422) throw new import_sdk_core12.ShareDeliveryRefusedError();
|
|
8157
8158
|
if (!response.ok) {
|
|
8158
8159
|
const reply = await response.text().catch(() => response.statusText);
|
|
8159
|
-
const body2 = (await (0,
|
|
8160
|
+
const body2 = (await (0, import_sdk_core12.withoutShareLink)(reply, input.shareUrl)).trim().slice(0, 512);
|
|
8160
8161
|
throw Object.assign(new Error(`V3 share delivery authorization failed: HTTP ${response.status}${body2 ? ` - ${body2}` : ""}`), { status: response.status });
|
|
8161
8162
|
}
|
|
8162
|
-
const verified = await (0,
|
|
8163
|
+
const verified = await (0, import_sdk_core12.verifyShareDeliveryAuthorizationV3Bytes)(new Uint8Array(await response.arrayBuffer()), {
|
|
8163
8164
|
request,
|
|
8164
8165
|
envelope: input.envelope,
|
|
8165
8166
|
envelopeRef,
|
|
@@ -8168,7 +8169,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8168
8169
|
});
|
|
8169
8170
|
const requestDigest = new Uint8Array(await crypto.subtle.digest(
|
|
8170
8171
|
"SHA-256",
|
|
8171
|
-
new TextEncoder().encode(`${
|
|
8172
|
+
new TextEncoder().encode(`${import_sdk_core12.CREDENTIAL_INVITATION_REQUEST_DOMAIN}${(0, import_sdk_core12.canonicalizeEncryptionJson)(verified.request)}`)
|
|
8172
8173
|
));
|
|
8173
8174
|
return {
|
|
8174
8175
|
...verified,
|
|
@@ -8180,7 +8181,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8180
8181
|
};
|
|
8181
8182
|
}
|
|
8182
8183
|
async createRootDelegationForSharing(params, assertActive) {
|
|
8183
|
-
(0,
|
|
8184
|
+
(0, import_sdk_core12.assertExpiryWithinTechnicalLimit)(params.requestedExpiry, "siwe");
|
|
8184
8185
|
try {
|
|
8185
8186
|
return (await this.createOwnerDelegation({
|
|
8186
8187
|
delegateDid: params.shareKeyDID,
|
|
@@ -8237,7 +8238,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8237
8238
|
if (!this._sql) {
|
|
8238
8239
|
const features = this.nodeFeatures;
|
|
8239
8240
|
if (features.length > 0 && !features.includes("sql")) {
|
|
8240
|
-
throw new
|
|
8241
|
+
throw new import_sdk_core12.UnsupportedFeatureError("sql", this.config.host, features);
|
|
8241
8242
|
}
|
|
8242
8243
|
throw new Error("Not signed in. Call signIn() first.");
|
|
8243
8244
|
}
|
|
@@ -8261,7 +8262,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8261
8262
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
8262
8263
|
throw new Error("Not signed in. Call signIn() first.");
|
|
8263
8264
|
}
|
|
8264
|
-
const sql = new
|
|
8265
|
+
const sql = new import_sdk_core12.SQLService({});
|
|
8265
8266
|
const spaceScopedContext = this._serviceGraph.track(createServiceContext({
|
|
8266
8267
|
requestSink: this._serviceGraph.requestSink,
|
|
8267
8268
|
invoke: this._serviceContext.invoke,
|
|
@@ -8293,7 +8294,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8293
8294
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
8294
8295
|
throw new Error("Not signed in. Call signIn() first.");
|
|
8295
8296
|
}
|
|
8296
|
-
const kv = new
|
|
8297
|
+
const kv = new import_sdk_core12.KVService({});
|
|
8297
8298
|
const spaceScopedContext = this._serviceGraph.track(createServiceContext({
|
|
8298
8299
|
requestSink: this._serviceGraph.requestSink,
|
|
8299
8300
|
invoke: this._serviceContext.invoke,
|
|
@@ -8313,7 +8314,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8313
8314
|
if (!this._duckdb) {
|
|
8314
8315
|
const features = this.nodeFeatures;
|
|
8315
8316
|
if (features.length > 0 && !features.includes("duckdb")) {
|
|
8316
|
-
throw new
|
|
8317
|
+
throw new import_sdk_core12.UnsupportedFeatureError("duckdb", this.config.host, features);
|
|
8317
8318
|
}
|
|
8318
8319
|
throw new Error("Not signed in. Call signIn() first.");
|
|
8319
8320
|
}
|
|
@@ -8392,7 +8393,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8392
8393
|
type: NETWORK_ADMIN_TYPE,
|
|
8393
8394
|
targetNode,
|
|
8394
8395
|
networkId,
|
|
8395
|
-
bodyHash: (0,
|
|
8396
|
+
bodyHash: (0, import_sdk_core12.canonicalHashHex)(
|
|
8396
8397
|
crypto2.sha256,
|
|
8397
8398
|
body
|
|
8398
8399
|
),
|
|
@@ -8410,7 +8411,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8410
8411
|
Authorization: signed.authorization,
|
|
8411
8412
|
"Content-Type": "application/json"
|
|
8412
8413
|
},
|
|
8413
|
-
body: (0,
|
|
8414
|
+
body: (0, import_sdk_core12.canonicalizeEncryptionJson)(
|
|
8414
8415
|
body
|
|
8415
8416
|
)
|
|
8416
8417
|
});
|
|
@@ -8422,7 +8423,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8422
8423
|
);
|
|
8423
8424
|
}
|
|
8424
8425
|
if (!response.ok) {
|
|
8425
|
-
throw await (0,
|
|
8426
|
+
throw await (0, import_sdk_core12.httpResponseError)(response, `Failed to create encryption network ${networkId}`);
|
|
8426
8427
|
}
|
|
8427
8428
|
const created = await response.json();
|
|
8428
8429
|
return created.descriptor;
|
|
@@ -8441,7 +8442,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8441
8442
|
return existing;
|
|
8442
8443
|
}
|
|
8443
8444
|
}
|
|
8444
|
-
const parsed = (0,
|
|
8445
|
+
const parsed = (0, import_sdk_core12.parseNetworkId)(networkId);
|
|
8445
8446
|
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
8446
8447
|
throw new Error(
|
|
8447
8448
|
`Cannot create encryption network ${networkId}: owner ${parsed.ownerDid} does not match signed-in DID ${this.did}`
|
|
@@ -8490,7 +8491,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8490
8491
|
* normal KV and encryption invocation paths.
|
|
8491
8492
|
*/
|
|
8492
8493
|
async readSecret(input) {
|
|
8493
|
-
const resolved = (0,
|
|
8494
|
+
const resolved = (0, import_sdk_core12.resolveSecretPath)(input.name, { scope: input.scope });
|
|
8494
8495
|
const targetSpace = input.space.startsWith("tinycloud:") ? input.space : this.ownedSpaceId(input.space);
|
|
8495
8496
|
const result = await this.getBaseVault(targetSpace).readNetworkEncrypted(
|
|
8496
8497
|
resolved.vaultKey
|
|
@@ -8524,7 +8525,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8524
8525
|
const resolvedSpace = spaceId.startsWith("tinycloud:") ? spaceId : this.ownedSpaceId(spaceId);
|
|
8525
8526
|
let secrets = this._baseSecrets.get(resolvedSpace);
|
|
8526
8527
|
if (!secrets) {
|
|
8527
|
-
secrets = new
|
|
8528
|
+
secrets = new import_sdk_core12.SecretsService(() => this.getBaseVault(resolvedSpace));
|
|
8528
8529
|
this._baseSecrets.set(resolvedSpace, secrets);
|
|
8529
8530
|
}
|
|
8530
8531
|
return secrets;
|
|
@@ -8626,7 +8627,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8626
8627
|
if (!session || !Array.isArray(permissions) || permissions.length === 0) {
|
|
8627
8628
|
return false;
|
|
8628
8629
|
}
|
|
8629
|
-
const expanded = (0,
|
|
8630
|
+
const expanded = (0, import_sdk_core12.expandRuntimePermissionEntries)(permissions, (0, import_sdk_core12.pkhDid)(session.address, session.chainId));
|
|
8630
8631
|
if (this.sessionCoversPermissionEntries(session, expanded)) {
|
|
8631
8632
|
return true;
|
|
8632
8633
|
}
|
|
@@ -8646,7 +8647,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8646
8647
|
if (!session || !Array.isArray(permissions) || permissions.length === 0) {
|
|
8647
8648
|
return [];
|
|
8648
8649
|
}
|
|
8649
|
-
const expanded = (0,
|
|
8650
|
+
const expanded = (0, import_sdk_core12.expandRuntimePermissionEntries)(permissions, (0, import_sdk_core12.pkhDid)(session.address, session.chainId));
|
|
8650
8651
|
return this.findRuntimeGrantsForPermissionEntries(expanded, session).map(
|
|
8651
8652
|
(grant) => grant.delegation
|
|
8652
8653
|
);
|
|
@@ -8667,7 +8668,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8667
8668
|
for (const grant of this.runtimePermissionGrants) {
|
|
8668
8669
|
if (grant.provenance === "primary") continue;
|
|
8669
8670
|
for (const operation of grant.operations) {
|
|
8670
|
-
const service =
|
|
8671
|
+
const service = import_sdk_core12.SERVICE_SHORT_TO_LONG[operation.service];
|
|
8671
8672
|
if (service === void 0 || typeof operation.path !== "string" || typeof operation.action !== "string") {
|
|
8672
8673
|
continue;
|
|
8673
8674
|
}
|
|
@@ -8685,7 +8686,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8685
8686
|
service,
|
|
8686
8687
|
...space === void 0 ? {} : { space },
|
|
8687
8688
|
path: operation.path,
|
|
8688
|
-
caveats: (0,
|
|
8689
|
+
caveats: (0, import_sdk_core12.canonicalizeRecapCaveats)(caveats)
|
|
8689
8690
|
});
|
|
8690
8691
|
const existing = grouped.get(identity);
|
|
8691
8692
|
if (existing === void 0) {
|
|
@@ -8730,7 +8731,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8730
8731
|
delegationCid: grant.delegationCid,
|
|
8731
8732
|
spaceId: grant.spaceId,
|
|
8732
8733
|
jwk: this.sessionKeyJwk,
|
|
8733
|
-
address: (0,
|
|
8734
|
+
address: (0, import_sdk_core12.canonicalizeAddress)(grant.address),
|
|
8734
8735
|
chainId: grant.chainId,
|
|
8735
8736
|
siwe: grant.siwe,
|
|
8736
8737
|
signature: grant.signature
|
|
@@ -8769,7 +8770,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8769
8770
|
if (!encryption && destination.nodeDid !== void 0) target.spaces.push(resource);
|
|
8770
8771
|
}
|
|
8771
8772
|
} catch (error) {
|
|
8772
|
-
if (!(error instanceof
|
|
8773
|
+
if (!(error instanceof import_sdk_core12.NodeNotFoundError)) throw error;
|
|
8773
8774
|
unserved ?? (unserved = error);
|
|
8774
8775
|
}
|
|
8775
8776
|
}
|
|
@@ -8783,7 +8784,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8783
8784
|
try {
|
|
8784
8785
|
await (0, import_sdk_services5.verifyResourceDestination)(target, globalThis.fetch.bind(globalThis));
|
|
8785
8786
|
const timeout = AbortSignal.timeout(5e3);
|
|
8786
|
-
const result = await (0,
|
|
8787
|
+
const result = await (0, import_sdk_core12.activateSessionWithHost)(
|
|
8787
8788
|
target.url,
|
|
8788
8789
|
delegationHeader,
|
|
8789
8790
|
signal ? AbortSignal.any([signal, timeout]) : timeout
|
|
@@ -8843,10 +8844,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8843
8844
|
const graph = this._serviceGraph;
|
|
8844
8845
|
const session = this.currentTinyCloudSession();
|
|
8845
8846
|
if (!session) {
|
|
8846
|
-
throw new
|
|
8847
|
+
throw new import_sdk_core12.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
8847
8848
|
}
|
|
8848
8849
|
if (delegation.expiry.getTime() <= Date.now()) {
|
|
8849
|
-
throw new
|
|
8850
|
+
throw new import_sdk_core12.SessionExpiredError(delegation.expiry);
|
|
8850
8851
|
}
|
|
8851
8852
|
const expectedDids = [session.verificationMethod, this.sessionDid];
|
|
8852
8853
|
if (!expectedDids.some((did) => didPrincipalMatches2(delegation.delegateDID, did))) {
|
|
@@ -8899,17 +8900,17 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8899
8900
|
const graph = this._serviceGraph;
|
|
8900
8901
|
const session = this.currentTinyCloudSession();
|
|
8901
8902
|
if (!session) {
|
|
8902
|
-
throw new
|
|
8903
|
+
throw new import_sdk_core12.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
8903
8904
|
}
|
|
8904
8905
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
8905
8906
|
if (sessionExpiry !== void 0) {
|
|
8906
8907
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
8907
8908
|
if (sessionExpiry.getTime() <= Date.now() + marginMs) {
|
|
8908
|
-
throw new
|
|
8909
|
+
throw new import_sdk_core12.SessionExpiredError(sessionExpiry);
|
|
8909
8910
|
}
|
|
8910
8911
|
}
|
|
8911
|
-
const expanded = (0,
|
|
8912
|
-
const bindsShareKey = expanded.some((entry) => entry.service ===
|
|
8912
|
+
const expanded = (0, import_sdk_core12.expandRuntimePermissionEntries)(permissions, (0, import_sdk_core12.pkhDid)(session.address, session.chainId));
|
|
8913
|
+
const bindsShareKey = expanded.some((entry) => entry.service === import_sdk_core12.ENCRYPTION_PERMISSION_SERVICE && entry.actions.includes("tinycloud.encryption/key.create"));
|
|
8913
8914
|
const captured = bindsShareKey ? { ...session, jwk: { ...options?.expectedSessionKey ?? session.jwk } } : session;
|
|
8914
8915
|
const assertCapturedKey = bindsShareKey ? () => {
|
|
8915
8916
|
const live = session.jwk;
|
|
@@ -8965,7 +8966,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8965
8966
|
if (sessionExpiry !== void 0 && sessionExpiry < expiresAt) {
|
|
8966
8967
|
expiresAt = sessionExpiry;
|
|
8967
8968
|
}
|
|
8968
|
-
(0,
|
|
8969
|
+
(0, import_sdk_core12.assertExpiryWithinTechnicalLimit)(expiresAt, "siwe");
|
|
8969
8970
|
const delegations = [];
|
|
8970
8971
|
let rawEntriesAttached = false;
|
|
8971
8972
|
for (const [spaceId, entries] of bySpace) {
|
|
@@ -9006,7 +9007,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9006
9007
|
this.assertRuntimeGrantMessage(prepared.siwe, session);
|
|
9007
9008
|
}
|
|
9008
9009
|
const signature = options?.signMessage !== void 0 ? await options.signMessage(prepared.siwe) : await this.signer.signMessage(prepared.siwe);
|
|
9009
|
-
if (options?.signMessage !== void 0 && !await (0,
|
|
9010
|
+
if (options?.signMessage !== void 0 && !await (0, import_sdk_core12.verifyEip191MessageSignature)(prepared.siwe, signature, session.address)) {
|
|
9010
9011
|
throw new Error("The signature does not match the account that owns this session.");
|
|
9011
9012
|
}
|
|
9012
9013
|
graph.assertActive();
|
|
@@ -9185,10 +9186,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9185
9186
|
}
|
|
9186
9187
|
await this.assertMayCreateSpace(publicSpaceId);
|
|
9187
9188
|
await this.auth.hostPublicSpace(publicSpaceId);
|
|
9188
|
-
const kvActions = [
|
|
9189
|
+
const kvActions = [import_sdk_core12.KV.PUT, import_sdk_core12.KV.GET, import_sdk_core12.KV.DEL, import_sdk_core12.KV.LIST, import_sdk_core12.KV.METADATA];
|
|
9189
9190
|
const abilities = { kv: { "": kvActions } };
|
|
9190
9191
|
const now = /* @__PURE__ */ new Date();
|
|
9191
|
-
const expiryMs =
|
|
9192
|
+
const expiryMs = import_sdk_core12.EXPIRY.EPHEMERAL_MS;
|
|
9192
9193
|
const expirationTime = new Date(now.getTime() + expiryMs);
|
|
9193
9194
|
const prepared = this.wasmBindings.prepareSession({
|
|
9194
9195
|
abilities,
|
|
@@ -9233,7 +9234,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9233
9234
|
}]);
|
|
9234
9235
|
}
|
|
9235
9236
|
if (this._serviceContext) {
|
|
9236
|
-
const publicKV = new
|
|
9237
|
+
const publicKV = new import_sdk_core12.KVService({ prefix: "" });
|
|
9237
9238
|
const publicContext = this._serviceGraph.track(createServiceContext({
|
|
9238
9239
|
requestSink: this._serviceGraph.requestSink,
|
|
9239
9240
|
invoke: this._serviceGraph.invoke,
|
|
@@ -9358,14 +9359,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9358
9359
|
}
|
|
9359
9360
|
const session = this.currentTinyCloudSession();
|
|
9360
9361
|
if (!session) {
|
|
9361
|
-
throw new
|
|
9362
|
+
throw new import_sdk_core12.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
9362
9363
|
}
|
|
9363
9364
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
9364
9365
|
if (sessionExpiry !== void 0) {
|
|
9365
9366
|
const now2 = Date.now();
|
|
9366
9367
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
9367
9368
|
if (sessionExpiry.getTime() <= now2 + marginMs) {
|
|
9368
|
-
throw new
|
|
9369
|
+
throw new import_sdk_core12.SessionExpiredError(sessionExpiry);
|
|
9369
9370
|
}
|
|
9370
9371
|
}
|
|
9371
9372
|
if (!Array.isArray(permissions) || permissions.length === 0) {
|
|
@@ -9373,18 +9374,18 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9373
9374
|
"delegateTo requires a non-empty permissions array"
|
|
9374
9375
|
);
|
|
9375
9376
|
}
|
|
9376
|
-
const expandedEntries = (0,
|
|
9377
|
-
const namedKeyEntries = expandedEntries.filter((entry) => entry.service ===
|
|
9377
|
+
const expandedEntries = (0, import_sdk_core12.expandDelegationPermissionEntries)(permissions);
|
|
9378
|
+
const namedKeyEntries = expandedEntries.filter((entry) => entry.service === import_sdk_core12.ENCRYPTION_PERMISSION_SERVICE && entry.path.includes("/"));
|
|
9378
9379
|
if (namedKeyEntries.length > 0) {
|
|
9379
|
-
if (expandedEntries.some((entry) => entry.service ===
|
|
9380
|
-
throw new
|
|
9380
|
+
if (expandedEntries.some((entry) => entry.service === import_sdk_core12.ENCRYPTION_PERMISSION_SERVICE && !entry.path.includes("/"))) {
|
|
9381
|
+
throw new import_sdk_core12.ManifestValidationError("named-key delegation cannot include bare-network permissions");
|
|
9381
9382
|
}
|
|
9382
9383
|
if (options?.forceWalletSign) {
|
|
9383
|
-
throw new
|
|
9384
|
+
throw new import_sdk_core12.ManifestValidationError("named-key delegation requires a signed session grant");
|
|
9384
9385
|
}
|
|
9385
9386
|
const granted = this.projectSignedRecapCapabilities(session.siwe);
|
|
9386
9387
|
const { subset, missing } = this.signedCapabilitySubset(namedKeyEntries, granted);
|
|
9387
|
-
if (!subset) throw new
|
|
9388
|
+
if (!subset) throw new import_sdk_core12.PermissionNotInManifestError(missing, granted);
|
|
9388
9389
|
}
|
|
9389
9390
|
const now = /* @__PURE__ */ new Date();
|
|
9390
9391
|
const expiryMs = resolveExpiryMs(options?.expiry);
|
|
@@ -9418,12 +9419,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9418
9419
|
);
|
|
9419
9420
|
if ("refused" in plan) {
|
|
9420
9421
|
if (plan.refused === "SESSION_EXPIRING") {
|
|
9421
|
-
throw new
|
|
9422
|
+
throw new import_sdk_core12.SessionExpiredError(plan.expiredAt ?? sessionExpiry ?? /* @__PURE__ */ new Date(0));
|
|
9422
9423
|
}
|
|
9423
9424
|
if (plan.refused === "CAVEATED_AUTHORITY") {
|
|
9424
|
-
throw new
|
|
9425
|
+
throw new import_sdk_core12.CaveatedDelegationUnsupportedError(plan.caveated ?? []);
|
|
9425
9426
|
}
|
|
9426
|
-
throw new
|
|
9427
|
+
throw new import_sdk_core12.PermissionNotInManifestError(plan.missing ?? [], plan.granted ?? []);
|
|
9427
9428
|
}
|
|
9428
9429
|
if (plan.path === "runtime") {
|
|
9429
9430
|
const delegation2 = await this.createDelegationViaRuntimeGrant(
|
|
@@ -9462,7 +9463,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9462
9463
|
*/
|
|
9463
9464
|
planDerivation(expandedEntries, session, effectiveExpiration, nowMs) {
|
|
9464
9465
|
const caveatedRequest = expandedEntries.filter(
|
|
9465
|
-
(entry) => !(0,
|
|
9466
|
+
(entry) => !(0, import_sdk_core12.recapCaveatsEqual)(entry.caveats, void 0)
|
|
9466
9467
|
);
|
|
9467
9468
|
if (caveatedRequest.length > 0) {
|
|
9468
9469
|
return { refused: "CAVEATED_AUTHORITY", caveated: caveatedRequest };
|
|
@@ -9603,7 +9604,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9603
9604
|
}, getNodeReplicationLoaders().gatedNetwork);
|
|
9604
9605
|
return;
|
|
9605
9606
|
}
|
|
9606
|
-
const identityPrincipal = principal ?? (this._address === void 0 ? void 0 : (0,
|
|
9607
|
+
const identityPrincipal = principal ?? (this._address === void 0 ? void 0 : (0, import_sdk_core12.pkhDid)(this._address, this._chainId));
|
|
9607
9608
|
if (identityPrincipal === void 0) return;
|
|
9608
9609
|
const authority = await this.replicationAuthority();
|
|
9609
9610
|
if (epoch !== this.sessionEpoch || attempt !== this.latestSessionAttempt || this._kv !== kv || this._serviceContext !== context) return;
|
|
@@ -9699,7 +9700,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9699
9700
|
const spaceId = resolvedSpaces.size === 1 ? [...resolvedSpaces][0] : session.spaceId;
|
|
9700
9701
|
const abilities = {};
|
|
9701
9702
|
for (const entry of entries) {
|
|
9702
|
-
const shortService =
|
|
9703
|
+
const shortService = import_sdk_core12.SERVICE_LONG_TO_SHORT[entry.service];
|
|
9703
9704
|
if (shortService === void 0) {
|
|
9704
9705
|
throw new Error(
|
|
9705
9706
|
`delegateTo: unknown service '${entry.service}' \u2014 no short-form mapping`
|
|
@@ -9811,7 +9812,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9811
9812
|
return this.wasmBindings.makeSpaceId(session.address, session.chainId, space);
|
|
9812
9813
|
}
|
|
9813
9814
|
expandPermissionEntries(permissions) {
|
|
9814
|
-
return (0,
|
|
9815
|
+
return (0, import_sdk_core12.expandPermissionEntries)(permissions);
|
|
9815
9816
|
}
|
|
9816
9817
|
/**
|
|
9817
9818
|
* Checks the SIWE text a caller-supplied signer is asked to sign: it must be in canonical form (parsing and
|
|
@@ -9828,7 +9829,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9828
9829
|
if (parsed.prepareMessage() !== siwe) {
|
|
9829
9830
|
throw new Error("The prepared sign-in message is not in canonical form.");
|
|
9830
9831
|
}
|
|
9831
|
-
if (parsed.chainId !== session.chainId || (0,
|
|
9832
|
+
if (parsed.chainId !== session.chainId || (0, import_sdk_core12.canonicalizeAddress)(parsed.address) !== (0, import_sdk_core12.canonicalizeAddress)(session.address)) {
|
|
9832
9833
|
throw new Error("The prepared sign-in message is for a different account or chain than this session.");
|
|
9833
9834
|
}
|
|
9834
9835
|
}
|
|
@@ -9838,10 +9839,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9838
9839
|
*/
|
|
9839
9840
|
assertDelegationCaveatsPreservable(entries) {
|
|
9840
9841
|
const caveated = entries.filter(
|
|
9841
|
-
(entry) => !(0,
|
|
9842
|
+
(entry) => !(0, import_sdk_core12.recapCaveatsEqual)(entry.caveats, void 0)
|
|
9842
9843
|
);
|
|
9843
9844
|
if (caveated.length > 0) {
|
|
9844
|
-
throw new
|
|
9845
|
+
throw new import_sdk_core12.CaveatedDelegationUnsupportedError(caveated);
|
|
9845
9846
|
}
|
|
9846
9847
|
}
|
|
9847
9848
|
/**
|
|
@@ -9853,7 +9854,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9853
9854
|
assertRuntimeGrantCaveatsPreservable(entries, requestedOperations, grant) {
|
|
9854
9855
|
const caveated = this.caveatedRuntimeGrantEntries(entries, requestedOperations, grant);
|
|
9855
9856
|
if (caveated.length > 0) {
|
|
9856
|
-
throw new
|
|
9857
|
+
throw new import_sdk_core12.CaveatedDelegationUnsupportedError(caveated);
|
|
9857
9858
|
}
|
|
9858
9859
|
}
|
|
9859
9860
|
/**
|
|
@@ -9870,7 +9871,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9870
9871
|
const requested = requestedOperations[operationIndex++];
|
|
9871
9872
|
if (!requested) continue;
|
|
9872
9873
|
const constrained = grant.operations.find(
|
|
9873
|
-
(granted) => this.operationCovers(granted, requested) && !(0,
|
|
9874
|
+
(granted) => this.operationCovers(granted, requested) && !(0, import_sdk_core12.recapCaveatsEqual)(granted.caveats, void 0)
|
|
9874
9875
|
);
|
|
9875
9876
|
if (constrained) {
|
|
9876
9877
|
caveated.push({
|
|
@@ -9887,7 +9888,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9887
9888
|
assertPortableDelegationCaveatsPreservable(delegation) {
|
|
9888
9889
|
const entries = [];
|
|
9889
9890
|
const add = (service, space, path, actions, caveats) => {
|
|
9890
|
-
if ((0,
|
|
9891
|
+
if ((0, import_sdk_core12.recapCaveatsEqual)(caveats, void 0)) return;
|
|
9891
9892
|
entries.push({
|
|
9892
9893
|
service: service.startsWith("tinycloud.") ? service : `tinycloud.${service}`,
|
|
9893
9894
|
space,
|
|
@@ -9907,11 +9908,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9907
9908
|
add(resource.service, resource.space, resource.path, resource.actions, resource.caveats);
|
|
9908
9909
|
}
|
|
9909
9910
|
if (entries.length > 0) {
|
|
9910
|
-
throw new
|
|
9911
|
+
throw new import_sdk_core12.CaveatedDelegationUnsupportedError(entries);
|
|
9911
9912
|
}
|
|
9912
9913
|
}
|
|
9913
9914
|
shortServiceName(service) {
|
|
9914
|
-
const short =
|
|
9915
|
+
const short = import_sdk_core12.SERVICE_LONG_TO_SHORT[service];
|
|
9915
9916
|
if (short === void 0) {
|
|
9916
9917
|
throw new Error(
|
|
9917
9918
|
`unknown service '${service}' \u2014 no short-form mapping`
|
|
@@ -9938,7 +9939,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9938
9939
|
return abilities;
|
|
9939
9940
|
}
|
|
9940
9941
|
isEncryptionPermissionEntry(entry) {
|
|
9941
|
-
return entry.service ===
|
|
9942
|
+
return entry.service === import_sdk_core12.ENCRYPTION_PERMISSION_SERVICE && this.isEncryptionNetworkOperation("encryption", entry.path, entry.space);
|
|
9942
9943
|
}
|
|
9943
9944
|
isRawRevocationPermissionEntry(entry) {
|
|
9944
9945
|
return entry.service === "tinycloud.delegation" && entry.path === "" && entry.space?.startsWith("urn:cid:") === true && entry.actions.includes("tinycloud.delegation/revoke");
|
|
@@ -9986,7 +9987,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9986
9987
|
const missing = requested.filter((entry) => {
|
|
9987
9988
|
const raw = this.isEncryptionPermissionEntry(entry) || this.isRawRevocationPermissionEntry(entry);
|
|
9988
9989
|
const comparable = raw && this.isEncryptionPermissionEntry(entry) ? { ...entry, space: "encryption" } : entry;
|
|
9989
|
-
return !(0,
|
|
9990
|
+
return !(0, import_sdk_core12.isCapabilitySubset)([comparable], raw ? rawGranted : spaceGranted).subset;
|
|
9990
9991
|
});
|
|
9991
9992
|
return { subset: missing.length === 0, missing };
|
|
9992
9993
|
}
|
|
@@ -10233,7 +10234,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10233
10234
|
if (granted.service !== requested.service || !this.actionContains(granted.action, requested.action)) {
|
|
10234
10235
|
return false;
|
|
10235
10236
|
}
|
|
10236
|
-
if (requested.caveats !== void 0 && !(0,
|
|
10237
|
+
if (requested.caveats !== void 0 && !(0, import_sdk_core12.recapCaveatsEqual)(granted.caveats, requested.caveats)) {
|
|
10237
10238
|
return false;
|
|
10238
10239
|
}
|
|
10239
10240
|
if (granted.resource !== void 0 || requested.resource !== void 0) {
|
|
@@ -10255,7 +10256,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10255
10256
|
if (grantedAction === requestedAction) {
|
|
10256
10257
|
return true;
|
|
10257
10258
|
}
|
|
10258
|
-
if ((0,
|
|
10259
|
+
if ((0, import_sdk_core12.isExplicitOnlyAction)(requestedAction)) {
|
|
10259
10260
|
return false;
|
|
10260
10261
|
}
|
|
10261
10262
|
if (grantedAction.endsWith("/*")) {
|
|
@@ -10367,7 +10368,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10367
10368
|
if (resolvedDelegateDID.endsWith(".eth") && this.config.ensResolver) {
|
|
10368
10369
|
const address = await this.config.ensResolver.resolveAddress(resolvedDelegateDID);
|
|
10369
10370
|
if (!address) throw new Error(`Could not resolve ENS name: ${resolvedDelegateDID}`);
|
|
10370
|
-
resolvedDelegateDID = (0,
|
|
10371
|
+
resolvedDelegateDID = (0, import_sdk_core12.pkhDid)(address, 1);
|
|
10371
10372
|
}
|
|
10372
10373
|
const entries = legacyParamsToPermissionEntries(
|
|
10373
10374
|
params.actions,
|
|
@@ -10381,7 +10382,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10381
10382
|
});
|
|
10382
10383
|
return result.delegation;
|
|
10383
10384
|
} catch (err2) {
|
|
10384
|
-
if (err2 instanceof
|
|
10385
|
+
if (err2 instanceof import_sdk_core12.PermissionNotInManifestError) {
|
|
10385
10386
|
} else {
|
|
10386
10387
|
throw err2;
|
|
10387
10388
|
}
|
|
@@ -10425,7 +10426,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10425
10426
|
const now = /* @__PURE__ */ new Date();
|
|
10426
10427
|
const expiryMs = params.expiryMs ?? 60 * 60 * 1e3;
|
|
10427
10428
|
const expirationTime = new Date(now.getTime() + expiryMs);
|
|
10428
|
-
(0,
|
|
10429
|
+
(0, import_sdk_core12.assertExpiryWithinTechnicalLimit)(expirationTime, "siwe");
|
|
10429
10430
|
const prepared = this.wasmBindings.prepareSession({
|
|
10430
10431
|
abilities,
|
|
10431
10432
|
address: this.wasmBindings.ensureEip55(session.address),
|
|
@@ -10464,12 +10465,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10464
10465
|
};
|
|
10465
10466
|
const hasKvActions = params.actions.some((a) => a.startsWith("tinycloud.kv/"));
|
|
10466
10467
|
if (hasKvActions && params.includePublicSpace !== false) {
|
|
10467
|
-
const publicSpaceId = (0,
|
|
10468
|
+
const publicSpaceId = (0, import_sdk_core12.makePublicSpaceId)(
|
|
10468
10469
|
this.wasmBindings.ensureEip55(session.address),
|
|
10469
10470
|
session.chainId
|
|
10470
10471
|
);
|
|
10471
10472
|
const publicAbilities = {
|
|
10472
|
-
kv: { "": [
|
|
10473
|
+
kv: { "": [import_sdk_core12.KV.GET, import_sdk_core12.KV.PUT, import_sdk_core12.KV.METADATA] }
|
|
10473
10474
|
};
|
|
10474
10475
|
const publicPrepared = this.wasmBindings.prepareSession({
|
|
10475
10476
|
abilities: publicAbilities,
|
|
@@ -10494,7 +10495,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10494
10495
|
delegationHeader: publicSession.delegationHeader,
|
|
10495
10496
|
spaceId: publicSpaceId,
|
|
10496
10497
|
path: "",
|
|
10497
|
-
actions: [
|
|
10498
|
+
actions: [import_sdk_core12.KV.GET, import_sdk_core12.KV.PUT, import_sdk_core12.KV.METADATA],
|
|
10498
10499
|
disableSubDelegation: false,
|
|
10499
10500
|
expiry: expirationTime,
|
|
10500
10501
|
delegateDID: params.delegateDID,
|
|
@@ -10574,7 +10575,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10574
10575
|
const { abilities, rawAbilities } = this.buildActivationAbilities(delegation);
|
|
10575
10576
|
const now = /* @__PURE__ */ new Date();
|
|
10576
10577
|
const expirationTime = delegation.expiry;
|
|
10577
|
-
(0,
|
|
10578
|
+
(0, import_sdk_core12.assertExpiryWithinTechnicalLimit)(expirationTime, "siwe");
|
|
10578
10579
|
const prepared = this.wasmBindings.prepareSession({
|
|
10579
10580
|
abilities,
|
|
10580
10581
|
address: this.wasmBindings.ensureEip55(mySession.address),
|
|
@@ -10690,7 +10691,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10690
10691
|
const now = /* @__PURE__ */ new Date();
|
|
10691
10692
|
const requestedExpiry = params.expiryMs === void 0 ? parentDelegation.expiry : new Date(now.getTime() + params.expiryMs);
|
|
10692
10693
|
const actualExpiry = requestedExpiry > parentDelegation.expiry ? parentDelegation.expiry : requestedExpiry;
|
|
10693
|
-
(0,
|
|
10694
|
+
(0, import_sdk_core12.assertExpiryWithinTechnicalLimit)(actualExpiry, "siwe");
|
|
10694
10695
|
const abilities = {};
|
|
10695
10696
|
const rawAbilities = {};
|
|
10696
10697
|
for (const resource of requestedResources) {
|
|
@@ -10764,7 +10765,6 @@ _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS = 6e4;
|
|
|
10764
10765
|
var TinyCloudNode = _TinyCloudNode;
|
|
10765
10766
|
|
|
10766
10767
|
// src/core.ts
|
|
10767
|
-
var import_sdk_core14 = require("@tinycloud/sdk-core");
|
|
10768
10768
|
var import_sdk_core15 = require("@tinycloud/sdk-core");
|
|
10769
10769
|
var import_sdk_core16 = require("@tinycloud/sdk-core");
|
|
10770
10770
|
var import_sdk_core17 = require("@tinycloud/sdk-core");
|
|
@@ -10774,6 +10774,7 @@ var import_sdk_core20 = require("@tinycloud/sdk-core");
|
|
|
10774
10774
|
var import_sdk_core21 = require("@tinycloud/sdk-core");
|
|
10775
10775
|
var import_sdk_core22 = require("@tinycloud/sdk-core");
|
|
10776
10776
|
var import_sdk_core23 = require("@tinycloud/sdk-core");
|
|
10777
|
+
var import_sdk_core24 = require("@tinycloud/sdk-core");
|
|
10777
10778
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10778
10779
|
0 && (module.exports = {
|
|
10779
10780
|
ACCOUNT_REGISTRY_PATH,
|