@tinycloud/sdk-core 3.8.0-beta.2 → 3.8.0-beta.20
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/{credential-admission-Cg1M9uyV.d.cts → credential-admission-B7_F6Yb3.d.cts} +1 -0
- package/dist/{credential-admission-7I_ymo-C.d.ts → credential-admission-DCJhDFFv.d.ts} +1 -0
- package/dist/delegations/index.cjs +76 -14
- package/dist/delegations/index.cjs.map +1 -1
- package/dist/delegations/index.d.cts +4 -2
- package/dist/delegations/index.d.ts +4 -2
- package/dist/delegations/index.js +69 -7
- package/dist/delegations/index.js.map +1 -1
- package/dist/delegations/issued.cjs +697 -0
- package/dist/delegations/issued.cjs.map +1 -0
- package/dist/delegations/issued.d.cts +54 -0
- package/dist/delegations/issued.d.ts +54 -0
- package/dist/delegations/issued.js +674 -0
- package/dist/delegations/issued.js.map +1 -0
- package/dist/index.cjs +442 -294
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -5
- package/dist/index.d.ts +21 -5
- package/dist/index.js +171 -23
- package/dist/index.js.map +1 -1
- package/dist/policy/index.cjs +4 -6
- package/dist/policy/index.cjs.map +1 -1
- package/dist/policy/index.d.cts +2 -2
- package/dist/policy/index.d.ts +2 -2
- package/dist/policy/index.js +4 -6
- package/dist/policy/index.js.map +1 -1
- package/dist/{recipient-types.schema-BApcOn1t.d.cts → recipient-types.schema-BIJcihno.d.cts} +42 -1741
- package/dist/{recipient-types.schema-BApcOn1t.d.ts → recipient-types.schema-Ebi5aliq.d.ts} +42 -1741
- package/dist/types.schema-BmN-OnCA.d.cts +1763 -0
- package/dist/types.schema-BmN-OnCA.d.ts +1763 -0
- package/package.json +9 -4
package/dist/index.cjs
CHANGED
|
@@ -74,13 +74,13 @@ __export(index_exports, {
|
|
|
74
74
|
ClientSessionSchema: () => ClientSessionSchema,
|
|
75
75
|
CloudLocationResolutionError: () => CloudLocationResolutionError,
|
|
76
76
|
CredentialError: () => CredentialError,
|
|
77
|
-
DECRYPT_ACTION: () =>
|
|
78
|
-
DECRYPT_FACT_TYPE: () =>
|
|
79
|
-
DECRYPT_RESULT_TYPE: () =>
|
|
77
|
+
DECRYPT_ACTION: () => import_sdk_services10.DECRYPT_ACTION,
|
|
78
|
+
DECRYPT_FACT_TYPE: () => import_sdk_services10.DECRYPT_FACT_TYPE,
|
|
79
|
+
DECRYPT_RESULT_TYPE: () => import_sdk_services10.DECRYPT_RESULT_TYPE,
|
|
80
80
|
DEFAULT_DEFAULTS: () => DEFAULT_DEFAULTS,
|
|
81
|
-
DEFAULT_ENCRYPTION_ALG: () =>
|
|
81
|
+
DEFAULT_ENCRYPTION_ALG: () => import_sdk_services10.DEFAULT_ENCRYPTION_ALG,
|
|
82
82
|
DEFAULT_EXPIRY: () => DEFAULT_EXPIRY,
|
|
83
|
-
DEFAULT_KEY_VERSION: () =>
|
|
83
|
+
DEFAULT_KEY_VERSION: () => import_sdk_services10.DEFAULT_KEY_VERSION,
|
|
84
84
|
DEFAULT_KNOWLEDGE_ROOT: () => DEFAULT_KNOWLEDGE_ROOT,
|
|
85
85
|
DEFAULT_LOCAL_NODE_PIN_STORAGE_KEY: () => DEFAULT_LOCAL_NODE_PIN_STORAGE_KEY,
|
|
86
86
|
DEFAULT_LOCAL_NODE_URL: () => DEFAULT_LOCAL_NODE_URL,
|
|
@@ -95,36 +95,36 @@ __export(index_exports, {
|
|
|
95
95
|
DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL: () => DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL,
|
|
96
96
|
DELIVERY_ADMISSION_DOMAIN: () => DELIVERY_ADMISSION_DOMAIN,
|
|
97
97
|
DUCKDB: () => import_bootstrap4.DUCKDB,
|
|
98
|
-
DataVaultService: () =>
|
|
99
|
-
DatabaseHandle: () =>
|
|
100
|
-
DecryptTransportResponseError: () =>
|
|
98
|
+
DataVaultService: () => import_sdk_services10.DataVaultService,
|
|
99
|
+
DatabaseHandle: () => import_sdk_services10.DatabaseHandle,
|
|
100
|
+
DecryptTransportResponseError: () => import_sdk_services10.DecryptTransportResponseError,
|
|
101
101
|
DelegationErrorCodes: () => DelegationErrorCodes,
|
|
102
102
|
DelegationManager: () => DelegationManager,
|
|
103
|
-
DuckDbAction: () =>
|
|
104
|
-
DuckDbDatabaseHandle: () =>
|
|
105
|
-
DuckDbService: () =>
|
|
103
|
+
DuckDbAction: () => import_sdk_services10.DuckDbAction,
|
|
104
|
+
DuckDbDatabaseHandle: () => import_sdk_services10.DuckDbDatabaseHandle,
|
|
105
|
+
DuckDbService: () => import_sdk_services10.DuckDbService,
|
|
106
106
|
ED25519_JCS_SIGNATURE_SUITE: () => ED25519_JCS_SIGNATURE_SUITE,
|
|
107
107
|
EIP191_JCS_SIGNATURE_SUITE: () => EIP191_JCS_SIGNATURE_SUITE,
|
|
108
108
|
EMAIL_CREDENTIAL_MAX_AGE_SECONDS: () => EMAIL_CREDENTIAL_MAX_AGE_SECONDS,
|
|
109
109
|
EMAIL_DOMAIN_CREDENTIAL_MAX_AGE_SECONDS: () => EMAIL_DOMAIN_CREDENTIAL_MAX_AGE_SECONDS,
|
|
110
110
|
ENCRYPTION: () => import_bootstrap4.ENCRYPTION,
|
|
111
111
|
ENCRYPTION_MANIFEST_SPACE: () => ENCRYPTION_MANIFEST_SPACE,
|
|
112
|
-
ENCRYPTION_NETWORK_URN_PREFIX: () =>
|
|
112
|
+
ENCRYPTION_NETWORK_URN_PREFIX: () => import_sdk_services10.ENCRYPTION_NETWORK_URN_PREFIX,
|
|
113
113
|
ENCRYPTION_PERMISSION_SERVICE: () => ENCRYPTION_PERMISSION_SERVICE,
|
|
114
|
-
ENCRYPTION_SERVICE: () =>
|
|
115
|
-
ENCRYPTION_SERVICE_SHORT: () =>
|
|
116
|
-
ENVELOPE_VERSION: () =>
|
|
114
|
+
ENCRYPTION_SERVICE: () => import_sdk_services10.ENCRYPTION_SERVICE,
|
|
115
|
+
ENCRYPTION_SERVICE_SHORT: () => import_sdk_services10.ENCRYPTION_SERVICE_SHORT,
|
|
116
|
+
ENVELOPE_VERSION: () => import_sdk_services10.ENVELOPE_VERSION,
|
|
117
117
|
EXPIRY: () => EXPIRY,
|
|
118
|
-
EncryptionService: () =>
|
|
118
|
+
EncryptionService: () => import_sdk_services10.EncryptionService,
|
|
119
119
|
EnsDataSchema: () => EnsDataSchema,
|
|
120
|
-
ErrorCodes: () =>
|
|
120
|
+
ErrorCodes: () => import_sdk_services10.ErrorCodes,
|
|
121
121
|
HOLDER_BINDING_DOMAIN: () => HOLDER_BINDING_DOMAIN,
|
|
122
122
|
HOLDER_KEY_BINDING_PRESENTATION_SCHEMA: () => HOLDER_KEY_BINDING_PRESENTATION_SCHEMA,
|
|
123
123
|
HOOKS: () => import_bootstrap4.HOOKS,
|
|
124
|
-
HooksService: () =>
|
|
124
|
+
HooksService: () => import_sdk_services10.HooksService,
|
|
125
125
|
IdentityParseError: () => IdentityParseError,
|
|
126
126
|
KV: () => import_bootstrap4.KV,
|
|
127
|
-
KVService: () =>
|
|
127
|
+
KVService: () => import_sdk_services10.KVService,
|
|
128
128
|
LAST_V2_CREATE_AT: () => LAST_V2_CREATE_AT,
|
|
129
129
|
LAST_V2_READ_AT: () => LAST_V2_READ_AT,
|
|
130
130
|
LISTEN_SQL_STATEMENT_CATALOG: () => LISTEN_SQL_STATEMENT_CATALOG,
|
|
@@ -136,7 +136,7 @@ __export(index_exports, {
|
|
|
136
136
|
MAX_CONTENT_BYTES: () => MAX_CONTENT_BYTES,
|
|
137
137
|
MAX_LEGACY_ENVELOPE_EXPIRES_AT: () => MAX_LEGACY_ENVELOPE_EXPIRES_AT,
|
|
138
138
|
MAX_SEALED_SHARE_CONTENT_BYTES: () => MAX_SEALED_SHARE_CONTENT_BYTES,
|
|
139
|
-
MAX_SECRET_SCOPE_LENGTH: () =>
|
|
139
|
+
MAX_SECRET_SCOPE_LENGTH: () => import_sdk_services10.MAX_SECRET_SCOPE_LENGTH,
|
|
140
140
|
MAX_SHARE_ARTIFACT_BYTES: () => MAX_SHARE_ARTIFACT_BYTES,
|
|
141
141
|
MAX_SHARE_CONTENT_BYTES: () => MAX_SHARE_CONTENT_BYTES,
|
|
142
142
|
ManifestValidationError: () => ManifestValidationError,
|
|
@@ -144,8 +144,8 @@ __export(index_exports, {
|
|
|
144
144
|
MemorySenderShareRecordStorage: () => MemorySenderShareRecordStorage,
|
|
145
145
|
MemoryShareCache: () => MemoryShareCache,
|
|
146
146
|
NATIVE_PROJECTION_V1_DOMAIN: () => NATIVE_PROJECTION_V1_DOMAIN,
|
|
147
|
-
NETWORK_NAME_PATTERN: () =>
|
|
148
|
-
NetworkIdError: () =>
|
|
147
|
+
NETWORK_NAME_PATTERN: () => import_sdk_services10.NETWORK_NAME_PATTERN,
|
|
148
|
+
NetworkIdError: () => import_sdk_services10.NetworkIdError,
|
|
149
149
|
NodeNotFoundError: () => NodeNotFoundError,
|
|
150
150
|
NodeRegistryEntryExistsError: () => NodeRegistryEntryExistsError,
|
|
151
151
|
OPENKEY_ACTION_ID_SEPARATOR: () => OPENKEY_ACTION_ID_SEPARATOR,
|
|
@@ -174,7 +174,7 @@ __export(index_exports, {
|
|
|
174
174
|
POLICY_V2_SCHEMA: () => POLICY_V2_SCHEMA,
|
|
175
175
|
PORTABLE_DELEGATION_SCHEMA: () => PORTABLE_DELEGATION_SCHEMA,
|
|
176
176
|
PermissionNotInManifestError: () => PermissionNotInManifestError,
|
|
177
|
-
PrefixedKVService: () =>
|
|
177
|
+
PrefixedKVService: () => import_sdk_services10.PrefixedKVService,
|
|
178
178
|
ProtocolMismatchError: () => ProtocolMismatchError,
|
|
179
179
|
REGISTRY_LOOKUP_MAX_BODY_BYTES: () => REGISTRY_LOOKUP_MAX_BODY_BYTES,
|
|
180
180
|
REGISTRY_NOT_FOUND_BODY: () => REGISTRY_NOT_FOUND_BODY,
|
|
@@ -189,22 +189,22 @@ __export(index_exports, {
|
|
|
189
189
|
RegistryLookupInputError: () => RegistryLookupInputError,
|
|
190
190
|
RegistryUnavailableError: () => RegistryUnavailableError,
|
|
191
191
|
SECRETS_SPACE: () => SECRETS_SPACE,
|
|
192
|
-
SECRET_NAME_RE: () =>
|
|
192
|
+
SECRET_NAME_RE: () => import_sdk_services10.SECRET_NAME_RE,
|
|
193
193
|
SECRET_RECORDS_SCHEMA: () => import_bootstrap4.SECRET_RECORDS_SCHEMA,
|
|
194
|
-
SECRET_SCOPE_RE: () =>
|
|
194
|
+
SECRET_SCOPE_RE: () => import_sdk_services10.SECRET_SCOPE_RE,
|
|
195
195
|
SERVICE_LONG_TO_SHORT: () => SERVICE_LONG_TO_SHORT,
|
|
196
196
|
SERVICE_SHORT_TO_LONG: () => SERVICE_SHORT_TO_LONG,
|
|
197
197
|
SPACE: () => import_bootstrap4.SPACE,
|
|
198
198
|
SQL: () => import_bootstrap4.SQL,
|
|
199
|
-
SQLAction: () =>
|
|
200
|
-
SQLService: () =>
|
|
201
|
-
STORAGE_FULL_MESSAGE: () =>
|
|
202
|
-
STORAGE_MANAGE_URL: () =>
|
|
203
|
-
STORAGE_NEARLY_FULL_RATIO: () =>
|
|
204
|
-
STORAGE_WRITE_TOO_LARGE_MESSAGE: () =>
|
|
205
|
-
SecretsService: () =>
|
|
199
|
+
SQLAction: () => import_sdk_services10.SQLAction,
|
|
200
|
+
SQLService: () => import_sdk_services10.SQLService,
|
|
201
|
+
STORAGE_FULL_MESSAGE: () => import_sdk_services10.STORAGE_FULL_MESSAGE,
|
|
202
|
+
STORAGE_MANAGE_URL: () => import_sdk_services10.STORAGE_MANAGE_URL,
|
|
203
|
+
STORAGE_NEARLY_FULL_RATIO: () => import_sdk_services10.STORAGE_NEARLY_FULL_RATIO,
|
|
204
|
+
STORAGE_WRITE_TOO_LARGE_MESSAGE: () => import_sdk_services10.STORAGE_WRITE_TOO_LARGE_MESSAGE,
|
|
205
|
+
SecretsService: () => import_sdk_services10.SecretsService,
|
|
206
206
|
SenderShareStore: () => SenderShareStore,
|
|
207
|
-
ServiceContext: () =>
|
|
207
|
+
ServiceContext: () => import_sdk_services10.ServiceContext,
|
|
208
208
|
SessionExpiredError: () => SessionExpiredError,
|
|
209
209
|
ShareAccessError: () => ShareAccessError,
|
|
210
210
|
ShareAddressedDelegationEnvelopeV2Schema: () => ShareAddressedDelegationEnvelopeV2Schema,
|
|
@@ -230,8 +230,8 @@ __export(index_exports, {
|
|
|
230
230
|
Space: () => Space,
|
|
231
231
|
SpaceErrorCodes: () => SpaceErrorCodes,
|
|
232
232
|
SpaceService: () => SpaceService,
|
|
233
|
-
StorageFullMonitor: () =>
|
|
234
|
-
TC832_RESERVED_SCOPES: () =>
|
|
233
|
+
StorageFullMonitor: () => import_sdk_services10.StorageFullMonitor,
|
|
234
|
+
TC832_RESERVED_SCOPES: () => import_sdk_services10.TC832_RESERVED_SCOPES,
|
|
235
235
|
TERMINAL_DELEGATION_FACT: () => TERMINAL_DELEGATION_FACT,
|
|
236
236
|
TINYCLOUD_ACCOUNT_SPACE_MANIFEST: () => import_bootstrap4.TINYCLOUD_ACCOUNT_SPACE_MANIFEST,
|
|
237
237
|
TINYCLOUD_AGENTS_SPACE_MANIFEST: () => import_bootstrap4.TINYCLOUD_AGENTS_SPACE_MANIFEST,
|
|
@@ -242,55 +242,55 @@ __export(index_exports, {
|
|
|
242
242
|
TINYCLOUD_PUBLIC_SPACE_MANIFEST: () => import_bootstrap4.TINYCLOUD_PUBLIC_SPACE_MANIFEST,
|
|
243
243
|
TINYCLOUD_SECRETS_BOOTSTRAP_MANIFEST: () => import_bootstrap4.TINYCLOUD_SECRETS_BOOTSTRAP_MANIFEST,
|
|
244
244
|
TinyCloud: () => TinyCloud,
|
|
245
|
-
TinyCloudDebugLogger: () =>
|
|
245
|
+
TinyCloudDebugLogger: () => import_sdk_services10.TinyCloudDebugLogger,
|
|
246
246
|
TranscriptRequester: () => TranscriptRequester,
|
|
247
247
|
TranscriptRequesterError: () => TranscriptRequesterError,
|
|
248
248
|
UnsupportedFeatureError: () => UnsupportedFeatureError,
|
|
249
249
|
UnsupportedSignatureSuiteError: () => UnsupportedSignatureSuiteError,
|
|
250
250
|
VAULT_PERMISSION_SERVICE: () => VAULT_PERMISSION_SERVICE,
|
|
251
|
-
VaultHeaders: () =>
|
|
252
|
-
VaultPublicSpaceKVActions: () =>
|
|
251
|
+
VaultHeaders: () => import_sdk_services10.VaultHeaders,
|
|
252
|
+
VaultPublicSpaceKVActions: () => import_sdk_services10.VaultPublicSpaceKVActions,
|
|
253
253
|
VersionCheckError: () => VersionCheckError,
|
|
254
254
|
actionContains: () => actionContains,
|
|
255
255
|
activateSessionWithHost: () => activateSessionWithHost,
|
|
256
256
|
addressStorageKey: () => addressStorageKey,
|
|
257
257
|
admitPolicyCredentialV3: () => admitPolicyCredentialV3,
|
|
258
258
|
admitPolicyCredentialV4: () => admitPolicyCredentialV4,
|
|
259
|
-
appSecretScope: () =>
|
|
259
|
+
appSecretScope: () => import_sdk_services10.appSecretScope,
|
|
260
260
|
applyPrefix: () => applyPrefix,
|
|
261
261
|
assertSpaceCreationAllowed: () => assertSpaceCreationAllowed,
|
|
262
|
-
authorizationVerdictOf: () =>
|
|
262
|
+
authorizationVerdictOf: () => import_sdk_services10.authorizationVerdictOf,
|
|
263
263
|
bootstrapEncryptionNetworkId: () => import_bootstrap4.bootstrapEncryptionNetworkId,
|
|
264
264
|
bootstrapSpaceId: () => import_bootstrap4.bootstrapSpaceId,
|
|
265
265
|
bootstrapSteps: () => import_bootstrap4.bootstrapSteps,
|
|
266
|
-
buildCanonicalDecryptRequest: () =>
|
|
267
|
-
buildDecryptAttenuation: () =>
|
|
268
|
-
buildDecryptFacts: () =>
|
|
269
|
-
buildDecryptInvocation: () =>
|
|
270
|
-
buildNetworkId: () =>
|
|
266
|
+
buildCanonicalDecryptRequest: () => import_sdk_services10.buildCanonicalDecryptRequest,
|
|
267
|
+
buildDecryptAttenuation: () => import_sdk_services10.buildDecryptAttenuation,
|
|
268
|
+
buildDecryptFacts: () => import_sdk_services10.buildDecryptFacts,
|
|
269
|
+
buildDecryptInvocation: () => import_sdk_services10.buildDecryptInvocation,
|
|
270
|
+
buildNetworkId: () => import_sdk_services10.buildNetworkId,
|
|
271
271
|
buildPolicyCredentialPresentationV3: () => buildPolicyCredentialPresentationV3,
|
|
272
272
|
buildPolicyCredentialPresentationV4: () => buildPolicyCredentialPresentationV4,
|
|
273
273
|
buildSpaceUri: () => buildSpaceUri,
|
|
274
274
|
canonicalDigest: () => canonicalDigest,
|
|
275
275
|
canonicalEmailDomain: () => import_share_envelope.canonicalEmailDomain,
|
|
276
|
-
canonicalHashHex: () =>
|
|
276
|
+
canonicalHashHex: () => import_sdk_services10.canonicalHashHex,
|
|
277
277
|
canonicalLocationPayload: () => canonicalLocationPayload,
|
|
278
278
|
canonicalMailbox: () => import_share_envelope.canonicalMailbox,
|
|
279
279
|
canonicalOwnerSharePolicy: () => canonicalOwnerSharePolicy,
|
|
280
|
-
canonicalSignedResponse: () =>
|
|
280
|
+
canonicalSignedResponse: () => import_sdk_services10.canonicalSignedResponse,
|
|
281
281
|
canonicalizeAddress: () => canonicalizeAddress,
|
|
282
282
|
canonicalizeDid: () => canonicalizeDid,
|
|
283
283
|
canonicalizeDidUrl: () => canonicalizeDidUrl,
|
|
284
|
-
canonicalizeEncryptionJson: () =>
|
|
284
|
+
canonicalizeEncryptionJson: () => import_sdk_services10.canonicalizeEncryptionJson,
|
|
285
285
|
canonicalizeNetworkId: () => canonicalizeNetworkId,
|
|
286
286
|
canonicalizeRecapCaveats: () => canonicalizeRecapCaveats,
|
|
287
|
-
canonicalizeSecretScope: () =>
|
|
287
|
+
canonicalizeSecretScope: () => import_sdk_services10.canonicalizeSecretScope,
|
|
288
288
|
canonicalizeSignedObjectUnsigned: () => canonicalizeSignedObjectUnsigned,
|
|
289
289
|
canonicalizeUnifiedPolicyCapability: () => canonicalizeUnifiedPolicyCapability,
|
|
290
|
-
checkDecryptInvocationInput: () =>
|
|
290
|
+
checkDecryptInvocationInput: () => import_sdk_services10.checkDecryptInvocationInput,
|
|
291
291
|
checkNodeInfo: () => checkNodeInfo,
|
|
292
292
|
classifyRegistryLookup: () => classifyRegistryLookup,
|
|
293
|
-
clearTinyCloudDebugLogs: () =>
|
|
293
|
+
clearTinyCloudDebugLogs: () => import_sdk_services10.clearTinyCloudDebugLogs,
|
|
294
294
|
compactAttenuationContains: () => compactAttenuationContains,
|
|
295
295
|
composeBootstrapSpaceManifest: () => import_bootstrap4.composeBootstrapSpaceManifest,
|
|
296
296
|
composeManifestRequest: () => composeManifestRequest,
|
|
@@ -321,7 +321,7 @@ __export(index_exports, {
|
|
|
321
321
|
createStorageReceipt: () => createStorageReceipt,
|
|
322
322
|
createStoredCredentialRecord: () => createStoredCredentialRecord,
|
|
323
323
|
createTranscriptRequester: () => createTranscriptRequester,
|
|
324
|
-
createVaultCrypto: () =>
|
|
324
|
+
createVaultCrypto: () => import_sdk_services10.createVaultCrypto,
|
|
325
325
|
credentialEndpointPath: () => credentialEndpointPath,
|
|
326
326
|
credentialError: () => credentialError,
|
|
327
327
|
credentialIndexKey: () => credentialIndexKey,
|
|
@@ -329,65 +329,66 @@ __export(index_exports, {
|
|
|
329
329
|
credentialRecordKey: () => credentialRecordKey,
|
|
330
330
|
credentialRequirementDigest: () => credentialRequirementDigest,
|
|
331
331
|
decodeBase64Url: () => decodeBase64Url,
|
|
332
|
-
decryptEnvelopeWithKey: () =>
|
|
332
|
+
decryptEnvelopeWithKey: () => import_sdk_services10.decryptEnvelopeWithKey,
|
|
333
333
|
decryptShareBytesAsync: () => decryptShareBytesAsync,
|
|
334
|
-
defaultRetryPolicy: () =>
|
|
334
|
+
defaultRetryPolicy: () => import_sdk_services10.defaultRetryPolicy,
|
|
335
335
|
defaultSignStrategy: () => defaultSignStrategy,
|
|
336
336
|
defaultSpaceCreationHandler: () => defaultSpaceCreationHandler,
|
|
337
337
|
delegatePortablePolicySession: () => delegatePortablePolicySession,
|
|
338
338
|
deriveDelegationCid: () => deriveDelegationCid,
|
|
339
339
|
deriveSignedObjectMaterial: () => deriveSignedObjectMaterial,
|
|
340
|
-
deriveSignedReceiverKey: () =>
|
|
340
|
+
deriveSignedReceiverKey: () => import_sdk_services10.deriveSignedReceiverKey,
|
|
341
341
|
descriptorSatisfiesRequirement: () => descriptorSatisfiesRequirement,
|
|
342
342
|
didCacheKey: () => didCacheKey,
|
|
343
343
|
didEquals: () => didEquals,
|
|
344
344
|
diffImmutableSiweFields: () => diffImmutableSiweFields,
|
|
345
|
-
disableTinyCloudDebug: () =>
|
|
345
|
+
disableTinyCloudDebug: () => import_sdk_services10.disableTinyCloudDebug,
|
|
346
346
|
discoverLocalTinyCloudNode: () => discoverLocalTinyCloudNode,
|
|
347
|
-
discoverNetwork: () =>
|
|
348
|
-
enableTinyCloudDebug: () =>
|
|
347
|
+
discoverNetwork: () => import_sdk_services10.discoverNetwork,
|
|
348
|
+
enableTinyCloudDebug: () => import_sdk_services10.enableTinyCloudDebug,
|
|
349
349
|
encodeBase64Url: () => encodeBase64Url,
|
|
350
350
|
encodeInlineShareUrl: () => encodeInlineShareUrl,
|
|
351
351
|
encodeShareArtifact: () => encodeShareArtifact,
|
|
352
352
|
encodeShareUrl: () => encodeShareUrl,
|
|
353
353
|
encryptShareBytes: () => encryptShareBytes,
|
|
354
354
|
encryptShareBytesAsync: () => encryptShareBytesAsync,
|
|
355
|
-
encryptToNetwork: () =>
|
|
356
|
-
encryptionBase64Decode: () =>
|
|
357
|
-
encryptionBase64Encode: () =>
|
|
358
|
-
encryptionError: () =>
|
|
359
|
-
encryptionUtf8Decode: () =>
|
|
360
|
-
encryptionUtf8Encode: () =>
|
|
361
|
-
ensureNetworkUsableForDecrypt: () =>
|
|
362
|
-
err: () =>
|
|
355
|
+
encryptToNetwork: () => import_sdk_services10.encryptToNetwork,
|
|
356
|
+
encryptionBase64Decode: () => import_sdk_services10.base64Decode,
|
|
357
|
+
encryptionBase64Encode: () => import_sdk_services10.base64Encode,
|
|
358
|
+
encryptionError: () => import_sdk_services10.encryptionError,
|
|
359
|
+
encryptionUtf8Decode: () => import_sdk_services10.utf8Decode,
|
|
360
|
+
encryptionUtf8Encode: () => import_sdk_services10.utf8Encode,
|
|
361
|
+
ensureNetworkUsableForDecrypt: () => import_sdk_services10.ensureNetworkUsableForDecrypt,
|
|
362
|
+
err: () => import_sdk_services10.err,
|
|
363
363
|
expandActionShortNames: () => expandActionShortNames,
|
|
364
|
+
expandDelegationPermissionEntries: () => expandDelegationPermissionEntries,
|
|
364
365
|
expandPermissionEntries: () => expandPermissionEntries,
|
|
365
366
|
expandPermissionEntry: () => expandPermissionEntry,
|
|
366
367
|
extractImmutableSiweFields: () => extractImmutableSiweFields,
|
|
367
368
|
extractRecapAttenuations: () => extractRecapAttenuations,
|
|
368
369
|
fetchLocationRecord: () => fetchLocationRecord,
|
|
369
370
|
fetchPeerId: () => fetchPeerId,
|
|
370
|
-
generateRandomReceiverKey: () =>
|
|
371
|
+
generateRandomReceiverKey: () => import_sdk_services10.generateRandomReceiverKey,
|
|
371
372
|
getPolicyRootStatusV3: () => getPolicyRootStatusV3,
|
|
372
|
-
getTinyCloudDebugLogs: () =>
|
|
373
|
+
getTinyCloudDebugLogs: () => import_sdk_services10.getTinyCloudDebugLogs,
|
|
373
374
|
hasTinyCloudManageKeyScope: () => hasTinyCloudManageKeyScope,
|
|
374
|
-
hexDecode: () =>
|
|
375
|
-
hexEncode: () =>
|
|
375
|
+
hexDecode: () => import_sdk_services10.hexDecode,
|
|
376
|
+
hexEncode: () => import_sdk_services10.hexEncode,
|
|
376
377
|
holderBindingCanonicalBytes: () => holderBindingCanonicalBytes,
|
|
377
378
|
holderBindingSigningBytes: () => holderBindingSigningBytes,
|
|
378
379
|
httpResponseError: () => httpResponseError,
|
|
379
380
|
httpUrlToMultiaddr: () => httpUrlToMultiaddr,
|
|
380
381
|
importPortableDelegation: () => importPortableDelegation,
|
|
381
|
-
installTinyCloudDebugGlobals: () =>
|
|
382
|
+
installTinyCloudDebugGlobals: () => import_sdk_services10.installTinyCloudDebugGlobals,
|
|
382
383
|
intersectShareCapabilities: () => intersectShareCapabilities,
|
|
383
384
|
isCanonicalEmailDomain: () => import_share_envelope.isCanonicalEmailDomain,
|
|
384
385
|
isCapabilitySubset: () => isCapabilitySubset,
|
|
385
386
|
isDigest: () => isDigest,
|
|
386
387
|
isEvmAddress: () => isEvmAddress,
|
|
387
388
|
isExplicitOnlyAction: () => isExplicitOnlyAction,
|
|
388
|
-
isNetworkId: () =>
|
|
389
|
+
isNetworkId: () => import_sdk_services10.isNetworkId,
|
|
389
390
|
isPlausibleOpenKeyActionId: () => isPlausibleOpenKeyActionId,
|
|
390
|
-
isStorageFullError: () =>
|
|
391
|
+
isStorageFullError: () => import_sdk_services10.isStorageFullError,
|
|
391
392
|
isV2ShareLink: () => isV2ShareLink,
|
|
392
393
|
issuedCredentialEnvelopeFromVerified: () => issuedCredentialEnvelopeFromVerified,
|
|
393
394
|
jcsCanonicalize: () => jcsCanonicalize,
|
|
@@ -400,36 +401,36 @@ __export(index_exports, {
|
|
|
400
401
|
manifestAbilitiesUnion: () => manifestAbilitiesUnion,
|
|
401
402
|
markDelegationTerminal: () => markDelegationTerminal,
|
|
402
403
|
multiaddrToHttpUrl: () => multiaddrToHttpUrl,
|
|
403
|
-
networkDiscoveryKey: () =>
|
|
404
|
+
networkDiscoveryKey: () => import_sdk_services10.networkDiscoveryKey,
|
|
404
405
|
normalizeDefaults: () => normalizeDefaults,
|
|
405
406
|
normalizeJson: () => normalizeJson,
|
|
406
407
|
normalizeShareActions: () => normalizeShareActions,
|
|
407
408
|
normalizeShareRecipientTarget: () => normalizeShareRecipientTarget,
|
|
408
409
|
normalizeShareResource: () => normalizeShareResource,
|
|
409
410
|
normalizeUnifiedPolicyCapability: () => normalizeUnifiedPolicyCapability,
|
|
410
|
-
ok: () =>
|
|
411
|
-
openWrappedKey: () =>
|
|
411
|
+
ok: () => import_sdk_services10.ok,
|
|
412
|
+
openWrappedKey: () => import_sdk_services10.openWrappedKey,
|
|
412
413
|
parseCanonicalNetworkId: () => parseCanonicalNetworkId,
|
|
413
414
|
parseCanonicalRecapResource: () => parseCanonicalRecapResource,
|
|
414
415
|
parseCanonicalTinyCloudIdentity: () => parseCanonicalTinyCloudIdentity,
|
|
415
416
|
parseCanonicalTinyCloudIdentityClaims: () => parseCanonicalTinyCloudIdentityClaims,
|
|
416
|
-
parseCapabilityResource: () =>
|
|
417
|
+
parseCapabilityResource: () => import_sdk_services10.parseCapabilityResource,
|
|
417
418
|
parseCompactUcanAuthorization: () => parseCompactUcanAuthorization,
|
|
418
419
|
parseExpiry: () => parseExpiry,
|
|
419
|
-
parseNetworkId: () =>
|
|
420
|
+
parseNetworkId: () => import_sdk_services10.parseNetworkId,
|
|
420
421
|
parseNodeNativePortableDelegation: () => parseNodeNativePortableDelegation,
|
|
421
422
|
parsePkhDid: () => parsePkhDid,
|
|
422
423
|
parsePolicySessionUcan: () => parsePolicySessionUcan,
|
|
423
424
|
parsePortableDelegation: () => parsePortableDelegation,
|
|
424
425
|
parseRecapCapabilities: () => parseRecapCapabilities,
|
|
425
|
-
parseSecretCatalogKey: () =>
|
|
426
|
+
parseSecretCatalogKey: () => import_sdk_services10.parseSecretCatalogKey,
|
|
426
427
|
parseShareArtifact: () => parseShareArtifact,
|
|
427
428
|
parseShareUrl: () => parseShareUrl,
|
|
428
429
|
parseSignedCompactUcanAttenuation: () => parseSignedCompactUcanAttenuation,
|
|
429
430
|
parseSignedSiweCacao: () => parseSignedSiweCacao,
|
|
430
431
|
parseSpaceUri: () => parseSpaceUri,
|
|
431
|
-
parseStorageRejection: () =>
|
|
432
|
-
parseStorageStatus: () =>
|
|
432
|
+
parseStorageRejection: () => import_sdk_services10.parseStorageRejection,
|
|
433
|
+
parseStorageStatus: () => import_sdk_services10.parseStorageStatus,
|
|
433
434
|
pkhDid: () => pkhDid,
|
|
434
435
|
policyCidFromCanonicalBytes: () => policyCidFromCanonicalBytes,
|
|
435
436
|
policyDigestHex: () => policyDigestHex,
|
|
@@ -450,8 +451,8 @@ __export(index_exports, {
|
|
|
450
451
|
resolveManifest: () => resolveManifest,
|
|
451
452
|
resolveManifestKnowledgeRoot: () => resolveManifestKnowledgeRoot,
|
|
452
453
|
resolveOwnerHosts: () => resolveOwnerHosts,
|
|
453
|
-
resolveSecretListPrefix: () =>
|
|
454
|
-
resolveSecretPath: () =>
|
|
454
|
+
resolveSecretListPrefix: () => import_sdk_services10.resolveSecretListPrefix,
|
|
455
|
+
resolveSecretPath: () => import_sdk_services10.resolveSecretPath,
|
|
455
456
|
resolveTinyCloudHosts: () => resolveTinyCloudHosts,
|
|
456
457
|
resourceCapabilitiesToAbilitiesMap: () => resourceCapabilitiesToAbilitiesMap,
|
|
457
458
|
resourceCapabilitiesToSpaceAbilitiesMap: () => resourceCapabilitiesToSpaceAbilitiesMap,
|
|
@@ -459,7 +460,7 @@ __export(index_exports, {
|
|
|
459
460
|
revokePolicyRootV3: () => revokePolicyRootV3,
|
|
460
461
|
serializeJcsJson: () => serialize,
|
|
461
462
|
serializePortableDelegation: () => serializePortableDelegation,
|
|
462
|
-
serviceError: () =>
|
|
463
|
+
serviceError: () => import_sdk_services10.serviceError,
|
|
463
464
|
sha256Base64Url: () => sha256Base64Url,
|
|
464
465
|
shareCapabilityAllows: () => shareCapabilityAllows,
|
|
465
466
|
shortDeliveryLinkBodyCid: () => shortDeliveryLinkBodyCid,
|
|
@@ -470,9 +471,9 @@ __export(index_exports, {
|
|
|
470
471
|
signPolicyCredentialPresentationV4: () => signPolicyCredentialPresentationV4,
|
|
471
472
|
signShareEnvelope: () => signShareEnvelope,
|
|
472
473
|
signedObjectIdFor: () => signedObjectIdFor,
|
|
473
|
-
storageUsageState: () =>
|
|
474
|
+
storageUsageState: () => import_sdk_services10.storageUsageState,
|
|
474
475
|
submitHostDelegation: () => submitHostDelegation,
|
|
475
|
-
tinyCloudDebugLogger: () =>
|
|
476
|
+
tinyCloudDebugLogger: () => import_sdk_services10.tinyCloudDebugLogger,
|
|
476
477
|
toSignedObjectError: () => toSignedObjectError,
|
|
477
478
|
unauthorizedRecapCapabilities: () => unauthorizedRecapCapabilities,
|
|
478
479
|
unifiedNativeProjectionHashHex: () => unifiedNativeProjectionHashHex,
|
|
@@ -484,7 +485,7 @@ __export(index_exports, {
|
|
|
484
485
|
validateCredentialFlowDescriptor: () => validateCredentialFlowDescriptor,
|
|
485
486
|
validateCredentialHolderBinding: () => validateCredentialHolderBinding,
|
|
486
487
|
validateCredentialRequirement: () => validateCredentialRequirement,
|
|
487
|
-
validateEnvelope: () =>
|
|
488
|
+
validateEnvelope: () => import_sdk_services10.validateEnvelope,
|
|
488
489
|
validateLocationRecord: () => validateLocationRecord,
|
|
489
490
|
validateLocationRecordPayload: () => validateLocationRecordPayload,
|
|
490
491
|
validateManifest: () => validateManifest,
|
|
@@ -502,8 +503,8 @@ __export(index_exports, {
|
|
|
502
503
|
validatePolicyStatusUnsigned: () => validatePolicyStatusUnsigned,
|
|
503
504
|
validatePolicyUnsigned: () => validatePolicyUnsigned,
|
|
504
505
|
validateUnifiedPolicyV2: () => validateUnifiedPolicyV2,
|
|
505
|
-
validatedCapabilityOf: () =>
|
|
506
|
-
verifyDecryptResponse: () =>
|
|
506
|
+
validatedCapabilityOf: () => import_sdk_services10.validatedCapabilityOf,
|
|
507
|
+
verifyDecryptResponse: () => import_sdk_services10.verifyDecryptResponse,
|
|
507
508
|
verifyDidKeyEd25519Signature: () => verifyDidKeyEd25519Signature,
|
|
508
509
|
verifyEip191MessageSignature: () => verifyEip191MessageSignature,
|
|
509
510
|
verifyIssuedCredential: () => verifyIssuedCredential,
|
|
@@ -3947,6 +3948,7 @@ var import_sha256 = require("@noble/hashes/sha256");
|
|
|
3947
3948
|
var import_blake3 = require("@noble/hashes/blake3");
|
|
3948
3949
|
var import_ed255193 = require("@noble/curves/ed25519");
|
|
3949
3950
|
var import_zod2 = require("zod");
|
|
3951
|
+
var import_sdk_services2 = require("@tinycloud/sdk-services");
|
|
3950
3952
|
|
|
3951
3953
|
// src/http-error.ts
|
|
3952
3954
|
var import_sdk_services = require("@tinycloud/sdk-services");
|
|
@@ -4215,12 +4217,9 @@ function parseKvResource(resource) {
|
|
|
4215
4217
|
return { space, path };
|
|
4216
4218
|
}
|
|
4217
4219
|
function parseEncryptionResource(resource) {
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
const ownerDid = separator < 0 ? "" : rest.slice(0, separator);
|
|
4222
|
-
const network = separator < 0 ? "" : rest.slice(separator + 1);
|
|
4223
|
-
if (!ownerDid.startsWith("did:") || network.length === 0 || network.includes(":") || network.includes("/") || network.includes("%") || network.includes("?") || network.includes("#")) {
|
|
4220
|
+
try {
|
|
4221
|
+
if ((0, import_sdk_services2.parseEncryptionResource)(resource).keyPath?.endsWith("/")) throw new Error("prefix");
|
|
4222
|
+
} catch {
|
|
4224
4223
|
throw new Error("encryption capability is invalid");
|
|
4225
4224
|
}
|
|
4226
4225
|
}
|
|
@@ -6687,7 +6686,11 @@ var DelegationErrorCodes = {
|
|
|
6687
6686
|
KV_SERVICE_UNAVAILABLE: "KV_SERVICE_UNAVAILABLE",
|
|
6688
6687
|
DATA_FETCH_FAILED: "DATA_FETCH_FAILED",
|
|
6689
6688
|
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
6690
|
-
UNSUPPORTED_OPERATION: "UNSUPPORTED_OPERATION"
|
|
6689
|
+
UNSUPPORTED_OPERATION: "UNSUPPORTED_OPERATION",
|
|
6690
|
+
/** The node answered 503: the delegation chain is too deep to evaluate right now. Retry later. */
|
|
6691
|
+
CHAIN_TOO_DEEP: "CHAIN_TOO_DEEP",
|
|
6692
|
+
/** The node answered 400 "invalid delegation query cursor": malformed, foreign or from another filter. Start the listing again without it. */
|
|
6693
|
+
INVALID_CURSOR: "INVALID_CURSOR"
|
|
6691
6694
|
};
|
|
6692
6695
|
var DelegationSchema = import_zod4.z.object({
|
|
6693
6696
|
/** Content identifier (CID) of the delegation */
|
|
@@ -6764,7 +6767,7 @@ var AccountDelegationPageSchema = import_zod4.z.object({
|
|
|
6764
6767
|
nextCursor: import_zod4.z.string().optional()
|
|
6765
6768
|
}).strict();
|
|
6766
6769
|
var AccountDelegationQueryOptionsSchema = import_zod4.z.object({
|
|
6767
|
-
direction: import_zod4.z.enum(["granted", "received", "all"]).optional(),
|
|
6770
|
+
direction: import_zod4.z.enum(["granted", "received", "all", "issued"]).optional(),
|
|
6768
6771
|
status: import_zod4.z.enum(["active", "pending", "expired", "revoked", "ancestor_revoked"]).optional(),
|
|
6769
6772
|
space: import_zod4.z.string().trim().min(1).optional(),
|
|
6770
6773
|
limit: import_zod4.z.number().int().min(1).max(100).optional(),
|
|
@@ -6950,6 +6953,8 @@ var DelegationManagerConfigSchema = import_zod4.z.object({
|
|
|
6950
6953
|
).optional(),
|
|
6951
6954
|
/** Optional owner-signed authorization for direct CID revocation */
|
|
6952
6955
|
signOwnerRevocation: import_zod4.z.custom().optional(),
|
|
6956
|
+
/** Optional signer for proofless invocations by the session's own did:key (issued-delegation list and revoke) */
|
|
6957
|
+
sessionInvocationSigner: import_zod4.z.custom().optional(),
|
|
6953
6958
|
/** Optional custom fetch implementation */
|
|
6954
6959
|
fetch: import_zod4.z.unknown().refine(
|
|
6955
6960
|
(val) => val === void 0 || typeof val === "function",
|
|
@@ -7045,7 +7050,7 @@ var CreateDelegationWasmResultSchema = import_zod4.z.object({
|
|
|
7045
7050
|
resources: import_zod4.z.array(DelegatedResourceSchema)
|
|
7046
7051
|
});
|
|
7047
7052
|
|
|
7048
|
-
// src/delegations/
|
|
7053
|
+
// src/delegations/shared.ts
|
|
7049
7054
|
var DelegationAction = {
|
|
7050
7055
|
REVOKE: "tinycloud.delegation/revoke",
|
|
7051
7056
|
STATUS: "tinycloud.delegation/status",
|
|
@@ -7062,6 +7067,8 @@ function createError(code3, message, cause, meta) {
|
|
|
7062
7067
|
meta
|
|
7063
7068
|
};
|
|
7064
7069
|
}
|
|
7070
|
+
|
|
7071
|
+
// src/delegations/DelegationManager.ts
|
|
7065
7072
|
async function readInvokedJson(response, action) {
|
|
7066
7073
|
const text3 = await response.text();
|
|
7067
7074
|
if (text3.trim() === "") {
|
|
@@ -7084,11 +7091,13 @@ var DelegationManager = class {
|
|
|
7084
7091
|
* @param config - Configuration including hosts, session, and invoke function
|
|
7085
7092
|
*/
|
|
7086
7093
|
constructor(config) {
|
|
7094
|
+
this.issuedState = { issuedQuerySupported: false };
|
|
7087
7095
|
this.hosts = config.hosts;
|
|
7088
7096
|
this.session = config.session;
|
|
7089
7097
|
this.invoke = config.invoke;
|
|
7090
7098
|
this.invokeAny = config.invokeAny;
|
|
7091
7099
|
this.signOwnerRevocation = config.signOwnerRevocation;
|
|
7100
|
+
this.sessionInvocationSigner = config.sessionInvocationSigner;
|
|
7092
7101
|
this.fetchFn = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
7093
7102
|
this.accountSpaceId = config.accountSpaceId;
|
|
7094
7103
|
}
|
|
@@ -7311,8 +7320,14 @@ var DelegationManager = class {
|
|
|
7311
7320
|
};
|
|
7312
7321
|
}
|
|
7313
7322
|
}
|
|
7314
|
-
/**
|
|
7315
|
-
|
|
7323
|
+
/**
|
|
7324
|
+
* Query lifecycle-complete delegation history for the authenticated account.
|
|
7325
|
+
*
|
|
7326
|
+
* `scope.spaces` lists the spaces to sign `tinycloud.delegation/list` for, in order. Omitted, the
|
|
7327
|
+
* account space is tried, then the session's own space. A caller that knows which of them the session
|
|
7328
|
+
* holds passes only those; an empty list sends nothing and answers PERMISSION_DENIED.
|
|
7329
|
+
*/
|
|
7330
|
+
async query(options2 = {}, scope = {}) {
|
|
7316
7331
|
const validated = AccountDelegationQueryOptionsSchema.safeParse(options2);
|
|
7317
7332
|
if (!validated.success) {
|
|
7318
7333
|
return {
|
|
@@ -7325,6 +7340,7 @@ var DelegationManager = class {
|
|
|
7325
7340
|
)
|
|
7326
7341
|
};
|
|
7327
7342
|
}
|
|
7343
|
+
if (validated.data.direction === "issued") return this.queryIssued(validated.data);
|
|
7328
7344
|
if (!this.invokeAny) {
|
|
7329
7345
|
return {
|
|
7330
7346
|
ok: false,
|
|
@@ -7346,7 +7362,7 @@ var DelegationManager = class {
|
|
|
7346
7362
|
}
|
|
7347
7363
|
try {
|
|
7348
7364
|
let response;
|
|
7349
|
-
for (const spaceId of
|
|
7365
|
+
for (const spaceId of new Set(scope.spaces ?? [accountSpaceId, this.session.spaceId])) {
|
|
7350
7366
|
const headers = Object.fromEntries(new Headers(this.invokeAny(this.session, [{
|
|
7351
7367
|
spaceId,
|
|
7352
7368
|
service: "delegation",
|
|
@@ -7406,6 +7422,45 @@ var DelegationManager = class {
|
|
|
7406
7422
|
};
|
|
7407
7423
|
}
|
|
7408
7424
|
}
|
|
7425
|
+
/** The state the lazily loaded issued-delegation module reads and updates. */
|
|
7426
|
+
issuedContext() {
|
|
7427
|
+
return {
|
|
7428
|
+
host: this.host,
|
|
7429
|
+
fetchFn: this.fetchFn,
|
|
7430
|
+
sessionInvocationSigner: this.sessionInvocationSigner,
|
|
7431
|
+
state: this.issuedState
|
|
7432
|
+
};
|
|
7433
|
+
}
|
|
7434
|
+
/**
|
|
7435
|
+
* Lists the delegations this session's own key issued (`direction: "issued"`).
|
|
7436
|
+
* The implementation loads on first use.
|
|
7437
|
+
*/
|
|
7438
|
+
async queryIssued(options2) {
|
|
7439
|
+
const issued = await import("@tinycloud/sdk-core/delegations/issued");
|
|
7440
|
+
return issued.queryIssued(this.issuedContext(), options2);
|
|
7441
|
+
}
|
|
7442
|
+
/**
|
|
7443
|
+
* Every delegation this session's key issued, following `nextCursor` until
|
|
7444
|
+
* it is absent. `maxItems` stops early once that many are collected;
|
|
7445
|
+
* `untilCid` stops after the page that contains that delegation. Items come
|
|
7446
|
+
* in CID order (each carries `issuedAt`). The implementation loads on first use.
|
|
7447
|
+
*/
|
|
7448
|
+
async queryAllIssued(options2 = {}) {
|
|
7449
|
+
const issued = await import("@tinycloud/sdk-core/delegations/issued");
|
|
7450
|
+
return issued.queryAllIssued((page) => this.query(page), options2);
|
|
7451
|
+
}
|
|
7452
|
+
/**
|
|
7453
|
+
* Revokes a delegation this session's key issued, with no proof: a UCAN
|
|
7454
|
+
* signed by the session's own did:key carrying `urn:cid:<cid>` and
|
|
7455
|
+
* `tinycloud.delegation/revoke`. Revoking a delegation that is already revoked
|
|
7456
|
+
* succeeds. A refusal (the key is not the delegator) carries the node's
|
|
7457
|
+
* message; 503 means the chain is too deep right now, retry later.
|
|
7458
|
+
* The implementation loads on first use.
|
|
7459
|
+
*/
|
|
7460
|
+
async revokeIssued(cid2) {
|
|
7461
|
+
const issued = await import("@tinycloud/sdk-core/delegations/issued");
|
|
7462
|
+
return issued.revokeIssued(this.issuedContext(), cid2);
|
|
7463
|
+
}
|
|
7409
7464
|
/**
|
|
7410
7465
|
* Gets the full delegation chain for a given delegation.
|
|
7411
7466
|
*
|
|
@@ -7712,7 +7767,8 @@ function validateEncodedShareData(data) {
|
|
|
7712
7767
|
// src/manifest.ts
|
|
7713
7768
|
var import_ms = __toESM(require("ms"), 1);
|
|
7714
7769
|
var import_bootstrap2 = require("@tinycloud/bootstrap");
|
|
7715
|
-
var
|
|
7770
|
+
var import_sdk_services3 = require("@tinycloud/sdk-services");
|
|
7771
|
+
var import_resource = require("@tinycloud/sdk-services/encryption/resource");
|
|
7716
7772
|
var DEFAULT_KNOWLEDGE_ROOT = "knowledge/index.md";
|
|
7717
7773
|
var ManifestValidationError = class extends Error {
|
|
7718
7774
|
constructor(message) {
|
|
@@ -7835,6 +7891,16 @@ function expandEncryptionPermissionEntry(entry) {
|
|
|
7835
7891
|
`tinycloud.encryption entries require path to be a networkId URN (got ${JSON.stringify(entry.path)})`
|
|
7836
7892
|
);
|
|
7837
7893
|
}
|
|
7894
|
+
const sharePrefix = entry.path.endsWith("/share/");
|
|
7895
|
+
if (entry.path.includes("/") && !sharePrefix) {
|
|
7896
|
+
throw new ManifestValidationError("named keys go in manifest.keys");
|
|
7897
|
+
}
|
|
7898
|
+
try {
|
|
7899
|
+
const network = (0, import_sdk_services3.parseNetworkId)(sharePrefix ? entry.path.slice(0, -"/share/".length) : entry.path);
|
|
7900
|
+
if (sharePrefix && network.name !== "default") throw new Error("share prefix requires default network");
|
|
7901
|
+
} catch {
|
|
7902
|
+
throw new ManifestValidationError("tinycloud.encryption entries require a valid networkId URN");
|
|
7903
|
+
}
|
|
7838
7904
|
const normalizedActions = [];
|
|
7839
7905
|
for (const action of entry.actions) {
|
|
7840
7906
|
if (action === "decrypt" || action === "tinycloud.encryption/decrypt") {
|
|
@@ -7866,6 +7932,9 @@ function expandEncryptionPermissionEntry(entry) {
|
|
|
7866
7932
|
seen.add(a);
|
|
7867
7933
|
}
|
|
7868
7934
|
}
|
|
7935
|
+
if (sharePrefix && dedupedActions.some((action) => action !== "tinycloud.encryption/decrypt")) {
|
|
7936
|
+
throw new ManifestValidationError("share prefix only supports decrypt");
|
|
7937
|
+
}
|
|
7869
7938
|
return [
|
|
7870
7939
|
{
|
|
7871
7940
|
service: ENCRYPTION_PERMISSION_SERVICE,
|
|
@@ -7881,6 +7950,29 @@ function expandEncryptionPermissionEntry(entry) {
|
|
|
7881
7950
|
function expandPermissionEntries(entries) {
|
|
7882
7951
|
return entries.flatMap(expandPermissionEntry);
|
|
7883
7952
|
}
|
|
7953
|
+
function expandDelegationPermissionEntries(entries) {
|
|
7954
|
+
return entries.flatMap((entry) => {
|
|
7955
|
+
if (entry.service !== ENCRYPTION_PERMISSION_SERVICE || typeof entry.path !== "string" || !entry.path.includes("/")) {
|
|
7956
|
+
return expandPermissionEntry(entry);
|
|
7957
|
+
}
|
|
7958
|
+
let resource;
|
|
7959
|
+
try {
|
|
7960
|
+
resource = (0, import_resource.parseEncryptionResource)(entry.path);
|
|
7961
|
+
} catch {
|
|
7962
|
+
throw new ManifestValidationError("delegation requires a canonical exact named-key resource");
|
|
7963
|
+
}
|
|
7964
|
+
if (resource.kind !== "key" || !Array.isArray(entry.actions) || entry.actions.length === 0 || entry.actions.some((action) => action !== "decrypt" && action !== "tinycloud.encryption/decrypt")) {
|
|
7965
|
+
throw new ManifestValidationError("named-key delegation requires an exact key and decrypt only");
|
|
7966
|
+
}
|
|
7967
|
+
return [{
|
|
7968
|
+
...entry,
|
|
7969
|
+
space: ENCRYPTION_MANIFEST_SPACE,
|
|
7970
|
+
path: `${resource.networkId}/${resource.path}`,
|
|
7971
|
+
actions: ["tinycloud.encryption/decrypt"],
|
|
7972
|
+
skipPrefix: true
|
|
7973
|
+
}];
|
|
7974
|
+
});
|
|
7975
|
+
}
|
|
7884
7976
|
function applyPrefix(prefix, path, skipPrefix) {
|
|
7885
7977
|
if (skipPrefix) {
|
|
7886
7978
|
return path;
|
|
@@ -7959,8 +8051,56 @@ function validateManifest(input) {
|
|
|
7959
8051
|
if (m.secrets !== void 0) {
|
|
7960
8052
|
validateManifestSecrets(m.secrets);
|
|
7961
8053
|
}
|
|
8054
|
+
if (Object.prototype.hasOwnProperty.call(m, "keys_app_id") && (typeof m.keys_app_id !== "string" || !KEY_APP_ID.test(m.keys_app_id))) {
|
|
8055
|
+
throw new ManifestValidationError("manifest.keys_app_id is invalid");
|
|
8056
|
+
}
|
|
8057
|
+
validateManifestKeys(m.keys_app_id ?? m.app_id, m.keys);
|
|
7962
8058
|
return m;
|
|
7963
8059
|
}
|
|
8060
|
+
var KEY_SEGMENT = "[a-z0-9][a-z0-9._-]{0,63}";
|
|
8061
|
+
var KEY_APP_ID = new RegExp(`^${KEY_SEGMENT}$`);
|
|
8062
|
+
var KEY_PATH = new RegExp(`^${KEY_SEGMENT}(?:/${KEY_SEGMENT}){2,7}$`);
|
|
8063
|
+
var KEY_ABILITIES = ["key.create", "decrypt", "key.block", "key.unblock"];
|
|
8064
|
+
function validateManifestKeys(appId, keys) {
|
|
8065
|
+
if (keys === void 0) return;
|
|
8066
|
+
if (!Array.isArray(keys) || keys.length > 32) {
|
|
8067
|
+
throw new ManifestValidationError("manifest.keys must contain at most 32 entries");
|
|
8068
|
+
}
|
|
8069
|
+
if (keys.length === 0) return;
|
|
8070
|
+
if (!KEY_APP_ID.test(appId)) {
|
|
8071
|
+
throw new ManifestValidationError("manifest.keys requires a valid app_id");
|
|
8072
|
+
}
|
|
8073
|
+
const paths = /* @__PURE__ */ new Set();
|
|
8074
|
+
let prefixSeen = false;
|
|
8075
|
+
for (const [index, value] of keys.entries()) {
|
|
8076
|
+
const label = `manifest.keys[${index}]`;
|
|
8077
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
8078
|
+
throw new ManifestValidationError(`${label} must be an object`);
|
|
8079
|
+
}
|
|
8080
|
+
const entry = value;
|
|
8081
|
+
const fields = Object.keys(entry);
|
|
8082
|
+
const hasPath = Object.prototype.hasOwnProperty.call(entry, "path");
|
|
8083
|
+
const hasPrefix = Object.prototype.hasOwnProperty.call(entry, "prefix");
|
|
8084
|
+
if (hasPath === hasPrefix || fields.some((field) => !["path", "prefix", "abilities"].includes(field))) {
|
|
8085
|
+
throw new ManifestValidationError(`${label} must have one path or prefix and abilities`);
|
|
8086
|
+
}
|
|
8087
|
+
if (!Array.isArray(entry.abilities) || entry.abilities.length === 0 || new Set(entry.abilities).size !== entry.abilities.length || entry.abilities.some((ability) => typeof ability !== "string" || !KEY_ABILITIES.includes(ability))) {
|
|
8088
|
+
throw new ManifestValidationError(`${label}.abilities is invalid`);
|
|
8089
|
+
}
|
|
8090
|
+
if (hasPath) {
|
|
8091
|
+
const path = entry.path;
|
|
8092
|
+
if (typeof path !== "string" || path.length > 255 || !KEY_PATH.test(path) || !path.startsWith(`apps/${appId}/`) || paths.has(path)) {
|
|
8093
|
+
throw new ManifestValidationError(`${label}.path is invalid`);
|
|
8094
|
+
}
|
|
8095
|
+
paths.add(path);
|
|
8096
|
+
} else {
|
|
8097
|
+
if (entry.prefix !== `apps/${appId}/` || prefixSeen) {
|
|
8098
|
+
throw new ManifestValidationError(`${label}.prefix is invalid`);
|
|
8099
|
+
}
|
|
8100
|
+
prefixSeen = true;
|
|
8101
|
+
}
|
|
8102
|
+
}
|
|
8103
|
+
}
|
|
7964
8104
|
function resolveManifestKnowledgeRoot(knowledge) {
|
|
7965
8105
|
if (knowledge === void 0) {
|
|
7966
8106
|
return void 0;
|
|
@@ -7985,13 +8125,13 @@ function validateManifestSecrets(secrets) {
|
|
|
7985
8125
|
throw new ManifestValidationError("manifest.secrets must be an object");
|
|
7986
8126
|
}
|
|
7987
8127
|
for (const [name2, spec] of Object.entries(secrets)) {
|
|
7988
|
-
if (!
|
|
8128
|
+
if (!import_sdk_services3.SECRET_NAME_RE.test(name2)) {
|
|
7989
8129
|
throw new ManifestValidationError(
|
|
7990
|
-
`manifest.secrets.${name2} must match ${
|
|
8130
|
+
`manifest.secrets.${name2} must match ${import_sdk_services3.SECRET_NAME_RE.source}`
|
|
7991
8131
|
);
|
|
7992
8132
|
}
|
|
7993
8133
|
try {
|
|
7994
|
-
(0,
|
|
8134
|
+
(0, import_sdk_services3.resolveSecretPath)(
|
|
7995
8135
|
secretNameFromSpec(name2, spec),
|
|
7996
8136
|
{ scope: secretScopeFromSpec(spec) }
|
|
7997
8137
|
);
|
|
@@ -8208,7 +8348,7 @@ function secretEntriesForManifest(secrets) {
|
|
|
8208
8348
|
const entries = [];
|
|
8209
8349
|
for (const [name2, spec] of Object.entries(secrets)) {
|
|
8210
8350
|
const actions = secretActionsFromSpec(name2, spec);
|
|
8211
|
-
const secretPath = (0,
|
|
8351
|
+
const secretPath = (0, import_sdk_services3.resolveSecretPath)(
|
|
8212
8352
|
secretNameFromSpec(name2, spec),
|
|
8213
8353
|
{ scope: secretScopeFromSpec(spec) }
|
|
8214
8354
|
);
|
|
@@ -8478,6 +8618,7 @@ function manifestAbilitiesUnion(resolved) {
|
|
|
8478
8618
|
}
|
|
8479
8619
|
|
|
8480
8620
|
// src/capabilities.ts
|
|
8621
|
+
var import_resource2 = require("@tinycloud/sdk-services/encryption/resource");
|
|
8481
8622
|
var PermissionNotInManifestError = class extends Error {
|
|
8482
8623
|
constructor(missing, granted) {
|
|
8483
8624
|
super(
|
|
@@ -8529,10 +8670,9 @@ function isCapabilitySubset(requested, granted) {
|
|
|
8529
8670
|
const grantedActions = matchingScope.flatMap(
|
|
8530
8671
|
(entry) => expandActionShortNames(entry.service, entry.actions)
|
|
8531
8672
|
);
|
|
8673
|
+
const namedKeyRequest = req.service === "tinycloud.encryption" && req.path.startsWith("urn:tinycloud:encryption:") && req.path.includes("/");
|
|
8532
8674
|
const covered = requestedActions.every(
|
|
8533
|
-
(requestedAction) => grantedActions.some(
|
|
8534
|
-
(grantedAction) => actionContains(grantedAction, requestedAction)
|
|
8535
|
-
)
|
|
8675
|
+
(requestedAction) => grantedActions.some((grantedAction) => namedKeyRequest ? grantedAction === requestedAction : actionContains(grantedAction, requestedAction))
|
|
8536
8676
|
);
|
|
8537
8677
|
if (!covered) {
|
|
8538
8678
|
missing.push(cloneEntry(req));
|
|
@@ -8547,7 +8687,9 @@ function canonicalizeEntryScopeMatches(requested, granted) {
|
|
|
8547
8687
|
if (normalizeSpace(requested.space ?? DEFAULT_MANIFEST_SPACE) !== normalizeSpace(granted.space ?? DEFAULT_MANIFEST_SPACE)) {
|
|
8548
8688
|
return false;
|
|
8549
8689
|
}
|
|
8550
|
-
|
|
8690
|
+
const namedKeyRequest = requested.service === "tinycloud.encryption" && requested.path.startsWith("urn:tinycloud:encryption:") && requested.path.includes("/");
|
|
8691
|
+
const coveredPath = namedKeyRequest ? (0, import_resource2.encryptionResourceContains)(granted.path, requested.path) : pathContains2(granted.path, requested.path);
|
|
8692
|
+
if (!coveredPath) {
|
|
8551
8693
|
return false;
|
|
8552
8694
|
}
|
|
8553
8695
|
if (!recapCaveatsEqual(requested.caveats, granted.caveats)) {
|
|
@@ -8659,7 +8801,7 @@ function parseRecapCapabilities(parseWasm, siwe) {
|
|
|
8659
8801
|
var import_ed255197 = require("@noble/curves/ed25519");
|
|
8660
8802
|
|
|
8661
8803
|
// src/delegations/ShareRecipientClient.ts
|
|
8662
|
-
var
|
|
8804
|
+
var import_sdk_services4 = require("@tinycloud/sdk-services");
|
|
8663
8805
|
var import_ed255196 = require("@noble/curves/ed25519");
|
|
8664
8806
|
var import_sha2565 = require("@noble/hashes/sha256");
|
|
8665
8807
|
|
|
@@ -9846,9 +9988,9 @@ function redactedCode(error) {
|
|
|
9846
9988
|
if (error instanceof ShareConflict) return error.code;
|
|
9847
9989
|
const code3 = error && typeof error === "object" && "code" in error ? error.code : void 0;
|
|
9848
9990
|
if (typeof code3 !== "string") return "SHARE_INVALID";
|
|
9849
|
-
if (code3 ===
|
|
9850
|
-
if (code3 ===
|
|
9851
|
-
if (code3 ===
|
|
9991
|
+
if (code3 === import_sdk_services4.ErrorCodes.KV_PRECONDITION_FAILED || code3 === "412") return "SHARE_CONFLICT";
|
|
9992
|
+
if (code3 === import_sdk_services4.ErrorCodes.NODE_BUSY || code3 === import_sdk_services4.ErrorCodes.REQUEST_TIMEOUT) return "SHARE_OFFLINE";
|
|
9993
|
+
if (code3 === import_sdk_services4.ErrorCodes.OUTCOME_UNKNOWN) return "SHARE_WRITE_FAILED";
|
|
9852
9994
|
if (code3 === "KV_NOT_FOUND" || code3 === "NOT_FOUND" || code3 === "404") return "SHARE_NOT_FOUND";
|
|
9853
9995
|
if (code3.includes("EXPIRED") || code3 === "expired") return "SHARE_EXPIRED";
|
|
9854
9996
|
if (code3.includes("REVOK")) return "SHARE_REVOKED";
|
|
@@ -10087,7 +10229,7 @@ var ShareRecipientClient = class {
|
|
|
10087
10229
|
if (portableDelegation !== void 0 && kv !== void 0) {
|
|
10088
10230
|
const result2 = await kv.put(resolvedPath, bytes2, { contentType: input.contentType ?? envelope.content.mimeType, ifMatch: input.etag });
|
|
10089
10231
|
if (!result2.ok) {
|
|
10090
|
-
if (result2.error.code ===
|
|
10232
|
+
if (result2.error.code === import_sdk_services4.ErrorCodes.KV_PRECONDITION_FAILED) throw new ShareConflict(resolvedPath, result2.error.meta?.etag);
|
|
10091
10233
|
throw result2.error;
|
|
10092
10234
|
}
|
|
10093
10235
|
return { etag: result2.data.headers.etag };
|
|
@@ -10095,7 +10237,7 @@ var ShareRecipientClient = class {
|
|
|
10095
10237
|
if (policySession !== void 0) return this.nativeSave(envelope, policySession, resolvedPath, bytes2, input);
|
|
10096
10238
|
const result = await kv.put(resolvedPath, bytes2, { contentType: input.contentType ?? envelope.content.mimeType, ifMatch: input.etag });
|
|
10097
10239
|
if (!result.ok) {
|
|
10098
|
-
if (result.error.code ===
|
|
10240
|
+
if (result.error.code === import_sdk_services4.ErrorCodes.KV_PRECONDITION_FAILED) throw new ShareConflict(resolvedPath, result.error.meta?.etag);
|
|
10099
10241
|
throw result.error;
|
|
10100
10242
|
}
|
|
10101
10243
|
return { etag: result.data.headers.etag };
|
|
@@ -10179,8 +10321,8 @@ var ShareRecipientClient = class {
|
|
|
10179
10321
|
if (this.options.createKVService !== void 0) {
|
|
10180
10322
|
return this.options.createKVService({ hosts: [origin2], session, invoke, fetch: this.fetchFn });
|
|
10181
10323
|
}
|
|
10182
|
-
const context = new
|
|
10183
|
-
const service = new
|
|
10324
|
+
const context = new import_sdk_services4.ServiceContext({ hosts: [origin2], session, invoke, fetch: this.fetchFn });
|
|
10325
|
+
const service = new import_sdk_services4.KVService({ prefix: "" });
|
|
10184
10326
|
context.registerService("kv", service);
|
|
10185
10327
|
service.initialize(context);
|
|
10186
10328
|
return service;
|
|
@@ -12728,14 +12870,14 @@ function markDelegationTerminal(token, key) {
|
|
|
12728
12870
|
}
|
|
12729
12871
|
|
|
12730
12872
|
// src/networkId.ts
|
|
12731
|
-
var
|
|
12873
|
+
var import_sdk_services5 = require("@tinycloud/sdk-services");
|
|
12732
12874
|
function canonicalizeNetworkId(networkId) {
|
|
12733
|
-
const parsed = (0,
|
|
12734
|
-
return (0,
|
|
12875
|
+
const parsed = (0, import_sdk_services5.parseNetworkId)(networkId);
|
|
12876
|
+
return (0, import_sdk_services5.buildNetworkId)(canonicalizeDid(parsed.ownerDid), parsed.name);
|
|
12735
12877
|
}
|
|
12736
12878
|
function parseCanonicalNetworkId(networkId) {
|
|
12737
12879
|
const canonical = canonicalizeNetworkId(networkId);
|
|
12738
|
-
return (0,
|
|
12880
|
+
return (0, import_sdk_services5.parseNetworkId)(canonical);
|
|
12739
12881
|
}
|
|
12740
12882
|
|
|
12741
12883
|
// src/storage.schema.ts
|
|
@@ -12843,10 +12985,10 @@ function validatePersistedSessionData(data) {
|
|
|
12843
12985
|
}
|
|
12844
12986
|
|
|
12845
12987
|
// src/TinyCloud.ts
|
|
12846
|
-
var
|
|
12988
|
+
var import_sdk_services7 = require("@tinycloud/sdk-services");
|
|
12847
12989
|
|
|
12848
12990
|
// src/spaces/SpaceService.ts
|
|
12849
|
-
var
|
|
12991
|
+
var import_sdk_services6 = require("@tinycloud/sdk-services");
|
|
12850
12992
|
|
|
12851
12993
|
// src/spaces/Space.ts
|
|
12852
12994
|
function unavailableSecretsService() {
|
|
@@ -13281,8 +13423,8 @@ var SpaceService = class {
|
|
|
13281
13423
|
*/
|
|
13282
13424
|
async list() {
|
|
13283
13425
|
if (!this.session) {
|
|
13284
|
-
return (0,
|
|
13285
|
-
(0,
|
|
13426
|
+
return (0, import_sdk_services6.err)(
|
|
13427
|
+
(0, import_sdk_services6.serviceError)(SpaceErrorCodes.AUTH_REQUIRED, "Authentication required", SERVICE_NAME)
|
|
13286
13428
|
);
|
|
13287
13429
|
}
|
|
13288
13430
|
try {
|
|
@@ -13291,8 +13433,8 @@ var SpaceService = class {
|
|
|
13291
13433
|
if (ownedResult.ok) {
|
|
13292
13434
|
spaces.push(...ownedResult.data);
|
|
13293
13435
|
} else {
|
|
13294
|
-
const verdict = (0,
|
|
13295
|
-
if (verdict === "unauthenticated" || verdict === "forbidden") return (0,
|
|
13436
|
+
const verdict = (0, import_sdk_services6.authorizationVerdictOf)(ownedResult.error);
|
|
13437
|
+
if (verdict === "unauthenticated" || verdict === "forbidden") return (0, import_sdk_services6.err)(ownedResult.error);
|
|
13296
13438
|
}
|
|
13297
13439
|
if (this.capabilityRegistry) {
|
|
13298
13440
|
const delegatedSpaces = this.discoverDelegatedSpaces();
|
|
@@ -13304,10 +13446,10 @@ var SpaceService = class {
|
|
|
13304
13446
|
this.notifySpaceRegistered(space);
|
|
13305
13447
|
}
|
|
13306
13448
|
}
|
|
13307
|
-
return (0,
|
|
13449
|
+
return (0, import_sdk_services6.ok)(uniqueSpaces);
|
|
13308
13450
|
} catch (error) {
|
|
13309
|
-
return (0,
|
|
13310
|
-
(0,
|
|
13451
|
+
return (0, import_sdk_services6.err)(
|
|
13452
|
+
(0, import_sdk_services6.serviceError)(
|
|
13311
13453
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13312
13454
|
`Failed to list spaces: ${String(error)}`,
|
|
13313
13455
|
SERVICE_NAME,
|
|
@@ -13327,7 +13469,7 @@ var SpaceService = class {
|
|
|
13327
13469
|
headers
|
|
13328
13470
|
});
|
|
13329
13471
|
if (!response.ok) {
|
|
13330
|
-
return (0,
|
|
13472
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
13331
13473
|
response,
|
|
13332
13474
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13333
13475
|
"Failed to list owned spaces",
|
|
@@ -13337,8 +13479,8 @@ var SpaceService = class {
|
|
|
13337
13479
|
const rawData = await response.json();
|
|
13338
13480
|
const validationResult = validateServerOwnedSpacesResponse(rawData);
|
|
13339
13481
|
if (!validationResult.ok) {
|
|
13340
|
-
return (0,
|
|
13341
|
-
(0,
|
|
13482
|
+
return (0, import_sdk_services6.err)(
|
|
13483
|
+
(0, import_sdk_services6.serviceError)(
|
|
13342
13484
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13343
13485
|
validationResult.error.message,
|
|
13344
13486
|
SERVICE_NAME,
|
|
@@ -13354,10 +13496,10 @@ var SpaceService = class {
|
|
|
13354
13496
|
permissions: ["*"]
|
|
13355
13497
|
// Full permissions for owned spaces
|
|
13356
13498
|
}));
|
|
13357
|
-
return (0,
|
|
13499
|
+
return (0, import_sdk_services6.ok)(spaces);
|
|
13358
13500
|
} catch (error) {
|
|
13359
|
-
return (0,
|
|
13360
|
-
(0,
|
|
13501
|
+
return (0, import_sdk_services6.err)(
|
|
13502
|
+
(0, import_sdk_services6.serviceError)(
|
|
13361
13503
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13362
13504
|
`Network error listing owned spaces: ${String(error)}`,
|
|
13363
13505
|
SERVICE_NAME,
|
|
@@ -13438,13 +13580,13 @@ var SpaceService = class {
|
|
|
13438
13580
|
*/
|
|
13439
13581
|
async create(name2) {
|
|
13440
13582
|
if (!this.session) {
|
|
13441
|
-
return (0,
|
|
13442
|
-
(0,
|
|
13583
|
+
return (0, import_sdk_services6.err)(
|
|
13584
|
+
(0, import_sdk_services6.serviceError)(SpaceErrorCodes.AUTH_REQUIRED, "Authentication required", SERVICE_NAME)
|
|
13443
13585
|
);
|
|
13444
13586
|
}
|
|
13445
13587
|
if (!name2 || !/^[a-zA-Z0-9_-]+$/.test(name2)) {
|
|
13446
|
-
return (0,
|
|
13447
|
-
(0,
|
|
13588
|
+
return (0, import_sdk_services6.err)(
|
|
13589
|
+
(0, import_sdk_services6.serviceError)(
|
|
13448
13590
|
SpaceErrorCodes.INVALID_NAME,
|
|
13449
13591
|
"Space name must contain only alphanumeric characters, underscores, and hyphens",
|
|
13450
13592
|
SERVICE_NAME
|
|
@@ -13460,14 +13602,14 @@ var SpaceService = class {
|
|
|
13460
13602
|
});
|
|
13461
13603
|
if (!response.ok) {
|
|
13462
13604
|
if (response.status === 409) {
|
|
13463
|
-
return (0,
|
|
13605
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
13464
13606
|
response,
|
|
13465
13607
|
SpaceErrorCodes.ALREADY_EXISTS,
|
|
13466
13608
|
`Space "${name2}" already exists`,
|
|
13467
13609
|
SERVICE_NAME
|
|
13468
13610
|
));
|
|
13469
13611
|
}
|
|
13470
|
-
return (0,
|
|
13612
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
13471
13613
|
response,
|
|
13472
13614
|
SpaceErrorCodes.CREATION_FAILED,
|
|
13473
13615
|
"Failed to create space",
|
|
@@ -13477,8 +13619,8 @@ var SpaceService = class {
|
|
|
13477
13619
|
const rawData = await response.json();
|
|
13478
13620
|
const validationResult = validateServerCreateSpaceResponse(rawData);
|
|
13479
13621
|
if (!validationResult.ok) {
|
|
13480
|
-
return (0,
|
|
13481
|
-
(0,
|
|
13622
|
+
return (0, import_sdk_services6.err)(
|
|
13623
|
+
(0, import_sdk_services6.serviceError)(
|
|
13482
13624
|
SpaceErrorCodes.CREATION_FAILED,
|
|
13483
13625
|
validationResult.error.message,
|
|
13484
13626
|
SERVICE_NAME,
|
|
@@ -13495,10 +13637,10 @@ var SpaceService = class {
|
|
|
13495
13637
|
};
|
|
13496
13638
|
this.infoCache.set(spaceInfo.id, { info: spaceInfo, cachedAt: Date.now() });
|
|
13497
13639
|
this.notifySpaceRegistered(spaceInfo);
|
|
13498
|
-
return (0,
|
|
13640
|
+
return (0, import_sdk_services6.ok)(spaceInfo);
|
|
13499
13641
|
} catch (error) {
|
|
13500
|
-
return (0,
|
|
13501
|
-
(0,
|
|
13642
|
+
return (0, import_sdk_services6.err)(
|
|
13643
|
+
(0, import_sdk_services6.serviceError)(
|
|
13502
13644
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13503
13645
|
`Network error creating space: ${String(error)}`,
|
|
13504
13646
|
SERVICE_NAME,
|
|
@@ -13568,10 +13710,10 @@ var SpaceService = class {
|
|
|
13568
13710
|
const spaceId = this.resolveSpaceId(nameOrUri);
|
|
13569
13711
|
const cached = this.infoCache.get(spaceId);
|
|
13570
13712
|
if (cached && Date.now() - cached.cachedAt < this.cacheTTL) {
|
|
13571
|
-
return (0,
|
|
13713
|
+
return (0, import_sdk_services6.ok)(true);
|
|
13572
13714
|
}
|
|
13573
13715
|
const infoResult = await this.getSpaceInfo(spaceId);
|
|
13574
|
-
return (0,
|
|
13716
|
+
return (0, import_sdk_services6.ok)(infoResult.ok);
|
|
13575
13717
|
}
|
|
13576
13718
|
// ===========================================================================
|
|
13577
13719
|
// Space Info
|
|
@@ -13582,11 +13724,11 @@ var SpaceService = class {
|
|
|
13582
13724
|
async getSpaceInfo(spaceId) {
|
|
13583
13725
|
const cached = this.infoCache.get(spaceId);
|
|
13584
13726
|
if (cached && Date.now() - cached.cachedAt < this.cacheTTL) {
|
|
13585
|
-
return (0,
|
|
13727
|
+
return (0, import_sdk_services6.ok)(cached.info);
|
|
13586
13728
|
}
|
|
13587
13729
|
if (!this.session) {
|
|
13588
|
-
return (0,
|
|
13589
|
-
(0,
|
|
13730
|
+
return (0, import_sdk_services6.err)(
|
|
13731
|
+
(0, import_sdk_services6.serviceError)(SpaceErrorCodes.AUTH_REQUIRED, "Authentication required", SERVICE_NAME)
|
|
13590
13732
|
);
|
|
13591
13733
|
}
|
|
13592
13734
|
try {
|
|
@@ -13598,14 +13740,14 @@ var SpaceService = class {
|
|
|
13598
13740
|
});
|
|
13599
13741
|
if (!response.ok) {
|
|
13600
13742
|
if (response.status === 404) {
|
|
13601
|
-
return (0,
|
|
13743
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
13602
13744
|
response,
|
|
13603
13745
|
SpaceErrorCodes.NOT_FOUND,
|
|
13604
13746
|
`Space not found: ${spaceId}`,
|
|
13605
13747
|
SERVICE_NAME
|
|
13606
13748
|
));
|
|
13607
13749
|
}
|
|
13608
|
-
return (0,
|
|
13750
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
13609
13751
|
response,
|
|
13610
13752
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13611
13753
|
"Failed to get space info",
|
|
@@ -13615,8 +13757,8 @@ var SpaceService = class {
|
|
|
13615
13757
|
const rawData = await response.json();
|
|
13616
13758
|
const validationResult = validateServerSpaceInfoResponse(rawData);
|
|
13617
13759
|
if (!validationResult.ok) {
|
|
13618
|
-
return (0,
|
|
13619
|
-
(0,
|
|
13760
|
+
return (0, import_sdk_services6.err)(
|
|
13761
|
+
(0, import_sdk_services6.serviceError)(
|
|
13620
13762
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13621
13763
|
validationResult.error.message,
|
|
13622
13764
|
SERVICE_NAME,
|
|
@@ -13634,10 +13776,10 @@ var SpaceService = class {
|
|
|
13634
13776
|
expiresAt: data.expiresAt ? new Date(data.expiresAt) : void 0
|
|
13635
13777
|
};
|
|
13636
13778
|
this.infoCache.set(spaceId, { info: spaceInfo, cachedAt: Date.now() });
|
|
13637
|
-
return (0,
|
|
13779
|
+
return (0, import_sdk_services6.ok)(spaceInfo);
|
|
13638
13780
|
} catch (error) {
|
|
13639
|
-
return (0,
|
|
13640
|
-
(0,
|
|
13781
|
+
return (0, import_sdk_services6.err)(
|
|
13782
|
+
(0, import_sdk_services6.serviceError)(
|
|
13641
13783
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13642
13784
|
`Network error getting space info: ${String(error)}`,
|
|
13643
13785
|
SERVICE_NAME,
|
|
@@ -13722,7 +13864,7 @@ var SpaceService = class {
|
|
|
13722
13864
|
headers
|
|
13723
13865
|
});
|
|
13724
13866
|
if (!response.ok) {
|
|
13725
|
-
return (0,
|
|
13867
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
13726
13868
|
response,
|
|
13727
13869
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13728
13870
|
"Failed to list delegations",
|
|
@@ -13732,8 +13874,8 @@ var SpaceService = class {
|
|
|
13732
13874
|
const rawData = await response.json();
|
|
13733
13875
|
const validationResult = validateServerDelegationsResponse(rawData);
|
|
13734
13876
|
if (!validationResult.ok) {
|
|
13735
|
-
return (0,
|
|
13736
|
-
(0,
|
|
13877
|
+
return (0, import_sdk_services6.err)(
|
|
13878
|
+
(0, import_sdk_services6.serviceError)(
|
|
13737
13879
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13738
13880
|
validationResult.error.message,
|
|
13739
13881
|
SERVICE_NAME,
|
|
@@ -13742,10 +13884,10 @@ var SpaceService = class {
|
|
|
13742
13884
|
);
|
|
13743
13885
|
}
|
|
13744
13886
|
const delegations = transformServerDelegations(validationResult.data, spaceId);
|
|
13745
|
-
return (0,
|
|
13887
|
+
return (0, import_sdk_services6.ok)(delegations);
|
|
13746
13888
|
} catch (error) {
|
|
13747
|
-
return (0,
|
|
13748
|
-
(0,
|
|
13889
|
+
return (0, import_sdk_services6.err)(
|
|
13890
|
+
(0, import_sdk_services6.serviceError)(
|
|
13749
13891
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13750
13892
|
`Network error listing delegations: ${String(error)}`,
|
|
13751
13893
|
SERVICE_NAME
|
|
@@ -13775,7 +13917,7 @@ var SpaceService = class {
|
|
|
13775
13917
|
headers
|
|
13776
13918
|
});
|
|
13777
13919
|
if (!response.ok) {
|
|
13778
|
-
return (0,
|
|
13920
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
13779
13921
|
response,
|
|
13780
13922
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13781
13923
|
"Failed to list received delegations",
|
|
@@ -13785,8 +13927,8 @@ var SpaceService = class {
|
|
|
13785
13927
|
const rawData = await response.json();
|
|
13786
13928
|
const validationResult = validateServerDelegationsResponse(rawData);
|
|
13787
13929
|
if (!validationResult.ok) {
|
|
13788
|
-
return (0,
|
|
13789
|
-
(0,
|
|
13930
|
+
return (0, import_sdk_services6.err)(
|
|
13931
|
+
(0, import_sdk_services6.serviceError)(
|
|
13790
13932
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13791
13933
|
validationResult.error.message,
|
|
13792
13934
|
SERVICE_NAME,
|
|
@@ -13795,10 +13937,10 @@ var SpaceService = class {
|
|
|
13795
13937
|
);
|
|
13796
13938
|
}
|
|
13797
13939
|
const delegations = transformServerDelegations(validationResult.data, spaceId);
|
|
13798
|
-
return (0,
|
|
13940
|
+
return (0, import_sdk_services6.ok)(delegations);
|
|
13799
13941
|
} catch (error) {
|
|
13800
|
-
return (0,
|
|
13801
|
-
(0,
|
|
13942
|
+
return (0, import_sdk_services6.err)(
|
|
13943
|
+
(0, import_sdk_services6.serviceError)(
|
|
13802
13944
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13803
13945
|
`Network error listing received delegations: ${String(error)}`,
|
|
13804
13946
|
SERVICE_NAME
|
|
@@ -13810,8 +13952,8 @@ var SpaceService = class {
|
|
|
13810
13952
|
if (self.createDelegationFn) {
|
|
13811
13953
|
return self.createDelegationFn({ ...params, spaceId });
|
|
13812
13954
|
}
|
|
13813
|
-
return (0,
|
|
13814
|
-
(0,
|
|
13955
|
+
return (0, import_sdk_services6.err)(
|
|
13956
|
+
(0, import_sdk_services6.serviceError)(
|
|
13815
13957
|
SpaceErrorCodes.NOT_INITIALIZED,
|
|
13816
13958
|
"Delegation creation requires a createDelegation function. This should be provided by the platform SDK (web-sdk or node-sdk).",
|
|
13817
13959
|
SERVICE_NAME
|
|
@@ -13832,17 +13974,17 @@ var SpaceService = class {
|
|
|
13832
13974
|
body: JSON.stringify({ cid: cid2, spaceId })
|
|
13833
13975
|
});
|
|
13834
13976
|
if (!response.ok) {
|
|
13835
|
-
return (0,
|
|
13977
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
13836
13978
|
response,
|
|
13837
13979
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13838
13980
|
"Failed to revoke delegation",
|
|
13839
13981
|
SERVICE_NAME
|
|
13840
13982
|
));
|
|
13841
13983
|
}
|
|
13842
|
-
return (0,
|
|
13984
|
+
return (0, import_sdk_services6.ok)(void 0);
|
|
13843
13985
|
} catch (error) {
|
|
13844
|
-
return (0,
|
|
13845
|
-
(0,
|
|
13986
|
+
return (0, import_sdk_services6.err)(
|
|
13987
|
+
(0, import_sdk_services6.serviceError)(
|
|
13846
13988
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13847
13989
|
`Network error revoking delegation: ${String(error)}`,
|
|
13848
13990
|
SERVICE_NAME
|
|
@@ -13865,18 +14007,18 @@ var SpaceService = class {
|
|
|
13865
14007
|
if (self.sharingService) {
|
|
13866
14008
|
const result = await self.sharingService.generate(params);
|
|
13867
14009
|
if (!result.ok) {
|
|
13868
|
-
return (0,
|
|
13869
|
-
(0,
|
|
14010
|
+
return (0, import_sdk_services6.err)(
|
|
14011
|
+
(0, import_sdk_services6.serviceError)(
|
|
13870
14012
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13871
14013
|
result.error.message || "Failed to generate share link",
|
|
13872
14014
|
SERVICE_NAME
|
|
13873
14015
|
)
|
|
13874
14016
|
);
|
|
13875
14017
|
}
|
|
13876
|
-
return (0,
|
|
14018
|
+
return (0, import_sdk_services6.ok)(result.data);
|
|
13877
14019
|
}
|
|
13878
|
-
return (0,
|
|
13879
|
-
(0,
|
|
14020
|
+
return (0, import_sdk_services6.err)(
|
|
14021
|
+
(0, import_sdk_services6.serviceError)(
|
|
13880
14022
|
SpaceErrorCodes.NOT_INITIALIZED,
|
|
13881
14023
|
"SharingService not configured. V2 sharing requires a SharingService instance.",
|
|
13882
14024
|
SERVICE_NAME
|
|
@@ -13884,8 +14026,8 @@ var SpaceService = class {
|
|
|
13884
14026
|
);
|
|
13885
14027
|
},
|
|
13886
14028
|
async list() {
|
|
13887
|
-
return (0,
|
|
13888
|
-
(0,
|
|
14029
|
+
return (0, import_sdk_services6.err)(
|
|
14030
|
+
(0, import_sdk_services6.serviceError)(
|
|
13889
14031
|
SpaceErrorCodes.NOT_INITIALIZED,
|
|
13890
14032
|
"Listing share links is not supported in v2. Share links are self-contained tokens that are not tracked on the server.",
|
|
13891
14033
|
SERVICE_NAME
|
|
@@ -13893,8 +14035,8 @@ var SpaceService = class {
|
|
|
13893
14035
|
);
|
|
13894
14036
|
},
|
|
13895
14037
|
async revoke(token) {
|
|
13896
|
-
return (0,
|
|
13897
|
-
(0,
|
|
14038
|
+
return (0, import_sdk_services6.err)(
|
|
14039
|
+
(0, import_sdk_services6.serviceError)(
|
|
13898
14040
|
SpaceErrorCodes.NOT_INITIALIZED,
|
|
13899
14041
|
"Revoking share links by token is not supported in v2. To revoke access, revoke the underlying delegation using space.delegations.revoke(cid).",
|
|
13900
14042
|
SERVICE_NAME
|
|
@@ -13954,7 +14096,7 @@ var TinyCloud = class _TinyCloud {
|
|
|
13954
14096
|
"hosts are required to initialize services. Provide them via config.hosts or initializeServices()."
|
|
13955
14097
|
);
|
|
13956
14098
|
}
|
|
13957
|
-
this._serviceContext = new
|
|
14099
|
+
this._serviceContext = new import_sdk_services7.ServiceContext({
|
|
13958
14100
|
invoke: effectiveInvoke,
|
|
13959
14101
|
invokeAny: this.config.invokeAny,
|
|
13960
14102
|
fetch: fetchFn ?? this.config.fetch ?? globalThis.fetch.bind(globalThis),
|
|
@@ -13963,10 +14105,10 @@ var TinyCloud = class _TinyCloud {
|
|
|
13963
14105
|
telemetry: this.config.telemetry
|
|
13964
14106
|
});
|
|
13965
14107
|
const serviceConstructors = {
|
|
13966
|
-
kv:
|
|
13967
|
-
sql:
|
|
13968
|
-
duckdb:
|
|
13969
|
-
hooks:
|
|
14108
|
+
kv: import_sdk_services7.KVService,
|
|
14109
|
+
sql: import_sdk_services7.SQLService,
|
|
14110
|
+
duckdb: import_sdk_services7.DuckDbService,
|
|
14111
|
+
hooks: import_sdk_services7.HooksService,
|
|
13970
14112
|
...this.config.services
|
|
13971
14113
|
};
|
|
13972
14114
|
for (const [name2, ServiceClass] of Object.entries(serviceConstructors)) {
|
|
@@ -14230,18 +14372,18 @@ var TinyCloud = class _TinyCloud {
|
|
|
14230
14372
|
const address = this.address();
|
|
14231
14373
|
const chainId = this.chainId();
|
|
14232
14374
|
if (!address || !chainId) {
|
|
14233
|
-
return (0,
|
|
14234
|
-
(0,
|
|
14235
|
-
|
|
14375
|
+
return (0, import_sdk_services7.err)(
|
|
14376
|
+
(0, import_sdk_services7.serviceError)(
|
|
14377
|
+
import_sdk_services7.ErrorCodes.AUTH_REQUIRED,
|
|
14236
14378
|
"Must be signed in to ensure public space",
|
|
14237
14379
|
"public-space"
|
|
14238
14380
|
)
|
|
14239
14381
|
);
|
|
14240
14382
|
}
|
|
14241
14383
|
if (!this._serviceContext) {
|
|
14242
|
-
return (0,
|
|
14243
|
-
(0,
|
|
14244
|
-
|
|
14384
|
+
return (0, import_sdk_services7.err)(
|
|
14385
|
+
(0, import_sdk_services7.serviceError)(
|
|
14386
|
+
import_sdk_services7.ErrorCodes.AUTH_REQUIRED,
|
|
14245
14387
|
"Services not initialized. Call initializeServices() or signIn() first.",
|
|
14246
14388
|
"public-space"
|
|
14247
14389
|
)
|
|
@@ -14251,9 +14393,9 @@ var TinyCloud = class _TinyCloud {
|
|
|
14251
14393
|
try {
|
|
14252
14394
|
const session = this._serviceContext.session;
|
|
14253
14395
|
if (!session) {
|
|
14254
|
-
return (0,
|
|
14255
|
-
(0,
|
|
14256
|
-
|
|
14396
|
+
return (0, import_sdk_services7.err)(
|
|
14397
|
+
(0, import_sdk_services7.serviceError)(
|
|
14398
|
+
import_sdk_services7.ErrorCodes.AUTH_REQUIRED,
|
|
14257
14399
|
"No active session",
|
|
14258
14400
|
"public-space"
|
|
14259
14401
|
)
|
|
@@ -14270,7 +14412,7 @@ var TinyCloud = class _TinyCloud {
|
|
|
14270
14412
|
{ method: "POST", headers, body: JSON.stringify({ spaceId }) }
|
|
14271
14413
|
);
|
|
14272
14414
|
if (response.ok) {
|
|
14273
|
-
return (0,
|
|
14415
|
+
return (0, import_sdk_services7.ok)(void 0);
|
|
14274
14416
|
}
|
|
14275
14417
|
if (response.status === 404) {
|
|
14276
14418
|
const createHeaders = this._serviceContext.invoke(
|
|
@@ -14289,27 +14431,27 @@ var TinyCloud = class _TinyCloud {
|
|
|
14289
14431
|
);
|
|
14290
14432
|
if (!createResponse.ok) {
|
|
14291
14433
|
if (createResponse.status === 409) {
|
|
14292
|
-
return (0,
|
|
14434
|
+
return (0, import_sdk_services7.ok)(void 0);
|
|
14293
14435
|
}
|
|
14294
|
-
return (0,
|
|
14436
|
+
return (0, import_sdk_services7.err)(await serviceHttpError(
|
|
14295
14437
|
createResponse,
|
|
14296
|
-
|
|
14438
|
+
import_sdk_services7.ErrorCodes.NETWORK_ERROR,
|
|
14297
14439
|
"Failed to create public space",
|
|
14298
14440
|
"public-space"
|
|
14299
14441
|
));
|
|
14300
14442
|
}
|
|
14301
|
-
return (0,
|
|
14443
|
+
return (0, import_sdk_services7.ok)(void 0);
|
|
14302
14444
|
}
|
|
14303
|
-
return (0,
|
|
14445
|
+
return (0, import_sdk_services7.err)(await serviceHttpError(
|
|
14304
14446
|
response,
|
|
14305
|
-
|
|
14447
|
+
import_sdk_services7.ErrorCodes.NETWORK_ERROR,
|
|
14306
14448
|
"Failed to check public space",
|
|
14307
14449
|
"public-space"
|
|
14308
14450
|
));
|
|
14309
14451
|
} catch (error) {
|
|
14310
|
-
return (0,
|
|
14311
|
-
(0,
|
|
14312
|
-
|
|
14452
|
+
return (0, import_sdk_services7.err)(
|
|
14453
|
+
(0, import_sdk_services7.serviceError)(
|
|
14454
|
+
import_sdk_services7.ErrorCodes.NETWORK_ERROR,
|
|
14313
14455
|
`Network error ensuring public space: ${String(error)}`,
|
|
14314
14456
|
"public-space",
|
|
14315
14457
|
{ cause: error instanceof Error ? error : void 0 }
|
|
@@ -14342,8 +14484,8 @@ var TinyCloud = class _TinyCloud {
|
|
|
14342
14484
|
if (!session) {
|
|
14343
14485
|
throw new Error("No active session. Sign in first.");
|
|
14344
14486
|
}
|
|
14345
|
-
const publicKV = new
|
|
14346
|
-
const publicContext = new
|
|
14487
|
+
const publicKV = new import_sdk_services7.KVService({ prefix: "" });
|
|
14488
|
+
const publicContext = new import_sdk_services7.ServiceContext({
|
|
14347
14489
|
invoke: this._serviceContext.invoke,
|
|
14348
14490
|
fetch: this._serviceContext.fetch,
|
|
14349
14491
|
hosts: this._serviceContext.hosts,
|
|
@@ -14376,16 +14518,16 @@ var TinyCloud = class _TinyCloud {
|
|
|
14376
14518
|
const response = await doFetch(url, { method: "GET" });
|
|
14377
14519
|
if (!response.ok) {
|
|
14378
14520
|
if (response.status === 404) {
|
|
14379
|
-
return (0,
|
|
14521
|
+
return (0, import_sdk_services7.err)(await serviceHttpError(
|
|
14380
14522
|
response,
|
|
14381
|
-
|
|
14523
|
+
import_sdk_services7.ErrorCodes.NOT_FOUND,
|
|
14382
14524
|
`Key not found: ${key} in space ${spaceId}`,
|
|
14383
14525
|
"public-space"
|
|
14384
14526
|
));
|
|
14385
14527
|
}
|
|
14386
|
-
return (0,
|
|
14528
|
+
return (0, import_sdk_services7.err)(await serviceHttpError(
|
|
14387
14529
|
response,
|
|
14388
|
-
|
|
14530
|
+
import_sdk_services7.ErrorCodes.NETWORK_ERROR,
|
|
14389
14531
|
"Failed to read public space",
|
|
14390
14532
|
"public-space"
|
|
14391
14533
|
));
|
|
@@ -14402,11 +14544,11 @@ var TinyCloud = class _TinyCloud {
|
|
|
14402
14544
|
data = text3;
|
|
14403
14545
|
}
|
|
14404
14546
|
}
|
|
14405
|
-
return (0,
|
|
14547
|
+
return (0, import_sdk_services7.ok)(data);
|
|
14406
14548
|
} catch (error) {
|
|
14407
|
-
return (0,
|
|
14408
|
-
(0,
|
|
14409
|
-
|
|
14549
|
+
return (0, import_sdk_services7.err)(
|
|
14550
|
+
(0, import_sdk_services7.serviceError)(
|
|
14551
|
+
import_sdk_services7.ErrorCodes.NETWORK_ERROR,
|
|
14410
14552
|
`Network error reading public space: ${String(error)}`,
|
|
14411
14553
|
"public-space",
|
|
14412
14554
|
{ cause: error instanceof Error ? error : void 0 }
|
|
@@ -14432,7 +14574,7 @@ var TinyCloud = class _TinyCloud {
|
|
|
14432
14574
|
};
|
|
14433
14575
|
|
|
14434
14576
|
// src/account/AccountService.ts
|
|
14435
|
-
var
|
|
14577
|
+
var import_sdk_services8 = require("@tinycloud/sdk-services");
|
|
14436
14578
|
var import_bootstrap3 = require("@tinycloud/bootstrap");
|
|
14437
14579
|
var SERVICE_NAME2 = "account";
|
|
14438
14580
|
var ACCOUNT_INDEX_DB = "account";
|
|
@@ -14480,7 +14622,7 @@ var AccountService = class {
|
|
|
14480
14622
|
applications.push(applicationFromRecord(key, loaded.data.data));
|
|
14481
14623
|
}
|
|
14482
14624
|
applications.sort((a, b) => a.appId.localeCompare(b.appId));
|
|
14483
|
-
return (0,
|
|
14625
|
+
return (0, import_sdk_services8.ok)(applications);
|
|
14484
14626
|
},
|
|
14485
14627
|
get: async (appId) => {
|
|
14486
14628
|
const kvResult = this.accountKV();
|
|
@@ -14488,14 +14630,14 @@ var AccountService = class {
|
|
|
14488
14630
|
const key = applicationKey(appId);
|
|
14489
14631
|
const loaded = await kvResult.data.get(key);
|
|
14490
14632
|
if (!loaded.ok) return accountErr(loaded.error);
|
|
14491
|
-
return (0,
|
|
14633
|
+
return (0, import_sdk_services8.ok)(applicationFromRecord(key, loaded.data.data));
|
|
14492
14634
|
},
|
|
14493
14635
|
register: async (manifest, options2 = {}) => {
|
|
14494
14636
|
const manifests = Array.isArray(manifest) ? manifest : [manifest];
|
|
14495
14637
|
const request = composeManifestRequest(manifests);
|
|
14496
14638
|
if (request.registryRecords.length === 0) {
|
|
14497
|
-
return (0,
|
|
14498
|
-
(0,
|
|
14639
|
+
return (0, import_sdk_services8.err)(
|
|
14640
|
+
(0, import_sdk_services8.serviceError)(
|
|
14499
14641
|
"INVALID_MANIFEST",
|
|
14500
14642
|
"Manifest did not produce an account application registry record",
|
|
14501
14643
|
SERVICE_NAME2
|
|
@@ -14529,7 +14671,7 @@ var AccountService = class {
|
|
|
14529
14671
|
registered = applicationFromRecord(record2.key, stored);
|
|
14530
14672
|
await this.upsertApplicationIndexQuietly(registered);
|
|
14531
14673
|
}
|
|
14532
|
-
return (0,
|
|
14674
|
+
return (0, import_sdk_services8.ok)(registered);
|
|
14533
14675
|
},
|
|
14534
14676
|
remove: async (appId) => {
|
|
14535
14677
|
const kvResult = this.accountKV();
|
|
@@ -14537,7 +14679,7 @@ var AccountService = class {
|
|
|
14537
14679
|
const removed = await kvResult.data.delete(applicationKey(appId));
|
|
14538
14680
|
if (!removed.ok) return accountErr(removed.error);
|
|
14539
14681
|
await this.deleteApplicationIndexQuietly(appId);
|
|
14540
|
-
return (0,
|
|
14682
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
14541
14683
|
}
|
|
14542
14684
|
};
|
|
14543
14685
|
this.spaces = {
|
|
@@ -14551,7 +14693,7 @@ var AccountService = class {
|
|
|
14551
14693
|
if (canonical.data.allRegistered && options2.refreshIndex !== false) {
|
|
14552
14694
|
await this.replaceSpacesIndexQuietly(canonical.data.spaces);
|
|
14553
14695
|
}
|
|
14554
|
-
return (0,
|
|
14696
|
+
return (0, import_sdk_services8.ok)(canonical.data.spaces);
|
|
14555
14697
|
}
|
|
14556
14698
|
const kvResult = this.accountKV();
|
|
14557
14699
|
if (!kvResult.ok) return kvResult;
|
|
@@ -14564,14 +14706,14 @@ var AccountService = class {
|
|
|
14564
14706
|
spaces.push(spaceFromRecord(key, loaded.data.data));
|
|
14565
14707
|
}
|
|
14566
14708
|
spaces.sort((a, b) => a.name.localeCompare(b.name) || a.spaceId.localeCompare(b.spaceId));
|
|
14567
|
-
return (0,
|
|
14709
|
+
return (0, import_sdk_services8.ok)(spaces);
|
|
14568
14710
|
},
|
|
14569
14711
|
get: async (spaceId) => {
|
|
14570
14712
|
const kvResult = this.accountKV();
|
|
14571
14713
|
if (!kvResult.ok) return kvResult;
|
|
14572
14714
|
const loaded = await kvResult.data.get(spaceKey(spaceId));
|
|
14573
14715
|
if (!loaded.ok) return accountErr(loaded.error);
|
|
14574
|
-
return (0,
|
|
14716
|
+
return (0, import_sdk_services8.ok)(spaceFromRecord(spaceKey(spaceId), loaded.data.data));
|
|
14575
14717
|
},
|
|
14576
14718
|
register: async (space) => {
|
|
14577
14719
|
await this.config.ensureAccountSpaceHosted?.();
|
|
@@ -14582,7 +14724,7 @@ var AccountService = class {
|
|
|
14582
14724
|
if (!written.ok) return accountErr(written.error);
|
|
14583
14725
|
const registered = spaceFromRecord(spaceKey(stored.space_id), stored);
|
|
14584
14726
|
await this.upsertSpaceIndexQuietly(registered);
|
|
14585
|
-
return (0,
|
|
14727
|
+
return (0, import_sdk_services8.ok)(registered);
|
|
14586
14728
|
},
|
|
14587
14729
|
/**
|
|
14588
14730
|
* Register multiple spaces in one KV batch write + one multi-row index
|
|
@@ -14595,7 +14737,7 @@ var AccountService = class {
|
|
|
14595
14737
|
* leave the first attempt's blocks orphaned.
|
|
14596
14738
|
*/
|
|
14597
14739
|
registerBatch: async (spaces) => {
|
|
14598
|
-
if (spaces.length === 0) return (0,
|
|
14740
|
+
if (spaces.length === 0) return (0, import_sdk_services8.ok)({ spaces: [] });
|
|
14599
14741
|
await this.config.ensureAccountSpaceHosted?.();
|
|
14600
14742
|
const kvResult = this.accountKV();
|
|
14601
14743
|
if (!kvResult.ok) return kvResult;
|
|
@@ -14610,7 +14752,7 @@ var AccountService = class {
|
|
|
14610
14752
|
const batchResult = await kvResult.data.batchPut(items);
|
|
14611
14753
|
if (batchResult.ok) {
|
|
14612
14754
|
await this.upsertSpacesIndexQuietly(registered);
|
|
14613
|
-
return (0,
|
|
14755
|
+
return (0, import_sdk_services8.ok)({ spaces: registered });
|
|
14614
14756
|
}
|
|
14615
14757
|
if (!isAmbiguousBatchFailure(batchResult.error)) {
|
|
14616
14758
|
return accountErr(batchResult.error);
|
|
@@ -14623,8 +14765,8 @@ var AccountService = class {
|
|
|
14623
14765
|
}
|
|
14624
14766
|
}
|
|
14625
14767
|
if (reconcileFailures.length > 0) {
|
|
14626
|
-
return (0,
|
|
14627
|
-
(0,
|
|
14768
|
+
return (0, import_sdk_services8.err)(
|
|
14769
|
+
(0, import_sdk_services8.serviceError)(
|
|
14628
14770
|
"KV_BATCH_RECONCILE_FAILED",
|
|
14629
14771
|
`KV batch write for ${items.length} space(s) failed ambiguously (${batchResult.error.message}) and per-space reconciliation also failed for: ${reconcileFailures.join("; ")}`,
|
|
14630
14772
|
SERVICE_NAME2,
|
|
@@ -14636,7 +14778,7 @@ var AccountService = class {
|
|
|
14636
14778
|
`[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}`
|
|
14637
14779
|
);
|
|
14638
14780
|
await this.upsertSpacesIndexQuietly(registered);
|
|
14639
|
-
return (0,
|
|
14781
|
+
return (0, import_sdk_services8.ok)({ spaces: registered, recoveredFromBatchError: batchResult.error });
|
|
14640
14782
|
},
|
|
14641
14783
|
/**
|
|
14642
14784
|
* Register only spaces without a registry record (TC-800). Existing
|
|
@@ -14644,7 +14786,7 @@ var AccountService = class {
|
|
|
14644
14786
|
* Bootstrap repair uses this on populated accounts.
|
|
14645
14787
|
*/
|
|
14646
14788
|
registerMissing: async (spaces) => {
|
|
14647
|
-
if (spaces.length === 0) return (0,
|
|
14789
|
+
if (spaces.length === 0) return (0, import_sdk_services8.ok)([]);
|
|
14648
14790
|
await this.config.ensureAccountSpaceHosted?.();
|
|
14649
14791
|
const kvResult = this.accountKV();
|
|
14650
14792
|
if (!kvResult.ok) return kvResult;
|
|
@@ -14660,15 +14802,15 @@ var AccountService = class {
|
|
|
14660
14802
|
const key = keys[i];
|
|
14661
14803
|
const result = byKey.get(key);
|
|
14662
14804
|
if (!result) {
|
|
14663
|
-
return (0,
|
|
14664
|
-
|
|
14805
|
+
return (0, import_sdk_services8.err)((0, import_sdk_services8.serviceError)(
|
|
14806
|
+
import_sdk_services8.ErrorCodes.NETWORK_ERROR,
|
|
14665
14807
|
`KV batch read omitted requested key ${JSON.stringify(key)}`,
|
|
14666
14808
|
SERVICE_NAME2
|
|
14667
14809
|
));
|
|
14668
14810
|
}
|
|
14669
14811
|
if (result.ok) {
|
|
14670
14812
|
final[i] = spaceFromRecord(key, result.data.data);
|
|
14671
|
-
} else if (result.error.code ===
|
|
14813
|
+
} else if (result.error.code === import_sdk_services8.ErrorCodes.KV_NOT_FOUND) {
|
|
14672
14814
|
missing.push({ index: i, key, record: stored[i] });
|
|
14673
14815
|
} else {
|
|
14674
14816
|
return accountErr(result.error);
|
|
@@ -14676,21 +14818,21 @@ var AccountService = class {
|
|
|
14676
14818
|
}
|
|
14677
14819
|
const creates = await Promise.all(missing.map(async ({ index, key, record: record2 }) => {
|
|
14678
14820
|
const written = await kv.put(key, record2, { ifNoneMatch: "*" });
|
|
14679
|
-
if (written.ok) return { index, result: (0,
|
|
14821
|
+
if (written.ok) return { index, result: (0, import_sdk_services8.ok)(spaceFromRecord(key, record2)) };
|
|
14680
14822
|
const raced = await kv.get(key);
|
|
14681
|
-
if (raced.ok) return { index, result: (0,
|
|
14682
|
-
return { index, result: (0,
|
|
14823
|
+
if (raced.ok) return { index, result: (0, import_sdk_services8.ok)(spaceFromRecord(key, raced.data.data)) };
|
|
14824
|
+
return { index, result: (0, import_sdk_services8.err)(written.error) };
|
|
14683
14825
|
}));
|
|
14684
14826
|
for (const { index, result } of creates) {
|
|
14685
14827
|
if (!result.ok) return accountErr(result.error);
|
|
14686
14828
|
final[index] = result.data;
|
|
14687
14829
|
}
|
|
14688
14830
|
await this.upsertSpacesIndexQuietly(final);
|
|
14689
|
-
return (0,
|
|
14831
|
+
return (0, import_sdk_services8.ok)(final);
|
|
14690
14832
|
},
|
|
14691
14833
|
syncAccessible: async () => {
|
|
14692
14834
|
const synced = await this.syncAccessibleSpaces({ tolerateStorageFull: false });
|
|
14693
|
-
return synced.ok ? (0,
|
|
14835
|
+
return synced.ok ? (0, import_sdk_services8.ok)(synced.data.spaces) : synced;
|
|
14694
14836
|
},
|
|
14695
14837
|
remove: async (spaceId) => {
|
|
14696
14838
|
const kvResult = this.accountKV();
|
|
@@ -14698,21 +14840,21 @@ var AccountService = class {
|
|
|
14698
14840
|
const removed = await kvResult.data.delete(spaceKey(spaceId));
|
|
14699
14841
|
if (!removed.ok) return accountErr(removed.error);
|
|
14700
14842
|
await this.deleteSpaceIndexQuietly(spaceId);
|
|
14701
|
-
return (0,
|
|
14843
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
14702
14844
|
}
|
|
14703
14845
|
};
|
|
14704
14846
|
this.delegations = {
|
|
14705
14847
|
query: async (options2 = {}) => {
|
|
14706
14848
|
const manager = this.config.getDelegationManager?.();
|
|
14707
14849
|
if (!manager) {
|
|
14708
|
-
return (0,
|
|
14850
|
+
return (0, import_sdk_services8.err)((0, import_sdk_services8.serviceError)(
|
|
14709
14851
|
"NOT_INITIALIZED",
|
|
14710
14852
|
"Delegation history requires an authenticated delegation manager",
|
|
14711
14853
|
SERVICE_NAME2
|
|
14712
14854
|
));
|
|
14713
14855
|
}
|
|
14714
14856
|
const queried = await manager.query(options2);
|
|
14715
|
-
return queried.ok ? (0,
|
|
14857
|
+
return queried.ok ? (0, import_sdk_services8.ok)(queried.data) : accountErr(queried.error);
|
|
14716
14858
|
},
|
|
14717
14859
|
list: async (options2 = {}) => {
|
|
14718
14860
|
if (options2.preferIndex) {
|
|
@@ -14746,17 +14888,17 @@ var AccountService = class {
|
|
|
14746
14888
|
}
|
|
14747
14889
|
}
|
|
14748
14890
|
delegations.sort((a, b) => a.spaceId.localeCompare(b.spaceId) || a.cid.localeCompare(b.cid));
|
|
14749
|
-
return (0,
|
|
14891
|
+
return (0, import_sdk_services8.ok)(delegations);
|
|
14750
14892
|
},
|
|
14751
14893
|
revoke: async (input) => {
|
|
14752
14894
|
const cid2 = typeof input === "string" ? input : input.cid;
|
|
14753
14895
|
const manager = this.config.getDelegationManager?.();
|
|
14754
14896
|
if (manager) {
|
|
14755
14897
|
const revoked2 = await manager.revoke(cid2);
|
|
14756
|
-
return revoked2.ok ? (0,
|
|
14898
|
+
return revoked2.ok ? (0, import_sdk_services8.ok)(revoked2.data) : accountErr(revoked2.error);
|
|
14757
14899
|
}
|
|
14758
14900
|
if (typeof input === "string") {
|
|
14759
|
-
return (0,
|
|
14901
|
+
return (0, import_sdk_services8.err)((0, import_sdk_services8.serviceError)(
|
|
14760
14902
|
"NOT_INITIALIZED",
|
|
14761
14903
|
"CID-only revocation requires an authenticated delegation manager",
|
|
14762
14904
|
SERVICE_NAME2
|
|
@@ -14766,7 +14908,7 @@ var AccountService = class {
|
|
|
14766
14908
|
if (!space.ok) return space;
|
|
14767
14909
|
const revoked = await this.config.getSpaces().get(space.data.id).delegations.revoke(cid2);
|
|
14768
14910
|
if (!revoked.ok) return accountErr(revoked.error);
|
|
14769
|
-
return (0,
|
|
14911
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
14770
14912
|
}
|
|
14771
14913
|
};
|
|
14772
14914
|
this.index = {
|
|
@@ -14775,7 +14917,7 @@ var AccountService = class {
|
|
|
14775
14917
|
if (!dbResult.ok) return dbResult;
|
|
14776
14918
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
14777
14919
|
if (!schema.ok) return schema;
|
|
14778
|
-
return (0,
|
|
14920
|
+
return (0, import_sdk_services8.ok)({ database: ACCOUNT_INDEX_DB });
|
|
14779
14921
|
},
|
|
14780
14922
|
rebuild: async () => {
|
|
14781
14923
|
const dbResult = this.accountDb();
|
|
@@ -14857,7 +14999,7 @@ var AccountService = class {
|
|
|
14857
14999
|
];
|
|
14858
15000
|
const rebuilt = await dbResult.data.batch(statements);
|
|
14859
15001
|
if (!rebuilt.ok) return accountErr(rebuilt.error);
|
|
14860
|
-
return (0,
|
|
15002
|
+
return (0, import_sdk_services8.ok)({
|
|
14861
15003
|
database: ACCOUNT_INDEX_DB,
|
|
14862
15004
|
applications: applications.data.length,
|
|
14863
15005
|
spaces: spaces.data.length,
|
|
@@ -14873,7 +15015,7 @@ var AccountService = class {
|
|
|
14873
15015
|
"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"
|
|
14874
15016
|
);
|
|
14875
15017
|
if (!queried.ok) return accountErr(queried.error);
|
|
14876
|
-
return (0,
|
|
15018
|
+
return (0, import_sdk_services8.ok)(queried.data.rows.map(indexedApplicationFromRow));
|
|
14877
15019
|
}
|
|
14878
15020
|
},
|
|
14879
15021
|
spaces: {
|
|
@@ -14884,7 +15026,7 @@ var AccountService = class {
|
|
|
14884
15026
|
"SELECT space_id, name, owner_did, type, permissions_json, status, registered_at, updated_at, expires_at FROM spaces ORDER BY name, space_id"
|
|
14885
15027
|
);
|
|
14886
15028
|
if (!queried.ok) return accountErr(queried.error);
|
|
14887
|
-
return (0,
|
|
15029
|
+
return (0, import_sdk_services8.ok)(queried.data.rows.map(indexedSpaceFromRow));
|
|
14888
15030
|
}
|
|
14889
15031
|
},
|
|
14890
15032
|
delegations: {
|
|
@@ -14906,7 +15048,7 @@ var AccountService = class {
|
|
|
14906
15048
|
params
|
|
14907
15049
|
);
|
|
14908
15050
|
if (!queried.ok) return accountErr(queried.error);
|
|
14909
|
-
return (0,
|
|
15051
|
+
return (0, import_sdk_services8.ok)(queried.data.rows.map(indexedDelegationFromRow));
|
|
14910
15052
|
}
|
|
14911
15053
|
},
|
|
14912
15054
|
query: async (sql, params) => {
|
|
@@ -14914,7 +15056,7 @@ var AccountService = class {
|
|
|
14914
15056
|
if (!dbResult.ok) return dbResult;
|
|
14915
15057
|
const queried = await dbResult.data.query(sql, params);
|
|
14916
15058
|
if (!queried.ok) return accountErr(queried.error);
|
|
14917
|
-
return (0,
|
|
15059
|
+
return (0, import_sdk_services8.ok)(queried.data);
|
|
14918
15060
|
},
|
|
14919
15061
|
status: async () => {
|
|
14920
15062
|
const dbResult = this.accountDb();
|
|
@@ -14924,11 +15066,11 @@ var AccountService = class {
|
|
|
14924
15066
|
);
|
|
14925
15067
|
if (!queried.ok) {
|
|
14926
15068
|
if (isMissingIndexError(queried.error)) {
|
|
14927
|
-
return (0,
|
|
15069
|
+
return (0, import_sdk_services8.ok)({ database: ACCOUNT_INDEX_DB, state: "missing", sources: [] });
|
|
14928
15070
|
}
|
|
14929
15071
|
return accountErr(queried.error);
|
|
14930
15072
|
}
|
|
14931
|
-
return (0,
|
|
15073
|
+
return (0, import_sdk_services8.ok)({
|
|
14932
15074
|
database: ACCOUNT_INDEX_DB,
|
|
14933
15075
|
state: "ready",
|
|
14934
15076
|
sources: queried.data.rows.map(([source, syncedAt, count]) => ({
|
|
@@ -14947,7 +15089,7 @@ var AccountService = class {
|
|
|
14947
15089
|
if (!delegations.ok) return delegations;
|
|
14948
15090
|
const spaces = await this.spaces.list();
|
|
14949
15091
|
if (!spaces.ok) return spaces;
|
|
14950
|
-
return (0,
|
|
15092
|
+
return (0, import_sdk_services8.ok)({
|
|
14951
15093
|
did: this.config.getDid(),
|
|
14952
15094
|
host: this.config.getHost(),
|
|
14953
15095
|
primarySpaceId: this.config.getPrimarySpaceId(),
|
|
@@ -14961,28 +15103,28 @@ var AccountService = class {
|
|
|
14961
15103
|
accountKV() {
|
|
14962
15104
|
const accountSpaceId = this.config.getAccountSpaceId();
|
|
14963
15105
|
if (!accountSpaceId) {
|
|
14964
|
-
return (0,
|
|
14965
|
-
(0,
|
|
15106
|
+
return (0, import_sdk_services8.err)(
|
|
15107
|
+
(0, import_sdk_services8.serviceError)(
|
|
14966
15108
|
"ACCOUNT_SPACE_UNAVAILABLE",
|
|
14967
15109
|
"Account space is unavailable. Sign in with a wallet-backed profile first.",
|
|
14968
15110
|
SERVICE_NAME2
|
|
14969
15111
|
)
|
|
14970
15112
|
);
|
|
14971
15113
|
}
|
|
14972
|
-
return (0,
|
|
15114
|
+
return (0, import_sdk_services8.ok)(this.config.getSpaces().get(accountSpaceId).kv);
|
|
14973
15115
|
}
|
|
14974
15116
|
accountDb() {
|
|
14975
15117
|
const db = this.config.getAccountDb?.();
|
|
14976
15118
|
if (!db) {
|
|
14977
|
-
return (0,
|
|
14978
|
-
(0,
|
|
15119
|
+
return (0, import_sdk_services8.err)(
|
|
15120
|
+
(0, import_sdk_services8.serviceError)(
|
|
14979
15121
|
"ACCOUNT_INDEX_UNAVAILABLE",
|
|
14980
15122
|
"Account index database is unavailable. Sign in with a wallet-backed profile first.",
|
|
14981
15123
|
SERVICE_NAME2
|
|
14982
15124
|
)
|
|
14983
15125
|
);
|
|
14984
15126
|
}
|
|
14985
|
-
return (0,
|
|
15127
|
+
return (0, import_sdk_services8.ok)(db);
|
|
14986
15128
|
}
|
|
14987
15129
|
async indexHasApplicationHash(appId, manifestHash) {
|
|
14988
15130
|
const dbResult = this.accountDb();
|
|
@@ -15000,7 +15142,7 @@ var AccountService = class {
|
|
|
15000
15142
|
}
|
|
15001
15143
|
async upsertApplicationIndex(app) {
|
|
15002
15144
|
const dbResult = this.accountDb();
|
|
15003
|
-
if (!dbResult.ok) return (0,
|
|
15145
|
+
if (!dbResult.ok) return (0, import_sdk_services8.ok)(void 0);
|
|
15004
15146
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
15005
15147
|
if (!schema.ok) return schema;
|
|
15006
15148
|
const updatedAt = app.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -15022,14 +15164,14 @@ var AccountService = class {
|
|
|
15022
15164
|
}
|
|
15023
15165
|
]);
|
|
15024
15166
|
if (!written.ok) return accountErr(written.error);
|
|
15025
|
-
return (0,
|
|
15167
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
15026
15168
|
}
|
|
15027
15169
|
async deleteApplicationIndexQuietly(appId) {
|
|
15028
15170
|
await ignoreIndexFailure(() => this.deleteApplicationIndex(appId));
|
|
15029
15171
|
}
|
|
15030
15172
|
async deleteApplicationIndex(appId) {
|
|
15031
15173
|
const dbResult = this.accountDb();
|
|
15032
|
-
if (!dbResult.ok) return (0,
|
|
15174
|
+
if (!dbResult.ok) return (0, import_sdk_services8.ok)(void 0);
|
|
15033
15175
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
15034
15176
|
if (!schema.ok) return schema;
|
|
15035
15177
|
const deleted = await dbResult.data.batch([
|
|
@@ -15037,14 +15179,14 @@ var AccountService = class {
|
|
|
15037
15179
|
{ sql: "DELETE FROM application_state WHERE app_id = ?", params: [appId] }
|
|
15038
15180
|
]);
|
|
15039
15181
|
if (!deleted.ok) return accountErr(deleted.error);
|
|
15040
|
-
return (0,
|
|
15182
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
15041
15183
|
}
|
|
15042
15184
|
async upsertSpaceIndexQuietly(space) {
|
|
15043
15185
|
await ignoreIndexFailure(() => this.upsertSpaceIndex(space));
|
|
15044
15186
|
}
|
|
15045
15187
|
async upsertSpaceIndex(space) {
|
|
15046
15188
|
const dbResult = this.accountDb();
|
|
15047
|
-
if (!dbResult.ok) return (0,
|
|
15189
|
+
if (!dbResult.ok) return (0, import_sdk_services8.ok)(void 0);
|
|
15048
15190
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
15049
15191
|
if (!schema.ok) return schema;
|
|
15050
15192
|
const updatedAt = space.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -15065,7 +15207,7 @@ var AccountService = class {
|
|
|
15065
15207
|
}
|
|
15066
15208
|
]);
|
|
15067
15209
|
if (!written.ok) return accountErr(written.error);
|
|
15068
|
-
return (0,
|
|
15210
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
15069
15211
|
}
|
|
15070
15212
|
async upsertSpacesIndexQuietly(spaces) {
|
|
15071
15213
|
await ignoreIndexFailure(() => this.upsertSpacesIndex(spaces));
|
|
@@ -15079,9 +15221,9 @@ var AccountService = class {
|
|
|
15079
15221
|
* atomically: all rows or none.
|
|
15080
15222
|
*/
|
|
15081
15223
|
async upsertSpacesIndex(spaces) {
|
|
15082
|
-
if (spaces.length === 0) return (0,
|
|
15224
|
+
if (spaces.length === 0) return (0, import_sdk_services8.ok)(void 0);
|
|
15083
15225
|
const dbResult = this.accountDb();
|
|
15084
|
-
if (!dbResult.ok) return (0,
|
|
15226
|
+
if (!dbResult.ok) return (0, import_sdk_services8.ok)(void 0);
|
|
15085
15227
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
15086
15228
|
if (!schema.ok) return schema;
|
|
15087
15229
|
const placeholders = spaces.map(() => "(?, ?, ?, ?, ?, ?, ?, ?, ?)").join(", ");
|
|
@@ -15106,21 +15248,21 @@ var AccountService = class {
|
|
|
15106
15248
|
}
|
|
15107
15249
|
]);
|
|
15108
15250
|
if (!written.ok) return accountErr(written.error);
|
|
15109
|
-
return (0,
|
|
15251
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
15110
15252
|
}
|
|
15111
15253
|
async deleteSpaceIndexQuietly(spaceId) {
|
|
15112
15254
|
await ignoreIndexFailure(() => this.deleteSpaceIndex(spaceId));
|
|
15113
15255
|
}
|
|
15114
15256
|
async deleteSpaceIndex(spaceId) {
|
|
15115
15257
|
const dbResult = this.accountDb();
|
|
15116
|
-
if (!dbResult.ok) return (0,
|
|
15258
|
+
if (!dbResult.ok) return (0, import_sdk_services8.ok)(void 0);
|
|
15117
15259
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
15118
15260
|
if (!schema.ok) return schema;
|
|
15119
15261
|
const deleted = await dbResult.data.batch([
|
|
15120
15262
|
{ sql: "DELETE FROM spaces WHERE space_id = ?", params: [spaceId] }
|
|
15121
15263
|
]);
|
|
15122
15264
|
if (!deleted.ok) return accountErr(deleted.error);
|
|
15123
|
-
return (0,
|
|
15265
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
15124
15266
|
}
|
|
15125
15267
|
/**
|
|
15126
15268
|
* Register every space the session can reach and return them. With
|
|
@@ -15140,7 +15282,7 @@ var AccountService = class {
|
|
|
15140
15282
|
spaces.push(result.data);
|
|
15141
15283
|
continue;
|
|
15142
15284
|
}
|
|
15143
|
-
if (!options2.tolerateStorageFull || !(0,
|
|
15285
|
+
if (!options2.tolerateStorageFull || !(0, import_sdk_services8.isStorageFullError)(result.error)) {
|
|
15144
15286
|
return result;
|
|
15145
15287
|
}
|
|
15146
15288
|
allRegistered = false;
|
|
@@ -15148,18 +15290,18 @@ var AccountService = class {
|
|
|
15148
15290
|
const record2 = spaceRecordFromInput(space);
|
|
15149
15291
|
spaces.push(spaceFromRecord(spaceKey(record2.space_id), record2));
|
|
15150
15292
|
}
|
|
15151
|
-
return (0,
|
|
15293
|
+
return (0, import_sdk_services8.ok)({ spaces, allRegistered });
|
|
15152
15294
|
}
|
|
15153
15295
|
async resolveSpace(space) {
|
|
15154
15296
|
const listed = await this.config.getSpaces().list();
|
|
15155
15297
|
if (!listed.ok) return accountErr(listed.error);
|
|
15156
15298
|
const found = listed.data.find((candidate) => candidate.id === space || candidate.name === space);
|
|
15157
15299
|
if (!found) {
|
|
15158
|
-
return (0,
|
|
15159
|
-
(0,
|
|
15300
|
+
return (0, import_sdk_services8.err)(
|
|
15301
|
+
(0, import_sdk_services8.serviceError)("SPACE_NOT_FOUND", `No account space found for ${JSON.stringify(space)}`, SERVICE_NAME2)
|
|
15160
15302
|
);
|
|
15161
15303
|
}
|
|
15162
|
-
return (0,
|
|
15304
|
+
return (0, import_sdk_services8.ok)(found);
|
|
15163
15305
|
}
|
|
15164
15306
|
async replaceApplicationsIndexQuietly(applications) {
|
|
15165
15307
|
await ignoreIndexFailure(async () => {
|
|
@@ -15301,7 +15443,7 @@ var AccountService = class {
|
|
|
15301
15443
|
]
|
|
15302
15444
|
});
|
|
15303
15445
|
if (!migrated.ok) return accountErr(migrated.error);
|
|
15304
|
-
return (0,
|
|
15446
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
15305
15447
|
}
|
|
15306
15448
|
};
|
|
15307
15449
|
function applicationKey(appId) {
|
|
@@ -15457,17 +15599,17 @@ function mapDelegation(delegation, space, direction) {
|
|
|
15457
15599
|
};
|
|
15458
15600
|
}
|
|
15459
15601
|
function accountErr(error) {
|
|
15460
|
-
return (0,
|
|
15602
|
+
return (0, import_sdk_services8.err)((0, import_sdk_services8.serviceError)(error.code, error.message, SERVICE_NAME2, { cause: error.cause, meta: error.meta }));
|
|
15461
15603
|
}
|
|
15462
15604
|
function isMissingIndexError(error) {
|
|
15463
15605
|
return /no such table:/i.test(error.message);
|
|
15464
15606
|
}
|
|
15465
15607
|
var AMBIGUOUS_WRITE_STATUSES = /* @__PURE__ */ new Set([500, 502, 503, 504, 520, 522, 524]);
|
|
15466
15608
|
function isAmbiguousBatchFailure(error) {
|
|
15467
|
-
if (error.code ===
|
|
15609
|
+
if (error.code === import_sdk_services8.ErrorCodes.NETWORK_ERROR || error.code === import_sdk_services8.ErrorCodes.TIMEOUT) {
|
|
15468
15610
|
return error.meta?.requestMayHaveDispatched === true;
|
|
15469
15611
|
}
|
|
15470
|
-
if (error.code ===
|
|
15612
|
+
if (error.code === import_sdk_services8.ErrorCodes.KV_WRITE_FAILED) {
|
|
15471
15613
|
const status = error.meta?.status;
|
|
15472
15614
|
return typeof status === "number" && AMBIGUOUS_WRITE_STATUSES.has(status);
|
|
15473
15615
|
}
|
|
@@ -15481,7 +15623,7 @@ async function ignoreIndexFailure(task) {
|
|
|
15481
15623
|
}
|
|
15482
15624
|
|
|
15483
15625
|
// src/index.ts
|
|
15484
|
-
var
|
|
15626
|
+
var import_sdk_services10 = require("@tinycloud/sdk-services");
|
|
15485
15627
|
|
|
15486
15628
|
// src/space.ts
|
|
15487
15629
|
async function fetchPeerId(host, spaceId, signal) {
|
|
@@ -15586,7 +15728,7 @@ async function postSessionActivation(host, delegationHeader, signal) {
|
|
|
15586
15728
|
}
|
|
15587
15729
|
|
|
15588
15730
|
// src/authorization/CapabilityKeyRegistry.ts
|
|
15589
|
-
var
|
|
15731
|
+
var import_sdk_services9 = require("@tinycloud/sdk-services");
|
|
15590
15732
|
var SERVICE_NAME3 = "capability-key-registry";
|
|
15591
15733
|
var CapabilityKeyRegistryErrorCodes = {
|
|
15592
15734
|
/** Key not found in registry */
|
|
@@ -15811,8 +15953,8 @@ var CapabilityKeyRegistry = class {
|
|
|
15811
15953
|
revokeDelegation(cid2) {
|
|
15812
15954
|
const stored = this.store.byCid.get(cid2);
|
|
15813
15955
|
if (!stored || stored.length === 0) {
|
|
15814
|
-
return (0,
|
|
15815
|
-
(0,
|
|
15956
|
+
return (0, import_sdk_services9.err)(
|
|
15957
|
+
(0, import_sdk_services9.serviceError)(
|
|
15816
15958
|
CapabilityKeyRegistryErrorCodes.KEY_NOT_FOUND,
|
|
15817
15959
|
`Delegation not found: ${cid2}`,
|
|
15818
15960
|
SERVICE_NAME3
|
|
@@ -15832,7 +15974,7 @@ var CapabilityKeyRegistry = class {
|
|
|
15832
15974
|
}
|
|
15833
15975
|
}
|
|
15834
15976
|
}
|
|
15835
|
-
return (0,
|
|
15977
|
+
return (0, import_sdk_services9.ok)(void 0);
|
|
15836
15978
|
}
|
|
15837
15979
|
// ===========================================================================
|
|
15838
15980
|
// Search
|
|
@@ -16496,8 +16638,14 @@ function diffImmutableSiweFields(original, signed, options2) {
|
|
|
16496
16638
|
function extractRecapAttenuations(siwe) {
|
|
16497
16639
|
const merged = {};
|
|
16498
16640
|
const lines = siwe.split(/\r?\n/);
|
|
16641
|
+
let resources = false;
|
|
16499
16642
|
for (const line of lines) {
|
|
16500
|
-
|
|
16643
|
+
if (line === "Resources:") {
|
|
16644
|
+
resources = true;
|
|
16645
|
+
continue;
|
|
16646
|
+
}
|
|
16647
|
+
if (!resources) continue;
|
|
16648
|
+
const match = line.match(/^- urn:recap:([A-Za-z0-9_-]+=*)$/);
|
|
16501
16649
|
if (!match) continue;
|
|
16502
16650
|
const encoded = match[1];
|
|
16503
16651
|
let decodedJson;
|