@tinycloud/web-sdk 3.3.0-beta.11 → 3.3.0-beta.13

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.
@@ -1,6 +1,7 @@
1
1
  import { type CredentialRequirement, type StoredCredentialRecord, type VerifiedCredential } from "@tinycloud/sdk-core";
2
2
  import type { ReceiverCredentialCustody } from "../credentials";
3
3
  import type { ReceiverSessionStorage } from "./receiver-session";
4
+ export declare const SHARE_RECEIVER_CREDENTIALS_STORAGE_KEY = "tinycloud.share.receiver-credentials.v1";
4
5
  export declare class SessionReceiverCredentialCustody implements ReceiverCredentialCustody {
5
6
  private readonly storage;
6
7
  constructor(storage?: ReceiverSessionStorage);
@@ -1,12 +1,24 @@
1
+ /**
2
+ * Former (v1) location of the receiver key. That record held private key
3
+ * material, so it is only ever removed, never read.
4
+ */
1
5
  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
- }
6
+ /** IndexedDB database holding non-extractable receiver key handles, one per origin. */
7
+ export declare const SHARE_RECEIVER_KEY_DATABASE = "tinycloud.share.receiver-keys";
8
+ /**
9
+ * Upper bound on how long a receiver key signs. An emailed credential lives
10
+ * for minutes, and the key alone authorizes nothing, so an hour keeps
11
+ * reloads working without keeping a signer around for days.
12
+ */
13
+ export declare const SHARE_RECEIVER_KEY_LIFETIME_MS: number;
14
+ /**
15
+ * Where the receiver signing key lives:
16
+ * - `persistent`: a non-extractable WebCrypto key whose handle is kept in
17
+ * IndexedDB, so the page survives a reload.
18
+ * - `memory`: a key held only by this page. A reload loses it, and the
19
+ * recipient verifies their email again.
20
+ */
21
+ export type ShareReceiverKeyCustody = "persistent" | "memory";
10
22
  export interface ReceiverSessionStorage {
11
23
  getItem(key: string): string | null;
12
24
  setItem(key: string, value: string): void;
@@ -16,7 +28,46 @@ export interface ShareReceiverSession {
16
28
  readonly holderDid: string;
17
29
  readonly origin: string;
18
30
  readonly createdAt: string;
31
+ readonly expiresAt: string;
32
+ readonly custody: ShareReceiverKeyCustody;
33
+ /** Where this key's credentials are kept; page memory when the key is. */
34
+ readonly credentialStorage: ReceiverSessionStorage;
35
+ /** Rejects with {@link ShareReceiverSessionEndedError} once the session expired, was forgotten or left with the page. */
19
36
  sign(bytes: Uint8Array): Promise<Uint8Array>;
20
37
  }
21
- export declare function createOrRestoreShareReceiverSession(originValue: string, storage?: ReceiverSessionStorage): Promise<ShareReceiverSession>;
38
+ export interface ShareReceiverSessionOptions {
39
+ /** IndexedDB used to keep the key handle; `null` keeps the key in memory only. */
40
+ readonly indexedDB?: IDBFactory | null;
41
+ /** @internal WebCrypto implementation; `null` simulates a browser without it. */
42
+ readonly subtle?: SubtleCrypto | null;
43
+ /** @internal */
44
+ readonly now?: () => Date;
45
+ }
46
+ /** This browser can create no signing key for the share page, so nothing can be opened. */
47
+ export declare class ShareReceiverKeyUnavailableError extends Error {
48
+ readonly code = "receiver_key_unavailable";
49
+ constructor();
50
+ }
51
+ /** The receiver key expired, was forgotten, or was discarded with the page; the recipient verifies again. */
52
+ export declare class ShareReceiverSessionEndedError extends Error {
53
+ readonly code = "receiver_session_ended";
54
+ constructor();
55
+ }
56
+ /**
57
+ * Returns this origin's receiver signing key, creating it when needed.
58
+ *
59
+ * The preferred key is a non-extractable WebCrypto Ed25519 key whose handle
60
+ * is kept in IndexedDB, so no script can read the private key out. When the
61
+ * handle cannot be kept, the same key stays in this page's memory only. A
62
+ * browser without WebCrypto Ed25519 gets a key held in memory only. Private
63
+ * key material is never written to any storage, URL, log or error. Without
64
+ * `storage`, session storage is used, or page memory where it is blocked.
65
+ */
66
+ export declare function createOrRestoreShareReceiverSession(originValue: string, storage?: ReceiverSessionStorage, options?: ShareReceiverSessionOptions): Promise<ShareReceiverSession>;
67
+ /**
68
+ * "Forget this browser": drops this origin's receiver key from IndexedDB and
69
+ * memory, and the credentials issued to it. Sessions already handed out stop
70
+ * signing. The next open verifies again.
71
+ */
72
+ export declare function forgetShareReceiverSession(originValue: string, storage?: ReceiverSessionStorage, options?: Pick<ShareReceiverSessionOptions, "indexedDB">): Promise<void>;
22
73
  //# sourceMappingURL=receiver-session.d.ts.map
@@ -7,6 +7,8 @@ import type { ReceivedShare, ShareDelegateOptions, ShareDelegation, ShareImportA
7
7
  export interface ShareReceiverServiceOptions {
8
8
  readonly origin?: string;
9
9
  readonly sessionStorage?: ReceiverSessionStorage;
10
+ /** Keeps the receiver key handle; `null` keeps the key in memory only. */
11
+ readonly indexedDB?: IDBFactory | null;
10
12
  readonly credentialDiscoveryUrl?: string;
11
13
  /** Out-of-band Share application origin allowed to supply invitation URLs. */
12
14
  readonly expectedShareOrigin: string;
@@ -55,7 +57,6 @@ export declare class ReceivedShareImpl implements ReceivedShare {
55
57
  export declare class ShareReceiverService {
56
58
  private readonly client;
57
59
  private readonly fetchFn;
58
- private readonly storage;
59
60
  private readonly config;
60
61
  constructor(client: ShareReceiverClient, config: ShareReceiverServiceOptions | undefined);
61
62
  receive(shareUrl: string, options: ShareReceiveOptions): Promise<ReceivedShare>;
@@ -1,13 +1,14 @@
1
1
  import type { ClientSession, IKVService } from "@tinycloud/sdk-core";
2
2
  import type { ShareMetadata } from "@tinycloud/share-sdk";
3
3
  import type { CredentialsService } from "../credentials";
4
+ import type { ShareReceiverKeyCustody } from "./receiver-session";
4
5
  export type ShareReceiverIdentity = {
5
6
  readonly kind: "account";
6
7
  readonly holderDid: string;
7
8
  } | {
8
9
  readonly kind: "receiver";
9
10
  readonly holderDid: string;
10
- readonly custody: "session";
11
+ readonly custody: ShareReceiverKeyCustody;
11
12
  readonly origin: string;
12
13
  };
13
14
  export type ShareReceiveProgress = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinycloud/web-sdk",
3
- "version": "3.3.0-beta.11",
3
+ "version": "3.3.0-beta.13",
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",
@@ -53,11 +53,12 @@
53
53
  "dependencies": {
54
54
  "@multiformats/multiaddr": "^13.0.1",
55
55
  "@multiformats/multiaddr-to-uri": "^12.0.0",
56
- "@tinycloud/node-sdk": "3.3.0-beta.11",
56
+ "@noble/curves": "^1.9.7",
57
+ "@tinycloud/node-sdk": "3.3.0-beta.13",
57
58
  "@tinycloud/replica": "0.3.0-beta.5",
58
- "@tinycloud/sdk-core": "3.3.0-beta.11",
59
+ "@tinycloud/sdk-core": "3.3.0-beta.13",
59
60
  "@tinycloud/share-envelope": "1.1.0",
60
- "@tinycloud/share-sdk": "1.2.0-beta.0",
61
+ "@tinycloud/share-sdk": "1.2.0-beta.1",
61
62
  "@tinycloud/web-sdk-wasm": "1.7.6",
62
63
  "axios": "^1.7.9",
63
64
  "viem": "^2.45.0",