attio 0.0.1-experimental.20250425 → 0.0.1-experimental.20250425.1

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.
package/lib/auth/auth.js CHANGED
@@ -4,7 +4,7 @@ import { randomBytes, createHash } from "crypto";
4
4
  import open from "open";
5
5
  import { APP } from "../env.js";
6
6
  import { findAvailablePort } from "../util/find-available-port.js";
7
- import { keychain } from "./keychain.js";
7
+ import { getKeychain } from "./keychain.js";
8
8
  import { api } from "../api/api.js";
9
9
  import { isErrored, complete, errored } from "@attio/fetchable";
10
10
  import { printFetcherError, printKeychainError } from "../print-errors.js";
@@ -12,7 +12,7 @@ class AuthenticatorImpl {
12
12
  clientId = "f881c6f1-82d7-48a5-a581-649596167845";
13
13
  refreshTimeout = null;
14
14
  async ensureAuthed() {
15
- const existingTokenResult = await keychain.load();
15
+ const existingTokenResult = await getKeychain().load();
16
16
  if (isErrored(existingTokenResult)) {
17
17
  return this.promptToAuthenticate();
18
18
  }
@@ -31,7 +31,7 @@ class AuthenticatorImpl {
31
31
  return this.authenticate();
32
32
  }
33
33
  async authenticate() {
34
- const existingTokenResult = await keychain.load();
34
+ const existingTokenResult = await getKeychain().load();
35
35
  if (isErrored(existingTokenResult)) {
36
36
  return existingTokenResult;
37
37
  }
@@ -108,7 +108,7 @@ class AuthenticatorImpl {
108
108
  token_type: token.token_type,
109
109
  expires_at: Date.now() + token.expires_in * 1000,
110
110
  };
111
- const saveResult = await keychain.save(keychainToken);
111
+ const saveResult = await getKeychain().save(keychainToken);
112
112
  if (isErrored(saveResult)) {
113
113
  return saveResult;
114
114
  }
@@ -141,7 +141,7 @@ class AuthenticatorImpl {
141
141
  token_type: refreshedToken.token_type,
142
142
  expires_at: Date.now() + refreshedToken.expires_in * 1000,
143
143
  };
144
- const saveResult = await keychain.save(keychainToken);
144
+ const saveResult = await getKeychain().save(keychainToken);
145
145
  if (isErrored(saveResult)) {
146
146
  printKeychainError(saveResult.error);
147
147
  return;
@@ -153,7 +153,7 @@ class AuthenticatorImpl {
153
153
  clearTimeout(this.refreshTimeout);
154
154
  this.refreshTimeout = null;
155
155
  }
156
- await keychain.delete();
156
+ await getKeychain().delete();
157
157
  }
158
158
  }
159
159
  export const authenticator = new AuthenticatorImpl();
@@ -99,4 +99,10 @@ class TestKeychain {
99
99
  return complete(undefined);
100
100
  }
101
101
  }
102
- export const keychain = process.env.NODE_ENV === "test" ? new TestKeychain() : new KeytarKeychain();
102
+ let keychain = null;
103
+ export const getKeychain = () => {
104
+ if (keychain === null) {
105
+ keychain = process.env.NODE_ENV === "test" ? new TestKeychain() : new KeytarKeychain();
106
+ }
107
+ return keychain;
108
+ };
@@ -1,9 +1,9 @@
1
1
  import { Command } from "commander";
2
- import { keychain } from "../auth/keychain.js";
2
+ import { getKeychain } from "../auth/keychain.js";
3
3
  import { printKeychainError } from "../print-errors.js";
4
4
  import { isErrored } from "@attio/fetchable";
5
5
  export const logout = new Command("logout").description("Log out from Attio").action(async () => {
6
- const result = await keychain.delete();
6
+ const result = await getKeychain().delete();
7
7
  if (isErrored(result)) {
8
8
  printKeychainError(result.error);
9
9
  process.exit(1);
@@ -1,5 +1,5 @@
1
1
  import { Command } from "commander";
2
- import { keychain } from "../auth/keychain.js";
2
+ import { getKeychain } from "../auth/keychain.js";
3
3
  import { api } from "../api/api.js";
4
4
  import { isErrored } from "@attio/fetchable";
5
5
  import { printFetcherError } from "../print-errors.js";
@@ -7,7 +7,7 @@ export const whoami = new Command()
7
7
  .name("whoami")
8
8
  .description("Identify the current user")
9
9
  .action(async () => {
10
- const tokenResult = await keychain.load();
10
+ const tokenResult = await getKeychain().load();
11
11
  if (isErrored(tokenResult) || tokenResult.value === null) {
12
12
  process.stdout.write("🔒 Not logged in.\n");
13
13
  process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attio",
3
- "version": "0.0.1-experimental.20250425",
3
+ "version": "0.0.1-experimental.20250425.1",
4
4
  "bin": "lib/attio.js",
5
5
  "type": "module",
6
6
  "files": [