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