@tinycloud/node-sdk 3.3.0-beta.18 → 3.3.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{TinyCloudNode-DmF9QUcS.d.cts → TinyCloudNode-BPDOmuf6.d.cts} +106 -4
- package/dist/{TinyCloudNode-DmF9QUcS.d.ts → TinyCloudNode-BPDOmuf6.d.ts} +106 -4
- package/dist/{authority-Cy5tMflt.d.cts → authority-21H2cKmO.d.cts} +1 -1
- package/dist/{authority-BY0jd0P3.d.ts → authority-C-pzOYXq.d.ts} +1 -1
- package/dist/core.cjs +114 -2
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +121 -2
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +114 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +121 -2
- package/dist/index.js.map +1 -1
- package/dist/replication/authority.d.cts +2 -2
- package/dist/replication/authority.d.ts +2 -2
- package/package.json +2 -2
package/dist/core.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ReplicationOptions } from '@tinycloud/sdk-core';
|
|
2
2
|
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AuthorityRefusal, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CanonicalAddress, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DidCacheKeyOptions, DidEqualsOptions, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, EncodedShareData, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVListPage, KVReadThrough, KVReplicaHandle, KVReplicaSpec, KVReplicaStorage, KVReplicationController, KVReplicationDeps, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, LocalGetResult, LocalListResult, LocalReadMeta, LocalReplicaStatus, LocalSyncResult, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, ParsedSecretCatalogKey, PendingWriteRecord, PendingWriteState, PendingWriteStore, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PinnedKey, PkhDidParts, PrefixedKVService, ProtocolMismatchError, PurgeTarget, QueryOptions, QueryResponse, ReceiveOptions, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ReplicaAuthorityState, ReplicaCoverage, ReplicaDevice, ReplicaGatedHandle, ReplicaGrantInfo, ReplicaInspectedStatus, ReplicaState, ReplicaStatusEntry, ReplicationAuthority, ReplicationControl, ReplicationEvent, ReplicationIdentity, ReplicationOptions, ReplicationPurgeReport, ReplicationReason, ReplicationScheduler, ResolvedCapabilities, ResolvedDelegate, ResolvedReplicationOptions, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TelemetryConfig, TelemetryEventHandler, TinyCloud, TinyCloudConfig, TinyCloudDebugEnableOptions, TinyCloudDebugEvent, TinyCloudDebugLevel, TinyCloudDebugLogger, TinyCloudDebugTimer, TinyCloudSession, UnsupportedFeatureError, VAULT_PERMISSION_SERVICE, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultNetworkReadResult, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, addressStorageKey, buildSpaceUri, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeSecretScope, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, didCacheKey, didEquals, disableTinyCloudDebug, enableTinyCloudDebug, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, loadManifest, makePkhSpaceId, makePublicSpaceId, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateManifest } from '@tinycloud/sdk-core';
|
|
3
3
|
import { _ as __gated_network } from './gated-network-BEF2XSTC.cjs';
|
|
4
|
-
import { _ as __authority } from './authority-
|
|
4
|
+
import { _ as __authority } from './authority-21H2cKmO.cjs';
|
|
5
5
|
import { _ as __runtime } from './runtime-D1o9Eybt.cjs';
|
|
6
6
|
import { ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
|
|
7
7
|
export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider } from './WasmKeyProvider-5Ee7fcAw.cjs';
|
|
8
|
-
export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, l as NodeUserAuthorizationConfig, p as OwnerDelegationReceipt, P as PortableDelegation, u as RuntimePermissionGrantOptions, S as SecretPermissionHint, v as SecretReadInput, w as SecretReadResult, y as SignStrategy, T as TinyCloudNode, z as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, F as UnifiedOwnerRootReceipt, G as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, J as activateCompactRuntimeDelegation, L as defaultSignStrategy, M as deserializeDelegation, W as serializeDelegation } from './TinyCloudNode-
|
|
8
|
+
export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, l as NodeUserAuthorizationConfig, p as OwnerDelegationReceipt, P as PortableDelegation, u as RuntimePermissionGrantOptions, S as SecretPermissionHint, v as SecretReadInput, w as SecretReadResult, y as SignStrategy, T as TinyCloudNode, z as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, F as UnifiedOwnerRootReceipt, G as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, J as activateCompactRuntimeDelegation, L as defaultSignStrategy, M as deserializeDelegation, W as serializeDelegation } from './TinyCloudNode-BPDOmuf6.cjs';
|
|
9
9
|
import '@tinycloud/sdk-services';
|
|
10
10
|
import 'events';
|
|
11
11
|
|
package/dist/core.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ReplicationOptions } from '@tinycloud/sdk-core';
|
|
2
2
|
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AuthorityRefusal, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CanonicalAddress, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DidCacheKeyOptions, DidEqualsOptions, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, EncodedShareData, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVListPage, KVReadThrough, KVReplicaHandle, KVReplicaSpec, KVReplicaStorage, KVReplicationController, KVReplicationDeps, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, LocalGetResult, LocalListResult, LocalReadMeta, LocalReplicaStatus, LocalSyncResult, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, ParsedSecretCatalogKey, PendingWriteRecord, PendingWriteState, PendingWriteStore, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PinnedKey, PkhDidParts, PrefixedKVService, ProtocolMismatchError, PurgeTarget, QueryOptions, QueryResponse, ReceiveOptions, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ReplicaAuthorityState, ReplicaCoverage, ReplicaDevice, ReplicaGatedHandle, ReplicaGrantInfo, ReplicaInspectedStatus, ReplicaState, ReplicaStatusEntry, ReplicationAuthority, ReplicationControl, ReplicationEvent, ReplicationIdentity, ReplicationOptions, ReplicationPurgeReport, ReplicationReason, ReplicationScheduler, ResolvedCapabilities, ResolvedDelegate, ResolvedReplicationOptions, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TelemetryConfig, TelemetryEventHandler, TinyCloud, TinyCloudConfig, TinyCloudDebugEnableOptions, TinyCloudDebugEvent, TinyCloudDebugLevel, TinyCloudDebugLogger, TinyCloudDebugTimer, TinyCloudSession, UnsupportedFeatureError, VAULT_PERMISSION_SERVICE, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultNetworkReadResult, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, addressStorageKey, buildSpaceUri, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeSecretScope, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, didCacheKey, didEquals, disableTinyCloudDebug, enableTinyCloudDebug, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, loadManifest, makePkhSpaceId, makePublicSpaceId, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateManifest } from '@tinycloud/sdk-core';
|
|
3
3
|
import { _ as __gated_network } from './gated-network-BEF2XSTC.js';
|
|
4
|
-
import { _ as __authority } from './authority-
|
|
4
|
+
import { _ as __authority } from './authority-C-pzOYXq.js';
|
|
5
5
|
import { _ as __runtime } from './runtime-v62FzQHz.js';
|
|
6
6
|
import { ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
|
|
7
7
|
export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider } from './WasmKeyProvider-5Ee7fcAw.js';
|
|
8
|
-
export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, l as NodeUserAuthorizationConfig, p as OwnerDelegationReceipt, P as PortableDelegation, u as RuntimePermissionGrantOptions, S as SecretPermissionHint, v as SecretReadInput, w as SecretReadResult, y as SignStrategy, T as TinyCloudNode, z as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, F as UnifiedOwnerRootReceipt, G as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, J as activateCompactRuntimeDelegation, L as defaultSignStrategy, M as deserializeDelegation, W as serializeDelegation } from './TinyCloudNode-
|
|
8
|
+
export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, l as NodeUserAuthorizationConfig, p as OwnerDelegationReceipt, P as PortableDelegation, u as RuntimePermissionGrantOptions, S as SecretPermissionHint, v as SecretReadInput, w as SecretReadResult, y as SignStrategy, T as TinyCloudNode, z as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, F as UnifiedOwnerRootReceipt, G as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, J as activateCompactRuntimeDelegation, L as defaultSignStrategy, M as deserializeDelegation, W as serializeDelegation } from './TinyCloudNode-BPDOmuf6.js';
|
|
9
9
|
import '@tinycloud/sdk-services';
|
|
10
10
|
import 'events';
|
|
11
11
|
|
package/dist/core.js
CHANGED
|
@@ -250,6 +250,11 @@ import {
|
|
|
250
250
|
resourceCapabilitiesToAbilitiesMap,
|
|
251
251
|
resourceCapabilitiesToSpaceAbilitiesMap,
|
|
252
252
|
resolveTinyCloudHosts,
|
|
253
|
+
resolveFailClosedTinyCloudHosts,
|
|
254
|
+
lookupOwnerRegistryVerdict,
|
|
255
|
+
assertSpaceCreationAllowed,
|
|
256
|
+
createInMemoryRegistrySequenceStore,
|
|
257
|
+
registryOwnerSubjectV1,
|
|
253
258
|
EXPIRY,
|
|
254
259
|
canonicalizeAddress,
|
|
255
260
|
makePkhSpaceId,
|
|
@@ -444,6 +449,11 @@ var NodeUserAuthorization = class {
|
|
|
444
449
|
this.tinycloudHosts = config.tinycloudHosts;
|
|
445
450
|
this.tinycloudRegistryUrl = config.tinycloudRegistryUrl;
|
|
446
451
|
this.tinycloudFallbackHosts = config.tinycloudFallbackHosts;
|
|
452
|
+
this.registryPolicy = config.registryPolicy;
|
|
453
|
+
this.newUserHost = config.newUserHost;
|
|
454
|
+
this.registryChainId = config.registryChainId;
|
|
455
|
+
this.registrySequenceStore = config.registrySequenceStore ?? createInMemoryRegistrySequenceStore();
|
|
456
|
+
this.onNodeNotFound = config.onNodeNotFound;
|
|
447
457
|
this.autoDiscoverLocalNode = config.autoDiscoverLocalNode;
|
|
448
458
|
this.localNodeUrl = config.localNodeUrl;
|
|
449
459
|
this.localLinkName = config.localLinkName;
|
|
@@ -555,6 +565,7 @@ var NodeUserAuthorization = class {
|
|
|
555
565
|
this._nodeFeaturesKnown = nodeFeatures !== void 0;
|
|
556
566
|
this._nodeInfoIdentity = void 0;
|
|
557
567
|
this.tinycloudHosts = hosts && hosts.length > 0 ? [...hosts] : void 0;
|
|
568
|
+
this.registryVerdict = void 0;
|
|
558
569
|
this._lastActivationSkippedSpaceIds = [];
|
|
559
570
|
this._lastActivationActivatedSpaceIds = [];
|
|
560
571
|
if (!session) {
|
|
@@ -605,6 +616,23 @@ var NodeUserAuthorization = class {
|
|
|
605
616
|
if (this.tinycloudHosts && this.tinycloudHosts.length > 0) {
|
|
606
617
|
return;
|
|
607
618
|
}
|
|
619
|
+
if (this.registryPolicy === "fail-closed") {
|
|
620
|
+
const resolved2 = await resolveFailClosedTinyCloudHosts(address, {
|
|
621
|
+
registryUrl: this.tinycloudRegistryUrl,
|
|
622
|
+
registryChainId: this.registryChainId,
|
|
623
|
+
newUserHost: this.newUserHost,
|
|
624
|
+
sequenceStore: this.registrySequenceStore,
|
|
625
|
+
onNodeNotFound: this.onNodeNotFound,
|
|
626
|
+
autoDiscoverLocalNode: this.autoDiscoverLocalNode,
|
|
627
|
+
localNodeUrl: this.localNodeUrl,
|
|
628
|
+
localLinkName: this.localLinkName,
|
|
629
|
+
expectedNodeDid: this.expectedNodeDid,
|
|
630
|
+
localNodeIdentityStore: this.localNodeIdentityStore
|
|
631
|
+
});
|
|
632
|
+
this.tinycloudHosts = resolved2.hosts;
|
|
633
|
+
this.registryVerdict = resolved2.verdict;
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
608
636
|
const subject = pkhDid(address, chainId);
|
|
609
637
|
const resolved = await resolveTinyCloudHosts(subject, {
|
|
610
638
|
registryUrl: this.tinycloudRegistryUrl,
|
|
@@ -617,6 +645,32 @@ var NodeUserAuthorization = class {
|
|
|
617
645
|
});
|
|
618
646
|
this.tinycloudHosts = resolved.hosts;
|
|
619
647
|
}
|
|
648
|
+
/**
|
|
649
|
+
* Space-creation guard (TC-1443). Under `registryPolicy: "fail-closed"`,
|
|
650
|
+
* throws unless the owner's registry verdict allows a space on the primary
|
|
651
|
+
* host: `NodeRegistryEntryExistsError` when the owner's record does not
|
|
652
|
+
* list it, `RegistryUnavailableError` when the registry gives no
|
|
653
|
+
* verdict. Reuses this session's sign-in verdict unless it was
|
|
654
|
+
* `unavailable`, else looks it up now (explicit-host apps). Under the
|
|
655
|
+
* default policy it returns at once and performs no lookup.
|
|
656
|
+
*/
|
|
657
|
+
async assertMayCreateSpace() {
|
|
658
|
+
if (this.registryPolicy !== "fail-closed") return;
|
|
659
|
+
if (this._address === void 0) {
|
|
660
|
+
throw new Error("Must be signed in to create a space");
|
|
661
|
+
}
|
|
662
|
+
await this.ensureTinyCloudHosts();
|
|
663
|
+
const subject = registryOwnerSubjectV1(this._address, this.registryChainId);
|
|
664
|
+
let verdict = this.registryVerdict;
|
|
665
|
+
if (verdict?.subject !== subject || verdict.status === "unavailable") {
|
|
666
|
+
verdict = await lookupOwnerRegistryVerdict(subject, {
|
|
667
|
+
registryUrl: this.tinycloudRegistryUrl,
|
|
668
|
+
sequenceStore: this.registrySequenceStore
|
|
669
|
+
});
|
|
670
|
+
this.registryVerdict = verdict;
|
|
671
|
+
}
|
|
672
|
+
assertSpaceCreationAllowed(verdict, this.primaryTinyCloudHost);
|
|
673
|
+
}
|
|
620
674
|
requireTinyCloudHosts() {
|
|
621
675
|
if (!this.tinycloudHosts || this.tinycloudHosts.length === 0) {
|
|
622
676
|
throw new Error("TinyCloud hosts have not been resolved. Call signIn() first.");
|
|
@@ -1065,6 +1119,7 @@ var NodeUserAuthorization = class {
|
|
|
1065
1119
|
if (!handler) {
|
|
1066
1120
|
return;
|
|
1067
1121
|
}
|
|
1122
|
+
await this.guardSpaceCreation(handler, creationContext);
|
|
1068
1123
|
const confirmed = await handler.confirmSpaceCreation(creationContext);
|
|
1069
1124
|
if (!confirmed) {
|
|
1070
1125
|
return;
|
|
@@ -1105,6 +1160,7 @@ var NodeUserAuthorization = class {
|
|
|
1105
1160
|
if (!handler) {
|
|
1106
1161
|
return;
|
|
1107
1162
|
}
|
|
1163
|
+
await this.guardSpaceCreation(handler, creationContext);
|
|
1108
1164
|
const confirmed = await handler.confirmSpaceCreation(creationContext);
|
|
1109
1165
|
if (!confirmed) {
|
|
1110
1166
|
return;
|
|
@@ -1146,6 +1202,16 @@ var NodeUserAuthorization = class {
|
|
|
1146
1202
|
{ cause: result }
|
|
1147
1203
|
);
|
|
1148
1204
|
}
|
|
1205
|
+
/** {@link assertMayCreateSpace}, reporting a refusal to the creation handler before rethrowing it. */
|
|
1206
|
+
async guardSpaceCreation(handler, context) {
|
|
1207
|
+
try {
|
|
1208
|
+
await this.assertMayCreateSpace();
|
|
1209
|
+
} catch (error) {
|
|
1210
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
1211
|
+
handler.onSpaceCreationFailed?.(context, failure);
|
|
1212
|
+
throw failure;
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1149
1215
|
recordActivationSkippedSpaces(result, primarySpaceId) {
|
|
1150
1216
|
if (result.success) {
|
|
1151
1217
|
this._lastActivationSkippedSpaceIds = result.skipped ?? [];
|
|
@@ -2533,6 +2599,8 @@ import {
|
|
|
2533
2599
|
canonicalizeAddress as canonicalizeAddress2,
|
|
2534
2600
|
pkhDid as pkhDid2,
|
|
2535
2601
|
resolveTinyCloudHosts as resolveTinyCloudHosts2,
|
|
2602
|
+
resolveFailClosedTinyCloudHosts as resolveFailClosedTinyCloudHosts2,
|
|
2603
|
+
createInMemoryRegistrySequenceStore as createInMemoryRegistrySequenceStore2,
|
|
2536
2604
|
publishLocationRecord,
|
|
2537
2605
|
principalDidEquals as principalDidEquals3,
|
|
2538
2606
|
parseNetworkId as parseNetworkId2,
|
|
@@ -3683,7 +3751,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3683
3751
|
this.explicitHost = config.host;
|
|
3684
3752
|
this.config = {
|
|
3685
3753
|
...config,
|
|
3686
|
-
host: config.host ?? DEFAULT_HOST
|
|
3754
|
+
host: config.host ?? DEFAULT_HOST,
|
|
3755
|
+
// One store for every authorization this client creates.
|
|
3756
|
+
registrySequenceStore: config.registrySequenceStore ?? createInMemoryRegistrySequenceStore2()
|
|
3687
3757
|
};
|
|
3688
3758
|
if (this.config.replication?.enabled) {
|
|
3689
3759
|
const runtime = getNodeReplicationLoaders().runtime().then(({ ReplicationRuntime }) => {
|
|
@@ -3953,6 +4023,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3953
4023
|
tinycloudHosts: this.explicitHost ? [this.explicitHost] : void 0,
|
|
3954
4024
|
tinycloudRegistryUrl: config.tinycloudRegistryUrl,
|
|
3955
4025
|
tinycloudFallbackHosts: config.tinycloudFallbackHosts,
|
|
4026
|
+
...this.registryPolicyConfig(),
|
|
3956
4027
|
autoDiscoverLocalNode: config.autoDiscoverLocalNode,
|
|
3957
4028
|
localNodeUrl: config.localNodeUrl,
|
|
3958
4029
|
localLinkName: config.localLinkName,
|
|
@@ -4658,6 +4729,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4658
4729
|
const primarySession = auth.tinyCloudSession;
|
|
4659
4730
|
const defaultSpaceId = this.ownedSpaceId("default");
|
|
4660
4731
|
const canReusePrimaryBootstrapSession = primarySession?.spaceId === defaultSpaceId && auth.capabilityRequest === BOOTSTRAP_SESSION_REQUESTS.default;
|
|
4732
|
+
if (steps.some((step) => step.kind === "host")) {
|
|
4733
|
+
await this.assertMayCreateSpace();
|
|
4734
|
+
}
|
|
4661
4735
|
for (const step of steps) {
|
|
4662
4736
|
if (step.kind !== "session") continue;
|
|
4663
4737
|
graph.assertActive();
|
|
@@ -5299,6 +5373,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5299
5373
|
{ cause: activation }
|
|
5300
5374
|
);
|
|
5301
5375
|
}
|
|
5376
|
+
await this.assertMayCreateSpace();
|
|
5377
|
+
if (signal?.aborted) throw signal.reason;
|
|
5302
5378
|
const created = await this.hostOwnedSpaceOnce(spaceId, signal);
|
|
5303
5379
|
if (!created.success) {
|
|
5304
5380
|
throw Object.assign(
|
|
@@ -5412,6 +5488,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5412
5488
|
* session's recap doesn't cover it and the registry has no record; the host
|
|
5413
5489
|
* SIWE is idempotent server-side. Must be called after {@link signIn}.
|
|
5414
5490
|
*
|
|
5491
|
+
* Under `registryPolicy: "fail-closed"`, hosting is refused with
|
|
5492
|
+
* `NodeRegistryEntryExistsError` when the owner's registry record does not
|
|
5493
|
+
* list the host, or `RegistryUnavailableError` when the registry gives no
|
|
5494
|
+
* verdict. {@link hostOwnedSpace} itself is an explicit action and is not
|
|
5495
|
+
* guarded.
|
|
5496
|
+
*
|
|
5415
5497
|
* @param name - The owned space name (e.g. `"secrets"`).
|
|
5416
5498
|
* @returns The hosted owned-space URI.
|
|
5417
5499
|
*/
|
|
@@ -5423,8 +5505,25 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5423
5505
|
if (this.hostedOwnedSpaceIds.has(spaceId) || await this.isOwnedSpaceRegistered(spaceId)) {
|
|
5424
5506
|
return spaceId;
|
|
5425
5507
|
}
|
|
5508
|
+
await this.assertMayCreateSpace();
|
|
5426
5509
|
return this.hostOwnedSpace(name);
|
|
5427
5510
|
}
|
|
5511
|
+
/**
|
|
5512
|
+
* Space-creation guard (TC-1443) for the automatic hosting paths: sign-in's
|
|
5513
|
+
* owned spaces, account bootstrap, {@link ensureOwnedSpaceHosted} and
|
|
5514
|
+
* {@link ensurePublicSpace}. Only `registryPolicy: "fail-closed"` consults
|
|
5515
|
+
* the registry ({@link NodeUserAuthorization.assertMayCreateSpace}); the
|
|
5516
|
+
* default policy performs no lookup.
|
|
5517
|
+
*/
|
|
5518
|
+
async assertMayCreateSpace() {
|
|
5519
|
+
if (this.config.registryPolicy !== "fail-closed") return;
|
|
5520
|
+
await this.auth.assertMayCreateSpace();
|
|
5521
|
+
}
|
|
5522
|
+
/** Registry-policy settings shared by every authorization this client creates. */
|
|
5523
|
+
registryPolicyConfig() {
|
|
5524
|
+
const { registryPolicy, newUserHost, registryChainId, registrySequenceStore, onNodeNotFound } = this.config;
|
|
5525
|
+
return { registryPolicy, newUserHost, registryChainId, registrySequenceStore, onNodeNotFound };
|
|
5526
|
+
}
|
|
5428
5527
|
/**
|
|
5429
5528
|
* Submit the host delegation for an owned space, sharing one in-flight
|
|
5430
5529
|
* request (and so one approval) between concurrent callers in this session,
|
|
@@ -6102,6 +6201,21 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6102
6201
|
if (address === void 0 || chainId === void 0) {
|
|
6103
6202
|
return void 0;
|
|
6104
6203
|
}
|
|
6204
|
+
if (this.config.registryPolicy === "fail-closed") {
|
|
6205
|
+
const resolved2 = await resolveFailClosedTinyCloudHosts2(address, {
|
|
6206
|
+
registryUrl: this.config.tinycloudRegistryUrl,
|
|
6207
|
+
registryChainId: this.config.registryChainId,
|
|
6208
|
+
newUserHost: this.config.newUserHost,
|
|
6209
|
+
sequenceStore: this.config.registrySequenceStore,
|
|
6210
|
+
onNodeNotFound: this.config.onNodeNotFound,
|
|
6211
|
+
autoDiscoverLocalNode: this.config.autoDiscoverLocalNode,
|
|
6212
|
+
localNodeUrl: this.config.localNodeUrl,
|
|
6213
|
+
localLinkName: this.config.localLinkName,
|
|
6214
|
+
expectedNodeDid: this.config.expectedNodeDid,
|
|
6215
|
+
localNodeIdentityStore: this.config.localNodeIdentityStore
|
|
6216
|
+
});
|
|
6217
|
+
return resolved2.hosts[0];
|
|
6218
|
+
}
|
|
6105
6219
|
const resolved = await resolveTinyCloudHosts2(pkhDid2(address, chainId), {
|
|
6106
6220
|
registryUrl: this.config.tinycloudRegistryUrl,
|
|
6107
6221
|
fallbackHosts: this.config.tinycloudFallbackHosts,
|
|
@@ -6294,6 +6408,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6294
6408
|
tinycloudHosts: this.explicitHost ? [this.explicitHost] : void 0,
|
|
6295
6409
|
tinycloudRegistryUrl: this.config.tinycloudRegistryUrl,
|
|
6296
6410
|
tinycloudFallbackHosts: this.config.tinycloudFallbackHosts,
|
|
6411
|
+
...this.registryPolicyConfig(),
|
|
6297
6412
|
autoDiscoverLocalNode: this.config.autoDiscoverLocalNode,
|
|
6298
6413
|
localNodeUrl: this.config.localNodeUrl,
|
|
6299
6414
|
localLinkName: this.config.localLinkName,
|
|
@@ -6353,6 +6468,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6353
6468
|
tinycloudHosts: this.explicitHost ? [this.explicitHost] : void 0,
|
|
6354
6469
|
tinycloudRegistryUrl: this.config.tinycloudRegistryUrl,
|
|
6355
6470
|
tinycloudFallbackHosts: this.config.tinycloudFallbackHosts,
|
|
6471
|
+
...this.registryPolicyConfig(),
|
|
6356
6472
|
autoDiscoverLocalNode: this.config.autoDiscoverLocalNode,
|
|
6357
6473
|
localNodeUrl: this.config.localNodeUrl,
|
|
6358
6474
|
localLinkName: this.config.localLinkName,
|
|
@@ -7990,7 +8106,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7990
8106
|
* Ensure the user's public space exists and is accessible.
|
|
7991
8107
|
* Creates the space and activates a session delegation for it.
|
|
7992
8108
|
* This is the trigger for lazy public space creation — call it
|
|
7993
|
-
* before writing to spaces.get('public').kv.
|
|
8109
|
+
* before writing to spaces.get('public').kv. The vault calls it on unlock.
|
|
8110
|
+
* Under `registryPolicy: "fail-closed"` creation goes through the
|
|
8111
|
+
* space-creation guard.
|
|
7994
8112
|
*/
|
|
7995
8113
|
async ensurePublicSpace() {
|
|
7996
8114
|
if (!this.auth || !this.session || !this.signer) {
|
|
@@ -8000,6 +8118,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8000
8118
|
if (!publicSpaceId) {
|
|
8001
8119
|
throw new Error("Public space not enabled. Set enablePublicSpace: true in config.");
|
|
8002
8120
|
}
|
|
8121
|
+
await this.assertMayCreateSpace();
|
|
8003
8122
|
await this.auth.hostPublicSpace(publicSpaceId);
|
|
8004
8123
|
const kvActions = [KV3.PUT, KV3.GET, KV3.DEL, KV3.LIST, KV3.METADATA];
|
|
8005
8124
|
const abilities = { kv: { "": kvActions } };
|