@zapier/zapier-sdk-cli 0.61.3 → 0.63.0
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/CHANGELOG.md +31 -0
- package/README.md +67 -65
- package/dist/cli.cjs +366 -50
- package/dist/cli.mjs +368 -52
- package/dist/experimental.cjs +357 -38
- package/dist/experimental.d.mts +1 -1
- package/dist/experimental.d.ts +1 -1
- package/dist/experimental.mjs +359 -40
- package/dist/{extensions-DggdwXJF.d.mts → extensions-N27h0wrp.d.mts} +1 -0
- package/dist/{extensions-DggdwXJF.d.ts → extensions-N27h0wrp.d.ts} +1 -0
- package/dist/index.cjs +361 -40
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +363 -42
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as jwt from 'jsonwebtoken';
|
|
2
|
-
import { deletePassword,
|
|
2
|
+
import { deletePassword, getKeyring, setPassword, getPassword } from 'cross-keychain';
|
|
3
3
|
import Conf from 'conf';
|
|
4
4
|
import * as fs from 'fs';
|
|
5
5
|
import { promises, createWriteStream, existsSync, readdirSync, rmSync, mkdirSync, writeFileSync, copyFileSync, readFileSync } from 'fs';
|
|
@@ -7,7 +7,7 @@ import crypto, { createHash } from 'crypto';
|
|
|
7
7
|
import * as path from 'path';
|
|
8
8
|
import { resolve, join, dirname, basename, relative, extname } from 'path';
|
|
9
9
|
import * as lockfile from 'proper-lockfile';
|
|
10
|
-
import { definePlugin, createPluginMethod, OutputPropertySchema, ZapierBundleError, DEFAULT_CONFIG_PATH, ZapierValidationError, ZapierUnknownError, ZapierReleaseTriggerMessageSignal, injectCliLogin,
|
|
10
|
+
import { definePlugin, createPluginMethod, OutputPropertySchema, ZapierBundleError, DEFAULT_CONFIG_PATH, ZapierValidationError, ZapierUnknownError, ZapierReleaseTriggerMessageSignal, injectCliLogin, isPermanentHttpError, invalidateCachedToken, batch, toSnakeCase, ZapierAbortDrainSignal, getOrCreateApiClient, isCredentialsObject, ZapierAuthenticationError, ZapierError, buildApplicationLifecycleEvent, AuthMechanism, createZapierSdkStack, createSdk, defineLegacyMerge, zapierSdkPlugin, addPlugin, getOsInfo, getPlatformVersions, getAgent, getTtyContext, getCiPlatform, isCi, getReleaseId, getCurrentTimestamp, generateEventId, DEPRECATION_NOTICE_EVENT } from '@zapier/zapier-sdk';
|
|
11
11
|
import { z } from 'zod';
|
|
12
12
|
import { hostname } from 'os';
|
|
13
13
|
import inquirer from 'inquirer';
|
|
@@ -954,6 +954,39 @@ async function resolveCredentialsBaseUrl(context) {
|
|
|
954
954
|
return getBaseUrlFromResolvedCredentials(resolvedCredentials) ?? getBaseUrlFromOptionsCredentials(context.options?.credentials) ?? context.options?.baseUrl;
|
|
955
955
|
}
|
|
956
956
|
|
|
957
|
+
// src/utils/cli-argument-sanitizer.ts
|
|
958
|
+
var SENSITIVE_FLAGS = [
|
|
959
|
+
"--credentials",
|
|
960
|
+
"--credentials-client-secret",
|
|
961
|
+
"--credentials-client-id",
|
|
962
|
+
"--credentials-base-url",
|
|
963
|
+
"--callback-url",
|
|
964
|
+
"--user",
|
|
965
|
+
"--header",
|
|
966
|
+
"-H",
|
|
967
|
+
"-u"
|
|
968
|
+
];
|
|
969
|
+
function sanitizeCliArguments(args) {
|
|
970
|
+
const sanitized = [];
|
|
971
|
+
let skipNext = false;
|
|
972
|
+
for (const arg of args) {
|
|
973
|
+
if (skipNext) {
|
|
974
|
+
skipNext = false;
|
|
975
|
+
sanitized.push("[REDACTED]");
|
|
976
|
+
continue;
|
|
977
|
+
}
|
|
978
|
+
if (SENSITIVE_FLAGS.some((flag) => arg.startsWith(flag + "="))) {
|
|
979
|
+
sanitized.push(arg.split("=")[0] + "=[REDACTED]");
|
|
980
|
+
} else if (SENSITIVE_FLAGS.includes(arg)) {
|
|
981
|
+
sanitized.push(arg);
|
|
982
|
+
skipNext = true;
|
|
983
|
+
} else {
|
|
984
|
+
sanitized.push(arg);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
return sanitized;
|
|
988
|
+
}
|
|
989
|
+
|
|
957
990
|
// src/utils/non-interactive.ts
|
|
958
991
|
function resolveNonInteractive(options) {
|
|
959
992
|
return options.nonInteractive === true || options.skipPrompts === true || !process.stdin.isTTY || !process.stdout.isTTY;
|
|
@@ -1273,6 +1306,14 @@ var client_default = api;
|
|
|
1273
1306
|
|
|
1274
1307
|
// src/utils/auth/oauth-transaction.ts
|
|
1275
1308
|
var OAUTH_LOOPBACK_HOST = "localhost";
|
|
1309
|
+
var OauthTransactionSchema = z.object({
|
|
1310
|
+
browserAuthUrl: z.string(),
|
|
1311
|
+
clientId: z.string(),
|
|
1312
|
+
codeVerifier: z.string(),
|
|
1313
|
+
redirectUri: z.string(),
|
|
1314
|
+
state: z.string(),
|
|
1315
|
+
tokenUrl: z.string()
|
|
1316
|
+
});
|
|
1276
1317
|
function buildBrowserAuthUrl({
|
|
1277
1318
|
authorizeUrl,
|
|
1278
1319
|
entryPoint = "login"
|
|
@@ -1361,8 +1402,51 @@ async function exchangeOauthCode({
|
|
|
1361
1402
|
expiresIn: data.expires_in
|
|
1362
1403
|
};
|
|
1363
1404
|
}
|
|
1405
|
+
var PENDING_OAUTH_TRANSACTION_KEY = "pending_oauth_transaction";
|
|
1406
|
+
var PendingOauthTransactionSchema = z.object({
|
|
1407
|
+
version: z.literal(1),
|
|
1408
|
+
entryPoint: z.enum(["login", "signup"]),
|
|
1409
|
+
expiresAt: z.number(),
|
|
1410
|
+
credentialsBaseUrl: z.string().optional(),
|
|
1411
|
+
credentialName: z.string().optional(),
|
|
1412
|
+
useApprovals: z.boolean(),
|
|
1413
|
+
headless: z.boolean().default(false),
|
|
1414
|
+
transaction: OauthTransactionSchema
|
|
1415
|
+
});
|
|
1416
|
+
function savePendingOauthTransaction({
|
|
1417
|
+
entryPoint,
|
|
1418
|
+
transaction,
|
|
1419
|
+
expiresAt,
|
|
1420
|
+
credentialsBaseUrl,
|
|
1421
|
+
credentialName,
|
|
1422
|
+
useApprovals,
|
|
1423
|
+
headless
|
|
1424
|
+
}) {
|
|
1425
|
+
const pendingTransaction = {
|
|
1426
|
+
version: 1,
|
|
1427
|
+
entryPoint,
|
|
1428
|
+
expiresAt,
|
|
1429
|
+
useApprovals,
|
|
1430
|
+
headless,
|
|
1431
|
+
transaction,
|
|
1432
|
+
...credentialsBaseUrl !== void 0 && { credentialsBaseUrl },
|
|
1433
|
+
...credentialName !== void 0 && { credentialName }
|
|
1434
|
+
};
|
|
1435
|
+
getConfig().set(PENDING_OAUTH_TRANSACTION_KEY, pendingTransaction);
|
|
1436
|
+
return pendingTransaction;
|
|
1437
|
+
}
|
|
1438
|
+
function getPendingOauthTransaction() {
|
|
1439
|
+
const result = PendingOauthTransactionSchema.safeParse(
|
|
1440
|
+
getConfig().get(PENDING_OAUTH_TRANSACTION_KEY)
|
|
1441
|
+
);
|
|
1442
|
+
return result.success ? result.data : void 0;
|
|
1443
|
+
}
|
|
1444
|
+
function clearPendingOauthTransaction() {
|
|
1445
|
+
getConfig().delete(PENDING_OAUTH_TRANSACTION_KEY);
|
|
1446
|
+
}
|
|
1364
1447
|
|
|
1365
1448
|
// src/utils/auth/oauth-flow.ts
|
|
1449
|
+
var PENDING_OAUTH_RECOVERY_MESSAGE = "Start a new non-interactive login or signup flow to generate a fresh URL.";
|
|
1366
1450
|
var LOGIN_OAUTH_COPY = {
|
|
1367
1451
|
flowName: "Login",
|
|
1368
1452
|
action: "log in",
|
|
@@ -1418,6 +1502,95 @@ async function runSignupOauthFlow(options) {
|
|
|
1418
1502
|
copy: SIGNUP_OAUTH_COPY
|
|
1419
1503
|
});
|
|
1420
1504
|
}
|
|
1505
|
+
async function startPendingOauthFlow({
|
|
1506
|
+
timeoutMs = LOGIN_TIMEOUT_MS,
|
|
1507
|
+
pkceCredentials,
|
|
1508
|
+
baseUrl,
|
|
1509
|
+
entryPoint,
|
|
1510
|
+
credentialName,
|
|
1511
|
+
useApprovals,
|
|
1512
|
+
headless
|
|
1513
|
+
}) {
|
|
1514
|
+
const copy = entryPoint === "signup" ? SIGNUP_OAUTH_COPY : LOGIN_OAUTH_COPY;
|
|
1515
|
+
const port = LOGIN_PORTS[0];
|
|
1516
|
+
const transaction = await prepareOauthTransaction({
|
|
1517
|
+
pkceCredentials,
|
|
1518
|
+
baseUrl,
|
|
1519
|
+
redirectUri: `http://${OAUTH_LOOPBACK_HOST}:${port}/oauth`,
|
|
1520
|
+
entryPoint
|
|
1521
|
+
});
|
|
1522
|
+
const pending = savePendingOauthTransaction({
|
|
1523
|
+
entryPoint,
|
|
1524
|
+
transaction,
|
|
1525
|
+
expiresAt: Date.now() + timeoutMs,
|
|
1526
|
+
credentialsBaseUrl: baseUrl,
|
|
1527
|
+
credentialName,
|
|
1528
|
+
useApprovals,
|
|
1529
|
+
headless
|
|
1530
|
+
});
|
|
1531
|
+
process.stderr.write(
|
|
1532
|
+
`Open this ${copy.urlLabel} in a browser to continue:
|
|
1533
|
+
`
|
|
1534
|
+
);
|
|
1535
|
+
console.log(transaction.browserAuthUrl);
|
|
1536
|
+
if (!headless) {
|
|
1537
|
+
process.stderr.write(`Opening your browser to ${entryPoint}.
|
|
1538
|
+
`);
|
|
1539
|
+
try {
|
|
1540
|
+
await open(transaction.browserAuthUrl);
|
|
1541
|
+
} catch (error) {
|
|
1542
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
1543
|
+
process.stderr.write(
|
|
1544
|
+
`Browser did not open automatically to ${entryPoint}: ${reason}
|
|
1545
|
+
`
|
|
1546
|
+
);
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
process.stderr.write(
|
|
1550
|
+
`After authorizing, finish with \`zapier-sdk ${entryPoint} --callback-url <final-url>\`.
|
|
1551
|
+
`
|
|
1552
|
+
);
|
|
1553
|
+
return pending;
|
|
1554
|
+
}
|
|
1555
|
+
function getPendingOauthFlow({
|
|
1556
|
+
entryPoint
|
|
1557
|
+
}) {
|
|
1558
|
+
const pending = getPendingOauthTransaction();
|
|
1559
|
+
if (!pending) {
|
|
1560
|
+
throw new ZapierCliValidationError(
|
|
1561
|
+
`No pending ${entryPoint} OAuth flow found. ${PENDING_OAUTH_RECOVERY_MESSAGE}`
|
|
1562
|
+
);
|
|
1563
|
+
}
|
|
1564
|
+
if (Date.now() > pending.expiresAt) {
|
|
1565
|
+
clearPendingOauthTransaction();
|
|
1566
|
+
throw new ZapierCliValidationError(
|
|
1567
|
+
`Pending ${pending.entryPoint} OAuth flow has expired. ${PENDING_OAUTH_RECOVERY_MESSAGE}`
|
|
1568
|
+
);
|
|
1569
|
+
}
|
|
1570
|
+
if (pending.entryPoint !== entryPoint) {
|
|
1571
|
+
throw new ZapierCliValidationError(
|
|
1572
|
+
`Pending OAuth flow is for ${pending.entryPoint}, not ${entryPoint}. ${PENDING_OAUTH_RECOVERY_MESSAGE}`
|
|
1573
|
+
);
|
|
1574
|
+
}
|
|
1575
|
+
return pending;
|
|
1576
|
+
}
|
|
1577
|
+
async function resumePendingOauthFlow({
|
|
1578
|
+
pending,
|
|
1579
|
+
callbackUrl,
|
|
1580
|
+
onProgress
|
|
1581
|
+
}) {
|
|
1582
|
+
const code = getCallbackCode({
|
|
1583
|
+
callbackUrl,
|
|
1584
|
+
transaction: pending.transaction
|
|
1585
|
+
});
|
|
1586
|
+
onProgress?.({ type: "callback_accepted" });
|
|
1587
|
+
process.stderr.write("Exchanging authorization code for tokens...\n");
|
|
1588
|
+
onProgress?.({ type: "token_exchange_started" });
|
|
1589
|
+
const tokens = await exchangeOauthCode({ ...pending.transaction, code });
|
|
1590
|
+
clearPendingOauthTransaction();
|
|
1591
|
+
onProgress?.({ type: "token_exchange_completed" });
|
|
1592
|
+
return tokens;
|
|
1593
|
+
}
|
|
1421
1594
|
function runOauthFlowForEntryPoint({
|
|
1422
1595
|
options,
|
|
1423
1596
|
entryPoint,
|
|
@@ -1953,12 +2126,19 @@ async function saveClientCredentials({
|
|
|
1953
2126
|
function emitAccountAuthSuccess({
|
|
1954
2127
|
sdk,
|
|
1955
2128
|
profile,
|
|
1956
|
-
clientId
|
|
2129
|
+
clientId,
|
|
2130
|
+
isNonInteractive,
|
|
2131
|
+
isHeadless
|
|
1957
2132
|
}) {
|
|
1958
2133
|
sdk.context.eventEmission.emit(
|
|
1959
2134
|
"platform.sdk.ApplicationLifecycleEvent",
|
|
1960
2135
|
buildApplicationLifecycleEvent(
|
|
1961
|
-
{
|
|
2136
|
+
{
|
|
2137
|
+
lifecycle_event_type: "login_success",
|
|
2138
|
+
used_non_interactive_mode: isNonInteractive,
|
|
2139
|
+
is_headless: isHeadless,
|
|
2140
|
+
process_argv: sanitizeCliArguments(process.argv.slice(2))
|
|
2141
|
+
},
|
|
1962
2142
|
{
|
|
1963
2143
|
customuser_id: profile.user_id,
|
|
1964
2144
|
account_id: profile.roles[0]?.account_id ?? null,
|
|
@@ -1969,11 +2149,18 @@ function emitAccountAuthSuccess({
|
|
|
1969
2149
|
);
|
|
1970
2150
|
}
|
|
1971
2151
|
function emitSignupSuccess({
|
|
1972
|
-
sdk
|
|
2152
|
+
sdk,
|
|
2153
|
+
isNonInteractive,
|
|
2154
|
+
isHeadless
|
|
1973
2155
|
}) {
|
|
1974
2156
|
sdk.context.eventEmission.emit(
|
|
1975
2157
|
"platform.sdk.ApplicationLifecycleEvent",
|
|
1976
|
-
buildApplicationLifecycleEvent({
|
|
2158
|
+
buildApplicationLifecycleEvent({
|
|
2159
|
+
lifecycle_event_type: "signup_success",
|
|
2160
|
+
used_non_interactive_mode: isNonInteractive,
|
|
2161
|
+
is_headless: isHeadless,
|
|
2162
|
+
process_argv: sanitizeCliArguments(process.argv.slice(2))
|
|
2163
|
+
})
|
|
1977
2164
|
);
|
|
1978
2165
|
}
|
|
1979
2166
|
async function runOauthWithRedaction(runOauth) {
|
|
@@ -2004,7 +2191,11 @@ async function runOauthForEntryPoint({
|
|
|
2004
2191
|
recoveryMessage: headless ? HEADLESS_SIGNUP_RECOVERY_MESSAGE : SIGNUP_RECOVERY_MESSAGE,
|
|
2005
2192
|
onProgress: (event) => {
|
|
2006
2193
|
if (event.type === "callback_accepted") {
|
|
2007
|
-
emitSignupSuccess({
|
|
2194
|
+
emitSignupSuccess({
|
|
2195
|
+
sdk,
|
|
2196
|
+
isNonInteractive: false,
|
|
2197
|
+
isHeadless: headless === true
|
|
2198
|
+
});
|
|
2008
2199
|
}
|
|
2009
2200
|
}
|
|
2010
2201
|
})
|
|
@@ -2021,11 +2212,124 @@ async function runOauthForEntryPoint({
|
|
|
2021
2212
|
})
|
|
2022
2213
|
);
|
|
2023
2214
|
}
|
|
2215
|
+
async function provisionAccountCredentials({
|
|
2216
|
+
sdk,
|
|
2217
|
+
entryPoint,
|
|
2218
|
+
accessToken,
|
|
2219
|
+
credentialsBaseUrl,
|
|
2220
|
+
credentialName,
|
|
2221
|
+
interactive,
|
|
2222
|
+
useApprovals,
|
|
2223
|
+
isNonInteractive,
|
|
2224
|
+
isHeadless
|
|
2225
|
+
}) {
|
|
2226
|
+
const scopedApi = getOrCreateApiClient({
|
|
2227
|
+
credentials: accessToken,
|
|
2228
|
+
baseUrl: credentialsBaseUrl,
|
|
2229
|
+
callerPackage: sdk.context.options?.callerPackage
|
|
2230
|
+
});
|
|
2231
|
+
const profile = await getProfile(scopedApi);
|
|
2232
|
+
process.stderr.write(`${getProfileMessage(entryPoint, profile.email)}
|
|
2233
|
+
`);
|
|
2234
|
+
process.stderr.write(
|
|
2235
|
+
"\nGenerating credentials so this machine can make authenticated requests on your behalf.\n"
|
|
2236
|
+
);
|
|
2237
|
+
const resolvedCredentialName = credentialName ?? await resolveCredentialName({
|
|
2238
|
+
email: profile.email,
|
|
2239
|
+
interactive,
|
|
2240
|
+
baseUrl: credentialsBaseUrl,
|
|
2241
|
+
entryPoint
|
|
2242
|
+
});
|
|
2243
|
+
const { clientId } = await saveClientCredentials({
|
|
2244
|
+
api: scopedApi,
|
|
2245
|
+
name: resolvedCredentialName,
|
|
2246
|
+
credentialsBaseUrl,
|
|
2247
|
+
useApprovals,
|
|
2248
|
+
cleanupLogPrefix: entryPoint
|
|
2249
|
+
});
|
|
2250
|
+
process.stderr.write(
|
|
2251
|
+
`\u2705 Credentials "${resolvedCredentialName}" created and set as default. You are ready to use the Zapier SDK.
|
|
2252
|
+
`
|
|
2253
|
+
);
|
|
2254
|
+
if (useApprovals) {
|
|
2255
|
+
process.stderr.write("\u{1F510} Approvals are enabled for these credentials.\n");
|
|
2256
|
+
}
|
|
2257
|
+
emitAccountAuthSuccess({
|
|
2258
|
+
sdk,
|
|
2259
|
+
profile,
|
|
2260
|
+
clientId,
|
|
2261
|
+
isNonInteractive,
|
|
2262
|
+
isHeadless
|
|
2263
|
+
});
|
|
2264
|
+
}
|
|
2024
2265
|
async function runAccountAuth({
|
|
2025
2266
|
sdk,
|
|
2026
2267
|
options,
|
|
2027
2268
|
entryPoint
|
|
2028
2269
|
}) {
|
|
2270
|
+
if (options.callbackUrl !== void 0) {
|
|
2271
|
+
const { callbackUrl } = options;
|
|
2272
|
+
const pending = getPendingOauthFlow({ entryPoint });
|
|
2273
|
+
const finishName = options.name !== void 0 ? validateCredentialsName(options.name) : void 0;
|
|
2274
|
+
if (finishName !== void 0 && finishName !== pending.credentialName) {
|
|
2275
|
+
throw new ZapierCliValidationError(
|
|
2276
|
+
"Cannot change --name while completing a pending OAuth flow. Start a new non-interactive login with the desired --name."
|
|
2277
|
+
);
|
|
2278
|
+
}
|
|
2279
|
+
if (options.useApprovals === true && !pending.useApprovals) {
|
|
2280
|
+
throw new ZapierCliValidationError(
|
|
2281
|
+
"Cannot add --use-approvals while completing a pending OAuth flow. Start a new non-interactive flow with --use-approvals."
|
|
2282
|
+
);
|
|
2283
|
+
}
|
|
2284
|
+
if (pending.credentialName !== void 0) {
|
|
2285
|
+
const activeCredentials = getActiveCredentials({
|
|
2286
|
+
baseUrl: pending.credentialsBaseUrl
|
|
2287
|
+
});
|
|
2288
|
+
if (activeCredentials?.name !== pending.credentialName && credentialNameExists({
|
|
2289
|
+
name: pending.credentialName,
|
|
2290
|
+
baseUrl: pending.credentialsBaseUrl
|
|
2291
|
+
})) {
|
|
2292
|
+
throw new ZapierCliValidationError(
|
|
2293
|
+
`A credential named "${pending.credentialName}" already exists. Choose a different --name.`
|
|
2294
|
+
);
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
if (!await clearExistingAuthState({
|
|
2298
|
+
sdk,
|
|
2299
|
+
baseUrl: pending.credentialsBaseUrl,
|
|
2300
|
+
interactive: false,
|
|
2301
|
+
entryPoint
|
|
2302
|
+
})) {
|
|
2303
|
+
return;
|
|
2304
|
+
}
|
|
2305
|
+
const { accessToken: accessToken2 } = await runOauthWithRedaction(async () => {
|
|
2306
|
+
return resumePendingOauthFlow({
|
|
2307
|
+
callbackUrl,
|
|
2308
|
+
pending,
|
|
2309
|
+
onProgress: (event) => {
|
|
2310
|
+
if (entryPoint === "signup" && event.type === "callback_accepted") {
|
|
2311
|
+
emitSignupSuccess({
|
|
2312
|
+
sdk,
|
|
2313
|
+
isNonInteractive: true,
|
|
2314
|
+
isHeadless: pending.headless
|
|
2315
|
+
});
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
2318
|
+
});
|
|
2319
|
+
});
|
|
2320
|
+
await provisionAccountCredentials({
|
|
2321
|
+
sdk,
|
|
2322
|
+
entryPoint,
|
|
2323
|
+
accessToken: accessToken2,
|
|
2324
|
+
credentialsBaseUrl: pending.credentialsBaseUrl,
|
|
2325
|
+
credentialName: pending.credentialName,
|
|
2326
|
+
interactive: false,
|
|
2327
|
+
useApprovals: pending.useApprovals,
|
|
2328
|
+
isNonInteractive: true,
|
|
2329
|
+
isHeadless: pending.headless
|
|
2330
|
+
});
|
|
2331
|
+
return;
|
|
2332
|
+
}
|
|
2029
2333
|
const timeoutSeconds = parseTimeoutSeconds(options.timeout);
|
|
2030
2334
|
const interactive = !resolveNonInteractive(options);
|
|
2031
2335
|
const resolvedCredentials = await sdk.context.resolveCredentials();
|
|
@@ -2054,6 +2358,19 @@ async function runAccountAuth({
|
|
|
2054
2358
|
})) {
|
|
2055
2359
|
return;
|
|
2056
2360
|
}
|
|
2361
|
+
const useApprovals = options.useApprovals === true;
|
|
2362
|
+
if (!interactive) {
|
|
2363
|
+
await startPendingOauthFlow({
|
|
2364
|
+
entryPoint,
|
|
2365
|
+
timeoutMs: timeoutSeconds * 1e3,
|
|
2366
|
+
pkceCredentials,
|
|
2367
|
+
baseUrl: credentialsBaseUrl,
|
|
2368
|
+
credentialName: providedName,
|
|
2369
|
+
useApprovals,
|
|
2370
|
+
headless
|
|
2371
|
+
});
|
|
2372
|
+
return;
|
|
2373
|
+
}
|
|
2057
2374
|
const { accessToken } = await runOauthForEntryPoint({
|
|
2058
2375
|
sdk,
|
|
2059
2376
|
entryPoint,
|
|
@@ -2063,39 +2380,17 @@ async function runAccountAuth({
|
|
|
2063
2380
|
headless,
|
|
2064
2381
|
interactive
|
|
2065
2382
|
});
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
});
|
|
2071
|
-
const profile = await getProfile(scopedApi);
|
|
2072
|
-
process.stderr.write(`${getProfileMessage(entryPoint, profile.email)}
|
|
2073
|
-
`);
|
|
2074
|
-
process.stderr.write(
|
|
2075
|
-
"\nGenerating credentials so this machine can make authenticated requests on your behalf.\n"
|
|
2076
|
-
);
|
|
2077
|
-
const credentialName = providedName ?? await resolveCredentialName({
|
|
2078
|
-
email: profile.email,
|
|
2079
|
-
interactive,
|
|
2080
|
-
baseUrl: credentialsBaseUrl,
|
|
2081
|
-
entryPoint
|
|
2082
|
-
});
|
|
2083
|
-
const useApprovals = options.useApprovals === true;
|
|
2084
|
-
const { clientId } = await saveClientCredentials({
|
|
2085
|
-
api: scopedApi,
|
|
2086
|
-
name: credentialName,
|
|
2383
|
+
await provisionAccountCredentials({
|
|
2384
|
+
sdk,
|
|
2385
|
+
entryPoint,
|
|
2386
|
+
accessToken,
|
|
2087
2387
|
credentialsBaseUrl,
|
|
2388
|
+
credentialName: providedName,
|
|
2389
|
+
interactive,
|
|
2088
2390
|
useApprovals,
|
|
2089
|
-
|
|
2391
|
+
isNonInteractive: false,
|
|
2392
|
+
isHeadless: headless
|
|
2090
2393
|
});
|
|
2091
|
-
process.stderr.write(
|
|
2092
|
-
`\u2705 Credentials "${credentialName}" created and set as default. You are ready to use the Zapier SDK.
|
|
2093
|
-
`
|
|
2094
|
-
);
|
|
2095
|
-
if (useApprovals) {
|
|
2096
|
-
process.stderr.write("\u{1F510} Approvals are enabled for these credentials.\n");
|
|
2097
|
-
}
|
|
2098
|
-
emitAccountAuthSuccess({ sdk, profile, clientId });
|
|
2099
2394
|
}
|
|
2100
2395
|
var LoginSchema = z.object({
|
|
2101
2396
|
name: z.string().optional().describe(
|
|
@@ -2115,8 +2410,20 @@ var LoginSchema = z.object({
|
|
|
2115
2410
|
}),
|
|
2116
2411
|
headless: z.boolean().optional().describe(
|
|
2117
2412
|
"Use when logging in from a machine that has no browser. Prints a login link to open elsewhere, then accepts the pasted loopback callback URL."
|
|
2413
|
+
),
|
|
2414
|
+
callbackUrl: z.string().optional().describe(
|
|
2415
|
+
"Resume a pending non-interactive login with the final OAuth callback URL from your browser."
|
|
2118
2416
|
)
|
|
2119
|
-
}).describe("Log in to Zapier to access your account")
|
|
2417
|
+
}).describe("Log in to Zapier to access your account").meta({
|
|
2418
|
+
cliTelemetry: {
|
|
2419
|
+
authFlow: {
|
|
2420
|
+
callbackUrlParam: "callbackUrl",
|
|
2421
|
+
headlessParam: "headless",
|
|
2422
|
+
nonInteractiveParam: "nonInteractive",
|
|
2423
|
+
skipPromptsParam: "skipPrompts"
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
});
|
|
2120
2427
|
|
|
2121
2428
|
// src/plugins/login/index.ts
|
|
2122
2429
|
var loginPlugin = definePlugin(
|
|
@@ -2145,8 +2452,20 @@ var SignupSchema = z.object({
|
|
|
2145
2452
|
}),
|
|
2146
2453
|
headless: z.boolean().optional().describe(
|
|
2147
2454
|
"Use when signing up from a machine that has no browser. Prints a signup link to open elsewhere, then accepts the pasted loopback callback URL."
|
|
2455
|
+
),
|
|
2456
|
+
callbackUrl: z.string().optional().describe(
|
|
2457
|
+
"Resume a pending non-interactive signup with the final OAuth callback URL from your browser."
|
|
2148
2458
|
)
|
|
2149
|
-
}).describe("Set up Zapier account access and SDK credentials")
|
|
2459
|
+
}).describe("Set up Zapier account access and SDK credentials").meta({
|
|
2460
|
+
cliTelemetry: {
|
|
2461
|
+
authFlow: {
|
|
2462
|
+
callbackUrlParam: "callbackUrl",
|
|
2463
|
+
headlessParam: "headless",
|
|
2464
|
+
nonInteractiveParam: "nonInteractive",
|
|
2465
|
+
skipPromptsParam: "skipPrompts"
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2468
|
+
});
|
|
2150
2469
|
|
|
2151
2470
|
// src/plugins/signup/index.ts
|
|
2152
2471
|
var signupPlugin = definePlugin(
|
|
@@ -4704,7 +5023,7 @@ function collectDeprecationNoticeAndForward(event, onEvent) {
|
|
|
4704
5023
|
// package.json with { type: 'json' }
|
|
4705
5024
|
var package_default = {
|
|
4706
5025
|
name: "@zapier/zapier-sdk-cli",
|
|
4707
|
-
version: "0.
|
|
5026
|
+
version: "0.63.0"};
|
|
4708
5027
|
|
|
4709
5028
|
// src/sdk.ts
|
|
4710
5029
|
injectCliLogin(login_exports);
|
|
@@ -4744,7 +5063,7 @@ function createZapierCliSdk(options = {}) {
|
|
|
4744
5063
|
|
|
4745
5064
|
// package.json
|
|
4746
5065
|
var package_default2 = {
|
|
4747
|
-
version: "0.
|
|
5066
|
+
version: "0.63.0"};
|
|
4748
5067
|
|
|
4749
5068
|
// src/telemetry/builders.ts
|
|
4750
5069
|
function createCliBaseEvent(context = {}) {
|
|
@@ -4799,7 +5118,9 @@ function buildCliCommandExecutedEvent({
|
|
|
4799
5118
|
files_created_count: data.files_created_count ?? null,
|
|
4800
5119
|
files_processed_size_bytes: data.files_processed_size_bytes ?? null,
|
|
4801
5120
|
cpu_time_ms: data.cpu_time_ms ?? null,
|
|
4802
|
-
subprocess_count: data.subprocess_count ?? null
|
|
5121
|
+
subprocess_count: data.subprocess_count ?? null,
|
|
5122
|
+
used_non_interactive_mode: data.used_non_interactive_mode ?? null,
|
|
5123
|
+
is_headless: data.is_headless ?? null
|
|
4803
5124
|
};
|
|
4804
5125
|
}
|
|
4805
5126
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zapier/zapier-sdk-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.0",
|
|
4
4
|
"description": "Command line interface for Zapier SDK",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"typescript": "^5.8.3",
|
|
96
96
|
"wrap-ansi": "^10.0.0",
|
|
97
97
|
"zod": "4.3.6",
|
|
98
|
-
"@zapier/zapier-sdk
|
|
99
|
-
"@zapier/zapier-sdk": "0.
|
|
98
|
+
"@zapier/zapier-sdk": "0.81.1",
|
|
99
|
+
"@zapier/zapier-sdk-mcp": "0.17.1"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@types/express": "^5.0.3",
|