@tinycloud/sdk-core 3.1.0-beta.1 → 3.1.0-beta.10
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/delegations/index.cjs +35 -9
- package/dist/delegations/index.cjs.map +1 -1
- package/dist/delegations/index.d.cts +2 -2
- package/dist/delegations/index.d.ts +2 -2
- package/dist/delegations/index.js +33 -7
- package/dist/delegations/index.js.map +1 -1
- package/dist/index.cjs +412 -358
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -8
- package/dist/index.d.ts +35 -8
- package/dist/index.js +246 -186
- package/dist/index.js.map +1 -1
- package/dist/policy/index.cjs +36 -16
- package/dist/policy/index.cjs.map +1 -1
- package/dist/policy/index.js +36 -16
- package/dist/policy/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/{recipient-types.schema-D9AI8tjN.d.cts → recipient-types.schema-_JkBDZB6.d.cts} +2 -2
- package/dist/{recipient-types.schema-D9AI8tjN.d.ts → recipient-types.schema-_JkBDZB6.d.ts} +2 -2
package/dist/index.cjs
CHANGED
|
@@ -73,13 +73,13 @@ __export(index_exports, {
|
|
|
73
73
|
ClientSessionSchema: () => ClientSessionSchema,
|
|
74
74
|
CloudLocationResolutionError: () => CloudLocationResolutionError,
|
|
75
75
|
CredentialError: () => CredentialError,
|
|
76
|
-
DECRYPT_ACTION: () =>
|
|
77
|
-
DECRYPT_FACT_TYPE: () =>
|
|
78
|
-
DECRYPT_RESULT_TYPE: () =>
|
|
76
|
+
DECRYPT_ACTION: () => import_sdk_services9.DECRYPT_ACTION,
|
|
77
|
+
DECRYPT_FACT_TYPE: () => import_sdk_services9.DECRYPT_FACT_TYPE,
|
|
78
|
+
DECRYPT_RESULT_TYPE: () => import_sdk_services9.DECRYPT_RESULT_TYPE,
|
|
79
79
|
DEFAULT_DEFAULTS: () => DEFAULT_DEFAULTS,
|
|
80
|
-
DEFAULT_ENCRYPTION_ALG: () =>
|
|
80
|
+
DEFAULT_ENCRYPTION_ALG: () => import_sdk_services9.DEFAULT_ENCRYPTION_ALG,
|
|
81
81
|
DEFAULT_EXPIRY: () => DEFAULT_EXPIRY,
|
|
82
|
-
DEFAULT_KEY_VERSION: () =>
|
|
82
|
+
DEFAULT_KEY_VERSION: () => import_sdk_services9.DEFAULT_KEY_VERSION,
|
|
83
83
|
DEFAULT_KNOWLEDGE_ROOT: () => DEFAULT_KNOWLEDGE_ROOT,
|
|
84
84
|
DEFAULT_LOCAL_NODE_PIN_STORAGE_KEY: () => DEFAULT_LOCAL_NODE_PIN_STORAGE_KEY,
|
|
85
85
|
DEFAULT_LOCAL_NODE_URL: () => DEFAULT_LOCAL_NODE_URL,
|
|
@@ -90,36 +90,36 @@ __export(index_exports, {
|
|
|
90
90
|
DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL: () => DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL,
|
|
91
91
|
DELIVERY_ADMISSION_DOMAIN: () => DELIVERY_ADMISSION_DOMAIN,
|
|
92
92
|
DUCKDB: () => import_bootstrap4.DUCKDB,
|
|
93
|
-
DataVaultService: () =>
|
|
94
|
-
DatabaseHandle: () =>
|
|
95
|
-
DecryptTransportResponseError: () =>
|
|
93
|
+
DataVaultService: () => import_sdk_services9.DataVaultService,
|
|
94
|
+
DatabaseHandle: () => import_sdk_services9.DatabaseHandle,
|
|
95
|
+
DecryptTransportResponseError: () => import_sdk_services9.DecryptTransportResponseError,
|
|
96
96
|
DelegationErrorCodes: () => DelegationErrorCodes,
|
|
97
97
|
DelegationManager: () => DelegationManager,
|
|
98
|
-
DuckDbAction: () =>
|
|
99
|
-
DuckDbDatabaseHandle: () =>
|
|
100
|
-
DuckDbService: () =>
|
|
98
|
+
DuckDbAction: () => import_sdk_services9.DuckDbAction,
|
|
99
|
+
DuckDbDatabaseHandle: () => import_sdk_services9.DuckDbDatabaseHandle,
|
|
100
|
+
DuckDbService: () => import_sdk_services9.DuckDbService,
|
|
101
101
|
ED25519_JCS_SIGNATURE_SUITE: () => ED25519_JCS_SIGNATURE_SUITE,
|
|
102
102
|
EIP191_JCS_SIGNATURE_SUITE: () => EIP191_JCS_SIGNATURE_SUITE,
|
|
103
103
|
EMAIL_CREDENTIAL_MAX_AGE_SECONDS: () => EMAIL_CREDENTIAL_MAX_AGE_SECONDS,
|
|
104
104
|
EMAIL_DOMAIN_CREDENTIAL_MAX_AGE_SECONDS: () => EMAIL_DOMAIN_CREDENTIAL_MAX_AGE_SECONDS,
|
|
105
105
|
ENCRYPTION: () => import_bootstrap4.ENCRYPTION,
|
|
106
106
|
ENCRYPTION_MANIFEST_SPACE: () => ENCRYPTION_MANIFEST_SPACE,
|
|
107
|
-
ENCRYPTION_NETWORK_URN_PREFIX: () =>
|
|
107
|
+
ENCRYPTION_NETWORK_URN_PREFIX: () => import_sdk_services9.ENCRYPTION_NETWORK_URN_PREFIX,
|
|
108
108
|
ENCRYPTION_PERMISSION_SERVICE: () => ENCRYPTION_PERMISSION_SERVICE,
|
|
109
|
-
ENCRYPTION_SERVICE: () =>
|
|
110
|
-
ENCRYPTION_SERVICE_SHORT: () =>
|
|
111
|
-
ENVELOPE_VERSION: () =>
|
|
109
|
+
ENCRYPTION_SERVICE: () => import_sdk_services9.ENCRYPTION_SERVICE,
|
|
110
|
+
ENCRYPTION_SERVICE_SHORT: () => import_sdk_services9.ENCRYPTION_SERVICE_SHORT,
|
|
111
|
+
ENVELOPE_VERSION: () => import_sdk_services9.ENVELOPE_VERSION,
|
|
112
112
|
EXPIRY: () => EXPIRY,
|
|
113
|
-
EncryptionService: () =>
|
|
113
|
+
EncryptionService: () => import_sdk_services9.EncryptionService,
|
|
114
114
|
EnsDataSchema: () => EnsDataSchema,
|
|
115
|
-
ErrorCodes: () =>
|
|
115
|
+
ErrorCodes: () => import_sdk_services9.ErrorCodes,
|
|
116
116
|
HOLDER_BINDING_DOMAIN: () => HOLDER_BINDING_DOMAIN,
|
|
117
117
|
HOLDER_KEY_BINDING_PRESENTATION_SCHEMA: () => HOLDER_KEY_BINDING_PRESENTATION_SCHEMA,
|
|
118
118
|
HOOKS: () => import_bootstrap4.HOOKS,
|
|
119
|
-
HooksService: () =>
|
|
119
|
+
HooksService: () => import_sdk_services9.HooksService,
|
|
120
120
|
IdentityParseError: () => IdentityParseError,
|
|
121
121
|
KV: () => import_bootstrap4.KV,
|
|
122
|
-
KVService: () =>
|
|
122
|
+
KVService: () => import_sdk_services9.KVService,
|
|
123
123
|
LAST_V2_CREATE_AT: () => LAST_V2_CREATE_AT,
|
|
124
124
|
LAST_V2_READ_AT: () => LAST_V2_READ_AT,
|
|
125
125
|
LISTEN_SQL_STATEMENT_CATALOG: () => LISTEN_SQL_STATEMENT_CATALOG,
|
|
@@ -138,8 +138,8 @@ __export(index_exports, {
|
|
|
138
138
|
MemorySenderShareRecordStorage: () => MemorySenderShareRecordStorage,
|
|
139
139
|
MemoryShareCache: () => MemoryShareCache,
|
|
140
140
|
NATIVE_PROJECTION_V1_DOMAIN: () => NATIVE_PROJECTION_V1_DOMAIN,
|
|
141
|
-
NETWORK_NAME_PATTERN: () =>
|
|
142
|
-
NetworkIdError: () =>
|
|
141
|
+
NETWORK_NAME_PATTERN: () => import_sdk_services9.NETWORK_NAME_PATTERN,
|
|
142
|
+
NetworkIdError: () => import_sdk_services9.NetworkIdError,
|
|
143
143
|
OPENKEY_ACTION_ID_SEPARATOR: () => OPENKEY_ACTION_ID_SEPARATOR,
|
|
144
144
|
OWNER_NODE_BINDING_TIMEOUT_MS: () => OWNER_NODE_BINDING_TIMEOUT_MS,
|
|
145
145
|
OpenKeyManageKeyError: () => OpenKeyManageKeyError,
|
|
@@ -166,7 +166,7 @@ __export(index_exports, {
|
|
|
166
166
|
POLICY_V2_SCHEMA: () => POLICY_V2_SCHEMA,
|
|
167
167
|
PORTABLE_DELEGATION_SCHEMA: () => PORTABLE_DELEGATION_SCHEMA,
|
|
168
168
|
PermissionNotInManifestError: () => PermissionNotInManifestError,
|
|
169
|
-
PrefixedKVService: () =>
|
|
169
|
+
PrefixedKVService: () => import_sdk_services9.PrefixedKVService,
|
|
170
170
|
ProtocolMismatchError: () => ProtocolMismatchError,
|
|
171
171
|
REQUESTER_ENGINE_RETRY_ATTEMPTS: () => REQUESTER_ENGINE_RETRY_ATTEMPTS,
|
|
172
172
|
REQUESTER_ENGINE_RETRY_MAX_DELAY_MS: () => REQUESTER_ENGINE_RETRY_MAX_DELAY_MS,
|
|
@@ -177,17 +177,19 @@ __export(index_exports, {
|
|
|
177
177
|
ROOT_STATUS_RENEWAL_V1_DOMAIN: () => ROOT_STATUS_RENEWAL_V1_DOMAIN,
|
|
178
178
|
ROOT_STATUS_V1_DOMAIN: () => ROOT_STATUS_V1_DOMAIN,
|
|
179
179
|
SECRETS_SPACE: () => SECRETS_SPACE,
|
|
180
|
-
SECRET_NAME_RE: () =>
|
|
180
|
+
SECRET_NAME_RE: () => import_sdk_services9.SECRET_NAME_RE,
|
|
181
181
|
SECRET_RECORDS_SCHEMA: () => import_bootstrap4.SECRET_RECORDS_SCHEMA,
|
|
182
182
|
SERVICE_LONG_TO_SHORT: () => SERVICE_LONG_TO_SHORT,
|
|
183
183
|
SERVICE_SHORT_TO_LONG: () => SERVICE_SHORT_TO_LONG,
|
|
184
184
|
SPACE: () => import_bootstrap4.SPACE,
|
|
185
185
|
SQL: () => import_bootstrap4.SQL,
|
|
186
|
-
SQLAction: () =>
|
|
187
|
-
SQLService: () =>
|
|
188
|
-
|
|
186
|
+
SQLAction: () => import_sdk_services9.SQLAction,
|
|
187
|
+
SQLService: () => import_sdk_services9.SQLService,
|
|
188
|
+
STORAGE_FULL_MESSAGE: () => import_sdk_services9.STORAGE_FULL_MESSAGE,
|
|
189
|
+
STORAGE_WRITE_TOO_LARGE_MESSAGE: () => import_sdk_services9.STORAGE_WRITE_TOO_LARGE_MESSAGE,
|
|
190
|
+
SecretsService: () => import_sdk_services9.SecretsService,
|
|
189
191
|
SenderShareStore: () => SenderShareStore,
|
|
190
|
-
ServiceContext: () =>
|
|
192
|
+
ServiceContext: () => import_sdk_services9.ServiceContext,
|
|
191
193
|
SessionExpiredError: () => SessionExpiredError,
|
|
192
194
|
ShareAccessError: () => ShareAccessError,
|
|
193
195
|
ShareAddressedDelegationEnvelopeV2Schema: () => ShareAddressedDelegationEnvelopeV2Schema,
|
|
@@ -220,14 +222,14 @@ __export(index_exports, {
|
|
|
220
222
|
TINYCLOUD_PUBLIC_SPACE_MANIFEST: () => import_bootstrap4.TINYCLOUD_PUBLIC_SPACE_MANIFEST,
|
|
221
223
|
TINYCLOUD_SECRETS_BOOTSTRAP_MANIFEST: () => import_bootstrap4.TINYCLOUD_SECRETS_BOOTSTRAP_MANIFEST,
|
|
222
224
|
TinyCloud: () => TinyCloud,
|
|
223
|
-
TinyCloudDebugLogger: () =>
|
|
225
|
+
TinyCloudDebugLogger: () => import_sdk_services9.TinyCloudDebugLogger,
|
|
224
226
|
TranscriptRequester: () => TranscriptRequester,
|
|
225
227
|
TranscriptRequesterError: () => TranscriptRequesterError,
|
|
226
228
|
UnsupportedFeatureError: () => UnsupportedFeatureError,
|
|
227
229
|
UnsupportedSignatureSuiteError: () => UnsupportedSignatureSuiteError,
|
|
228
230
|
VAULT_PERMISSION_SERVICE: () => VAULT_PERMISSION_SERVICE,
|
|
229
|
-
VaultHeaders: () =>
|
|
230
|
-
VaultPublicSpaceKVActions: () =>
|
|
231
|
+
VaultHeaders: () => import_sdk_services9.VaultHeaders,
|
|
232
|
+
VaultPublicSpaceKVActions: () => import_sdk_services9.VaultPublicSpaceKVActions,
|
|
231
233
|
VersionCheckError: () => VersionCheckError,
|
|
232
234
|
actionContains: () => actionContains,
|
|
233
235
|
activateSessionWithHost: () => activateSessionWithHost,
|
|
@@ -235,37 +237,37 @@ __export(index_exports, {
|
|
|
235
237
|
admitPolicyCredentialV3: () => admitPolicyCredentialV3,
|
|
236
238
|
admitPolicyCredentialV4: () => admitPolicyCredentialV4,
|
|
237
239
|
applyPrefix: () => applyPrefix,
|
|
238
|
-
authorizationVerdictOf: () =>
|
|
240
|
+
authorizationVerdictOf: () => import_sdk_services9.authorizationVerdictOf,
|
|
239
241
|
bootstrapEncryptionNetworkId: () => import_bootstrap4.bootstrapEncryptionNetworkId,
|
|
240
242
|
bootstrapSpaceId: () => import_bootstrap4.bootstrapSpaceId,
|
|
241
243
|
bootstrapSteps: () => import_bootstrap4.bootstrapSteps,
|
|
242
|
-
buildCanonicalDecryptRequest: () =>
|
|
243
|
-
buildDecryptAttenuation: () =>
|
|
244
|
-
buildDecryptFacts: () =>
|
|
245
|
-
buildDecryptInvocation: () =>
|
|
246
|
-
buildNetworkId: () =>
|
|
244
|
+
buildCanonicalDecryptRequest: () => import_sdk_services9.buildCanonicalDecryptRequest,
|
|
245
|
+
buildDecryptAttenuation: () => import_sdk_services9.buildDecryptAttenuation,
|
|
246
|
+
buildDecryptFacts: () => import_sdk_services9.buildDecryptFacts,
|
|
247
|
+
buildDecryptInvocation: () => import_sdk_services9.buildDecryptInvocation,
|
|
248
|
+
buildNetworkId: () => import_sdk_services9.buildNetworkId,
|
|
247
249
|
buildPolicyCredentialPresentationV3: () => buildPolicyCredentialPresentationV3,
|
|
248
250
|
buildPolicyCredentialPresentationV4: () => buildPolicyCredentialPresentationV4,
|
|
249
251
|
buildSpaceUri: () => buildSpaceUri,
|
|
250
252
|
canonicalDigest: () => canonicalDigest,
|
|
251
253
|
canonicalEmailDomain: () => import_share_envelope.canonicalEmailDomain,
|
|
252
|
-
canonicalHashHex: () =>
|
|
254
|
+
canonicalHashHex: () => import_sdk_services9.canonicalHashHex,
|
|
253
255
|
canonicalLocationPayload: () => canonicalLocationPayload,
|
|
254
256
|
canonicalMailbox: () => import_share_envelope.canonicalMailbox,
|
|
255
257
|
canonicalOwnerSharePolicy: () => canonicalOwnerSharePolicy,
|
|
256
|
-
canonicalSignedResponse: () =>
|
|
258
|
+
canonicalSignedResponse: () => import_sdk_services9.canonicalSignedResponse,
|
|
257
259
|
canonicalizeAddress: () => canonicalizeAddress,
|
|
258
260
|
canonicalizeDid: () => canonicalizeDid,
|
|
259
261
|
canonicalizeDidUrl: () => canonicalizeDidUrl,
|
|
260
|
-
canonicalizeEncryptionJson: () =>
|
|
262
|
+
canonicalizeEncryptionJson: () => import_sdk_services9.canonicalizeEncryptionJson,
|
|
261
263
|
canonicalizeNetworkId: () => canonicalizeNetworkId,
|
|
262
264
|
canonicalizeRecapCaveats: () => canonicalizeRecapCaveats,
|
|
263
|
-
canonicalizeSecretScope: () =>
|
|
265
|
+
canonicalizeSecretScope: () => import_sdk_services9.canonicalizeSecretScope,
|
|
264
266
|
canonicalizeSignedObjectUnsigned: () => canonicalizeSignedObjectUnsigned,
|
|
265
267
|
canonicalizeUnifiedPolicyCapability: () => canonicalizeUnifiedPolicyCapability,
|
|
266
|
-
checkDecryptInvocationInput: () =>
|
|
268
|
+
checkDecryptInvocationInput: () => import_sdk_services9.checkDecryptInvocationInput,
|
|
267
269
|
checkNodeInfo: () => checkNodeInfo,
|
|
268
|
-
clearTinyCloudDebugLogs: () =>
|
|
270
|
+
clearTinyCloudDebugLogs: () => import_sdk_services9.clearTinyCloudDebugLogs,
|
|
269
271
|
compactAttenuationContains: () => compactAttenuationContains,
|
|
270
272
|
composeBootstrapSpaceManifest: () => import_bootstrap4.composeBootstrapSpaceManifest,
|
|
271
273
|
composeManifestRequest: () => composeManifestRequest,
|
|
@@ -294,7 +296,7 @@ __export(index_exports, {
|
|
|
294
296
|
createStorageReceipt: () => createStorageReceipt,
|
|
295
297
|
createStoredCredentialRecord: () => createStoredCredentialRecord,
|
|
296
298
|
createTranscriptRequester: () => createTranscriptRequester,
|
|
297
|
-
createVaultCrypto: () =>
|
|
299
|
+
createVaultCrypto: () => import_sdk_services9.createVaultCrypto,
|
|
298
300
|
credentialEndpointPath: () => credentialEndpointPath,
|
|
299
301
|
credentialError: () => credentialError,
|
|
300
302
|
credentialIndexKey: () => credentialIndexKey,
|
|
@@ -302,37 +304,37 @@ __export(index_exports, {
|
|
|
302
304
|
credentialRecordKey: () => credentialRecordKey,
|
|
303
305
|
credentialRequirementDigest: () => credentialRequirementDigest,
|
|
304
306
|
decodeBase64Url: () => decodeBase64Url,
|
|
305
|
-
decryptEnvelopeWithKey: () =>
|
|
307
|
+
decryptEnvelopeWithKey: () => import_sdk_services9.decryptEnvelopeWithKey,
|
|
306
308
|
decryptShareBytesAsync: () => decryptShareBytesAsync,
|
|
307
|
-
defaultRetryPolicy: () =>
|
|
309
|
+
defaultRetryPolicy: () => import_sdk_services9.defaultRetryPolicy,
|
|
308
310
|
defaultSignStrategy: () => defaultSignStrategy,
|
|
309
311
|
defaultSpaceCreationHandler: () => defaultSpaceCreationHandler,
|
|
310
312
|
delegatePortablePolicySession: () => delegatePortablePolicySession,
|
|
311
313
|
deriveDelegationCid: () => deriveDelegationCid,
|
|
312
314
|
deriveSignedObjectMaterial: () => deriveSignedObjectMaterial,
|
|
313
|
-
deriveSignedReceiverKey: () =>
|
|
315
|
+
deriveSignedReceiverKey: () => import_sdk_services9.deriveSignedReceiverKey,
|
|
314
316
|
descriptorSatisfiesRequirement: () => descriptorSatisfiesRequirement,
|
|
315
317
|
didCacheKey: () => didCacheKey,
|
|
316
318
|
didEquals: () => didEquals,
|
|
317
319
|
diffImmutableSiweFields: () => diffImmutableSiweFields,
|
|
318
|
-
disableTinyCloudDebug: () =>
|
|
320
|
+
disableTinyCloudDebug: () => import_sdk_services9.disableTinyCloudDebug,
|
|
319
321
|
discoverLocalTinyCloudNode: () => discoverLocalTinyCloudNode,
|
|
320
|
-
discoverNetwork: () =>
|
|
321
|
-
enableTinyCloudDebug: () =>
|
|
322
|
+
discoverNetwork: () => import_sdk_services9.discoverNetwork,
|
|
323
|
+
enableTinyCloudDebug: () => import_sdk_services9.enableTinyCloudDebug,
|
|
322
324
|
encodeBase64Url: () => encodeBase64Url,
|
|
323
325
|
encodeInlineShareUrl: () => encodeInlineShareUrl,
|
|
324
326
|
encodeShareArtifact: () => encodeShareArtifact,
|
|
325
327
|
encodeShareUrl: () => encodeShareUrl,
|
|
326
328
|
encryptShareBytes: () => encryptShareBytes,
|
|
327
329
|
encryptShareBytesAsync: () => encryptShareBytesAsync,
|
|
328
|
-
encryptToNetwork: () =>
|
|
329
|
-
encryptionBase64Decode: () =>
|
|
330
|
-
encryptionBase64Encode: () =>
|
|
331
|
-
encryptionError: () =>
|
|
332
|
-
encryptionUtf8Decode: () =>
|
|
333
|
-
encryptionUtf8Encode: () =>
|
|
334
|
-
ensureNetworkUsableForDecrypt: () =>
|
|
335
|
-
err: () =>
|
|
330
|
+
encryptToNetwork: () => import_sdk_services9.encryptToNetwork,
|
|
331
|
+
encryptionBase64Decode: () => import_sdk_services9.base64Decode,
|
|
332
|
+
encryptionBase64Encode: () => import_sdk_services9.base64Encode,
|
|
333
|
+
encryptionError: () => import_sdk_services9.encryptionError,
|
|
334
|
+
encryptionUtf8Decode: () => import_sdk_services9.utf8Decode,
|
|
335
|
+
encryptionUtf8Encode: () => import_sdk_services9.utf8Encode,
|
|
336
|
+
ensureNetworkUsableForDecrypt: () => import_sdk_services9.ensureNetworkUsableForDecrypt,
|
|
337
|
+
err: () => import_sdk_services9.err,
|
|
336
338
|
expandActionShortNames: () => expandActionShortNames,
|
|
337
339
|
expandPermissionEntries: () => expandPermissionEntries,
|
|
338
340
|
expandPermissionEntry: () => expandPermissionEntry,
|
|
@@ -340,24 +342,27 @@ __export(index_exports, {
|
|
|
340
342
|
extractRecapAttenuations: () => extractRecapAttenuations,
|
|
341
343
|
fetchLocationRecord: () => fetchLocationRecord,
|
|
342
344
|
fetchPeerId: () => fetchPeerId,
|
|
343
|
-
generateRandomReceiverKey: () =>
|
|
345
|
+
generateRandomReceiverKey: () => import_sdk_services9.generateRandomReceiverKey,
|
|
344
346
|
getPolicyRootStatusV3: () => getPolicyRootStatusV3,
|
|
345
|
-
getTinyCloudDebugLogs: () =>
|
|
347
|
+
getTinyCloudDebugLogs: () => import_sdk_services9.getTinyCloudDebugLogs,
|
|
346
348
|
hasTinyCloudManageKeyScope: () => hasTinyCloudManageKeyScope,
|
|
347
|
-
hexDecode: () =>
|
|
348
|
-
hexEncode: () =>
|
|
349
|
+
hexDecode: () => import_sdk_services9.hexDecode,
|
|
350
|
+
hexEncode: () => import_sdk_services9.hexEncode,
|
|
349
351
|
holderBindingCanonicalBytes: () => holderBindingCanonicalBytes,
|
|
350
352
|
holderBindingSigningBytes: () => holderBindingSigningBytes,
|
|
353
|
+
httpResponseError: () => httpResponseError,
|
|
351
354
|
httpUrlToMultiaddr: () => httpUrlToMultiaddr,
|
|
352
355
|
importPortableDelegation: () => importPortableDelegation,
|
|
353
|
-
installTinyCloudDebugGlobals: () =>
|
|
356
|
+
installTinyCloudDebugGlobals: () => import_sdk_services9.installTinyCloudDebugGlobals,
|
|
354
357
|
intersectShareCapabilities: () => intersectShareCapabilities,
|
|
355
358
|
isCanonicalEmailDomain: () => import_share_envelope.isCanonicalEmailDomain,
|
|
356
359
|
isCapabilitySubset: () => isCapabilitySubset,
|
|
357
360
|
isDigest: () => isDigest,
|
|
358
361
|
isEvmAddress: () => isEvmAddress,
|
|
359
|
-
|
|
362
|
+
isExplicitOnlyAction: () => isExplicitOnlyAction,
|
|
363
|
+
isNetworkId: () => import_sdk_services9.isNetworkId,
|
|
360
364
|
isPlausibleOpenKeyActionId: () => isPlausibleOpenKeyActionId,
|
|
365
|
+
isStorageFullError: () => import_sdk_services9.isStorageFullError,
|
|
361
366
|
isV2ShareLink: () => isV2ShareLink,
|
|
362
367
|
issuedCredentialEnvelopeFromVerified: () => issuedCredentialEnvelopeFromVerified,
|
|
363
368
|
jcsCanonicalize: () => jcsCanonicalize,
|
|
@@ -368,28 +373,29 @@ __export(index_exports, {
|
|
|
368
373
|
makePublicSpaceId: () => makePublicSpaceId,
|
|
369
374
|
manifestAbilitiesUnion: () => manifestAbilitiesUnion,
|
|
370
375
|
multiaddrToHttpUrl: () => multiaddrToHttpUrl,
|
|
371
|
-
networkDiscoveryKey: () =>
|
|
376
|
+
networkDiscoveryKey: () => import_sdk_services9.networkDiscoveryKey,
|
|
372
377
|
normalizeDefaults: () => normalizeDefaults,
|
|
373
378
|
normalizeJson: () => normalizeJson,
|
|
374
379
|
normalizeShareActions: () => normalizeShareActions,
|
|
375
380
|
normalizeShareRecipientTarget: () => normalizeShareRecipientTarget,
|
|
376
381
|
normalizeShareResource: () => normalizeShareResource,
|
|
377
382
|
normalizeUnifiedPolicyCapability: () => normalizeUnifiedPolicyCapability,
|
|
378
|
-
ok: () =>
|
|
379
|
-
openWrappedKey: () =>
|
|
383
|
+
ok: () => import_sdk_services9.ok,
|
|
384
|
+
openWrappedKey: () => import_sdk_services9.openWrappedKey,
|
|
380
385
|
parseCanonicalNetworkId: () => parseCanonicalNetworkId,
|
|
381
386
|
parseCanonicalRecapResource: () => parseCanonicalRecapResource,
|
|
382
387
|
parseCanonicalTinyCloudIdentity: () => parseCanonicalTinyCloudIdentity,
|
|
383
388
|
parseCanonicalTinyCloudIdentityClaims: () => parseCanonicalTinyCloudIdentityClaims,
|
|
389
|
+
parseCapabilityResource: () => import_sdk_services9.parseCapabilityResource,
|
|
384
390
|
parseCompactUcanAuthorization: () => parseCompactUcanAuthorization,
|
|
385
391
|
parseExpiry: () => parseExpiry,
|
|
386
|
-
parseNetworkId: () =>
|
|
392
|
+
parseNetworkId: () => import_sdk_services9.parseNetworkId,
|
|
387
393
|
parseNodeNativePortableDelegation: () => parseNodeNativePortableDelegation,
|
|
388
394
|
parsePkhDid: () => parsePkhDid,
|
|
389
395
|
parsePolicySessionUcan: () => parsePolicySessionUcan,
|
|
390
396
|
parsePortableDelegation: () => parsePortableDelegation,
|
|
391
397
|
parseRecapCapabilities: () => parseRecapCapabilities,
|
|
392
|
-
parseSecretCatalogKey: () =>
|
|
398
|
+
parseSecretCatalogKey: () => import_sdk_services9.parseSecretCatalogKey,
|
|
393
399
|
parseShareArtifact: () => parseShareArtifact,
|
|
394
400
|
parseShareUrl: () => parseShareUrl,
|
|
395
401
|
parseSpaceUri: () => parseSpaceUri,
|
|
@@ -410,8 +416,8 @@ __export(index_exports, {
|
|
|
410
416
|
resolveCloudLocation: () => resolveCloudLocation,
|
|
411
417
|
resolveManifest: () => resolveManifest,
|
|
412
418
|
resolveManifestKnowledgeRoot: () => resolveManifestKnowledgeRoot,
|
|
413
|
-
resolveSecretListPrefix: () =>
|
|
414
|
-
resolveSecretPath: () =>
|
|
419
|
+
resolveSecretListPrefix: () => import_sdk_services9.resolveSecretListPrefix,
|
|
420
|
+
resolveSecretPath: () => import_sdk_services9.resolveSecretPath,
|
|
415
421
|
resolveTinyCloudHosts: () => resolveTinyCloudHosts,
|
|
416
422
|
resourceCapabilitiesToAbilitiesMap: () => resourceCapabilitiesToAbilitiesMap,
|
|
417
423
|
resourceCapabilitiesToSpaceAbilitiesMap: () => resourceCapabilitiesToSpaceAbilitiesMap,
|
|
@@ -419,7 +425,7 @@ __export(index_exports, {
|
|
|
419
425
|
revokePolicyRootV3: () => revokePolicyRootV3,
|
|
420
426
|
serializeJcsJson: () => serialize,
|
|
421
427
|
serializePortableDelegation: () => serializePortableDelegation,
|
|
422
|
-
serviceError: () =>
|
|
428
|
+
serviceError: () => import_sdk_services9.serviceError,
|
|
423
429
|
sha256Base64Url: () => sha256Base64Url,
|
|
424
430
|
shareCapabilityAllows: () => shareCapabilityAllows,
|
|
425
431
|
signCompactPolicyDescendant: () => signCompactPolicyDescendant,
|
|
@@ -430,7 +436,7 @@ __export(index_exports, {
|
|
|
430
436
|
signShareEnvelope: () => signShareEnvelope,
|
|
431
437
|
signedObjectIdFor: () => signedObjectIdFor,
|
|
432
438
|
submitHostDelegation: () => submitHostDelegation,
|
|
433
|
-
tinyCloudDebugLogger: () =>
|
|
439
|
+
tinyCloudDebugLogger: () => import_sdk_services9.tinyCloudDebugLogger,
|
|
434
440
|
toSignedObjectError: () => toSignedObjectError,
|
|
435
441
|
unauthorizedRecapCapabilities: () => unauthorizedRecapCapabilities,
|
|
436
442
|
unifiedNativeProjectionHashHex: () => unifiedNativeProjectionHashHex,
|
|
@@ -442,7 +448,7 @@ __export(index_exports, {
|
|
|
442
448
|
validateCredentialFlowDescriptor: () => validateCredentialFlowDescriptor,
|
|
443
449
|
validateCredentialHolderBinding: () => validateCredentialHolderBinding,
|
|
444
450
|
validateCredentialRequirement: () => validateCredentialRequirement,
|
|
445
|
-
validateEnvelope: () =>
|
|
451
|
+
validateEnvelope: () => import_sdk_services9.validateEnvelope,
|
|
446
452
|
validateLocationRecord: () => validateLocationRecord,
|
|
447
453
|
validateLocationRecordPayload: () => validateLocationRecordPayload,
|
|
448
454
|
validateManifest: () => validateManifest,
|
|
@@ -461,7 +467,8 @@ __export(index_exports, {
|
|
|
461
467
|
validatePolicyUnsigned: () => validatePolicyUnsigned,
|
|
462
468
|
validateShareDeliveryAuthorizationV3Bytes: () => validateShareDeliveryAuthorizationV3Bytes,
|
|
463
469
|
validateUnifiedPolicyV2: () => validateUnifiedPolicyV2,
|
|
464
|
-
|
|
470
|
+
validatedCapabilityOf: () => import_sdk_services9.validatedCapabilityOf,
|
|
471
|
+
verifyDecryptResponse: () => import_sdk_services9.verifyDecryptResponse,
|
|
465
472
|
verifyDidKeyEd25519Signature: () => verifyDidKeyEd25519Signature,
|
|
466
473
|
verifyEip191MessageSignature: () => verifyEip191MessageSignature,
|
|
467
474
|
verifyIssuedCredential: () => verifyIssuedCredential,
|
|
@@ -3903,6 +3910,32 @@ var import_sha256 = require("@noble/hashes/sha256");
|
|
|
3903
3910
|
var import_blake3 = require("@noble/hashes/blake3");
|
|
3904
3911
|
var import_ed255193 = require("@noble/curves/ed25519");
|
|
3905
3912
|
var import_zod2 = require("zod");
|
|
3913
|
+
|
|
3914
|
+
// src/http-error.ts
|
|
3915
|
+
var import_sdk_services = require("@tinycloud/sdk-services");
|
|
3916
|
+
async function httpResponseError(response, context) {
|
|
3917
|
+
let body;
|
|
3918
|
+
try {
|
|
3919
|
+
body = await response.text();
|
|
3920
|
+
} catch {
|
|
3921
|
+
body = response.statusText;
|
|
3922
|
+
}
|
|
3923
|
+
body = body.trim().slice(0, 512);
|
|
3924
|
+
return Object.assign(new Error(`${context}: HTTP ${response.status}${body ? ` - ${body}` : ""}`), {
|
|
3925
|
+
status: response.status
|
|
3926
|
+
});
|
|
3927
|
+
}
|
|
3928
|
+
async function serviceHttpError(response, code3, context, service) {
|
|
3929
|
+
const failure = await httpResponseError(response, context);
|
|
3930
|
+
return (0, import_sdk_services.serviceError)(
|
|
3931
|
+
response.status === 401 || response.status === 403 ? import_sdk_services.ErrorCodes.AUTH_UNAUTHORIZED : code3,
|
|
3932
|
+
failure.message,
|
|
3933
|
+
service,
|
|
3934
|
+
{ meta: { status: response.status } }
|
|
3935
|
+
);
|
|
3936
|
+
}
|
|
3937
|
+
|
|
3938
|
+
// src/policy/unified.ts
|
|
3906
3939
|
var POLICY_V1_SCHEMA = "xyz.tinycloud.policy/policy/v1";
|
|
3907
3940
|
var POLICY_CAPABILITY_V1_SCHEMA = "xyz.tinycloud.policy/capability/v1";
|
|
3908
3941
|
var POLICY_ENFORCEMENT_DELEGATION_V2_SCHEMA = "xyz.tinycloud.policy/enforcement-delegation/v2";
|
|
@@ -3930,7 +3963,7 @@ async function requestPolicyChallengeV3(input) {
|
|
|
3930
3963
|
headers: { accept: "application/json", "content-type": "application/json" },
|
|
3931
3964
|
body: JSON.stringify({ policyCid: input.policyCid, recipientDid: input.recipientDid, requestedCapabilities: input.requestedCapabilities.map(normalizeUnifiedPolicyCapability) })
|
|
3932
3965
|
});
|
|
3933
|
-
if (!response.ok) throw
|
|
3966
|
+
if (!response.ok) throw await httpResponseError(response, "policy challenge rejected");
|
|
3934
3967
|
const value = object2(await response.json(), "policy challenge");
|
|
3935
3968
|
if (typeof value.challengeId !== "string" || typeof value.nonce !== "string" || value.policyCid !== input.policyCid || value.recipientDid !== input.recipientDid)
|
|
3936
3969
|
throw new Error("policy challenge binding is invalid");
|
|
@@ -3993,7 +4026,7 @@ async function getPolicyRootStatusV3(input) {
|
|
|
3993
4026
|
redirect: "error",
|
|
3994
4027
|
headers: { accept: "application/json" }
|
|
3995
4028
|
});
|
|
3996
|
-
if (!response.ok) throw
|
|
4029
|
+
if (!response.ok) throw await httpResponseError(response, "policy root status rejected");
|
|
3997
4030
|
const value = object2(await response.json(), "policy root status");
|
|
3998
4031
|
const checkpoint = object2(value.checkpoint, "policy root checkpoint");
|
|
3999
4032
|
if (value.rootCid !== input.rootCid || value.state !== "active" && value.state !== "revoked" || value.state !== checkpoint.state || !verifyPolicyRootStatusCheckpointV3({ rootCid: input.rootCid, checkpoint, expectedNodeAudience: input.expectedNodeAudience, now: input.now }))
|
|
@@ -4053,9 +4086,12 @@ async function renewPolicyRootStatusV3(input) {
|
|
|
4053
4086
|
headers: { accept: "application/json", "content-type": "application/json" },
|
|
4054
4087
|
body: JSON.stringify({ rootCid: input.rootCid, renewal: { ...unsigned, signature: { suite: "Ed25519", signerDid: input.ownerDid, value: encodeBase64Url2(signature) } } })
|
|
4055
4088
|
});
|
|
4056
|
-
if (!response.ok) throw
|
|
4089
|
+
if (!response.ok) throw await httpResponseError(response, "policy root renewal rejected");
|
|
4057
4090
|
return object2(await response.json(), "policy root renewal");
|
|
4058
4091
|
}
|
|
4092
|
+
function rfc3339Seconds(value) {
|
|
4093
|
+
return new Date(Math.floor(value.getTime() / 1e3) * 1e3).toISOString().replace(/\.000Z$/, "Z");
|
|
4094
|
+
}
|
|
4059
4095
|
async function revokePolicyRootV3(input) {
|
|
4060
4096
|
if (input.reason.length === 0) throw new Error("policy root revocation reason is required");
|
|
4061
4097
|
const unsigned = {
|
|
@@ -4064,7 +4100,7 @@ async function revokePolicyRootV3(input) {
|
|
|
4064
4100
|
targetRole: input.targetRole,
|
|
4065
4101
|
ownerDid: input.ownerDid,
|
|
4066
4102
|
nodeAudience: input.nodeAudience,
|
|
4067
|
-
revokedAt: (input.now ?? /* @__PURE__ */ new Date())
|
|
4103
|
+
revokedAt: rfc3339Seconds(input.now ?? /* @__PURE__ */ new Date()),
|
|
4068
4104
|
reason: input.reason,
|
|
4069
4105
|
issuerDid: input.issuerDid
|
|
4070
4106
|
};
|
|
@@ -4077,7 +4113,7 @@ async function revokePolicyRootV3(input) {
|
|
|
4077
4113
|
headers: { accept: "application/json", "content-type": "application/json" },
|
|
4078
4114
|
body: JSON.stringify({ revocation: { ...unsigned, signature: { suite: "Ed25519", signerDid: input.issuerDid, value: encodeBase64Url2(signature) } } })
|
|
4079
4115
|
});
|
|
4080
|
-
if (!response.ok) throw
|
|
4116
|
+
if (!response.ok) throw await httpResponseError(response, "policy root revocation rejected");
|
|
4081
4117
|
return object2(await response.json(), "policy root revocation");
|
|
4082
4118
|
}
|
|
4083
4119
|
var POLICY_SESSION_FACT_KEYS = [
|
|
@@ -4346,7 +4382,7 @@ async function registerPolicyV3(input) {
|
|
|
4346
4382
|
}
|
|
4347
4383
|
);
|
|
4348
4384
|
if (!bindingResponse.ok) {
|
|
4349
|
-
throw
|
|
4385
|
+
throw await httpResponseError(bindingResponse, "policy enforcer binding rejected");
|
|
4350
4386
|
}
|
|
4351
4387
|
const binding = exactObject(
|
|
4352
4388
|
await bindingResponse.json(),
|
|
@@ -4412,7 +4448,7 @@ async function registerPolicyV3(input) {
|
|
|
4412
4448
|
}
|
|
4413
4449
|
);
|
|
4414
4450
|
if (!response.ok) {
|
|
4415
|
-
throw
|
|
4451
|
+
throw await httpResponseError(response, "policy registration rejected");
|
|
4416
4452
|
}
|
|
4417
4453
|
const receipt = exactObject(
|
|
4418
4454
|
await response.json(),
|
|
@@ -4815,7 +4851,7 @@ function date(value, label) {
|
|
|
4815
4851
|
if (!Number.isFinite(Date.parse(text2))) throw new Error(`${label} is invalid`);
|
|
4816
4852
|
return text2;
|
|
4817
4853
|
}
|
|
4818
|
-
function
|
|
4854
|
+
function rfc3339Seconds2(value) {
|
|
4819
4855
|
return new Date(Math.floor(value.getTime() / 1e3) * 1e3).toISOString().replace(/\.000Z$/, "Z");
|
|
4820
4856
|
}
|
|
4821
4857
|
function validateUnifiedPolicyV2(value, expectedPolicyCid) {
|
|
@@ -4980,8 +5016,8 @@ async function buildPolicyCredentialPresentationV4(input) {
|
|
|
4980
5016
|
requirementDigest,
|
|
4981
5017
|
descriptorDigest: input.credential.descriptorDigest,
|
|
4982
5018
|
requestedCapabilities: Object.freeze(requestedCapabilities),
|
|
4983
|
-
issuedAt:
|
|
4984
|
-
expiresAt:
|
|
5019
|
+
issuedAt: rfc3339Seconds2(now),
|
|
5020
|
+
expiresAt: rfc3339Seconds2(new Date(expiresAtMs))
|
|
4985
5021
|
}), input.sign);
|
|
4986
5022
|
}
|
|
4987
5023
|
async function buildPolicyCredentialPresentationV3(input) {
|
|
@@ -5035,8 +5071,8 @@ async function buildPolicyCredentialPresentationV3(input) {
|
|
|
5035
5071
|
requirementDigest,
|
|
5036
5072
|
descriptorDigest: input.credential.descriptorDigest,
|
|
5037
5073
|
requestedCapabilities: Object.freeze(requestedCapabilities),
|
|
5038
|
-
issuedAt:
|
|
5039
|
-
expiresAt:
|
|
5074
|
+
issuedAt: rfc3339Seconds2(now),
|
|
5075
|
+
expiresAt: rfc3339Seconds2(new Date(expiresAtMs))
|
|
5040
5076
|
});
|
|
5041
5077
|
const digest4 = (0, import_sha2562.sha256)(
|
|
5042
5078
|
new TextEncoder().encode(
|
|
@@ -5098,7 +5134,7 @@ async function admitPolicyCredentialV3(input) {
|
|
|
5098
5134
|
requestedSessionExpiry(input.requestedExpiresAt, policy),
|
|
5099
5135
|
input.signal
|
|
5100
5136
|
);
|
|
5101
|
-
if (!response.ok) throw
|
|
5137
|
+
if (!response.ok) throw await httpResponseError(response, "policy delegation rejected");
|
|
5102
5138
|
const value = record(await response.json(), "policy delegation");
|
|
5103
5139
|
if (value.admitted !== true || typeof value.sessionCid !== "string" || typeof value.authorization !== "string") {
|
|
5104
5140
|
throw new Error("policy delegation response is invalid");
|
|
@@ -5151,7 +5187,7 @@ async function admitPolicyCredentialV4(input) {
|
|
|
5151
5187
|
requestedSessionExpiry(input.requestedExpiresAt, policy),
|
|
5152
5188
|
input.signal
|
|
5153
5189
|
);
|
|
5154
|
-
if (!response.ok) throw
|
|
5190
|
+
if (!response.ok) throw await httpResponseError(response, "policy delegation rejected");
|
|
5155
5191
|
const value = record(await response.json(), "policy delegation");
|
|
5156
5192
|
if (value.admitted !== true || typeof value.sessionCid !== "string" || typeof value.authorization !== "string") throw new Error("policy delegation response is invalid");
|
|
5157
5193
|
const session = parsePolicySessionUcan(value.authorization, [
|
|
@@ -5170,7 +5206,7 @@ async function admitPolicyCredentialV4(input) {
|
|
|
5170
5206
|
signal: input.signal,
|
|
5171
5207
|
headers: { Authorization: session.authorization }
|
|
5172
5208
|
});
|
|
5173
|
-
if (!importResponse.ok) throw
|
|
5209
|
+
if (!importResponse.ok) throw await httpResponseError(importResponse, "delegation import rejected");
|
|
5174
5210
|
input.signal?.throwIfAborted();
|
|
5175
5211
|
return Object.freeze({ challenge, presentation, session, delegationImported: true });
|
|
5176
5212
|
}
|
|
@@ -7754,7 +7790,7 @@ function validateEncodedShareData(data) {
|
|
|
7754
7790
|
// src/manifest.ts
|
|
7755
7791
|
var import_ms = __toESM(require("ms"), 1);
|
|
7756
7792
|
var import_bootstrap2 = require("@tinycloud/bootstrap");
|
|
7757
|
-
var
|
|
7793
|
+
var import_sdk_services2 = require("@tinycloud/sdk-services");
|
|
7758
7794
|
var DEFAULT_KNOWLEDGE_ROOT = "knowledge/index.md";
|
|
7759
7795
|
var ManifestValidationError = class extends Error {
|
|
7760
7796
|
constructor(message) {
|
|
@@ -8025,13 +8061,13 @@ function validateManifestSecrets(secrets) {
|
|
|
8025
8061
|
throw new ManifestValidationError("manifest.secrets must be an object");
|
|
8026
8062
|
}
|
|
8027
8063
|
for (const [name2, spec] of Object.entries(secrets)) {
|
|
8028
|
-
if (!
|
|
8064
|
+
if (!import_sdk_services2.SECRET_NAME_RE.test(name2)) {
|
|
8029
8065
|
throw new ManifestValidationError(
|
|
8030
|
-
`manifest.secrets.${name2} must match ${
|
|
8066
|
+
`manifest.secrets.${name2} must match ${import_sdk_services2.SECRET_NAME_RE.source}`
|
|
8031
8067
|
);
|
|
8032
8068
|
}
|
|
8033
8069
|
try {
|
|
8034
|
-
(0,
|
|
8070
|
+
(0, import_sdk_services2.resolveSecretPath)(
|
|
8035
8071
|
secretNameFromSpec(name2, spec),
|
|
8036
8072
|
{ scope: secretScopeFromSpec(spec) }
|
|
8037
8073
|
);
|
|
@@ -8248,7 +8284,7 @@ function secretEntriesForManifest(secrets) {
|
|
|
8248
8284
|
const entries = [];
|
|
8249
8285
|
for (const [name2, spec] of Object.entries(secrets)) {
|
|
8250
8286
|
const actions = secretActionsFromSpec(name2, spec);
|
|
8251
|
-
const secretPath = (0,
|
|
8287
|
+
const secretPath = (0, import_sdk_services2.resolveSecretPath)(
|
|
8252
8288
|
secretNameFromSpec(name2, spec),
|
|
8253
8289
|
{ scope: secretScopeFromSpec(spec) }
|
|
8254
8290
|
);
|
|
@@ -8626,8 +8662,17 @@ function canonicalizeRecapCaveats(caveats) {
|
|
|
8626
8662
|
}
|
|
8627
8663
|
return `[${branches.join(",")}]`;
|
|
8628
8664
|
}
|
|
8665
|
+
var EXPLICIT_ONLY_ACTIONS = {
|
|
8666
|
+
"tinycloud.kv/sync": true,
|
|
8667
|
+
"tinycloud.kv/retain": true
|
|
8668
|
+
};
|
|
8669
|
+
function isExplicitOnlyAction(action) {
|
|
8670
|
+
return Object.prototype.hasOwnProperty.call(EXPLICIT_ONLY_ACTIONS, action);
|
|
8671
|
+
}
|
|
8629
8672
|
function actionContains(grantedAction, requestedAction) {
|
|
8630
|
-
if (grantedAction ===
|
|
8673
|
+
if (grantedAction === requestedAction) return true;
|
|
8674
|
+
if (isExplicitOnlyAction(requestedAction)) return false;
|
|
8675
|
+
if (grantedAction === "*") return true;
|
|
8631
8676
|
if (!grantedAction.endsWith("/*")) return false;
|
|
8632
8677
|
const service = grantedAction.slice(0, -2);
|
|
8633
8678
|
return requestedAction === service || requestedAction.startsWith(`${service}/`);
|
|
@@ -8690,7 +8735,7 @@ function parseRecapCapabilities(parseWasm, siwe) {
|
|
|
8690
8735
|
var import_ed255197 = require("@noble/curves/ed25519");
|
|
8691
8736
|
|
|
8692
8737
|
// src/delegations/ShareRecipientClient.ts
|
|
8693
|
-
var
|
|
8738
|
+
var import_sdk_services3 = require("@tinycloud/sdk-services");
|
|
8694
8739
|
var import_ed255196 = require("@noble/curves/ed25519");
|
|
8695
8740
|
var import_sha2565 = require("@noble/hashes/sha256");
|
|
8696
8741
|
|
|
@@ -9808,7 +9853,7 @@ async function importPortableDelegation(fetchFn, host, delegation) {
|
|
|
9808
9853
|
headers: { Authorization: parsed.delegationHeader.Authorization }
|
|
9809
9854
|
});
|
|
9810
9855
|
if (!response.ok)
|
|
9811
|
-
throw
|
|
9856
|
+
throw await httpResponseError(response, "node rejected delegation import");
|
|
9812
9857
|
const body = await response.json().catch(() => ({}));
|
|
9813
9858
|
if (body === null || typeof body !== "object" || Array.isArray(body))
|
|
9814
9859
|
return {};
|
|
@@ -9877,7 +9922,7 @@ function redactedCode(error) {
|
|
|
9877
9922
|
if (error instanceof ShareConflict) return error.code;
|
|
9878
9923
|
const code3 = error && typeof error === "object" && "code" in error ? error.code : void 0;
|
|
9879
9924
|
if (typeof code3 !== "string") return "SHARE_INVALID";
|
|
9880
|
-
if (code3 ===
|
|
9925
|
+
if (code3 === import_sdk_services3.ErrorCodes.KV_PRECONDITION_FAILED || code3 === import_sdk_services3.ErrorCodes.KV_CONFLICT || code3 === "412") return "SHARE_CONFLICT";
|
|
9881
9926
|
if (code3 === "KV_NOT_FOUND" || code3 === "NOT_FOUND" || code3 === "404") return "SHARE_NOT_FOUND";
|
|
9882
9927
|
if (code3.includes("EXPIRED") || code3 === "expired") return "SHARE_EXPIRED";
|
|
9883
9928
|
if (code3.includes("REVOK")) return "SHARE_REVOKED";
|
|
@@ -10116,7 +10161,7 @@ var ShareRecipientClient = class {
|
|
|
10116
10161
|
if (portableDelegation !== void 0 && kv !== void 0) {
|
|
10117
10162
|
const result2 = await kv.put(resolvedPath, bytes2, { contentType: input.contentType ?? envelope.content.mimeType, ifMatch: input.etag });
|
|
10118
10163
|
if (!result2.ok) {
|
|
10119
|
-
if (result2.error.code ===
|
|
10164
|
+
if (result2.error.code === import_sdk_services3.ErrorCodes.KV_PRECONDITION_FAILED || result2.error.code === import_sdk_services3.ErrorCodes.KV_CONFLICT) throw new ShareConflict(resolvedPath, result2.error.meta?.etag);
|
|
10120
10165
|
throw result2.error;
|
|
10121
10166
|
}
|
|
10122
10167
|
return { etag: result2.data.headers.etag };
|
|
@@ -10124,7 +10169,7 @@ var ShareRecipientClient = class {
|
|
|
10124
10169
|
if (policySession !== void 0) return this.nativeSave(envelope, policySession, resolvedPath, bytes2, input);
|
|
10125
10170
|
const result = await kv.put(resolvedPath, bytes2, { contentType: input.contentType ?? envelope.content.mimeType, ifMatch: input.etag });
|
|
10126
10171
|
if (!result.ok) {
|
|
10127
|
-
if (result.error.code ===
|
|
10172
|
+
if (result.error.code === import_sdk_services3.ErrorCodes.KV_PRECONDITION_FAILED || result.error.code === import_sdk_services3.ErrorCodes.KV_CONFLICT) throw new ShareConflict(resolvedPath, result.error.meta?.etag);
|
|
10128
10173
|
throw result.error;
|
|
10129
10174
|
}
|
|
10130
10175
|
return { etag: result.data.headers.etag };
|
|
@@ -10208,8 +10253,8 @@ var ShareRecipientClient = class {
|
|
|
10208
10253
|
if (this.options.createKVService !== void 0) {
|
|
10209
10254
|
return this.options.createKVService({ hosts: [origin2], session, invoke, fetch: this.fetchFn });
|
|
10210
10255
|
}
|
|
10211
|
-
const context = new
|
|
10212
|
-
const service = new
|
|
10256
|
+
const context = new import_sdk_services3.ServiceContext({ hosts: [origin2], session, invoke, fetch: this.fetchFn });
|
|
10257
|
+
const service = new import_sdk_services3.KVService({ prefix: "" });
|
|
10213
10258
|
context.registerService("kv", service);
|
|
10214
10259
|
service.initialize(context);
|
|
10215
10260
|
return service;
|
|
@@ -11310,7 +11355,9 @@ var SharingService = class {
|
|
|
11310
11355
|
if (delegation.allowSubDelegation === false) continue;
|
|
11311
11356
|
if (!this.pathMatches(delegation.path || "", path)) continue;
|
|
11312
11357
|
const delegationActions = delegation.actions || [];
|
|
11313
|
-
if (!actions.every(
|
|
11358
|
+
if (!actions.every(
|
|
11359
|
+
(action) => delegationActions.some((granted) => actionContains(granted, action))
|
|
11360
|
+
)) {
|
|
11314
11361
|
continue;
|
|
11315
11362
|
}
|
|
11316
11363
|
if ((delegation.caveats?.length ?? 0) > 0) {
|
|
@@ -12468,14 +12515,14 @@ var import_share_sdk = require("@tinycloud/share-sdk");
|
|
|
12468
12515
|
var import_share_sdk2 = require("@tinycloud/share-sdk");
|
|
12469
12516
|
|
|
12470
12517
|
// src/networkId.ts
|
|
12471
|
-
var
|
|
12518
|
+
var import_sdk_services4 = require("@tinycloud/sdk-services");
|
|
12472
12519
|
function canonicalizeNetworkId(networkId) {
|
|
12473
|
-
const parsed = (0,
|
|
12474
|
-
return (0,
|
|
12520
|
+
const parsed = (0, import_sdk_services4.parseNetworkId)(networkId);
|
|
12521
|
+
return (0, import_sdk_services4.buildNetworkId)(canonicalizeDid(parsed.ownerDid), parsed.name);
|
|
12475
12522
|
}
|
|
12476
12523
|
function parseCanonicalNetworkId(networkId) {
|
|
12477
12524
|
const canonical = canonicalizeNetworkId(networkId);
|
|
12478
|
-
return (0,
|
|
12525
|
+
return (0, import_sdk_services4.parseNetworkId)(canonical);
|
|
12479
12526
|
}
|
|
12480
12527
|
|
|
12481
12528
|
// src/storage.schema.ts
|
|
@@ -12574,10 +12621,10 @@ function validatePersistedSessionData(data) {
|
|
|
12574
12621
|
}
|
|
12575
12622
|
|
|
12576
12623
|
// src/TinyCloud.ts
|
|
12577
|
-
var
|
|
12624
|
+
var import_sdk_services6 = require("@tinycloud/sdk-services");
|
|
12578
12625
|
|
|
12579
12626
|
// src/spaces/SpaceService.ts
|
|
12580
|
-
var
|
|
12627
|
+
var import_sdk_services5 = require("@tinycloud/sdk-services");
|
|
12581
12628
|
|
|
12582
12629
|
// src/spaces/Space.ts
|
|
12583
12630
|
function unavailableSecretsService() {
|
|
@@ -13006,8 +13053,8 @@ var SpaceService = class {
|
|
|
13006
13053
|
*/
|
|
13007
13054
|
async list() {
|
|
13008
13055
|
if (!this.session) {
|
|
13009
|
-
return (0,
|
|
13010
|
-
(0,
|
|
13056
|
+
return (0, import_sdk_services5.err)(
|
|
13057
|
+
(0, import_sdk_services5.serviceError)(SpaceErrorCodes.AUTH_REQUIRED, "Authentication required", SERVICE_NAME)
|
|
13011
13058
|
);
|
|
13012
13059
|
}
|
|
13013
13060
|
try {
|
|
@@ -13015,6 +13062,9 @@ var SpaceService = class {
|
|
|
13015
13062
|
const ownedResult = await this.listOwnedSpaces();
|
|
13016
13063
|
if (ownedResult.ok) {
|
|
13017
13064
|
spaces.push(...ownedResult.data);
|
|
13065
|
+
} else {
|
|
13066
|
+
const verdict = (0, import_sdk_services5.authorizationVerdictOf)(ownedResult.error);
|
|
13067
|
+
if (verdict === "unauthenticated" || verdict === "forbidden") return (0, import_sdk_services5.err)(ownedResult.error);
|
|
13018
13068
|
}
|
|
13019
13069
|
if (this.capabilityRegistry) {
|
|
13020
13070
|
const delegatedSpaces = this.discoverDelegatedSpaces();
|
|
@@ -13024,10 +13074,10 @@ var SpaceService = class {
|
|
|
13024
13074
|
for (const space of uniqueSpaces) {
|
|
13025
13075
|
this.notifySpaceRegistered(space);
|
|
13026
13076
|
}
|
|
13027
|
-
return (0,
|
|
13077
|
+
return (0, import_sdk_services5.ok)(uniqueSpaces);
|
|
13028
13078
|
} catch (error) {
|
|
13029
|
-
return (0,
|
|
13030
|
-
(0,
|
|
13079
|
+
return (0, import_sdk_services5.err)(
|
|
13080
|
+
(0, import_sdk_services5.serviceError)(
|
|
13031
13081
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13032
13082
|
`Failed to list spaces: ${String(error)}`,
|
|
13033
13083
|
SERVICE_NAME,
|
|
@@ -13047,21 +13097,18 @@ var SpaceService = class {
|
|
|
13047
13097
|
headers
|
|
13048
13098
|
});
|
|
13049
13099
|
if (!response.ok) {
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
{ meta: { status: response.status } }
|
|
13057
|
-
)
|
|
13058
|
-
);
|
|
13100
|
+
return (0, import_sdk_services5.err)(await serviceHttpError(
|
|
13101
|
+
response,
|
|
13102
|
+
SpaceErrorCodes.NETWORK_ERROR,
|
|
13103
|
+
"Failed to list owned spaces",
|
|
13104
|
+
SERVICE_NAME
|
|
13105
|
+
));
|
|
13059
13106
|
}
|
|
13060
13107
|
const rawData = await response.json();
|
|
13061
13108
|
const validationResult = validateServerOwnedSpacesResponse(rawData);
|
|
13062
13109
|
if (!validationResult.ok) {
|
|
13063
|
-
return (0,
|
|
13064
|
-
(0,
|
|
13110
|
+
return (0, import_sdk_services5.err)(
|
|
13111
|
+
(0, import_sdk_services5.serviceError)(
|
|
13065
13112
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13066
13113
|
validationResult.error.message,
|
|
13067
13114
|
SERVICE_NAME,
|
|
@@ -13077,10 +13124,10 @@ var SpaceService = class {
|
|
|
13077
13124
|
permissions: ["*"]
|
|
13078
13125
|
// Full permissions for owned spaces
|
|
13079
13126
|
}));
|
|
13080
|
-
return (0,
|
|
13127
|
+
return (0, import_sdk_services5.ok)(spaces);
|
|
13081
13128
|
} catch (error) {
|
|
13082
|
-
return (0,
|
|
13083
|
-
(0,
|
|
13129
|
+
return (0, import_sdk_services5.err)(
|
|
13130
|
+
(0, import_sdk_services5.serviceError)(
|
|
13084
13131
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13085
13132
|
`Network error listing owned spaces: ${String(error)}`,
|
|
13086
13133
|
SERVICE_NAME,
|
|
@@ -13161,13 +13208,13 @@ var SpaceService = class {
|
|
|
13161
13208
|
*/
|
|
13162
13209
|
async create(name2) {
|
|
13163
13210
|
if (!this.session) {
|
|
13164
|
-
return (0,
|
|
13165
|
-
(0,
|
|
13211
|
+
return (0, import_sdk_services5.err)(
|
|
13212
|
+
(0, import_sdk_services5.serviceError)(SpaceErrorCodes.AUTH_REQUIRED, "Authentication required", SERVICE_NAME)
|
|
13166
13213
|
);
|
|
13167
13214
|
}
|
|
13168
13215
|
if (!name2 || !/^[a-zA-Z0-9_-]+$/.test(name2)) {
|
|
13169
|
-
return (0,
|
|
13170
|
-
(0,
|
|
13216
|
+
return (0, import_sdk_services5.err)(
|
|
13217
|
+
(0, import_sdk_services5.serviceError)(
|
|
13171
13218
|
SpaceErrorCodes.INVALID_NAME,
|
|
13172
13219
|
"Space name must contain only alphanumeric characters, underscores, and hyphens",
|
|
13173
13220
|
SERVICE_NAME
|
|
@@ -13182,30 +13229,26 @@ var SpaceService = class {
|
|
|
13182
13229
|
body: JSON.stringify({ name: name2 })
|
|
13183
13230
|
});
|
|
13184
13231
|
if (!response.ok) {
|
|
13185
|
-
const errorText = await response.text();
|
|
13186
13232
|
if (response.status === 409) {
|
|
13187
|
-
return (0,
|
|
13188
|
-
|
|
13189
|
-
|
|
13190
|
-
|
|
13191
|
-
|
|
13192
|
-
|
|
13193
|
-
);
|
|
13233
|
+
return (0, import_sdk_services5.err)(await serviceHttpError(
|
|
13234
|
+
response,
|
|
13235
|
+
SpaceErrorCodes.ALREADY_EXISTS,
|
|
13236
|
+
`Space "${name2}" already exists`,
|
|
13237
|
+
SERVICE_NAME
|
|
13238
|
+
));
|
|
13194
13239
|
}
|
|
13195
|
-
return (0,
|
|
13196
|
-
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
13200
|
-
|
|
13201
|
-
)
|
|
13202
|
-
);
|
|
13240
|
+
return (0, import_sdk_services5.err)(await serviceHttpError(
|
|
13241
|
+
response,
|
|
13242
|
+
SpaceErrorCodes.CREATION_FAILED,
|
|
13243
|
+
"Failed to create space",
|
|
13244
|
+
SERVICE_NAME
|
|
13245
|
+
));
|
|
13203
13246
|
}
|
|
13204
13247
|
const rawData = await response.json();
|
|
13205
13248
|
const validationResult = validateServerCreateSpaceResponse(rawData);
|
|
13206
13249
|
if (!validationResult.ok) {
|
|
13207
|
-
return (0,
|
|
13208
|
-
(0,
|
|
13250
|
+
return (0, import_sdk_services5.err)(
|
|
13251
|
+
(0, import_sdk_services5.serviceError)(
|
|
13209
13252
|
SpaceErrorCodes.CREATION_FAILED,
|
|
13210
13253
|
validationResult.error.message,
|
|
13211
13254
|
SERVICE_NAME,
|
|
@@ -13222,10 +13265,10 @@ var SpaceService = class {
|
|
|
13222
13265
|
};
|
|
13223
13266
|
this.infoCache.set(spaceInfo.id, { info: spaceInfo, cachedAt: Date.now() });
|
|
13224
13267
|
this.notifySpaceRegistered(spaceInfo);
|
|
13225
|
-
return (0,
|
|
13268
|
+
return (0, import_sdk_services5.ok)(spaceInfo);
|
|
13226
13269
|
} catch (error) {
|
|
13227
|
-
return (0,
|
|
13228
|
-
(0,
|
|
13270
|
+
return (0, import_sdk_services5.err)(
|
|
13271
|
+
(0, import_sdk_services5.serviceError)(
|
|
13229
13272
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13230
13273
|
`Network error creating space: ${String(error)}`,
|
|
13231
13274
|
SERVICE_NAME,
|
|
@@ -13295,10 +13338,10 @@ var SpaceService = class {
|
|
|
13295
13338
|
const spaceId = this.resolveSpaceId(nameOrUri);
|
|
13296
13339
|
const cached = this.infoCache.get(spaceId);
|
|
13297
13340
|
if (cached && Date.now() - cached.cachedAt < this.cacheTTL) {
|
|
13298
|
-
return (0,
|
|
13341
|
+
return (0, import_sdk_services5.ok)(true);
|
|
13299
13342
|
}
|
|
13300
13343
|
const infoResult = await this.getSpaceInfo(spaceId);
|
|
13301
|
-
return (0,
|
|
13344
|
+
return (0, import_sdk_services5.ok)(infoResult.ok);
|
|
13302
13345
|
}
|
|
13303
13346
|
// ===========================================================================
|
|
13304
13347
|
// Space Info
|
|
@@ -13309,11 +13352,11 @@ var SpaceService = class {
|
|
|
13309
13352
|
async getSpaceInfo(spaceId) {
|
|
13310
13353
|
const cached = this.infoCache.get(spaceId);
|
|
13311
13354
|
if (cached && Date.now() - cached.cachedAt < this.cacheTTL) {
|
|
13312
|
-
return (0,
|
|
13355
|
+
return (0, import_sdk_services5.ok)(cached.info);
|
|
13313
13356
|
}
|
|
13314
13357
|
if (!this.session) {
|
|
13315
|
-
return (0,
|
|
13316
|
-
(0,
|
|
13358
|
+
return (0, import_sdk_services5.err)(
|
|
13359
|
+
(0, import_sdk_services5.serviceError)(SpaceErrorCodes.AUTH_REQUIRED, "Authentication required", SERVICE_NAME)
|
|
13317
13360
|
);
|
|
13318
13361
|
}
|
|
13319
13362
|
try {
|
|
@@ -13325,24 +13368,25 @@ var SpaceService = class {
|
|
|
13325
13368
|
});
|
|
13326
13369
|
if (!response.ok) {
|
|
13327
13370
|
if (response.status === 404) {
|
|
13328
|
-
return (0,
|
|
13329
|
-
|
|
13330
|
-
|
|
13331
|
-
|
|
13332
|
-
const errorText = await response.text();
|
|
13333
|
-
return (0, import_sdk_services4.err)(
|
|
13334
|
-
(0, import_sdk_services4.serviceError)(
|
|
13335
|
-
SpaceErrorCodes.NETWORK_ERROR,
|
|
13336
|
-
`Failed to get space info: ${response.status} - ${errorText}`,
|
|
13371
|
+
return (0, import_sdk_services5.err)(await serviceHttpError(
|
|
13372
|
+
response,
|
|
13373
|
+
SpaceErrorCodes.NOT_FOUND,
|
|
13374
|
+
`Space not found: ${spaceId}`,
|
|
13337
13375
|
SERVICE_NAME
|
|
13338
|
-
)
|
|
13339
|
-
|
|
13376
|
+
));
|
|
13377
|
+
}
|
|
13378
|
+
return (0, import_sdk_services5.err)(await serviceHttpError(
|
|
13379
|
+
response,
|
|
13380
|
+
SpaceErrorCodes.NETWORK_ERROR,
|
|
13381
|
+
"Failed to get space info",
|
|
13382
|
+
SERVICE_NAME
|
|
13383
|
+
));
|
|
13340
13384
|
}
|
|
13341
13385
|
const rawData = await response.json();
|
|
13342
13386
|
const validationResult = validateServerSpaceInfoResponse(rawData);
|
|
13343
13387
|
if (!validationResult.ok) {
|
|
13344
|
-
return (0,
|
|
13345
|
-
(0,
|
|
13388
|
+
return (0, import_sdk_services5.err)(
|
|
13389
|
+
(0, import_sdk_services5.serviceError)(
|
|
13346
13390
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13347
13391
|
validationResult.error.message,
|
|
13348
13392
|
SERVICE_NAME,
|
|
@@ -13360,10 +13404,10 @@ var SpaceService = class {
|
|
|
13360
13404
|
expiresAt: data.expiresAt ? new Date(data.expiresAt) : void 0
|
|
13361
13405
|
};
|
|
13362
13406
|
this.infoCache.set(spaceId, { info: spaceInfo, cachedAt: Date.now() });
|
|
13363
|
-
return (0,
|
|
13407
|
+
return (0, import_sdk_services5.ok)(spaceInfo);
|
|
13364
13408
|
} catch (error) {
|
|
13365
|
-
return (0,
|
|
13366
|
-
(0,
|
|
13409
|
+
return (0, import_sdk_services5.err)(
|
|
13410
|
+
(0, import_sdk_services5.serviceError)(
|
|
13367
13411
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13368
13412
|
`Network error getting space info: ${String(error)}`,
|
|
13369
13413
|
SERVICE_NAME,
|
|
@@ -13448,20 +13492,18 @@ var SpaceService = class {
|
|
|
13448
13492
|
headers
|
|
13449
13493
|
});
|
|
13450
13494
|
if (!response.ok) {
|
|
13451
|
-
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
|
|
13456
|
-
|
|
13457
|
-
)
|
|
13458
|
-
);
|
|
13495
|
+
return (0, import_sdk_services5.err)(await serviceHttpError(
|
|
13496
|
+
response,
|
|
13497
|
+
SpaceErrorCodes.NETWORK_ERROR,
|
|
13498
|
+
"Failed to list delegations",
|
|
13499
|
+
SERVICE_NAME
|
|
13500
|
+
));
|
|
13459
13501
|
}
|
|
13460
13502
|
const rawData = await response.json();
|
|
13461
13503
|
const validationResult = validateServerDelegationsResponse(rawData);
|
|
13462
13504
|
if (!validationResult.ok) {
|
|
13463
|
-
return (0,
|
|
13464
|
-
(0,
|
|
13505
|
+
return (0, import_sdk_services5.err)(
|
|
13506
|
+
(0, import_sdk_services5.serviceError)(
|
|
13465
13507
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13466
13508
|
validationResult.error.message,
|
|
13467
13509
|
SERVICE_NAME,
|
|
@@ -13470,10 +13512,10 @@ var SpaceService = class {
|
|
|
13470
13512
|
);
|
|
13471
13513
|
}
|
|
13472
13514
|
const delegations = transformServerDelegations(validationResult.data, spaceId);
|
|
13473
|
-
return (0,
|
|
13515
|
+
return (0, import_sdk_services5.ok)(delegations);
|
|
13474
13516
|
} catch (error) {
|
|
13475
|
-
return (0,
|
|
13476
|
-
(0,
|
|
13517
|
+
return (0, import_sdk_services5.err)(
|
|
13518
|
+
(0, import_sdk_services5.serviceError)(
|
|
13477
13519
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13478
13520
|
`Network error listing delegations: ${String(error)}`,
|
|
13479
13521
|
SERVICE_NAME
|
|
@@ -13503,20 +13545,18 @@ var SpaceService = class {
|
|
|
13503
13545
|
headers
|
|
13504
13546
|
});
|
|
13505
13547
|
if (!response.ok) {
|
|
13506
|
-
|
|
13507
|
-
|
|
13508
|
-
|
|
13509
|
-
|
|
13510
|
-
|
|
13511
|
-
|
|
13512
|
-
)
|
|
13513
|
-
);
|
|
13548
|
+
return (0, import_sdk_services5.err)(await serviceHttpError(
|
|
13549
|
+
response,
|
|
13550
|
+
SpaceErrorCodes.NETWORK_ERROR,
|
|
13551
|
+
"Failed to list received delegations",
|
|
13552
|
+
SERVICE_NAME
|
|
13553
|
+
));
|
|
13514
13554
|
}
|
|
13515
13555
|
const rawData = await response.json();
|
|
13516
13556
|
const validationResult = validateServerDelegationsResponse(rawData);
|
|
13517
13557
|
if (!validationResult.ok) {
|
|
13518
|
-
return (0,
|
|
13519
|
-
(0,
|
|
13558
|
+
return (0, import_sdk_services5.err)(
|
|
13559
|
+
(0, import_sdk_services5.serviceError)(
|
|
13520
13560
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13521
13561
|
validationResult.error.message,
|
|
13522
13562
|
SERVICE_NAME,
|
|
@@ -13525,10 +13565,10 @@ var SpaceService = class {
|
|
|
13525
13565
|
);
|
|
13526
13566
|
}
|
|
13527
13567
|
const delegations = transformServerDelegations(validationResult.data, spaceId);
|
|
13528
|
-
return (0,
|
|
13568
|
+
return (0, import_sdk_services5.ok)(delegations);
|
|
13529
13569
|
} catch (error) {
|
|
13530
|
-
return (0,
|
|
13531
|
-
(0,
|
|
13570
|
+
return (0, import_sdk_services5.err)(
|
|
13571
|
+
(0, import_sdk_services5.serviceError)(
|
|
13532
13572
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13533
13573
|
`Network error listing received delegations: ${String(error)}`,
|
|
13534
13574
|
SERVICE_NAME
|
|
@@ -13540,8 +13580,8 @@ var SpaceService = class {
|
|
|
13540
13580
|
if (self.createDelegationFn) {
|
|
13541
13581
|
return self.createDelegationFn({ ...params, spaceId });
|
|
13542
13582
|
}
|
|
13543
|
-
return (0,
|
|
13544
|
-
(0,
|
|
13583
|
+
return (0, import_sdk_services5.err)(
|
|
13584
|
+
(0, import_sdk_services5.serviceError)(
|
|
13545
13585
|
SpaceErrorCodes.NOT_INITIALIZED,
|
|
13546
13586
|
"Delegation creation requires a createDelegation function. This should be provided by the platform SDK (web-sdk or node-sdk).",
|
|
13547
13587
|
SERVICE_NAME
|
|
@@ -13562,19 +13602,17 @@ var SpaceService = class {
|
|
|
13562
13602
|
body: JSON.stringify({ cid: cid2, spaceId })
|
|
13563
13603
|
});
|
|
13564
13604
|
if (!response.ok) {
|
|
13565
|
-
|
|
13566
|
-
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
)
|
|
13572
|
-
);
|
|
13605
|
+
return (0, import_sdk_services5.err)(await serviceHttpError(
|
|
13606
|
+
response,
|
|
13607
|
+
SpaceErrorCodes.NETWORK_ERROR,
|
|
13608
|
+
"Failed to revoke delegation",
|
|
13609
|
+
SERVICE_NAME
|
|
13610
|
+
));
|
|
13573
13611
|
}
|
|
13574
|
-
return (0,
|
|
13612
|
+
return (0, import_sdk_services5.ok)(void 0);
|
|
13575
13613
|
} catch (error) {
|
|
13576
|
-
return (0,
|
|
13577
|
-
(0,
|
|
13614
|
+
return (0, import_sdk_services5.err)(
|
|
13615
|
+
(0, import_sdk_services5.serviceError)(
|
|
13578
13616
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13579
13617
|
`Network error revoking delegation: ${String(error)}`,
|
|
13580
13618
|
SERVICE_NAME
|
|
@@ -13597,18 +13635,18 @@ var SpaceService = class {
|
|
|
13597
13635
|
if (self.sharingService) {
|
|
13598
13636
|
const result = await self.sharingService.generate(params);
|
|
13599
13637
|
if (!result.ok) {
|
|
13600
|
-
return (0,
|
|
13601
|
-
(0,
|
|
13638
|
+
return (0, import_sdk_services5.err)(
|
|
13639
|
+
(0, import_sdk_services5.serviceError)(
|
|
13602
13640
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13603
13641
|
result.error.message || "Failed to generate share link",
|
|
13604
13642
|
SERVICE_NAME
|
|
13605
13643
|
)
|
|
13606
13644
|
);
|
|
13607
13645
|
}
|
|
13608
|
-
return (0,
|
|
13646
|
+
return (0, import_sdk_services5.ok)(result.data);
|
|
13609
13647
|
}
|
|
13610
|
-
return (0,
|
|
13611
|
-
(0,
|
|
13648
|
+
return (0, import_sdk_services5.err)(
|
|
13649
|
+
(0, import_sdk_services5.serviceError)(
|
|
13612
13650
|
SpaceErrorCodes.NOT_INITIALIZED,
|
|
13613
13651
|
"SharingService not configured. V2 sharing requires a SharingService instance.",
|
|
13614
13652
|
SERVICE_NAME
|
|
@@ -13616,8 +13654,8 @@ var SpaceService = class {
|
|
|
13616
13654
|
);
|
|
13617
13655
|
},
|
|
13618
13656
|
async list() {
|
|
13619
|
-
return (0,
|
|
13620
|
-
(0,
|
|
13657
|
+
return (0, import_sdk_services5.err)(
|
|
13658
|
+
(0, import_sdk_services5.serviceError)(
|
|
13621
13659
|
SpaceErrorCodes.NOT_INITIALIZED,
|
|
13622
13660
|
"Listing share links is not supported in v2. Share links are self-contained tokens that are not tracked on the server.",
|
|
13623
13661
|
SERVICE_NAME
|
|
@@ -13625,8 +13663,8 @@ var SpaceService = class {
|
|
|
13625
13663
|
);
|
|
13626
13664
|
},
|
|
13627
13665
|
async revoke(token) {
|
|
13628
|
-
return (0,
|
|
13629
|
-
(0,
|
|
13666
|
+
return (0, import_sdk_services5.err)(
|
|
13667
|
+
(0, import_sdk_services5.serviceError)(
|
|
13630
13668
|
SpaceErrorCodes.NOT_INITIALIZED,
|
|
13631
13669
|
"Revoking share links by token is not supported in v2. To revoke access, revoke the underlying delegation using space.delegations.revoke(cid).",
|
|
13632
13670
|
SERVICE_NAME
|
|
@@ -13686,7 +13724,7 @@ var TinyCloud = class _TinyCloud {
|
|
|
13686
13724
|
"hosts are required to initialize services. Provide them via config.hosts or initializeServices()."
|
|
13687
13725
|
);
|
|
13688
13726
|
}
|
|
13689
|
-
this._serviceContext = new
|
|
13727
|
+
this._serviceContext = new import_sdk_services6.ServiceContext({
|
|
13690
13728
|
invoke: effectiveInvoke,
|
|
13691
13729
|
invokeAny: this.config.invokeAny,
|
|
13692
13730
|
fetch: fetchFn ?? this.config.fetch ?? globalThis.fetch.bind(globalThis),
|
|
@@ -13695,10 +13733,10 @@ var TinyCloud = class _TinyCloud {
|
|
|
13695
13733
|
telemetry: this.config.telemetry
|
|
13696
13734
|
});
|
|
13697
13735
|
const serviceConstructors = {
|
|
13698
|
-
kv:
|
|
13699
|
-
sql:
|
|
13700
|
-
duckdb:
|
|
13701
|
-
hooks:
|
|
13736
|
+
kv: import_sdk_services6.KVService,
|
|
13737
|
+
sql: import_sdk_services6.SQLService,
|
|
13738
|
+
duckdb: import_sdk_services6.DuckDbService,
|
|
13739
|
+
hooks: import_sdk_services6.HooksService,
|
|
13702
13740
|
...this.config.services
|
|
13703
13741
|
};
|
|
13704
13742
|
for (const [name2, ServiceClass] of Object.entries(serviceConstructors)) {
|
|
@@ -13962,18 +14000,18 @@ var TinyCloud = class _TinyCloud {
|
|
|
13962
14000
|
const address = this.address();
|
|
13963
14001
|
const chainId = this.chainId();
|
|
13964
14002
|
if (!address || !chainId) {
|
|
13965
|
-
return (0,
|
|
13966
|
-
(0,
|
|
13967
|
-
|
|
14003
|
+
return (0, import_sdk_services6.err)(
|
|
14004
|
+
(0, import_sdk_services6.serviceError)(
|
|
14005
|
+
import_sdk_services6.ErrorCodes.AUTH_REQUIRED,
|
|
13968
14006
|
"Must be signed in to ensure public space",
|
|
13969
14007
|
"public-space"
|
|
13970
14008
|
)
|
|
13971
14009
|
);
|
|
13972
14010
|
}
|
|
13973
14011
|
if (!this._serviceContext) {
|
|
13974
|
-
return (0,
|
|
13975
|
-
(0,
|
|
13976
|
-
|
|
14012
|
+
return (0, import_sdk_services6.err)(
|
|
14013
|
+
(0, import_sdk_services6.serviceError)(
|
|
14014
|
+
import_sdk_services6.ErrorCodes.AUTH_REQUIRED,
|
|
13977
14015
|
"Services not initialized. Call initializeServices() or signIn() first.",
|
|
13978
14016
|
"public-space"
|
|
13979
14017
|
)
|
|
@@ -13983,9 +14021,9 @@ var TinyCloud = class _TinyCloud {
|
|
|
13983
14021
|
try {
|
|
13984
14022
|
const session = this._serviceContext.session;
|
|
13985
14023
|
if (!session) {
|
|
13986
|
-
return (0,
|
|
13987
|
-
(0,
|
|
13988
|
-
|
|
14024
|
+
return (0, import_sdk_services6.err)(
|
|
14025
|
+
(0, import_sdk_services6.serviceError)(
|
|
14026
|
+
import_sdk_services6.ErrorCodes.AUTH_REQUIRED,
|
|
13989
14027
|
"No active session",
|
|
13990
14028
|
"public-space"
|
|
13991
14029
|
)
|
|
@@ -14002,7 +14040,7 @@ var TinyCloud = class _TinyCloud {
|
|
|
14002
14040
|
{ method: "POST", headers, body: JSON.stringify({ spaceId }) }
|
|
14003
14041
|
);
|
|
14004
14042
|
if (response.ok) {
|
|
14005
|
-
return (0,
|
|
14043
|
+
return (0, import_sdk_services6.ok)(void 0);
|
|
14006
14044
|
}
|
|
14007
14045
|
if (response.status === 404) {
|
|
14008
14046
|
const createHeaders = this._serviceContext.invoke(
|
|
@@ -14021,31 +14059,27 @@ var TinyCloud = class _TinyCloud {
|
|
|
14021
14059
|
);
|
|
14022
14060
|
if (!createResponse.ok) {
|
|
14023
14061
|
if (createResponse.status === 409) {
|
|
14024
|
-
return (0,
|
|
14062
|
+
return (0, import_sdk_services6.ok)(void 0);
|
|
14025
14063
|
}
|
|
14026
|
-
|
|
14027
|
-
|
|
14028
|
-
|
|
14029
|
-
|
|
14030
|
-
|
|
14031
|
-
|
|
14032
|
-
)
|
|
14033
|
-
);
|
|
14064
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
14065
|
+
createResponse,
|
|
14066
|
+
import_sdk_services6.ErrorCodes.NETWORK_ERROR,
|
|
14067
|
+
"Failed to create public space",
|
|
14068
|
+
"public-space"
|
|
14069
|
+
));
|
|
14034
14070
|
}
|
|
14035
|
-
return (0,
|
|
14071
|
+
return (0, import_sdk_services6.ok)(void 0);
|
|
14036
14072
|
}
|
|
14037
|
-
|
|
14038
|
-
|
|
14039
|
-
|
|
14040
|
-
|
|
14041
|
-
|
|
14042
|
-
|
|
14043
|
-
)
|
|
14044
|
-
);
|
|
14073
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
14074
|
+
response,
|
|
14075
|
+
import_sdk_services6.ErrorCodes.NETWORK_ERROR,
|
|
14076
|
+
"Failed to check public space",
|
|
14077
|
+
"public-space"
|
|
14078
|
+
));
|
|
14045
14079
|
} catch (error) {
|
|
14046
|
-
return (0,
|
|
14047
|
-
(0,
|
|
14048
|
-
|
|
14080
|
+
return (0, import_sdk_services6.err)(
|
|
14081
|
+
(0, import_sdk_services6.serviceError)(
|
|
14082
|
+
import_sdk_services6.ErrorCodes.NETWORK_ERROR,
|
|
14049
14083
|
`Network error ensuring public space: ${String(error)}`,
|
|
14050
14084
|
"public-space",
|
|
14051
14085
|
{ cause: error instanceof Error ? error : void 0 }
|
|
@@ -14078,8 +14112,8 @@ var TinyCloud = class _TinyCloud {
|
|
|
14078
14112
|
if (!session) {
|
|
14079
14113
|
throw new Error("No active session. Sign in first.");
|
|
14080
14114
|
}
|
|
14081
|
-
const publicKV = new
|
|
14082
|
-
const publicContext = new
|
|
14115
|
+
const publicKV = new import_sdk_services6.KVService({ prefix: "" });
|
|
14116
|
+
const publicContext = new import_sdk_services6.ServiceContext({
|
|
14083
14117
|
invoke: this._serviceContext.invoke,
|
|
14084
14118
|
fetch: this._serviceContext.fetch,
|
|
14085
14119
|
hosts: this._serviceContext.hosts,
|
|
@@ -14112,23 +14146,19 @@ var TinyCloud = class _TinyCloud {
|
|
|
14112
14146
|
const response = await doFetch(url, { method: "GET" });
|
|
14113
14147
|
if (!response.ok) {
|
|
14114
14148
|
if (response.status === 404) {
|
|
14115
|
-
return (0,
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
);
|
|
14149
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
14150
|
+
response,
|
|
14151
|
+
import_sdk_services6.ErrorCodes.NOT_FOUND,
|
|
14152
|
+
`Key not found: ${key} in space ${spaceId}`,
|
|
14153
|
+
"public-space"
|
|
14154
|
+
));
|
|
14122
14155
|
}
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
|
|
14129
|
-
{ meta: { status: response.status } }
|
|
14130
|
-
)
|
|
14131
|
-
);
|
|
14156
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
14157
|
+
response,
|
|
14158
|
+
import_sdk_services6.ErrorCodes.NETWORK_ERROR,
|
|
14159
|
+
"Failed to read public space",
|
|
14160
|
+
"public-space"
|
|
14161
|
+
));
|
|
14132
14162
|
}
|
|
14133
14163
|
const contentType = response.headers.get("content-type");
|
|
14134
14164
|
let data;
|
|
@@ -14142,11 +14172,11 @@ var TinyCloud = class _TinyCloud {
|
|
|
14142
14172
|
data = text2;
|
|
14143
14173
|
}
|
|
14144
14174
|
}
|
|
14145
|
-
return (0,
|
|
14175
|
+
return (0, import_sdk_services6.ok)(data);
|
|
14146
14176
|
} catch (error) {
|
|
14147
|
-
return (0,
|
|
14148
|
-
(0,
|
|
14149
|
-
|
|
14177
|
+
return (0, import_sdk_services6.err)(
|
|
14178
|
+
(0, import_sdk_services6.serviceError)(
|
|
14179
|
+
import_sdk_services6.ErrorCodes.NETWORK_ERROR,
|
|
14150
14180
|
`Network error reading public space: ${String(error)}`,
|
|
14151
14181
|
"public-space",
|
|
14152
14182
|
{ cause: error instanceof Error ? error : void 0 }
|
|
@@ -14172,7 +14202,7 @@ var TinyCloud = class _TinyCloud {
|
|
|
14172
14202
|
};
|
|
14173
14203
|
|
|
14174
14204
|
// src/account/AccountService.ts
|
|
14175
|
-
var
|
|
14205
|
+
var import_sdk_services7 = require("@tinycloud/sdk-services");
|
|
14176
14206
|
var import_bootstrap3 = require("@tinycloud/bootstrap");
|
|
14177
14207
|
var SERVICE_NAME2 = "account";
|
|
14178
14208
|
var ACCOUNT_INDEX_DB = "account";
|
|
@@ -14185,10 +14215,10 @@ var AccountService = class {
|
|
|
14185
14215
|
* Per-account-space memo for {@link ensureAccountIndex}.
|
|
14186
14216
|
*
|
|
14187
14217
|
* Applying the index migration is a no-op once the schema exists, but the
|
|
14188
|
-
* SQL service still spends
|
|
14189
|
-
*
|
|
14190
|
-
*
|
|
14191
|
-
*
|
|
14218
|
+
* SQL service still spends a round trip discovering that (reading the
|
|
14219
|
+
* applied-migration rows). Account bootstrap touches the index eight times,
|
|
14220
|
+
* so without a memo that is ~7 wasted requests on the cold sign-in path.
|
|
14221
|
+
* The in-flight dedupe inside SQLService
|
|
14192
14222
|
* never helps here: the node SDK builds a fresh SQLService per
|
|
14193
14223
|
* `getAccountDb()` call, so its lock map is always empty.
|
|
14194
14224
|
*
|
|
@@ -14220,7 +14250,7 @@ var AccountService = class {
|
|
|
14220
14250
|
applications.push(applicationFromRecord(key, loaded.data.data));
|
|
14221
14251
|
}
|
|
14222
14252
|
applications.sort((a, b) => a.appId.localeCompare(b.appId));
|
|
14223
|
-
return (0,
|
|
14253
|
+
return (0, import_sdk_services7.ok)(applications);
|
|
14224
14254
|
},
|
|
14225
14255
|
get: async (appId) => {
|
|
14226
14256
|
const kvResult = this.accountKV();
|
|
@@ -14228,14 +14258,14 @@ var AccountService = class {
|
|
|
14228
14258
|
const key = applicationKey(appId);
|
|
14229
14259
|
const loaded = await kvResult.data.get(key);
|
|
14230
14260
|
if (!loaded.ok) return accountErr(loaded.error);
|
|
14231
|
-
return (0,
|
|
14261
|
+
return (0, import_sdk_services7.ok)(applicationFromRecord(key, loaded.data.data));
|
|
14232
14262
|
},
|
|
14233
14263
|
register: async (manifest, options2 = {}) => {
|
|
14234
14264
|
const manifests = Array.isArray(manifest) ? manifest : [manifest];
|
|
14235
14265
|
const request = composeManifestRequest(manifests);
|
|
14236
14266
|
if (request.registryRecords.length === 0) {
|
|
14237
|
-
return (0,
|
|
14238
|
-
(0,
|
|
14267
|
+
return (0, import_sdk_services7.err)(
|
|
14268
|
+
(0, import_sdk_services7.serviceError)(
|
|
14239
14269
|
"INVALID_MANIFEST",
|
|
14240
14270
|
"Manifest did not produce an account application registry record",
|
|
14241
14271
|
SERVICE_NAME2
|
|
@@ -14269,7 +14299,7 @@ var AccountService = class {
|
|
|
14269
14299
|
registered = applicationFromRecord(record2.key, stored);
|
|
14270
14300
|
await this.upsertApplicationIndexQuietly(registered);
|
|
14271
14301
|
}
|
|
14272
|
-
return (0,
|
|
14302
|
+
return (0, import_sdk_services7.ok)(registered);
|
|
14273
14303
|
},
|
|
14274
14304
|
remove: async (appId) => {
|
|
14275
14305
|
const kvResult = this.accountKV();
|
|
@@ -14277,7 +14307,7 @@ var AccountService = class {
|
|
|
14277
14307
|
const removed = await kvResult.data.delete(applicationKey(appId));
|
|
14278
14308
|
if (!removed.ok) return accountErr(removed.error);
|
|
14279
14309
|
await this.deleteApplicationIndexQuietly(appId);
|
|
14280
|
-
return (0,
|
|
14310
|
+
return (0, import_sdk_services7.ok)(void 0);
|
|
14281
14311
|
}
|
|
14282
14312
|
};
|
|
14283
14313
|
this.spaces = {
|
|
@@ -14286,11 +14316,12 @@ var AccountService = class {
|
|
|
14286
14316
|
const indexed = await this.index.spaces.list();
|
|
14287
14317
|
if (indexed.ok && indexed.data.length > 0) return indexed;
|
|
14288
14318
|
if (!indexed.ok && !isMissingIndexError(indexed.error)) return indexed;
|
|
14289
|
-
const canonical = await this.
|
|
14290
|
-
if (canonical.ok
|
|
14291
|
-
|
|
14319
|
+
const canonical = await this.syncAccessibleSpaces({ tolerateStorageFull: true });
|
|
14320
|
+
if (!canonical.ok) return canonical;
|
|
14321
|
+
if (canonical.data.allRegistered && options2.refreshIndex !== false) {
|
|
14322
|
+
await this.replaceSpacesIndexQuietly(canonical.data.spaces);
|
|
14292
14323
|
}
|
|
14293
|
-
return canonical;
|
|
14324
|
+
return (0, import_sdk_services7.ok)(canonical.data.spaces);
|
|
14294
14325
|
}
|
|
14295
14326
|
const kvResult = this.accountKV();
|
|
14296
14327
|
if (!kvResult.ok) return kvResult;
|
|
@@ -14303,14 +14334,14 @@ var AccountService = class {
|
|
|
14303
14334
|
spaces.push(spaceFromRecord(key, loaded.data.data));
|
|
14304
14335
|
}
|
|
14305
14336
|
spaces.sort((a, b) => a.name.localeCompare(b.name) || a.spaceId.localeCompare(b.spaceId));
|
|
14306
|
-
return (0,
|
|
14337
|
+
return (0, import_sdk_services7.ok)(spaces);
|
|
14307
14338
|
},
|
|
14308
14339
|
get: async (spaceId) => {
|
|
14309
14340
|
const kvResult = this.accountKV();
|
|
14310
14341
|
if (!kvResult.ok) return kvResult;
|
|
14311
14342
|
const loaded = await kvResult.data.get(spaceKey(spaceId));
|
|
14312
14343
|
if (!loaded.ok) return accountErr(loaded.error);
|
|
14313
|
-
return (0,
|
|
14344
|
+
return (0, import_sdk_services7.ok)(spaceFromRecord(spaceKey(spaceId), loaded.data.data));
|
|
14314
14345
|
},
|
|
14315
14346
|
register: async (space) => {
|
|
14316
14347
|
await this.config.ensureAccountSpaceHosted?.();
|
|
@@ -14321,7 +14352,7 @@ var AccountService = class {
|
|
|
14321
14352
|
if (!written.ok) return accountErr(written.error);
|
|
14322
14353
|
const registered = spaceFromRecord(spaceKey(stored.space_id), stored);
|
|
14323
14354
|
await this.upsertSpaceIndexQuietly(registered);
|
|
14324
|
-
return (0,
|
|
14355
|
+
return (0, import_sdk_services7.ok)(registered);
|
|
14325
14356
|
},
|
|
14326
14357
|
/**
|
|
14327
14358
|
* Register multiple spaces in one KV batch write + one multi-row index
|
|
@@ -14334,7 +14365,7 @@ var AccountService = class {
|
|
|
14334
14365
|
* leave the first attempt's blocks orphaned.
|
|
14335
14366
|
*/
|
|
14336
14367
|
registerBatch: async (spaces) => {
|
|
14337
|
-
if (spaces.length === 0) return (0,
|
|
14368
|
+
if (spaces.length === 0) return (0, import_sdk_services7.ok)({ spaces: [] });
|
|
14338
14369
|
await this.config.ensureAccountSpaceHosted?.();
|
|
14339
14370
|
const kvResult = this.accountKV();
|
|
14340
14371
|
if (!kvResult.ok) return kvResult;
|
|
@@ -14349,7 +14380,7 @@ var AccountService = class {
|
|
|
14349
14380
|
const batchResult = await kvResult.data.batchPut(items);
|
|
14350
14381
|
if (batchResult.ok) {
|
|
14351
14382
|
await this.upsertSpacesIndexQuietly(registered);
|
|
14352
|
-
return (0,
|
|
14383
|
+
return (0, import_sdk_services7.ok)({ spaces: registered });
|
|
14353
14384
|
}
|
|
14354
14385
|
if (!isAmbiguousBatchFailure(batchResult.error)) {
|
|
14355
14386
|
return accountErr(batchResult.error);
|
|
@@ -14362,8 +14393,8 @@ var AccountService = class {
|
|
|
14362
14393
|
}
|
|
14363
14394
|
}
|
|
14364
14395
|
if (reconcileFailures.length > 0) {
|
|
14365
|
-
return (0,
|
|
14366
|
-
(0,
|
|
14396
|
+
return (0, import_sdk_services7.err)(
|
|
14397
|
+
(0, import_sdk_services7.serviceError)(
|
|
14367
14398
|
"KV_BATCH_RECONCILE_FAILED",
|
|
14368
14399
|
`KV batch write for ${items.length} space(s) failed ambiguously (${batchResult.error.message}) and per-space reconciliation also failed for: ${reconcileFailures.join("; ")}`,
|
|
14369
14400
|
SERVICE_NAME2,
|
|
@@ -14375,18 +14406,11 @@ var AccountService = class {
|
|
|
14375
14406
|
`[AccountService] KV batch write for ${items.length} space(s) returned an ambiguous error and was reconciled via per-space fallback. Original error: ${batchResult.error.message}`
|
|
14376
14407
|
);
|
|
14377
14408
|
await this.upsertSpacesIndexQuietly(registered);
|
|
14378
|
-
return (0,
|
|
14409
|
+
return (0, import_sdk_services7.ok)({ spaces: registered, recoveredFromBatchError: batchResult.error });
|
|
14379
14410
|
},
|
|
14380
14411
|
syncAccessible: async () => {
|
|
14381
|
-
const
|
|
14382
|
-
|
|
14383
|
-
const registered = [];
|
|
14384
|
-
for (const space of listed.data) {
|
|
14385
|
-
const result = await this.spaces.register(space);
|
|
14386
|
-
if (!result.ok) return result;
|
|
14387
|
-
registered.push(result.data);
|
|
14388
|
-
}
|
|
14389
|
-
return (0, import_sdk_services6.ok)(registered);
|
|
14412
|
+
const synced = await this.syncAccessibleSpaces({ tolerateStorageFull: false });
|
|
14413
|
+
return synced.ok ? (0, import_sdk_services7.ok)(synced.data.spaces) : synced;
|
|
14390
14414
|
},
|
|
14391
14415
|
remove: async (spaceId) => {
|
|
14392
14416
|
const kvResult = this.accountKV();
|
|
@@ -14394,21 +14418,21 @@ var AccountService = class {
|
|
|
14394
14418
|
const removed = await kvResult.data.delete(spaceKey(spaceId));
|
|
14395
14419
|
if (!removed.ok) return accountErr(removed.error);
|
|
14396
14420
|
await this.deleteSpaceIndexQuietly(spaceId);
|
|
14397
|
-
return (0,
|
|
14421
|
+
return (0, import_sdk_services7.ok)(void 0);
|
|
14398
14422
|
}
|
|
14399
14423
|
};
|
|
14400
14424
|
this.delegations = {
|
|
14401
14425
|
query: async (options2 = {}) => {
|
|
14402
14426
|
const manager = this.config.getDelegationManager?.();
|
|
14403
14427
|
if (!manager) {
|
|
14404
|
-
return (0,
|
|
14428
|
+
return (0, import_sdk_services7.err)((0, import_sdk_services7.serviceError)(
|
|
14405
14429
|
"NOT_INITIALIZED",
|
|
14406
14430
|
"Delegation history requires an authenticated delegation manager",
|
|
14407
14431
|
SERVICE_NAME2
|
|
14408
14432
|
));
|
|
14409
14433
|
}
|
|
14410
14434
|
const queried = await manager.query(options2);
|
|
14411
|
-
return queried.ok ? (0,
|
|
14435
|
+
return queried.ok ? (0, import_sdk_services7.ok)(queried.data) : accountErr(queried.error);
|
|
14412
14436
|
},
|
|
14413
14437
|
list: async (options2 = {}) => {
|
|
14414
14438
|
if (options2.preferIndex) {
|
|
@@ -14442,17 +14466,17 @@ var AccountService = class {
|
|
|
14442
14466
|
}
|
|
14443
14467
|
}
|
|
14444
14468
|
delegations.sort((a, b) => a.spaceId.localeCompare(b.spaceId) || a.cid.localeCompare(b.cid));
|
|
14445
|
-
return (0,
|
|
14469
|
+
return (0, import_sdk_services7.ok)(delegations);
|
|
14446
14470
|
},
|
|
14447
14471
|
revoke: async (input) => {
|
|
14448
14472
|
const cid2 = typeof input === "string" ? input : input.cid;
|
|
14449
14473
|
const manager = this.config.getDelegationManager?.();
|
|
14450
14474
|
if (manager) {
|
|
14451
14475
|
const revoked2 = await manager.revoke(cid2);
|
|
14452
|
-
return revoked2.ok ? (0,
|
|
14476
|
+
return revoked2.ok ? (0, import_sdk_services7.ok)(revoked2.data) : accountErr(revoked2.error);
|
|
14453
14477
|
}
|
|
14454
14478
|
if (typeof input === "string") {
|
|
14455
|
-
return (0,
|
|
14479
|
+
return (0, import_sdk_services7.err)((0, import_sdk_services7.serviceError)(
|
|
14456
14480
|
"NOT_INITIALIZED",
|
|
14457
14481
|
"CID-only revocation requires an authenticated delegation manager",
|
|
14458
14482
|
SERVICE_NAME2
|
|
@@ -14462,7 +14486,7 @@ var AccountService = class {
|
|
|
14462
14486
|
if (!space.ok) return space;
|
|
14463
14487
|
const revoked = await this.config.getSpaces().get(space.data.id).delegations.revoke(cid2);
|
|
14464
14488
|
if (!revoked.ok) return accountErr(revoked.error);
|
|
14465
|
-
return (0,
|
|
14489
|
+
return (0, import_sdk_services7.ok)(void 0);
|
|
14466
14490
|
}
|
|
14467
14491
|
};
|
|
14468
14492
|
this.index = {
|
|
@@ -14471,7 +14495,7 @@ var AccountService = class {
|
|
|
14471
14495
|
if (!dbResult.ok) return dbResult;
|
|
14472
14496
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
14473
14497
|
if (!schema.ok) return schema;
|
|
14474
|
-
return (0,
|
|
14498
|
+
return (0, import_sdk_services7.ok)({ database: ACCOUNT_INDEX_DB });
|
|
14475
14499
|
},
|
|
14476
14500
|
rebuild: async () => {
|
|
14477
14501
|
const dbResult = this.accountDb();
|
|
@@ -14553,7 +14577,7 @@ var AccountService = class {
|
|
|
14553
14577
|
];
|
|
14554
14578
|
const rebuilt = await dbResult.data.batch(statements);
|
|
14555
14579
|
if (!rebuilt.ok) return accountErr(rebuilt.error);
|
|
14556
|
-
return (0,
|
|
14580
|
+
return (0, import_sdk_services7.ok)({
|
|
14557
14581
|
database: ACCOUNT_INDEX_DB,
|
|
14558
14582
|
applications: applications.data.length,
|
|
14559
14583
|
spaces: spaces.data.length,
|
|
@@ -14569,7 +14593,7 @@ var AccountService = class {
|
|
|
14569
14593
|
"SELECT applications.app_id, name, description, updated_at, manifest_json, application_state.manifest_hash FROM applications LEFT JOIN application_state ON applications.app_id = application_state.app_id ORDER BY applications.app_id"
|
|
14570
14594
|
);
|
|
14571
14595
|
if (!queried.ok) return accountErr(queried.error);
|
|
14572
|
-
return (0,
|
|
14596
|
+
return (0, import_sdk_services7.ok)(queried.data.rows.map(indexedApplicationFromRow));
|
|
14573
14597
|
}
|
|
14574
14598
|
},
|
|
14575
14599
|
spaces: {
|
|
@@ -14580,7 +14604,7 @@ var AccountService = class {
|
|
|
14580
14604
|
"SELECT space_id, name, owner_did, type, permissions_json, status, registered_at, updated_at, expires_at FROM spaces ORDER BY name, space_id"
|
|
14581
14605
|
);
|
|
14582
14606
|
if (!queried.ok) return accountErr(queried.error);
|
|
14583
|
-
return (0,
|
|
14607
|
+
return (0, import_sdk_services7.ok)(queried.data.rows.map(indexedSpaceFromRow));
|
|
14584
14608
|
}
|
|
14585
14609
|
},
|
|
14586
14610
|
delegations: {
|
|
@@ -14602,7 +14626,7 @@ var AccountService = class {
|
|
|
14602
14626
|
params
|
|
14603
14627
|
);
|
|
14604
14628
|
if (!queried.ok) return accountErr(queried.error);
|
|
14605
|
-
return (0,
|
|
14629
|
+
return (0, import_sdk_services7.ok)(queried.data.rows.map(indexedDelegationFromRow));
|
|
14606
14630
|
}
|
|
14607
14631
|
},
|
|
14608
14632
|
query: async (sql, params) => {
|
|
@@ -14610,7 +14634,7 @@ var AccountService = class {
|
|
|
14610
14634
|
if (!dbResult.ok) return dbResult;
|
|
14611
14635
|
const queried = await dbResult.data.query(sql, params);
|
|
14612
14636
|
if (!queried.ok) return accountErr(queried.error);
|
|
14613
|
-
return (0,
|
|
14637
|
+
return (0, import_sdk_services7.ok)(queried.data);
|
|
14614
14638
|
},
|
|
14615
14639
|
status: async () => {
|
|
14616
14640
|
const dbResult = this.accountDb();
|
|
@@ -14620,11 +14644,11 @@ var AccountService = class {
|
|
|
14620
14644
|
);
|
|
14621
14645
|
if (!queried.ok) {
|
|
14622
14646
|
if (isMissingIndexError(queried.error)) {
|
|
14623
|
-
return (0,
|
|
14647
|
+
return (0, import_sdk_services7.ok)({ database: ACCOUNT_INDEX_DB, state: "missing", sources: [] });
|
|
14624
14648
|
}
|
|
14625
14649
|
return accountErr(queried.error);
|
|
14626
14650
|
}
|
|
14627
|
-
return (0,
|
|
14651
|
+
return (0, import_sdk_services7.ok)({
|
|
14628
14652
|
database: ACCOUNT_INDEX_DB,
|
|
14629
14653
|
state: "ready",
|
|
14630
14654
|
sources: queried.data.rows.map(([source, syncedAt, count]) => ({
|
|
@@ -14643,7 +14667,7 @@ var AccountService = class {
|
|
|
14643
14667
|
if (!delegations.ok) return delegations;
|
|
14644
14668
|
const spaces = await this.spaces.list();
|
|
14645
14669
|
if (!spaces.ok) return spaces;
|
|
14646
|
-
return (0,
|
|
14670
|
+
return (0, import_sdk_services7.ok)({
|
|
14647
14671
|
did: this.config.getDid(),
|
|
14648
14672
|
host: this.config.getHost(),
|
|
14649
14673
|
primarySpaceId: this.config.getPrimarySpaceId(),
|
|
@@ -14657,28 +14681,28 @@ var AccountService = class {
|
|
|
14657
14681
|
accountKV() {
|
|
14658
14682
|
const accountSpaceId = this.config.getAccountSpaceId();
|
|
14659
14683
|
if (!accountSpaceId) {
|
|
14660
|
-
return (0,
|
|
14661
|
-
(0,
|
|
14684
|
+
return (0, import_sdk_services7.err)(
|
|
14685
|
+
(0, import_sdk_services7.serviceError)(
|
|
14662
14686
|
"ACCOUNT_SPACE_UNAVAILABLE",
|
|
14663
14687
|
"Account space is unavailable. Sign in with a wallet-backed profile first.",
|
|
14664
14688
|
SERVICE_NAME2
|
|
14665
14689
|
)
|
|
14666
14690
|
);
|
|
14667
14691
|
}
|
|
14668
|
-
return (0,
|
|
14692
|
+
return (0, import_sdk_services7.ok)(this.config.getSpaces().get(accountSpaceId).kv);
|
|
14669
14693
|
}
|
|
14670
14694
|
accountDb() {
|
|
14671
14695
|
const db = this.config.getAccountDb?.();
|
|
14672
14696
|
if (!db) {
|
|
14673
|
-
return (0,
|
|
14674
|
-
(0,
|
|
14697
|
+
return (0, import_sdk_services7.err)(
|
|
14698
|
+
(0, import_sdk_services7.serviceError)(
|
|
14675
14699
|
"ACCOUNT_INDEX_UNAVAILABLE",
|
|
14676
14700
|
"Account index database is unavailable. Sign in with a wallet-backed profile first.",
|
|
14677
14701
|
SERVICE_NAME2
|
|
14678
14702
|
)
|
|
14679
14703
|
);
|
|
14680
14704
|
}
|
|
14681
|
-
return (0,
|
|
14705
|
+
return (0, import_sdk_services7.ok)(db);
|
|
14682
14706
|
}
|
|
14683
14707
|
async indexHasApplicationHash(appId, manifestHash) {
|
|
14684
14708
|
const dbResult = this.accountDb();
|
|
@@ -14696,7 +14720,7 @@ var AccountService = class {
|
|
|
14696
14720
|
}
|
|
14697
14721
|
async upsertApplicationIndex(app) {
|
|
14698
14722
|
const dbResult = this.accountDb();
|
|
14699
|
-
if (!dbResult.ok) return (0,
|
|
14723
|
+
if (!dbResult.ok) return (0, import_sdk_services7.ok)(void 0);
|
|
14700
14724
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
14701
14725
|
if (!schema.ok) return schema;
|
|
14702
14726
|
const updatedAt = app.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -14718,14 +14742,14 @@ var AccountService = class {
|
|
|
14718
14742
|
}
|
|
14719
14743
|
]);
|
|
14720
14744
|
if (!written.ok) return accountErr(written.error);
|
|
14721
|
-
return (0,
|
|
14745
|
+
return (0, import_sdk_services7.ok)(void 0);
|
|
14722
14746
|
}
|
|
14723
14747
|
async deleteApplicationIndexQuietly(appId) {
|
|
14724
14748
|
await ignoreIndexFailure(() => this.deleteApplicationIndex(appId));
|
|
14725
14749
|
}
|
|
14726
14750
|
async deleteApplicationIndex(appId) {
|
|
14727
14751
|
const dbResult = this.accountDb();
|
|
14728
|
-
if (!dbResult.ok) return (0,
|
|
14752
|
+
if (!dbResult.ok) return (0, import_sdk_services7.ok)(void 0);
|
|
14729
14753
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
14730
14754
|
if (!schema.ok) return schema;
|
|
14731
14755
|
const deleted = await dbResult.data.batch([
|
|
@@ -14733,14 +14757,14 @@ var AccountService = class {
|
|
|
14733
14757
|
{ sql: "DELETE FROM application_state WHERE app_id = ?", params: [appId] }
|
|
14734
14758
|
]);
|
|
14735
14759
|
if (!deleted.ok) return accountErr(deleted.error);
|
|
14736
|
-
return (0,
|
|
14760
|
+
return (0, import_sdk_services7.ok)(void 0);
|
|
14737
14761
|
}
|
|
14738
14762
|
async upsertSpaceIndexQuietly(space) {
|
|
14739
14763
|
await ignoreIndexFailure(() => this.upsertSpaceIndex(space));
|
|
14740
14764
|
}
|
|
14741
14765
|
async upsertSpaceIndex(space) {
|
|
14742
14766
|
const dbResult = this.accountDb();
|
|
14743
|
-
if (!dbResult.ok) return (0,
|
|
14767
|
+
if (!dbResult.ok) return (0, import_sdk_services7.ok)(void 0);
|
|
14744
14768
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
14745
14769
|
if (!schema.ok) return schema;
|
|
14746
14770
|
const updatedAt = space.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -14761,7 +14785,7 @@ var AccountService = class {
|
|
|
14761
14785
|
}
|
|
14762
14786
|
]);
|
|
14763
14787
|
if (!written.ok) return accountErr(written.error);
|
|
14764
|
-
return (0,
|
|
14788
|
+
return (0, import_sdk_services7.ok)(void 0);
|
|
14765
14789
|
}
|
|
14766
14790
|
async upsertSpacesIndexQuietly(spaces) {
|
|
14767
14791
|
await ignoreIndexFailure(() => this.upsertSpacesIndex(spaces));
|
|
@@ -14775,9 +14799,9 @@ var AccountService = class {
|
|
|
14775
14799
|
* atomically: all rows or none.
|
|
14776
14800
|
*/
|
|
14777
14801
|
async upsertSpacesIndex(spaces) {
|
|
14778
|
-
if (spaces.length === 0) return (0,
|
|
14802
|
+
if (spaces.length === 0) return (0, import_sdk_services7.ok)(void 0);
|
|
14779
14803
|
const dbResult = this.accountDb();
|
|
14780
|
-
if (!dbResult.ok) return (0,
|
|
14804
|
+
if (!dbResult.ok) return (0, import_sdk_services7.ok)(void 0);
|
|
14781
14805
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
14782
14806
|
if (!schema.ok) return schema;
|
|
14783
14807
|
const placeholders = spaces.map(() => "(?, ?, ?, ?, ?, ?, ?, ?, ?)").join(", ");
|
|
@@ -14802,32 +14826,60 @@ var AccountService = class {
|
|
|
14802
14826
|
}
|
|
14803
14827
|
]);
|
|
14804
14828
|
if (!written.ok) return accountErr(written.error);
|
|
14805
|
-
return (0,
|
|
14829
|
+
return (0, import_sdk_services7.ok)(void 0);
|
|
14806
14830
|
}
|
|
14807
14831
|
async deleteSpaceIndexQuietly(spaceId) {
|
|
14808
14832
|
await ignoreIndexFailure(() => this.deleteSpaceIndex(spaceId));
|
|
14809
14833
|
}
|
|
14810
14834
|
async deleteSpaceIndex(spaceId) {
|
|
14811
14835
|
const dbResult = this.accountDb();
|
|
14812
|
-
if (!dbResult.ok) return (0,
|
|
14836
|
+
if (!dbResult.ok) return (0, import_sdk_services7.ok)(void 0);
|
|
14813
14837
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
14814
14838
|
if (!schema.ok) return schema;
|
|
14815
14839
|
const deleted = await dbResult.data.batch([
|
|
14816
14840
|
{ sql: "DELETE FROM spaces WHERE space_id = ?", params: [spaceId] }
|
|
14817
14841
|
]);
|
|
14818
14842
|
if (!deleted.ok) return accountErr(deleted.error);
|
|
14819
|
-
return (0,
|
|
14843
|
+
return (0, import_sdk_services7.ok)(void 0);
|
|
14844
|
+
}
|
|
14845
|
+
/**
|
|
14846
|
+
* Register every space the session can reach and return them. With
|
|
14847
|
+
* `tolerateStorageFull`, a full account space stops the registration
|
|
14848
|
+
* writes but not the listing: the remaining spaces are returned as they
|
|
14849
|
+
* would have been registered, and `allRegistered` is false.
|
|
14850
|
+
*/
|
|
14851
|
+
async syncAccessibleSpaces(options2) {
|
|
14852
|
+
const listed = await this.config.getSpaces().list();
|
|
14853
|
+
if (!listed.ok) return accountErr(listed.error);
|
|
14854
|
+
const spaces = [];
|
|
14855
|
+
let allRegistered = true;
|
|
14856
|
+
for (const space of listed.data) {
|
|
14857
|
+
if (allRegistered) {
|
|
14858
|
+
const result = await this.spaces.register(space);
|
|
14859
|
+
if (result.ok) {
|
|
14860
|
+
spaces.push(result.data);
|
|
14861
|
+
continue;
|
|
14862
|
+
}
|
|
14863
|
+
if (!options2.tolerateStorageFull || !(0, import_sdk_services7.isStorageFullError)(result.error)) {
|
|
14864
|
+
return result;
|
|
14865
|
+
}
|
|
14866
|
+
allRegistered = false;
|
|
14867
|
+
}
|
|
14868
|
+
const record2 = spaceRecordFromInput(space);
|
|
14869
|
+
spaces.push(spaceFromRecord(spaceKey(record2.space_id), record2));
|
|
14870
|
+
}
|
|
14871
|
+
return (0, import_sdk_services7.ok)({ spaces, allRegistered });
|
|
14820
14872
|
}
|
|
14821
14873
|
async resolveSpace(space) {
|
|
14822
14874
|
const listed = await this.config.getSpaces().list();
|
|
14823
14875
|
if (!listed.ok) return accountErr(listed.error);
|
|
14824
14876
|
const found = listed.data.find((candidate) => candidate.id === space || candidate.name === space);
|
|
14825
14877
|
if (!found) {
|
|
14826
|
-
return (0,
|
|
14827
|
-
(0,
|
|
14878
|
+
return (0, import_sdk_services7.err)(
|
|
14879
|
+
(0, import_sdk_services7.serviceError)("SPACE_NOT_FOUND", `No account space found for ${JSON.stringify(space)}`, SERVICE_NAME2)
|
|
14828
14880
|
);
|
|
14829
14881
|
}
|
|
14830
|
-
return (0,
|
|
14882
|
+
return (0, import_sdk_services7.ok)(found);
|
|
14831
14883
|
}
|
|
14832
14884
|
async replaceApplicationsIndexQuietly(applications) {
|
|
14833
14885
|
await ignoreIndexFailure(async () => {
|
|
@@ -14969,7 +15021,7 @@ var AccountService = class {
|
|
|
14969
15021
|
]
|
|
14970
15022
|
});
|
|
14971
15023
|
if (!migrated.ok) return accountErr(migrated.error);
|
|
14972
|
-
return (0,
|
|
15024
|
+
return (0, import_sdk_services7.ok)(void 0);
|
|
14973
15025
|
}
|
|
14974
15026
|
};
|
|
14975
15027
|
function applicationKey(appId) {
|
|
@@ -15125,17 +15177,17 @@ function mapDelegation(delegation, space, direction) {
|
|
|
15125
15177
|
};
|
|
15126
15178
|
}
|
|
15127
15179
|
function accountErr(error) {
|
|
15128
|
-
return (0,
|
|
15180
|
+
return (0, import_sdk_services7.err)((0, import_sdk_services7.serviceError)(error.code, error.message, SERVICE_NAME2, { cause: error.cause, meta: error.meta }));
|
|
15129
15181
|
}
|
|
15130
15182
|
function isMissingIndexError(error) {
|
|
15131
15183
|
return /no such table:/i.test(error.message);
|
|
15132
15184
|
}
|
|
15133
15185
|
var AMBIGUOUS_WRITE_STATUSES = /* @__PURE__ */ new Set([500, 502, 503, 504, 520, 522, 524]);
|
|
15134
15186
|
function isAmbiguousBatchFailure(error) {
|
|
15135
|
-
if (error.code ===
|
|
15187
|
+
if (error.code === import_sdk_services7.ErrorCodes.NETWORK_ERROR || error.code === import_sdk_services7.ErrorCodes.TIMEOUT) {
|
|
15136
15188
|
return error.meta?.requestMayHaveDispatched === true;
|
|
15137
15189
|
}
|
|
15138
|
-
if (error.code ===
|
|
15190
|
+
if (error.code === import_sdk_services7.ErrorCodes.KV_WRITE_FAILED) {
|
|
15139
15191
|
const status = error.meta?.status;
|
|
15140
15192
|
return typeof status === "number" && AMBIGUOUS_WRITE_STATUSES.has(status);
|
|
15141
15193
|
}
|
|
@@ -15149,7 +15201,7 @@ async function ignoreIndexFailure(task) {
|
|
|
15149
15201
|
}
|
|
15150
15202
|
|
|
15151
15203
|
// src/index.ts
|
|
15152
|
-
var
|
|
15204
|
+
var import_sdk_services9 = require("@tinycloud/sdk-services");
|
|
15153
15205
|
|
|
15154
15206
|
// src/space.ts
|
|
15155
15207
|
async function fetchPeerId(host, spaceId) {
|
|
@@ -15158,7 +15210,9 @@ async function fetchPeerId(host, spaceId) {
|
|
|
15158
15210
|
);
|
|
15159
15211
|
if (!res.ok) {
|
|
15160
15212
|
const error = await res.text().catch(() => res.statusText);
|
|
15161
|
-
throw new Error(`Failed to get peer ID: ${res.status} - ${error}`)
|
|
15213
|
+
throw Object.assign(new Error(`Failed to get peer ID: ${res.status} - ${error}`), {
|
|
15214
|
+
status: res.status
|
|
15215
|
+
});
|
|
15162
15216
|
}
|
|
15163
15217
|
return res.text();
|
|
15164
15218
|
}
|
|
@@ -15248,7 +15302,7 @@ async function postSessionActivation(host, delegationHeader) {
|
|
|
15248
15302
|
}
|
|
15249
15303
|
|
|
15250
15304
|
// src/authorization/CapabilityKeyRegistry.ts
|
|
15251
|
-
var
|
|
15305
|
+
var import_sdk_services8 = require("@tinycloud/sdk-services");
|
|
15252
15306
|
var SERVICE_NAME3 = "capability-key-registry";
|
|
15253
15307
|
var CapabilityKeyRegistryErrorCodes = {
|
|
15254
15308
|
/** Key not found in registry */
|
|
@@ -15473,8 +15527,8 @@ var CapabilityKeyRegistry = class {
|
|
|
15473
15527
|
revokeDelegation(cid2) {
|
|
15474
15528
|
const stored = this.store.byCid.get(cid2);
|
|
15475
15529
|
if (!stored || stored.length === 0) {
|
|
15476
|
-
return (0,
|
|
15477
|
-
(0,
|
|
15530
|
+
return (0, import_sdk_services8.err)(
|
|
15531
|
+
(0, import_sdk_services8.serviceError)(
|
|
15478
15532
|
CapabilityKeyRegistryErrorCodes.KEY_NOT_FOUND,
|
|
15479
15533
|
`Delegation not found: ${cid2}`,
|
|
15480
15534
|
SERVICE_NAME3
|
|
@@ -15494,7 +15548,7 @@ var CapabilityKeyRegistry = class {
|
|
|
15494
15548
|
}
|
|
15495
15549
|
}
|
|
15496
15550
|
}
|
|
15497
|
-
return (0,
|
|
15551
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
15498
15552
|
}
|
|
15499
15553
|
// ===========================================================================
|
|
15500
15554
|
// Search
|