@tinycloud/node-sdk 3.2.0-beta.1 → 3.2.0-beta.3

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.
@@ -0,0 +1,97 @@
1
+ import { PermissionEntry, ReplicationOptions as ReplicationOptions$1, TinyCloudSession } from '@tinycloud/sdk-core';
2
+ import { ReplicationOptions, AuthorityRefusal, ReplicationAuthority } from '@tinycloud/sdk-services';
3
+
4
+ /** Constructor-time validation; the space-dependent secrets check runs at sign-in and open. */
5
+ declare function assertValidReplicationConfig(replication: (ReplicationOptions & {
6
+ storage?: unknown;
7
+ }) | undefined): void;
8
+
9
+ declare function hasUnrestrictedGetCoverage(entries: readonly PermissionEntry[], spaceId: string, prefix: string): boolean;
10
+ declare function augmentSignInEntriesWithReplication(input: {
11
+ entries: readonly PermissionEntry[];
12
+ primarySpaceId: string;
13
+ replication?: Pick<ReplicationOptions$1, "prefixes" | "allowSecrets">;
14
+ }): PermissionEntry[];
15
+
16
+ /**
17
+ * Replication authority (TC-858, plan v3 §4).
18
+ *
19
+ * `ReplicationAuthority` answers, per configured prefix, whether this node's
20
+ * session can back a local replica: the session UCAN itself (delegate
21
+ * posture), a child UCAN minted through `delegateTo`, or nothing (the
22
+ * controller then reports `grant_missing` and reads from the network).
23
+ *
24
+ * The unrestricted-authority rule is enforced here, before any network work:
25
+ * a prefix covered only by a caveated `get`/`sync` refuses with
26
+ * `CAVEATED_AUTHORITY` — on the session path, the runtime-grant path, and on
27
+ * any reuse of an installed grant (the adapter marks every grant's
28
+ * `unconstrained` flag; the controller enforces it on reuse).
29
+ */
30
+
31
+ /**
32
+ * Whether the signed `att` grants `ability` over the selected namespace, with
33
+ * each grant unrestricted (no caveats). A bare selector requires both its
34
+ * exact key and its slash descendants; a trailing-slash selector is one range.
35
+ */
36
+ declare function ucanAttCovers(att: Record<string, Record<string, unknown>>, space: string, prefix: string, ability: string, options?: {
37
+ ignoreCaveats?: boolean;
38
+ }): boolean;
39
+ /** `unconstrained` for `ReplicaGrantInfo` (§2.1): get AND sync on the prefix carry no caveats. */
40
+ declare function ucanAttUnconstrainedFor(att: Record<string, Record<string, unknown>>, space: string, prefix: string): boolean;
41
+ interface DelegationPlanResult {
42
+ path: "session" | "runtime";
43
+ parentCid: string;
44
+ expiresAt: number;
45
+ }
46
+ /**
47
+ * The `TinyCloudNode` internals the authority needs. `planDelegation` is the
48
+ * pure extraction of `delegateTo`'s parent selection (§4.3), so `plan` and
49
+ * `mint` can never disagree about which parent or expiry a delegation gets.
50
+ */
51
+ type ReplicationAuthoritySession = Pick<TinyCloudSession, "delegationHeader" | "delegationCid" | "spaceId" | "verificationMethod" | "jwk"> & Partial<Pick<TinyCloudSession, "siwe">>;
52
+ interface ReplicationAuthorityHost {
53
+ replicationSession(): ReplicationAuthoritySession | undefined;
54
+ /** The SIWE "Expiration Time" of the session — the delegateTo delegation cap. */
55
+ siweExpiration(siwe: string): Date | undefined;
56
+ planDelegation(entries: PermissionEntry[], options?: {
57
+ expiry?: string | number;
58
+ }): ({
59
+ grant?: unknown;
60
+ } & DelegationPlanResult) | AuthorityRefusal;
61
+ mintDelegation(deviceDid: string, entries: PermissionEntry[]): Promise<{
62
+ ucan: string;
63
+ expiresAt: number;
64
+ }>;
65
+ }
66
+ /** Milliseconds of validity a session or parent must have left for authority reuse (delegateTo's margin). */
67
+ declare const AUTHORITY_EXPIRY_MARGIN_MS = 60000;
68
+ /** Verify a compact session delegation before using any persisted space metadata. */
69
+ declare function replicationScopeFromSignedSession(input: {
70
+ delegationHeader: {
71
+ Authorization: string;
72
+ };
73
+ delegationCid: string;
74
+ verificationMethod: string;
75
+ persistedSpace: string;
76
+ }): {
77
+ space: string;
78
+ principal: string;
79
+ } | undefined;
80
+ declare function createReplicationAuthority(host: ReplicationAuthorityHost): ReplicationAuthority;
81
+
82
+ declare const __authority_AUTHORITY_EXPIRY_MARGIN_MS: typeof AUTHORITY_EXPIRY_MARGIN_MS;
83
+ type __authority_DelegationPlanResult = DelegationPlanResult;
84
+ type __authority_ReplicationAuthorityHost = ReplicationAuthorityHost;
85
+ type __authority_ReplicationAuthoritySession = ReplicationAuthoritySession;
86
+ declare const __authority_assertValidReplicationConfig: typeof assertValidReplicationConfig;
87
+ declare const __authority_augmentSignInEntriesWithReplication: typeof augmentSignInEntriesWithReplication;
88
+ declare const __authority_createReplicationAuthority: typeof createReplicationAuthority;
89
+ declare const __authority_hasUnrestrictedGetCoverage: typeof hasUnrestrictedGetCoverage;
90
+ declare const __authority_replicationScopeFromSignedSession: typeof replicationScopeFromSignedSession;
91
+ declare const __authority_ucanAttCovers: typeof ucanAttCovers;
92
+ declare const __authority_ucanAttUnconstrainedFor: typeof ucanAttUnconstrainedFor;
93
+ declare namespace __authority {
94
+ 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_assertValidReplicationConfig as assertValidReplicationConfig, __authority_augmentSignInEntriesWithReplication as augmentSignInEntriesWithReplication, __authority_createReplicationAuthority as createReplicationAuthority, __authority_hasUnrestrictedGetCoverage as hasUnrestrictedGetCoverage, __authority_replicationScopeFromSignedSession as replicationScopeFromSignedSession, __authority_ucanAttCovers as ucanAttCovers, __authority_ucanAttUnconstrainedFor as ucanAttUnconstrainedFor };
95
+ }
96
+
97
+ export { AUTHORITY_EXPIRY_MARGIN_MS as A, type DelegationPlanResult as D, type ReplicationAuthorityHost as R, __authority as _, type ReplicationAuthoritySession as a, assertValidReplicationConfig as b, augmentSignInEntriesWithReplication as c, createReplicationAuthority as d, ucanAttUnconstrainedFor as e, hasUnrestrictedGetCoverage as h, replicationScopeFromSignedSession as r, ucanAttCovers as u };