@tinycloud/web-sdk 3.0.0-beta.0 → 3.0.0-beta.10

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,25 @@
1
+ import { type CanonicalTinyCloudIdentity, type ClientSession, type OpenKeyManageKeySigningStrategyOptions } from "@tinycloud/sdk-core";
2
+ import { TinyCloudWeb, type Config } from "./modules/tcw";
3
+ /** Configuration for one OAuth-bound canonical TinyCloud sign-in. */
4
+ export interface EstablishManageKeySessionOptions {
5
+ /** The canonical identity claim returned with a consented OAuth token. */
6
+ identity: CanonicalTinyCloudIdentity | unknown;
7
+ /** OAuth bearer signer configuration. No browser session credentials are used. */
8
+ signer: Omit<OpenKeyManageKeySigningStrategyOptions, "identity">;
9
+ /** TinyCloud client configuration, including the app's requested capabilities. */
10
+ tinycloud: Omit<Config, "provider" | "signStrategy" | "autoBootstrapAccount">;
11
+ }
12
+ /** Result of a completed TinyCloud sign-in using the OAuth canonical key. */
13
+ export interface EstablishManageKeySessionResult {
14
+ client: TinyCloudWeb;
15
+ identity: CanonicalTinyCloudIdentity;
16
+ /** The verified TinyCloud session produced by the public SDK sign-in flow. */
17
+ session: ClientSession;
18
+ }
19
+ /**
20
+ * Sign in through the public TinyCloud web SDK using a consented OAuth
21
+ * canonical key. The identity is token-bound; callers cannot select another
22
+ * address or key ID, and the signer makes cookie-free requests only.
23
+ */
24
+ export declare function establishManageKeySession(options: EstablishManageKeySessionOptions): Promise<EstablishManageKeySessionResult>;
25
+ //# sourceMappingURL=manage-key-session.d.ts.map
@@ -38,22 +38,22 @@ export declare const SessionConfigSchema: z.ZodObject<{
38
38
  spaceId?: string;
39
39
  address?: string;
40
40
  chainId?: number;
41
+ jwk?: Record<string, unknown>;
41
42
  issuedAt?: string;
42
43
  notBefore?: string;
43
44
  expirationTime?: string;
44
45
  parents?: string[];
45
- jwk?: Record<string, unknown>;
46
46
  }, {
47
47
  domain?: string;
48
48
  actions?: Record<string, Record<string, string[]>>;
49
49
  spaceId?: string;
50
50
  address?: string;
51
51
  chainId?: number;
52
+ jwk?: Record<string, unknown>;
52
53
  issuedAt?: string;
53
54
  notBefore?: string;
54
55
  expirationTime?: string;
55
56
  parents?: string[];
56
- jwk?: Record<string, unknown>;
57
57
  }>;
58
58
  export type SessionConfig = z.infer<typeof SessionConfigSchema>;
59
59
  /**
@@ -26,6 +26,7 @@ export declare class WebSecretsService implements ISecretsService {
26
26
  put(name: string, value: string, options?: SecretScopeOptions): ReturnType<ISecretsService["put"]>;
27
27
  delete(name: string, options?: SecretScopeOptions): ReturnType<ISecretsService["delete"]>;
28
28
  list(options?: SecretScopeOptions): ReturnType<ISecretsService["list"]>;
29
+ listAll(): ReturnType<ISecretsService["listAll"]>;
29
30
  private get service();
30
31
  private ensureMutationPermission;
31
32
  private restoreUnlockAfterEscalation;
@@ -9,13 +9,14 @@
9
9
  *
10
10
  * @packageDocumentation
11
11
  */
12
- import { TinyCloudNode, type BootstrapWarning, type DelegateToOptions, type DelegateToResult, type ISessionStorage, type SignStrategy, type ValidatedRuntimeDelegation, type UnifiedOwnerRootInput, type UnifiedOwnerRootReceipt } from "@tinycloud/node-sdk/core";
13
- import { IKVService, ISQLService, IDuckDbService, IDataVaultService, ISecretsService, ISpaceService, ISpace, ISharingService, ICapabilityKeyRegistry, IHooksService, IEncryptionService, DelegationManager, Delegation, DelegationRevocationReceipt, CreateDelegationParams, Result, DelegationError, ClientSession, Extension, type TelemetryConfig, ISpaceCreationHandler, type Manifest, type ComposedManifestRequest, type AccountService, type ResolvedDelegate, type PermissionEntry, type NetworkDescriptor, type CreateOwnerDelegationParams, type OwnerDelegationReceipt, type RegisterOwnerSharePolicyParams, type OwnerSharePolicyRegistrationReceipt, type LocalNodeIdentityStore, SignInOptions } from "@tinycloud/sdk-core";
12
+ import { TinyCloudNode, type BootstrapWarning, type DelegateToOptions, type DelegateToResult, type ISessionStorage, type SignStrategy, type ValidatedRuntimeDelegation, type UnifiedOwnerRootInput, type UnifiedOwnerRootReceipt, type RegisterPolicyV3Input, type RegisterPolicyV3Receipt } from "@tinycloud/node-sdk/core";
13
+ import { IKVService, ISQLService, IDuckDbService, IDataVaultService, ISecretsService, ISpaceService, ISpace, ISharingService, ICapabilityKeyRegistry, IHooksService, IEncryptionService, DelegationManager, Delegation, DelegationRevocationReceipt, CreateDelegationParams, Result, DelegationError, ClientSession, Extension, type TelemetryConfig, ISpaceCreationHandler, type Manifest, type ComposedManifestRequest, type AccountService, type ResolvedDelegate, type PermissionEntry, type NetworkDescriptor, type CreateOwnerDelegationParams, type OwnerDelegationReceipt, type LocalNodeIdentityStore, SignInOptions } from "@tinycloud/sdk-core";
14
14
  import { type BrowserProvider, type BrowserWalletProvider } from "../adapters/browserProvider";
15
15
  import { RPCProviders, ClientConfig } from "../providers";
16
16
  import type { NotificationConfig } from "../notifications/types";
17
17
  import type { PortableDelegation, DelegatedAccess } from "@tinycloud/node-sdk/core";
18
18
  import { CredentialsService } from "../credentials";
19
+ import { ShareReceiverService, type ShareReceiverServiceOptions } from "../share";
19
20
  declare global {
20
21
  interface Window {
21
22
  ethereum?: any;
@@ -109,6 +110,8 @@ export interface Config extends ClientConfig {
109
110
  includeAccountRegistryPermissions?: boolean;
110
111
  /** Default-off service telemetry. */
111
112
  telemetry?: TelemetryConfig;
113
+ /** Accountless share receiver transport and session-custody configuration. */
114
+ shareReceiver?: ShareReceiverServiceOptions;
112
115
  }
113
116
  /**
114
117
  * Result of {@link TinyCloudWeb.requestPermissions}. On approve, `session`
@@ -134,6 +137,8 @@ export interface ShareReceiveResult<T = unknown> {
134
137
  delegation: Delegation;
135
138
  path: string;
136
139
  spaceId: string;
140
+ /** Owner Node named by the link; that node independently verifies the accompanying delegation. */
141
+ host: string;
137
142
  }
138
143
  export declare class TinyCloudWeb {
139
144
  /** The connected wallet's raw EIP-1193 provider. */
@@ -154,6 +159,7 @@ export declare class TinyCloudWeb {
154
159
  private _sessionRestoreStatus;
155
160
  private _secrets;
156
161
  private _credentialsService?;
162
+ private _shareReceiverService?;
157
163
  /** Promise that resolves when WASM + node are ready */
158
164
  private _initPromise;
159
165
  /** User config */
@@ -229,9 +235,18 @@ export declare class TinyCloudWeb {
229
235
  get accountSpaceId(): string | undefined;
230
236
  get account(): AccountService;
231
237
  get hosts(): string[];
238
+ /** Registry-resolved owner Node identity used to bind native share targets. */
239
+ activeNodeIdentity(): Promise<{
240
+ readonly origin: string;
241
+ readonly nodeDid: string;
242
+ }>;
243
+ /** Publish the active owner Node as a session-signed registry record. */
244
+ publishActiveNodeLocation(registryUrl: string, fetchFn?: typeof fetch): Promise<import("@tinycloud/sdk-core").LocationRecord>;
232
245
  get sessionRestoreStatus(): SessionRestoreStatus;
233
246
  /** Holder-bound OpenCredentials issuance using the active TinyCloud session. */
234
247
  get credentials(): CredentialsService;
248
+ /** First-class signed-in or accountless share receiving. */
249
+ get share(): ShareReceiverService;
235
250
  space(nameOrUri: string): ISpace;
236
251
  get kvPrefix(): string;
237
252
  getEncryptionNetwork(nameOrNetworkId?: string): Promise<NetworkDescriptor | null>;
@@ -304,10 +319,10 @@ export declare class TinyCloudWeb {
304
319
  createOwnerDelegation(params: CreateOwnerDelegationParams extends infer PermissionShape ? PermissionShape extends CreateOwnerDelegationParams ? Omit<PermissionShape, "spaceId"> & {
305
320
  readonly spaceId?: string;
306
321
  } : never : never): Promise<OwnerDelegationReceipt>;
307
- /** Register an owner-bound addressed sharing policy through TinyCloud Node. */
308
- registerOwnerSharePolicy(params: RegisterOwnerSharePolicyParams): Promise<OwnerSharePolicyRegistrationReceipt>;
309
- /** Authorize a short-lived, one-use v2 delivery using the authenticated invocation chain. */
310
- authorizeShareDelivery(input: Parameters<TinyCloudNode["authorizeShareDelivery"]>[0]): ReturnType<TinyCloudNode["authorizeShareDelivery"]>;
322
+ /** Register signed policy material through the Node-owned Policy/v3 runtime. */
323
+ registerPolicy(params: Omit<RegisterPolicyV3Input, "nodeOrigin" | "fetch">): Promise<RegisterPolicyV3Receipt>;
324
+ /** Authorize a short-lived, one-use v3 delivery against the signed envelope and roots. */
325
+ authorizeShareDeliveryV3(input: Parameters<TinyCloudNode["authorizeShareDeliveryV3"]>[0]): ReturnType<TinyCloudNode["authorizeShareDeliveryV3"]>;
311
326
  /**
312
327
  * Issue a delegation using the capability-chain flow (spec:
313
328
  * `.claude/specs/capability-chain.md`). When the requested permissions
@@ -378,9 +393,11 @@ export declare class TinyCloudWeb {
378
393
  listDelegations(): Promise<Result<Delegation[], DelegationError>>;
379
394
  checkPermission(path: string, action: string): Promise<Result<boolean, DelegationError>>;
380
395
  /**
381
- * Receive and retrieve data from a v2 share link.
396
+ * Receive and retrieve data from a native TinyCloud bearer delegation.
382
397
  * Static method — no auth required. Uses browser WASM.
383
398
  */
384
- static receiveShare<T = unknown>(link: string, key?: string): Promise<Result<ShareReceiveResult<T>, DelegationError>>;
399
+ static receiveShare<T = unknown>(link: string, key?: string, options?: {
400
+ readonly binary?: boolean;
401
+ }): Promise<Result<ShareReceiveResult<T>, DelegationError>>;
385
402
  }
386
403
  //# sourceMappingURL=tcw.d.ts.map
@@ -54,8 +54,8 @@ export declare const ToastSchema: z.ZodObject<{
54
54
  timestamp: z.ZodNumber;
55
55
  }, "strip", z.ZodTypeAny, {
56
56
  description?: string;
57
- id?: string;
58
57
  type?: "error" | "success" | "warning" | "info" | "loading";
58
+ id?: string;
59
59
  title?: string;
60
60
  duration?: number;
61
61
  action?: {
@@ -65,8 +65,8 @@ export declare const ToastSchema: z.ZodObject<{
65
65
  timestamp?: number;
66
66
  }, {
67
67
  description?: string;
68
- id?: string;
69
68
  type?: "error" | "success" | "warning" | "info" | "loading";
69
+ id?: string;
70
70
  title?: string;
71
71
  duration?: number;
72
72
  action?: {
@@ -0,0 +1,5 @@
1
+ export * from "./receiver-credentials";
2
+ export * from "./receiver-session";
3
+ export { ShareReceiverService, validateShareReceiverServiceTrust, type ShareReceiverServiceOptions, } from "./service";
4
+ export * from "./types";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { type CredentialRequirement, type StoredCredentialRecord, type VerifiedCredential } from "@tinycloud/sdk-core";
2
+ import type { ReceiverCredentialCustody } from "../credentials";
3
+ import type { ReceiverSessionStorage } from "./receiver-session";
4
+ export declare class SessionReceiverCredentialCustody implements ReceiverCredentialCustody {
5
+ private readonly storage;
6
+ constructor(storage?: ReceiverSessionStorage);
7
+ find(input: {
8
+ readonly requirement: CredentialRequirement;
9
+ readonly requirementDigest: string;
10
+ readonly holderDid: string;
11
+ readonly now?: Date;
12
+ }): Promise<StoredCredentialRecord | undefined>;
13
+ store(input: {
14
+ readonly verified: VerifiedCredential;
15
+ readonly requirement: CredentialRequirement;
16
+ readonly requirementDigest: string;
17
+ readonly holderDid: string;
18
+ readonly now?: Date;
19
+ }): Promise<StoredCredentialRecord>;
20
+ }
21
+ //# sourceMappingURL=receiver-credentials.d.ts.map
@@ -0,0 +1,22 @@
1
+ export declare const SHARE_RECEIVER_SESSION_STORAGE_KEY = "tinycloud.share.receiver-session.v1";
2
+ export interface ShareReceiverSessionRecordV1 {
3
+ readonly type: "TinyCloudShareReceiverSession";
4
+ readonly version: 1;
5
+ readonly origin: string;
6
+ readonly holderDid: string;
7
+ readonly jwk: JsonWebKey;
8
+ readonly createdAt: string;
9
+ }
10
+ export interface ReceiverSessionStorage {
11
+ getItem(key: string): string | null;
12
+ setItem(key: string, value: string): void;
13
+ removeItem(key: string): void;
14
+ }
15
+ export interface ShareReceiverSession {
16
+ readonly holderDid: string;
17
+ readonly origin: string;
18
+ readonly createdAt: string;
19
+ sign(bytes: Uint8Array): Promise<Uint8Array>;
20
+ }
21
+ export declare function createOrRestoreShareReceiverSession(originValue: string, storage?: ReceiverSessionStorage): Promise<ShareReceiverSession>;
22
+ //# sourceMappingURL=receiver-session.d.ts.map
@@ -0,0 +1,47 @@
1
+ import { type ShareMetadata } from "@tinycloud/share-sdk";
2
+ import { type ShareEnvelopeV3 } from "@tinycloud/share-envelope";
3
+ import { CredentialsService } from "../credentials";
4
+ import { type ReceiverSessionStorage } from "./receiver-session";
5
+ import type { ReceivedShare, ShareImportAccountClient, ShareImportOptions, ShareImportResult, ShareReceiveOptions, ShareReceivedContent, ShareReceiverClient, ShareReceiverIdentity } from "./types";
6
+ export interface ShareReceiverServiceOptions {
7
+ readonly origin?: string;
8
+ readonly sessionStorage?: ReceiverSessionStorage;
9
+ readonly credentialDiscoveryUrl?: string;
10
+ /** Out-of-band Share application origin allowed to supply invitation URLs. */
11
+ readonly expectedShareOrigin: string;
12
+ /** Registry containing the share owner's signed TinyCloud location record. */
13
+ readonly registryOrigin: string;
14
+ readonly fetch?: typeof fetch;
15
+ }
16
+ export declare function validateShareReceiverServiceTrust(envelope: Pick<ShareEnvelopeV3, "target" | "attestedEnforcerBinding">): void;
17
+ /** @internal */
18
+ export declare function validateShareReceiverExpectedOrigin(shareUrl: string, expectedOrigin: string): string;
19
+ /** @internal */
20
+ export declare function selectShareReceiverAccountSession(client: ShareReceiverClient, requestedIdentity: ShareReceiveOptions["identity"]): Promise<ReturnType<ShareReceiverClient["session"]>>;
21
+ /** @internal */
22
+ export declare class ReceivedShareImpl implements ReceivedShare {
23
+ readonly identity: ShareReceiverIdentity;
24
+ readonly metadata: ShareMetadata;
25
+ private readonly envelope;
26
+ private readonly credentials;
27
+ private readonly sign;
28
+ private readonly options;
29
+ private readonly fetchFn;
30
+ private readonly credentialDiscoveryUrl;
31
+ private content?;
32
+ private getPromise?;
33
+ constructor(identity: ShareReceiverIdentity, metadata: ShareMetadata, envelope: ShareEnvelopeV3, credentials: CredentialsService, sign: (bytes: Uint8Array) => Promise<Uint8Array>, options: ShareReceiveOptions, fetchFn: typeof fetch, credentialDiscoveryUrl: string);
34
+ get shareId(): string;
35
+ get(): Promise<ShareReceivedContent>;
36
+ private load;
37
+ importInto(accountClient: ShareImportAccountClient, options: ShareImportOptions): Promise<ShareImportResult>;
38
+ }
39
+ export declare class ShareReceiverService {
40
+ private readonly client;
41
+ private readonly fetchFn;
42
+ private readonly storage;
43
+ private readonly config;
44
+ constructor(client: ShareReceiverClient, config: ShareReceiverServiceOptions | undefined);
45
+ receive(shareUrl: string, options: ShareReceiveOptions): Promise<ReceivedShare>;
46
+ }
47
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1,89 @@
1
+ import type { ClientSession, IKVService } from "@tinycloud/sdk-core";
2
+ import type { ShareMetadata } from "@tinycloud/share-sdk";
3
+ import type { CredentialsService } from "../credentials";
4
+ export type ShareReceiverIdentity = {
5
+ readonly kind: "account";
6
+ readonly holderDid: string;
7
+ } | {
8
+ readonly kind: "receiver";
9
+ readonly holderDid: string;
10
+ readonly custody: "session";
11
+ readonly origin: string;
12
+ };
13
+ export type ShareReceiveProgress = {
14
+ readonly state: "identity-selection";
15
+ readonly status: "started" | "completed";
16
+ readonly identity?: ShareReceiverIdentity;
17
+ } | {
18
+ readonly state: "credential-acquisition";
19
+ readonly status: "started" | "completed";
20
+ } | {
21
+ readonly state: "policy-admission";
22
+ readonly status: "started" | "completed";
23
+ } | {
24
+ readonly state: "delegation-import";
25
+ readonly status: "started" | "completed";
26
+ } | {
27
+ readonly state: "invocation";
28
+ readonly status: "started" | "completed";
29
+ } | {
30
+ readonly state: "decryption";
31
+ readonly status: "started" | "completed";
32
+ } | {
33
+ readonly state: "ready";
34
+ readonly status: "completed";
35
+ } | {
36
+ readonly state: "import";
37
+ readonly status: "started" | "completed";
38
+ };
39
+ export interface ShareReceiveOptions {
40
+ readonly identity: "auto" | "account" | "receiver";
41
+ readonly interaction: {
42
+ readonly kind: "inline";
43
+ readonly mountTarget: Element | string;
44
+ };
45
+ readonly signal?: AbortSignal;
46
+ readonly onProgress?: (event: ShareReceiveProgress) => void;
47
+ }
48
+ export interface ShareReceivedContent {
49
+ readonly bytes: Uint8Array;
50
+ readonly filename: string;
51
+ readonly mediaType: string;
52
+ readonly senderDid: string;
53
+ readonly shareId: string;
54
+ readonly byteDigest: string;
55
+ readonly receivedAt: string;
56
+ }
57
+ export interface ShareImportOptions {
58
+ readonly namespace: "files-for-you";
59
+ readonly filename?: string;
60
+ readonly signal?: AbortSignal;
61
+ }
62
+ export interface ShareImportResult {
63
+ readonly status: "imported" | "existing";
64
+ readonly path: string;
65
+ readonly byteDigest: string;
66
+ }
67
+ export interface ShareImportAccountClient {
68
+ session(): ClientSession | undefined;
69
+ ensureOwnedSpaceHosted(name: string): Promise<string>;
70
+ kvForSpace(spaceId: string): IKVService;
71
+ }
72
+ export interface ReceivedShare {
73
+ readonly identity: ShareReceiverIdentity;
74
+ readonly metadata: ShareMetadata;
75
+ readonly shareId: string;
76
+ get(): Promise<ShareReceivedContent>;
77
+ importInto(accountClient: ShareImportAccountClient, options: ShareImportOptions): Promise<ShareImportResult>;
78
+ }
79
+ export interface ShareReceiverClient extends ShareImportAccountClient {
80
+ readonly credentialHolderDid: string;
81
+ readonly credentialHolderKid: string;
82
+ readonly credentials: CredentialsService;
83
+ restoreSession(): Promise<{
84
+ readonly status: string;
85
+ readonly session?: ClientSession;
86
+ }>;
87
+ signSessionBytes(bytes: Uint8Array): Promise<Uint8Array>;
88
+ }
89
+ //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinycloud/web-sdk",
3
- "version": "3.0.0-beta.0",
3
+ "version": "3.0.0-beta.10",
4
4
  "description": "A set of tools and utilities to help you build your app with TinyCloud.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -43,8 +43,10 @@
43
43
  "dependencies": {
44
44
  "@multiformats/multiaddr": "^13.0.1",
45
45
  "@multiformats/multiaddr-to-uri": "^12.0.0",
46
- "@tinycloud/node-sdk": "3.0.0-beta.0",
47
- "@tinycloud/sdk-core": "3.0.0-beta.0",
46
+ "@tinycloud/node-sdk": "3.0.0-beta.10",
47
+ "@tinycloud/sdk-core": "3.0.0-beta.10",
48
+ "@tinycloud/share-envelope": "1.0.0-beta.4",
49
+ "@tinycloud/share-sdk": "1.0.0-beta.4",
48
50
  "@tinycloud/web-sdk-wasm": "1.7.6",
49
51
  "axios": "^1.7.9",
50
52
  "viem": "^2.45.0",