@tinycloud/sdk-core 3.11.0 → 3.12.0-beta.4

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/index.d.ts CHANGED
@@ -3419,6 +3419,27 @@ interface LocationRecordPayload {
3419
3419
  interface LocationRecord extends LocationRecordPayload {
3420
3420
  signature: string;
3421
3421
  }
3422
+ interface LocationRecordV2Payload {
3423
+ version: 2;
3424
+ subject: string;
3425
+ nodes: Array<{
3426
+ did: string;
3427
+ url: string;
3428
+ }>;
3429
+ spaces: Array<{
3430
+ space: string;
3431
+ nodes: Array<{
3432
+ did: string;
3433
+ mode: "read-write" | "read-only";
3434
+ }>;
3435
+ }>;
3436
+ encryptionNode: string | null;
3437
+ updated_at: string;
3438
+ sequence: number;
3439
+ }
3440
+ interface LocationRecordV2 extends LocationRecordV2Payload {
3441
+ signature: string;
3442
+ }
3422
3443
  interface VerifyOwnerNodeBindingOptions {
3423
3444
  /** Registry that serves the owner's signed location record. */
3424
3445
  registryUrl: string;
@@ -3630,6 +3651,11 @@ declare function signLocationRecord(payload: LocationRecordPayload, signer: Loca
3630
3651
  declare function validateLocationRecordPayload(input: unknown): LocationRecordPayload;
3631
3652
  declare function validateLocationRecord(input: unknown): LocationRecord;
3632
3653
  declare function verifyLocationRecord(input: LocationRecord): Promise<boolean>;
3654
+ declare function canonicalLocationPayloadV2(payload: LocationRecordV2Payload): string;
3655
+ declare function validateLocationRecordV2Payload(input: unknown): LocationRecordV2Payload;
3656
+ declare function validateLocationRecordV2(input: unknown): LocationRecordV2;
3657
+ declare function verifyLocationRecordV2(input: LocationRecordV2): Promise<boolean>;
3658
+ declare function signLocationRecordV2(payload: LocationRecordV2Payload, signer: LocationRecordSigner): Promise<LocationRecordV2>;
3633
3659
  declare function fetchLocationRecord(registryUrl: string, subject: string, fetchFn?: typeof fetch, signal?: AbortSignal): Promise<LocationRecord | null>;
3634
3660
  /**
3635
3661
  * Publish the active owner node as a subject-signed discovery record.
@@ -3660,6 +3686,7 @@ declare function resolveTinyCloudHosts(subject: string, options?: ResolveTinyClo
3660
3686
  */
3661
3687
  declare function discoverLocalTinyCloudNode(options?: DiscoverLocalTinyCloudNodeOptions): Promise<DiscoveredLocalTinyCloudNode | null>;
3662
3688
  declare function multiaddrToHttpUrl(input: string): string;
3689
+ declare function exactHttpOrigin(value: string, label: string): string;
3663
3690
  /**
3664
3691
  * Proves that an addressed-share target is the owner's published TinyCloud.
3665
3692
  *
@@ -3695,6 +3722,7 @@ declare function verifyDidKeyEd25519Signature(did: string, payload: Uint8Array,
3695
3722
  * classifier's rules are written to be portable: the shared vectors in
3696
3723
  * `test-vectors/registry-verdict/` state them for other implementations.
3697
3724
  */
3725
+
3698
3726
  type RegistryVerdictStatus = "registered" | "unregistered" | "unavailable";
3699
3727
  /** Which registry source produced a verdict. */
3700
3728
  type RegistryVerdictSource = "chain" | "chain-cache" | "offchain";
@@ -3729,23 +3757,29 @@ type RegistryUnavailableReason =
3729
3757
  /** The record signature does not verify for its subject. */
3730
3758
  | "invalid-signature"
3731
3759
  /** The record's sequence is below the remembered sequence. */
3732
- | "rollback"
3733
- /** The registry said "not found" for a subject remembered as registered. */
3734
- | "not-found-after-registered";
3760
+ | "rollback" | "not-found-after-registered"
3761
+ /** The owner has only a recognized record in the legacy registry format. */
3762
+ | "unsupported-format";
3735
3763
  interface RegisteredRegistryVerdict {
3736
3764
  readonly status: "registered";
3737
3765
  readonly subject: string;
3738
3766
  readonly source: RegistryVerdictSource;
3739
3767
  /** Sequence of the accepted record. Callers persist the maximum they have seen. */
3740
3768
  readonly sequence: number;
3769
+ /** Present for accepted signed-v2 records; absent for legacy classifiers. */
3770
+ readonly record?: LocationRecordV2;
3741
3771
  /** Listed hosts in record order. Empty when the record lists no usable host. */
3742
3772
  readonly hosts: readonly RegistryHost[];
3773
+ /** Routing used a reverified cache younger than one hour after an eligible outage. */
3774
+ readonly offline?: true;
3743
3775
  }
3744
3776
  interface UnregisteredRegistryVerdict {
3745
3777
  readonly status: "unregistered";
3746
3778
  readonly subject: string;
3747
3779
  readonly source: RegistryVerdictSource;
3748
3780
  readonly hosts: readonly [];
3781
+ /** Cold transport outage compatibility, not an authenticated registry absence. */
3782
+ readonly offline?: true;
3749
3783
  }
3750
3784
  interface UnavailableRegistryVerdict {
3751
3785
  readonly status: "unavailable";
@@ -3778,6 +3812,8 @@ interface ClassifyRegistryLookupOptions {
3778
3812
  * or an older record is `unavailable`, never `unregistered`.
3779
3813
  */
3780
3814
  rememberedSequence?: number | null;
3815
+ /** v1 remains available to non-routing callers; owner routing requests v2. */
3816
+ recordVersion?: 1 | 2;
3781
3817
  }
3782
3818
  type RegistryLookupInputErrorCode = "invalid-subject" | "invalid-remembered-sequence";
3783
3819
  /** The caller passed a lookup input that cannot be classified. */
@@ -3790,17 +3826,14 @@ declare const REGISTRY_LOOKUP_MAX_BODY_BYTES: number;
3790
3826
  /** The exact body of the location registry's 404 for a subject with no record. */
3791
3827
  declare const REGISTRY_NOT_FOUND_BODY = "{\"error\":\"location record not found\"}";
3792
3828
  /**
3793
- * Classify one off-chain location registry v1 response for `subject`.
3829
+ * Classify one off-chain location registry response for `subject`. The
3830
+ * default is v1 for legacy non-routing callers; v2 owner routing selects
3831
+ * `recordVersion: 2` and receives a verified owner record with node-bound
3832
+ * hosts.
3794
3833
  *
3795
- * Checks run in this order, and the first failure decides the reason:
3796
- * transport (`network-error`, `timeout`); status other than 200 or 404
3797
- * (`http-status`); body over 65536 UTF-8 bytes (`oversize-response`). A 404
3798
- * is `unregistered` only if its body, with leading and trailing JSON
3799
- * whitespace removed, is exactly {@link REGISTRY_NOT_FOUND_BODY} and no
3800
- * sequence is remembered. A 200 must be strict JSON holding a valid v1
3801
- * `record` (`malformed-response`) for exactly `subject`
3802
- * (`subject-mismatch`) whose signature verifies (`invalid-signature`) and
3803
- * whose sequence is not below the remembered one (`rollback`).
3834
+ * Both formats share strict transport, status, body-size, not-found, and
3835
+ * rollback classification. V2 additionally rejects unknown fields and binds
3836
+ * owner membership, node origins, and encryption destination to its signature.
3804
3837
  *
3805
3838
  * A 404 is unauthenticated: its exact bytes are the only evidence that the
3806
3839
  * registry itself answered.
@@ -3810,24 +3843,54 @@ declare const REGISTRY_NOT_FOUND_BODY = "{\"error\":\"location record not found\
3810
3843
  * `rememberedSequence` is not a non-negative safe integer.
3811
3844
  */
3812
3845
  declare function classifyRegistryLookup(subject: string, response: RegistryLookupResponse, options?: ClassifyRegistryLookupOptions): Promise<RegistryVerdict>;
3846
+ /** Settled chain-independent key shared by lookup, cache storage and signature owner binding. */
3847
+ declare function registryOwnerKeyV2(subject: string): string;
3848
+
3849
+ /** Storage metadata is outside the untouched signed HTTP response text. */
3850
+ interface RegistryCacheEntry {
3851
+ readonly ownerKey: string;
3852
+ readonly responseBody: string;
3853
+ readonly fetchedAt: number;
3854
+ readonly sequence: number;
3855
+ /** Local invalidation generation, not a signed sequence. Legacy entries omit it. */
3856
+ readonly revision?: number;
3857
+ }
3858
+ /** Durable negative state. No signed response bytes survive an invalidation. */
3859
+ interface RegistryCacheTombstone {
3860
+ readonly ownerKey: string;
3861
+ readonly revision: number;
3862
+ readonly invalidated: true;
3863
+ }
3864
+ type RegistryCacheRecord = RegistryCacheEntry | RegistryCacheTombstone;
3865
+ /** Entry, revision, update and invalidation guards share one serialized authority. */
3866
+ interface RegistryCacheStore {
3867
+ get(ownerKey: string): Promise<RegistryCacheEntry | undefined>;
3868
+ /** Legacy/absent state is zero; positive tombstone revisions retain known-owner evidence. */
3869
+ getRevision(ownerKey: string): Promise<number>;
3870
+ /** Pass the locked revision and preserve it regardless of callback-provided metadata. */
3871
+ update(ownerKey: string, update: (current: RegistryCacheEntry | undefined, revision: number) => Promise<RegistryCacheEntry>): Promise<RegistryCacheEntry>;
3872
+ /** Advance even when empty. Guard mismatches refuse without a write or counter advance. */
3873
+ delete(ownerKey: string, expectedRevision?: number, maximumSequence?: number): Promise<void>;
3874
+ }
3875
+ declare function createInMemoryRegistryCacheStore(): RegistryCacheStore;
3876
+ declare const DEFAULT_REGISTRY_CACHE_STORAGE_KEY = "tinycloud.registryCache.v2";
3877
+ /** Web Locks make the signature-check/compare/write atomic across browser tabs. */
3878
+ declare function createLocalStorageRegistryCacheStore(storage?: WebStorageLike, storageKey?: string): RegistryCacheStore;
3879
+ /** Every read, including comparison under the storage lock, uses the canonical verifier. */
3880
+ declare function verifyRegistryCacheEntry(subject: string, ownerKey: string, entry: RegistryCacheEntry, rememberedSequence?: number): Promise<RegisteredRegistryVerdict>;
3813
3881
 
3814
3882
  /**
3815
- * Registry policy for host resolution and space creation (TC-1443).
3816
- *
3817
- * - `legacy-fallback` (the default, deprecated): {@link resolveTinyCloudHosts}
3818
- * as before. A registry miss or failure silently routes to the hosted
3819
- * fallback node, with a one-time deprecation warning.
3820
- * - `fail-closed` (opt-in): routing and space creation act on the three-state
3821
- * registry verdict. `unavailable` is never treated as `unregistered`.
3883
+ * Signed-v2 registry policy for host resolution and space creation (TC-2481).
3884
+ * Every routing decision awaits a bounded refresh. A reverified cache younger
3885
+ * than one hour can serve transport/timeouts or HTTP 502/503/504 only.
3886
+ * Only verified absence permits onboarding; an outage without saved settings refuses.
3822
3887
  *
3823
- * Registry lookups key on the owner's signer address, never the session
3824
- * chain. The v1 registry stores records under an exact
3825
- * `did:pkh:eip155:<chain>:<EIP-55 address>` subject, so v1 lookups use
3826
- * {@link registryOwnerSubjectV1} with a configured chain (default 1). Registry
3827
- * v2 keys owner records on the EIP-55 address alone, chain-independent.
3888
+ * V2 owner keys are chain-independent: EOA records use the exact EIP-55
3889
+ * address and did:key records use the exact DID. V1 probes distinguish
3890
+ * legacy-only owners, never supply routing hosts.
3828
3891
  */
3829
3892
 
3830
- type RegistryPolicy = "legacy-fallback" | "fail-closed";
3893
+ type RegistryPolicy = "fail-closed";
3831
3894
  /** Chain of the v1 registry subject when none is configured. */
3832
3895
  declare const DEFAULT_REGISTRY_OWNER_CHAIN_ID = 1;
3833
3896
  /** Host for `unregistered` owners under `fail-closed` when none is configured. */
@@ -3835,7 +3898,10 @@ declare const DEFAULT_NEW_USER_HOST = "https://node.tinycloud.xyz";
3835
3898
  /** Budget for one registry lookup, covering the request and the body. */
3836
3899
  declare const DEFAULT_REGISTRY_LOOKUP_TIMEOUT_MS = 3000;
3837
3900
  /** Default key {@link createLocalStorageRegistrySequenceStore} stores its sequences under. */
3838
- declare const DEFAULT_REGISTRY_SEQUENCE_STORAGE_KEY = "tinycloud.registrySequences.v1";
3901
+ declare const DEFAULT_REGISTRY_SEQUENCE_STORAGE_KEY = "tinycloud.registrySequences.v2";
3902
+ /** Strict maximum age for cached routing during an eligible registry outage. */
3903
+ declare const REGISTRY_CACHE_MAX_AGE_MS = 3600000;
3904
+ type RegistryFallbackReason = "using_default_node" | "using_cached_settings";
3839
3905
  /**
3840
3906
  * The v1 registry subject for an owner: `did:pkh:eip155:<registryChainId>:<EIP-55 address>`.
3841
3907
  *
@@ -3849,11 +3915,10 @@ declare function registryOwnerSubjectV1(address: string, registryChainId?: numbe
3849
3915
  * sequence marks the subject as registered: a later not-found or an older
3850
3916
  * record is `unavailable`, never `unregistered`.
3851
3917
  *
3852
- * `set` is only called with a sequence above the remembered one. A `get`
3853
- * failure fails that lookup closed (`RegistryUnavailableError`, never
3854
- * "nothing remembered"). A `set` failure is logged once and the verdict in
3855
- * hand stands: failing to remember weakens later rollback detection but
3856
- * never turns a correct `registered` answer into a lockout.
3918
+ * Ordinary accepted-record `set` calls advance the remembered sequence; a
3919
+ * failure is logged once and the accepted verdict stands. A `get` failure
3920
+ * fails the lookup closed. Authoritative cache invalidation may restate the
3921
+ * current maximum and requires that marker write to succeed before deletion.
3857
3922
  */
3858
3923
  interface RegistrySequenceStore {
3859
3924
  get(subject: string): number | undefined | Promise<number | undefined>;
@@ -3868,31 +3933,36 @@ declare function createInMemoryRegistrySequenceStore(): RegistrySequenceStore;
3868
3933
  * read-only storage) is still remembered for this page. A storage read that
3869
3934
  * throws, or a corrupt stored value, throws instead of being reset:
3870
3935
  * forgetting a sequence would let a registry not-found read as
3871
- * `unregistered`. Remove `storageKey` to reset.
3936
+ * `unregistered`. Persistent merges require a storage-key Web Lock; write
3937
+ * failures still retain per-page memory and the resolver's best-effort policy.
3938
+ * Remove `storageKey` to reset persisted history.
3872
3939
  */
3873
3940
  declare function createLocalStorageRegistrySequenceStore(storage?: WebStorageLike, storageKey?: string): RegistrySequenceStore;
3874
3941
  interface ResolveOwnerHostsOptions {
3875
3942
  /** Location registry base URL. Default https://registry.tinycloud.xyz. */
3876
3943
  registryUrl?: string;
3877
- /** Remembered sequences. Omit to remember nothing. */
3944
+ /** Remembered v2 sequences keyed by EIP-55 address or exact did:key. */
3878
3945
  sequenceStore?: RegistrySequenceStore;
3946
+ /** Exact signed-v2 responses; verified on every read. */
3947
+ cacheStore?: RegistryCacheStore;
3879
3948
  /** Custom fetch implementation. Defaults to globalThis.fetch. */
3880
3949
  fetch?: typeof fetch;
3881
3950
  /** Lookup budget in milliseconds. Default {@link DEFAULT_REGISTRY_LOOKUP_TIMEOUT_MS}. */
3882
3951
  timeoutMs?: number;
3952
+ /** V1 format-probe chain for EOA owners. V2 lookup is chain-independent. */
3953
+ registryChainId?: number;
3883
3954
  }
3884
3955
  /**
3885
- * Look up `subject` in the off-chain v1 location registry and classify the
3886
- * answer with {@link classifyRegistryLookup}, using and updating the
3887
- * remembered sequence. Transport failures, timeouts and oversize or non-UTF-8
3888
- * bodies are `unavailable` verdicts. Performs no host probing and never
3889
- * applies a fallback.
3890
- *
3891
- * @throws RegistryLookupInputError if `subject` is not canonical or a
3892
- * remembered sequence is invalid. The subject is length-checked before any
3893
- * other parsing.
3956
+ * Read and reverify cached signed-v2 state before starting network refresh.
3957
+ * Cold lookups probe v1 after v2 absence (or a cold registry outage) so
3958
+ * recognized legacy records cannot authorize fallback. Sequence memory and
3959
+ * signed cache entries use the chain-independent v2 owner key.
3894
3960
  */
3895
3961
  declare function resolveOwnerHosts(subject: string, options?: ResolveOwnerHostsOptions): Promise<RegistryVerdict>;
3962
+ /** Coalesce overlapping refreshes only; every later decision starts a new lookup. */
3963
+ declare function refreshOwnerRegistry(subject: string, options: ResolveOwnerHostsOptions): Promise<RegistryVerdict>;
3964
+ /** Report only an actual cold default-node selection, never a background lookup. */
3965
+ declare function warnRegistryDefaultNode(verdict: RegistryVerdict, cacheStore?: RegistryCacheStore, onRegistryFallback?: (reason: string, code?: RegistryFallbackReason) => void): void;
3896
3966
  /** Sign-in found no usable host for a registered owner, or none for an unregistered owner when `newUserHost` is null. */
3897
3967
  declare class NodeNotFoundError extends Error {
3898
3968
  readonly subject: string;
@@ -3926,18 +3996,32 @@ declare class NodeRegistryEntryExistsError extends Error {
3926
3996
  constructor(subject: string, host: string, verdict: RegisteredRegistryVerdict);
3927
3997
  }
3928
3998
  interface LookupOwnerRegistryVerdictOptions {
3929
- /** Location registry base URL. `null` means none, which is `RegistryUnavailableError`. */
3999
+ /** Location registry base URL. `null` means none, which is unavailable. */
3930
4000
  registryUrl?: string | null;
3931
4001
  sequenceStore?: RegistrySequenceStore;
4002
+ cacheStore?: RegistryCacheStore;
3932
4003
  fetch?: typeof fetch;
3933
4004
  timeoutMs?: number;
4005
+ /** V1 format-probe chain for EOA owners. V2 lookup is chain-independent. */
4006
+ registryChainId?: number;
4007
+ /** Value-free warning only after a fallback route is selected. */
4008
+ onRegistryFallback?: (reason: string, code?: RegistryFallbackReason) => void;
3934
4009
  }
3935
4010
  /**
3936
- * {@link resolveOwnerHosts} for policy decisions: a lookup that throws, or no
3937
- * configured registry, becomes {@link RegistryUnavailableError}. An
3938
- * `unavailable` verdict is returned as a verdict.
4011
+ * {@link resolveOwnerHosts} for policy decisions: a lookup that throws, no
4012
+ * configured registry, or cold outage without saved settings becomes
4013
+ * {@link RegistryUnavailableError}. Other `unavailable` verdicts remain verdicts.
3939
4014
  */
3940
4015
  declare function lookupOwnerRegistryVerdict(subject: string, options?: LookupOwnerRegistryVerdictOptions): Promise<RegistryVerdict>;
4016
+ /**
4017
+ * Resolve one resource exclusively from a verified v2 owner record. A genuine
4018
+ * no-entry verdict returns no hosts for existing onboarding; a registered
4019
+ * resource with no authorized destination throws instead of falling back.
4020
+ */
4021
+ declare function resolveRegistryResource(subject: string, resource: string, access: "read" | "write" | "host" | "encryption", options: LookupOwnerRegistryVerdictOptions): Promise<{
4022
+ verdict: RegistryVerdict;
4023
+ hosts: RegistryHost[];
4024
+ }>;
3941
4025
  interface NodeNotFoundContext {
3942
4026
  readonly error: NodeNotFoundError | RegistryUnavailableError;
3943
4027
  /** 1 for the first failure, incremented after each `retry`. */
@@ -3952,16 +4036,12 @@ type NodeNotFoundDecision = {
3952
4036
  readonly action: "abort";
3953
4037
  };
3954
4038
  /**
3955
- * Decides what sign-in does when no host can be resolved under `fail-closed`:
3956
- * look up again, use another host, or abort with the error. A `use-host`
3957
- * host must be an HTTPS or loopback HTTP origin. The SDK does not verify its
3958
- * identity, and it persists with the session like any resolved host; space
3959
- * creation there still goes through the creation guard.
4039
+ * Decides what sign-in does when no host can be resolved under `fail-closed`.
4040
+ * A callback may retry or abort for any error; `use-host` is accepted only
4041
+ * for a genuine unregistered verdict with no configured host.
3960
4042
  */
3961
4043
  type OnNodeNotFound = (context: NodeNotFoundContext) => NodeNotFoundDecision | Promise<NodeNotFoundDecision>;
3962
4044
  interface FailClosedHostOptions extends LookupOwnerRegistryVerdictOptions {
3963
- /** Chain of the v1 registry subject. Default {@link DEFAULT_REGISTRY_OWNER_CHAIN_ID}. */
3964
- registryChainId?: number;
3965
4045
  /**
3966
4046
  * Host for owners the registry reports as `unregistered`, and only them.
3967
4047
  * Default {@link DEFAULT_NEW_USER_HOST}. `null`: unregistered owners get
@@ -3971,9 +4051,8 @@ interface FailClosedHostOptions extends LookupOwnerRegistryVerdictOptions {
3971
4051
  /** Without a callback, resolution throws the error. */
3972
4052
  onNodeNotFound?: OnNodeNotFound;
3973
4053
  /**
3974
- * Probe local nodes before routing on the verdict. Default true. Only
3975
- * configured candidates (`localNodeUrl`, `localLinkName`) and
3976
- * `*.local.tinycloud.link` hosts from a `registered` verdict are probed.
4054
+ * Probe configured local candidates only after genuine unregistration.
4055
+ * Discovery never overrides a registered or unavailable verdict.
3977
4056
  */
3978
4057
  autoDiscoverLocalNode?: boolean;
3979
4058
  localNodeUrl?: string;
@@ -3983,29 +4062,27 @@ interface FailClosedHostOptions extends LookupOwnerRegistryVerdictOptions {
3983
4062
  }
3984
4063
  interface FailClosedHosts {
3985
4064
  hosts: string[];
3986
- /** The registry verdict behind `hosts`. Absent when a verified local node was used. */
4065
+ /** The registry verdict behind `hosts`. */
3987
4066
  verdict?: RegistryVerdict;
3988
4067
  }
3989
4068
  /**
3990
- * Resolve the hosts for `address` under the `fail-closed` policy. The
3991
- * registry verdict for {@link registryOwnerSubjectV1} comes first. Then a
3992
- * verified local node is used if one is configured or listed by a
3993
- * `registered` verdict. Otherwise `registered` routes to the record's hosts
3994
- * (record order, HTTPS or loopback only), `unregistered` to `newUserHost`,
3995
- * and `unavailable` or a record without a usable host goes to
3996
- * `onNodeNotFound`, else throws.
4069
+ * Resolve the hosts for `address` under the `fail-closed` policy. A
4070
+ * registered v2 verdict routes only to its signed nodes; `unregistered`
4071
+ * routes to `newUserHost` or a configured verified local node. An unavailable
4072
+ * verdict or registered record without a usable host throws unless the
4073
+ * callback retries or aborts.
3997
4074
  */
3998
4075
  declare function resolveFailClosedTinyCloudHosts(address: string, options?: FailClosedHostOptions): Promise<FailClosedHosts>;
3999
4076
  /**
4000
- * The space-creation guard under `fail-closed`: creating a space on `host` is
4001
- * allowed for an `unregistered` owner, or for a `registered` owner whose
4002
- * record lists `host` as an HTTPS or loopback HTTP origin.
4077
+ * The replica-registration guard under `fail-closed`. Signed v2 verdicts require
4078
+ * the full `spaceId` and a listed node membership. Read-only members may register
4079
+ * a replica; ordinary writes are separately restricted to read-write members.
4003
4080
  *
4004
- * @throws NodeRegistryEntryExistsError for a registered owner whose record
4005
- * does not list `host` that way (including an empty record).
4081
+ * @throws NodeRegistryEntryExistsError when a registered owner does not list
4082
+ * the requested space on this host (including when v2 `spaceId` is omitted).
4006
4083
  * @throws RegistryUnavailableError for an `unavailable` verdict.
4007
4084
  */
4008
- declare function assertSpaceCreationAllowed(verdict: RegistryVerdict, host: string): void;
4085
+ declare function assertSpaceCreationAllowed(verdict: RegistryVerdict, host: string, spaceId?: string): void;
4009
4086
 
4010
4087
  /**
4011
4088
  * Default lifetimes for the various delegation shapes the SDK mints.
@@ -4059,4 +4136,4 @@ declare function assertExpiryWithinTechnicalLimit(expiresAt: Date | number, kind
4059
4136
  declare const DEFAULT_SIGNED_READ_URL_EXPIRY_MS: number;
4060
4137
  type ExpiryTier = keyof typeof EXPIRY;
4061
4138
 
4062
- export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, type AccountApplication, type AccountApplicationListOptions, type AccountApplicationRegisterOptions, type AccountDelegation, type AccountDelegationListOptions, AccountDelegationPage, AccountDelegationQueryOptions, type AccountDelegationRevokeOptions, type AccountIndexEnsureResult, type AccountIndexRebuildResult, type AccountIndexStatus, type AccountIndexedReadOptions, AccountService, type AccountServiceConfig, type AccountSpace, type AccountSpaceListOptions, type AccountStatus, AutoApproveSpaceCreationHandler, type AutoRejectStrategy, type AutoSignStrategy, type Bytes, CREDENTIAL_ERROR_CODES, type CallbackStrategy, type CanonicalAddress, type CanonicalParsedNetworkId, type CanonicalTinyCloudIdentity, type CapabilityPresentationEnvelopeV1, CaveatedDelegationUnsupportedError, type CheckChangedExpirationInput, type ClassifyRegistryLookupOptions, type ClientSession, ClientSessionSchema, CloudLocationResolutionError, type ComposeManifestOptions, type ComposedManifestRequest, type CreateDelegationFunction, CreateDelegationParams, CredentialError, type CredentialErrorCode, CredentialFlowDescriptor, CredentialHolderBinding, CredentialIssuerMetadata, CredentialRequirement, CredentialStorageReceipt, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, DEFAULT_KNOWLEDGE_ROOT, DEFAULT_LOCAL_NODE_PIN_STORAGE_KEY, DEFAULT_LOCAL_NODE_URL, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_NEW_USER_HOST, DEFAULT_REGISTRY_LOOKUP_TIMEOUT_MS, DEFAULT_REGISTRY_OWNER_CHAIN_ID, DEFAULT_REGISTRY_SEQUENCE_STORAGE_KEY, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DEFAULT_TINYCLOUD_FALLBACK_HOST, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, Delegation, DelegationManager, DelegationRevocationReceipt, type DidCacheKeyOptions, type DidEqualsOptions, type DiscoverLocalTinyCloudNodeOptions, type DiscoveredLocalTinyCloudNode, EMAIL_CREDENTIAL_MAX_AGE_SECONDS, EMAIL_DOMAIN_CREDENTIAL_MAX_AGE_SECONDS, ENCRYPTION_MANIFEST_SPACE, ENCRYPTION_PERMISSION_SERVICE, EXPIRY, type EnsData, EnsDataSchema, type EventEmitterStrategy, type ExpiryTier, type Extension, type FailClosedHostOptions, type FailClosedHosts, GenerateShareParams, ICapabilityKeyRegistry, type IENSResolver, type INotificationHandler, type ISessionManager, type ISessionStorage, ISharingService, type ISigner, type ISpace, type ISpaceCreationHandler, type ISpaceScopedDelegations, type ISpaceScopedSharing, type ISpaceService, type IUserAuthorization, type IWasmBindings, IdentityParseError, type ImmutableSiweFields, IssuedCredentialEnvelope, LOCAL_LINK_HOST_SUFFIX, LOCAL_LINK_PROBE_TIMEOUT_MS, LOCAL_LOOPBACK_PROBE_TIMEOUT_MS, type LocalNodeIdentityStore, type LocationCandidate, type LocationCandidateInput, type LocationRecord, type LocationRecordPayload, type LocationRecordSigner, LocationRecordValidationError, LocationRegistryHttpError, type LocationResolutionAttempt, type LocationSource, type LookupOwnerRegistryVerdictOptions, MAX_SIWE_EXPIRY_MS, MAX_UCAN_EXPIRY_MS, type Manifest, type ManifestDefaults, type ManifestKnowledge, type ManifestRegistryRecord, type ManifestSecretActions, ManifestValidationError, type NodeInfo, type NodeNotFoundContext, type NodeNotFoundDecision, NodeNotFoundError, NodeRegistryEntryExistsError, OPENKEY_ACTION_ID_SEPARATOR, OWNER_NODE_BINDING_TIMEOUT_MS, type OnNodeNotFound, type OpenKeyCallbackStrategy, type OpenKeyManageKeyCallbackStrategy, OpenKeyManageKeyError, type OpenKeyManageKeyErrorCode, type OpenKeyManageKeyFetch, type OpenKeyManageKeySigningRequestBody, type OpenKeyManageKeySigningResponseBody, type OpenKeyManageKeySigningStrategyOptions, type OpenKeySigningRequestBody, type OpenKeySigningResponseBody, type OpenKeySigningStrategyOptions, type ParseRecapFromSiwe, type PartialSiweMessage, type PermissionEntry, PermissionNotInManifestError, type PersistedSessionData, type PersistedSessionProof, type PersistedTinyCloudSession, type PkhDidParts, ProtocolMismatchError, type PublishLocationRecordOptions, REGISTRY_LOOKUP_MAX_BODY_BYTES, REGISTRY_NOT_FOUND_BODY, type RecapAttenuation, type RegisterBatchSuccess, type RegisteredRegistryVerdict, type RegistryHost, type RegistryHostSource, RegistryLookupInputError, type RegistryLookupInputErrorCode, type RegistryLookupResponse, type RegistryPolicy, type RegistrySequenceStore, RegistryUnavailableError, type RegistryUnavailableReason, type RegistryVerdict, type RegistryVerdictSource, type RegistryVerdictStatus, type ResolveCloudLocationOptions, type ResolveOwnerHostsOptions, type ResolveTinyCloudHostsOptions, type ResolvedCapabilities, type ResolvedCloudLocation, type ResolvedDelegate, type ResolvedTinyCloudHosts, type ResourceCapability, SECRETS_SPACE, SERVICE_LONG_TO_SHORT, SERVICE_SHORT_TO_LONG, type ServerHost, SessionExpiredError, ShareLink, type SignCallback, type SignInOptions, type SignRequest, type SignResponse, type SignStrategy, type SignedSiweCacao, SilentNotificationHandler, type SiweConfig, SiweConfigSchema, Space, type SpaceAbilitiesMap, type SpaceConfig, type SpaceCreationContext, type SpaceDelegationParams, type SpaceErrorCode, SpaceErrorCodes, type SpaceHostResult, SpaceInfo, SpaceService, type SpaceServiceConfig, StoredCredentialRecord, type SubsetCheckResult, TERMINAL_DELEGATION_FACT, TINYCLOUD_CANONICAL_IDENTITY_CLAIM, TINYCLOUD_MANAGE_KEY_SCOPE, type TechnicalExpiryKind, type TerminalDelegationSigningKey, TicketHolderBinding, TinyCloud, type TinyCloudAuthorizationRequestV1, type TinyCloudAuthorizationResultV1, type TinyCloudConfig, type TinyCloudEffectiveGrantV1, type TinyCloudSession, type UnavailableRegistryVerdict, type UnregisteredRegistryVerdict, UnsupportedFeatureError, type UserAuthorizationConfig, VAULT_PERMISSION_SERVICE, type ValidatedPersistedSessionProof, type ValidationError, VerifiedCredential, type VerifiedOwnerNodeBinding, type VerifyOwnerNodeBindingOptions, VersionCheckError, type WasmRecapEntry, type WebStorageLike, actionContains, activateSessionWithHost, addressStorageKey, applyPrefix, assertExpiryWithinTechnicalLimit, assertSpaceCreationAllowed, buildSpaceUri, canonicalDigest, canonicalLocationPayload, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeRecapCaveats, checkChangedExpiration, checkNodeInfo, classifyRegistryLookup, composeManifestRequest, createEmailCredentialRequirement, createEmailDomainCredentialRequirement, createHolderBinding, createInMemoryLocalNodeIdentityStore, createInMemoryRegistrySequenceStore, createLocalStorageLocalNodeIdentityStore, createLocalStorageRegistrySequenceStore, createOpenKeyCallbackSigningStrategy, createOpenKeyManageKeySigningStrategy, createSpaceService, createStorageReceipt, createStoredCredentialRecord, credentialEndpointPath, credentialError, credentialIndexKey, credentialMatchesRequirement, credentialRecordKey, credentialRequirementDigest, decodeBase64Url, defaultSignStrategy, defaultSpaceCreationHandler, descriptorSatisfiesRequirement, didCacheKey, didEquals, diffImmutableSiweFields, discoverLocalTinyCloudNode, encodeBase64Url, expandActionShortNames, expandDelegationPermissionEntries, expandPermissionEntries, expandPermissionEntry, expandRuntimePermissionEntries, extractImmutableSiweFields, extractRecapAttenuations, fetchLocationRecord, fetchPeerId, hasTinyCloudManageKeyScope, holderBindingCanonicalBytes, holderBindingSigningBytes, httpResponseError, httpUrlToMultiaddr, isCapabilitySubset, isDigest, isEvmAddress, isExplicitOnlyAction, isPlausibleOpenKeyActionId, loadManifest, locationPayloadForRecord, lookupOwnerRegistryVerdict, makePkhSpaceId, makePublicSpaceId, manifestAbilitiesUnion, markDelegationTerminal, multiaddrToHttpUrl, normalizeDefaults, parseCanonicalNetworkId, parseCanonicalRecapResource, parseCanonicalTinyCloudIdentity, parseCanonicalTinyCloudIdentityClaims, parseExpiry, parsePkhDid, parseRecapCapabilities, parseSignedSiweCacao, parseSpaceUri, pkhDid, principalDid, principalDidEquals, publishLocationRecord, recapCaveatsEqual, registryOwnerSubjectV1, requestTinyCloudManageKeyScope, resolveCloudLocation, resolveFailClosedTinyCloudHosts, resolveManifest, resolveManifestKnowledgeRoot, resolveOwnerHosts, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, sha256Base64Url, signLocationRecord, submitHostDelegation, technicalExpiryRefusal, unauthorizedRecapCapabilities, validateAuthorizationResultV1, validateClientSession, validateCredentialFlowDescriptor, validateCredentialHolderBinding, validateCredentialRequirement, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyDidKeyEd25519Signature, verifyEip191MessageSignature, verifyIssuedCredential, verifyLocationRecord, verifyOwnerNodeBinding, verifyStorageReceipt };
4139
+ export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, type AccountApplication, type AccountApplicationListOptions, type AccountApplicationRegisterOptions, type AccountDelegation, type AccountDelegationListOptions, AccountDelegationPage, AccountDelegationQueryOptions, type AccountDelegationRevokeOptions, type AccountIndexEnsureResult, type AccountIndexRebuildResult, type AccountIndexStatus, type AccountIndexedReadOptions, AccountService, type AccountServiceConfig, type AccountSpace, type AccountSpaceListOptions, type AccountStatus, AutoApproveSpaceCreationHandler, type AutoRejectStrategy, type AutoSignStrategy, type Bytes, CREDENTIAL_ERROR_CODES, type CallbackStrategy, type CanonicalAddress, type CanonicalParsedNetworkId, type CanonicalTinyCloudIdentity, type CapabilityPresentationEnvelopeV1, CaveatedDelegationUnsupportedError, type CheckChangedExpirationInput, type ClassifyRegistryLookupOptions, type ClientSession, ClientSessionSchema, CloudLocationResolutionError, type ComposeManifestOptions, type ComposedManifestRequest, type CreateDelegationFunction, CreateDelegationParams, CredentialError, type CredentialErrorCode, CredentialFlowDescriptor, CredentialHolderBinding, CredentialIssuerMetadata, CredentialRequirement, CredentialStorageReceipt, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, DEFAULT_KNOWLEDGE_ROOT, DEFAULT_LOCAL_NODE_PIN_STORAGE_KEY, DEFAULT_LOCAL_NODE_URL, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_NEW_USER_HOST, DEFAULT_REGISTRY_CACHE_STORAGE_KEY, DEFAULT_REGISTRY_LOOKUP_TIMEOUT_MS, DEFAULT_REGISTRY_OWNER_CHAIN_ID, DEFAULT_REGISTRY_SEQUENCE_STORAGE_KEY, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DEFAULT_TINYCLOUD_FALLBACK_HOST, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, Delegation, DelegationManager, DelegationRevocationReceipt, type DidCacheKeyOptions, type DidEqualsOptions, type DiscoverLocalTinyCloudNodeOptions, type DiscoveredLocalTinyCloudNode, EMAIL_CREDENTIAL_MAX_AGE_SECONDS, EMAIL_DOMAIN_CREDENTIAL_MAX_AGE_SECONDS, ENCRYPTION_MANIFEST_SPACE, ENCRYPTION_PERMISSION_SERVICE, EXPIRY, type EnsData, EnsDataSchema, type EventEmitterStrategy, type ExpiryTier, type Extension, type FailClosedHostOptions, type FailClosedHosts, GenerateShareParams, ICapabilityKeyRegistry, type IENSResolver, type INotificationHandler, type ISessionManager, type ISessionStorage, ISharingService, type ISigner, type ISpace, type ISpaceCreationHandler, type ISpaceScopedDelegations, type ISpaceScopedSharing, type ISpaceService, type IUserAuthorization, type IWasmBindings, IdentityParseError, type ImmutableSiweFields, IssuedCredentialEnvelope, LOCAL_LINK_HOST_SUFFIX, LOCAL_LINK_PROBE_TIMEOUT_MS, LOCAL_LOOPBACK_PROBE_TIMEOUT_MS, type LocalNodeIdentityStore, type LocationCandidate, type LocationCandidateInput, type LocationRecord, type LocationRecordPayload, type LocationRecordSigner, type LocationRecordV2, type LocationRecordV2Payload, LocationRecordValidationError, LocationRegistryHttpError, type LocationResolutionAttempt, type LocationSource, type LookupOwnerRegistryVerdictOptions, MAX_SIWE_EXPIRY_MS, MAX_UCAN_EXPIRY_MS, type Manifest, type ManifestDefaults, type ManifestKnowledge, type ManifestRegistryRecord, type ManifestSecretActions, ManifestValidationError, type NodeInfo, type NodeNotFoundContext, type NodeNotFoundDecision, NodeNotFoundError, NodeRegistryEntryExistsError, OPENKEY_ACTION_ID_SEPARATOR, OWNER_NODE_BINDING_TIMEOUT_MS, type OnNodeNotFound, type OpenKeyCallbackStrategy, type OpenKeyManageKeyCallbackStrategy, OpenKeyManageKeyError, type OpenKeyManageKeyErrorCode, type OpenKeyManageKeyFetch, type OpenKeyManageKeySigningRequestBody, type OpenKeyManageKeySigningResponseBody, type OpenKeyManageKeySigningStrategyOptions, type OpenKeySigningRequestBody, type OpenKeySigningResponseBody, type OpenKeySigningStrategyOptions, type ParseRecapFromSiwe, type PartialSiweMessage, type PermissionEntry, PermissionNotInManifestError, type PersistedSessionData, type PersistedSessionProof, type PersistedTinyCloudSession, type PkhDidParts, ProtocolMismatchError, type PublishLocationRecordOptions, REGISTRY_CACHE_MAX_AGE_MS, REGISTRY_LOOKUP_MAX_BODY_BYTES, REGISTRY_NOT_FOUND_BODY, type RecapAttenuation, type RegisterBatchSuccess, type RegisteredRegistryVerdict, type RegistryCacheEntry, type RegistryCacheRecord, type RegistryCacheStore, type RegistryCacheTombstone, type RegistryFallbackReason, type RegistryHost, type RegistryHostSource, RegistryLookupInputError, type RegistryLookupInputErrorCode, type RegistryLookupResponse, type RegistryPolicy, type RegistrySequenceStore, RegistryUnavailableError, type RegistryUnavailableReason, type RegistryVerdict, type RegistryVerdictSource, type RegistryVerdictStatus, type ResolveCloudLocationOptions, type ResolveOwnerHostsOptions, type ResolveTinyCloudHostsOptions, type ResolvedCapabilities, type ResolvedCloudLocation, type ResolvedDelegate, type ResolvedTinyCloudHosts, type ResourceCapability, SECRETS_SPACE, SERVICE_LONG_TO_SHORT, SERVICE_SHORT_TO_LONG, type ServerHost, SessionExpiredError, ShareLink, type SignCallback, type SignInOptions, type SignRequest, type SignResponse, type SignStrategy, type SignedSiweCacao, SilentNotificationHandler, type SiweConfig, SiweConfigSchema, Space, type SpaceAbilitiesMap, type SpaceConfig, type SpaceCreationContext, type SpaceDelegationParams, type SpaceErrorCode, SpaceErrorCodes, type SpaceHostResult, SpaceInfo, SpaceService, type SpaceServiceConfig, StoredCredentialRecord, type SubsetCheckResult, TERMINAL_DELEGATION_FACT, TINYCLOUD_CANONICAL_IDENTITY_CLAIM, TINYCLOUD_MANAGE_KEY_SCOPE, type TechnicalExpiryKind, type TerminalDelegationSigningKey, TicketHolderBinding, TinyCloud, type TinyCloudAuthorizationRequestV1, type TinyCloudAuthorizationResultV1, type TinyCloudConfig, type TinyCloudEffectiveGrantV1, type TinyCloudSession, type UnavailableRegistryVerdict, type UnregisteredRegistryVerdict, UnsupportedFeatureError, type UserAuthorizationConfig, VAULT_PERMISSION_SERVICE, type ValidatedPersistedSessionProof, type ValidationError, VerifiedCredential, type VerifiedOwnerNodeBinding, type VerifyOwnerNodeBindingOptions, VersionCheckError, type WasmRecapEntry, type WebStorageLike, actionContains, activateSessionWithHost, addressStorageKey, applyPrefix, assertExpiryWithinTechnicalLimit, assertSpaceCreationAllowed, buildSpaceUri, canonicalDigest, canonicalLocationPayload, canonicalLocationPayloadV2, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeRecapCaveats, checkChangedExpiration, checkNodeInfo, classifyRegistryLookup, composeManifestRequest, createEmailCredentialRequirement, createEmailDomainCredentialRequirement, createHolderBinding, createInMemoryLocalNodeIdentityStore, createInMemoryRegistryCacheStore, createInMemoryRegistrySequenceStore, createLocalStorageLocalNodeIdentityStore, createLocalStorageRegistryCacheStore, createLocalStorageRegistrySequenceStore, createOpenKeyCallbackSigningStrategy, createOpenKeyManageKeySigningStrategy, createSpaceService, createStorageReceipt, createStoredCredentialRecord, credentialEndpointPath, credentialError, credentialIndexKey, credentialMatchesRequirement, credentialRecordKey, credentialRequirementDigest, decodeBase64Url, defaultSignStrategy, defaultSpaceCreationHandler, descriptorSatisfiesRequirement, didCacheKey, didEquals, diffImmutableSiweFields, discoverLocalTinyCloudNode, encodeBase64Url, exactHttpOrigin, expandActionShortNames, expandDelegationPermissionEntries, expandPermissionEntries, expandPermissionEntry, expandRuntimePermissionEntries, extractImmutableSiweFields, extractRecapAttenuations, fetchLocationRecord, fetchPeerId, hasTinyCloudManageKeyScope, holderBindingCanonicalBytes, holderBindingSigningBytes, httpResponseError, httpUrlToMultiaddr, isCapabilitySubset, isDigest, isEvmAddress, isExplicitOnlyAction, isPlausibleOpenKeyActionId, loadManifest, locationPayloadForRecord, lookupOwnerRegistryVerdict, makePkhSpaceId, makePublicSpaceId, manifestAbilitiesUnion, markDelegationTerminal, multiaddrToHttpUrl, normalizeDefaults, parseCanonicalNetworkId, parseCanonicalRecapResource, parseCanonicalTinyCloudIdentity, parseCanonicalTinyCloudIdentityClaims, parseExpiry, parsePkhDid, parseRecapCapabilities, parseSignedSiweCacao, parseSpaceUri, pkhDid, principalDid, principalDidEquals, publishLocationRecord, recapCaveatsEqual, refreshOwnerRegistry, registryOwnerKeyV2, registryOwnerSubjectV1, requestTinyCloudManageKeyScope, resolveCloudLocation, resolveFailClosedTinyCloudHosts, resolveManifest, resolveManifestKnowledgeRoot, resolveOwnerHosts, resolveRegistryResource, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, sha256Base64Url, signLocationRecord, signLocationRecordV2, submitHostDelegation, technicalExpiryRefusal, unauthorizedRecapCapabilities, validateAuthorizationResultV1, validateClientSession, validateCredentialFlowDescriptor, validateCredentialHolderBinding, validateCredentialRequirement, validateLocationRecord, validateLocationRecordPayload, validateLocationRecordV2, validateLocationRecordV2Payload, validateManifest, validatePersistedSessionData, verifyDidKeyEd25519Signature, verifyEip191MessageSignature, verifyIssuedCredential, verifyLocationRecord, verifyLocationRecordV2, verifyOwnerNodeBinding, verifyRegistryCacheEntry, verifyStorageReceipt, warnRegistryDefaultNode };