@tinycloud/web-sdk 3.0.0-beta.9 → 3.0.1-beta.0

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.
@@ -74,7 +74,7 @@ export interface Config extends ClientConfig {
74
74
  * modal handler is in use.
75
75
  */
76
76
  spaceCreationTimeoutMs?: number;
77
- /** Session expiration time in milliseconds (default: 1 hour) */
77
+ /** Session expiration time in milliseconds (default: 30 days, `EXPIRY.SESSION_MS`) */
78
78
  sessionExpirationMs?: number;
79
79
  /** Persist browser sessions so signIn() can restore before prompting. Default true. */
80
80
  persistSession?: boolean;
@@ -1,8 +1,9 @@
1
+ import { type CredentialRequirement } from "@tinycloud/sdk-core";
1
2
  import { type ShareMetadata } from "@tinycloud/share-sdk";
2
3
  import { type ShareEnvelopeV3 } from "@tinycloud/share-envelope";
3
4
  import { CredentialsService } from "../credentials";
4
5
  import { type ReceiverSessionStorage } from "./receiver-session";
5
- import type { ReceivedShare, ShareImportAccountClient, ShareImportOptions, ShareImportResult, ShareReceiveOptions, ShareReceivedContent, ShareReceiverClient, ShareReceiverIdentity } from "./types";
6
+ import type { ReceivedShare, ShareDelegateOptions, ShareDelegation, ShareImportAccountClient, ShareImportOptions, ShareImportResult, ShareReceiveOptions, ShareReceivedContent, ShareReceiverClient, ShareReceiverIdentity, ShareReceiverRecipient } from "./types";
6
7
  export interface ShareReceiverServiceOptions {
7
8
  readonly origin?: string;
8
9
  readonly sessionStorage?: ReceiverSessionStorage;
@@ -18,11 +19,17 @@ export declare function validateShareReceiverServiceTrust(envelope: Pick<ShareEn
18
19
  export declare function validateShareReceiverExpectedOrigin(shareUrl: string, expectedOrigin: string): string;
19
20
  /** @internal */
20
21
  export declare function selectShareReceiverAccountSession(client: ShareReceiverClient, requestedIdentity: ShareReceiveOptions["identity"]): Promise<ReturnType<ShareReceiverClient["session"]>>;
21
- /** @internal */
22
+ /**
23
+ * @internal Binds the invitation's addressed recipient to the owner-signed
24
+ * policy's credential commitment. A matcher that does not hash to the
25
+ * committed requirement is rejected before anything is displayed or sent.
26
+ */
27
+ export declare function verifiedShareRequirement(envelope: ShareEnvelopeV3): Promise<CredentialRequirement>;
22
28
  export declare class ReceivedShareImpl implements ReceivedShare {
23
29
  readonly identity: ShareReceiverIdentity;
24
30
  readonly metadata: ShareMetadata;
25
31
  private readonly envelope;
32
+ private readonly requirement;
26
33
  private readonly credentials;
27
34
  private readonly sign;
28
35
  private readonly options;
@@ -30,10 +37,19 @@ export declare class ReceivedShareImpl implements ReceivedShare {
30
37
  private readonly credentialDiscoveryUrl;
31
38
  private content?;
32
39
  private getPromise?;
33
- constructor(identity: ShareReceiverIdentity, metadata: ShareMetadata, envelope: ShareEnvelopeV3, credentials: CredentialsService, sign: (bytes: Uint8Array) => Promise<Uint8Array>, options: ShareReceiveOptions, fetchFn: typeof fetch, credentialDiscoveryUrl: string);
40
+ private accessPromise?;
41
+ private stage?;
42
+ readonly recipient: ShareReceiverRecipient;
43
+ constructor(identity: ShareReceiverIdentity, metadata: ShareMetadata, envelope: ShareEnvelopeV3, requirement: CredentialRequirement, credentials: CredentialsService, sign: (bytes: Uint8Array) => Promise<Uint8Array>, options: ShareReceiveOptions, fetchFn: typeof fetch, credentialDiscoveryUrl: string);
34
44
  get shareId(): string;
35
45
  get(): Promise<ShareReceivedContent>;
46
+ /** The admitted access, admitted again once its chain has expired. */
47
+ private access;
48
+ /** Forget `access` so the next request admits again, unless it was already replaced. */
49
+ private forget;
50
+ private admit;
36
51
  private load;
52
+ delegate(options: ShareDelegateOptions): Promise<ShareDelegation>;
37
53
  importInto(accountClient: ShareImportAccountClient, options: ShareImportOptions): Promise<ShareImportResult>;
38
54
  }
39
55
  export declare class ShareReceiverService {
@@ -17,6 +17,7 @@ export type ShareReceiveProgress = {
17
17
  } | {
18
18
  readonly state: "credential-acquisition";
19
19
  readonly status: "started" | "completed";
20
+ readonly mailbox?: string;
20
21
  } | {
21
22
  readonly state: "policy-admission";
22
23
  readonly status: "started" | "completed";
@@ -44,6 +45,34 @@ export interface ShareReceiveOptions {
44
45
  };
45
46
  readonly signal?: AbortSignal;
46
47
  readonly onProgress?: (event: ShareReceiveProgress) => void;
48
+ /**
49
+ * Open through access another recipient delegated to this identity's key,
50
+ * instead of proving a credential.
51
+ */
52
+ readonly delegation?: ShareDelegation;
53
+ }
54
+ /** One signed link of a share's delegation chain. The owner's Node holds it too. */
55
+ export interface ShareDelegationLink {
56
+ readonly authorization: string;
57
+ readonly cid: string;
58
+ }
59
+ /**
60
+ * A share's access re-delegated to another key: the admitted session first,
61
+ * then each re-delegation in order. It holds no secret; only the key it names
62
+ * can use it.
63
+ */
64
+ export interface ShareDelegation {
65
+ readonly shareId: string;
66
+ readonly delegateDid: string;
67
+ readonly expiresAt: string;
68
+ readonly chain: readonly ShareDelegationLink[];
69
+ }
70
+ export interface ShareDelegateOptions {
71
+ /** DID of the key that should hold this share's access, such as an account session key. */
72
+ readonly to: string;
73
+ /** Defaults to the longest the current access allows. */
74
+ readonly expiresAt?: Date;
75
+ readonly signal?: AbortSignal;
47
76
  }
48
77
  export interface ShareReceivedContent {
49
78
  readonly bytes: Uint8Array;
@@ -69,12 +98,33 @@ export interface ShareImportAccountClient {
69
98
  ensureOwnedSpaceHosted(name: string): Promise<string>;
70
99
  kvForSpace(spaceId: string): IKVService;
71
100
  }
101
+ /**
102
+ * The recipient an invitation is addressed to. It comes from the signed,
103
+ * sealed invitation and is checked against the policy's credential
104
+ * requirement commitment before `receive` returns, so a host may display it.
105
+ */
106
+ export type ShareReceiverRecipient = {
107
+ readonly kind: "exactEmail";
108
+ readonly email: string;
109
+ }
110
+ /** Anyone who proves a mailbox whose issuer-derived domain equals `domain` exactly. */
111
+ | {
112
+ readonly kind: "emailDomain";
113
+ readonly domain: string;
114
+ };
72
115
  export interface ReceivedShare {
73
116
  readonly identity: ShareReceiverIdentity;
117
+ readonly recipient: ShareReceiverRecipient;
74
118
  readonly metadata: ShareMetadata;
75
119
  readonly shareId: string;
76
120
  get(): Promise<ShareReceivedContent>;
77
121
  importInto(accountClient: ShareImportAccountClient, options: ShareImportOptions): Promise<ShareImportResult>;
122
+ /**
123
+ * Re-delegate this share's access, including decryption, to another key.
124
+ * Proves the credential first if this share has not been opened yet. The
125
+ * delegate opens it with `receive(url, { delegation })`.
126
+ */
127
+ delegate(options: ShareDelegateOptions): Promise<ShareDelegation>;
78
128
  }
79
129
  export interface ShareReceiverClient extends ShareImportAccountClient {
80
130
  readonly credentialHolderDid: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinycloud/web-sdk",
3
- "version": "3.0.0-beta.9",
3
+ "version": "3.0.1-beta.0",
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,10 +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.9",
47
- "@tinycloud/sdk-core": "3.0.0-beta.9",
48
- "@tinycloud/share-envelope": "1.0.0-beta.3",
49
- "@tinycloud/share-sdk": "1.0.0-beta.3",
46
+ "@tinycloud/node-sdk": "3.0.1-beta.0",
47
+ "@tinycloud/sdk-core": "3.0.1-beta.0",
48
+ "@tinycloud/share-envelope": "1.1.0-beta.0",
49
+ "@tinycloud/share-sdk": "1.0.1-beta.0",
50
50
  "@tinycloud/web-sdk-wasm": "1.7.6",
51
51
  "axios": "^1.7.9",
52
52
  "viem": "^2.45.0",