@tinycloud/node-sdk 3.12.0-beta.3 → 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/README.md +2 -2
- 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 -347
- 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 +7 -6
- 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 +148 -146
- 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 +9 -6
- 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 +4 -4
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,15 +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
|
|
6594
|
-
const stagedHost = resolvedHost ?? (0, import_sdk_core11.exactHttpOrigin)(restoreHints[0] ?? this.config.host, "restored host hint");
|
|
6594
|
+
const stagedHost = (0, import_sdk_core12.exactHttpOrigin)(restoreHints[0] ?? this.config.host, "restored host hint");
|
|
6595
6595
|
let restoredNodeFeatures;
|
|
6596
6596
|
let replicaProtocolMismatch = false;
|
|
6597
6597
|
if (this.config.replication?.enabled) {
|
|
6598
6598
|
try {
|
|
6599
|
-
restoredNodeFeatures = (await (0,
|
|
6599
|
+
restoredNodeFeatures = (await (0, import_sdk_core12.checkNodeInfo)(stagedHost, this.wasmBindings.protocolVersion())).features;
|
|
6600
6600
|
} catch (error) {
|
|
6601
|
-
replicaProtocolMismatch = error instanceof
|
|
6601
|
+
replicaProtocolMismatch = error instanceof import_sdk_core12.ProtocolMismatchError;
|
|
6602
6602
|
}
|
|
6603
6603
|
}
|
|
6604
6604
|
const stagedAddress = restoredAddress;
|
|
@@ -6609,7 +6609,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6609
6609
|
let replicationScopeUnavailable = false;
|
|
6610
6610
|
if (this.config.replication?.enabled) {
|
|
6611
6611
|
if (stagedAddress !== void 0) {
|
|
6612
|
-
replicationPrincipal = (0,
|
|
6612
|
+
replicationPrincipal = (0, import_sdk_core12.pkhDid)(stagedAddress, stagedChainId);
|
|
6613
6613
|
} else {
|
|
6614
6614
|
try {
|
|
6615
6615
|
const { replicationScopeFromSignedSession } = await getNodeReplicationLoaders().authority();
|
|
@@ -6658,7 +6658,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6658
6658
|
}
|
|
6659
6659
|
}
|
|
6660
6660
|
}
|
|
6661
|
-
const stagedNodeDid = stagedAddress ? (0,
|
|
6661
|
+
const stagedNodeDid = stagedAddress ? (0, import_sdk_core12.pkhDid)(stagedAddress, stagedChainId) : canonicalVerificationMethod;
|
|
6662
6662
|
const serviceSession = {
|
|
6663
6663
|
delegationHeader: sessionData.delegationHeader,
|
|
6664
6664
|
delegationCid: sessionData.delegationCid,
|
|
@@ -6686,7 +6686,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6686
6686
|
stagedSessionExpiry,
|
|
6687
6687
|
stagedRecap
|
|
6688
6688
|
);
|
|
6689
|
-
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;
|
|
6690
6690
|
const stagedGraph = this.stageRestoredServiceGraph({
|
|
6691
6691
|
host: stagedHost,
|
|
6692
6692
|
manager: stagedManager,
|
|
@@ -6776,7 +6776,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6776
6776
|
this.assertSessionEpoch(epoch, "Session restore");
|
|
6777
6777
|
}
|
|
6778
6778
|
if (this.config.replication?.enabled) {
|
|
6779
|
-
if (stagedAddress !== void 0) this.refreshRegistryOwner((0,
|
|
6779
|
+
if (stagedAddress !== void 0) this.refreshRegistryOwner((0, import_sdk_core12.pkhDid)(stagedAddress, stagedChainId));
|
|
6780
6780
|
this.refreshRegistryForCapabilities(this.getVerifiedSessionCapabilities());
|
|
6781
6781
|
}
|
|
6782
6782
|
}
|
|
@@ -6828,7 +6828,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6828
6828
|
}
|
|
6829
6829
|
stageRestoredServiceGraph(input) {
|
|
6830
6830
|
const graph = this.createServiceGraphLifetime(input.serviceSession);
|
|
6831
|
-
const core = this.auth ? new
|
|
6831
|
+
const core = this.auth ? new import_sdk_core12.TinyCloud(this.auth, {
|
|
6832
6832
|
invokeAny: graph.invokeAny,
|
|
6833
6833
|
telemetry: this.config.telemetry,
|
|
6834
6834
|
retryPolicy: this.config.retryPolicy
|
|
@@ -6847,16 +6847,16 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6847
6847
|
telemetry: this.config.telemetry,
|
|
6848
6848
|
retryPolicy: this.config.retryPolicy
|
|
6849
6849
|
}));
|
|
6850
|
-
const kv = new
|
|
6850
|
+
const kv = new import_sdk_core12.KVService({});
|
|
6851
6851
|
kv.initialize(serviceContext);
|
|
6852
6852
|
serviceContext.registerService("kv", kv);
|
|
6853
|
-
const sql = new
|
|
6853
|
+
const sql = new import_sdk_core12.SQLService({});
|
|
6854
6854
|
sql.initialize(serviceContext);
|
|
6855
6855
|
serviceContext.registerService("sql", sql);
|
|
6856
|
-
const duckdb = new
|
|
6856
|
+
const duckdb = new import_sdk_core12.DuckDbService({});
|
|
6857
6857
|
duckdb.initialize(serviceContext);
|
|
6858
6858
|
serviceContext.registerService("duckdb", duckdb);
|
|
6859
|
-
const hooks = new
|
|
6859
|
+
const hooks = new import_sdk_core12.HooksService({});
|
|
6860
6860
|
hooks.initialize(serviceContext);
|
|
6861
6861
|
serviceContext.registerService("hooks", hooks);
|
|
6862
6862
|
serviceContext.setSession(input.serviceSession);
|
|
@@ -6879,7 +6879,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6879
6879
|
});
|
|
6880
6880
|
vault.initialize(serviceContext);
|
|
6881
6881
|
serviceContext.registerService("vault", vault);
|
|
6882
|
-
const capabilityRegistry = new
|
|
6882
|
+
const capabilityRegistry = new import_sdk_core12.CapabilityKeyRegistry();
|
|
6883
6883
|
if (input.tinyCloudSession) {
|
|
6884
6884
|
const session = input.tinyCloudSession;
|
|
6885
6885
|
const delegations = input.recap.map((entry) => ({
|
|
@@ -6903,7 +6903,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6903
6903
|
}, delegations);
|
|
6904
6904
|
}
|
|
6905
6905
|
}
|
|
6906
|
-
const delegationManager = new
|
|
6906
|
+
const delegationManager = new import_sdk_core12.DelegationManager({
|
|
6907
6907
|
hosts: [input.host],
|
|
6908
6908
|
accountSpaceId: input.accountSpaceId,
|
|
6909
6909
|
session: input.serviceSession,
|
|
@@ -6914,7 +6914,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6914
6914
|
fetch: graph.fetch
|
|
6915
6915
|
});
|
|
6916
6916
|
const keyProvider = new WasmKeyProvider({ sessionManager: input.manager });
|
|
6917
|
-
const sharingService = new
|
|
6917
|
+
const sharingService = new import_sdk_core12.SharingService({
|
|
6918
6918
|
hosts: [input.host],
|
|
6919
6919
|
invoke: graph.invoke,
|
|
6920
6920
|
fetch: graph.fetch,
|
|
@@ -6927,7 +6927,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6927
6927
|
return this.wasmBindings.computeCid(data, codec);
|
|
6928
6928
|
},
|
|
6929
6929
|
createKVService: (config) => {
|
|
6930
|
-
const service = new
|
|
6930
|
+
const service = new import_sdk_core12.KVService({ prefix: config.pathPrefix?.replace(/\/$/, "") });
|
|
6931
6931
|
const context = graph.track(createServiceContext({
|
|
6932
6932
|
requestSink: graph.requestSink,
|
|
6933
6933
|
invoke: config.invoke,
|
|
@@ -6959,7 +6959,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6959
6959
|
return delegation;
|
|
6960
6960
|
} : void 0
|
|
6961
6961
|
});
|
|
6962
|
-
const spaceService = new
|
|
6962
|
+
const spaceService = new import_sdk_core12.SpaceService({
|
|
6963
6963
|
hosts: [input.host],
|
|
6964
6964
|
session: input.serviceSession,
|
|
6965
6965
|
invoke: graph.invoke,
|
|
@@ -6968,7 +6968,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6968
6968
|
userDid: input.nodeDid,
|
|
6969
6969
|
createKVService: (spaceId) => {
|
|
6970
6970
|
graph.assertActive();
|
|
6971
|
-
const scopedKv = new
|
|
6971
|
+
const scopedKv = new import_sdk_core12.KVService({});
|
|
6972
6972
|
const context = graph.track(createServiceContext({
|
|
6973
6973
|
requestSink: graph.requestSink,
|
|
6974
6974
|
invoke: graph.invoke,
|
|
@@ -6985,7 +6985,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6985
6985
|
},
|
|
6986
6986
|
createVaultService: (spaceId) => {
|
|
6987
6987
|
graph.assertActive();
|
|
6988
|
-
const scopedKv = new
|
|
6988
|
+
const scopedKv = new import_sdk_core12.KVService({});
|
|
6989
6989
|
const context = graph.track(createServiceContext({
|
|
6990
6990
|
requestSink: graph.requestSink,
|
|
6991
6991
|
invoke: graph.invoke,
|
|
@@ -7086,7 +7086,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7086
7086
|
did: () => session.verificationMethod.split("#", 1)[0],
|
|
7087
7087
|
sign: async (attenuation) => {
|
|
7088
7088
|
const now = Math.floor(Date.now() / 1e3);
|
|
7089
|
-
const invocation = await (0,
|
|
7089
|
+
const invocation = await (0, import_sdk_core12.signCompactUcanAuthorization)({
|
|
7090
7090
|
issuerDid: session.verificationMethod.split("#", 1)[0],
|
|
7091
7091
|
audienceDid: await this.fetchNodeId(),
|
|
7092
7092
|
attenuation,
|
|
@@ -7118,7 +7118,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7118
7118
|
nodeAudience: input.nodeAudience,
|
|
7119
7119
|
...input.role === "policy-enforcement" ? { enforcerDid: input.audienceDid } : {}
|
|
7120
7120
|
};
|
|
7121
|
-
const root = await (0,
|
|
7121
|
+
const root = await (0, import_sdk_core12.signCompactUcanRootAuthorization)({
|
|
7122
7122
|
issuerDid: ownerDid,
|
|
7123
7123
|
audienceDid: input.audienceDid,
|
|
7124
7124
|
attenuation: unifiedRootAttenuation(input.capabilities),
|
|
@@ -7160,7 +7160,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7160
7160
|
if (decision.needsApproval) return void 0;
|
|
7161
7161
|
throw new Error(decision.reason ?? "OpenKey automatic credential signing was rejected");
|
|
7162
7162
|
}
|
|
7163
|
-
if (typeof decision.signature !== "string" || !await (0,
|
|
7163
|
+
if (typeof decision.signature !== "string" || !await (0, import_sdk_core12.verifyEip191MessageSignature)(
|
|
7164
7164
|
request.message,
|
|
7165
7165
|
decision.signature,
|
|
7166
7166
|
request.address
|
|
@@ -7185,7 +7185,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7185
7185
|
if (approval) {
|
|
7186
7186
|
const decision = await approval(request);
|
|
7187
7187
|
if (!decision.approved) throw new Error(decision.reason ?? "Credential signing was rejected");
|
|
7188
|
-
if (decision.signature !== void 0 && !await (0,
|
|
7188
|
+
if (decision.signature !== void 0 && !await (0, import_sdk_core12.verifyEip191MessageSignature)(
|
|
7189
7189
|
request.message,
|
|
7190
7190
|
decision.signature,
|
|
7191
7191
|
request.address
|
|
@@ -7277,7 +7277,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7277
7277
|
nonce: this.config.nonce,
|
|
7278
7278
|
siweConfig: this.config.siweConfig,
|
|
7279
7279
|
manifest: useBootstrapSignInRequest ? void 0 : this.config.manifest,
|
|
7280
|
-
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,
|
|
7281
7281
|
includeAccountRegistryPermissions: useBootstrapSignInRequest ? false : this.config.includeAccountRegistryPermissions,
|
|
7282
7282
|
replication: this.config.replication?.enabled === true ? {
|
|
7283
7283
|
enabled: true,
|
|
@@ -7286,7 +7286,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7286
7286
|
syncScope: this.config.replication.syncScope
|
|
7287
7287
|
} : void 0
|
|
7288
7288
|
});
|
|
7289
|
-
this.tc = new
|
|
7289
|
+
this.tc = new import_sdk_core12.TinyCloud(this.auth, {
|
|
7290
7290
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
7291
7291
|
telemetry: this.config.telemetry,
|
|
7292
7292
|
retryPolicy: this.config.retryPolicy
|
|
@@ -7340,7 +7340,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7340
7340
|
nonce: this.config.nonce,
|
|
7341
7341
|
siweConfig: this.config.siweConfig,
|
|
7342
7342
|
manifest: useBootstrapSignInRequest ? void 0 : this.config.manifest,
|
|
7343
|
-
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,
|
|
7344
7344
|
includeAccountRegistryPermissions: useBootstrapSignInRequest ? false : this.config.includeAccountRegistryPermissions,
|
|
7345
7345
|
replication: this.config.replication?.enabled === true ? {
|
|
7346
7346
|
enabled: true,
|
|
@@ -7349,7 +7349,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7349
7349
|
syncScope: this.config.replication.syncScope
|
|
7350
7350
|
} : void 0
|
|
7351
7351
|
});
|
|
7352
|
-
this.tc = new
|
|
7352
|
+
this.tc = new import_sdk_core12.TinyCloud(this.auth, {
|
|
7353
7353
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
7354
7354
|
telemetry: this.config.telemetry,
|
|
7355
7355
|
retryPolicy: this.config.retryPolicy
|
|
@@ -7380,21 +7380,21 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7380
7380
|
telemetry: this.config.telemetry,
|
|
7381
7381
|
retryPolicy: this.config.retryPolicy
|
|
7382
7382
|
}));
|
|
7383
|
-
this._kv = new
|
|
7383
|
+
this._kv = new import_sdk_core12.KVService({});
|
|
7384
7384
|
this._kv.initialize(this._serviceContext);
|
|
7385
7385
|
this._serviceContext.registerService("kv", this._kv);
|
|
7386
7386
|
const features = this.nodeFeatures;
|
|
7387
7387
|
if (features.length === 0 || features.includes("sql")) {
|
|
7388
|
-
this._sql = new
|
|
7388
|
+
this._sql = new import_sdk_core12.SQLService({});
|
|
7389
7389
|
this._sql.initialize(this._serviceContext);
|
|
7390
7390
|
this._serviceContext.registerService("sql", this._sql);
|
|
7391
7391
|
}
|
|
7392
7392
|
if (features.length === 0 || features.includes("duckdb")) {
|
|
7393
|
-
this._duckdb = new
|
|
7393
|
+
this._duckdb = new import_sdk_core12.DuckDbService({});
|
|
7394
7394
|
this._duckdb.initialize(this._serviceContext);
|
|
7395
7395
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
7396
7396
|
}
|
|
7397
|
-
this._hooks = new
|
|
7397
|
+
this._hooks = new import_sdk_core12.HooksService({});
|
|
7398
7398
|
this._hooks.initialize(this._serviceContext);
|
|
7399
7399
|
this._serviceContext.registerService("hooks", this._hooks);
|
|
7400
7400
|
const serviceSession = {
|
|
@@ -7418,7 +7418,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7418
7418
|
kvService.setReadThroughReady(attached);
|
|
7419
7419
|
}
|
|
7420
7420
|
createSpaceScopedKVService(spaceId) {
|
|
7421
|
-
const kvService = new
|
|
7421
|
+
const kvService = new import_sdk_core12.KVService({});
|
|
7422
7422
|
if (this._serviceContext) {
|
|
7423
7423
|
const spaceScopedContext = this._serviceGraph.track(createServiceContext({
|
|
7424
7424
|
requestSink: this._serviceGraph.requestSink,
|
|
@@ -7515,7 +7515,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7515
7515
|
const shared = wasm.vault_x25519_dh(receiverPrivateKey, peerPublic);
|
|
7516
7516
|
return columnDecrypt(shared, ciphertext);
|
|
7517
7517
|
},
|
|
7518
|
-
verifyNodeSignature: (nodeId, message, signature) => (0,
|
|
7518
|
+
verifyNodeSignature: (nodeId, message, signature) => (0, import_sdk_core12.verifyDidKeyEd25519Signature)(nodeId, message, signature)
|
|
7519
7519
|
};
|
|
7520
7520
|
}
|
|
7521
7521
|
/**
|
|
@@ -7531,7 +7531,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7531
7531
|
if (cached) return cached;
|
|
7532
7532
|
const response = await fetch(`${host}/info`);
|
|
7533
7533
|
if (!response.ok) {
|
|
7534
|
-
throw await (0,
|
|
7534
|
+
throw await (0, import_sdk_core12.httpResponseError)(response, "Failed to fetch node info");
|
|
7535
7535
|
}
|
|
7536
7536
|
const info = await response.json();
|
|
7537
7537
|
if (typeof info.nodeId !== "string" || info.nodeId.length === 0) {
|
|
@@ -7597,7 +7597,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7597
7597
|
}
|
|
7598
7598
|
if (response.status === 404) return null;
|
|
7599
7599
|
if (!response.ok) {
|
|
7600
|
-
throw await (0,
|
|
7600
|
+
throw await (0, import_sdk_core12.httpResponseError)(response, `Failed to fetch encryption network ${networkId}`);
|
|
7601
7601
|
}
|
|
7602
7602
|
const body = await response.json();
|
|
7603
7603
|
return "descriptor" in body && body.descriptor ? body.descriptor : body;
|
|
@@ -7633,7 +7633,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7633
7633
|
path: networkId,
|
|
7634
7634
|
actions: ["tinycloud.encryption/decrypt"]
|
|
7635
7635
|
}) : void 0;
|
|
7636
|
-
throw new
|
|
7636
|
+
throw new import_sdk_core12.DecryptTransportResponseError(
|
|
7637
7637
|
response.status,
|
|
7638
7638
|
permissionHint,
|
|
7639
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
|
|
@@ -7642,7 +7642,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7642
7642
|
return await response.json();
|
|
7643
7643
|
}
|
|
7644
7644
|
};
|
|
7645
|
-
return new
|
|
7645
|
+
return new import_sdk_core12.EncryptionService({
|
|
7646
7646
|
resolveTargetNode: async (networkId) => (await this.encryptionDestination(networkId)).nodeDid,
|
|
7647
7647
|
crypto: crypto2,
|
|
7648
7648
|
signer: {
|
|
@@ -7657,7 +7657,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7657
7657
|
graph.assertActive();
|
|
7658
7658
|
return {
|
|
7659
7659
|
...signed,
|
|
7660
|
-
canonicalBody: (0,
|
|
7660
|
+
canonicalBody: (0, import_sdk_core12.canonicalizeEncryptionJson)(
|
|
7661
7661
|
input.body
|
|
7662
7662
|
)
|
|
7663
7663
|
};
|
|
@@ -7681,7 +7681,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7681
7681
|
if (!address || !didPrincipalMatches2(principal, did)) {
|
|
7682
7682
|
return null;
|
|
7683
7683
|
}
|
|
7684
|
-
const publicSpaceId = (0,
|
|
7684
|
+
const publicSpaceId = (0, import_sdk_core12.makePublicSpaceId)(address, chainId);
|
|
7685
7685
|
const encodedKey = discoveryKey.split("/").map(encodeURIComponent).join("/");
|
|
7686
7686
|
const response = await graph.fetch(
|
|
7687
7687
|
`${destination.url}/public/${encodeURIComponent(publicSpaceId)}/kv/${encodedKey}`,
|
|
@@ -7713,7 +7713,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7713
7713
|
createVaultService(spaceId, kv, encryptionService = this.getEncryptionService(), nodeContext) {
|
|
7714
7714
|
const wasm = this.wasmBindings;
|
|
7715
7715
|
const serviceGraph = nodeContext?.serviceGraph ?? this._serviceGraph;
|
|
7716
|
-
const vaultCrypto = (0,
|
|
7716
|
+
const vaultCrypto = (0, import_sdk_core12.createVaultCrypto)({
|
|
7717
7717
|
vault_encrypt: wasm.vault_encrypt,
|
|
7718
7718
|
vault_decrypt: wasm.vault_decrypt,
|
|
7719
7719
|
vault_derive_key: wasm.vault_derive_key,
|
|
@@ -7728,7 +7728,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7728
7728
|
const chainId = nodeContext?.chainId ?? this._chainId;
|
|
7729
7729
|
const host = nodeContext?.host ?? this.config.host;
|
|
7730
7730
|
const ownerDid = this.ownerDidFromSpaceId(spaceId) ?? did;
|
|
7731
|
-
return new
|
|
7731
|
+
return new import_sdk_core12.DataVaultService({
|
|
7732
7732
|
spaceId,
|
|
7733
7733
|
crypto: vaultCrypto,
|
|
7734
7734
|
encryption: {
|
|
@@ -7753,8 +7753,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7753
7753
|
serviceGraph.assertActive();
|
|
7754
7754
|
return self._publicKV ?? self.tc.publicKV;
|
|
7755
7755
|
},
|
|
7756
|
-
readPublicSpace: (host2, targetSpaceId, key) =>
|
|
7757
|
-
makePublicSpaceId:
|
|
7756
|
+
readPublicSpace: (host2, targetSpaceId, key) => import_sdk_core12.TinyCloud.readPublicSpace(host2, targetSpaceId, key),
|
|
7757
|
+
makePublicSpaceId: import_sdk_core12.TinyCloud.makePublicSpaceId,
|
|
7758
7758
|
did,
|
|
7759
7759
|
address: address ?? "",
|
|
7760
7760
|
chainId,
|
|
@@ -7768,7 +7768,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7768
7768
|
*/
|
|
7769
7769
|
initializeV2Services(serviceSession) {
|
|
7770
7770
|
const graph = this._serviceGraph;
|
|
7771
|
-
this._capabilityRegistry = new
|
|
7771
|
+
this._capabilityRegistry = new import_sdk_core12.CapabilityKeyRegistry();
|
|
7772
7772
|
const tcSession = this.auth?.tinyCloudSession;
|
|
7773
7773
|
if (tcSession && this._address) {
|
|
7774
7774
|
const sessionKey = {
|
|
@@ -7808,7 +7808,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7808
7808
|
}
|
|
7809
7809
|
this._capabilityRegistry.registerKey(sessionKey, delegations);
|
|
7810
7810
|
}
|
|
7811
|
-
this._delegationManager = new
|
|
7811
|
+
this._delegationManager = new import_sdk_core12.DelegationManager({
|
|
7812
7812
|
hosts: [this.config.host],
|
|
7813
7813
|
accountSpaceId: this.accountSpaceId,
|
|
7814
7814
|
session: serviceSession,
|
|
@@ -7818,7 +7818,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7818
7818
|
sessionInvocationSigner: this.sessionInvocationSignerFor(serviceSession),
|
|
7819
7819
|
fetch: graph.fetch
|
|
7820
7820
|
});
|
|
7821
|
-
this._spaceService = new
|
|
7821
|
+
this._spaceService = new import_sdk_core12.SpaceService({
|
|
7822
7822
|
hosts: [this.config.host],
|
|
7823
7823
|
session: serviceSession,
|
|
7824
7824
|
invoke: graph.invoke,
|
|
@@ -7884,7 +7884,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7884
7884
|
},
|
|
7885
7885
|
isStorageFull: () => this.ownStorageFull
|
|
7886
7886
|
});
|
|
7887
|
-
this._sharingService = new
|
|
7887
|
+
this._sharingService = new import_sdk_core12.SharingService({
|
|
7888
7888
|
hosts: [this.config.host],
|
|
7889
7889
|
session: serviceSession,
|
|
7890
7890
|
invoke: graph.invoke,
|
|
@@ -7903,7 +7903,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7903
7903
|
},
|
|
7904
7904
|
createKVService: (config) => {
|
|
7905
7905
|
graph.assertActive();
|
|
7906
|
-
const service = new
|
|
7906
|
+
const service = new import_sdk_core12.KVService({ prefix: config.pathPrefix?.replace(/\/$/, "") });
|
|
7907
7907
|
const context = graph.track(createServiceContext({
|
|
7908
7908
|
requestSink: graph.requestSink,
|
|
7909
7909
|
invoke: config.invoke,
|
|
@@ -7991,7 +7991,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7991
7991
|
// DID here and rejects the fragment as an invalid audience DID.
|
|
7992
7992
|
verificationMethod: params.session.verificationMethod.split("#", 1)[0]
|
|
7993
7993
|
};
|
|
7994
|
-
(0,
|
|
7994
|
+
(0, import_sdk_core12.assertExpiryWithinTechnicalLimit)(params.expirationSecs * 1e3, "ucan");
|
|
7995
7995
|
const result = this.wasmBindings.createDelegation(
|
|
7996
7996
|
wasmSession,
|
|
7997
7997
|
params.delegateDID,
|
|
@@ -8001,7 +8001,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8001
8001
|
params.notBeforeSecs
|
|
8002
8002
|
);
|
|
8003
8003
|
return {
|
|
8004
|
-
...terminal ? (0,
|
|
8004
|
+
...terminal ? (0, import_sdk_core12.markDelegationTerminal)(result.delegation, params.session.jwk) : { delegation: result.delegation, cid: result.cid },
|
|
8005
8005
|
// Rust serde `rename_all = "camelCase"` emits `delegateDid`
|
|
8006
8006
|
// (lowercase d); the TypeScript interface uses `delegateDID`
|
|
8007
8007
|
// (historical, matches Delegation.delegateDID). Normalize here.
|
|
@@ -8027,13 +8027,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8027
8027
|
if (!(params.expiresAt instanceof Date) || params.expiresAt.getTime() <= now.getTime()) {
|
|
8028
8028
|
throw new Error("Owner delegation expiry must be explicit, future, and a valid date");
|
|
8029
8029
|
}
|
|
8030
|
-
(0,
|
|
8030
|
+
(0, import_sdk_core12.assertExpiryWithinTechnicalLimit)(params.expiresAt, "siwe");
|
|
8031
8031
|
if (!this.signer) throw new Error("Owner wallet signer is required");
|
|
8032
8032
|
const session = this.currentTinyCloudSession();
|
|
8033
8033
|
if (!session) throw new Error("Owner session is required");
|
|
8034
|
-
const ownerDid = (0,
|
|
8034
|
+
const ownerDid = (0, import_sdk_core12.pkhDid)(session.address, session.chainId);
|
|
8035
8035
|
for (const permission of permissions) {
|
|
8036
|
-
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)) {
|
|
8037
8037
|
throw new Error("Owner delegation cannot grant a foreign encryption network");
|
|
8038
8038
|
}
|
|
8039
8039
|
}
|
|
@@ -8115,7 +8115,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8115
8115
|
/** Register a signed policy and sibling roots with this Node's Policy/v3 runtime. */
|
|
8116
8116
|
async registerPolicy(params) {
|
|
8117
8117
|
this._serviceGraph.assertActive();
|
|
8118
|
-
return (0,
|
|
8118
|
+
return (0, import_sdk_core12.registerPolicyV3)({
|
|
8119
8119
|
...params,
|
|
8120
8120
|
nodeOrigin: this.config.host,
|
|
8121
8121
|
fetch: globalThis.fetch.bind(globalThis)
|
|
@@ -8128,8 +8128,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8128
8128
|
* not sent.
|
|
8129
8129
|
*/
|
|
8130
8130
|
async authorizeShareDeliveryV3(input) {
|
|
8131
|
-
(0,
|
|
8132
|
-
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);
|
|
8133
8133
|
const session = this.currentTinyCloudSession();
|
|
8134
8134
|
const serviceSession = this._serviceContext?.session;
|
|
8135
8135
|
if (!session || !serviceSession) throw new Error("Share delivery requires an authenticated session");
|
|
@@ -8146,21 +8146,21 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8146
8146
|
// Re-normalised through Date, so the sent value is always `YYYY-MM-DDTHH:mm:ss.SSSZ` (UTC, three digits).
|
|
8147
8147
|
expiresAt: new Date(input.expiresAt).toISOString()
|
|
8148
8148
|
};
|
|
8149
|
-
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)))));
|
|
8150
8150
|
const request = { ...body, requestBodyDigest };
|
|
8151
8151
|
const authorization = authorizationHeader(this.wasmBindings.invoke(serviceSession, "kv", input.resourcePath, "tinycloud.kv/get"));
|
|
8152
8152
|
const response = await fetch(`${this.config.host}/policy/v3/deliveries/authorize`, {
|
|
8153
8153
|
method: "POST",
|
|
8154
8154
|
headers: { accept: "application/json", "content-type": "application/json", authorization },
|
|
8155
|
-
body: (0,
|
|
8155
|
+
body: (0, import_sdk_core12.canonicalizeEncryptionJson)(request)
|
|
8156
8156
|
});
|
|
8157
|
-
if (response.status === 400 || response.status === 422) throw new
|
|
8157
|
+
if (response.status === 400 || response.status === 422) throw new import_sdk_core12.ShareDeliveryRefusedError();
|
|
8158
8158
|
if (!response.ok) {
|
|
8159
8159
|
const reply = await response.text().catch(() => response.statusText);
|
|
8160
|
-
const body2 = (await (0,
|
|
8160
|
+
const body2 = (await (0, import_sdk_core12.withoutShareLink)(reply, input.shareUrl)).trim().slice(0, 512);
|
|
8161
8161
|
throw Object.assign(new Error(`V3 share delivery authorization failed: HTTP ${response.status}${body2 ? ` - ${body2}` : ""}`), { status: response.status });
|
|
8162
8162
|
}
|
|
8163
|
-
const verified = await (0,
|
|
8163
|
+
const verified = await (0, import_sdk_core12.verifyShareDeliveryAuthorizationV3Bytes)(new Uint8Array(await response.arrayBuffer()), {
|
|
8164
8164
|
request,
|
|
8165
8165
|
envelope: input.envelope,
|
|
8166
8166
|
envelopeRef,
|
|
@@ -8169,7 +8169,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8169
8169
|
});
|
|
8170
8170
|
const requestDigest = new Uint8Array(await crypto.subtle.digest(
|
|
8171
8171
|
"SHA-256",
|
|
8172
|
-
new TextEncoder().encode(`${
|
|
8172
|
+
new TextEncoder().encode(`${import_sdk_core12.CREDENTIAL_INVITATION_REQUEST_DOMAIN}${(0, import_sdk_core12.canonicalizeEncryptionJson)(verified.request)}`)
|
|
8173
8173
|
));
|
|
8174
8174
|
return {
|
|
8175
8175
|
...verified,
|
|
@@ -8181,7 +8181,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8181
8181
|
};
|
|
8182
8182
|
}
|
|
8183
8183
|
async createRootDelegationForSharing(params, assertActive) {
|
|
8184
|
-
(0,
|
|
8184
|
+
(0, import_sdk_core12.assertExpiryWithinTechnicalLimit)(params.requestedExpiry, "siwe");
|
|
8185
8185
|
try {
|
|
8186
8186
|
return (await this.createOwnerDelegation({
|
|
8187
8187
|
delegateDid: params.shareKeyDID,
|
|
@@ -8238,7 +8238,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8238
8238
|
if (!this._sql) {
|
|
8239
8239
|
const features = this.nodeFeatures;
|
|
8240
8240
|
if (features.length > 0 && !features.includes("sql")) {
|
|
8241
|
-
throw new
|
|
8241
|
+
throw new import_sdk_core12.UnsupportedFeatureError("sql", this.config.host, features);
|
|
8242
8242
|
}
|
|
8243
8243
|
throw new Error("Not signed in. Call signIn() first.");
|
|
8244
8244
|
}
|
|
@@ -8262,7 +8262,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8262
8262
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
8263
8263
|
throw new Error("Not signed in. Call signIn() first.");
|
|
8264
8264
|
}
|
|
8265
|
-
const sql = new
|
|
8265
|
+
const sql = new import_sdk_core12.SQLService({});
|
|
8266
8266
|
const spaceScopedContext = this._serviceGraph.track(createServiceContext({
|
|
8267
8267
|
requestSink: this._serviceGraph.requestSink,
|
|
8268
8268
|
invoke: this._serviceContext.invoke,
|
|
@@ -8294,7 +8294,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8294
8294
|
if (!this._serviceContext || !this._serviceContext.session) {
|
|
8295
8295
|
throw new Error("Not signed in. Call signIn() first.");
|
|
8296
8296
|
}
|
|
8297
|
-
const kv = new
|
|
8297
|
+
const kv = new import_sdk_core12.KVService({});
|
|
8298
8298
|
const spaceScopedContext = this._serviceGraph.track(createServiceContext({
|
|
8299
8299
|
requestSink: this._serviceGraph.requestSink,
|
|
8300
8300
|
invoke: this._serviceContext.invoke,
|
|
@@ -8314,7 +8314,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8314
8314
|
if (!this._duckdb) {
|
|
8315
8315
|
const features = this.nodeFeatures;
|
|
8316
8316
|
if (features.length > 0 && !features.includes("duckdb")) {
|
|
8317
|
-
throw new
|
|
8317
|
+
throw new import_sdk_core12.UnsupportedFeatureError("duckdb", this.config.host, features);
|
|
8318
8318
|
}
|
|
8319
8319
|
throw new Error("Not signed in. Call signIn() first.");
|
|
8320
8320
|
}
|
|
@@ -8393,7 +8393,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8393
8393
|
type: NETWORK_ADMIN_TYPE,
|
|
8394
8394
|
targetNode,
|
|
8395
8395
|
networkId,
|
|
8396
|
-
bodyHash: (0,
|
|
8396
|
+
bodyHash: (0, import_sdk_core12.canonicalHashHex)(
|
|
8397
8397
|
crypto2.sha256,
|
|
8398
8398
|
body
|
|
8399
8399
|
),
|
|
@@ -8411,7 +8411,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8411
8411
|
Authorization: signed.authorization,
|
|
8412
8412
|
"Content-Type": "application/json"
|
|
8413
8413
|
},
|
|
8414
|
-
body: (0,
|
|
8414
|
+
body: (0, import_sdk_core12.canonicalizeEncryptionJson)(
|
|
8415
8415
|
body
|
|
8416
8416
|
)
|
|
8417
8417
|
});
|
|
@@ -8423,7 +8423,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8423
8423
|
);
|
|
8424
8424
|
}
|
|
8425
8425
|
if (!response.ok) {
|
|
8426
|
-
throw await (0,
|
|
8426
|
+
throw await (0, import_sdk_core12.httpResponseError)(response, `Failed to create encryption network ${networkId}`);
|
|
8427
8427
|
}
|
|
8428
8428
|
const created = await response.json();
|
|
8429
8429
|
return created.descriptor;
|
|
@@ -8442,7 +8442,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8442
8442
|
return existing;
|
|
8443
8443
|
}
|
|
8444
8444
|
}
|
|
8445
|
-
const parsed = (0,
|
|
8445
|
+
const parsed = (0, import_sdk_core12.parseNetworkId)(networkId);
|
|
8446
8446
|
if (!didPrincipalMatches2(parsed.ownerDid, this.did)) {
|
|
8447
8447
|
throw new Error(
|
|
8448
8448
|
`Cannot create encryption network ${networkId}: owner ${parsed.ownerDid} does not match signed-in DID ${this.did}`
|
|
@@ -8491,7 +8491,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8491
8491
|
* normal KV and encryption invocation paths.
|
|
8492
8492
|
*/
|
|
8493
8493
|
async readSecret(input) {
|
|
8494
|
-
const resolved = (0,
|
|
8494
|
+
const resolved = (0, import_sdk_core12.resolveSecretPath)(input.name, { scope: input.scope });
|
|
8495
8495
|
const targetSpace = input.space.startsWith("tinycloud:") ? input.space : this.ownedSpaceId(input.space);
|
|
8496
8496
|
const result = await this.getBaseVault(targetSpace).readNetworkEncrypted(
|
|
8497
8497
|
resolved.vaultKey
|
|
@@ -8525,7 +8525,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8525
8525
|
const resolvedSpace = spaceId.startsWith("tinycloud:") ? spaceId : this.ownedSpaceId(spaceId);
|
|
8526
8526
|
let secrets = this._baseSecrets.get(resolvedSpace);
|
|
8527
8527
|
if (!secrets) {
|
|
8528
|
-
secrets = new
|
|
8528
|
+
secrets = new import_sdk_core12.SecretsService(() => this.getBaseVault(resolvedSpace));
|
|
8529
8529
|
this._baseSecrets.set(resolvedSpace, secrets);
|
|
8530
8530
|
}
|
|
8531
8531
|
return secrets;
|
|
@@ -8627,7 +8627,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8627
8627
|
if (!session || !Array.isArray(permissions) || permissions.length === 0) {
|
|
8628
8628
|
return false;
|
|
8629
8629
|
}
|
|
8630
|
-
const expanded = (0,
|
|
8630
|
+
const expanded = (0, import_sdk_core12.expandRuntimePermissionEntries)(permissions, (0, import_sdk_core12.pkhDid)(session.address, session.chainId));
|
|
8631
8631
|
if (this.sessionCoversPermissionEntries(session, expanded)) {
|
|
8632
8632
|
return true;
|
|
8633
8633
|
}
|
|
@@ -8647,7 +8647,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8647
8647
|
if (!session || !Array.isArray(permissions) || permissions.length === 0) {
|
|
8648
8648
|
return [];
|
|
8649
8649
|
}
|
|
8650
|
-
const expanded = (0,
|
|
8650
|
+
const expanded = (0, import_sdk_core12.expandRuntimePermissionEntries)(permissions, (0, import_sdk_core12.pkhDid)(session.address, session.chainId));
|
|
8651
8651
|
return this.findRuntimeGrantsForPermissionEntries(expanded, session).map(
|
|
8652
8652
|
(grant) => grant.delegation
|
|
8653
8653
|
);
|
|
@@ -8668,7 +8668,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8668
8668
|
for (const grant of this.runtimePermissionGrants) {
|
|
8669
8669
|
if (grant.provenance === "primary") continue;
|
|
8670
8670
|
for (const operation of grant.operations) {
|
|
8671
|
-
const service =
|
|
8671
|
+
const service = import_sdk_core12.SERVICE_SHORT_TO_LONG[operation.service];
|
|
8672
8672
|
if (service === void 0 || typeof operation.path !== "string" || typeof operation.action !== "string") {
|
|
8673
8673
|
continue;
|
|
8674
8674
|
}
|
|
@@ -8686,7 +8686,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8686
8686
|
service,
|
|
8687
8687
|
...space === void 0 ? {} : { space },
|
|
8688
8688
|
path: operation.path,
|
|
8689
|
-
caveats: (0,
|
|
8689
|
+
caveats: (0, import_sdk_core12.canonicalizeRecapCaveats)(caveats)
|
|
8690
8690
|
});
|
|
8691
8691
|
const existing = grouped.get(identity);
|
|
8692
8692
|
if (existing === void 0) {
|
|
@@ -8731,7 +8731,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8731
8731
|
delegationCid: grant.delegationCid,
|
|
8732
8732
|
spaceId: grant.spaceId,
|
|
8733
8733
|
jwk: this.sessionKeyJwk,
|
|
8734
|
-
address: (0,
|
|
8734
|
+
address: (0, import_sdk_core12.canonicalizeAddress)(grant.address),
|
|
8735
8735
|
chainId: grant.chainId,
|
|
8736
8736
|
siwe: grant.siwe,
|
|
8737
8737
|
signature: grant.signature
|
|
@@ -8770,7 +8770,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8770
8770
|
if (!encryption && destination.nodeDid !== void 0) target.spaces.push(resource);
|
|
8771
8771
|
}
|
|
8772
8772
|
} catch (error) {
|
|
8773
|
-
if (!(error instanceof
|
|
8773
|
+
if (!(error instanceof import_sdk_core12.NodeNotFoundError)) throw error;
|
|
8774
8774
|
unserved ?? (unserved = error);
|
|
8775
8775
|
}
|
|
8776
8776
|
}
|
|
@@ -8784,7 +8784,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8784
8784
|
try {
|
|
8785
8785
|
await (0, import_sdk_services5.verifyResourceDestination)(target, globalThis.fetch.bind(globalThis));
|
|
8786
8786
|
const timeout = AbortSignal.timeout(5e3);
|
|
8787
|
-
const result = await (0,
|
|
8787
|
+
const result = await (0, import_sdk_core12.activateSessionWithHost)(
|
|
8788
8788
|
target.url,
|
|
8789
8789
|
delegationHeader,
|
|
8790
8790
|
signal ? AbortSignal.any([signal, timeout]) : timeout
|
|
@@ -8844,10 +8844,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8844
8844
|
const graph = this._serviceGraph;
|
|
8845
8845
|
const session = this.currentTinyCloudSession();
|
|
8846
8846
|
if (!session) {
|
|
8847
|
-
throw new
|
|
8847
|
+
throw new import_sdk_core12.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
8848
8848
|
}
|
|
8849
8849
|
if (delegation.expiry.getTime() <= Date.now()) {
|
|
8850
|
-
throw new
|
|
8850
|
+
throw new import_sdk_core12.SessionExpiredError(delegation.expiry);
|
|
8851
8851
|
}
|
|
8852
8852
|
const expectedDids = [session.verificationMethod, this.sessionDid];
|
|
8853
8853
|
if (!expectedDids.some((did) => didPrincipalMatches2(delegation.delegateDID, did))) {
|
|
@@ -8900,17 +8900,17 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8900
8900
|
const graph = this._serviceGraph;
|
|
8901
8901
|
const session = this.currentTinyCloudSession();
|
|
8902
8902
|
if (!session) {
|
|
8903
|
-
throw new
|
|
8903
|
+
throw new import_sdk_core12.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
8904
8904
|
}
|
|
8905
8905
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
8906
8906
|
if (sessionExpiry !== void 0) {
|
|
8907
8907
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
8908
8908
|
if (sessionExpiry.getTime() <= Date.now() + marginMs) {
|
|
8909
|
-
throw new
|
|
8909
|
+
throw new import_sdk_core12.SessionExpiredError(sessionExpiry);
|
|
8910
8910
|
}
|
|
8911
8911
|
}
|
|
8912
|
-
const expanded = (0,
|
|
8913
|
-
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"));
|
|
8914
8914
|
const captured = bindsShareKey ? { ...session, jwk: { ...options?.expectedSessionKey ?? session.jwk } } : session;
|
|
8915
8915
|
const assertCapturedKey = bindsShareKey ? () => {
|
|
8916
8916
|
const live = session.jwk;
|
|
@@ -8966,7 +8966,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8966
8966
|
if (sessionExpiry !== void 0 && sessionExpiry < expiresAt) {
|
|
8967
8967
|
expiresAt = sessionExpiry;
|
|
8968
8968
|
}
|
|
8969
|
-
(0,
|
|
8969
|
+
(0, import_sdk_core12.assertExpiryWithinTechnicalLimit)(expiresAt, "siwe");
|
|
8970
8970
|
const delegations = [];
|
|
8971
8971
|
let rawEntriesAttached = false;
|
|
8972
8972
|
for (const [spaceId, entries] of bySpace) {
|
|
@@ -9007,7 +9007,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9007
9007
|
this.assertRuntimeGrantMessage(prepared.siwe, session);
|
|
9008
9008
|
}
|
|
9009
9009
|
const signature = options?.signMessage !== void 0 ? await options.signMessage(prepared.siwe) : await this.signer.signMessage(prepared.siwe);
|
|
9010
|
-
if (options?.signMessage !== void 0 && !await (0,
|
|
9010
|
+
if (options?.signMessage !== void 0 && !await (0, import_sdk_core12.verifyEip191MessageSignature)(prepared.siwe, signature, session.address)) {
|
|
9011
9011
|
throw new Error("The signature does not match the account that owns this session.");
|
|
9012
9012
|
}
|
|
9013
9013
|
graph.assertActive();
|
|
@@ -9186,10 +9186,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9186
9186
|
}
|
|
9187
9187
|
await this.assertMayCreateSpace(publicSpaceId);
|
|
9188
9188
|
await this.auth.hostPublicSpace(publicSpaceId);
|
|
9189
|
-
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];
|
|
9190
9190
|
const abilities = { kv: { "": kvActions } };
|
|
9191
9191
|
const now = /* @__PURE__ */ new Date();
|
|
9192
|
-
const expiryMs =
|
|
9192
|
+
const expiryMs = import_sdk_core12.EXPIRY.EPHEMERAL_MS;
|
|
9193
9193
|
const expirationTime = new Date(now.getTime() + expiryMs);
|
|
9194
9194
|
const prepared = this.wasmBindings.prepareSession({
|
|
9195
9195
|
abilities,
|
|
@@ -9234,7 +9234,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9234
9234
|
}]);
|
|
9235
9235
|
}
|
|
9236
9236
|
if (this._serviceContext) {
|
|
9237
|
-
const publicKV = new
|
|
9237
|
+
const publicKV = new import_sdk_core12.KVService({ prefix: "" });
|
|
9238
9238
|
const publicContext = this._serviceGraph.track(createServiceContext({
|
|
9239
9239
|
requestSink: this._serviceGraph.requestSink,
|
|
9240
9240
|
invoke: this._serviceGraph.invoke,
|
|
@@ -9359,14 +9359,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9359
9359
|
}
|
|
9360
9360
|
const session = this.currentTinyCloudSession();
|
|
9361
9361
|
if (!session) {
|
|
9362
|
-
throw new
|
|
9362
|
+
throw new import_sdk_core12.SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
9363
9363
|
}
|
|
9364
9364
|
const sessionExpiry = extractSiweExpiration(session.siwe);
|
|
9365
9365
|
if (sessionExpiry !== void 0) {
|
|
9366
9366
|
const now2 = Date.now();
|
|
9367
9367
|
const marginMs = _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
9368
9368
|
if (sessionExpiry.getTime() <= now2 + marginMs) {
|
|
9369
|
-
throw new
|
|
9369
|
+
throw new import_sdk_core12.SessionExpiredError(sessionExpiry);
|
|
9370
9370
|
}
|
|
9371
9371
|
}
|
|
9372
9372
|
if (!Array.isArray(permissions) || permissions.length === 0) {
|
|
@@ -9374,18 +9374,18 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9374
9374
|
"delegateTo requires a non-empty permissions array"
|
|
9375
9375
|
);
|
|
9376
9376
|
}
|
|
9377
|
-
const expandedEntries = (0,
|
|
9378
|
-
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("/"));
|
|
9379
9379
|
if (namedKeyEntries.length > 0) {
|
|
9380
|
-
if (expandedEntries.some((entry) => entry.service ===
|
|
9381
|
-
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");
|
|
9382
9382
|
}
|
|
9383
9383
|
if (options?.forceWalletSign) {
|
|
9384
|
-
throw new
|
|
9384
|
+
throw new import_sdk_core12.ManifestValidationError("named-key delegation requires a signed session grant");
|
|
9385
9385
|
}
|
|
9386
9386
|
const granted = this.projectSignedRecapCapabilities(session.siwe);
|
|
9387
9387
|
const { subset, missing } = this.signedCapabilitySubset(namedKeyEntries, granted);
|
|
9388
|
-
if (!subset) throw new
|
|
9388
|
+
if (!subset) throw new import_sdk_core12.PermissionNotInManifestError(missing, granted);
|
|
9389
9389
|
}
|
|
9390
9390
|
const now = /* @__PURE__ */ new Date();
|
|
9391
9391
|
const expiryMs = resolveExpiryMs(options?.expiry);
|
|
@@ -9419,12 +9419,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9419
9419
|
);
|
|
9420
9420
|
if ("refused" in plan) {
|
|
9421
9421
|
if (plan.refused === "SESSION_EXPIRING") {
|
|
9422
|
-
throw new
|
|
9422
|
+
throw new import_sdk_core12.SessionExpiredError(plan.expiredAt ?? sessionExpiry ?? /* @__PURE__ */ new Date(0));
|
|
9423
9423
|
}
|
|
9424
9424
|
if (plan.refused === "CAVEATED_AUTHORITY") {
|
|
9425
|
-
throw new
|
|
9425
|
+
throw new import_sdk_core12.CaveatedDelegationUnsupportedError(plan.caveated ?? []);
|
|
9426
9426
|
}
|
|
9427
|
-
throw new
|
|
9427
|
+
throw new import_sdk_core12.PermissionNotInManifestError(plan.missing ?? [], plan.granted ?? []);
|
|
9428
9428
|
}
|
|
9429
9429
|
if (plan.path === "runtime") {
|
|
9430
9430
|
const delegation2 = await this.createDelegationViaRuntimeGrant(
|
|
@@ -9463,7 +9463,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9463
9463
|
*/
|
|
9464
9464
|
planDerivation(expandedEntries, session, effectiveExpiration, nowMs) {
|
|
9465
9465
|
const caveatedRequest = expandedEntries.filter(
|
|
9466
|
-
(entry) => !(0,
|
|
9466
|
+
(entry) => !(0, import_sdk_core12.recapCaveatsEqual)(entry.caveats, void 0)
|
|
9467
9467
|
);
|
|
9468
9468
|
if (caveatedRequest.length > 0) {
|
|
9469
9469
|
return { refused: "CAVEATED_AUTHORITY", caveated: caveatedRequest };
|
|
@@ -9604,7 +9604,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9604
9604
|
}, getNodeReplicationLoaders().gatedNetwork);
|
|
9605
9605
|
return;
|
|
9606
9606
|
}
|
|
9607
|
-
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));
|
|
9608
9608
|
if (identityPrincipal === void 0) return;
|
|
9609
9609
|
const authority = await this.replicationAuthority();
|
|
9610
9610
|
if (epoch !== this.sessionEpoch || attempt !== this.latestSessionAttempt || this._kv !== kv || this._serviceContext !== context) return;
|
|
@@ -9700,7 +9700,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9700
9700
|
const spaceId = resolvedSpaces.size === 1 ? [...resolvedSpaces][0] : session.spaceId;
|
|
9701
9701
|
const abilities = {};
|
|
9702
9702
|
for (const entry of entries) {
|
|
9703
|
-
const shortService =
|
|
9703
|
+
const shortService = import_sdk_core12.SERVICE_LONG_TO_SHORT[entry.service];
|
|
9704
9704
|
if (shortService === void 0) {
|
|
9705
9705
|
throw new Error(
|
|
9706
9706
|
`delegateTo: unknown service '${entry.service}' \u2014 no short-form mapping`
|
|
@@ -9812,7 +9812,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9812
9812
|
return this.wasmBindings.makeSpaceId(session.address, session.chainId, space);
|
|
9813
9813
|
}
|
|
9814
9814
|
expandPermissionEntries(permissions) {
|
|
9815
|
-
return (0,
|
|
9815
|
+
return (0, import_sdk_core12.expandPermissionEntries)(permissions);
|
|
9816
9816
|
}
|
|
9817
9817
|
/**
|
|
9818
9818
|
* Checks the SIWE text a caller-supplied signer is asked to sign: it must be in canonical form (parsing and
|
|
@@ -9829,7 +9829,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9829
9829
|
if (parsed.prepareMessage() !== siwe) {
|
|
9830
9830
|
throw new Error("The prepared sign-in message is not in canonical form.");
|
|
9831
9831
|
}
|
|
9832
|
-
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)) {
|
|
9833
9833
|
throw new Error("The prepared sign-in message is for a different account or chain than this session.");
|
|
9834
9834
|
}
|
|
9835
9835
|
}
|
|
@@ -9839,10 +9839,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9839
9839
|
*/
|
|
9840
9840
|
assertDelegationCaveatsPreservable(entries) {
|
|
9841
9841
|
const caveated = entries.filter(
|
|
9842
|
-
(entry) => !(0,
|
|
9842
|
+
(entry) => !(0, import_sdk_core12.recapCaveatsEqual)(entry.caveats, void 0)
|
|
9843
9843
|
);
|
|
9844
9844
|
if (caveated.length > 0) {
|
|
9845
|
-
throw new
|
|
9845
|
+
throw new import_sdk_core12.CaveatedDelegationUnsupportedError(caveated);
|
|
9846
9846
|
}
|
|
9847
9847
|
}
|
|
9848
9848
|
/**
|
|
@@ -9854,7 +9854,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9854
9854
|
assertRuntimeGrantCaveatsPreservable(entries, requestedOperations, grant) {
|
|
9855
9855
|
const caveated = this.caveatedRuntimeGrantEntries(entries, requestedOperations, grant);
|
|
9856
9856
|
if (caveated.length > 0) {
|
|
9857
|
-
throw new
|
|
9857
|
+
throw new import_sdk_core12.CaveatedDelegationUnsupportedError(caveated);
|
|
9858
9858
|
}
|
|
9859
9859
|
}
|
|
9860
9860
|
/**
|
|
@@ -9871,7 +9871,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9871
9871
|
const requested = requestedOperations[operationIndex++];
|
|
9872
9872
|
if (!requested) continue;
|
|
9873
9873
|
const constrained = grant.operations.find(
|
|
9874
|
-
(granted) => this.operationCovers(granted, requested) && !(0,
|
|
9874
|
+
(granted) => this.operationCovers(granted, requested) && !(0, import_sdk_core12.recapCaveatsEqual)(granted.caveats, void 0)
|
|
9875
9875
|
);
|
|
9876
9876
|
if (constrained) {
|
|
9877
9877
|
caveated.push({
|
|
@@ -9888,7 +9888,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9888
9888
|
assertPortableDelegationCaveatsPreservable(delegation) {
|
|
9889
9889
|
const entries = [];
|
|
9890
9890
|
const add = (service, space, path, actions, caveats) => {
|
|
9891
|
-
if ((0,
|
|
9891
|
+
if ((0, import_sdk_core12.recapCaveatsEqual)(caveats, void 0)) return;
|
|
9892
9892
|
entries.push({
|
|
9893
9893
|
service: service.startsWith("tinycloud.") ? service : `tinycloud.${service}`,
|
|
9894
9894
|
space,
|
|
@@ -9908,11 +9908,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9908
9908
|
add(resource.service, resource.space, resource.path, resource.actions, resource.caveats);
|
|
9909
9909
|
}
|
|
9910
9910
|
if (entries.length > 0) {
|
|
9911
|
-
throw new
|
|
9911
|
+
throw new import_sdk_core12.CaveatedDelegationUnsupportedError(entries);
|
|
9912
9912
|
}
|
|
9913
9913
|
}
|
|
9914
9914
|
shortServiceName(service) {
|
|
9915
|
-
const short =
|
|
9915
|
+
const short = import_sdk_core12.SERVICE_LONG_TO_SHORT[service];
|
|
9916
9916
|
if (short === void 0) {
|
|
9917
9917
|
throw new Error(
|
|
9918
9918
|
`unknown service '${service}' \u2014 no short-form mapping`
|
|
@@ -9939,7 +9939,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9939
9939
|
return abilities;
|
|
9940
9940
|
}
|
|
9941
9941
|
isEncryptionPermissionEntry(entry) {
|
|
9942
|
-
return entry.service ===
|
|
9942
|
+
return entry.service === import_sdk_core12.ENCRYPTION_PERMISSION_SERVICE && this.isEncryptionNetworkOperation("encryption", entry.path, entry.space);
|
|
9943
9943
|
}
|
|
9944
9944
|
isRawRevocationPermissionEntry(entry) {
|
|
9945
9945
|
return entry.service === "tinycloud.delegation" && entry.path === "" && entry.space?.startsWith("urn:cid:") === true && entry.actions.includes("tinycloud.delegation/revoke");
|
|
@@ -9987,7 +9987,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
9987
9987
|
const missing = requested.filter((entry) => {
|
|
9988
9988
|
const raw = this.isEncryptionPermissionEntry(entry) || this.isRawRevocationPermissionEntry(entry);
|
|
9989
9989
|
const comparable = raw && this.isEncryptionPermissionEntry(entry) ? { ...entry, space: "encryption" } : entry;
|
|
9990
|
-
return !(0,
|
|
9990
|
+
return !(0, import_sdk_core12.isCapabilitySubset)([comparable], raw ? rawGranted : spaceGranted).subset;
|
|
9991
9991
|
});
|
|
9992
9992
|
return { subset: missing.length === 0, missing };
|
|
9993
9993
|
}
|
|
@@ -10234,7 +10234,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10234
10234
|
if (granted.service !== requested.service || !this.actionContains(granted.action, requested.action)) {
|
|
10235
10235
|
return false;
|
|
10236
10236
|
}
|
|
10237
|
-
if (requested.caveats !== void 0 && !(0,
|
|
10237
|
+
if (requested.caveats !== void 0 && !(0, import_sdk_core12.recapCaveatsEqual)(granted.caveats, requested.caveats)) {
|
|
10238
10238
|
return false;
|
|
10239
10239
|
}
|
|
10240
10240
|
if (granted.resource !== void 0 || requested.resource !== void 0) {
|
|
@@ -10256,7 +10256,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10256
10256
|
if (grantedAction === requestedAction) {
|
|
10257
10257
|
return true;
|
|
10258
10258
|
}
|
|
10259
|
-
if ((0,
|
|
10259
|
+
if ((0, import_sdk_core12.isExplicitOnlyAction)(requestedAction)) {
|
|
10260
10260
|
return false;
|
|
10261
10261
|
}
|
|
10262
10262
|
if (grantedAction.endsWith("/*")) {
|
|
@@ -10368,7 +10368,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10368
10368
|
if (resolvedDelegateDID.endsWith(".eth") && this.config.ensResolver) {
|
|
10369
10369
|
const address = await this.config.ensResolver.resolveAddress(resolvedDelegateDID);
|
|
10370
10370
|
if (!address) throw new Error(`Could not resolve ENS name: ${resolvedDelegateDID}`);
|
|
10371
|
-
resolvedDelegateDID = (0,
|
|
10371
|
+
resolvedDelegateDID = (0, import_sdk_core12.pkhDid)(address, 1);
|
|
10372
10372
|
}
|
|
10373
10373
|
const entries = legacyParamsToPermissionEntries(
|
|
10374
10374
|
params.actions,
|
|
@@ -10382,7 +10382,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10382
10382
|
});
|
|
10383
10383
|
return result.delegation;
|
|
10384
10384
|
} catch (err2) {
|
|
10385
|
-
if (err2 instanceof
|
|
10385
|
+
if (err2 instanceof import_sdk_core12.PermissionNotInManifestError) {
|
|
10386
10386
|
} else {
|
|
10387
10387
|
throw err2;
|
|
10388
10388
|
}
|
|
@@ -10426,7 +10426,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10426
10426
|
const now = /* @__PURE__ */ new Date();
|
|
10427
10427
|
const expiryMs = params.expiryMs ?? 60 * 60 * 1e3;
|
|
10428
10428
|
const expirationTime = new Date(now.getTime() + expiryMs);
|
|
10429
|
-
(0,
|
|
10429
|
+
(0, import_sdk_core12.assertExpiryWithinTechnicalLimit)(expirationTime, "siwe");
|
|
10430
10430
|
const prepared = this.wasmBindings.prepareSession({
|
|
10431
10431
|
abilities,
|
|
10432
10432
|
address: this.wasmBindings.ensureEip55(session.address),
|
|
@@ -10465,12 +10465,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10465
10465
|
};
|
|
10466
10466
|
const hasKvActions = params.actions.some((a) => a.startsWith("tinycloud.kv/"));
|
|
10467
10467
|
if (hasKvActions && params.includePublicSpace !== false) {
|
|
10468
|
-
const publicSpaceId = (0,
|
|
10468
|
+
const publicSpaceId = (0, import_sdk_core12.makePublicSpaceId)(
|
|
10469
10469
|
this.wasmBindings.ensureEip55(session.address),
|
|
10470
10470
|
session.chainId
|
|
10471
10471
|
);
|
|
10472
10472
|
const publicAbilities = {
|
|
10473
|
-
kv: { "": [
|
|
10473
|
+
kv: { "": [import_sdk_core12.KV.GET, import_sdk_core12.KV.PUT, import_sdk_core12.KV.METADATA] }
|
|
10474
10474
|
};
|
|
10475
10475
|
const publicPrepared = this.wasmBindings.prepareSession({
|
|
10476
10476
|
abilities: publicAbilities,
|
|
@@ -10495,7 +10495,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10495
10495
|
delegationHeader: publicSession.delegationHeader,
|
|
10496
10496
|
spaceId: publicSpaceId,
|
|
10497
10497
|
path: "",
|
|
10498
|
-
actions: [
|
|
10498
|
+
actions: [import_sdk_core12.KV.GET, import_sdk_core12.KV.PUT, import_sdk_core12.KV.METADATA],
|
|
10499
10499
|
disableSubDelegation: false,
|
|
10500
10500
|
expiry: expirationTime,
|
|
10501
10501
|
delegateDID: params.delegateDID,
|
|
@@ -10575,7 +10575,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10575
10575
|
const { abilities, rawAbilities } = this.buildActivationAbilities(delegation);
|
|
10576
10576
|
const now = /* @__PURE__ */ new Date();
|
|
10577
10577
|
const expirationTime = delegation.expiry;
|
|
10578
|
-
(0,
|
|
10578
|
+
(0, import_sdk_core12.assertExpiryWithinTechnicalLimit)(expirationTime, "siwe");
|
|
10579
10579
|
const prepared = this.wasmBindings.prepareSession({
|
|
10580
10580
|
abilities,
|
|
10581
10581
|
address: this.wasmBindings.ensureEip55(mySession.address),
|
|
@@ -10691,7 +10691,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
10691
10691
|
const now = /* @__PURE__ */ new Date();
|
|
10692
10692
|
const requestedExpiry = params.expiryMs === void 0 ? parentDelegation.expiry : new Date(now.getTime() + params.expiryMs);
|
|
10693
10693
|
const actualExpiry = requestedExpiry > parentDelegation.expiry ? parentDelegation.expiry : requestedExpiry;
|
|
10694
|
-
(0,
|
|
10694
|
+
(0, import_sdk_core12.assertExpiryWithinTechnicalLimit)(actualExpiry, "siwe");
|
|
10695
10695
|
const abilities = {};
|
|
10696
10696
|
const rawAbilities = {};
|
|
10697
10697
|
for (const resource of requestedResources) {
|
|
@@ -10765,7 +10765,6 @@ _TinyCloudNode.SESSION_EXPIRY_SAFETY_MARGIN_MS = 6e4;
|
|
|
10765
10765
|
var TinyCloudNode = _TinyCloudNode;
|
|
10766
10766
|
|
|
10767
10767
|
// src/core.ts
|
|
10768
|
-
var import_sdk_core14 = require("@tinycloud/sdk-core");
|
|
10769
10768
|
var import_sdk_core15 = require("@tinycloud/sdk-core");
|
|
10770
10769
|
var import_sdk_core16 = require("@tinycloud/sdk-core");
|
|
10771
10770
|
var import_sdk_core17 = require("@tinycloud/sdk-core");
|
|
@@ -10775,6 +10774,7 @@ var import_sdk_core20 = require("@tinycloud/sdk-core");
|
|
|
10775
10774
|
var import_sdk_core21 = require("@tinycloud/sdk-core");
|
|
10776
10775
|
var import_sdk_core22 = require("@tinycloud/sdk-core");
|
|
10777
10776
|
var import_sdk_core23 = require("@tinycloud/sdk-core");
|
|
10777
|
+
var import_sdk_core24 = require("@tinycloud/sdk-core");
|
|
10778
10778
|
// Annotate the CommonJS export names for ESM import in node:
|
|
10779
10779
|
0 && (module.exports = {
|
|
10780
10780
|
ACCOUNT_REGISTRY_PATH,
|