@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
@@ -0,0 +1,137 @@
1
+ import { resolveExtensionId } from '@wallets-e2e/core';
2
+ import { FREIGHTER_SERVICE_WORKER } from './extension.js';
3
+ import { networkOfStored, STELLAR_NETWORKS } from './networks.js';
4
+ import { ONBOARDING, ROUTES, SETTINGS, STORAGE_KEYS } from './selectors.js';
5
+ import { extensionUrl, phraseWords, STELLAR_ACCOUNT } from './utils.js';
6
+ /** The id of the Freighter extension in `context`, whatever other extension is loaded beside it. */
7
+ export function freighterExtensionId(context) {
8
+ return resolveExtensionId(context, { serviceWorkerPath: FREIGHTER_SERVICE_WORKER });
9
+ }
10
+ /**
11
+ * A page of the extension to work in. Freighter opens its welcome tab by itself on first load, but
12
+ * not reliably before the first driver call, so an open one is reused and one is opened otherwise.
13
+ */
14
+ export async function extensionPage(context, extensionId) {
15
+ const prefix = `chrome-extension://${extensionId}/`;
16
+ const open = context.pages().find((page) => page.url().startsWith(prefix) && !page.url().includes(ROUTES.grantAccess) && !page.url().includes(ROUTES.signTransaction));
17
+ if (open)
18
+ return { page: open, opened: false };
19
+ return { page: await context.newPage(), opened: true };
20
+ }
21
+ /** Reads the wallet's own `chrome.storage.local`, from one of its pages. */
22
+ export async function readStorage(page, keys) {
23
+ return page.evaluate((names) => chrome.storage.local.get(names), [...keys]);
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 async function importWallet(context, seedPhrase, options) {
36
+ const words = phraseWords(seedPhrase);
37
+ const extensionId = await freighterExtensionId(context);
38
+ const { page } = await extensionPage(context, extensionId);
39
+ await page.goto(extensionUrl(extensionId, ROUTES.welcome));
40
+ const existing = await readStorage(page, [STORAGE_KEYS.keyId, STORAGE_KEYS.lastUsedAccount]);
41
+ if (typeof existing[STORAGE_KEYS.keyId] === 'string' && existing[STORAGE_KEYS.keyId] !== '') {
42
+ const address = existing[STORAGE_KEYS.lastUsedAccount];
43
+ if (typeof address === 'string' && STELLAR_ACCOUNT.test(address)) {
44
+ await page.close().catch(() => undefined);
45
+ return { address };
46
+ }
47
+ }
48
+ await page.getByRole('button', { name: ONBOARDING.importWalletButton }).click();
49
+ await page.getByTestId(ONBOARDING.passwordInput).fill(options.password);
50
+ await page.getByTestId(ONBOARDING.confirmPasswordInput).fill(options.password);
51
+ // The checkbox is drawn by a styled sibling that covers the input itself.
52
+ await page.getByTestId(ONBOARDING.termsCheckbox).check({ force: true });
53
+ await page.getByTestId(ONBOARDING.submitPassword).click();
54
+ // The phrase screen defaults to 12 words; a 24-word phrase needs the toggle first.
55
+ await page.locator(ONBOARDING.phraseWord(1)).waitFor({ state: 'visible', timeout: 30_000 });
56
+ if (words.length === 24)
57
+ await page.getByText(ONBOARDING.twentyFourWords, { exact: true }).click();
58
+ // Each word goes into its own masked input; the phrase never appears on screen or in a log.
59
+ for (const [index, word] of words.entries())
60
+ await page.locator(ONBOARDING.phraseWord(index + 1)).fill(word);
61
+ await page.getByRole('button', { name: ONBOARDING.importButton, exact: true }).click();
62
+ const address = await waitForAccount(page);
63
+ if (options.shareUsageData !== true)
64
+ await turnOffUsageDataSharing(page, extensionId);
65
+ await page.close().catch(() => undefined);
66
+ return { address };
67
+ }
68
+ /** Waits for the wallet to persist the imported account and returns it. */
69
+ async function waitForAccount(page, timeoutMs = 60_000) {
70
+ const deadline = Date.now() + timeoutMs;
71
+ while (Date.now() < deadline) {
72
+ const stored = await readStorage(page, [STORAGE_KEYS.lastUsedAccount]).catch(() => ({}));
73
+ const address = stored[STORAGE_KEYS.lastUsedAccount];
74
+ if (typeof address === 'string' && STELLAR_ACCOUNT.test(address))
75
+ return address;
76
+ await page.waitForTimeout(250);
77
+ }
78
+ throw new Error('[wallets/freighter] The wallet did not store an account after the import. ' +
79
+ 'Check that the recovery phrase is a valid BIP-39 phrase of 12 or 24 words.');
80
+ }
81
+ async function turnOffUsageDataSharing(page, extensionId) {
82
+ await page.goto(extensionUrl(extensionId, ROUTES.preferences));
83
+ const sharing = page.locator(SETTINGS.dataSharingCheckbox);
84
+ await sharing.waitFor({ state: 'attached', timeout: 30_000 });
85
+ // The input sits outside the viewport behind its styled switch: click it in the page itself.
86
+ if (await sharing.isChecked())
87
+ await sharing.evaluate((input) => input.click());
88
+ const deadline = Date.now() + 10_000;
89
+ while ((await sharing.isChecked()) && Date.now() < deadline)
90
+ await page.waitForTimeout(100);
91
+ if (await sharing.isChecked())
92
+ throw new Error('[wallets/freighter] Could not turn off usage data sharing in the wallet.');
93
+ }
94
+ /** The network the wallet is on, or null for a custom one. */
95
+ export async function activeNetwork(context) {
96
+ const extensionId = await freighterExtensionId(context);
97
+ const { page, opened } = await extensionPage(context, extensionId);
98
+ if (opened)
99
+ await page.goto(extensionUrl(extensionId, ROUTES.settings));
100
+ try {
101
+ return networkOfStored((await readStorage(page, [STORAGE_KEYS.network]))[STORAGE_KEYS.network]);
102
+ }
103
+ finally {
104
+ if (opened)
105
+ await page.close().catch(() => undefined);
106
+ }
107
+ }
108
+ /** Puts the wallet on `network` through its own settings, and proves it from the wallet's stored state. */
109
+ export async function ensureNetwork(context, network) {
110
+ const info = STELLAR_NETWORKS[network];
111
+ if (!info)
112
+ throw new Error(`[wallets/freighter] Unknown Stellar network "${String(network)}". Use "testnet" or "mainnet".`);
113
+ const extensionId = await freighterExtensionId(context);
114
+ const { page, opened } = await extensionPage(context, extensionId);
115
+ try {
116
+ await page.goto(extensionUrl(extensionId, ROUTES.settings));
117
+ const stored = async () => networkOfStored((await readStorage(page, [STORAGE_KEYS.network]))[STORAGE_KEYS.network]);
118
+ if ((await stored()) === network)
119
+ return;
120
+ await page.getByTestId(SETTINGS.networkLink).click();
121
+ await page.getByTestId(SETTINGS.networkSelect).selectOption({ label: info.label });
122
+ const deadline = Date.now() + 15_000;
123
+ while (Date.now() < deadline) {
124
+ if ((await stored()) === network)
125
+ return;
126
+ await page.waitForTimeout(200);
127
+ }
128
+ throw new Error(`[wallets/freighter] The wallet did not switch to ${info.label}.`);
129
+ }
130
+ finally {
131
+ if (opened)
132
+ await page.close().catch(() => undefined);
133
+ else
134
+ await page.goto(extensionUrl(extensionId, ROUTES.home)).catch(() => undefined);
135
+ }
136
+ }
137
+ //# sourceMappingURL=onboarding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"onboarding.js","sourceRoot":"","sources":["../../src/onboarding.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAsB,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAuB,MAAM,eAAe,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAExE,oGAAoG;AACpG,MAAM,UAAU,oBAAoB,CAAC,OAAuB;IAC1D,OAAO,kBAAkB,CAAC,OAAO,EAAE,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,CAAC,CAAC;AACtF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAuB,EAAE,WAAmB;IAC9E,MAAM,MAAM,GAAG,sBAAsB,WAAW,GAAG,CAAC;IACpD,MAAM,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,IAAI,CAAC,MAAM,MAAM,EAAE,CAAC,KAAK,OAAO;YAAE,OAAO;QACzC,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,CAAC;QACrD,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACnF,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC;QACrC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,MAAM,EAAE,CAAC,KAAK,OAAO;gBAAE,OAAO;YACzC,MAAM,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,oDAAoD,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACrF,CAAC;YAAS,CAAC;QACT,IAAI,MAAM;YAAE,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;;YACjD,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACtF,CAAC;AACH,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { BrowserContext, Page } from '@playwright/test';
2
+ import type { WalletPromptOptions } from '@wallets-e2e/core';
3
+ export type PromptKind = 'connect' | 'transaction';
4
+ export interface PromptOptions extends WalletPromptOptions {
5
+ /** How long to wait for the wallet's prompt after the trigger. Default 60 s. */
6
+ timeoutMs?: number;
7
+ }
8
+ /**
9
+ * The wallet's prompt for `kind`, opened by `trigger`. Freighter raises each prompt in a window of
10
+ * its own, which is a page of this context: it is looked for among the context's pages rather than
11
+ * awaited as one event, so a prompt that opened before the listener was ready is still found.
12
+ */
13
+ export declare function openPrompt(context: BrowserContext, extensionId: string, kind: PromptKind, trigger: () => Promise<void>, timeoutMs?: number): Promise<Page>;
14
+ export declare function confirmPrompt(prompt: Page, kind: PromptKind, options?: PromptOptions): Promise<void>;
15
+ export declare function cancelPrompt(prompt: Page, options?: PromptOptions): Promise<void>;
16
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAW,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAI7D,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,aAAa,CAAC;AAEnD,MAAM,WAAW,aAAc,SAAQ,mBAAmB;IACxD,gFAAgF;IAChF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,cAAc,EACvB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAC5B,SAAS,SAAS,GACjB,OAAO,CAAC,IAAI,CAAC,CAoBf;AAWD,wBAAgB,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAExG;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAErF"}
@@ -0,0 +1,41 @@
1
+ import { PROMPTS } from './selectors.js';
2
+ import { isPromptUrl } from './utils.js';
3
+ /**
4
+ * The wallet's prompt for `kind`, opened by `trigger`. Freighter raises each prompt in a window of
5
+ * its own, which is a page of this context: it is looked for among the context's pages rather than
6
+ * awaited as one event, so a prompt that opened before the listener was ready is still found.
7
+ */
8
+ export async function openPrompt(context, extensionId, kind, trigger, timeoutMs = 60_000) {
9
+ const { route } = PROMPTS[kind];
10
+ const before = new Set(context.pages());
11
+ await trigger();
12
+ const deadline = Date.now() + timeoutMs;
13
+ while (Date.now() < deadline) {
14
+ const prompt = context.pages().find((page) => !before.has(page) && isPromptUrl(page.url(), extensionId, route));
15
+ if (prompt) {
16
+ await prompt.waitForLoadState('domcontentloaded');
17
+ return prompt;
18
+ }
19
+ await new Promise((resolve) => setTimeout(resolve, 150));
20
+ }
21
+ const other = context.pages().filter((page) => !before.has(page)).map((page) => page.url().slice(0, 120)).join(', ') || 'none';
22
+ throw new Error(`[wallets/freighter] The wallet opened no ${kind} prompt within ${timeoutMs} ms. Pages opened since the trigger: ${other}. ` +
23
+ (kind === 'connect'
24
+ ? 'A dapp the wallet already trusts connects without a prompt.'
25
+ : 'A transaction the dapp refused before signing (a failed simulation) never reaches the wallet.'));
26
+ }
27
+ /** Presses `button` on a prompt and waits for the wallet to close it, which is how it says it took the answer. */
28
+ async function answer(prompt, button, options) {
29
+ await button.waitFor({ state: 'visible', timeout: 30_000 });
30
+ await options.beforeAnswer?.(prompt, button);
31
+ const closed = prompt.isClosed() ? Promise.resolve() : prompt.waitForEvent('close', { timeout: 30_000 }).catch(() => undefined);
32
+ await button.click();
33
+ await closed;
34
+ }
35
+ export function confirmPrompt(prompt, kind, options = {}) {
36
+ return answer(prompt, prompt.getByTestId(PROMPTS[kind].confirm), options);
37
+ }
38
+ export function cancelPrompt(prompt, options = {}) {
39
+ return answer(prompt, prompt.getByRole('button', { name: PROMPTS.cancelButton, exact: true }), options);
40
+ }
41
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/prompts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAA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1G,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Every selector and route the driver relies on, read off the real Freighter 5.53.1 release build
3
+ * (named Varial in its own UI), not guessed. When an upstream release moves one of these, this is
4
+ * the only file to change, together with `FREIGHTER_VERSION`.
5
+ */
6
+ export declare const ROUTES: {
7
+ readonly welcome: "#/welcome";
8
+ readonly home: "";
9
+ readonly settings: "#/settings";
10
+ readonly preferences: "#/settings/preferences";
11
+ /** The prompt a dapp's connection request opens, in a window of its own. */
12
+ readonly grantAccess: "#/grant-access";
13
+ /** The prompt a transaction to sign opens, in a window of its own. */
14
+ readonly signTransaction: "#/sign-transaction";
15
+ };
16
+ export declare const ONBOARDING: {
17
+ readonly importWalletButton: "Import wallet";
18
+ readonly passwordInput: "account-creator-password-input";
19
+ readonly confirmPasswordInput: "account-creator-confirm-password-input";
20
+ readonly termsCheckbox: "account-creator-termsOfUse-input";
21
+ readonly submitPassword: "account-creator-submit";
22
+ /** The recovery phrase is one masked input per word, named `MnemonicPhrase-1` … `-12` (or `-24`). */
23
+ readonly phraseWord: (index: number) => string;
24
+ readonly twentyFourWords: "24 word";
25
+ readonly importButton: "Import";
26
+ /** On the home screen once an account exists. */
27
+ readonly accountChip: "account-chip";
28
+ };
29
+ export declare const SETTINGS: {
30
+ readonly networkLink: "settings-network-link";
31
+ readonly networkSelect: "network-settings-select";
32
+ /** "Usage data sharing": on by default, and it reports the wallet's public keys. */
33
+ readonly dataSharingCheckbox: "input[name=\"isDataSharingAllowedValue\"]";
34
+ };
35
+ export declare const PROMPTS: {
36
+ readonly connect: {
37
+ readonly route: "#/grant-access";
38
+ readonly confirm: "grant-access-connect-button";
39
+ };
40
+ readonly transaction: {
41
+ readonly route: "#/sign-transaction";
42
+ readonly confirm: "sign-transaction-sign";
43
+ };
44
+ /** Both prompts carry the same plain "Cancel" button. */
45
+ readonly cancelButton: "Cancel";
46
+ };
47
+ /** What the wallet keeps in `chrome.storage.local`, as far as the driver reads it. */
48
+ export declare const STORAGE_KEYS: {
49
+ /** The `G…` account in use: the independent proof that an import produced the expected account. */
50
+ readonly lastUsedAccount: "lastUsedAccount";
51
+ /** `{ network, networkName, networkPassphrase, … }` of the selected network. */
52
+ readonly network: "network";
53
+ /** Present once a wallet exists in this profile. */
54
+ readonly keyId: "keyId";
55
+ };
56
+ //# sourceMappingURL=selectors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../src/selectors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,MAAM;;;;;IAKjB,4EAA4E;;IAE5E,sEAAsE;;CAE9D,CAAC;AAEX,eAAO,MAAM,UAAU;;;;;;IAMrB,qGAAqG;iCACjF,MAAM;;;IAG1B,iDAAiD;;CAEzC,CAAC;AAEX,eAAO,MAAM,QAAQ;;;IAGnB,oFAAoF;;CAE5E,CAAC;AAEX,eAAO,MAAM,OAAO;;;;;;;;;IAGlB,yDAAyD;;CAEjD,CAAC;AAEX,sFAAsF;AACtF,eAAO,MAAM,YAAY;IACvB,mGAAmG;;IAEnG,gFAAgF;;IAEhF,oDAAoD;;CAE5C,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Every selector and route the driver relies on, read off the real Freighter 5.53.1 release build
3
+ * (named Varial in its own UI), not guessed. When an upstream release moves one of these, this is
4
+ * the only file to change, together with `FREIGHTER_VERSION`.
5
+ */
6
+ export const ROUTES = {
7
+ welcome: '#/welcome',
8
+ home: '',
9
+ settings: '#/settings',
10
+ preferences: '#/settings/preferences',
11
+ /** The prompt a dapp's connection request opens, in a window of its own. */
12
+ grantAccess: '#/grant-access',
13
+ /** The prompt a transaction to sign opens, in a window of its own. */
14
+ signTransaction: '#/sign-transaction',
15
+ };
16
+ export const ONBOARDING = {
17
+ importWalletButton: 'Import wallet',
18
+ passwordInput: 'account-creator-password-input',
19
+ confirmPasswordInput: 'account-creator-confirm-password-input',
20
+ termsCheckbox: 'account-creator-termsOfUse-input',
21
+ submitPassword: 'account-creator-submit',
22
+ /** The recovery phrase is one masked input per word, named `MnemonicPhrase-1` … `-12` (or `-24`). */
23
+ phraseWord: (index) => `input[name="MnemonicPhrase-${index}"]`,
24
+ twentyFourWords: '24 word',
25
+ importButton: 'Import',
26
+ /** On the home screen once an account exists. */
27
+ accountChip: 'account-chip',
28
+ };
29
+ export const SETTINGS = {
30
+ networkLink: 'settings-network-link',
31
+ networkSelect: 'network-settings-select',
32
+ /** "Usage data sharing": on by default, and it reports the wallet's public keys. */
33
+ dataSharingCheckbox: 'input[name="isDataSharingAllowedValue"]',
34
+ };
35
+ export const PROMPTS = {
36
+ connect: { route: ROUTES.grantAccess, confirm: 'grant-access-connect-button' },
37
+ transaction: { route: ROUTES.signTransaction, confirm: 'sign-transaction-sign' },
38
+ /** Both prompts carry the same plain "Cancel" button. */
39
+ cancelButton: 'Cancel',
40
+ };
41
+ /** What the wallet keeps in `chrome.storage.local`, as far as the driver reads it. */
42
+ export const STORAGE_KEYS = {
43
+ /** The `G…` account in use: the independent proof that an import produced the expected account. */
44
+ lastUsedAccount: 'lastUsedAccount',
45
+ /** `{ network, networkName, networkPassphrase, … }` of the selected network. */
46
+ network: 'network',
47
+ /** Present once a wallet exists in this profile. */
48
+ keyId: 'keyId',
49
+ };
50
+ //# sourceMappingURL=selectors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../src/selectors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,OAAO,EAAE,WAAW;IACpB,IAAI,EAAE,EAAE;IACR,QAAQ,EAAE,YAAY;IACtB,WAAW,EAAE,wBAAwB;IACrC,4EAA4E;IAC5E,WAAW,EAAE,gBAAgB;IAC7B,sEAAsE;IACtE,eAAe,EAAE,oBAAoB;CAC7B,CAAC;AAEX,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,kBAAkB,EAAE,eAAe;IACnC,aAAa,EAAE,gCAAgC;IAC/C,oBAAoB,EAAE,wCAAwC;IAC9D,aAAa,EAAE,kCAAkC;IACjD,cAAc,EAAE,wBAAwB;IACxC,qGAAqG;IACrG,UAAU,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,8BAA8B,KAAK,IAAI;IACtE,eAAe,EAAE,SAAS;IAC1B,YAAY,EAAE,QAAQ;IACtB,iDAAiD;IACjD,WAAW,EAAE,cAAc;CACnB,CAAC;AAEX,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,WAAW,EAAE,uBAAuB;IACpC,aAAa,EAAE,yBAAyB;IACxC,oFAAoF;IACpF,mBAAmB,EAAE,yCAAyC;CACtD,CAAC;AAEX,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,EAAE,6BAA6B,EAAE;IAC9E,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,eAAe,EAAE,OAAO,EAAE,uBAAuB,EAAE;IAChF,yDAAyD;IACzD,YAAY,EAAE,QAAQ;CACd,CAAC;AAEX,sFAAsF;AACtF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,mGAAmG;IACnG,eAAe,EAAE,iBAAiB;IAClC,gFAAgF;IAChF,OAAO,EAAE,SAAS;IAClB,oDAAoD;IACpD,KAAK,EAAE,OAAO;CACN,CAAC"}
@@ -0,0 +1,26 @@
1
+ import type { PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, TestType } from '@playwright/test';
2
+ import { type CreateExtensionTestOptions, type ExtensionFixtures, type ExtraExtension } from '@wallets-e2e/core';
3
+ type AnyTestArgs = PlaywrightTestArgs & PlaywrightTestOptions;
4
+ type AnyWorkerArgs = PlaywrightWorkerArgs & PlaywrightWorkerOptions;
5
+ export interface CreateFreighterTestOptions<TBase extends TestType<AnyTestArgs, AnyWorkerArgs> = TestType<AnyTestArgs, AnyWorkerArgs>> extends Omit<CreateExtensionTestOptions<TBase>, 'extensionPath' | 'prepareExtension'> {
6
+ /** An unpacked Freighter build of your own. Defaults to the pinned one this package ships with. */
7
+ extensionPath?: string;
8
+ }
9
+ /**
10
+ * The Playwright `test` for Freighter, with the extension already wired up: the packaged build is
11
+ * located, and downloaded on first use if an install skipped its `postinstall`.
12
+ *
13
+ * Consumers therefore need no extension path, no download script and no `.wallet-extensions`
14
+ * directory of their own — only their own artifact and profile preferences, which this forwards to
15
+ * `createExtensionTest` untouched.
16
+ */
17
+ export declare function createFreighterTest<TArgs extends AnyTestArgs = AnyTestArgs, TWorkerArgs extends AnyWorkerArgs = AnyWorkerArgs>(options?: CreateFreighterTestOptions<TestType<TArgs, TWorkerArgs>>): TestType<TArgs & ExtensionFixtures, TWorkerArgs>;
18
+ /**
19
+ * Freighter as a second wallet beside another one: pass the result as `extraExtensions` of that
20
+ * wallet's test, e.g. `createMetamaskTest({ extraExtensions: [freighterExtraExtension()] })`. A
21
+ * dapp that signs on an EVM chain with MetaMask and on Stellar with Freighter gets both in one
22
+ * browser; `freighterDriver` finds its own extension whatever else is loaded.
23
+ */
24
+ export declare function freighterExtraExtension(extensionPath?: string): ExtraExtension;
25
+ export {};
26
+ //# sourceMappingURL=test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAuB,KAAK,0BAA0B,EAAE,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQtI,KAAK,WAAW,GAAG,kBAAkB,GAAG,qBAAqB,CAAC;AAC9D,KAAK,aAAa,GAAG,oBAAoB,GAAG,uBAAuB,CAAC;AAEpE,MAAM,WAAW,0BAA0B,CACzC,KAAK,SAAS,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,CACzF,SAAQ,IAAI,CAAC,0BAA0B,CAAC,KAAK,CAAC,EAAE,eAAe,GAAG,kBAAkB,CAAC;IACrF,mGAAmG;IACnG,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,SAAS,WAAW,GAAG,WAAW,EACvC,WAAW,SAAS,aAAa,GAAG,aAAa,EAEjD,OAAO,GAAE,0BAA0B,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAM,GACrE,QAAQ,CAAC,KAAK,GAAG,iBAAiB,EAAE,WAAW,CAAC,CAUlD;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,aAAa,GAAE,MAAiC,GAAG,cAAc,CAOxG"}
@@ -0,0 +1,36 @@
1
+ import { createExtensionTest } from '@wallets-e2e/core';
2
+ import { ensureFreighterExtension, freighterExtensionPath, FREIGHTER_PREPARE_COMMAND, FREIGHTER_VERSION, } from './extension.js';
3
+ /**
4
+ * The Playwright `test` for Freighter, with the extension already wired up: the packaged build is
5
+ * located, and downloaded on first use if an install skipped its `postinstall`.
6
+ *
7
+ * Consumers therefore need no extension path, no download script and no `.wallet-extensions`
8
+ * directory of their own — only their own artifact and profile preferences, which this forwards to
9
+ * `createExtensionTest` untouched.
10
+ */
11
+ export function createFreighterTest(options = {}) {
12
+ const extensionPath = options.extensionPath ?? freighterExtensionPath();
13
+ return createExtensionTest({
14
+ profilePrefix: 'wallets-e2e-freighter',
15
+ extensionName: `Freighter ${FREIGHTER_VERSION}`,
16
+ buildCommand: FREIGHTER_PREPARE_COMMAND,
17
+ ...options,
18
+ extensionPath,
19
+ prepareExtension: () => ensureFreighterExtension(extensionPath),
20
+ });
21
+ }
22
+ /**
23
+ * Freighter as a second wallet beside another one: pass the result as `extraExtensions` of that
24
+ * wallet's test, e.g. `createMetamaskTest({ extraExtensions: [freighterExtraExtension()] })`. A
25
+ * dapp that signs on an EVM chain with MetaMask and on Stellar with Freighter gets both in one
26
+ * browser; `freighterDriver` finds its own extension whatever else is loaded.
27
+ */
28
+ export function freighterExtraExtension(extensionPath = freighterExtensionPath()) {
29
+ return {
30
+ extensionPath,
31
+ extensionName: `Freighter ${FREIGHTER_VERSION}`,
32
+ buildCommand: FREIGHTER_PREPARE_COMMAND,
33
+ prepareExtension: () => ensureFreighterExtension(extensionPath),
34
+ };
35
+ }
36
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.js","sourceRoot":"","sources":["../../src/test.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAgF,MAAM,mBAAmB,CAAC;AACtI,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAYxB;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAIjC,UAAoE,EAAE;IAEtE,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,sBAAsB,EAAE,CAAC;IACxE,OAAO,mBAAmB,CAAqB;QAC7C,aAAa,EAAE,uBAAuB;QACtC,aAAa,EAAE,aAAa,iBAAiB,EAAE;QAC/C,YAAY,EAAE,yBAAyB;QACvC,GAAG,OAAO;QACV,aAAa;QACb,gBAAgB,EAAE,GAAG,EAAE,CAAC,wBAAwB,CAAC,aAAa,CAAC;KAChE,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,gBAAwB,sBAAsB,EAAE;IACtF,OAAO;QACL,aAAa;QACb,aAAa,EAAE,aAAa,iBAAiB,EAAE;QAC/C,YAAY,EAAE,yBAAyB;QACvC,gBAAgB,EAAE,GAAG,EAAE,CAAC,wBAAwB,CAAC,aAAa,CAAC;KAChE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ /** The extension's single page; every screen is a hash route of it. */
2
+ export declare const INDEX_PAGE = "index.html";
3
+ /** A Stellar account id: `G` and 55 base32 characters. */
4
+ export declare const STELLAR_ACCOUNT: RegExp;
5
+ /** The URL of one of the extension's screens. */
6
+ export declare function extensionUrl(extensionId: string, route?: string): string;
7
+ /**
8
+ * Whether `url` is the extension's prompt for `route`. A prompt's URL is the route followed by `?`
9
+ * and the request, base64-encoded: `…/index.html#/sign-transaction?eyJ…`.
10
+ */
11
+ export declare function isPromptUrl(url: string, extensionId: string, route: string): boolean;
12
+ /** A recovery phrase as its words; throws on anything but 12 or 24 of them, without echoing the phrase. */
13
+ export declare function phraseWords(seedPhrase: string): string[];
14
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAEA,uEAAuE;AACvE,eAAO,MAAM,UAAU,eAAe,CAAC;AAEvC,0DAA0D;AAC1D,eAAO,MAAM,eAAe,QAAoB,CAAC;AAEjD,iDAAiD;AACjD,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,MAAM,CAEpE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAKpF;AAED,2GAA2G;AAC3G,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAMxD"}
@@ -0,0 +1,29 @@
1
+ // No runtime imports: `node --test` runs this file straight from source.
2
+ /** The extension's single page; every screen is a hash route of it. */
3
+ export const INDEX_PAGE = 'index.html';
4
+ /** A Stellar account id: `G` and 55 base32 characters. */
5
+ export const STELLAR_ACCOUNT = /^G[A-Z2-7]{55}$/;
6
+ /** The URL of one of the extension's screens. */
7
+ export function extensionUrl(extensionId, route = '') {
8
+ return `chrome-extension://${extensionId}/${INDEX_PAGE}${route}`;
9
+ }
10
+ /**
11
+ * Whether `url` is the extension's prompt for `route`. A prompt's URL is the route followed by `?`
12
+ * and the request, base64-encoded: `…/index.html#/sign-transaction?eyJ…`.
13
+ */
14
+ export function isPromptUrl(url, extensionId, route) {
15
+ const prefix = extensionUrl(extensionId, route);
16
+ if (!url.startsWith(prefix))
17
+ return false;
18
+ const rest = url.slice(prefix.length);
19
+ return rest === '' || rest.startsWith('?') || rest.startsWith('/');
20
+ }
21
+ /** A recovery phrase as its words; throws on anything but 12 or 24 of them, without echoing the phrase. */
22
+ export function phraseWords(seedPhrase) {
23
+ const words = seedPhrase.trim().split(/\s+/).filter(Boolean);
24
+ if (words.length !== 12 && words.length !== 24) {
25
+ throw new Error(`[wallets/freighter] The recovery phrase must be 12 or 24 words; got ${words.length}.`);
26
+ }
27
+ return words;
28
+ }
29
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAEzE,uEAAuE;AACvE,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC;AAEvC,0DAA0D;AAC1D,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAEjD,iDAAiD;AACjD,MAAM,UAAU,YAAY,CAAC,WAAmB,EAAE,KAAK,GAAG,EAAE;IAC1D,OAAO,sBAAsB,WAAW,IAAI,UAAU,GAAG,KAAK,EAAE,CAAC;AACnE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,WAAmB,EAAE,KAAa;IACzE,MAAM,MAAM,GAAG,YAAY,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAChD,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1C,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtC,OAAO,IAAI,KAAK,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AACrE,CAAC;AAED,2GAA2G;AAC3G,MAAM,UAAU,WAAW,CAAC,UAAkB;IAC5C,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC7D,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE,IAAI,KAAK,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,uEAAuE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1G,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,74 @@
1
1
  {
2
2
  "name": "@wallets-e2e/freighter",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "WalletDriver adapter for the pinned official Freighter 5.53.1 extension (named Varial since October 2026), for Stellar and Soroban dapps.",
6
+ "keywords": [
7
+ "playwright",
8
+ "stellar",
9
+ "soroban",
10
+ "freighter",
11
+ "varial",
12
+ "wallet",
13
+ "e2e",
14
+ "blockchain",
15
+ "web3",
16
+ "browser-extension"
17
+ ],
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/yehia67/e2e-wallets.git",
22
+ "directory": "wallets/freighter"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/yehia67/e2e-wallets/issues"
26
+ },
27
+ "homepage": "https://github.com/yehia67/e2e-wallets#readme",
28
+ "main": "./lib/src/index.js",
29
+ "types": "./lib/src/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./lib/src/index.d.ts",
33
+ "default": "./lib/src/index.js"
34
+ },
35
+ "./fixtures/wallet.js": {
36
+ "types": "./lib/fixtures/wallet.d.ts",
37
+ "default": "./lib/fixtures/wallet.js"
38
+ },
39
+ "./extension": {
40
+ "types": "./lib/src/extension.d.ts",
41
+ "default": "./lib/src/extension.js"
42
+ }
43
+ },
44
+ "files": [
45
+ "lib",
46
+ "src",
47
+ "!src/**/*.test.ts",
48
+ "fixtures",
49
+ "scripts/extension.mjs",
50
+ "scripts/prepare-extension.mjs"
51
+ ],
52
+ "dependencies": {
53
+ "@wallets-e2e/core": "^0.3.0"
54
+ },
55
+ "peerDependencies": {
56
+ "@playwright/test": "^1.47.0"
57
+ },
58
+ "devDependencies": {
59
+ "@playwright/test": "^1.47.0",
60
+ "@types/chrome": "^0.2.7",
61
+ "@types/node": "^22.7.5",
62
+ "typescript": "^5.6.3"
63
+ },
64
+ "bin": {
65
+ "wallets-e2e-freighter": "./scripts/prepare-extension.mjs"
66
+ },
67
+ "scripts": {
68
+ "build": "tsc -p tsconfig.build.json",
69
+ "typecheck": "tsc --noEmit -p tsconfig.json",
70
+ "test": "node --test \"src/**/*.test.ts\"",
71
+ "build:extension": "node scripts/prepare-extension.mjs",
72
+ "postinstall": "node scripts/prepare-extension.mjs --optional"
73
+ }
6
74
  }