feat(desktop): import browser cookies into a profile (#7255)
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
e01c153c18
commit
39449e53e3
27 files changed
+3913
-183
No files matched your search
@@ -200,6 +200,22 @@ export class MacPasskeySigningConfigurationResolutionError extends Schema.Tagged
|
||||
}
|
||||
}
|
||||
|
||||
export class KeyringNativePackageMissingError extends Schema.TaggedErrorClass<KeyringNativePackageMissingError>()(
|
||||
"KeyringNativePackageMissingError",
|
||||
{
|
||||
packageName: Schema.String,
|
||||
binaryFileName: Schema.String,
|
||||
packageEntryPath: Schema.String,
|
||||
platform: BuildPlatform,
|
||||
arch: BuildArch,
|
||||
cause: Schema.Defect(),
|
||||
},
|
||||
) {
|
||||
override get message(): string {
|
||||
return `Keyring native package is missing: ${this.packageName}`;
|
||||
}
|
||||
}
|
||||
|
||||
export class ClerkPasskeyNativePackageMissingError extends Schema.TaggedErrorClass<ClerkPasskeyNativePackageMissingError>()(
|
||||
"ClerkPasskeyNativePackageMissingError",
|
||||
{
|
||||
@@ -1343,6 +1359,69 @@ export function resolveClerkPasskeyNativeArtifacts(
|
||||
return [];
|
||||
}
|
||||
|
||||
export function resolveKeyringNativeArtifacts(
|
||||
platform: typeof BuildPlatform.Type,
|
||||
arch: typeof BuildArch.Type,
|
||||
): readonly ClerkPasskeyNativeArtifact[] {
|
||||
const architectures = arch === "universal" ? (["arm64", "x64"] as const) : [arch];
|
||||
|
||||
if (platform === "mac") {
|
||||
return architectures.map((architecture) => ({
|
||||
packageName: `@napi-rs/keyring-darwin-${architecture}`,
|
||||
binaryFileName: `keyring.darwin-${architecture}.node`,
|
||||
}));
|
||||
}
|
||||
|
||||
if (platform === "win") {
|
||||
return architectures.map((architecture) => ({
|
||||
packageName: `@napi-rs/keyring-win32-${architecture}-msvc`,
|
||||
binaryFileName: `keyring.win32-${architecture}-msvc.node`,
|
||||
}));
|
||||
}
|
||||
|
||||
return architectures.map((architecture) => ({
|
||||
packageName: `@napi-rs/keyring-linux-${architecture}-gnu`,
|
||||
binaryFileName: `keyring.linux-${architecture}-gnu.node`,
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Same nesting problem as the Clerk passkey binaries: pnpm keeps the platform
|
||||
* package under `@napi-rs/keyring`, electron-builder only retains collected
|
||||
* top-level dependencies, and the generated loader checks for a sibling
|
||||
* `keyring.<platform>.node` before falling back to the package. Staging the
|
||||
* binary beside `index.js` lets that first branch win.
|
||||
*/
|
||||
const stageKeyringNativeBinaries = Effect.fn("stageKeyringNativeBinaries")(function* (
|
||||
stageAppDir: string,
|
||||
platform: typeof BuildPlatform.Type,
|
||||
arch: typeof BuildArch.Type,
|
||||
) {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const packageEntryPath = yield* fs.realPath(
|
||||
path.join(stageAppDir, "node_modules", "@napi-rs", "keyring", "index.js"),
|
||||
);
|
||||
const packageDir = path.dirname(packageEntryPath);
|
||||
const packageRequire = NodeModule.createRequire(packageEntryPath);
|
||||
|
||||
for (const artifact of resolveKeyringNativeArtifacts(platform, arch)) {
|
||||
const sourcePath = yield* Effect.try({
|
||||
try: () => packageRequire.resolve(`${artifact.packageName}/${artifact.binaryFileName}`),
|
||||
catch: (cause) =>
|
||||
new KeyringNativePackageMissingError({
|
||||
packageName: artifact.packageName,
|
||||
binaryFileName: artifact.binaryFileName,
|
||||
packageEntryPath,
|
||||
platform,
|
||||
arch,
|
||||
cause,
|
||||
}),
|
||||
});
|
||||
yield* fs.copyFile(sourcePath, path.join(packageDir, artifact.binaryFileName));
|
||||
}
|
||||
});
|
||||
|
||||
// pnpm nests the architecture package under @clerk/electron-passkeys, while electron-builder only
|
||||
// retains collected top-level dependencies. The SDK loader checks beside index.js first, so stage
|
||||
// the binary there and let electron-builder's native-addon handling unpack it from the ASAR.
|
||||
@@ -3554,6 +3633,7 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
|
||||
{ label: "vp install --prod", verbose: options.verbose },
|
||||
);
|
||||
yield* stageClerkPasskeyNativeBinaries(stageAppDir, options.platform, options.arch);
|
||||
yield* stageKeyringNativeBinaries(stageAppDir, options.platform, options.arch);
|
||||
|
||||
// WSL is Windows-only, so only the Windows artifact carries the server
|
||||
// sidecar (which embeds the Linux node-pty prebuild); other platforms
|
||||
|
||||
Reference in new issue
Block a user