@solarpunkltd/swarm-id 0.8.2 → 0.9.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 +17 -7
- package/dist/chunks/{chat-binding-DgECjSWW.js → chat-binding-BirKsDU3.js} +9 -9
- package/dist/chunks/{chat-binding-DgECjSWW.js.map → chat-binding-BirKsDU3.js.map} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.esm.js +1 -1
- package/dist/internal.esm.js.map +1 -1
- package/dist/swarm-id-button-frame.d.ts +77 -0
- package/dist/swarm-id-client.d.ts +64 -69
- package/dist/swarm-id-proxy.d.ts +18 -49
- package/dist/swarm-id.esm.js +1 -1
- package/dist/swarm-id.esm.js.map +1 -1
- package/dist/types.d.ts +330 -59
- package/dist/utils/button-view.d.ts +16 -0
- package/dist/utils/storage-probe.d.ts +20 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,10 +4,11 @@ TypeScript library for integrating Swarm ID authentication and Bee API operation
|
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
The Swarm ID library provides a secure, iframe-based authentication system for Swarm applications. It consists of
|
|
7
|
+
The Swarm ID library provides a secure, iframe-based authentication system for Swarm applications. It consists of three main components:
|
|
8
8
|
|
|
9
9
|
1. **SwarmIdClient** — For parent windows/dApps to interact with the authentication system
|
|
10
|
-
2. **SwarmIdProxy** — Runs in the iframe, handles authentication and proxies Bee API calls
|
|
10
|
+
2. **SwarmIdProxy** — Runs in the hidden iframe, handles authentication and proxies Bee API calls
|
|
11
|
+
3. **SwarmIdButtonFrame**: the visible Swarm ID button a dApp mounts, whose click opens the connect window
|
|
11
12
|
|
|
12
13
|
Authentication is handled by the SvelteKit identity management UI ([ui](../ui/)).
|
|
13
14
|
|
|
@@ -53,12 +54,21 @@ const client = new SwarmIdClient({
|
|
|
53
54
|
// 2. Initialize (creates hidden iframe; populates client.connectionInfo)
|
|
54
55
|
await client.initialize()
|
|
55
56
|
|
|
56
|
-
//
|
|
57
|
-
//
|
|
57
|
+
// 3. Show Swarm ID's button. It is a small frame of Swarm ID's own that fills
|
|
58
|
+
// the container, and its click opens the connect window. A site on another
|
|
59
|
+
// site than Swarm ID can sign in no other way, because the browser keeps
|
|
60
|
+
// Swarm ID's frames apart from Swarm ID's storage there and lets a frame
|
|
61
|
+
// open a window only from its own click. Unmounting it keeps the session.
|
|
62
|
+
const button = client.mountButton(document.getElementById("sign-in")!, {
|
|
63
|
+
action: "sign-in", // or "change-stamp" for a person signed in
|
|
64
|
+
config: { text: "Sign in", backgroundColor: "#000", borderRadius: "6px" },
|
|
65
|
+
onWindowChange: (state) => console.log("Swarm ID window:", state),
|
|
66
|
+
})
|
|
67
|
+
await button.ready
|
|
58
68
|
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
await client.
|
|
69
|
+
// connect() opens the same window from your own control, but only where your
|
|
70
|
+
// site shares Swarm ID's storage. Elsewhere it refuses with button-required.
|
|
71
|
+
// Sign out stays a library call with no window: await client.disconnect()
|
|
62
72
|
|
|
63
73
|
// 4. Read current connection state synchronously
|
|
64
74
|
const info = client.connectionInfo
|