@tinycloud/web-sdk 3.12.0-beta.2 → 3.12.0-beta.20
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 +62 -7
- package/dist/adapters/BrowserSessionStorage.d.ts +3 -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/Storage/tinycloud/types.schema.d.ts +4 -4
- package/dist/modules/requestPermissionsCore.d.ts +0 -7
- package/dist/modules/runtimeGrantPersistence.d.ts +4 -2
- package/dist/modules/tcw.d.ts +31 -45
- 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-entry.d.ts +1 -1
- package/dist/space-hosting.cjs +1 -1
- package/dist/space-hosting.mjs +1 -1
- package/package.json +8 -7
|
@@ -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) */
|
|
@@ -36,10 +36,10 @@ export declare const SessionConfigSchema: z.ZodObject<{
|
|
|
36
36
|
domain?: string;
|
|
37
37
|
actions?: Record<string, Record<string, string[]>>;
|
|
38
38
|
spaceId?: string;
|
|
39
|
-
jwk?: Record<string, unknown>;
|
|
40
39
|
address?: string;
|
|
41
40
|
chainId?: number;
|
|
42
41
|
issuedAt?: string;
|
|
42
|
+
jwk?: Record<string, unknown>;
|
|
43
43
|
notBefore?: string;
|
|
44
44
|
expirationTime?: string;
|
|
45
45
|
parents?: string[];
|
|
@@ -47,10 +47,10 @@ export declare const SessionConfigSchema: z.ZodObject<{
|
|
|
47
47
|
domain?: string;
|
|
48
48
|
actions?: Record<string, Record<string, string[]>>;
|
|
49
49
|
spaceId?: string;
|
|
50
|
-
jwk?: Record<string, unknown>;
|
|
51
50
|
address?: string;
|
|
52
51
|
chainId?: number;
|
|
53
52
|
issuedAt?: string;
|
|
53
|
+
jwk?: Record<string, unknown>;
|
|
54
54
|
notBefore?: string;
|
|
55
55
|
expirationTime?: string;
|
|
56
56
|
parents?: string[];
|
|
@@ -78,18 +78,18 @@ export declare const SessionSchema: z.ZodObject<{
|
|
|
78
78
|
verificationMethod: z.ZodString;
|
|
79
79
|
}, "strip", z.ZodTypeAny, {
|
|
80
80
|
spaceId?: string;
|
|
81
|
-
jwk?: Record<string, unknown>;
|
|
82
81
|
delegationHeader?: {
|
|
83
82
|
Authorization?: string;
|
|
84
83
|
};
|
|
84
|
+
jwk?: Record<string, unknown>;
|
|
85
85
|
delegationCid?: string;
|
|
86
86
|
verificationMethod?: string;
|
|
87
87
|
}, {
|
|
88
88
|
spaceId?: string;
|
|
89
|
-
jwk?: Record<string, unknown>;
|
|
90
89
|
delegationHeader?: {
|
|
91
90
|
Authorization?: string;
|
|
92
91
|
};
|
|
92
|
+
jwk?: Record<string, unknown>;
|
|
93
93
|
delegationCid?: string;
|
|
94
94
|
verificationMethod?: string;
|
|
95
95
|
}>;
|
|
@@ -15,8 +15,6 @@ import type { PortableDelegation } from "@tinycloud/node-sdk/core";
|
|
|
15
15
|
export interface RequestPermissionsCoreDeps {
|
|
16
16
|
/** Current stored manifest. Must be defined — caller validates first. */
|
|
17
17
|
manifest: Manifest;
|
|
18
|
-
/** Authenticated owner from the current node, never from a requested resource. */
|
|
19
|
-
ownerDid?: string;
|
|
20
18
|
/**
|
|
21
19
|
* Show the permission request modal. Resolves with `{ approved }`
|
|
22
20
|
* once the user interacts. In tests this is a stub; in production it
|
|
@@ -51,11 +49,6 @@ export interface RequestPermissionsOptions {
|
|
|
51
49
|
* the same error text.
|
|
52
50
|
*/
|
|
53
51
|
export declare function validateAdditionalPermissions(additional: PermissionEntry[]): void;
|
|
54
|
-
/**
|
|
55
|
-
* Normalize only encryption key creation here. Other runtime entries retain
|
|
56
|
-
* their existing Web consent representation; the node validates them.
|
|
57
|
-
*/
|
|
58
|
-
export declare function normalizeRuntimeKeyCreatePermissions(additional: PermissionEntry[], ownerDid?: string): PermissionEntry[];
|
|
59
52
|
/**
|
|
60
53
|
* Core escalation flow. See the TinyCloudWeb.requestPermissions JSDoc
|
|
61
54
|
* for the full spec-level description — this function is the plumbing.
|
|
@@ -3,7 +3,9 @@ export interface RuntimeGrantStore {
|
|
|
3
3
|
loadRuntimeGrants(address: string): Promise<PortableDelegation[]>;
|
|
4
4
|
saveRuntimeGrants(address: string, grants: readonly PortableDelegation[]): Promise<void>;
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
6
|
+
/** Serialize short storage mutations while grant activation runs independently. */
|
|
7
|
+
export declare function serializeRuntimeGrantMutation<T>(store: RuntimeGrantStore | undefined, mutation: () => Promise<T>): Promise<T>;
|
|
8
|
+
/** Bound for the automatic post-restore grant reactivation wait. */
|
|
7
9
|
export declare const RESTORE_GRANT_BUDGET_MS = 4000;
|
|
8
10
|
interface Resource {
|
|
9
11
|
readonly service: string;
|
|
@@ -26,7 +28,7 @@ export declare function isPanelGrant(grant: PortableDelegation, address: string)
|
|
|
26
28
|
* Stores the panel's own grants among `grants` for `address`, replacing a stored grant with the same cid. Other
|
|
27
29
|
* delegations (an app's larger grant that already covered the request) are never stored.
|
|
28
30
|
*/
|
|
29
|
-
export declare function rememberRuntimeGrants(store: RuntimeGrantStore, address: string, grants: readonly PortableDelegation[]): Promise<void>;
|
|
31
|
+
export declare function rememberRuntimeGrants(store: RuntimeGrantStore, address: string, grants: readonly PortableDelegation[], isCurrent?: () => boolean): Promise<void>;
|
|
30
32
|
/**
|
|
31
33
|
* Activates each stored grant through `use` (the SDK's validated activation). A grant refused for good is removed from
|
|
32
34
|
* storage; the others stay, including one whose activation failed for a transient reason. Waits at most `budgetMs`;
|
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,14 +190,15 @@ 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 {
|
|
201
197
|
private openkeySignInInFlight;
|
|
202
198
|
private prepareSignInToken;
|
|
203
|
-
/**
|
|
199
|
+
/** Time bound for the background hosting probe. */
|
|
204
200
|
private spaceHostingCapMs;
|
|
201
|
+
private restoredNetworkWork?;
|
|
205
202
|
private preparedSignIn?;
|
|
206
203
|
private invalidatePreparedSignIn;
|
|
207
204
|
/** The connected wallet's raw EIP-1193 provider. */
|
|
@@ -233,9 +230,8 @@ export declare class TinyCloudWeb {
|
|
|
233
230
|
private signOutCount;
|
|
234
231
|
/** The signer set with `setRuntimePermissionSigner`, with the session it was set for. */
|
|
235
232
|
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
233
|
private signOutInFlight;
|
|
234
|
+
private signOutOperation?;
|
|
239
235
|
private persistedRestoreBlocked;
|
|
240
236
|
private signOutCleanupFailed;
|
|
241
237
|
private remoteSignOutTimeoutMs;
|
|
@@ -281,6 +277,8 @@ export declare class TinyCloudWeb {
|
|
|
281
277
|
* @internal
|
|
282
278
|
*/
|
|
283
279
|
private ensureNode;
|
|
280
|
+
/** Bind a wrapper call to its entry-time authority before initialization can yield. */
|
|
281
|
+
private dispatchCurrentNode;
|
|
284
282
|
/**
|
|
285
283
|
* Get the TinyCloudNode instance synchronously.
|
|
286
284
|
* Throws if called before WASM initialization completes.
|
|
@@ -337,7 +335,7 @@ export declare class TinyCloudWeb {
|
|
|
337
335
|
get delegations(): DelegationManager;
|
|
338
336
|
get capabilityRegistry(): ICapabilityKeyRegistry;
|
|
339
337
|
get spaceId(): string | undefined;
|
|
340
|
-
/**
|
|
338
|
+
/** Hosting display hint bound to account, space and host, corrected by the automatic background probe. */
|
|
341
339
|
get spaceHosting(): SpaceHosting;
|
|
342
340
|
get accountSpaceId(): string | undefined;
|
|
343
341
|
get account(): AccountService;
|
|
@@ -387,6 +385,7 @@ export declare class TinyCloudWeb {
|
|
|
387
385
|
private trackRestoreAddress;
|
|
388
386
|
private untrackRestoreAddress;
|
|
389
387
|
restoreSession(address?: string): Promise<SessionRestoreResult>;
|
|
388
|
+
private startRestoredNetworkWork;
|
|
390
389
|
/** One node read for the restored session, held to {@link spaceHostingCapMs}; past it, or on any failure, the answer stays unknown. */
|
|
391
390
|
private probeSpaceHosting;
|
|
392
391
|
private spaceHostingInFlight?;
|
|
@@ -403,6 +402,7 @@ export declare class TinyCloudWeb {
|
|
|
403
402
|
* resolves `"unknown"` when the node has no hosting answer.
|
|
404
403
|
* Rejects with `Error("Space hosting was cancelled by sign-out.")` if sign-out
|
|
405
404
|
* happens during the hosting run. Call from a user gesture so the approval popup can open.
|
|
405
|
+
* Also rejects if the initiating session is replaced before hosting finishes.
|
|
406
406
|
*/
|
|
407
407
|
ensureSpaceHosted(): Promise<SpaceHosting>;
|
|
408
408
|
clearPersistedSession(address?: string): Promise<void>;
|
|
@@ -524,8 +524,6 @@ export declare class TinyCloudWeb {
|
|
|
524
524
|
* On approve, this does not mutate the manifest or force a new sign-in.
|
|
525
525
|
* The underlying node creates a secondary delegation to the current
|
|
526
526
|
* session key and records it in the invocation permission map.
|
|
527
|
-
* Exact current-owner `default/share/<id>` key creation is bound to this
|
|
528
|
-
* live signed session across consent. Native shells cannot request it.
|
|
529
527
|
*
|
|
530
528
|
* `options.expiryMs` sets the requested lifetime of the issued step-up
|
|
531
529
|
* delegation, in milliseconds. Omitted, the node's default applies. The
|
|
@@ -538,24 +536,12 @@ export declare class TinyCloudWeb {
|
|
|
538
536
|
requestPermissions(additional: PermissionEntry[], options?: RequestPermissionsOptions): Promise<RequestPermissionsResult>;
|
|
539
537
|
/**
|
|
540
538
|
* Signs the SIWE of a runtime permission grant. Precedence: the signer set with `setRuntimePermissionSigner`, then
|
|
541
|
-
* the OpenKey client
|
|
542
|
-
*
|
|
543
|
-
* `
|
|
539
|
+
* the configured OpenKey client's byte-exact `signMessage` (an OpenKey session's wallet provider does not implement
|
|
540
|
+
* `personal_sign`), signing with the keyId of the connected account after connecting the client first when it is not
|
|
541
|
+
* connected; a missing or ambiguous key throws `OpenKeySigningKeyError`. Without an OpenKey client or a session account,
|
|
542
|
+
* undefined: the connected wallet signs. Only `requestPermissions` calls this; sign-in and session setup never do.
|
|
544
543
|
*/
|
|
545
544
|
private runtimeMessageSigner;
|
|
546
|
-
/**
|
|
547
|
-
* Whether the OpenKey client may sign a runtime grant: always, unless there is POSITIVE evidence that it is not connected. It may sign when
|
|
548
|
-
* this instance's session was established through it (and is still the live session), or when its in-memory `lastAuth` is set (`connect()` ran
|
|
549
|
-
* 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
|
|
550
|
-
* does not know: today's behaviour, fail open). `lastAuth` is read here because nothing public says it: `@openkey/sdk` 0.12.2 declares
|
|
551
|
-
* `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`.
|
|
552
|
-
* `getSessionToken()` always answers null in 0.12.2 and `isConnected()` reads the OpenKey cookie, which can be true when `connect()` never ran
|
|
553
|
-
* 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
|
|
554
|
-
* `signMessage()` rejecting when not connected, in `@openkey/sdk`. Trade-off: an app that connects through a DIFFERENT OpenKey instance than
|
|
555
|
-
* `config.openkey.client`, or restores after an authorize-only sign-in, must call `openkey.connect()` on the configured client or
|
|
556
|
-
* `setRuntimePermissionSigner`.
|
|
557
|
-
*/
|
|
558
|
-
private openkeyClientMaySign;
|
|
559
545
|
/**
|
|
560
546
|
* Sets the signer for runtime permission grants (`requestPermissions`, and the panel's "allow" buttons), or clears
|
|
561
547
|
* it with no argument. For apps whose sign-in is not the SDK's OpenKey flow, for example a restored session whose
|
|
@@ -595,7 +581,7 @@ export declare class TinyCloudWeb {
|
|
|
595
581
|
checkPermission(path: string, action: string): Promise<Result<boolean, DelegationError>>;
|
|
596
582
|
/**
|
|
597
583
|
* Receive and retrieve data from a native TinyCloud bearer delegation.
|
|
598
|
-
* Static method — no
|
|
584
|
+
* Static method — no sign-in required. Verifies the parent with browser WASM and routes through the owner's registry.
|
|
599
585
|
*/
|
|
600
586
|
static receiveShare<T = unknown>(link: string, key?: string, options?: {
|
|
601
587
|
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
|