@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/README.md
CHANGED
|
@@ -76,6 +76,35 @@ await tc.signIn();
|
|
|
76
76
|
There is no separate "fresh sign-in" option. Calling `restoreSession()` yourself
|
|
77
77
|
restores a stored session without the manifest check.
|
|
78
78
|
|
|
79
|
+
### Runtime permission grants with OpenKey
|
|
80
|
+
|
|
81
|
+
`requestPermissions()` (and the panel's "allow" buttons) sign each runtime grant's SIWE as a byte-exact message through
|
|
82
|
+
`config.openkey.client.signMessage`, with the `keyId` of the connected OpenKey account. The SDK never sends `signMessage`
|
|
83
|
+
without a `keyId`. If the client is not connected (a restored session, or a sign-in through `authorizeTinyCloud`), the SDK
|
|
84
|
+
connects it first with `client.connect()`, in the configured `mode`:
|
|
85
|
+
|
|
86
|
+
- **`iframe` (and `redirect`)**: the grant connects and signs in one go, in one click.
|
|
87
|
+
- **`popup` (the default)**: a browser lets a page open a popup only soon after the user's click, and the user needs longer
|
|
88
|
+
than that to sign in inside the connect popup, so a sign popup opened right after it would be blocked. The first click
|
|
89
|
+
therefore connects and rejects with `OpenKeySigningKeyError` code `OPENKEY_CONNECTED_RETRY`, signing nothing. The client
|
|
90
|
+
is now connected: show your Allow button again, and the second click signs with the connected key in one popup. Once the
|
|
91
|
+
client is connected, every later grant is one click.
|
|
92
|
+
|
|
93
|
+
When no single key can be named, or the client was just connected in popup mode, `requestPermissions()` rejects with
|
|
94
|
+
`OpenKeySigningKeyError` before any sign request:
|
|
95
|
+
|
|
96
|
+
| `code` | Meaning |
|
|
97
|
+
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
98
|
+
| `OPENKEY_CONNECTED_RETRY` | Popup mode only. The SDK connected the client. Nothing was signed; ask the user to click Allow again. |
|
|
99
|
+
| `OPENKEY_KEY_MISSING` | The client is not connected and has no `connect()`, or `connect()` answered without a `keyId`. |
|
|
100
|
+
| `OPENKEY_KEY_AMBIGUOUS` | The connected key's address is not the signed-in account's, or it reports no address. |
|
|
101
|
+
|
|
102
|
+
`OPENKEY_KEY_MISSING` and `OPENKEY_KEY_AMBIGUOUS`: connect the configured client as the signed-in account
|
|
103
|
+
(`await openkey.connect()`), or sign runtime grants with `tc.setRuntimePermissionSigner(...)`. Connecting it yourself in the
|
|
104
|
+
click that starts sign-in avoids the extra click. A user closing the connect dialog rejects with `@openkey/sdk`'s own plain-object rejection `{ code: "USER_CANCELLED" }` (not an `Error`, and not an `OpenKeySigningKeyError`), so tell it apart from `OPENKEY_CONNECTED_RETRY`, which is an `OpenKeySigningKeyError`. A blocked popup rejects the same way with `{ code: "POPUP_BLOCKED" }`. If
|
|
105
|
+
the session ends or changes (sign-out, another account) while a dialog is open, the grant is cancelled and nothing is
|
|
106
|
+
signed. The two-click flow needs a client that keeps the connect result in `lastAuth`, as `@openkey/sdk` does.
|
|
107
|
+
|
|
79
108
|
## Signed registry cache
|
|
80
109
|
|
|
81
110
|
The browser client stores exact owner-signed v2 registry responses beside its identity pins, under `tinycloud.registryCache.v2:<ownerKey>`. Fetch time, invalidation revision and sequence metadata are outside the signed response. Every routing decision awaits a bounded, coalesced refresh and verifies cached responses again. Only a higher verified sequence replaces signed bytes; equal-sequence renewal requires identical canonical signed meaning, not identical HTTP formatting.
|