@beaconmcu/auth 0.1.4 → 0.1.5

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/dist/index.cjs CHANGED
@@ -143,7 +143,8 @@ var WalletConnection = class {
143
143
  zIndex: "2147483647",
144
144
  alignItems: "center",
145
145
  justifyContent: "center",
146
- background: "rgba(0, 0, 0, 0.6)"
146
+ background: "transparent"
147
+ // no dark backdrop: only a soft shadow around the wallet (on the iframe below)
147
148
  });
148
149
  const iframe = document.createElement("iframe");
149
150
  iframe.title = "Beacon wallet";
@@ -151,13 +152,15 @@ var WalletConnection = class {
151
152
  iframe.src = this.src;
152
153
  Object.assign(iframe.style, {
153
154
  width: "min(380px, calc(100vw - 32px))",
154
- height: "520px",
155
- // the wallet's fixed height; the wallet confirms it with beacon:resize
155
+ height: "380px",
156
+ // the wallet's fixed height (a square: same as the width); the wallet confirms it with beacon:resize
156
157
  maxHeight: "calc(100vh - 32px)",
157
158
  transition: "height 120ms ease",
158
159
  border: "0",
159
160
  borderRadius: "20px",
160
161
  // the wallet is one white card; the iframe clips it to rounded corners
162
+ boxShadow: "0 0 0 1px rgba(0,0,0,0.04), 0 8px 40px rgba(0,0,0,0.28), 0 0 90px 24px rgba(0,0,0,0.18)",
163
+ // feathered glow
161
164
  background: "#ffffff",
162
165
  overflow: "hidden"
163
166
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/shared/networks.ts","../src/shared/messages.ts","../src/errors.ts","../src/connection.ts","../src/emitter.ts","../src/stellar.ts","../src/BeaconAuth.ts"],"names":[],"mappings":";;;AAeO,IAAM,QAAA,GAA2C;AAAA,EACtD,OAAA,EAAS;AAAA,IACP,EAAA,EAAI,SAAA;AAAA,IACJ,IAAA,EAAM,iBAAA;AAAA,IACN,UAAA,EAAY,mCAAA;AAAA,IACZ,UAAA,EAAY,qCAAA;AAAA,IACZ,WAAA,EAAa,yCAAA;AAAA,IACb,YAAA,EAAc;AAAA,GAChB;AA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AA,EAGA,OAAA,GAAgB;AACd,IAAA,IAAA,CAAK,WAAW,OAAA,EAAQ;AAAA,EAC1B;AAAA;AAAA,EAIQ,qBAAqB,OAAA,EAA0B;AACrD,IAAA,IAAI,OAAA,KAAY,KAAK,OAAA,EAAS;AAC9B,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AACf,IAAA,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,gBAAA,EAAkB,OAAO,CAAA;AAAA,EAC5C;AAAA,EAEQ,eAAA,CAAgB,SAAiB,OAAA,EAA0B;AACjE,IAAA,MAAM,cAAA,GAAiB,KAAK,OAAA,KAAY,OAAA;AACxC,IAAA,MAAM,cAAA,GAAiB,KAAK,OAAA,KAAY,OAAA;AACxC,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AACf,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAEf,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,SAAA,EAAW,EAAE,OAAA,EAAS,SAAS,CAAA;AAChD,IAAA,IAAI,cAAA,EAAgB,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,kBAAkB,OAAO,CAAA;AAC9D,IAAA,IAAI,cAAA,EAAgB,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,kBAAkB,OAAO,CAAA;AAAA,EAChE;AAAA,EAEQ,kBAAA,GAA2B;AACjC,IAAA,IAAI,CAAC,KAAK,OAAA,EAAS;AACnB,IAAA,IAAA,CAAK,OAAA,GAAU,IAAA;AACf,IAAA,IAAA,CAAK,MAAA,CAAO,KAAK,YAAY,CAAA;AAC7B,IAAA,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,gBAAA,EAAkB,IAAI,CAAA;AAAA,EACzC;AACF","file":"index.cjs","sourcesContent":["// Stellar network data with NO imports, so the SDK bundle stays tiny.\n// The wallet keeps its own copy (wallet/src/shared/networks.ts): keep them in sync.\n// Source: https://developers.stellar.org/docs/networks\n\nexport type NetworkId = \"testnet\" | \"mainnet\";\n\nexport type NetworkInfo = {\n id: NetworkId;\n name: string;\n passphrase: string; // identifies the network inside every signed transaction\n horizonUrl: string;\n explorerUrl: string;\n friendbotUrl?: string; // free test funds: testnet only\n};\n\nexport const NETWORKS: Record<NetworkId, NetworkInfo> = {\n testnet: {\n id: \"testnet\",\n name: \"Stellar Testnet\",\n passphrase: \"Test SDF Network ; September 2015\",\n horizonUrl: \"https://horizon-testnet.stellar.org\",\n explorerUrl: \"https://stellar.expert/explorer/testnet\",\n friendbotUrl: \"https://friendbot.stellar.org\",\n },\n mainnet: {\n id: \"mainnet\",\n name: \"Stellar Mainnet\",\n passphrase: \"Public Global Stellar Network ; September 2015\",\n horizonUrl: \"https://horizon.stellar.org\",\n explorerUrl: \"https://stellar.expert/explorer/public\",\n },\n};\n\nexport const isNetworkId = (value: unknown): value is NetworkId => value === \"testnet\" || value === \"mainnet\";\n","// postMessage protocol between the SDK (parent page) and the wallet iframe.\n// Used by both sides. Contains no secrets and no crypto.\n// The wallet keeps its own copy (wallet/src/shared/messages.ts): keep them in sync.\n\nimport { isNetworkId, type NetworkId } from \"./networks\";\n\n// ---- error codes: the ones from SEP-43 (Stellar wallet interface), plus a few of ours ----\nexport const ErrorCode = {\n INTERNAL: -1, // internal wallet error\n EXTERNAL: -2, // an outside service (Horizon, network) failed\n INVALID_REQUEST: -3, // bad parameters, malformed XDR, wrong network\n USER_REJECTED: -4, // the user said no: do not retry\n NOT_CONNECTED: -5, // log in first\n UNSUPPORTED: -6, // method or network not supported\n BUSY: -7, // another request is already waiting for the user\n} as const;\n\nexport type RpcError = { code: number; message: string };\n\n// ---- SDK -> wallet ----\n\n// Must be the FIRST message the SDK sends. The wallet checks event.origin against the app's allowed origins.\n// Optionally carries the networks the app configured in code (defaultNetwork / supportedNetworks).\nexport type BeaconInit = {\n type: \"beacon:init\";\n networks?: { default?: NetworkId; supported?: NetworkId[] };\n // false = sign LOW-RISK requests (messages, plain payments) without a confirmation screen. Default: true.\n showWalletUI?: boolean;\n};\n\nexport type BeaconRequest = {\n type: \"beacon:request\";\n id: string;\n method: string;\n params?: unknown[];\n};\n\n// Methods the wallet handles.\nexport const WALLET_METHODS = [\n \"beacon_login\",\n \"beacon_logout\",\n \"beacon_cancel\", // params: [requestId]. The SDK gave up on a request (timeout): the wallet drops it.\n \"stellar_getAddress\",\n \"stellar_getNetwork\",\n \"stellar_switchNetwork\", // params: [networkId], only between the app's supported networks\n \"stellar_sendPayment\", // params: [{ to, amount, memo? }]. The wallet builds, signs and submits an XLM payment.\n \"stellar_signTransaction\", // params: [xdr, { networkPassphrase?, address? }?]\n \"stellar_signMessage\", // params: [message, { address? }?] (SEP-53)\n \"stellar_signAuthEntry\", // params: [base64 preimage, { networkPassphrase?, address? }?]\n] as const;\n\n// ---- wallet -> SDK ----\n\nexport type BeaconResponse =\n | { type: \"beacon:response\"; id: string; result: unknown }\n | { type: \"beacon:response\"; id: string; error: RpcError };\n\nexport type WalletEvent =\n | { type: \"beacon:ready\" }\n | { type: \"beacon:connected\"; address: string; network: NetworkId }\n | { type: \"beacon:disconnected\" }\n | { type: \"beacon:show\" }\n | { type: \"beacon:hide\" }\n | { type: \"beacon:resize\"; height: number } // content height in px, so the SDK can fit the iframe\n | { type: \"beacon:networkChanged\"; network: NetworkId };\n\nexport type WalletMessage = BeaconResponse | WalletEvent;\n\n// ---- type guards (message data is untrusted) ----\n\nconst isObject = (v: unknown): v is Record<string, unknown> => typeof v === \"object\" && v !== null;\n\nexport function isBeaconInit(data: unknown): data is BeaconInit {\n return isObject(data) && data.type === \"beacon:init\";\n}\n\n// The networks an app asked for in its init message (untrusted input): known ids only.\nexport function readInitNetworks(init: BeaconInit): { default?: NetworkId; supported: NetworkId[] } {\n const raw = init.networks;\n const supported = Array.isArray(raw?.supported) ? raw.supported.filter(isNetworkId).slice(0, 2) : [];\n return { default: isNetworkId(raw?.default) ? raw.default : undefined, supported };\n}\n\n// Did the app turn confirmation screens off? (untrusted input: only an explicit false counts)\nexport function readInitShowWalletUI(init: BeaconInit): boolean {\n return init.showWalletUI !== false;\n}\n\nexport function isBeaconRequest(data: unknown): data is BeaconRequest {\n return (\n isObject(data) &&\n data.type === \"beacon:request\" &&\n typeof data.id === \"string\" &&\n typeof data.method === \"string\" &&\n (data.params === undefined || Array.isArray(data.params))\n );\n}\n\nexport function isWalletMessage(data: unknown): data is WalletMessage {\n if (!isObject(data) || typeof data.type !== \"string\") return false;\n switch (data.type) {\n case \"beacon:ready\":\n case \"beacon:disconnected\":\n case \"beacon:show\":\n case \"beacon:hide\":\n return true;\n case \"beacon:networkChanged\":\n return isNetworkId(data.network);\n case \"beacon:resize\":\n return typeof data.height === \"number\" && Number.isFinite(data.height) && data.height > 0;\n case \"beacon:connected\":\n return typeof data.address === \"string\" && isNetworkId(data.network);\n case \"beacon:response\":\n return (\n typeof data.id === \"string\" &&\n (\"result\" in data ||\n (isObject(data.error) && typeof data.error.code === \"number\" && typeof data.error.message === \"string\"))\n );\n default:\n return false;\n }\n}\n","import { ErrorCode } from \"./shared/messages\";\n\n// Error with a numeric `code` from the Stellar wallet standard (SEP-43): -4 means the user rejected it.\nexport class BeaconError extends Error {\n code: number;\n\n constructor(code: number, message: string) {\n super(message);\n this.name = \"BeaconError\";\n this.code = code;\n }\n}\n\nexport const internalError = (message: string) => new BeaconError(ErrorCode.INTERNAL, message);\n","import {\n isWalletMessage,\n ErrorCode,\n type BeaconInit,\n type BeaconRequest,\n type BeaconResponse,\n} from \"./shared/messages\";\nimport { BeaconError, internalError } from \"./errors\";\nimport type { NetworkId } from \"./shared/networks\";\n\nconst READY_TIMEOUT_MS = 15_000;\n\n// Requests that open the wallet window. If the wallet is still loading, the frame opens at once and\n// the wallet shows its own loading screen (the SDK draws nothing itself).\nconst INTERACTIVE_METHODS = new Set([\n \"beacon_login\",\n \"stellar_sendPayment\",\n \"stellar_signTransaction\",\n \"stellar_signMessage\",\n \"stellar_signAuthEntry\",\n]);\n\ntype Pending = {\n resolve: (value: unknown) => void;\n reject: (error: Error) => void;\n timer: ReturnType<typeof setTimeout>;\n};\n\ntype Handlers = {\n onNetworkChanged: (network: NetworkId) => void;\n onConnected: (address: string, network: NetworkId) => void;\n onDisconnected: () => void;\n};\n\n// Owns the wallet iframe and the postMessage channel to it.\n// Only messages from the wallet's origin AND from this iframe's window are accepted.\nexport class WalletConnection {\n private readonly walletOrigin: string;\n private readonly src: string;\n private overlay: HTMLDivElement | null = null;\n private iframe: HTMLIFrameElement | null = null;\n private openedEarly = false; // the frame was opened before the wallet asked for it (it was still loading)\n private pending = new Map<string, Pending>();\n private isReady = false;\n private readyWaiters: Array<() => void> = [];\n\n constructor(\n walletUrl: string,\n private clientId: string,\n private networks: { default?: NetworkId; supported?: NetworkId[] } | undefined,\n private showWalletUI: boolean,\n private handlers: Handlers,\n ) {\n let url: URL;\n try {\n url = new URL(walletUrl);\n } catch {\n throw new BeaconError(ErrorCode.INTERNAL, `Invalid walletUrl: ${walletUrl}`);\n }\n this.walletOrigin = url.origin;\n url.pathname = \"/\";\n url.search = \"\";\n url.hash = \"\";\n url.searchParams.set(\"client_id\", clientId);\n this.src = url.toString();\n\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"message\", this.onMessage);\n this.mount();\n }\n }\n\n // ---- iframe + modal ----\n\n private mount(): void {\n const attach = () => {\n const overlay = document.createElement(\"div\");\n Object.assign(overlay.style, {\n display: \"none\",\n position: \"fixed\",\n inset: \"0\",\n zIndex: \"2147483647\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"rgba(0, 0, 0, 0.6)\",\n });\n\n const iframe = document.createElement(\"iframe\");\n iframe.title = \"Beacon wallet\";\n // clipboard-write: lets the wallet copy the address.\n iframe.allow = \"clipboard-write\";\n iframe.src = this.src;\n Object.assign(iframe.style, {\n width: \"min(380px, calc(100vw - 32px))\",\n height: \"520px\", // the wallet's fixed height; the wallet confirms it with beacon:resize\n maxHeight: \"calc(100vh - 32px)\",\n transition: \"height 120ms ease\",\n border: \"0\",\n borderRadius: \"20px\", // the wallet is one white card; the iframe clips it to rounded corners\n background: \"#ffffff\",\n overflow: \"hidden\",\n });\n\n // The first message to the wallet. It checks our origin against the app's allowed origins.\n iframe.addEventListener(\"load\", () => {\n const init: BeaconInit = { type: \"beacon:init\", ...(this.networks && { networks: this.networks }),\n ...(!this.showWalletUI && { showWalletUI: false }) };\n iframe.contentWindow?.postMessage(init, this.walletOrigin);\n });\n\n overlay.appendChild(iframe);\n document.body.appendChild(overlay);\n this.overlay = overlay;\n this.iframe = iframe;\n };\n\n if (document.body) attach();\n else document.addEventListener(\"DOMContentLoaded\", attach, { once: true });\n }\n\n private setVisible(visible: boolean): void {\n if (!this.overlay || !this.iframe) return;\n this.openedEarly = false;\n this.overlay.style.display = visible ? \"flex\" : \"none\";\n if (visible) this.iframe.focus();\n }\n\n // The user acted before the wallet finished loading: open the frame now. The wallet's own\n // loading screen is what they see, and it takes over from there.\n private openEarly(): void {\n if (!this.overlay || this.openedEarly || this.overlay.style.display !== \"none\") return;\n this.openedEarly = true;\n this.overlay.style.display = \"flex\";\n }\n\n // Opened early, but the wallet never asked to be shown (or failed): close it again.\n private closeEarly(): void {\n if (!this.openedEarly) return;\n this.openedEarly = false;\n if (this.overlay) this.overlay.style.display = \"none\";\n }\n\n // ---- incoming messages ----\n\n private onMessage = (event: MessageEvent): void => {\n if (event.origin !== this.walletOrigin) return;\n if (!this.iframe || event.source !== this.iframe.contentWindow) return;\n if (!isWalletMessage(event.data)) return;\n\n const message = event.data;\n switch (message.type) {\n case \"beacon:ready\":\n this.isReady = true;\n this.readyWaiters.splice(0).forEach((resolve) => resolve());\n break;\n case \"beacon:show\":\n this.setVisible(true);\n break;\n case \"beacon:hide\":\n this.setVisible(false);\n break;\n case \"beacon:resize\":\n // Fit the modal to the wallet's content (max-height keeps it inside the viewport).\n if (this.iframe) this.iframe.style.height = `${Math.ceil(message.height)}px`;\n break;\n case \"beacon:networkChanged\":\n this.handlers.onNetworkChanged(message.network);\n break;\n case \"beacon:connected\":\n this.handlers.onConnected(message.address, message.network);\n break;\n case \"beacon:disconnected\":\n this.handlers.onDisconnected();\n break;\n case \"beacon:response\":\n this.settle(message);\n break;\n }\n };\n\n private settle(message: BeaconResponse): void {\n const entry = this.pending.get(message.id);\n if (!entry) return; // unknown or already timed out\n this.closeEarly(); // answered without ever showing the wallet (e.g. already connected)\n this.pending.delete(message.id);\n clearTimeout(entry.timer);\n\n if (\"error\" in message) entry.reject(new BeaconError(message.error.code, message.error.message));\n else entry.resolve(message.result);\n }\n\n // ---- outgoing requests ----\n\n private whenReady(): Promise<void> {\n if (this.isReady) return Promise.resolve();\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => {\n this.readyWaiters = this.readyWaiters.filter((w) => w !== onReady);\n this.closeEarly();\n reject(\n internalError(\n `The Beacon wallet did not load. Check that this site (${window.location.origin}) is an allowed origin ` +\n `for Client ID ${this.clientId}, and that the wallet URL (${this.walletOrigin}) is correct.`,\n ),\n );\n }, READY_TIMEOUT_MS);\n const onReady = () => {\n clearTimeout(timer);\n resolve();\n };\n this.readyWaiters.push(onReady);\n });\n }\n\n async request(method: string, params: unknown[], timeoutMs: number): Promise<unknown> {\n if (typeof window === \"undefined\") throw internalError(\"Beacon can only be used in a browser\");\n // Still loading? Open the frame now instead of waiting invisibly.\n if (!this.isReady && INTERACTIVE_METHODS.has(method)) this.openEarly();\n await this.whenReady();\n\n const target = this.iframe?.contentWindow;\n if (!target) throw internalError(\"The Beacon wallet is not available\");\n\n const id = newId();\n return new Promise<unknown>((resolve, reject) => {\n const timer = setTimeout(() => {\n this.pending.delete(id);\n this.cancel(id); // tell the wallet to drop it, so a late approval can't go unnoticed\n reject(internalError(`Wallet request timed out (${method})`));\n }, timeoutMs);\n\n this.pending.set(id, { resolve, reject, timer });\n const request: BeaconRequest = { type: \"beacon:request\", id, method, params };\n target.postMessage(request, this.walletOrigin);\n });\n }\n\n private cancel(requestId: string): void {\n const request: BeaconRequest = { type: \"beacon:request\", id: newId(), method: \"beacon_cancel\", params: [requestId] };\n this.iframe?.contentWindow?.postMessage(request, this.walletOrigin);\n }\n\n destroy(): void {\n if (typeof window === \"undefined\") return;\n window.removeEventListener(\"message\", this.onMessage);\n this.pending.forEach((entry) => {\n clearTimeout(entry.timer);\n entry.reject(internalError(\"Beacon was destroyed\"));\n });\n this.pending.clear();\n this.overlay?.remove();\n this.overlay = this.iframe = null;\n }\n}\n\nfunction newId(): string {\n if (typeof crypto !== \"undefined\" && \"randomUUID\" in crypto) return crypto.randomUUID();\n return `${Date.now()}-${Math.random().toString(36).slice(2)}`;\n}\n","// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Listener = (...args: any[]) => void;\n\nexport class Emitter {\n private listeners = new Map<string, Set<Listener>>();\n\n on(event: string, listener: Listener): () => void {\n let set = this.listeners.get(event);\n if (!set) this.listeners.set(event, (set = new Set()));\n set.add(listener);\n return () => this.off(event, listener);\n }\n\n off(event: string, listener: Listener): void {\n this.listeners.get(event)?.delete(listener);\n }\n\n emit(event: string, ...args: unknown[]): void {\n for (const listener of [...(this.listeners.get(event) ?? [])]) {\n try {\n listener(...args);\n } catch {\n // A faulty listener in the dApp must not break the SDK.\n }\n }\n }\n}\n","import type { BeaconAuth } from \"./BeaconAuth\";\nimport { BeaconError } from \"./errors\";\n\n// The standard Stellar wallet interface (SEP-43), so Beacon can plug into libraries like Stellar\n// Wallets Kit. Each function returns the result, or { error: { code, message } } instead of throwing.\n// Error codes: -1 internal, -2 external service, -3 invalid request, -4 user rejected.\n\ntype WalletError = { error: { code: number; message: string } };\n\nexport interface StellarWalletInterface {\n getAddress(): Promise<{ address: string } | WalletError>;\n getNetwork(): Promise<{ network: string; networkPassphrase: string } | WalletError>;\n signTransaction(\n xdr: string,\n opts?: { networkPassphrase?: string; address?: string },\n ): Promise<{ signedTxXdr: string; signerAddress: string } | WalletError>;\n signMessage(\n message: string,\n opts?: { address?: string },\n ): Promise<{ signedMessage: string; signerAddress: string } | WalletError>;\n signAuthEntry(\n authEntry: string,\n opts?: { networkPassphrase?: string; address?: string },\n ): Promise<{ signedAuthEntry: string; signerAddress: string } | WalletError>;\n}\n\nasync function wrap<T>(run: () => Promise<T>): Promise<T | WalletError> {\n try {\n return await run();\n } catch (error) {\n if (error instanceof BeaconError) return { error: { code: error.code, message: error.message } };\n return { error: { code: -1, message: \"Something went wrong\" } };\n }\n}\n\nexport function createWalletInterface(beacon: BeaconAuth): StellarWalletInterface {\n return {\n // getAddress logs the user in if needed, like Freighter's \"connect\".\n getAddress: () => wrap(() => beacon.login()),\n getNetwork: () =>\n wrap(async () => {\n const { id, passphrase } = beacon.getNetwork();\n return { network: id === \"mainnet\" ? \"PUBLIC\" : \"TESTNET\", networkPassphrase: passphrase };\n }),\n signTransaction: (xdr, opts) => wrap(() => beacon.signTransaction(xdr, opts)),\n signMessage: (message, opts) => wrap(() => beacon.signMessage(message, opts)),\n signAuthEntry: (authEntry, opts) => wrap(() => beacon.signAuthEntry(authEntry, opts)),\n };\n}\n","import { WalletConnection } from \"./connection\";\nimport { Emitter } from \"./emitter\";\nimport { BeaconError } from \"./errors\";\nimport { ErrorCode } from \"./shared/messages\";\nimport { isNetworkId, NETWORKS, type NetworkId, type NetworkInfo } from \"./shared/networks\";\nimport { createWalletInterface, type StellarWalletInterface } from \"./stellar\";\n\nexport type BeaconOptions = {\n /** Public Client ID from the Beacon dashboard (bcn_app_...). */\n clientId: string;\n /** Network used on login. Defaults to the app's network from the dashboard (testnet if none). */\n defaultNetwork?: NetworkId;\n /** Networks the app can switch between with switchNetwork(). Defaults to just the default network. */\n supportedNetworks?: NetworkId[];\n /** Optional. Beacon's wallet is built in, so apps normally never set this (it is for testing a different wallet). */\n walletUrl?: string;\n /**\n * Show the wallet's confirmation screen before signing. Default true.\n * Set false to sign low-risk requests silently (messages and plain XLM payments from the user's own\n * account). Anything risky (contract calls, account changes, other accounts) is always confirmed.\n */\n showWalletUI?: boolean;\n};\n\nexport type BeaconEventMap = {\n connect: (info: { address: string; network: NetworkId }) => void;\n disconnect: () => void;\n accountChanged: (address: string | null) => void;\n networkChanged: (network: NetworkId) => void;\n};\n\n// The wallet apps open by default. Published versions keep calling this address, so it must stay working.\n// (Versions before 0.1.3 used the older wallet.josephakpansunday.workers.dev, which must also stay up.)\nconst DEFAULT_WALLET_URL = \"https://wallet.beaconmcu.space\";\n\n// Waiting for a person: sign-in includes a Google popup, so it gets longer than other calls.\nconst LOGIN_TIMEOUT_MS = 5 * 60_000;\nconst SIGNING_TIMEOUT_MS = 60_000;\nconst SEND_TIMEOUT_MS = 90_000; // approval plus building and submitting on the network\nconst DEFAULT_TIMEOUT_MS = 15_000;\n\nfunction checkNetwork(network: unknown): NetworkId {\n if (!isNetworkId(network)) {\n throw new BeaconError(ErrorCode.UNSUPPORTED, `Unknown network \"${String(network)}\". Use \"testnet\" or \"mainnet\".`);\n }\n return network;\n}\n\nexport class BeaconAuth {\n private address: string | null = null;\n private network: NetworkId; // replaced by the wallet's active network once it connects\n private events = new Emitter();\n private connection: WalletConnection;\n\n constructor(options: BeaconOptions) {\n if (!options || typeof options.clientId !== \"string\" || !options.clientId) {\n throw new BeaconError(ErrorCode.INVALID_REQUEST, \"BeaconAuth: clientId is required\");\n }\n\n const defaultNetwork = options.defaultNetwork ? checkNetwork(options.defaultNetwork) : undefined;\n const supported = options.supportedNetworks?.map(checkNetwork);\n this.network = defaultNetwork ?? \"testnet\";\n const networks = defaultNetwork || supported ? { default: defaultNetwork, supported } : undefined;\n\n this.connection = new WalletConnection(options.walletUrl ?? DEFAULT_WALLET_URL, options.clientId, networks, options.showWalletUI !== false, {\n onConnected: (address, network) => this.handleConnected(address, network),\n onDisconnected: () => this.handleDisconnected(),\n onNetworkChanged: (network) => this.handleNetworkChanged(network),\n });\n }\n\n /** Opens the wallet and signs the user in with Google. Resolves with the Stellar address (G...). */\n async login(): Promise<{ address: string }> {\n if (this.address) return { address: this.address };\n const result = (await this.connection.request(\"beacon_login\", [], LOGIN_TIMEOUT_MS)) as { address: string };\n return { address: result.address };\n }\n\n async logout(): Promise<void> {\n try {\n await this.connection.request(\"beacon_logout\", [], DEFAULT_TIMEOUT_MS);\n } catch {\n // The wallet is unreachable: still forget the session locally.\n }\n this.handleDisconnected();\n }\n\n /** Switches to another of the app's supportedNetworks. Rejects with code -6 for any other network. */\n async switchNetwork(network: NetworkId): Promise<void> {\n await this.connection.request(\"stellar_switchNetwork\", [checkNetwork(network)], DEFAULT_TIMEOUT_MS);\n }\n\n // ---- sending and signing (the user approves in the wallet) ----\n\n /**\n * Sends XLM in one call. The wallet builds the payment, asks the user to approve it, signs it and\n * submits it. Resolves with the transaction hash. (To create a new account, send at least 1 XLM.)\n */\n async sendPayment(payment: { to: string; amount: string; memo?: string }): Promise<{ hash: string }> {\n return (await this.connection.request(\"stellar_sendPayment\", [payment], SEND_TIMEOUT_MS)) as { hash: string };\n }\n\n // ---- signing (the user always approves inside the wallet) ----\n\n /** Signs a transaction (base64 XDR). Returns the signed XDR; submit it yourself, e.g. through Horizon. */\n async signTransaction(\n xdr: string,\n options: { networkPassphrase?: string; address?: string } = {},\n ): Promise<{ signedTxXdr: string; signerAddress: string }> {\n return (await this.connection.request(\n \"stellar_signTransaction\",\n [xdr, options],\n SIGNING_TIMEOUT_MS,\n )) as { signedTxXdr: string; signerAddress: string };\n }\n\n /** Signs a text message (SEP-53). The signature is base64. */\n async signMessage(\n message: string,\n options: { address?: string } = {},\n ): Promise<{ signedMessage: string; signerAddress: string }> {\n return (await this.connection.request(\"stellar_signMessage\", [message, options], SIGNING_TIMEOUT_MS)) as {\n signedMessage: string;\n signerAddress: string;\n };\n }\n\n /** Signs a Soroban authorization entry preimage (base64 XDR). Returns a base64 signature. */\n async signAuthEntry(\n preimage: string,\n options: { networkPassphrase?: string; address?: string } = {},\n ): Promise<{ signedAuthEntry: string; signerAddress: string }> {\n return (await this.connection.request(\n \"stellar_signAuthEntry\",\n [preimage, options],\n SIGNING_TIMEOUT_MS,\n )) as { signedAuthEntry: string; signerAddress: string };\n }\n\n // ---- state ----\n\n getAddress(): string | null {\n return this.address;\n }\n\n /** The active network (the default one until the wallet reports otherwise). */\n getNetwork(): NetworkInfo {\n return NETWORKS[this.network];\n }\n\n /**\n * The same functions in the standard Stellar wallet shape (SEP-43), for libraries such as\n * Stellar Wallets Kit: getAddress, signTransaction, signMessage, signAuthEntry, getNetwork.\n */\n getWalletInterface(): StellarWalletInterface {\n return createWalletInterface(this);\n }\n\n on<E extends keyof BeaconEventMap>(event: E, callback: BeaconEventMap[E]): () => void {\n return this.events.on(event, callback);\n }\n\n off<E extends keyof BeaconEventMap>(event: E, callback: BeaconEventMap[E]): void {\n this.events.off(event, callback);\n }\n\n /** Removes the wallet iframe and listeners. */\n destroy(): void {\n this.connection.destroy();\n }\n\n // ---- wallet events ----\n\n private handleNetworkChanged(network: NetworkId): void {\n if (network === this.network) return;\n this.network = network;\n this.events.emit(\"networkChanged\", network);\n }\n\n private handleConnected(address: string, network: NetworkId): void {\n const accountChanged = this.address !== address;\n const networkChanged = this.network !== network;\n this.address = address;\n this.network = network;\n\n this.events.emit(\"connect\", { address, network });\n if (networkChanged) this.events.emit(\"networkChanged\", network);\n if (accountChanged) this.events.emit(\"accountChanged\", address);\n }\n\n private handleDisconnected(): void {\n if (!this.address) return;\n this.address = null;\n this.events.emit(\"disconnect\");\n this.events.emit(\"accountChanged\", null);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/shared/networks.ts","../src/shared/messages.ts","../src/errors.ts","../src/connection.ts","../src/emitter.ts","../src/stellar.ts","../src/BeaconAuth.ts"],"names":[],"mappings":";;;AAeO,IAAM,QAAA,GAA2C;AAAA,EACtD,OAAA,EAAS;AAAA,IACP,EAAA,EAAI,SAAA;AAAA,IACJ,IAAA,EAAM,iBAAA;AAAA,IACN,UAAA,EAAY,mCAAA;AAAA,IACZ,UAAA,EAAY,qCAAA;AAAA,IACZ,WAAA,EAAa,yCAAA;AAAA,IACb,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,OAAA,EAAS;AAAA,IACP,EAAA,EAAI,SA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AGA,OAAA,GAAgB;AACd,IAAA,IAAA,CAAK,WAAW,OAAA,EAAQ;AAAA,EAC1B;AAAA;AAAA,EAIQ,qBAAqB,OAAA,EAA0B;AACrD,IAAA,IAAI,OAAA,KAAY,KAAK,OAAA,EAAS;AAC9B,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AACf,IAAA,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,gBAAA,EAAkB,OAAO,CAAA;AAAA,EAC5C;AAAA,EAEQ,eAAA,CAAgB,SAAiB,OAAA,EAA0B;AACjE,IAAA,MAAM,cAAA,GAAiB,KAAK,OAAA,KAAY,OAAA;AACxC,IAAA,MAAM,cAAA,GAAiB,KAAK,OAAA,KAAY,OAAA;AACxC,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AACf,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAEf,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,SAAA,EAAW,EAAE,OAAA,EAAS,SAAS,CAAA;AAChD,IAAA,IAAI,cAAA,EAAgB,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,kBAAkB,OAAO,CAAA;AAC9D,IAAA,IAAI,cAAA,EAAgB,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,kBAAkB,OAAO,CAAA;AAAA,EAChE;AAAA,EAEQ,kBAAA,GAA2B;AACjC,IAAA,IAAI,CAAC,KAAK,OAAA,EAAS;AACnB,IAAA,IAAA,CAAK,OAAA,GAAU,IAAA;AACf,IAAA,IAAA,CAAK,MAAA,CAAO,KAAK,YAAY,CAAA;AAC7B,IAAA,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,gBAAA,EAAkB,IAAI,CAAA;AAAA,EACzC;AACF","file":"index.cjs","sourcesContent":["// Stellar network data with NO imports, so the SDK bundle stays tiny.\n// The wallet keeps its own copy (wallet/src/shared/networks.ts): keep them in sync.\n// Source: https://developers.stellar.org/docs/networks\n\nexport type NetworkId = \"testnet\" | \"mainnet\";\n\nexport type NetworkInfo = {\n id: NetworkId;\n name: string;\n passphrase: string; // identifies the network inside every signed transaction\n horizonUrl: string;\n explorerUrl: string;\n friendbotUrl?: string; // free test funds: testnet only\n};\n\nexport const NETWORKS: Record<NetworkId, NetworkInfo> = {\n testnet: {\n id: \"testnet\",\n name: \"Stellar Testnet\",\n passphrase: \"Test SDF Network ; September 2015\",\n horizonUrl: \"https://horizon-testnet.stellar.org\",\n explorerUrl: \"https://stellar.expert/explorer/testnet\",\n friendbotUrl: \"https://friendbot.stellar.org\",\n },\n mainnet: {\n id: \"mainnet\",\n name: \"Stellar Mainnet\",\n passphrase: \"Public Global Stellar Network ; September 2015\",\n horizonUrl: \"https://horizon.stellar.org\",\n explorerUrl: \"https://stellar.expert/explorer/public\",\n },\n};\n\nexport const isNetworkId = (value: unknown): value is NetworkId => value === \"testnet\" || value === \"mainnet\";\n","// postMessage protocol between the SDK (parent page) and the wallet iframe.\n// Used by both sides. Contains no secrets and no crypto.\n// The wallet keeps its own copy (wallet/src/shared/messages.ts): keep them in sync.\n\nimport { isNetworkId, type NetworkId } from \"./networks\";\n\n// ---- error codes: the ones from SEP-43 (Stellar wallet interface), plus a few of ours ----\nexport const ErrorCode = {\n INTERNAL: -1, // internal wallet error\n EXTERNAL: -2, // an outside service (Horizon, network) failed\n INVALID_REQUEST: -3, // bad parameters, malformed XDR, wrong network\n USER_REJECTED: -4, // the user said no: do not retry\n NOT_CONNECTED: -5, // log in first\n UNSUPPORTED: -6, // method or network not supported\n BUSY: -7, // another request is already waiting for the user\n} as const;\n\nexport type RpcError = { code: number; message: string };\n\n// ---- SDK -> wallet ----\n\n// Must be the FIRST message the SDK sends. The wallet checks event.origin against the app's allowed origins.\n// Optionally carries the networks the app configured in code (defaultNetwork / supportedNetworks).\nexport type BeaconInit = {\n type: \"beacon:init\";\n networks?: { default?: NetworkId; supported?: NetworkId[] };\n // false = sign LOW-RISK requests (messages, plain payments) without a confirmation screen. Default: true.\n showWalletUI?: boolean;\n};\n\nexport type BeaconRequest = {\n type: \"beacon:request\";\n id: string;\n method: string;\n params?: unknown[];\n};\n\n// Methods the wallet handles.\nexport const WALLET_METHODS = [\n \"beacon_login\",\n \"beacon_logout\",\n \"beacon_cancel\", // params: [requestId]. The SDK gave up on a request (timeout): the wallet drops it.\n \"stellar_getAddress\",\n \"stellar_getNetwork\",\n \"stellar_switchNetwork\", // params: [networkId], only between the app's supported networks\n \"stellar_sendPayment\", // params: [{ to, amount, memo? }]. The wallet builds, signs and submits an XLM payment.\n \"stellar_signTransaction\", // params: [xdr, { networkPassphrase?, address? }?]\n \"stellar_signMessage\", // params: [message, { address? }?] (SEP-53)\n \"stellar_signAuthEntry\", // params: [base64 preimage, { networkPassphrase?, address? }?]\n] as const;\n\n// ---- wallet -> SDK ----\n\nexport type BeaconResponse =\n | { type: \"beacon:response\"; id: string; result: unknown }\n | { type: \"beacon:response\"; id: string; error: RpcError };\n\nexport type WalletEvent =\n | { type: \"beacon:ready\" }\n | { type: \"beacon:connected\"; address: string; network: NetworkId }\n | { type: \"beacon:disconnected\" }\n | { type: \"beacon:show\" }\n | { type: \"beacon:hide\" }\n | { type: \"beacon:resize\"; height: number } // content height in px, so the SDK can fit the iframe\n | { type: \"beacon:networkChanged\"; network: NetworkId };\n\nexport type WalletMessage = BeaconResponse | WalletEvent;\n\n// ---- type guards (message data is untrusted) ----\n\nconst isObject = (v: unknown): v is Record<string, unknown> => typeof v === \"object\" && v !== null;\n\nexport function isBeaconInit(data: unknown): data is BeaconInit {\n return isObject(data) && data.type === \"beacon:init\";\n}\n\n// The networks an app asked for in its init message (untrusted input): known ids only.\nexport function readInitNetworks(init: BeaconInit): { default?: NetworkId; supported: NetworkId[] } {\n const raw = init.networks;\n const supported = Array.isArray(raw?.supported) ? raw.supported.filter(isNetworkId).slice(0, 2) : [];\n return { default: isNetworkId(raw?.default) ? raw.default : undefined, supported };\n}\n\n// Did the app turn confirmation screens off? (untrusted input: only an explicit false counts)\nexport function readInitShowWalletUI(init: BeaconInit): boolean {\n return init.showWalletUI !== false;\n}\n\nexport function isBeaconRequest(data: unknown): data is BeaconRequest {\n return (\n isObject(data) &&\n data.type === \"beacon:request\" &&\n typeof data.id === \"string\" &&\n typeof data.method === \"string\" &&\n (data.params === undefined || Array.isArray(data.params))\n );\n}\n\nexport function isWalletMessage(data: unknown): data is WalletMessage {\n if (!isObject(data) || typeof data.type !== \"string\") return false;\n switch (data.type) {\n case \"beacon:ready\":\n case \"beacon:disconnected\":\n case \"beacon:show\":\n case \"beacon:hide\":\n return true;\n case \"beacon:networkChanged\":\n return isNetworkId(data.network);\n case \"beacon:resize\":\n return typeof data.height === \"number\" && Number.isFinite(data.height) && data.height > 0;\n case \"beacon:connected\":\n return typeof data.address === \"string\" && isNetworkId(data.network);\n case \"beacon:response\":\n return (\n typeof data.id === \"string\" &&\n (\"result\" in data ||\n (isObject(data.error) && typeof data.error.code === \"number\" && typeof data.error.message === \"string\"))\n );\n default:\n return false;\n }\n}\n","import { ErrorCode } from \"./shared/messages\";\n\n// Error with a numeric `code` from the Stellar wallet standard (SEP-43): -4 means the user rejected it.\nexport class BeaconError extends Error {\n code: number;\n\n constructor(code: number, message: string) {\n super(message);\n this.name = \"BeaconError\";\n this.code = code;\n }\n}\n\nexport const internalError = (message: string) => new BeaconError(ErrorCode.INTERNAL, message);\n","import {\n isWalletMessage,\n ErrorCode,\n type BeaconInit,\n type BeaconRequest,\n type BeaconResponse,\n} from \"./shared/messages\";\nimport { BeaconError, internalError } from \"./errors\";\nimport type { NetworkId } from \"./shared/networks\";\n\nconst READY_TIMEOUT_MS = 15_000;\n\n// Requests that open the wallet window. If the wallet is still loading, the frame opens at once and\n// the wallet shows its own loading screen (the SDK draws nothing itself).\nconst INTERACTIVE_METHODS = new Set([\n \"beacon_login\",\n \"stellar_sendPayment\",\n \"stellar_signTransaction\",\n \"stellar_signMessage\",\n \"stellar_signAuthEntry\",\n]);\n\ntype Pending = {\n resolve: (value: unknown) => void;\n reject: (error: Error) => void;\n timer: ReturnType<typeof setTimeout>;\n};\n\ntype Handlers = {\n onNetworkChanged: (network: NetworkId) => void;\n onConnected: (address: string, network: NetworkId) => void;\n onDisconnected: () => void;\n};\n\n// Owns the wallet iframe and the postMessage channel to it.\n// Only messages from the wallet's origin AND from this iframe's window are accepted.\nexport class WalletConnection {\n private readonly walletOrigin: string;\n private readonly src: string;\n private overlay: HTMLDivElement | null = null;\n private iframe: HTMLIFrameElement | null = null;\n private openedEarly = false; // the frame was opened before the wallet asked for it (it was still loading)\n private pending = new Map<string, Pending>();\n private isReady = false;\n private readyWaiters: Array<() => void> = [];\n\n constructor(\n walletUrl: string,\n private clientId: string,\n private networks: { default?: NetworkId; supported?: NetworkId[] } | undefined,\n private showWalletUI: boolean,\n private handlers: Handlers,\n ) {\n let url: URL;\n try {\n url = new URL(walletUrl);\n } catch {\n throw new BeaconError(ErrorCode.INTERNAL, `Invalid walletUrl: ${walletUrl}`);\n }\n this.walletOrigin = url.origin;\n url.pathname = \"/\";\n url.search = \"\";\n url.hash = \"\";\n url.searchParams.set(\"client_id\", clientId);\n this.src = url.toString();\n\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"message\", this.onMessage);\n this.mount();\n }\n }\n\n // ---- iframe + modal ----\n\n private mount(): void {\n const attach = () => {\n const overlay = document.createElement(\"div\");\n Object.assign(overlay.style, {\n display: \"none\",\n position: \"fixed\",\n inset: \"0\",\n zIndex: \"2147483647\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\", // no dark backdrop: only a soft shadow around the wallet (on the iframe below)\n });\n\n const iframe = document.createElement(\"iframe\");\n iframe.title = \"Beacon wallet\";\n // clipboard-write: lets the wallet copy the address.\n iframe.allow = \"clipboard-write\";\n iframe.src = this.src;\n Object.assign(iframe.style, {\n width: \"min(380px, calc(100vw - 32px))\",\n height: \"380px\", // the wallet's fixed height (a square: same as the width); the wallet confirms it with beacon:resize\n maxHeight: \"calc(100vh - 32px)\",\n transition: \"height 120ms ease\",\n border: \"0\",\n borderRadius: \"20px\", // the wallet is one white card; the iframe clips it to rounded corners\n boxShadow: \"0 0 0 1px rgba(0,0,0,0.04), 0 8px 40px rgba(0,0,0,0.28), 0 0 90px 24px rgba(0,0,0,0.18)\", // feathered glow\n background: \"#ffffff\",\n overflow: \"hidden\",\n });\n\n // The first message to the wallet. It checks our origin against the app's allowed origins.\n iframe.addEventListener(\"load\", () => {\n const init: BeaconInit = { type: \"beacon:init\", ...(this.networks && { networks: this.networks }),\n ...(!this.showWalletUI && { showWalletUI: false }) };\n iframe.contentWindow?.postMessage(init, this.walletOrigin);\n });\n\n overlay.appendChild(iframe);\n document.body.appendChild(overlay);\n this.overlay = overlay;\n this.iframe = iframe;\n };\n\n if (document.body) attach();\n else document.addEventListener(\"DOMContentLoaded\", attach, { once: true });\n }\n\n private setVisible(visible: boolean): void {\n if (!this.overlay || !this.iframe) return;\n this.openedEarly = false;\n this.overlay.style.display = visible ? \"flex\" : \"none\";\n if (visible) this.iframe.focus();\n }\n\n // The user acted before the wallet finished loading: open the frame now. The wallet's own\n // loading screen is what they see, and it takes over from there.\n private openEarly(): void {\n if (!this.overlay || this.openedEarly || this.overlay.style.display !== \"none\") return;\n this.openedEarly = true;\n this.overlay.style.display = \"flex\";\n }\n\n // Opened early, but the wallet never asked to be shown (or failed): close it again.\n private closeEarly(): void {\n if (!this.openedEarly) return;\n this.openedEarly = false;\n if (this.overlay) this.overlay.style.display = \"none\";\n }\n\n // ---- incoming messages ----\n\n private onMessage = (event: MessageEvent): void => {\n if (event.origin !== this.walletOrigin) return;\n if (!this.iframe || event.source !== this.iframe.contentWindow) return;\n if (!isWalletMessage(event.data)) return;\n\n const message = event.data;\n switch (message.type) {\n case \"beacon:ready\":\n this.isReady = true;\n this.readyWaiters.splice(0).forEach((resolve) => resolve());\n break;\n case \"beacon:show\":\n this.setVisible(true);\n break;\n case \"beacon:hide\":\n this.setVisible(false);\n break;\n case \"beacon:resize\":\n // Fit the modal to the wallet's content (max-height keeps it inside the viewport).\n if (this.iframe) this.iframe.style.height = `${Math.ceil(message.height)}px`;\n break;\n case \"beacon:networkChanged\":\n this.handlers.onNetworkChanged(message.network);\n break;\n case \"beacon:connected\":\n this.handlers.onConnected(message.address, message.network);\n break;\n case \"beacon:disconnected\":\n this.handlers.onDisconnected();\n break;\n case \"beacon:response\":\n this.settle(message);\n break;\n }\n };\n\n private settle(message: BeaconResponse): void {\n const entry = this.pending.get(message.id);\n if (!entry) return; // unknown or already timed out\n this.closeEarly(); // answered without ever showing the wallet (e.g. already connected)\n this.pending.delete(message.id);\n clearTimeout(entry.timer);\n\n if (\"error\" in message) entry.reject(new BeaconError(message.error.code, message.error.message));\n else entry.resolve(message.result);\n }\n\n // ---- outgoing requests ----\n\n private whenReady(): Promise<void> {\n if (this.isReady) return Promise.resolve();\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => {\n this.readyWaiters = this.readyWaiters.filter((w) => w !== onReady);\n this.closeEarly();\n reject(\n internalError(\n `The Beacon wallet did not load. Check that this site (${window.location.origin}) is an allowed origin ` +\n `for Client ID ${this.clientId}, and that the wallet URL (${this.walletOrigin}) is correct.`,\n ),\n );\n }, READY_TIMEOUT_MS);\n const onReady = () => {\n clearTimeout(timer);\n resolve();\n };\n this.readyWaiters.push(onReady);\n });\n }\n\n async request(method: string, params: unknown[], timeoutMs: number): Promise<unknown> {\n if (typeof window === \"undefined\") throw internalError(\"Beacon can only be used in a browser\");\n // Still loading? Open the frame now instead of waiting invisibly.\n if (!this.isReady && INTERACTIVE_METHODS.has(method)) this.openEarly();\n await this.whenReady();\n\n const target = this.iframe?.contentWindow;\n if (!target) throw internalError(\"The Beacon wallet is not available\");\n\n const id = newId();\n return new Promise<unknown>((resolve, reject) => {\n const timer = setTimeout(() => {\n this.pending.delete(id);\n this.cancel(id); // tell the wallet to drop it, so a late approval can't go unnoticed\n reject(internalError(`Wallet request timed out (${method})`));\n }, timeoutMs);\n\n this.pending.set(id, { resolve, reject, timer });\n const request: BeaconRequest = { type: \"beacon:request\", id, method, params };\n target.postMessage(request, this.walletOrigin);\n });\n }\n\n private cancel(requestId: string): void {\n const request: BeaconRequest = { type: \"beacon:request\", id: newId(), method: \"beacon_cancel\", params: [requestId] };\n this.iframe?.contentWindow?.postMessage(request, this.walletOrigin);\n }\n\n destroy(): void {\n if (typeof window === \"undefined\") return;\n window.removeEventListener(\"message\", this.onMessage);\n this.pending.forEach((entry) => {\n clearTimeout(entry.timer);\n entry.reject(internalError(\"Beacon was destroyed\"));\n });\n this.pending.clear();\n this.overlay?.remove();\n this.overlay = this.iframe = null;\n }\n}\n\nfunction newId(): string {\n if (typeof crypto !== \"undefined\" && \"randomUUID\" in crypto) return crypto.randomUUID();\n return `${Date.now()}-${Math.random().toString(36).slice(2)}`;\n}\n","// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Listener = (...args: any[]) => void;\n\nexport class Emitter {\n private listeners = new Map<string, Set<Listener>>();\n\n on(event: string, listener: Listener): () => void {\n let set = this.listeners.get(event);\n if (!set) this.listeners.set(event, (set = new Set()));\n set.add(listener);\n return () => this.off(event, listener);\n }\n\n off(event: string, listener: Listener): void {\n this.listeners.get(event)?.delete(listener);\n }\n\n emit(event: string, ...args: unknown[]): void {\n for (const listener of [...(this.listeners.get(event) ?? [])]) {\n try {\n listener(...args);\n } catch {\n // A faulty listener in the dApp must not break the SDK.\n }\n }\n }\n}\n","import type { BeaconAuth } from \"./BeaconAuth\";\nimport { BeaconError } from \"./errors\";\n\n// The standard Stellar wallet interface (SEP-43), so Beacon can plug into libraries like Stellar\n// Wallets Kit. Each function returns the result, or { error: { code, message } } instead of throwing.\n// Error codes: -1 internal, -2 external service, -3 invalid request, -4 user rejected.\n\ntype WalletError = { error: { code: number; message: string } };\n\nexport interface StellarWalletInterface {\n getAddress(): Promise<{ address: string } | WalletError>;\n getNetwork(): Promise<{ network: string; networkPassphrase: string } | WalletError>;\n signTransaction(\n xdr: string,\n opts?: { networkPassphrase?: string; address?: string },\n ): Promise<{ signedTxXdr: string; signerAddress: string } | WalletError>;\n signMessage(\n message: string,\n opts?: { address?: string },\n ): Promise<{ signedMessage: string; signerAddress: string } | WalletError>;\n signAuthEntry(\n authEntry: string,\n opts?: { networkPassphrase?: string; address?: string },\n ): Promise<{ signedAuthEntry: string; signerAddress: string } | WalletError>;\n}\n\nasync function wrap<T>(run: () => Promise<T>): Promise<T | WalletError> {\n try {\n return await run();\n } catch (error) {\n if (error instanceof BeaconError) return { error: { code: error.code, message: error.message } };\n return { error: { code: -1, message: \"Something went wrong\" } };\n }\n}\n\nexport function createWalletInterface(beacon: BeaconAuth): StellarWalletInterface {\n return {\n // getAddress logs the user in if needed, like Freighter's \"connect\".\n getAddress: () => wrap(() => beacon.login()),\n getNetwork: () =>\n wrap(async () => {\n const { id, passphrase } = beacon.getNetwork();\n return { network: id === \"mainnet\" ? \"PUBLIC\" : \"TESTNET\", networkPassphrase: passphrase };\n }),\n signTransaction: (xdr, opts) => wrap(() => beacon.signTransaction(xdr, opts)),\n signMessage: (message, opts) => wrap(() => beacon.signMessage(message, opts)),\n signAuthEntry: (authEntry, opts) => wrap(() => beacon.signAuthEntry(authEntry, opts)),\n };\n}\n","import { WalletConnection } from \"./connection\";\nimport { Emitter } from \"./emitter\";\nimport { BeaconError } from \"./errors\";\nimport { ErrorCode } from \"./shared/messages\";\nimport { isNetworkId, NETWORKS, type NetworkId, type NetworkInfo } from \"./shared/networks\";\nimport { createWalletInterface, type StellarWalletInterface } from \"./stellar\";\n\nexport type BeaconOptions = {\n /** Public Client ID from the Beacon dashboard (bcn_app_...). */\n clientId: string;\n /** Network used on login. Defaults to the app's network from the dashboard (testnet if none). */\n defaultNetwork?: NetworkId;\n /** Networks the app can switch between with switchNetwork(). Defaults to just the default network. */\n supportedNetworks?: NetworkId[];\n /** Optional. Beacon's wallet is built in, so apps normally never set this (it is for testing a different wallet). */\n walletUrl?: string;\n /**\n * Show the wallet's confirmation screen before signing. Default true.\n * Set false to sign low-risk requests silently (messages and plain XLM payments from the user's own\n * account). Anything risky (contract calls, account changes, other accounts) is always confirmed.\n */\n showWalletUI?: boolean;\n};\n\nexport type BeaconEventMap = {\n connect: (info: { address: string; network: NetworkId }) => void;\n disconnect: () => void;\n accountChanged: (address: string | null) => void;\n networkChanged: (network: NetworkId) => void;\n};\n\n// The wallet apps open by default. Published versions keep calling this address, so it must stay working.\n// (Versions before 0.1.3 used the older wallet.josephakpansunday.workers.dev, which must also stay up.)\nconst DEFAULT_WALLET_URL = \"https://wallet.beaconmcu.space\";\n\n// Waiting for a person: sign-in includes a Google popup, so it gets longer than other calls.\nconst LOGIN_TIMEOUT_MS = 5 * 60_000;\nconst SIGNING_TIMEOUT_MS = 60_000;\nconst SEND_TIMEOUT_MS = 90_000; // approval plus building and submitting on the network\nconst DEFAULT_TIMEOUT_MS = 15_000;\n\nfunction checkNetwork(network: unknown): NetworkId {\n if (!isNetworkId(network)) {\n throw new BeaconError(ErrorCode.UNSUPPORTED, `Unknown network \"${String(network)}\". Use \"testnet\" or \"mainnet\".`);\n }\n return network;\n}\n\nexport class BeaconAuth {\n private address: string | null = null;\n private network: NetworkId; // replaced by the wallet's active network once it connects\n private events = new Emitter();\n private connection: WalletConnection;\n\n constructor(options: BeaconOptions) {\n if (!options || typeof options.clientId !== \"string\" || !options.clientId) {\n throw new BeaconError(ErrorCode.INVALID_REQUEST, \"BeaconAuth: clientId is required\");\n }\n\n const defaultNetwork = options.defaultNetwork ? checkNetwork(options.defaultNetwork) : undefined;\n const supported = options.supportedNetworks?.map(checkNetwork);\n this.network = defaultNetwork ?? \"testnet\";\n const networks = defaultNetwork || supported ? { default: defaultNetwork, supported } : undefined;\n\n this.connection = new WalletConnection(options.walletUrl ?? DEFAULT_WALLET_URL, options.clientId, networks, options.showWalletUI !== false, {\n onConnected: (address, network) => this.handleConnected(address, network),\n onDisconnected: () => this.handleDisconnected(),\n onNetworkChanged: (network) => this.handleNetworkChanged(network),\n });\n }\n\n /** Opens the wallet and signs the user in with Google. Resolves with the Stellar address (G...). */\n async login(): Promise<{ address: string }> {\n if (this.address) return { address: this.address };\n const result = (await this.connection.request(\"beacon_login\", [], LOGIN_TIMEOUT_MS)) as { address: string };\n return { address: result.address };\n }\n\n async logout(): Promise<void> {\n try {\n await this.connection.request(\"beacon_logout\", [], DEFAULT_TIMEOUT_MS);\n } catch {\n // The wallet is unreachable: still forget the session locally.\n }\n this.handleDisconnected();\n }\n\n /** Switches to another of the app's supportedNetworks. Rejects with code -6 for any other network. */\n async switchNetwork(network: NetworkId): Promise<void> {\n await this.connection.request(\"stellar_switchNetwork\", [checkNetwork(network)], DEFAULT_TIMEOUT_MS);\n }\n\n // ---- sending and signing (the user approves in the wallet) ----\n\n /**\n * Sends XLM in one call. The wallet builds the payment, asks the user to approve it, signs it and\n * submits it. Resolves with the transaction hash. (To create a new account, send at least 1 XLM.)\n */\n async sendPayment(payment: { to: string; amount: string; memo?: string }): Promise<{ hash: string }> {\n return (await this.connection.request(\"stellar_sendPayment\", [payment], SEND_TIMEOUT_MS)) as { hash: string };\n }\n\n // ---- signing (the user always approves inside the wallet) ----\n\n /** Signs a transaction (base64 XDR). Returns the signed XDR; submit it yourself, e.g. through Horizon. */\n async signTransaction(\n xdr: string,\n options: { networkPassphrase?: string; address?: string } = {},\n ): Promise<{ signedTxXdr: string; signerAddress: string }> {\n return (await this.connection.request(\n \"stellar_signTransaction\",\n [xdr, options],\n SIGNING_TIMEOUT_MS,\n )) as { signedTxXdr: string; signerAddress: string };\n }\n\n /** Signs a text message (SEP-53). The signature is base64. */\n async signMessage(\n message: string,\n options: { address?: string } = {},\n ): Promise<{ signedMessage: string; signerAddress: string }> {\n return (await this.connection.request(\"stellar_signMessage\", [message, options], SIGNING_TIMEOUT_MS)) as {\n signedMessage: string;\n signerAddress: string;\n };\n }\n\n /** Signs a Soroban authorization entry preimage (base64 XDR). Returns a base64 signature. */\n async signAuthEntry(\n preimage: string,\n options: { networkPassphrase?: string; address?: string } = {},\n ): Promise<{ signedAuthEntry: string; signerAddress: string }> {\n return (await this.connection.request(\n \"stellar_signAuthEntry\",\n [preimage, options],\n SIGNING_TIMEOUT_MS,\n )) as { signedAuthEntry: string; signerAddress: string };\n }\n\n // ---- state ----\n\n getAddress(): string | null {\n return this.address;\n }\n\n /** The active network (the default one until the wallet reports otherwise). */\n getNetwork(): NetworkInfo {\n return NETWORKS[this.network];\n }\n\n /**\n * The same functions in the standard Stellar wallet shape (SEP-43), for libraries such as\n * Stellar Wallets Kit: getAddress, signTransaction, signMessage, signAuthEntry, getNetwork.\n */\n getWalletInterface(): StellarWalletInterface {\n return createWalletInterface(this);\n }\n\n on<E extends keyof BeaconEventMap>(event: E, callback: BeaconEventMap[E]): () => void {\n return this.events.on(event, callback);\n }\n\n off<E extends keyof BeaconEventMap>(event: E, callback: BeaconEventMap[E]): void {\n this.events.off(event, callback);\n }\n\n /** Removes the wallet iframe and listeners. */\n destroy(): void {\n this.connection.destroy();\n }\n\n // ---- wallet events ----\n\n private handleNetworkChanged(network: NetworkId): void {\n if (network === this.network) return;\n this.network = network;\n this.events.emit(\"networkChanged\", network);\n }\n\n private handleConnected(address: string, network: NetworkId): void {\n const accountChanged = this.address !== address;\n const networkChanged = this.network !== network;\n this.address = address;\n this.network = network;\n\n this.events.emit(\"connect\", { address, network });\n if (networkChanged) this.events.emit(\"networkChanged\", network);\n if (accountChanged) this.events.emit(\"accountChanged\", address);\n }\n\n private handleDisconnected(): void {\n if (!this.address) return;\n this.address = null;\n this.events.emit(\"disconnect\");\n this.events.emit(\"accountChanged\", null);\n }\n}\n"]}
package/dist/index.js CHANGED
@@ -141,7 +141,8 @@ var WalletConnection = class {
141
141
  zIndex: "2147483647",
142
142
  alignItems: "center",
143
143
  justifyContent: "center",
144
- background: "rgba(0, 0, 0, 0.6)"
144
+ background: "transparent"
145
+ // no dark backdrop: only a soft shadow around the wallet (on the iframe below)
145
146
  });
146
147
  const iframe = document.createElement("iframe");
147
148
  iframe.title = "Beacon wallet";
@@ -149,13 +150,15 @@ var WalletConnection = class {
149
150
  iframe.src = this.src;
150
151
  Object.assign(iframe.style, {
151
152
  width: "min(380px, calc(100vw - 32px))",
152
- height: "520px",
153
- // the wallet's fixed height; the wallet confirms it with beacon:resize
153
+ height: "380px",
154
+ // the wallet's fixed height (a square: same as the width); the wallet confirms it with beacon:resize
154
155
  maxHeight: "calc(100vh - 32px)",
155
156
  transition: "height 120ms ease",
156
157
  border: "0",
157
158
  borderRadius: "20px",
158
159
  // the wallet is one white card; the iframe clips it to rounded corners
160
+ boxShadow: "0 0 0 1px rgba(0,0,0,0.04), 0 8px 40px rgba(0,0,0,0.28), 0 0 90px 24px rgba(0,0,0,0.18)",
161
+ // feathered glow
159
162
  background: "#ffffff",
160
163
  overflow: "hidden"
161
164
  });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/shared/networks.ts","../src/shared/messages.ts","../src/errors.ts","../src/connection.ts","../src/emitter.ts","../src/stellar.ts","../src/BeaconAuth.ts"],"names":[],"mappings":";AAeO,IAAM,QAAA,GAA2C;AAAA,EACtD,OAAA,EAAS;AAAA,IACP,EAAA,EAAI,SAAA;AAAA,IACJ,IAAA,EAAM,iBAAA;AAAA,IACN,UAAA,EAAY,mCAAA;AAAA,IACZ,UAAA,EAAY,qCAAA;AAAA,IACZ,WAAA,EAAa,yCAAA;AAAA,IACb,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,OAAA,EAAS;AAAA,IACP,EAAA,EAAI,SAAA;AAAA,IACJ,IAAA,EAAM,iBAAA;AAAA,IACN,UAAA,EAAY,gDAAA;AAAA,IACZ,UAAA,EAAY,6BAAA;AAAA,IACZ,WAAA,EAAa;AAAA;AAEjB;AAEO,IAAM,WAAA,GAAc,CAAC,KAAA,KAAuC,KAAA,KAAU,aAAa,KAAA,KAAU,SAAA;;;AC1B7F,IAAM,SAAA,GAAY;AAAA,EACvB,QAAA,EAAU,EAAA;AAAA,EACA;AAAA,EACV,eAAA,EAAiB,EAAA;AAAA,EAEF;AAAA,EACf,WA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AA,KAAY,OAAA;AACxC,IAAA,MAAM,cAAA,GAAiB,KAAK,OAAA,KAAY,OAAA;AACxC,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AACf,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAEf,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,SAAA,EAAW,EAAE,OAAA,EAAS,SAAS,CAAA;AAChD,IAAA,IAAI,cAAA,EAAgB,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,kBAAkB,OAAO,CAAA;AAC9D,IAAA,IAAI,cAAA,EAAgB,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,kBAAkB,OAAO,CAAA;AAAA,EAChE;AAAA,EAEQ,kBAAA,GAA2B;AACjC,IAAA,IAAI,CAAC,KAAK,OAAA,EAAS;AACnB,IAAA,IAAA,CAAK,OAAA,GAAU,IAAA;AACf,IAAA,IAAA,CAAK,MAAA,CAAO,KAAK,YAAY,CAAA;AAC7B,IAAA,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,gBAAA,EAAkB,IAAI,CAAA;AAAA,EACzC;AACF","file":"index.js","sourcesContent":["// Stellar network data with NO imports, so the SDK bundle stays tiny.\n// The wallet keeps its own copy (wallet/src/shared/networks.ts): keep them in sync.\n// Source: https://developers.stellar.org/docs/networks\n\nexport type NetworkId = \"testnet\" | \"mainnet\";\n\nexport type NetworkInfo = {\n id: NetworkId;\n name: string;\n passphrase: string; // identifies the network inside every signed transaction\n horizonUrl: string;\n explorerUrl: string;\n friendbotUrl?: string; // free test funds: testnet only\n};\n\nexport const NETWORKS: Record<NetworkId, NetworkInfo> = {\n testnet: {\n id: \"testnet\",\n name: \"Stellar Testnet\",\n passphrase: \"Test SDF Network ; September 2015\",\n horizonUrl: \"https://horizon-testnet.stellar.org\",\n explorerUrl: \"https://stellar.expert/explorer/testnet\",\n friendbotUrl: \"https://friendbot.stellar.org\",\n },\n mainnet: {\n id: \"mainnet\",\n name: \"Stellar Mainnet\",\n passphrase: \"Public Global Stellar Network ; September 2015\",\n horizonUrl: \"https://horizon.stellar.org\",\n explorerUrl: \"https://stellar.expert/explorer/public\",\n },\n};\n\nexport const isNetworkId = (value: unknown): value is NetworkId => value === \"testnet\" || value === \"mainnet\";\n","// postMessage protocol between the SDK (parent page) and the wallet iframe.\n// Used by both sides. Contains no secrets and no crypto.\n// The wallet keeps its own copy (wallet/src/shared/messages.ts): keep them in sync.\n\nimport { isNetworkId, type NetworkId } from \"./networks\";\n\n// ---- error codes: the ones from SEP-43 (Stellar wallet interface), plus a few of ours ----\nexport const ErrorCode = {\n INTERNAL: -1, // internal wallet error\n EXTERNAL: -2, // an outside service (Horizon, network) failed\n INVALID_REQUEST: -3, // bad parameters, malformed XDR, wrong network\n USER_REJECTED: -4, // the user said no: do not retry\n NOT_CONNECTED: -5, // log in first\n UNSUPPORTED: -6, // method or network not supported\n BUSY: -7, // another request is already waiting for the user\n} as const;\n\nexport type RpcError = { code: number; message: string };\n\n// ---- SDK -> wallet ----\n\n// Must be the FIRST message the SDK sends. The wallet checks event.origin against the app's allowed origins.\n// Optionally carries the networks the app configured in code (defaultNetwork / supportedNetworks).\nexport type BeaconInit = {\n type: \"beacon:init\";\n networks?: { default?: NetworkId; supported?: NetworkId[] };\n // false = sign LOW-RISK requests (messages, plain payments) without a confirmation screen. Default: true.\n showWalletUI?: boolean;\n};\n\nexport type BeaconRequest = {\n type: \"beacon:request\";\n id: string;\n method: string;\n params?: unknown[];\n};\n\n// Methods the wallet handles.\nexport const WALLET_METHODS = [\n \"beacon_login\",\n \"beacon_logout\",\n \"beacon_cancel\", // params: [requestId]. The SDK gave up on a request (timeout): the wallet drops it.\n \"stellar_getAddress\",\n \"stellar_getNetwork\",\n \"stellar_switchNetwork\", // params: [networkId], only between the app's supported networks\n \"stellar_sendPayment\", // params: [{ to, amount, memo? }]. The wallet builds, signs and submits an XLM payment.\n \"stellar_signTransaction\", // params: [xdr, { networkPassphrase?, address? }?]\n \"stellar_signMessage\", // params: [message, { address? }?] (SEP-53)\n \"stellar_signAuthEntry\", // params: [base64 preimage, { networkPassphrase?, address? }?]\n] as const;\n\n// ---- wallet -> SDK ----\n\nexport type BeaconResponse =\n | { type: \"beacon:response\"; id: string; result: unknown }\n | { type: \"beacon:response\"; id: string; error: RpcError };\n\nexport type WalletEvent =\n | { type: \"beacon:ready\" }\n | { type: \"beacon:connected\"; address: string; network: NetworkId }\n | { type: \"beacon:disconnected\" }\n | { type: \"beacon:show\" }\n | { type: \"beacon:hide\" }\n | { type: \"beacon:resize\"; height: number } // content height in px, so the SDK can fit the iframe\n | { type: \"beacon:networkChanged\"; network: NetworkId };\n\nexport type WalletMessage = BeaconResponse | WalletEvent;\n\n// ---- type guards (message data is untrusted) ----\n\nconst isObject = (v: unknown): v is Record<string, unknown> => typeof v === \"object\" && v !== null;\n\nexport function isBeaconInit(data: unknown): data is BeaconInit {\n return isObject(data) && data.type === \"beacon:init\";\n}\n\n// The networks an app asked for in its init message (untrusted input): known ids only.\nexport function readInitNetworks(init: BeaconInit): { default?: NetworkId; supported: NetworkId[] } {\n const raw = init.networks;\n const supported = Array.isArray(raw?.supported) ? raw.supported.filter(isNetworkId).slice(0, 2) : [];\n return { default: isNetworkId(raw?.default) ? raw.default : undefined, supported };\n}\n\n// Did the app turn confirmation screens off? (untrusted input: only an explicit false counts)\nexport function readInitShowWalletUI(init: BeaconInit): boolean {\n return init.showWalletUI !== false;\n}\n\nexport function isBeaconRequest(data: unknown): data is BeaconRequest {\n return (\n isObject(data) &&\n data.type === \"beacon:request\" &&\n typeof data.id === \"string\" &&\n typeof data.method === \"string\" &&\n (data.params === undefined || Array.isArray(data.params))\n );\n}\n\nexport function isWalletMessage(data: unknown): data is WalletMessage {\n if (!isObject(data) || typeof data.type !== \"string\") return false;\n switch (data.type) {\n case \"beacon:ready\":\n case \"beacon:disconnected\":\n case \"beacon:show\":\n case \"beacon:hide\":\n return true;\n case \"beacon:networkChanged\":\n return isNetworkId(data.network);\n case \"beacon:resize\":\n return typeof data.height === \"number\" && Number.isFinite(data.height) && data.height > 0;\n case \"beacon:connected\":\n return typeof data.address === \"string\" && isNetworkId(data.network);\n case \"beacon:response\":\n return (\n typeof data.id === \"string\" &&\n (\"result\" in data ||\n (isObject(data.error) && typeof data.error.code === \"number\" && typeof data.error.message === \"string\"))\n );\n default:\n return false;\n }\n}\n","import { ErrorCode } from \"./shared/messages\";\n\n// Error with a numeric `code` from the Stellar wallet standard (SEP-43): -4 means the user rejected it.\nexport class BeaconError extends Error {\n code: number;\n\n constructor(code: number, message: string) {\n super(message);\n this.name = \"BeaconError\";\n this.code = code;\n }\n}\n\nexport const internalError = (message: string) => new BeaconError(ErrorCode.INTERNAL, message);\n","import {\n isWalletMessage,\n ErrorCode,\n type BeaconInit,\n type BeaconRequest,\n type BeaconResponse,\n} from \"./shared/messages\";\nimport { BeaconError, internalError } from \"./errors\";\nimport type { NetworkId } from \"./shared/networks\";\n\nconst READY_TIMEOUT_MS = 15_000;\n\n// Requests that open the wallet window. If the wallet is still loading, the frame opens at once and\n// the wallet shows its own loading screen (the SDK draws nothing itself).\nconst INTERACTIVE_METHODS = new Set([\n \"beacon_login\",\n \"stellar_sendPayment\",\n \"stellar_signTransaction\",\n \"stellar_signMessage\",\n \"stellar_signAuthEntry\",\n]);\n\ntype Pending = {\n resolve: (value: unknown) => void;\n reject: (error: Error) => void;\n timer: ReturnType<typeof setTimeout>;\n};\n\ntype Handlers = {\n onNetworkChanged: (network: NetworkId) => void;\n onConnected: (address: string, network: NetworkId) => void;\n onDisconnected: () => void;\n};\n\n// Owns the wallet iframe and the postMessage channel to it.\n// Only messages from the wallet's origin AND from this iframe's window are accepted.\nexport class WalletConnection {\n private readonly walletOrigin: string;\n private readonly src: string;\n private overlay: HTMLDivElement | null = null;\n private iframe: HTMLIFrameElement | null = null;\n private openedEarly = false; // the frame was opened before the wallet asked for it (it was still loading)\n private pending = new Map<string, Pending>();\n private isReady = false;\n private readyWaiters: Array<() => void> = [];\n\n constructor(\n walletUrl: string,\n private clientId: string,\n private networks: { default?: NetworkId; supported?: NetworkId[] } | undefined,\n private showWalletUI: boolean,\n private handlers: Handlers,\n ) {\n let url: URL;\n try {\n url = new URL(walletUrl);\n } catch {\n throw new BeaconError(ErrorCode.INTERNAL, `Invalid walletUrl: ${walletUrl}`);\n }\n this.walletOrigin = url.origin;\n url.pathname = \"/\";\n url.search = \"\";\n url.hash = \"\";\n url.searchParams.set(\"client_id\", clientId);\n this.src = url.toString();\n\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"message\", this.onMessage);\n this.mount();\n }\n }\n\n // ---- iframe + modal ----\n\n private mount(): void {\n const attach = () => {\n const overlay = document.createElement(\"div\");\n Object.assign(overlay.style, {\n display: \"none\",\n position: \"fixed\",\n inset: \"0\",\n zIndex: \"2147483647\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"rgba(0, 0, 0, 0.6)\",\n });\n\n const iframe = document.createElement(\"iframe\");\n iframe.title = \"Beacon wallet\";\n // clipboard-write: lets the wallet copy the address.\n iframe.allow = \"clipboard-write\";\n iframe.src = this.src;\n Object.assign(iframe.style, {\n width: \"min(380px, calc(100vw - 32px))\",\n height: \"520px\", // the wallet's fixed height; the wallet confirms it with beacon:resize\n maxHeight: \"calc(100vh - 32px)\",\n transition: \"height 120ms ease\",\n border: \"0\",\n borderRadius: \"20px\", // the wallet is one white card; the iframe clips it to rounded corners\n background: \"#ffffff\",\n overflow: \"hidden\",\n });\n\n // The first message to the wallet. It checks our origin against the app's allowed origins.\n iframe.addEventListener(\"load\", () => {\n const init: BeaconInit = { type: \"beacon:init\", ...(this.networks && { networks: this.networks }),\n ...(!this.showWalletUI && { showWalletUI: false }) };\n iframe.contentWindow?.postMessage(init, this.walletOrigin);\n });\n\n overlay.appendChild(iframe);\n document.body.appendChild(overlay);\n this.overlay = overlay;\n this.iframe = iframe;\n };\n\n if (document.body) attach();\n else document.addEventListener(\"DOMContentLoaded\", attach, { once: true });\n }\n\n private setVisible(visible: boolean): void {\n if (!this.overlay || !this.iframe) return;\n this.openedEarly = false;\n this.overlay.style.display = visible ? \"flex\" : \"none\";\n if (visible) this.iframe.focus();\n }\n\n // The user acted before the wallet finished loading: open the frame now. The wallet's own\n // loading screen is what they see, and it takes over from there.\n private openEarly(): void {\n if (!this.overlay || this.openedEarly || this.overlay.style.display !== \"none\") return;\n this.openedEarly = true;\n this.overlay.style.display = \"flex\";\n }\n\n // Opened early, but the wallet never asked to be shown (or failed): close it again.\n private closeEarly(): void {\n if (!this.openedEarly) return;\n this.openedEarly = false;\n if (this.overlay) this.overlay.style.display = \"none\";\n }\n\n // ---- incoming messages ----\n\n private onMessage = (event: MessageEvent): void => {\n if (event.origin !== this.walletOrigin) return;\n if (!this.iframe || event.source !== this.iframe.contentWindow) return;\n if (!isWalletMessage(event.data)) return;\n\n const message = event.data;\n switch (message.type) {\n case \"beacon:ready\":\n this.isReady = true;\n this.readyWaiters.splice(0).forEach((resolve) => resolve());\n break;\n case \"beacon:show\":\n this.setVisible(true);\n break;\n case \"beacon:hide\":\n this.setVisible(false);\n break;\n case \"beacon:resize\":\n // Fit the modal to the wallet's content (max-height keeps it inside the viewport).\n if (this.iframe) this.iframe.style.height = `${Math.ceil(message.height)}px`;\n break;\n case \"beacon:networkChanged\":\n this.handlers.onNetworkChanged(message.network);\n break;\n case \"beacon:connected\":\n this.handlers.onConnected(message.address, message.network);\n break;\n case \"beacon:disconnected\":\n this.handlers.onDisconnected();\n break;\n case \"beacon:response\":\n this.settle(message);\n break;\n }\n };\n\n private settle(message: BeaconResponse): void {\n const entry = this.pending.get(message.id);\n if (!entry) return; // unknown or already timed out\n this.closeEarly(); // answered without ever showing the wallet (e.g. already connected)\n this.pending.delete(message.id);\n clearTimeout(entry.timer);\n\n if (\"error\" in message) entry.reject(new BeaconError(message.error.code, message.error.message));\n else entry.resolve(message.result);\n }\n\n // ---- outgoing requests ----\n\n private whenReady(): Promise<void> {\n if (this.isReady) return Promise.resolve();\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => {\n this.readyWaiters = this.readyWaiters.filter((w) => w !== onReady);\n this.closeEarly();\n reject(\n internalError(\n `The Beacon wallet did not load. Check that this site (${window.location.origin}) is an allowed origin ` +\n `for Client ID ${this.clientId}, and that the wallet URL (${this.walletOrigin}) is correct.`,\n ),\n );\n }, READY_TIMEOUT_MS);\n const onReady = () => {\n clearTimeout(timer);\n resolve();\n };\n this.readyWaiters.push(onReady);\n });\n }\n\n async request(method: string, params: unknown[], timeoutMs: number): Promise<unknown> {\n if (typeof window === \"undefined\") throw internalError(\"Beacon can only be used in a browser\");\n // Still loading? Open the frame now instead of waiting invisibly.\n if (!this.isReady && INTERACTIVE_METHODS.has(method)) this.openEarly();\n await this.whenReady();\n\n const target = this.iframe?.contentWindow;\n if (!target) throw internalError(\"The Beacon wallet is not available\");\n\n const id = newId();\n return new Promise<unknown>((resolve, reject) => {\n const timer = setTimeout(() => {\n this.pending.delete(id);\n this.cancel(id); // tell the wallet to drop it, so a late approval can't go unnoticed\n reject(internalError(`Wallet request timed out (${method})`));\n }, timeoutMs);\n\n this.pending.set(id, { resolve, reject, timer });\n const request: BeaconRequest = { type: \"beacon:request\", id, method, params };\n target.postMessage(request, this.walletOrigin);\n });\n }\n\n private cancel(requestId: string): void {\n const request: BeaconRequest = { type: \"beacon:request\", id: newId(), method: \"beacon_cancel\", params: [requestId] };\n this.iframe?.contentWindow?.postMessage(request, this.walletOrigin);\n }\n\n destroy(): void {\n if (typeof window === \"undefined\") return;\n window.removeEventListener(\"message\", this.onMessage);\n this.pending.forEach((entry) => {\n clearTimeout(entry.timer);\n entry.reject(internalError(\"Beacon was destroyed\"));\n });\n this.pending.clear();\n this.overlay?.remove();\n this.overlay = this.iframe = null;\n }\n}\n\nfunction newId(): string {\n if (typeof crypto !== \"undefined\" && \"randomUUID\" in crypto) return crypto.randomUUID();\n return `${Date.now()}-${Math.random().toString(36).slice(2)}`;\n}\n","// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Listener = (...args: any[]) => void;\n\nexport class Emitter {\n private listeners = new Map<string, Set<Listener>>();\n\n on(event: string, listener: Listener): () => void {\n let set = this.listeners.get(event);\n if (!set) this.listeners.set(event, (set = new Set()));\n set.add(listener);\n return () => this.off(event, listener);\n }\n\n off(event: string, listener: Listener): void {\n this.listeners.get(event)?.delete(listener);\n }\n\n emit(event: string, ...args: unknown[]): void {\n for (const listener of [...(this.listeners.get(event) ?? [])]) {\n try {\n listener(...args);\n } catch {\n // A faulty listener in the dApp must not break the SDK.\n }\n }\n }\n}\n","import type { BeaconAuth } from \"./BeaconAuth\";\nimport { BeaconError } from \"./errors\";\n\n// The standard Stellar wallet interface (SEP-43), so Beacon can plug into libraries like Stellar\n// Wallets Kit. Each function returns the result, or { error: { code, message } } instead of throwing.\n// Error codes: -1 internal, -2 external service, -3 invalid request, -4 user rejected.\n\ntype WalletError = { error: { code: number; message: string } };\n\nexport interface StellarWalletInterface {\n getAddress(): Promise<{ address: string } | WalletError>;\n getNetwork(): Promise<{ network: string; networkPassphrase: string } | WalletError>;\n signTransaction(\n xdr: string,\n opts?: { networkPassphrase?: string; address?: string },\n ): Promise<{ signedTxXdr: string; signerAddress: string } | WalletError>;\n signMessage(\n message: string,\n opts?: { address?: string },\n ): Promise<{ signedMessage: string; signerAddress: string } | WalletError>;\n signAuthEntry(\n authEntry: string,\n opts?: { networkPassphrase?: string; address?: string },\n ): Promise<{ signedAuthEntry: string; signerAddress: string } | WalletError>;\n}\n\nasync function wrap<T>(run: () => Promise<T>): Promise<T | WalletError> {\n try {\n return await run();\n } catch (error) {\n if (error instanceof BeaconError) return { error: { code: error.code, message: error.message } };\n return { error: { code: -1, message: \"Something went wrong\" } };\n }\n}\n\nexport function createWalletInterface(beacon: BeaconAuth): StellarWalletInterface {\n return {\n // getAddress logs the user in if needed, like Freighter's \"connect\".\n getAddress: () => wrap(() => beacon.login()),\n getNetwork: () =>\n wrap(async () => {\n const { id, passphrase } = beacon.getNetwork();\n return { network: id === \"mainnet\" ? \"PUBLIC\" : \"TESTNET\", networkPassphrase: passphrase };\n }),\n signTransaction: (xdr, opts) => wrap(() => beacon.signTransaction(xdr, opts)),\n signMessage: (message, opts) => wrap(() => beacon.signMessage(message, opts)),\n signAuthEntry: (authEntry, opts) => wrap(() => beacon.signAuthEntry(authEntry, opts)),\n };\n}\n","import { WalletConnection } from \"./connection\";\nimport { Emitter } from \"./emitter\";\nimport { BeaconError } from \"./errors\";\nimport { ErrorCode } from \"./shared/messages\";\nimport { isNetworkId, NETWORKS, type NetworkId, type NetworkInfo } from \"./shared/networks\";\nimport { createWalletInterface, type StellarWalletInterface } from \"./stellar\";\n\nexport type BeaconOptions = {\n /** Public Client ID from the Beacon dashboard (bcn_app_...). */\n clientId: string;\n /** Network used on login. Defaults to the app's network from the dashboard (testnet if none). */\n defaultNetwork?: NetworkId;\n /** Networks the app can switch between with switchNetwork(). Defaults to just the default network. */\n supportedNetworks?: NetworkId[];\n /** Optional. Beacon's wallet is built in, so apps normally never set this (it is for testing a different wallet). */\n walletUrl?: string;\n /**\n * Show the wallet's confirmation screen before signing. Default true.\n * Set false to sign low-risk requests silently (messages and plain XLM payments from the user's own\n * account). Anything risky (contract calls, account changes, other accounts) is always confirmed.\n */\n showWalletUI?: boolean;\n};\n\nexport type BeaconEventMap = {\n connect: (info: { address: string; network: NetworkId }) => void;\n disconnect: () => void;\n accountChanged: (address: string | null) => void;\n networkChanged: (network: NetworkId) => void;\n};\n\n// The wallet apps open by default. Published versions keep calling this address, so it must stay working.\n// (Versions before 0.1.3 used the older wallet.josephakpansunday.workers.dev, which must also stay up.)\nconst DEFAULT_WALLET_URL = \"https://wallet.beaconmcu.space\";\n\n// Waiting for a person: sign-in includes a Google popup, so it gets longer than other calls.\nconst LOGIN_TIMEOUT_MS = 5 * 60_000;\nconst SIGNING_TIMEOUT_MS = 60_000;\nconst SEND_TIMEOUT_MS = 90_000; // approval plus building and submitting on the network\nconst DEFAULT_TIMEOUT_MS = 15_000;\n\nfunction checkNetwork(network: unknown): NetworkId {\n if (!isNetworkId(network)) {\n throw new BeaconError(ErrorCode.UNSUPPORTED, `Unknown network \"${String(network)}\". Use \"testnet\" or \"mainnet\".`);\n }\n return network;\n}\n\nexport class BeaconAuth {\n private address: string | null = null;\n private network: NetworkId; // replaced by the wallet's active network once it connects\n private events = new Emitter();\n private connection: WalletConnection;\n\n constructor(options: BeaconOptions) {\n if (!options || typeof options.clientId !== \"string\" || !options.clientId) {\n throw new BeaconError(ErrorCode.INVALID_REQUEST, \"BeaconAuth: clientId is required\");\n }\n\n const defaultNetwork = options.defaultNetwork ? checkNetwork(options.defaultNetwork) : undefined;\n const supported = options.supportedNetworks?.map(checkNetwork);\n this.network = defaultNetwork ?? \"testnet\";\n const networks = defaultNetwork || supported ? { default: defaultNetwork, supported } : undefined;\n\n this.connection = new WalletConnection(options.walletUrl ?? DEFAULT_WALLET_URL, options.clientId, networks, options.showWalletUI !== false, {\n onConnected: (address, network) => this.handleConnected(address, network),\n onDisconnected: () => this.handleDisconnected(),\n onNetworkChanged: (network) => this.handleNetworkChanged(network),\n });\n }\n\n /** Opens the wallet and signs the user in with Google. Resolves with the Stellar address (G...). */\n async login(): Promise<{ address: string }> {\n if (this.address) return { address: this.address };\n const result = (await this.connection.request(\"beacon_login\", [], LOGIN_TIMEOUT_MS)) as { address: string };\n return { address: result.address };\n }\n\n async logout(): Promise<void> {\n try {\n await this.connection.request(\"beacon_logout\", [], DEFAULT_TIMEOUT_MS);\n } catch {\n // The wallet is unreachable: still forget the session locally.\n }\n this.handleDisconnected();\n }\n\n /** Switches to another of the app's supportedNetworks. Rejects with code -6 for any other network. */\n async switchNetwork(network: NetworkId): Promise<void> {\n await this.connection.request(\"stellar_switchNetwork\", [checkNetwork(network)], DEFAULT_TIMEOUT_MS);\n }\n\n // ---- sending and signing (the user approves in the wallet) ----\n\n /**\n * Sends XLM in one call. The wallet builds the payment, asks the user to approve it, signs it and\n * submits it. Resolves with the transaction hash. (To create a new account, send at least 1 XLM.)\n */\n async sendPayment(payment: { to: string; amount: string; memo?: string }): Promise<{ hash: string }> {\n return (await this.connection.request(\"stellar_sendPayment\", [payment], SEND_TIMEOUT_MS)) as { hash: string };\n }\n\n // ---- signing (the user always approves inside the wallet) ----\n\n /** Signs a transaction (base64 XDR). Returns the signed XDR; submit it yourself, e.g. through Horizon. */\n async signTransaction(\n xdr: string,\n options: { networkPassphrase?: string; address?: string } = {},\n ): Promise<{ signedTxXdr: string; signerAddress: string }> {\n return (await this.connection.request(\n \"stellar_signTransaction\",\n [xdr, options],\n SIGNING_TIMEOUT_MS,\n )) as { signedTxXdr: string; signerAddress: string };\n }\n\n /** Signs a text message (SEP-53). The signature is base64. */\n async signMessage(\n message: string,\n options: { address?: string } = {},\n ): Promise<{ signedMessage: string; signerAddress: string }> {\n return (await this.connection.request(\"stellar_signMessage\", [message, options], SIGNING_TIMEOUT_MS)) as {\n signedMessage: string;\n signerAddress: string;\n };\n }\n\n /** Signs a Soroban authorization entry preimage (base64 XDR). Returns a base64 signature. */\n async signAuthEntry(\n preimage: string,\n options: { networkPassphrase?: string; address?: string } = {},\n ): Promise<{ signedAuthEntry: string; signerAddress: string }> {\n return (await this.connection.request(\n \"stellar_signAuthEntry\",\n [preimage, options],\n SIGNING_TIMEOUT_MS,\n )) as { signedAuthEntry: string; signerAddress: string };\n }\n\n // ---- state ----\n\n getAddress(): string | null {\n return this.address;\n }\n\n /** The active network (the default one until the wallet reports otherwise). */\n getNetwork(): NetworkInfo {\n return NETWORKS[this.network];\n }\n\n /**\n * The same functions in the standard Stellar wallet shape (SEP-43), for libraries such as\n * Stellar Wallets Kit: getAddress, signTransaction, signMessage, signAuthEntry, getNetwork.\n */\n getWalletInterface(): StellarWalletInterface {\n return createWalletInterface(this);\n }\n\n on<E extends keyof BeaconEventMap>(event: E, callback: BeaconEventMap[E]): () => void {\n return this.events.on(event, callback);\n }\n\n off<E extends keyof BeaconEventMap>(event: E, callback: BeaconEventMap[E]): void {\n this.events.off(event, callback);\n }\n\n /** Removes the wallet iframe and listeners. */\n destroy(): void {\n this.connection.destroy();\n }\n\n // ---- wallet events ----\n\n private handleNetworkChanged(network: NetworkId): void {\n if (network === this.network) return;\n this.network = network;\n this.events.emit(\"networkChanged\", network);\n }\n\n private handleConnected(address: string, network: NetworkId): void {\n const accountChanged = this.address !== address;\n const networkChanged = this.network !== network;\n this.address = address;\n this.network = network;\n\n this.events.emit(\"connect\", { address, network });\n if (networkChanged) this.events.emit(\"networkChanged\", network);\n if (accountChanged) this.events.emit(\"accountChanged\", address);\n }\n\n private handleDisconnected(): void {\n if (!this.address) return;\n this.address = null;\n this.events.emit(\"disconnect\");\n this.events.emit(\"accountChanged\", null);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/shared/networks.ts","../src/shared/messages.ts","../src/errors.ts","../src/connection.ts","../src/emitter.ts","../src/stellar.ts","../src/BeaconAuth.ts"],"names":[],"mappings":";AAeO,IAAM,QAAA,GAA2C;AAAA,EACtD,OAAA,EAAS;AAAA,IACP,EAAA,EAAI,SAAA;AAAA,IACJ,IAAA,EAAM,iBAAA;AAAA,IACN,UAAA,EAAY,mCAAA;AAAA,IACZ,UAAA,EAAY,qCAAA;AAAA,IACZ,WAAA,EAAa,yCAAA;AAAA,IACb,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,OAAA,EAAS;AAAA,IACP,EAAA,EAAI,SAAA;AAAA,IACJ,IAAA,EAAM,iBAAA;AAAA,IACN,UAAA,EAAY,gDAAA;AAAA,IACZ,UAAA,EAAY,6BAAA;AAAA,IACZ,WAAA,EAAa;AAAA;AAEjB;AAEO,IAAM,WAAA,GAAc,CAAC,KAAA,KAAuC,KAAA,KAAU,aAAa,KAAA,KAAU,SAAA;;;AC1B7F,IAAM,SAAA,GAAY;AAAA,EACvB,QAAA,EAAU,EAAA;AAAA,EACA;AAAA,EACV,eAAA,EAAiB,EAAA;AAAA,EAEF;AAAA,EACf,WAAA,EAAa,EAEf,CAAA;AAuDA,IAAM,WAAW,CAAC,CAA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OAAA;AACxC,IAAA,MAAM,cAAA,GAAiB,KAAK,OAAA,KAAY,OAAA;AACxC,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AACf,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAEf,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,SAAA,EAAW,EAAE,OAAA,EAAS,SAAS,CAAA;AAChD,IAAA,IAAI,cAAA,EAAgB,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,kBAAkB,OAAO,CAAA;AAC9D,IAAA,IAAI,cAAA,EAAgB,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,kBAAkB,OAAO,CAAA;AAAA,EAChE;AAAA,EAEQ,kBAAA,GAA2B;AACjC,IAAA,IAAI,CAAC,KAAK,OAAA,EAAS;AACnB,IAAA,IAAA,CAAK,OAAA,GAAU,IAAA;AACf,IAAA,IAAA,CAAK,MAAA,CAAO,KAAK,YAAY,CAAA;AAC7B,IAAA,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,gBAAA,EAAkB,IAAI,CAAA;AAAA,EACzC;AACF","file":"index.js","sourcesContent":["// Stellar network data with NO imports, so the SDK bundle stays tiny.\n// The wallet keeps its own copy (wallet/src/shared/networks.ts): keep them in sync.\n// Source: https://developers.stellar.org/docs/networks\n\nexport type NetworkId = \"testnet\" | \"mainnet\";\n\nexport type NetworkInfo = {\n id: NetworkId;\n name: string;\n passphrase: string; // identifies the network inside every signed transaction\n horizonUrl: string;\n explorerUrl: string;\n friendbotUrl?: string; // free test funds: testnet only\n};\n\nexport const NETWORKS: Record<NetworkId, NetworkInfo> = {\n testnet: {\n id: \"testnet\",\n name: \"Stellar Testnet\",\n passphrase: \"Test SDF Network ; September 2015\",\n horizonUrl: \"https://horizon-testnet.stellar.org\",\n explorerUrl: \"https://stellar.expert/explorer/testnet\",\n friendbotUrl: \"https://friendbot.stellar.org\",\n },\n mainnet: {\n id: \"mainnet\",\n name: \"Stellar Mainnet\",\n passphrase: \"Public Global Stellar Network ; September 2015\",\n horizonUrl: \"https://horizon.stellar.org\",\n explorerUrl: \"https://stellar.expert/explorer/public\",\n },\n};\n\nexport const isNetworkId = (value: unknown): value is NetworkId => value === \"testnet\" || value === \"mainnet\";\n","// postMessage protocol between the SDK (parent page) and the wallet iframe.\n// Used by both sides. Contains no secrets and no crypto.\n// The wallet keeps its own copy (wallet/src/shared/messages.ts): keep them in sync.\n\nimport { isNetworkId, type NetworkId } from \"./networks\";\n\n// ---- error codes: the ones from SEP-43 (Stellar wallet interface), plus a few of ours ----\nexport const ErrorCode = {\n INTERNAL: -1, // internal wallet error\n EXTERNAL: -2, // an outside service (Horizon, network) failed\n INVALID_REQUEST: -3, // bad parameters, malformed XDR, wrong network\n USER_REJECTED: -4, // the user said no: do not retry\n NOT_CONNECTED: -5, // log in first\n UNSUPPORTED: -6, // method or network not supported\n BUSY: -7, // another request is already waiting for the user\n} as const;\n\nexport type RpcError = { code: number; message: string };\n\n// ---- SDK -> wallet ----\n\n// Must be the FIRST message the SDK sends. The wallet checks event.origin against the app's allowed origins.\n// Optionally carries the networks the app configured in code (defaultNetwork / supportedNetworks).\nexport type BeaconInit = {\n type: \"beacon:init\";\n networks?: { default?: NetworkId; supported?: NetworkId[] };\n // false = sign LOW-RISK requests (messages, plain payments) without a confirmation screen. Default: true.\n showWalletUI?: boolean;\n};\n\nexport type BeaconRequest = {\n type: \"beacon:request\";\n id: string;\n method: string;\n params?: unknown[];\n};\n\n// Methods the wallet handles.\nexport const WALLET_METHODS = [\n \"beacon_login\",\n \"beacon_logout\",\n \"beacon_cancel\", // params: [requestId]. The SDK gave up on a request (timeout): the wallet drops it.\n \"stellar_getAddress\",\n \"stellar_getNetwork\",\n \"stellar_switchNetwork\", // params: [networkId], only between the app's supported networks\n \"stellar_sendPayment\", // params: [{ to, amount, memo? }]. The wallet builds, signs and submits an XLM payment.\n \"stellar_signTransaction\", // params: [xdr, { networkPassphrase?, address? }?]\n \"stellar_signMessage\", // params: [message, { address? }?] (SEP-53)\n \"stellar_signAuthEntry\", // params: [base64 preimage, { networkPassphrase?, address? }?]\n] as const;\n\n// ---- wallet -> SDK ----\n\nexport type BeaconResponse =\n | { type: \"beacon:response\"; id: string; result: unknown }\n | { type: \"beacon:response\"; id: string; error: RpcError };\n\nexport type WalletEvent =\n | { type: \"beacon:ready\" }\n | { type: \"beacon:connected\"; address: string; network: NetworkId }\n | { type: \"beacon:disconnected\" }\n | { type: \"beacon:show\" }\n | { type: \"beacon:hide\" }\n | { type: \"beacon:resize\"; height: number } // content height in px, so the SDK can fit the iframe\n | { type: \"beacon:networkChanged\"; network: NetworkId };\n\nexport type WalletMessage = BeaconResponse | WalletEvent;\n\n// ---- type guards (message data is untrusted) ----\n\nconst isObject = (v: unknown): v is Record<string, unknown> => typeof v === \"object\" && v !== null;\n\nexport function isBeaconInit(data: unknown): data is BeaconInit {\n return isObject(data) && data.type === \"beacon:init\";\n}\n\n// The networks an app asked for in its init message (untrusted input): known ids only.\nexport function readInitNetworks(init: BeaconInit): { default?: NetworkId; supported: NetworkId[] } {\n const raw = init.networks;\n const supported = Array.isArray(raw?.supported) ? raw.supported.filter(isNetworkId).slice(0, 2) : [];\n return { default: isNetworkId(raw?.default) ? raw.default : undefined, supported };\n}\n\n// Did the app turn confirmation screens off? (untrusted input: only an explicit false counts)\nexport function readInitShowWalletUI(init: BeaconInit): boolean {\n return init.showWalletUI !== false;\n}\n\nexport function isBeaconRequest(data: unknown): data is BeaconRequest {\n return (\n isObject(data) &&\n data.type === \"beacon:request\" &&\n typeof data.id === \"string\" &&\n typeof data.method === \"string\" &&\n (data.params === undefined || Array.isArray(data.params))\n );\n}\n\nexport function isWalletMessage(data: unknown): data is WalletMessage {\n if (!isObject(data) || typeof data.type !== \"string\") return false;\n switch (data.type) {\n case \"beacon:ready\":\n case \"beacon:disconnected\":\n case \"beacon:show\":\n case \"beacon:hide\":\n return true;\n case \"beacon:networkChanged\":\n return isNetworkId(data.network);\n case \"beacon:resize\":\n return typeof data.height === \"number\" && Number.isFinite(data.height) && data.height > 0;\n case \"beacon:connected\":\n return typeof data.address === \"string\" && isNetworkId(data.network);\n case \"beacon:response\":\n return (\n typeof data.id === \"string\" &&\n (\"result\" in data ||\n (isObject(data.error) && typeof data.error.code === \"number\" && typeof data.error.message === \"string\"))\n );\n default:\n return false;\n }\n}\n","import { ErrorCode } from \"./shared/messages\";\n\n// Error with a numeric `code` from the Stellar wallet standard (SEP-43): -4 means the user rejected it.\nexport class BeaconError extends Error {\n code: number;\n\n constructor(code: number, message: string) {\n super(message);\n this.name = \"BeaconError\";\n this.code = code;\n }\n}\n\nexport const internalError = (message: string) => new BeaconError(ErrorCode.INTERNAL, message);\n","import {\n isWalletMessage,\n ErrorCode,\n type BeaconInit,\n type BeaconRequest,\n type BeaconResponse,\n} from \"./shared/messages\";\nimport { BeaconError, internalError } from \"./errors\";\nimport type { NetworkId } from \"./shared/networks\";\n\nconst READY_TIMEOUT_MS = 15_000;\n\n// Requests that open the wallet window. If the wallet is still loading, the frame opens at once and\n// the wallet shows its own loading screen (the SDK draws nothing itself).\nconst INTERACTIVE_METHODS = new Set([\n \"beacon_login\",\n \"stellar_sendPayment\",\n \"stellar_signTransaction\",\n \"stellar_signMessage\",\n \"stellar_signAuthEntry\",\n]);\n\ntype Pending = {\n resolve: (value: unknown) => void;\n reject: (error: Error) => void;\n timer: ReturnType<typeof setTimeout>;\n};\n\ntype Handlers = {\n onNetworkChanged: (network: NetworkId) => void;\n onConnected: (address: string, network: NetworkId) => void;\n onDisconnected: () => void;\n};\n\n// Owns the wallet iframe and the postMessage channel to it.\n// Only messages from the wallet's origin AND from this iframe's window are accepted.\nexport class WalletConnection {\n private readonly walletOrigin: string;\n private readonly src: string;\n private overlay: HTMLDivElement | null = null;\n private iframe: HTMLIFrameElement | null = null;\n private openedEarly = false; // the frame was opened before the wallet asked for it (it was still loading)\n private pending = new Map<string, Pending>();\n private isReady = false;\n private readyWaiters: Array<() => void> = [];\n\n constructor(\n walletUrl: string,\n private clientId: string,\n private networks: { default?: NetworkId; supported?: NetworkId[] } | undefined,\n private showWalletUI: boolean,\n private handlers: Handlers,\n ) {\n let url: URL;\n try {\n url = new URL(walletUrl);\n } catch {\n throw new BeaconError(ErrorCode.INTERNAL, `Invalid walletUrl: ${walletUrl}`);\n }\n this.walletOrigin = url.origin;\n url.pathname = \"/\";\n url.search = \"\";\n url.hash = \"\";\n url.searchParams.set(\"client_id\", clientId);\n this.src = url.toString();\n\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"message\", this.onMessage);\n this.mount();\n }\n }\n\n // ---- iframe + modal ----\n\n private mount(): void {\n const attach = () => {\n const overlay = document.createElement(\"div\");\n Object.assign(overlay.style, {\n display: \"none\",\n position: \"fixed\",\n inset: \"0\",\n zIndex: \"2147483647\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\", // no dark backdrop: only a soft shadow around the wallet (on the iframe below)\n });\n\n const iframe = document.createElement(\"iframe\");\n iframe.title = \"Beacon wallet\";\n // clipboard-write: lets the wallet copy the address.\n iframe.allow = \"clipboard-write\";\n iframe.src = this.src;\n Object.assign(iframe.style, {\n width: \"min(380px, calc(100vw - 32px))\",\n height: \"380px\", // the wallet's fixed height (a square: same as the width); the wallet confirms it with beacon:resize\n maxHeight: \"calc(100vh - 32px)\",\n transition: \"height 120ms ease\",\n border: \"0\",\n borderRadius: \"20px\", // the wallet is one white card; the iframe clips it to rounded corners\n boxShadow: \"0 0 0 1px rgba(0,0,0,0.04), 0 8px 40px rgba(0,0,0,0.28), 0 0 90px 24px rgba(0,0,0,0.18)\", // feathered glow\n background: \"#ffffff\",\n overflow: \"hidden\",\n });\n\n // The first message to the wallet. It checks our origin against the app's allowed origins.\n iframe.addEventListener(\"load\", () => {\n const init: BeaconInit = { type: \"beacon:init\", ...(this.networks && { networks: this.networks }),\n ...(!this.showWalletUI && { showWalletUI: false }) };\n iframe.contentWindow?.postMessage(init, this.walletOrigin);\n });\n\n overlay.appendChild(iframe);\n document.body.appendChild(overlay);\n this.overlay = overlay;\n this.iframe = iframe;\n };\n\n if (document.body) attach();\n else document.addEventListener(\"DOMContentLoaded\", attach, { once: true });\n }\n\n private setVisible(visible: boolean): void {\n if (!this.overlay || !this.iframe) return;\n this.openedEarly = false;\n this.overlay.style.display = visible ? \"flex\" : \"none\";\n if (visible) this.iframe.focus();\n }\n\n // The user acted before the wallet finished loading: open the frame now. The wallet's own\n // loading screen is what they see, and it takes over from there.\n private openEarly(): void {\n if (!this.overlay || this.openedEarly || this.overlay.style.display !== \"none\") return;\n this.openedEarly = true;\n this.overlay.style.display = \"flex\";\n }\n\n // Opened early, but the wallet never asked to be shown (or failed): close it again.\n private closeEarly(): void {\n if (!this.openedEarly) return;\n this.openedEarly = false;\n if (this.overlay) this.overlay.style.display = \"none\";\n }\n\n // ---- incoming messages ----\n\n private onMessage = (event: MessageEvent): void => {\n if (event.origin !== this.walletOrigin) return;\n if (!this.iframe || event.source !== this.iframe.contentWindow) return;\n if (!isWalletMessage(event.data)) return;\n\n const message = event.data;\n switch (message.type) {\n case \"beacon:ready\":\n this.isReady = true;\n this.readyWaiters.splice(0).forEach((resolve) => resolve());\n break;\n case \"beacon:show\":\n this.setVisible(true);\n break;\n case \"beacon:hide\":\n this.setVisible(false);\n break;\n case \"beacon:resize\":\n // Fit the modal to the wallet's content (max-height keeps it inside the viewport).\n if (this.iframe) this.iframe.style.height = `${Math.ceil(message.height)}px`;\n break;\n case \"beacon:networkChanged\":\n this.handlers.onNetworkChanged(message.network);\n break;\n case \"beacon:connected\":\n this.handlers.onConnected(message.address, message.network);\n break;\n case \"beacon:disconnected\":\n this.handlers.onDisconnected();\n break;\n case \"beacon:response\":\n this.settle(message);\n break;\n }\n };\n\n private settle(message: BeaconResponse): void {\n const entry = this.pending.get(message.id);\n if (!entry) return; // unknown or already timed out\n this.closeEarly(); // answered without ever showing the wallet (e.g. already connected)\n this.pending.delete(message.id);\n clearTimeout(entry.timer);\n\n if (\"error\" in message) entry.reject(new BeaconError(message.error.code, message.error.message));\n else entry.resolve(message.result);\n }\n\n // ---- outgoing requests ----\n\n private whenReady(): Promise<void> {\n if (this.isReady) return Promise.resolve();\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => {\n this.readyWaiters = this.readyWaiters.filter((w) => w !== onReady);\n this.closeEarly();\n reject(\n internalError(\n `The Beacon wallet did not load. Check that this site (${window.location.origin}) is an allowed origin ` +\n `for Client ID ${this.clientId}, and that the wallet URL (${this.walletOrigin}) is correct.`,\n ),\n );\n }, READY_TIMEOUT_MS);\n const onReady = () => {\n clearTimeout(timer);\n resolve();\n };\n this.readyWaiters.push(onReady);\n });\n }\n\n async request(method: string, params: unknown[], timeoutMs: number): Promise<unknown> {\n if (typeof window === \"undefined\") throw internalError(\"Beacon can only be used in a browser\");\n // Still loading? Open the frame now instead of waiting invisibly.\n if (!this.isReady && INTERACTIVE_METHODS.has(method)) this.openEarly();\n await this.whenReady();\n\n const target = this.iframe?.contentWindow;\n if (!target) throw internalError(\"The Beacon wallet is not available\");\n\n const id = newId();\n return new Promise<unknown>((resolve, reject) => {\n const timer = setTimeout(() => {\n this.pending.delete(id);\n this.cancel(id); // tell the wallet to drop it, so a late approval can't go unnoticed\n reject(internalError(`Wallet request timed out (${method})`));\n }, timeoutMs);\n\n this.pending.set(id, { resolve, reject, timer });\n const request: BeaconRequest = { type: \"beacon:request\", id, method, params };\n target.postMessage(request, this.walletOrigin);\n });\n }\n\n private cancel(requestId: string): void {\n const request: BeaconRequest = { type: \"beacon:request\", id: newId(), method: \"beacon_cancel\", params: [requestId] };\n this.iframe?.contentWindow?.postMessage(request, this.walletOrigin);\n }\n\n destroy(): void {\n if (typeof window === \"undefined\") return;\n window.removeEventListener(\"message\", this.onMessage);\n this.pending.forEach((entry) => {\n clearTimeout(entry.timer);\n entry.reject(internalError(\"Beacon was destroyed\"));\n });\n this.pending.clear();\n this.overlay?.remove();\n this.overlay = this.iframe = null;\n }\n}\n\nfunction newId(): string {\n if (typeof crypto !== \"undefined\" && \"randomUUID\" in crypto) return crypto.randomUUID();\n return `${Date.now()}-${Math.random().toString(36).slice(2)}`;\n}\n","// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Listener = (...args: any[]) => void;\n\nexport class Emitter {\n private listeners = new Map<string, Set<Listener>>();\n\n on(event: string, listener: Listener): () => void {\n let set = this.listeners.get(event);\n if (!set) this.listeners.set(event, (set = new Set()));\n set.add(listener);\n return () => this.off(event, listener);\n }\n\n off(event: string, listener: Listener): void {\n this.listeners.get(event)?.delete(listener);\n }\n\n emit(event: string, ...args: unknown[]): void {\n for (const listener of [...(this.listeners.get(event) ?? [])]) {\n try {\n listener(...args);\n } catch {\n // A faulty listener in the dApp must not break the SDK.\n }\n }\n }\n}\n","import type { BeaconAuth } from \"./BeaconAuth\";\nimport { BeaconError } from \"./errors\";\n\n// The standard Stellar wallet interface (SEP-43), so Beacon can plug into libraries like Stellar\n// Wallets Kit. Each function returns the result, or { error: { code, message } } instead of throwing.\n// Error codes: -1 internal, -2 external service, -3 invalid request, -4 user rejected.\n\ntype WalletError = { error: { code: number; message: string } };\n\nexport interface StellarWalletInterface {\n getAddress(): Promise<{ address: string } | WalletError>;\n getNetwork(): Promise<{ network: string; networkPassphrase: string } | WalletError>;\n signTransaction(\n xdr: string,\n opts?: { networkPassphrase?: string; address?: string },\n ): Promise<{ signedTxXdr: string; signerAddress: string } | WalletError>;\n signMessage(\n message: string,\n opts?: { address?: string },\n ): Promise<{ signedMessage: string; signerAddress: string } | WalletError>;\n signAuthEntry(\n authEntry: string,\n opts?: { networkPassphrase?: string; address?: string },\n ): Promise<{ signedAuthEntry: string; signerAddress: string } | WalletError>;\n}\n\nasync function wrap<T>(run: () => Promise<T>): Promise<T | WalletError> {\n try {\n return await run();\n } catch (error) {\n if (error instanceof BeaconError) return { error: { code: error.code, message: error.message } };\n return { error: { code: -1, message: \"Something went wrong\" } };\n }\n}\n\nexport function createWalletInterface(beacon: BeaconAuth): StellarWalletInterface {\n return {\n // getAddress logs the user in if needed, like Freighter's \"connect\".\n getAddress: () => wrap(() => beacon.login()),\n getNetwork: () =>\n wrap(async () => {\n const { id, passphrase } = beacon.getNetwork();\n return { network: id === \"mainnet\" ? \"PUBLIC\" : \"TESTNET\", networkPassphrase: passphrase };\n }),\n signTransaction: (xdr, opts) => wrap(() => beacon.signTransaction(xdr, opts)),\n signMessage: (message, opts) => wrap(() => beacon.signMessage(message, opts)),\n signAuthEntry: (authEntry, opts) => wrap(() => beacon.signAuthEntry(authEntry, opts)),\n };\n}\n","import { WalletConnection } from \"./connection\";\nimport { Emitter } from \"./emitter\";\nimport { BeaconError } from \"./errors\";\nimport { ErrorCode } from \"./shared/messages\";\nimport { isNetworkId, NETWORKS, type NetworkId, type NetworkInfo } from \"./shared/networks\";\nimport { createWalletInterface, type StellarWalletInterface } from \"./stellar\";\n\nexport type BeaconOptions = {\n /** Public Client ID from the Beacon dashboard (bcn_app_...). */\n clientId: string;\n /** Network used on login. Defaults to the app's network from the dashboard (testnet if none). */\n defaultNetwork?: NetworkId;\n /** Networks the app can switch between with switchNetwork(). Defaults to just the default network. */\n supportedNetworks?: NetworkId[];\n /** Optional. Beacon's wallet is built in, so apps normally never set this (it is for testing a different wallet). */\n walletUrl?: string;\n /**\n * Show the wallet's confirmation screen before signing. Default true.\n * Set false to sign low-risk requests silently (messages and plain XLM payments from the user's own\n * account). Anything risky (contract calls, account changes, other accounts) is always confirmed.\n */\n showWalletUI?: boolean;\n};\n\nexport type BeaconEventMap = {\n connect: (info: { address: string; network: NetworkId }) => void;\n disconnect: () => void;\n accountChanged: (address: string | null) => void;\n networkChanged: (network: NetworkId) => void;\n};\n\n// The wallet apps open by default. Published versions keep calling this address, so it must stay working.\n// (Versions before 0.1.3 used the older wallet.josephakpansunday.workers.dev, which must also stay up.)\nconst DEFAULT_WALLET_URL = \"https://wallet.beaconmcu.space\";\n\n// Waiting for a person: sign-in includes a Google popup, so it gets longer than other calls.\nconst LOGIN_TIMEOUT_MS = 5 * 60_000;\nconst SIGNING_TIMEOUT_MS = 60_000;\nconst SEND_TIMEOUT_MS = 90_000; // approval plus building and submitting on the network\nconst DEFAULT_TIMEOUT_MS = 15_000;\n\nfunction checkNetwork(network: unknown): NetworkId {\n if (!isNetworkId(network)) {\n throw new BeaconError(ErrorCode.UNSUPPORTED, `Unknown network \"${String(network)}\". Use \"testnet\" or \"mainnet\".`);\n }\n return network;\n}\n\nexport class BeaconAuth {\n private address: string | null = null;\n private network: NetworkId; // replaced by the wallet's active network once it connects\n private events = new Emitter();\n private connection: WalletConnection;\n\n constructor(options: BeaconOptions) {\n if (!options || typeof options.clientId !== \"string\" || !options.clientId) {\n throw new BeaconError(ErrorCode.INVALID_REQUEST, \"BeaconAuth: clientId is required\");\n }\n\n const defaultNetwork = options.defaultNetwork ? checkNetwork(options.defaultNetwork) : undefined;\n const supported = options.supportedNetworks?.map(checkNetwork);\n this.network = defaultNetwork ?? \"testnet\";\n const networks = defaultNetwork || supported ? { default: defaultNetwork, supported } : undefined;\n\n this.connection = new WalletConnection(options.walletUrl ?? DEFAULT_WALLET_URL, options.clientId, networks, options.showWalletUI !== false, {\n onConnected: (address, network) => this.handleConnected(address, network),\n onDisconnected: () => this.handleDisconnected(),\n onNetworkChanged: (network) => this.handleNetworkChanged(network),\n });\n }\n\n /** Opens the wallet and signs the user in with Google. Resolves with the Stellar address (G...). */\n async login(): Promise<{ address: string }> {\n if (this.address) return { address: this.address };\n const result = (await this.connection.request(\"beacon_login\", [], LOGIN_TIMEOUT_MS)) as { address: string };\n return { address: result.address };\n }\n\n async logout(): Promise<void> {\n try {\n await this.connection.request(\"beacon_logout\", [], DEFAULT_TIMEOUT_MS);\n } catch {\n // The wallet is unreachable: still forget the session locally.\n }\n this.handleDisconnected();\n }\n\n /** Switches to another of the app's supportedNetworks. Rejects with code -6 for any other network. */\n async switchNetwork(network: NetworkId): Promise<void> {\n await this.connection.request(\"stellar_switchNetwork\", [checkNetwork(network)], DEFAULT_TIMEOUT_MS);\n }\n\n // ---- sending and signing (the user approves in the wallet) ----\n\n /**\n * Sends XLM in one call. The wallet builds the payment, asks the user to approve it, signs it and\n * submits it. Resolves with the transaction hash. (To create a new account, send at least 1 XLM.)\n */\n async sendPayment(payment: { to: string; amount: string; memo?: string }): Promise<{ hash: string }> {\n return (await this.connection.request(\"stellar_sendPayment\", [payment], SEND_TIMEOUT_MS)) as { hash: string };\n }\n\n // ---- signing (the user always approves inside the wallet) ----\n\n /** Signs a transaction (base64 XDR). Returns the signed XDR; submit it yourself, e.g. through Horizon. */\n async signTransaction(\n xdr: string,\n options: { networkPassphrase?: string; address?: string } = {},\n ): Promise<{ signedTxXdr: string; signerAddress: string }> {\n return (await this.connection.request(\n \"stellar_signTransaction\",\n [xdr, options],\n SIGNING_TIMEOUT_MS,\n )) as { signedTxXdr: string; signerAddress: string };\n }\n\n /** Signs a text message (SEP-53). The signature is base64. */\n async signMessage(\n message: string,\n options: { address?: string } = {},\n ): Promise<{ signedMessage: string; signerAddress: string }> {\n return (await this.connection.request(\"stellar_signMessage\", [message, options], SIGNING_TIMEOUT_MS)) as {\n signedMessage: string;\n signerAddress: string;\n };\n }\n\n /** Signs a Soroban authorization entry preimage (base64 XDR). Returns a base64 signature. */\n async signAuthEntry(\n preimage: string,\n options: { networkPassphrase?: string; address?: string } = {},\n ): Promise<{ signedAuthEntry: string; signerAddress: string }> {\n return (await this.connection.request(\n \"stellar_signAuthEntry\",\n [preimage, options],\n SIGNING_TIMEOUT_MS,\n )) as { signedAuthEntry: string; signerAddress: string };\n }\n\n // ---- state ----\n\n getAddress(): string | null {\n return this.address;\n }\n\n /** The active network (the default one until the wallet reports otherwise). */\n getNetwork(): NetworkInfo {\n return NETWORKS[this.network];\n }\n\n /**\n * The same functions in the standard Stellar wallet shape (SEP-43), for libraries such as\n * Stellar Wallets Kit: getAddress, signTransaction, signMessage, signAuthEntry, getNetwork.\n */\n getWalletInterface(): StellarWalletInterface {\n return createWalletInterface(this);\n }\n\n on<E extends keyof BeaconEventMap>(event: E, callback: BeaconEventMap[E]): () => void {\n return this.events.on(event, callback);\n }\n\n off<E extends keyof BeaconEventMap>(event: E, callback: BeaconEventMap[E]): void {\n this.events.off(event, callback);\n }\n\n /** Removes the wallet iframe and listeners. */\n destroy(): void {\n this.connection.destroy();\n }\n\n // ---- wallet events ----\n\n private handleNetworkChanged(network: NetworkId): void {\n if (network === this.network) return;\n this.network = network;\n this.events.emit(\"networkChanged\", network);\n }\n\n private handleConnected(address: string, network: NetworkId): void {\n const accountChanged = this.address !== address;\n const networkChanged = this.network !== network;\n this.address = address;\n this.network = network;\n\n this.events.emit(\"connect\", { address, network });\n if (networkChanged) this.events.emit(\"networkChanged\", network);\n if (accountChanged) this.events.emit(\"accountChanged\", address);\n }\n\n private handleDisconnected(): void {\n if (!this.address) return;\n this.address = null;\n this.events.emit(\"disconnect\");\n this.events.emit(\"accountChanged\", null);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beaconmcu/auth",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Embedded wallet with Google sign-in for Stellar dApps",
5
5
  "keywords": [
6
6
  "stellar",