@tinycloud/sdk-core 3.8.0-beta.2 → 3.8.0-beta.21
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 +469 -294
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -5
- package/dist/index.d.ts +27 -5
- package/dist/index.js +198 -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,67 @@ __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,
|
|
367
|
+
expandRuntimePermissionEntries: () => expandRuntimePermissionEntries,
|
|
366
368
|
extractImmutableSiweFields: () => extractImmutableSiweFields,
|
|
367
369
|
extractRecapAttenuations: () => extractRecapAttenuations,
|
|
368
370
|
fetchLocationRecord: () => fetchLocationRecord,
|
|
369
371
|
fetchPeerId: () => fetchPeerId,
|
|
370
|
-
generateRandomReceiverKey: () =>
|
|
372
|
+
generateRandomReceiverKey: () => import_sdk_services10.generateRandomReceiverKey,
|
|
371
373
|
getPolicyRootStatusV3: () => getPolicyRootStatusV3,
|
|
372
|
-
getTinyCloudDebugLogs: () =>
|
|
374
|
+
getTinyCloudDebugLogs: () => import_sdk_services10.getTinyCloudDebugLogs,
|
|
373
375
|
hasTinyCloudManageKeyScope: () => hasTinyCloudManageKeyScope,
|
|
374
|
-
hexDecode: () =>
|
|
375
|
-
hexEncode: () =>
|
|
376
|
+
hexDecode: () => import_sdk_services10.hexDecode,
|
|
377
|
+
hexEncode: () => import_sdk_services10.hexEncode,
|
|
376
378
|
holderBindingCanonicalBytes: () => holderBindingCanonicalBytes,
|
|
377
379
|
holderBindingSigningBytes: () => holderBindingSigningBytes,
|
|
378
380
|
httpResponseError: () => httpResponseError,
|
|
379
381
|
httpUrlToMultiaddr: () => httpUrlToMultiaddr,
|
|
380
382
|
importPortableDelegation: () => importPortableDelegation,
|
|
381
|
-
installTinyCloudDebugGlobals: () =>
|
|
383
|
+
installTinyCloudDebugGlobals: () => import_sdk_services10.installTinyCloudDebugGlobals,
|
|
382
384
|
intersectShareCapabilities: () => intersectShareCapabilities,
|
|
383
385
|
isCanonicalEmailDomain: () => import_share_envelope.isCanonicalEmailDomain,
|
|
384
386
|
isCapabilitySubset: () => isCapabilitySubset,
|
|
385
387
|
isDigest: () => isDigest,
|
|
386
388
|
isEvmAddress: () => isEvmAddress,
|
|
387
389
|
isExplicitOnlyAction: () => isExplicitOnlyAction,
|
|
388
|
-
isNetworkId: () =>
|
|
390
|
+
isNetworkId: () => import_sdk_services10.isNetworkId,
|
|
389
391
|
isPlausibleOpenKeyActionId: () => isPlausibleOpenKeyActionId,
|
|
390
|
-
isStorageFullError: () =>
|
|
392
|
+
isStorageFullError: () => import_sdk_services10.isStorageFullError,
|
|
391
393
|
isV2ShareLink: () => isV2ShareLink,
|
|
392
394
|
issuedCredentialEnvelopeFromVerified: () => issuedCredentialEnvelopeFromVerified,
|
|
393
395
|
jcsCanonicalize: () => jcsCanonicalize,
|
|
@@ -400,36 +402,36 @@ __export(index_exports, {
|
|
|
400
402
|
manifestAbilitiesUnion: () => manifestAbilitiesUnion,
|
|
401
403
|
markDelegationTerminal: () => markDelegationTerminal,
|
|
402
404
|
multiaddrToHttpUrl: () => multiaddrToHttpUrl,
|
|
403
|
-
networkDiscoveryKey: () =>
|
|
405
|
+
networkDiscoveryKey: () => import_sdk_services10.networkDiscoveryKey,
|
|
404
406
|
normalizeDefaults: () => normalizeDefaults,
|
|
405
407
|
normalizeJson: () => normalizeJson,
|
|
406
408
|
normalizeShareActions: () => normalizeShareActions,
|
|
407
409
|
normalizeShareRecipientTarget: () => normalizeShareRecipientTarget,
|
|
408
410
|
normalizeShareResource: () => normalizeShareResource,
|
|
409
411
|
normalizeUnifiedPolicyCapability: () => normalizeUnifiedPolicyCapability,
|
|
410
|
-
ok: () =>
|
|
411
|
-
openWrappedKey: () =>
|
|
412
|
+
ok: () => import_sdk_services10.ok,
|
|
413
|
+
openWrappedKey: () => import_sdk_services10.openWrappedKey,
|
|
412
414
|
parseCanonicalNetworkId: () => parseCanonicalNetworkId,
|
|
413
415
|
parseCanonicalRecapResource: () => parseCanonicalRecapResource,
|
|
414
416
|
parseCanonicalTinyCloudIdentity: () => parseCanonicalTinyCloudIdentity,
|
|
415
417
|
parseCanonicalTinyCloudIdentityClaims: () => parseCanonicalTinyCloudIdentityClaims,
|
|
416
|
-
parseCapabilityResource: () =>
|
|
418
|
+
parseCapabilityResource: () => import_sdk_services10.parseCapabilityResource,
|
|
417
419
|
parseCompactUcanAuthorization: () => parseCompactUcanAuthorization,
|
|
418
420
|
parseExpiry: () => parseExpiry,
|
|
419
|
-
parseNetworkId: () =>
|
|
421
|
+
parseNetworkId: () => import_sdk_services10.parseNetworkId,
|
|
420
422
|
parseNodeNativePortableDelegation: () => parseNodeNativePortableDelegation,
|
|
421
423
|
parsePkhDid: () => parsePkhDid,
|
|
422
424
|
parsePolicySessionUcan: () => parsePolicySessionUcan,
|
|
423
425
|
parsePortableDelegation: () => parsePortableDelegation,
|
|
424
426
|
parseRecapCapabilities: () => parseRecapCapabilities,
|
|
425
|
-
parseSecretCatalogKey: () =>
|
|
427
|
+
parseSecretCatalogKey: () => import_sdk_services10.parseSecretCatalogKey,
|
|
426
428
|
parseShareArtifact: () => parseShareArtifact,
|
|
427
429
|
parseShareUrl: () => parseShareUrl,
|
|
428
430
|
parseSignedCompactUcanAttenuation: () => parseSignedCompactUcanAttenuation,
|
|
429
431
|
parseSignedSiweCacao: () => parseSignedSiweCacao,
|
|
430
432
|
parseSpaceUri: () => parseSpaceUri,
|
|
431
|
-
parseStorageRejection: () =>
|
|
432
|
-
parseStorageStatus: () =>
|
|
433
|
+
parseStorageRejection: () => import_sdk_services10.parseStorageRejection,
|
|
434
|
+
parseStorageStatus: () => import_sdk_services10.parseStorageStatus,
|
|
433
435
|
pkhDid: () => pkhDid,
|
|
434
436
|
policyCidFromCanonicalBytes: () => policyCidFromCanonicalBytes,
|
|
435
437
|
policyDigestHex: () => policyDigestHex,
|
|
@@ -450,8 +452,8 @@ __export(index_exports, {
|
|
|
450
452
|
resolveManifest: () => resolveManifest,
|
|
451
453
|
resolveManifestKnowledgeRoot: () => resolveManifestKnowledgeRoot,
|
|
452
454
|
resolveOwnerHosts: () => resolveOwnerHosts,
|
|
453
|
-
resolveSecretListPrefix: () =>
|
|
454
|
-
resolveSecretPath: () =>
|
|
455
|
+
resolveSecretListPrefix: () => import_sdk_services10.resolveSecretListPrefix,
|
|
456
|
+
resolveSecretPath: () => import_sdk_services10.resolveSecretPath,
|
|
455
457
|
resolveTinyCloudHosts: () => resolveTinyCloudHosts,
|
|
456
458
|
resourceCapabilitiesToAbilitiesMap: () => resourceCapabilitiesToAbilitiesMap,
|
|
457
459
|
resourceCapabilitiesToSpaceAbilitiesMap: () => resourceCapabilitiesToSpaceAbilitiesMap,
|
|
@@ -459,7 +461,7 @@ __export(index_exports, {
|
|
|
459
461
|
revokePolicyRootV3: () => revokePolicyRootV3,
|
|
460
462
|
serializeJcsJson: () => serialize,
|
|
461
463
|
serializePortableDelegation: () => serializePortableDelegation,
|
|
462
|
-
serviceError: () =>
|
|
464
|
+
serviceError: () => import_sdk_services10.serviceError,
|
|
463
465
|
sha256Base64Url: () => sha256Base64Url,
|
|
464
466
|
shareCapabilityAllows: () => shareCapabilityAllows,
|
|
465
467
|
shortDeliveryLinkBodyCid: () => shortDeliveryLinkBodyCid,
|
|
@@ -470,9 +472,9 @@ __export(index_exports, {
|
|
|
470
472
|
signPolicyCredentialPresentationV4: () => signPolicyCredentialPresentationV4,
|
|
471
473
|
signShareEnvelope: () => signShareEnvelope,
|
|
472
474
|
signedObjectIdFor: () => signedObjectIdFor,
|
|
473
|
-
storageUsageState: () =>
|
|
475
|
+
storageUsageState: () => import_sdk_services10.storageUsageState,
|
|
474
476
|
submitHostDelegation: () => submitHostDelegation,
|
|
475
|
-
tinyCloudDebugLogger: () =>
|
|
477
|
+
tinyCloudDebugLogger: () => import_sdk_services10.tinyCloudDebugLogger,
|
|
476
478
|
toSignedObjectError: () => toSignedObjectError,
|
|
477
479
|
unauthorizedRecapCapabilities: () => unauthorizedRecapCapabilities,
|
|
478
480
|
unifiedNativeProjectionHashHex: () => unifiedNativeProjectionHashHex,
|
|
@@ -484,7 +486,7 @@ __export(index_exports, {
|
|
|
484
486
|
validateCredentialFlowDescriptor: () => validateCredentialFlowDescriptor,
|
|
485
487
|
validateCredentialHolderBinding: () => validateCredentialHolderBinding,
|
|
486
488
|
validateCredentialRequirement: () => validateCredentialRequirement,
|
|
487
|
-
validateEnvelope: () =>
|
|
489
|
+
validateEnvelope: () => import_sdk_services10.validateEnvelope,
|
|
488
490
|
validateLocationRecord: () => validateLocationRecord,
|
|
489
491
|
validateLocationRecordPayload: () => validateLocationRecordPayload,
|
|
490
492
|
validateManifest: () => validateManifest,
|
|
@@ -502,8 +504,8 @@ __export(index_exports, {
|
|
|
502
504
|
validatePolicyStatusUnsigned: () => validatePolicyStatusUnsigned,
|
|
503
505
|
validatePolicyUnsigned: () => validatePolicyUnsigned,
|
|
504
506
|
validateUnifiedPolicyV2: () => validateUnifiedPolicyV2,
|
|
505
|
-
validatedCapabilityOf: () =>
|
|
506
|
-
verifyDecryptResponse: () =>
|
|
507
|
+
validatedCapabilityOf: () => import_sdk_services10.validatedCapabilityOf,
|
|
508
|
+
verifyDecryptResponse: () => import_sdk_services10.verifyDecryptResponse,
|
|
507
509
|
verifyDidKeyEd25519Signature: () => verifyDidKeyEd25519Signature,
|
|
508
510
|
verifyEip191MessageSignature: () => verifyEip191MessageSignature,
|
|
509
511
|
verifyIssuedCredential: () => verifyIssuedCredential,
|
|
@@ -3947,6 +3949,7 @@ var import_sha256 = require("@noble/hashes/sha256");
|
|
|
3947
3949
|
var import_blake3 = require("@noble/hashes/blake3");
|
|
3948
3950
|
var import_ed255193 = require("@noble/curves/ed25519");
|
|
3949
3951
|
var import_zod2 = require("zod");
|
|
3952
|
+
var import_sdk_services2 = require("@tinycloud/sdk-services");
|
|
3950
3953
|
|
|
3951
3954
|
// src/http-error.ts
|
|
3952
3955
|
var import_sdk_services = require("@tinycloud/sdk-services");
|
|
@@ -4215,12 +4218,9 @@ function parseKvResource(resource) {
|
|
|
4215
4218
|
return { space, path };
|
|
4216
4219
|
}
|
|
4217
4220
|
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("#")) {
|
|
4221
|
+
try {
|
|
4222
|
+
if ((0, import_sdk_services2.parseEncryptionResource)(resource).keyPath?.endsWith("/")) throw new Error("prefix");
|
|
4223
|
+
} catch {
|
|
4224
4224
|
throw new Error("encryption capability is invalid");
|
|
4225
4225
|
}
|
|
4226
4226
|
}
|
|
@@ -6687,7 +6687,11 @@ var DelegationErrorCodes = {
|
|
|
6687
6687
|
KV_SERVICE_UNAVAILABLE: "KV_SERVICE_UNAVAILABLE",
|
|
6688
6688
|
DATA_FETCH_FAILED: "DATA_FETCH_FAILED",
|
|
6689
6689
|
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
6690
|
-
UNSUPPORTED_OPERATION: "UNSUPPORTED_OPERATION"
|
|
6690
|
+
UNSUPPORTED_OPERATION: "UNSUPPORTED_OPERATION",
|
|
6691
|
+
/** The node answered 503: the delegation chain is too deep to evaluate right now. Retry later. */
|
|
6692
|
+
CHAIN_TOO_DEEP: "CHAIN_TOO_DEEP",
|
|
6693
|
+
/** The node answered 400 "invalid delegation query cursor": malformed, foreign or from another filter. Start the listing again without it. */
|
|
6694
|
+
INVALID_CURSOR: "INVALID_CURSOR"
|
|
6691
6695
|
};
|
|
6692
6696
|
var DelegationSchema = import_zod4.z.object({
|
|
6693
6697
|
/** Content identifier (CID) of the delegation */
|
|
@@ -6764,7 +6768,7 @@ var AccountDelegationPageSchema = import_zod4.z.object({
|
|
|
6764
6768
|
nextCursor: import_zod4.z.string().optional()
|
|
6765
6769
|
}).strict();
|
|
6766
6770
|
var AccountDelegationQueryOptionsSchema = import_zod4.z.object({
|
|
6767
|
-
direction: import_zod4.z.enum(["granted", "received", "all"]).optional(),
|
|
6771
|
+
direction: import_zod4.z.enum(["granted", "received", "all", "issued"]).optional(),
|
|
6768
6772
|
status: import_zod4.z.enum(["active", "pending", "expired", "revoked", "ancestor_revoked"]).optional(),
|
|
6769
6773
|
space: import_zod4.z.string().trim().min(1).optional(),
|
|
6770
6774
|
limit: import_zod4.z.number().int().min(1).max(100).optional(),
|
|
@@ -6950,6 +6954,8 @@ var DelegationManagerConfigSchema = import_zod4.z.object({
|
|
|
6950
6954
|
).optional(),
|
|
6951
6955
|
/** Optional owner-signed authorization for direct CID revocation */
|
|
6952
6956
|
signOwnerRevocation: import_zod4.z.custom().optional(),
|
|
6957
|
+
/** Optional signer for proofless invocations by the session's own did:key (issued-delegation list and revoke) */
|
|
6958
|
+
sessionInvocationSigner: import_zod4.z.custom().optional(),
|
|
6953
6959
|
/** Optional custom fetch implementation */
|
|
6954
6960
|
fetch: import_zod4.z.unknown().refine(
|
|
6955
6961
|
(val) => val === void 0 || typeof val === "function",
|
|
@@ -7045,7 +7051,7 @@ var CreateDelegationWasmResultSchema = import_zod4.z.object({
|
|
|
7045
7051
|
resources: import_zod4.z.array(DelegatedResourceSchema)
|
|
7046
7052
|
});
|
|
7047
7053
|
|
|
7048
|
-
// src/delegations/
|
|
7054
|
+
// src/delegations/shared.ts
|
|
7049
7055
|
var DelegationAction = {
|
|
7050
7056
|
REVOKE: "tinycloud.delegation/revoke",
|
|
7051
7057
|
STATUS: "tinycloud.delegation/status",
|
|
@@ -7062,6 +7068,8 @@ function createError(code3, message, cause, meta) {
|
|
|
7062
7068
|
meta
|
|
7063
7069
|
};
|
|
7064
7070
|
}
|
|
7071
|
+
|
|
7072
|
+
// src/delegations/DelegationManager.ts
|
|
7065
7073
|
async function readInvokedJson(response, action) {
|
|
7066
7074
|
const text3 = await response.text();
|
|
7067
7075
|
if (text3.trim() === "") {
|
|
@@ -7084,11 +7092,13 @@ var DelegationManager = class {
|
|
|
7084
7092
|
* @param config - Configuration including hosts, session, and invoke function
|
|
7085
7093
|
*/
|
|
7086
7094
|
constructor(config) {
|
|
7095
|
+
this.issuedState = { issuedQuerySupported: false };
|
|
7087
7096
|
this.hosts = config.hosts;
|
|
7088
7097
|
this.session = config.session;
|
|
7089
7098
|
this.invoke = config.invoke;
|
|
7090
7099
|
this.invokeAny = config.invokeAny;
|
|
7091
7100
|
this.signOwnerRevocation = config.signOwnerRevocation;
|
|
7101
|
+
this.sessionInvocationSigner = config.sessionInvocationSigner;
|
|
7092
7102
|
this.fetchFn = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
7093
7103
|
this.accountSpaceId = config.accountSpaceId;
|
|
7094
7104
|
}
|
|
@@ -7311,8 +7321,14 @@ var DelegationManager = class {
|
|
|
7311
7321
|
};
|
|
7312
7322
|
}
|
|
7313
7323
|
}
|
|
7314
|
-
/**
|
|
7315
|
-
|
|
7324
|
+
/**
|
|
7325
|
+
* Query lifecycle-complete delegation history for the authenticated account.
|
|
7326
|
+
*
|
|
7327
|
+
* `scope.spaces` lists the spaces to sign `tinycloud.delegation/list` for, in order. Omitted, the
|
|
7328
|
+
* account space is tried, then the session's own space. A caller that knows which of them the session
|
|
7329
|
+
* holds passes only those; an empty list sends nothing and answers PERMISSION_DENIED.
|
|
7330
|
+
*/
|
|
7331
|
+
async query(options2 = {}, scope = {}) {
|
|
7316
7332
|
const validated = AccountDelegationQueryOptionsSchema.safeParse(options2);
|
|
7317
7333
|
if (!validated.success) {
|
|
7318
7334
|
return {
|
|
@@ -7325,6 +7341,7 @@ var DelegationManager = class {
|
|
|
7325
7341
|
)
|
|
7326
7342
|
};
|
|
7327
7343
|
}
|
|
7344
|
+
if (validated.data.direction === "issued") return this.queryIssued(validated.data);
|
|
7328
7345
|
if (!this.invokeAny) {
|
|
7329
7346
|
return {
|
|
7330
7347
|
ok: false,
|
|
@@ -7346,7 +7363,7 @@ var DelegationManager = class {
|
|
|
7346
7363
|
}
|
|
7347
7364
|
try {
|
|
7348
7365
|
let response;
|
|
7349
|
-
for (const spaceId of
|
|
7366
|
+
for (const spaceId of new Set(scope.spaces ?? [accountSpaceId, this.session.spaceId])) {
|
|
7350
7367
|
const headers = Object.fromEntries(new Headers(this.invokeAny(this.session, [{
|
|
7351
7368
|
spaceId,
|
|
7352
7369
|
service: "delegation",
|
|
@@ -7406,6 +7423,45 @@ var DelegationManager = class {
|
|
|
7406
7423
|
};
|
|
7407
7424
|
}
|
|
7408
7425
|
}
|
|
7426
|
+
/** The state the lazily loaded issued-delegation module reads and updates. */
|
|
7427
|
+
issuedContext() {
|
|
7428
|
+
return {
|
|
7429
|
+
host: this.host,
|
|
7430
|
+
fetchFn: this.fetchFn,
|
|
7431
|
+
sessionInvocationSigner: this.sessionInvocationSigner,
|
|
7432
|
+
state: this.issuedState
|
|
7433
|
+
};
|
|
7434
|
+
}
|
|
7435
|
+
/**
|
|
7436
|
+
* Lists the delegations this session's own key issued (`direction: "issued"`).
|
|
7437
|
+
* The implementation loads on first use.
|
|
7438
|
+
*/
|
|
7439
|
+
async queryIssued(options2) {
|
|
7440
|
+
const issued = await import("@tinycloud/sdk-core/delegations/issued");
|
|
7441
|
+
return issued.queryIssued(this.issuedContext(), options2);
|
|
7442
|
+
}
|
|
7443
|
+
/**
|
|
7444
|
+
* Every delegation this session's key issued, following `nextCursor` until
|
|
7445
|
+
* it is absent. `maxItems` stops early once that many are collected;
|
|
7446
|
+
* `untilCid` stops after the page that contains that delegation. Items come
|
|
7447
|
+
* in CID order (each carries `issuedAt`). The implementation loads on first use.
|
|
7448
|
+
*/
|
|
7449
|
+
async queryAllIssued(options2 = {}) {
|
|
7450
|
+
const issued = await import("@tinycloud/sdk-core/delegations/issued");
|
|
7451
|
+
return issued.queryAllIssued((page) => this.query(page), options2);
|
|
7452
|
+
}
|
|
7453
|
+
/**
|
|
7454
|
+
* Revokes a delegation this session's key issued, with no proof: a UCAN
|
|
7455
|
+
* signed by the session's own did:key carrying `urn:cid:<cid>` and
|
|
7456
|
+
* `tinycloud.delegation/revoke`. Revoking a delegation that is already revoked
|
|
7457
|
+
* succeeds. A refusal (the key is not the delegator) carries the node's
|
|
7458
|
+
* message; 503 means the chain is too deep right now, retry later.
|
|
7459
|
+
* The implementation loads on first use.
|
|
7460
|
+
*/
|
|
7461
|
+
async revokeIssued(cid2) {
|
|
7462
|
+
const issued = await import("@tinycloud/sdk-core/delegations/issued");
|
|
7463
|
+
return issued.revokeIssued(this.issuedContext(), cid2);
|
|
7464
|
+
}
|
|
7409
7465
|
/**
|
|
7410
7466
|
* Gets the full delegation chain for a given delegation.
|
|
7411
7467
|
*
|
|
@@ -7712,7 +7768,8 @@ function validateEncodedShareData(data) {
|
|
|
7712
7768
|
// src/manifest.ts
|
|
7713
7769
|
var import_ms = __toESM(require("ms"), 1);
|
|
7714
7770
|
var import_bootstrap2 = require("@tinycloud/bootstrap");
|
|
7715
|
-
var
|
|
7771
|
+
var import_sdk_services3 = require("@tinycloud/sdk-services");
|
|
7772
|
+
var import_resource = require("@tinycloud/sdk-services/encryption/resource");
|
|
7716
7773
|
var DEFAULT_KNOWLEDGE_ROOT = "knowledge/index.md";
|
|
7717
7774
|
var ManifestValidationError = class extends Error {
|
|
7718
7775
|
constructor(message) {
|
|
@@ -7835,6 +7892,16 @@ function expandEncryptionPermissionEntry(entry) {
|
|
|
7835
7892
|
`tinycloud.encryption entries require path to be a networkId URN (got ${JSON.stringify(entry.path)})`
|
|
7836
7893
|
);
|
|
7837
7894
|
}
|
|
7895
|
+
const sharePrefix = entry.path.endsWith("/share/");
|
|
7896
|
+
if (entry.path.includes("/") && !sharePrefix) {
|
|
7897
|
+
throw new ManifestValidationError("named keys go in manifest.keys");
|
|
7898
|
+
}
|
|
7899
|
+
try {
|
|
7900
|
+
const network = (0, import_sdk_services3.parseNetworkId)(sharePrefix ? entry.path.slice(0, -"/share/".length) : entry.path);
|
|
7901
|
+
if (sharePrefix && network.name !== "default") throw new Error("share prefix requires default network");
|
|
7902
|
+
} catch {
|
|
7903
|
+
throw new ManifestValidationError("tinycloud.encryption entries require a valid networkId URN");
|
|
7904
|
+
}
|
|
7838
7905
|
const normalizedActions = [];
|
|
7839
7906
|
for (const action of entry.actions) {
|
|
7840
7907
|
if (action === "decrypt" || action === "tinycloud.encryption/decrypt") {
|
|
@@ -7866,6 +7933,9 @@ function expandEncryptionPermissionEntry(entry) {
|
|
|
7866
7933
|
seen.add(a);
|
|
7867
7934
|
}
|
|
7868
7935
|
}
|
|
7936
|
+
if (sharePrefix && dedupedActions.some((action) => action !== "tinycloud.encryption/decrypt")) {
|
|
7937
|
+
throw new ManifestValidationError("share prefix only supports decrypt");
|
|
7938
|
+
}
|
|
7869
7939
|
return [
|
|
7870
7940
|
{
|
|
7871
7941
|
service: ENCRYPTION_PERMISSION_SERVICE,
|
|
@@ -7881,6 +7951,55 @@ function expandEncryptionPermissionEntry(entry) {
|
|
|
7881
7951
|
function expandPermissionEntries(entries) {
|
|
7882
7952
|
return entries.flatMap(expandPermissionEntry);
|
|
7883
7953
|
}
|
|
7954
|
+
function expandRuntimePermissionEntries(entries, ownerDid) {
|
|
7955
|
+
return entries.flatMap((entry) => {
|
|
7956
|
+
if (entry.service !== ENCRYPTION_PERMISSION_SERVICE || typeof entry.path !== "string" || !entry.path.includes("/") || entry.path.endsWith("/share/")) {
|
|
7957
|
+
return expandPermissionEntry(entry);
|
|
7958
|
+
}
|
|
7959
|
+
let resource;
|
|
7960
|
+
let ownerNetwork;
|
|
7961
|
+
try {
|
|
7962
|
+
resource = (0, import_resource.parseEncryptionResource)(entry.path);
|
|
7963
|
+
if (typeof ownerDid !== "string" || ownerDid.length === 0) throw new Error("missing owner");
|
|
7964
|
+
ownerNetwork = (0, import_resource.parseEncryptionResource)(`urn:tinycloud:encryption:${ownerDid}:default`);
|
|
7965
|
+
} catch {
|
|
7966
|
+
throw new ManifestValidationError("runtime Share key creation requires a canonical current-owner key resource");
|
|
7967
|
+
}
|
|
7968
|
+
if (resource.kind !== "key" || resource.networkId !== ownerNetwork.networkId || !/^share\/[^/]+$/.test(resource.path) || entry.space !== void 0 && entry.space !== ENCRYPTION_MANIFEST_SPACE || !Array.isArray(entry.actions) || entry.actions.length === 0 || entry.actions.some((action) => action !== "key.create" && action !== "tinycloud.encryption/key.create")) {
|
|
7969
|
+
throw new ManifestValidationError("runtime Share key creation requires the current owner's exact default/share/<id> key and key.create only");
|
|
7970
|
+
}
|
|
7971
|
+
return [{
|
|
7972
|
+
...entry,
|
|
7973
|
+
space: ENCRYPTION_MANIFEST_SPACE,
|
|
7974
|
+
path: `${resource.networkId}/${resource.path}`,
|
|
7975
|
+
actions: ["tinycloud.encryption/key.create"],
|
|
7976
|
+
skipPrefix: true
|
|
7977
|
+
}];
|
|
7978
|
+
});
|
|
7979
|
+
}
|
|
7980
|
+
function expandDelegationPermissionEntries(entries) {
|
|
7981
|
+
return entries.flatMap((entry) => {
|
|
7982
|
+
if (entry.service !== ENCRYPTION_PERMISSION_SERVICE || typeof entry.path !== "string" || !entry.path.includes("/")) {
|
|
7983
|
+
return expandPermissionEntry(entry);
|
|
7984
|
+
}
|
|
7985
|
+
let resource;
|
|
7986
|
+
try {
|
|
7987
|
+
resource = (0, import_resource.parseEncryptionResource)(entry.path);
|
|
7988
|
+
} catch {
|
|
7989
|
+
throw new ManifestValidationError("delegation requires a canonical exact named-key resource");
|
|
7990
|
+
}
|
|
7991
|
+
if (resource.kind !== "key" || !Array.isArray(entry.actions) || entry.actions.length === 0 || entry.actions.some((action) => action !== "decrypt" && action !== "tinycloud.encryption/decrypt")) {
|
|
7992
|
+
throw new ManifestValidationError("named-key delegation requires an exact key and decrypt only");
|
|
7993
|
+
}
|
|
7994
|
+
return [{
|
|
7995
|
+
...entry,
|
|
7996
|
+
space: ENCRYPTION_MANIFEST_SPACE,
|
|
7997
|
+
path: `${resource.networkId}/${resource.path}`,
|
|
7998
|
+
actions: ["tinycloud.encryption/decrypt"],
|
|
7999
|
+
skipPrefix: true
|
|
8000
|
+
}];
|
|
8001
|
+
});
|
|
8002
|
+
}
|
|
7884
8003
|
function applyPrefix(prefix, path, skipPrefix) {
|
|
7885
8004
|
if (skipPrefix) {
|
|
7886
8005
|
return path;
|
|
@@ -7959,8 +8078,56 @@ function validateManifest(input) {
|
|
|
7959
8078
|
if (m.secrets !== void 0) {
|
|
7960
8079
|
validateManifestSecrets(m.secrets);
|
|
7961
8080
|
}
|
|
8081
|
+
if (Object.prototype.hasOwnProperty.call(m, "keys_app_id") && (typeof m.keys_app_id !== "string" || !KEY_APP_ID.test(m.keys_app_id))) {
|
|
8082
|
+
throw new ManifestValidationError("manifest.keys_app_id is invalid");
|
|
8083
|
+
}
|
|
8084
|
+
validateManifestKeys(m.keys_app_id ?? m.app_id, m.keys);
|
|
7962
8085
|
return m;
|
|
7963
8086
|
}
|
|
8087
|
+
var KEY_SEGMENT = "[a-z0-9][a-z0-9._-]{0,63}";
|
|
8088
|
+
var KEY_APP_ID = new RegExp(`^${KEY_SEGMENT}$`);
|
|
8089
|
+
var KEY_PATH = new RegExp(`^${KEY_SEGMENT}(?:/${KEY_SEGMENT}){2,7}$`);
|
|
8090
|
+
var KEY_ABILITIES = ["key.create", "decrypt", "key.block", "key.unblock"];
|
|
8091
|
+
function validateManifestKeys(appId, keys) {
|
|
8092
|
+
if (keys === void 0) return;
|
|
8093
|
+
if (!Array.isArray(keys) || keys.length > 32) {
|
|
8094
|
+
throw new ManifestValidationError("manifest.keys must contain at most 32 entries");
|
|
8095
|
+
}
|
|
8096
|
+
if (keys.length === 0) return;
|
|
8097
|
+
if (!KEY_APP_ID.test(appId)) {
|
|
8098
|
+
throw new ManifestValidationError("manifest.keys requires a valid app_id");
|
|
8099
|
+
}
|
|
8100
|
+
const paths = /* @__PURE__ */ new Set();
|
|
8101
|
+
let prefixSeen = false;
|
|
8102
|
+
for (const [index, value] of keys.entries()) {
|
|
8103
|
+
const label = `manifest.keys[${index}]`;
|
|
8104
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
8105
|
+
throw new ManifestValidationError(`${label} must be an object`);
|
|
8106
|
+
}
|
|
8107
|
+
const entry = value;
|
|
8108
|
+
const fields = Object.keys(entry);
|
|
8109
|
+
const hasPath = Object.prototype.hasOwnProperty.call(entry, "path");
|
|
8110
|
+
const hasPrefix = Object.prototype.hasOwnProperty.call(entry, "prefix");
|
|
8111
|
+
if (hasPath === hasPrefix || fields.some((field) => !["path", "prefix", "abilities"].includes(field))) {
|
|
8112
|
+
throw new ManifestValidationError(`${label} must have one path or prefix and abilities`);
|
|
8113
|
+
}
|
|
8114
|
+
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))) {
|
|
8115
|
+
throw new ManifestValidationError(`${label}.abilities is invalid`);
|
|
8116
|
+
}
|
|
8117
|
+
if (hasPath) {
|
|
8118
|
+
const path = entry.path;
|
|
8119
|
+
if (typeof path !== "string" || path.length > 255 || !KEY_PATH.test(path) || !path.startsWith(`apps/${appId}/`) || paths.has(path)) {
|
|
8120
|
+
throw new ManifestValidationError(`${label}.path is invalid`);
|
|
8121
|
+
}
|
|
8122
|
+
paths.add(path);
|
|
8123
|
+
} else {
|
|
8124
|
+
if (entry.prefix !== `apps/${appId}/` || prefixSeen) {
|
|
8125
|
+
throw new ManifestValidationError(`${label}.prefix is invalid`);
|
|
8126
|
+
}
|
|
8127
|
+
prefixSeen = true;
|
|
8128
|
+
}
|
|
8129
|
+
}
|
|
8130
|
+
}
|
|
7964
8131
|
function resolveManifestKnowledgeRoot(knowledge) {
|
|
7965
8132
|
if (knowledge === void 0) {
|
|
7966
8133
|
return void 0;
|
|
@@ -7985,13 +8152,13 @@ function validateManifestSecrets(secrets) {
|
|
|
7985
8152
|
throw new ManifestValidationError("manifest.secrets must be an object");
|
|
7986
8153
|
}
|
|
7987
8154
|
for (const [name2, spec] of Object.entries(secrets)) {
|
|
7988
|
-
if (!
|
|
8155
|
+
if (!import_sdk_services3.SECRET_NAME_RE.test(name2)) {
|
|
7989
8156
|
throw new ManifestValidationError(
|
|
7990
|
-
`manifest.secrets.${name2} must match ${
|
|
8157
|
+
`manifest.secrets.${name2} must match ${import_sdk_services3.SECRET_NAME_RE.source}`
|
|
7991
8158
|
);
|
|
7992
8159
|
}
|
|
7993
8160
|
try {
|
|
7994
|
-
(0,
|
|
8161
|
+
(0, import_sdk_services3.resolveSecretPath)(
|
|
7995
8162
|
secretNameFromSpec(name2, spec),
|
|
7996
8163
|
{ scope: secretScopeFromSpec(spec) }
|
|
7997
8164
|
);
|
|
@@ -8208,7 +8375,7 @@ function secretEntriesForManifest(secrets) {
|
|
|
8208
8375
|
const entries = [];
|
|
8209
8376
|
for (const [name2, spec] of Object.entries(secrets)) {
|
|
8210
8377
|
const actions = secretActionsFromSpec(name2, spec);
|
|
8211
|
-
const secretPath = (0,
|
|
8378
|
+
const secretPath = (0, import_sdk_services3.resolveSecretPath)(
|
|
8212
8379
|
secretNameFromSpec(name2, spec),
|
|
8213
8380
|
{ scope: secretScopeFromSpec(spec) }
|
|
8214
8381
|
);
|
|
@@ -8478,6 +8645,7 @@ function manifestAbilitiesUnion(resolved) {
|
|
|
8478
8645
|
}
|
|
8479
8646
|
|
|
8480
8647
|
// src/capabilities.ts
|
|
8648
|
+
var import_resource2 = require("@tinycloud/sdk-services/encryption/resource");
|
|
8481
8649
|
var PermissionNotInManifestError = class extends Error {
|
|
8482
8650
|
constructor(missing, granted) {
|
|
8483
8651
|
super(
|
|
@@ -8529,10 +8697,9 @@ function isCapabilitySubset(requested, granted) {
|
|
|
8529
8697
|
const grantedActions = matchingScope.flatMap(
|
|
8530
8698
|
(entry) => expandActionShortNames(entry.service, entry.actions)
|
|
8531
8699
|
);
|
|
8700
|
+
const namedKeyRequest = req.service === "tinycloud.encryption" && req.path.startsWith("urn:tinycloud:encryption:") && req.path.includes("/");
|
|
8532
8701
|
const covered = requestedActions.every(
|
|
8533
|
-
(requestedAction) => grantedActions.some(
|
|
8534
|
-
(grantedAction) => actionContains(grantedAction, requestedAction)
|
|
8535
|
-
)
|
|
8702
|
+
(requestedAction) => grantedActions.some((grantedAction) => namedKeyRequest ? grantedAction === requestedAction : actionContains(grantedAction, requestedAction))
|
|
8536
8703
|
);
|
|
8537
8704
|
if (!covered) {
|
|
8538
8705
|
missing.push(cloneEntry(req));
|
|
@@ -8547,7 +8714,9 @@ function canonicalizeEntryScopeMatches(requested, granted) {
|
|
|
8547
8714
|
if (normalizeSpace(requested.space ?? DEFAULT_MANIFEST_SPACE) !== normalizeSpace(granted.space ?? DEFAULT_MANIFEST_SPACE)) {
|
|
8548
8715
|
return false;
|
|
8549
8716
|
}
|
|
8550
|
-
|
|
8717
|
+
const namedKeyRequest = requested.service === "tinycloud.encryption" && requested.path.startsWith("urn:tinycloud:encryption:") && requested.path.includes("/");
|
|
8718
|
+
const coveredPath = namedKeyRequest ? (0, import_resource2.encryptionResourceContains)(granted.path, requested.path) : pathContains2(granted.path, requested.path);
|
|
8719
|
+
if (!coveredPath) {
|
|
8551
8720
|
return false;
|
|
8552
8721
|
}
|
|
8553
8722
|
if (!recapCaveatsEqual(requested.caveats, granted.caveats)) {
|
|
@@ -8659,7 +8828,7 @@ function parseRecapCapabilities(parseWasm, siwe) {
|
|
|
8659
8828
|
var import_ed255197 = require("@noble/curves/ed25519");
|
|
8660
8829
|
|
|
8661
8830
|
// src/delegations/ShareRecipientClient.ts
|
|
8662
|
-
var
|
|
8831
|
+
var import_sdk_services4 = require("@tinycloud/sdk-services");
|
|
8663
8832
|
var import_ed255196 = require("@noble/curves/ed25519");
|
|
8664
8833
|
var import_sha2565 = require("@noble/hashes/sha256");
|
|
8665
8834
|
|
|
@@ -9846,9 +10015,9 @@ function redactedCode(error) {
|
|
|
9846
10015
|
if (error instanceof ShareConflict) return error.code;
|
|
9847
10016
|
const code3 = error && typeof error === "object" && "code" in error ? error.code : void 0;
|
|
9848
10017
|
if (typeof code3 !== "string") return "SHARE_INVALID";
|
|
9849
|
-
if (code3 ===
|
|
9850
|
-
if (code3 ===
|
|
9851
|
-
if (code3 ===
|
|
10018
|
+
if (code3 === import_sdk_services4.ErrorCodes.KV_PRECONDITION_FAILED || code3 === "412") return "SHARE_CONFLICT";
|
|
10019
|
+
if (code3 === import_sdk_services4.ErrorCodes.NODE_BUSY || code3 === import_sdk_services4.ErrorCodes.REQUEST_TIMEOUT) return "SHARE_OFFLINE";
|
|
10020
|
+
if (code3 === import_sdk_services4.ErrorCodes.OUTCOME_UNKNOWN) return "SHARE_WRITE_FAILED";
|
|
9852
10021
|
if (code3 === "KV_NOT_FOUND" || code3 === "NOT_FOUND" || code3 === "404") return "SHARE_NOT_FOUND";
|
|
9853
10022
|
if (code3.includes("EXPIRED") || code3 === "expired") return "SHARE_EXPIRED";
|
|
9854
10023
|
if (code3.includes("REVOK")) return "SHARE_REVOKED";
|
|
@@ -10087,7 +10256,7 @@ var ShareRecipientClient = class {
|
|
|
10087
10256
|
if (portableDelegation !== void 0 && kv !== void 0) {
|
|
10088
10257
|
const result2 = await kv.put(resolvedPath, bytes2, { contentType: input.contentType ?? envelope.content.mimeType, ifMatch: input.etag });
|
|
10089
10258
|
if (!result2.ok) {
|
|
10090
|
-
if (result2.error.code ===
|
|
10259
|
+
if (result2.error.code === import_sdk_services4.ErrorCodes.KV_PRECONDITION_FAILED) throw new ShareConflict(resolvedPath, result2.error.meta?.etag);
|
|
10091
10260
|
throw result2.error;
|
|
10092
10261
|
}
|
|
10093
10262
|
return { etag: result2.data.headers.etag };
|
|
@@ -10095,7 +10264,7 @@ var ShareRecipientClient = class {
|
|
|
10095
10264
|
if (policySession !== void 0) return this.nativeSave(envelope, policySession, resolvedPath, bytes2, input);
|
|
10096
10265
|
const result = await kv.put(resolvedPath, bytes2, { contentType: input.contentType ?? envelope.content.mimeType, ifMatch: input.etag });
|
|
10097
10266
|
if (!result.ok) {
|
|
10098
|
-
if (result.error.code ===
|
|
10267
|
+
if (result.error.code === import_sdk_services4.ErrorCodes.KV_PRECONDITION_FAILED) throw new ShareConflict(resolvedPath, result.error.meta?.etag);
|
|
10099
10268
|
throw result.error;
|
|
10100
10269
|
}
|
|
10101
10270
|
return { etag: result.data.headers.etag };
|
|
@@ -10179,8 +10348,8 @@ var ShareRecipientClient = class {
|
|
|
10179
10348
|
if (this.options.createKVService !== void 0) {
|
|
10180
10349
|
return this.options.createKVService({ hosts: [origin2], session, invoke, fetch: this.fetchFn });
|
|
10181
10350
|
}
|
|
10182
|
-
const context = new
|
|
10183
|
-
const service = new
|
|
10351
|
+
const context = new import_sdk_services4.ServiceContext({ hosts: [origin2], session, invoke, fetch: this.fetchFn });
|
|
10352
|
+
const service = new import_sdk_services4.KVService({ prefix: "" });
|
|
10184
10353
|
context.registerService("kv", service);
|
|
10185
10354
|
service.initialize(context);
|
|
10186
10355
|
return service;
|
|
@@ -12728,14 +12897,14 @@ function markDelegationTerminal(token, key) {
|
|
|
12728
12897
|
}
|
|
12729
12898
|
|
|
12730
12899
|
// src/networkId.ts
|
|
12731
|
-
var
|
|
12900
|
+
var import_sdk_services5 = require("@tinycloud/sdk-services");
|
|
12732
12901
|
function canonicalizeNetworkId(networkId) {
|
|
12733
|
-
const parsed = (0,
|
|
12734
|
-
return (0,
|
|
12902
|
+
const parsed = (0, import_sdk_services5.parseNetworkId)(networkId);
|
|
12903
|
+
return (0, import_sdk_services5.buildNetworkId)(canonicalizeDid(parsed.ownerDid), parsed.name);
|
|
12735
12904
|
}
|
|
12736
12905
|
function parseCanonicalNetworkId(networkId) {
|
|
12737
12906
|
const canonical = canonicalizeNetworkId(networkId);
|
|
12738
|
-
return (0,
|
|
12907
|
+
return (0, import_sdk_services5.parseNetworkId)(canonical);
|
|
12739
12908
|
}
|
|
12740
12909
|
|
|
12741
12910
|
// src/storage.schema.ts
|
|
@@ -12843,10 +13012,10 @@ function validatePersistedSessionData(data) {
|
|
|
12843
13012
|
}
|
|
12844
13013
|
|
|
12845
13014
|
// src/TinyCloud.ts
|
|
12846
|
-
var
|
|
13015
|
+
var import_sdk_services7 = require("@tinycloud/sdk-services");
|
|
12847
13016
|
|
|
12848
13017
|
// src/spaces/SpaceService.ts
|
|
12849
|
-
var
|
|
13018
|
+
var import_sdk_services6 = require("@tinycloud/sdk-services");
|
|
12850
13019
|
|
|
12851
13020
|
// src/spaces/Space.ts
|
|
12852
13021
|
function unavailableSecretsService() {
|
|
@@ -13281,8 +13450,8 @@ var SpaceService = class {
|
|
|
13281
13450
|
*/
|
|
13282
13451
|
async list() {
|
|
13283
13452
|
if (!this.session) {
|
|
13284
|
-
return (0,
|
|
13285
|
-
(0,
|
|
13453
|
+
return (0, import_sdk_services6.err)(
|
|
13454
|
+
(0, import_sdk_services6.serviceError)(SpaceErrorCodes.AUTH_REQUIRED, "Authentication required", SERVICE_NAME)
|
|
13286
13455
|
);
|
|
13287
13456
|
}
|
|
13288
13457
|
try {
|
|
@@ -13291,8 +13460,8 @@ var SpaceService = class {
|
|
|
13291
13460
|
if (ownedResult.ok) {
|
|
13292
13461
|
spaces.push(...ownedResult.data);
|
|
13293
13462
|
} else {
|
|
13294
|
-
const verdict = (0,
|
|
13295
|
-
if (verdict === "unauthenticated" || verdict === "forbidden") return (0,
|
|
13463
|
+
const verdict = (0, import_sdk_services6.authorizationVerdictOf)(ownedResult.error);
|
|
13464
|
+
if (verdict === "unauthenticated" || verdict === "forbidden") return (0, import_sdk_services6.err)(ownedResult.error);
|
|
13296
13465
|
}
|
|
13297
13466
|
if (this.capabilityRegistry) {
|
|
13298
13467
|
const delegatedSpaces = this.discoverDelegatedSpaces();
|
|
@@ -13304,10 +13473,10 @@ var SpaceService = class {
|
|
|
13304
13473
|
this.notifySpaceRegistered(space);
|
|
13305
13474
|
}
|
|
13306
13475
|
}
|
|
13307
|
-
return (0,
|
|
13476
|
+
return (0, import_sdk_services6.ok)(uniqueSpaces);
|
|
13308
13477
|
} catch (error) {
|
|
13309
|
-
return (0,
|
|
13310
|
-
(0,
|
|
13478
|
+
return (0, import_sdk_services6.err)(
|
|
13479
|
+
(0, import_sdk_services6.serviceError)(
|
|
13311
13480
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13312
13481
|
`Failed to list spaces: ${String(error)}`,
|
|
13313
13482
|
SERVICE_NAME,
|
|
@@ -13327,7 +13496,7 @@ var SpaceService = class {
|
|
|
13327
13496
|
headers
|
|
13328
13497
|
});
|
|
13329
13498
|
if (!response.ok) {
|
|
13330
|
-
return (0,
|
|
13499
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
13331
13500
|
response,
|
|
13332
13501
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13333
13502
|
"Failed to list owned spaces",
|
|
@@ -13337,8 +13506,8 @@ var SpaceService = class {
|
|
|
13337
13506
|
const rawData = await response.json();
|
|
13338
13507
|
const validationResult = validateServerOwnedSpacesResponse(rawData);
|
|
13339
13508
|
if (!validationResult.ok) {
|
|
13340
|
-
return (0,
|
|
13341
|
-
(0,
|
|
13509
|
+
return (0, import_sdk_services6.err)(
|
|
13510
|
+
(0, import_sdk_services6.serviceError)(
|
|
13342
13511
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13343
13512
|
validationResult.error.message,
|
|
13344
13513
|
SERVICE_NAME,
|
|
@@ -13354,10 +13523,10 @@ var SpaceService = class {
|
|
|
13354
13523
|
permissions: ["*"]
|
|
13355
13524
|
// Full permissions for owned spaces
|
|
13356
13525
|
}));
|
|
13357
|
-
return (0,
|
|
13526
|
+
return (0, import_sdk_services6.ok)(spaces);
|
|
13358
13527
|
} catch (error) {
|
|
13359
|
-
return (0,
|
|
13360
|
-
(0,
|
|
13528
|
+
return (0, import_sdk_services6.err)(
|
|
13529
|
+
(0, import_sdk_services6.serviceError)(
|
|
13361
13530
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13362
13531
|
`Network error listing owned spaces: ${String(error)}`,
|
|
13363
13532
|
SERVICE_NAME,
|
|
@@ -13438,13 +13607,13 @@ var SpaceService = class {
|
|
|
13438
13607
|
*/
|
|
13439
13608
|
async create(name2) {
|
|
13440
13609
|
if (!this.session) {
|
|
13441
|
-
return (0,
|
|
13442
|
-
(0,
|
|
13610
|
+
return (0, import_sdk_services6.err)(
|
|
13611
|
+
(0, import_sdk_services6.serviceError)(SpaceErrorCodes.AUTH_REQUIRED, "Authentication required", SERVICE_NAME)
|
|
13443
13612
|
);
|
|
13444
13613
|
}
|
|
13445
13614
|
if (!name2 || !/^[a-zA-Z0-9_-]+$/.test(name2)) {
|
|
13446
|
-
return (0,
|
|
13447
|
-
(0,
|
|
13615
|
+
return (0, import_sdk_services6.err)(
|
|
13616
|
+
(0, import_sdk_services6.serviceError)(
|
|
13448
13617
|
SpaceErrorCodes.INVALID_NAME,
|
|
13449
13618
|
"Space name must contain only alphanumeric characters, underscores, and hyphens",
|
|
13450
13619
|
SERVICE_NAME
|
|
@@ -13460,14 +13629,14 @@ var SpaceService = class {
|
|
|
13460
13629
|
});
|
|
13461
13630
|
if (!response.ok) {
|
|
13462
13631
|
if (response.status === 409) {
|
|
13463
|
-
return (0,
|
|
13632
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
13464
13633
|
response,
|
|
13465
13634
|
SpaceErrorCodes.ALREADY_EXISTS,
|
|
13466
13635
|
`Space "${name2}" already exists`,
|
|
13467
13636
|
SERVICE_NAME
|
|
13468
13637
|
));
|
|
13469
13638
|
}
|
|
13470
|
-
return (0,
|
|
13639
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
13471
13640
|
response,
|
|
13472
13641
|
SpaceErrorCodes.CREATION_FAILED,
|
|
13473
13642
|
"Failed to create space",
|
|
@@ -13477,8 +13646,8 @@ var SpaceService = class {
|
|
|
13477
13646
|
const rawData = await response.json();
|
|
13478
13647
|
const validationResult = validateServerCreateSpaceResponse(rawData);
|
|
13479
13648
|
if (!validationResult.ok) {
|
|
13480
|
-
return (0,
|
|
13481
|
-
(0,
|
|
13649
|
+
return (0, import_sdk_services6.err)(
|
|
13650
|
+
(0, import_sdk_services6.serviceError)(
|
|
13482
13651
|
SpaceErrorCodes.CREATION_FAILED,
|
|
13483
13652
|
validationResult.error.message,
|
|
13484
13653
|
SERVICE_NAME,
|
|
@@ -13495,10 +13664,10 @@ var SpaceService = class {
|
|
|
13495
13664
|
};
|
|
13496
13665
|
this.infoCache.set(spaceInfo.id, { info: spaceInfo, cachedAt: Date.now() });
|
|
13497
13666
|
this.notifySpaceRegistered(spaceInfo);
|
|
13498
|
-
return (0,
|
|
13667
|
+
return (0, import_sdk_services6.ok)(spaceInfo);
|
|
13499
13668
|
} catch (error) {
|
|
13500
|
-
return (0,
|
|
13501
|
-
(0,
|
|
13669
|
+
return (0, import_sdk_services6.err)(
|
|
13670
|
+
(0, import_sdk_services6.serviceError)(
|
|
13502
13671
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13503
13672
|
`Network error creating space: ${String(error)}`,
|
|
13504
13673
|
SERVICE_NAME,
|
|
@@ -13568,10 +13737,10 @@ var SpaceService = class {
|
|
|
13568
13737
|
const spaceId = this.resolveSpaceId(nameOrUri);
|
|
13569
13738
|
const cached = this.infoCache.get(spaceId);
|
|
13570
13739
|
if (cached && Date.now() - cached.cachedAt < this.cacheTTL) {
|
|
13571
|
-
return (0,
|
|
13740
|
+
return (0, import_sdk_services6.ok)(true);
|
|
13572
13741
|
}
|
|
13573
13742
|
const infoResult = await this.getSpaceInfo(spaceId);
|
|
13574
|
-
return (0,
|
|
13743
|
+
return (0, import_sdk_services6.ok)(infoResult.ok);
|
|
13575
13744
|
}
|
|
13576
13745
|
// ===========================================================================
|
|
13577
13746
|
// Space Info
|
|
@@ -13582,11 +13751,11 @@ var SpaceService = class {
|
|
|
13582
13751
|
async getSpaceInfo(spaceId) {
|
|
13583
13752
|
const cached = this.infoCache.get(spaceId);
|
|
13584
13753
|
if (cached && Date.now() - cached.cachedAt < this.cacheTTL) {
|
|
13585
|
-
return (0,
|
|
13754
|
+
return (0, import_sdk_services6.ok)(cached.info);
|
|
13586
13755
|
}
|
|
13587
13756
|
if (!this.session) {
|
|
13588
|
-
return (0,
|
|
13589
|
-
(0,
|
|
13757
|
+
return (0, import_sdk_services6.err)(
|
|
13758
|
+
(0, import_sdk_services6.serviceError)(SpaceErrorCodes.AUTH_REQUIRED, "Authentication required", SERVICE_NAME)
|
|
13590
13759
|
);
|
|
13591
13760
|
}
|
|
13592
13761
|
try {
|
|
@@ -13598,14 +13767,14 @@ var SpaceService = class {
|
|
|
13598
13767
|
});
|
|
13599
13768
|
if (!response.ok) {
|
|
13600
13769
|
if (response.status === 404) {
|
|
13601
|
-
return (0,
|
|
13770
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
13602
13771
|
response,
|
|
13603
13772
|
SpaceErrorCodes.NOT_FOUND,
|
|
13604
13773
|
`Space not found: ${spaceId}`,
|
|
13605
13774
|
SERVICE_NAME
|
|
13606
13775
|
));
|
|
13607
13776
|
}
|
|
13608
|
-
return (0,
|
|
13777
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
13609
13778
|
response,
|
|
13610
13779
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13611
13780
|
"Failed to get space info",
|
|
@@ -13615,8 +13784,8 @@ var SpaceService = class {
|
|
|
13615
13784
|
const rawData = await response.json();
|
|
13616
13785
|
const validationResult = validateServerSpaceInfoResponse(rawData);
|
|
13617
13786
|
if (!validationResult.ok) {
|
|
13618
|
-
return (0,
|
|
13619
|
-
(0,
|
|
13787
|
+
return (0, import_sdk_services6.err)(
|
|
13788
|
+
(0, import_sdk_services6.serviceError)(
|
|
13620
13789
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13621
13790
|
validationResult.error.message,
|
|
13622
13791
|
SERVICE_NAME,
|
|
@@ -13634,10 +13803,10 @@ var SpaceService = class {
|
|
|
13634
13803
|
expiresAt: data.expiresAt ? new Date(data.expiresAt) : void 0
|
|
13635
13804
|
};
|
|
13636
13805
|
this.infoCache.set(spaceId, { info: spaceInfo, cachedAt: Date.now() });
|
|
13637
|
-
return (0,
|
|
13806
|
+
return (0, import_sdk_services6.ok)(spaceInfo);
|
|
13638
13807
|
} catch (error) {
|
|
13639
|
-
return (0,
|
|
13640
|
-
(0,
|
|
13808
|
+
return (0, import_sdk_services6.err)(
|
|
13809
|
+
(0, import_sdk_services6.serviceError)(
|
|
13641
13810
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13642
13811
|
`Network error getting space info: ${String(error)}`,
|
|
13643
13812
|
SERVICE_NAME,
|
|
@@ -13722,7 +13891,7 @@ var SpaceService = class {
|
|
|
13722
13891
|
headers
|
|
13723
13892
|
});
|
|
13724
13893
|
if (!response.ok) {
|
|
13725
|
-
return (0,
|
|
13894
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
13726
13895
|
response,
|
|
13727
13896
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13728
13897
|
"Failed to list delegations",
|
|
@@ -13732,8 +13901,8 @@ var SpaceService = class {
|
|
|
13732
13901
|
const rawData = await response.json();
|
|
13733
13902
|
const validationResult = validateServerDelegationsResponse(rawData);
|
|
13734
13903
|
if (!validationResult.ok) {
|
|
13735
|
-
return (0,
|
|
13736
|
-
(0,
|
|
13904
|
+
return (0, import_sdk_services6.err)(
|
|
13905
|
+
(0, import_sdk_services6.serviceError)(
|
|
13737
13906
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13738
13907
|
validationResult.error.message,
|
|
13739
13908
|
SERVICE_NAME,
|
|
@@ -13742,10 +13911,10 @@ var SpaceService = class {
|
|
|
13742
13911
|
);
|
|
13743
13912
|
}
|
|
13744
13913
|
const delegations = transformServerDelegations(validationResult.data, spaceId);
|
|
13745
|
-
return (0,
|
|
13914
|
+
return (0, import_sdk_services6.ok)(delegations);
|
|
13746
13915
|
} catch (error) {
|
|
13747
|
-
return (0,
|
|
13748
|
-
(0,
|
|
13916
|
+
return (0, import_sdk_services6.err)(
|
|
13917
|
+
(0, import_sdk_services6.serviceError)(
|
|
13749
13918
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13750
13919
|
`Network error listing delegations: ${String(error)}`,
|
|
13751
13920
|
SERVICE_NAME
|
|
@@ -13775,7 +13944,7 @@ var SpaceService = class {
|
|
|
13775
13944
|
headers
|
|
13776
13945
|
});
|
|
13777
13946
|
if (!response.ok) {
|
|
13778
|
-
return (0,
|
|
13947
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
13779
13948
|
response,
|
|
13780
13949
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13781
13950
|
"Failed to list received delegations",
|
|
@@ -13785,8 +13954,8 @@ var SpaceService = class {
|
|
|
13785
13954
|
const rawData = await response.json();
|
|
13786
13955
|
const validationResult = validateServerDelegationsResponse(rawData);
|
|
13787
13956
|
if (!validationResult.ok) {
|
|
13788
|
-
return (0,
|
|
13789
|
-
(0,
|
|
13957
|
+
return (0, import_sdk_services6.err)(
|
|
13958
|
+
(0, import_sdk_services6.serviceError)(
|
|
13790
13959
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13791
13960
|
validationResult.error.message,
|
|
13792
13961
|
SERVICE_NAME,
|
|
@@ -13795,10 +13964,10 @@ var SpaceService = class {
|
|
|
13795
13964
|
);
|
|
13796
13965
|
}
|
|
13797
13966
|
const delegations = transformServerDelegations(validationResult.data, spaceId);
|
|
13798
|
-
return (0,
|
|
13967
|
+
return (0, import_sdk_services6.ok)(delegations);
|
|
13799
13968
|
} catch (error) {
|
|
13800
|
-
return (0,
|
|
13801
|
-
(0,
|
|
13969
|
+
return (0, import_sdk_services6.err)(
|
|
13970
|
+
(0, import_sdk_services6.serviceError)(
|
|
13802
13971
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13803
13972
|
`Network error listing received delegations: ${String(error)}`,
|
|
13804
13973
|
SERVICE_NAME
|
|
@@ -13810,8 +13979,8 @@ var SpaceService = class {
|
|
|
13810
13979
|
if (self.createDelegationFn) {
|
|
13811
13980
|
return self.createDelegationFn({ ...params, spaceId });
|
|
13812
13981
|
}
|
|
13813
|
-
return (0,
|
|
13814
|
-
(0,
|
|
13982
|
+
return (0, import_sdk_services6.err)(
|
|
13983
|
+
(0, import_sdk_services6.serviceError)(
|
|
13815
13984
|
SpaceErrorCodes.NOT_INITIALIZED,
|
|
13816
13985
|
"Delegation creation requires a createDelegation function. This should be provided by the platform SDK (web-sdk or node-sdk).",
|
|
13817
13986
|
SERVICE_NAME
|
|
@@ -13832,17 +14001,17 @@ var SpaceService = class {
|
|
|
13832
14001
|
body: JSON.stringify({ cid: cid2, spaceId })
|
|
13833
14002
|
});
|
|
13834
14003
|
if (!response.ok) {
|
|
13835
|
-
return (0,
|
|
14004
|
+
return (0, import_sdk_services6.err)(await serviceHttpError(
|
|
13836
14005
|
response,
|
|
13837
14006
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13838
14007
|
"Failed to revoke delegation",
|
|
13839
14008
|
SERVICE_NAME
|
|
13840
14009
|
));
|
|
13841
14010
|
}
|
|
13842
|
-
return (0,
|
|
14011
|
+
return (0, import_sdk_services6.ok)(void 0);
|
|
13843
14012
|
} catch (error) {
|
|
13844
|
-
return (0,
|
|
13845
|
-
(0,
|
|
14013
|
+
return (0, import_sdk_services6.err)(
|
|
14014
|
+
(0, import_sdk_services6.serviceError)(
|
|
13846
14015
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13847
14016
|
`Network error revoking delegation: ${String(error)}`,
|
|
13848
14017
|
SERVICE_NAME
|
|
@@ -13865,18 +14034,18 @@ var SpaceService = class {
|
|
|
13865
14034
|
if (self.sharingService) {
|
|
13866
14035
|
const result = await self.sharingService.generate(params);
|
|
13867
14036
|
if (!result.ok) {
|
|
13868
|
-
return (0,
|
|
13869
|
-
(0,
|
|
14037
|
+
return (0, import_sdk_services6.err)(
|
|
14038
|
+
(0, import_sdk_services6.serviceError)(
|
|
13870
14039
|
SpaceErrorCodes.NETWORK_ERROR,
|
|
13871
14040
|
result.error.message || "Failed to generate share link",
|
|
13872
14041
|
SERVICE_NAME
|
|
13873
14042
|
)
|
|
13874
14043
|
);
|
|
13875
14044
|
}
|
|
13876
|
-
return (0,
|
|
14045
|
+
return (0, import_sdk_services6.ok)(result.data);
|
|
13877
14046
|
}
|
|
13878
|
-
return (0,
|
|
13879
|
-
(0,
|
|
14047
|
+
return (0, import_sdk_services6.err)(
|
|
14048
|
+
(0, import_sdk_services6.serviceError)(
|
|
13880
14049
|
SpaceErrorCodes.NOT_INITIALIZED,
|
|
13881
14050
|
"SharingService not configured. V2 sharing requires a SharingService instance.",
|
|
13882
14051
|
SERVICE_NAME
|
|
@@ -13884,8 +14053,8 @@ var SpaceService = class {
|
|
|
13884
14053
|
);
|
|
13885
14054
|
},
|
|
13886
14055
|
async list() {
|
|
13887
|
-
return (0,
|
|
13888
|
-
(0,
|
|
14056
|
+
return (0, import_sdk_services6.err)(
|
|
14057
|
+
(0, import_sdk_services6.serviceError)(
|
|
13889
14058
|
SpaceErrorCodes.NOT_INITIALIZED,
|
|
13890
14059
|
"Listing share links is not supported in v2. Share links are self-contained tokens that are not tracked on the server.",
|
|
13891
14060
|
SERVICE_NAME
|
|
@@ -13893,8 +14062,8 @@ var SpaceService = class {
|
|
|
13893
14062
|
);
|
|
13894
14063
|
},
|
|
13895
14064
|
async revoke(token) {
|
|
13896
|
-
return (0,
|
|
13897
|
-
(0,
|
|
14065
|
+
return (0, import_sdk_services6.err)(
|
|
14066
|
+
(0, import_sdk_services6.serviceError)(
|
|
13898
14067
|
SpaceErrorCodes.NOT_INITIALIZED,
|
|
13899
14068
|
"Revoking share links by token is not supported in v2. To revoke access, revoke the underlying delegation using space.delegations.revoke(cid).",
|
|
13900
14069
|
SERVICE_NAME
|
|
@@ -13954,7 +14123,7 @@ var TinyCloud = class _TinyCloud {
|
|
|
13954
14123
|
"hosts are required to initialize services. Provide them via config.hosts or initializeServices()."
|
|
13955
14124
|
);
|
|
13956
14125
|
}
|
|
13957
|
-
this._serviceContext = new
|
|
14126
|
+
this._serviceContext = new import_sdk_services7.ServiceContext({
|
|
13958
14127
|
invoke: effectiveInvoke,
|
|
13959
14128
|
invokeAny: this.config.invokeAny,
|
|
13960
14129
|
fetch: fetchFn ?? this.config.fetch ?? globalThis.fetch.bind(globalThis),
|
|
@@ -13963,10 +14132,10 @@ var TinyCloud = class _TinyCloud {
|
|
|
13963
14132
|
telemetry: this.config.telemetry
|
|
13964
14133
|
});
|
|
13965
14134
|
const serviceConstructors = {
|
|
13966
|
-
kv:
|
|
13967
|
-
sql:
|
|
13968
|
-
duckdb:
|
|
13969
|
-
hooks:
|
|
14135
|
+
kv: import_sdk_services7.KVService,
|
|
14136
|
+
sql: import_sdk_services7.SQLService,
|
|
14137
|
+
duckdb: import_sdk_services7.DuckDbService,
|
|
14138
|
+
hooks: import_sdk_services7.HooksService,
|
|
13970
14139
|
...this.config.services
|
|
13971
14140
|
};
|
|
13972
14141
|
for (const [name2, ServiceClass] of Object.entries(serviceConstructors)) {
|
|
@@ -14230,18 +14399,18 @@ var TinyCloud = class _TinyCloud {
|
|
|
14230
14399
|
const address = this.address();
|
|
14231
14400
|
const chainId = this.chainId();
|
|
14232
14401
|
if (!address || !chainId) {
|
|
14233
|
-
return (0,
|
|
14234
|
-
(0,
|
|
14235
|
-
|
|
14402
|
+
return (0, import_sdk_services7.err)(
|
|
14403
|
+
(0, import_sdk_services7.serviceError)(
|
|
14404
|
+
import_sdk_services7.ErrorCodes.AUTH_REQUIRED,
|
|
14236
14405
|
"Must be signed in to ensure public space",
|
|
14237
14406
|
"public-space"
|
|
14238
14407
|
)
|
|
14239
14408
|
);
|
|
14240
14409
|
}
|
|
14241
14410
|
if (!this._serviceContext) {
|
|
14242
|
-
return (0,
|
|
14243
|
-
(0,
|
|
14244
|
-
|
|
14411
|
+
return (0, import_sdk_services7.err)(
|
|
14412
|
+
(0, import_sdk_services7.serviceError)(
|
|
14413
|
+
import_sdk_services7.ErrorCodes.AUTH_REQUIRED,
|
|
14245
14414
|
"Services not initialized. Call initializeServices() or signIn() first.",
|
|
14246
14415
|
"public-space"
|
|
14247
14416
|
)
|
|
@@ -14251,9 +14420,9 @@ var TinyCloud = class _TinyCloud {
|
|
|
14251
14420
|
try {
|
|
14252
14421
|
const session = this._serviceContext.session;
|
|
14253
14422
|
if (!session) {
|
|
14254
|
-
return (0,
|
|
14255
|
-
(0,
|
|
14256
|
-
|
|
14423
|
+
return (0, import_sdk_services7.err)(
|
|
14424
|
+
(0, import_sdk_services7.serviceError)(
|
|
14425
|
+
import_sdk_services7.ErrorCodes.AUTH_REQUIRED,
|
|
14257
14426
|
"No active session",
|
|
14258
14427
|
"public-space"
|
|
14259
14428
|
)
|
|
@@ -14270,7 +14439,7 @@ var TinyCloud = class _TinyCloud {
|
|
|
14270
14439
|
{ method: "POST", headers, body: JSON.stringify({ spaceId }) }
|
|
14271
14440
|
);
|
|
14272
14441
|
if (response.ok) {
|
|
14273
|
-
return (0,
|
|
14442
|
+
return (0, import_sdk_services7.ok)(void 0);
|
|
14274
14443
|
}
|
|
14275
14444
|
if (response.status === 404) {
|
|
14276
14445
|
const createHeaders = this._serviceContext.invoke(
|
|
@@ -14289,27 +14458,27 @@ var TinyCloud = class _TinyCloud {
|
|
|
14289
14458
|
);
|
|
14290
14459
|
if (!createResponse.ok) {
|
|
14291
14460
|
if (createResponse.status === 409) {
|
|
14292
|
-
return (0,
|
|
14461
|
+
return (0, import_sdk_services7.ok)(void 0);
|
|
14293
14462
|
}
|
|
14294
|
-
return (0,
|
|
14463
|
+
return (0, import_sdk_services7.err)(await serviceHttpError(
|
|
14295
14464
|
createResponse,
|
|
14296
|
-
|
|
14465
|
+
import_sdk_services7.ErrorCodes.NETWORK_ERROR,
|
|
14297
14466
|
"Failed to create public space",
|
|
14298
14467
|
"public-space"
|
|
14299
14468
|
));
|
|
14300
14469
|
}
|
|
14301
|
-
return (0,
|
|
14470
|
+
return (0, import_sdk_services7.ok)(void 0);
|
|
14302
14471
|
}
|
|
14303
|
-
return (0,
|
|
14472
|
+
return (0, import_sdk_services7.err)(await serviceHttpError(
|
|
14304
14473
|
response,
|
|
14305
|
-
|
|
14474
|
+
import_sdk_services7.ErrorCodes.NETWORK_ERROR,
|
|
14306
14475
|
"Failed to check public space",
|
|
14307
14476
|
"public-space"
|
|
14308
14477
|
));
|
|
14309
14478
|
} catch (error) {
|
|
14310
|
-
return (0,
|
|
14311
|
-
(0,
|
|
14312
|
-
|
|
14479
|
+
return (0, import_sdk_services7.err)(
|
|
14480
|
+
(0, import_sdk_services7.serviceError)(
|
|
14481
|
+
import_sdk_services7.ErrorCodes.NETWORK_ERROR,
|
|
14313
14482
|
`Network error ensuring public space: ${String(error)}`,
|
|
14314
14483
|
"public-space",
|
|
14315
14484
|
{ cause: error instanceof Error ? error : void 0 }
|
|
@@ -14342,8 +14511,8 @@ var TinyCloud = class _TinyCloud {
|
|
|
14342
14511
|
if (!session) {
|
|
14343
14512
|
throw new Error("No active session. Sign in first.");
|
|
14344
14513
|
}
|
|
14345
|
-
const publicKV = new
|
|
14346
|
-
const publicContext = new
|
|
14514
|
+
const publicKV = new import_sdk_services7.KVService({ prefix: "" });
|
|
14515
|
+
const publicContext = new import_sdk_services7.ServiceContext({
|
|
14347
14516
|
invoke: this._serviceContext.invoke,
|
|
14348
14517
|
fetch: this._serviceContext.fetch,
|
|
14349
14518
|
hosts: this._serviceContext.hosts,
|
|
@@ -14376,16 +14545,16 @@ var TinyCloud = class _TinyCloud {
|
|
|
14376
14545
|
const response = await doFetch(url, { method: "GET" });
|
|
14377
14546
|
if (!response.ok) {
|
|
14378
14547
|
if (response.status === 404) {
|
|
14379
|
-
return (0,
|
|
14548
|
+
return (0, import_sdk_services7.err)(await serviceHttpError(
|
|
14380
14549
|
response,
|
|
14381
|
-
|
|
14550
|
+
import_sdk_services7.ErrorCodes.NOT_FOUND,
|
|
14382
14551
|
`Key not found: ${key} in space ${spaceId}`,
|
|
14383
14552
|
"public-space"
|
|
14384
14553
|
));
|
|
14385
14554
|
}
|
|
14386
|
-
return (0,
|
|
14555
|
+
return (0, import_sdk_services7.err)(await serviceHttpError(
|
|
14387
14556
|
response,
|
|
14388
|
-
|
|
14557
|
+
import_sdk_services7.ErrorCodes.NETWORK_ERROR,
|
|
14389
14558
|
"Failed to read public space",
|
|
14390
14559
|
"public-space"
|
|
14391
14560
|
));
|
|
@@ -14402,11 +14571,11 @@ var TinyCloud = class _TinyCloud {
|
|
|
14402
14571
|
data = text3;
|
|
14403
14572
|
}
|
|
14404
14573
|
}
|
|
14405
|
-
return (0,
|
|
14574
|
+
return (0, import_sdk_services7.ok)(data);
|
|
14406
14575
|
} catch (error) {
|
|
14407
|
-
return (0,
|
|
14408
|
-
(0,
|
|
14409
|
-
|
|
14576
|
+
return (0, import_sdk_services7.err)(
|
|
14577
|
+
(0, import_sdk_services7.serviceError)(
|
|
14578
|
+
import_sdk_services7.ErrorCodes.NETWORK_ERROR,
|
|
14410
14579
|
`Network error reading public space: ${String(error)}`,
|
|
14411
14580
|
"public-space",
|
|
14412
14581
|
{ cause: error instanceof Error ? error : void 0 }
|
|
@@ -14432,7 +14601,7 @@ var TinyCloud = class _TinyCloud {
|
|
|
14432
14601
|
};
|
|
14433
14602
|
|
|
14434
14603
|
// src/account/AccountService.ts
|
|
14435
|
-
var
|
|
14604
|
+
var import_sdk_services8 = require("@tinycloud/sdk-services");
|
|
14436
14605
|
var import_bootstrap3 = require("@tinycloud/bootstrap");
|
|
14437
14606
|
var SERVICE_NAME2 = "account";
|
|
14438
14607
|
var ACCOUNT_INDEX_DB = "account";
|
|
@@ -14480,7 +14649,7 @@ var AccountService = class {
|
|
|
14480
14649
|
applications.push(applicationFromRecord(key, loaded.data.data));
|
|
14481
14650
|
}
|
|
14482
14651
|
applications.sort((a, b) => a.appId.localeCompare(b.appId));
|
|
14483
|
-
return (0,
|
|
14652
|
+
return (0, import_sdk_services8.ok)(applications);
|
|
14484
14653
|
},
|
|
14485
14654
|
get: async (appId) => {
|
|
14486
14655
|
const kvResult = this.accountKV();
|
|
@@ -14488,14 +14657,14 @@ var AccountService = class {
|
|
|
14488
14657
|
const key = applicationKey(appId);
|
|
14489
14658
|
const loaded = await kvResult.data.get(key);
|
|
14490
14659
|
if (!loaded.ok) return accountErr(loaded.error);
|
|
14491
|
-
return (0,
|
|
14660
|
+
return (0, import_sdk_services8.ok)(applicationFromRecord(key, loaded.data.data));
|
|
14492
14661
|
},
|
|
14493
14662
|
register: async (manifest, options2 = {}) => {
|
|
14494
14663
|
const manifests = Array.isArray(manifest) ? manifest : [manifest];
|
|
14495
14664
|
const request = composeManifestRequest(manifests);
|
|
14496
14665
|
if (request.registryRecords.length === 0) {
|
|
14497
|
-
return (0,
|
|
14498
|
-
(0,
|
|
14666
|
+
return (0, import_sdk_services8.err)(
|
|
14667
|
+
(0, import_sdk_services8.serviceError)(
|
|
14499
14668
|
"INVALID_MANIFEST",
|
|
14500
14669
|
"Manifest did not produce an account application registry record",
|
|
14501
14670
|
SERVICE_NAME2
|
|
@@ -14529,7 +14698,7 @@ var AccountService = class {
|
|
|
14529
14698
|
registered = applicationFromRecord(record2.key, stored);
|
|
14530
14699
|
await this.upsertApplicationIndexQuietly(registered);
|
|
14531
14700
|
}
|
|
14532
|
-
return (0,
|
|
14701
|
+
return (0, import_sdk_services8.ok)(registered);
|
|
14533
14702
|
},
|
|
14534
14703
|
remove: async (appId) => {
|
|
14535
14704
|
const kvResult = this.accountKV();
|
|
@@ -14537,7 +14706,7 @@ var AccountService = class {
|
|
|
14537
14706
|
const removed = await kvResult.data.delete(applicationKey(appId));
|
|
14538
14707
|
if (!removed.ok) return accountErr(removed.error);
|
|
14539
14708
|
await this.deleteApplicationIndexQuietly(appId);
|
|
14540
|
-
return (0,
|
|
14709
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
14541
14710
|
}
|
|
14542
14711
|
};
|
|
14543
14712
|
this.spaces = {
|
|
@@ -14551,7 +14720,7 @@ var AccountService = class {
|
|
|
14551
14720
|
if (canonical.data.allRegistered && options2.refreshIndex !== false) {
|
|
14552
14721
|
await this.replaceSpacesIndexQuietly(canonical.data.spaces);
|
|
14553
14722
|
}
|
|
14554
|
-
return (0,
|
|
14723
|
+
return (0, import_sdk_services8.ok)(canonical.data.spaces);
|
|
14555
14724
|
}
|
|
14556
14725
|
const kvResult = this.accountKV();
|
|
14557
14726
|
if (!kvResult.ok) return kvResult;
|
|
@@ -14564,14 +14733,14 @@ var AccountService = class {
|
|
|
14564
14733
|
spaces.push(spaceFromRecord(key, loaded.data.data));
|
|
14565
14734
|
}
|
|
14566
14735
|
spaces.sort((a, b) => a.name.localeCompare(b.name) || a.spaceId.localeCompare(b.spaceId));
|
|
14567
|
-
return (0,
|
|
14736
|
+
return (0, import_sdk_services8.ok)(spaces);
|
|
14568
14737
|
},
|
|
14569
14738
|
get: async (spaceId) => {
|
|
14570
14739
|
const kvResult = this.accountKV();
|
|
14571
14740
|
if (!kvResult.ok) return kvResult;
|
|
14572
14741
|
const loaded = await kvResult.data.get(spaceKey(spaceId));
|
|
14573
14742
|
if (!loaded.ok) return accountErr(loaded.error);
|
|
14574
|
-
return (0,
|
|
14743
|
+
return (0, import_sdk_services8.ok)(spaceFromRecord(spaceKey(spaceId), loaded.data.data));
|
|
14575
14744
|
},
|
|
14576
14745
|
register: async (space) => {
|
|
14577
14746
|
await this.config.ensureAccountSpaceHosted?.();
|
|
@@ -14582,7 +14751,7 @@ var AccountService = class {
|
|
|
14582
14751
|
if (!written.ok) return accountErr(written.error);
|
|
14583
14752
|
const registered = spaceFromRecord(spaceKey(stored.space_id), stored);
|
|
14584
14753
|
await this.upsertSpaceIndexQuietly(registered);
|
|
14585
|
-
return (0,
|
|
14754
|
+
return (0, import_sdk_services8.ok)(registered);
|
|
14586
14755
|
},
|
|
14587
14756
|
/**
|
|
14588
14757
|
* Register multiple spaces in one KV batch write + one multi-row index
|
|
@@ -14595,7 +14764,7 @@ var AccountService = class {
|
|
|
14595
14764
|
* leave the first attempt's blocks orphaned.
|
|
14596
14765
|
*/
|
|
14597
14766
|
registerBatch: async (spaces) => {
|
|
14598
|
-
if (spaces.length === 0) return (0,
|
|
14767
|
+
if (spaces.length === 0) return (0, import_sdk_services8.ok)({ spaces: [] });
|
|
14599
14768
|
await this.config.ensureAccountSpaceHosted?.();
|
|
14600
14769
|
const kvResult = this.accountKV();
|
|
14601
14770
|
if (!kvResult.ok) return kvResult;
|
|
@@ -14610,7 +14779,7 @@ var AccountService = class {
|
|
|
14610
14779
|
const batchResult = await kvResult.data.batchPut(items);
|
|
14611
14780
|
if (batchResult.ok) {
|
|
14612
14781
|
await this.upsertSpacesIndexQuietly(registered);
|
|
14613
|
-
return (0,
|
|
14782
|
+
return (0, import_sdk_services8.ok)({ spaces: registered });
|
|
14614
14783
|
}
|
|
14615
14784
|
if (!isAmbiguousBatchFailure(batchResult.error)) {
|
|
14616
14785
|
return accountErr(batchResult.error);
|
|
@@ -14623,8 +14792,8 @@ var AccountService = class {
|
|
|
14623
14792
|
}
|
|
14624
14793
|
}
|
|
14625
14794
|
if (reconcileFailures.length > 0) {
|
|
14626
|
-
return (0,
|
|
14627
|
-
(0,
|
|
14795
|
+
return (0, import_sdk_services8.err)(
|
|
14796
|
+
(0, import_sdk_services8.serviceError)(
|
|
14628
14797
|
"KV_BATCH_RECONCILE_FAILED",
|
|
14629
14798
|
`KV batch write for ${items.length} space(s) failed ambiguously (${batchResult.error.message}) and per-space reconciliation also failed for: ${reconcileFailures.join("; ")}`,
|
|
14630
14799
|
SERVICE_NAME2,
|
|
@@ -14636,7 +14805,7 @@ var AccountService = class {
|
|
|
14636
14805
|
`[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
14806
|
);
|
|
14638
14807
|
await this.upsertSpacesIndexQuietly(registered);
|
|
14639
|
-
return (0,
|
|
14808
|
+
return (0, import_sdk_services8.ok)({ spaces: registered, recoveredFromBatchError: batchResult.error });
|
|
14640
14809
|
},
|
|
14641
14810
|
/**
|
|
14642
14811
|
* Register only spaces without a registry record (TC-800). Existing
|
|
@@ -14644,7 +14813,7 @@ var AccountService = class {
|
|
|
14644
14813
|
* Bootstrap repair uses this on populated accounts.
|
|
14645
14814
|
*/
|
|
14646
14815
|
registerMissing: async (spaces) => {
|
|
14647
|
-
if (spaces.length === 0) return (0,
|
|
14816
|
+
if (spaces.length === 0) return (0, import_sdk_services8.ok)([]);
|
|
14648
14817
|
await this.config.ensureAccountSpaceHosted?.();
|
|
14649
14818
|
const kvResult = this.accountKV();
|
|
14650
14819
|
if (!kvResult.ok) return kvResult;
|
|
@@ -14660,15 +14829,15 @@ var AccountService = class {
|
|
|
14660
14829
|
const key = keys[i];
|
|
14661
14830
|
const result = byKey.get(key);
|
|
14662
14831
|
if (!result) {
|
|
14663
|
-
return (0,
|
|
14664
|
-
|
|
14832
|
+
return (0, import_sdk_services8.err)((0, import_sdk_services8.serviceError)(
|
|
14833
|
+
import_sdk_services8.ErrorCodes.NETWORK_ERROR,
|
|
14665
14834
|
`KV batch read omitted requested key ${JSON.stringify(key)}`,
|
|
14666
14835
|
SERVICE_NAME2
|
|
14667
14836
|
));
|
|
14668
14837
|
}
|
|
14669
14838
|
if (result.ok) {
|
|
14670
14839
|
final[i] = spaceFromRecord(key, result.data.data);
|
|
14671
|
-
} else if (result.error.code ===
|
|
14840
|
+
} else if (result.error.code === import_sdk_services8.ErrorCodes.KV_NOT_FOUND) {
|
|
14672
14841
|
missing.push({ index: i, key, record: stored[i] });
|
|
14673
14842
|
} else {
|
|
14674
14843
|
return accountErr(result.error);
|
|
@@ -14676,21 +14845,21 @@ var AccountService = class {
|
|
|
14676
14845
|
}
|
|
14677
14846
|
const creates = await Promise.all(missing.map(async ({ index, key, record: record2 }) => {
|
|
14678
14847
|
const written = await kv.put(key, record2, { ifNoneMatch: "*" });
|
|
14679
|
-
if (written.ok) return { index, result: (0,
|
|
14848
|
+
if (written.ok) return { index, result: (0, import_sdk_services8.ok)(spaceFromRecord(key, record2)) };
|
|
14680
14849
|
const raced = await kv.get(key);
|
|
14681
|
-
if (raced.ok) return { index, result: (0,
|
|
14682
|
-
return { index, result: (0,
|
|
14850
|
+
if (raced.ok) return { index, result: (0, import_sdk_services8.ok)(spaceFromRecord(key, raced.data.data)) };
|
|
14851
|
+
return { index, result: (0, import_sdk_services8.err)(written.error) };
|
|
14683
14852
|
}));
|
|
14684
14853
|
for (const { index, result } of creates) {
|
|
14685
14854
|
if (!result.ok) return accountErr(result.error);
|
|
14686
14855
|
final[index] = result.data;
|
|
14687
14856
|
}
|
|
14688
14857
|
await this.upsertSpacesIndexQuietly(final);
|
|
14689
|
-
return (0,
|
|
14858
|
+
return (0, import_sdk_services8.ok)(final);
|
|
14690
14859
|
},
|
|
14691
14860
|
syncAccessible: async () => {
|
|
14692
14861
|
const synced = await this.syncAccessibleSpaces({ tolerateStorageFull: false });
|
|
14693
|
-
return synced.ok ? (0,
|
|
14862
|
+
return synced.ok ? (0, import_sdk_services8.ok)(synced.data.spaces) : synced;
|
|
14694
14863
|
},
|
|
14695
14864
|
remove: async (spaceId) => {
|
|
14696
14865
|
const kvResult = this.accountKV();
|
|
@@ -14698,21 +14867,21 @@ var AccountService = class {
|
|
|
14698
14867
|
const removed = await kvResult.data.delete(spaceKey(spaceId));
|
|
14699
14868
|
if (!removed.ok) return accountErr(removed.error);
|
|
14700
14869
|
await this.deleteSpaceIndexQuietly(spaceId);
|
|
14701
|
-
return (0,
|
|
14870
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
14702
14871
|
}
|
|
14703
14872
|
};
|
|
14704
14873
|
this.delegations = {
|
|
14705
14874
|
query: async (options2 = {}) => {
|
|
14706
14875
|
const manager = this.config.getDelegationManager?.();
|
|
14707
14876
|
if (!manager) {
|
|
14708
|
-
return (0,
|
|
14877
|
+
return (0, import_sdk_services8.err)((0, import_sdk_services8.serviceError)(
|
|
14709
14878
|
"NOT_INITIALIZED",
|
|
14710
14879
|
"Delegation history requires an authenticated delegation manager",
|
|
14711
14880
|
SERVICE_NAME2
|
|
14712
14881
|
));
|
|
14713
14882
|
}
|
|
14714
14883
|
const queried = await manager.query(options2);
|
|
14715
|
-
return queried.ok ? (0,
|
|
14884
|
+
return queried.ok ? (0, import_sdk_services8.ok)(queried.data) : accountErr(queried.error);
|
|
14716
14885
|
},
|
|
14717
14886
|
list: async (options2 = {}) => {
|
|
14718
14887
|
if (options2.preferIndex) {
|
|
@@ -14746,17 +14915,17 @@ var AccountService = class {
|
|
|
14746
14915
|
}
|
|
14747
14916
|
}
|
|
14748
14917
|
delegations.sort((a, b) => a.spaceId.localeCompare(b.spaceId) || a.cid.localeCompare(b.cid));
|
|
14749
|
-
return (0,
|
|
14918
|
+
return (0, import_sdk_services8.ok)(delegations);
|
|
14750
14919
|
},
|
|
14751
14920
|
revoke: async (input) => {
|
|
14752
14921
|
const cid2 = typeof input === "string" ? input : input.cid;
|
|
14753
14922
|
const manager = this.config.getDelegationManager?.();
|
|
14754
14923
|
if (manager) {
|
|
14755
14924
|
const revoked2 = await manager.revoke(cid2);
|
|
14756
|
-
return revoked2.ok ? (0,
|
|
14925
|
+
return revoked2.ok ? (0, import_sdk_services8.ok)(revoked2.data) : accountErr(revoked2.error);
|
|
14757
14926
|
}
|
|
14758
14927
|
if (typeof input === "string") {
|
|
14759
|
-
return (0,
|
|
14928
|
+
return (0, import_sdk_services8.err)((0, import_sdk_services8.serviceError)(
|
|
14760
14929
|
"NOT_INITIALIZED",
|
|
14761
14930
|
"CID-only revocation requires an authenticated delegation manager",
|
|
14762
14931
|
SERVICE_NAME2
|
|
@@ -14766,7 +14935,7 @@ var AccountService = class {
|
|
|
14766
14935
|
if (!space.ok) return space;
|
|
14767
14936
|
const revoked = await this.config.getSpaces().get(space.data.id).delegations.revoke(cid2);
|
|
14768
14937
|
if (!revoked.ok) return accountErr(revoked.error);
|
|
14769
|
-
return (0,
|
|
14938
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
14770
14939
|
}
|
|
14771
14940
|
};
|
|
14772
14941
|
this.index = {
|
|
@@ -14775,7 +14944,7 @@ var AccountService = class {
|
|
|
14775
14944
|
if (!dbResult.ok) return dbResult;
|
|
14776
14945
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
14777
14946
|
if (!schema.ok) return schema;
|
|
14778
|
-
return (0,
|
|
14947
|
+
return (0, import_sdk_services8.ok)({ database: ACCOUNT_INDEX_DB });
|
|
14779
14948
|
},
|
|
14780
14949
|
rebuild: async () => {
|
|
14781
14950
|
const dbResult = this.accountDb();
|
|
@@ -14857,7 +15026,7 @@ var AccountService = class {
|
|
|
14857
15026
|
];
|
|
14858
15027
|
const rebuilt = await dbResult.data.batch(statements);
|
|
14859
15028
|
if (!rebuilt.ok) return accountErr(rebuilt.error);
|
|
14860
|
-
return (0,
|
|
15029
|
+
return (0, import_sdk_services8.ok)({
|
|
14861
15030
|
database: ACCOUNT_INDEX_DB,
|
|
14862
15031
|
applications: applications.data.length,
|
|
14863
15032
|
spaces: spaces.data.length,
|
|
@@ -14873,7 +15042,7 @@ var AccountService = class {
|
|
|
14873
15042
|
"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
15043
|
);
|
|
14875
15044
|
if (!queried.ok) return accountErr(queried.error);
|
|
14876
|
-
return (0,
|
|
15045
|
+
return (0, import_sdk_services8.ok)(queried.data.rows.map(indexedApplicationFromRow));
|
|
14877
15046
|
}
|
|
14878
15047
|
},
|
|
14879
15048
|
spaces: {
|
|
@@ -14884,7 +15053,7 @@ var AccountService = class {
|
|
|
14884
15053
|
"SELECT space_id, name, owner_did, type, permissions_json, status, registered_at, updated_at, expires_at FROM spaces ORDER BY name, space_id"
|
|
14885
15054
|
);
|
|
14886
15055
|
if (!queried.ok) return accountErr(queried.error);
|
|
14887
|
-
return (0,
|
|
15056
|
+
return (0, import_sdk_services8.ok)(queried.data.rows.map(indexedSpaceFromRow));
|
|
14888
15057
|
}
|
|
14889
15058
|
},
|
|
14890
15059
|
delegations: {
|
|
@@ -14906,7 +15075,7 @@ var AccountService = class {
|
|
|
14906
15075
|
params
|
|
14907
15076
|
);
|
|
14908
15077
|
if (!queried.ok) return accountErr(queried.error);
|
|
14909
|
-
return (0,
|
|
15078
|
+
return (0, import_sdk_services8.ok)(queried.data.rows.map(indexedDelegationFromRow));
|
|
14910
15079
|
}
|
|
14911
15080
|
},
|
|
14912
15081
|
query: async (sql, params) => {
|
|
@@ -14914,7 +15083,7 @@ var AccountService = class {
|
|
|
14914
15083
|
if (!dbResult.ok) return dbResult;
|
|
14915
15084
|
const queried = await dbResult.data.query(sql, params);
|
|
14916
15085
|
if (!queried.ok) return accountErr(queried.error);
|
|
14917
|
-
return (0,
|
|
15086
|
+
return (0, import_sdk_services8.ok)(queried.data);
|
|
14918
15087
|
},
|
|
14919
15088
|
status: async () => {
|
|
14920
15089
|
const dbResult = this.accountDb();
|
|
@@ -14924,11 +15093,11 @@ var AccountService = class {
|
|
|
14924
15093
|
);
|
|
14925
15094
|
if (!queried.ok) {
|
|
14926
15095
|
if (isMissingIndexError(queried.error)) {
|
|
14927
|
-
return (0,
|
|
15096
|
+
return (0, import_sdk_services8.ok)({ database: ACCOUNT_INDEX_DB, state: "missing", sources: [] });
|
|
14928
15097
|
}
|
|
14929
15098
|
return accountErr(queried.error);
|
|
14930
15099
|
}
|
|
14931
|
-
return (0,
|
|
15100
|
+
return (0, import_sdk_services8.ok)({
|
|
14932
15101
|
database: ACCOUNT_INDEX_DB,
|
|
14933
15102
|
state: "ready",
|
|
14934
15103
|
sources: queried.data.rows.map(([source, syncedAt, count]) => ({
|
|
@@ -14947,7 +15116,7 @@ var AccountService = class {
|
|
|
14947
15116
|
if (!delegations.ok) return delegations;
|
|
14948
15117
|
const spaces = await this.spaces.list();
|
|
14949
15118
|
if (!spaces.ok) return spaces;
|
|
14950
|
-
return (0,
|
|
15119
|
+
return (0, import_sdk_services8.ok)({
|
|
14951
15120
|
did: this.config.getDid(),
|
|
14952
15121
|
host: this.config.getHost(),
|
|
14953
15122
|
primarySpaceId: this.config.getPrimarySpaceId(),
|
|
@@ -14961,28 +15130,28 @@ var AccountService = class {
|
|
|
14961
15130
|
accountKV() {
|
|
14962
15131
|
const accountSpaceId = this.config.getAccountSpaceId();
|
|
14963
15132
|
if (!accountSpaceId) {
|
|
14964
|
-
return (0,
|
|
14965
|
-
(0,
|
|
15133
|
+
return (0, import_sdk_services8.err)(
|
|
15134
|
+
(0, import_sdk_services8.serviceError)(
|
|
14966
15135
|
"ACCOUNT_SPACE_UNAVAILABLE",
|
|
14967
15136
|
"Account space is unavailable. Sign in with a wallet-backed profile first.",
|
|
14968
15137
|
SERVICE_NAME2
|
|
14969
15138
|
)
|
|
14970
15139
|
);
|
|
14971
15140
|
}
|
|
14972
|
-
return (0,
|
|
15141
|
+
return (0, import_sdk_services8.ok)(this.config.getSpaces().get(accountSpaceId).kv);
|
|
14973
15142
|
}
|
|
14974
15143
|
accountDb() {
|
|
14975
15144
|
const db = this.config.getAccountDb?.();
|
|
14976
15145
|
if (!db) {
|
|
14977
|
-
return (0,
|
|
14978
|
-
(0,
|
|
15146
|
+
return (0, import_sdk_services8.err)(
|
|
15147
|
+
(0, import_sdk_services8.serviceError)(
|
|
14979
15148
|
"ACCOUNT_INDEX_UNAVAILABLE",
|
|
14980
15149
|
"Account index database is unavailable. Sign in with a wallet-backed profile first.",
|
|
14981
15150
|
SERVICE_NAME2
|
|
14982
15151
|
)
|
|
14983
15152
|
);
|
|
14984
15153
|
}
|
|
14985
|
-
return (0,
|
|
15154
|
+
return (0, import_sdk_services8.ok)(db);
|
|
14986
15155
|
}
|
|
14987
15156
|
async indexHasApplicationHash(appId, manifestHash) {
|
|
14988
15157
|
const dbResult = this.accountDb();
|
|
@@ -15000,7 +15169,7 @@ var AccountService = class {
|
|
|
15000
15169
|
}
|
|
15001
15170
|
async upsertApplicationIndex(app) {
|
|
15002
15171
|
const dbResult = this.accountDb();
|
|
15003
|
-
if (!dbResult.ok) return (0,
|
|
15172
|
+
if (!dbResult.ok) return (0, import_sdk_services8.ok)(void 0);
|
|
15004
15173
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
15005
15174
|
if (!schema.ok) return schema;
|
|
15006
15175
|
const updatedAt = app.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -15022,14 +15191,14 @@ var AccountService = class {
|
|
|
15022
15191
|
}
|
|
15023
15192
|
]);
|
|
15024
15193
|
if (!written.ok) return accountErr(written.error);
|
|
15025
|
-
return (0,
|
|
15194
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
15026
15195
|
}
|
|
15027
15196
|
async deleteApplicationIndexQuietly(appId) {
|
|
15028
15197
|
await ignoreIndexFailure(() => this.deleteApplicationIndex(appId));
|
|
15029
15198
|
}
|
|
15030
15199
|
async deleteApplicationIndex(appId) {
|
|
15031
15200
|
const dbResult = this.accountDb();
|
|
15032
|
-
if (!dbResult.ok) return (0,
|
|
15201
|
+
if (!dbResult.ok) return (0, import_sdk_services8.ok)(void 0);
|
|
15033
15202
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
15034
15203
|
if (!schema.ok) return schema;
|
|
15035
15204
|
const deleted = await dbResult.data.batch([
|
|
@@ -15037,14 +15206,14 @@ var AccountService = class {
|
|
|
15037
15206
|
{ sql: "DELETE FROM application_state WHERE app_id = ?", params: [appId] }
|
|
15038
15207
|
]);
|
|
15039
15208
|
if (!deleted.ok) return accountErr(deleted.error);
|
|
15040
|
-
return (0,
|
|
15209
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
15041
15210
|
}
|
|
15042
15211
|
async upsertSpaceIndexQuietly(space) {
|
|
15043
15212
|
await ignoreIndexFailure(() => this.upsertSpaceIndex(space));
|
|
15044
15213
|
}
|
|
15045
15214
|
async upsertSpaceIndex(space) {
|
|
15046
15215
|
const dbResult = this.accountDb();
|
|
15047
|
-
if (!dbResult.ok) return (0,
|
|
15216
|
+
if (!dbResult.ok) return (0, import_sdk_services8.ok)(void 0);
|
|
15048
15217
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
15049
15218
|
if (!schema.ok) return schema;
|
|
15050
15219
|
const updatedAt = space.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -15065,7 +15234,7 @@ var AccountService = class {
|
|
|
15065
15234
|
}
|
|
15066
15235
|
]);
|
|
15067
15236
|
if (!written.ok) return accountErr(written.error);
|
|
15068
|
-
return (0,
|
|
15237
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
15069
15238
|
}
|
|
15070
15239
|
async upsertSpacesIndexQuietly(spaces) {
|
|
15071
15240
|
await ignoreIndexFailure(() => this.upsertSpacesIndex(spaces));
|
|
@@ -15079,9 +15248,9 @@ var AccountService = class {
|
|
|
15079
15248
|
* atomically: all rows or none.
|
|
15080
15249
|
*/
|
|
15081
15250
|
async upsertSpacesIndex(spaces) {
|
|
15082
|
-
if (spaces.length === 0) return (0,
|
|
15251
|
+
if (spaces.length === 0) return (0, import_sdk_services8.ok)(void 0);
|
|
15083
15252
|
const dbResult = this.accountDb();
|
|
15084
|
-
if (!dbResult.ok) return (0,
|
|
15253
|
+
if (!dbResult.ok) return (0, import_sdk_services8.ok)(void 0);
|
|
15085
15254
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
15086
15255
|
if (!schema.ok) return schema;
|
|
15087
15256
|
const placeholders = spaces.map(() => "(?, ?, ?, ?, ?, ?, ?, ?, ?)").join(", ");
|
|
@@ -15106,21 +15275,21 @@ var AccountService = class {
|
|
|
15106
15275
|
}
|
|
15107
15276
|
]);
|
|
15108
15277
|
if (!written.ok) return accountErr(written.error);
|
|
15109
|
-
return (0,
|
|
15278
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
15110
15279
|
}
|
|
15111
15280
|
async deleteSpaceIndexQuietly(spaceId) {
|
|
15112
15281
|
await ignoreIndexFailure(() => this.deleteSpaceIndex(spaceId));
|
|
15113
15282
|
}
|
|
15114
15283
|
async deleteSpaceIndex(spaceId) {
|
|
15115
15284
|
const dbResult = this.accountDb();
|
|
15116
|
-
if (!dbResult.ok) return (0,
|
|
15285
|
+
if (!dbResult.ok) return (0, import_sdk_services8.ok)(void 0);
|
|
15117
15286
|
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
15118
15287
|
if (!schema.ok) return schema;
|
|
15119
15288
|
const deleted = await dbResult.data.batch([
|
|
15120
15289
|
{ sql: "DELETE FROM spaces WHERE space_id = ?", params: [spaceId] }
|
|
15121
15290
|
]);
|
|
15122
15291
|
if (!deleted.ok) return accountErr(deleted.error);
|
|
15123
|
-
return (0,
|
|
15292
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
15124
15293
|
}
|
|
15125
15294
|
/**
|
|
15126
15295
|
* Register every space the session can reach and return them. With
|
|
@@ -15140,7 +15309,7 @@ var AccountService = class {
|
|
|
15140
15309
|
spaces.push(result.data);
|
|
15141
15310
|
continue;
|
|
15142
15311
|
}
|
|
15143
|
-
if (!options2.tolerateStorageFull || !(0,
|
|
15312
|
+
if (!options2.tolerateStorageFull || !(0, import_sdk_services8.isStorageFullError)(result.error)) {
|
|
15144
15313
|
return result;
|
|
15145
15314
|
}
|
|
15146
15315
|
allRegistered = false;
|
|
@@ -15148,18 +15317,18 @@ var AccountService = class {
|
|
|
15148
15317
|
const record2 = spaceRecordFromInput(space);
|
|
15149
15318
|
spaces.push(spaceFromRecord(spaceKey(record2.space_id), record2));
|
|
15150
15319
|
}
|
|
15151
|
-
return (0,
|
|
15320
|
+
return (0, import_sdk_services8.ok)({ spaces, allRegistered });
|
|
15152
15321
|
}
|
|
15153
15322
|
async resolveSpace(space) {
|
|
15154
15323
|
const listed = await this.config.getSpaces().list();
|
|
15155
15324
|
if (!listed.ok) return accountErr(listed.error);
|
|
15156
15325
|
const found = listed.data.find((candidate) => candidate.id === space || candidate.name === space);
|
|
15157
15326
|
if (!found) {
|
|
15158
|
-
return (0,
|
|
15159
|
-
(0,
|
|
15327
|
+
return (0, import_sdk_services8.err)(
|
|
15328
|
+
(0, import_sdk_services8.serviceError)("SPACE_NOT_FOUND", `No account space found for ${JSON.stringify(space)}`, SERVICE_NAME2)
|
|
15160
15329
|
);
|
|
15161
15330
|
}
|
|
15162
|
-
return (0,
|
|
15331
|
+
return (0, import_sdk_services8.ok)(found);
|
|
15163
15332
|
}
|
|
15164
15333
|
async replaceApplicationsIndexQuietly(applications) {
|
|
15165
15334
|
await ignoreIndexFailure(async () => {
|
|
@@ -15301,7 +15470,7 @@ var AccountService = class {
|
|
|
15301
15470
|
]
|
|
15302
15471
|
});
|
|
15303
15472
|
if (!migrated.ok) return accountErr(migrated.error);
|
|
15304
|
-
return (0,
|
|
15473
|
+
return (0, import_sdk_services8.ok)(void 0);
|
|
15305
15474
|
}
|
|
15306
15475
|
};
|
|
15307
15476
|
function applicationKey(appId) {
|
|
@@ -15457,17 +15626,17 @@ function mapDelegation(delegation, space, direction) {
|
|
|
15457
15626
|
};
|
|
15458
15627
|
}
|
|
15459
15628
|
function accountErr(error) {
|
|
15460
|
-
return (0,
|
|
15629
|
+
return (0, import_sdk_services8.err)((0, import_sdk_services8.serviceError)(error.code, error.message, SERVICE_NAME2, { cause: error.cause, meta: error.meta }));
|
|
15461
15630
|
}
|
|
15462
15631
|
function isMissingIndexError(error) {
|
|
15463
15632
|
return /no such table:/i.test(error.message);
|
|
15464
15633
|
}
|
|
15465
15634
|
var AMBIGUOUS_WRITE_STATUSES = /* @__PURE__ */ new Set([500, 502, 503, 504, 520, 522, 524]);
|
|
15466
15635
|
function isAmbiguousBatchFailure(error) {
|
|
15467
|
-
if (error.code ===
|
|
15636
|
+
if (error.code === import_sdk_services8.ErrorCodes.NETWORK_ERROR || error.code === import_sdk_services8.ErrorCodes.TIMEOUT) {
|
|
15468
15637
|
return error.meta?.requestMayHaveDispatched === true;
|
|
15469
15638
|
}
|
|
15470
|
-
if (error.code ===
|
|
15639
|
+
if (error.code === import_sdk_services8.ErrorCodes.KV_WRITE_FAILED) {
|
|
15471
15640
|
const status = error.meta?.status;
|
|
15472
15641
|
return typeof status === "number" && AMBIGUOUS_WRITE_STATUSES.has(status);
|
|
15473
15642
|
}
|
|
@@ -15481,7 +15650,7 @@ async function ignoreIndexFailure(task) {
|
|
|
15481
15650
|
}
|
|
15482
15651
|
|
|
15483
15652
|
// src/index.ts
|
|
15484
|
-
var
|
|
15653
|
+
var import_sdk_services10 = require("@tinycloud/sdk-services");
|
|
15485
15654
|
|
|
15486
15655
|
// src/space.ts
|
|
15487
15656
|
async function fetchPeerId(host, spaceId, signal) {
|
|
@@ -15586,7 +15755,7 @@ async function postSessionActivation(host, delegationHeader, signal) {
|
|
|
15586
15755
|
}
|
|
15587
15756
|
|
|
15588
15757
|
// src/authorization/CapabilityKeyRegistry.ts
|
|
15589
|
-
var
|
|
15758
|
+
var import_sdk_services9 = require("@tinycloud/sdk-services");
|
|
15590
15759
|
var SERVICE_NAME3 = "capability-key-registry";
|
|
15591
15760
|
var CapabilityKeyRegistryErrorCodes = {
|
|
15592
15761
|
/** Key not found in registry */
|
|
@@ -15811,8 +15980,8 @@ var CapabilityKeyRegistry = class {
|
|
|
15811
15980
|
revokeDelegation(cid2) {
|
|
15812
15981
|
const stored = this.store.byCid.get(cid2);
|
|
15813
15982
|
if (!stored || stored.length === 0) {
|
|
15814
|
-
return (0,
|
|
15815
|
-
(0,
|
|
15983
|
+
return (0, import_sdk_services9.err)(
|
|
15984
|
+
(0, import_sdk_services9.serviceError)(
|
|
15816
15985
|
CapabilityKeyRegistryErrorCodes.KEY_NOT_FOUND,
|
|
15817
15986
|
`Delegation not found: ${cid2}`,
|
|
15818
15987
|
SERVICE_NAME3
|
|
@@ -15832,7 +16001,7 @@ var CapabilityKeyRegistry = class {
|
|
|
15832
16001
|
}
|
|
15833
16002
|
}
|
|
15834
16003
|
}
|
|
15835
|
-
return (0,
|
|
16004
|
+
return (0, import_sdk_services9.ok)(void 0);
|
|
15836
16005
|
}
|
|
15837
16006
|
// ===========================================================================
|
|
15838
16007
|
// Search
|
|
@@ -16496,8 +16665,14 @@ function diffImmutableSiweFields(original, signed, options2) {
|
|
|
16496
16665
|
function extractRecapAttenuations(siwe) {
|
|
16497
16666
|
const merged = {};
|
|
16498
16667
|
const lines = siwe.split(/\r?\n/);
|
|
16668
|
+
let resources = false;
|
|
16499
16669
|
for (const line of lines) {
|
|
16500
|
-
|
|
16670
|
+
if (line === "Resources:") {
|
|
16671
|
+
resources = true;
|
|
16672
|
+
continue;
|
|
16673
|
+
}
|
|
16674
|
+
if (!resources) continue;
|
|
16675
|
+
const match = line.match(/^- urn:recap:([A-Za-z0-9_-]+=*)$/);
|
|
16501
16676
|
if (!match) continue;
|
|
16502
16677
|
const encoded = match[1];
|
|
16503
16678
|
let decodedJson;
|