@beaconmcu/auth 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +37 -2
  2. package/package.json +12 -1
package/README.md CHANGED
@@ -8,7 +8,9 @@ Add "Sign in with Google" to your Stellar dApp. Your users get a wallet instantl
8
8
  npm install @beaconmcu/auth
9
9
  ```
10
10
 
11
- Create an app in the [Beacon dashboard](https://dashboard.beaconmcu.space), add your site's URL as an allowed origin, and copy the Client ID.
11
+ Create an app in the [Beacon dashboard](https://dashboard.beaconmcu.space) and copy its Client ID. Local development (`localhost`) works with nothing else to set up; add your live site's address under **Domains** before you launch.
12
+
13
+ **Requirements:** a modern browser. The package has no dependencies, includes TypeScript types, and works as ESM or CommonJS. Full docs: https://dashboard.beaconmcu.space/docs
12
14
 
13
15
  ## Quick start
14
16
 
@@ -26,6 +28,38 @@ await beacon.logout();
26
28
 
27
29
  `beacon.getAddress()` returns the address or `null`. `beacon.getNetwork()` returns the active network.
28
30
 
31
+ ## Build with AI
32
+
33
+ Copy a ready-made prompt for Claude, ChatGPT or Cursor from https://dashboard.beaconmcu.space/docs#build-with-ai. It describes the whole SDK, so an assistant can build your app from it. Open one of your apps in the dashboard to get the prompt with your Client ID filled in.
34
+
35
+ ## React and Next.js
36
+
37
+ Create one `BeaconAuth` for the whole app, in its own file, and read it from your components:
38
+
39
+ ```tsx
40
+ // beacon.ts
41
+ import { BeaconAuth } from "@beaconmcu/auth";
42
+ export const beacon = new BeaconAuth({ clientId: "bcn_app_...", defaultNetwork: "testnet" });
43
+
44
+ // LoginButton.tsx (in Next.js, add "use client" at the top)
45
+ import { useEffect, useState } from "react";
46
+ import { beacon } from "./beacon";
47
+
48
+ export function LoginButton() {
49
+ const [address, setAddress] = useState(beacon.getAddress());
50
+
51
+ useEffect(() => beacon.on("accountChanged", setAddress), []); // returns the function that unsubscribes
52
+
53
+ return address ? (
54
+ <button onClick={() => beacon.logout()}>Log out ({address.slice(0, 6)}…)</button>
55
+ ) : (
56
+ <button onClick={() => beacon.login()}>Log in</button>
57
+ );
58
+ }
59
+ ```
60
+
61
+ It is safe to import on the server (it only touches the page in the browser). Use it from client-side code.
62
+
29
63
  ## Send XLM (one call)
30
64
 
31
65
  ```ts
@@ -83,7 +117,8 @@ beacon.on("networkChanged", (network) => console.log(network));
83
117
  ```
84
118
 
85
119
  - `"testnet"` has free test XLM (Friendbot). `"mainnet"` is real money.
86
- - Without `defaultNetwork`, the app's network from the Beacon dashboard is used (testnet if none).
120
+ - **Which network is used:** your code wins. If `defaultNetwork` is set, that is used. If not, the app's **default network** from the Beacon dashboard (Settings) is used.
121
+ - **Call `getNetwork()` after `login()`.** Before login the SDK has not heard from the wallet, so without `defaultNetwork` in code it reports testnet even if your dashboard says Mainnet. After login it reports the wallet's real network.
87
122
  - A network outside `supportedNetworks` is rejected with error code `-6`.
88
123
  - Every approval screen in the wallet shows the network, and marks mainnet as "real funds".
89
124
  - A Stellar account exists only after it receives at least 1 XLM. On testnet, fund it with Friendbot.
package/package.json CHANGED
@@ -1,7 +1,18 @@
1
1
  {
2
2
  "name": "@beaconmcu/auth",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Embedded wallet with Google sign-in for Stellar dApps",
5
+ "keywords": [
6
+ "stellar",
7
+ "soroban",
8
+ "wallet",
9
+ "embedded-wallet",
10
+ "google-login",
11
+ "social-login",
12
+ "web3",
13
+ "auth"
14
+ ],
15
+ "homepage": "https://dashboard.beaconmcu.space/docs",
5
16
  "license": "MIT",
6
17
  "type": "module",
7
18
  "main": "./dist/index.cjs",