-
Notifications
You must be signed in to change notification settings - Fork 305
Expand file tree
/
Copy pathKeyringUnavailableError.ts
More file actions
76 lines (58 loc) · 2.26 KB
/
KeyringUnavailableError.ts
File metadata and controls
76 lines (58 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { CliError } from "@fern-api/task-context";
/**
* Error thrown when the system keyring is unavailable.
*/
export class KeyringUnavailableError extends CliError {
public readonly platform: NodeJS.Platform;
public override readonly cause?: Error;
constructor(platform: NodeJS.Platform, cause?: Error) {
super({
message: getKeyringErrorMessage(platform),
code: CliError.Code.AuthError
});
Object.setPrototypeOf(this, KeyringUnavailableError.prototype);
this.platform = platform;
this.cause = cause;
}
}
/**
* Gets platform-specific error message with instructions.
*/
function getKeyringErrorMessage(platform: NodeJS.Platform): string {
switch (platform) {
case "darwin":
return `Cannot access macOS Keychain
Fern requires the system keyring to securely store access tokens.
To fix this:
1. Open Keychain Access (Applications > Utilities > Keychain Access)
2. Select "login" keychain in the sidebar
3. Right-click and select "Unlock Keychain"
4. Enter your macOS login password
If running in a headless environment, use FERN_TOKEN instead:
export FERN_TOKEN=<your-token>`;
case "linux":
return `Cannot access GNOME Keyring
Fern requires the system keyring to securely store access tokens.
To fix this:
1. Ensure gnome-keyring is installed:
sudo apt install gnome-keyring libsecret-1-0
2. Ensure the keyring daemon is running:
eval $(gnome-keyring-daemon --start --components=secrets)
If running in a headless environment, use FERN_TOKEN instead:
export FERN_TOKEN=<your-token>`;
case "win32":
return `Cannot access Windows Credential Manager
Fern requires the system keyring to securely store access tokens.
To fix this:
1. Open Control Panel > User Accounts > Credential Manager
2. Ensure Windows Credential Manager is functioning
3. Try restarting the Credential Manager service
If running in a headless environment, use FERN_TOKEN instead:
set FERN_TOKEN=<your-token>`;
default:
return `Cannot access system keyring
Fern requires the system keyring to securely store access tokens.
If running in a headless environment, use FERN_TOKEN instead:
export FERN_TOKEN=<your-token>`;
}
}