Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/picture-chrome-no-keychain-prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astryxdesign/cli': patch
---

[fix] When `astryx experimental export --pictures` takes its pictures with an installed Google Chrome or Chromium, the browser no longer asks the macOS keychain or the Linux password store for access. Before, each browser start could open a keychain dialog.

@dante01yoon
5 changes: 5 additions & 0 deletions packages/cli/foundation/render/picture-chrome.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ const browser = spawn(
'--no-sandbox',
'--hide-scrollbars',
'--remote-debugging-pipe',
// The throwaway profile stores no secret. Without these flags, each
// browser start asks the system keychain (macOS) or password store
// (Linux) for access, and the person sees a dialog.
'--use-mock-keychain',
'--password-store=basic',
// The browser's own network off: a picture asks the network for nothing.
...QUIET_BROWSER_ARGS,
`--user-data-dir=${path.join(os.tmpdir(), 'profile')}`,
Expand Down
55 changes: 55 additions & 0 deletions packages/cli/foundation/render/picture-chrome.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.

import {spawnSync} from 'node:child_process';
import * as fs from 'node:fs';
import * as os from 'node:os';
import * as path from 'node:path';
import {fileURLToPath} from 'node:url';
import {afterEach, describe, expect, it} from 'vitest';

const SCRIPT = fileURLToPath(new URL('./picture-chrome.mjs', import.meta.url));

/** @type {string[]} */
const dirs = [];
afterEach(() => {
for (const d of dirs.splice(0)) fs.rmSync(d, {recursive: true, force: true});
});

/**
* The flags picture-chrome.mjs starts its browser with, read from a stand-in
* browser that writes them down and stops.
*/
function browserFlags() {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-picture-chrome-'));
dirs.push(dir);
const argsFile = path.join(dir, 'args.json');
const fake = path.join(dir, 'chrome');
fs.writeFileSync(
fake,
`#!${process.execPath}\n` +
`require('node:fs').writeFileSync(${JSON.stringify(argsFile)}, JSON.stringify(process.argv.slice(2)));\n`,
{mode: 0o755},
);
const batch = JSON.stringify([
{
html: path.join(dir, 'p.html'),
png: path.join(dir, 'p.png'),
mode: 'light',
},
]);
spawnSync(process.execPath, [SCRIPT, fake, batch], {
env: {...process.env, TMPDIR: dir},
timeout: 20_000,
});
return /** @type {string[]} */ (
JSON.parse(fs.readFileSync(argsFile, 'utf8'))
);
}

describe.skipIf(process.platform === 'win32')("a picture's Chrome", () => {
it('keeps away from the system keychain and password store', () => {
const flags = browserFlags();
expect(flags).toContain('--use-mock-keychain');
expect(flags).toContain('--password-store=basic');
});
});
Loading