@zapier/zapier-sdk-cli 0.42.2 → 0.43.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cli.cjs +1047 -547
  3. package/dist/cli.d.mts +0 -1
  4. package/dist/cli.d.ts +0 -1
  5. package/dist/cli.mjs +1034 -537
  6. package/dist/index.cjs +1037 -538
  7. package/dist/index.d.mts +395 -23
  8. package/dist/index.d.ts +395 -23
  9. package/dist/index.mjs +1027 -531
  10. package/dist/login.cjs +599 -7
  11. package/dist/login.d.mts +144 -1
  12. package/dist/login.d.ts +144 -1
  13. package/dist/login.mjs +565 -1
  14. package/dist/package.json +5 -2
  15. package/dist/src/login/filesystem-cache.d.ts +25 -0
  16. package/dist/src/login/filesystem-cache.js +195 -0
  17. package/dist/src/login/index.d.ts +115 -0
  18. package/dist/src/login/index.js +442 -0
  19. package/dist/src/login/keychain.d.ts +18 -0
  20. package/dist/src/login/keychain.js +74 -0
  21. package/dist/src/login.d.ts +10 -1
  22. package/dist/src/login.js +10 -1
  23. package/dist/src/plugins/add/index.d.ts +250 -11
  24. package/dist/src/plugins/add/index.js +8 -16
  25. package/dist/src/plugins/buildManifest/index.d.ts +116 -9
  26. package/dist/src/plugins/buildManifest/index.js +14 -23
  27. package/dist/src/plugins/bundleCode/index.d.ts +19 -10
  28. package/dist/src/plugins/bundleCode/index.js +7 -17
  29. package/dist/src/plugins/cliOverrides/index.d.ts +12 -10
  30. package/dist/src/plugins/cliOverrides/index.js +16 -20
  31. package/dist/src/plugins/curl/index.d.ts +69 -10
  32. package/dist/src/plugins/curl/index.js +3 -2
  33. package/dist/src/plugins/feedback/index.d.ts +18 -13
  34. package/dist/src/plugins/feedback/index.js +18 -26
  35. package/dist/src/plugins/generateAppTypes/index.d.ts +261 -9
  36. package/dist/src/plugins/generateAppTypes/index.js +17 -45
  37. package/dist/src/plugins/getLoginConfigPath/index.d.ts +12 -10
  38. package/dist/src/plugins/getLoginConfigPath/index.js +9 -19
  39. package/dist/src/plugins/init/index.d.ts +15 -11
  40. package/dist/src/plugins/init/index.js +9 -17
  41. package/dist/src/plugins/login/index.d.ts +18 -13
  42. package/dist/src/plugins/login/index.js +10 -18
  43. package/dist/src/plugins/logout/index.d.ts +12 -11
  44. package/dist/src/plugins/logout/index.js +11 -17
  45. package/dist/src/plugins/mcp/index.d.ts +18 -15
  46. package/dist/src/plugins/mcp/index.js +9 -21
  47. package/dist/src/sdk.js +1 -1
  48. package/dist/src/utils/auth/login.d.ts +1 -1
  49. package/dist/src/utils/auth/login.js +1 -1
  50. package/dist/src/utils/constants.d.ts +1 -1
  51. package/dist/src/utils/constants.js +1 -1
  52. package/dist/src/utils/version-checker.js +1 -1
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/package.json +7 -4
package/dist/login.mjs CHANGED
@@ -1 +1,565 @@
1
- export * from '@zapier/zapier-sdk-cli-login';
1
+ import Conf from 'conf';
2
+ import { mkdirSync, existsSync, writeFileSync } from 'fs';
3
+ import * as jwt from 'jsonwebtoken';
4
+ import { deletePassword, setPassword, getKeyring, getPassword } from 'cross-keychain';
5
+ import { createHash } from 'crypto';
6
+ import { dirname } from 'path';
7
+ import * as lockfile from 'proper-lockfile';
8
+
9
+ // src/login/index.ts
10
+ var SERVICE = "zapier-sdk-cli";
11
+ var ACCOUNT = "login";
12
+ var cachedBackendInfo;
13
+ async function getBackendInfo() {
14
+ if (!cachedBackendInfo) {
15
+ const keyring = await getKeyring();
16
+ cachedBackendInfo = `${keyring.name} (${keyring.id})`;
17
+ }
18
+ return cachedBackendInfo;
19
+ }
20
+ var keychainQueue = Promise.resolve();
21
+ function enqueue(fn) {
22
+ const result = keychainQueue.then(fn, fn);
23
+ keychainQueue = result.then(
24
+ () => {
25
+ },
26
+ () => {
27
+ }
28
+ );
29
+ return result;
30
+ }
31
+ async function getTokensFromKeychain({
32
+ debugLog
33
+ } = {}) {
34
+ return enqueue(async () => {
35
+ const backendInfo = await getBackendInfo();
36
+ debugLog?.(`Keychain read via ${backendInfo}`);
37
+ const startTime = Date.now();
38
+ const raw = await getPassword(SERVICE, ACCOUNT);
39
+ debugLog?.(`Keychain read completed in ${Date.now() - startTime}ms`);
40
+ if (!raw) {
41
+ debugLog?.("Keychain returned no data");
42
+ return void 0;
43
+ }
44
+ let parsed;
45
+ try {
46
+ parsed = JSON.parse(raw);
47
+ } catch {
48
+ debugLog?.("Keychain data is not valid JSON");
49
+ return void 0;
50
+ }
51
+ if (typeof parsed.login_jwt === "string" && typeof parsed.login_refresh_token === "string") {
52
+ return {
53
+ login_jwt: parsed.login_jwt,
54
+ login_refresh_token: parsed.login_refresh_token
55
+ };
56
+ }
57
+ debugLog?.("Keychain data has invalid shape", parsed);
58
+ return void 0;
59
+ });
60
+ }
61
+ async function setTokensInKeychain({
62
+ data,
63
+ debugLog
64
+ }) {
65
+ return enqueue(async () => {
66
+ const backendInfo = await getBackendInfo();
67
+ debugLog?.(`Keychain write via ${backendInfo}`);
68
+ const startTime = Date.now();
69
+ await setPassword(SERVICE, ACCOUNT, JSON.stringify(data));
70
+ debugLog?.(`Keychain write completed in ${Date.now() - startTime}ms`);
71
+ });
72
+ }
73
+ async function clearTokensFromKeychain({
74
+ debugLog
75
+ } = {}) {
76
+ return enqueue(async () => {
77
+ try {
78
+ const backendInfo = await getBackendInfo();
79
+ debugLog?.(`Keychain clear via ${backendInfo}`);
80
+ await deletePassword(SERVICE, ACCOUNT);
81
+ } catch {
82
+ }
83
+ });
84
+ }
85
+ var SERVICE2 = "zapier-sdk-cache";
86
+ var CONFIG_KEY = "cache";
87
+ var LOCK_UPDATE_MS = 5e3;
88
+ var LOCK_STALE_MS = 1e4;
89
+ var LOCK_RETRY_WAIT_MS = 100;
90
+ var LOCK_RETRY_MAX_WAIT_MS = 1e3;
91
+ var LOCK_RETRY_COUNT = 120;
92
+ function keychainAccount(key) {
93
+ return createHash("sha256").update(key).digest("hex");
94
+ }
95
+ function readConfigMap() {
96
+ const cfg = getConfig();
97
+ const stored = cfg.get(CONFIG_KEY);
98
+ if (stored && typeof stored === "object") {
99
+ return stored;
100
+ }
101
+ return {};
102
+ }
103
+ function writeConfigMap(map) {
104
+ getConfig().set(CONFIG_KEY, map);
105
+ }
106
+ function entryIsExpired(entry) {
107
+ return entry.expires_at !== void 0 && entry.expires_at <= Date.now();
108
+ }
109
+ function createCache() {
110
+ return {
111
+ async get(key) {
112
+ const entry = readConfigMap()[key];
113
+ if (!entry) return void 0;
114
+ if (entryIsExpired(entry)) return void 0;
115
+ if (entry.secret) {
116
+ const stored = await enqueue(async () => {
117
+ await getBackendInfo();
118
+ return getPassword(SERVICE2, keychainAccount(key));
119
+ });
120
+ if (!stored) {
121
+ return void 0;
122
+ }
123
+ return { value: stored, expiresAt: entry.expires_at };
124
+ }
125
+ if (entry.value === void 0) return void 0;
126
+ return { value: entry.value, expiresAt: entry.expires_at };
127
+ },
128
+ async set(key, value, options) {
129
+ const secret = options?.secret ?? false;
130
+ const expiresAt = options?.ttl ? Date.now() + options.ttl * 1e3 : void 0;
131
+ if (secret) {
132
+ try {
133
+ await enqueue(async () => {
134
+ await getBackendInfo();
135
+ await setPassword(SERVICE2, keychainAccount(key), value);
136
+ });
137
+ } catch {
138
+ return;
139
+ }
140
+ const map = readConfigMap();
141
+ map[key] = { secret: true, expires_at: expiresAt };
142
+ try {
143
+ writeConfigMap(map);
144
+ } catch {
145
+ }
146
+ } else {
147
+ const map = readConfigMap();
148
+ map[key] = { secret: false, value, expires_at: expiresAt };
149
+ try {
150
+ writeConfigMap(map);
151
+ } catch {
152
+ }
153
+ }
154
+ },
155
+ async delete(key) {
156
+ const map = readConfigMap();
157
+ const entry = map[key];
158
+ if (entry) {
159
+ delete map[key];
160
+ try {
161
+ writeConfigMap(map);
162
+ } catch {
163
+ }
164
+ }
165
+ if (entry?.secret) {
166
+ try {
167
+ await enqueue(async () => {
168
+ await getBackendInfo();
169
+ await deletePassword(SERVICE2, keychainAccount(key));
170
+ });
171
+ } catch {
172
+ }
173
+ }
174
+ },
175
+ async withLock(_key, fn) {
176
+ const cfg = getConfig();
177
+ const lockTarget = `${cfg.path}.cache-lock`;
178
+ try {
179
+ mkdirSync(dirname(lockTarget), { recursive: true });
180
+ if (!existsSync(lockTarget)) {
181
+ writeFileSync(lockTarget, "");
182
+ }
183
+ } catch {
184
+ return fn();
185
+ }
186
+ let release = null;
187
+ try {
188
+ release = await lockfile.lock(lockTarget, {
189
+ stale: LOCK_STALE_MS,
190
+ update: LOCK_UPDATE_MS,
191
+ retries: {
192
+ retries: LOCK_RETRY_COUNT,
193
+ factor: 1.2,
194
+ minTimeout: LOCK_RETRY_WAIT_MS,
195
+ maxTimeout: LOCK_RETRY_MAX_WAIT_MS
196
+ }
197
+ });
198
+ } catch {
199
+ return fn();
200
+ }
201
+ try {
202
+ return await fn();
203
+ } finally {
204
+ try {
205
+ await release();
206
+ } catch {
207
+ }
208
+ }
209
+ }
210
+ };
211
+ }
212
+
213
+ // src/login/index.ts
214
+ var ZapierAuthenticationError = class extends Error {
215
+ constructor(message) {
216
+ super(message);
217
+ this.name = "ZapierAuthenticationError";
218
+ }
219
+ };
220
+ var config = null;
221
+ var DEFAULT_AUTH_CLIENT_ID = "grwWZD5hUWGvb4V8ODBuOtXer3h0DBEZ2HR8aay6";
222
+ var TOKEN_REFRESH_BUFFER_MS = 5 * 60 * 1e3;
223
+ function createDebugLog(enabled) {
224
+ if (!enabled) {
225
+ return () => {
226
+ };
227
+ }
228
+ return (message, data) => {
229
+ if (data === void 0) {
230
+ console.log(`[Zapier SDK CLI Login] ${message}`);
231
+ } else {
232
+ console.log(`[Zapier SDK CLI Login] ${message}`, data);
233
+ }
234
+ };
235
+ }
236
+ function censorHeaderValue(value) {
237
+ if (value.length > 12) {
238
+ return `${value.substring(0, 4)}...${value.substring(value.length - 4)}`;
239
+ }
240
+ return `${value.charAt(0)}...`;
241
+ }
242
+ function getAuthClientId(clientId) {
243
+ return clientId || DEFAULT_AUTH_CLIENT_ID;
244
+ }
245
+ var AUTH_MODE_HEADER = "X-Auth";
246
+ var DEFAULT_AUTH_BASE_URL = "https://zapier.com";
247
+ function getAuthTokenUrl(options) {
248
+ const authBaseUrl = options?.baseUrl || DEFAULT_AUTH_BASE_URL;
249
+ return `${authBaseUrl}/oauth/token/`;
250
+ }
251
+ function getAuthAuthorizeUrl(options) {
252
+ const authBaseUrl = options?.baseUrl || DEFAULT_AUTH_BASE_URL;
253
+ return `${authBaseUrl}/oauth/authorize/`;
254
+ }
255
+ function getPkceLoginConfig(options) {
256
+ return {
257
+ clientId: getAuthClientId(options?.credentials?.clientId),
258
+ tokenUrl: getAuthTokenUrl({ baseUrl: options?.credentials?.baseUrl }),
259
+ authorizeUrl: getAuthAuthorizeUrl({
260
+ baseUrl: options?.credentials?.baseUrl
261
+ })
262
+ };
263
+ }
264
+ var cachedLogin;
265
+ function getConfig() {
266
+ if (!config) {
267
+ config = new Conf({ projectName: "zapier-sdk-cli" });
268
+ if (!config.has("login_storage_mode")) {
269
+ config.set(
270
+ "login_storage_mode",
271
+ existsSync(config.path) ? "config" : "keychain"
272
+ );
273
+ }
274
+ }
275
+ return config;
276
+ }
277
+ function unloadConfig() {
278
+ config = null;
279
+ cachedLogin = void 0;
280
+ }
281
+ async function updateLogin(loginData, options = {}) {
282
+ const debugLog = createDebugLog(options.debug ?? false);
283
+ const storage = options.storage ?? cachedLogin?.storage ?? "keychain";
284
+ const expiresAt = Date.now() + loginData.expires_in * 1e3;
285
+ const cfg = getConfig();
286
+ cfg.set("login_storage_mode", storage);
287
+ if (storage === "keychain") {
288
+ await setTokensInKeychain({
289
+ data: {
290
+ login_jwt: loginData.access_token,
291
+ login_refresh_token: loginData.refresh_token
292
+ },
293
+ debugLog
294
+ });
295
+ cfg.set("login_expires_at", expiresAt);
296
+ cfg.delete("login_jwt");
297
+ cfg.delete("login_refresh_token");
298
+ } else {
299
+ cfg.set("login_jwt", loginData.access_token);
300
+ cfg.set("login_refresh_token", loginData.refresh_token);
301
+ cfg.set("login_expires_at", expiresAt);
302
+ await clearTokensFromKeychain({ debugLog });
303
+ }
304
+ cachedLogin = {
305
+ jwt: loginData.access_token,
306
+ refreshToken: loginData.refresh_token,
307
+ expiresAt,
308
+ storage
309
+ };
310
+ }
311
+ function decodeJwtOrThrow(token) {
312
+ if (typeof token !== "string") {
313
+ throw new Error("Expected JWT to be a string");
314
+ }
315
+ const decodedJwt = jwt.decode(token, { complete: true });
316
+ if (!decodedJwt) {
317
+ throw new Error("Could not decode JWT");
318
+ }
319
+ if (typeof decodedJwt.payload === "string") {
320
+ throw new Error("Did not expect JWT payload to be a string");
321
+ }
322
+ return decodedJwt;
323
+ }
324
+ async function refreshJwt(refreshToken, options = {}) {
325
+ const {
326
+ onEvent,
327
+ fetch = globalThis.fetch,
328
+ credentials,
329
+ debug = false
330
+ } = options;
331
+ const debugLog = createDebugLog(debug);
332
+ const tokenUrl = getAuthTokenUrl({ baseUrl: credentials?.baseUrl });
333
+ const clientId = getAuthClientId(credentials?.clientId);
334
+ const startTime = Date.now();
335
+ try {
336
+ onEvent?.({
337
+ type: "auth_refreshing",
338
+ payload: {
339
+ message: "Refreshing your token...",
340
+ operation: "token_refresh"
341
+ },
342
+ timestamp: Date.now()
343
+ });
344
+ debugLog(`\u2192 POST ${tokenUrl}`, {
345
+ headers: {
346
+ "Content-Type": "application/x-www-form-urlencoded",
347
+ [AUTH_MODE_HEADER]: "no"
348
+ },
349
+ body: {
350
+ client_id: clientId,
351
+ refresh_token: censorHeaderValue(refreshToken),
352
+ grant_type: "refresh_token"
353
+ }
354
+ });
355
+ const response = await fetch(tokenUrl, {
356
+ method: "POST",
357
+ headers: {
358
+ "Content-Type": "application/x-www-form-urlencoded",
359
+ [AUTH_MODE_HEADER]: "no"
360
+ },
361
+ body: new URLSearchParams({
362
+ client_id: clientId,
363
+ refresh_token: refreshToken,
364
+ grant_type: "refresh_token"
365
+ })
366
+ });
367
+ const duration = Date.now() - startTime;
368
+ if (!response.ok) {
369
+ debugLog(`\u2190 ${response.status} ${response.statusText} (${duration}ms)`);
370
+ throw new Error(
371
+ `Token refresh failed: ${response.status} ${response.statusText}`
372
+ );
373
+ }
374
+ debugLog(`\u2190 ${response.status} ${response.statusText} (${duration}ms)`);
375
+ const data = await response.json();
376
+ await updateLogin(data, { debug });
377
+ debugLog(
378
+ `Token refreshed and saved to ${cachedLogin?.storage ?? "keychain"}`
379
+ );
380
+ onEvent?.({
381
+ type: "auth_success",
382
+ payload: {
383
+ message: "Token refreshed successfully",
384
+ operation: "token_refresh"
385
+ },
386
+ timestamp: Date.now()
387
+ });
388
+ return data.access_token;
389
+ } catch (error) {
390
+ const duration = Date.now() - startTime;
391
+ debugLog(`\u2716 Token refresh failed (${duration}ms)`, {
392
+ error: error instanceof Error ? error.message : error
393
+ });
394
+ cachedLogin = void 0;
395
+ const errorMessage = `Token refresh failed: ${error instanceof Error ? error.message : "Unknown error"}`;
396
+ onEvent?.({
397
+ type: "auth_error",
398
+ payload: {
399
+ message: errorMessage,
400
+ error: errorMessage,
401
+ operation: "token_refresh"
402
+ },
403
+ timestamp: Date.now()
404
+ });
405
+ throw error;
406
+ }
407
+ }
408
+ var pendingRefresh = null;
409
+ var pendingResolve = null;
410
+ async function resolveStoredLogin(debugLog) {
411
+ if (cachedLogin) {
412
+ debugLog("Using in-memory cached credentials");
413
+ return cachedLogin;
414
+ }
415
+ if (pendingResolve) {
416
+ debugLog("Waiting for existing keychain read to complete");
417
+ return pendingResolve;
418
+ }
419
+ pendingResolve = resolveStoredLoginFromStorage(debugLog).finally(() => {
420
+ pendingResolve = null;
421
+ });
422
+ return pendingResolve;
423
+ }
424
+ async function resolveStoredLoginFromStorage(debugLog) {
425
+ let cfg;
426
+ try {
427
+ cfg = getConfig();
428
+ } catch (error) {
429
+ debugLog("Failed to load config", {
430
+ error: error instanceof Error ? error.message : error
431
+ });
432
+ return void 0;
433
+ }
434
+ const expiresAt = cfg.get("login_expires_at");
435
+ const configJwt = cfg.get("login_jwt");
436
+ const configRefresh = cfg.get("login_refresh_token");
437
+ if (configJwt && configRefresh && typeof expiresAt === "number") {
438
+ debugLog("Loaded credentials from config (legacy format)");
439
+ cachedLogin = {
440
+ jwt: configJwt,
441
+ refreshToken: configRefresh,
442
+ expiresAt,
443
+ storage: "config"
444
+ };
445
+ return cachedLogin;
446
+ }
447
+ if (typeof expiresAt !== "number") {
448
+ debugLog("No stored login credentials found");
449
+ return void 0;
450
+ }
451
+ const keychainData = await getTokensFromKeychain({ debugLog });
452
+ if (!keychainData) {
453
+ debugLog("No tokens found in keychain");
454
+ return void 0;
455
+ }
456
+ debugLog("Loaded credentials from keychain");
457
+ cachedLogin = {
458
+ jwt: keychainData.login_jwt,
459
+ refreshToken: keychainData.login_refresh_token,
460
+ expiresAt,
461
+ storage: "keychain"
462
+ };
463
+ return cachedLogin;
464
+ }
465
+ async function resolveOrRefreshToken(options = {}) {
466
+ const { debug = false } = options;
467
+ const debugLog = createDebugLog(debug);
468
+ const stored = await resolveStoredLogin(debugLog);
469
+ if (!stored) {
470
+ return void 0;
471
+ }
472
+ const { jwt: storedJwt, refreshToken, expiresAt } = stored;
473
+ if (expiresAt > Date.now() + TOKEN_REFRESH_BUFFER_MS) {
474
+ debugLog("Using cached token (still valid)");
475
+ return storedJwt;
476
+ }
477
+ debugLog("Token expired, refreshing...");
478
+ if (pendingRefresh) {
479
+ debugLog("Waiting for existing refresh to complete");
480
+ return pendingRefresh;
481
+ }
482
+ pendingRefresh = refreshJwt(refreshToken, options).finally(() => {
483
+ pendingRefresh = null;
484
+ });
485
+ return await pendingRefresh;
486
+ }
487
+ async function getToken(options = {}) {
488
+ try {
489
+ return await resolveOrRefreshToken(options);
490
+ } catch (error) {
491
+ const message = error instanceof Error ? error.message : "Token refresh failed";
492
+ throw new ZapierAuthenticationError(
493
+ `${message}
494
+ Please run 'login' to authenticate again.`
495
+ );
496
+ }
497
+ }
498
+ async function getLoggedInUser(options = {}) {
499
+ const jwt2 = await getToken(options).catch(() => void 0);
500
+ if (!jwt2) {
501
+ throw new Error(
502
+ "No valid authentication token available. Please login first."
503
+ );
504
+ }
505
+ let decodedJwt = decodeJwtOrThrow(jwt2);
506
+ if (decodedJwt.payload["sub_type"] == "service") {
507
+ decodedJwt = decodeJwtOrThrow(decodedJwt.payload["njwt"]);
508
+ }
509
+ if (typeof decodedJwt.payload["zap:acc"] !== "string") {
510
+ throw new Error("JWT payload does not contain accountId");
511
+ }
512
+ const accountId = parseInt(decodedJwt.payload["zap:acc"], 10);
513
+ if (isNaN(accountId)) {
514
+ throw new Error("JWT accountId is not a number");
515
+ }
516
+ if (decodedJwt.payload["sub_type"] !== "customuser" || typeof decodedJwt.payload["sub"] !== "string") {
517
+ throw new Error("JWT payload does not contain customUserId");
518
+ }
519
+ const customUserId = parseInt(decodedJwt.payload["sub"], 10);
520
+ if (isNaN(customUserId)) {
521
+ throw new Error("JWT customUserId is not a number");
522
+ }
523
+ const email = decodedJwt.payload["zap:uname"];
524
+ if (typeof email !== "string") {
525
+ throw new Error("JWT payload does not contain email");
526
+ }
527
+ return {
528
+ accountId,
529
+ customUserId,
530
+ email
531
+ };
532
+ }
533
+ function getLoginStorageMode() {
534
+ const cfg = getConfig();
535
+ if (typeof cfg.get("login_jwt") === "string") {
536
+ return "config";
537
+ }
538
+ const explicitMode = cfg.get("login_storage_mode");
539
+ if (explicitMode === "keychain" || explicitMode === "config") {
540
+ return explicitMode;
541
+ }
542
+ return "keychain";
543
+ }
544
+ async function logout(options = {}) {
545
+ const { onEvent } = options;
546
+ const mode = getLoginStorageMode();
547
+ cachedLogin = void 0;
548
+ await clearTokensFromKeychain();
549
+ const cfg = getConfig();
550
+ cfg.set("login_storage_mode", mode);
551
+ cfg.delete("login_expires_at");
552
+ cfg.delete("login_jwt");
553
+ cfg.delete("login_refresh_token");
554
+ onEvent?.({
555
+ type: "auth_logout",
556
+ payload: { message: "Logged out successfully", operation: "logout" },
557
+ timestamp: Date.now()
558
+ });
559
+ }
560
+ function getConfigPath() {
561
+ const cfg = getConfig();
562
+ return cfg.path;
563
+ }
564
+
565
+ export { AUTH_MODE_HEADER, ZapierAuthenticationError, createCache, getAuthAuthorizeUrl, getAuthTokenUrl, getConfig, getConfigPath, getLoggedInUser, getLoginStorageMode, getPkceLoginConfig, getToken, logout, unloadConfig, updateLogin };
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zapier/zapier-sdk-cli",
3
- "version": "0.42.2",
3
+ "version": "0.43.1",
4
4
  "description": "Command line interface for Zapier SDK",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -66,11 +66,12 @@
66
66
  },
67
67
  "dependencies": {
68
68
  "@zapier/zapier-sdk": "workspace:*",
69
- "@zapier/zapier-sdk-cli-login": "workspace:*",
70
69
  "@zapier/zapier-sdk-mcp": "workspace:*",
71
70
  "chalk": "^5.3.0",
72
71
  "cli-table3": "^0.6.5",
73
72
  "commander": "^12.0.0",
73
+ "conf": "^14.0.0",
74
+ "cross-keychain": "^1.1.0",
74
75
  "esbuild": "^0.25.5",
75
76
  "express": "^5.1.0",
76
77
  "handlebars": "^4.7.8",
@@ -81,6 +82,7 @@
81
82
  "ora": "^8.2.0",
82
83
  "package-json": "^10.0.1",
83
84
  "pkce-challenge": "^5.0.0",
85
+ "proper-lockfile": "^4.1.2",
84
86
  "semver": "^7.7.3",
85
87
  "typescript": "^5.8.3",
86
88
  "wrap-ansi": "^10.0.0",
@@ -91,6 +93,7 @@
91
93
  "@types/inquirer": "^9.0.8",
92
94
  "@types/jsonwebtoken": "^9.0.10",
93
95
  "@types/node": "^24.0.1",
96
+ "@types/proper-lockfile": "^4.1.4",
94
97
  "@types/semver": "^7.7.1",
95
98
  "tsup": "^8.5.0",
96
99
  "vitest": "^4.1.4"
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Default filesystem + OS keychain cache adapter for the SDK.
3
+ *
4
+ * Conforms to the generic ZapierCache interface that the SDK defines.
5
+ * Secrets go to the OS keychain via cross-keychain; non-secret values
6
+ * and the identity metadata (expires_at, secret flag) go to the
7
+ * existing zapier-sdk-cli Conf file. A proper-lockfile lock wraps the
8
+ * exchange/persist critical section so N concurrent CLI invocations
9
+ * collapse to a single network exchange.
10
+ *
11
+ * The SDK treats this (like any ZapierCache) as a cache — values may
12
+ * disappear, and the caller must always be able to recreate them.
13
+ */
14
+ export declare function createCache(): {
15
+ get(key: string): Promise<{
16
+ value: string;
17
+ expiresAt?: number;
18
+ } | undefined>;
19
+ set(key: string, value: string, options?: {
20
+ secret?: boolean;
21
+ ttl?: number;
22
+ }): Promise<void>;
23
+ delete(key: string): Promise<void>;
24
+ withLock<T>(key: string, fn: () => Promise<T>): Promise<T>;
25
+ };