@tinycloud/sdk-core 2.3.0-beta.3 → 2.3.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +198 -183
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -2
- package/dist/index.d.ts +17 -2
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -37,52 +37,52 @@ __export(index_exports, {
|
|
|
37
37
|
CapabilityKeyRegistryErrorCodes: () => CapabilityKeyRegistryErrorCodes,
|
|
38
38
|
ClientSessionSchema: () => ClientSessionSchema,
|
|
39
39
|
CloudLocationResolutionError: () => CloudLocationResolutionError,
|
|
40
|
-
DECRYPT_ACTION: () =>
|
|
41
|
-
DECRYPT_FACT_TYPE: () =>
|
|
42
|
-
DECRYPT_RESULT_TYPE: () =>
|
|
40
|
+
DECRYPT_ACTION: () => import_sdk_services6.DECRYPT_ACTION,
|
|
41
|
+
DECRYPT_FACT_TYPE: () => import_sdk_services6.DECRYPT_FACT_TYPE,
|
|
42
|
+
DECRYPT_RESULT_TYPE: () => import_sdk_services6.DECRYPT_RESULT_TYPE,
|
|
43
43
|
DEFAULT_DEFAULTS: () => DEFAULT_DEFAULTS,
|
|
44
|
-
DEFAULT_ENCRYPTION_ALG: () =>
|
|
44
|
+
DEFAULT_ENCRYPTION_ALG: () => import_sdk_services6.DEFAULT_ENCRYPTION_ALG,
|
|
45
45
|
DEFAULT_EXPIRY: () => DEFAULT_EXPIRY,
|
|
46
|
-
DEFAULT_KEY_VERSION: () =>
|
|
46
|
+
DEFAULT_KEY_VERSION: () => import_sdk_services6.DEFAULT_KEY_VERSION,
|
|
47
47
|
DEFAULT_MANIFEST_SPACE: () => DEFAULT_MANIFEST_SPACE,
|
|
48
48
|
DEFAULT_MANIFEST_VERSION: () => DEFAULT_MANIFEST_VERSION,
|
|
49
49
|
DEFAULT_SIGNED_READ_URL_EXPIRY_MS: () => DEFAULT_SIGNED_READ_URL_EXPIRY_MS,
|
|
50
50
|
DEFAULT_TINYCLOUD_FALLBACK_HOST: () => DEFAULT_TINYCLOUD_FALLBACK_HOST,
|
|
51
51
|
DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL: () => DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL,
|
|
52
|
-
DataVaultService: () =>
|
|
53
|
-
DatabaseHandle: () =>
|
|
52
|
+
DataVaultService: () => import_sdk_services6.DataVaultService,
|
|
53
|
+
DatabaseHandle: () => import_sdk_services6.DatabaseHandle,
|
|
54
54
|
DelegationErrorCodes: () => DelegationErrorCodes,
|
|
55
55
|
DelegationManager: () => DelegationManager,
|
|
56
|
-
DuckDbAction: () =>
|
|
57
|
-
DuckDbDatabaseHandle: () =>
|
|
58
|
-
DuckDbService: () =>
|
|
56
|
+
DuckDbAction: () => import_sdk_services6.DuckDbAction,
|
|
57
|
+
DuckDbDatabaseHandle: () => import_sdk_services6.DuckDbDatabaseHandle,
|
|
58
|
+
DuckDbService: () => import_sdk_services6.DuckDbService,
|
|
59
59
|
ENCRYPTION_MANIFEST_SPACE: () => ENCRYPTION_MANIFEST_SPACE,
|
|
60
|
-
ENCRYPTION_NETWORK_URN_PREFIX: () =>
|
|
60
|
+
ENCRYPTION_NETWORK_URN_PREFIX: () => import_sdk_services6.ENCRYPTION_NETWORK_URN_PREFIX,
|
|
61
61
|
ENCRYPTION_PERMISSION_SERVICE: () => ENCRYPTION_PERMISSION_SERVICE,
|
|
62
|
-
ENCRYPTION_SERVICE: () =>
|
|
63
|
-
ENCRYPTION_SERVICE_SHORT: () =>
|
|
64
|
-
ENVELOPE_VERSION: () =>
|
|
62
|
+
ENCRYPTION_SERVICE: () => import_sdk_services6.ENCRYPTION_SERVICE,
|
|
63
|
+
ENCRYPTION_SERVICE_SHORT: () => import_sdk_services6.ENCRYPTION_SERVICE_SHORT,
|
|
64
|
+
ENVELOPE_VERSION: () => import_sdk_services6.ENVELOPE_VERSION,
|
|
65
65
|
EXPIRY: () => EXPIRY,
|
|
66
|
-
EncryptionService: () =>
|
|
66
|
+
EncryptionService: () => import_sdk_services6.EncryptionService,
|
|
67
67
|
EnsDataSchema: () => EnsDataSchema,
|
|
68
|
-
ErrorCodes: () =>
|
|
69
|
-
HooksService: () =>
|
|
68
|
+
ErrorCodes: () => import_sdk_services6.ErrorCodes,
|
|
69
|
+
HooksService: () => import_sdk_services6.HooksService,
|
|
70
70
|
IdentityParseError: () => IdentityParseError,
|
|
71
|
-
KVService: () =>
|
|
71
|
+
KVService: () => import_sdk_services6.KVService,
|
|
72
72
|
LocationRecordValidationError: () => LocationRecordValidationError,
|
|
73
73
|
ManifestValidationError: () => ManifestValidationError,
|
|
74
|
-
NETWORK_NAME_PATTERN: () =>
|
|
75
|
-
NetworkIdError: () =>
|
|
74
|
+
NETWORK_NAME_PATTERN: () => import_sdk_services6.NETWORK_NAME_PATTERN,
|
|
75
|
+
NetworkIdError: () => import_sdk_services6.NetworkIdError,
|
|
76
76
|
PermissionNotInManifestError: () => PermissionNotInManifestError,
|
|
77
|
-
PrefixedKVService: () =>
|
|
77
|
+
PrefixedKVService: () => import_sdk_services6.PrefixedKVService,
|
|
78
78
|
ProtocolMismatchError: () => ProtocolMismatchError,
|
|
79
|
-
SECRET_NAME_RE: () =>
|
|
79
|
+
SECRET_NAME_RE: () => import_sdk_services6.SECRET_NAME_RE,
|
|
80
80
|
SERVICE_LONG_TO_SHORT: () => SERVICE_LONG_TO_SHORT,
|
|
81
81
|
SERVICE_SHORT_TO_LONG: () => SERVICE_SHORT_TO_LONG,
|
|
82
|
-
SQLAction: () =>
|
|
83
|
-
SQLService: () =>
|
|
84
|
-
SecretsService: () =>
|
|
85
|
-
ServiceContext: () =>
|
|
82
|
+
SQLAction: () => import_sdk_services6.SQLAction,
|
|
83
|
+
SQLService: () => import_sdk_services6.SQLService,
|
|
84
|
+
SecretsService: () => import_sdk_services6.SecretsService,
|
|
85
|
+
ServiceContext: () => import_sdk_services6.ServiceContext,
|
|
86
86
|
SessionExpiredError: () => SessionExpiredError,
|
|
87
87
|
SharingService: () => SharingService,
|
|
88
88
|
SilentNotificationHandler: () => SilentNotificationHandler,
|
|
@@ -94,73 +94,75 @@ __export(index_exports, {
|
|
|
94
94
|
TinyCloud: () => TinyCloud,
|
|
95
95
|
UnsupportedFeatureError: () => UnsupportedFeatureError,
|
|
96
96
|
VAULT_PERMISSION_SERVICE: () => VAULT_PERMISSION_SERVICE,
|
|
97
|
-
VaultHeaders: () =>
|
|
98
|
-
VaultPublicSpaceKVActions: () =>
|
|
97
|
+
VaultHeaders: () => import_sdk_services6.VaultHeaders,
|
|
98
|
+
VaultPublicSpaceKVActions: () => import_sdk_services6.VaultPublicSpaceKVActions,
|
|
99
99
|
VersionCheckError: () => VersionCheckError,
|
|
100
100
|
activateSessionWithHost: () => activateSessionWithHost,
|
|
101
101
|
addressStorageKey: () => addressStorageKey,
|
|
102
102
|
applyPrefix: () => applyPrefix,
|
|
103
|
-
buildCanonicalDecryptRequest: () =>
|
|
104
|
-
buildDecryptAttenuation: () =>
|
|
105
|
-
buildDecryptFacts: () =>
|
|
106
|
-
buildDecryptInvocation: () =>
|
|
107
|
-
buildNetworkId: () =>
|
|
103
|
+
buildCanonicalDecryptRequest: () => import_sdk_services6.buildCanonicalDecryptRequest,
|
|
104
|
+
buildDecryptAttenuation: () => import_sdk_services6.buildDecryptAttenuation,
|
|
105
|
+
buildDecryptFacts: () => import_sdk_services6.buildDecryptFacts,
|
|
106
|
+
buildDecryptInvocation: () => import_sdk_services6.buildDecryptInvocation,
|
|
107
|
+
buildNetworkId: () => import_sdk_services6.buildNetworkId,
|
|
108
108
|
buildSpaceUri: () => buildSpaceUri,
|
|
109
|
-
canonicalHashHex: () =>
|
|
109
|
+
canonicalHashHex: () => import_sdk_services6.canonicalHashHex,
|
|
110
110
|
canonicalLocationPayload: () => canonicalLocationPayload,
|
|
111
|
-
canonicalSignedResponse: () =>
|
|
111
|
+
canonicalSignedResponse: () => import_sdk_services6.canonicalSignedResponse,
|
|
112
112
|
canonicalizeAddress: () => canonicalizeAddress,
|
|
113
113
|
canonicalizeDid: () => canonicalizeDid,
|
|
114
114
|
canonicalizeDidUrl: () => canonicalizeDidUrl,
|
|
115
|
-
canonicalizeEncryptionJson: () =>
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
canonicalizeEncryptionJson: () => import_sdk_services6.canonicalizeEncryptionJson,
|
|
116
|
+
canonicalizeNetworkId: () => canonicalizeNetworkId,
|
|
117
|
+
canonicalizeSecretScope: () => import_sdk_services6.canonicalizeSecretScope,
|
|
118
|
+
checkDecryptInvocationInput: () => import_sdk_services6.checkDecryptInvocationInput,
|
|
118
119
|
checkNodeInfo: () => checkNodeInfo,
|
|
119
120
|
composeManifestRequest: () => composeManifestRequest,
|
|
120
121
|
createCapabilityKeyRegistry: () => createCapabilityKeyRegistry,
|
|
121
122
|
createSharingService: () => createSharingService,
|
|
122
123
|
createSpaceService: () => createSpaceService,
|
|
123
|
-
createVaultCrypto: () =>
|
|
124
|
-
decryptEnvelopeWithKey: () =>
|
|
125
|
-
defaultRetryPolicy: () =>
|
|
124
|
+
createVaultCrypto: () => import_sdk_services6.createVaultCrypto,
|
|
125
|
+
decryptEnvelopeWithKey: () => import_sdk_services6.decryptEnvelopeWithKey,
|
|
126
|
+
defaultRetryPolicy: () => import_sdk_services6.defaultRetryPolicy,
|
|
126
127
|
defaultSignStrategy: () => defaultSignStrategy,
|
|
127
128
|
defaultSpaceCreationHandler: () => defaultSpaceCreationHandler,
|
|
128
|
-
deriveSignedReceiverKey: () =>
|
|
129
|
+
deriveSignedReceiverKey: () => import_sdk_services6.deriveSignedReceiverKey,
|
|
129
130
|
didCacheKey: () => didCacheKey,
|
|
130
131
|
didEquals: () => didEquals,
|
|
131
|
-
discoverNetwork: () =>
|
|
132
|
-
encryptToNetwork: () =>
|
|
133
|
-
encryptionBase64Decode: () =>
|
|
134
|
-
encryptionBase64Encode: () =>
|
|
135
|
-
encryptionError: () =>
|
|
136
|
-
encryptionUtf8Decode: () =>
|
|
137
|
-
encryptionUtf8Encode: () =>
|
|
138
|
-
ensureNetworkUsableForDecrypt: () =>
|
|
139
|
-
err: () =>
|
|
132
|
+
discoverNetwork: () => import_sdk_services6.discoverNetwork,
|
|
133
|
+
encryptToNetwork: () => import_sdk_services6.encryptToNetwork,
|
|
134
|
+
encryptionBase64Decode: () => import_sdk_services6.base64Decode,
|
|
135
|
+
encryptionBase64Encode: () => import_sdk_services6.base64Encode,
|
|
136
|
+
encryptionError: () => import_sdk_services6.encryptionError,
|
|
137
|
+
encryptionUtf8Decode: () => import_sdk_services6.utf8Decode,
|
|
138
|
+
encryptionUtf8Encode: () => import_sdk_services6.utf8Encode,
|
|
139
|
+
ensureNetworkUsableForDecrypt: () => import_sdk_services6.ensureNetworkUsableForDecrypt,
|
|
140
|
+
err: () => import_sdk_services6.err,
|
|
140
141
|
expandActionShortNames: () => expandActionShortNames,
|
|
141
142
|
expandPermissionEntries: () => expandPermissionEntries,
|
|
142
143
|
expandPermissionEntry: () => expandPermissionEntry,
|
|
143
144
|
fetchLocationRecord: () => fetchLocationRecord,
|
|
144
145
|
fetchPeerId: () => fetchPeerId,
|
|
145
|
-
generateRandomReceiverKey: () =>
|
|
146
|
-
hexDecode: () =>
|
|
147
|
-
hexEncode: () =>
|
|
146
|
+
generateRandomReceiverKey: () => import_sdk_services6.generateRandomReceiverKey,
|
|
147
|
+
hexDecode: () => import_sdk_services6.hexDecode,
|
|
148
|
+
hexEncode: () => import_sdk_services6.hexEncode,
|
|
148
149
|
httpUrlToMultiaddr: () => httpUrlToMultiaddr,
|
|
149
150
|
isCapabilitySubset: () => isCapabilitySubset,
|
|
150
151
|
isEvmAddress: () => isEvmAddress,
|
|
151
|
-
isNetworkId: () =>
|
|
152
|
+
isNetworkId: () => import_sdk_services6.isNetworkId,
|
|
152
153
|
loadManifest: () => loadManifest,
|
|
153
154
|
locationPayloadForRecord: () => locationPayloadForRecord,
|
|
154
155
|
makePkhSpaceId: () => makePkhSpaceId,
|
|
155
156
|
makePublicSpaceId: () => makePublicSpaceId,
|
|
156
157
|
manifestAbilitiesUnion: () => manifestAbilitiesUnion,
|
|
157
158
|
multiaddrToHttpUrl: () => multiaddrToHttpUrl,
|
|
158
|
-
networkDiscoveryKey: () =>
|
|
159
|
+
networkDiscoveryKey: () => import_sdk_services6.networkDiscoveryKey,
|
|
159
160
|
normalizeDefaults: () => normalizeDefaults,
|
|
160
|
-
ok: () =>
|
|
161
|
-
openWrappedKey: () =>
|
|
161
|
+
ok: () => import_sdk_services6.ok,
|
|
162
|
+
openWrappedKey: () => import_sdk_services6.openWrappedKey,
|
|
163
|
+
parseCanonicalNetworkId: () => parseCanonicalNetworkId,
|
|
162
164
|
parseExpiry: () => parseExpiry,
|
|
163
|
-
parseNetworkId: () =>
|
|
165
|
+
parseNetworkId: () => import_sdk_services6.parseNetworkId,
|
|
164
166
|
parsePkhDid: () => parsePkhDid,
|
|
165
167
|
parseRecapCapabilities: () => parseRecapCapabilities,
|
|
166
168
|
parseSpaceUri: () => parseSpaceUri,
|
|
@@ -169,21 +171,21 @@ __export(index_exports, {
|
|
|
169
171
|
principalDidEquals: () => principalDidEquals,
|
|
170
172
|
resolveCloudLocation: () => resolveCloudLocation,
|
|
171
173
|
resolveManifest: () => resolveManifest,
|
|
172
|
-
resolveSecretListPrefix: () =>
|
|
173
|
-
resolveSecretPath: () =>
|
|
174
|
+
resolveSecretListPrefix: () => import_sdk_services6.resolveSecretListPrefix,
|
|
175
|
+
resolveSecretPath: () => import_sdk_services6.resolveSecretPath,
|
|
174
176
|
resolveTinyCloudHosts: () => resolveTinyCloudHosts,
|
|
175
177
|
resourceCapabilitiesToAbilitiesMap: () => resourceCapabilitiesToAbilitiesMap,
|
|
176
178
|
resourceCapabilitiesToSpaceAbilitiesMap: () => resourceCapabilitiesToSpaceAbilitiesMap,
|
|
177
|
-
serviceError: () =>
|
|
179
|
+
serviceError: () => import_sdk_services6.serviceError,
|
|
178
180
|
signLocationRecord: () => signLocationRecord,
|
|
179
181
|
submitHostDelegation: () => submitHostDelegation,
|
|
180
182
|
validateClientSession: () => validateClientSession,
|
|
181
|
-
validateEnvelope: () =>
|
|
183
|
+
validateEnvelope: () => import_sdk_services6.validateEnvelope,
|
|
182
184
|
validateLocationRecord: () => validateLocationRecord,
|
|
183
185
|
validateLocationRecordPayload: () => validateLocationRecordPayload,
|
|
184
186
|
validateManifest: () => validateManifest,
|
|
185
187
|
validatePersistedSessionData: () => validatePersistedSessionData,
|
|
186
|
-
verifyDecryptResponse: () =>
|
|
188
|
+
verifyDecryptResponse: () => import_sdk_services6.verifyDecryptResponse,
|
|
187
189
|
verifyDidKeyEd25519Signature: () => verifyDidKeyEd25519Signature,
|
|
188
190
|
verifyLocationRecord: () => verifyLocationRecord
|
|
189
191
|
});
|
|
@@ -322,6 +324,17 @@ function makePkhSpaceId(address, chainId, name) {
|
|
|
322
324
|
return `tinycloud:pkh:eip155:${chainId}:${canonicalizeAddress(address)}:${name}`;
|
|
323
325
|
}
|
|
324
326
|
|
|
327
|
+
// src/networkId.ts
|
|
328
|
+
var import_sdk_services = require("@tinycloud/sdk-services");
|
|
329
|
+
function canonicalizeNetworkId(networkId) {
|
|
330
|
+
const parsed = (0, import_sdk_services.parseNetworkId)(networkId);
|
|
331
|
+
return (0, import_sdk_services.buildNetworkId)(canonicalizeDid(parsed.ownerDid), parsed.name);
|
|
332
|
+
}
|
|
333
|
+
function parseCanonicalNetworkId(networkId) {
|
|
334
|
+
const canonical = canonicalizeNetworkId(networkId);
|
|
335
|
+
return (0, import_sdk_services.parseNetworkId)(canonical);
|
|
336
|
+
}
|
|
337
|
+
|
|
325
338
|
// src/storage.schema.ts
|
|
326
339
|
var import_zod2 = require("zod");
|
|
327
340
|
var ethereumAddressPattern = /^0x[a-fA-F0-9]{40}$/;
|
|
@@ -410,10 +423,10 @@ function validatePersistedSessionData(data) {
|
|
|
410
423
|
}
|
|
411
424
|
|
|
412
425
|
// src/TinyCloud.ts
|
|
413
|
-
var
|
|
426
|
+
var import_sdk_services3 = require("@tinycloud/sdk-services");
|
|
414
427
|
|
|
415
428
|
// src/spaces/SpaceService.ts
|
|
416
|
-
var
|
|
429
|
+
var import_sdk_services2 = require("@tinycloud/sdk-services");
|
|
417
430
|
|
|
418
431
|
// src/spaces/Space.ts
|
|
419
432
|
var Space = class {
|
|
@@ -1187,8 +1200,8 @@ var SpaceService = class {
|
|
|
1187
1200
|
*/
|
|
1188
1201
|
async list() {
|
|
1189
1202
|
if (!this.session) {
|
|
1190
|
-
return (0,
|
|
1191
|
-
(0,
|
|
1203
|
+
return (0, import_sdk_services2.err)(
|
|
1204
|
+
(0, import_sdk_services2.serviceError)(SpaceErrorCodes.AUTH_REQUIRED, "Authentication required", SERVICE_NAME)
|
|
1192
1205
|
);
|
|
1193
1206
|
}
|
|
1194
1207
|
try {
|
|
@@ -1202,10 +1215,10 @@ var SpaceService = class {
|
|
|
1202
1215
|
spaces.push(...delegatedSpaces);
|
|
1203
1216
|
}
|
|
1204
1217
|
const uniqueSpaces = this.deduplicateSpaces(spaces);
|
|
1205
|
-
return (0,
|
|
1218
|
+
return (0, import_sdk_services2.ok)(uniqueSpaces);
|
|
1206
1219
|
} catch (error) {
|
|
1207
|
-
return (0,
|
|
1208
|
-
(0,
|
|
1220
|
+
return (0, import_sdk_services2.err)(
|
|
1221
|
+
(0, import_sdk_services2.serviceError)(
|
|
1209
1222
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1210
1223
|
`Failed to list spaces: ${String(error)}`,
|
|
1211
1224
|
SERVICE_NAME,
|
|
@@ -1226,8 +1239,8 @@ var SpaceService = class {
|
|
|
1226
1239
|
});
|
|
1227
1240
|
if (!response.ok) {
|
|
1228
1241
|
const errorText = await response.text();
|
|
1229
|
-
return (0,
|
|
1230
|
-
(0,
|
|
1242
|
+
return (0, import_sdk_services2.err)(
|
|
1243
|
+
(0, import_sdk_services2.serviceError)(
|
|
1231
1244
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1232
1245
|
`Failed to list owned spaces: ${response.status} - ${errorText}`,
|
|
1233
1246
|
SERVICE_NAME,
|
|
@@ -1238,8 +1251,8 @@ var SpaceService = class {
|
|
|
1238
1251
|
const rawData = await response.json();
|
|
1239
1252
|
const validationResult = validateServerOwnedSpacesResponse(rawData);
|
|
1240
1253
|
if (!validationResult.ok) {
|
|
1241
|
-
return (0,
|
|
1242
|
-
(0,
|
|
1254
|
+
return (0, import_sdk_services2.err)(
|
|
1255
|
+
(0, import_sdk_services2.serviceError)(
|
|
1243
1256
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1244
1257
|
validationResult.error.message,
|
|
1245
1258
|
SERVICE_NAME,
|
|
@@ -1255,10 +1268,10 @@ var SpaceService = class {
|
|
|
1255
1268
|
permissions: ["*"]
|
|
1256
1269
|
// Full permissions for owned spaces
|
|
1257
1270
|
}));
|
|
1258
|
-
return (0,
|
|
1271
|
+
return (0, import_sdk_services2.ok)(spaces);
|
|
1259
1272
|
} catch (error) {
|
|
1260
|
-
return (0,
|
|
1261
|
-
(0,
|
|
1273
|
+
return (0, import_sdk_services2.err)(
|
|
1274
|
+
(0, import_sdk_services2.serviceError)(
|
|
1262
1275
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1263
1276
|
`Network error listing owned spaces: ${String(error)}`,
|
|
1264
1277
|
SERVICE_NAME,
|
|
@@ -1339,13 +1352,13 @@ var SpaceService = class {
|
|
|
1339
1352
|
*/
|
|
1340
1353
|
async create(name) {
|
|
1341
1354
|
if (!this.session) {
|
|
1342
|
-
return (0,
|
|
1343
|
-
(0,
|
|
1355
|
+
return (0, import_sdk_services2.err)(
|
|
1356
|
+
(0, import_sdk_services2.serviceError)(SpaceErrorCodes.AUTH_REQUIRED, "Authentication required", SERVICE_NAME)
|
|
1344
1357
|
);
|
|
1345
1358
|
}
|
|
1346
1359
|
if (!name || !/^[a-zA-Z0-9_-]+$/.test(name)) {
|
|
1347
|
-
return (0,
|
|
1348
|
-
(0,
|
|
1360
|
+
return (0, import_sdk_services2.err)(
|
|
1361
|
+
(0, import_sdk_services2.serviceError)(
|
|
1349
1362
|
SpaceErrorCodes.INVALID_NAME,
|
|
1350
1363
|
"Space name must contain only alphanumeric characters, underscores, and hyphens",
|
|
1351
1364
|
SERVICE_NAME
|
|
@@ -1362,16 +1375,16 @@ var SpaceService = class {
|
|
|
1362
1375
|
if (!response.ok) {
|
|
1363
1376
|
const errorText = await response.text();
|
|
1364
1377
|
if (response.status === 409) {
|
|
1365
|
-
return (0,
|
|
1366
|
-
(0,
|
|
1378
|
+
return (0, import_sdk_services2.err)(
|
|
1379
|
+
(0, import_sdk_services2.serviceError)(
|
|
1367
1380
|
SpaceErrorCodes.ALREADY_EXISTS,
|
|
1368
1381
|
`Space "${name}" already exists`,
|
|
1369
1382
|
SERVICE_NAME
|
|
1370
1383
|
)
|
|
1371
1384
|
);
|
|
1372
1385
|
}
|
|
1373
|
-
return (0,
|
|
1374
|
-
(0,
|
|
1386
|
+
return (0, import_sdk_services2.err)(
|
|
1387
|
+
(0, import_sdk_services2.serviceError)(
|
|
1375
1388
|
SpaceErrorCodes.CREATION_FAILED,
|
|
1376
1389
|
`Failed to create space: ${response.status} - ${errorText}`,
|
|
1377
1390
|
SERVICE_NAME,
|
|
@@ -1382,8 +1395,8 @@ var SpaceService = class {
|
|
|
1382
1395
|
const rawData = await response.json();
|
|
1383
1396
|
const validationResult = validateServerCreateSpaceResponse(rawData);
|
|
1384
1397
|
if (!validationResult.ok) {
|
|
1385
|
-
return (0,
|
|
1386
|
-
(0,
|
|
1398
|
+
return (0, import_sdk_services2.err)(
|
|
1399
|
+
(0, import_sdk_services2.serviceError)(
|
|
1387
1400
|
SpaceErrorCodes.CREATION_FAILED,
|
|
1388
1401
|
validationResult.error.message,
|
|
1389
1402
|
SERVICE_NAME,
|
|
@@ -1399,10 +1412,10 @@ var SpaceService = class {
|
|
|
1399
1412
|
permissions: ["*"]
|
|
1400
1413
|
};
|
|
1401
1414
|
this.infoCache.set(spaceInfo.id, { info: spaceInfo, cachedAt: Date.now() });
|
|
1402
|
-
return (0,
|
|
1415
|
+
return (0, import_sdk_services2.ok)(spaceInfo);
|
|
1403
1416
|
} catch (error) {
|
|
1404
|
-
return (0,
|
|
1405
|
-
(0,
|
|
1417
|
+
return (0, import_sdk_services2.err)(
|
|
1418
|
+
(0, import_sdk_services2.serviceError)(
|
|
1406
1419
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1407
1420
|
`Network error creating space: ${String(error)}`,
|
|
1408
1421
|
SERVICE_NAME,
|
|
@@ -1466,10 +1479,10 @@ var SpaceService = class {
|
|
|
1466
1479
|
const spaceId = this.resolveSpaceId(nameOrUri);
|
|
1467
1480
|
const cached = this.infoCache.get(spaceId);
|
|
1468
1481
|
if (cached && Date.now() - cached.cachedAt < this.cacheTTL) {
|
|
1469
|
-
return (0,
|
|
1482
|
+
return (0, import_sdk_services2.ok)(true);
|
|
1470
1483
|
}
|
|
1471
1484
|
const infoResult = await this.getSpaceInfo(spaceId);
|
|
1472
|
-
return (0,
|
|
1485
|
+
return (0, import_sdk_services2.ok)(infoResult.ok);
|
|
1473
1486
|
}
|
|
1474
1487
|
// ===========================================================================
|
|
1475
1488
|
// Space Info
|
|
@@ -1480,11 +1493,11 @@ var SpaceService = class {
|
|
|
1480
1493
|
async getSpaceInfo(spaceId) {
|
|
1481
1494
|
const cached = this.infoCache.get(spaceId);
|
|
1482
1495
|
if (cached && Date.now() - cached.cachedAt < this.cacheTTL) {
|
|
1483
|
-
return (0,
|
|
1496
|
+
return (0, import_sdk_services2.ok)(cached.info);
|
|
1484
1497
|
}
|
|
1485
1498
|
if (!this.session) {
|
|
1486
|
-
return (0,
|
|
1487
|
-
(0,
|
|
1499
|
+
return (0, import_sdk_services2.err)(
|
|
1500
|
+
(0, import_sdk_services2.serviceError)(SpaceErrorCodes.AUTH_REQUIRED, "Authentication required", SERVICE_NAME)
|
|
1488
1501
|
);
|
|
1489
1502
|
}
|
|
1490
1503
|
try {
|
|
@@ -1496,13 +1509,13 @@ var SpaceService = class {
|
|
|
1496
1509
|
});
|
|
1497
1510
|
if (!response.ok) {
|
|
1498
1511
|
if (response.status === 404) {
|
|
1499
|
-
return (0,
|
|
1500
|
-
(0,
|
|
1512
|
+
return (0, import_sdk_services2.err)(
|
|
1513
|
+
(0, import_sdk_services2.serviceError)(SpaceErrorCodes.NOT_FOUND, `Space not found: ${spaceId}`, SERVICE_NAME)
|
|
1501
1514
|
);
|
|
1502
1515
|
}
|
|
1503
1516
|
const errorText = await response.text();
|
|
1504
|
-
return (0,
|
|
1505
|
-
(0,
|
|
1517
|
+
return (0, import_sdk_services2.err)(
|
|
1518
|
+
(0, import_sdk_services2.serviceError)(
|
|
1506
1519
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1507
1520
|
`Failed to get space info: ${response.status} - ${errorText}`,
|
|
1508
1521
|
SERVICE_NAME
|
|
@@ -1512,8 +1525,8 @@ var SpaceService = class {
|
|
|
1512
1525
|
const rawData = await response.json();
|
|
1513
1526
|
const validationResult = validateServerSpaceInfoResponse(rawData);
|
|
1514
1527
|
if (!validationResult.ok) {
|
|
1515
|
-
return (0,
|
|
1516
|
-
(0,
|
|
1528
|
+
return (0, import_sdk_services2.err)(
|
|
1529
|
+
(0, import_sdk_services2.serviceError)(
|
|
1517
1530
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1518
1531
|
validationResult.error.message,
|
|
1519
1532
|
SERVICE_NAME,
|
|
@@ -1531,10 +1544,10 @@ var SpaceService = class {
|
|
|
1531
1544
|
expiresAt: data.expiresAt ? new Date(data.expiresAt) : void 0
|
|
1532
1545
|
};
|
|
1533
1546
|
this.infoCache.set(spaceId, { info: spaceInfo, cachedAt: Date.now() });
|
|
1534
|
-
return (0,
|
|
1547
|
+
return (0, import_sdk_services2.ok)(spaceInfo);
|
|
1535
1548
|
} catch (error) {
|
|
1536
|
-
return (0,
|
|
1537
|
-
(0,
|
|
1549
|
+
return (0, import_sdk_services2.err)(
|
|
1550
|
+
(0, import_sdk_services2.serviceError)(
|
|
1538
1551
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1539
1552
|
`Network error getting space info: ${String(error)}`,
|
|
1540
1553
|
SERVICE_NAME,
|
|
@@ -1605,8 +1618,8 @@ var SpaceService = class {
|
|
|
1605
1618
|
});
|
|
1606
1619
|
if (!response.ok) {
|
|
1607
1620
|
const errorText = await response.text();
|
|
1608
|
-
return (0,
|
|
1609
|
-
(0,
|
|
1621
|
+
return (0, import_sdk_services2.err)(
|
|
1622
|
+
(0, import_sdk_services2.serviceError)(
|
|
1610
1623
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1611
1624
|
`Failed to list delegations: ${response.status} - ${errorText}`,
|
|
1612
1625
|
SERVICE_NAME
|
|
@@ -1616,8 +1629,8 @@ var SpaceService = class {
|
|
|
1616
1629
|
const rawData = await response.json();
|
|
1617
1630
|
const validationResult = validateServerDelegationsResponse(rawData);
|
|
1618
1631
|
if (!validationResult.ok) {
|
|
1619
|
-
return (0,
|
|
1620
|
-
(0,
|
|
1632
|
+
return (0, import_sdk_services2.err)(
|
|
1633
|
+
(0, import_sdk_services2.serviceError)(
|
|
1621
1634
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1622
1635
|
validationResult.error.message,
|
|
1623
1636
|
SERVICE_NAME,
|
|
@@ -1626,10 +1639,10 @@ var SpaceService = class {
|
|
|
1626
1639
|
);
|
|
1627
1640
|
}
|
|
1628
1641
|
const delegations = transformServerDelegations(validationResult.data, spaceId);
|
|
1629
|
-
return (0,
|
|
1642
|
+
return (0, import_sdk_services2.ok)(delegations);
|
|
1630
1643
|
} catch (error) {
|
|
1631
|
-
return (0,
|
|
1632
|
-
(0,
|
|
1644
|
+
return (0, import_sdk_services2.err)(
|
|
1645
|
+
(0, import_sdk_services2.serviceError)(
|
|
1633
1646
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1634
1647
|
`Network error listing delegations: ${String(error)}`,
|
|
1635
1648
|
SERVICE_NAME
|
|
@@ -1660,8 +1673,8 @@ var SpaceService = class {
|
|
|
1660
1673
|
});
|
|
1661
1674
|
if (!response.ok) {
|
|
1662
1675
|
const errorText = await response.text();
|
|
1663
|
-
return (0,
|
|
1664
|
-
(0,
|
|
1676
|
+
return (0, import_sdk_services2.err)(
|
|
1677
|
+
(0, import_sdk_services2.serviceError)(
|
|
1665
1678
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1666
1679
|
`Failed to list received delegations: ${response.status} - ${errorText}`,
|
|
1667
1680
|
SERVICE_NAME
|
|
@@ -1671,8 +1684,8 @@ var SpaceService = class {
|
|
|
1671
1684
|
const rawData = await response.json();
|
|
1672
1685
|
const validationResult = validateServerDelegationsResponse(rawData);
|
|
1673
1686
|
if (!validationResult.ok) {
|
|
1674
|
-
return (0,
|
|
1675
|
-
(0,
|
|
1687
|
+
return (0, import_sdk_services2.err)(
|
|
1688
|
+
(0, import_sdk_services2.serviceError)(
|
|
1676
1689
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1677
1690
|
validationResult.error.message,
|
|
1678
1691
|
SERVICE_NAME,
|
|
@@ -1681,10 +1694,10 @@ var SpaceService = class {
|
|
|
1681
1694
|
);
|
|
1682
1695
|
}
|
|
1683
1696
|
const delegations = transformServerDelegations(validationResult.data, spaceId);
|
|
1684
|
-
return (0,
|
|
1697
|
+
return (0, import_sdk_services2.ok)(delegations);
|
|
1685
1698
|
} catch (error) {
|
|
1686
|
-
return (0,
|
|
1687
|
-
(0,
|
|
1699
|
+
return (0, import_sdk_services2.err)(
|
|
1700
|
+
(0, import_sdk_services2.serviceError)(
|
|
1688
1701
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1689
1702
|
`Network error listing received delegations: ${String(error)}`,
|
|
1690
1703
|
SERVICE_NAME
|
|
@@ -1696,8 +1709,8 @@ var SpaceService = class {
|
|
|
1696
1709
|
if (self.createDelegationFn) {
|
|
1697
1710
|
return self.createDelegationFn({ ...params, spaceId });
|
|
1698
1711
|
}
|
|
1699
|
-
return (0,
|
|
1700
|
-
(0,
|
|
1712
|
+
return (0, import_sdk_services2.err)(
|
|
1713
|
+
(0, import_sdk_services2.serviceError)(
|
|
1701
1714
|
SpaceErrorCodes.NOT_INITIALIZED,
|
|
1702
1715
|
"Delegation creation requires a createDelegation function. This should be provided by the platform SDK (web-sdk or node-sdk).",
|
|
1703
1716
|
SERVICE_NAME
|
|
@@ -1719,18 +1732,18 @@ var SpaceService = class {
|
|
|
1719
1732
|
});
|
|
1720
1733
|
if (!response.ok) {
|
|
1721
1734
|
const errorText = await response.text();
|
|
1722
|
-
return (0,
|
|
1723
|
-
(0,
|
|
1735
|
+
return (0, import_sdk_services2.err)(
|
|
1736
|
+
(0, import_sdk_services2.serviceError)(
|
|
1724
1737
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1725
1738
|
`Failed to revoke delegation: ${response.status} - ${errorText}`,
|
|
1726
1739
|
SERVICE_NAME
|
|
1727
1740
|
)
|
|
1728
1741
|
);
|
|
1729
1742
|
}
|
|
1730
|
-
return (0,
|
|
1743
|
+
return (0, import_sdk_services2.ok)(void 0);
|
|
1731
1744
|
} catch (error) {
|
|
1732
|
-
return (0,
|
|
1733
|
-
(0,
|
|
1745
|
+
return (0, import_sdk_services2.err)(
|
|
1746
|
+
(0, import_sdk_services2.serviceError)(
|
|
1734
1747
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1735
1748
|
`Network error revoking delegation: ${String(error)}`,
|
|
1736
1749
|
SERVICE_NAME
|
|
@@ -1753,18 +1766,18 @@ var SpaceService = class {
|
|
|
1753
1766
|
if (self.sharingService) {
|
|
1754
1767
|
const result = await self.sharingService.generate(params);
|
|
1755
1768
|
if (!result.ok) {
|
|
1756
|
-
return (0,
|
|
1757
|
-
(0,
|
|
1769
|
+
return (0, import_sdk_services2.err)(
|
|
1770
|
+
(0, import_sdk_services2.serviceError)(
|
|
1758
1771
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
1759
1772
|
result.error.message || "Failed to generate share link",
|
|
1760
1773
|
SERVICE_NAME
|
|
1761
1774
|
)
|
|
1762
1775
|
);
|
|
1763
1776
|
}
|
|
1764
|
-
return (0,
|
|
1777
|
+
return (0, import_sdk_services2.ok)(result.data);
|
|
1765
1778
|
}
|
|
1766
|
-
return (0,
|
|
1767
|
-
(0,
|
|
1779
|
+
return (0, import_sdk_services2.err)(
|
|
1780
|
+
(0, import_sdk_services2.serviceError)(
|
|
1768
1781
|
SpaceErrorCodes.NOT_INITIALIZED,
|
|
1769
1782
|
"SharingService not configured. V2 sharing requires a SharingService instance.",
|
|
1770
1783
|
SERVICE_NAME
|
|
@@ -1772,8 +1785,8 @@ var SpaceService = class {
|
|
|
1772
1785
|
);
|
|
1773
1786
|
},
|
|
1774
1787
|
async list() {
|
|
1775
|
-
return (0,
|
|
1776
|
-
(0,
|
|
1788
|
+
return (0, import_sdk_services2.err)(
|
|
1789
|
+
(0, import_sdk_services2.serviceError)(
|
|
1777
1790
|
SpaceErrorCodes.NOT_INITIALIZED,
|
|
1778
1791
|
"Listing share links is not supported in v2. Share links are self-contained tokens that are not tracked on the server.",
|
|
1779
1792
|
SERVICE_NAME
|
|
@@ -1781,8 +1794,8 @@ var SpaceService = class {
|
|
|
1781
1794
|
);
|
|
1782
1795
|
},
|
|
1783
1796
|
async revoke(token) {
|
|
1784
|
-
return (0,
|
|
1785
|
-
(0,
|
|
1797
|
+
return (0, import_sdk_services2.err)(
|
|
1798
|
+
(0, import_sdk_services2.serviceError)(
|
|
1786
1799
|
SpaceErrorCodes.NOT_INITIALIZED,
|
|
1787
1800
|
"Revoking share links by token is not supported in v2. To revoke access, revoke the underlying delegation using space.delegations.revoke(cid).",
|
|
1788
1801
|
SERVICE_NAME
|
|
@@ -1842,7 +1855,7 @@ var TinyCloud = class _TinyCloud {
|
|
|
1842
1855
|
"hosts are required to initialize services. Provide them via config.hosts or initializeServices()."
|
|
1843
1856
|
);
|
|
1844
1857
|
}
|
|
1845
|
-
this._serviceContext = new
|
|
1858
|
+
this._serviceContext = new import_sdk_services3.ServiceContext({
|
|
1846
1859
|
invoke: effectiveInvoke,
|
|
1847
1860
|
invokeAny: this.config.invokeAny,
|
|
1848
1861
|
fetch: fetchFn ?? this.config.fetch ?? globalThis.fetch.bind(globalThis),
|
|
@@ -1850,10 +1863,10 @@ var TinyCloud = class _TinyCloud {
|
|
|
1850
1863
|
retryPolicy: this.config.retryPolicy
|
|
1851
1864
|
});
|
|
1852
1865
|
const serviceConstructors = {
|
|
1853
|
-
kv:
|
|
1854
|
-
sql:
|
|
1855
|
-
duckdb:
|
|
1856
|
-
hooks:
|
|
1866
|
+
kv: import_sdk_services3.KVService,
|
|
1867
|
+
sql: import_sdk_services3.SQLService,
|
|
1868
|
+
duckdb: import_sdk_services3.DuckDbService,
|
|
1869
|
+
hooks: import_sdk_services3.HooksService,
|
|
1857
1870
|
...this.config.services
|
|
1858
1871
|
};
|
|
1859
1872
|
for (const [name, ServiceClass] of Object.entries(serviceConstructors)) {
|
|
@@ -2108,18 +2121,18 @@ var TinyCloud = class _TinyCloud {
|
|
|
2108
2121
|
const address = this.address();
|
|
2109
2122
|
const chainId = this.chainId();
|
|
2110
2123
|
if (!address || !chainId) {
|
|
2111
|
-
return (0,
|
|
2112
|
-
(0,
|
|
2113
|
-
|
|
2124
|
+
return (0, import_sdk_services3.err)(
|
|
2125
|
+
(0, import_sdk_services3.serviceError)(
|
|
2126
|
+
import_sdk_services3.ErrorCodes.AUTH_REQUIRED,
|
|
2114
2127
|
"Must be signed in to ensure public space",
|
|
2115
2128
|
"public-space"
|
|
2116
2129
|
)
|
|
2117
2130
|
);
|
|
2118
2131
|
}
|
|
2119
2132
|
if (!this._serviceContext) {
|
|
2120
|
-
return (0,
|
|
2121
|
-
(0,
|
|
2122
|
-
|
|
2133
|
+
return (0, import_sdk_services3.err)(
|
|
2134
|
+
(0, import_sdk_services3.serviceError)(
|
|
2135
|
+
import_sdk_services3.ErrorCodes.AUTH_REQUIRED,
|
|
2123
2136
|
"Services not initialized. Call initializeServices() or signIn() first.",
|
|
2124
2137
|
"public-space"
|
|
2125
2138
|
)
|
|
@@ -2129,9 +2142,9 @@ var TinyCloud = class _TinyCloud {
|
|
|
2129
2142
|
try {
|
|
2130
2143
|
const session = this._serviceContext.session;
|
|
2131
2144
|
if (!session) {
|
|
2132
|
-
return (0,
|
|
2133
|
-
(0,
|
|
2134
|
-
|
|
2145
|
+
return (0, import_sdk_services3.err)(
|
|
2146
|
+
(0, import_sdk_services3.serviceError)(
|
|
2147
|
+
import_sdk_services3.ErrorCodes.AUTH_REQUIRED,
|
|
2135
2148
|
"No active session",
|
|
2136
2149
|
"public-space"
|
|
2137
2150
|
)
|
|
@@ -2148,7 +2161,7 @@ var TinyCloud = class _TinyCloud {
|
|
|
2148
2161
|
{ method: "POST", headers, body: JSON.stringify({ spaceId }) }
|
|
2149
2162
|
);
|
|
2150
2163
|
if (response.ok) {
|
|
2151
|
-
return (0,
|
|
2164
|
+
return (0, import_sdk_services3.ok)(void 0);
|
|
2152
2165
|
}
|
|
2153
2166
|
if (response.status === 404) {
|
|
2154
2167
|
const createHeaders = this._serviceContext.invoke(
|
|
@@ -2167,31 +2180,31 @@ var TinyCloud = class _TinyCloud {
|
|
|
2167
2180
|
);
|
|
2168
2181
|
if (!createResponse.ok) {
|
|
2169
2182
|
if (createResponse.status === 409) {
|
|
2170
|
-
return (0,
|
|
2183
|
+
return (0, import_sdk_services3.ok)(void 0);
|
|
2171
2184
|
}
|
|
2172
2185
|
const errorText2 = await createResponse.text();
|
|
2173
|
-
return (0,
|
|
2174
|
-
(0,
|
|
2175
|
-
|
|
2186
|
+
return (0, import_sdk_services3.err)(
|
|
2187
|
+
(0, import_sdk_services3.serviceError)(
|
|
2188
|
+
import_sdk_services3.ErrorCodes.NETWORK_ERROR,
|
|
2176
2189
|
`Failed to create public space: ${createResponse.status} - ${errorText2}`,
|
|
2177
2190
|
"public-space"
|
|
2178
2191
|
)
|
|
2179
2192
|
);
|
|
2180
2193
|
}
|
|
2181
|
-
return (0,
|
|
2194
|
+
return (0, import_sdk_services3.ok)(void 0);
|
|
2182
2195
|
}
|
|
2183
2196
|
const errorText = await response.text();
|
|
2184
|
-
return (0,
|
|
2185
|
-
(0,
|
|
2186
|
-
|
|
2197
|
+
return (0, import_sdk_services3.err)(
|
|
2198
|
+
(0, import_sdk_services3.serviceError)(
|
|
2199
|
+
import_sdk_services3.ErrorCodes.NETWORK_ERROR,
|
|
2187
2200
|
`Failed to check public space: ${response.status} - ${errorText}`,
|
|
2188
2201
|
"public-space"
|
|
2189
2202
|
)
|
|
2190
2203
|
);
|
|
2191
2204
|
} catch (error) {
|
|
2192
|
-
return (0,
|
|
2193
|
-
(0,
|
|
2194
|
-
|
|
2205
|
+
return (0, import_sdk_services3.err)(
|
|
2206
|
+
(0, import_sdk_services3.serviceError)(
|
|
2207
|
+
import_sdk_services3.ErrorCodes.NETWORK_ERROR,
|
|
2195
2208
|
`Network error ensuring public space: ${String(error)}`,
|
|
2196
2209
|
"public-space",
|
|
2197
2210
|
{ cause: error instanceof Error ? error : void 0 }
|
|
@@ -2224,8 +2237,8 @@ var TinyCloud = class _TinyCloud {
|
|
|
2224
2237
|
if (!session) {
|
|
2225
2238
|
throw new Error("No active session. Sign in first.");
|
|
2226
2239
|
}
|
|
2227
|
-
const publicKV = new
|
|
2228
|
-
const publicContext = new
|
|
2240
|
+
const publicKV = new import_sdk_services3.KVService({ prefix: "" });
|
|
2241
|
+
const publicContext = new import_sdk_services3.ServiceContext({
|
|
2229
2242
|
invoke: this._serviceContext.invoke,
|
|
2230
2243
|
fetch: this._serviceContext.fetch,
|
|
2231
2244
|
hosts: this._serviceContext.hosts,
|
|
@@ -2257,18 +2270,18 @@ var TinyCloud = class _TinyCloud {
|
|
|
2257
2270
|
const response = await doFetch(url, { method: "GET" });
|
|
2258
2271
|
if (!response.ok) {
|
|
2259
2272
|
if (response.status === 404) {
|
|
2260
|
-
return (0,
|
|
2261
|
-
(0,
|
|
2262
|
-
|
|
2273
|
+
return (0, import_sdk_services3.err)(
|
|
2274
|
+
(0, import_sdk_services3.serviceError)(
|
|
2275
|
+
import_sdk_services3.ErrorCodes.NOT_FOUND,
|
|
2263
2276
|
`Key not found: ${key} in space ${spaceId}`,
|
|
2264
2277
|
"public-space"
|
|
2265
2278
|
)
|
|
2266
2279
|
);
|
|
2267
2280
|
}
|
|
2268
2281
|
const errorText = await response.text();
|
|
2269
|
-
return (0,
|
|
2270
|
-
(0,
|
|
2271
|
-
|
|
2282
|
+
return (0, import_sdk_services3.err)(
|
|
2283
|
+
(0, import_sdk_services3.serviceError)(
|
|
2284
|
+
import_sdk_services3.ErrorCodes.NETWORK_ERROR,
|
|
2272
2285
|
`Failed to read public space: ${response.status} - ${errorText}`,
|
|
2273
2286
|
"public-space",
|
|
2274
2287
|
{ meta: { status: response.status } }
|
|
@@ -2287,11 +2300,11 @@ var TinyCloud = class _TinyCloud {
|
|
|
2287
2300
|
data = text;
|
|
2288
2301
|
}
|
|
2289
2302
|
}
|
|
2290
|
-
return (0,
|
|
2303
|
+
return (0, import_sdk_services3.ok)(data);
|
|
2291
2304
|
} catch (error) {
|
|
2292
|
-
return (0,
|
|
2293
|
-
(0,
|
|
2294
|
-
|
|
2305
|
+
return (0, import_sdk_services3.err)(
|
|
2306
|
+
(0, import_sdk_services3.serviceError)(
|
|
2307
|
+
import_sdk_services3.ErrorCodes.NETWORK_ERROR,
|
|
2295
2308
|
`Network error reading public space: ${String(error)}`,
|
|
2296
2309
|
"public-space",
|
|
2297
2310
|
{ cause: error instanceof Error ? error : void 0 }
|
|
@@ -2317,7 +2330,7 @@ var TinyCloud = class _TinyCloud {
|
|
|
2317
2330
|
};
|
|
2318
2331
|
|
|
2319
2332
|
// src/index.ts
|
|
2320
|
-
var
|
|
2333
|
+
var import_sdk_services6 = require("@tinycloud/sdk-services");
|
|
2321
2334
|
|
|
2322
2335
|
// src/space.ts
|
|
2323
2336
|
async function fetchPeerId(host, spaceId) {
|
|
@@ -2985,7 +2998,7 @@ function validateEncodedShareData(data) {
|
|
|
2985
2998
|
|
|
2986
2999
|
// src/manifest.ts
|
|
2987
3000
|
var import_ms = __toESM(require("ms"), 1);
|
|
2988
|
-
var
|
|
3001
|
+
var import_sdk_services4 = require("@tinycloud/sdk-services");
|
|
2989
3002
|
var ManifestValidationError = class extends Error {
|
|
2990
3003
|
constructor(message) {
|
|
2991
3004
|
super(`Manifest validation failed: ${message}`);
|
|
@@ -3232,13 +3245,13 @@ function validateManifestSecrets(secrets) {
|
|
|
3232
3245
|
throw new ManifestValidationError("manifest.secrets must be an object");
|
|
3233
3246
|
}
|
|
3234
3247
|
for (const [name, spec] of Object.entries(secrets)) {
|
|
3235
|
-
if (!
|
|
3248
|
+
if (!import_sdk_services4.SECRET_NAME_RE.test(name)) {
|
|
3236
3249
|
throw new ManifestValidationError(
|
|
3237
|
-
`manifest.secrets.${name} must match ${
|
|
3250
|
+
`manifest.secrets.${name} must match ${import_sdk_services4.SECRET_NAME_RE.source}`
|
|
3238
3251
|
);
|
|
3239
3252
|
}
|
|
3240
3253
|
try {
|
|
3241
|
-
(0,
|
|
3254
|
+
(0, import_sdk_services4.resolveSecretPath)(
|
|
3242
3255
|
secretNameFromSpec(name, spec),
|
|
3243
3256
|
{ scope: secretScopeFromSpec(spec) }
|
|
3244
3257
|
);
|
|
@@ -3450,7 +3463,7 @@ function secretEntriesForManifest(secrets) {
|
|
|
3450
3463
|
const entries = [];
|
|
3451
3464
|
for (const [name, spec] of Object.entries(secrets)) {
|
|
3452
3465
|
const actions = secretActionsFromSpec(name, spec);
|
|
3453
|
-
const secretPath = (0,
|
|
3466
|
+
const secretPath = (0, import_sdk_services4.resolveSecretPath)(
|
|
3454
3467
|
secretNameFromSpec(name, spec),
|
|
3455
3468
|
{ scope: secretScopeFromSpec(spec) }
|
|
3456
3469
|
);
|
|
@@ -4381,7 +4394,7 @@ function createSharingService(config) {
|
|
|
4381
4394
|
}
|
|
4382
4395
|
|
|
4383
4396
|
// src/authorization/CapabilityKeyRegistry.ts
|
|
4384
|
-
var
|
|
4397
|
+
var import_sdk_services5 = require("@tinycloud/sdk-services");
|
|
4385
4398
|
var SERVICE_NAME2 = "capability-key-registry";
|
|
4386
4399
|
var CapabilityKeyRegistryErrorCodes = {
|
|
4387
4400
|
/** Key not found in registry */
|
|
@@ -4599,8 +4612,8 @@ var CapabilityKeyRegistry = class {
|
|
|
4599
4612
|
revokeDelegation(cid) {
|
|
4600
4613
|
const stored = this.store.byCid.get(cid);
|
|
4601
4614
|
if (!stored) {
|
|
4602
|
-
return (0,
|
|
4603
|
-
(0,
|
|
4615
|
+
return (0, import_sdk_services5.err)(
|
|
4616
|
+
(0, import_sdk_services5.serviceError)(
|
|
4604
4617
|
CapabilityKeyRegistryErrorCodes.KEY_NOT_FOUND,
|
|
4605
4618
|
`Delegation not found: ${cid}`,
|
|
4606
4619
|
SERVICE_NAME2
|
|
@@ -4622,7 +4635,7 @@ var CapabilityKeyRegistry = class {
|
|
|
4622
4635
|
}
|
|
4623
4636
|
}
|
|
4624
4637
|
}
|
|
4625
|
-
return (0,
|
|
4638
|
+
return (0, import_sdk_services5.ok)(void 0);
|
|
4626
4639
|
}
|
|
4627
4640
|
// ===========================================================================
|
|
4628
4641
|
// Search
|
|
@@ -5466,6 +5479,7 @@ function parseRecapCapabilities(parseWasm, siwe) {
|
|
|
5466
5479
|
canonicalizeDid,
|
|
5467
5480
|
canonicalizeDidUrl,
|
|
5468
5481
|
canonicalizeEncryptionJson,
|
|
5482
|
+
canonicalizeNetworkId,
|
|
5469
5483
|
canonicalizeSecretScope,
|
|
5470
5484
|
checkDecryptInvocationInput,
|
|
5471
5485
|
checkNodeInfo,
|
|
@@ -5512,6 +5526,7 @@ function parseRecapCapabilities(parseWasm, siwe) {
|
|
|
5512
5526
|
normalizeDefaults,
|
|
5513
5527
|
ok,
|
|
5514
5528
|
openWrappedKey,
|
|
5529
|
+
parseCanonicalNetworkId,
|
|
5515
5530
|
parseExpiry,
|
|
5516
5531
|
parseNetworkId,
|
|
5517
5532
|
parsePkhDid,
|