@tinycloud/web-sdk 3.12.0-beta.5 → 3.12.0-beta.6
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 +29 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +1 -1
- package/dist/modules/tcw.d.ts +4 -18
- package/dist/openkey-signing-key.d.ts +51 -0
- package/package.json +3 -2
package/dist/modules/tcw.d.ts
CHANGED
|
@@ -223,8 +223,6 @@ export declare class TinyCloudWeb {
|
|
|
223
223
|
private signOutCount;
|
|
224
224
|
/** The signer set with `setRuntimePermissionSigner`, with the session it was set for. */
|
|
225
225
|
private runtimeSigner?;
|
|
226
|
-
/** Set when this instance's session was established through the configured OpenKey client; bound to that session like `runtimeSigner`. */
|
|
227
|
-
private openkeySession?;
|
|
228
226
|
private signOutInFlight;
|
|
229
227
|
private persistedRestoreBlocked;
|
|
230
228
|
private signOutCleanupFailed;
|
|
@@ -528,24 +526,12 @@ export declare class TinyCloudWeb {
|
|
|
528
526
|
requestPermissions(additional: PermissionEntry[], options?: RequestPermissionsOptions): Promise<RequestPermissionsResult>;
|
|
529
527
|
/**
|
|
530
528
|
* Signs the SIWE of a runtime permission grant. Precedence: the signer set with `setRuntimePermissionSigner`, then
|
|
531
|
-
* the OpenKey client
|
|
532
|
-
*
|
|
533
|
-
* `
|
|
529
|
+
* the configured OpenKey client's byte-exact `signMessage` (an OpenKey session's wallet provider does not implement
|
|
530
|
+
* `personal_sign`), signing with the keyId of the connected account after connecting the client first when it is not
|
|
531
|
+
* connected; a missing or ambiguous key throws `OpenKeySigningKeyError`. Without an OpenKey client or a session account,
|
|
532
|
+
* undefined: the connected wallet signs. Only `requestPermissions` calls this; sign-in and session setup never do.
|
|
534
533
|
*/
|
|
535
534
|
private runtimeMessageSigner;
|
|
536
|
-
/**
|
|
537
|
-
* Whether the OpenKey client may sign a runtime grant: always, unless there is POSITIVE evidence that it is not connected. It may sign when
|
|
538
|
-
* this instance's session was established through it (and is still the live session), or when its in-memory `lastAuth` is set (`connect()` ran
|
|
539
|
-
* 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
|
|
540
|
-
* does not know: today's behaviour, fail open). `lastAuth` is read here because nothing public says it: `@openkey/sdk` 0.12.2 declares
|
|
541
|
-
* `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`.
|
|
542
|
-
* `getSessionToken()` always answers null in 0.12.2 and `isConnected()` reads the OpenKey cookie, which can be true when `connect()` never ran
|
|
543
|
-
* 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
|
|
544
|
-
* `signMessage()` rejecting when not connected, in `@openkey/sdk`. Trade-off: an app that connects through a DIFFERENT OpenKey instance than
|
|
545
|
-
* `config.openkey.client`, or restores after an authorize-only sign-in, must call `openkey.connect()` on the configured client or
|
|
546
|
-
* `setRuntimePermissionSigner`.
|
|
547
|
-
*/
|
|
548
|
-
private openkeyClientMaySign;
|
|
549
535
|
/**
|
|
550
536
|
* Sets the signer for runtime permission grants (`requestPermissions`, and the panel's "allow" buttons), or clears
|
|
551
537
|
* it with no argument. For apps whose sign-in is not the SDK's OpenKey flow, for example a restored session whose
|
|
@@ -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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinycloud/web-sdk",
|
|
3
|
-
"version": "3.12.0-beta.
|
|
3
|
+
"version": "3.12.0-beta.6",
|
|
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",
|
|
@@ -59,7 +59,8 @@
|
|
|
59
59
|
"build:e2e-data-proxy": "bun build ./e2e/fixtures/data-proxy-harness-entry.ts --target=browser --format=esm --splitting --outdir=./e2e/.build/data-proxy",
|
|
60
60
|
"build:e2e-prompts-lazy": "bun build ./e2e/fixtures/prompts-lazy-harness-entry.ts --target=browser --format=esm --splitting --outdir=./e2e/.build/prompts-lazy",
|
|
61
61
|
"build:e2e-prefetch": "bun build ./e2e/fixtures/prefetch-harness-entry.ts --target=browser --format=esm --splitting --outdir=./e2e/.build/prefetch",
|
|
62
|
-
"
|
|
62
|
+
"build:e2e-openkey-grant": "bun build ./e2e/fixtures/openkey-runtime-grant-harness-entry.ts --target=browser --format=iife --outfile=./e2e/.build/openkey-grant.bundle.js",
|
|
63
|
+
"test:e2e": "bun run build:e2e-ui && bun run build:e2e-storage && bun run build:e2e-prompts && bun run build:e2e-prompts-lazy && bun run build:e2e-prefetch && bun run build:e2e-data-proxy && bun run build:e2e-openkey-grant && playwright test -c playwright.e2e.config.ts",
|
|
63
64
|
"test": "jest"
|
|
64
65
|
},
|
|
65
66
|
"dependencies": {
|