@tinycloud/web-sdk 3.0.0-beta.0 → 3.0.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.
@@ -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
@@ -39,10 +39,10 @@ export declare const SessionConfigSchema: z.ZodObject<{
39
39
  address?: string;
40
40
  chainId?: number;
41
41
  issuedAt?: string;
42
+ jwk?: Record<string, unknown>;
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[]>>;
@@ -50,10 +50,10 @@ export declare const SessionConfigSchema: z.ZodObject<{
50
50
  address?: string;
51
51
  chainId?: number;
52
52
  issuedAt?: string;
53
+ jwk?: Record<string, unknown>;
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
  /**
@@ -16,6 +16,7 @@ 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`
@@ -154,6 +157,7 @@ export declare class TinyCloudWeb {
154
157
  private _sessionRestoreStatus;
155
158
  private _secrets;
156
159
  private _credentialsService?;
160
+ private _shareReceiverService?;
157
161
  /** Promise that resolves when WASM + node are ready */
158
162
  private _initPromise;
159
163
  /** User config */
@@ -232,6 +236,8 @@ export declare class TinyCloudWeb {
232
236
  get sessionRestoreStatus(): SessionRestoreStatus;
233
237
  /** Holder-bound OpenCredentials issuance using the active TinyCloud session. */
234
238
  get credentials(): CredentialsService;
239
+ /** First-class signed-in or accountless share receiving. */
240
+ get share(): ShareReceiverService;
235
241
  space(nameOrUri: string): ISpace;
236
242
  get kvPrefix(): string;
237
243
  getEncryptionNetwork(nameOrNetworkId?: string): Promise<NetworkDescriptor | null>;
@@ -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,61 @@
1
+ import { type ShareEnvelopeV3 } from "@tinycloud/share-envelope";
2
+ import { CredentialsService } from "../credentials";
3
+ import { type ReceiverSessionStorage } from "./receiver-session";
4
+ import type { ReceivedShare, ShareImportAccountClient, ShareImportOptions, ShareImportResult, ShareReceiveOptions, ShareReceivedContent, ShareReceiverClient, ShareReceiverIdentity } from "./types";
5
+ export interface ShareReceiverServiceOptions {
6
+ readonly origin?: string;
7
+ readonly sessionStorage?: ReceiverSessionStorage;
8
+ readonly credentialDiscoveryUrl?: string;
9
+ /** Out-of-band Share application origin allowed to supply invitation URLs. */
10
+ readonly expectedShareOrigin: string;
11
+ /** Explicit share blob registry. Never inferred from the viewer URL. */
12
+ readonly registryBaseUrl: string;
13
+ /** Pinned Node identity used by recipient response verification. */
14
+ readonly trustedNode: {
15
+ readonly invitationKid: string;
16
+ readonly invitationPublicKey: Uint8Array;
17
+ };
18
+ /** Exact Ed25519 enforcer DID committed as the signed envelope target. */
19
+ readonly expectedEnforcerDid: string;
20
+ readonly fetch?: typeof fetch;
21
+ }
22
+ export declare function validateShareReceiverServiceTrust(envelope: Pick<ShareEnvelopeV3, "target">, config: ShareReceiverServiceOptions): {
23
+ readonly invitationKid: string;
24
+ readonly invitationPublicKey: Uint8Array;
25
+ };
26
+ /** @internal */
27
+ export declare function validateShareReceiverRegistryBaseUrl(value: string): string;
28
+ /** @internal */
29
+ export declare function validateShareReceiverExpectedOrigin(shareUrl: string, expectedOrigin: string): string;
30
+ /** @internal */
31
+ export declare function selectShareReceiverAccountSession(client: ShareReceiverClient, requestedIdentity: ShareReceiveOptions["identity"]): Promise<ReturnType<ShareReceiverClient["session"]>>;
32
+ /** @internal */
33
+ export declare class ReceivedShareImpl implements ReceivedShare {
34
+ readonly identity: ShareReceiverIdentity;
35
+ readonly shareId: string;
36
+ private readonly envelope;
37
+ private readonly credentials;
38
+ private readonly sign;
39
+ private readonly options;
40
+ private readonly fetchFn;
41
+ private readonly credentialDiscoveryUrl;
42
+ private readonly trustedNode;
43
+ private content?;
44
+ private getPromise?;
45
+ constructor(identity: ShareReceiverIdentity, shareId: string, envelope: ShareEnvelopeV3, credentials: CredentialsService, sign: (bytes: Uint8Array) => Promise<Uint8Array>, options: ShareReceiveOptions, fetchFn: typeof fetch, credentialDiscoveryUrl: string, trustedNode: {
46
+ readonly invitationKid: string;
47
+ readonly invitationPublicKey: Uint8Array;
48
+ });
49
+ get(): Promise<ShareReceivedContent>;
50
+ private load;
51
+ importInto(accountClient: ShareImportAccountClient, options: ShareImportOptions): Promise<ShareImportResult>;
52
+ }
53
+ export declare class ShareReceiverService {
54
+ private readonly client;
55
+ private readonly fetchFn;
56
+ private readonly storage;
57
+ private readonly config;
58
+ constructor(client: ShareReceiverClient, config: ShareReceiverServiceOptions | undefined);
59
+ receive(shareUrl: string, options: ShareReceiveOptions): Promise<ReceivedShare>;
60
+ }
61
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1,87 @@
1
+ import type { ClientSession, IKVService } from "@tinycloud/sdk-core";
2
+ import type { CredentialsService } from "../credentials";
3
+ export type ShareReceiverIdentity = {
4
+ readonly kind: "account";
5
+ readonly holderDid: string;
6
+ } | {
7
+ readonly kind: "receiver";
8
+ readonly holderDid: string;
9
+ readonly custody: "session";
10
+ readonly origin: string;
11
+ };
12
+ export type ShareReceiveProgress = {
13
+ readonly state: "identity-selection";
14
+ readonly status: "started" | "completed";
15
+ readonly identity?: ShareReceiverIdentity;
16
+ } | {
17
+ readonly state: "credential-acquisition";
18
+ readonly status: "started" | "completed";
19
+ } | {
20
+ readonly state: "policy-admission";
21
+ readonly status: "started" | "completed";
22
+ } | {
23
+ readonly state: "delegation-import";
24
+ readonly status: "started" | "completed";
25
+ } | {
26
+ readonly state: "invocation";
27
+ readonly status: "started" | "completed";
28
+ } | {
29
+ readonly state: "decryption";
30
+ readonly status: "started" | "completed";
31
+ } | {
32
+ readonly state: "ready";
33
+ readonly status: "completed";
34
+ } | {
35
+ readonly state: "import";
36
+ readonly status: "started" | "completed";
37
+ };
38
+ export interface ShareReceiveOptions {
39
+ readonly identity: "auto" | "account" | "receiver";
40
+ readonly interaction: {
41
+ readonly kind: "inline";
42
+ readonly mountTarget: Element | string;
43
+ };
44
+ readonly signal?: AbortSignal;
45
+ readonly onProgress?: (event: ShareReceiveProgress) => void;
46
+ }
47
+ export interface ShareReceivedContent {
48
+ readonly bytes: Uint8Array;
49
+ readonly filename: string;
50
+ readonly mediaType: string;
51
+ readonly senderDid: string;
52
+ readonly shareId: string;
53
+ readonly byteDigest: string;
54
+ readonly receivedAt: string;
55
+ }
56
+ export interface ShareImportOptions {
57
+ readonly namespace: "files-for-you";
58
+ readonly filename?: string;
59
+ readonly signal?: AbortSignal;
60
+ }
61
+ export interface ShareImportResult {
62
+ readonly status: "imported" | "existing";
63
+ readonly path: string;
64
+ readonly byteDigest: string;
65
+ }
66
+ export interface ShareImportAccountClient {
67
+ session(): ClientSession | undefined;
68
+ ensureOwnedSpaceHosted(name: string): Promise<string>;
69
+ kvForSpace(spaceId: string): IKVService;
70
+ }
71
+ export interface ReceivedShare {
72
+ readonly identity: ShareReceiverIdentity;
73
+ readonly shareId: string;
74
+ get(): Promise<ShareReceivedContent>;
75
+ importInto(accountClient: ShareImportAccountClient, options: ShareImportOptions): Promise<ShareImportResult>;
76
+ }
77
+ export interface ShareReceiverClient extends ShareImportAccountClient {
78
+ readonly credentialHolderDid: string;
79
+ readonly credentialHolderKid: string;
80
+ readonly credentials: CredentialsService;
81
+ restoreSession(): Promise<{
82
+ readonly status: string;
83
+ readonly session?: ClientSession;
84
+ }>;
85
+ signSessionBytes(bytes: Uint8Array): Promise<Uint8Array>;
86
+ }
87
+ //# 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.2",
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.2",
47
+ "@tinycloud/sdk-core": "3.0.0-beta.2",
48
+ "@tinycloud/share-envelope": "0.2.1-beta.0",
49
+ "@tinycloud/share-sdk": "0.3.0-beta.0",
48
50
  "@tinycloud/web-sdk-wasm": "1.7.6",
49
51
  "axios": "^1.7.9",
50
52
  "viem": "^2.45.0",