@tinycloud/web-sdk 3.3.0-beta.8 → 3.3.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.
- package/README.md +140 -4
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/modules/tcw.d.ts +24 -4
- package/dist/share/receiver-credentials.d.ts +1 -0
- package/dist/share/receiver-session.d.ts +60 -9
- package/dist/share/service.d.ts +2 -1
- package/dist/share/types.d.ts +2 -1
- package/package.json +8 -7
package/dist/modules/tcw.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @packageDocumentation
|
|
11
11
|
*/
|
|
12
12
|
import { TinyCloudNode, type ReplicationModuleLoaders, TinyCloudNodeConfig, 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,
|
|
13
|
+
import { IKVService, ISQLService, IDuckDbService, IDataVaultService, ISecretsService, ISpaceService, ISpace, ISharingService, ICapabilityKeyRegistry, IHooksService, IEncryptionService, DelegationManager, Delegation, DelegationRevocationReceipt, Result, DelegationError, ClientSession, Extension, type TelemetryConfig, type RetryPolicy, ISpaceCreationHandler, type Manifest, type ComposedManifestRequest, type AccountService, type ResolvedDelegate, type PermissionEntry, type NetworkDescriptor, type CreateOwnerDelegationParams, type OwnerDelegationReceipt, type LocalNodeIdentityStore, type OnNodeNotFound, type RegistryPolicy, type RegistrySequenceStore, SignInOptions, type StorageFullEvent, type IStorageService } from "@tinycloud/sdk-core";
|
|
14
14
|
import { type BrowserProvider, type BrowserWalletProvider } from "../adapters/browserProvider";
|
|
15
15
|
import { BrowserWalletSigner } from "../adapters/BrowserWalletSigner";
|
|
16
16
|
import { RPCProviders, ClientConfig } from "../providers";
|
|
@@ -41,8 +41,28 @@ export interface Config extends ClientConfig {
|
|
|
41
41
|
tinycloudHosts?: string[];
|
|
42
42
|
/** TinyCloud location registry URL. Default: https://registry.tinycloud.xyz. */
|
|
43
43
|
tinycloudRegistryUrl?: string | null;
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Fallback TinyCloud hosts. Default: hosted TinyCloud node. Used only by the
|
|
46
|
+
* default `registryPolicy` ("legacy-fallback"), whose silent fallback is
|
|
47
|
+
* deprecated and will be removed in a future major release.
|
|
48
|
+
*/
|
|
45
49
|
tinycloudFallbackHosts?: string[] | null;
|
|
50
|
+
/**
|
|
51
|
+
* How sign-in uses the location registry when no `tinycloudHosts` are set.
|
|
52
|
+
* Default `"legacy-fallback"` (deprecated). `"fail-closed"` routes on the
|
|
53
|
+
* registry verdict for the wallet address and refuses automatic space
|
|
54
|
+
* creation on a host the owner's registry record does not list, or when
|
|
55
|
+
* the registry gives no verdict. See `TinyCloudNodeConfig.registryPolicy`.
|
|
56
|
+
*/
|
|
57
|
+
registryPolicy?: RegistryPolicy;
|
|
58
|
+
/** `fail-closed` only: host for owners with no registry record. Default https://node.tinycloud.xyz; `null` refuses them. */
|
|
59
|
+
newUserHost?: string | null;
|
|
60
|
+
/** `fail-closed` only: chain ID of the v1 registry subject built from the wallet address. Default 1. */
|
|
61
|
+
registryChainId?: number;
|
|
62
|
+
/** `fail-closed` only: highest registry sequence seen per owner. Default: a `localStorage`-backed store. */
|
|
63
|
+
registrySequenceStore?: RegistrySequenceStore;
|
|
64
|
+
/** `fail-closed` only: retry, use another host (not identity-checked; it persists with the session), or abort when sign-in resolves no host. Without it, sign-in throws. */
|
|
65
|
+
onNodeNotFound?: OnNodeNotFound;
|
|
46
66
|
/** Probe configured/registered local nodes before registry/fallback resolution. Default: true. */
|
|
47
67
|
autoDiscoverLocalNode?: boolean;
|
|
48
68
|
/** Local loopback node URL to probe. Omit to avoid probing loopback. */
|
|
@@ -113,6 +133,8 @@ export interface Config extends ClientConfig {
|
|
|
113
133
|
includeAccountRegistryPermissions?: boolean;
|
|
114
134
|
/** Default-off service telemetry. */
|
|
115
135
|
telemetry?: TelemetryConfig;
|
|
136
|
+
/** Retry of node busy/timeout answers; `{ maxAttempts: 1 }` disables it. See {@link RetryPolicy}. */
|
|
137
|
+
retryPolicy?: Partial<RetryPolicy>;
|
|
116
138
|
/** Accountless share receiver transport and session-custody configuration. */
|
|
117
139
|
shareReceiver?: ShareReceiverServiceOptions;
|
|
118
140
|
}
|
|
@@ -426,9 +448,7 @@ export declare class TinyCloudWeb {
|
|
|
426
448
|
actions: string[];
|
|
427
449
|
}>;
|
|
428
450
|
}): Promise<PortableDelegation>;
|
|
429
|
-
delegate(params: CreateDelegationParams): Promise<Result<Delegation, DelegationError>>;
|
|
430
451
|
revokeDelegation(cid: string): Promise<Result<DelegationRevocationReceipt, DelegationError>>;
|
|
431
|
-
listDelegations(): Promise<Result<Delegation[], DelegationError>>;
|
|
432
452
|
checkPermission(path: string, action: string): Promise<Result<boolean, DelegationError>>;
|
|
433
453
|
/**
|
|
434
454
|
* Receive and retrieve data from a native TinyCloud bearer delegation.
|
|
@@ -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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
|
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
|
package/dist/share/service.d.ts
CHANGED
|
@@ -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>;
|
package/dist/share/types.d.ts
CHANGED
|
@@ -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:
|
|
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
|
|
3
|
+
"version": "3.3.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",
|
|
@@ -53,12 +53,13 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@multiformats/multiaddr": "^13.0.1",
|
|
55
55
|
"@multiformats/multiaddr-to-uri": "^12.0.0",
|
|
56
|
-
"@
|
|
57
|
-
"@tinycloud/
|
|
58
|
-
"@tinycloud/
|
|
59
|
-
"@tinycloud/
|
|
60
|
-
"@tinycloud/share-
|
|
61
|
-
"@tinycloud/
|
|
56
|
+
"@noble/curves": "^1.9.7",
|
|
57
|
+
"@tinycloud/node-sdk": "3.3.0",
|
|
58
|
+
"@tinycloud/replica": "0.3.0",
|
|
59
|
+
"@tinycloud/sdk-core": "3.3.0",
|
|
60
|
+
"@tinycloud/share-envelope": "1.2.0",
|
|
61
|
+
"@tinycloud/share-sdk": "1.2.0",
|
|
62
|
+
"@tinycloud/web-sdk-wasm": "1.7.7",
|
|
62
63
|
"axios": "^1.7.9",
|
|
63
64
|
"viem": "^2.45.0",
|
|
64
65
|
"zod": "^3.22.0"
|