@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 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 two main components:
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
- // 3a. Option A: Use iframe authentication button
57
- // The iframe will show a connect/disconnect button automatically
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
- // 3b. Option B: Manual authentication with connect()
60
- // Opens the authentication page in a new window/tab (useful for custom UI)
61
- await client.connect()
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