@beaconmcu/auth 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +293 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +293 -5
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.cjs.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,WAAA,EAAa,EAEf,CAAA;AAuDA,IAAM,WAAW,CAAC,CAAA,KAA6C,OAAO,CAAA,KAAM,YAAY,CAAA,KAAM,IAAA;AA4BvF,SAAS,gBAAgB,IAAA,EAAsC;AACpE,EAAA,IAAI,CAAC,SAAS,IAAI,CAAA,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AO,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/wallets/registry.ts","../src/wallets/external.ts","../src/wallets/picker.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;AAAA,EACV,QAAA,EAAU,EAAA;AAAA;AAAA,EACV,eAAA,EAAiB,EAAA;AAAA;AAAA,EACjB,aAAA,EAAe,EAAA;AAAA;AAAA,EACf,aAAA,EAAe,EAAA;AAAA;AAAA,EACf,WAAA,EAAa,EAEf,CAAA;AAwDA,IAAM,WAAW,CAAC,CAAA,KAA6C,OAAO,CAAA,KAAM,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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 // authMethods: what the app turned on in the dashboard (\"google\", \"wallets\"). Older wallets send none.\n | { type: \"beacon:ready\"; authMethods?: string[] }\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 authMethods: string[] = [];\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 // The sign-in methods the app turned on (untrusted input: only strings count). Older wallets send none.\n this.authMethods = Array.isArray(message.authMethods) ? message.authMethods.filter((m) => typeof m === \"string\") : [];\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 /** The sign-in methods the app turned on in the dashboard (waits for the wallet to load). */\n async signInMethods(): Promise<string[]> {\n await this.whenReady();\n return this.authMethods;\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","// The external Stellar wallets Beacon can connect to. Each one is loaded only when needed (a dynamic import),\n// so apps that don't use external wallets never download any of this code.\n//\n// The wallets come from Stellar Wallets Kit (@creit.tech/stellar-wallets-kit). Only its wallet modules are used:\n// Beacon draws its own list, the kit's own window is never shown.\n\n// What Beacon needs from a wallet module (a subset of the kit's ModuleInterface).\nexport interface WalletModule {\n productId: string;\n productName: string;\n productUrl: string;\n productIcon: string;\n isAvailable(): Promise<boolean>;\n getAddress(params?: { skipRequestAccess?: boolean }): Promise<{ address: string }>;\n signTransaction(\n xdr: string,\n opts?: { networkPassphrase?: string; address?: string },\n ): Promise<{ signedTxXdr: string; signerAddress?: string }>;\n signMessage?(\n message: string,\n opts?: { networkPassphrase?: string; address?: string },\n ): Promise<{ signedMessage: string; signerAddress?: string }>;\n signAuthEntry?(\n authEntry: string,\n opts?: { networkPassphrase?: string; address?: string },\n ): Promise<{ signedAuthEntry: string; signerAddress?: string }>;\n}\n\n// In the order they are listed. Add a wallet here (one line) to offer it.\nexport const WALLET_LOADERS: Array<() => Promise<WalletModule>> = [\n async () => new (await import(\"@creit.tech/stellar-wallets-kit/modules/xbull\")).xBullModule(),\n async () => new (await import(\"@creit.tech/stellar-wallets-kit/modules/varial\")).VarialModule(), // Freighter, now called Varial\n async () => new (await import(\"@creit.tech/stellar-wallets-kit/modules/lobstr\")).LobstrModule(),\n async () => new (await import(\"@creit.tech/stellar-wallets-kit/modules/hana\")).HanaModule(),\n async () => new (await import(\"@creit.tech/stellar-wallets-kit/modules/albedo\")).AlbedoModule(),\n async () => new (await import(\"@creit.tech/stellar-wallets-kit/modules/rabet\")).RabetModule(),\n];\n","import { BeaconError } from \"../errors\";\nimport { ErrorCode } from \"../shared/messages\";\nimport { WALLET_LOADERS, type WalletModule } from \"./registry\";\n\nexport type WalletChoice = {\n id: string;\n name: string;\n icon: string;\n url: string; // where to get the wallet\n installed: boolean;\n};\n\nconst AVAILABLE_TIMEOUT_MS = 1_500; // the kit says a wallet must answer within a second\n\n// Turns whatever a wallet throws into a BeaconError (code -4 = the user said no).\nfunction toBeaconError(error: unknown, fallback: string): BeaconError {\n if (error instanceof BeaconError) return error;\n const e = error as { code?: unknown; message?: unknown; error?: { code?: unknown; message?: unknown } } | null;\n const code = typeof e?.code === \"number\" ? e.code : typeof e?.error?.code === \"number\" ? e.error.code : undefined;\n const raw = typeof e?.message === \"string\" ? e.message : typeof e?.error?.message === \"string\" ? e.error.message : \"\";\n const rejected = code === ErrorCode.USER_REJECTED || /reject|denied|declin|cancel/i.test(raw);\n if (rejected) return new BeaconError(ErrorCode.USER_REJECTED, \"The request was cancelled in the wallet.\");\n return new BeaconError(ErrorCode.EXTERNAL, raw || fallback);\n}\n\n// One connected external wallet at a time. Created by BeaconAuth only when the app turned external wallets on.\nexport class ExternalWallets {\n private modules: Promise<WalletModule[]> | null = null;\n private active: WalletModule | null = null;\n\n private load(): Promise<WalletModule[]> {\n this.modules ??= Promise.all(WALLET_LOADERS.map((load) => load()));\n return this.modules;\n }\n\n /** The wallets to show, and which of them are installed in this browser. */\n async list(): Promise<WalletChoice[]> {\n const modules = await this.load();\n return Promise.all(\n modules.map(async (m) => ({\n id: m.productId,\n name: m.productName,\n icon: m.productIcon,\n url: m.productUrl,\n installed: await Promise.race([\n m.isAvailable().catch(() => false),\n new Promise<boolean>((resolve) => setTimeout(() => resolve(false), AVAILABLE_TIMEOUT_MS)),\n ]),\n })),\n );\n }\n\n /** Asks the wallet to share its address (the wallet shows its own approval). */\n async connect(id: string): Promise<string> {\n const wallet = (await this.load()).find((m) => m.productId === id);\n if (!wallet) throw new BeaconError(ErrorCode.INVALID_REQUEST, `Unknown wallet \"${id}\".`);\n try {\n const { address } = await wallet.getAddress();\n if (!address) throw new Error(\"The wallet did not return an address.\");\n this.active = wallet;\n return address;\n } catch (e) {\n throw toBeaconError(e, \"Could not connect to the wallet.\");\n }\n }\n\n get connected(): boolean {\n return this.active !== null;\n }\n\n disconnect(): void {\n this.active = null;\n }\n\n private wallet(): WalletModule {\n if (!this.active) throw new BeaconError(ErrorCode.NOT_CONNECTED, \"No wallet is connected.\");\n return this.active;\n }\n\n async signTransaction(xdr: string, opts: { networkPassphrase: string; address?: string }) {\n try {\n const r = await this.wallet().signTransaction(xdr, opts);\n return { signedTxXdr: r.signedTxXdr, signerAddress: r.signerAddress ?? opts.address ?? \"\" };\n } catch (e) {\n throw toBeaconError(e, \"The wallet could not sign the transaction.\");\n }\n }\n\n async signMessage(message: string, opts: { address?: string }) {\n const w = this.wallet();\n if (!w.signMessage) throw new BeaconError(ErrorCode.UNSUPPORTED, `${w.productName} cannot sign messages.`);\n try {\n const r = await w.signMessage(message, opts);\n return { signedMessage: r.signedMessage, signerAddress: r.signerAddress ?? opts.address ?? \"\" };\n } catch (e) {\n throw toBeaconError(e, \"The wallet could not sign the message.\");\n }\n }\n\n async signAuthEntry(entry: string, opts: { networkPassphrase: string; address?: string }) {\n const w = this.wallet();\n if (!w.signAuthEntry) throw new BeaconError(ErrorCode.UNSUPPORTED, `${w.productName} cannot sign authorization entries.`);\n try {\n const r = await w.signAuthEntry(entry, opts);\n return { signedAuthEntry: r.signedAuthEntry, signerAddress: r.signerAddress ?? opts.address ?? \"\" };\n } catch (e) {\n throw toBeaconError(e, \"The wallet could not sign the authorization entry.\");\n }\n }\n}\n","import type { WalletChoice } from \"./external\";\n\n// Beacon's own sign-in window for apps that turned external wallets on: \"Continue with Google\", then the list of\n// wallets. It is plain DOM drawn by the SDK in the app's page (browser wallet extensions only work there, not inside\n// the wallet iframe). Same look as the Beacon wallet.\n\nexport type PickerResult = { kind: \"google\" } | { kind: \"wallet\"; id: string };\n\nconst FONT = 'Inter, system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif';\n\nfunction el<K extends keyof HTMLElementTagNameMap>(\n tag: K,\n style: Partial<CSSStyleDeclaration> = {},\n text?: string,\n): HTMLElementTagNameMap[K] {\n const node = document.createElement(tag);\n Object.assign(node.style, style);\n if (text !== undefined) node.textContent = text;\n return node;\n}\n\nconst GOOGLE_G =\n '<svg viewBox=\"0 0 24 24\" width=\"20\" height=\"20\" aria-hidden=\"true\"><path fill=\"#4285F4\" d=\"M23.5 12.3c0-.8-.1-1.6-.2-2.3H12v4.5h6.5a5.6 5.6 0 0 1-2.4 3.7v3h3.9c2.3-2.1 3.5-5.2 3.5-8.9z\"/><path fill=\"#34A853\" d=\"M12 24c3.2 0 6-1.1 7.9-2.9l-3.9-3c-1.1.7-2.5 1.2-4 1.2-3.1 0-5.7-2.1-6.6-4.9H1.4v3.1A12 12 0 0 0 12 24z\"/><path fill=\"#FBBC05\" d=\"M5.4 14.4a7.2 7.2 0 0 1 0-4.8V6.5H1.4a12 12 0 0 0 0 11z\"/><path fill=\"#EA4335\" d=\"M12 4.8c1.8 0 3.3.6 4.6 1.8l3.4-3.4A12 12 0 0 0 1.4 6.5l4 3.1C6.3 6.9 8.9 4.8 12 4.8z\"/></svg>';\n\nconst rowStyle: Partial<CSSStyleDeclaration> = {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"12px\",\n width: \"100%\",\n boxSizing: \"border-box\",\n padding: \"10px 12px\",\n border: \"1px solid #e5e7eb\",\n borderRadius: \"12px\",\n background: \"#fff\",\n color: \"#111827\",\n font: `500 15px ${FONT}`,\n textAlign: \"left\",\n cursor: \"pointer\",\n};\n\n/** Shows the window. Resolves with the choice, or null when the person closes it. */\nexport function pickSignIn(loadWallets: () => Promise<WalletChoice[]>): Promise<PickerResult | null> {\n return new Promise((resolve) => {\n const overlay = el(\"div\", {\n position: \"fixed\",\n inset: \"0\",\n zIndex: \"2147483647\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n background: \"transparent\",\n });\n\n const card = el(\"div\", {\n width: \"min(380px, calc(100vw - 32px))\",\n maxHeight: \"calc(100vh - 32px)\",\n boxSizing: \"border-box\",\n overflowY: \"auto\",\n padding: \"20px\",\n borderRadius: \"20px\",\n background: \"#fff\",\n color: \"#111827\",\n fontFamily: FONT,\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)\",\n });\n card.setAttribute(\"role\", \"dialog\");\n card.setAttribute(\"aria-modal\", \"true\");\n card.setAttribute(\"aria-label\", \"Sign in\");\n\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") done(null);\n };\n const done = (result: PickerResult | null) => {\n document.removeEventListener(\"keydown\", onKey);\n overlay.remove();\n resolve(result);\n };\n document.addEventListener(\"keydown\", onKey);\n overlay.addEventListener(\"mousedown\", (e) => {\n if (e.target === overlay) done(null);\n });\n\n // header\n const header = el(\"div\", { display: \"flex\", alignItems: \"center\", justifyContent: \"space-between\", marginBottom: \"16px\" });\n header.appendChild(el(\"p\", { margin: \"0\", font: `600 18px ${FONT}` }, \"Sign in\"));\n const close = el(\n \"button\",\n { border: \"0\", background: \"transparent\", cursor: \"pointer\", padding: \"4px\", color: \"#6b7280\", font: `400 22px ${FONT}`, lineHeight: \"1\" },\n \"×\",\n );\n close.type = \"button\";\n close.setAttribute(\"aria-label\", \"Close\");\n close.addEventListener(\"click\", () => done(null));\n header.appendChild(close);\n card.appendChild(header);\n\n // Google\n const google = el(\"button\", { ...rowStyle, justifyContent: \"center\" });\n google.type = \"button\";\n google.innerHTML = GOOGLE_G;\n google.appendChild(el(\"span\", {}, \"Continue with Google\"));\n google.addEventListener(\"click\", () => done({ kind: \"google\" }));\n card.appendChild(google);\n\n card.appendChild(el(\"p\", { margin: \"16px 0 10px\", font: `500 13px ${FONT}`, color: \"#6b7280\" }, \"Or connect a Stellar wallet\"));\n\n // wallets\n const list = el(\"div\", { display: \"flex\", flexDirection: \"column\", gap: \"8px\" });\n const loading = el(\"p\", { margin: \"0\", font: `400 14px ${FONT}`, color: \"#6b7280\" }, \"Loading wallets…\");\n list.appendChild(loading);\n card.appendChild(list);\n\n overlay.appendChild(card);\n document.body.appendChild(overlay);\n google.focus();\n\n loadWallets()\n .then((wallets) => {\n list.replaceChildren();\n // Installed wallets first.\n [...wallets]\n .sort((a, b) => Number(b.installed) - Number(a.installed))\n .forEach((w) => list.appendChild(walletRow(w, done)));\n })\n .catch(() => {\n loading.textContent = \"Wallets could not be loaded. Use Google instead.\";\n });\n });\n}\n\nfunction walletRow(wallet: WalletChoice, done: (r: PickerResult | null) => void): HTMLElement {\n const row = el(\"button\", rowStyle);\n row.type = \"button\";\n\n const icon = el(\"img\", { width: \"28px\", height: \"28px\", borderRadius: \"8px\", objectFit: \"cover\", flexShrink: \"0\" });\n icon.alt = \"\";\n icon.src = wallet.icon;\n icon.addEventListener(\"error\", () => (icon.style.visibility = \"hidden\"));\n row.appendChild(icon);\n\n row.appendChild(el(\"span\", { flex: \"1\" }, wallet.name));\n\n if (wallet.installed) {\n row.addEventListener(\"click\", () => done({ kind: \"wallet\", id: wallet.id }));\n } else {\n // Not installed: the row sends the person to the wallet's website.\n row.appendChild(\n el(\"span\", { font: `500 12px ${FONT}`, color: \"#4b5563\", border: \"1px solid #d1d5db\", borderRadius: \"8px\", padding: \"3px 8px\" }, \"Install ↗\"),\n );\n row.addEventListener(\"click\", () => window.open(wallet.url, \"_blank\", \"noopener,noreferrer\"));\n }\n return row;\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\";\nimport { ExternalWallets } from \"./wallets/external\";\nimport { pickSignIn } from \"./wallets/picker\";\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 private external = new ExternalWallets(); // an external Stellar wallet (Freighter, xBull, ...), when the app allows them\n private supported: NetworkId[] = [];\n private loginInFlight: Promise<{ address: string }> | null = null;\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 this.supported = [...new Set([this.network, ...(supported ?? [])])];\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.external.connected && this.handleDisconnected(), // the Beacon wallet's events do not end an external wallet's session\n onNetworkChanged: (network) => this.handleNetworkChanged(network),\n });\n }\n\n /**\n * Signs the user in and resolves with the Stellar address (G...). With Google only, it opens the Beacon wallet.\n * When the app turned on External wallets in the dashboard, the person first picks Google or a wallet.\n */\n async login(): Promise<{ address: string }> {\n if (this.address) return { address: this.address };\n this.loginInFlight ??= this.startLogin().finally(() => (this.loginInFlight = null));\n return this.loginInFlight;\n }\n\n private async startLogin(): Promise<{ address: string }> {\n const methods = await this.connection.signInMethods();\n if (methods.includes(\"wallets\")) {\n const choice = await pickSignIn(() => this.external.list());\n if (!choice) throw new BeaconError(ErrorCode.USER_REJECTED, \"Sign-in was closed.\");\n if (choice.kind === \"wallet\") {\n const address = await this.external.connect(choice.id);\n this.handleConnected(address, this.network);\n return { address };\n }\n }\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 if (this.external.connected) {\n this.external.disconnect();\n this.handleDisconnected();\n return;\n }\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 if (this.external.connected) {\n // The external wallet has its own network setting; Beacon only changes which network it signs for.\n if (!this.supported.includes(checkNetwork(network))) {\n throw new BeaconError(ErrorCode.UNSUPPORTED, `Network \"${network}\" is not one of this app's supportedNetworks.`);\n }\n this.handleNetworkChanged(network);\n return;\n }\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 if (this.external.connected) {\n throw new BeaconError(\n ErrorCode.UNSUPPORTED,\n \"sendPayment is only available with a Beacon (Google) wallet. With an external wallet, build the transaction and use signTransaction.\",\n );\n }\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 if (this.external.connected) {\n return this.external.signTransaction(xdr, {\n networkPassphrase: options.networkPassphrase ?? NETWORKS[this.network].passphrase,\n address: options.address ?? this.address ?? undefined,\n });\n }\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 if (this.external.connected) {\n return this.external.signMessage(message, { address: options.address ?? this.address ?? undefined });\n }\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 if (this.external.connected) {\n return this.external.signAuthEntry(preimage, {\n networkPassphrase: options.networkPassphrase ?? NETWORKS[this.network].passphrase,\n address: options.address ?? this.address ?? undefined,\n });\n }\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.d.cts
CHANGED
|
@@ -75,11 +75,18 @@ declare class BeaconAuth {
|
|
|
75
75
|
private network;
|
|
76
76
|
private events;
|
|
77
77
|
private connection;
|
|
78
|
+
private external;
|
|
79
|
+
private supported;
|
|
80
|
+
private loginInFlight;
|
|
78
81
|
constructor(options: BeaconOptions);
|
|
79
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* Signs the user in and resolves with the Stellar address (G...). With Google only, it opens the Beacon wallet.
|
|
84
|
+
* When the app turned on External wallets in the dashboard, the person first picks Google or a wallet.
|
|
85
|
+
*/
|
|
80
86
|
login(): Promise<{
|
|
81
87
|
address: string;
|
|
82
88
|
}>;
|
|
89
|
+
private startLogin;
|
|
83
90
|
logout(): Promise<void>;
|
|
84
91
|
/** Switches to another of the app's supportedNetworks. Rejects with code -6 for any other network. */
|
|
85
92
|
switchNetwork(network: NetworkId): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -75,11 +75,18 @@ declare class BeaconAuth {
|
|
|
75
75
|
private network;
|
|
76
76
|
private events;
|
|
77
77
|
private connection;
|
|
78
|
+
private external;
|
|
79
|
+
private supported;
|
|
80
|
+
private loginInFlight;
|
|
78
81
|
constructor(options: BeaconOptions);
|
|
79
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* Signs the user in and resolves with the Stellar address (G...). With Google only, it opens the Beacon wallet.
|
|
84
|
+
* When the app turned on External wallets in the dashboard, the person first picks Google or a wallet.
|
|
85
|
+
*/
|
|
80
86
|
login(): Promise<{
|
|
81
87
|
address: string;
|
|
82
88
|
}>;
|
|
89
|
+
private startLogin;
|
|
83
90
|
logout(): Promise<void>;
|
|
84
91
|
/** Switches to another of the app's supportedNetworks. Rejects with code -6 for any other network. */
|
|
85
92
|
switchNetwork(network: NetworkId): Promise<void>;
|