@tinycloud/node-sdk 3.8.0-beta.0 → 3.8.0-beta.2
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-BtKzLDJX.d.ts → TinyCloudNode-B6VOBrCb.d.ts} +15 -2
- package/dist/{TinyCloudNode-ggmlnSfI.d.cts → TinyCloudNode-CVO41O12.d.cts} +15 -2
- package/dist/{authority-sJ6buHMj.d.ts → authority-DGi1hIMK.d.ts} +21 -5
- package/dist/{authority-_SYAE-uV.d.cts → authority-DgVV80bI.d.cts} +21 -5
- package/dist/core.cjs +54 -17
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +3 -3
- package/dist/core.d.ts +3 -3
- package/dist/core.js +54 -17
- package/dist/core.js.map +1 -1
- package/dist/encryption-keys.d.cts +1 -1
- package/dist/encryption-keys.d.ts +1 -1
- package/dist/index.cjs +93 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +93 -18
- package/dist/index.js.map +1 -1
- package/dist/replication/authority.cjs +40 -1
- package/dist/replication/authority.cjs.map +1 -1
- package/dist/replication/authority.d.cts +2 -2
- package/dist/replication/authority.d.ts +2 -2
- package/dist/replication/authority.js +39 -1
- package/dist/replication/authority.js.map +1 -1
- package/dist/replication/runtime.cjs.map +1 -1
- package/dist/replication/runtime.d.cts +1 -1
- package/dist/replication/runtime.d.ts +1 -1
- package/dist/replication/runtime.js.map +1 -1
- package/dist/{runtime-v62FzQHz.d.ts → runtime-CO4VXnPq.d.ts} +2 -1
- package/dist/{runtime-D1o9Eybt.d.cts → runtime-mRhSu-vJ.d.cts} +2 -1
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _tinycloud_sdk_core from '@tinycloud/sdk-core';
|
|
2
2
|
import { AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, CapabilityPresentationEnvelopeV1, IUserAuthorization, ISigner, ISessionStorage, ISpaceCreationHandler, RegistryPolicy, RegistrySequenceStore, OnNodeNotFound, LocalNodeIdentityStore, IWasmBindings, ISessionManager, SiweConfig, Manifest, ComposedManifestRequest, ReplicationOptions, TinyCloudSession, PersistedSessionData, ClientSession, PermissionEntry, Extension, SignRequest, SpaceHostResult, SignInOptions, TelemetryConfig, ServiceContext, IKVService, ISQLService, IDuckDbService, IHooksService, CreateOwnerDelegationParams as CreateOwnerDelegationParams$1, OwnerDelegationReceipt as OwnerDelegationReceipt$1, Delegation, StorageFullEvent, IStorageService, INotificationHandler, IENSResolver, RetryPolicy, KVReplicaStorage, AccountService, InvokeAnyFunction as InvokeAnyFunction$1, UnifiedPolicyCapability, RegisterPolicyV3Input, RegisterPolicyV3Receipt, CanonicalJson, ShareDeliveryAuthorizationV3Receipt, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, DelegationResult, DelegationRevocationReceipt, DelegationStatus, ServiceSession, ReplicationControl, ResolvedDelegate } from '@tinycloud/sdk-core';
|
|
3
|
-
import { ReplicaSessionStamp } from '@tinycloud/sdk-services/kv/replication';
|
|
3
|
+
import { ReplicaPurgeFailedEvent, ReplicaSessionStamp } from '@tinycloud/sdk-services/kv/replication';
|
|
4
4
|
import { InvokeFunction, InvokeAnyFunction, FetchFunction, RequestSink, RequestLogReader } from '@tinycloud/sdk-services';
|
|
5
5
|
import { EventEmitter } from 'events';
|
|
6
6
|
import { P as PortableDelegation, S as SessionGrantProof, g as VerifiedSessionGrant } from './delegation-0LKZkmP2.js';
|
|
@@ -275,7 +275,7 @@ interface NodeUserAuthorizationConfig {
|
|
|
275
275
|
* unrestricted `get` covering it is already requested. Storage and
|
|
276
276
|
* scheduling never reach this layer.
|
|
277
277
|
*/
|
|
278
|
-
replication?: Pick<ReplicationOptions, "enabled" | "prefixes" | "allowSecrets">;
|
|
278
|
+
replication?: Pick<ReplicationOptions, "enabled" | "prefixes" | "allowSecrets" | "syncScope">;
|
|
279
279
|
/** Extra top-level resource URIs and their abilities added to the sign-in ReCap (e.g. named-key prefixes). */
|
|
280
280
|
additionalRawAbilities?: Record<string, string[]>;
|
|
281
281
|
/**
|
|
@@ -1292,6 +1292,7 @@ declare class TinyCloudNode {
|
|
|
1292
1292
|
private replicaRestoreGate?;
|
|
1293
1293
|
private replicaSessionPrincipal?;
|
|
1294
1294
|
private replicaSessionStamp?;
|
|
1295
|
+
private readonly replicaPurgeFailedHandlers;
|
|
1295
1296
|
/** Mints the replica session stamp on each fresh sign-in (TC-858 §4.1). Undefined when replication is off. */
|
|
1296
1297
|
private readonly establishReplicaStamp;
|
|
1297
1298
|
private readonly replicationControl?;
|
|
@@ -1421,6 +1422,12 @@ declare class TinyCloudNode {
|
|
|
1421
1422
|
* the unsubscribe function.
|
|
1422
1423
|
*/
|
|
1423
1424
|
on(event: "storage.full", handler: (event: StorageFullEvent) => void): () => void;
|
|
1425
|
+
/**
|
|
1426
|
+
* Subscribe to `replica.purge.failed`. It fires when the browser local copy could not be erased
|
|
1427
|
+
* after the bounded retries (sign-out, account switch or `purgeLocalCopy()`). The event carries the
|
|
1428
|
+
* typed gate reason and `retryNow`; the SDK retries again on the next load. Returns the unsubscribe function.
|
|
1429
|
+
*/
|
|
1430
|
+
on(event: "replica.purge.failed", handler: (event: ReplicaPurgeFailedEvent) => void): () => void;
|
|
1424
1431
|
/**
|
|
1425
1432
|
* Storage episode state for the UI mount. @internal
|
|
1426
1433
|
*
|
|
@@ -1611,6 +1618,12 @@ declare class TinyCloudNode {
|
|
|
1611
1618
|
*/
|
|
1612
1619
|
signOut(): Promise<void>;
|
|
1613
1620
|
private endSession;
|
|
1621
|
+
/**
|
|
1622
|
+
* Erases the browser local copy after a deny (retry, event and next-load marker live in the lazy
|
|
1623
|
+
* replication authority). Never rejects; `undefined` when replication is off or the storage keeps
|
|
1624
|
+
* no browser database.
|
|
1625
|
+
*/
|
|
1626
|
+
private eraseReplicaLocalCopy;
|
|
1614
1627
|
/**
|
|
1615
1628
|
* Step 1 of replica sign-out. Never rejects: failures come back as `unguarded` so the session
|
|
1616
1629
|
* is still cleared. Returns `undefined` when replication is off.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _tinycloud_sdk_core from '@tinycloud/sdk-core';
|
|
2
2
|
import { AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, CapabilityPresentationEnvelopeV1, IUserAuthorization, ISigner, ISessionStorage, ISpaceCreationHandler, RegistryPolicy, RegistrySequenceStore, OnNodeNotFound, LocalNodeIdentityStore, IWasmBindings, ISessionManager, SiweConfig, Manifest, ComposedManifestRequest, ReplicationOptions, TinyCloudSession, PersistedSessionData, ClientSession, PermissionEntry, Extension, SignRequest, SpaceHostResult, SignInOptions, TelemetryConfig, ServiceContext, IKVService, ISQLService, IDuckDbService, IHooksService, CreateOwnerDelegationParams as CreateOwnerDelegationParams$1, OwnerDelegationReceipt as OwnerDelegationReceipt$1, Delegation, StorageFullEvent, IStorageService, INotificationHandler, IENSResolver, RetryPolicy, KVReplicaStorage, AccountService, InvokeAnyFunction as InvokeAnyFunction$1, UnifiedPolicyCapability, RegisterPolicyV3Input, RegisterPolicyV3Receipt, CanonicalJson, ShareDeliveryAuthorizationV3Receipt, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, DelegationResult, DelegationRevocationReceipt, DelegationStatus, ServiceSession, ReplicationControl, ResolvedDelegate } from '@tinycloud/sdk-core';
|
|
3
|
-
import { ReplicaSessionStamp } from '@tinycloud/sdk-services/kv/replication';
|
|
3
|
+
import { ReplicaPurgeFailedEvent, ReplicaSessionStamp } from '@tinycloud/sdk-services/kv/replication';
|
|
4
4
|
import { InvokeFunction, InvokeAnyFunction, FetchFunction, RequestSink, RequestLogReader } from '@tinycloud/sdk-services';
|
|
5
5
|
import { EventEmitter } from 'events';
|
|
6
6
|
import { P as PortableDelegation, S as SessionGrantProof, g as VerifiedSessionGrant } from './delegation-0LKZkmP2.cjs';
|
|
@@ -275,7 +275,7 @@ interface NodeUserAuthorizationConfig {
|
|
|
275
275
|
* unrestricted `get` covering it is already requested. Storage and
|
|
276
276
|
* scheduling never reach this layer.
|
|
277
277
|
*/
|
|
278
|
-
replication?: Pick<ReplicationOptions, "enabled" | "prefixes" | "allowSecrets">;
|
|
278
|
+
replication?: Pick<ReplicationOptions, "enabled" | "prefixes" | "allowSecrets" | "syncScope">;
|
|
279
279
|
/** Extra top-level resource URIs and their abilities added to the sign-in ReCap (e.g. named-key prefixes). */
|
|
280
280
|
additionalRawAbilities?: Record<string, string[]>;
|
|
281
281
|
/**
|
|
@@ -1292,6 +1292,7 @@ declare class TinyCloudNode {
|
|
|
1292
1292
|
private replicaRestoreGate?;
|
|
1293
1293
|
private replicaSessionPrincipal?;
|
|
1294
1294
|
private replicaSessionStamp?;
|
|
1295
|
+
private readonly replicaPurgeFailedHandlers;
|
|
1295
1296
|
/** Mints the replica session stamp on each fresh sign-in (TC-858 §4.1). Undefined when replication is off. */
|
|
1296
1297
|
private readonly establishReplicaStamp;
|
|
1297
1298
|
private readonly replicationControl?;
|
|
@@ -1421,6 +1422,12 @@ declare class TinyCloudNode {
|
|
|
1421
1422
|
* the unsubscribe function.
|
|
1422
1423
|
*/
|
|
1423
1424
|
on(event: "storage.full", handler: (event: StorageFullEvent) => void): () => void;
|
|
1425
|
+
/**
|
|
1426
|
+
* Subscribe to `replica.purge.failed`. It fires when the browser local copy could not be erased
|
|
1427
|
+
* after the bounded retries (sign-out, account switch or `purgeLocalCopy()`). The event carries the
|
|
1428
|
+
* typed gate reason and `retryNow`; the SDK retries again on the next load. Returns the unsubscribe function.
|
|
1429
|
+
*/
|
|
1430
|
+
on(event: "replica.purge.failed", handler: (event: ReplicaPurgeFailedEvent) => void): () => void;
|
|
1424
1431
|
/**
|
|
1425
1432
|
* Storage episode state for the UI mount. @internal
|
|
1426
1433
|
*
|
|
@@ -1611,6 +1618,12 @@ declare class TinyCloudNode {
|
|
|
1611
1618
|
*/
|
|
1612
1619
|
signOut(): Promise<void>;
|
|
1613
1620
|
private endSession;
|
|
1621
|
+
/**
|
|
1622
|
+
* Erases the browser local copy after a deny (retry, event and next-load marker live in the lazy
|
|
1623
|
+
* replication authority). Never rejects; `undefined` when replication is off or the storage keeps
|
|
1624
|
+
* no browser database.
|
|
1625
|
+
*/
|
|
1626
|
+
private eraseReplicaLocalCopy;
|
|
1614
1627
|
/**
|
|
1615
1628
|
* Step 1 of replica sign-out. Never rejects: failures come back as `unguarded` so the session
|
|
1616
1629
|
* is still cleared. Returns `undefined` when replication is off.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReplicationOptions, PermissionEntry, TinyCloudSession, KVReplicaStorage, ServiceContext, IWasmBindings, WasmRecapEntry } from '@tinycloud/sdk-core';
|
|
2
2
|
import { ReplicaConsentAnchor, AuthorityRefusal, ReplicationAuthority } from '@tinycloud/sdk-services';
|
|
3
|
-
import { ReplicaSessionStamp, ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
|
|
4
|
-
import { T as TinyCloudNode } from './TinyCloudNode-
|
|
3
|
+
import { ReplicaLocalEraseOutcome, ReplicaPurgeLocalCopyResult, ReplicaPurgeTrigger, ReplicaPurgeFailedEvent, ReplicaSessionStamp, ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
|
|
4
|
+
import { T as TinyCloudNode } from './TinyCloudNode-B6VOBrCb.js';
|
|
5
5
|
|
|
6
6
|
/** Constructor-time validation; the space-dependent secrets check runs at sign-in and open. */
|
|
7
7
|
declare function assertValidReplicationConfig(replication: (ReplicationOptions & {
|
|
@@ -12,7 +12,7 @@ declare function hasUnrestrictedGetCoverage(entries: readonly PermissionEntry[],
|
|
|
12
12
|
declare function augmentSignInEntriesWithReplication(input: {
|
|
13
13
|
entries: readonly PermissionEntry[];
|
|
14
14
|
primarySpaceId: string;
|
|
15
|
-
replication?: Pick<ReplicationOptions, "prefixes" | "allowSecrets">;
|
|
15
|
+
replication?: Pick<ReplicationOptions, "prefixes" | "allowSecrets" | "syncScope">;
|
|
16
16
|
}): PermissionEntry[];
|
|
17
17
|
|
|
18
18
|
/** Report a completed deny from the already-loaded authority; delivery was revoked synchronously. */
|
|
@@ -21,6 +21,20 @@ declare function reportReplicaDenial(result: {
|
|
|
21
21
|
code?: string;
|
|
22
22
|
intents?: number;
|
|
23
23
|
}, reason: ReplicaDenyInput["reason"], onEvent: ReplicationOptions["onEvent"], context?: ServiceContext): void;
|
|
24
|
+
/** What the root needs after a local-copy erase: the outcome, the `purgeLocalCopy()` result and the marker state. */
|
|
25
|
+
interface ReplicaLocalEraseReport {
|
|
26
|
+
outcome: ReplicaLocalEraseOutcome;
|
|
27
|
+
purge: ReplicaPurgeLocalCopyResult;
|
|
28
|
+
/** The logout marker is set: the next load finishes the erase and the replica stays gated meanwhile. */
|
|
29
|
+
logoutPending?: true;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Erases the browser local copy after a deny, retrying a `failed` outcome with the delays above. After
|
|
33
|
+
* the last failure (or a refusal while the deny kept the keys) it notifies `handlers` with
|
|
34
|
+
* `replica.purge.failed`; the logout marker the lifecycle set makes the next load finish the erase.
|
|
35
|
+
* Never rejects. `undefined`: this storage has no browser local copy to erase.
|
|
36
|
+
*/
|
|
37
|
+
declare function eraseReplicaLocalCopy(lifecycle: KVReplicaStorage["lifecycle"], trigger: ReplicaPurgeTrigger, denyStatus: string | undefined, handlers: ReadonlySet<(event: ReplicaPurgeFailedEvent) => void>): Promise<ReplicaLocalEraseReport | undefined>;
|
|
24
38
|
/** The verified owner proof is signed, finite, exact-space, and uncaveated on one get+sync scope. */
|
|
25
39
|
declare function verifiedOwnerConsentAnchor(session: TinyCloudSession, wasmBindings: Pick<IWasmBindings, "validatePersistedSession">, exactVerifiedRecap: (verified: {
|
|
26
40
|
verifiedRecap?: unknown;
|
|
@@ -96,12 +110,14 @@ declare function createReplicationAuthority(host: ReplicationAuthorityHost): Rep
|
|
|
96
110
|
|
|
97
111
|
declare const __authority_AUTHORITY_EXPIRY_MARGIN_MS: typeof AUTHORITY_EXPIRY_MARGIN_MS;
|
|
98
112
|
type __authority_DelegationPlanResult = DelegationPlanResult;
|
|
113
|
+
type __authority_ReplicaLocalEraseReport = ReplicaLocalEraseReport;
|
|
99
114
|
type __authority_ReplicationAuthorityHost = ReplicationAuthorityHost;
|
|
100
115
|
type __authority_ReplicationAuthoritySession = ReplicationAuthoritySession;
|
|
101
116
|
declare const __authority_assertRenewalParent: typeof assertRenewalParent;
|
|
102
117
|
declare const __authority_assertValidReplicationConfig: typeof assertValidReplicationConfig;
|
|
103
118
|
declare const __authority_augmentSignInEntriesWithReplication: typeof augmentSignInEntriesWithReplication;
|
|
104
119
|
declare const __authority_createReplicationAuthority: typeof createReplicationAuthority;
|
|
120
|
+
declare const __authority_eraseReplicaLocalCopy: typeof eraseReplicaLocalCopy;
|
|
105
121
|
declare const __authority_establishReplicaSessionStamp: typeof establishReplicaSessionStamp;
|
|
106
122
|
declare const __authority_hasUnrestrictedGetCoverage: typeof hasUnrestrictedGetCoverage;
|
|
107
123
|
declare const __authority_mintNodeReplicationGrant: typeof mintNodeReplicationGrant;
|
|
@@ -112,7 +128,7 @@ declare const __authority_ucanAttCovers: typeof ucanAttCovers;
|
|
|
112
128
|
declare const __authority_ucanAttUnconstrainedFor: typeof ucanAttUnconstrainedFor;
|
|
113
129
|
declare const __authority_verifiedOwnerConsentAnchor: typeof verifiedOwnerConsentAnchor;
|
|
114
130
|
declare namespace __authority {
|
|
115
|
-
export { __authority_AUTHORITY_EXPIRY_MARGIN_MS as AUTHORITY_EXPIRY_MARGIN_MS, type __authority_DelegationPlanResult as DelegationPlanResult, type __authority_ReplicationAuthorityHost as ReplicationAuthorityHost, type __authority_ReplicationAuthoritySession as ReplicationAuthoritySession, __authority_assertRenewalParent as assertRenewalParent, __authority_assertValidReplicationConfig as assertValidReplicationConfig, __authority_augmentSignInEntriesWithReplication as augmentSignInEntriesWithReplication, __authority_createReplicationAuthority as createReplicationAuthority, __authority_establishReplicaSessionStamp as establishReplicaSessionStamp, __authority_hasUnrestrictedGetCoverage as hasUnrestrictedGetCoverage, __authority_mintNodeReplicationGrant as mintNodeReplicationGrant, __authority_replicationScopeFromSignedSession as replicationScopeFromSignedSession, __authority_reportReplicaDenial as reportReplicaDenial, __authority_restoreReplicaSessionStamp as restoreReplicaSessionStamp, __authority_ucanAttCovers as ucanAttCovers, __authority_ucanAttUnconstrainedFor as ucanAttUnconstrainedFor, __authority_verifiedOwnerConsentAnchor as verifiedOwnerConsentAnchor };
|
|
131
|
+
export { __authority_AUTHORITY_EXPIRY_MARGIN_MS as AUTHORITY_EXPIRY_MARGIN_MS, type __authority_DelegationPlanResult as DelegationPlanResult, type __authority_ReplicaLocalEraseReport as ReplicaLocalEraseReport, type __authority_ReplicationAuthorityHost as ReplicationAuthorityHost, type __authority_ReplicationAuthoritySession as ReplicationAuthoritySession, __authority_assertRenewalParent as assertRenewalParent, __authority_assertValidReplicationConfig as assertValidReplicationConfig, __authority_augmentSignInEntriesWithReplication as augmentSignInEntriesWithReplication, __authority_createReplicationAuthority as createReplicationAuthority, __authority_eraseReplicaLocalCopy as eraseReplicaLocalCopy, __authority_establishReplicaSessionStamp as establishReplicaSessionStamp, __authority_hasUnrestrictedGetCoverage as hasUnrestrictedGetCoverage, __authority_mintNodeReplicationGrant as mintNodeReplicationGrant, __authority_replicationScopeFromSignedSession as replicationScopeFromSignedSession, __authority_reportReplicaDenial as reportReplicaDenial, __authority_restoreReplicaSessionStamp as restoreReplicaSessionStamp, __authority_ucanAttCovers as ucanAttCovers, __authority_ucanAttUnconstrainedFor as ucanAttUnconstrainedFor, __authority_verifiedOwnerConsentAnchor as verifiedOwnerConsentAnchor };
|
|
116
132
|
}
|
|
117
133
|
|
|
118
|
-
export { AUTHORITY_EXPIRY_MARGIN_MS as A, type DelegationPlanResult as D, type
|
|
134
|
+
export { AUTHORITY_EXPIRY_MARGIN_MS as A, type DelegationPlanResult as D, type ReplicaLocalEraseReport as R, __authority as _, type ReplicationAuthorityHost as a, type ReplicationAuthoritySession as b, assertRenewalParent as c, assertValidReplicationConfig as d, augmentSignInEntriesWithReplication as e, createReplicationAuthority as f, eraseReplicaLocalCopy as g, establishReplicaSessionStamp as h, hasUnrestrictedGetCoverage as i, reportReplicaDenial as j, restoreReplicaSessionStamp as k, ucanAttUnconstrainedFor as l, mintNodeReplicationGrant as m, replicationScopeFromSignedSession as r, ucanAttCovers as u, verifiedOwnerConsentAnchor as v };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReplicationOptions, PermissionEntry, TinyCloudSession, KVReplicaStorage, ServiceContext, IWasmBindings, WasmRecapEntry } from '@tinycloud/sdk-core';
|
|
2
2
|
import { ReplicaConsentAnchor, AuthorityRefusal, ReplicationAuthority } from '@tinycloud/sdk-services';
|
|
3
|
-
import { ReplicaSessionStamp, ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
|
|
4
|
-
import { T as TinyCloudNode } from './TinyCloudNode-
|
|
3
|
+
import { ReplicaLocalEraseOutcome, ReplicaPurgeLocalCopyResult, ReplicaPurgeTrigger, ReplicaPurgeFailedEvent, ReplicaSessionStamp, ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
|
|
4
|
+
import { T as TinyCloudNode } from './TinyCloudNode-CVO41O12.cjs';
|
|
5
5
|
|
|
6
6
|
/** Constructor-time validation; the space-dependent secrets check runs at sign-in and open. */
|
|
7
7
|
declare function assertValidReplicationConfig(replication: (ReplicationOptions & {
|
|
@@ -12,7 +12,7 @@ declare function hasUnrestrictedGetCoverage(entries: readonly PermissionEntry[],
|
|
|
12
12
|
declare function augmentSignInEntriesWithReplication(input: {
|
|
13
13
|
entries: readonly PermissionEntry[];
|
|
14
14
|
primarySpaceId: string;
|
|
15
|
-
replication?: Pick<ReplicationOptions, "prefixes" | "allowSecrets">;
|
|
15
|
+
replication?: Pick<ReplicationOptions, "prefixes" | "allowSecrets" | "syncScope">;
|
|
16
16
|
}): PermissionEntry[];
|
|
17
17
|
|
|
18
18
|
/** Report a completed deny from the already-loaded authority; delivery was revoked synchronously. */
|
|
@@ -21,6 +21,20 @@ declare function reportReplicaDenial(result: {
|
|
|
21
21
|
code?: string;
|
|
22
22
|
intents?: number;
|
|
23
23
|
}, reason: ReplicaDenyInput["reason"], onEvent: ReplicationOptions["onEvent"], context?: ServiceContext): void;
|
|
24
|
+
/** What the root needs after a local-copy erase: the outcome, the `purgeLocalCopy()` result and the marker state. */
|
|
25
|
+
interface ReplicaLocalEraseReport {
|
|
26
|
+
outcome: ReplicaLocalEraseOutcome;
|
|
27
|
+
purge: ReplicaPurgeLocalCopyResult;
|
|
28
|
+
/** The logout marker is set: the next load finishes the erase and the replica stays gated meanwhile. */
|
|
29
|
+
logoutPending?: true;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Erases the browser local copy after a deny, retrying a `failed` outcome with the delays above. After
|
|
33
|
+
* the last failure (or a refusal while the deny kept the keys) it notifies `handlers` with
|
|
34
|
+
* `replica.purge.failed`; the logout marker the lifecycle set makes the next load finish the erase.
|
|
35
|
+
* Never rejects. `undefined`: this storage has no browser local copy to erase.
|
|
36
|
+
*/
|
|
37
|
+
declare function eraseReplicaLocalCopy(lifecycle: KVReplicaStorage["lifecycle"], trigger: ReplicaPurgeTrigger, denyStatus: string | undefined, handlers: ReadonlySet<(event: ReplicaPurgeFailedEvent) => void>): Promise<ReplicaLocalEraseReport | undefined>;
|
|
24
38
|
/** The verified owner proof is signed, finite, exact-space, and uncaveated on one get+sync scope. */
|
|
25
39
|
declare function verifiedOwnerConsentAnchor(session: TinyCloudSession, wasmBindings: Pick<IWasmBindings, "validatePersistedSession">, exactVerifiedRecap: (verified: {
|
|
26
40
|
verifiedRecap?: unknown;
|
|
@@ -96,12 +110,14 @@ declare function createReplicationAuthority(host: ReplicationAuthorityHost): Rep
|
|
|
96
110
|
|
|
97
111
|
declare const __authority_AUTHORITY_EXPIRY_MARGIN_MS: typeof AUTHORITY_EXPIRY_MARGIN_MS;
|
|
98
112
|
type __authority_DelegationPlanResult = DelegationPlanResult;
|
|
113
|
+
type __authority_ReplicaLocalEraseReport = ReplicaLocalEraseReport;
|
|
99
114
|
type __authority_ReplicationAuthorityHost = ReplicationAuthorityHost;
|
|
100
115
|
type __authority_ReplicationAuthoritySession = ReplicationAuthoritySession;
|
|
101
116
|
declare const __authority_assertRenewalParent: typeof assertRenewalParent;
|
|
102
117
|
declare const __authority_assertValidReplicationConfig: typeof assertValidReplicationConfig;
|
|
103
118
|
declare const __authority_augmentSignInEntriesWithReplication: typeof augmentSignInEntriesWithReplication;
|
|
104
119
|
declare const __authority_createReplicationAuthority: typeof createReplicationAuthority;
|
|
120
|
+
declare const __authority_eraseReplicaLocalCopy: typeof eraseReplicaLocalCopy;
|
|
105
121
|
declare const __authority_establishReplicaSessionStamp: typeof establishReplicaSessionStamp;
|
|
106
122
|
declare const __authority_hasUnrestrictedGetCoverage: typeof hasUnrestrictedGetCoverage;
|
|
107
123
|
declare const __authority_mintNodeReplicationGrant: typeof mintNodeReplicationGrant;
|
|
@@ -112,7 +128,7 @@ declare const __authority_ucanAttCovers: typeof ucanAttCovers;
|
|
|
112
128
|
declare const __authority_ucanAttUnconstrainedFor: typeof ucanAttUnconstrainedFor;
|
|
113
129
|
declare const __authority_verifiedOwnerConsentAnchor: typeof verifiedOwnerConsentAnchor;
|
|
114
130
|
declare namespace __authority {
|
|
115
|
-
export { __authority_AUTHORITY_EXPIRY_MARGIN_MS as AUTHORITY_EXPIRY_MARGIN_MS, type __authority_DelegationPlanResult as DelegationPlanResult, type __authority_ReplicationAuthorityHost as ReplicationAuthorityHost, type __authority_ReplicationAuthoritySession as ReplicationAuthoritySession, __authority_assertRenewalParent as assertRenewalParent, __authority_assertValidReplicationConfig as assertValidReplicationConfig, __authority_augmentSignInEntriesWithReplication as augmentSignInEntriesWithReplication, __authority_createReplicationAuthority as createReplicationAuthority, __authority_establishReplicaSessionStamp as establishReplicaSessionStamp, __authority_hasUnrestrictedGetCoverage as hasUnrestrictedGetCoverage, __authority_mintNodeReplicationGrant as mintNodeReplicationGrant, __authority_replicationScopeFromSignedSession as replicationScopeFromSignedSession, __authority_reportReplicaDenial as reportReplicaDenial, __authority_restoreReplicaSessionStamp as restoreReplicaSessionStamp, __authority_ucanAttCovers as ucanAttCovers, __authority_ucanAttUnconstrainedFor as ucanAttUnconstrainedFor, __authority_verifiedOwnerConsentAnchor as verifiedOwnerConsentAnchor };
|
|
131
|
+
export { __authority_AUTHORITY_EXPIRY_MARGIN_MS as AUTHORITY_EXPIRY_MARGIN_MS, type __authority_DelegationPlanResult as DelegationPlanResult, type __authority_ReplicaLocalEraseReport as ReplicaLocalEraseReport, type __authority_ReplicationAuthorityHost as ReplicationAuthorityHost, type __authority_ReplicationAuthoritySession as ReplicationAuthoritySession, __authority_assertRenewalParent as assertRenewalParent, __authority_assertValidReplicationConfig as assertValidReplicationConfig, __authority_augmentSignInEntriesWithReplication as augmentSignInEntriesWithReplication, __authority_createReplicationAuthority as createReplicationAuthority, __authority_eraseReplicaLocalCopy as eraseReplicaLocalCopy, __authority_establishReplicaSessionStamp as establishReplicaSessionStamp, __authority_hasUnrestrictedGetCoverage as hasUnrestrictedGetCoverage, __authority_mintNodeReplicationGrant as mintNodeReplicationGrant, __authority_replicationScopeFromSignedSession as replicationScopeFromSignedSession, __authority_reportReplicaDenial as reportReplicaDenial, __authority_restoreReplicaSessionStamp as restoreReplicaSessionStamp, __authority_ucanAttCovers as ucanAttCovers, __authority_ucanAttUnconstrainedFor as ucanAttUnconstrainedFor, __authority_verifiedOwnerConsentAnchor as verifiedOwnerConsentAnchor };
|
|
116
132
|
}
|
|
117
133
|
|
|
118
|
-
export { AUTHORITY_EXPIRY_MARGIN_MS as A, type DelegationPlanResult as D, type
|
|
134
|
+
export { AUTHORITY_EXPIRY_MARGIN_MS as A, type DelegationPlanResult as D, type ReplicaLocalEraseReport as R, __authority as _, type ReplicationAuthorityHost as a, type ReplicationAuthoritySession as b, assertRenewalParent as c, assertValidReplicationConfig as d, augmentSignInEntriesWithReplication as e, createReplicationAuthority as f, eraseReplicaLocalCopy as g, establishReplicaSessionStamp as h, hasUnrestrictedGetCoverage as i, reportReplicaDenial as j, restoreReplicaSessionStamp as k, ucanAttUnconstrainedFor as l, mintNodeReplicationGrant as m, replicationScopeFromSignedSession as r, ucanAttCovers as u, verifiedOwnerConsentAnchor as v };
|
package/dist/core.cjs
CHANGED
|
@@ -375,7 +375,7 @@ function augmentSignInEntriesWithReplication(input) {
|
|
|
375
375
|
}
|
|
376
376
|
eligiblePaths.push(path);
|
|
377
377
|
}
|
|
378
|
-
if (eligiblePaths.length === replication.prefixes.length && eligiblePaths.length > 0 && hasUnrestrictedGetCoverage(input.entries, input.primarySpaceId, "")) {
|
|
378
|
+
if (replication.syncScope !== "prefixes" && eligiblePaths.length === replication.prefixes.length && eligiblePaths.length > 0 && hasUnrestrictedGetCoverage(input.entries, input.primarySpaceId, "")) {
|
|
379
379
|
return [{
|
|
380
380
|
service: KV_SERVICE,
|
|
381
381
|
space: input.primarySpaceId,
|
|
@@ -3735,6 +3735,7 @@ function replicaRestoreRefusal(error) {
|
|
|
3735
3735
|
case "purge_pending":
|
|
3736
3736
|
case "logout_pending":
|
|
3737
3737
|
case "gate_unavailable":
|
|
3738
|
+
case "wallet_provider_required":
|
|
3738
3739
|
return error.gate;
|
|
3739
3740
|
}
|
|
3740
3741
|
}
|
|
@@ -3769,6 +3770,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3769
3770
|
this.auth = null;
|
|
3770
3771
|
this.tc = null;
|
|
3771
3772
|
this._chainId = 1;
|
|
3773
|
+
this.replicaPurgeFailedHandlers = /* @__PURE__ */ new Set();
|
|
3772
3774
|
/** Mints the replica session stamp on each fresh sign-in (TC-858 §4.1). Undefined when replication is off. */
|
|
3773
3775
|
this.establishReplicaStamp = async (session) => {
|
|
3774
3776
|
const replication = this.config.replication;
|
|
@@ -3975,6 +3977,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3975
3977
|
return instance ? instance.control.purge(input) : runtime.then((ready) => ready.control.purge(input));
|
|
3976
3978
|
},
|
|
3977
3979
|
clearPending: async () => (await runtime).control.clearPending(),
|
|
3980
|
+
purgeLocalCopy: async () => (await this.eraseReplicaLocalCopy("purge_local_copy"))?.purge ?? { ok: false, retryNow: false },
|
|
3978
3981
|
close: async () => (await runtime).control.close()
|
|
3979
3982
|
};
|
|
3980
3983
|
}
|
|
@@ -4029,18 +4032,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4029
4032
|
get freshEncryptionNetworkCreated() {
|
|
4030
4033
|
return this._freshEncryptionNetworkCreated;
|
|
4031
4034
|
}
|
|
4032
|
-
/**
|
|
4033
|
-
* Subscribe to `storage.full`. It fires on the first write any service had
|
|
4034
|
-
* rejected because the owner's TinyCloud storage is full
|
|
4035
|
-
* (`STORAGE_QUOTA_EXCEEDED` or `STORAGE_LIMIT_REACHED`), so an app can show
|
|
4036
|
-
* one read-only banner. Reads keep working. For the signed-in account's own
|
|
4037
|
-
* storage it fires once per episode: the episode ends only when a write to
|
|
4038
|
-
* that storage succeeds, or on sign-out. A `storage.status()` read does not
|
|
4039
|
-
* end it. A rejection on another owner's delegated space fires once per
|
|
4040
|
-
* owner, until that owner's `storage.status()` reports space again. Returns
|
|
4041
|
-
* the unsubscribe function.
|
|
4042
|
-
*/
|
|
4043
4035
|
on(event, handler) {
|
|
4036
|
+
if (event === "replica.purge.failed") {
|
|
4037
|
+
const listener = handler;
|
|
4038
|
+
this.replicaPurgeFailedHandlers.add(listener);
|
|
4039
|
+
return () => {
|
|
4040
|
+
this.replicaPurgeFailedHandlers.delete(listener);
|
|
4041
|
+
};
|
|
4042
|
+
}
|
|
4044
4043
|
if (event !== "storage.full") {
|
|
4045
4044
|
throw new Error(`Unknown TinyCloud event: ${String(event)}`);
|
|
4046
4045
|
}
|
|
@@ -4260,7 +4259,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4260
4259
|
replication: config.replication?.enabled === true ? {
|
|
4261
4260
|
enabled: true,
|
|
4262
4261
|
prefixes: config.replication.prefixes,
|
|
4263
|
-
allowSecrets: config.replication.allowSecrets === true
|
|
4262
|
+
allowSecrets: config.replication.allowSecrets === true,
|
|
4263
|
+
syncScope: config.replication.syncScope
|
|
4264
4264
|
} : void 0
|
|
4265
4265
|
});
|
|
4266
4266
|
this.tc = new import_sdk_core11.TinyCloud(this.auth, {
|
|
@@ -4520,6 +4520,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4520
4520
|
const leavingAuth = this.auth;
|
|
4521
4521
|
const leavingContext = this._serviceContext;
|
|
4522
4522
|
let denied;
|
|
4523
|
+
let erased;
|
|
4523
4524
|
try {
|
|
4524
4525
|
this.teardownSession();
|
|
4525
4526
|
} finally {
|
|
@@ -4530,6 +4531,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4530
4531
|
try {
|
|
4531
4532
|
await this.accountRegistryTail;
|
|
4532
4533
|
await this.quiesceReplicaRuntime();
|
|
4534
|
+
if (denied) erased = await this.eraseReplicaLocalCopy("sign_out", denied.status);
|
|
4533
4535
|
} finally {
|
|
4534
4536
|
if (leavingAddress) {
|
|
4535
4537
|
await (leavingAuth ? leavingAuth.clearPersistedSession(leavingAddress) : this.config.sessionStorage?.clear(leavingAddress));
|
|
@@ -4537,8 +4539,37 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4537
4539
|
}
|
|
4538
4540
|
}
|
|
4539
4541
|
}
|
|
4540
|
-
if (denied?.status === "unguarded") {
|
|
4541
|
-
throw
|
|
4542
|
+
if (denied?.status === "unguarded" && erased?.outcome.status !== "erased") {
|
|
4543
|
+
throw Object.assign(
|
|
4544
|
+
new Error(`Replica gate was not denied (${denied.code ?? "unknown"}); the replica may still be restorable.`),
|
|
4545
|
+
{
|
|
4546
|
+
code: "REPLICA_PURGE_FAILED",
|
|
4547
|
+
reason: "gate_unavailable",
|
|
4548
|
+
retryNow: erased?.outcome.status === "failed"
|
|
4549
|
+
}
|
|
4550
|
+
);
|
|
4551
|
+
}
|
|
4552
|
+
}
|
|
4553
|
+
/**
|
|
4554
|
+
* Erases the browser local copy after a deny (retry, event and next-load marker live in the lazy
|
|
4555
|
+
* replication authority). Never rejects; `undefined` when replication is off or the storage keeps
|
|
4556
|
+
* no browser database.
|
|
4557
|
+
*/
|
|
4558
|
+
async eraseReplicaLocalCopy(trigger, denyStatus) {
|
|
4559
|
+
const replication = this.config.replication;
|
|
4560
|
+
if (!replication?.enabled) return void 0;
|
|
4561
|
+
try {
|
|
4562
|
+
const { eraseReplicaLocalCopy } = await getNodeReplicationLoaders().authority();
|
|
4563
|
+
const erased = await eraseReplicaLocalCopy(
|
|
4564
|
+
replication.storage.lifecycle,
|
|
4565
|
+
trigger,
|
|
4566
|
+
denyStatus,
|
|
4567
|
+
this.replicaPurgeFailedHandlers
|
|
4568
|
+
);
|
|
4569
|
+
if (erased?.logoutPending) this.replicaRestoreGate = "logout_pending";
|
|
4570
|
+
return erased;
|
|
4571
|
+
} catch {
|
|
4572
|
+
return void 0;
|
|
4542
4573
|
}
|
|
4543
4574
|
}
|
|
4544
4575
|
/**
|
|
@@ -4702,6 +4733,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4702
4733
|
const priorPrincipal = this.replicaSessionPrincipal ?? (this.address ? (0, import_sdk_core11.pkhDid)(this.address, this._chainId) : void 0);
|
|
4703
4734
|
if (this.config.replication?.enabled && priorPrincipal && priorPrincipal !== nextPrincipal) {
|
|
4704
4735
|
const denial = await this.denyReplicaGate({ reason: "account_switch", principal: priorPrincipal, next: nextPrincipal });
|
|
4736
|
+
if (denial) {
|
|
4737
|
+
await this.quiesceReplicaRuntime();
|
|
4738
|
+
await this.eraseReplicaLocalCopy("account_switch", denial.status);
|
|
4739
|
+
}
|
|
4705
4740
|
this.replicaRestoreGate = denial?.status === "unguarded" ? "gate_unavailable" : "stamp_stale";
|
|
4706
4741
|
}
|
|
4707
4742
|
if (address !== this._address || chainId !== this._chainId) {
|
|
@@ -6682,7 +6717,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6682
6717
|
replication: this.config.replication?.enabled === true ? {
|
|
6683
6718
|
enabled: true,
|
|
6684
6719
|
prefixes: this.config.replication.prefixes,
|
|
6685
|
-
allowSecrets: this.config.replication.allowSecrets === true
|
|
6720
|
+
allowSecrets: this.config.replication.allowSecrets === true,
|
|
6721
|
+
syncScope: this.config.replication.syncScope
|
|
6686
6722
|
} : void 0
|
|
6687
6723
|
});
|
|
6688
6724
|
this.tc = new import_sdk_core11.TinyCloud(this.auth, {
|
|
@@ -6744,7 +6780,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6744
6780
|
replication: this.config.replication?.enabled === true ? {
|
|
6745
6781
|
enabled: true,
|
|
6746
6782
|
prefixes: this.config.replication.prefixes,
|
|
6747
|
-
allowSecrets: this.config.replication.allowSecrets === true
|
|
6783
|
+
allowSecrets: this.config.replication.allowSecrets === true,
|
|
6784
|
+
syncScope: this.config.replication.syncScope
|
|
6748
6785
|
} : void 0
|
|
6749
6786
|
});
|
|
6750
6787
|
this.tc = new import_sdk_core11.TinyCloud(this.auth, {
|