@tinycloud/web-sdk 3.12.0-beta.1 → 3.12.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.
- package/README.md +43 -0
- package/dist/delegations-issued.cjs +2 -1
- package/dist/delegations-issued.cjs.LICENSE.txt +5 -0
- package/dist/delegations-issued.mjs +2 -1
- package/dist/delegations-issued.mjs.LICENSE.txt +5 -0
- package/dist/encryption-keys.cjs +1 -1
- package/dist/encryption-keys.cjs.LICENSE.txt +4 -0
- package/dist/encryption-keys.mjs +1 -1
- package/dist/encryption-keys.mjs.LICENSE.txt +4 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.LICENSE.txt +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.LICENSE.txt +2 -0
- package/dist/modules/tcw.d.ts +41 -41
- package/dist/openkey-signing-key.d.ts +51 -0
- package/dist/replica.cjs +1 -1
- package/dist/replica.mjs +1 -1
- package/dist/space-hosting.cjs +1 -1
- package/dist/space-hosting.mjs +1 -1
- package/package.json +6 -5
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
11
11
|
|
|
12
|
+
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
|
|
13
|
+
|
|
12
14
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
13
15
|
|
|
14
16
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
package/dist/modules/tcw.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { TinyCloudNode, TinyCloudNodeConfig, type OpenKeyAuthorizeTinyCloud, 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
13
|
import { type LocalCopyPurgeFailedEvent } from "./replica-wiring";
|
|
14
|
-
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
|
|
14
|
+
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 RegistrySequenceStore, SignInOptions, type RegistryCacheStore, type StorageFullEvent, type IStorageService } from "@tinycloud/sdk-core";
|
|
15
15
|
import { type RequestPermissionsOptions } from "./requestPermissionsCore";
|
|
16
16
|
import { type BrowserProvider, type BrowserWalletProvider } from "../adapters/browserProvider";
|
|
17
17
|
import { type TinyCloudUI, type UiConfig } from "../ui";
|
|
@@ -35,6 +35,12 @@ export interface RuntimePermissionSigner {
|
|
|
35
35
|
* Extends ClientConfig with browser-specific options.
|
|
36
36
|
*/
|
|
37
37
|
export interface Config extends ClientConfig {
|
|
38
|
+
/** Write TCW2 network-key wraps. Disabled by default. */
|
|
39
|
+
keyWrapV2?: boolean;
|
|
40
|
+
/** Require TCW2 incoming network-key wraps, not signed receiver responses. Disabled by default. */
|
|
41
|
+
requireKeyWrapV2?: boolean;
|
|
42
|
+
/** Refuse explicitly designated legacy plaintext columns. Disabled by default. */
|
|
43
|
+
strictEncryption?: boolean;
|
|
38
44
|
/**
|
|
39
45
|
* OpenKey authorize-sign client. Requires @openkey/sdk >=0.12.2; popup is the default mode.
|
|
40
46
|
*
|
|
@@ -62,33 +68,23 @@ export interface Config extends ClientConfig {
|
|
|
62
68
|
spacePrefix?: string;
|
|
63
69
|
/** Local KV replication. Off unless set; node-sdk validates the config and owns the storage. */
|
|
64
70
|
replication?: TinyCloudNodeConfig["replication"];
|
|
65
|
-
/** Explicit
|
|
71
|
+
/** Explicit host hints for owners absent from both registry namespaces. Signed v2 entries select their own hosts. */
|
|
66
72
|
tinycloudHosts?: string[];
|
|
67
73
|
/** TinyCloud location registry URL. Default: https://registry.tinycloud.xyz. */
|
|
68
74
|
tinycloudRegistryUrl?: string | null;
|
|
69
|
-
/**
|
|
70
|
-
* Fallback TinyCloud hosts. Default: hosted TinyCloud node. Used only by the
|
|
71
|
-
* default `registryPolicy` ("legacy-fallback"), whose silent fallback is
|
|
72
|
-
* deprecated and will be removed in a future major release.
|
|
73
|
-
*/
|
|
74
|
-
tinycloudFallbackHosts?: string[] | null;
|
|
75
|
-
/**
|
|
76
|
-
* How sign-in uses the location registry when no `tinycloudHosts` are set.
|
|
77
|
-
* Default `"legacy-fallback"` (deprecated). `"fail-closed"` routes on the
|
|
78
|
-
* registry verdict for the wallet address and refuses automatic space
|
|
79
|
-
* creation on a host the owner's registry record does not list, or when
|
|
80
|
-
* the registry gives no verdict. See `TinyCloudNodeConfig.registryPolicy`.
|
|
81
|
-
*/
|
|
82
|
-
registryPolicy?: RegistryPolicy;
|
|
83
|
-
/** `fail-closed` only: host for owners with no registry record. Default https://node.tinycloud.xyz; `null` refuses them. */
|
|
75
|
+
/** Host hint for owners absent from both v2 and v1 registries. Default https://node.tinycloud.xyz; null disables onboarding. */
|
|
84
76
|
newUserHost?: string | null;
|
|
85
|
-
/**
|
|
77
|
+
/** Chain ID used to distinguish a v1-only owner from an owner with no registry entry. Default 1. */
|
|
86
78
|
registryChainId?: number;
|
|
87
|
-
/**
|
|
79
|
+
/** Highest signed v2 sequence seen per owner. Default: a `localStorage`-backed store. */
|
|
88
80
|
registrySequenceStore?: RegistrySequenceStore;
|
|
89
|
-
/**
|
|
81
|
+
/** Exact signed responses in browser storage, reverified on every routing read. */
|
|
82
|
+
registryCacheStore?: RegistryCacheStore;
|
|
83
|
+
/** Called after an actual cached-settings or default-node fallback. */
|
|
84
|
+
onRegistryFallback?: TinyCloudNodeConfig["onRegistryFallback"];
|
|
85
|
+
/** Called only when no host resolves for a genuinely unregistered owner. */
|
|
90
86
|
onNodeNotFound?: OnNodeNotFound;
|
|
91
|
-
/** Probe
|
|
87
|
+
/** Probe local nodes only for owners absent from both registry namespaces. Default: true. */
|
|
92
88
|
autoDiscoverLocalNode?: boolean;
|
|
93
89
|
/** Local loopback node URL to probe. Omit to avoid probing loopback. */
|
|
94
90
|
localNodeUrl?: string;
|
|
@@ -194,7 +190,7 @@ export interface ShareReceiveResult<T = unknown> {
|
|
|
194
190
|
delegation: Delegation;
|
|
195
191
|
path: string;
|
|
196
192
|
spaceId: string;
|
|
197
|
-
/**
|
|
193
|
+
/** Identity-checked registry destination where the verified parent was activated. */
|
|
198
194
|
host: string;
|
|
199
195
|
}
|
|
200
196
|
export declare class TinyCloudWeb {
|
|
@@ -233,8 +229,6 @@ export declare class TinyCloudWeb {
|
|
|
233
229
|
private signOutCount;
|
|
234
230
|
/** The signer set with `setRuntimePermissionSigner`, with the session it was set for. */
|
|
235
231
|
private runtimeSigner?;
|
|
236
|
-
/** Set when this instance's session was established through the configured OpenKey client; bound to that session like `runtimeSigner`. */
|
|
237
|
-
private openkeySession?;
|
|
238
232
|
private signOutInFlight;
|
|
239
233
|
private persistedRestoreBlocked;
|
|
240
234
|
private signOutCleanupFailed;
|
|
@@ -281,6 +275,8 @@ export declare class TinyCloudWeb {
|
|
|
281
275
|
* @internal
|
|
282
276
|
*/
|
|
283
277
|
private ensureNode;
|
|
278
|
+
/** Bind a wrapper call to its entry-time authority before initialization can yield. */
|
|
279
|
+
private dispatchCurrentNode;
|
|
284
280
|
/**
|
|
285
281
|
* Get the TinyCloudNode instance synchronously.
|
|
286
282
|
* Throws if called before WASM initialization completes.
|
|
@@ -389,7 +385,23 @@ export declare class TinyCloudWeb {
|
|
|
389
385
|
restoreSession(address?: string): Promise<SessionRestoreResult>;
|
|
390
386
|
/** One node read for the restored session, held to {@link spaceHostingCapMs}; past it, or on any failure, the answer stays unknown. */
|
|
391
387
|
private probeSpaceHosting;
|
|
388
|
+
private spaceHostingInFlight?;
|
|
389
|
+
/**
|
|
390
|
+
* Host a restored session's primary space only when the node reports it
|
|
391
|
+
* missing. Reuses that session and its existing creation confirmation.
|
|
392
|
+
* Call from a user gesture so the approval popup can open.
|
|
393
|
+
*/
|
|
392
394
|
private restoredSessionNotHosted;
|
|
395
|
+
/**
|
|
396
|
+
* Ensure the primary space is hosted, asking for approval only when needed.
|
|
397
|
+
* Resolves `"hosted"` when the node reports hosting or the space is created;
|
|
398
|
+
* resolves `"not-hosted"` when creation is unavailable or declined; and
|
|
399
|
+
* resolves `"unknown"` when the node has no hosting answer.
|
|
400
|
+
* Rejects with `Error("Space hosting was cancelled by sign-out.")` if sign-out
|
|
401
|
+
* happens during the hosting run. Call from a user gesture so the approval popup can open.
|
|
402
|
+
* Also rejects if the initiating session is replaced before hosting finishes.
|
|
403
|
+
*/
|
|
404
|
+
ensureSpaceHosted(): Promise<SpaceHosting>;
|
|
393
405
|
clearPersistedSession(address?: string): Promise<void>;
|
|
394
406
|
private configuredManifestPermissions;
|
|
395
407
|
/**
|
|
@@ -523,24 +535,12 @@ export declare class TinyCloudWeb {
|
|
|
523
535
|
requestPermissions(additional: PermissionEntry[], options?: RequestPermissionsOptions): Promise<RequestPermissionsResult>;
|
|
524
536
|
/**
|
|
525
537
|
* Signs the SIWE of a runtime permission grant. Precedence: the signer set with `setRuntimePermissionSigner`, then
|
|
526
|
-
* the OpenKey client
|
|
527
|
-
*
|
|
528
|
-
* `
|
|
538
|
+
* the configured OpenKey client's byte-exact `signMessage` (an OpenKey session's wallet provider does not implement
|
|
539
|
+
* `personal_sign`), signing with the keyId of the connected account after connecting the client first when it is not
|
|
540
|
+
* connected; a missing or ambiguous key throws `OpenKeySigningKeyError`. Without an OpenKey client or a session account,
|
|
541
|
+
* undefined: the connected wallet signs. Only `requestPermissions` calls this; sign-in and session setup never do.
|
|
529
542
|
*/
|
|
530
543
|
private runtimeMessageSigner;
|
|
531
|
-
/**
|
|
532
|
-
* Whether the OpenKey client may sign a runtime grant: always, unless there is POSITIVE evidence that it is not connected. It may sign when
|
|
533
|
-
* this instance's session was established through it (and is still the live session), or when its in-memory `lastAuth` is set (`connect()` ran
|
|
534
|
-
* on this client, for example because the app connected it after a restore), or when it exposes no `lastAuth` at all (a client shape this SDK
|
|
535
|
-
* does not know: today's behaviour, fail open). `lastAuth` is read here because nothing public says it: `@openkey/sdk` 0.12.2 declares
|
|
536
|
-
* `lastAuth = null`, sets it in `connect()` and clears it in `signOut()`; 0.9.0 declares it and sets it in `connect()` but has no `signOut`.
|
|
537
|
-
* `getSessionToken()` always answers null in 0.12.2 and `isConnected()` reads the OpenKey cookie, which can be true when `connect()` never ran
|
|
538
|
-
* on this page. web-sdk documents `@openkey/sdk` >= 0.12.2, so 0.12.2 is the lowest version this was checked against. The clean fix is
|
|
539
|
-
* `signMessage()` rejecting when not connected, in `@openkey/sdk`. Trade-off: an app that connects through a DIFFERENT OpenKey instance than
|
|
540
|
-
* `config.openkey.client`, or restores after an authorize-only sign-in, must call `openkey.connect()` on the configured client or
|
|
541
|
-
* `setRuntimePermissionSigner`.
|
|
542
|
-
*/
|
|
543
|
-
private openkeyClientMaySign;
|
|
544
544
|
/**
|
|
545
545
|
* Sets the signer for runtime permission grants (`requestPermissions`, and the panel's "allow" buttons), or clears
|
|
546
546
|
* it with no argument. For apps whose sign-in is not the SDK's OpenKey flow, for example a restored session whose
|
|
@@ -580,7 +580,7 @@ export declare class TinyCloudWeb {
|
|
|
580
580
|
checkPermission(path: string, action: string): Promise<Result<boolean, DelegationError>>;
|
|
581
581
|
/**
|
|
582
582
|
* Receive and retrieve data from a native TinyCloud bearer delegation.
|
|
583
|
-
* Static method — no
|
|
583
|
+
* Static method — no sign-in required. Verifies the parent with browser WASM and routes through the owner's registry.
|
|
584
584
|
*/
|
|
585
585
|
static receiveShare<T = unknown>(link: string, key?: string, options?: {
|
|
586
586
|
readonly binary?: boolean;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why the SDK did not ask OpenKey to sign.
|
|
3
|
+
*
|
|
4
|
+
* - `OPENKEY_KEY_MISSING`: there is no OpenKey key to sign with. The client is not connected and cannot connect, or its
|
|
5
|
+
* `connect()` answered without a `keyId`.
|
|
6
|
+
* - `OPENKEY_KEY_AMBIGUOUS`: the connected OpenKey key cannot be tied to the session's account: its address is another
|
|
7
|
+
* account's, or it reports none.
|
|
8
|
+
* - `OPENKEY_CONNECTED_RETRY`: popup mode only. The client was not connected, so the SDK connected it. The user needed longer in
|
|
9
|
+
* that popup than the click's user activation lasts, so a sign popup opened right after would be blocked by the browser.
|
|
10
|
+
* Nothing was signed. The client is now connected: ask the user to click Allow again, which signs with the connected key
|
|
11
|
+
* in one popup. Iframe and redirect mode connect and sign in one go and never throw this.
|
|
12
|
+
*
|
|
13
|
+
* None of these opens a sign dialog: the SDK never sends `signMessage` without the keyId of the connected account.
|
|
14
|
+
* Connect the configured client as the session's account (`await openkey.connect()`), or sign runtime grants with
|
|
15
|
+
* `TinyCloudWeb.setRuntimePermissionSigner`.
|
|
16
|
+
*/
|
|
17
|
+
export type OpenKeySigningKeyErrorCode = "OPENKEY_KEY_MISSING" | "OPENKEY_KEY_AMBIGUOUS" | "OPENKEY_CONNECTED_RETRY";
|
|
18
|
+
/**
|
|
19
|
+
* Thrown by `TinyCloudWeb.requestPermissions` (and the panel's "allow" buttons, which call it) when the runtime grant
|
|
20
|
+
* must be signed through the configured OpenKey client but no single connected key can be named, or when the SDK just
|
|
21
|
+
* connected the client in popup mode and the user must click again.
|
|
22
|
+
* `code` is an {@link OpenKeySigningKeyErrorCode}; `name` is `"OpenKeySigningKeyError"`.
|
|
23
|
+
*/
|
|
24
|
+
export declare class OpenKeySigningKeyError extends Error {
|
|
25
|
+
readonly code: OpenKeySigningKeyErrorCode;
|
|
26
|
+
readonly name = "OpenKeySigningKeyError";
|
|
27
|
+
constructor(code: OpenKeySigningKeyErrorCode, message: string);
|
|
28
|
+
}
|
|
29
|
+
/** What `@openkey/sdk`'s `connect()` answers (and keeps in `lastAuth`) that this SDK reads. */
|
|
30
|
+
export interface OpenKeyAuthLike {
|
|
31
|
+
readonly keyId?: unknown;
|
|
32
|
+
readonly address?: unknown;
|
|
33
|
+
}
|
|
34
|
+
/** The parts of an `@openkey/sdk` client the key lookup reads. `lastAuth` is set by `connect()` and cleared by `signOut()`; nothing public says whether the client is connected. */
|
|
35
|
+
export interface OpenKeyConnection {
|
|
36
|
+
readonly lastAuth?: OpenKeyAuthLike | null;
|
|
37
|
+
connect?(opts: {
|
|
38
|
+
mode: "iframe" | "popup" | "redirect";
|
|
39
|
+
}): Promise<OpenKeyAuthLike | null | undefined>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The keyId OpenKey must sign with for `account`: the connected key (`lastAuth`; a getter that throws reads as not
|
|
43
|
+
* connected), else the key `client.connect()` returns, after connecting it first. The key's address must be `account`,
|
|
44
|
+
* case-insensitively. `assertCurrent` runs right after `connect()` and throws when the session ended or changed while the
|
|
45
|
+
* dialog was open.
|
|
46
|
+
*
|
|
47
|
+
* @throws {OpenKeySigningKeyError} no key, a key that is not `account`'s, or (popup mode) a client that was just connected.
|
|
48
|
+
* Whatever `connect()` rejects with (the user closing the dialog) propagates unchanged.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveOpenKeySigningKey(client: OpenKeyConnection, account: string, mode: "iframe" | "popup" | "redirect", assertCurrent: () => void): Promise<string>;
|
|
51
|
+
//# sourceMappingURL=openkey-signing-key.d.ts.map
|