@wallets-e2e/freighter 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +121 -2
  3. package/fixtures/wallet.ts +41 -0
  4. package/lib/fixtures/wallet.d.ts +15 -0
  5. package/lib/fixtures/wallet.d.ts.map +1 -0
  6. package/lib/fixtures/wallet.js +36 -0
  7. package/lib/fixtures/wallet.js.map +1 -0
  8. package/lib/src/extension.d.ts +27 -0
  9. package/lib/src/extension.d.ts.map +1 -0
  10. package/lib/src/extension.js +82 -0
  11. package/lib/src/extension.js.map +1 -0
  12. package/lib/src/index.d.ts +40 -0
  13. package/lib/src/index.d.ts.map +1 -0
  14. package/lib/src/index.js +56 -0
  15. package/lib/src/index.js.map +1 -0
  16. package/lib/src/networks.d.ts +14 -0
  17. package/lib/src/networks.d.ts.map +1 -0
  18. package/lib/src/networks.js +16 -0
  19. package/lib/src/networks.js.map +1 -0
  20. package/lib/src/onboarding.d.ts +40 -0
  21. package/lib/src/onboarding.d.ts.map +1 -0
  22. package/lib/src/onboarding.js +137 -0
  23. package/lib/src/onboarding.js.map +1 -0
  24. package/lib/src/prompts.d.ts +16 -0
  25. package/lib/src/prompts.d.ts.map +1 -0
  26. package/lib/src/prompts.js +41 -0
  27. package/lib/src/prompts.js.map +1 -0
  28. package/lib/src/selectors.d.ts +56 -0
  29. package/lib/src/selectors.d.ts.map +1 -0
  30. package/lib/src/selectors.js +50 -0
  31. package/lib/src/selectors.js.map +1 -0
  32. package/lib/src/test.d.ts +26 -0
  33. package/lib/src/test.d.ts.map +1 -0
  34. package/lib/src/test.js +36 -0
  35. package/lib/src/test.js.map +1 -0
  36. package/lib/src/utils.d.ts +14 -0
  37. package/lib/src/utils.d.ts.map +1 -0
  38. package/lib/src/utils.js +29 -0
  39. package/lib/src/utils.js.map +1 -0
  40. package/package.json +71 -3
  41. package/scripts/extension.mjs +111 -0
  42. package/scripts/prepare-extension.mjs +37 -0
  43. package/src/extension.ts +91 -0
  44. package/src/index.ts +103 -0
  45. package/src/networks.ts +26 -0
  46. package/src/onboarding.ts +144 -0
  47. package/src/prompts.ts +61 -0
  48. package/src/selectors.ts +54 -0
  49. package/src/test.ts +64 -0
  50. package/src/utils.ts +32 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Yehia Tarek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,122 @@
1
- # Temporary Holding Version
1
+ # @wallets-e2e/freighter
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `WalletDriver` for the real [Freighter](https://www.freighter.app) extension, pinned to the official **5.53.1 release build**, for Stellar and Soroban dapps. The wallet has been named **Varial** since October 2026: its own screens and the wallet lists of dapps say Varial, while its repository, its release assets and `@stellar/freighter-api` keep the name Freighter. This package drives that one wallet, under both names.
4
+
5
+ Real import of a recovery phrase, a real network switch, the wallet's real connection and transaction prompts. No mock.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ export FREIGHTER_EXTENSION_PATH="$PWD/.wallet-extensions/freighter-5.53.1"
11
+ npm install --save-dev \
12
+ @wallets-e2e/core@^0.3.0 \
13
+ @wallets-e2e/freighter@^0.1.0 \
14
+ @playwright/test
15
+ npx playwright install chromium
16
+ ```
17
+
18
+ Never substitute a repository checkout or a link for the published packages.
19
+
20
+ ## The extension
21
+
22
+ Keep `.wallet-extensions/` gitignored and retain `FREIGHTER_EXTENSION_PATH` in the test environment.
23
+ Installing downloads `build-5.53.1.zip` from the [stellar/freighter release](https://github.com/stellar/freighter/releases/tag/5.53.1), verifies the pinned SHA-256
24
+ `fd6567de460e438989f5ea780cba8a37317347a47cacb930727015d797cef68f`, and unpacks it at that caller-owned path.
25
+ The browser artifact is separate from the JavaScript package.
26
+
27
+ pnpm 10 and npm `--ignore-scripts` block install scripts by default, and CI may install offline. The first test run then downloads it instead, or you can do it yourself:
28
+
29
+ ```bash
30
+ npx wallets-e2e-freighter # idempotent; no-op when the pinned build is already there
31
+ npx wallets-e2e-freighter --force # re-download, replacing whatever is there
32
+ ```
33
+
34
+ To allow the install-time download under pnpm 10, add to your `package.json`:
35
+
36
+ ```json
37
+ { "pnpm": { "onlyBuiltDependencies": ["@wallets-e2e/freighter"] } }
38
+ ```
39
+
40
+ Set `FREIGHTER_EXTENSION_PATH` to drive an unpacked build of your own instead; nothing is downloaded over it. It needs `unzip` on the machine, as the MetaMask package does.
41
+
42
+ ## Fixture wallet
43
+
44
+ Use a dedicated, throwaway testnet wallet, given through the Playwright process environment (a `.env.wallet-e2e.local` or `.env.local` beside your tests is loaded for you):
45
+
46
+ ```text
47
+ WALLETS_E2E_STELLAR_SEED_PHRASE=<12 or 24 words of a test wallet>
48
+ WALLETS_E2E_STELLAR_ADDRESS=<its first account, G…>
49
+ ```
50
+
51
+ The address is what the wallet must produce from the phrase (SEP-0005, account 0). The driver reads the imported account back from the wallet's own stored state, so your test can compare the two. Never use a phrase that holds anything of value: videos, screenshots and traces of a run are test artifacts.
52
+
53
+ ## A test
54
+
55
+ ```ts
56
+ // tests/fixtures.ts
57
+ import { createFreighterTest } from '@wallets-e2e/freighter';
58
+
59
+ export const test = createFreighterTest();
60
+ export { expect } from '@playwright/test';
61
+ ```
62
+
63
+ ```ts
64
+ // tests/sign.spec.ts
65
+ import { freighterDriver } from '@wallets-e2e/freighter';
66
+ import { wallet } from '@wallets-e2e/freighter/fixtures/wallet.js';
67
+ import { test, expect } from './fixtures';
68
+
69
+ test('connects and signs', async ({ extensionContext }) => {
70
+ const account = await freighterDriver.importWallet(extensionContext, wallet.seedPhrase);
71
+ expect(account.address).toBe(wallet.address);
72
+ await freighterDriver.switchNetwork(extensionContext, 'testnet');
73
+
74
+ const dapp = await extensionContext.newPage();
75
+ await dapp.goto('/');
76
+
77
+ // The click that makes the wallet open its prompt goes inside the trigger.
78
+ await freighterDriver.connectToDapp(extensionContext, () => dapp.getByTestId('connect-wallet').click());
79
+ await expect(dapp.getByTestId('connected-address')).toHaveText(wallet.address);
80
+
81
+ await freighterDriver.confirmTransaction(extensionContext, () => dapp.getByTestId('send').click());
82
+ // Then wait for the transaction on the network and assert the state it must produce.
83
+ });
84
+ ```
85
+
86
+ In a dapp that lists wallets through Stellar Wallets Kit, the trigger of `connectToDapp` is the click on the **Varial** row.
87
+
88
+ ## The driver
89
+
90
+ | Method | What it does |
91
+ |---|---|
92
+ | `importWallet(context, seedPhrase, options?)` | Imports a 12- or 24-word phrase and returns `{ address }`, read from the wallet's stored state. Idempotent in a profile that already holds a wallet. Turns the wallet's usage-data sharing off unless `shareUsageData: true`. |
93
+ | `switchNetwork(context, 'testnet' \| 'mainnet')` | Selects the network in the wallet's settings and proves it from the wallet's stored state. A fresh wallet starts on Main Net. |
94
+ | `connectToDapp(context, trigger, options?)` | Approves the connection request `trigger` raises. |
95
+ | `confirmTransaction(context, trigger, options?)` | Signs the transaction `trigger` raises. |
96
+ | `rejectConnection`, `rejectTransaction` | Press Cancel on the same prompts: the dapp gets the wallet's own refusal. |
97
+ | `activeAccount(context)`, `activeNetwork(context)` | What the wallet is using, from its stored state. |
98
+
99
+ `options.beforeAnswer(prompt, button)` runs with the prompt open, before the driver presses its button: assert on what the wallet displays (the account, the network, the fee), or hand it to [`@wallets-e2e/walkthrough`](https://www.npmjs.com/package/@wallets-e2e/walkthrough) to show the prompt in a recorded demo.
100
+
101
+ Usage-data sharing: Freighter turns it on by default, and it reports the wallet's public keys to the wallet's analytics providers. The driver turns it off right after the import.
102
+
103
+ ## Beside another wallet
104
+
105
+ A dapp that signs on an EVM chain with MetaMask and on Stellar with Freighter needs both in one browser:
106
+
107
+ ```ts
108
+ import { freighterExtraExtension } from '@wallets-e2e/freighter';
109
+ import { createMetamaskTest } from '@wallets-e2e/metamask';
110
+
111
+ export const test = createMetamaskTest({ extraExtensions: [freighterExtraExtension()] });
112
+ ```
113
+
114
+ `metamaskDriver` and `freighterDriver` then both work on the same `extensionContext`: each finds its own extension by its service worker, not by load order. This needs `@wallets-e2e/metamask@^0.3.0`.
115
+
116
+ ## What is covered
117
+
118
+ Verified against the pinned build: the import of a phrase, the network switch, the connection prompt and the transaction prompt, each confirmed and cancelled, alone and beside MetaMask.
119
+
120
+ Not driven yet: message signing, auth-entry signing, adding a custom network, several accounts, and unlocking a wallet that locked itself. A test that needs one of them fails loudly at the prompt it does not know.
121
+
122
+ When the wallet's UI moves, every selector and route the driver uses is in `src/selectors.ts`, together with the pinned version.
@@ -0,0 +1,41 @@
1
+ import { loadEnvFiles } from '@wallets-e2e/core';
2
+
3
+ /**
4
+ * `.env.wallet-e2e.local`, `.env.wallet-e2e` and `.env.local`, searched from the working directory
5
+ * upwards. A variable the environment already carries is never overwritten.
6
+ */
7
+ loadEnvFiles();
8
+
9
+ function requireEnv(name: string): string {
10
+ const value = process.env[name]?.trim();
11
+ if (!value) {
12
+ throw new Error(
13
+ `[wallets/freighter] ${name} is not set. Use a throwaway Stellar testnet wallet and export ` +
14
+ `WALLETS_E2E_STELLAR_SEED_PHRASE and WALLETS_E2E_STELLAR_ADDRESS ` +
15
+ `(a .env.wallet-e2e.local or .env.local beside your tests is auto-loaded).`,
16
+ );
17
+ }
18
+ return value;
19
+ }
20
+
21
+ /** A password for the throwaway browser profile, when none is configured. It protects nothing of value. */
22
+ export const DEFAULT_PROFILE_PASSWORD = 'Wallets-E2E-Profile-1!';
23
+
24
+ /**
25
+ * Getters, not values: importing `@wallets-e2e/freighter` must not throw for a consumer who has
26
+ * not set the variables, before a test even runs.
27
+ */
28
+ export const wallet = {
29
+ /** The recovery phrase of the test wallet: 12 or 24 words. */
30
+ get seedPhrase(): string {
31
+ return requireEnv('WALLETS_E2E_STELLAR_SEED_PHRASE');
32
+ },
33
+ /** The `G…` account the phrase's first account must be: checked against what the wallet itself imported. */
34
+ get address(): string {
35
+ return requireEnv('WALLETS_E2E_STELLAR_ADDRESS');
36
+ },
37
+ /** The wallet's unlock password in the test profile: `WALLETS_E2E_PASSWORD`, else a fixed throwaway one. */
38
+ get password(): string {
39
+ return process.env.WALLETS_E2E_PASSWORD?.trim() || DEFAULT_PROFILE_PASSWORD;
40
+ },
41
+ };
@@ -0,0 +1,15 @@
1
+ /** A password for the throwaway browser profile, when none is configured. It protects nothing of value. */
2
+ export declare const DEFAULT_PROFILE_PASSWORD = "Wallets-E2E-Profile-1!";
3
+ /**
4
+ * Getters, not values: importing `@wallets-e2e/freighter` must not throw for a consumer who has
5
+ * not set the variables, before a test even runs.
6
+ */
7
+ export declare const wallet: {
8
+ /** The recovery phrase of the test wallet: 12 or 24 words. */
9
+ readonly seedPhrase: string;
10
+ /** The `G…` account the phrase's first account must be: checked against what the wallet itself imported. */
11
+ readonly address: string;
12
+ /** The wallet's unlock password in the test profile: `WALLETS_E2E_PASSWORD`, else a fixed throwaway one. */
13
+ readonly password: string;
14
+ };
15
+ //# sourceMappingURL=wallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../fixtures/wallet.ts"],"names":[],"mappings":"AAoBA,2GAA2G;AAC3G,eAAO,MAAM,wBAAwB,2BAA2B,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,MAAM;IACjB,8DAA8D;yBAC5C,MAAM;IAGxB,4GAA4G;sBAC7F,MAAM;IAGrB,4GAA4G;uBAC5F,MAAM;CAGvB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { loadEnvFiles } from '@wallets-e2e/core';
2
+ /**
3
+ * `.env.wallet-e2e.local`, `.env.wallet-e2e` and `.env.local`, searched from the working directory
4
+ * upwards. A variable the environment already carries is never overwritten.
5
+ */
6
+ loadEnvFiles();
7
+ function requireEnv(name) {
8
+ const value = process.env[name]?.trim();
9
+ if (!value) {
10
+ throw new Error(`[wallets/freighter] ${name} is not set. Use a throwaway Stellar testnet wallet and export ` +
11
+ `WALLETS_E2E_STELLAR_SEED_PHRASE and WALLETS_E2E_STELLAR_ADDRESS ` +
12
+ `(a .env.wallet-e2e.local or .env.local beside your tests is auto-loaded).`);
13
+ }
14
+ return value;
15
+ }
16
+ /** A password for the throwaway browser profile, when none is configured. It protects nothing of value. */
17
+ export const DEFAULT_PROFILE_PASSWORD = 'Wallets-E2E-Profile-1!';
18
+ /**
19
+ * Getters, not values: importing `@wallets-e2e/freighter` must not throw for a consumer who has
20
+ * not set the variables, before a test even runs.
21
+ */
22
+ export const wallet = {
23
+ /** The recovery phrase of the test wallet: 12 or 24 words. */
24
+ get seedPhrase() {
25
+ return requireEnv('WALLETS_E2E_STELLAR_SEED_PHRASE');
26
+ },
27
+ /** The `G…` account the phrase's first account must be: checked against what the wallet itself imported. */
28
+ get address() {
29
+ return requireEnv('WALLETS_E2E_STELLAR_ADDRESS');
30
+ },
31
+ /** The wallet's unlock password in the test profile: `WALLETS_E2E_PASSWORD`, else a fixed throwaway one. */
32
+ get password() {
33
+ return process.env.WALLETS_E2E_PASSWORD?.trim() || DEFAULT_PROFILE_PASSWORD;
34
+ },
35
+ };
36
+ //# sourceMappingURL=wallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../fixtures/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;GAGG;AACH,YAAY,EAAE,CAAC;AAEf,SAAS,UAAU,CAAC,IAAY;IAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC;IACxC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,uBAAuB,IAAI,iEAAiE;YAC1F,kEAAkE;YAClE,2EAA2E,CAC9E,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,2GAA2G;AAC3G,MAAM,CAAC,MAAM,wBAAwB,GAAG,wBAAwB,CAAC;AAEjE;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,8DAA8D;IAC9D,IAAI,UAAU;QACZ,OAAO,UAAU,CAAC,iCAAiC,CAAC,CAAC;IACvD,CAAC;IACD,4GAA4G;IAC5G,IAAI,OAAO;QACT,OAAO,UAAU,CAAC,6BAA6B,CAAC,CAAC;IACnD,CAAC;IACD,4GAA4G;IAC5G,IAAI,QAAQ;QACV,OAAO,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,EAAE,IAAI,wBAAwB,CAAC;IAC9E,CAAC;CACF,CAAC"}
@@ -0,0 +1,27 @@
1
+ /** The only Freighter build this package's selectors are written against. */
2
+ export declare const FREIGHTER_VERSION = "5.53.1";
3
+ /**
4
+ * Freighter's background service worker, as its manifest names it. The driver finds its own
5
+ * extension by it, so another wallet loaded in the same browser is never mistaken for Freighter.
6
+ */
7
+ export declare const FREIGHTER_SERVICE_WORKER = "background.min.js";
8
+ /** Points the driver at an unpacked extension of your own instead of the packaged one. */
9
+ export declare const FREIGHTER_EXTENSION_PATH_ENV = "FREIGHTER_EXTENSION_PATH";
10
+ /** Printed when the extension is missing, and runnable as-is. */
11
+ export declare const FREIGHTER_PREPARE_COMMAND = "npx wallets-e2e-freighter";
12
+ /**
13
+ * Where the unpacked extension is, without touching the network: the `FREIGHTER_EXTENSION_PATH`
14
+ * override when set, else the copy inside this package. Safe to call at module scope — the
15
+ * directory does not have to exist yet.
16
+ */
17
+ export declare function freighterExtensionPath(): string;
18
+ export declare function isFreighterExtensionReady(dir?: string): boolean;
19
+ /**
20
+ * Makes sure the pinned Freighter build is unpacked, downloading it when it is not, and returns its
21
+ * path. Idempotent and safe to call on every run.
22
+ *
23
+ * The install-time `postinstall` normally does this already; this is the fallback for the installs
24
+ * where it could not run — `--ignore-scripts`, an offline or proxied CI, a restored cache.
25
+ */
26
+ export declare function ensureFreighterExtension(dir?: string): Promise<string>;
27
+ //# sourceMappingURL=extension.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../../src/extension.ts"],"names":[],"mappings":"AAIA,6EAA6E;AAC7E,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAE5D,0FAA0F;AAC1F,eAAO,MAAM,4BAA4B,6BAA6B,CAAC;AAEvE,iEAAiE;AACjE,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AA8BrE;;;;GAIG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAG/C;AAED,wBAAgB,yBAAyB,CAAC,GAAG,SAA2B,GAAG,OAAO,CAQjF;AAOD;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAAC,GAAG,SAA2B,GAAG,OAAO,CAAC,MAAM,CAAC,CAW9F"}
@@ -0,0 +1,82 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ import { fileURLToPath, pathToFileURL } from 'node:url';
4
+ /** The only Freighter build this package's selectors are written against. */
5
+ export const FREIGHTER_VERSION = '5.53.1';
6
+ /**
7
+ * Freighter's background service worker, as its manifest names it. The driver finds its own
8
+ * extension by it, so another wallet loaded in the same browser is never mistaken for Freighter.
9
+ */
10
+ export const FREIGHTER_SERVICE_WORKER = 'background.min.js';
11
+ /** Points the driver at an unpacked extension of your own instead of the packaged one. */
12
+ export const FREIGHTER_EXTENSION_PATH_ENV = 'FREIGHTER_EXTENSION_PATH';
13
+ /** Printed when the extension is missing, and runnable as-is. */
14
+ export const FREIGHTER_PREPARE_COMMAND = 'npx wallets-e2e-freighter';
15
+ /**
16
+ * Walks up from this module to the package it was published in. Resolved at runtime rather than
17
+ * written as a relative depth, because this file is imported both from `lib/src` (published) and
18
+ * from `src` (this monorepo, and consumers running the TypeScript sources directly).
19
+ */
20
+ function packageRoot() {
21
+ let dir = dirname(fileURLToPath(import.meta.url));
22
+ for (let i = 0; i < 6; i++) {
23
+ const manifest = join(dir, 'package.json');
24
+ if (existsSync(manifest)) {
25
+ try {
26
+ if (JSON.parse(readFileSync(manifest, 'utf8')).name === '@wallets-e2e/freighter')
27
+ return dir;
28
+ }
29
+ catch {
30
+ // Unreadable package.json: keep walking rather than guessing.
31
+ }
32
+ }
33
+ const parent = dirname(dir);
34
+ if (parent === dir)
35
+ break;
36
+ dir = parent;
37
+ }
38
+ throw new Error('[@wallets-e2e/freighter] Could not locate the package root.');
39
+ }
40
+ /**
41
+ * Where the unpacked extension is, without touching the network: the `FREIGHTER_EXTENSION_PATH`
42
+ * override when set, else the copy inside this package. Safe to call at module scope — the
43
+ * directory does not have to exist yet.
44
+ */
45
+ export function freighterExtensionPath() {
46
+ const override = process.env[FREIGHTER_EXTENSION_PATH_ENV]?.trim();
47
+ return override ? override : join(packageRoot(), 'dist');
48
+ }
49
+ export function isFreighterExtensionReady(dir = freighterExtensionPath()) {
50
+ const manifestPath = join(dir, 'manifest.json');
51
+ if (!existsSync(manifestPath))
52
+ return false;
53
+ try {
54
+ return JSON.parse(readFileSync(manifestPath, 'utf8')).version === FREIGHTER_VERSION;
55
+ }
56
+ catch {
57
+ return false;
58
+ }
59
+ }
60
+ async function extensionScript() {
61
+ const path = join(packageRoot(), 'scripts', 'extension.mjs');
62
+ return (await import(pathToFileURL(path).href));
63
+ }
64
+ /**
65
+ * Makes sure the pinned Freighter build is unpacked, downloading it when it is not, and returns its
66
+ * path. Idempotent and safe to call on every run.
67
+ *
68
+ * The install-time `postinstall` normally does this already; this is the fallback for the installs
69
+ * where it could not run — `--ignore-scripts`, an offline or proxied CI, a restored cache.
70
+ */
71
+ export async function ensureFreighterExtension(dir = freighterExtensionPath()) {
72
+ if (isFreighterExtensionReady(dir))
73
+ return dir;
74
+ if (process.env[FREIGHTER_EXTENSION_PATH_ENV]?.trim()) {
75
+ // An explicit override is the caller's own build. Downloading over it would discard it.
76
+ throw new Error(`[@wallets-e2e/freighter] ${FREIGHTER_EXTENSION_PATH_ENV} points at "${dir}", which holds no ` +
77
+ `Freighter ${FREIGHTER_VERSION} build. Unset it to use the packaged extension.`);
78
+ }
79
+ const { ensureExtension } = await extensionScript();
80
+ return ensureExtension(dir);
81
+ }
82
+ //# sourceMappingURL=extension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.js","sourceRoot":"","sources":["../../src/extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAExD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAE5D,0FAA0F;AAC1F,MAAM,CAAC,MA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;IAChD,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK,iBAAiB,CAAC;IACtF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,KAAK,UAAU,eAAe;IAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;IAC7D,OAAO,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAoB,CAAC;AACrE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,GAAG,GAAG,sBAAsB,EAAE;IAC3E,IAAI,yBAAyB,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IAC/C,IAAI,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;QACtD,wFAAwF;QACxF,MAAM,IAAI,KAAK,CACb,4BAA4B,4BAA4B,eAAe,GAAG,oBAAoB;YAC5F,aAAa,iBAAiB,iDAAiD,CAClF,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,eAAe,EAAE,CAAC;IACpD,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,40 @@
1
+ import type { BrowserContext, WalletAccount, WalletDriver } from '@wallets-e2e/core';
2
+ import type { StellarNetwork } from './networks.js';
3
+ import { type ImportOptions } from './onboarding.js';
4
+ import { type PromptOptions } from './prompts.js';
5
+ export { ensureFreighterExtension, freighterExtensionPath, isFreighterExtensionReady, FREIGHTER_EXTENSION_PATH_ENV, FREIGHTER_PREPARE_COMMAND, FREIGHTER_SERVICE_WORKER, FREIGHTER_VERSION, } from './extension.js';
6
+ export { createFreighterTest, freighterExtraExtension, type CreateFreighterTestOptions } from './test.js';
7
+ export { STELLAR_NETWORKS, type StellarNetwork, type StellarNetworkInfo } from './networks.js';
8
+ export { freighterExtensionId } from './onboarding.js';
9
+ export type { PromptOptions } from './prompts.js';
10
+ /**
11
+ * Drives the real Freighter extension (named Varial in its own UI since October 2026) for a Stellar
12
+ * or Soroban dapp. Every selector was read off the pinned release build; see `selectors.ts`.
13
+ *
14
+ * What is covered: importing a recovery phrase, choosing the network, the connection prompt and the
15
+ * transaction prompt, each confirmed or cancelled. Message and auth-entry signing prompts are not
16
+ * driven yet.
17
+ */
18
+ export interface FreighterDriver extends WalletDriver<StellarNetwork> {
19
+ /**
20
+ * Imports a 12- or 24-word recovery phrase and returns the wallet's first account, read from the
21
+ * wallet's own stored state. The wallet's usage-data sharing is turned off unless
22
+ * `shareUsageData` is true. Idempotent in a profile that already holds a wallet.
23
+ */
24
+ importWallet(context: BrowserContext, seedPhrase: string, options?: Partial<ImportOptions>): Promise<WalletAccount>;
25
+ switchNetwork(context: BrowserContext, network: StellarNetwork): Promise<void>;
26
+ /** Approves the connection prompt `trigger` raises (picking the wallet in the dapp's wallet list). */
27
+ connectToDapp(context: BrowserContext, trigger: () => Promise<void>, options?: PromptOptions): Promise<void>;
28
+ /** Signs the transaction prompt `trigger` raises. */
29
+ confirmTransaction(context: BrowserContext, trigger: () => Promise<void>, options?: PromptOptions): Promise<void>;
30
+ /** Cancels the connection prompt `trigger` raises, as a user who declines does. */
31
+ rejectConnection(context: BrowserContext, trigger: () => Promise<void>, options?: PromptOptions): Promise<void>;
32
+ /** Cancels the transaction prompt `trigger` raises: the dapp gets the wallet's own "declined" answer. */
33
+ rejectTransaction(context: BrowserContext, trigger: () => Promise<void>, options?: PromptOptions): Promise<void>;
34
+ /** The `G…` account the wallet is using, or null before a wallet is imported. */
35
+ activeAccount(context: BrowserContext): Promise<string | null>;
36
+ /** The network the wallet is on, or null for a custom network. */
37
+ activeNetwork(context: BrowserContext): Promise<StellarNetwork | null>;
38
+ }
39
+ export declare const freighterDriver: FreighterDriver;
40
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAErF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAgG,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACnJ,OAAO,EAA2C,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAI3F,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EACzB,4BAA4B,EAC5B,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,KAAK,0BAA0B,EAAE,MAAM,WAAW,CAAC;AAC1G,OAAO,EAAE,gBAAgB,EAAE,KAAK,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,WAAW,eAAgB,SAAQ,YAAY,CAAC,cAAc,CAAC;IACnE;;;;OAIG;IACH,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACpH,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/E,sGAAsG;IACtG,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7G,qDAAqD;IACrD,kBAAkB,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClH,mFAAmF;IACnF,gBAAgB,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChH,yGAAyG;IACzG,iBAAiB,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjH,iFAAiF;IACjF,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC/D,kEAAkE;IAClE,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;CACxE;AAED,eAAO,MAAM,eAAe,EAAE,eAkD7B,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { DEFAULT_PROFILE_PASSWORD } from '../fixtures/wallet.js';
2
+ import { activeNetwork, ensureNetwork, extensionPage, freighterExtensionId, importWallet, readStorage } from './onboarding.js';
3
+ import { cancelPrompt, confirmPrompt, openPrompt } from './prompts.js';
4
+ import { ROUTES, STORAGE_KEYS } from './selectors.js';
5
+ import { extensionUrl, STELLAR_ACCOUNT } from './utils.js';
6
+ export { ensureFreighterExtension, freighterExtensionPath, isFreighterExtensionReady, FREIGHTER_EXTENSION_PATH_ENV, FREIGHTER_PREPARE_COMMAND, FREIGHTER_SERVICE_WORKER, FREIGHTER_VERSION, } from './extension.js';
7
+ export { createFreighterTest, freighterExtraExtension } from './test.js';
8
+ export { STELLAR_NETWORKS } from './networks.js';
9
+ export { freighterExtensionId } from './onboarding.js';
10
+ export const freighterDriver = {
11
+ importWallet(context, seedPhrase, options = {}) {
12
+ return importWallet(context, seedPhrase, { password: DEFAULT_PROFILE_PASSWORD, ...options });
13
+ },
14
+ switchNetwork(context, network) {
15
+ return ensureNetwork(context, network);
16
+ },
17
+ async switchToTestnetNetwork(context) {
18
+ await ensureNetwork(context, 'testnet');
19
+ },
20
+ async connectToDapp(context, trigger, options = {}) {
21
+ const extensionId = await freighterExtensionId(context);
22
+ const prompt = await openPrompt(context, extensionId, 'connect', trigger, options.timeoutMs);
23
+ await confirmPrompt(prompt, 'connect', options);
24
+ },
25
+ async confirmTransaction(context, trigger, options = {}) {
26
+ const extensionId = await freighterExtensionId(context);
27
+ const prompt = await openPrompt(context, extensionId, 'transaction', trigger, options.timeoutMs);
28
+ await confirmPrompt(prompt, 'transaction', options);
29
+ },
30
+ async rejectConnection(context, trigger, options = {}) {
31
+ const extensionId = await freighterExtensionId(context);
32
+ const prompt = await openPrompt(context, extensionId, 'connect', trigger, options.timeoutMs);
33
+ await cancelPrompt(prompt, options);
34
+ },
35
+ async rejectTransaction(context, trigger, options = {}) {
36
+ const extensionId = await freighterExtensionId(context);
37
+ const prompt = await openPrompt(context, extensionId, 'transaction', trigger, options.timeoutMs);
38
+ await cancelPrompt(prompt, options);
39
+ },
40
+ async activeAccount(context) {
41
+ const extensionId = await freighterExtensionId(context);
42
+ const { page, opened } = await extensionPage(context, extensionId);
43
+ if (opened)
44
+ await page.goto(extensionUrl(extensionId, ROUTES.settings));
45
+ try {
46
+ const address = (await readStorage(page, [STORAGE_KEYS.lastUsedAccount]))[STORAGE_KEYS.lastUsedAccount];
47
+ return typeof address === 'string' && STELLAR_ACCOUNT.test(address) ? address : null;
48
+ }
49
+ finally {
50
+ if (opened)
51
+ await page.close().catch(() => undefined);
52
+ }
53
+ },
54
+ activeNetwork,
55
+ };
56
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,oBAAoB,EAAE,YAAY,EAAE,WAAW,EAAsB,MAAM,iBAAiB,CAAC;AACnJ,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAsB,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE3D,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EACzB,4BAA4B,EAC5B,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAmC,MAAM,WAAW,CAAC;AAC1G,OAAO,EAAE,gBAAgB,EAAgD,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAiCvD,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC9C,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,GAAG,EAAE;QAC5C,OAAO,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,wBAAwB,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC/F,CAAC;IAED,aAAa,CAAC,OAAO,EAAE,OAAO;QAC5B,OAAO,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,sBAAsB,CAAC,OAAO;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AAC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QACjG,MAAM,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAAO;QACzB,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC,CAAC;QACxD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACnE,IAAI,MAAM;YAAE,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QACxE,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,CAAC,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;YACxG,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;QACvF,CAAC;gBAAS,CAAC;YACT,IAAI,MAAM;gBAAE,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAED,aAAa;CACd,CAAC"}
@@ -0,0 +1,14 @@
1
+ /** The Stellar networks Freighter ships with. A custom network is added in the wallet's own settings. */
2
+ export type StellarNetwork = 'mainnet' | 'testnet';
3
+ export interface StellarNetworkInfo {
4
+ /** The option's label in the wallet's network select. */
5
+ label: string;
6
+ /** What the wallet stores as the selected network's `network`. */
7
+ storedName: string;
8
+ /** The passphrase every transaction on the network is signed for. */
9
+ passphrase: string;
10
+ }
11
+ export declare const STELLAR_NETWORKS: Readonly<Record<StellarNetwork, StellarNetworkInfo>>;
12
+ /** The network a stored `network` object names, or null for one the driver does not know (a custom network). */
13
+ export declare function networkOfStored(stored: unknown): StellarNetwork | null;
14
+ //# sourceMappingURL=networks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"networks.d.ts","sourceRoot":"","sources":["../../src/networks.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,SAAS,CAAC;AAEnD,MAAM,WAAW,kBAAkB;IACjC,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,UAAU,EAAE,MAAM,CAAC;IACnB,qEAAqE;IACrE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAGjF,CAAC;AAEF,gHAAgH;AAChH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAOtE"}
@@ -0,0 +1,16 @@
1
+ export const STELLAR_NETWORKS = {
2
+ mainnet: { label: 'Main Net', storedName: 'PUBLIC', passphrase: 'Public Global Stellar Network ; September 2015' },
3
+ testnet: { label: 'Test Net', storedName: 'TESTNET', passphrase: 'Test SDF Network ; September 2015' },
4
+ };
5
+ /** The network a stored `network` object names, or null for one the driver does not know (a custom network). */
6
+ export function networkOfStored(stored) {
7
+ if (typeof stored !== 'object' || stored === null)
8
+ return null;
9
+ const { network, networkPassphrase } = stored;
10
+ for (const [name, info] of Object.entries(STELLAR_NETWORKS)) {
11
+ if (networkPassphrase === info.passphrase || network === info.storedName)
12
+ return name;
13
+ }
14
+ return null;
15
+ }
16
+ //# sourceMappingURL=networks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"networks.js","sourceRoot":"","sources":["../../src/networks.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,gBAAgB,GAAyD;IACpF,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,gDAAgD,EAAE;IAClH,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,mCAAmC,EAAE;CACvG,CAAC;AAEF,gHAAgH;AAChH,MAAM,UAAU,eAAe,CAAC,MAAe;IAC7C,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/D,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,MAA4D,CAAC;IACpG,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAA2C,EAAE,CAAC;QACtG,IAAI,iBAAiB,KAAK,IAAI,CAAC,UAAU,IAAI,OAAO,KAAK,IAAI,CAAC,UAAU;YAAE,OAAO,IAAI,CAAC;IACxF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,40 @@
1
+ import type { BrowserContext, Page } from '@playwright/test';
2
+ import { type WalletAccount } from '@wallets-e2e/core';
3
+ import { type StellarNetwork } from './networks.js';
4
+ /** The id of the Freighter extension in `context`, whatever other extension is loaded beside it. */
5
+ export declare function freighterExtensionId(context: BrowserContext): Promise<string>;
6
+ /**
7
+ * A page of the extension to work in. Freighter opens its welcome tab by itself on first load, but
8
+ * not reliably before the first driver call, so an open one is reused and one is opened otherwise.
9
+ */
10
+ export declare function extensionPage(context: BrowserContext, extensionId: string): Promise<{
11
+ page: Page;
12
+ opened: boolean;
13
+ }>;
14
+ /** Reads the wallet's own `chrome.storage.local`, from one of its pages. */
15
+ export declare function readStorage(page: Page, keys: readonly string[]): Promise<Record<string, unknown>>;
16
+ export interface ImportOptions {
17
+ /** The wallet's unlock password in this browser profile. */
18
+ password: string;
19
+ /**
20
+ * Whether the wallet may share usage data with its analytics providers. Freighter turns this on
21
+ * by default and it reports the wallet's public keys, so the driver turns it off unless told otherwise.
22
+ */
23
+ shareUsageData?: boolean;
24
+ }
25
+ /**
26
+ * Imports a recovery phrase through the wallet's own onboarding and returns the account it produced.
27
+ *
28
+ * The address is not read off the screen: the wallet shows it shortened. It is read from the
29
+ * wallet's own persisted state (`lastUsedAccount`), which only exists once the import really
30
+ * created an account, so a flow that "completed" without one fails here.
31
+ *
32
+ * Idempotent: a profile that already holds a wallet is left as it is and its account is returned,
33
+ * so a worker-scoped browser can call this at the start of every test.
34
+ */
35
+ export declare function importWallet(context: BrowserContext, seedPhrase: string, options: ImportOptions): Promise<WalletAccount>;
36
+ /** The network the wallet is on, or null for a custom one. */
37
+ export declare function activeNetwork(context: BrowserContext): Promise<StellarNetwork | null>;
38
+ /** Puts the wallet on `network` through its own settings, and proves it from the wallet's stored state. */
39
+ export declare function ensureNetwork(context: BrowserContext, network: StellarNetwork): Promise<void>;
40
+ //# sourceMappingURL=onboarding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onboarding.d.ts","sourceRoot":"","sources":["../../src/onboarding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE3E,OAAO,EAAqC,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAIvF,oGAAoG;AACpG,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAE7E;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,CAK1H;AAED,4EAA4E;AAC5E,wBAAsB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,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